[{"Question":"Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux.\nThe problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?","AnswerCount":13,"Available Count":2,"Score":0.0614608973,"is_accepted":false,"ViewCount":199251,"Q_Id":2933,"Users Score":4,"Answer":"I'm not sure that this is the best way to do it, but when I'm deploying Ruby GUI apps (not Python, but has the same \"problem\" as far as .exe's are concerned) on Windows, I just write a short launcher in C# that calls on my main script. It compiles to an executable, and I then have an application executable.","Q_Score":300,"Tags":"python,user-interface,deployment,tkinter,release-management","A_Id":12167,"CreationDate":"2008-08-05T22:26:00.000","Title":"Create a directly-executable cross-platform GUI app using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux.\nThe problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?","AnswerCount":13,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":199251,"Q_Id":2933,"Users Score":6,"Answer":"Since python is installed on nearly every non-Windows OS by default now, the only thing you really need to make sure of is that all of the non-standard libraries you use are installed.\nHaving said that, it is possible to build executables that include the python interpreter, and any libraries you use.  This is likely to create a large executable, however.\nMacOS X even includes support in the Xcode IDE for creating full standalone GUI apps.  These can be run by any user running OS X.","Q_Score":300,"Tags":"python,user-interface,deployment,tkinter,release-management","A_Id":2980,"CreationDate":"2008-08-05T22:26:00.000","Title":"Create a directly-executable cross-platform GUI app using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how as semantic service like Open Calais figures out the names of companies, or people, tech concepts, keywords, etc. from a piece of text. Is it because they have a large database that they match the text against? \nHow would a service like Zemanta know what images to suggest to a piece of text for instance?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2346,"Q_Id":22059,"Users Score":0,"Answer":"Open Calais probably use language parsing technology and language statics to guess which words or phrases are Names, Places, Companies, etc. Then, it is just another step to do some kind of search for those entities and return meta data.\nZementa probably does something similar, but matches the phrases against meta-data attached to images in order to acquire related results.\nIt certainly isn't easy.","Q_Score":5,"Tags":"python,ruby,semantics,zemanta","A_Id":23041,"CreationDate":"2008-08-22T10:51:00.000","Title":"How do content discovery engines, like Zemanta and Open Calais work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a small utility that I use to download an MP3 file from a website on a schedule and then builds\/updates a podcast XML file which I've added to iTunes.\nThe text processing that creates\/updates the XML file is written in Python. However, I use wget inside a Windows .bat file to download the actual MP3 file. I would prefer to have the entire utility written in Python.\nI struggled to find a way to actually download the file in Python, thus why I resorted to using wget.\nSo, how do I download the file using Python?","AnswerCount":27,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1341778,"Q_Id":22676,"Users Score":20,"Answer":"Following are the most commonly used calls for downloading files in python:\n\nurllib.urlretrieve ('url_to_file', file_name)\nurllib2.urlopen('url_to_file')\nrequests.get(url)\nwget.download('url', file_name)\n\nNote: urlopen and urlretrieve are found to perform relatively bad with downloading large files (size > 500 MB). requests.get stores the file in-memory until download is complete.","Q_Score":1032,"Tags":"python,http,urllib","A_Id":39573536,"CreationDate":"2008-08-22T15:34:00.000","Title":"How to download a file over HTTP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How would you go about finding out how much memory is being used by an object? I know it is possible to find out how much is used by a block of code, but not by an instantiated object (anytime during its life), which is what I want.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":222118,"Q_Id":33978,"Users Score":2,"Answer":"For big objects you may use a somewhat crude but effective method:\ncheck how much memory your Python process occupies in the system, then delete the object and compare.\nThis method has many drawbacks but it will give you a very fast estimate for very big objects.","Q_Score":267,"Tags":"python,performance,memory-profiling","A_Id":24495011,"CreationDate":"2008-08-29T04:59:00.000","Title":"Find out how much memory is being used by an object in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you please tell me how much is (-2) % 5?\nAccording to my Python interpreter is 3, but do you have a wise explanation for this?\nI've read that in some languages the result can be machine-dependent, but I'm not sure though.","AnswerCount":12,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":11706,"Q_Id":43775,"Users Score":16,"Answer":"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 <= r < b by definition.","Q_Score":18,"Tags":"python,math,modulo","A_Id":43794,"CreationDate":"2008-09-04T13:36:00.000","Title":"Modulus operation with negatives values - weird thing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you please tell me how much is (-2) % 5?\nAccording to my Python interpreter is 3, but do you have a wise explanation for this?\nI've read that in some languages the result can be machine-dependent, but I'm not sure though.","AnswerCount":12,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":11706,"Q_Id":43775,"Users Score":14,"Answer":"Your Python interpreter is correct.\nOne (stupid) way of calculating a modulus is to subtract or add the modulus until the resulting value is between 0 and (modulus \u2212 1).\ne.g.:\n13 mod 5 = (13 \u2212 5) mod 5 = (13 \u2212 10) mod 5 = 3\nor in your case: \u22122 mod 5 = (\u22122 + 5) mod 5 = 3","Q_Score":18,"Tags":"python,math,modulo","A_Id":43780,"CreationDate":"2008-09-04T13:36:00.000","Title":"Modulus operation with negatives values - weird thing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you please tell me how much is (-2) % 5?\nAccording to my Python interpreter is 3, but do you have a wise explanation for this?\nI've read that in some languages the result can be machine-dependent, but I'm not sure though.","AnswerCount":12,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":11706,"Q_Id":43775,"Users Score":0,"Answer":"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.","Q_Score":18,"Tags":"python,math,modulo","A_Id":43781,"CreationDate":"2008-09-04T13:36:00.000","Title":"Modulus operation with negatives values - weird thing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you please tell me how much is (-2) % 5?\nAccording to my Python interpreter is 3, but do you have a wise explanation for this?\nI've read that in some languages the result can be machine-dependent, but I'm not sure though.","AnswerCount":12,"Available Count":6,"Score":0.0665680765,"is_accepted":false,"ViewCount":11706,"Q_Id":43775,"Users Score":4,"Answer":"Well, 0 % 5 should be 0, right?\n-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).\nAnd following along by that logic, -2 must be 3.\nThe easiest way to think of how it will work is that you keep adding or subtracting 5 until the number falls between 0 (inclusive) and 5 (exclusive).\nI'm not sure about machine dependence - I've never seen an implementation that was, but I can't say it's never done.","Q_Score":18,"Tags":"python,math,modulo","A_Id":43785,"CreationDate":"2008-09-04T13:36:00.000","Title":"Modulus operation with negatives values - weird thing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you please tell me how much is (-2) % 5?\nAccording to my Python interpreter is 3, but do you have a wise explanation for this?\nI've read that in some languages the result can be machine-dependent, but I'm not sure though.","AnswerCount":12,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":11706,"Q_Id":43775,"Users Score":0,"Answer":"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#).","Q_Score":18,"Tags":"python,math,modulo","A_Id":43799,"CreationDate":"2008-09-04T13:36:00.000","Title":"Modulus operation with negatives values - weird thing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you please tell me how much is (-2) % 5?\nAccording to my Python interpreter is 3, but do you have a wise explanation for this?\nI've read that in some languages the result can be machine-dependent, but I'm not sure though.","AnswerCount":12,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":11706,"Q_Id":43775,"Users Score":0,"Answer":"There seems to be a common confusion between the terms \"modulo\" and \"remainder\".\nIn 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.\nHowever, modulo should always give a result 0 <= r < divisor, which is only consistent with round-to-minus-infinity division if you allow negative integers. If division rounds towards zero (which is common), modulo and remainder are only equivalent for non-negative values.\nSome languages (notably C and C++) don't define the required rounding\/remainder behaviours and % is ambiguous. Many define rounding as towards zero, yet use the term modulo where remainder would be more correct. Python is relatively unusual in that it rounds to negative infinity, so modulo and remainder are equivalent.\nAda rounds towards zero IIRC, but has both mod and rem operators.\nThe C policy is intended to allow compilers to choose the most efficient implementation for the machine, but IMO is a false optimisation, at least these days. A good compiler will probably be able to use the equivalence for optimisation wherever a negative number cannot occur (and almost certainly if you use unsigned types). On the other hand, where negative numbers can occur, you almost certainly care about the details - for portability reasons you have to use very carefully designed overcomplex algorithms and\/or checks to ensure that you get the results you want irrespective of the rounding and remainder behaviour.\nIn other words, the gain for this \"optimisation\" is mostly (if not always) an illusion, whereas there are very real costs in some cases - so it's a false optimisation.","Q_Score":18,"Tags":"python,math,modulo","A_Id":5203460,"CreationDate":"2008-09-04T13:36:00.000","Title":"Modulus operation with negatives values - weird thing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project.\nBuilding the boost libraries and bjam from source (v1.35.0), when I run bjam I get a .so in the bin\/gcc-4.1.2\/debug directory. I run python and \"import \" and I get:\nImportError: libboost_python-gcc41-d-1_35.so.1.35.0: cannot open shared object file: No such file or directory\nLooking in the library directory, I have the following:\nlibboost_python-gcc41-mt-1_35.so libboost_python-gcc41-mt-1_35.so.1.35.0 libboost_python-gcc41-mt.so\nObviously I need the -d instead of the -mt libraries, or to point at the -mt libraries instead of -d, but I can't figure out how to make my Jamroot file do that.\nWhen I install Debian Etch's versions of the libraries, I get \"No Jamfile in \/usr\/include\" - and there's a debian bug that says they left out the system-level jamfile.\nI'm more hopeful about getting it working from source, so if anyone has any suggestions to resolve the library issues, I'd like to hear them.\nResponse to answer 1: Thanks for the tip. So, do you know how I'd go about getting it to use the MT libraries instead? It appears to be more of a problem with bjam or the Jamfile I am using thinking I am in debug mode, even though I can't find any flags for that. While I know how to include specific libraries in a call to GCC, I don't see a way to configure that from the Boost end.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":3149,"Q_Id":67015,"Users Score":2,"Answer":"Found the solution! Boost builds a debug build by default. Typing \"bjam release\" builds the release configuration. (This isn't listed in any documentation anywhere, as far as I can tell.) Note that this is not the same as changing your build-type to release, as that doesn't build a release configuration. Doing a 'complete' build as Torsten suggests also does not stop it from building only a debug version.\nIt's also worth noting that the -d libraries were in <boost-version>\/bin.v2\/libs\/python\/build\/<gcc version>\/debug\/ and the release libraries were in <gcc-version>\/release, and not installed into the top-level 'libs' directory.\nThanks for the other suggestions!","Q_Score":3,"Tags":"c++,boost-python","A_Id":93027,"CreationDate":"2008-09-15T21:11:00.000","Title":"Using boost-python with C++ in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My development shop has put together a fairly useful Python-based test suite, and we'd like to test some Linux-based C++ code with it. We've gotten the test project they ship with Boost to compile (type 'bjam' in the directory and it works), but we're having issues with our actual project.\nBuilding the boost libraries and bjam from source (v1.35.0), when I run bjam I get a .so in the bin\/gcc-4.1.2\/debug directory. I run python and \"import \" and I get:\nImportError: libboost_python-gcc41-d-1_35.so.1.35.0: cannot open shared object file: No such file or directory\nLooking in the library directory, I have the following:\nlibboost_python-gcc41-mt-1_35.so libboost_python-gcc41-mt-1_35.so.1.35.0 libboost_python-gcc41-mt.so\nObviously I need the -d instead of the -mt libraries, or to point at the -mt libraries instead of -d, but I can't figure out how to make my Jamroot file do that.\nWhen I install Debian Etch's versions of the libraries, I get \"No Jamfile in \/usr\/include\" - and there's a debian bug that says they left out the system-level jamfile.\nI'm more hopeful about getting it working from source, so if anyone has any suggestions to resolve the library issues, I'd like to hear them.\nResponse to answer 1: Thanks for the tip. So, do you know how I'd go about getting it to use the MT libraries instead? It appears to be more of a problem with bjam or the Jamfile I am using thinking I am in debug mode, even though I can't find any flags for that. While I know how to include specific libraries in a call to GCC, I don't see a way to configure that from the Boost end.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":3149,"Q_Id":67015,"Users Score":2,"Answer":"If you want to build the debug variants of the boost libraries as well, you have to invoke bjam with the option --build-type=complete. \nOn Debian, you get the debug Python interpreter in the python2.x-dbg packages. Debug builds of the Boost libraries are in libboost1.xy-dbg, if you want to use the system Boost.","Q_Score":3,"Tags":"c++,boost-python","A_Id":67282,"CreationDate":"2008-09-15T21:11:00.000","Title":"Using boost-python with C++ in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?\nIf it's not, how would you do it with POST? Just out of curiosity.\nCheers!","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2893,"Q_Id":69979,"Users Score":0,"Answer":"With a bit of JavaScript, you could have the client hash the entered password and a server-generated nonce, and use that in an HTTP GET.","Q_Score":1,"Tags":"python,authentication,cgi","A_Id":70003,"CreationDate":"2008-09-16T07:07:00.000","Title":"Can I implement a web user authentication system in python without POST?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?\nIf it's not, how would you do it with POST? Just out of curiosity.\nCheers!","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2893,"Q_Id":69979,"Users Score":5,"Answer":"You can actually do it all with GET methods.  However, you'll want to use a full challenge response protocol for the logins.  (You can hash on the client side using javascript.  You just need to send out a unique challenge each time.)  You'll also want to use SSL to ensure that no one can see the strings as they go across.\nIn some senses there's no real security difference between GET and POST requests as they both go across in plaintext, in other senses and in practice... GET is are a hell of a lot easier to intercept and is all over most people's logs and your web browser's history. :)\n(Or as suggested by the other posters, use a different method entirely like HTTP auth, digest auth or some higher level authentication scheme like AD, LDAP, kerberos or shib.  However I kinda assumed that if you didn't have POST you wouldn't have these either.)","Q_Score":1,"Tags":"python,authentication,cgi","A_Id":69995,"CreationDate":"2008-09-16T07:07:00.000","Title":"Can I implement a web user authentication system in python without POST?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My university doesn't support the POST cgi method (I know, it's crazy), and I was hoping to be able to have a system where a user can have a username and password and log in securely. Is this even possible?\nIf it's not, how would you do it with POST? Just out of curiosity.\nCheers!","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":2893,"Q_Id":69979,"Users Score":1,"Answer":"You could use HTTP Authentication, if supported.\nYou'd have to add SSL, as all methods, POST, GET and HTTP Auth (well, except Digest HHTP authentication) send plaintext.\nGET is basically just like POST, it just has a limit on the amount of data you can send which is usually a lot smaller than POST and a semantic difference which makes GET not a good candidate from that point of view, even if technically they both can do it.\nAs for examples, what are you using? There are many choices in Python, like the cgi module or some framework like Django, CherryPy, and so on","Q_Score":1,"Tags":"python,authentication,cgi","A_Id":69989,"CreationDate":"2008-09-16T07:07:00.000","Title":"Can I implement a web user authentication system in python without POST?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I have a Python script that a) can accept user input and how do I make it b) read in arguments if run from the command line?","AnswerCount":12,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1321249,"Q_Id":70797,"Users Score":19,"Answer":"Careful not to use the input function, unless you know what you're doing. Unlike raw_input, input will accept any python expression, so it's kinda like eval","Q_Score":591,"Tags":"python,input,command-line-arguments","A_Id":70869,"CreationDate":"2008-09-16T09:44:00.000","Title":"How to prompt for user input and read command-line arguments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute. \nAdvanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use execute, so he won't see the correct docstring if he uses help(execute).\nTherefore it would be nice to modify the base class in such a way that in a subclass the docstring of execute is automatically replaced with that of _execute. Any ideas how this might be done?\nI was thinking of metaclasses to do this, to make this completely transparent to the user.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2897,"Q_Id":71817,"Users Score":1,"Answer":"Look at the functools.wraps() decorator; it does all of this, but I don't know offhand if you can get it to run in the right context","Q_Score":4,"Tags":"python,metaclass","A_Id":73473,"CreationDate":"2008-09-16T12:46:00.000","Title":"Using the docstring from one method to automatically overwrite that of another method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute. \nAdvanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use execute, so he won't see the correct docstring if he uses help(execute).\nTherefore it would be nice to modify the base class in such a way that in a subclass the docstring of execute is automatically replaced with that of _execute. Any ideas how this might be done?\nI was thinking of metaclasses to do this, to make this completely transparent to the user.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2897,"Q_Id":71817,"Users Score":0,"Answer":"Well the doc-string is stored in __doc__ so it wouldn't be too hard to re-assign it based on the doc-string of _execute after the fact.\nBasically:\n\n\nclass MyClass(object):\n    def execute(self):\n        '''original doc-string'''\n        self._execute()\n\nclass SubClass(MyClass):\n    def _execute(self):\n        '''sub-class doc-string'''\n        pass\n\n    # re-assign doc-string of execute\n    def execute(self,*args,**kw):\n        return MyClass.execute(*args,**kw)\n    execute.__doc__=_execute.__doc__\n\n\n\nExecute has to be re-declared to that the doc string gets attached to the version of execute for the SubClass and not for MyClass (which would otherwise interfere with other sub-classes).\nThat's not a very tidy way of doing it, but from the POV of the user of a library it should give the desired result.  You could then wrap this up in a meta-class to make it easier for people who are sub-classing.","Q_Score":4,"Tags":"python,metaclass","A_Id":72126,"CreationDate":"2008-09-16T12:46:00.000","Title":"Using the docstring from one method to automatically overwrite that of another method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. \nIf, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.\nRight now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate?\nAgain, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing.\nOne more thing: maybe some of you will ask \"Why settle on one language?\". To answer this: I would like to choose only one language, in order to try to master it.","AnswerCount":12,"Available Count":7,"Score":0.049958375,"is_accepted":false,"ViewCount":6338,"Q_Id":76408,"Users Score":3,"Answer":"That depends on the implementation, if it will be distributed I would go with Java, seeing as you know that, because of its portability.  If it is just for internal use, or will be used in semi-controlled environments, then go with whatever you are the most comfortable maintaining, and whichever has the best long-term outlook.\nNow to just answer the question, I would go with Perl, but I'm a linux guy so I may be a bit biased in this.","Q_Score":6,"Tags":"python,ruby,perl,security,penetration-testing","A_Id":76441,"CreationDate":"2008-09-16T20:11:00.000","Title":"Which of these scripting languages is more appropriate for pen-testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. \nIf, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.\nRight now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate?\nAgain, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing.\nOne more thing: maybe some of you will ask \"Why settle on one language?\". To answer this: I would like to choose only one language, in order to try to master it.","AnswerCount":12,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":6338,"Q_Id":76408,"Users Score":0,"Answer":"Well, what kind of exploits are you thinking about? If you want to write something that needs low level stuff (ptrace, raw sockets, etc.) then you'll need to learn C. But both Perl and Python can be used. The real question is which one suits your style more?\nAs for toolmaking, Perl has good string-processing abilities, is closer to the system, has good support, but IMHO it's very confusing. I prefer Python: it's a clean, easy to use, easy to learn language with good support (complete language\/lib reference, 3rd party libs, etc.). And it's (strictly IMHO) cool.","Q_Score":6,"Tags":"python,ruby,perl,security,penetration-testing","A_Id":76470,"CreationDate":"2008-09-16T20:11:00.000","Title":"Which of these scripting languages is more appropriate for pen-testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. \nIf, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.\nRight now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate?\nAgain, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing.\nOne more thing: maybe some of you will ask \"Why settle on one language?\". To answer this: I would like to choose only one language, in order to try to master it.","AnswerCount":12,"Available Count":7,"Score":0.0166651236,"is_accepted":false,"ViewCount":6338,"Q_Id":76408,"Users Score":1,"Answer":"All of them should be sufficient for that. Unless you need some library that is only available in one language, I'd let personal preference guide me.","Q_Score":6,"Tags":"python,ruby,perl,security,penetration-testing","A_Id":76495,"CreationDate":"2008-09-16T20:11:00.000","Title":"Which of these scripting languages is more appropriate for pen-testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. \nIf, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.\nRight now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate?\nAgain, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing.\nOne more thing: maybe some of you will ask \"Why settle on one language?\". To answer this: I would like to choose only one language, in order to try to master it.","AnswerCount":12,"Available Count":7,"Score":0.0166651236,"is_accepted":false,"ViewCount":6338,"Q_Id":76408,"Users Score":1,"Answer":"If you're looking for a scripting language that will play well with Java, you might want to look at Groovy.  It has the flexibility and power of Perl (closures, built in regexes, associative arrays on every corner) but you can access Java code from it thus you have access to a huge number of libraries, and in particular the rest of the system you're developing.","Q_Score":6,"Tags":"python,ruby,perl,security,penetration-testing","A_Id":76508,"CreationDate":"2008-09-16T20:11:00.000","Title":"Which of these scripting languages is more appropriate for pen-testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. \nIf, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.\nRight now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate?\nAgain, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing.\nOne more thing: maybe some of you will ask \"Why settle on one language?\". To answer this: I would like to choose only one language, in order to try to master it.","AnswerCount":12,"Available Count":7,"Score":0.049958375,"is_accepted":false,"ViewCount":6338,"Q_Id":76408,"Users Score":3,"Answer":"If you plan on using Metasploit for pen-testing and exploit development I would recommend ruby as mentioned previously Metasploit is written in ruby and any exploit\/module development you may wish to do will require ruby.\nIf you will be using Immunity CANVAS for pen testing then for the same reasons I would recommend Python as CANVAS is written in python. Also allot of fuzzing frameworks like Peach and Sulley are written in Python.\nI would not recommend Perl as you will find very little tools\/scripts\/frameworks related to pen testing\/fuzzing\/exploits\/... in Perl.\nAs your question is \"tool writing and exploit development\" I would recommend Ruby if you choose Metasploit or python if you choose CANVAS.\nhope that helps :)","Q_Score":6,"Tags":"python,ruby,perl,security,penetration-testing","A_Id":78106,"CreationDate":"2008-09-16T20:11:00.000","Title":"Which of these scripting languages is more appropriate for pen-testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. \nIf, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.\nRight now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate?\nAgain, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing.\nOne more thing: maybe some of you will ask \"Why settle on one language?\". To answer this: I would like to choose only one language, in order to try to master it.","AnswerCount":12,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":6338,"Q_Id":76408,"Users Score":0,"Answer":"I'm with tqbf.  I've worked with Python and Ruby.  Currently I'm working with JRuby.  It has all the power of Ruby with access to the Java libraries so if there is something you absolutely need a low-level language to solve you can do so with a high-level language.  So far I haven't needed to really use much Java as Ruby has had the ability to do everything I've needed as an API tester.","Q_Score":6,"Tags":"python,ruby,perl,security,penetration-testing","A_Id":4927367,"CreationDate":"2008-09-16T20:11:00.000","Title":"Which of these scripting languages is more appropriate for pen-testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all, I want to avoid a flame-war on languages. The languages to choose from are Perl, Python and Ruby . I want to mention that I'm comfortable with all of them, but the problem is that I can't focus just on one. \nIf, for example, I see a cool Perl module, I have to try it out. If I see a nice Python app, I have to know how it's made. If I see a Ruby DSL or some Ruby voodoo, I'm hooked on Ruby for a while.\nRight now I'm working as a Java developer, but plan on taking CEH in the near future. My question is: for tool writing and exploit development, which language do you find to be the most appropriate?\nAgain, I don't want to cause a flame-war or any trouble, I just want honest opinions from scripters that know what they're doing.\nOne more thing: maybe some of you will ask \"Why settle on one language?\". To answer this: I would like to choose only one language, in order to try to master it.","AnswerCount":12,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":6338,"Q_Id":76408,"Users Score":8,"Answer":"[Disclaimer: I am primarily a Perl programmer, which may be colouring my judgement. However, I am not a particularly tribal one, and I think on this particular question my argument is reasonably objective.]\nPerl was designed to blend seamlessly into the Unix landscape, and that is why it feels so alien to people with a mainly-OO background (particularly the Java school of OOP). For that reason, though, it\u2019s incredibly widely installed on machines with any kind of Unixoid OS, and many vendor system utilities are written in it. Also for the same reason, servers that have neither Python nor Ruby installed are still likely to have Perl on them, again making it important to have some familiarity with. So if your CEH activity includes extensive activity on Unix, you will have to have some amount of familiarity with Perl anyway, and you might as well focus on it.\nThat said, it is largely a matter of preference. There is not much to differentiate the languages; their expressive power is virtually identical. Some things are a little easier in one of the languages, some a little easier in another.\nIn terms of libraries I do not know how Ruby and Python compare against each other \u2013 I do know that Perl has them beat by a margin. Then again, sometimes (particularly when you\u2019re looking for libraries for common needs) the only effect of that is that you get deluged with choices. And if you are only looking to do things in some particular area which is well covered by libraries for Python or Ruby, the mass of other stuff on CPAN isn\u2019t necessarily an advantage. In niche areas, however, it matters, and you never know what unforeseen need you will eventually have (err, by definition).\nFor one-liner use on the command line, Python is kind of a non-starter.\nIn terms of interactive interpreter environment, Perl\u2026 uhm\u2026 well, you can use the debugger, which is not that great, or you can install one from CPAN, but Perl doesn\u2019t ship a good one itself.\nSo I think Perl does have a very slight edge for your needs in particular, but only just. If you pick Ruby you\u2019ll probably not be much worse off at all. Python might inconvenience you a little more noticeably, but it too is hardly a bad choice.","Q_Score":6,"Tags":"python,ruby,perl,security,penetration-testing","A_Id":77717,"CreationDate":"2008-09-16T20:11:00.000","Title":"Which of these scripting languages is more appropriate for pen-testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":7,"Answer":"I would assume that PHP (>5.5) is faster and more reliable for complex web applications because it is optimized for website scripting.\nMany of the benchmarks you will find at the net are only made to prove that the favoured language is better. But you can not compare 2 languages with a mathematical task running X-times. For a real benchmark you need two comparable frameworks with hundreds of classes\/files an a web application running 100 clients at once.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":33627050,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":1,"Answer":"If it ain't broke don't fix it.\nJust write a quick test, but bear in mind that each language will be faster with certain functions then the other.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":77093,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":1,"Answer":"You need to be able to make a business case for switching, not just that \"it's faster\".  If a site built on technology B costs 20% more in developer time for maintenance over a set period (say, 3 years), it would likely be cheaper to add another webserver to the system running technology A to bridge the performance gap.\nJust saying \"we should switch to technology B because technology B is faster!\" doesn't really work.\nSince Python is far less ubiquitous than PHP, I wouldn't be surprised if hosting, developer, and other maintenance costs for it (long term) would have it fit this scenario.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":77166,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":1.0,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":30,"Answer":"There's no point in attempting to convince your employer to port from PHP to Python, especially not for an existing system, which is what I think you implied in your question.\nThe reason for this is that you already have a (presumably) working system, with an existing investment of time and effort (and experience). To discard this in favour of a trivial performance gain (not that I'm claiming there would be one) would be foolish, and no manager worth his salt ought to endorse it.\nIt may also create a problem with maintainability, depending on who else has to work with the system, and their experience with Python.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":77297,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":0,"Answer":"The only right answer is \"It depends\". There's a lot of variables that can affect the performance, and you can optimize many things in either situation.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":77112,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":0.0399786803,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":2,"Answer":"PHP and Python are similiar enough to not warrent any kind of switching.\nAny performance improvement you might get from switching from one language to another would be vastly outgunned by simply not spending the money on converting the code (you don't code for free right?) and just buy more hardware.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":77220,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":0.0199973338,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":1,"Answer":"an IS organization would not ponder this unless availability was becoming an issue.\nif so the case, look into replication, load balancing and lots of ram.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":510276,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":-0.0199973338,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":-1,"Answer":"I had to come back to web development at my new job, and, if not Pylons\/Python, maybe I would have chosen to live in jungle instead :) In my subjective opinion, PHP is for kindergarten, I did it in my 3rd year of uni and, I believe, many self-respecting (or over-estimating) software engineers will not want to be bothered with PHP code. \nWhy my employers agreed? We (the team) just switched to Python, and they did not have much to say. The website still is and will be PHP, but we are developing other applications, including web, in Python. Advantages of Pylons? You can integrate your python libraries into the web app, and that is, imho, a huge advantage.\nAs for performance, we are still having troubles.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":2412215,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is faster, python webpages or php webpages?\nDoes anyone know how the speed of pylons(or any of the other frameworks) compares to a  similar website made with php?  \nI know that serving a python base webpage via cgi is slower than php because of its long start up every time.\nI enjoy using pylons and I would still use it if it was slower than php. But if pylons was faster than php, I could maybe, hopefully, eventually convince my employer to allow me to convert the site over to pylons.","AnswerCount":10,"Available Count":9,"Score":0.0399786803,"is_accepted":false,"ViewCount":58657,"Q_Id":77086,"Users Score":2,"Answer":"It's about the same. The difference shouldn't be large enough to be the reason to pick one or the other. Don't try to compare them by writing your own tiny benchmarks (\"hello world\") because you will probably not have results that are representative of a real web site generating a more complex page.","Q_Score":41,"Tags":"php,python,performance,pylons","A_Id":77174,"CreationDate":"2008-09-16T21:05:00.000","Title":"Which is faster, python webpages or php webpages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to search for a given MAC address on my network, all from within a Python script.  I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address.  Any ideas?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":16340,"Q_Id":85577,"Users Score":1,"Answer":"I don't think there is a built in way to get it from Python itself.  \nMy question is, how are you getting the IP information from your network?\nTo get it from your local machine you could parse ifconfig (unix) or ipconfig (windows) with little difficulty.","Q_Score":9,"Tags":"python,network-programming","A_Id":85608,"CreationDate":"2008-09-17T17:23:00.000","Title":"Search for host with MAC-address using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to search for a given MAC address on my network, all from within a Python script.  I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address.  Any ideas?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":16340,"Q_Id":85577,"Users Score":0,"Answer":"You would want to parse the output of 'arp', but the kernel ARP cache will only contain those IP address(es) if those hosts have communicated with the host where the Python script is running.\nifconfig can be used to display the MAC addresses of local interfaces, but not those on the LAN.","Q_Score":9,"Tags":"python,network-programming","A_Id":85641,"CreationDate":"2008-09-17T17:23:00.000","Title":"Search for host with MAC-address using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to search for a given MAC address on my network, all from within a Python script.  I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address.  Any ideas?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":16340,"Q_Id":85577,"Users Score":1,"Answer":"It seems that there is not a native way of doing this with Python.  Your best bet would be to parse the output of \"ipconfig \/all\" on Windows, or \"ifconfig\" on Linux.  Consider using os.popen() with some regexps.","Q_Score":9,"Tags":"python,network-programming","A_Id":85634,"CreationDate":"2008-09-17T17:23:00.000","Title":"Search for host with MAC-address using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to search for a given MAC address on my network, all from within a Python script.  I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address.  Any ideas?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":16340,"Q_Id":85577,"Users Score":0,"Answer":"Depends on your platform. If you're using *nix, you can use the 'arp' command to look up the mac address for a given IP (assuming IPv4) address. If that doesn't work, you could ping the address and then look, or if you have access to the raw network (using BPF or some other mechanism), you could send your own ARP packets (but that is probably overkill).","Q_Score":9,"Tags":"python,network-programming","A_Id":85620,"CreationDate":"2008-09-17T17:23:00.000","Title":"Search for host with MAC-address using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others.\nCurrently there are two paths being discussed:\n\nPort the existing application to Classic ASP using JScript, which will allow us to hopefully go from there to .NET MSJscript without too much trouble, and eventually end up on the .NET platform (preferably the MVC stuff will be done by then, ASP.NET isn't much better than were we are on now, in our opinions). This has been argued as the safer path with less risk than the next option, albeit it might take slightly longer.\nCompletely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't\/don't get it right.\n\nThis does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background.\nNow, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","AnswerCount":9,"Available Count":7,"Score":0.022218565,"is_accepted":false,"ViewCount":406,"Q_Id":87522,"Users Score":1,"Answer":"Half a year ago I took over a large web application (fortunately already in Python) which had some major architectural deficiencies (templates and code mixed, code duplication, you name it...).\nMy plan is to eventually have the system respond to WSGI, but I am not there yet. I found the best way to do it, is in small steps. Over the last 6 month, code reuse has gone up and progress has accelerated. \nGeneral principles which have worked for me:\n\nThrow away code which is not used or commented out\nThrow away all comments which are not useful\nDefine a layer hierarchy (models, business logic, view\/controller logic, display logic, etc.) of your application. This has not to be very clear cut architecture but rather should help you think about the various parts of your application and help you better categorize your code.\nIf something grossly violates this hierarchy, change the offending code. Move the code around, recode it at another place, etc. At the same time adjust the rest of your application to use this code instead of the old one. Throw the old one away if not used anymore.\nKeep you APIs simple!\n\nProgress can be painstakingly slow, but should be worth it.","Q_Score":3,"Tags":"python,asp-classic,vbscript","A_Id":101074,"CreationDate":"2008-09-17T20:48:00.000","Title":"If it is decided that our system needs an overhaul, what is the best way to go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others.\nCurrently there are two paths being discussed:\n\nPort the existing application to Classic ASP using JScript, which will allow us to hopefully go from there to .NET MSJscript without too much trouble, and eventually end up on the .NET platform (preferably the MVC stuff will be done by then, ASP.NET isn't much better than were we are on now, in our opinions). This has been argued as the safer path with less risk than the next option, albeit it might take slightly longer.\nCompletely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't\/don't get it right.\n\nThis does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background.\nNow, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":87522,"Users Score":0,"Answer":"Don't try and go 2.0 ( more features then currently exists or scheduled) instead build your new platform with the intent of resolving the current issues with the code base (maintainability\/speed\/wtf) and go from there.","Q_Score":3,"Tags":"python,asp-classic,vbscript","A_Id":89452,"CreationDate":"2008-09-17T20:48:00.000","Title":"If it is decided that our system needs an overhaul, what is the best way to go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others.\nCurrently there are two paths being discussed:\n\nPort the existing application to Classic ASP using JScript, which will allow us to hopefully go from there to .NET MSJscript without too much trouble, and eventually end up on the .NET platform (preferably the MVC stuff will be done by then, ASP.NET isn't much better than were we are on now, in our opinions). This has been argued as the safer path with less risk than the next option, albeit it might take slightly longer.\nCompletely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't\/don't get it right.\n\nThis does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background.\nNow, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","AnswerCount":9,"Available Count":7,"Score":0.0444152037,"is_accepted":false,"ViewCount":406,"Q_Id":87522,"Users Score":2,"Answer":"Whatever you do, see if you can manage to follow a plan where you do not have to port the application all in one big bang. It is tempting to throw it all away and start from scratch, but if you can manage to do it gradually the mistakes you do will not cost so much and cause so much panic.","Q_Score":3,"Tags":"python,asp-classic,vbscript","A_Id":87684,"CreationDate":"2008-09-17T20:48:00.000","Title":"If it is decided that our system needs an overhaul, what is the best way to go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others.\nCurrently there are two paths being discussed:\n\nPort the existing application to Classic ASP using JScript, which will allow us to hopefully go from there to .NET MSJscript without too much trouble, and eventually end up on the .NET platform (preferably the MVC stuff will be done by then, ASP.NET isn't much better than were we are on now, in our opinions). This has been argued as the safer path with less risk than the next option, albeit it might take slightly longer.\nCompletely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't\/don't get it right.\n\nThis does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background.\nNow, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":87522,"Users Score":0,"Answer":"I agree with Michael Pryor and Joel that it's almost always a better idea to continue evolving your existing code base rather than re-writing from scratch. There are typically opportunities to just re-write or re-factor certain components for performance or flexibility.","Q_Score":3,"Tags":"python,asp-classic,vbscript","A_Id":994326,"CreationDate":"2008-09-17T20:48:00.000","Title":"If it is decided that our system needs an overhaul, what is the best way to go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others.\nCurrently there are two paths being discussed:\n\nPort the existing application to Classic ASP using JScript, which will allow us to hopefully go from there to .NET MSJscript without too much trouble, and eventually end up on the .NET platform (preferably the MVC stuff will be done by then, ASP.NET isn't much better than were we are on now, in our opinions). This has been argued as the safer path with less risk than the next option, albeit it might take slightly longer.\nCompletely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't\/don't get it right.\n\nThis does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background.\nNow, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","AnswerCount":9,"Available Count":7,"Score":0.0665680765,"is_accepted":false,"ViewCount":406,"Q_Id":87522,"Users Score":3,"Answer":"Use this as an opportunity to remove unused features!  Definitely go with the new language.  Call it 2.0.  It will be a lot less work to rebuild the 80% of it that you really need.\nStart by wiping your brain clean of the whole application.  Sit down with a list of its overall goals, then decide which features are needed based on which ones are used.  Then redesign it with those features in mind, and build.\n(I love to delete code.)","Q_Score":3,"Tags":"python,asp-classic,vbscript","A_Id":87562,"CreationDate":"2008-09-17T20:48:00.000","Title":"If it is decided that our system needs an overhaul, what is the best way to go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others.\nCurrently there are two paths being discussed:\n\nPort the existing application to Classic ASP using JScript, which will allow us to hopefully go from there to .NET MSJscript without too much trouble, and eventually end up on the .NET platform (preferably the MVC stuff will be done by then, ASP.NET isn't much better than were we are on now, in our opinions). This has been argued as the safer path with less risk than the next option, albeit it might take slightly longer.\nCompletely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't\/don't get it right.\n\nThis does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background.\nNow, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","AnswerCount":9,"Available Count":7,"Score":0.0665680765,"is_accepted":false,"ViewCount":406,"Q_Id":87522,"Users Score":3,"Answer":"It works out better than you'd believe. \nRecently I did a large reverse-engineering job on a hideous old collection of C code.  Function by function I reallocated the features that were still relevant into classes, wrote unit tests for the classes, and built up what looked like a replacement application.  It had some of the original \"logic flow\" through the classes, and some classes were poorly designed [Mostly this was because of a subset of the global variables that was too hard to tease apart.]\nIt passed unit tests at the class level and at the overall application level.  The legacy source was mostly used as a kind of \"specification in C\" to ferret out the really obscure business rules.\nLast year, I wrote a project plan for replacing 30-year old COBOL.  The customer was leaning toward Java.  I prototyped the revised data model in Python using Django as part of the planning effort.  I could demo the core transactions before I was done planning.\nNote:  It was quicker to build a the model and admin interface in Django than to plan the project as a whole.\nBecause of the \"we need to use Java\" mentality, the resulting project will be larger and more expensive than finishing the Django demo.  With no real value to balance that cost.\nAlso, I did the same basic \"prototype in Django\" for a VB desktop application that needed to become a web application.  I built the model in Django, loaded legacy data, and was up and running in a few weeks.  I used that working prototype to specify the rest of the conversion effort.\nNote:  I had a working Django implementation (model and admin pages only) that I used to plan the rest of the effort.\nThe best part about doing this kind of prototyping in Django is that you can mess around with the model, unit tests and admin pages until you get it right.    Once the model's right, you can spend the rest of your time fiddling around with the user interface until everyone's happy.","Q_Score":3,"Tags":"python,asp-classic,vbscript","A_Id":87998,"CreationDate":"2008-09-17T20:48:00.000","Title":"If it is decided that our system needs an overhaul, what is the best way to go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others.\nCurrently there are two paths being discussed:\n\nPort the existing application to Classic ASP using JScript, which will allow us to hopefully go from there to .NET MSJscript without too much trouble, and eventually end up on the .NET platform (preferably the MVC stuff will be done by then, ASP.NET isn't much better than were we are on now, in our opinions). This has been argued as the safer path with less risk than the next option, albeit it might take slightly longer.\nCompletely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't\/don't get it right.\n\nThis does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background.\nNow, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","AnswerCount":9,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":87522,"Users Score":0,"Answer":"I would not recommend JScript as that is definitely the road less traveled.\nASP.NET MVC is rapidly maturing, and I think that you could begin a migration to it, simultaneously ramping up on the ASP.NET MVC framework as its finalization comes through.\nAnother option would be to use something like ASP.NET w\/Subsonic or NHibernate.","Q_Score":3,"Tags":"python,asp-classic,vbscript","A_Id":87573,"CreationDate":"2008-09-17T20:48:00.000","Title":"If it is decided that our system needs an overhaul, what is the best way to go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I know how to do this if I iterate through all of the characters in the string but I am looking for a more elegant method.","AnswerCount":11,"Available Count":1,"Score":-0.0181798149,"is_accepted":false,"ViewCount":148492,"Q_Id":89909,"Users Score":-1,"Answer":"You could always use a list comprehension and check the results with all, it would be a little less resource intensive than using a regex: all([c in string.letters + string.digits + [\"_\", \"-\"] for c in mystring])","Q_Score":95,"Tags":"python,regex,string","A_Id":89940,"CreationDate":"2008-09-18T04:04:00.000","Title":"How do I verify that a string only contains letters, numbers, underscores and dashes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.","AnswerCount":10,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":4581,"Q_Id":92230,"Users Score":2,"Answer":"The Python Cookbook is absolutely essential if you want to master idiomatic Python. Besides, that's the book that made me fall in love with the language.","Q_Score":14,"Tags":"python","A_Id":92691,"CreationDate":"2008-09-18T12:51:00.000","Title":"Python, beyond the basics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.","AnswerCount":10,"Available Count":3,"Score":0.0199973338,"is_accepted":false,"ViewCount":4581,"Q_Id":92230,"Users Score":1,"Answer":"Search \"Alex Martelli\", \"Alex Martelli patterns\" and \"Thomas Wouters\" on Google video. There's plenty of interesting talks on advanced Python, design patterns in Python, and so on.","Q_Score":14,"Tags":"python","A_Id":181078,"CreationDate":"2008-09-18T12:51:00.000","Title":"Python, beyond the basics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.","AnswerCount":10,"Available Count":3,"Score":0.0199973338,"is_accepted":false,"ViewCount":4581,"Q_Id":92230,"Users Score":1,"Answer":"I'd suggest writing a non-trivial webapp using either Django or Pylons, something that does some number crunching.\nNo better way to learn a new language than commiting yourself to a problem and learning as you go!","Q_Score":14,"Tags":"python","A_Id":92254,"CreationDate":"2008-09-18T12:51:00.000","Title":"Python, beyond the basics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to write a module to detect similar documents. I have read many papers of fingerprints of documents techniques and others, but I do not know how to write code or implement such a solution. The algorithm should work for Chinese, Japanese, English and German language or be language independent. How can I accomplish this?","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":13411,"Q_Id":101569,"Users Score":0,"Answer":"I think Jeremy has hit the nail on the head - if you just want to detect if files are different, a hash algorithm like MD5 or SHA1 is a good way to go.\nLinus Torvalds' Git source control software uses SHA1 hashing in just this way - to check when files have been modified.","Q_Score":10,"Tags":"python,algorithm,diff","A_Id":108649,"CreationDate":"2008-09-19T12:47:00.000","Title":"Algorithm to detect similar documents in python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I need to write a module to detect similar documents. I have read many papers of fingerprints of documents techniques and others, but I do not know how to write code or implement such a solution. The algorithm should work for Chinese, Japanese, English and German language or be language independent. How can I accomplish this?","AnswerCount":10,"Available Count":2,"Score":0.0599281035,"is_accepted":false,"ViewCount":13411,"Q_Id":101569,"Users Score":3,"Answer":"You need to make your question more concrete.  If you've already read the fingerprinting papers, you already know the principles at work, so describing common approaches here would not be beneficial.  If you haven't, you should also check out papers on \"duplicate detection\" and various web spam detection related papers that have come out of Stanford, Google, Yahoo, and MS in recent years.\nAre you having specific problems with coding the described algorithms?\nTrouble getting started?\nThe first thing I'd probably do is separate the tokenization (the process of extracting \"words\" or other sensible sequences) from the duplicate detection logic, so that it is easy to plug in different parsers for different languages and keep the duplicate detection piece the same.","Q_Score":10,"Tags":"python,algorithm,diff","A_Id":101623,"CreationDate":"2008-09-19T12:47:00.000","Title":"Algorithm to detect similar documents in python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"In Python specifically, how do variables get shared between threads?\nAlthough I have used threading.Thread before I never really understood or saw examples of how variables got shared.  Are they shared between the main thread and the children or only among the children? When would I need to use thread local storage to avoid this sharing?\nI have seen many warnings about synchronizing access to shared data among threads by using locks but I have yet to see a really good example of the problem. \nThanks in advance!","AnswerCount":6,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":68654,"Q_Id":104983,"Users Score":3,"Answer":"Just like in every other language, every thread in Python has access to the same variables. There's no distinction between the 'main thread' and child threads.\nOne difference with Python is that the Global Interpreter Lock means that only one thread can be running Python code at a time. This isn't much help when it comes to synchronising access, however, as all the usual pre-emption issues still apply, and you have to use threading primitives just like in other languages. It does mean you need to reconsider if you were using threads for performance, however.","Q_Score":123,"Tags":"python,multithreading,thread-local","A_Id":105058,"CreationDate":"2008-09-19T19:53:00.000","Title":"What is \"thread local storage\" in Python, and why do I need it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python specifically, how do variables get shared between threads?\nAlthough I have used threading.Thread before I never really understood or saw examples of how variables got shared.  Are they shared between the main thread and the children or only among the children? When would I need to use thread local storage to avoid this sharing?\nI have seen many warnings about synchronizing access to shared data among threads by using locks but I have yet to see a really good example of the problem. \nThanks in advance!","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":68654,"Q_Id":104983,"Users Score":1,"Answer":"Worth mentioning threading.local() is not a singleton.\nYou can use more of them per thread.\nIt is not one storage.","Q_Score":123,"Tags":"python,multithreading,thread-local","A_Id":70450414,"CreationDate":"2008-09-19T19:53:00.000","Title":"What is \"thread local storage\" in Python, and why do I need it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python specifically, how do variables get shared between threads?\nAlthough I have used threading.Thread before I never really understood or saw examples of how variables got shared.  Are they shared between the main thread and the children or only among the children? When would I need to use thread local storage to avoid this sharing?\nI have seen many warnings about synchronizing access to shared data among threads by using locks but I have yet to see a really good example of the problem. \nThanks in advance!","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":68654,"Q_Id":104983,"Users Score":1,"Answer":"I may be wrong here. If you know otherwise please expound as this would help explain why one would need to use thread local().\nThis statement seems off, not wrong: \"If you want to atomically modify anything that another thread has access to, you have to protect it with a lock.\" I think this statement is ->effectively<- right but not entirely accurate. I thought the term \"atomic\" meant that the Python interpreter created a byte-code chunk that left no room for an interrupt signal to the CPU.\nI thought atomic operations are chunks of Python byte code that does not give access to interrupts. Python statements like \"running = True\" is atomic. You do not need to lock CPU from interrupts in this case (I believe). The Python byte code breakdown is safe from thread interruption.\nPython code like \"threads_running[5] = True\" is not atomic. There are two chunks of Python byte code here; one to de-reference the list() for an object and another byte code chunk to assign a value to an object, in this case a \"place\" in a list. An interrupt can be raised -->between<- the two byte-code ->chunks<-. That is were bad stuff happens.\nHow does thread local() relate to \"atomic\"? This is why the statement seems misdirecting to me. If not can you explain?","Q_Score":123,"Tags":"python,multithreading,thread-local","A_Id":60241832,"CreationDate":"2008-09-19T19:53:00.000","Title":"What is \"thread local storage\" in Python, and why do I need it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Almost every Python web framework has a simple server that runs a wsgi application and automatically reloads the imported modules every time the source gets changed. I know I can look at the code and see how it's done, but that may take some time and I'm asking just out of curiosity. Does anyone have any idea how this is implemented?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":304,"Q_Id":126787,"Users Score":2,"Answer":"As the author of one of the reloader mechanisms (the one in werkzeug) I can tell you that it doesn't work.  What all the reloaders do is forking one time and restarting the child process if a monitor thread notices that one module changed on the file system.\nInline reload()ing doesn't work because references to the reloaded module are not updated.","Q_Score":2,"Tags":"python","A_Id":126843,"CreationDate":"2008-09-24T12:21:00.000","Title":"Checking for code changes in all imported python modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I write tons of python scripts, and I find myself reusing lots code that I've written for other projects. My solution has been to make sure the code is separated into logical modules\/packages (this one's a given). I then make them setuptools-aware and publish them on PyPI. This allows my other scripts to always have the most up-to-date code, I get a warm fuzzy feeling because I'm not repeating myself, and my development, in general, is made less complicated. I also feel good that there MAY be someone out there that finds my code handy for something they're working on, but it's mainly for selfish reasons :)\nTo all the pythonistas, how do you handle this? Do you use PyPI or setuptools (easy_install)? or something else?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":344,"Q_Id":136207,"Users Score":0,"Answer":"I store it all offline in a logical directory structure, with commonly used modules grouped as utilities.  This means it's easier to control which versions I publish, and manage.  I also automate the build process to interpret the logical directory structure.","Q_Score":9,"Tags":"python,code-reuse","A_Id":48569865,"CreationDate":"2008-09-25T21:18:00.000","Title":"How do you manage your custom modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I write tons of python scripts, and I find myself reusing lots code that I've written for other projects. My solution has been to make sure the code is separated into logical modules\/packages (this one's a given). I then make them setuptools-aware and publish them on PyPI. This allows my other scripts to always have the most up-to-date code, I get a warm fuzzy feeling because I'm not repeating myself, and my development, in general, is made less complicated. I also feel good that there MAY be someone out there that finds my code handy for something they're working on, but it's mainly for selfish reasons :)\nTo all the pythonistas, how do you handle this? Do you use PyPI or setuptools (easy_install)? or something else?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":344,"Q_Id":136207,"Users Score":1,"Answer":"What kind of modules are we talking about here?  If you're planning on distributing your projects to other python developers, setuptools is great.  But it's usually not a very good way to distribute apps to end users.  Your best bet in the latter case is to tailor your packaging to the platforms you're distributing it for.  Sure, it's a pain, but it makes life for end users far easier.\nFor example, in my Debian system, I usually don't use easy_install because it is a little bit more difficult to get eggs to work well with the package manager.  In OS X and windows, you'd probably want to package everything up using py2app and py2exe respectively.  This makes life for the end user better.  After all, they shouldn't know or care what language your scripts are written in.  They just need them to install.","Q_Score":9,"Tags":"python,code-reuse","A_Id":137291,"CreationDate":"2008-09-25T21:18:00.000","Title":"How do you manage your custom modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Dear Stacktoverflow, can you show me an example of how to use a QScrollBar? Thanks.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3106,"Q_Id":139005,"Users Score":1,"Answer":"It will come down to you using the QScrollArea, it is a widget that implements showing something that is larger than the available space. You will not need to use QScrollBar directly. I don't have a PyQt example but there is a C++ example in the QT distribution it is called the \"Image Viewer\". The object hierarchy will still be the same","Q_Score":0,"Tags":"python,pyqt","A_Id":139056,"CreationDate":"2008-09-26T12:05:00.000","Title":"PyQt - QScrollBar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it?\nThe variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is updated in others. I'd be fine if I could set foo before importing other modules and then they would see the same value for it.","AnswerCount":12,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":177508,"Q_Id":142545,"Users Score":28,"Answer":"I believe that there are plenty of circumstances in which it does make sense and it simplifies programming to have some globals that are known across several (tightly coupled) modules.  In this spirit, I would like to elaborate a bit on the idea of having a module of globals which is imported by those modules which need to reference them.\nWhen there is only one such module, I name it \"g\".  In it, I assign default values for every variable I intend to treat as global.  In each module that uses any of them, I do not use \"from g import var\", as this only results in a local variable which is initialized from g only at the time of the import.  I make most references in the form g.var, and the \"g.\" serves as a constant reminder that I am dealing with a variable that is potentially accessible to other modules.  \nIf the value of such a global variable is to be used frequently in some function in a module, then that function can make a local copy: var = g.var.  However, it is important to realize that assignments to var are local, and global g.var cannot be updated without referencing g.var explicitly in an assignment.\nNote that you can also have multiple such globals modules shared by different subsets of your modules to keep things a little more tightly controlled.  The reason I use short names for my globals modules is to avoid cluttering up the code too much with occurrences of them.  With only a little experience, they become mnemonic enough with only 1 or 2 characters.  \nIt is still possible to make an assignment to, say, g.x when x was not already defined in g, and a different module can then access g.x.  However, even though the interpreter permits it, this approach is not so transparent, and I do avoid it.  There is still the possibility of accidentally creating a new variable in g as a result of a typo in the variable name for an assignment.  Sometimes an examination of dir(g) is useful to discover any surprise names that may have arisen by such accident.","Q_Score":127,"Tags":"python,module,global","A_Id":15035172,"CreationDate":"2008-09-26T23:59:00.000","Title":"How to make a cross-module variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it?\nThe variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is updated in others. I'd be fine if I could set foo before importing other modules and then they would see the same value for it.","AnswerCount":12,"Available Count":2,"Score":0.0831409664,"is_accepted":false,"ViewCount":177508,"Q_Id":142545,"Users Score":5,"Answer":"You can already do this with module-level variables.  Modules are the same no matter what module they're being imported from.  So you can make the variable a module-level variable in whatever module it makes sense to put it in, and access it or assign to it from other modules.  It would be better to call a function to set the variable's value, or to make it a property of some singleton object.  That way if you end up needing to run some code when the variable's changed, you can do so without breaking your module's external interface.\nIt's not usually a great way to do things \u2014 using globals seldom is \u2014 but I think this is the cleanest way to do it.","Q_Score":127,"Tags":"python,module,global","A_Id":3911089,"CreationDate":"2008-09-26T23:59:00.000","Title":"How to make a cross-module variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to develop a small-medium sized desktop GUI application, preferably with Python as a language of choice because of time constraints.\nWhat GUI library choices do I have which allow me to redistribute my application standalone, assuming that the users don't have a working Python installation and obviously don't have the GUI libraries I'm using either?\nAlso, how would I go about packaging everything up in binaries of reasonable size for each target OS? (my main targets are Windows and Mac OS X)\nAddition:\nI've been looking at WxPython, but I've found plenty of horror stories of packaging it with cx_freeze and getting 30mb+ binaries, and no real advice on how to actually do the packaging and how trust-worthy it is.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5407,"Q_Id":153956,"Users Score":0,"Answer":"I've used py2Exe myself - it's really easy (at least for small apps).","Q_Score":11,"Tags":"python,user-interface,wxpython,distribution,freeze","A_Id":153999,"CreationDate":"2008-09-30T16:50:00.000","Title":"Python GUI Application redistribution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to write a reliable, totally-ordered multicast system from scratch in Python. I can't use any external libraries.  I'm allowed to use a central sequencer.\nThere seems to be two immediate approaches:\n\nwrite an efficient system, attaching a unique id to each multicasted message,\nhaving the sequencer multicast sequence numbers for the message id's it receives,\nand sending back and forth ACK's and NACK's.\nwrite an inefficient flooding system, where each multicaster simply re-sends each\nmessage it receives once (unless it was sent by that particular multicaster.)\n\nI'm allowed to use the second option, and am inclined to do so.\nI'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2.  Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that?  And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3074,"Q_Id":176179,"Users Score":1,"Answer":"The approach you take is going to depend very much on the nature of the data that you're sending, the scale of your network and the quantity of data you're sending. In particular it is going to depend on the number of targets each of your nodes is connected to.\nIf you're expecting this to scale to a large number of targets for each node and a large quantity of data then you may well find that the overhead of adding an ACK\/NAK to every packet is sufficient to adversely limit your throughput, particularly when you add retransmissions into the mix.\nAs Frank Szczerba has said multimedia data has the benefit of being able to recover from lost packets. If you have any control over the data that you're sending you should try to design the payloads so that you minimise the susceptibility to dropped packets.\nIf the data that you're sending cannot tolerate dropped packets and you're trying to scale to high utilisation of your network then perhaps udp is not the best protocol to use. Implementing a series of tcp proxies (where each node retransmits, unicast, to all other connected nodes - similar to your flooding idea) would be a more reliable mechanism.\nWith all of that said, have you considered using true multicast for this application?\n\nJust saw the \"homework\" tag... these suggestions might not be appropriate for a homework problem.","Q_Score":5,"Tags":"python,sockets,networking,ip,multicast","A_Id":176501,"CreationDate":"2008-10-06T21:03:00.000","Title":"Writing a reliable, totally-ordered multicast system in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to write a reliable, totally-ordered multicast system from scratch in Python. I can't use any external libraries.  I'm allowed to use a central sequencer.\nThere seems to be two immediate approaches:\n\nwrite an efficient system, attaching a unique id to each multicasted message,\nhaving the sequencer multicast sequence numbers for the message id's it receives,\nand sending back and forth ACK's and NACK's.\nwrite an inefficient flooding system, where each multicaster simply re-sends each\nmessage it receives once (unless it was sent by that particular multicaster.)\n\nI'm allowed to use the second option, and am inclined to do so.\nI'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2.  Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that?  And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3074,"Q_Id":176179,"Users Score":4,"Answer":"The flooding approach can cause a bad situation to get worse. If messages are dropped due to high network load, having every node resend every message will only make the situation worse.\nThe best approach to take depends on the nature of the data you are sending. For example:\n\nMultimedia data: no retries, a dropped packet is a dropped frame, which won't matter when the next frame gets there anyway.\nFixed period data: Recipient node keeps a timer that is reset each time an update is received. If the time expires, it requests the missing update from the master node. Retries can be unicast to the requesting node.\n\nIf neither of these situations applies (every packet has to be received by every node, and the packet timing is unpredictable, so recipients can't detect missed packets on their own), then your options include:\n\nExplicit ACK from every node for each packet. Sender retries (unicast) any packet that is not ACKed.\nTCP-based grid approach, where each node is manually repeats received packets to neighbor nodes, relying on TCP mechanisms to ensure delivery.\n\nYou could possibly rely on recipients noticing a missed packet upon reception of one with a later sequence number, but this requires the sender to keep the packet around until at least one additional packet has been sent. Requiring positive ACKs is more reliable (and provable).","Q_Score":5,"Tags":"python,sockets,networking,ip,multicast","A_Id":176287,"CreationDate":"2008-10-06T21:03:00.000","Title":"Writing a reliable, totally-ordered multicast system in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a series of datetime objects and would like to calculate the average delta between them.\nFor example, if the input was (2008-10-01 12:15:00, 2008-10-01 12:25:00, 2008-10-01 12:35:00), then the average delta would be exactly 00:10:00, or 10 minutes.\nAny suggestions on how to calculate this using Python?","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":6291,"Q_Id":179716,"Users Score":2,"Answer":"Since you seem to be throwing out the 20 minute delta between times 1 and 3 in your example, I'd say you should just sort the list of datetimes, add up the deltas between adjacent times, then divide by n-1.\nDo you have any code you can share with us, so we can help you debug it?","Q_Score":4,"Tags":"python,algorithm,datetime","A_Id":179760,"CreationDate":"2008-10-07T18:18:00.000","Title":"Average difference between dates in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a series of datetime objects and would like to calculate the average delta between them.\nFor example, if the input was (2008-10-01 12:15:00, 2008-10-01 12:25:00, 2008-10-01 12:35:00), then the average delta would be exactly 00:10:00, or 10 minutes.\nAny suggestions on how to calculate this using Python?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6291,"Q_Id":179716,"Users Score":0,"Answer":"You can subtract each successive date from the one prior (resulting in a timedelta object which represents the difference in days, seconds).  You can then average the timedelta objects to find your answer.","Q_Score":4,"Tags":"python,algorithm,datetime","A_Id":179761,"CreationDate":"2008-10-07T18:18:00.000","Title":"Average difference between dates in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot imagine that such a large number of people would care about it. \nWhat am I missing? What is the problem with reduce()?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":22140,"Q_Id":181543,"Users Score":37,"Answer":"reduce() is not being removed -- it's simply being moved into the functools module. Guido's reasoning is that except for trivial cases like summation, code written using reduce() is usually clearer when written as an accumulation loop.","Q_Score":78,"Tags":"python,python-3.x","A_Id":181646,"CreationDate":"2008-10-08T06:27:00.000","Title":"What is the problem with reduce()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot imagine that such a large number of people would care about it. \nWhat am I missing? What is the problem with reduce()?","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":22140,"Q_Id":181543,"Users Score":4,"Answer":"The primary reason of reduce's existence is to avoid writing explicit for loops with accumulators. Even though python has some facilities to support the functional style, it is not encouraged. If you like the 'real' and not 'pythonic' functional style - use a modern Lisp (Clojure?) or Haskell instead.","Q_Score":78,"Tags":"python,python-3.x","A_Id":43993022,"CreationDate":"2008-10-08T06:27:00.000","Title":"What is the problem with reduce()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot imagine that such a large number of people would care about it. \nWhat am I missing? What is the problem with reduce()?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":22140,"Q_Id":181543,"Users Score":9,"Answer":"People worry it encourages an obfuscated style of programming, doing something that can be achieved with clearer methods.\nI'm not against reduce myself, I also find it a useful tool sometimes.","Q_Score":78,"Tags":"python,python-3.x","A_Id":181593,"CreationDate":"2008-10-08T06:27:00.000","Title":"What is the problem with reduce()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.\nSo, because it's so easy to immediately see the output of your program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use?\nI'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":1057,"Q_Id":181724,"Users Score":2,"Answer":"Any time you want to inspect the contents of variables that may have caused the error.  The only way you can do that is to stop execution and take a look at the stack.\npydev in Eclipse is a pretty good IDE if you are looking for one.","Q_Score":6,"Tags":"python,debugging","A_Id":181761,"CreationDate":"2008-10-08T07:49:00.000","Title":"When to use the Python debugger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.\nSo, because it's so easy to immediately see the output of your program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use?\nI'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":1057,"Q_Id":181724,"Users Score":1,"Answer":"I find it very useful to drop into a debugger in a failing test case.\nI add import pdb; pdb.set_trace() just before the failure point of the test. The test runs, building up a potentially quite large context (e.g. importing a database fixture or constructing an HTTP request). When the test reaches the pdb.set_trace() line, it drops into the interactive debugger and I can inspect the context in which the failure occurs with the usual pdb commands looking for clues as to the cause.","Q_Score":6,"Tags":"python,debugging","A_Id":183563,"CreationDate":"2008-10-08T07:49:00.000","Title":"When to use the Python debugger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.\nSo, because it's so easy to immediately see the output of your program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use?\nI'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":1057,"Q_Id":181724,"Users Score":8,"Answer":"In 30 years of programming I've used a debugger exactly 4 times.  All four times were to read the core file produced from a C program crashing to locate the traceback information that's buried in there.\nI don't think debuggers help much, even in compiled languages.  Many people like debuggers, there are some reasons for using them, I'm sure, or people wouldn't lavish such love and care on them.\nHere's the point -- software is knowledge capture.  \nYes, it does have to run.  More importantly, however, software has meaning.\nThis is not an indictment of your use of a debugger.  However, I find that the folks who rely on debugging will sometimes produce really odd-looking code and won't have a good justification for what it means.  They can only say \"it may be a hack, but it works.\"  \nMy suggestion on debuggers is \"don't bother\".\n\"But, what if I'm totally stumped?\" you ask, \"should I learn the debugger then?\"  Totally stumped by what?  The language?  Python's too simple for utter befuddlement.  Some library?  Perhaps.\nHere's what you do -- with or without a debugger.\n\nYou have the source, read it.\nYou write small tests to exercise the library.  Using the interactive shell, if possible.  [All the really good libraries seem to show their features using the interactive Python mode -- I strive for this level of tight, clear simplicity.]\nYou have the source, add print functions.","Q_Score":6,"Tags":"python,debugging","A_Id":182010,"CreationDate":"2008-10-08T07:49:00.000","Title":"When to use the Python debugger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick.\nSo, because it's so easy to immediately see the output of your program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use?\nI'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1057,"Q_Id":181724,"Users Score":7,"Answer":"I use pdb for basic python debugging. Some of the situations I use it are:\n\nWhen you have a loop iterating over 100,000 entries and want to break at a specific point, it becomes really helpful.(conditional breaks)\nTrace the control flow of someone else's code.\nIts always better to use a debugger than litter the code with prints.\nNormally there can be more than one point of failures resulting in a bug, all are not obvious in the first look. So you look for obvious places, if nothing is wrong there, you move ahead and add some more prints.. debugger can save you time here, you dont need to add the print and run again.","Q_Score":6,"Tags":"python,debugging","A_Id":181767,"CreationDate":"2008-10-08T07:49:00.000","Title":"When to use the Python debugger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python and struggling to find how to control the amount of memory a python process can take? I am running python on a Cento OS machine with more than 2 GB of main memory size. Python is taking up only 128mb of this and I want to allocate it more. I tried to search all over the internet on this for last half an hour and found absolutely nothing! Why is it so difficult to find information on python related stuff :(\nI would be happy if someone could throw some light on how to configure python for various things like allowed memory size, number of threads etc.\nA link to a site where most controllable parameters of python are described would be appreciated well.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1627,"Q_Id":191700,"Users Score":2,"Answer":"Are you sure that the machine does not have a 128M process limit? If you are running the python script as a CGI inside a web server, it is quite likely that there is a process limit set - you will need to look at the web server configuration.","Q_Score":2,"Tags":"python,memory","A_Id":191790,"CreationDate":"2008-10-10T14:52:00.000","Title":"Configuring python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python and struggling to find how to control the amount of memory a python process can take? I am running python on a Cento OS machine with more than 2 GB of main memory size. Python is taking up only 128mb of this and I want to allocate it more. I tried to search all over the internet on this for last half an hour and found absolutely nothing! Why is it so difficult to find information on python related stuff :(\nI would be happy if someone could throw some light on how to configure python for various things like allowed memory size, number of threads etc.\nA link to a site where most controllable parameters of python are described would be appreciated well.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1627,"Q_Id":191700,"Users Score":11,"Answer":"Forget all that, python just allocates more memory as needed, there is not a myriad of comandline arguments for the VM as in java, just let it run. For all comandline switches you can just run python -h or read man python.","Q_Score":2,"Tags":"python,memory","A_Id":191744,"CreationDate":"2008-10-10T14:52:00.000","Title":"Configuring python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm not exactly sure how to ask this question really, and I'm no where close to finding an answer, so I hope someone can help me. \nI'm writing a Python app that connects to a remote host and receives back byte data, which I unpack using Python's built-in struct module. My problem is with the strings, as they include multiple character encodings. Here is an example of such a string:\n\"^LThis is an example ^Gstring with multiple ^Jcharacter encodings\"\nWhere the different encoding starts and ends is marked using special escape chars:\n\n^L - Latin1\n^E - Central Europe\n^T - Turkish\n^B - Baltic\n^J - Japanese\n^C - Cyrillic\n^G - Greek\n\nAnd so on... I need a way to convert this sort of string into Unicode, but I'm really not sure how to do it. I've read up on Python's codecs and string.encode\/decode, but I'm none the wiser really. I should mention as well, that I have no control over how the strings are outputted by the host.\nI hope someone can help me with how to get started on this.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":3280,"Q_Id":197759,"Users Score":1,"Answer":"I don't suppose you have any way of convincing the person who hosts the other machine to switch to unicode?\nThis is one of the reasons Unicode was invented, after all.","Q_Score":9,"Tags":"python,string,unicode,encoding","A_Id":197854,"CreationDate":"2008-10-13T14:26:00.000","Title":"Dealing with a string containing multiple character encodings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not exactly sure how to ask this question really, and I'm no where close to finding an answer, so I hope someone can help me. \nI'm writing a Python app that connects to a remote host and receives back byte data, which I unpack using Python's built-in struct module. My problem is with the strings, as they include multiple character encodings. Here is an example of such a string:\n\"^LThis is an example ^Gstring with multiple ^Jcharacter encodings\"\nWhere the different encoding starts and ends is marked using special escape chars:\n\n^L - Latin1\n^E - Central Europe\n^T - Turkish\n^B - Baltic\n^J - Japanese\n^C - Cyrillic\n^G - Greek\n\nAnd so on... I need a way to convert this sort of string into Unicode, but I'm really not sure how to do it. I've read up on Python's codecs and string.encode\/decode, but I'm none the wiser really. I should mention as well, that I have no control over how the strings are outputted by the host.\nI hope someone can help me with how to get started on this.","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":3280,"Q_Id":197759,"Users Score":3,"Answer":"I would write a codec that incrementally scanned the string and decoded the bytes as they came along. Essentially, you would have to separate strings into chunks with a consistent encoding and decode those and append them to the strings that followed them.","Q_Score":9,"Tags":"python,string,unicode,encoding","A_Id":197786,"CreationDate":"2008-10-13T14:26:00.000","Title":"Dealing with a string containing multiple character encodings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the difference between multiprocessor programming and multicore programming?\npreferably show examples in python how to write a small program for multiprogramming & multicore programming","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":71173,"Q_Id":203912,"Users Score":1,"Answer":"The main difference is how you organize and distribute data. Multicore typically has higher bandwidths between the different cores in a cpu, and multiprocessor needs to involve the bus between the cpus more.\nPython 2.6 has gotten multiprocess (process, as in program running) and more synchronization and communication objects for multithreaded programming.","Q_Score":70,"Tags":"python,multicore","A_Id":203923,"CreationDate":"2008-10-15T06:59:00.000","Title":"Does python support multiprocessor\/multicore programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been wondering about how hard it would be to write some Python code to search a string for the index of a substring of the form ${expr}, for example, where expr is meant to be a Python expression or something resembling one.  Given such a thing, one could easily imagine going on to check the expression's syntax with compile(), evaluate it against a particular scope with eval(), and perhaps even substitute the result into the original string.  People must do very similar things all the time.\nI could imagine solving such a problem using a third-party parser generator [oof], or by hand-coding some sort of state machine [eek], or perhaps by convincing Python's own parser to do the heavy lifting somehow [hmm].  Maybe there's a third-party templating library somewhere that can be made to do exactly this.  Maybe restricting the syntax of expr is likely to be a worthwhile compromise in terms of simplicity or execution time or cutting down on external dependencies -- for example, maybe all I really need is something that matches any expr that has balanced curly braces.\nWhat's your sense?\nUpdate:\nThanks very much for your responses so far!  Looking back at what I wrote yesterday, I'm not sure I was sufficiently clear about what I'm asking.  Template substitution is indeed an interesting problem, and probably much more useful to many more people than the expression extraction subproblem I'm wondering about, but I brought it up only as a simple example of how the answer to my question might be useful in real life.  Some other potential applications might include passing the extracted expressions to a syntax highlighter; passing the result to a real Python parser and looking at or monkeying with the parse tree; or using the sequence of extracted expressions to build up a larger Python program, perhaps in conjunction with some information taken from the surrounding text.\nThe ${expr} syntax I mentioned is also intended as an example, and in fact I wonder if I shouldn't have used $(expr) as my example instead, because it makes the potential drawbacks of the obvious approach, along the lines of re.finditer(r'$\\{([^}]+)\\}', s), a bit easier to see.  Python expressions can (and often do) contain the ) (or }) character.  It seems possible that handling any of those cases might be much more trouble than it's worth, but I'm not convinced of that yet.  Please feel free to try to make this case!\nPrior to posting this question, I spent quite a bit of time looking at Python template engines hoping that one might expose the sort of low-level functionality I'm asking about -- namely, something that can find expressions in a variety of contexts and tell me where they are rather than being limited to finding expressions embedded using a single hard-coded syntax, always evaluating them, and always substituting the results back into the original string.  I haven't figured out how to use any of them to solve my problem yet, but I do very much appreciate the suggestions regarding more to look at (can't believe I missed that wonderful list on the wiki!).  The API documentation for these things tends to be pretty high-level, and I'm not too familiar with the internals of any of them, so I'm sure I could use help looking at those and figuring out how to get them to do this sort of thing.\nThanks for your patience!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1094,"Q_Id":207290,"Users Score":1,"Answer":"If you want to handle arbitrary expressions like {'{spam': 42}[\"spam}\"], you can't get away without full-blown parser.","Q_Score":1,"Tags":"python,parsing","A_Id":209420,"CreationDate":"2008-10-16T03:02:00.000","Title":"Extracting a parenthesized Python expression from a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially \"inline\", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production.\nWhat I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if\/else statements, whichever is better).\nI created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try\/except before but figured this is a good time to learn).\nAre there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":31269,"Q_Id":211501,"Users Score":0,"Answer":"Yes, I was nuking out the problem. All I needed to do was check for the file and catch the IOError if it didn't exist.\nThanks for all the other answers. They may come in handy in the future.","Q_Score":13,"Tags":"python,exception,sqlite","A_Id":214623,"CreationDate":"2008-10-17T09:02:00.000","Title":"Using SQLite in a Python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially \"inline\", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production.\nWhat I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if\/else statements, whichever is better).\nI created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try\/except before but figured this is a good time to learn).\nAre there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","AnswerCount":8,"Available Count":5,"Score":0.0748596907,"is_accepted":false,"ViewCount":31269,"Q_Id":211501,"Users Score":3,"Answer":"Doing SQL in overall is horrible in any language I've picked up. SQLalchemy has shown to be easiest from them to use because actual query and committing with it is so clean and absent from troubles.\nHere's some basic steps on actually using sqlalchemy in your app, better details can be found from the documentation.\n\nprovide table definitions and create ORM-mappings\nload database\nask it to create tables from the definitions (won't do so if they exist)\ncreate session maker (optional)\ncreate session\n\nAfter creating a session, you can commit and query from the database.","Q_Score":13,"Tags":"python,exception,sqlite","A_Id":211539,"CreationDate":"2008-10-17T09:02:00.000","Title":"Using SQLite in a Python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially \"inline\", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production.\nWhat I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if\/else statements, whichever is better).\nI created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try\/except before but figured this is a good time to learn).\nAre there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":31269,"Q_Id":211501,"Users Score":7,"Answer":"SQLite automatically creates the database file the first time you try to use it. The SQL statements for creating tables can use IF NOT EXISTS to make the commands only take effect if the table has not been created This way you don't need to check for the database's existence beforehand: SQLite can take care of that for you.\nThe main thing I would still be worried about is that executing CREATE TABLE IF EXISTS for every web transaction (say) would be inefficient; you can avoid that by having the program keep an (in-memory) variable saying whether it has created the database today, so it runs the CREATE TABLE script once per run. This would still allow for you to delete the database and start over during debugging.","Q_Score":13,"Tags":"python,exception,sqlite","A_Id":211573,"CreationDate":"2008-10-17T09:02:00.000","Title":"Using SQLite in a Python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially \"inline\", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production.\nWhat I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if\/else statements, whichever is better).\nI created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try\/except before but figured this is a good time to learn).\nAre there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":31269,"Q_Id":211501,"Users Score":29,"Answer":"Don't make this more complex than it needs to be.  The big, independent databases have complex setup and configuration requirements.  SQLite is just a file you access with SQL, it's much simpler.\nDo the following.\n\nAdd a table to your database for \"Components\" or \"Versions\" or \"Configuration\" or \"Release\" or something administrative like that.  \nCREATE TABLE REVISION(\n    RELEASE_NUMBER CHAR(20)\n);\nIn your application, connect to your database normally.\nExecute a simple query against the revision table.  Here's what can happen.\n\n\nThe query fails to execute: your database doesn't exist, so execute a series of CREATE statements to build it.\nThe query succeeds but returns no rows or the release number is lower than expected: your database exists, but is out of date.  You need to migrate from that release to the current release.  Hopefully, you have a sequence of DROP, CREATE and ALTER statements to do this.\nThe query succeeds, and the release number is the expected value.  Do nothing more, your database is configured correctly.","Q_Score":13,"Tags":"python,exception,sqlite","A_Id":211660,"CreationDate":"2008-10-17T09:02:00.000","Title":"Using SQLite in a Python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially \"inline\", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production.\nWhat I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if\/else statements, whichever is better).\nI created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try\/except before but figured this is a good time to learn).\nAre there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","AnswerCount":8,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":31269,"Q_Id":211501,"Users Score":13,"Answer":"AFAIK an SQLITE database is just a file.\nTo check if the database exists, check for file existence.\nWhen you open a SQLITE database it will automatically create one if the file that backs it up is not in place.\nIf you try and open a file as a sqlite3 database that is NOT a database, you will get this:\n\"sqlite3.DatabaseError: file is encrypted or is not a database\"\nso check to see if the file exists and also make sure to try and catch the exception in case the file is not a sqlite3 database","Q_Score":13,"Tags":"python,exception,sqlite","A_Id":211534,"CreationDate":"2008-10-17T09:02:00.000","Title":"Using SQLite in a Python program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I installed Python 2.6 for one user on Windows Vista.  Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors.  I've tried tinkering with the Visual Studio runtime, with no good results.  Any ideas on how to resolve this?","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":1345,"Q_Id":219215,"Users Score":-1,"Answer":"python 2.6.2 + tkinter 8.5, no problems","Q_Score":3,"Tags":"python,windows,windows-vista,tkinter","A_Id":792527,"CreationDate":"2008-10-20T17:19:00.000","Title":"How do I use Tkinter with Python on Windows Vista?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Python 2.6 for one user on Windows Vista.  Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors.  I've tried tinkering with the Visual Studio runtime, with no good results.  Any ideas on how to resolve this?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1345,"Q_Id":219215,"Users Score":1,"Answer":"It seems this is a one of the many weird Vista problems and some random reinstalling, installing\/upgrading of the visual studio runtime or some such seems sometimes to help, or disabling sxs in the system configuration or writing a manifest file etc.\nThough I think you should downgrade to windows XP.","Q_Score":3,"Tags":"python,windows,windows-vista,tkinter","A_Id":219326,"CreationDate":"2008-10-20T17:19:00.000","Title":"How do I use Tkinter with Python on Windows Vista?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Python 2.6 for one user on Windows Vista.  Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors.  I've tried tinkering with the Visual Studio runtime, with no good results.  Any ideas on how to resolve this?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1345,"Q_Id":219215,"Users Score":1,"Answer":"Maybe you should downgrade to 2.5 version?","Q_Score":3,"Tags":"python,windows,windows-vista,tkinter","A_Id":219284,"CreationDate":"2008-10-20T17:19:00.000","Title":"How do I use Tkinter with Python on Windows Vista?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a program that fits the wizard concept ideally; the user is walked through the steps to create a character for a game.\nHowever, I'm realizing that the limitations of the wizard are making it difficult to design \"elegant\" logic flow. For example, because all pages of the wizard are initalized at the same time, I can't have the values entered in one page available to the next one. I have to put a button on each page to get the values from a previous page rather than simply having fields auto-populated.\nI've thought about alternatives to using the wizard. I think the best idea is to have some buttons on one panel that change the information on another panel, e.g. a splitter window.\nHowever, I can't find any documentation in wxPython on how to dynamically change the panel. Everything I've found so far is really pretty static, hence the use of the wizard. Even the \"wxPython in Action\" book doesn't mention it.\nAre there any tutorials for making \"dynamic panels\" or better management of a wizard?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2843,"Q_Id":224337,"Users Score":1,"Answer":"The wxPython demo has an example of a \"dynamic\" wizard. Pages override GetNext() and GetPrev() to show pages dynamically. This shows the basic technique; you can extend it to add and remove pages, change pages on the fly, and rearrange pages dynamically.\nThe wizard class is just a convenience, though. You can modify it, or create your own implementation. A style that seems popular nowadays is to use an HTML-based presentation; you can emulate this with the wxHtml control, or the IEHtmlWindow control if your app is Windows only.","Q_Score":3,"Tags":"python,wxpython,wizard","A_Id":247409,"CreationDate":"2008-10-22T02:54:00.000","Title":"Alternatives to a wizard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a program that fits the wizard concept ideally; the user is walked through the steps to create a character for a game.\nHowever, I'm realizing that the limitations of the wizard are making it difficult to design \"elegant\" logic flow. For example, because all pages of the wizard are initalized at the same time, I can't have the values entered in one page available to the next one. I have to put a button on each page to get the values from a previous page rather than simply having fields auto-populated.\nI've thought about alternatives to using the wizard. I think the best idea is to have some buttons on one panel that change the information on another panel, e.g. a splitter window.\nHowever, I can't find any documentation in wxPython on how to dynamically change the panel. Everything I've found so far is really pretty static, hence the use of the wizard. Even the \"wxPython in Action\" book doesn't mention it.\nAre there any tutorials for making \"dynamic panels\" or better management of a wizard?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2843,"Q_Id":224337,"Users Score":0,"Answer":"I'd get rid of wizard in whole. They are the most unpleasant things I've ever used.\nThe problem that requires a wizard-application where you click 'next' is perhaps a problem where you could apply a better user interface in a bit different manner. Instead of bringing up a dialog with annoying 'next' -button. Do this:\nBring up a page. When the user inserts the information to the page, extend or shorten it according to the input. If your application needs to do some processing to continue, and it's impossible to revert after that, write a new page or disable the earlier section of the current page. When you don't need any input from the user anymore or the app is finished, you can show a button or enable an existing such.\nI don't mean you should implement it all in browser. Make simply a scrolling container that can contain buttons and labels in a flat list.\nBenefit: The user can just click a tab, and you are encouraged to put all the processing into the end of filling the page.","Q_Score":3,"Tags":"python,wxpython,wizard","A_Id":247633,"CreationDate":"2008-10-22T02:54:00.000","Title":"Alternatives to a wizard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've been exploring the details of Django for about a week now and like what I see. However I've come upon some.. negativity in relation to fine-grained control of permissions to the CRUD interface.\nWhat I'm writing is an Intranet client management web-app. The organisation is about 6 tiers, and I need to restrict access to client groups based on tiers. Continually expanding. I have a fairly good idea how I'm going to do this, but am not sure if I'll be able to integrate it well into the pre-built admin interface. \nI've done absolutely zero Django development otherwise I'd probably have a better idea on whether this would work or not. I probably won't use Django if the generated admin interface is going to be useless to this project - but like I said, there is a heavy reliance on fine-grained custom permissions.\nWill Django let me build custom permissions\/rules and integrate it seamlessly into the admin CRUD interface?\nUpdate One: I want to use the admin app to minimise the repitition of generating CRUD interfaces, so yes I consider it a must have.\nUpdate Two:\nI want to describe the permissions required for this project.\nA client can belong to one or many 'stores'. Full time employees should only be able to edit clients at their store (even if they belong to another store). However, they should not be able to see\/edit clients at another store. Casuals should only be able to view clients based on what store they are rostered too (or if the casual is logged in as the store user - more likely).\nManagement above them need to be able to see all employees for the stores they manage, nothing more.\nSenior management should be able to edit ALL employees and grant permissions below themselves.\nAfter reading the django documentation, it says you can't (autmoatically) set permissions for a sub-set of a group. Only the entire group. Is it easy enough to mock up your own permissions for this purpose?","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":8167,"Q_Id":232008,"Users Score":4,"Answer":"The Django permission system totally rules.  Each model has a default set of permissions. You can add new permissions to your models, also.\nEach User has a set of permissions as well as group memberships.  Individual users can have individual permissions.  And they inherit permissions from their group membership.\nYour view functions (and templates) can easily check the presence of absence of those permissions at any level of granularity you need to use.  \nAnd if this isn't enough for you, the Profile add-on gives you yet more options for defining a \"User\" and their capabilities, permissions, roles, responsibilities, etc.\nAnd if this isn't enough for you, you can define your own authentication schemes.\n\nWhat's important is not to try and define groups that are actual subsets of users, not casually defined titles or roles.  You never need to \"set permissions for a sub-set of a group\".  You need to have smaller groups.   Groups defined around subsets of people.\nDjango's default permissions are around model access, not row access within a model.  On the other hand, your problem is about subsets of rows in several models: Client, Store, Employee, Manager.\nYou'll need a basic set of FK's among these items, and some filters to subset the rows.  You may have trouble doing this with default admin pages.  You may need your own version of admin to make use of specialized filters.\n\nIf you can't do it with the Django permission system, you should rethink your use cases.  Seriously.\n[The Django-REST Interface, however, is another beast entirely, and requires some care and feeding.]","Q_Score":14,"Tags":"python,django,permissions","A_Id":232243,"CreationDate":"2008-10-23T23:50:00.000","Title":"Will Django be a good choice for a permissions based web-app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base?\n\nWhen you make incompatibility changes to the signature of a method, how do you find all the places where that method is being called. In C++\/Java the compiler will find it for you, how do you do it in Python?\nWhen you make changes deep inside the code, how do you find out what operations an instance provides, since you don't have a static type to lookup?\nHow do you handle\/prevent typing errors (typos)?\nAre UnitTest's used as a substitute for static type checking?\n\nAs you can guess I almost only worked with statically typed languages (C++\/Java), but I would like to try my hands on Python for larger programs. But I had a very bad experience, a long time ago, with the clipper (dBase) language, which was also dynamically typed.","AnswerCount":8,"Available Count":4,"Score":0.0748596907,"is_accepted":false,"ViewCount":19675,"Q_Id":236407,"Users Score":3,"Answer":"My general rule of thumb is to use dynamic languages for small non-mission-critical projects and statically-typed languages for big projects. I find that code written in a dynamic language such as python gets \"tangled\" more quickly. Partly that is because it is much quicker to write code in a dynamic language and that leads to shortcuts and worse design, at least in my case. Partly it's because I have IntelliJ for quick and easy refactoring when I use Java, which I don't have for python.","Q_Score":62,"Tags":"python,development-environment","A_Id":236570,"CreationDate":"2008-10-25T13:30:00.000","Title":"How can I use Python for large scale development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base?\n\nWhen you make incompatibility changes to the signature of a method, how do you find all the places where that method is being called. In C++\/Java the compiler will find it for you, how do you do it in Python?\nWhen you make changes deep inside the code, how do you find out what operations an instance provides, since you don't have a static type to lookup?\nHow do you handle\/prevent typing errors (typos)?\nAre UnitTest's used as a substitute for static type checking?\n\nAs you can guess I almost only worked with statically typed languages (C++\/Java), but I would like to try my hands on Python for larger programs. But I had a very bad experience, a long time ago, with the clipper (dBase) language, which was also dynamically typed.","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":19675,"Q_Id":236407,"Users Score":2,"Answer":"The usual answer to that is testing testing testing. You're supposed to have an extensive unit test suite and run it often, particularly before a new version goes online.\nProponents of dynamically typed languages make the case that you have to test anyway because even in a statically typed language conformance to the crude rules of the type system covers only a small part of what can potentially go wrong.","Q_Score":62,"Tags":"python,development-environment","A_Id":236470,"CreationDate":"2008-10-25T13:30:00.000","Title":"How can I use Python for large scale development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base?\n\nWhen you make incompatibility changes to the signature of a method, how do you find all the places where that method is being called. In C++\/Java the compiler will find it for you, how do you do it in Python?\nWhen you make changes deep inside the code, how do you find out what operations an instance provides, since you don't have a static type to lookup?\nHow do you handle\/prevent typing errors (typos)?\nAre UnitTest's used as a substitute for static type checking?\n\nAs you can guess I almost only worked with statically typed languages (C++\/Java), but I would like to try my hands on Python for larger programs. But I had a very bad experience, a long time ago, with the clipper (dBase) language, which was also dynamically typed.","AnswerCount":8,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":19675,"Q_Id":236407,"Users Score":24,"Answer":"Since nobody pointed out pychecker, pylint and similar tools, I will: pychecker and pylint are tools that can help you find incorrect assumptions (about function signatures, object attributes, etc.) They won't find everything that a compiler might find in a statically typed language -- but they can find problems that such compilers for such languages can't find, too.\nPython (and any dynamically typed language) is fundamentally different in terms of the errors you're likely to cause and how you would detect and fix them. It has definite downsides as well as upsides, but many (including me) would argue that in Python's case, the ease of writing code (and the ease of making it structurally sound) and of modifying code without breaking API compatibility (adding new optional arguments, providing different objects that have the same set of methods and attributes) make it suitable just fine for large codebases.","Q_Score":62,"Tags":"python,development-environment","A_Id":236537,"CreationDate":"2008-10-25T13:30:00.000","Title":"How can I use Python for large scale development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base?\n\nWhen you make incompatibility changes to the signature of a method, how do you find all the places where that method is being called. In C++\/Java the compiler will find it for you, how do you do it in Python?\nWhen you make changes deep inside the code, how do you find out what operations an instance provides, since you don't have a static type to lookup?\nHow do you handle\/prevent typing errors (typos)?\nAre UnitTest's used as a substitute for static type checking?\n\nAs you can guess I almost only worked with statically typed languages (C++\/Java), but I would like to try my hands on Python for larger programs. But I had a very bad experience, a long time ago, with the clipper (dBase) language, which was also dynamically typed.","AnswerCount":8,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":19675,"Q_Id":236407,"Users Score":40,"Answer":"I had some experience with modifying \"Frets On Fire\", an open source python \"Guitar Hero\" clone.\nas I see it, python is not really suitable for a really large scale project.\nI found myself spending a large part of the development time debugging issues related to assignment of incompatible types, things that static typed laguages will reveal effortlessly at compile-time.\nalso, since types are determined on run-time, trying to understand existing code becomes harder, because you have no idea what's the type of that parameter you are currently looking at.\nin addition to that, calling functions using their name string with the __getattr__ built in function is generally more common in Python than in other programming languages, thus getting the call graph to a certain function somewhat hard (although you can call functions with their name in some statically typed languages as well).\nI think that Python really shines in small scale software, rapid prototype development, and gluing existing programs together, but I would not use it for large scale software projects, since in those types of programs maintainability becomes the real issue, and in my opinion python is relatively weak there.","Q_Score":62,"Tags":"python,development-environment","A_Id":236445,"CreationDate":"2008-10-25T13:30:00.000","Title":"How can I use Python for large scale development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to update data to a mssql 2005 database so I have decided to use adodbapi, which is supposed to come built into the standard installation of python 2.1.1 and greater.\nIt needs pywin32 to work correctly and the open office python 2.3 installation does not have pywin32 built into it. It also seems like this built int python installation does not have adodbapi, as I get an error when I go import adodbapi. \nAny suggestions on how to get both pywin32 and adodbapi installed into this open office 2.4 python installation?\nthanks \n\noh yeah I tried those ways. annoyingly nothing. So i have reverted to jython, that way I can access Open Office for its conversion capabilities along with decent database access.\nThanks for the help.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":833,"Q_Id":239009,"Users Score":1,"Answer":"maybe the best way to install pywin32 is to place it in \n(openofficedir)\\program\\python-core-2.3.4\\lib\\site-packages\nit is easy  if you have a python 2.3 installation (with pywin installed) under \nC:\\python2.3 \nmove the C:\\python2.3\\Lib\\site-packages\\ to your\n(openofficedir)\\program\\python-core-2.3.4\\lib\\site-packages","Q_Score":0,"Tags":"python,openoffice.org,pywin32,adodbapi","A_Id":239487,"CreationDate":"2008-10-27T03:32:00.000","Title":"getting pywin32 to work inside open office 2.4 built in python 2.3 interpreter","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Anyone have any thoughts on how\/if it is possible to integrate Google Code commits to cause a Google AppEngine deployment of the most recent code?\nI have a simple Google AppEngine project's source hosted on Google Code and would love if everytime I committed to Subversion, that AppEngine would reflect the latest commit.  I don't mind if things are broken on the live site since the project is for personal use mainly and for learning.\nAnyone have any thoughts on how to tie into the subversion commit for the Code repository and\/or how to kickoff the deployment to AppEngine? Ideally the solution would not require anything manual from me nor any type of server\/listener software on my machine.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2320,"Q_Id":241007,"Users Score":1,"Answer":"For those of us who are using Github, this feature from the GAE team would make us all seriously consider switching to Google Code...","Q_Score":18,"Tags":"python,svn,google-app-engine,continuous-integration,google-code","A_Id":241672,"CreationDate":"2008-10-27T18:43:00.000","Title":"Possible to integrate Google AppEngine and Google Code for continuous integration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Anyone have any thoughts on how\/if it is possible to integrate Google Code commits to cause a Google AppEngine deployment of the most recent code?\nI have a simple Google AppEngine project's source hosted on Google Code and would love if everytime I committed to Subversion, that AppEngine would reflect the latest commit.  I don't mind if things are broken on the live site since the project is for personal use mainly and for learning.\nAnyone have any thoughts on how to tie into the subversion commit for the Code repository and\/or how to kickoff the deployment to AppEngine? Ideally the solution would not require anything manual from me nor any type of server\/listener software on my machine.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2320,"Q_Id":241007,"Users Score":1,"Answer":"Very interesting, but not yet possible, AFAIK.  I have been looking for that option in Google Code with no success.\nThe only solution I can figure out is to install something in your machine that checks for changes in your SVN repository.\nI'll be happy to hear about other approaches.","Q_Score":18,"Tags":"python,svn,google-app-engine,continuous-integration,google-code","A_Id":241126,"CreationDate":"2008-10-27T18:43:00.000","Title":"Possible to integrate Google AppEngine and Google Code for continuous integration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been enjoying learning the basics of python, but before I started reading things I tried to install various python versions and modules clumsily. Now that I have some ideas of what I want to do and how to do it I'm finding that various aspects are broken. For instance, 2.6 IDLE won't launch, and when I try to import modules they usually don't work.\nMy question is, how would you recommend I clean this up and start fresh? I have read information about modifying the 2.6 install, but I still can't get it to work.\nIDLE 2.4 works, and when I launch python from the terminal I am running python 2.4.4.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3948,"Q_Id":242065,"Users Score":1,"Answer":"Macports should be easy to get rid of; just delete \/opt\/local\/. I think that Fink does something similar.\nYou can do which python to see what python is the default one. The system python should be in \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.5\/bin\/python\nThe MacPython you may have downloaded would either be in \/Library\/Frameworks\/Python.framework. You can delete this as well.\nAlso, both MacPython and MacPorts edit your ~\/.profile and change the PYTHONPATH, make sure to edit it and remove the extra paths there.","Q_Score":2,"Tags":"python,python-2.6,python-install","A_Id":248884,"CreationDate":"2008-10-28T02:34:00.000","Title":"Python + Leopard + Fink + Mac Ports + Python.org + Idiot = broken Python - fresh start?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am getting a DC for a window handle of an object in another program using win32gui.GetDC which returns an int\/long.  I need to blit this DC into a memory DC in python.  The only thing I can't figure out how to do is get a wxDC derived object from the int\/long that win32gui returns.  None of the wxDC objects allow me to pass an actual DC handle to them from what I can tell.  This of course keeps me from doing my blit. Is there any way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1086,"Q_Id":244340,"Users Score":0,"Answer":"From what I can tell, DCs in python are abstracted due to platform variation.  So a device context in python doesn't directly map to a device context in Windows even though many of the methods are direct Windows method calls.  To make this happen it appears you would need to make your own DelegateDC class or something similar that is intended just for Windows so that you could set the DC handle directly.\nThere might also be some way to attach a wxWindow to the window handle after which you could get a wxWindowDC from the wxWindow...can't figure this out though.","Q_Score":2,"Tags":"wxpython,device,win32gui,bitblit","A_Id":253897,"CreationDate":"2008-10-28T18:35:00.000","Title":"wxPython wxDC object from win32gui.GetDC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As it seems there is no scripting language for Windows mobile devices that gives access to phone (sms, mms, make a call, take photo). I wonder how complex it would be to make a Python library that would enable that (write something in C, compile, and import in PythonCE).\nQuestion: Where shall start to understand how to compile a PythonCE module that will give additional functionality to Python on Windows mobile. Also, what is the required toolkit. Is it at all possible on Mac (Leopard)?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":871,"Q_Id":252859,"Users Score":1,"Answer":"MSDN has plenty of samples for C++ development on Windows Mobile, and the SDK comes with several sample application. Unfortunately VS Express editions (the free ones) do not come with compilers for Smart Devices.  The only free option is the older eMbedded Visual C++ (eVC), which is now something like 8 years old and not supported (though it can still create apps for devices at least up through CE 5.0).","Q_Score":1,"Tags":"c,windows-mobile,extending,pythonce","A_Id":253562,"CreationDate":"2008-10-31T08:13:00.000","Title":"Extending PythonCE to Access gsm\/camera\/gps Easily from PythonCE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that I would like to add a \"Shutdown when done\" feature to.\nI know I can use gksudo (when the user clicks on \"shutdown when done\") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished).\nI have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that.\nAny ideas how I can achieve this?\nThanks in advance,\nAshy.","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":552,"Q_Id":263773,"Users Score":4,"Answer":"Instead of chmod u+sing the shutdown command, allowing passwordless sudo access to that command would be better..\nAs for allowing shutdown at the end of the script, I suppose you could run the entire script with sudo, then drop privileges to the initial user at the start of the script?","Q_Score":7,"Tags":"python,linux,ubuntu","A_Id":263859,"CreationDate":"2008-11-04T22:47:00.000","Title":"How can I ask for root password but perform the action at a later time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that I would like to add a \"Shutdown when done\" feature to.\nI know I can use gksudo (when the user clicks on \"shutdown when done\") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished).\nI have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that.\nAny ideas how I can achieve this?\nThanks in advance,\nAshy.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":552,"Q_Id":263773,"Users Score":1,"Answer":"Escalate priority, spawn (fork (2)) a separate process that will wait (2), and drop priority in the main process.","Q_Score":7,"Tags":"python,linux,ubuntu","A_Id":263851,"CreationDate":"2008-11-04T22:47:00.000","Title":"How can I ask for root password but perform the action at a later time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that I would like to add a \"Shutdown when done\" feature to.\nI know I can use gksudo (when the user clicks on \"shutdown when done\") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished).\nI have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that.\nAny ideas how I can achieve this?\nThanks in advance,\nAshy.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":552,"Q_Id":263773,"Users Score":3,"Answer":"gksudo should have a timeout, I believe it's from the time you last executed a gksudo command.\nSo I think I'd just throw out a \"gksudo echo meh\" or something every minute.  Should reset the timer and keep you active until you reboot.","Q_Score":7,"Tags":"python,linux,ubuntu","A_Id":263804,"CreationDate":"2008-11-04T22:47:00.000","Title":"How can I ask for root password but perform the action at a later time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm conducting experiments regarding e-mail spam. One of these experiments require sending mail thru Tor. Since I'm using Python and smtplib for my experiments, I'm looking for a way to use the Tor proxy (or other method) to perform that mail sending.\nIdeas how this can be done?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2405,"Q_Id":266849,"Users Score":1,"Answer":"Because of abuse by spammers, many Tor egress nodes decline to emit port 25 (SMTP) traffic, so you may have problems.","Q_Score":2,"Tags":"python,smtp,tor","A_Id":275164,"CreationDate":"2008-11-05T21:50:00.000","Title":"Using Python's smtplib with Tor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet.\nCan anyone please tell me how one can achieve multiple database connections in Django.\nDoes anyone have any idea by when Django will fully\/officially support Multiple database connections.","AnswerCount":10,"Available Count":1,"Score":0.0599281035,"is_accepted":false,"ViewCount":9347,"Q_Id":268089,"Users Score":3,"Answer":"If you read a few of the many (many) threads on this subject in django-dev, you will see that what looks straightforward, isn't. If you pick a single use case, then it looks easy, but as soon as you start to generalize in any way you start to run into trouble.\nTo use the above-referenced thread as an example, when you say \"multiple databases\", which of the following are you talking about?\n\nAll DB on the same machine under the same engine.\nAll DB on same machine, different engines (E.g. MySQL + PostgreSQL)\nOne Master DB with N read-only slaves on different machines.\nSharding of tables across multiple DB servers.\n\nWill you need:\n\nForeign keys across DBs\nJOINs across machines and\/or engines\netc. etc.\n\nOne of the problems with a slick ORM like Django's is that it hides all of those messy details under a nice paint job. To continue to do that, but to then add in any of the above, is Not Easy (tm).","Q_Score":10,"Tags":"python,django,database-connection","A_Id":272522,"CreationDate":"2008-11-06T09:39:00.000","Title":"Multiple database support in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I develop a client-server style, database based system and I need to devise a way to stress \/ load test the system.  Customers inevitably want to know such things as:\n\u2022 How many clients can a server support?\n\u2022 How many concurrent searches can a server support?\n\u2022 How much data can we store in the database?\n\u2022 Etc.\nKey to all these questions is response time.  We need to be able to measure how response time and performance degrades as new load is introduced so that we could for example, produce some kind of pretty graph we could throw at clients to give them an idea what kind of performance to expect with a given hardware configuration.\nRight now we just put out fingers in the air and make educated guesses based on what we already know about the system from experience.  As the product is put under more demanding conditions, this is proving to be inadequate for our needs going forward though.\nI've been given the task of devising a method to get such answers in a meaningful way.  I realise that this is not a question that anyone can answer definitively but I'm looking for suggestions about how people have gone about doing such work on their own systems.\nOne thing to note is that we have full access to our client API via the Python language (courtesy of SWIG) which is a lot easier to work with than C++ for this kind of work.\nSo there we go, I throw this to the floor: really interested to see what ideas you guys can come up with!","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":10487,"Q_Id":271825,"Users Score":5,"Answer":"For performance you are looking at two things: latency (the responsiveness of the application) and throughput (how many ops per interval). For latency you need to have an acceptable benchmark. For throughput you need to have a minimum acceptable throughput.\nThese are you starting points. For telling a client how many xyz's you can do per interval then you are going to need to know the hardware and software configuration. Knowing the production hardware is important to getting accurate figures. If you do not know the hardware configuration then you need to devise a way to map your figures from the test hardware to the eventual production hardware.\nWithout knowledge of hardware then you can really only observe trends in performance over time rather than absolutes.\nKnowing the software configuration is equally important. Do you have a clustered server configuration, is it load balanced, is there anything else running on the server? Can you scale your software or do you have to scale the hardware to meet demand.\nTo know how many clients you can support you need to understand what is a standard set of operations. A quick test is to remove the client and write a stub client and the spin up as many of these as you can. Have each one connect to the server. You will eventually reach the server connection resource limit. Without connection pooling or better hardware you can't get higher than this. Often you will hit a architectural issue before here but in either case you have an upper bounds.\nTake this information and design a script that your client can enact. You need to map how long your script takes to perform the action with respect to how long it will take the expected user to do it. Start increasing your numbers as mentioned above to you hit the point where the increase in clients causes a greater decrease in performance. \nThere are many ways to stress test but the key is understanding expected load. Ask your client about their expectations. What is the expected demand per interval? From there you can work out upper loads.\nYou can do a soak test with many clients operating continously for many hours or days. You can try to connect as many clients as you can as fast you can to see how well your server handles high demand (also a DOS attack). \nConcurrent searches should be done through your standard behaviour searches acting on behalf of the client or, write a script to establish a semaphore that waits on many threads, then you can release them all at once. This is fun and punishes your database. When performing searches you need to take into account any caching layers that may exist. You need to test both caching and without caching (in scenarios where everyone makes unique search requests).\nDatabase storage is based on physical space; you can determine row size from the field lengths and expected data population. Extrapolate this out statistically or create a data generation script (useful for your load testing scenarios and should be an asset to your organisation) and then map the generated data to business objects. Your clients will care about how many \"business objects\" they can store while you will care about how much raw data can be stored.\nOther things to consider: What is the expected availability? What about how long it takes to bring a server online. 99.9% availability is not good if it takes two days to bring back online the one time it does go down. On the flip side a lower availablility is more acceptable if it takes 5 seconds to reboot and you have a fall over.","Q_Score":13,"Tags":"python,database,client-server,load-testing,stress-testing","A_Id":271918,"CreationDate":"2008-11-07T11:35:00.000","Title":"How should I stress test \/ load test a client server application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I develop a client-server style, database based system and I need to devise a way to stress \/ load test the system.  Customers inevitably want to know such things as:\n\u2022 How many clients can a server support?\n\u2022 How many concurrent searches can a server support?\n\u2022 How much data can we store in the database?\n\u2022 Etc.\nKey to all these questions is response time.  We need to be able to measure how response time and performance degrades as new load is introduced so that we could for example, produce some kind of pretty graph we could throw at clients to give them an idea what kind of performance to expect with a given hardware configuration.\nRight now we just put out fingers in the air and make educated guesses based on what we already know about the system from experience.  As the product is put under more demanding conditions, this is proving to be inadequate for our needs going forward though.\nI've been given the task of devising a method to get such answers in a meaningful way.  I realise that this is not a question that anyone can answer definitively but I'm looking for suggestions about how people have gone about doing such work on their own systems.\nOne thing to note is that we have full access to our client API via the Python language (courtesy of SWIG) which is a lot easier to work with than C++ for this kind of work.\nSo there we go, I throw this to the floor: really interested to see what ideas you guys can come up with!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10487,"Q_Id":271825,"Users Score":0,"Answer":"If you have the budget, LoadRunner would be perfect for this.","Q_Score":13,"Tags":"python,database,client-server,load-testing,stress-testing","A_Id":271891,"CreationDate":"2008-11-07T11:35:00.000","Title":"How should I stress test \/ load test a client server application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to set my process to run under 'nobody', I've found os.setuid(), but how do I find uid if I have login?\nI've found out that uids are in \/etc\/passwd, but maybe there is a more pythonic way than scanning \/etc\/passwd. Anybody?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":4216,"Q_Id":294470,"Users Score":5,"Answer":"Never directly scan \/etc\/passwd.\nFor instance, on a Linux system I administer, the user accounts are not on \/etc\/passwd, but on a LDAP server.\nThe correct way is to use getpwent\/getgrent and related C functions (as in @TFKyle's answer), which will get the information on the correct way for each system (on Linux glibc, it reads \/etc\/nsswitch.conf to know which NSS dynamic libraries to load to get the information).","Q_Score":12,"Tags":"python,linux,unix,process-management","A_Id":294535,"CreationDate":"2008-11-16T22:11:00.000","Title":"How do I find userid by login (Python under *NIX)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is and how can it be used in C#.\nCan you use the same concept in Python\/Perl?","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2258,"Q_Id":295670,"Users Score":0,"Answer":"Python also has meta classes but that is more like a template class than a partial class.  A good example of meta class usage is the Django ORM.  All of your table models inherit from a base model class which also gets functionality included from a meta class.  It is a pretty cool concept that enables an active record like pattern (is it full active record?).","Q_Score":8,"Tags":"c#,python,oop,programming-languages","A_Id":296801,"CreationDate":"2008-11-17T14:24:00.000","Title":"What is a partial class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is and how can it be used in C#.\nCan you use the same concept in Python\/Perl?","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":2258,"Q_Id":295670,"Users Score":1,"Answer":"Because python is a dynamic language you don't need a concept like partial class. In python is possible to extend object with functionality in runtime so it possible to break class declaration into different files","Q_Score":8,"Tags":"c#,python,oop,programming-languages","A_Id":295704,"CreationDate":"2008-11-17T14:24:00.000","Title":"What is a partial class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is and how can it be used in C#.\nCan you use the same concept in Python\/Perl?","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2258,"Q_Id":295670,"Users Score":0,"Answer":"A Partial type is a type whose declaration is separated across multiple files. It makes sense to use them if you have a big class, which is hard to handle and read for a typical developer, to separate that class definition in separate files and to put in each file a logically separated section of code (for instance all public methods and proprieties in one file, private in other, db handling code in third and so on..)\nNo you don't have the same syntactical element in Python.","Q_Score":8,"Tags":"c#,python,oop,programming-languages","A_Id":295735,"CreationDate":"2008-11-17T14:24:00.000","Title":"What is a partial class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to remove two files from a folder at the conclusion of my script. Do I need to create a function responsible for removing these two specific files? I would like to know in some detail how to use os.remove (if that is what I should use) properly. These two files will always be discarded at the conclusion of my script (which packages a series of files together in a zip format). Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":296490,"Users Score":0,"Answer":"It is perfectly acceptable to have a 'cleanup()' function that you call at the end of your script, which will call 'os.remove()' on your files.","Q_Score":0,"Tags":"python,file","A_Id":296498,"CreationDate":"2008-11-17T18:56:00.000","Title":"How do I remove a specific number of files using python (version 2.5)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}.\nIs there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to be able to lookup details using an AJAX lookup based on the values contained in the variables passed in.","AnswerCount":16,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":309660,"Q_Id":298772,"Users Score":8,"Answer":"For a dictionary, you're best of encoding to JSON first. You can use simplejson.dumps() or if you want to convert from a data model in App Engine, you could use encode() from the GQLEncoder library.","Q_Score":276,"Tags":"javascript,python,django,google-app-engine,django-templates","A_Id":304627,"CreationDate":"2008-11-18T13:52:00.000","Title":"Django Template Variables and Javascript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am familiar with using the os.system to run from the command line. However, I would like to be able to run a jar file from inside of a specific folder, eg. my 'test' folder. This is because my jar (located in my 'test' folder) requires a file inside of my 'test' folder. So, how would I write a function in my script that does the following: c:\\test>java -jar run_this.jar required_parameter.ext ? I'm a python newbie so details are greatly appreciated. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8648,"Q_Id":299249,"Users Score":1,"Answer":"In general: Use os.chdir to change the directory of the parent process, then os.system to run the jar file. If you need to keep Python's working directory stable, you need to chdir back to original working directory - you need to record that with os.getcwd().\nOn Unix: Create a child process with os.fork explicitly. In the parent, wait for the child with os.waitpid. In the child, use os.chdir, then os.exec to run java.","Q_Score":5,"Tags":"python","A_Id":299262,"CreationDate":"2008-11-18T16:22:00.000","Title":"How can I get my python (version 2.5) script to run a jar file inside a folder instead of from command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","AnswerCount":16,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":28130,"Q_Id":299704,"Users Score":0,"Answer":"Eric4 IDE also has a great built-in debugger.","Q_Score":53,"Tags":"python,debugging","A_Id":2537067,"CreationDate":"2008-11-18T18:39:00.000","Title":"What are good ways to make my Python code run first time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","AnswerCount":16,"Available Count":6,"Score":0.049958375,"is_accepted":false,"ViewCount":28130,"Q_Id":299704,"Users Score":4,"Answer":"The PyDev plugin for eclipse is my tool of choice. It recognizes simple syntax mistakes and indentation errors and underlines the error with a red line. It has a powerful debugger and even has a plugin called PyLint which warns you about dangerous code.\nEdit:\nIt also has a user friendly stack trace on runtime errors, partial auto complete and some other nifty features.\nEdit again:\nI didn't notice that pydev was mentioned in the top post. I hope I brought something else to the table.","Q_Score":53,"Tags":"python,debugging","A_Id":300397,"CreationDate":"2008-11-18T18:39:00.000","Title":"What are good ways to make my Python code run first time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","AnswerCount":16,"Available Count":6,"Score":0.0624187467,"is_accepted":false,"ViewCount":28130,"Q_Id":299704,"Users Score":5,"Answer":"Using assert statement liberally.","Q_Score":53,"Tags":"python,debugging","A_Id":299732,"CreationDate":"2008-11-18T18:39:00.000","Title":"What are good ways to make my Python code run first time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","AnswerCount":16,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":28130,"Q_Id":299704,"Users Score":7,"Answer":"Test early and test often.\nThis doesn't necessarily mean to jump into the test driven design pool head first (though that's not such a bad idea). It just means, test your objects and methods as soon as you have something that works. Don't wait until you have a huge pile of code before doing testing. \nInvest some time in learning a testing framework. If it's trivial for you to type in a test case you'll more likely do it. If you don't have any sort of framework testing can be a pain so you'll avoid it. So, establish some good habits early on and you'll have fewer problems down the road.","Q_Score":53,"Tags":"python,debugging","A_Id":299727,"CreationDate":"2008-11-18T18:39:00.000","Title":"What are good ways to make my Python code run first time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","AnswerCount":16,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":28130,"Q_Id":299704,"Users Score":15,"Answer":"All the really cool stuff is easily demonstrated in the interactive interpreter.  I think this might be the \"gold standard\" for good design:\nCan you exercise your class interactively?\nIf you can do stuff interactively, then you can write unittests and doctests with confidence that it's testable, simple, reliable.\nAnd, more important, you can explore it interactively.  There's nothing better than the instant gratification that comes from typing code and seeing exactly what happens.\nThe compiled language habits (write a bunch of stuff, debug a bunch of stuff, test a bunch of stuff) can be left behind.  Instead, you can write a little bit of stuff, explore it, write a formal test and then attach your little bit of stuff to your growing final project.\nYou still do overall design.  But you don't squander time writing code that may or may not work.  In Python you write code that works.  If you're not sure, you play with it interactively until you're sure.  Then you write code that works.","Q_Score":53,"Tags":"python,debugging","A_Id":299753,"CreationDate":"2008-11-18T18:39:00.000","Title":"What are good ways to make my Python code run first time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","AnswerCount":16,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":28130,"Q_Id":299704,"Users Score":10,"Answer":"I am new to python, and have been trying several different debuggers. Here are the options I've come across so far:\n\nEclipse with Pydev - If you're already using eclipse, this is probably the way to go. The debugger works well, and is pretty featureful.\nKomodo IDE - A light-weight python IDE. Basically a text editor + a debugger. It was really easy to figure out and be productive with immediately.\nWinPDB - Trying this one next. Looks very featureful, and I get to use whichever editor I choose.\nPDB - Haven't tried yet since I've read about how WinPDB is a better alternative.\nIpython with %run command - I've used IPython, but not as a debugger like this. I need to try this out. (Thanks for the tip, EOL)\nEric IDE - Also on the list to try.\nOld-school print, assert statements - Simple, useful, but not a full solution.\n\nMemory debugging - To debug memory problems, I've come across a few tools:\n\nobjgraph - Will generate png's of reference graphs. Neat. There's other functionality as well, like: import objgraph;print(objgraph.show_most_common_types(limit=10)) will print the top 10 most common types in memory.\ngc module - Interact directly with the garbage collector.\nheapy - Heap analyzer. For example: from guppy import hpy; hp = hpy(); print(hp.heap()) will print the most common types, their memory usage, etc.\n\nThis is a very incomplete list, but hopefully it's a good start.","Q_Score":53,"Tags":"python,debugging","A_Id":4643720,"CreationDate":"2008-11-18T18:39:00.000","Title":"What are good ways to make my Python code run first time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been trying to build a simple prototype application in Django, and am reaching the point of giving up, sadly, as it's just too complicated (I know it would be worth it in the long-run, but I really just don't have enough time available -- I need something up and running in a few days). So, I'm now thinking of going with PHP instead, as it's the method for creating dynamic web content I'm most familiar with, and I know I can get something working quickly.\nMy application, while simple, is probably going to be doing some reasonably complex AI stuff, and it may be that libraries don't exist for what I need in PHP. So I'm wondering how easy \/ possible it is for a PHP script to \"call\" a Java program or Python script or a program or script in another language. It's not entirely clear to me what exactly I mean by \"call\" in this context, but I guess I probably mean that ideally I'd like to define a function in, let's say Java, and then be able to call it from PHP. If that's not possible, then I guess my best bet (assuming I do go with PHP) will be to pass control directly to the external program explicitly through a POST or GET to a CGI program or similar.\nFeel free to convince me I should stick with Django, although I'm really at the point where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex...\nAlternatively, anyone who can offer any advice on linking PHP and other languages, that'll be grateful received.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1939,"Q_Id":299913,"Users Score":4,"Answer":"\"where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex\"  \nCommon problem.\nRoot cause: Too much programming.\nSolution.  Do less programming.  Seriously.\nDefine the Django model.  Use the default admin pages to see if it's right.  Fix the model.  Regenerate the database.  Look at the default admin pages.  Repeat until the default admin pages work correctly and simply.\nOnce it's right in the default admin pages, you have a model that works.  It's testable.  And the automatic stuff is hooked up correctly.  Choices are defined correctly.  Computations are in the model mmethods.  Queries work.  Now you can start working on other presentations of the data.\nDjango generally starts (and ends) with the model.  The forms, view and templates are derived from the model.","Q_Score":3,"Tags":"java,php,python,dynamic-linking","A_Id":300035,"CreationDate":"2008-11-18T19:51:00.000","Title":"Calling Java (or python or perl) from a PHP script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been able to zip the contents of my folder. But I would like the zipped file to remain in the folder that was just compressed. For example, I've zipped a folder called test in my C: drive. But I would like my \"test.zip\" file to be contained in C:\\test. How can I do this? Thanks in advance.\nclarification of question with code example:\nSomeone kindly pointed out that my question is confusing, but for a python newbie a lot of things are confusing :) - my advance apologies if this question is too basic or the answer is obvious. I don't know how I can ensure that the resulting zip file is inside the folder that has been zipped. In other words, I would like the zip process to take place in 'basedir.' That way the user does not waste time searching for it somewhere on the C drive.\n\n    def zip_folder(basedir, zip_file):\n        z = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED)\n        for dirpath, dirnames, filenames in os.walk(basedir):\n        print \"zipping files:\"\n        for fn in filenames:\n        print fn\n        absfn = os.path.join(dirpath, fn)\n        z.write(absfn)\n        z.close","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":306811,"Users Score":2,"Answer":"Whatever you pass as zip_file to your function will be the file that the ZipFile object will write to. So if you pass it a full path, then it will be put there. If you pass it just a filename, then it will be written to that filename under the current working path. It sounds like you just need to make sure that zip_file is an absolute path.","Q_Score":1,"Tags":"python,file,zip","A_Id":307091,"CreationDate":"2008-11-20T20:47:00.000","Title":"With Python, how can I ensure that compression of a folder takes place within a particular folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a way to periodically send some data over all clients connected to a TCP port. I am looking at twisted python and I am aware of reactor.callLater. But how do I use it to send some data to all connected clients periodically ? The data sending logic is in Protocol class and it is instantiated by the reactor as needed. I don't know how to tie it from reactor to all protocol instances...","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":8021,"Q_Id":315716,"Users Score":3,"Answer":"I'd imagine the easiest way to do that is to manage a list of clients in the protocol with connectionMade and connectionLost in the client and then use a LoopingCall to ask each client to send data.\nThat feels a little invasive, but I don't think you'd want to do it without the protocol having some control over the transmission\/reception.  Of course, I'd have to see your code to really know how it'd fit in well.  Got a github link?  :)","Q_Score":24,"Tags":"python,tcp,twisted,protocols","A_Id":315855,"CreationDate":"2008-11-24T22:21:00.000","Title":"Running a function periodically in twisted protocol","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"using jython\nI have a situation where emails come in with different attachments. Certain file types I process others I ignore and dont write to file.\nI am caught in a rather nasty situation, because sometimes people send an email as an attachment, and that attached email has legal attachments. \nWhat I want to do is skip that attached email and all its attachments.\nusing python\/jythons std email lib how can i do this?\n\nto make it clearer\nI need to parse an email (named ROOT email), I want to get the attachments from this email using jython.\nNext certain attachments are supported ie .pdf .doc etc\nnow it just so happens that, the clients send an email (ROOT email) with another email message (CHILD email) as an attachment, and in CHILD email it has .pdf attachments and such like.\nWhat I need is: to get rid of any CHILD emails attached to the ROOT email AND the CHILD emails attachments. What happens is I walk over the whole email and it just parses every attachment, BOTH ROOT attachments and CHILD attachments as if they were ROOT attachments.\nI cannot have this. I am only interested in ROOT attachements that are legal ie .pdf .doc. xls .rtf .tif .tiff\nThat should do for now, I have to run to catch a bus!\nthanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":978,"Q_Id":319896,"Users Score":0,"Answer":"Have you tried the get_payload( [i[, decode]]) method? Unlike walk it is not documented to  recursively open attachments.","Q_Score":3,"Tags":"python,email,jython,attachment","A_Id":320285,"CreationDate":"2008-11-26T06:20:00.000","Title":"How do I skip processing the attachments of an email which is an attachment of a different email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is in Python, and I'm using ElementTree (not that that really matters here since I'm just dealing with XML in strings at this level).","AnswerCount":10,"Available Count":2,"Score":0.0599281035,"is_accepted":false,"ViewCount":17177,"Q_Id":321795,"Users Score":3,"Answer":"Why are you examining the XML data at all?\nThe way to test object serialization is to create an instance of the object, serialize it, deserialize it into a new object, and compare the two objects.  When you make a change that breaks serialization or deserialization, this test will fail.\nThe only thing checking the XML data is going to find for you is if your serializer is emitting a superset of what the deserializer requires, and the deserializer silently ignores stuff it doesn't expect.\nOf course, if something else is going to be consuming the serialized data, that's another matter.  But in that case, you ought to be thinking about establishing a schema for the XML and validating it.","Q_Score":41,"Tags":"python,xml,elementtree","A_Id":322088,"CreationDate":"2008-11-26T19:09:00.000","Title":"Comparing XML in a unit test in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is in Python, and I'm using ElementTree (not that that really matters here since I'm just dealing with XML in strings at this level).","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":17177,"Q_Id":321795,"Users Score":0,"Answer":"The Java component dbUnit does a lot of XML comparisons, so you might find it useful to look at their approach (especially to find any gotchas that they may have already addressed).","Q_Score":41,"Tags":"python,xml,elementtree","A_Id":322600,"CreationDate":"2008-11-26T19:09:00.000","Title":"Comparing XML in a unit test in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to be able to submit a form in an HTML source (string). In other words I need at least the ability to generate POST parameters from a string containing HTML source of the form. This is needed in unit tests for a Django project. I would like a solution that possibly;\n\nUses only standard Python library and Django.\nAllows parameter generation from a specific form if there is more than one form present.\nAllows me to change the values before submission.\n\nA solution that returns a (Django) form instance from a given form class is best. Because it would allow me to use validation. Ideally it would consume the source (which is a string), a form class, and optionally a form name and return the instance as it was before rendering.\nNOTE: I am aware this is not an easy task, and probably the gains would hardly justify the effort needed. But I am just curious about how this can be done, in a practical and reliable way. If possible.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":941,"Q_Id":343622,"Users Score":2,"Answer":"It is simple... and hard at the same time.\nDisclaimer: I don't know much about Python and nothing at all about Django... So I give general, language agnostic advices...\nIf one of the above advices doesn't work for you, you might want to do it manually:\n\nLoad the page with an HTML parser, list the forms.\nIf the method attribute is POST (case insensitive), get the action attribute to get the URL of the request (can be relative).\nIn the form, get all input and select tags. The name (or id if no name) attributes are the keys of the request parameters. The value attributes (empty if absent) are the corresponding values.\nFor select, the value is the one of the selected option or the displayed text is no value attribute.\n\nThese names and values must be URL encoded in GET requests, but not in POST ones.\nHTH.","Q_Score":0,"Tags":"python,django,testing,parsing,form-submit","A_Id":343794,"CreationDate":"2008-12-05T12:02:00.000","Title":"How do I submit a form given only the HTML source?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using urllib2 to read in a page. I need to do a quick regex on the source and pull out a few variables but urllib2 presents as a file object rather than a string.\nI'm new to python so I'm struggling to see how I use a file object to do this. Is there a quick way to convert this into a string?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48579,"Q_Id":346230,"Users Score":77,"Answer":"You can use Python in interactive mode to search for solutions.\nif f is your object, you can enter dir(f) to see all methods and attributes. There's one called read. Enter help(f.read) and it tells you that f.read() is the way to retrieve a string from an file object.","Q_Score":31,"Tags":"python,file,urllib2","A_Id":346237,"CreationDate":"2008-12-06T12:41:00.000","Title":"Read file object as string in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As the title suggests. I want to be able to change the label of a single field in the admin application. I'm aware of the Form.field attribute, but how do I get my Model or ModelAdmin to pass along that information?","AnswerCount":6,"Available Count":1,"Score":0.1651404129,"is_accepted":false,"ViewCount":67765,"Q_Id":365082,"Users Score":5,"Answer":"Building on Javier's answer; if you need one label in forms (on the front-end) and another label on admin it is best to set internal (admin) one in the model and overwrite it on forms. Admin will of course use the label in the model field automatically.","Q_Score":64,"Tags":"python,python-3.x,django,django-forms,django-admin","A_Id":365431,"CreationDate":"2008-12-13T10:30:00.000","Title":"Can you change a field label in the Django Admin application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a ftp system setup to monitor\/download from remote ftp servers that are not under our control. The script connects to the remote ftp, and grabs the file names of files on the server, we then check to see if its something that has already been downloaded. If it hasn't been downloaded then we download the file and add it to the list.\nWe recently ran into an issue, where someone on the remote ftp side, will copy in a massive single file(>1GB) then the script will wake up see a new file and begin downloading the file that is being copied in.\nWhat is the best way to check this? I was thinking of grabbing the file size waiting a few seconds checking the file size again and see if it has increased, if it hasn't then we download it. But since time is of the concern, we can't wait a few seconds for every single file set and see if it's file size has increased. \nWhat would be the best way to go about this, currently everything is done via pythons ftplib, how can we do this aside from using the aforementioned method.\nYet again let me reiterate this, we have 0 control over the remote ftp sites.\nThanks.\nUPDATE1:\nI was thinking what if i tried to rename it... since we have full permissions on the ftp, if the file upload is in progress would the rename command fail?\nWe don't have any real options here... do we?\nUPDATE2:\nWell here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts.\nE.g. If i transfer a 200mb file to the ftp server. While the transfer is active if i connect to the ftp server and do a size while the upload is happening. It shows 200mb for the size. Even though the file is only like 10% complete.\nPermissions also seem to be randomly set the FTP Server that comes with IIS sets the permissions AFTER the file is finished copying. While some of the other older ftp servers set it as soon as you send the file.\n:'(","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1585,"Q_Id":375620,"Users Score":0,"Answer":"You can't know when the OS copy is done.  It could slow down or wait.\nFor absolute certainty, you really need two files.\n\nThe massive file.\nAnd a tiny trigger file.\n\nThey can mess with the massive file all they want.  But when they touch the trigger file, you're downloading both.\n\nIf you can't get a trigger, you have to balance the time required to poll vs. the time required to download.\nDo this.\n\nGet a listing.  Check timestamps.\nCheck sizes vs. previous size of file.  If size isn't even close, it's being copied right now.  Wait; loop on this step until size is close to previous size.\nWhile you're not done:\na. Get the file.\nb. Get a listing AGAIN.  Check the size of the new listing, previous listing and your file.  If they agree: you're done.  If they don't agree: file changed while you were downloading; you're not done.","Q_Score":4,"Tags":"python,ftp,ftplib","A_Id":375650,"CreationDate":"2008-12-17T18:54:00.000","Title":"Prevent ftplib from Downloading a File in Progress?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We have a ftp system setup to monitor\/download from remote ftp servers that are not under our control. The script connects to the remote ftp, and grabs the file names of files on the server, we then check to see if its something that has already been downloaded. If it hasn't been downloaded then we download the file and add it to the list.\nWe recently ran into an issue, where someone on the remote ftp side, will copy in a massive single file(>1GB) then the script will wake up see a new file and begin downloading the file that is being copied in.\nWhat is the best way to check this? I was thinking of grabbing the file size waiting a few seconds checking the file size again and see if it has increased, if it hasn't then we download it. But since time is of the concern, we can't wait a few seconds for every single file set and see if it's file size has increased. \nWhat would be the best way to go about this, currently everything is done via pythons ftplib, how can we do this aside from using the aforementioned method.\nYet again let me reiterate this, we have 0 control over the remote ftp sites.\nThanks.\nUPDATE1:\nI was thinking what if i tried to rename it... since we have full permissions on the ftp, if the file upload is in progress would the rename command fail?\nWe don't have any real options here... do we?\nUPDATE2:\nWell here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts.\nE.g. If i transfer a 200mb file to the ftp server. While the transfer is active if i connect to the ftp server and do a size while the upload is happening. It shows 200mb for the size. Even though the file is only like 10% complete.\nPermissions also seem to be randomly set the FTP Server that comes with IIS sets the permissions AFTER the file is finished copying. While some of the other older ftp servers set it as soon as you send the file.\n:'(","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1585,"Q_Id":375620,"Users Score":5,"Answer":"\u201cDamn the torpedoes! Full speed ahead!\u201d\nJust download the file. If it is a large file then after the download completes wait as long as is reasonable for your scenario and continue the download from the point it stopped. Repeat until there is no more stuff to download.","Q_Score":4,"Tags":"python,ftp,ftplib","A_Id":375800,"CreationDate":"2008-12-17T18:54:00.000","Title":"Prevent ftplib from Downloading a File in Progress?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We have a ftp system setup to monitor\/download from remote ftp servers that are not under our control. The script connects to the remote ftp, and grabs the file names of files on the server, we then check to see if its something that has already been downloaded. If it hasn't been downloaded then we download the file and add it to the list.\nWe recently ran into an issue, where someone on the remote ftp side, will copy in a massive single file(>1GB) then the script will wake up see a new file and begin downloading the file that is being copied in.\nWhat is the best way to check this? I was thinking of grabbing the file size waiting a few seconds checking the file size again and see if it has increased, if it hasn't then we download it. But since time is of the concern, we can't wait a few seconds for every single file set and see if it's file size has increased. \nWhat would be the best way to go about this, currently everything is done via pythons ftplib, how can we do this aside from using the aforementioned method.\nYet again let me reiterate this, we have 0 control over the remote ftp sites.\nThanks.\nUPDATE1:\nI was thinking what if i tried to rename it... since we have full permissions on the ftp, if the file upload is in progress would the rename command fail?\nWe don't have any real options here... do we?\nUPDATE2:\nWell here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts.\nE.g. If i transfer a 200mb file to the ftp server. While the transfer is active if i connect to the ftp server and do a size while the upload is happening. It shows 200mb for the size. Even though the file is only like 10% complete.\nPermissions also seem to be randomly set the FTP Server that comes with IIS sets the permissions AFTER the file is finished copying. While some of the other older ftp servers set it as soon as you send the file.\n:'(","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1585,"Q_Id":375620,"Users Score":0,"Answer":"If you are dealing with multiple files, you could get the list of all the sizes at once, wait ten seconds, and see which are the same.  Whichever are still the same should be safe to download.","Q_Score":4,"Tags":"python,ftp,ftplib","A_Id":375716,"CreationDate":"2008-12-17T18:54:00.000","Title":"Prevent ftplib from Downloading a File in Progress?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"We have a ftp system setup to monitor\/download from remote ftp servers that are not under our control. The script connects to the remote ftp, and grabs the file names of files on the server, we then check to see if its something that has already been downloaded. If it hasn't been downloaded then we download the file and add it to the list.\nWe recently ran into an issue, where someone on the remote ftp side, will copy in a massive single file(>1GB) then the script will wake up see a new file and begin downloading the file that is being copied in.\nWhat is the best way to check this? I was thinking of grabbing the file size waiting a few seconds checking the file size again and see if it has increased, if it hasn't then we download it. But since time is of the concern, we can't wait a few seconds for every single file set and see if it's file size has increased. \nWhat would be the best way to go about this, currently everything is done via pythons ftplib, how can we do this aside from using the aforementioned method.\nYet again let me reiterate this, we have 0 control over the remote ftp sites.\nThanks.\nUPDATE1:\nI was thinking what if i tried to rename it... since we have full permissions on the ftp, if the file upload is in progress would the rename command fail?\nWe don't have any real options here... do we?\nUPDATE2:\nWell here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts.\nE.g. If i transfer a 200mb file to the ftp server. While the transfer is active if i connect to the ftp server and do a size while the upload is happening. It shows 200mb for the size. Even though the file is only like 10% complete.\nPermissions also seem to be randomly set the FTP Server that comes with IIS sets the permissions AFTER the file is finished copying. While some of the other older ftp servers set it as soon as you send the file.\n:'(","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1585,"Q_Id":375620,"Users Score":0,"Answer":"As you say you have 0 control over the servers and can't make your clients post trigger files as suggested by S. Lott, you must deal with the imperfect solution and risk incomplete file transmission, perhaps by waiting for a while and compare file sizes before and after.\nYou can try to rename as you suggested, but as you have 0 control you can't be sure that the ftp-server-administrator (or their successor) doesn't change platforms or ftp servers or restricts your permissions.\nSorry.","Q_Score":4,"Tags":"python,ftp,ftplib","A_Id":375705,"CreationDate":"2008-12-17T18:54:00.000","Title":"Prevent ftplib from Downloading a File in Progress?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a block of code that basically intializes several classes, but they are placed in a sequential order, as later ones reference early ones.\nFor some reason the last one initializes before the first one...it seems to me there is some sort of threading going on. What I need to know is how can I stop it from doing this? \nIs there some way to make a class init do something similar to sending a return value?\nOr maybe I could use the class in an if statement of some sort to check if the class has already been initialized?\nI'm a bit new to Python and am migrating from C, so I'm still getting used to the little differences like naming conventions.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":377362,"Users Score":0,"Answer":"Spaces vs. Tabs issue...ugh. >.>\nWell, atleast it works now. I admit that I kind of miss the braces from C instead of forced-indentation. It's quite handy as a prototyping language though. Maybe I'll grow to love it more when I get a better grasp of it.","Q_Score":1,"Tags":"python","A_Id":377418,"CreationDate":"2008-12-18T09:41:00.000","Title":"Code not waiting for class initialization!","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a block of code that basically intializes several classes, but they are placed in a sequential order, as later ones reference early ones.\nFor some reason the last one initializes before the first one...it seems to me there is some sort of threading going on. What I need to know is how can I stop it from doing this? \nIs there some way to make a class init do something similar to sending a return value?\nOr maybe I could use the class in an if statement of some sort to check if the class has already been initialized?\nI'm a bit new to Python and am migrating from C, so I'm still getting used to the little differences like naming conventions.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":377362,"Users Score":0,"Answer":"Python upto 3.0 has a global lock, so everything is running in a single thread and in sequence.\nMy guess is that some side effect initializes the last class from a different place than you expect. Throw an exception in __init__ of that last class to see where it gets called.","Q_Score":1,"Tags":"python","A_Id":377382,"CreationDate":"2008-12-18T09:41:00.000","Title":"Code not waiting for class initialization!","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated.\nWho has done it?  How?\nEDIT:  The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc.  I am interested in MochiKit, demand CherryPy, but I don't want any other template engine than StringTemplate (architecture is critical--I don't want another broken\/bad template engine).\nTherefore, it would be acceptable to answer this question by addressing how to integrate StringTemplate with TurboGears.\nIt may also be acceptable to answer this question by addressing how to use CherryPy and StringTemplate in the Google App Engine.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1241,"Q_Id":379338,"Users Score":4,"Answer":"Based on the tutorials for both, it looks pretty straightforward:\n\nimport stringtemplate\nimport cherrypy\n\nclass HelloWorld(object):\n    def index(self):\n        hello = stringtemplate.StringTemplate(\"Hello, $name$\")\n        hello[\"name\"] = \"World\"\n        return str(hello)\n    index.exposed = True\n\ncherrypy.quickstart(HelloWorld())\n\nYou'll probably want to have the CherryPy functions find the StringTemplate's in some location on disk instead, but the general idea will be like this.\nDjango is conceptually similar:  url's are mapped to python functions, and the python functions generally build up a context dictionary, render a template with that context object, and return the result.","Q_Score":2,"Tags":"python,cherrypy,stringtemplate","A_Id":467736,"CreationDate":"2008-12-18T21:23:00.000","Title":"How to integrate the StringTemplate engine into the CherryPy web server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated.\nWho has done it?  How?\nEDIT:  The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc.  I am interested in MochiKit, demand CherryPy, but I don't want any other template engine than StringTemplate (architecture is critical--I don't want another broken\/bad template engine).\nTherefore, it would be acceptable to answer this question by addressing how to integrate StringTemplate with TurboGears.\nIt may also be acceptable to answer this question by addressing how to use CherryPy and StringTemplate in the Google App Engine.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1241,"Q_Id":379338,"Users Score":0,"Answer":"Rob,\nThere's reason behind people's selection of tools. StringTemplate is not terribly popular for Python, there are templating engines that are much better supported and with a much wider audience. If you don't like Kid, there's also Django's templating, Jinja, Cheetah and others. Perhaps you can find in one of them the features you like so much in StringTemplate and live happily ever after.","Q_Score":2,"Tags":"python,cherrypy,stringtemplate","A_Id":463042,"CreationDate":"2008-12-18T21:23:00.000","Title":"How to integrate the StringTemplate engine into the CherryPy web server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking into writing a wxWidget that displays a graphical node network, and therefore does a lot of drawing operations.  I know that using Python to do it is going to be slower, but I'd rather get it working and port it later when its functional.  Ideally, if the performance hit isn't too great, I'd prefer to keep the codebase in Python for easy updates.\nWhat I'm wondering is how much slower should I expect things to go?  I realize this is vague and open ended, but I just need a sense of what to expect.  Will drawing 500 circles bog down?  Will it be noticeable at all? What are your experiences?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1255,"Q_Id":379442,"Users Score":1,"Answer":"For drawing, people have suggested PyGame. I like PyGame, its easy to work with and works well. Other choices would be Pyglet, or using PyOpenGL (you can most likely draw to a wx widget too, though I've never done it).\nPersonally, I'd do it in Python using whatever library I'm most familiar with (in my case, I'd use pygtk and cairo) and worry about performance only when it becomes a problem - then profile and optimize the bottleneck, if its Python code thats slow, I'll know which bits to run in C instead.","Q_Score":6,"Tags":"c++,python,performance,drawing,wxpython","A_Id":380558,"CreationDate":"2008-12-18T21:52:00.000","Title":"How much slower is a wxWidget written in Python versus C++?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to traditional OO.\nThe general notion that I got is that prototype based OO is basically programming with objects but no standard on how to use them whereas in normal OO there is a fixed predefined way to make and use objects.\nIn summary, what is the good, the bad and the ugly parts of such approach?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":4736,"Q_Id":385403,"Users Score":1,"Answer":"Classical inheritance is inherently flawed in terms of flexibility, in that we are saying \"this object is of this type and no other\". Some languages introduce multiple inheritance to alleviate this, but multiple inheritance has its own pitfalls, and so the benefits of pure composition over inheritance (which, in a statically typed language, is a runtime rather than a compile time mechanism) become clear. \nTaking the concept of composition to this \"pure\" level, we can eliminate classical inheritance altogether along with static typing. By composing objects at runtime and using them as blueprints (the prototypal approach), we need never concern ourselves with boxing objects too tightly through inheritance, nor burden ourselves with the issues inherent in multiple inheritance approaches.\nSo prototypal means much more flexible development of modules.\nOf course, it's quite another thing to say it's EASY to develop without static typing. IMO, it is not.","Q_Score":10,"Tags":"javascript,python,language-agnostic,lua,oop","A_Id":3958261,"CreationDate":"2008-12-22T02:25:00.000","Title":"Prototype based object orientation. The good, the bad and the ugly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to traditional OO.\nThe general notion that I got is that prototype based OO is basically programming with objects but no standard on how to use them whereas in normal OO there is a fixed predefined way to make and use objects.\nIn summary, what is the good, the bad and the ugly parts of such approach?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4736,"Q_Id":385403,"Users Score":0,"Answer":"Okay, first of all, the prototype model isn't all that different in reality; Smalltalk uses a similar sort of scheme; the class is an object with the classes methods.\nLooked at from the class POV, a class is really the equivalence class of objects with the same data, and all the same methods; you can look at adding a method to a prototype as creating a new subclass.\nThe implementation is simple, but makes it very difficult to do effective typechecking.","Q_Score":10,"Tags":"javascript,python,language-agnostic,lua,oop","A_Id":385417,"CreationDate":"2008-12-22T02:25:00.000","Title":"Prototype based object orientation. The good, the bad and the ugly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. \nI am a bit stuck on how to get started. Does anyone have any tips for me?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4847,"Q_Id":387606,"Users Score":0,"Answer":"To start with, treat the barcode input as plain old text.   \nIt has been quite a while since I worked with barcode scanners, but I doubt they have changed that much, the older ones used to just piggyback on the keyboard input, so from a programming perspective, the net result was a stream of characters in the keyboard buffer, either typed or scanned made no difference. \nIf the device you are targeting differs from that, you will need to write something to deal with that before you get to the database query.   \nIf you have one of the devices to play with, plug it in, start notepad, start scanning some barcodes and see what happens.","Q_Score":1,"Tags":"python,sql,user-input","A_Id":387800,"CreationDate":"2008-12-22T22:37:00.000","Title":"Using user input to find information in a Mysql database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. \nI am a bit stuck on how to get started. Does anyone have any tips for me?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":4847,"Q_Id":387606,"Users Score":1,"Answer":"A barcode is simply a graphical representation of a series of characters (alphanumeric)\nSo if you have a method for users to enter this code (a barcode scanner), then its just an issue of querying the mysql database for the character string.","Q_Score":1,"Tags":"python,sql,user-input","A_Id":387622,"CreationDate":"2008-12-22T22:37:00.000","Title":"Using user input to find information in a Mysql database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. \nI am a bit stuck on how to get started. Does anyone have any tips for me?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4847,"Q_Id":387606,"Users Score":0,"Answer":"That is a very ambiguous question. What you want can be done in many ways depending on what you actually want to do.\nHow are your users going to enter the bar code? Are they going to use a bar code scanner? Are they entering the bar code numbers manually? \nIs this going to run on a desktop\/laptop computer or is it going to run on a handheld device? \nIs the bar code scanner storing the bar codes for later retrieval or is it sending them directly to the computer. Will it send them through a USB cable or wireless?","Q_Score":1,"Tags":"python,sql,user-input","A_Id":387694,"CreationDate":"2008-12-22T22:37:00.000","Title":"Using user input to find information in a Mysql database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am using python to read a currency value from excel. The returned from the range.Value method is a tuple that I don't know how to parse.\nFor example, the cell appears as $548,982, but in python the value is returned as (1, 1194857614).\nHow can I get the numerical amount from excel or how can I convert this tuple value into the numerical value?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":586,"Q_Id":390263,"Users Score":0,"Answer":"I tried this with Excel 2007 and VBA. It is giving correct value.\n1) Try pasting this value in a new excel workbook\n2) Press Alt + F11. Gets you to VBA Editor.\n3) Press Ctrl + G. Gets you to immediate window.\n4) In the immediate window, type  ?cells(\"a1\").Value \nhere \"a1\" is the cell where you have pasted the value.\nI am doubting that the cell has some value or character due to which it is interpreted this way.\nPost your observations here.","Q_Score":1,"Tags":"python,excel,pywin32","A_Id":390304,"CreationDate":"2008-12-23T22:37:00.000","Title":"Interpreting Excel Currency Values","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to write a program in Python that will calculate the addition of the harmonic series. i.e. 1 + 1\/2 +1\/3 +1\/4...","AnswerCount":11,"Available Count":2,"Score":0.0906594778,"is_accepted":false,"ViewCount":22477,"Q_Id":404346,"Users Score":5,"Answer":"Just a footnote on the other answers that used floating point; starting with the largest divisor and iterating downward (toward the reciprocals with largest value) will put off accumulated round-off error as much as possible.","Q_Score":8,"Tags":"python,math","A_Id":404587,"CreationDate":"2009-01-01T00:55:00.000","Title":"Python program to calculate harmonic series","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to write a program in Python that will calculate the addition of the harmonic series. i.e. 1 + 1\/2 +1\/3 +1\/4...","AnswerCount":11,"Available Count":2,"Score":0.072599319,"is_accepted":false,"ViewCount":22477,"Q_Id":404346,"Users Score":4,"Answer":"The harmonic series diverges, i.e. its sum is infinity..\nedit: Unless you want partial sums, but you weren't really clear about that.","Q_Score":8,"Tags":"python,math","A_Id":404364,"CreationDate":"2009-01-01T00:55:00.000","Title":"Python program to calculate harmonic series","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know what versions of Python and wxPython correspond to each version of OSX.  I'm interested to know exactly how far back some of my apps will remain compatible on a mac before having to install newer versions of Python and wxPython.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":412,"Q_Id":409677,"Users Score":3,"Answer":"Tiger shipped with Python 2.3.5 and wxPython 2.5.3, Leopard ships with python 2.5.1 and wxPython 2.8.4.\nwxPython was not shipped with previous versions.\n\nOSX Lion has 2.7.1","Q_Score":0,"Tags":"python,macos,wxpython,compatibility","A_Id":409702,"CreationDate":"2009-01-03T19:37:00.000","Title":"What versions of Python and wxPython correspond to each version of OSX?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I create or use a global variable in a function?\nIf I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?","AnswerCount":24,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3715726,"Q_Id":423379,"Users Score":26,"Answer":"You're not actually storing the global in a local variable, just creating a local reference to the same object that your original global reference refers to. Remember that pretty much everything in Python is a name referring to an object, and nothing gets copied in usual operation.\nIf you didn't have to explicitly specify when an identifier was to refer to a predefined global, then you'd presumably have to explicitly specify when an identifier is a new local variable instead (for example, with something like the 'var' command seen in JavaScript). Since local variables are more common than global variables in any serious and non-trivial system, Python's system makes more sense in most cases.\nYou could have a language which attempted to guess, using a global variable if it existed or creating a local variable if it didn't. However, that would be very error-prone. For example, importing another module could inadvertently introduce a global variable by that name, changing the behaviour of your program.","Q_Score":3667,"Tags":"python,global-variables,scope","A_Id":427818,"CreationDate":"2009-01-08T05:45:00.000","Title":"Using global variables in a function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I create or use a global variable in a function?\nIf I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?","AnswerCount":24,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3715726,"Q_Id":423379,"Users Score":70,"Answer":"If you want to refer to a global variable in a function, you can use the global keyword to declare which variables are global. You don't have to use it in all cases (as someone here incorrectly claims) - if the name referenced in an expression cannot be found in local scope or scopes in the functions in which this function is defined, it is looked up among global variables.\nHowever, if you assign to a new variable not declared as global in the function, it is implicitly declared as local, and it can overshadow any existing global variable with the same name.\nAlso, global variables are useful, contrary to some OOP zealots who claim otherwise - especially for smaller scripts, where OOP is overkill.","Q_Score":3667,"Tags":"python,global-variables,scope","A_Id":423641,"CreationDate":"2009-01-08T05:45:00.000","Title":"Using global variables in a function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know of an example where it is shown how to drag a button from one panel to another in wxPython?\nI have created a bitmap button in a panel, and I would like to be able to drag it to a different panel and drop I there. \nI haven't found any examples using buttons, just text and files.\nI am using the latest version of Python and wxPython.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1052,"Q_Id":425722,"Users Score":4,"Answer":"If you want to graphically represent the drag, one good way to do this is to create a borderless Frame that follows the mouse during a drag.  You remove the button from your source Frame, temporarily put it in this \"drag Frame\", and then, when the user drops, add it to your destination Frame.","Q_Score":1,"Tags":"python,drag-and-drop,wxpython","A_Id":425740,"CreationDate":"2009-01-08T20:17:00.000","Title":"Drag button between panels in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to poll a web service, in this case twitter's API, and I'm wondering what the conventional wisdom is on this topic. I'm not sure whether this is important, but I've always found feedback useful in the past.\nA couple scenarios I've come up with:\n\nThe querying process starts every X seconds, eg a cron job runs a python script\nA process continually loops and queries at each iteration, eg ... well, here is where I enter unfamiliar territory. Do I just run a python script that doesn't end?\n\nThanks for your advice.\nps - regarding the particulars of twitter: I know that it sends emails for following and direct messages, but sometimes one might want the flexibility of parsing @replies. In those cases, I believe polling is as good as it gets.\npps - twitter limits bots to 100 requests per 60 minutes. I don't know if this also limits web scraping or rss feed reading. Anyone know how easy or hard it is to be whitelisted?\nThanks again.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5380,"Q_Id":430226,"Users Score":0,"Answer":"You should have a page that is like a Ping or Heartbeat page. The you have another process that \"tickles\" or hits that page, usually you can do this in your Control Panel of your web host, or use a cron if you have a local access. Then this script can keep statistics of how often it has polled in a database or some data store and then you poll the service as often as you really need to, of course limiting it to whatever the providers limit is. You definitely don't want to (and certainly don't want to rely) on a python scrip that \"doesn't end.\" :)","Q_Score":5,"Tags":"python,twitter,polling","A_Id":430245,"CreationDate":"2009-01-10T00:10:00.000","Title":"Best way to poll a web service (eg, for a twitter app)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a sudoku solver program in Java (maybe Python).\nI'm just wondering how I should go about structuring this...\nDo I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class?\nDo I just create functions to calculate and just control all the numbers in there with something like an multi-D array?\nAnd actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object?\nThanks.","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":10048,"Q_Id":431996,"Users Score":1,"Answer":"The simplest way to do it is to represent the board by a 2D 9x9 array.  You'll want to have references to each row, column and 3x3 box as a separate object, so storing each cell in a String makes more sense (in Java) than using a primitive.  With a String you can keep references to the same object in multiple containers.","Q_Score":0,"Tags":"python,data-structures,sudoku","A_Id":432008,"CreationDate":"2009-01-10T23:57:00.000","Title":"Programming Design Help - How to Structure a Sudoku Solver program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a sudoku solver program in Java (maybe Python).\nI'm just wondering how I should go about structuring this...\nDo I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class?\nDo I just create functions to calculate and just control all the numbers in there with something like an multi-D array?\nAnd actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object?\nThanks.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":10048,"Q_Id":431996,"Users Score":0,"Answer":"Maybe a design that had a box per square, and another class to represent the puzzle itself that would have a collection of boxes, contain all the rules for box interactions, and control the overall game would be a good design.","Q_Score":0,"Tags":"python,data-structures,sudoku","A_Id":432001,"CreationDate":"2009-01-10T23:57:00.000","Title":"Programming Design Help - How to Structure a Sudoku Solver program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a sudoku solver program in Java (maybe Python).\nI'm just wondering how I should go about structuring this...\nDo I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class?\nDo I just create functions to calculate and just control all the numbers in there with something like an multi-D array?\nAnd actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object?\nThanks.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":10048,"Q_Id":431996,"Users Score":2,"Answer":"Well, I would use one class for the sudoku itself, with a 9 x 9 array and all the functionality to add numbers and detect errors in the pattern.\nAnother class will be used to solve the puzzle.","Q_Score":0,"Tags":"python,data-structures,sudoku","A_Id":432003,"CreationDate":"2009-01-10T23:57:00.000","Title":"Programming Design Help - How to Structure a Sudoku Solver program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a sudoku solver program in Java (maybe Python).\nI'm just wondering how I should go about structuring this...\nDo I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class?\nDo I just create functions to calculate and just control all the numbers in there with something like an multi-D array?\nAnd actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object?\nThanks.","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":10048,"Q_Id":431996,"Users Score":0,"Answer":"First, it looks like there are two kinds of cells.\n\nKnown calls; those with a fixed value, no choices.\nUnknown cells; those with a set of candidate values that reduces down to a single final value.\n\nSecond, there are several groups of cells.\n\nHorizontal rows and Vertical columns which must have one cell of each value.  That constraint is used to remove values from various cells in the row or column.\n3x3 blocks which must have one cell of each value. That constraint is used to remove values from various cells in the block.\n\nFinally, there's the overall grid.   This has several complementary views.\n\nIt's 81 cells.\nThe cells are also collected into a 3x3 grid of 3x3 blocks.\nThe cells are also collected into 9 columns.\nThe cells are also collected into 9 rows.\n\nAnd you have a solver strategy object.  \n\nEach Unknown cell it set to having set( range(1,10) ) as the candidate values.\nFor each row, column and 3x3 block (27 different collections):\na.  For each cell:\n\nIf it has  definite value (Known cells and Unknown cells implement this differently): remove that value from all other cells in this grouping.\n\n\nThe above must be iterated until no changes are found.\nAt this point, you either have it solved (all cells report a definite value), or, you have some cells with multiple values.  Now you have to engage in a sophisticated back-tracking solver to find a combination of the remaining values that \"works\".","Q_Score":0,"Tags":"python,data-structures,sudoku","A_Id":432052,"CreationDate":"2009-01-10T23:57:00.000","Title":"Programming Design Help - How to Structure a Sudoku Solver program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a sudoku solver program in Java (maybe Python).\nI'm just wondering how I should go about structuring this...\nDo I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class?\nDo I just create functions to calculate and just control all the numbers in there with something like an multi-D array?\nAnd actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object?\nThanks.","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":10048,"Q_Id":431996,"Users Score":12,"Answer":"Don't over-engineer it.  It's a 2-D array or maybe a Board class that represents a 2-D array at best.  Have functions that calculate a given row\/column and functions that let you access each square.  Additional methods can be used validate that each sub-3x3 and row\/column don't violate the required constraints.","Q_Score":0,"Tags":"python,data-structures,sudoku","A_Id":432000,"CreationDate":"2009-01-10T23:57:00.000","Title":"Programming Design Help - How to Structure a Sudoku Solver program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I want to start using virtualenv this year.  I like the no-site-packages option, that is nice.  However I was wondering how to install certain packages into each virtualenv.  For example, lets say I want to install django into each virtualenv... is this possible, and if so, how?  Does buildout address this?\n\nWell it's not so much django, more like the django applications... I dont mind installing a version of django into each virtualenv... i was just wondering if there was some intermediate option to 'no-site-packages'","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3218,"Q_Id":434407,"Users Score":0,"Answer":"The other option (one I've used) is to easy_install Django after you've created the virtual environment. This is easily scripted. The penalty you pay is waiting for Django installation in each of your virtual environments.\nI'm with Toby, though: Unless there's a compelling reason why you have to have a separate copy of Django in each virtual environment, you should just consider installing it in your main Python area, and allowing each virtual environment to use it from there.","Q_Score":2,"Tags":"python,virtualenv,buildout","A_Id":436427,"CreationDate":"2009-01-12T04:05:00.000","Title":"Installing certain packages using virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I want to start using virtualenv this year.  I like the no-site-packages option, that is nice.  However I was wondering how to install certain packages into each virtualenv.  For example, lets say I want to install django into each virtualenv... is this possible, and if so, how?  Does buildout address this?\n\nWell it's not so much django, more like the django applications... I dont mind installing a version of django into each virtualenv... i was just wondering if there was some intermediate option to 'no-site-packages'","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":3218,"Q_Id":434407,"Users Score":2,"Answer":"If you want django to be installed on EACH virtualenv, you might as well install it in the  site-packages directory? Just a thought.","Q_Score":2,"Tags":"python,virtualenv,buildout","A_Id":434445,"CreationDate":"2009-01-12T04:05:00.000","Title":"Installing certain packages using virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function?\nImporting __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names...\nIs there a pythonic way to do this?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":36370,"Q_Id":436497,"Users Score":23,"Answer":"This doesn't exactly answer your question, but I'm going to suggest that you move the function outside of the __init__.py file, and into another module inside that package. You can then easily import that function into your other module. If you want, you can have an import statement in the __init__.py file that will import that function (when the package is imported) as well.","Q_Score":62,"Tags":"python,module,package,python-import","A_Id":436511,"CreationDate":"2009-01-12T18:38:00.000","Title":"Python: import the containing package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function?\nImporting __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names...\nIs there a pythonic way to do this?","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":36370,"Q_Id":436497,"Users Score":5,"Answer":"If the package is named testmod and your init file is therefore testmod\/__init__.py and your module within the package is submod.py then from within submod.py file, you should just be able to say import testmod and use whatever you want that's defined in testmod.","Q_Score":62,"Tags":"python,module,package,python-import","A_Id":436607,"CreationDate":"2009-01-12T18:38:00.000","Title":"Python: import the containing package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function?\nImporting __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names...\nIs there a pythonic way to do this?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":36370,"Q_Id":436497,"Users Score":1,"Answer":"In Django, the file manage.py has from django.core.management import execute_manager, but execute_manager is not a module. It is a function within the __init__.py module of the management directory.","Q_Score":62,"Tags":"python,module,package,python-import","A_Id":708076,"CreationDate":"2009-01-12T18:38:00.000","Title":"Python: import the containing package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python-based app that can accept a few commands in a simple read-eval-print-loop. I'm using raw_input('> ') to get the input. On Unix-based systems, I also import readline to make things behave a little better. All this is working fine.\nThe problem is that there are asynchronous events coming in, and I'd like to print output as soon as they happen. Unfortunately, this makes things look ugly. The \"> \" string doesn't show up again after the output, and if the user is halfway through typing something, it chops their text in half. It should probably redraw the user's text-in-progress after printing something.\nThis seems like it must be a solved problem. What's the proper way to do this?\nAlso note that some of my users are Windows-based.\nTIA\nEdit: The accepted answer works under Unixy platforms (when the readline module is available), but if anyone knows how to make this work under Windows, it would be much appreciated!","AnswerCount":6,"Available Count":1,"Score":-0.0333209931,"is_accepted":false,"ViewCount":7222,"Q_Id":437025,"Users Score":-1,"Answer":"I think you have 2 basic options:\n\nSynchronize your output (i.e. block until it comes back)\nSeparate your input and your (asyncronous) output, perhaps in two separate columns.","Q_Score":13,"Tags":"python,readline,read-eval-print-loop","A_Id":439403,"CreationDate":"2009-01-12T21:11:00.000","Title":"How to implement a python REPL that nicely handles asynchronous output?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For my next project I plan to create images with text and graphics.  I'm comfortable with ruby, but interested in learning python.  I figured this may be a good time because PIL looks like a great library to use.  However, I don't know how it compares to what ruby has to offer (e.g. RMagick and ruby-gd).  From what I can gather PIL had better documentation (does ruby-gd even have a homepage?) and more features. Just wanted  to hear a few opinions to help me decide.\nThanks.\nVince","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2243,"Q_Id":439641,"Users Score":7,"Answer":"PIL is a good library, use it.  ImageMagic (what RMagick wraps) is a very heavy library that should be avoided if possible.  Its good for doing local processing of images, say, a batch photo editor, but way too processor inefficient for common image manipulation tasks for web.\nEDIT: In response to the question, PIL supports drawing vector shapes.  It can draw polygons, curves, lines, fills and text.  I've used it in a project to produce rounded alpha corners to PNG images on the fly over the web.  It essentially has most of the drawing features of GDI+ (in Windows) or GTK (in Gnome on Linux).","Q_Score":4,"Tags":"python,ruby,python-imaging-library,rmagick","A_Id":440298,"CreationDate":"2009-01-13T16:21:00.000","Title":"PIL vs RMagick\/ruby-gd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've seen a couple of Python IDE's (e.g. PyDev Extensions, WingIDE) that provide a debug console - an interactive terminal that runs in the context of the method where the breakpoint is. This lets you print members, call other methods and see the results, and redefine methods to try to fix bugs. Cool.\nCan anyone tell me how this is implemented? I know there's the Code module, which provides an InteractiveConsole class, but I don't know how this can be run in the context of currently loaded code. I'm quite new to Python, so gentle assistance would be appreciated!","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1515,"Q_Id":444509,"Users Score":6,"Answer":"You could try looking at the python debugger pdb.  It's like gdb in how you use it, but implemented in pure python.  Have a look for pdb.py in your python install directory.","Q_Score":11,"Tags":"python,debugging,interactive","A_Id":444918,"CreationDate":"2009-01-14T20:17:00.000","Title":"How are debug consoles implemented in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a wx.Toolbar and I'd like to make the buttons larger.  I've searched and can't seem to find any concrete documentation on how to do this.\nI'm also wondering how well this will translate across platforms; what will happen to the buttons and icons on OSX?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":3854,"Q_Id":445037,"Users Score":2,"Answer":"Doesn't the size of the toolbar adapts itself automatically to the size of the bitmap icons? I think if you want a bigger toolbar, you need bigger bitmaps.","Q_Score":2,"Tags":"python,user-interface,wxpython,wxwidgets,toolbar","A_Id":446014,"CreationDate":"2009-01-14T22:57:00.000","Title":"How to make a wx Toolbar buttons larger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I want to write a piece of software which is essentially a regex data scrubber. I am going to take a contact list in CSV and remove all non-word characters and such from the person's name.\nThis project has Perl written all over it but my client base is largely non-technical and installing Perl on Windows would not be worth it for them.\nAny ideas on how I can use a Perl\/Python\/Ruby type language without all the headaches of getting the interpreter on their computer?\nThought about web for a second but it would not work for business reasons.","AnswerCount":9,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11996,"Q_Id":446685,"Users Score":0,"Answer":"\"installing Perl on Windows would not be worth it for them\"  Really?  It's that complex?\nPython has a simple .MSI that neatly installs itself with no muss or fuss.\nA simple application program is just a few .py files, so, I don't see a big pain factor there.\nYou know your customers best.\nI find that the following isn't so bad.  And it's much easier to support, since your upgrades will just be a single .MSI with simple, easy-to-live with source.\n1) double click this .MSI file to install Python (or Perl or whatever)\n2) double click this other .MSI to install the good stuff","Q_Score":22,"Tags":"python,ruby,perl","A_Id":447176,"CreationDate":"2009-01-15T13:21:00.000","Title":"How can I deploy a Perl\/Python\/Ruby script without installing an interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities.\nI'd like to create a web page served from one of my systems that would merely present a few buttons which would allow me to initiate these scripts remotely.\nThe problem is that I don't know where to start investigating how to do this.  Let's say I have a script called:\nfile_arranger.py\nWhat do I need to do to have a webpage execute that script?  This isn't meant for public consumption, so anything lightweight would be great.  For bonus points, what do I need to look into to provide the web user with the output from such scripts?\nedit:  The first answer made me realize I forgot to include that this is a Win2k3 system.","AnswerCount":9,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38798,"Q_Id":448837,"Users Score":0,"Answer":"When setting this up, please be careful to restrict access to the scripts that take some action on your web server. It is not sufficient to place them in a directory where you just don't publish the URL, because sooner or later somebody will find them.\nAt the very least, put these scripts in a location that is password protected. You don't want just anybody out there on the internet being able to run your scripts.","Q_Score":25,"Tags":"python,windows,web-services,cgi","A_Id":449199,"CreationDate":"2009-01-15T22:58:00.000","Title":"How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities.\nI'd like to create a web page served from one of my systems that would merely present a few buttons which would allow me to initiate these scripts remotely.\nThe problem is that I don't know where to start investigating how to do this.  Let's say I have a script called:\nfile_arranger.py\nWhat do I need to do to have a webpage execute that script?  This isn't meant for public consumption, so anything lightweight would be great.  For bonus points, what do I need to look into to provide the web user with the output from such scripts?\nedit:  The first answer made me realize I forgot to include that this is a Win2k3 system.","AnswerCount":9,"Available Count":2,"Score":0.022218565,"is_accepted":false,"ViewCount":38798,"Q_Id":448837,"Users Score":1,"Answer":"A simple cgi script (or set of scripts) is all you need to get started. The other answers have covered how to do this so I won't repeat it; instead, I will stress that using plain text will get you a long way. Just output the header (print(\"Content-type: text\/plain\\n\") plus print adds its own newline to give you the needed blank line) and then run your normal program.\nThis way, any normal output from your script gets sent to the browser and you don't have to worry about HTML, escaping, frameworks, anything. \"Do the simplest thing that could possibly work.\"\nThis is especially appropriate for non-interactive private administrative tasks like you describe, and lets you use identical programs from a shell with a minimum of fuss. Your driver, the page with the buttons, can be a static HTML file with single-button forms. Or even a list of links.\nTo advance from there, look at the logging module (for example, sending INFO messages to the browser but not the command line, or easily categorizing messages by using different loggers, by configuring your handlers), and then start to consider template engines and frameworks.\nDon't output your own HTML and skip to using one of the many existing libraries\u2014it'll save a ton of headache even spending a bit of extra time to learn the library. Or at the very least encapsulate your output by effectively writing your own mini-engine.","Q_Score":25,"Tags":"python,windows,web-services,cgi","A_Id":449062,"CreationDate":"2009-01-15T22:58:00.000","Title":"How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a code that creates file(s) in user-specified directory. User can point to a directory in which he can't create files, but he can rename it.\nI have created directory for test purposes, let's call it C:\\foo.  \nI have following permissions to C:\\foo:  \n\nTraversing directory\/Execute file  \nRemoving subfolders and files\nRemoving\nRead permissions\nChange permissions\nTake ownership\n\nI don't have any of the following permissions to C:\\foo:  \n\nFull Control  \nFile creation  \nFolder creation  \n\nI have tried following approaches, so far:\n\nos.access('C:\\foo', os.W_OK) == True  \nst = os.stat('C:\\foo')\nmode = st[stat.ST_MODE]\nmode & stat.S_IWRITE == True \n \nI believe that this is caused by the fact that I can rename folder, so it is changeable for me. But it's content - not. \nDoes anyone know how can I write code that will check for a given directory if current user has permissions to create file in that directory?\nIn brief - I want to check if current user has File creation and Folder creation permissions for given folder name.\nEDIT: The need for such code arisen from the Test case no 3 from 'Certified for Windows Vista' program, which states: \n\n\nThe application must not allow the Least-Privileged user to save any files to Windows System directory in order to pass this test case.  \n\n\nShould this be understood as 'Application may try to save file in Windows System directory, but shouldn't crash on failure?' or rather 'Application has to perform security checks before trying to save file?' \nShould I stop bothering just because Windows Vista itself won't allow the Least-Privileged user to save any files in %WINDIR%?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3469,"Q_Id":450210,"Users Score":4,"Answer":"I recently wrote a App to pass a set of test to obtain the ISV status from Microsoft and I also add that condition.\nThe way I understood it was that if the user is Least Priveledge then he won't have permission to write in the system folders. So I approached the problem the the way Ishmaeel described. I try to create the file and catch the exception then inform the user that he doesn't have permission to write files to that directory.\nIn my understanding an Least-Priviledged user will not have the necessary permissions to write to those folders, if he has then he is not a Least-Priveledge user.\n\nShould I stop bothering just because Windows Vista itself won't allow the Least-Privileged user to save any files in %WINDIR%?\n\nIn my opinion? Yes.","Q_Score":6,"Tags":"python,windows,winapi,windows-vista,permissions","A_Id":450297,"CreationDate":"2009-01-16T12:01:00.000","Title":"How to check if a file can be created inside given directory on MS XP\/Vista?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a code that creates file(s) in user-specified directory. User can point to a directory in which he can't create files, but he can rename it.\nI have created directory for test purposes, let's call it C:\\foo.  \nI have following permissions to C:\\foo:  \n\nTraversing directory\/Execute file  \nRemoving subfolders and files\nRemoving\nRead permissions\nChange permissions\nTake ownership\n\nI don't have any of the following permissions to C:\\foo:  \n\nFull Control  \nFile creation  \nFolder creation  \n\nI have tried following approaches, so far:\n\nos.access('C:\\foo', os.W_OK) == True  \nst = os.stat('C:\\foo')\nmode = st[stat.ST_MODE]\nmode & stat.S_IWRITE == True \n \nI believe that this is caused by the fact that I can rename folder, so it is changeable for me. But it's content - not. \nDoes anyone know how can I write code that will check for a given directory if current user has permissions to create file in that directory?\nIn brief - I want to check if current user has File creation and Folder creation permissions for given folder name.\nEDIT: The need for such code arisen from the Test case no 3 from 'Certified for Windows Vista' program, which states: \n\n\nThe application must not allow the Least-Privileged user to save any files to Windows System directory in order to pass this test case.  \n\n\nShould this be understood as 'Application may try to save file in Windows System directory, but shouldn't crash on failure?' or rather 'Application has to perform security checks before trying to save file?' \nShould I stop bothering just because Windows Vista itself won't allow the Least-Privileged user to save any files in %WINDIR%?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3469,"Q_Id":450210,"Users Score":4,"Answer":"I wouldn't waste time and LOCs on checking for permissions. Ultimate test of file creation in Windows is the creation itself. Other factors may come into play (such as existing files (or worse, folders) with the same name, disk space, background processes. These conditions can even change between the time you make the initial check and the time you actually try to create your file.\nSo, if I had a scenario like that, I would just design my method to not lose any data in case of failure, to go ahead and try to create my file, and offer the user an option to change the selected directory and try again if creation fails.","Q_Score":6,"Tags":"python,windows,winapi,windows-vista,permissions","A_Id":450259,"CreationDate":"2009-01-16T12:01:00.000","Title":"How to check if a file can be created inside given directory on MS XP\/Vista?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am installing active python, django. I really dont know how to set the python path in vista environment system. first of all will it work in vista.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1226,"Q_Id":450290,"Users Score":0,"Answer":"Remember that in addition to setting PYTHONPATH in your system environment, you'll also want to assign DJANGO_SETTINGS_MODULE.","Q_Score":2,"Tags":"python","A_Id":450545,"CreationDate":"2009-01-16T12:33:00.000","Title":"Python Path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a \"manager\" process on a node, and several worker processes. The manager is the actual server who holds all of the connections to the clients. The manager accepts all incoming packets and puts them into a queue, and then the worker processes pull the packets out of the queue, process them, and generate a result. They send the result back to the manager (by putting them into another queue which is read by the manager), but here is where I get stuck: how do I send the result to a specific socket? When dealing with the processing of the packets on a single process, it's easy, because when you receive a packet you can reply to it by just grabbing the \"transport\" object in-context. But how would I do this with the method I'm using?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":829,"Q_Id":460068,"Users Score":3,"Answer":"It sounds like you might need to keep a reference to the transport (or protocol) along with the bytes the just came in on that protocol in your 'event' object.  That way responses that came in on a connection go out on the same connection. \nIf things don't need to be processed serially perhaps you should think about setting up functors that can handle the data in parallel to remove the need for queueing.  Just keep in mind that you will need to protect critical sections of your code.\nEdit:\nJudging from your other question about evaluating your server design it would seem that processing in parallel may not be possible for your situation, so my first suggestion stands.","Q_Score":2,"Tags":"python,sockets,twisted,multiprocess","A_Id":460245,"CreationDate":"2009-01-20T03:43:00.000","Title":"Python\/Twisted - Sending to a specific socket object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you give me some links or explain how to configure an existing python project onto Netbeans? \nI'm trying it these days and it continues to crash also code navigation doesn't work well and I've problems with debugging. Surely these problems are related to my low eperience about python and I need support also in trivial things as organizing source folders, imports ecc,, thank you very much. \nValerio","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":263,"Q_Id":462068,"Users Score":1,"Answer":"Python support is in beta, and as someone who works with NB for a past 2 years, I can say that even a release versions are buggy and sometimes crashes. Early Ruby support was also very shaky.","Q_Score":1,"Tags":"python,netbeans,project","A_Id":462107,"CreationDate":"2009-01-20T16:37:00.000","Title":"Python with Netbeans 6.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that?\nI was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":464314,"Users Score":1,"Answer":"When you say the last minute, do you mean the exact last seconds or the last full minute from x:00 to x:59? The latter will be easier to implement and would probably give accurate results. You have one prev variable holding the value of the hits for the previous minute. Then you have a current value that increments every time there is a new hit. You return the value of prev to the users. At the change of the minute you swap prev with current and reset current.\nIf you want higher analysis you could split the minute in 2 to 6 slices. You need a variable or list entry for every slice. Let's say you have 6 slices of 10 seconds. You also have an index variable pointing to the current slice (0..5). For every hit you increment a temp variable. When the slice is over, you replace the value of the indexed variable with the value of temp, reset temp and move the index forward. You return the sum of the slice variables to the users.","Q_Score":2,"Tags":"python","A_Id":464347,"CreationDate":"2009-01-21T07:14:00.000","Title":"Python - Hits per minute implementation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that?\nI was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":303,"Q_Id":464314,"Users Score":1,"Answer":"For what it's worth, your implementation above won't work if you don't receive a packet every second, as the next second entry won't necessarily be reset to 0.\nEither way, afaik the \"correct\" way to do this, ala logs analysis, is to keep a limited record of all the queries you receive. So just chuck the query, time received etc. into a database, and then simple database queries will give you the use over a minute, or any minute in the past. Not sure whether this is too heavyweight for you, though.","Q_Score":2,"Tags":"python","A_Id":464329,"CreationDate":"2009-01-21T07:14:00.000","Title":"Python - Hits per minute implementation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that?\nI was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":303,"Q_Id":464314,"Users Score":3,"Answer":"A common pattern for solving this in other languages is to let the thing being measured simply increment an integer. Then you leave it to the listening client to determine intervals and frequencies.\nSo you basically do not let the socket server know about stuff like \"minutes\", because that's a feature the observer calculates. Then you can also support multiple listeners with different interval resolution.\nI suppose you want some kind of ring-buffer structure to do the rolling logging.","Q_Score":2,"Tags":"python","A_Id":464322,"CreationDate":"2009-01-21T07:14:00.000","Title":"Python - Hits per minute implementation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python, how can information such as CPU usage, memory usage (free, used, etc), process count, etc be returned in a generic manner so that the same code can be run on Linux, Windows, BSD, etc?\nAlternatively, how could this information be returned on all the above systems with the code specific to that OS being run only if that OS is indeed the operating environment?","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":29587,"Q_Id":466684,"Users Score":1,"Answer":"It looks like you want to get a lot more information than the standard Python library offers. If I were you, I would download the source code for 'ps' or 'top', or the Gnome\/KDE version of the same, or any number of system monitoring\/graphing programs which are more likely to have all the necessary Unix cross platform bits, see what they do, and then make the necessary native calls with ctypes.\nIt's trivial to detect the platform. For example with ctypes you might try to load libc.so, if that throws an exception try to load 'msvcrt.dll' and so on. Not to mention simply checking the operating system's name with os.name. Then just delegate calls to your new cross-platform API to the appropriate platform-specific (sorry) implementation.\nWhen you're done, don't forget to upload the resulting package to pypi.","Q_Score":25,"Tags":"python,operating-system","A_Id":466755,"CreationDate":"2009-01-21T19:40:00.000","Title":"How can I return system information in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is going to be a generic question.\nI am struggling in designing a GUI application, esp. with dealing with interactions between different parts.\nI don't know how I should deal with shared state. On one hand, shared state is bad, and things should be as explicit as possible. On the other hand, not having shared state introduces unwanted coupling between components.\nAn example:\nI want my application to be extendable in an Emacs\/Vim sort of way, via scripts. Clearly, some sort of shared state needs to be modified, so that the GUI will use it. My initial plan was having a global \"session\" that is accessible from everywhere, but I'm not so sure about it.\nOne tricky use case is key bindings. I want the user to be able to specify custom keybindings from a script. Each keybinding maps to an arbitrary command, that receives the session as the only argument.\nNow, the editor component captures keypresses. It has to have access to the keymappings, which are per-session, so it needs access to the session. Is coupling the editor to the session a good idea? Other components will also need to access the keybindings, so the session now becomes shared and can be a singleton...\nIs there any good reading about designing GUI applications that goes beyond MVC?\nThis is Python and wxPython, FWIW.\n[EDIT]: Added concrete usecase.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":805,"Q_Id":471279,"Users Score":2,"Answer":"If you've looked at MVC you're probably moving in the right direction.  MVC, MVP, Passive View, Supervising Controller.  Those are all different ways, each with their own pros and cons, of accomplishing what you're after.  I find that Passive View is the \"ideal\", but it causes you to introduce far too many widgets into your GUI interfaces (i.e. IInterface).  In general I find that Supervising Controller is a good compromise.","Q_Score":9,"Tags":"python,model-view-controller,user-interface,architecture,wxpython","A_Id":471297,"CreationDate":"2009-01-22T23:25:00.000","Title":"Organising a GUI application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is going to be a generic question.\nI am struggling in designing a GUI application, esp. with dealing with interactions between different parts.\nI don't know how I should deal with shared state. On one hand, shared state is bad, and things should be as explicit as possible. On the other hand, not having shared state introduces unwanted coupling between components.\nAn example:\nI want my application to be extendable in an Emacs\/Vim sort of way, via scripts. Clearly, some sort of shared state needs to be modified, so that the GUI will use it. My initial plan was having a global \"session\" that is accessible from everywhere, but I'm not so sure about it.\nOne tricky use case is key bindings. I want the user to be able to specify custom keybindings from a script. Each keybinding maps to an arbitrary command, that receives the session as the only argument.\nNow, the editor component captures keypresses. It has to have access to the keymappings, which are per-session, so it needs access to the session. Is coupling the editor to the session a good idea? Other components will also need to access the keybindings, so the session now becomes shared and can be a singleton...\nIs there any good reading about designing GUI applications that goes beyond MVC?\nThis is Python and wxPython, FWIW.\n[EDIT]: Added concrete usecase.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":805,"Q_Id":471279,"Users Score":1,"Answer":"In MVC, the Model stuff is the shared state of the information.\nThe Control stuff is the shared state of the GUI control settings and responses to mouse-clicks and what-not.\nYour scripting angle can \n1) Update the Model objects.  This is good.  The Control can be \"Observers\" of the model objects and the View be updated to reflect the observed changes.\n2) Update the Control objects.  This is not so good, but...  The Control objects can then make appropriate changes to the Model and\/or View.\nI'm not sure what the problem is with MVC.  Could you provide a more detailed design example with specific issues or concerns?","Q_Score":9,"Tags":"python,model-view-controller,user-interface,architecture,wxpython","A_Id":471307,"CreationDate":"2009-01-22T23:25:00.000","Title":"Organising a GUI application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python's Imaging Library I want to create a PNG file.\nI would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page.\nIs the resolution encoded in the image? \nIf so, how do I specify it?\nAnd even if it is, does this have any relevance when it goes to the printer?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":4781,"Q_Id":473498,"Users Score":1,"Answer":"Printers have various resolutions in which they print. If you select a print resolution of 200 DPI for instance (or if it's set as default in the printer driver), then a 200 pixel image should be one inch in size.","Q_Score":5,"Tags":"python,python-imaging-library,dpi","A_Id":473514,"CreationDate":"2009-01-23T16:16:00.000","Title":"When printing an image, what determines how large it will appear on a page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python's Imaging Library I want to create a PNG file.\nI would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page.\nIs the resolution encoded in the image? \nIf so, how do I specify it?\nAnd even if it is, does this have any relevance when it goes to the printer?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4781,"Q_Id":473498,"Users Score":0,"Answer":"Much is going to depend on the software you're using to print. If you're placing the image in a Word document, it will scale according to the DPI, up to the width of your page. If you're putting it on a web page, the DPI will not matter at all.","Q_Score":5,"Tags":"python,python-imaging-library,dpi","A_Id":473539,"CreationDate":"2009-01-23T16:16:00.000","Title":"When printing an image, what determines how large it will appear on a page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python's Imaging Library I want to create a PNG file.\nI would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page.\nIs the resolution encoded in the image? \nIf so, how do I specify it?\nAnd even if it is, does this have any relevance when it goes to the printer?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":4781,"Q_Id":473498,"Users Score":1,"Answer":"Both image print size and resolution are relevant to printing an image of a specific scale and quality. Bear in mind that if the image is then included with a desktop publishing workspace (Word, InDesign) or even a web page, the image is then subject to any specified resolution in the parent document -- this won't necessarily alter the relative scale of the image in the case of desktop publishing programs but will alter image quality.\nAnd yes, all images have a resolution property, which answers half your question - I don't know Python...","Q_Score":5,"Tags":"python,python-imaging-library,dpi","A_Id":473556,"CreationDate":"2009-01-23T16:16:00.000","Title":"When printing an image, what determines how large it will appear on a page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python's Imaging Library I want to create a PNG file.\nI would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page.\nIs the resolution encoded in the image? \nIf so, how do I specify it?\nAnd even if it is, does this have any relevance when it goes to the printer?","AnswerCount":5,"Available Count":4,"Score":0.1194272985,"is_accepted":false,"ViewCount":4781,"Q_Id":473498,"Users Score":3,"Answer":"I found a very simple way to get dpi information into the png:\nim.save('myfile.png',dpi=[600,600])\nUnfortunately I did not find this documented anywhere and had to dig into the PIL source code.","Q_Score":5,"Tags":"python,python-imaging-library,dpi","A_Id":21163772,"CreationDate":"2009-01-23T16:16:00.000","Title":"When printing an image, what determines how large it will appear on a page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A regular function can contain a call to itself in its definition, no problem.  I can't figure out how to do it with a lambda function though for the simple reason that the lambda function has no name to refer back to.  Is there a way to do it?  How?","AnswerCount":15,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":54314,"Q_Id":481692,"Users Score":-3,"Answer":"If you were truly masochistic, you might be able to do it using C extensions, but this exceeds the capability of a lambda (unnamed, anonymous) functon.\nNo.  (for most values of no).","Q_Score":80,"Tags":"python,recursion,lambda,y-combinator","A_Id":481793,"CreationDate":"2009-01-26T22:42:00.000","Title":"Can a lambda function call itself recursively in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We currently have an inventory management system that was built in-house. It works great, and we are constantly innovating it. \nThis past Fall, we began selling products directly on one of our websites via a Shopping Cart checkout.\nOur inventory management system runs off a server in the office, while the three websites we currently have (only one actually sells things) runs off an outside source, obviously.\nSee my problem here? Basically, I am trying to think of ways I can create a central inventory control system that allows both the internal software and external websites to communicate so that inventory is always up to date and we are not selling something we don't have.\nOur internal inventory tracking works great and flows well, but I have no idea on how I would implement a solid tracking system that can communicate between the two.\nThe software is all written in Python, but it does not matter as I am mostly looking for ideas and methods on how would this be implemented.\nThanks in advance for any answers, and I hope that made sense .. I can elaborate.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1492,"Q_Id":487642,"Users Score":1,"Answer":"One possibility would be to expose a web service interface on your inventory management system that allows the transactions used by the web shopfront to be accessed remotely.  With a reasonably secure VPN link or ssh tunnel type arrangement, the web shopfront could get stock levels, place orders or execute searches against the inventory system.\nNotes:\n\nYou would still have to add a reasonable security layer to the inventory service in case the web shopfront was compromised.\nYou would have to make sure your inventory management application and server was big enough to handle the load, or could be reasonably easily scaled so it could do so.\n\nYour SLA for the inventory application would need to be good enough to support the web shopfront.  This probably means some sort of hot failover arrangement.","Q_Score":0,"Tags":"python,tracking,inventory","A_Id":487660,"CreationDate":"2009-01-28T13:39:00.000","Title":"Inventory Control Across Multiple Servers .. Ideas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We currently have an inventory management system that was built in-house. It works great, and we are constantly innovating it. \nThis past Fall, we began selling products directly on one of our websites via a Shopping Cart checkout.\nOur inventory management system runs off a server in the office, while the three websites we currently have (only one actually sells things) runs off an outside source, obviously.\nSee my problem here? Basically, I am trying to think of ways I can create a central inventory control system that allows both the internal software and external websites to communicate so that inventory is always up to date and we are not selling something we don't have.\nOur internal inventory tracking works great and flows well, but I have no idea on how I would implement a solid tracking system that can communicate between the two.\nThe software is all written in Python, but it does not matter as I am mostly looking for ideas and methods on how would this be implemented.\nThanks in advance for any answers, and I hope that made sense .. I can elaborate.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1492,"Q_Id":487642,"Users Score":0,"Answer":"I don't see the problem... You have an application running on one server that manages your database locally. There's no reason a remote server can't also talk to that database.\nOf course, if you don't have a database and are instead using a homegrown app to act as some sort of faux-database, I recommend that you refactor to use something sort of actual DB sooner rather than later.","Q_Score":0,"Tags":"python,tracking,inventory","A_Id":487674,"CreationDate":"2009-01-28T13:39:00.000","Title":"Inventory Control Across Multiple Servers .. Ideas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We currently have an inventory management system that was built in-house. It works great, and we are constantly innovating it. \nThis past Fall, we began selling products directly on one of our websites via a Shopping Cart checkout.\nOur inventory management system runs off a server in the office, while the three websites we currently have (only one actually sells things) runs off an outside source, obviously.\nSee my problem here? Basically, I am trying to think of ways I can create a central inventory control system that allows both the internal software and external websites to communicate so that inventory is always up to date and we are not selling something we don't have.\nOur internal inventory tracking works great and flows well, but I have no idea on how I would implement a solid tracking system that can communicate between the two.\nThe software is all written in Python, but it does not matter as I am mostly looking for ideas and methods on how would this be implemented.\nThanks in advance for any answers, and I hope that made sense .. I can elaborate.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1492,"Q_Id":487642,"Users Score":0,"Answer":"I'm not sure if there is any one really good solution for your problem.  I think the way you are doing it now works fine, but if you don't agree then I don't know what to tell you.","Q_Score":0,"Tags":"python,tracking,inventory","A_Id":706707,"CreationDate":"2009-01-28T13:39:00.000","Title":"Inventory Control Across Multiple Servers .. Ideas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to reverse a regular expression. I.e. given a regular expression, I want to produce any string that will match that regex.\nI know how to do this from a theoretical computer science background using a finite state machine, but I just want to know if someone has already written a library to do this. :)\nI'm using Python, so I'd like a Python library.\nTo reiterate, I only want one string that will match the regex. Things like \".\" or \".*\" would make an infinite amount of strings match the regex, but I don't care about all options.\nI'm willing for this library to only work on a certain subset of regex.","AnswerCount":8,"Available Count":1,"Score":0.1243530018,"is_accepted":false,"ViewCount":14829,"Q_Id":492716,"Users Score":5,"Answer":"Unless your regex is extremely simple (i.e. no stars or pluses), there will be infinitely many strings which match it.  If your regex only involves concatenation and alternation, then you can expand each alternation into all of its possibilities, e.g. (foo|bar)(baz|quux) can be expanded into the list ['foobaz', 'fooquux', 'barbaz', 'barquux'].","Q_Score":45,"Tags":"python,regex","A_Id":492728,"CreationDate":"2009-01-29T18:05:00.000","Title":"Reversing a regular expression in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a C++ programmer just starting to learn Python.  I'd like to know how you keep track of instance variables in large Python classes.  I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members.  But since Python allows you to add new instance variables on the fly, how do you keep track of them all?\nI'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working.  Are there standard practices for avoiding this?\nEdit: It appears I created some confusion with the term \"member variable.\"  I really mean instance variable, and I've edited my question accordingly.","AnswerCount":10,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":3466,"Q_Id":496582,"Users Score":8,"Answer":"First of all: class attributes, or instance attributes? Or both? =)\nUsually you just add instance attributes in __init__, and class attributes in the class definition, often before method definitions... which should probably cover 90% of use cases.\nIf code adds attributes on the fly, it probably (hopefully :-) has good reasons for doing so... leveraging dynamic features, introspection, etc.  Other than that, adding attributes this way is probably less common than you think.","Q_Score":11,"Tags":"python,variables","A_Id":496656,"CreationDate":"2009-01-30T18:21:00.000","Title":"What's a good way to keep track of class instance variables in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a C++ programmer just starting to learn Python.  I'd like to know how you keep track of instance variables in large Python classes.  I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members.  But since Python allows you to add new instance variables on the fly, how do you keep track of them all?\nI'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working.  Are there standard practices for avoiding this?\nEdit: It appears I created some confusion with the term \"member variable.\"  I really mean instance variable, and I've edited my question accordingly.","AnswerCount":10,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":3466,"Q_Id":496582,"Users Score":10,"Answer":"I would say, the standard practice to avoid this is to not write classes where you can be 1000 lines away from anything!\nSeriously, that's way too much for just about any useful class, especially in a language that is as expressive as Python. Using more of what the Standard Library offers and abstracting away code into separate modules should help keeping your LOC count down.\nThe largest classes in the standard library have well below 100 lines!","Q_Score":11,"Tags":"python,variables","A_Id":498284,"CreationDate":"2009-01-30T18:21:00.000","Title":"What's a good way to keep track of class instance variables in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a C++ programmer just starting to learn Python.  I'd like to know how you keep track of instance variables in large Python classes.  I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members.  But since Python allows you to add new instance variables on the fly, how do you keep track of them all?\nI'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working.  Are there standard practices for avoiding this?\nEdit: It appears I created some confusion with the term \"member variable.\"  I really mean instance variable, and I've edited my question accordingly.","AnswerCount":10,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":3466,"Q_Id":496582,"Users Score":2,"Answer":"This is a common concern I hear from many programmers who come from a C, C++, or other statically typed language where variables are pre-declared. In fact it was one of the biggest concerns we heard when we were persuading programmers at our organization to abandon C for high-level programs and use Python instead.\nIn theory, yes you can add instance variables to an object at any time. Yes it can happen from typos, etc. In practice, it rarely results in a bug. When it does, the bugs are generally not hard to find. \nAs long as your classes are not bloated (1000 lines is pretty huge!) and you have ample unit tests, you should rarely run in to a real problem. In case you do, it's easy to drop to a Python console at almost any time and inspect things as much as you wish.","Q_Score":11,"Tags":"python,variables","A_Id":498421,"CreationDate":"2009-01-30T18:21:00.000","Title":"What's a good way to keep track of class instance variables in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a C++ programmer just starting to learn Python.  I'd like to know how you keep track of instance variables in large Python classes.  I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members.  But since Python allows you to add new instance variables on the fly, how do you keep track of them all?\nI'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working.  Are there standard practices for avoiding this?\nEdit: It appears I created some confusion with the term \"member variable.\"  I really mean instance variable, and I've edited my question accordingly.","AnswerCount":10,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":3466,"Q_Id":496582,"Users Score":4,"Answer":"Instance variables should be initialized in the class's __init__() method. (In general)\nIf that's not possible. You can use __dict__ to get a dictionary of all instance variables of an object during runtime. If you really need to track this in documentation add a list of instance variables you are using into the docstring of the class.","Q_Score":11,"Tags":"python,variables","A_Id":496820,"CreationDate":"2009-01-30T18:21:00.000","Title":"What's a good way to keep track of class instance variables in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a C++ programmer just starting to learn Python.  I'd like to know how you keep track of instance variables in large Python classes.  I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members.  But since Python allows you to add new instance variables on the fly, how do you keep track of them all?\nI'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working.  Are there standard practices for avoiding this?\nEdit: It appears I created some confusion with the term \"member variable.\"  I really mean instance variable, and I've edited my question accordingly.","AnswerCount":10,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3466,"Q_Id":496582,"Users Score":0,"Answer":"The easiest is to use an IDE. PyDev is a plugin for eclipse.\nI'm not a full on expert in all ways pythonic, but in general I define my class members right under the class definition in python, so if I add members, they're all relative.\nMy personal opinion is that class members should be declared in one section, for this specific reason.\nLocal scoped variables, otoh, should be defined closest to when they are used (except in C--which I believe still requires variables to be declared at the beginning of a method).","Q_Score":11,"Tags":"python,variables","A_Id":496641,"CreationDate":"2009-01-30T18:21:00.000","Title":"What's a good way to keep track of class instance variables in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was just wondering how do you make python fail in a user defined way in all possible errors. \nFor example, I'm writing a program that processes a (large) list of items, and some of the items may not be in the format I defined. If python detects an error, it currently just spits out an ugly error message and stop the whole process. However, I want it to just outputs the error to somewhere together with some context and then move on to the next item. \nIf anyone can help me with this it would be greatly appreciated!\nThanks a lot!\nJason","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":17154,"Q_Id":497952,"Users Score":2,"Answer":"all possible errors\n\nThe other answers pretty much cover how to make your program gracefully fail, but I'd like to mention one thing -- You don't want to gracefully fail all errors. If you hide all your errors, you won't be shown those which signify that the logic of the program is wrong - namely errors you want to see.\nSo while it's important to catch your exceptions, make sure you know exactly which exceptions are actually being caught.","Q_Score":15,"Tags":"python","A_Id":498046,"CreationDate":"2009-01-31T01:22:00.000","Title":"How to make python gracefully fail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"On the intranet at my part time job (not IT related) there are various web applications that we use that do not require logging in explicitly. We are required to login to Windows obviously, and that then authenticates us some how.\nI'm wondering how this is done? Without worrying about security TOO much, how would I go about authenticating a user to a web application, utilizing the windows login information? I'd be using Python (and Django). \nAre there limitations on how this can be achieved? For instance, would a specific browser be required? Would the application and intranet backend have to be hosted at the same location or at least have to communicate? Or is it simply getting the users Windows credentials, and passing that to the authentication software of the web application?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4695,"Q_Id":500134,"Users Score":0,"Answer":"To the best of my knowledge the only browser that automatically passes your login credentials is Internet Explorer.   To enable this feature select \"Enable Integrated Windows Authentication\" in the advanced Internet options dialog under the security section.  This is usually enabled by default.  \nThe web server will have to have the Anonymous user permission removed from the web application and enable windows authentication option checked.   Simply add the users you want to have access to the web application to the file\/folder permissions. \nI have only tried this with IIS so I'm not sure if it will work on other web servers.","Q_Score":3,"Tags":"python,authentication,web-applications,windows-authentication","A_Id":500260,"CreationDate":"2009-02-01T03:37:00.000","Title":"Can I log into a web application automatically using a users windows logon?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a small project I am doing in Python using web.py. It's a name generator, using 4 \"parts\" of a name (firstname, middlename, anothername, surname). Each part of the name is a collection of entites in a MySQL databse (name_part (id, part, type_id), and name_part_type (id, description)). Basic stuff, I guess.\nMy generator picks a random entry of each \"type\", and assembles a comical name. Right now, I am using select * from name_part where type_id=[something] order by rand() limit 1 to select a random entry of each type (so I also have 4 queries that run per pageview, I figured this was better than one fat query returning potentially hundreds of rows; if you have a suggestion for how to pull this off in one query w\/o a sproc I'll listen).\nObviously I want to make this more random. Actually, I want to give it better coverage, not necessarily randomness. I want to make sure it's using as many possibilities as possible. That's what I am asking in this question, what sorts of strategies can I use to give coverage over a large random sample? \nMy idea, is to implement a counter column on each name_part, and increment it each time I use it. I would need some logic to then say like: \"get a name_part that is less than the highest \"counter\" for this \"name_part_type\", unless there are none then pick a random one\". I am not very good at SQL, is this kind of logic even possible? The only way I can think to do this would require up to 3 or 4 queries for each part of the name (so up to 12 queries per pageview). \nCan I get some input on my logic here? Am I overthinking it? This actually sounds ideal for a stored procedure... but can you guys at least help me solve how to do it without a sproc? (I don't know if I can even use a sproc with the built-in database stuff of web.py).\nI hope this isn't terribly dumb but thanks ahead of time. \nedit: Aside from my specific problem I am still curious if there are any alternate strategies I can use that may be better.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1758,"Q_Id":514617,"Users Score":1,"Answer":"I agree with your intuition that using a stored procedure is the right way to go, but then, I almost always try to implement database stuff in the database.\nIn your proc, I would introduce some kind of logic like say, there's only a 30% chance that returning the result will actually increment the counter. Just to increase the variability.","Q_Score":4,"Tags":"python,mysql,random,web.py","A_Id":514643,"CreationDate":"2009-02-05T04:51:00.000","Title":"Random name generator strategy - help me improve it","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.\nLike any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times.  I'm wondering if, and how, to clear the Python interpreter console.\nI've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do.\nNote: I'm running on Windows, so Ctrl+L doesn't work.","AnswerCount":30,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":824944,"Q_Id":517970,"Users Score":25,"Answer":"Quickest and easiest way without a doubt is Ctrl+L.\nThis is the same for OS X on the terminal.","Q_Score":437,"Tags":"python,windows,console","A_Id":32280047,"CreationDate":"2009-02-05T21:19:00.000","Title":"How to clear the interpreter console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.\nLike any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times.  I'm wondering if, and how, to clear the Python interpreter console.\nI've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do.\nNote: I'm running on Windows, so Ctrl+L doesn't work.","AnswerCount":30,"Available Count":7,"Score":0.0133325433,"is_accepted":false,"ViewCount":824944,"Q_Id":517970,"Users Score":2,"Answer":"just use this..\nprint '\\n'*1000","Q_Score":437,"Tags":"python,windows,console","A_Id":23730811,"CreationDate":"2009-02-05T21:19:00.000","Title":"How to clear the interpreter console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.\nLike any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times.  I'm wondering if, and how, to clear the Python interpreter console.\nI've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do.\nNote: I'm running on Windows, so Ctrl+L doesn't work.","AnswerCount":30,"Available Count":7,"Score":0.0266603475,"is_accepted":false,"ViewCount":824944,"Q_Id":517970,"Users Score":4,"Answer":"Use idle. It has many handy features.  Ctrl+F6, for example, resets the console.  Closing and opening the console are good ways to clear it.","Q_Score":437,"Tags":"python,windows,console","A_Id":518401,"CreationDate":"2009-02-05T21:19:00.000","Title":"How to clear the interpreter console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.\nLike any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times.  I'm wondering if, and how, to clear the Python interpreter console.\nI've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do.\nNote: I'm running on Windows, so Ctrl+L doesn't work.","AnswerCount":30,"Available Count":7,"Score":0.0066665679,"is_accepted":false,"ViewCount":824944,"Q_Id":517970,"Users Score":1,"Answer":"OK, so this is a much less technical answer, but I'm using the Python plugin for Notepad++ and it turns out you can just clear the console manually by right-clicking on it and clicking \"clear\". Hope this helps someone out there!","Q_Score":437,"Tags":"python,windows,console","A_Id":17536224,"CreationDate":"2009-02-05T21:19:00.000","Title":"How to clear the interpreter console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.\nLike any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times.  I'm wondering if, and how, to clear the Python interpreter console.\nI've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do.\nNote: I'm running on Windows, so Ctrl+L doesn't work.","AnswerCount":30,"Available Count":7,"Score":0.0133325433,"is_accepted":false,"ViewCount":824944,"Q_Id":517970,"Users Score":2,"Answer":"If it is on mac, then a simple cmd + k should do the trick.","Q_Score":437,"Tags":"python,windows,console","A_Id":31640548,"CreationDate":"2009-02-05T21:19:00.000","Title":"How to clear the interpreter console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.\nLike any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times.  I'm wondering if, and how, to clear the Python interpreter console.\nI've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do.\nNote: I'm running on Windows, so Ctrl+L doesn't work.","AnswerCount":30,"Available Count":7,"Score":0.0066665679,"is_accepted":false,"ViewCount":824944,"Q_Id":517970,"Users Score":1,"Answer":"I am using Spyder (Python 2.7) and to clean the interpreter console I use either \n%clear  \nthat forces the command line to go to the top and I will not see the previous old commands.\nor I click \"option\" on the Console environment and select \"Restart kernel\" that removes everything.","Q_Score":437,"Tags":"python,windows,console","A_Id":29520444,"CreationDate":"2009-02-05T21:19:00.000","Title":"How to clear the interpreter console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.\nLike any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times.  I'm wondering if, and how, to clear the Python interpreter console.\nI've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do.\nNote: I'm running on Windows, so Ctrl+L doesn't work.","AnswerCount":30,"Available Count":7,"Score":0.0066665679,"is_accepted":false,"ViewCount":824944,"Q_Id":517970,"Users Score":1,"Answer":"I found the simplest way is just to close the window and run a module\/script to reopen the shell.","Q_Score":437,"Tags":"python,windows,console","A_Id":18846817,"CreationDate":"2009-02-05T21:19:00.000","Title":"How to clear the interpreter console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know if there is some parameter available for programmatic search on yahoo allowing to restrict results so only links to files of specific type will be returned (like PDF for example)?\nIt's possible to do that in GUI, but how to make it happen through API?\nI'd very much appreciate a sample code in Python, but any other solutions might be helpful as well.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1551,"Q_Id":522781,"Users Score":0,"Answer":"Thank you.\nI found myself that something like this works OK (file type is the first argument, and query is the second):\nformat = sys.argv[1]\nquery = \" \".join(sys.argv[2:])\nsrch = create_search(\"Web\", app_id, query=query, format=format)","Q_Score":1,"Tags":"python,yahoo-api,yahoo-search","A_Id":526491,"CreationDate":"2009-02-07T00:27:00.000","Title":"how to search for specific file type with yahoo search API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any way to inject a command into a bash prompt in Linux? I am working on a command history app - like the Ctrl+R lookup but different. I am using python for this.\nI will show a list of commands from history based on the user's search term - if the user presses enter, the app will execute the command and print the results. So far, so good.\nIf the user chooses a command and then press the right or left key, I want to insert the command into the prompt - so that the user can edit the command before executing it.\nIf you are on Linux, just fire up a bash console, press Ctrl+r, type cd(or something), and then press the right arrow key - the selected command will be shown at the prompt. This is the functionality I am looking for - but I want to know how to do that from within python.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":2348,"Q_Id":524068,"Users Score":3,"Answer":"You can do this, but only if the shell runs as a subprocess of your Python program; you can't feed content into the stdin of your parent process. (If you could, UNIX would have a host of related security issues when folks run processes with fewer privileges than the calling shell!)\nIf you're familiar with how Expect allows passthrough to interactive subprocesses (with specific key sequences from the user or strings received from the child process triggering matches and sending control back to your program), the same thing can be done from Python with pexpect. Alternately, as another post mentioned, the curses module provides full control over the drawing of terminal displays -- which you'll want if this history menu is happening within the window rather than in a graphical (X11\/win32) pop-up.","Q_Score":1,"Tags":"python,linux,bash,shell,command","A_Id":524104,"CreationDate":"2009-02-07T16:30:00.000","Title":"Insert Command into Bash Shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.\nSo I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database.   \nThen in the main thread start a CherryPy application that will query that SQLite database and serve the data.\nMy problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application?\nIf I'd do a connection per thread to the database will I also be able to create\/use an in memory database?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":13542,"Q_Id":524797,"Users Score":0,"Answer":"Depending on the data rate sqlite could be exactly the correct way to do this. The entire database is locked for each write so you aren't going to scale to 1000s of simultaneous writes per second. But if you only have a few it is the safest way of assuring you don't overwrite each other.","Q_Score":9,"Tags":"python,multithreading,sqlite","A_Id":524955,"CreationDate":"2009-02-07T23:18:00.000","Title":"Python, SQLite and threading","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.\nSo I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database.   \nThen in the main thread start a CherryPy application that will query that SQLite database and serve the data.\nMy problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application?\nIf I'd do a connection per thread to the database will I also be able to create\/use an in memory database?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":13542,"Q_Id":524797,"Users Score":0,"Answer":"Depending on the application the DB could be a real overhead.  If we are talking about volatile data, maybe you could skip the communication via DB completely and share the data between the data gathering process and the data serving process(es) via IPC.  This is not an option if the data has to be persisted, of course.","Q_Score":9,"Tags":"python,multithreading,sqlite","A_Id":524937,"CreationDate":"2009-02-07T23:18:00.000","Title":"Python, SQLite and threading","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.\nSo I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database.   \nThen in the main thread start a CherryPy application that will query that SQLite database and serve the data.\nMy problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application?\nIf I'd do a connection per thread to the database will I also be able to create\/use an in memory database?","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":13542,"Q_Id":524797,"Users Score":8,"Answer":"Short answer: Don't use Sqlite3 in a threaded application.\nSqlite3 databases scale well for size, but rather terribly for concurrency. You will be plagued with \"Database is locked\" errors.\nIf you do, you will need a connection per thread, and you have to ensure that these connections clean up after themselves. This is traditionally handled using thread-local sessions, and is performed rather well (for example) using SQLAlchemy's ScopedSession. I would use this if I were you, even if you aren't using the SQLAlchemy ORM features.","Q_Score":9,"Tags":"python,multithreading,sqlite","A_Id":524806,"CreationDate":"2009-02-07T23:18:00.000","Title":"Python, SQLite and threading","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.\nSo I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database.   \nThen in the main thread start a CherryPy application that will query that SQLite database and serve the data.\nMy problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application?\nIf I'd do a connection per thread to the database will I also be able to create\/use an in memory database?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":13542,"Q_Id":524797,"Users Score":1,"Answer":"\"...create several threads that will gather data at a specified interval and cache that data locally into a sqlite database.\nThen in the main thread start a CherryPy app that will query that sqlite db and serve the data.\"\nDon't waste a lot of time on threads.  The things you're describing are simply OS processes.  Just start ordinary processes to do gathering and run Cherry Py.\nYou have no real use for concurrent threads in a single process for this. Gathering data at a specified interval -- when done with simple OS processes -- can be scheduled by the OS very simply.  Cron, for example, does a great job of this.\nA CherryPy App, also, is an OS process, not a single thread of some larger process.\nJust use processes -- threads won't help you.","Q_Score":9,"Tags":"python,multithreading,sqlite","A_Id":524901,"CreationDate":"2009-02-07T23:18:00.000","Title":"Python, SQLite and threading","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been writing tools in Maya for years using MEL and Python.  I'd consider myself an expert in custom window\/gui design in Maya except for one area; modifying existing panels and editors.\nTypically, I'm building tools that need totally custom UIs, so its customary for me to build them from scratch.  However, recently I've found myself wanting to add some additional functionality to the layer editor in Maya.  I've seen tutorials that explain how to do this, but now that I want to do it, I can't find any.\nLinks to tutorials or a brief code snippet to get me started would be great.  I just need to know how to find the layer editor\/panel and, say, add a button or text field to it.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5048,"Q_Id":527314,"Users Score":1,"Answer":"Have you tried searching ui item names in MEL files under maya installation directory? It should be one of the MEL scripts included, and from there you can just modify it.","Q_Score":1,"Tags":"python,user-interface,maya,panels,mel","A_Id":551109,"CreationDate":"2009-02-09T07:05:00.000","Title":"How to modify existing panels in Maya using MEL or Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to fetch data from a mysql database using sqlalchemy and use the data in a different class.. Basically I fetch a row at a time, use the data, fetch another row, use the data and so on.. I am running into some problem doing this.. \nBasically, how do I output data a row at a time from mysql data?.. I have looked into all tutorials but they are not helping much.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":563,"Q_Id":536051,"Users Score":1,"Answer":"Exactly what problems are you running into?\nYou can simply iterate over the ResultProxy object:\n\nfor row in conn_or_sess_or_engine.execute(selectable_obj_or_SQLstring):\n   do_something_with(row)","Q_Score":0,"Tags":"python,mysql,sqlalchemy","A_Id":536269,"CreationDate":"2009-02-11T09:19:00.000","Title":"Outputting data a row at a time from mysql using sqlalchemy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was working a bit in the python interpreter (python 2.4 on RHEL 5.3), and suddenly found myself in what seems to be a 'vi command mode'. That is, I can edit previous commands with typical vi key bindings, going left with h, deleting with x...\nI love it - the only thing is, I don't know how I got here (perhaps it's through one of the modules I've imported: pylab\/matplotlib?).\nCan anyone shed some light on how to enable this mode in the interpreter?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":10401,"Q_Id":537522,"Users Score":6,"Answer":"For Mac OS X 10.10.3, python2.7, vi mode can be configured by placing bind -v in ~\/.editrc.  The last few paragraphs of the man page hint at this.","Q_Score":32,"Tags":"python,vi","A_Id":29808730,"CreationDate":"2009-02-11T16:11:00.000","Title":"Standard python interpreter has a vi command mode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application?  Within a single module?  Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":234,"Q_Id":543140,"Users Score":2,"Answer":"I am not sure that I ever think about it like this. \nOnce you start \"thinking in Ruby\" the multi-paradigms just merge into ... well, Ruby. \nRuby is object-oriented, but I find that other things such as the functional aspect tend to mean that some of the \"traditional\" design patters present in OO languages are just simply not relevant. The iterator is a classic example ... iteration is something that is handled elegantly in Ruby and the heavy-weight OO iteration patterns no longer really apply. This seems to be true throughout the language.","Q_Score":2,"Tags":"python,ruby,coding-style","A_Id":579842,"CreationDate":"2009-02-12T20:41:00.000","Title":"Granularity of Paradigm Mixing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application?  Within a single module?  Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":234,"Q_Id":543140,"Users Score":2,"Answer":"Different paradigms mix in different ways.  For example, Using OOP doesn't eliminate the use of subroutines and procedural code from an outside library.  It merely moves the procedures around into a different place.\nIt is impossible to purely program with one paradigm.  You may think you have a single one in mind when you program, but that's your illusion.  Your resultant code will land along the borders and within the bounds of many paradigms.","Q_Score":2,"Tags":"python,ruby,coding-style","A_Id":543166,"CreationDate":"2009-02-12T20:41:00.000","Title":"Granularity of Paradigm Mixing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application?  Within a single module?  Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":234,"Q_Id":543140,"Users Score":0,"Answer":"Different problems require different solutions, but it helps if you solve things the same way in the same layer. And varying to wildly will just confuse you and everyone else in the project.\nFor C++, I've found that statically typed OOP (use zope.interface in Python) work well for higher-level parts (connecting, updating, signaling, etc) and functional stuff solves many lower-level problems (parsing, nuts 'n bolts data processing, etc) more nicely. \nAnd usually, a dynamically typed scripting system is good for selecting and configuring the specific app, game level, whatnot. This may be the language itself (i.e. Python)  or something else (an xml-script engine + necessary system for dynamic links in C++).","Q_Score":2,"Tags":"python,ruby,coding-style","A_Id":622514,"CreationDate":"2009-02-12T20:41:00.000","Title":"Granularity of Paradigm Mixing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application?  Within a single module?  Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":234,"Q_Id":543140,"Users Score":1,"Answer":"Mixing paradigms has an advantage of letting you express solutions in most natural and esy way.  Which is very good thing when it help keeping your program logic smaller.  For example, filtering a list by some criteria is several times simpler to express with functional solution compared to traditional loop.\nOn the other hand, to get benefit from mixing two or more paradigms programmer should be reasonably fluent with all of them.  So this is powerful tool that should be used with care.","Q_Score":2,"Tags":"python,ruby,coding-style","A_Id":583881,"CreationDate":"2009-02-12T20:41:00.000","Title":"Granularity of Paradigm Mixing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest.\nWhich is the fastest method, and why?\n\nUsing import on a .py file that just contains the list assigned to a variable\nUsing cPickle's load\nSome other method (perhaps numpy?)\n\nAlso, how can one benchmark such things reliably?\nAddendum: measuring this reliably is difficult, because import is cached so it can't be executed multiple times in a test. The loading with pickle also gets faster after the first time probably because page-precaching by the OS. Loading 1 million numbers with cPickle takes 1.1 sec the first time run, and 0.2 sec on subsequent executions of the script.\nIntuitively I feel cPickle should be faster, but I'd appreciate numbers (this is quite a challenge to measure, I think). \nAnd yes, it's important for me that this performs quickly.\nThanks","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":8359,"Q_Id":556730,"Users Score":1,"Answer":"cPickle will be the fastest since it is saved in binary and no real python code has to be parsed.\nOther advantates are that it is more secure (since it does not execute commands) and you have no problems with setting $PYTHONPATH correctly.","Q_Score":11,"Tags":"python,serialization,caching","A_Id":556961,"CreationDate":"2009-02-17T13:16:00.000","Title":"Python list serialization - fastest method","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create my first site in Django and as I'm looking for example apps out there to draw inspiration from, I constantly stumble upon a term called \"reusable apps\".\nI understand the concept of an app  that is reusable easy enough, but the means of reusing an app in Django are quite lost for me. Few questions that are bugging me in the whole business are:\nWhat is the preferred way to re-use an existing Django app? Where do I put it and how do I reference it?\nFrom what I understand, the recommendation is to put it on your \"PYTHONPATH\", but that breaks as soon as I need to deploy my app to a remote location that I have limited access to (e.g. on a hosting service).\nSo, if I develop my site on my local computer and intend to deploy it on an ISP where I only have ftp access, how do I re-use 3rd party Django apps so that if I deploy my site, the site keeps working (e.g. the only thing I can count on is that the service provider has Python 2.5 and Django 1.x installed)?\nHow do I organize my Django project so that I could easily deploy it along with all of the reusable apps I want to use?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3945,"Q_Id":557171,"Users Score":2,"Answer":"An old question, but here's what I do:\nIf you're using a version control system (VCS), I suggest putting all of the reusable apps and libraries (including django) that your software needs in the VCS. If you don't want to put them directly under your project root, you can modify settings.py to add their location to sys.path.\nAfter that deployment is as simple as cloning or checking out the VCS repository to wherever you want to use it.\nThis has two added benefits:\n\nVersion mismatches; your software always uses the version that you tested it with, and not the version that was available at the time of deployment.\nIf multiple people work on the project, nobody else has to deal with installing the dependencies.\n\nWhen it's time to update a component's version, update it in your VCS and then propagate the update to your deployments via it.","Q_Score":22,"Tags":"python,django,code-reuse","A_Id":3710136,"CreationDate":"2009-02-17T14:50:00.000","Title":"How to re-use a reusable app in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the cleanest way to convert an integer to base64 (and back again) using Python.\nThe base64 module has methods for dealing with bytestrings - so maybe one solution would be to convert an integer to its binary representation as a Python string... but I'm not sure how to do that either.","AnswerCount":15,"Available Count":2,"Score":0.0532828229,"is_accepted":false,"ViewCount":34136,"Q_Id":561486,"Users Score":4,"Answer":"Base64 takes 4 bytes\/characters to encode 3 bytes and can only encode multiples of 3 bytes (and adds padding otherwise).\nSo representing 4 bytes (your average int) in Base64 would take 8 bytes. Encoding the same 4 bytes in hex would also take 8 bytes. So you wouldn't gain anything for a single int.","Q_Score":68,"Tags":"python,url,base64","A_Id":561534,"CreationDate":"2009-02-18T15:25:00.000","Title":"How to convert an integer to the shortest url-safe string in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the cleanest way to convert an integer to base64 (and back again) using Python.\nThe base64 module has methods for dealing with bytestrings - so maybe one solution would be to convert an integer to its binary representation as a Python string... but I'm not sure how to do that either.","AnswerCount":15,"Available Count":2,"Score":0.0266603475,"is_accepted":false,"ViewCount":34136,"Q_Id":561486,"Users Score":2,"Answer":"If you are looking for a way to shorten the integer representation using base64, I think you need to look elsewhere. When you encode something with base64 it doesn't get shorter, in fact it gets longer. \nE.g. 11234 encoded with base64 would yield MTEyMzQ=\nWhen using base64 you have overlooked the fact that you are not converting just the digits (0-9) to a 64 character encoding. You are converting 3 bytes into 4 bytes so you are guaranteed your base64 encoded string would be 33.33% longer.","Q_Score":68,"Tags":"python,url,base64","A_Id":561547,"CreationDate":"2009-02-18T15:25:00.000","Title":"How to convert an integer to the shortest url-safe string in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as \"The Python Way\". I know build scripts and glue scripts are not really the most exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python.\nAm I really missing something?\n(Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)","AnswerCount":16,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":3078,"Q_Id":566865,"Users Score":4,"Answer":"Think like this:\n\nIf you are writing too much for little work, something is wrong, this is not pythonic.\n\nMost Python code you will write is very simple and direct. Usually you don't need much work for anything simple. If you are writing too much, stop and think if there is a better way. (and this is how I learned many things in Python!)","Q_Score":16,"Tags":"python","A_Id":4105859,"CreationDate":"2009-02-19T19:50:00.000","Title":"Python: Am I missing something?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as \"The Python Way\". I know build scripts and glue scripts are not really the most exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python.\nAm I really missing something?\n(Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)","AnswerCount":16,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":3078,"Q_Id":566865,"Users Score":2,"Answer":"Write some Python code and post it on SO for review and feedback whether it is pythonic.","Q_Score":16,"Tags":"python","A_Id":689204,"CreationDate":"2009-02-19T19:50:00.000","Title":"Python: Am I missing something?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as \"The Python Way\". I know build scripts and glue scripts are not really the most exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python.\nAm I really missing something?\n(Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)","AnswerCount":16,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3078,"Q_Id":566865,"Users Score":0,"Answer":"To echo TLHOLADAY, read the standard library.  That's where the \"pythonic\" stuff is.  If you're not getting a good feel there, then read the source for sqlachemy or django or your project of choice.","Q_Score":16,"Tags":"python","A_Id":571297,"CreationDate":"2009-02-19T19:50:00.000","Title":"Python: Am I missing something?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as \"The Python Way\". I know build scripts and glue scripts are not really the most exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python.\nAm I really missing something?\n(Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)","AnswerCount":16,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3078,"Q_Id":566865,"Users Score":0,"Answer":"I would suggest finding a personal python guru.  Show them some of your code and have them review\/rewrite it into idiomatic python.  Thus will you be enlightened.","Q_Score":16,"Tags":"python","A_Id":569123,"CreationDate":"2009-02-19T19:50:00.000","Title":"Python: Am I missing something?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as \"The Python Way\". I know build scripts and glue scripts are not really the most exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python.\nAm I really missing something?\n(Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)","AnswerCount":16,"Available Count":5,"Score":0.0374824318,"is_accepted":false,"ViewCount":3078,"Q_Id":566865,"Users Score":3,"Answer":"To add to the answers of Andrew Hare and Baishampayan Ghose...\nTo learn the idiom of any language must involve reading code written in that idiom. I'm still learning the Python idiom, but I've been through this with other languages. I can read about list comprehensions, but the lightbulb only really comes on when you see such things in use and say, \"Wow! That's awesome! Two lines of code and it's crystal clear!\" So go find some pythonic code that you find interesting and start reading it and understanding it. The knowledge will stay in your head better if you see everything in the context of a working program.","Q_Score":16,"Tags":"python","A_Id":566934,"CreationDate":"2009-02-19T19:50:00.000","Title":"Python: Am I missing something?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working at some plots and statistics for work and I am not sure how I can do some statistics using numpy: I have a list of prices and another one of basePrices. And I want to know how many prices are with X percent above basePrice, how many are with Y percent above basePrice.\nIs there a simple way to do that using numpy?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1834,"Q_Id":570137,"Users Score":1,"Answer":"In addition to df's answer, if you want to know the specific prices that are above the base prices, you can do:\nprices[prices > (1.10 * base_prices)]","Q_Score":1,"Tags":"python,numpy","A_Id":570197,"CreationDate":"2009-02-20T16:04:00.000","Title":"Statistics with numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically. \nBasically I just want to run through the database and make some calculations\/updates on an automatic, regular basis, but I can't seem to find any documentation on doing this.\nDoes anyone know how to set this up?\nTo clarify:  I know I can set up a cron job to do this, but I'm curious if there is some feature in Django that provides this functionality.   I'd like people to be able to deploy this app themselves without having to do much config (preferably zero).\nI've considered triggering these actions \"retroactively\" by simply checking if a job should have been run since the last time a request was sent to the site, but I'm hoping for something a bit cleaner.","AnswerCount":24,"Available Count":1,"Score":0.0166651236,"is_accepted":false,"ViewCount":206437,"Q_Id":573618,"Users Score":2,"Answer":"I had something similar with your problem today.\nI didn't wanted to have it handled by the server trhough cron (and most of the libs were just cron helpers in the end).\nSo i've created a scheduling module and attached it to the init .\nIt's not the best approach, but it helps me to have all the code in a single place and with its execution related to the main app.","Q_Score":567,"Tags":"python,django,web-applications,scheduled-tasks","A_Id":7287891,"CreationDate":"2009-02-21T19:39:00.000","Title":"Set up a scheduled job?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.\nSo how can it be done?\n\nApache Mod-wsgi (the other mod-wsgi's seem to not be worth it)\nPure Python web server eg paste, cherrypy, Spawning, Twisted.web\nas 2 but with reverse proxy from nginx, apache2 etc, with good static file handling\nConversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server.\n\nMore?\nI want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.","AnswerCount":9,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":14313,"Q_Id":574068,"Users Score":3,"Answer":"Apache httpd + mod_fcgid using web.py (which is a wsgi application).\nWorks like a charm.","Q_Score":42,"Tags":"python,deployment,wsgi","A_Id":612622,"CreationDate":"2009-02-22T00:58:00.000","Title":"How do YOU deploy your WSGI application? (and why it is the best way)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.\nSo how can it be done?\n\nApache Mod-wsgi (the other mod-wsgi's seem to not be worth it)\nPure Python web server eg paste, cherrypy, Spawning, Twisted.web\nas 2 but with reverse proxy from nginx, apache2 etc, with good static file handling\nConversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server.\n\nMore?\nI want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":14313,"Q_Id":574068,"Users Score":1,"Answer":"We are using pure Paste for some of our web services.  It is easy to deploy (with our internal deployment mechanism; we're not using Paste Deploy or anything like that) and it is nice to minimize the difference between production systems and what's running on developers' workstations.  Caveat: we don't expect low latency out of Paste itself because of the heavyweight nature of our requests.  In some crude benchmarking we did we weren't getting fantastic results; it just ended up being moot due to the expense of our typical request handler.  So far it has worked fine.\nStatic data has been handled by completely separate (and somewhat \"organically\" grown) stacks, including the use of S3, Akamai, Apache and IIS, in various ways.","Q_Score":42,"Tags":"python,deployment,wsgi","A_Id":612607,"CreationDate":"2009-02-22T00:58:00.000","Title":"How do YOU deploy your WSGI application? (and why it is the best way)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.\nSo how can it be done?\n\nApache Mod-wsgi (the other mod-wsgi's seem to not be worth it)\nPure Python web server eg paste, cherrypy, Spawning, Twisted.web\nas 2 but with reverse proxy from nginx, apache2 etc, with good static file handling\nConversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server.\n\nMore?\nI want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.","AnswerCount":9,"Available Count":4,"Score":0.022218565,"is_accepted":false,"ViewCount":14313,"Q_Id":574068,"Users Score":1,"Answer":"Apache+mod_wsgi,\nSimple, clean. (only four lines of webserver config), easy for other sysadimns to get their head around.","Q_Score":42,"Tags":"python,deployment,wsgi","A_Id":616720,"CreationDate":"2009-02-22T00:58:00.000","Title":"How do YOU deploy your WSGI application? (and why it is the best way)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.\nSo how can it be done?\n\nApache Mod-wsgi (the other mod-wsgi's seem to not be worth it)\nPure Python web server eg paste, cherrypy, Spawning, Twisted.web\nas 2 but with reverse proxy from nginx, apache2 etc, with good static file handling\nConversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server.\n\nMore?\nI want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.","AnswerCount":9,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":14313,"Q_Id":574068,"Users Score":6,"Answer":"Nginx reverse proxy and static file sharing + XSendfile + uploadprogress_module. Nothing beats it for the purpose.\nOn the WSGI side either Apache + mod_wsgi or cherrypy server. I like to use cherrypy wsgi server for applications on servers with less memory and less requests.\nReasoning:\nI've done benchmarks with different tools for different popular solutions.\nI have more experience with lower level TCP\/IP than web development, especially http implementations. I'm more confident that I can recognize a good http server than I can recognize a good web framework.\nI know Twisted much more than Django or Pylons. The http stack in Twisted is still not up to this but it will be there.","Q_Score":42,"Tags":"python,deployment,wsgi","A_Id":635680,"CreationDate":"2009-02-22T00:58:00.000","Title":"How do YOU deploy your WSGI application? (and why it is the best way)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Good morning.\nAs the title indicates, I've got some questions about using python for web development.\n\nWhat is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.\n\nMy major concern when I last tried apache + mod_python + CherryPy was having to reload webserver to see the changes. Is it considered normal? For some reason cherrypy's autoreload didn't work at all.\n\nWhat is the best setup to deploy a working Python app to production and why? I'm now using lighttpd for my PHP web apps, but how would it do for python compared to nginx for example?\nIs it worth diving straight with a framework or to roll something simple of my own? I see that Django has got quite a lot of fans, but I'm thinking it would be overkill for my needs, so I've started looking into CherryPy.\nHow exactly are Python apps served if I have to reload httpd to see the changes? Something like a permanent process spawning child processes, with all the major file includes happening on server start and then just lazy loading needed resources?\nPython supports multithreading, do I need to look into using that for a benefit when developing web apps? What would be that benefit and in what situations?\n\nBig thanks!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2349,"Q_Id":581038,"Users Score":1,"Answer":"When you use mod_python on a threaded Apache server (the default on Windows), CherryPy runs in the same process as Apache. In that case, you almost certainly don't want CP to restart the process.\nSolution: use mod_rewrite or mod_proxy so that CherryPy runs in its own process. Then you can autoreload to your heart's content. :)","Q_Score":12,"Tags":"python,cherrypy","A_Id":582467,"CreationDate":"2009-02-24T09:15:00.000","Title":"Python web programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Good morning.\nAs the title indicates, I've got some questions about using python for web development.\n\nWhat is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.\n\nMy major concern when I last tried apache + mod_python + CherryPy was having to reload webserver to see the changes. Is it considered normal? For some reason cherrypy's autoreload didn't work at all.\n\nWhat is the best setup to deploy a working Python app to production and why? I'm now using lighttpd for my PHP web apps, but how would it do for python compared to nginx for example?\nIs it worth diving straight with a framework or to roll something simple of my own? I see that Django has got quite a lot of fans, but I'm thinking it would be overkill for my needs, so I've started looking into CherryPy.\nHow exactly are Python apps served if I have to reload httpd to see the changes? Something like a permanent process spawning child processes, with all the major file includes happening on server start and then just lazy loading needed resources?\nPython supports multithreading, do I need to look into using that for a benefit when developing web apps? What would be that benefit and in what situations?\n\nBig thanks!","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2349,"Q_Id":581038,"Users Score":8,"Answer":"What is the best setup for a development environment?\nDoesn't much matter.  We use Django, which runs in Windows and Unix nicely.  For production, we use Apache in Red Hat.\nIs having to reload webserver to see the changes considered normal?\nYes.  Not clear why you'd want anything different.  Web application software shouldn't be dynamic.  Content yes.  Software no.\nIn Django, we develop without using a web server of any kind on our desktop.  The Django \"runserver\" command reloads the application under most circumstances.  For development, this works great.  The times when it won't reload are when we've damaged things so badly that the app doesn't properly.\nWhat is the best setup to deploy a working Python app to production and why?\n\"Best\" is undefined in this context.  Therefore, please provide some qualification for \"nest\" (e.g., \"fastest\", \"cheapest\", \"bluest\")\nIs it worth diving straight with a framework or to roll something simple of my own?\nDon't waste time rolling your own.  We use Django because of the built-in admin page that we don't have to write or maintain.  Saves mountains of work.\nHow exactly are Python apps served if I have to reload httpd to see the changes?\nTwo methods:\n\nDaemon - mod_wsgi or mod_fastcgi have a Python daemon process to which they connect.  Change your software.  Restart the daemon.\nEmbedded - mod_wsgi or mod_python have an embedded mode in which the Python interpreter is inside the mod, inside Apache.  You have to restart httpd to restart that embedded interpreter.\n\nDo I need to look into using multi-threaded?\nYes and no.  Yes you do need to be aware of this.  No, you don't need to do very much.  Apache and mod_wsgi and Django should handle this for you.","Q_Score":12,"Tags":"python,cherrypy","A_Id":581356,"CreationDate":"2009-02-24T09:15:00.000","Title":"Python web programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a very basic CSV file upload module working to bulk upload my user's data into my site.  I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload.  This process works ok operationally, but my issue is with the format of the csv file.  \nAre there good tools or even basic rules on how to accept different formats of the csv file?  The user may have a different order of data columns, slightly different names for the column headers (I want the email column to be entitled \"Email\", but it may say \"Primary Email\", \"Email Address\"), or missing additional data columns.  Any good examples of CSV upload functionality that is very permissive and user friendly?\nAlso, how do I tell the user to export as CSV data?  I'm importing address book information, so this data often comes from Outlook, Thunderbird, other software packages that have address books.  Are there other popular data formats that I should accept?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":2198,"Q_Id":586517,"Users Score":1,"Answer":"Look at csv module from stdlib.  It contains presets for popualr CSV dialects like one produced by Excel.\nReader class support field mapping and if file contains column header it coes not depend on column order.  For more complex logic, like looking up several alternative names for a field, you'll need to write your own implementation.","Q_Score":2,"Tags":"jquery,python,django,django-models,csv","A_Id":588212,"CreationDate":"2009-02-25T15:39:00.000","Title":"What are good ways to upload bulk .csv data into a webapp using Django\/Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a very basic CSV file upload module working to bulk upload my user's data into my site.  I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload.  This process works ok operationally, but my issue is with the format of the csv file.  \nAre there good tools or even basic rules on how to accept different formats of the csv file?  The user may have a different order of data columns, slightly different names for the column headers (I want the email column to be entitled \"Email\", but it may say \"Primary Email\", \"Email Address\"), or missing additional data columns.  Any good examples of CSV upload functionality that is very permissive and user friendly?\nAlso, how do I tell the user to export as CSV data?  I'm importing address book information, so this data often comes from Outlook, Thunderbird, other software packages that have address books.  Are there other popular data formats that I should accept?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":2198,"Q_Id":586517,"Users Score":1,"Answer":"If you'll copy excel table into clipboard and then paste results into notepad, you'll notice that it's tab separated. I once used it to make bulk import from most of table editors by copy-pasting data from the editor into textarea on html page.\nYou can use a background for textarea as a hint for number of columns and place your headers at the top suggesting the order for a user. \nJavascript will process pasted data and display them to the user immediately with simple prevalidation making it easy to fix an error and repaste.\nThen import button is clicked, data is validated again and import results are displayed.\nUnfortunately, I've never heard any feedback about whenever this was easy to use or not.\nAnyway, I still see it as an option when implementing bulk import.","Q_Score":2,"Tags":"jquery,python,django,django-models,csv","A_Id":586694,"CreationDate":"2009-02-25T15:39:00.000","Title":"What are good ways to upload bulk .csv data into a webapp using Django\/Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application.\nIs there a pythonic way to do this? Otherwise, how do I achieve this in Unix and Windows?\nedit: I'll try and clarify. Is there a way to check if the current file has been opened by another application?\nI'd like to start with this question. Whether those other application read\/write is irrelevant for now.\nI realize it is probably OS dependent, so this may not really be python related right now.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22009,"Q_Id":589407,"Users Score":0,"Answer":"One thing I've done is have python very temporarily rename the file.  If we're able to rename it, then no other process is using it.  I only tested this on Windows.","Q_Score":9,"Tags":"python,windows,unix,logging,file-io","A_Id":592121,"CreationDate":"2009-02-26T06:44:00.000","Title":"Python - How to check if a file is used by another application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to know a way to call a function defined in the exe from a python script.\nI know how to call entire exe from py file.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2356,"Q_Id":598569,"Users Score":0,"Answer":"Unless the said executable takes command line arguments which will specify which function to use, I don't think this is possible.\nWith that being said, if you created the EXE, command line arguments are a good way to implement the functionality you're looking for.","Q_Score":4,"Tags":"python","A_Id":598571,"CreationDate":"2009-02-28T19:55:00.000","Title":"Calling function defined in exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to know a way to call a function defined in the exe from a python script.\nI know how to call entire exe from py file.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2356,"Q_Id":598569,"Users Score":1,"Answer":"Not sure if it is for windows. But you can treat an exe like a dll (if functions are exported). And they can be used by other programs.","Q_Score":4,"Tags":"python","A_Id":598585,"CreationDate":"2009-02-28T19:55:00.000","Title":"Calling function defined in exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just beginning Python, and I'd like to use an external RSS class.  Where do I put that class and how do I import it?  I'd like to eventually be able to share python programs.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26764,"Q_Id":598668,"Users Score":0,"Answer":"If you want to store your RSS file in a different place use sys.append(\"\") and pout the module in that directory and use\nimport  or from  import *","Q_Score":6,"Tags":"python,python-module,python-import","A_Id":15196925,"CreationDate":"2009-02-28T20:54:00.000","Title":"External classes in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get a package installed on Google App Engine.  The package relies rather extensively on pkg_resources, but there's no way to run setup.py on App Engine.\nThere's no platform-specific code in the source, however, so it's no problem to just zip up the source and include those in the system path.  And I've gotten a version of pkg_resources installed and working as well.\nThe only problem is getting the package actually registered with pkg_resources so when it calls iter_entry_points it can find the appropriate plugins.\nWhat methods do I need to call to register modules on sys.path with all the appropriate metadata, and how do I figure out what that metadata needs to be?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":724,"Q_Id":599205,"Users Score":0,"Answer":"Create a setup.py for the package just as you would normally, and then use \"setup.py sdist --formats=zip\" to build your source zip.  The built source zip will include an .egg-info metadata directory, which will then be findable by pkg_resources.  Alternately, you can use bdist_egg for all your packages.","Q_Score":1,"Tags":"python,google-app-engine,setuptools,pkg-resources","A_Id":2164138,"CreationDate":"2009-03-01T03:40:00.000","Title":"How can I manually register distributions with pkg_resources?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get a package installed on Google App Engine.  The package relies rather extensively on pkg_resources, but there's no way to run setup.py on App Engine.\nThere's no platform-specific code in the source, however, so it's no problem to just zip up the source and include those in the system path.  And I've gotten a version of pkg_resources installed and working as well.\nThe only problem is getting the package actually registered with pkg_resources so when it calls iter_entry_points it can find the appropriate plugins.\nWhat methods do I need to call to register modules on sys.path with all the appropriate metadata, and how do I figure out what that metadata needs to be?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":724,"Q_Id":599205,"Users Score":0,"Answer":"On your local development system, run python setup.py bdist_egg, which will create a Zip archive with the necessary metadata included. Add it to your sys.path, and it should work properly.","Q_Score":1,"Tags":"python,google-app-engine,setuptools,pkg-resources","A_Id":744882,"CreationDate":"2009-03-01T03:40:00.000","Title":"How can I manually register distributions with pkg_resources?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python web client that uses urllib2.  It is easy enough to add HTTP headers to my outgoing requests. I just create a dictionary of the headers I want to add, and pass it to the Request initializer.\nHowever, other \"standard\" HTTP headers get added to the request as well as the custom ones I explicitly add.  When I sniff the request using Wireshark, I see headers besides the ones I add myself.  My question is how do a I get access to these headers?  I want to log every request (including the full set of HTTP headers), and can't figure out how.\nany pointers?\nin a nutshell:  How do I get all the outgoing headers from an HTTP request created by urllib2?","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14482,"Q_Id":603856,"Users Score":0,"Answer":"see urllib2.py:do_request (line 1044 (1067)) and urllib2.py:do_open (line 1073)\n(line 293) self.addheaders = [('User-agent', client_version)] (only 'User-agent' added)","Q_Score":15,"Tags":"python,urllib2","A_Id":603916,"CreationDate":"2009-03-02T20:24:00.000","Title":"How do you get default headers in a urllib2 Request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)\nAre there any standard protocols for this? I've heard about STUN but I don't know how can I use it?\nP.S. I'm planning on writing a short python script to do it","AnswerCount":16,"Available Count":3,"Score":0.0374824318,"is_accepted":false,"ViewCount":19213,"Q_Id":613471,"Users Score":3,"Answer":"Your simplest way may be to ask some server on the outside of your network.\nOne thing to keep in mind is that different destinations may see a different address for you. The router may be multihomed. And really that's just where problems begin.","Q_Score":28,"Tags":"python,ip-address,tcp","A_Id":613477,"CreationDate":"2009-03-05T03:18:00.000","Title":"Discovering public IP programmatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)\nAre there any standard protocols for this? I've heard about STUN but I don't know how can I use it?\nP.S. I'm planning on writing a short python script to do it","AnswerCount":16,"Available Count":3,"Score":0.012499349,"is_accepted":false,"ViewCount":19213,"Q_Id":613471,"Users Score":1,"Answer":"Here are a few public services that support IPv4 and IPv6:\n\ncurl http:\/\/icanhazip.com\ncurl http:\/\/www.trackip.net\/ip\ncurl https:\/\/ipapi.co\/ip\ncurl http:\/\/api6.ipify.org\ncurl http:\/\/www.cloudflare.com\/cdn-cgi\/trace\ncurl http:\/\/checkip.dns.he.net\n\nThe following seem to support only IPv4 at this time:\n\ncurl http:\/\/bot.whatismyipaddress.com\ncurl http:\/\/checkip.dyndns.org\ncurl http:\/\/ifconfig.me\ncurl http:\/\/ip-api.com\ncurl http:\/\/api.infoip.io\/ip\n\nIt's easy to make an HTTP call programmatically. So all should be relatively easy to use, and you can try multiple different URLs in case one fails.","Q_Score":28,"Tags":"python,ip-address,tcp","A_Id":60525518,"CreationDate":"2009-03-05T03:18:00.000","Title":"Discovering public IP programmatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results)\nAre there any standard protocols for this? I've heard about STUN but I don't know how can I use it?\nP.S. I'm planning on writing a short python script to do it","AnswerCount":16,"Available Count":3,"Score":0.0374824318,"is_accepted":false,"ViewCount":19213,"Q_Id":613471,"Users Score":3,"Answer":"If the network has an UpNp server running on the gateway you are able to talk to the gateway and ask it for your outside IP address.","Q_Score":28,"Tags":"python,ip-address,tcp","A_Id":613518,"CreationDate":"2009-03-05T03:18:00.000","Title":"Discovering public IP programmatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I often need to execute custom sql queries in django, and manually converting query results into objects every time is kinda painful. I wonder how fellow Slackers deal with this. Maybe someone had written some kind of a library to help dealing with custom SQL in Django?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3263,"Q_Id":619384,"Users Score":3,"Answer":"Since the issue is \"manually converting query results into objects,\" the simplest solution is often to see if your custom SQL can fit into an ORM .extra() call rather than being a pure-SQL query.  Often it can, and then you let the ORM do all the work of building up objects as usual.","Q_Score":2,"Tags":"python,django,orm","A_Id":620117,"CreationDate":"2009-03-06T16:11:00.000","Title":"Tools to ease executing raw SQL with Django ORM","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue.","AnswerCount":7,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2509,"Q_Id":623054,"Users Score":13,"Answer":"You will probably find your application is bandwidth limited not CPU or I\/O limited.\nAs such, add as many as you like until performance begins to degrade.\nYou may come up against other limits depending on your network setup.  Like if you're behind an ADSL router, there will be a limit on the number of concurrent NAT sessions, which may impact making too many HTTP requests at once.  Make too many and your provider may treat you as being infected by a virus or the like.\nThere's also the issue of how many requests the server you're crawling can handle and how much of a load you want to put on it.\nI wrote a crawler once that used just one thread.  It took about a day to process all the information I wanted at about one page every two seconds.  I could've done it faster but I figured this was less  of a burden for the server.\nSo really theres no hard and fast answer.  Assuming a 1-5 megabit connection I'd say you could easily have up to 20-30 threads without any problems.","Q_Score":3,"Tags":"python,multithreading","A_Id":623070,"CreationDate":"2009-03-08T04:44:00.000","Title":"For my app, how many threads would be optimal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue.","AnswerCount":7,"Available Count":3,"Score":0.0855049882,"is_accepted":false,"ViewCount":2509,"Q_Id":623054,"Users Score":3,"Answer":"It's usually simpler to make multiple concurrent processes.  Simply use subprocess to create as many Popens as you feel it necessary to run concurrently.\nThere's no \"optimal\" number.  Generally, when you run just one crawler, your PC spends a lot of time waiting.  How much?  Hard to say.\nWhen you're running some small number of concurrent crawlers, you'll see that they take about the same amount of time as one.  Your CPU switches among the various processes, filling up the wait time on one with work on the others.\nYou you run some larger number, you see that the overall elapsed time is longer because there's now more to do than your CPU can manage.  So the overall process takes longer.\nYou can create a graph that shows how the process scales.  Based on this you can balance the number of processes and your desirable elapsed time.\nThink of it this way.  \n1 crawler does it's job in 1 minute.  100 pages done serially could take a 100 minutes.  100 crawlers concurrently might take on hour.  Let's say that 25 crawlers finishes the job in 50 minutes.\nYou don't know what's optimal until you run various combinations and compare the results.","Q_Score":3,"Tags":"python,multithreading","A_Id":623064,"CreationDate":"2009-03-08T04:44:00.000","Title":"For my app, how many threads would be optimal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue.","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":2509,"Q_Id":623054,"Users Score":1,"Answer":"One thing you should keep in mind is that some servers may interpret too many concurrent requests from the same IP address as a DoS attack and abort connections or return error pages for requests that would otherwise succeed.\nSo it might be a good idea to limit the number of concurrent requests to the same server to a relatively low number (5 should be on the safe side).","Q_Score":3,"Tags":"python,multithreading","A_Id":623515,"CreationDate":"2009-03-08T04:44:00.000","Title":"For my app, how many threads would be optimal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I know one can set the session timeout. But, if the application itself has received no requests for a given period of time, IIS shuts down the application.\nThis behavior is configurable in the IIS management console, and I know how to do this. Still, I wonder if it is possible to configure this in web.config.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13542,"Q_Id":625614,"Users Score":5,"Answer":"Not in IIS 6.  In IIS 6, Application Pools are controlled by Worker Processes, which map to a Request Queue handled by HTTP.sys.  HTTP.sys handles the communication with the WWW Server to determine when to start and stop Worker Processes.\nSince IIS 6 was created before .Net, there's no communication hooks between .Net and the low-level http handlers.  \nASP.net is implimented as an ISAPI filter, which is loaded by the Worker Process itself.  You have a chicken-before-the-egg issue if you are looking at the web.config controlling a worker process.  This is primarily why MS did the major re-write of IIS 7 which integrates .Net through the entire request life-cycle, not just the ISAPI filter portion.","Q_Score":15,"Tags":"iis,web-config,application-pool,python-idle","A_Id":627740,"CreationDate":"2009-03-09T09:57:00.000","Title":"Is there a way to configure the Application Pool's \"Idle timeout\" in web.config?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like my application to store some data for access by all users. Using Python, how can I find where the data should go?","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":60928,"Q_Id":626796,"Users Score":3,"Answer":"You can access all of your OS environment variables using the os.environ dictionary in the os module.  Choosing which key to use from that dictionary could be tricky, though.  In particular, you should remain aware of internationalized (i.e., non-English) versions of Windows when using these paths.\nos.environ['ALLUSERSPROFILE'] should give you the root directory for all users on the computer, but after that be careful not to hard code subdirectory names like \"Application Data,\" because these directories don't exist on non-English versions of Windows.  For that matter, you may want to do some research on what versions of Windows you can expect to have the ALLUSERSPROFILE environment variable set (I don't know myself -- it may be universal).\nMy XP machine here has a COMMONAPPDATA environment variable which points to the All Users\\Application Data folder, but my Win2K3 system does not have this environment variable.","Q_Score":31,"Tags":"python,windows,application-data,common-files","A_Id":627071,"CreationDate":"2009-03-09T15:48:00.000","Title":"How do I find the Windows common application data folder using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anybody know if Python has an equivalent to Java's SortedSet interface?\nHeres what I'm looking for: lets say I have an object of type foo, and I know how to compare two objects of type foo to see whether foo1 is \"greater than\" or \"less than\" foo2. I want a way of storing many objects of type foo in a list L, so that whenever I traverse the list L, I get the objects in order, according to the comparison method I define.\nEdit:\nI guess I can use a dictionary or a list and sort() it every time I modify it, but is this the best way?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9278,"Q_Id":628192,"Users Score":0,"Answer":"Do you have the possibility of using Jython? I just mention it because using TreeMap, TreeSet, etc. is trivial.  Also if you're coming from a Java background and you want to head in a Pythonic direction Jython is wonderful for making the transition easier.  Though I recognise that use of TreeSet in this case would not be part of such a \"transition\".\nFor Jython superusers I have a question myself: the blist package can't be imported because it uses a C file which must be imported. But would there be any advantage of using blist instead of TreeSet? Can we generally assume the JVM uses algorithms which are essentially as good as those of CPython stuff?","Q_Score":22,"Tags":"python,data-structures","A_Id":20666684,"CreationDate":"2009-03-09T21:58:00.000","Title":"Python equivalent to java.util.SortedSet?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).\nIs there a way, and how can I do that?","AnswerCount":10,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":520059,"Q_Id":633127,"Users Score":5,"Answer":"In my Python 2.7 interpreter, the same whos command that exists in MATLAB exists in Python. It shows the same details as the MATLAB analog (variable name, type, and value\/data).\nNote that in the Python interpreter, whos lists all variables in the \"interactive namespace\".","Q_Score":352,"Tags":"python,variables","A_Id":21862978,"CreationDate":"2009-03-11T02:32:00.000","Title":"Viewing all defined variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).\nIs there a way, and how can I do that?","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":520059,"Q_Id":633127,"Users Score":437,"Answer":"A few things you could use:\n\ndir() will give you the list of in scope variables:\nglobals() will give  you a dictionary of global variables\nlocals() will give you a dictionary of local variables","Q_Score":352,"Tags":"python,variables","A_Id":633134,"CreationDate":"2009-03-11T02:32:00.000","Title":"Viewing all defined variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).\nIs there a way, and how can I do that?","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":520059,"Q_Id":633127,"Users Score":16,"Answer":"globals(), locals(), vars(), and dir() may all help you in what you want.","Q_Score":352,"Tags":"python,variables","A_Id":633136,"CreationDate":"2009-03-11T02:32:00.000","Title":"Viewing all defined variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if someone could help me out.  In some web application, the app will send out emails, say when a new message has been posted.  Then instead of signing into the application to post a reply you can just simply reply to the email and it will automatically update the web app with your response.\nMy question is, how is this done and what is it called?\nThanks","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1824,"Q_Id":640970,"Users Score":7,"Answer":"Generally:\n1) Set up a dedicated email account for the purpose.\n2) Have a programm monitor the mailbox (let's say fetchmail, since that's what I do).\n3) When an email arrives at the account, fetchmail downloads the email, writes it to disk, and calls script or program you have written with the email file as an argument.\n4) Your script or program parses the email and takes an appropriate action.\nThe part that's usually mysterious to people is the fetchmail part (#2).\nSpecifically on Mail Servers (iff you control the mailserver enough to redirect emails to scripts):\n1-3) Configure an address to be piped to a script you have written.\n4) Same as above.","Q_Score":12,"Tags":"python,django,email","A_Id":641004,"CreationDate":"2009-03-13T00:09:00.000","Title":"Email integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm in the middle of web-based filesystem abstraction layer development. \nJust like file browser, except it has some extra features like freaky permissions etc. \nI would like users to be notified somehow about directory changes. \nSo, i.e. when someone uploads a new file via FTP, certain users should get a proper message. It is not required for the message to be extra detailed, I don't really need to show the exact resource changed. The parent directory name should be enough.\nWhat approach would you recommend?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2053,"Q_Id":649623,"Users Score":0,"Answer":"A simple approach would be to monitor\/check the last modification date of the working directory (using os.stat() for example). \nWhenever a file in a directory is modified, the working directory's (the directory the file is in) last modification date changes as well.\nAt least this works on the filesystems I am working on (ufs, ext3). I'm not sure if all filesystems do it this way.","Q_Score":3,"Tags":"python,file,filesystems,checksum","A_Id":649665,"CreationDate":"2009-03-16T08:22:00.000","Title":"Directory checksum with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"OMG!\nWhat an apparent problem... my django based scripts have locked my sqlite db...\nDoes anyone know how to fix?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4579,"Q_Id":652750,"Users Score":6,"Answer":"Your database is locked because you have a transaction running somewhere.  \nStop all your Django apps.  If necessary, reboot.\nIt's also remotely possible that you crashed a SQLite client in the middle of a transaction and the file lock was left in place.","Q_Score":1,"Tags":"python,django","A_Id":652758,"CreationDate":"2009-03-17T01:33:00.000","Title":"How to unlock an sqlite3 db?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to find some examples but no luck. Does anyone know of some examples on the net? I would like to know what it returns when it can't find, and how to specify from start to end, which I guess is going to be 0, -1.","AnswerCount":9,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":376942,"Q_Id":674764,"Users Score":0,"Answer":"if x is a string and you search for y which also a string  their is two cases :\ncase 1: y is exist in x so  x.find(y) = the index (the position) of the y in x .\ncase 2: y is not exist so   x.find (y) = -1 this mean y is not found in x.","Q_Score":63,"Tags":"python,string,find","A_Id":48610988,"CreationDate":"2009-03-23T18:57:00.000","Title":"Examples for string find in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes. \nThe \"player\" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.\nAn \"editor\" process is any editor for that database: it changes the database constantly.\nNow I want the player to reflect the editing changes quickly.\nI know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes.\nI could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size.\nI am thinking about using a log table and triggers, but I wonder if there is a simpler method.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":15631,"Q_Id":677028,"Users Score":2,"Answer":"Just open a socket between the two processes and have the editor tell all the players about the update.","Q_Score":15,"Tags":"python,sqlite,notifications","A_Id":677042,"CreationDate":"2009-03-24T11:34:00.000","Title":"How do I notify a process of an SQLite database change done in a different process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes. \nThe \"player\" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.\nAn \"editor\" process is any editor for that database: it changes the database constantly.\nNow I want the player to reflect the editing changes quickly.\nI know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes.\nI could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size.\nI am thinking about using a log table and triggers, but I wonder if there is a simpler method.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":15631,"Q_Id":677028,"Users Score":2,"Answer":"I think in that case, I would make a process to manage the database read\/writes.\nEach editor that want to make some modifications to the database makes a call to this proccess, be it through IPC or network, or whatever method.\nThis process can then notify the player of a change in the database. The player, when he wants to retrieve some data should make a request of the data it wants to the process managing the database. (Or the db process tells it what it needs, when it notifies of a change, so no request from the player needed)\nDoing this will have the advantage of having only one process accessing the SQLite DB, so no locking or concurrency issues on the database.","Q_Score":15,"Tags":"python,sqlite,notifications","A_Id":677215,"CreationDate":"2009-03-24T11:34:00.000","Title":"How do I notify a process of an SQLite database change done in a different process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes. \nThe \"player\" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.\nAn \"editor\" process is any editor for that database: it changes the database constantly.\nNow I want the player to reflect the editing changes quickly.\nI know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes.\nI could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size.\nI am thinking about using a log table and triggers, but I wonder if there is a simpler method.","AnswerCount":8,"Available Count":5,"Score":0.049958375,"is_accepted":false,"ViewCount":15631,"Q_Id":677028,"Users Score":2,"Answer":"If it's on the same machine, the simplest way would be to have named pipe, \"player\" with blocking read() and \"editors\" putting a token in pipe whenever they modify DB.","Q_Score":15,"Tags":"python,sqlite,notifications","A_Id":677087,"CreationDate":"2009-03-24T11:34:00.000","Title":"How do I notify a process of an SQLite database change done in a different process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes. \nThe \"player\" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.\nAn \"editor\" process is any editor for that database: it changes the database constantly.\nNow I want the player to reflect the editing changes quickly.\nI know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes.\nI could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size.\nI am thinking about using a log table and triggers, but I wonder if there is a simpler method.","AnswerCount":8,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":15631,"Q_Id":677028,"Users Score":4,"Answer":"A relational database is not your best first choice for this.\nWhy?\nYou want all of your editors to pass changes to your player.  \nYour player is -- effectively -- a server for all those editors.  Your player needs multiple open connections.  It must listen to all those connections for changes.  It must display those changes.\nIf the changes are really large, you can move to a hybrid solution where the editors persist the changes and notify the player.  \nEither way, the editors must notify they player that they have a change.  It's much, much simpler than the player trying to discover changes in a database.\n\nA better design is a server which accepts messages from the editors, persists them, and notifies the player.  This server is neither editor nor player, but merely a broker that assures that all the messages are handled.  It accepts connections from editors and players.  It manages the database.\nThere are two implementations.  Server IS the player.  Server is separate from the player.  The design of server doesn't change -- only the protocol.  When server is the player, then server calls the player objects directly.  When server is separate from the player, then the server writes to the player's socket.\nWhen the player is part of the server, player objects are invoked directly when a message is received from an editor.  When the player is separate, a small reader collects the messages from a socket and calls the player objects.\nThe player connects to the server and then waits for a stream of information.  This can either be input from the editors or references to data that the server persisted in the database.\nIf your message traffic is small enough so that network latency is not a problem, editor sends all the data to the server\/player.  If message traffic is too large, then the editor  writes to a database and sends a message with just a database FK to the server\/player.  \n\nPlease clarify \"If the editor crashes while notifying, the player is permanently messed up\" in your question.\nThis sounds like a poor design for the player service.  It can't be \"permanently messed up\" unless it's not getting state from the various editors.  If it's getting state from the editors (but attempting to mirror that state, for example) then you should consider a design where the player simply gets state from the editor and cannot get \"permanently messed up\".","Q_Score":15,"Tags":"python,sqlite,notifications","A_Id":677085,"CreationDate":"2009-03-24T11:34:00.000","Title":"How do I notify a process of an SQLite database change done in a different process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have two or more processes dealing with an SQLite database - a \"player\" process and many \"editor\" processes. \nThe \"player\" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database.\nAn \"editor\" process is any editor for that database: it changes the database constantly.\nNow I want the player to reflect the editing changes quickly.\nI know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes.\nI could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size.\nI am thinking about using a log table and triggers, but I wonder if there is a simpler method.","AnswerCount":8,"Available Count":5,"Score":0.024994793,"is_accepted":false,"ViewCount":15631,"Q_Id":677028,"Users Score":1,"Answer":"How many editor processes (why processes?), and how often do you expect updates? This doesn't sound like a good design, especially not considering sqlite really isn't too happy about multiple concurrent accesses to the database.\nIf multiple processes makes sense and you want persistence, it would probably be smarter to have the editors notify your player via sockets, pipes, shared memory or the like and then have the player (aka server process) do the persisting.","Q_Score":15,"Tags":"python,sqlite,notifications","A_Id":677169,"CreationDate":"2009-03-24T11:34:00.000","Title":"How do I notify a process of an SQLite database change done in a different process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python 2.5.2. How can I tell whether it is CPython or IronPython or Jython?\nAnother question: how can I use a DLL developed in VB.NET in my project?","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":6072,"Q_Id":680207,"Users Score":4,"Answer":"If you are typing \"python\" to launch it, it is probably CPython. IronPython's executable name is \"ipy\".","Q_Score":4,"Tags":"python","A_Id":680227,"CreationDate":"2009-03-25T04:23:00.000","Title":"How do I tell which Python interpreter I'm using?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I often test my module in the Python Interpreter, and when I see an error, I quickly update the .py file. But how do I make it reflect on the Interpreter ? So, far I have been exiting and reentering the Interpreter because re importing the file again is not working for me.","AnswerCount":11,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":297115,"Q_Id":684171,"Users Score":38,"Answer":"So, far I have been exiting and reentering the Interpreter because re importing the file again is not working for me.\n\nYes, just saying import again gives you the existing copy of the module from sys.modules.\nYou can say reload(module) to update sys.modules and get a new copy of that single module, but if any other modules have a reference to the original module or any object from the original module, they will keep their old references and Very Confusing Things will happen.\nSo if you've got a module a, which depends on module b, and b changes, you have to \u2018reload b\u2019 followed by \u2018reload a\u2019. If you've got two modules which depend on each other, which is extremely common when those modules are part of the same package, you can't reload them both: if you reload p.a it'll get a reference to the old p.b, and vice versa. The only way to do it is to unload them both at once by deleting their items from sys.modules, before importing them again. This is icky and has some practical pitfalls to do with modules entries being None as a failed-relative-import marker.\nAnd if you've got a module which passes references to its objects to system modules\u2009\u2014\u2009for example it registers a codec, or adds a warnings handler\u2009\u2014\u2009you're stuck; you can't reload the system module without confusing the rest of the Python environment.\nIn summary: for all but the simplest case of one self-contained module being loaded by one standalone script, reload() is very tricky to get right; if, as you imply, you are using a \u2018package\u2019, you will probably be better off continuing to cycle the interpreter.","Q_Score":448,"Tags":"python","A_Id":684229,"CreationDate":"2009-03-26T01:19:00.000","Title":"How to re import an updated package while in Python Interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a list of strings that should be unique. I want to be able to check for duplicates quickly. Specifically, I'd like to be able to take the original list and produce a new list containing any repeated items. I don't care how many times the items are repeated so it doesn't have to have a word twice if there are two duplicates.\nUnfortunately, I can't think of a way to do this that wouldn't be clunky. Any suggestions?\nEDIT:\nThanks for the answers and I thought I'd make a clarification. I'm not concerned with having a list of uniques for it's own sake. I'm generating the list based off of text files and I want to know what the duplicates are so I can go in the text files and remove them if any show up.","AnswerCount":9,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":837,"Q_Id":685671,"Users Score":0,"Answer":"the solutions based on 'set' have a small drawback, namely they only work for hashable objects.\nthe solution based on itertools.groupby on the other hand works for all comparable objects (e.g.: dictionaries and lists).","Q_Score":0,"Tags":"python","A_Id":970635,"CreationDate":"2009-03-26T13:01:00.000","Title":"In Python, how do I take a list and reduce it to a list of duplicates?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to run a process, wait a few hours, kill it, and start it again.  Is there an easy way that I can accomplish this with Python or Bash?  I can run it in the background but how do I identify it to use kill on it?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2629,"Q_Id":704203,"Users Score":0,"Answer":"One idea: Save the process's PID (returned by fork() in your child process) to a file, then either schedule a cron job to kill it or kill it manually, reading the PID from the file.\nAnother option: Create a shell script wrapper that automatically kills and restarts the process. Same as above, but you can keep the PID in memory, sleep for as long as you need, kill the process, then loop.","Q_Score":0,"Tags":"python,bash,unix,process,kill","A_Id":704223,"CreationDate":"2009-04-01T05:44:00.000","Title":"How do I schedule a process' termination?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how do I fix it?\nEdit: I think I've found the problem. My character data contains \"&lt\" and \"&gt\" characters, presumably from html tags. After being parsed, these are converted to \"<\" and \">\" characters, which seems to bother the SAX parser. Is there any way to prevent this from happening?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2338,"Q_Id":708531,"Users Score":0,"Answer":"You could load it into Firefox, if you don't have an XML editor. Firefox shows you the error.","Q_Score":0,"Tags":"python,xml,sax","A_Id":715813,"CreationDate":"2009-04-02T06:35:00.000","Title":"Python SAX parser says XML file is not well-formed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how do I fix it?\nEdit: I think I've found the problem. My character data contains \"&lt\" and \"&gt\" characters, presumably from html tags. After being parsed, these are converted to \"<\" and \">\" characters, which seems to bother the SAX parser. Is there any way to prevent this from happening?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2338,"Q_Id":708531,"Users Score":0,"Answer":"I would second recommendation to try to parse it using another XML parser. That should give an indication as to whether it's the document that's wrong, or parser.\nAlso, the actual error message might be useful. One fairly common problem for example is that the xml declaration (if one is used, it's optional) must be the very first thing -- not even whitespace is allowed before it.","Q_Score":0,"Tags":"python,xml,sax","A_Id":711033,"CreationDate":"2009-04-02T06:35:00.000","Title":"Python SAX parser says XML file is not well-formed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how do I fix it?\nEdit: I think I've found the problem. My character data contains \"&lt\" and \"&gt\" characters, presumably from html tags. After being parsed, these are converted to \"<\" and \">\" characters, which seems to bother the SAX parser. Is there any way to prevent this from happening?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2338,"Q_Id":708531,"Users Score":2,"Answer":"I would suggest putting those tags back in and making sure it still works. Then, if you want to take them out, do it one at a time until it breaks.\nHowever, I question the wisdom of taking them out. If it's your XML file, you should understand it better. If it's a third-party XML file, you really shouldn't be fiddling with it (until you understand it better :-).","Q_Score":0,"Tags":"python,xml,sax","A_Id":708546,"CreationDate":"2009-04-02T06:35:00.000","Title":"Python SAX parser says XML file is not well-formed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've got a python project I've been making in terminal with vim etc.. I've read that XCode supports Python development at that it supports SVN (which I am using) but I can't find documentation on how to start a new XCode project from an existing code repository.\nOther developers are working on the project not using XCode - They won't mind if I add a project file or something, but they will mind if I have to reorganise the whole thing.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":9095,"Q_Id":709397,"Users Score":1,"Answer":"There are no special facilities for working with non-Cocoa Python projects with Xcode. Therefore, you probably just want to create a project with the \"Empty Project\" template (under \"Other\") and just drag in your source code.\nFor convenience, you may want to set up an executable in the project. You can do this by ctrl\/right-clicking in the project source list and choosing \"Add\" > \"New Custom Executable...\". You can also add a target, although I'm not sure what this would buy you.","Q_Score":6,"Tags":"python,xcode,macos","A_Id":851810,"CreationDate":"2009-04-02T11:54:00.000","Title":"Import an existing python project to XCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Problems\n\nhow to make an Ajax buttons (upward and downward arrows) such that the number can increase or decrease\nhow to save the action af an user to an variable NumberOfVotesOfQuestionID\n\nI am not sure whether I should use database or not for the variable. However, I know that there is an easier way too to save the number of votes.\nHow can you solve those problems?\n[edit]\nThe server-side programming language is Python.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":7516,"Q_Id":719194,"Users Score":3,"Answer":"You create the buttons, which can be links or images or whatever. Now hook a JavaScript function up to each button's click event. On clicking, the function fires and\n\nSends a request to the server code that says, more or less, +1 or -1.\nServer code takes over. This will vary wildly depending on what framework you use (or don't) and a bunch of other things.\nCode connects to the database and runs a query to +1 or -1 the score. How this happens will vary wildly depending on your database design, but it'll be something like UPDATE posts SET score=score+1 WHERE score_id={{insert id here}};.\nDepending on what the database says, the server returns a success code or a failure code  as the AJAX request response.\nResponse gets sent to AJAX, asynchronously.\nThe JS response function updates the score if it's a success code, displays an error if it's a failure.\n\nYou can store the code in a variable, but this is complicated and depends on how well you know the semantics of your code's runtime environment. It eventually needs to be pushed to persistent storage anyway, so using the database 100% is a good initial solution. When the time for optimizing performance comes, there are enough software in the world to cache database queries to make you feel woozy so it's not that big a deal.","Q_Score":32,"Tags":"javascript,python,html,ajax","A_Id":719293,"CreationDate":"2009-04-05T16:07:00.000","Title":"How can you make a vote-up-down button like in Stackoverflow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to do the schedule for the upcoming season for my simulation baseball team.  I have an existing Postgresql database that contains the old schedule.\nThere are 648 rows in the database: 27 weeks of series for 24 teams.  The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts of their schedule.  What I want to do is take the existing schedule and randomize it.  That way teams are still playing each other the proper number of times but not in the same order as before.\nThere is one rule that has been tripping me up:  each team can only play one home and one road series PER week.  I had been fooling around with SELECT statements based on ORDER BY RANDOM() but I haven't figured out how to make sure a team only has one home and one road series per week.\nNow, I could do this in PHP (which is the language I am most comfortable with) but I am trying to make the shift to Python so I'm not sure how to get this done in Python.  I know that Python doesn't seem to handle two dimensional arrays very well.\nAny help would be greatly appreciated.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2359,"Q_Id":719886,"Users Score":2,"Answer":"Have you considered keeping your same \"schedule\", and just shuffling the teams?  Generating a schedule where everyone plays each other the proper number of times is possible, but if you already have such a schedule then it's much easier to just shuffle the teams.\nYou could keep your current table, but replace each team in it with an id (0-23, or A-X, or whatever), then randomly generate into another table where you assign each team to each id (0 = TeamJoe, 1 = TeamBob, etc).  Then when it's time to shuffle again next year, just regenerate that mapping table.\nNot sure if this answers the question the way you want, but is probably what I would go with (and is actually how I do it on my fantasy football website).","Q_Score":0,"Tags":"python,postgresql","A_Id":719913,"CreationDate":"2009-04-05T23:34:00.000","Title":"Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to do the schedule for the upcoming season for my simulation baseball team.  I have an existing Postgresql database that contains the old schedule.\nThere are 648 rows in the database: 27 weeks of series for 24 teams.  The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts of their schedule.  What I want to do is take the existing schedule and randomize it.  That way teams are still playing each other the proper number of times but not in the same order as before.\nThere is one rule that has been tripping me up:  each team can only play one home and one road series PER week.  I had been fooling around with SELECT statements based on ORDER BY RANDOM() but I haven't figured out how to make sure a team only has one home and one road series per week.\nNow, I could do this in PHP (which is the language I am most comfortable with) but I am trying to make the shift to Python so I'm not sure how to get this done in Python.  I know that Python doesn't seem to handle two dimensional arrays very well.\nAny help would be greatly appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2359,"Q_Id":719886,"Users Score":1,"Answer":"I'm not sure I fully understand the problem, but here is how I would do it:\n1. create a complete list of matches that need to happen\n2. iterate over the weeks, selecting which match needs to happen in this week.\nYou can use Python lists to represent the matches that still need to happen, and, for each week, the matches that are happening in this week.\nIn step 2, selecting a match to happen would work this way:\na. use random.choice to select a random match to happen.\nb. determine which team has a home round for this match, using random.choice([1,2]) (if it could have been a home round for either team)\nc. temporarily remove all matches that get blocked by this selection. a match is blocked if one of its teams has already two matches in the week, or if both teams already have a home match in this week, or if both teams already have a road match in this week.\nd. when there are no available matches anymore for a week, proceed to the next week, readding all the matches that got blocked for the previous week.","Q_Score":0,"Tags":"python,postgresql","A_Id":719909,"CreationDate":"2009-04-05T23:34:00.000","Title":"Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with a 20 gig XML file that I would like to import into a SQL database (preferably MySQL, since that is what I am familiar with). This seems like it would be a common task, but after Googling around a bit I haven't been able to figure out how to do it. What is the best way to do this? \nI know this ability is built into MySQL 6.0, but that is not an option right now because it is an alpha development release.\nAlso, if I have to do any scripting I would prefer to use Python because that's what I am most familiar with. \nThanks.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12197,"Q_Id":723757,"Users Score":0,"Answer":"It may be a common task, but maybe 20GB isn't as common with MySQL as it is with SQL Server.\nI've done this using SQL Server Integration Services and a bit of custom code. Whether you need either of those depends on what you need to do with 20GB of XML in a database. Is it going to be a single column of a single row of a table? One row per child element?\nSQL Server has an XML datatype if you simply want to store the XML as XML. This type allows you to do queries using XQuery, allows you to create XML indexes over the XML, and allows the XML column to be \"strongly-typed\" by referring it to a set of XML schemas, which you store in the database.","Q_Score":5,"Tags":"python,sql,xml","A_Id":723931,"CreationDate":"2009-04-07T00:39:00.000","Title":"Import XML into SQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)?\nUPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there.","AnswerCount":6,"Available Count":2,"Score":-0.0333209931,"is_accepted":false,"ViewCount":15132,"Q_Id":724664,"Users Score":-1,"Answer":"import distutils.ccompiler\ncompiler_name = distutils.ccompiler.get_default_compiler()","Q_Score":35,"Tags":"python,compiler-construction,installation,distutils","A_Id":724745,"CreationDate":"2009-04-07T08:36:00.000","Title":"Python distutils, how to get a compiler that is going to be used?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)?\nUPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there.","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":15132,"Q_Id":724664,"Users Score":8,"Answer":"You can subclass the distutils.command.build_ext.build_ext command.\nOnce build_ext.finalize_options() method has been called, the compiler type is stored in self.compiler.compiler_type as a string (the same as the one passed to the build_ext's --compiler option, e.g. 'mingw32', 'gcc', etc...).","Q_Score":35,"Tags":"python,compiler-construction,installation,distutils","A_Id":1671060,"CreationDate":"2009-04-07T08:36:00.000","Title":"Python distutils, how to get a compiler that is going to be used?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I build a list of Django model objects by making several queries. Then I want to remove any duplicates, (all of these objects are of the same type with an auto_increment int PK), but I can't use set() because they aren't hashable. \nIs there a quick and easy way to do this? I'm considering using a dict instead of a list with the id as the key.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8768,"Q_Id":744424,"Users Score":0,"Answer":"If the order doesn't matter, use a dict.","Q_Score":6,"Tags":"python,django,data-structures,set,unique","A_Id":744439,"CreationDate":"2009-04-13T16:20:00.000","Title":"Django models - how to filter out duplicate values by PK after the fact?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written a little script that collects my external IP address every time I open a new terminal window and appends it, at well as the current time, to a text file. I'm looking for ideas on a way to visualize when\/how often my IP address changes. I bounce between home and campus and could separate them using the script, but it would be nice to visualize them separately.\nI frequently use matplotlib. Any ideas?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2072,"Q_Id":749937,"Users Score":0,"Answer":"There's a section in the matplotlib user guide about drawing bars on a chart to represent ranges. I've never done that myself but it seems appropriate for what you're looking for.","Q_Score":1,"Tags":"python,matplotlib,ip-address,visualization","A_Id":749951,"CreationDate":"2009-04-15T01:05:00.000","Title":"How to visualize IP addresses as they change in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am supporting an application with a hard dependency on python-devel 2.3.7. The application runs the python interpreter embedded, attempting to load libpython2.3.so - but since the local machine has libpython2.4.so under \/usr\/lib64, the application is failing.\nI see that there are RPMs for python-devel (but not version 2.3.x).  Another wrinkle is that I don't want to overwrite the existing python under \/usr\/lib (I don't have su anyway).  What I want to do is place the somewhere in my home directory (i.e. \/home\/noahz\/lib) and use PATH and LD_LIBRARY_PATH to point to the older version for this application.  \nWhat I'm trying to find out (but can't seem to craft the right google search for) is:\n1) Where do I download python-devel-2.3 or libpython2.3.so.1.0 (if either available)\n2a) If I can't download python-devel-2.3, how do I build libpython2.3.so from source (already downloaded Python-2.3.tgz and \n2b) Is building libpython2.3.so.1.0 from source and pointing to it with LD_LIBRARY_PATH good enough, or am I going to run into other problems (other dependencies)\n3) In general, am I approaching this problem the right way?  \nADDITIONAL INFO:\n\nI attempted to symlink (ln -s) to the later version.  This caused the app to fail silently.\nDistro is Red Hat Enterprise Linux 5 (RHEL5) - for x86_64","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1219,"Q_Id":753749,"Users Score":2,"Answer":"You can use the python RPM's linked to from the python home page ChristopheD mentioned.\nYou can extract the RPM's using cpio, as they are just specialized cpio archives.\nYour method of extracting them to your home directory and setting LD_LIBRARY_PATH and PATH should work; I use this all the time for hand-built newer versions of projects I also have installed.\nDon't focus on the -devel package though; you need the main package.  You can unpack the -devel one as well, but the only thing you'll actually use from it is the libpython2.3.so symlink that points to the actual library, and you can just as well create this by hand.\nWhether this is the right approach depends on what you are trying to do.  If all you're trying to do is to get this one application to run for you personally, then this hack sounds fine.\nIf you wanted to actually distribute something to other people for running this application, and you have no way of fixing the actual application, you should consider building an rpm of the older python version that doesn't conflict with the system-installed one.","Q_Score":2,"Tags":"python,linux,build","A_Id":754180,"CreationDate":"2009-04-15T21:13:00.000","Title":"Need to build (or otherwise obtain) python-devel 2.3 and add to LD_LIBRARY_PATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The host I'm considering for hosting a Django site has mod_python installed, but does not have Django. Django's INSTALL file indicates that I can simply copy the django directory to Python's site-packages directory to install Django, so I suspect that it might be possible to configure Python \/ mod_python to look for it elsewhere (namely my user space) by modifying sys.path, but I don't know how to change it from .htaccess or mod_python.\nHow do I modify sys.path from .htaccess to allow mod_python to see Django?\nP.S. I can only access the site via FTP (i.e. no shell access). I realize that it sounds like I should just switch hosts, but there are compelling reasons for me to make this work so I'm at least going to try.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1417,"Q_Id":764312,"Users Score":1,"Answer":"You're using mod_python wrong. It was never intended to serve python web applications. You should be using WSGI for this... or at least FastCGI.","Q_Score":4,"Tags":"python,django,apache,.htaccess,mod-python","A_Id":764769,"CreationDate":"2009-04-18T22:02:00.000","Title":"How do I modify sys.path from .htaccess to allow mod_python to see Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.","AnswerCount":21,"Available Count":4,"Score":0.0095235216,"is_accepted":false,"ViewCount":196787,"Q_Id":765797,"Users Score":1,"Answer":"In the end what you have is a maths issue. If every 4 years we have an extra day lets then dived the timedelta in days, not by 365 but 365*4 + 1, that would give you the amount of 4 years. Then divide it again by 4. \ntimedelta \/ ((365*4) +1) \/ 4 = timedelta * 4 \/ (365*4 +1)","Q_Score":172,"Tags":"python,datetime,timedelta","A_Id":3260826,"CreationDate":"2009-04-19T18:00:00.000","Title":"Convert timedelta to years?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.","AnswerCount":21,"Available Count":4,"Score":0.047583087,"is_accepted":false,"ViewCount":196787,"Q_Id":765797,"Users Score":5,"Answer":"How exact do you need it to be?  td.days \/ 365.25 will get you pretty close, if you're worried about leap years.","Q_Score":172,"Tags":"python,datetime,timedelta","A_Id":765804,"CreationDate":"2009-04-19T18:00:00.000","Title":"Convert timedelta to years?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.","AnswerCount":21,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":196787,"Q_Id":765797,"Users Score":57,"Answer":"If you're trying to check if someone is 18 years of age, using timedelta will not work correctly on some edge cases because of leap years.  For example, someone born on January 1, 2000, will turn 18 exactly 6575 days later on January 1, 2018 (5 leap years included), but someone born on January 1, 2001, will turn 18 exactly 6574 days later on January 1, 2019 (4 leap years included).  Thus, you if someone is exactly 6574 days old, you can't determine if they are 17 or 18 without knowing a little more information about their birthdate.\nThe correct way to do this is to calculate the age directly from the dates, by subtracting the two years, and then subtracting one if the current month\/day precedes the birth month\/day.","Q_Score":172,"Tags":"python,datetime,timedelta","A_Id":765862,"CreationDate":"2009-04-19T18:00:00.000","Title":"Convert timedelta to years?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.","AnswerCount":21,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":196787,"Q_Id":765797,"Users Score":7,"Answer":"Get the number of days, then divide by 365.2425 (the mean Gregorian year) for years. Divide by 30.436875 (the mean Gregorian month) for months.","Q_Score":172,"Tags":"python,datetime,timedelta","A_Id":1959782,"CreationDate":"2009-04-19T18:00:00.000","Title":"Convert timedelta to years?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to understand S3...How do you limit access to a file you upload to S3?  For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file?  It seems like the query string authentication requires an expiration date and that won't work for me, is there another way to do this?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":4305,"Q_Id":765964,"Users Score":1,"Answer":"You will have to build the whole access logic to S3 in your applications","Q_Score":10,"Tags":"python,django,amazon-web-services,amazon-s3","A_Id":766030,"CreationDate":"2009-04-19T19:51:00.000","Title":"Amazon S3 permissions","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to understand S3...How do you limit access to a file you upload to S3?  For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file?  It seems like the query string authentication requires an expiration date and that won't work for me, is there another way to do this?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":4305,"Q_Id":765964,"Users Score":8,"Answer":"Have the user hit your server\nHave the server set up a query-string authentication with a short expiration (minutes, hours?)\nHave your server redirect to #2","Q_Score":10,"Tags":"python,django,amazon-web-services,amazon-s3","A_Id":768090,"CreationDate":"2009-04-19T19:51:00.000","Title":"Amazon S3 permissions","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to understand S3...How do you limit access to a file you upload to S3?  For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file?  It seems like the query string authentication requires an expiration date and that won't work for me, is there another way to do this?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":4305,"Q_Id":765964,"Users Score":14,"Answer":"There are various ways to control access to the S3 objects:\n\nUse the query string auth - but as you noted this does require an expiration date.  You could make it far in the future, which has been good enough for most things I have done.\nUse the S3 ACLS - but this requires the user to have an AWS account and authenticate with AWS to access the S3 object.  This is probably not what you are looking for.\nYou proxy the access to the S3 object through your application, which implements your access control logic.  This will bring all the bandwidth through your box.\nYou can set up an EC2 instance with your proxy logic - this keeps the bandwidth closer to S3 and can reduce latency in certain situations.  The difference between this and #3 could be minimal, but depends your particular situation.","Q_Score":10,"Tags":"python,django,amazon-web-services,amazon-s3","A_Id":768050,"CreationDate":"2009-04-19T19:51:00.000","Title":"Amazon S3 permissions","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to use the entry point functionality in setuptools.\nThere are a number of occasions where I would like to tightly control the list of eggs that are run, and thence the extensions that contribute to a set of entry points:\n\negg integration testing, where I want to run multiple test suites on different combinations of eggs.\nscanning a single directory of eggs\/plugins so as to run two different instances of the same program, but with different eggs.\ndevelopment time, where I am developing one or more egg, and would like to run the program as part of the normal edit-run cycle.\n\nI have looked through the setuptools documentation, and while it doesn't say that this is not possible, I must have missed something saying how to do it. \nWhat is the best way to approach deploying plugins differently to the default system-wide discovery?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":294,"Q_Id":769766,"Users Score":0,"Answer":"We're solving something similar, ability to use setup.py develop if You're mere user without access to global site-packages. So far, we solved it with virtualenv.\nI'd say it will help for your case too: have minimal system-wide install (or explicitly exclude it), create virtual environment with eggs you want and test there.\n(Or, for integration tests, create clean environment, install egg and test all dependencies are installed).\nFor 2, I'm not sure, but it should work too, with multiple virtualenvs. For 3, setup.py develop is the way to go.","Q_Score":0,"Tags":"python,setuptools,distutils,egg","A_Id":1000651,"CreationDate":"2009-04-20T19:27:00.000","Title":"How do I load entry-points for a defined set of eggs with Python setuptools?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"A friend of mine was talking about a word game she liked to play where you try to convert one word to another (they have the same number of letters) by switching one letter at a time, where each iteration produces a real word.\nExample:\n\nMOON --> WOLF\n  GOON\n  GOOF\n  GOLF\n  WOLF\n\nI figured it'd be a fun little project to write a program to generate solutions, and taking it further, given 2 words, determine if a solution exists and the number of iterations in optimal solution.\nProblem is I'm having trouble finding free word lists that I can easily access programmatically.  I'm also thinking about using this as an excuse to learn Python, so it'd be great if anyone knows of free word lists and pointers on how to parse and access it from Python.  The algorithm for figuring out how to find an optimal path I'll work on my own.","AnswerCount":7,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":67206,"Q_Id":772922,"Users Score":33,"Answer":"Most unix (which includes osx) have a file \/usr\/share\/dict\/words.","Q_Score":43,"Tags":"python,dictionary,word-list","A_Id":772936,"CreationDate":"2009-04-21T14:43:00.000","Title":"Free word list for use programmatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing an rather simple http web server in python3. The web server needs to be simple - only basic reading from config files, etc. I am using only standard libraries and for now it works rather ok. \nThere is only one requirement for this project, which I can't implement on my own - virtual hosts. I need to have at least two virtual hosts, defined in config files. The problem is, that I can't find a way how can I implement them in python. Does anyone have any guides, articles, maybe some simple implementation how can this be done?\nI would be grateful for any help.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3802,"Q_Id":781466,"Users Score":10,"Answer":"Virtual hosts work by obeying the Host: header in the HTTP request.\nJust read the headers of the request, and take action based on the value of the Host: header","Q_Score":3,"Tags":"python,http,python-3.x,virtualhost","A_Id":781474,"CreationDate":"2009-04-23T12:20:00.000","Title":"Python3 Http Web Server: virtual hosts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Has anyone done this?  I've tried generating a c# proxy class and connecting through it, but I cannot figure out how to get IronPython to use the generated app.config file that defines the endpoint.  It tries to connect, but I just get an error about no default endpoint.  I would ideally like to make the connection using only IronPython code and not use the proxy class, if possible.  The binding for the service I am trying to connect to is a NetTcpBinding if that makes any difference.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2231,"Q_Id":783120,"Users Score":0,"Answer":"Is your WCF service interface available in a shared assembly?  If so, you could look at using the ChannelFactory to create your client proxy dynamically (instead of using the generated C# proxy).  With that method you can supply all the details of the endpoint when you create the ChannelFactory and you won't require any configuration in your .config file.","Q_Score":2,"Tags":"wcf,ironpython","A_Id":783626,"CreationDate":"2009-04-23T19:08:00.000","Title":"How to connect to a WCF Service with IronPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them.\nNow, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed.\nPython will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task).","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":3573,"Q_Id":786138,"Users Score":3,"Answer":"A few thousand emails per hour isn't really that much, as long as your outgoing mail server is willing to accept them in a timely manner.\nI would send them using a local mta, like postfix, or exim (which would then send them through your outgoing relay if required). That service is then responsible for the mail queues, retries, bounces, etc. If your looking for more \"mailing list\" features, try adding mailman into the mix. It's written in python, and you've probably seen it, as it runs tons of internet mailing lists.","Q_Score":3,"Tags":"python,linux,email","A_Id":787170,"CreationDate":"2009-04-24T14:45:00.000","Title":"How to design an email system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them.\nNow, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed.\nPython will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task).","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3573,"Q_Id":786138,"Users Score":0,"Answer":"You might want to try Twisted Mail for implementing your own backend in pure Python.","Q_Score":3,"Tags":"python,linux,email","A_Id":787214,"CreationDate":"2009-04-24T14:45:00.000","Title":"How to design an email system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django website as follows:\n\nsite has several views\neach view has its own template to show its data\neach template extends a base template\nbase template is the base of the site, has all the JS\/CSS and the basic layout\n\nSo up until now it's all good. So now we have the master head of the site (which exists in the base template), and it is common to all the views.\nBut now I want to make it dynamic, and add some dynamic data to it. On which view do I do this? All my views are basically render_to_response('viewtemplate.html', someContext). So how do add a common view to a base template?\nObviously I will not duplicate the common code to each separate view...\nI think I'm missing something fundamental in the MVT basis of Django.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":539,"Q_Id":786149,"Users Score":2,"Answer":"Context processors and RequestContext (see Tyler's answer) are the way to go for data that is used on every page load.  For data that you may need on various views, but not all (especially data that isn't really related to the primary purpose of the view, but appears in something like a navigation sidebar), it often makes most sense to define a custom template tag for retrieving the data.","Q_Score":6,"Tags":"python,django,django-templates","A_Id":793167,"CreationDate":"2009-04-24T14:46:00.000","Title":"Basic MVT issue in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to provide a functionality for users of my website to get assigned an email address upon registration (such as firstname.lastname@mydomain.com) but I don't really think it is feasible to actually support all these emails account normally through a webmail program. I am also not sure if my webhost would be cool with it. What I'd really want is to be able to have a seamless integration of this email into the bigger system that the website is, as it is mostly going to be for intra-site messaging but we want to allow users to put actual email addresses. So what I would like to do instead is have a catch-all account under mydomain and have this email look at incoming mail, see who it was meant to be sent to, and add a message for the user in the system.\nSo, the questions are:\n1) Is this the right approach? How expensive would it be to get a host that would allow me to just assign emails to at will to my domain? I am currently using WebFaction's shared hosting.\n2) If it is an okay approach, what is the best way to route this catch all account to my python script? I have read about .forward but I am not very good at UNIX stuff. Once I figure that out, how would I get the script to be in the \"Django environment\" so I can use Django's model functionality to add the new messages to the user?\n3) Is there anything Django can do to make this any easier?\n4) Are there any tools in Python to help me parse the email address? How do they work?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2191,"Q_Id":789685,"Users Score":0,"Answer":"but I don't really think it is\n  feasible to actually support all these\n  emails account normally through a\n  webmail program\n\nI think that your base assumption here is incorrect. You see, most 'webmail' programs are just frontends (or clients) to the backend mail system (postfix etc). You will need to see how your webhost is set up. There is no reason why you can not create these accounts programmatically and then let them use a normal webmail interface like SquirrelMail or RoundCube. For instance, my webhost (bluehost) allows me 2500 email accounts - I am not sure how many yours allows - but I can upgrade to unlimited for a few extra dollars a month. I think that using the builtin email handling facility is a more robust way to go.","Q_Score":2,"Tags":"python,django,email","A_Id":789699,"CreationDate":"2009-04-25T20:35:00.000","Title":"What is the best way to redirect email to a Python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a long-running Python service and I'd like to know how much cumulative wall clock time has been spent by any runnable threads (i.e., threads that weren't blocked for some other reason) waiting for the GIL.  Is there an easy way to do this?  E.g., perhaps I could periodically dump some counter to its log file.\nMy underlying motivation is to rule out the GIL as a source of mystery response latency from these long-running processes.  There is no particular reason to suspect the GIL (other than that it would fit the symptoms), but other forms of logging haven't turned up anything yet, so, if it is easy, it would be nice to have this information.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":536,"Q_Id":795405,"Users Score":3,"Answer":"I don't think there's an easy way. There's probably an awkward way, involving rebuilding Python to traverse the PyThreadState list and count the threads each time the lock is acquired, but I doubt it's worth the effort!\nI know this is a speculative question but if you are even moderately concerned about there being delays caused by threading it may be prudent to move to a multiprocessing model instead of a multithreading model. Since processes are both safer and more scalable in Python they are almost always the best choice if practical.","Q_Score":6,"Tags":"python,multithreading","A_Id":797218,"CreationDate":"2009-04-27T21:42:00.000","Title":"Is there an easy way to tell how much time is spent waiting for the Python GIL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django view, which receives part of its data from an external website, which I parse using urllib2\/BeautifulSoup.\nThis operation is rather expensive so I cache it using the low-level cache API, for ~5 minutes. However, each user which accesses the site after the cached data expires will receive a significant delay of a few seconds while I go to the external site to parse the new data.\nIs there any way to load the new data lazily so that no user will ever get that kind of delay? Or is this unavoidable?\nPlease note that I am on a shared hosting server, so keep that in mind with your answers.\nEDIT: thanks for the help so far. However, I'm still unsure as to how I accomplish this with the python script I will be calling. A basic test I did shows that the django cache is not global. Meaning if I call it from an external script, it does not see the cache data going on in the framework. Suggestions?\nAnother EDIT: coming to think of it, this is probably because I am still using local memory cache. I suspect that if I move the cache to memcached, DB, whatever, this will be solved.","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1876,"Q_Id":797773,"Users Score":4,"Answer":"I have no proof, but I've read BeautifulSoup is slow and consumes a lot of memory. You may want to look at using the lxml module instead. lxml is supposed to be much faster and efficient, and can do much more than BeautifulSoup.\nOf course, the parsing probably isn't your bottleneck here; the external I\/O is. \nFirst off, use memcached!\nThen, one strategy that can be used is as follows:\n\nYour cached object, called A, is stored in the cache with a dynamic key (A_<timestamp>, for example).\nAnother cached object holds the current key for A, called A_key.\nYour app would then get the key for A by first getting the value at A_key\nA periodic process would populate the cache with the A_<timestamp> keys and upon completion, change the value at A_key to the new key\n\nUsing this method, all users every 5 minutes won't have to wait for the cache to be updated, they'll just get older versions until the update happens.","Q_Score":5,"Tags":"python,django,caching","A_Id":804829,"CreationDate":"2009-04-28T12:56:00.000","Title":"Django caching - can it be done pre-emptively?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django view, which receives part of its data from an external website, which I parse using urllib2\/BeautifulSoup.\nThis operation is rather expensive so I cache it using the low-level cache API, for ~5 minutes. However, each user which accesses the site after the cached data expires will receive a significant delay of a few seconds while I go to the external site to parse the new data.\nIs there any way to load the new data lazily so that no user will ever get that kind of delay? Or is this unavoidable?\nPlease note that I am on a shared hosting server, so keep that in mind with your answers.\nEDIT: thanks for the help so far. However, I'm still unsure as to how I accomplish this with the python script I will be calling. A basic test I did shows that the django cache is not global. Meaning if I call it from an external script, it does not see the cache data going on in the framework. Suggestions?\nAnother EDIT: coming to think of it, this is probably because I am still using local memory cache. I suspect that if I move the cache to memcached, DB, whatever, this will be solved.","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1876,"Q_Id":797773,"Users Score":4,"Answer":"\"I'm still unsure as to how I accomplish this with the python script I will be calling. \"\nThe issue is that your \"significant delay of a few seconds while I go to the external site to parse the new data\" has nothing to do with Django cache at all.\nYou can cache it everywhere, and when you go to reparse the external site, there's a delay.  The trick is to NOT parse the external site while a user is waiting for their page.\nThe trick is to parse the external site before a user asks for a page.  Since you can't go back in time, you have to periodically parse the external site and leave the parsed results in a local file or a database or something.\nWhen a user makes a request you already have the results fetched and parsed, and all you're doing is presenting.","Q_Score":5,"Tags":"python,django,caching","A_Id":798462,"CreationDate":"2009-04-28T12:56:00.000","Title":"Django caching - can it be done pre-emptively?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to add \"IDLE-like functionality\" to C# WinForms application, but I don't quite have an idea how to do that and couldn't find anything useful with Google.\nSo basically I want interactive command line interface, where user could enter some Python code and execute it (not just expressions, should be possible to define new functions).\nSo, where to start? Are there any good tutorials or samples available?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":975,"Q_Id":801432,"Users Score":0,"Answer":"IronRuby comes with a command line interpreter. Doesn't IronPython also have one? If so, the source code would be a good start :)\nOh, and if it doesn't, be sure to look at the IronRuby interpreter, because both languages are based on the DLR and are therefore similar enough to learn from both.","Q_Score":0,"Tags":"c#,winforms,ironpython","A_Id":801447,"CreationDate":"2009-04-29T08:28:00.000","Title":"How to create IDLE -like functionality to WinForms application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have two classes: Account and Operator. Account contains a list of Operators. Now, whenever an operator (in the list) receives a message I want to notify Account object to perform some business logic as well.\nI think of three alternatives on how to achieve this:\n1) Hold a reference within Operator to the container [Account] object and call methods directly. Not absolutely good because of circular references.\n2) Use events. As far as I know there is no built-in event handling mechanism in Python. So, this one is a bit tricky to implement.\n3) Don't send messages to Operators directly. Instead, operate only Accounts, and within them, internally, handler operators. This one is a bit limiting because in this case I cannot pass around references to operators.\nI wonder which approach is the most advantageous from the architectural point of view. How do you usually handle this task?\nIt would be great if you could point out snippets in Python.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":403,"Q_Id":801931,"Users Score":5,"Answer":"You're over-thinking this.  Seriously.  Python isn't C++; your concerns are non-issues in Python.  Just write what makes sense in your problem domain.\n\" Not absolutely good because of circular references.\"\nWhy not?  Circularity is of no relevance here at all.  Bidirectional relationships are great things.  Use them.  Python garbage collects them just fine without any thinking on your part.\nWhat possible problem do you have with mutual (birectional) relationships?\n\"...operate only Accounts, and within them, internally, handler operators. This one is a bit limiting because in this case I cannot pass around references to operators.\n\"\nWhat?  Your Operators are Python objects, pass all you want.  All Python objects are (in effect) references, don't sweat it. \nWhat possible problem do you have with manipulating Operator objects?","Q_Score":4,"Tags":"python,architecture,containers,notifications","A_Id":802084,"CreationDate":"2009-04-29T11:31:00.000","Title":"Notifying container object: best practices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two classes: Account and Operator. Account contains a list of Operators. Now, whenever an operator (in the list) receives a message I want to notify Account object to perform some business logic as well.\nI think of three alternatives on how to achieve this:\n1) Hold a reference within Operator to the container [Account] object and call methods directly. Not absolutely good because of circular references.\n2) Use events. As far as I know there is no built-in event handling mechanism in Python. So, this one is a bit tricky to implement.\n3) Don't send messages to Operators directly. Instead, operate only Accounts, and within them, internally, handler operators. This one is a bit limiting because in this case I cannot pass around references to operators.\nI wonder which approach is the most advantageous from the architectural point of view. How do you usually handle this task?\nIt would be great if you could point out snippets in Python.","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":403,"Q_Id":801931,"Users Score":3,"Answer":"There is no \"one-size-fits-all\" solution for the Observer pattern. But usually, it's better to define an EventManager object where interested parties can register themselves for certain events and post these events whenever they happen. It simply creates less dependencies.\nNote that you need to use a global EventManager instance, which can be problematic during testing or from a general OO point of view (it's a global variable). I strongly advise against passing the EventManager around all the time because that will clutter your code.\nIn my own code, the \"key\" for registering events is the class of the event. The EventManager uses a dictionary (event class -> list of observers) to know which event goes where. In the notification code, you can then use dict.get(event.__class__, ()) to find your listeners.","Q_Score":4,"Tags":"python,architecture,containers,notifications","A_Id":802031,"CreationDate":"2009-04-29T11:31:00.000","Title":"Notifying container object: best practices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43756,"Q_Id":805393,"Users Score":0,"Answer":"I guess the improved raw sql queryset support in Django 1.2 can make this easier as you wouldn't have to roll your own make_instance type code.","Q_Score":34,"Tags":"python,sql,django,stored-procedures,django-models","A_Id":3675814,"CreationDate":"2009-04-30T05:03:00.000","Title":"What is the best way to access stored procedures in Django's ORM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":43756,"Q_Id":805393,"Users Score":6,"Answer":"Don't.\nSeriously.\nMove the stored procedure logic into your model where it belongs.  \nPutting some code in Django and some code in the database is a maintenance nightmare.  I've spent too many of my 30+ years in IT trying to clean up this kind of mess.","Q_Score":34,"Tags":"python,sql,django,stored-procedures,django-models","A_Id":806302,"CreationDate":"2009-04-30T05:03:00.000","Title":"What is the best way to access stored procedures in Django's ORM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams.\nIt's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller.\nAre there some huge companies that develop primarily in Python?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":22280,"Q_Id":810055,"Users Score":3,"Answer":"Python is very powerful language, Many big and the very high ranked websites are built on python.. \nSome big products of python are:-\n\nGoogle (extensively used)\nYoutube (extensively used)\nDisqus \nEventbrite\nPinterest \nReddit\nQuora \nMozilla\nAsana (extensively used)\nDropbox (started with python, stayed with python)\n\nEven Many companies are shifting their websites from PHP to Python, Because of its efficiency, fast ability, and reliability, and availability of huge support and many good frameworks such as Django..\nMoreover, I am not saying that PHP is not a good server side scripting language, But truth is that, most users are adapting python instead of PHP.","Q_Score":21,"Tags":"python","A_Id":40535335,"CreationDate":"2009-05-01T03:24:00.000","Title":"Biggest python projects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams.\nIt's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller.\nAre there some huge companies that develop primarily in Python?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":22280,"Q_Id":810055,"Users Score":12,"Answer":"Among many other Python-centered companies, beyond the ones already mentioned by Unknown, I'd mention big pharma firms such as Astra-Zeneca, film studios such as Lucasfilm, and research places such as NASA, Caltech, Lawrence Livermore NRL.\nAmong the sponsors of Pycon Italia Tre (next week in Firenze, IT -- see www.pycon.it) are Qt\/Trolltech (a wholly owned subsidiary of Nokia), Google of course, Statpro, ActiveState, Wingware -- besides, of course, several Italian companies.\nAmong the sponsors of Pycon US in Chicago in March were (of course) Google, as well as Sun Microsystems, Microsoft, Slide.com, Walt Disney Animation Studios, Oracle, Canonical, VMWare -- these are all companies who thought it worthwhile to spend money in order to have visibility to experienced Pythonistas, so presumably ones making significant large-scale use of Python (and in most cases trying to hire experienced Python developers in particular).","Q_Score":21,"Tags":"python","A_Id":810240,"CreationDate":"2009-05-01T03:24:00.000","Title":"Biggest python projects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams.\nIt's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller.\nAre there some huge companies that develop primarily in Python?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":22280,"Q_Id":810055,"Users Score":8,"Answer":"Our project is over 30,000 lines of Python.  That's probably small by some standards.  But it's plenty big enough to fill my little brain.  The application is mentioned in our annual report, so it's \"strategic\" in that sense.  We're not a \"huge\" company, so we don't really qualify.\nA \"huge company\" (Fortune 1000?) doesn't develop primarily in any single language.  Large companies will have lots of development teams, each using a different technology, depending on -- well -- on nothing in particular.\nWhen you get to \"epic companies\" (Fortune 10) you're looking at an organization that's very much like a conglomerate of several huge companies rolled together.  Each huge company within an epic company is still a huge company with multiple uncoordinated IT shops doing unrelated things -- there's no \"develop primarily in\" any particular language or toolset.\nEven for \"large companies\" and \"small companies\" (like ours) you still have fragmentation.  Our in-house IT is mostly Microsoft.  Our other product development is mostly Java.  My team, however, doesn't have much useful specification, so we use Python.  We use python because of the duck typing and dynamic programming features.\n(I don't know what a dynamic type system is -- Python types are static -- when you create an object, its type can never change.)\nSince no huge company develops primarily in any particular language or toolset, the trivial answer to your question is \"No\" for any language or tool.  And No for Python in particular.","Q_Score":21,"Tags":"python","A_Id":810992,"CreationDate":"2009-05-01T03:24:00.000","Title":"Biggest python projects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given an ip address (say 192.168.0.1), how do I check if it's in a network (say 192.168.0.0\/24) in Python?\nAre there general tools in Python for ip address manipulation? Stuff like host lookups, ip adddress to int, network address with netmask to int and so on? Hopefully in the standard Python library for 2.5.","AnswerCount":28,"Available Count":1,"Score":0.0142847425,"is_accepted":false,"ViewCount":174240,"Q_Id":819355,"Users Score":2,"Answer":"#This works properly without the weird byte by byte handling\ndef addressInNetwork(ip,net):\n    '''Is an address in a network'''\n    # Convert addresses to host order, so shifts actually make sense\n    ip = struct.unpack('>L',socket.inet_aton(ip))[0]\n    netaddr,bits = net.split('\/')\n    netaddr = struct.unpack('>L',socket.inet_aton(netaddr))[0]\n    # Must shift left an all ones value, \/32 = zero shift, \/0 = 32 shift left\n    netmask = (0xffffffff << (32-int(bits))) & 0xffffffff\n    # There's no need to mask the network address, as long as its a proper network address\n    return (ip & netmask) == netaddr","Q_Score":123,"Tags":"python,networking,ip-address,cidr","A_Id":10053031,"CreationDate":"2009-05-04T08:59:00.000","Title":"How can I check if an ip is in a network in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python is so dynamic that it's not always clear what's going on in a large program, and looking at a tiny bit of source code does not  always help. To make matters worse, editors tend to have poor support for navigating to the definitions of tokens or import statements in a Python file.\nOne way to compensate might be to write a special profiler that, instead of timing the program, would record the runtime types and paths of objects of the program and expose this data to the editor.\nThis might be implemented with sys.settrace() which sets a callback for each line of code and is how pdb is implemented, or by using the ast module and an import hook to instrument the code, or is there a better strategy? How would you write something like this without making it impossibly slow, and without runnning afoul of extreme dynamism e.g side affects on property access?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":235,"Q_Id":823103,"Users Score":1,"Answer":"What if you monkey-patched object's class or another prototypical object?\nThis might not be the easiest if you're not using new-style classes.","Q_Score":3,"Tags":"python,profiling","A_Id":823117,"CreationDate":"2009-05-05T02:52:00.000","Title":"What's the best way to record the type of every variable assignment in a Python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using wx.FileDialog in a wxPython 2.8.8.0 application, under Xubuntu 8.10.. My problem is that this dialog isn't network-aware, so I can't browse Samba shares.\nI see that this problem plagues other applications too (Firefox, Audacious...) so I'd like to ask where I could find informations on how to make it work.\nIs that dialog supposed to be already network-aware? Am I missing something? Some library maybe? Or should I write my own implementation?\nMany thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":825724,"Users Score":0,"Answer":"Robin Dunn himself told me that\n\nIt's using the \"native\" GTK file\n  dialog, just like the other apps, so \n  there isn't anything that wx can do\n  about it.\n\nSo as a workaround I ended up installing gvfs-fuse and browsing\nthe network through $HOME\/.gvfs.. A bit klunky but it works.","Q_Score":1,"Tags":"linux,ubuntu,wxpython","A_Id":876524,"CreationDate":"2009-05-05T16:22:00.000","Title":"Network-aware wx.FileDialog","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm importing a module which raises the following error in some conditions:\n    RuntimeError: pyparted requires root access\nI know that I can just check for root access before the import, but I'd like to know how to catch this spesific kind of error via a try\/except statement for future reference. Is there any way to differentiate between this RuntimeError and others that might be raised?","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24955,"Q_Id":825909,"Users Score":8,"Answer":"I know that I can just check for root access before the import, but I'd like to know how to catch this spesific kind of error via a try\/except statement for future reference. Is there any way to differentiate between this RuntimeError and others that might be raised?\n\nIf the error is caused by a specific condition, then I think the easiest way to catch the error is to test for the condition, and you can raise a more specific error yourself. After all the 'error' exists before the error is thrown, since in this case its a problem with the environment.\nI agree with those above - text matching on an error is kind of a terrifying prospect.","Q_Score":8,"Tags":"python,exception-handling,try-catch,runtime-error","A_Id":826144,"CreationDate":"2009-05-05T17:01:00.000","Title":"Catch only some runtime errors in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Suppose that I have the model Foo in GAE and this query:\nquery = Foo.all().order('-key')\nI want to get the n-th record. What is the most efficient way to achieve that? \nWill the solution break if the ordering property is not unique, such as the one below:\nquery = Foo.all().order('-color')\nedit: n > 1000\nedit 2: I want to develop a friendly paging mechanism that shows pages available (such as Page 1, Page 2, ... Page 185) and requires a \"?page=x\" in the query string, instead of a \"?bookmark=XXX\". When page = x, the query is to fetch the records beginning from the first record of that page.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":845,"Q_Id":826724,"Users Score":3,"Answer":"There is no efficient way to do this - in any DBMS. In every case, you have to at least read sequentially through the index records until you find the nth one, then look up the corresponding data record. This is more or less what fetch(count, offset) does in GAE, with the additional limitation of 1000 records.\nA better approach to this is to keep a 'bookmark', consisting of the value of the field you're ordering on for the last entity you retrieved, and the entity's key. Then, when you want to continue from where you left off, you can add the field's value as the lower bound of an inequality query, and skip records until you match or exceed the last one you saw.\nIf you want to provide 'friendly' page offsets to users, what you can do is to use memcache to store an association between a start offset and a bookmark (order_property, key) tuple. When you generate a page, insert or update the bookmark for the entity following the last one. When you fetch a page, use the bookmark if it exists, or generate it the hard way, by doing queries with offsets - potentially multiple queries if the offset is high enough.","Q_Score":1,"Tags":"python,google-app-engine,google-cloud-datastore,custompaging","A_Id":827149,"CreationDate":"2009-05-05T20:14:00.000","Title":"how to get the n-th record of a datastore query","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How does one test a method that does some interactions with the local D-Bus (accessing a HAL object)? \nResults of tests will differ depending on the system that the test is run on, so I don't know how to provide the method reliable input. \nI'm working in Python, by the way.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":827295,"Users Score":2,"Answer":"If you can not mock the environment then it's probably impossible for you to write the test.\nIf your access to HAL\/D-Bus is via an object and you provide a mock instance to your test then it should be possible to emulate the necessary inputs to your test from the mock implementation.","Q_Score":2,"Tags":"python,unit-testing,dbus,hal","A_Id":827391,"CreationDate":"2009-05-05T22:56:00.000","Title":"Unit testing for D-Bus and HAL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a scheduled task which runs a python script every 10 min\nso it turns out that a script pops up on my desktop every 10 min\nhow can i make it invincible so my script will work in the background ?\nI've been told that pythonw will do the work, but I cant figure out how to use it\nany help ?\nthanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":833356,"Users Score":0,"Answer":"Set the scheduled task to start the script as minimized.","Q_Score":1,"Tags":"python","A_Id":833364,"CreationDate":"2009-05-07T07:45:00.000","Title":"How to run a script without being in the tasktray?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a scheduled task which runs a python script every 10 min\nso it turns out that a script pops up on my desktop every 10 min\nhow can i make it invincible so my script will work in the background ?\nI've been told that pythonw will do the work, but I cant figure out how to use it\nany help ?\nthanks","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":109,"Q_Id":833356,"Users Score":3,"Answer":"I've been told that pythonw will do the work, but I cant figure out how to use it\n\nNormally you just have to rename the file extension to .pyw. Then it will be executed by pythonw.","Q_Score":1,"Tags":"python","A_Id":833391,"CreationDate":"2009-05-07T07:45:00.000","Title":"How to run a script without being in the tasktray?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in my google app application, whenever a user purchases a number of contracts, these events are executed (simplified for clarity):\n\nuser.cash is decreased\nuser.contracts is increased by the number\ncontracts.current_price is updated.\nmarket.no_of_transactions is increased by 1.\n\nin a rdms, these would be placed within the same transaction. I conceive that google datastore does not allow entities of more than one model to be in the same transaction.\nwhat is the correct approach to this issue? how can I ensure that if a write fails, all preceding writes are rolled back? \nedit: I have obviously missed entity groups. Now I'd appreciate some further information regarding how they are used. Another point to clarify is google says \"Only use entity groups when they are needed for transactions. For other relationships between entities, use ReferenceProperty properties and Key values, which can be used in queries\". does it mean I have to define both a reference property (since I need queriying them) and a parent-child relationship (for transactions)? \nedit 2: and finally, how do I define two parents for an entity if the entity is being created to establish an n-to-n relationship between 2 parents?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":384,"Q_Id":836992,"Users Score":0,"Answer":"After a through research, I have found that a distributed transaction layer that provides a solution to the single entity group restriction has been developed in userland with the help of some google people. But so far, it is not released and is only available in java.","Q_Score":3,"Tags":"python,google-app-engine,transactions,google-cloud-datastore","A_Id":838960,"CreationDate":"2009-05-07T20:55:00.000","Title":"datastore transaction restrictions","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Forgive me, I'm completely new to parsing and lex\/yacc, and I'm probably in way over my head, but nonetheless:\nI'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an equation, which it parses fine and calculates, or something that is nothing like an equation, which fails parsing and is also fine.\nThe gray area is an input that has equation-like parts, of which the parser will grab and work out. This isn't what I want - I need to be able to tell if parts of the string didn't get picked up and tokenized so I can throw back an error, but I have no idea how to do this.\nDoes anyone know how I can define, basically, a 'catch anything that's left' token? Or is there a better way I can handle this?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":674,"Q_Id":841159,"Users Score":0,"Answer":"I typically use a separate 'command reader' to obtain a complete command - probably a line in your case - into a host variable string, and then arrange for the lexical analyzer to analyze the string, including telling me when it didn't reach the end.  This is hard to set up, but make some classes of error reporting easier.  One of the places I've used this technique routinely has multi-line commands with 3 comment conventions, two sets of quoted strings, and some other nasties to set my teeth on edge (context sensitive tokenization - yuck!).\nOtherwise, Don's advice with the Yacc 'error' token is good.","Q_Score":3,"Tags":"python,yacc,lex,ply","A_Id":842331,"CreationDate":"2009-05-08T18:23:00.000","Title":"Tokenizing left over data with lex\/yacc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"Forgive me, I'm completely new to parsing and lex\/yacc, and I'm probably in way over my head, but nonetheless:\nI'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an equation, which it parses fine and calculates, or something that is nothing like an equation, which fails parsing and is also fine.\nThe gray area is an input that has equation-like parts, of which the parser will grab and work out. This isn't what I want - I need to be able to tell if parts of the string didn't get picked up and tokenized so I can throw back an error, but I have no idea how to do this.\nDoes anyone know how I can define, basically, a 'catch anything that's left' token? Or is there a better way I can handle this?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":674,"Q_Id":841159,"Users Score":1,"Answer":"There is a built-in error token in yacc. You would normally do something like:\n\nline: goodline | badline ;\nbadline : error '\\n' \/* Error-handling action, if needed *\/\ngoodline : equation '\\n' ;\n\nAny line that doesn't match equation will be handled by badline.\nYou might want to use yyerrok in the error handling action to ensure error processing is reset for the next line.","Q_Score":3,"Tags":"python,yacc,lex,ply","A_Id":842248,"CreationDate":"2009-05-08T18:23:00.000","Title":"Tokenizing left over data with lex\/yacc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I'm trying to write a python script (in windows) that runs a batch file and will take the command line output of that batch file as input. The batch file runs processes that I don't have access to and gives output based on whether those processes are successful. I'd like to take those messages from the batch file and use them in the python script. Anyone have any ideas on how to do this ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9251,"Q_Id":842120,"Users Score":1,"Answer":"Try subprocess.Popen(). It allows you to redirect stdout and stderr to files.","Q_Score":3,"Tags":"python,windows,scripting,batch-file,io","A_Id":842139,"CreationDate":"2009-05-08T22:41:00.000","Title":"Piping Batch File output to a Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a vb.net application that has got 2 textboxes, 7 radio buttons and 2 buttons(one named compile and the other 'run'). How can I load the content of a C\/C++(or any programming language) file into the 1st textbox and on clicking the compile button, i should be able to show the errors or the C\/C++ program in the 2nd textbox. On clicking Run, I should be able to show the output in the 2nd textbox. In short, I want to use the 2nd textbox as a terminal\/console. The radio buttons are 4 selecting the language C or C++ or python or C# or java or perl or vb.\nAre the compilers of all these languages present in .net? If so how can I call them?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1053,"Q_Id":847860,"Users Score":1,"Answer":"Compiling can be done by calling cl.exe which comes with Visual Studio. Of course you could also use GCC instead.","Q_Score":1,"Tags":"c#,c++,python,c,vb.net","A_Id":847883,"CreationDate":"2009-05-11T12:24:00.000","Title":"How to write a vb.net code to compile C\/C++ programs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"M2Crypto provides EC support for ECDSA\/ECDH. I have installed OpenSSL 0.9.8i which contains support for EC. However when I run \"from M2Crypto import EC,BIO\" I get error saying EC_init() failed. So I added debug to print m2.OPENSSL_VERSION_TEXT value. It gets printed as \"OpenSSL 0.9.7 19 Feb 2003\". This version of OpenSSL doesnot support EC. \nI tried \"python setup.py build build_ext --openssl=\"new_path where OpenSSL 0.9.8i is installed\". Though M2Crypto is built again \"Python setup.py install\" , I still see that it points to \"Old version of OpenSSL\". \nAny Pointers on how to successfully get M2Crypto to use 0.9.8i will be useful.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":880,"Q_Id":848508,"Users Score":0,"Answer":"Possibly its looking up shared libs libssl.so and libcrypto.so and finding the old ones in \/usr\/lib if you add the new_path to the top of \/etc\/ld.so.conf so it gets searched first it would work. But this might break other OpenSSL applications expecting old OpenSSL.","Q_Score":2,"Tags":"python,m2crypto","A_Id":848795,"CreationDate":"2009-05-11T14:55:00.000","Title":"Python M2Crypto EC Support","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Say I want to manipulate some files on a floppy drive or a USB card reader.  How do I check to see if the drive in question is ready? (That is, has a disk physically inserted.)\nThe drive letter exists, so os.exists() will always return True in this case.  Also, at this point in the process I don't yet know any file names, so checking to see if a given file exists also won't work.\nSome clarification: the issue here is exception handling.  Most of the win32 API calls in question just throw an exception when you try to access a drive that isn't ready.  Normally, this would work fine - look for something like the free space, and then catch the raised exception and assume that means there isn't a disk present.  However, even when I catch any and all exceptions, I still get an angry exception dialog box from Windows telling me the floppy \/ card reader isn't ready.  So, I guess the real question is - how do I suppress the windows error box?","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":3839,"Q_Id":851010,"Users Score":4,"Answer":"You can compare len(os.listdir(\"path\")) to zero to see if there are any files in the directory.","Q_Score":4,"Tags":"python,windows","A_Id":851039,"CreationDate":"2009-05-12T03:20:00.000","Title":"How do I check if a disk is in a drive using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache.\nI'm running OSX 10.5 and have the standard apache (which refuses to run python) and MAMP (which begrudgingly allows it in cgi-bin). The problem is that I've no idea which script to call, in the tutorial it was always localhost:8000\/polls but I've no idea how that's meant to map to a specific file.\nHave I missed something blatantly obvious about what to do with a .htaccess file or does the tutorial not actually explain how to use it somewhere else?","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":1602,"Q_Id":855408,"Users Score":5,"Answer":"Unless you are planning on going to production with OS X you might not want to bother. If you must do it, go straight to mod_wsgi. Don't bother with mod_python or older solutions. I did mod_python on Apache and while it runs great now, it took countless hours to set up.\nAlso, just to clarify something based on what you said: You're not going to find a mapping between the url path (like \/polls) and a script that is being called. Django doesn't work like that. With Django your application is loaded into memory waiting for requests. Once a request comes in it gets dispatched through the url map that you created in urls.py. That boils down to a function call somewhere in your code.\nThat's why for a webserver like Apache you need a module like mod_wsgi, which gives your app a spot in memory in which to live. Compare that with something like CGI where the webserver executes a specific script on demand at a location that is physically mapped between the url and the filesystem.\nI hope that's helpful and not telling you something you already knew. :)","Q_Score":1,"Tags":"python,django,macos","A_Id":856033,"CreationDate":"2009-05-12T23:29:00.000","Title":"Running django on OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache.\nI'm running OSX 10.5 and have the standard apache (which refuses to run python) and MAMP (which begrudgingly allows it in cgi-bin). The problem is that I've no idea which script to call, in the tutorial it was always localhost:8000\/polls but I've no idea how that's meant to map to a specific file.\nHave I missed something blatantly obvious about what to do with a .htaccess file or does the tutorial not actually explain how to use it somewhere else?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1602,"Q_Id":855408,"Users Score":2,"Answer":"Yet another option is to consider using a virtual machine for your development. You can install a full version of whatever OS your production server will be running - say, Debian - and run your Apache and DB in the VM.\nYou can connect to the virtual disk in the Finder, so you can still use TextMate (or whatever) on OSX to do your editing.\nI've had good experiences doing this via VMWare Fusion.","Q_Score":1,"Tags":"python,django,macos","A_Id":856986,"CreationDate":"2009-05-12T23:29:00.000","Title":"Running django on OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a file containing roughly all the words in English (~60k words, ~500k characters). I want to test whether a certain word I receive as input is \"in English\" (i.e. if this exact word is in the list).\nWhat would be the most efficient way to do this in Python?\nThe trivial solution is to load the file into a list and check whether the word is in that list. The list can be sorted, which I believe will shrink the complexity to O(logn). However I'm not sure about how Python implements searching through lists, and whether there's a performance penalty if such a large list is in memory. Can I \"abuse\" the fact I can put a cap on the length of words? (e.g. say the longest one is 15 characters long).\nPlease note I run the application on a machine with lots of memory, so I care less for memory consumption than for speed and CPU utilization.\nThanks","AnswerCount":9,"Available Count":2,"Score":0.0444152037,"is_accepted":false,"ViewCount":15715,"Q_Id":872290,"Users Score":2,"Answer":"You're basically testing whether a member is in a set or not, right?\nIf so, and because you said you have lots of memory, why not just load all the words as keys in memcache, and then for every word, just check if it is present in memcache or not.\nOr use that data structure that is used by bash to autocomplete command names - this is fast and highly efficient in memory (can't remember the name).","Q_Score":11,"Tags":"python,string","A_Id":872295,"CreationDate":"2009-05-16T12:01:00.000","Title":"Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a file containing roughly all the words in English (~60k words, ~500k characters). I want to test whether a certain word I receive as input is \"in English\" (i.e. if this exact word is in the list).\nWhat would be the most efficient way to do this in Python?\nThe trivial solution is to load the file into a list and check whether the word is in that list. The list can be sorted, which I believe will shrink the complexity to O(logn). However I'm not sure about how Python implements searching through lists, and whether there's a performance penalty if such a large list is in memory. Can I \"abuse\" the fact I can put a cap on the length of words? (e.g. say the longest one is 15 characters long).\nPlease note I run the application on a machine with lots of memory, so I care less for memory consumption than for speed and CPU utilization.\nThanks","AnswerCount":9,"Available Count":2,"Score":0.0444152037,"is_accepted":false,"ViewCount":15715,"Q_Id":872290,"Users Score":2,"Answer":"Two things: \nThe Python 'mutable set' type has an 'add' method ( s.add(item) ), so you could go right from reading (a line) from your big file straight into a set without using a list as an intermediate data structure.  \nPython lets you 'pickle' a data structure, so you could save your big set to a file and save the time of reinitiating the set.\nSecond, I've been looking for a list of all the single-syllable words in English for my own amusement, but the ones I've found mentioned seem to be proprietary.  If it isn't being intrusive, could I ask whether your list of English words can be obtained by others?","Q_Score":11,"Tags":"python,string","A_Id":872353,"CreationDate":"2009-05-16T12:01:00.000","Title":"Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"using Ruby or Python, does someone know how to draw on the screen, covering up any other window?  Kind of like, press a key, and the program will show current weather or stock quote on the screen (using the whole screen as the canvas), and then press the key again, and everything restores to the same as before?  (like Mac OS X's dash board).","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":179,"Q_Id":872737,"Users Score":1,"Answer":"I would recommend PyGame.","Q_Score":1,"Tags":"python,ruby,user-interface","A_Id":873925,"CreationDate":"2009-05-16T16:19:00.000","Title":"does someone know how to show content on screen (covering up any window) using Ruby or Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"using Ruby or Python, does someone know how to draw on the screen, covering up any other window?  Kind of like, press a key, and the program will show current weather or stock quote on the screen (using the whole screen as the canvas), and then press the key again, and everything restores to the same as before?  (like Mac OS X's dash board).","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":872737,"Users Score":4,"Answer":"You could use the systems dashboard (desktop widgets, or whatever it's called) API. In order to do that you need bindings to it for Python or Ruby.\nAlternatively you could use some generic gui toolkit or application framework and just create a frameless window with transparent background. Then you need to be sure that the chosen toolkit supports 'always-on-top' options on your desired platform(s).","Q_Score":1,"Tags":"python,ruby,user-interface","A_Id":872757,"CreationDate":"2009-05-16T16:19:00.000","Title":"does someone know how to show content on screen (covering up any window) using Ruby or Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i check admin-privileges for my script during running?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2996,"Q_Id":874476,"Users Score":7,"Answer":"The concept of \"admin-privileges\" in our day of fine grained privilege control is becoming hard to define. If you are running on unix with \"traditional\" access control model, getting the effective user id (available in os module) and checking that against root (0) could be what you are looking for. If you know accessing a file on the system requires the privileges you want your script to have, you can use the os.access() to check if you are privileged enough.\nUnfortunately there is no easy nor portable method to give. You need to find out or define the security model used, what system provided APIs are available to query and set privileges and try to locate (or possibly implement yourself) the appropriate python modules that can be used to access the API.\nThe classic question, why do you need to find out? What if your script tries to do what it needs to do and \"just\" catches and properly handles failures?","Q_Score":2,"Tags":"python,unix,root,sudo","A_Id":874519,"CreationDate":"2009-05-17T12:09:00.000","Title":"Admin privileges for script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed.\nI'm sure python has library for doing such a task easily but so far all the approaches I have found seemed like it would have been sloppy to get it to work and I'm sure there is a better approach. So far I've tried: \n\nthe array.toFile() method but couldn't figure out how to get it to work with nested arrays of strings, it seemed geared towards integer data.\nLists and sets do not have a toFile method built in, so I would have had to parse and encode it manually. \nCSV seemed like a good approach but this would also require manually parsing it, and did not allow me to simply append new lines at the end - so any new calls the the CSVWriter would overwrite the file existing data.\n\nI'm really trying to avoid using databases (maybe SQLite but it seems a bit overkill) because I'm trying to develop this to have no software prerequisites besides Python.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":5460,"Q_Id":875228,"Users Score":2,"Answer":"I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed.\n\nIs the data only ever going to be parsed by Python programs? If not, then I'd avoid pickle et al (shelve and marshal) since they're very Python specific. JSON and YAML have the important advantage that parsers are easily available for most any language.","Q_Score":3,"Tags":"python,file-io,csv,multidimensional-array,fileparsing","A_Id":875525,"CreationDate":"2009-05-17T19:00:00.000","Title":"Simple data storing in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My PyQt application that uses matplotlib takes several seconds to load for the first time, even on a fast machine (the second load time is much shorter as the DLLs are kept in memory by Windows).\nI'm wondering whether it's feasible to show a splash screen while the matplotlib library is being loaded. Where does the actual loading take place - is it when the from line is executed? If so, how can I make this line execute during the splash screen and still be able to use the module throughout the code?\nA related dilemma is how to test this - can I ask Windows to load the DLLs for every execution and not cache them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3080,"Q_Id":876107,"Users Score":3,"Answer":"Yes, loading the module takes place at the line where the import statement is. If you create your QApplication and show your splash screen before that, you should be able to do what you want -- also you need  to call QApplication.processEvents() whenever you need the splash screen to update with a new message.","Q_Score":4,"Tags":"python,performance,matplotlib,pyqt","A_Id":876151,"CreationDate":"2009-05-18T03:15:00.000","Title":"PyQt: splash screen while loading \"heavy\" libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"MySQL has a RENAME TABLE statemnt that will allow you to change the name of a table.  \nThe manual mentions \n\nThe rename operation is done atomically, which means that no other session can \n  access any of the tables while the rename is running\n\nThe manual does not (to my knowedge) state how this renaming is accomplished.  Is an entire copy of the table created, given a new name, and then the old table deleted?  Or does MySQL do some magic behind the scenes to quickly rename the table?\nIn other words, does the size of the table have an effect on how long the RENAME table statement will take to run.  Are there other things that might cause the renaming of a block to significantly block?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2472,"Q_Id":885771,"Users Score":5,"Answer":"I believe MySQL only needs to alter metadata and references to the table's old name in stored procedures -- the number of records in the table should be irrelevant.","Q_Score":3,"Tags":"php,python,mysql,ruby,migration","A_Id":885783,"CreationDate":"2009-05-20T01:22:00.000","Title":"How does MySQL's RENAME TABLE statment work\/perform?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a little script for Ubuntu. \nMy intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome)  .\nI can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb).\nAny ideas?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1143,"Q_Id":906509,"Users Score":2,"Answer":"You can't import rhythmbox \"built-in\" modules from a standard python console. \nAs far as I know they aren't real modules, they are just objects from the rhythmbox process exposed to plugins. So you can access them only if you are running your script from the rhythmbox process.","Q_Score":0,"Tags":"python,plugins,gnome,rhythmbox","A_Id":1450802,"CreationDate":"2009-05-25T12:16:00.000","Title":"show lyrics on ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a little script for Ubuntu. \nMy intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome)  .\nI can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb).\nAny ideas?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1143,"Q_Id":906509,"Users Score":0,"Answer":"in this case i guess you'll have to write the whole plugin yourself and , then listen to dbus for change of songs in rhythmbox , to detect which song is being played .","Q_Score":0,"Tags":"python,plugins,gnome,rhythmbox","A_Id":4594514,"CreationDate":"2009-05-25T12:16:00.000","Title":"show lyrics on ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My hosting provider says my python script must be made to be executable(chmod755).  What does this mean & how do I do it?\nCheers!","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3729,"Q_Id":907579,"Users Score":0,"Answer":"In addition to the other fine answers here, you should be aware that most FTP clients have a chmod command to allow you to set permissions on files at the server. You may not need this if permissions come across properly, but there's a good chance they do not.","Q_Score":4,"Tags":"python,hosting","A_Id":907605,"CreationDate":"2009-05-25T18:05:00.000","Title":"Making a Python script executable chmod755?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A table has been ETLed to another table. My task is to verify the data between two tables programmatically. \nOne of the difficulties I m facing rite now is:\nhow to use the expression that I can get from, let s say, derived column task and verify with the source and destination.\nor in other words, how can I use the expression to work in the code. \nAny ideas....highly appreciated\nSagar","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1102,"Q_Id":921268,"Users Score":2,"Answer":"Set up a column which holds a CHECKSUM() of each row.  Do a left outer join between the two tables .  If you have any nulls for the right side, you have problems.","Q_Score":0,"Tags":".net,ssis,ironpython","A_Id":1233648,"CreationDate":"2009-05-28T14:55:00.000","Title":"How to compare data of two tables transformed in SSIS package","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to add python and ruby libs as a resource in a dll for deployment?  I want to host a script engine in my app, but dont want to have to deploy the entire standard libraries of the respective languages in source files.  Is there a simple way to do this so that a require or import statement will find the embedded resources?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":520,"Q_Id":933822,"Users Score":0,"Answer":"IronPython 2.0 has a sample compiler called PYC on Codeplex.com\/ironpython which can create DLL's (and applications if you need them too).\nIronPython 2.6 has a newer version of PYC under Tools\\script.\nCheers,\nDavy","Q_Score":3,"Tags":"c#,python,ruby,ironpython,ironruby","A_Id":933988,"CreationDate":"2009-06-01T07:14:00.000","Title":"Packaging script source files in IronPython and IronRuby","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to add python and ruby libs as a resource in a dll for deployment?  I want to host a script engine in my app, but dont want to have to deploy the entire standard libraries of the respective languages in source files.  Is there a simple way to do this so that a require or import statement will find the embedded resources?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":520,"Q_Id":933822,"Users Score":1,"Answer":"You could add custom import hook that looks for embedded resources when an import is executed. This is slightly complex and probably not worth the trouble.\nA better technique would be to fetch all of the embedded modules at startup time, execute them with the ScriptEngine and put the modules you have created into the sys.modules dictionary associated with the engine. This automatically makes them available for import by Python code executed by the engine.","Q_Score":3,"Tags":"c#,python,ruby,ironpython,ironruby","A_Id":934609,"CreationDate":"2009-06-01T07:14:00.000","Title":"Packaging script source files in IronPython and IronRuby","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"float('nan') represents NaN (not a number). But how do I check for it?","AnswerCount":18,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2218724,"Q_Id":944700,"Users Score":241,"Answer":"numpy.isnan(number) tells you if it's NaN or not.","Q_Score":1412,"Tags":"python,math","A_Id":944756,"CreationDate":"2009-06-03T13:19:00.000","Title":"How can I check for NaN values?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need help writing a recursive function which detects whether a string is a palindrome. But i can't use any loops it must be recursive. Can anyone help show me how this is done . Im using Python.","AnswerCount":11,"Available Count":2,"Score":0.0363476168,"is_accepted":false,"ViewCount":99261,"Q_Id":952110,"Users Score":2,"Answer":"Here's another viewpoint\nA palindromic string is\n\nSome letter, x.\nSome palindromic substrinng.\nThe same letter, x, repeated.\n\nAlso, note that you may be given a proper English sentence \"Able was I ere I saw Elba.\" with punctuation.  Your palindrome checker may have to quietly skip punctuation.  Also, you may have to quietly match without considering case.  This is slightly more complex.\n\nSome leading punctuation.  Some letter, x.\nSome palindromic substring.\nSome letter, x, repeated without regard to case.  Some trailing punctuation.\n\nAnd, by definition, a zero-length string is a palindrome.  Also a single-letter string (after removing punctuation) is a palindrome.","Q_Score":10,"Tags":"python,recursion,palindrome","A_Id":952171,"CreationDate":"2009-06-04T17:51:00.000","Title":"Recursive Function palindrome in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need help writing a recursive function which detects whether a string is a palindrome. But i can't use any loops it must be recursive. Can anyone help show me how this is done . Im using Python.","AnswerCount":11,"Available Count":2,"Score":0.0544914242,"is_accepted":false,"ViewCount":99261,"Q_Id":952110,"Users Score":3,"Answer":"If a string is zero or one letters long, it's a palindrome.\nIf a string has the first and last letters the same, and the remaining letters (I think it's a [1: -1] slice in Python, but my Python is a bit rusty) are a palindrome, it's a palindrome.\nNow, write that as a palindrome function that takes a string.  It will call itself.","Q_Score":10,"Tags":"python,recursion,palindrome","A_Id":952129,"CreationDate":"2009-06-04T17:51:00.000","Title":"Recursive Function palindrome in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":3989,"Q_Id":960467,"Users Score":3,"Answer":"I have a single main window with a QGraphicsView and lots of QGraphicsItem objects.  Each type of the Items have a different context menu.\nI find that not being able to create the contextMenu's, or at least the actions that are in them a serious limitation of QtDesigner.  It means that I can create about 10% or so of the actions using the designer, and I have to create 90% programaticaly.  Compare that with the Microsoft resource editor which allows all of these things to be created, and maintained effortlessly.  \nI hope this will be addressed at some point.","Q_Score":1,"Tags":"python,qt,widget,designer","A_Id":1235766,"CreationDate":"2009-06-06T20:33:00.000","Title":"how can I add a QMenu and QMenuItems to a window from Qt Designer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3989,"Q_Id":960467,"Users Score":3,"Answer":"When you edit a QMainWindow you can right click the window and then choose \"create menu bar\".\nOr are you talking about a \"context menu\" aka \"right click menu\"?","Q_Score":1,"Tags":"python,qt,widget,designer","A_Id":960506,"CreationDate":"2009-06-06T20:33:00.000","Title":"how can I add a QMenu and QMenuItems to a window from Qt Designer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3989,"Q_Id":960467,"Users Score":0,"Answer":"Adding menu editing for every widget in the designer would probably make a very awkward and inconvenient UI. There's really no place you can visualize it on.\nIf you're editing a QMainWindow you can edit the menu bar and its popups because there's a proper place for them to be displayed in.","Q_Score":1,"Tags":"python,qt,widget,designer","A_Id":960479,"CreationDate":"2009-06-06T20:33:00.000","Title":"how can I add a QMenu and QMenuItems to a window from Qt Designer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to remove text between <script> and <\/script> using python?","AnswerCount":9,"Available Count":2,"Score":-0.022218565,"is_accepted":false,"ViewCount":10944,"Q_Id":964459,"Users Score":-1,"Answer":"I don't know Python good enough to tell you a solution. But if you want to use that to sanitize the user input you have to be very, very careful. Removing stuff between  and  just doesn't catch everything. Maybe you can have a look at existing solutions (I assume Django includes something like this).","Q_Score":5,"Tags":"javascript,python","A_Id":964478,"CreationDate":"2009-06-08T11:30:00.000","Title":"how to remove text between  using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to remove text between <script> and <\/script> using python?","AnswerCount":9,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10944,"Q_Id":964459,"Users Score":0,"Answer":"If you're removing everything between <script> and <\/script> why not just remove the entire node? \nAre you expecting a resig-style src and body?","Q_Score":5,"Tags":"javascript,python","A_Id":964487,"CreationDate":"2009-06-08T11:30:00.000","Title":"how to remove text between  using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can truncate an input like 315.15321531321\nI want to truncate all the values after the hundredths position so it becomes 315.15\nhow do i do that?","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":38627,"Q_Id":967661,"Users Score":1,"Answer":"You have several options - you can round the number using round(), however this can introduce some inaccuracies (315.15 might round to 315.150000003 for example). If you're just looking to truncate the value of the float when you're displaying it, you can specify the width of the output using printf(\"%.2f\", mynumber).  This is probably a better solution, since without knowing more about your specific application it's a good idea in general to keep the entire length of the number for calculation.","Q_Score":12,"Tags":"python,truncate","A_Id":967676,"CreationDate":"2009-06-09T00:29:00.000","Title":"python truncate after a hundreds?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been having a look at Django and, from what I've seen, it's pretty darn fantastic. I'm a little confused, however, how I go about implementing a \"home page\" for my website? Would it be a separate app, or just a view within the project, or what?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11919,"Q_Id":971983,"Users Score":11,"Answer":"There's no real rule for this, But one thing I like to do is actually arrange for the index access to redirect to another spot.  If you prefer, though, you can just give the index page a plain view.  \nThat said, It's probably a good idea to keep all your code in an actual app, so that you can refactor it more easily, and so that it appears on the python path as a normal module.  Putting views in the project rather than an app seems to cause more headaches than it solves.","Q_Score":20,"Tags":"python,django","A_Id":972004,"CreationDate":"2009-06-09T19:18:00.000","Title":"Django - Website Home Page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been in love with zsh for a long time, and more recently I have been discovering the advantages of the ipython interactive interpreter over python itself. Being able to cd, to ls, to run or to ! is indeed very handy. But now it feels weird to have such a clumsy shell when in ipython, and I wonder how I could integrate my zsh and my ipython better.\nOf course, I could rewrite my .zshrc and all my scripts in python, and emulate most of my shell world from ipython, but it doesn't feel right. And I am obviously not ready to use ipython as a main shell anyway.\nSo, here comes my question: how do you work efficiently between your shell and your python command-loop ? Am I missing some obvious integration strategy ? Should I do all that in emacs ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8591,"Q_Id":973520,"Users Score":11,"Answer":"I asked this question on the zsh list and this answer worked for me. YMMV.\nIn genutils.py after the line \n\nif not debug:\n\nRemove the line:\n\nstat = os.system(cmd)\n\nReplace it with:\n\nstat =\n  subprocess.call(cmd,shell=True,executable='\/bin\/zsh')\n\nyou see, the problem is that that \"!\" call uses os.system to run it, which defaults to manky old \/bin\/sh .\nLike I said, it worked for me, although I'm not sure what got borked behind the scenes.","Q_Score":11,"Tags":"python,shell,zsh,ipython","A_Id":1070597,"CreationDate":"2009-06-10T03:11:00.000","Title":"how to integrate ZSH and (i)python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed python and django in my system that uses win vista. Now when I go to  command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":139,"Q_Id":974821,"Users Score":1,"Answer":"you can't run a command that isn't in your path. it should be set globally when you installed python.\ntype 'set' at a dos prompt and look at the PATH variable. c:\\python25 (or whever you installed python) has to be in that variable ie PATH=c:\\windows;c:\\python25;... etc \nif it isn't in PATH then you or the installer missed the part where you needed to set it. It can be done from the 'Environment Variables' button in the 'System' control panel.","Q_Score":0,"Tags":"python,windows,django-admin","A_Id":974834,"CreationDate":"2009-06-10T10:42:00.000","Title":"python not starting properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed python and django in my system that uses win vista. Now when I go to  command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":974821,"Users Score":0,"Answer":"Either use the system control panel to set the PATH environment variable that applies permanently or\nReinstall Python as a system administrator so that the installer can set the registry and environment variables for you.\nIf you install the \"just for me\" option, then you have to set the PATH variable in the control panel.","Q_Score":0,"Tags":"python,windows,django-admin","A_Id":974848,"CreationDate":"2009-06-10T10:42:00.000","Title":"python not starting properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed python and django in my system that uses win vista. Now when I go to  command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":974821,"Users Score":0,"Answer":"In your path, I think you need to have both the location of the Python install and the Python\\Scripts folder.  For example, on XP, I have C:\\Python25;C:\\Python25\\Scripts.  Can you verify that you have both?","Q_Score":0,"Tags":"python,windows,django-admin","A_Id":975292,"CreationDate":"2009-06-10T10:42:00.000","Title":"python not starting properly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to set up auto completion to work nicely with python, django, and vim?\nI've been trying to use pysmell, but I can't seem to get it set up correctly (or maybe I don't know how it works). Right now, I run pysmell in the django directory (I'm using the trunk) and move the resulting tags to my project directory, then I also run pysmell in the project directory. Vim doesn't pick up the django tags, though, and they don't get auto completed.\nDoes anyone know how to set up auto completion in vim so that it will complete the long django functions (like get_object_or_404) as well as classes\/functions in my own code? I have poked around on google but haven't found any good resources.\nThanks.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":19878,"Q_Id":978643,"Users Score":2,"Answer":"Today, you not need special extentions for django autocomplete in vim. Make sure that you have vim with python support.\nTo check it, type in xterm:\nvim --version|grep python\noutput:\n+python -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs ... ...\nTo make work autocomplete, add this lines in your .vimrc:\n\nautocmd FileType python set omnifunc=pythoncomplete#Complete\nif has(\"python\")\npython import sys,os\npython sys.path.append('\/home\/sergey\/workspace\/django')\npython os.environ['DJANGO_SETTINGS_MODULE'] = 'djangoProject.settings'\nendif\n\nwhere:\n\nsys.path.append is path to your django workspace directory\ndjangoProject is name of your django project, which is going just after '\/home\/sergey\/workspace\/django'\n\nFinally, save it and restart vim. Now, after '.', you press default ctrl-x ctrl-o to get your autocomplete.","Q_Score":48,"Tags":"python,django,vim","A_Id":10666285,"CreationDate":"2009-06-10T23:35:00.000","Title":"Vim, Python, and Django autocompletion (pysmell?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to set up auto completion to work nicely with python, django, and vim?\nI've been trying to use pysmell, but I can't seem to get it set up correctly (or maybe I don't know how it works). Right now, I run pysmell in the django directory (I'm using the trunk) and move the resulting tags to my project directory, then I also run pysmell in the project directory. Vim doesn't pick up the django tags, though, and they don't get auto completed.\nDoes anyone know how to set up auto completion in vim so that it will complete the long django functions (like get_object_or_404) as well as classes\/functions in my own code? I have poked around on google but haven't found any good resources.\nThanks.","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":19878,"Q_Id":978643,"Users Score":3,"Answer":"I've had good luck with exuberant-ctags for this.\nI use this macro in my vimrc:\n\nexecute 'map  :!\/usr\/bin\/exuberant-ctags -f '.&tags.' --recurse '.$_P4ROOT.' '\n\nYou'll want to modify that slightly, so that it includes your python \/site-packages\/django\/ directory as well as your own code.\nThen, hit F2 inside vim to update the tags, and use the regular vim tag bindings to navigate.","Q_Score":48,"Tags":"python,django,vim","A_Id":978766,"CreationDate":"2009-06-10T23:35:00.000","Title":"Vim, Python, and Django autocompletion (pysmell?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed lxml which was built using a standalone version of libxml2. Reason for this was that the lxml needed a later version of libxml2 than what was currently installed.\nWhen I use the lxml module how do I tell it (python) where to find the correct version of the libxml2 shared library?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2097,"Q_Id":985155,"Users Score":5,"Answer":"Assuming you're talking about a .so file, it's not up to Python to find it -- it's up to the operating system's dynamic library loaded.  For Linux, for example, LD_LIBRARY_PATH is the environment variable you need to set.","Q_Score":5,"Tags":"python","A_Id":985176,"CreationDate":"2009-06-12T05:28:00.000","Title":"How to specify native library search path for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract the namespaces defined in C++ files.\nBasically, if my C++ file contains:\n\nnamespace n1 {\n  ...\n  namespace n2 { ... } \/\/ end namespace n2 \n  ...\n  namespace n3 { ...} \/\/end namespace n3 \n  ...\n} \/\/end namespace n1\n\nI want to be able to retrieve: n1, n1::n2, n1::n3.\nDoes someone have any suggestion of how I could do that using python-regex? \nThanks.","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":799,"Q_Id":995165,"Users Score":0,"Answer":"That is what I did earlier today:    \n\nExtract the comment out of the C++ files\nUse regex to extract the namespace definition\nUse a simple string search to get the open & close braces positions\n\nThe various sanity check added show that I am successfully processing 99.925% of my files (5 failures ouf of 6678 files). The issues are due to mismatches in numbers of { and } cause by few '{' or '}' in strings, and unclean usage of the preprocessor instruction.\nHowever, I am only dealing with header files, and I own the code. That limits the number of scenari that could cause some issues and I can manually modify the ones I don't cover.\nOf course I know there are plenty of cases where it would fail but it is probably enough for what I want to achieve.\nThanks for your answers.","Q_Score":1,"Tags":"c++,python,regex,namespaces","A_Id":998230,"CreationDate":"2009-06-15T09:15:00.000","Title":"Using python regex to extract namespaces from C++ sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract the namespaces defined in C++ files.\nBasically, if my C++ file contains:\n\nnamespace n1 {\n  ...\n  namespace n2 { ... } \/\/ end namespace n2 \n  ...\n  namespace n3 { ...} \/\/end namespace n3 \n  ...\n} \/\/end namespace n1\n\nI want to be able to retrieve: n1, n1::n2, n1::n3.\nDoes someone have any suggestion of how I could do that using python-regex? \nThanks.","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":799,"Q_Id":995165,"Users Score":1,"Answer":"You could write a basic lexer for it. It's not that hard.","Q_Score":1,"Tags":"c++,python,regex,namespaces","A_Id":997076,"CreationDate":"2009-06-15T09:15:00.000","Title":"Using python regex to extract namespaces from C++ sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract the namespaces defined in C++ files.\nBasically, if my C++ file contains:\n\nnamespace n1 {\n  ...\n  namespace n2 { ... } \/\/ end namespace n2 \n  ...\n  namespace n3 { ...} \/\/end namespace n3 \n  ...\n} \/\/end namespace n1\n\nI want to be able to retrieve: n1, n1::n2, n1::n3.\nDoes someone have any suggestion of how I could do that using python-regex? \nThanks.","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":799,"Q_Id":995165,"Users Score":2,"Answer":"The need is simple enough that you may not need a complex parser. You need to:\n\nextract the namespace names\ncount the open\/close braces to keep track of where your namespace is defined.\n\nThis simple approach works if the other conditions are met:\n\nyou don't get spurious namespace like strings inside comments or inside strings\nyou don't get unmatched open\/closeing braces inside comments or strings\n\nI don't think this is too much asking from your source.","Q_Score":1,"Tags":"c++,python,regex,namespaces","A_Id":997110,"CreationDate":"2009-06-15T09:15:00.000","Title":"Using python regex to extract namespaces from C++ sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract the namespaces defined in C++ files.\nBasically, if my C++ file contains:\n\nnamespace n1 {\n  ...\n  namespace n2 { ... } \/\/ end namespace n2 \n  ...\n  namespace n3 { ...} \/\/end namespace n3 \n  ...\n} \/\/end namespace n1\n\nI want to be able to retrieve: n1, n1::n2, n1::n3.\nDoes someone have any suggestion of how I could do that using python-regex? \nThanks.","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":799,"Q_Id":995165,"Users Score":6,"Answer":"Searching for the namespace names is pretty easy with a regular expression. However, to determine the nesting level you will have to keep track of the curly bracket nesting level in the source file. This is a parsing problem, one that cannot be solved (sanely) with regular expressions. Also, you may have to deal with any C preprocessor directives in the file which can definitely affect parsing.\nC++ is a notoriously tricky language to parse completely, but you may be able to get by with a tokeniser and a curly bracket counter.","Q_Score":1,"Tags":"c++,python,regex,namespaces","A_Id":995182,"CreationDate":"2009-06-15T09:15:00.000","Title":"Using python regex to extract namespaces from C++ sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract the namespaces defined in C++ files.\nBasically, if my C++ file contains:\n\nnamespace n1 {\n  ...\n  namespace n2 { ... } \/\/ end namespace n2 \n  ...\n  namespace n3 { ...} \/\/end namespace n3 \n  ...\n} \/\/end namespace n1\n\nI want to be able to retrieve: n1, n1::n2, n1::n3.\nDoes someone have any suggestion of how I could do that using python-regex? \nThanks.","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":799,"Q_Id":995165,"Users Score":0,"Answer":"Most of the time when someone asks how to do something with regex, they're doing something very wrong.  I don't think this case is different.\nIf you want to parse c++, you need to use a c++ parser.  There are many things that can be done that will defeat a regex but still be valid c++.","Q_Score":1,"Tags":"c++,python,regex,namespaces","A_Id":997065,"CreationDate":"2009-06-15T09:15:00.000","Title":"Using python regex to extract namespaces from C++ sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a basic program in python using the PyQt4 module. I'd like to be able to use my system theme's icons for things like the preference dialog's icon, but i have no idea how to do this. So my question is, how do you get the location of an icon, but make sure it changes with the system's icon theme? If it matters, i'm developing this under ubuntu 9.04, so i am using the gnome desktop.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3720,"Q_Id":997904,"Users Score":0,"Answer":"I spent a decent amount of researching this myself not long ago, and my conclusion was that, unfortunately, Qt doesn't provide this functionality in a cross-platform fashion.  Ideally the QIcon class would have defaults for file open, save, '+', '-', preferences, etc, but considering it doesn't you'll have to grab the appropriate icon for your desktop environment.","Q_Score":8,"Tags":"python,icons,pyqt4","A_Id":999115,"CreationDate":"2009-06-15T19:25:00.000","Title":"System theme icons and PyQt4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First, my question is not about password hashing, but password encryption. I'm building a desktop application that needs to authentificate the user to a third party service. To speed up the login process, I want to give the user the option to save his credentials. Since I need the password to authentificate him to the service, it can't be hashed.\nI thought of using the pyCrypto module and its Blowfish or AES implementation to encrypt the credentials. The problem is where to store the key. I know some applications store the key directly in the source code, but since I am coding an open source application, this doesn't seem like a very efficient solution.\nSo I was wondering how, on Linux, you would implement user specific or system specific keys to increase password storing security.\nIf you have a better solution to this problem than using pyCrypto and system\/user specific keys, don't hesitate to share it. As I said before, hashing is not a solution and I know password encryption is vulnerable, but I want to give the option to the user. Using Gnome-Keyring is not an option either, since a lot of people (including myself) don't use it.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2912,"Q_Id":1001744,"Users Score":5,"Answer":"Encrypting the passwords doesn't really buy you a whole lot more protection than storing in plaintext.  Anyone capable of accessing the database probably also has full access to your webserver machines.\nHowever, if the loss of security is acceptable, and you really need this, I'd generate a new keyfile (from a good source of random data) as part of the installation process and use this.  Obviously store this key as securely as possible (locked down file permissions etc).  Using a single key embedded in the source is not a good idea - there's no reason why seperate installations should have the same keys.","Q_Score":7,"Tags":"python,linux,encryption,passwords","A_Id":1001833,"CreationDate":"2009-06-16T14:09:00.000","Title":"How To Reversibly Store Password With Python On Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Django, how can I see the number of current visitors? Or how do I determine the number of active sessions?\nIs this a good method?\nuse django.contrib.sessions.models.Session, set the expiry time short. Every time when somebody does something on the site, update expiry time. Then count the number of sessions that are not expired.","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":4771,"Q_Id":1003302,"Users Score":-2,"Answer":"Edit: Added some more information about why I present this answer here.  I found chartbeat when I tried to answer this same question for my django based site.  I don't work for them.\nNot specifically Django, but chartbeat.com is very interesting to add to a website as well.\ndjango-tracking is great, +1 for that answer, etc.  \nCouple of things I could not do with django-tracking, that chartbeat helped with; tracked interactions with completely cached pages which never hit the django tracking code and pages not delivered through django (e.g. wordpress, etc.)","Q_Score":3,"Tags":"python,django","A_Id":1004658,"CreationDate":"2009-06-16T18:50:00.000","Title":"Number of visitors in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an interface that has two toolbars, one attached to the frame and one embedded in a notebook tab. The one in the frame dutifully shows longHelp strings in the statusbar, the one in the notebook tab\ndoes not. How do I tell the one on the notebook tab where to display its help, or do I have to manage enter and leave bindings myself?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":948,"Q_Id":1014239,"Users Score":0,"Answer":"from wxPython docs\n\"\"\"\nlongHelpString\nThis string is shown in the statusbar (if any) of the parent frame when the mouse pointer is inside the tool\n\"\"\"\nso toolbar in notebook doesn't get any statusbar to display long help, so either thru src we should invertigate how it inquires abt status bar and supply a ref to main frame status bar\nelse i think better way is to just override wxToolBar::OnMouseEnter and display help directly on status bar","Q_Score":2,"Tags":"wxpython,wxwidgets","A_Id":1021396,"CreationDate":"2009-06-18T17:57:00.000","Title":"wxPython: how to make two toolbars use one statusbar for tooltips?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning Python because it appeals to me as a mathematician but also has many useful libraries for scientific computing, image processing, web apps, etc etc.  \nIt is frustrating to me that for certain of my interests (eletronic music or installation art) there are very specific programming languages which seem better suited to these purposes, such as Max\/MSP, PureData, and ChucK -- all quite fascinating.\nMy question is, how should one approach these different languages? Should I simply learn Python and manage the others by using plugins and Python interpreters in them? Are there good tools for integrating the languages, or is the proper way simply to learn all of them?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1140,"Q_Id":1016301,"Users Score":8,"Answer":"I would say learn them all. While it's true that many languages can do many things, specialised languages are usually more expressive and easier to use for a particular task. Case-in-point is while most languages allow shell interaction and process control very few are as well suited to the task as bash scripts.\nPlugins and libraries can bridge the gap between general and specialised languages but in my experience this is not always without drawbacks - be they speed, stability or complexity. It isn't uncommon to have to compile additional libraries or apply patches or use untrusted and poorly supported modules. It also isn't uncommon that the resulting interface is still harder to use than the original language.\nI know about 15 languages well and a few of those very well. I do not use my prefered languages when another is more suitable.","Q_Score":6,"Tags":"python,chuck,puredata","A_Id":1016318,"CreationDate":"2009-06-19T04:04:00.000","Title":"Synthesis of general programming language (Python) with tailored language (PureData\/MaxMSP\/ChucK)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning Python because it appeals to me as a mathematician but also has many useful libraries for scientific computing, image processing, web apps, etc etc.  \nIt is frustrating to me that for certain of my interests (eletronic music or installation art) there are very specific programming languages which seem better suited to these purposes, such as Max\/MSP, PureData, and ChucK -- all quite fascinating.\nMy question is, how should one approach these different languages? Should I simply learn Python and manage the others by using plugins and Python interpreters in them? Are there good tools for integrating the languages, or is the proper way simply to learn all of them?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1140,"Q_Id":1016301,"Users Score":4,"Answer":"This thread is a little old, but I wanted to point out that the majority of the mature audio development environments e.g. supercollider\/max-msp\/pure data can be controlled via open sound control. You can google up a better description of OSC, but suffice it to say that it allows you to send control data to synths built in these environments similar to how MIDI works, but way more extensive. This does not solve the problem of actually building synths in python per se but it allows you to \"drive\" these other environments without having to know the ins and outs of the language.","Q_Score":6,"Tags":"python,chuck,puredata","A_Id":1716786,"CreationDate":"2009-06-19T04:04:00.000","Title":"Synthesis of general programming language (Python) with tailored language (PureData\/MaxMSP\/ChucK)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications.\nSo I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option.\nThe uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method?\nWhat would be the best way to go about this - other than \"don't do it at all\"? :) What other glaring security problems have I missed?\nFWIW, the web app will be written in Python.","AnswerCount":12,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7104,"Q_Id":1019707,"Users Score":0,"Answer":"I think your solutions must concentrate on analyzing the source code. I don't know any tools, and I think this would be pretty hard with C, but, for example, a Pascal program which doesn't include any modules would be pretty harmless in my opinion.","Q_Score":16,"Tags":"python,c,linux,security,sandbox","A_Id":1029301,"CreationDate":"2009-06-19T19:35:00.000","Title":"Sandboxing in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications.\nSo I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option.\nThe uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method?\nWhat would be the best way to go about this - other than \"don't do it at all\"? :) What other glaring security problems have I missed?\nFWIW, the web app will be written in Python.","AnswerCount":12,"Available Count":3,"Score":-0.0333209931,"is_accepted":false,"ViewCount":7104,"Q_Id":1019707,"Users Score":-2,"Answer":"About the only chance you have is running a VirtualMachine and those can have vulnerabilities. If you want your machine hacked in the short term just use permissions and make a special user with access to maybe one directory. If you want to postpone the hacking to some point in the future then run a webserver inside a virtual machine and port forward to that. You'll want to keep a backup of that because you'll probably have that hacked in under an hour and want to restart a fresh copy every few hours. You'll also want to keep an image of the whole machine to just reimage the whole thing once a week or so in order to overcome the weekly hackings. Don't let that machine talk to any other machine on your network. Blacklist it everywhere. I'm talking about the virtual machine and the physical machine IP addresses. Do regular security audits on any other machines on your other machines on the network. Please rename the machines IHaveBeenHacked1 and IHaveBeenHacked2 and prevent access to those in your hosts lists and firewalls.\nThis way you might stave off your level of hackage for a while.","Q_Score":16,"Tags":"python,c,linux,security,sandbox","A_Id":1019986,"CreationDate":"2009-06-19T19:35:00.000","Title":"Sandboxing in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a Web app which would allow the user to upload some C code, and see the results of its execution (the code would be compiled on the server). The users are untrusted, which obviously has some huge security implications.\nSo I need to create some kind of sandbox for the apps. At the most basic level, I'd like to restrict access to the file system to some specified directories. I cannot use chroot jails directly, since the web app is not running as a privileged user. I guess a suid executable which sets up the jail would be an option.\nThe uploaded programs would be rather small, so they should execute quickly (a couple of seconds at most). Hence, I can kill the process after a preset timeout, but how do I ensure that it doesn't spawn new processes? Or if I can't, is killing the entire pgid a reliable method?\nWhat would be the best way to go about this - other than \"don't do it at all\"? :) What other glaring security problems have I missed?\nFWIW, the web app will be written in Python.","AnswerCount":12,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7104,"Q_Id":1019707,"Users Score":0,"Answer":"Spawning a new VM under KVM or qemu to compile and run the code looks like the way to go. Running the code under jail\/LXC can compromise the machine if it exploits the unsecured parts of the OS like networking code. Advantage of running under a VM are obvious. One can only hack the VM but not the machine itself. But the side effect is you need lots of resources (CPU and Memory) to spawn a VM for each request.","Q_Score":16,"Tags":"python,c,linux,security,sandbox","A_Id":15609095,"CreationDate":"2009-06-19T19:35:00.000","Title":"Sandboxing in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm implementing a \"Google Suggest\" like autocomplete feature for tag searching using jQuery's autocomplete. \nI need to provide a web service to jQuery giving it a list of suggestions based on what the user has typed. I see 2 ways of implementing the web service:\n1) just store all the tags in a database and search the DB using user input as prefix. This is simple, but I'm concerned about latency.\n2) Use an in-process trie to store all the tags and search it for matching results. As everything will be in-process, I expect this to have much lower latency. But there are several difficulties:\n-What's a good way to initialize the trie on process start up? Presumable I'll store the tag data in a DB and retrieve them and turn them into a trie when I frist start up the process. But I'm not sure how. I'm using Python\/Django. \n-When a new tag is created by a user, I need to insert the new tag into the trie. But let's say I have 5 Django processes and hence 5 tries, how do I tell the other 4 tries that they need to insert a new tag too?\n-How to make sure the trie is threadsafe as my Django processes will be threaded (I'm using mod_wsgi). Or do I not have to worry about threadsafty because of Python's GIL?\n-Any way I can store the tag's frequency of use within the trie as well? How do I tell when does the tag's string end and when does the frequency start - eg. if I store apple213 into the trie, is it \"apple\" with frequency 213 or is it \"apple2\" with frequency 13??\nAny help on the issues above or any suggestions on a different approach would be really appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1169,"Q_Id":1025018,"Users Score":1,"Answer":"I would use the first option. 'KISS' - (Keep It Simple Stupid).\nFor small amounts of data there shouldn't be much latency. We run the same kind of thing for a name search and results appear pretty quickly on a few thousand rows.\nHope that helps,\nJosh","Q_Score":2,"Tags":"python,ajax,autocomplete,trie","A_Id":1025027,"CreationDate":"2009-06-21T23:31:00.000","Title":"What's the best way to implement web service for ajax autocomplete","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was just wondering if anybody knows how to add reference to \"Ritmo for iSeries\" in IronPython.\nI did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, \"could not add reference to assembly Ritmo for iSeries\".\nI was doing\nimport clr\nclr.AddReference('Ritmo for iSeries')\nfrom Ritmo........\nIOError: Could not add reference to assembly Ritmo for iSeries","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":1032888,"Users Score":0,"Answer":"Jonathan helped me to figure out that I had not copied the dll file to the location where IronPython can find it.\nAfter copying the dll file to the location, usually it s \"c:\\Program Files\\IronPython 2.0\\\"\nunless stated otherwise, I did:\nimport clr\nclr.AddReference('System.Data')\nclr.AddReferenceToFile('Sql400.dll')  \nfrom System.Data import Sql400\nfrom System.Data.Sql400 import *","Q_Score":0,"Tags":"c#,ironpython","A_Id":1034326,"CreationDate":"2009-06-23T14:24:00.000","Title":"how to addreference to Ritmo for iSeries in ironpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was just wondering if anybody knows how to add reference to \"Ritmo for iSeries\" in IronPython.\nI did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, \"could not add reference to assembly Ritmo for iSeries\".\nI was doing\nimport clr\nclr.AddReference('Ritmo for iSeries')\nfrom Ritmo........\nIOError: Could not add reference to assembly Ritmo for iSeries","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":1032888,"Users Score":0,"Answer":"You need to use the actual name of the assembly (it won't have spaces).\nIn your C# project, what does it list under the 'references' folder once you've added it as a reference?  Try putting that.  Also, make sure you've copied the dll for the library to where your IronPython script can find it (if it's not in the GAC).","Q_Score":0,"Tags":"c#,ironpython","A_Id":1032962,"CreationDate":"2009-06-23T14:24:00.000","Title":"how to addreference to Ritmo for iSeries in ironpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to convert HTML CSS file to wxPython files? That is, how to create slidsheet in wxPython like HTML CSS files?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":677,"Q_Id":1038182,"Users Score":0,"Answer":"stylesheet, not slidesheet.\nf = open('NAMEOFSTYLESHEET.css','w')\nf.write('#ID{}\\n.class{}')","Q_Score":0,"Tags":"wxpython","A_Id":14180592,"CreationDate":"2009-06-24T12:54:00.000","Title":"HTML conversion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to take a string in Python and encrypt it using a public key.\nCan anyone give me an example or recommendation about how to go about doing this?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2977,"Q_Id":1043382,"Users Score":2,"Answer":"I looked at the ezPyCrypto library that was recommended in another answer.\nPlease don't use this library. It is very incomplete and in some cases incorrect and highly insecure. Public key algorithms have many pitfalls and need to be implemented carefully.\nFor example, RSA message should use a padding scheme such as PKCS #1, OAEP etc to be secure. This library doesn't pad. DSA signatures should use the SHA1 hash function. This library uses the broken MD5 hash and there is even a bigger bug in the random number generation. Hence the DSA implementation is neither standards conform nor secure. ElGamal is also implemented incorrectly.\nFollowing standards does make implementations somewhat more complex. But not following any is not an option. At least not if you care about security.","Q_Score":2,"Tags":"python,encryption","A_Id":1051793,"CreationDate":"2009-06-25T11:19:00.000","Title":"Encrypt a string using a public key","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a system sitting on a \"Master Server\", that is periodically transferring quite a few chunks of information from a MySQL DB to another server in the web.\nBoth servers have a MySQL Server and an Apache running. I would like an easy-to-use solution for this.\nCurrently I'm looking into:\n\nXMLRPC\nRestFul Services\na simple POST to a processing script\nsocket transfers\n\nThe app on my master is a TurboGears app, so I would prefer \"pythonic\" aka  less ugly solutions. Copying a dumped table to another server via FTP \/ SCP or something like that might be quick, but in my eyes it is also very (quick and) dirty, and I'd love to have a nicer solution.\nCan anyone describe shortly how you would do this the \"best-practise\" way?\nThis doesn't necessarily have to involve Databases. Dumping the table on Server1 and transferring the raw data in a structured way so server2 can process it without parsing too much is just as good. One requirement though: As soon as the data arrives on server2, I want it to be processed, so there has to be a notification of some sort when the transfer is done. Of course I could just write my whole own server sitting on a socket on the second machine and accepting the file with own code and processing it and so forth, but this is just a very very small piece of a very big system, so I dont want to spend half a day implementing this.\nThanks,\nTom","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":810,"Q_Id":1043528,"Users Score":2,"Answer":"Server 1: Convert rows to JSON, call the RESTful api of second with JSON data\nServer 2: listens on a URI e.g. POST \/data , get json data convert back to dictionary or ORM objects, insert into db\nsqlalchemy\/sqlobject and simplejson is what you need.","Q_Score":2,"Tags":"python,web-services,database-design","A_Id":1043653,"CreationDate":"2009-06-25T11:59:00.000","Title":"Best Practise for transferring a MySQL table to another server?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a system sitting on a \"Master Server\", that is periodically transferring quite a few chunks of information from a MySQL DB to another server in the web.\nBoth servers have a MySQL Server and an Apache running. I would like an easy-to-use solution for this.\nCurrently I'm looking into:\n\nXMLRPC\nRestFul Services\na simple POST to a processing script\nsocket transfers\n\nThe app on my master is a TurboGears app, so I would prefer \"pythonic\" aka  less ugly solutions. Copying a dumped table to another server via FTP \/ SCP or something like that might be quick, but in my eyes it is also very (quick and) dirty, and I'd love to have a nicer solution.\nCan anyone describe shortly how you would do this the \"best-practise\" way?\nThis doesn't necessarily have to involve Databases. Dumping the table on Server1 and transferring the raw data in a structured way so server2 can process it without parsing too much is just as good. One requirement though: As soon as the data arrives on server2, I want it to be processed, so there has to be a notification of some sort when the transfer is done. Of course I could just write my whole own server sitting on a socket on the second machine and accepting the file with own code and processing it and so forth, but this is just a very very small piece of a very big system, so I dont want to spend half a day implementing this.\nThanks,\nTom","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":810,"Q_Id":1043528,"Users Score":0,"Answer":"Assuming your situation allows this security-wise, you forgot one transport mechanism: simply opening a mysql connection from one server to another.\nMe, I would start by thinking about one script that ran regularly on the write server and opens a read only db connection to the read server (A bit of added security) and a full connection to it's own data base server. \nHow you then proceed depends on the data (is it just inserts to deal with? do you have to mirror deletes? how many inserts vs updates? etc) but basically you could write a script that pulled data from the read server and processed it immediately into the write server.\nAlso, would mysql server replication work or would it be to over-blown as a solution?","Q_Score":2,"Tags":"python,web-services,database-design","A_Id":1043595,"CreationDate":"2009-06-25T11:59:00.000","Title":"Best Practise for transferring a MySQL table to another server?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing an student attendance application in wxpython and I need to know how to ensure that password field doesn't echo characters to the screen.\nForexample :if I give the name as moni means then it should be displayed as in format of   ****","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":427,"Q_Id":1048446,"Users Score":1,"Answer":"You need to give your text control the TE_PASSWORD style.\n(As J\u00f8rn's comment points out, this isn't \"encryption\" - I'm assuming you're only talking about the visual presentation of the password.)","Q_Score":0,"Tags":"wxpython","A_Id":1048463,"CreationDate":"2009-06-26T10:44:00.000","Title":"Hiding characters typed into password field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron.\nI think the idea would be for each type of feed, define the ftp connection\/file information. Then there should be a translation of how data fields in the file relate to data fields that the application can work with (and of course process this translation). Additionally write separate scripts that do the common inserting functions for the different objects that may be used in different feeds.\nAs an e-commerce example, lets say I work with different suppliers who provide feeds to me. The feeds can be different (object) types: product, category, or order information. For each type of feed I obviously work with different fields and call different update or insert scripts.\nWhat is the best language to implement this in? I can work with PHP but am looking for a project to start learning Perl or Python so this could be good for me as well.\nIf Perl or Python, can you briefly give high level implementation. So how to separate the different scripts, object oriented approach?, how to make it easy to implement new feeds or processing functions in the future, etc.\n[full disclosure: There were already classes written in PHP which I used to create a new feed recently. I already did my job, but it was super messy and difficult to do. So this question is not 'Please help me do my job' but rather a 'best approach' type of question for my own development.]\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1025,"Q_Id":1050089,"Users Score":1,"Answer":"Most modern languages scripting languages allow you to do all of these things. Because of that, I think your choice of language should be based on what you and the people who read your code know. \nIn Perl I'd make use of the following modules:\nNet::FTP to access the ftp sites.\nDBI to insert data into your database. \nModules like that are nice reusable pieces of code that you don't have to write, and interaction with ftp sites and databases are so common that every modern scripting language should have similar modules. \nI don't think that PHP is a great language so I'd avoid it if possible, but it might make sense for you if you have a lot of experience in it.","Q_Score":2,"Tags":"php,python,perl,parsing,feed","A_Id":1050136,"CreationDate":"2009-06-26T16:39:00.000","Title":"Get remote text file, process, and update database - approach and scripting language to use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two python installations, 2.5 and 2.6\nI want to change the default python interpreter from 2.5 to 2.6.\nAnyone know how?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":7934,"Q_Id":1053794,"Users Score":1,"Answer":"just FYI, since both c:\\python25 and c:\\python26 are on PATH, I copy C:\\Python25\\python.exe to C:\\Python25\\py25.exe, and copy C:\\Python26\\python.exe to C:\\Python26\\py26.exe\nThen just type py25(or py26) get the specific version.","Q_Score":5,"Tags":"python,windows","A_Id":1053888,"CreationDate":"2009-06-27T22:41:00.000","Title":"Changing python interpreter windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two python installations, 2.5 and 2.6\nI want to change the default python interpreter from 2.5 to 2.6.\nAnyone know how?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7934,"Q_Id":1053794,"Users Score":10,"Answer":"PYTHONPATH is NOT what you are looking for. That is for varying where Python's \"import\" looks for packages and modules.\nYou need to change the PATH variable in your environment so that it contains e.g. \"....;c:\\python26;....\" instead of \"....;c:\\python25;....\". Click on start > control panel > system > advanced > environment variables. Select \"path\". Edit it. Click on OK enough times to get out of there.","Q_Score":5,"Tags":"python,windows","A_Id":1053856,"CreationDate":"2009-06-27T22:41:00.000","Title":"Changing python interpreter windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some french letters (\u00e9, \u00e8, \u00e0...) in a django template but when it is loaded by django, an UnicodeDecodeError exception is raised.\nIf I don't load the template but directly use a python string. It works ok.\nIs there something to do to use unicode with django template?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4002,"Q_Id":1063626,"Users Score":7,"Answer":"You are probably storing the template in a non-unicode encoding, such as latin-1.  I believe Django assumes that templates are in UTF-8 by default (though there is a setting to override this).\nYour editor should be capable of saving the template file in the UTF-8 encoding (probably via a dropdown on the save as page, though this may depend on your editor).  Re-save the file as UTF-8, and the error should go away.","Q_Score":5,"Tags":"python,django,unicode","A_Id":1063665,"CreationDate":"2009-06-30T13:14:00.000","Title":"how to use french letters in a django template?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a username which I must change in numerous (up to ~25) tables.  (Yeah, I know.)  An atomic transaction seems to be the way to go for this sort of thing.  However, I do not know how to do this with pyodbc.  I've seen various tutorials on atomic transactions before, but have never used them.\nThe setup: Windows platform, Python 2.6, pyodbc, Microsoft SQL 2005.  I've used pyodbc for single SQL statements, but no compound statements or transactions.\nBest practices for SQL seem to suggest that creating a stored procedure is excellent for this.  My fears about doing a stored procedure are as follows, in order of increasing importance:\n    1) I have never written a stored procedure.\n    2) I heard that pyodbc does not return results from stored procedures as of yet.\n    3) This is most definitely Not My Database.  It's vendor-supplied, vendor-updated, and so forth.\nSo, what's the best way to go about this?","AnswerCount":2,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":27883,"Q_Id":1063770,"Users Score":-10,"Answer":"I don't think pyodbc has any specific support for transactions. You need to send the SQL command to start\/commit\/rollback transactions.","Q_Score":15,"Tags":"python,transactions,pyodbc","A_Id":1063879,"CreationDate":"2009-06-30T13:45:00.000","Title":"In Python, Using pyodbc, How Do You Perform Transactions?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":2414,"Q_Id":1075304,"Users Score":3,"Answer":"I'm not an Eclipse expert, but since you didn't get any other answer...\nIf you make the SCons source a part of the Eclipse project, and run the whole command from within Eclipse it should work like any Eclipse debugging. SCons is written in Python, there is no reason it shouldn't be debuggable in Eclipse just like anything else.","Q_Score":4,"Tags":"python,eclipse,pydev,scons","A_Id":1075694,"CreationDate":"2009-07-02T16:16:00.000","Title":"How to debug SCons scripts using eclipse and pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2414,"Q_Id":1075304,"Users Score":0,"Answer":"As an addendum: on Windows, I had to copy the scons-installed files to reside under C:\\Python27\\Lib\\site-packages\\scons in order for this to work.  Adding the original installed location, qualified with the version number, to the PYTHONPATH, did not work.","Q_Score":4,"Tags":"python,eclipse,pydev,scons","A_Id":45216082,"CreationDate":"2009-07-02T16:16:00.000","Title":"How to debug SCons scripts using eclipse and pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":2414,"Q_Id":1075304,"Users Score":1,"Answer":"On MAC to debug scons through pydev follow Lennart's answer but with one simply addition.\nUsing Finder (or terminal) browse to where scons is installed. You can find this with the \"which\" command.\ne.g. which scons\n-> \/usr\/local\/bin\/scons\nMake a copy of the scons file and call it scons.py.\nNow when you create the Debug Configuration in Eclipse use scons.py as the \"Main Module\".\nPS: To add a scons project to Eclipse I found it easier to use a \"Linked Folder\" pointing at \/usr\/local\/bin\/. i.e. Because I was getting a read-only error when trying to add the directory itself.","Q_Score":4,"Tags":"python,eclipse,pydev,scons","A_Id":15386322,"CreationDate":"2009-07-02T16:16:00.000","Title":"How to debug SCons scripts using eclipse and pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":2414,"Q_Id":1075304,"Users Score":6,"Answer":"You are right. Since the SCons is python based, the SCons scripts are debuggable via EClipse PyDev. For this, you need to do the following in the debug configuration...\n  1. Under the main tab, set the main module to the SCons file which will be available under the python\/scripts directory if you have installed SCons. If you have not run the install of SCons you can point to this file under the SCons directory.\n   2. Under the arguments tab, set the working directory to the root of your project.\nNow set the breakpoint either on SConstruct or SConcript and run in debug mode. That's all!! \nWith this approach you can not only debug your product code but also the build scripts that builds your product :-) Happy Debugging!!!!","Q_Score":4,"Tags":"python,eclipse,pydev,scons","A_Id":1077102,"CreationDate":"2009-07-02T16:16:00.000","Title":"How to debug SCons scripts using eclipse and pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2414,"Q_Id":1075304,"Users Score":0,"Answer":"I've since gain more experience with SCons \/ Python and I'd recommend using python's pdb module. To use it simply add the following code to your SCons\/Python files.\nimport pdb; pdb.set_trace()\nWhen the file is run from the command line a breakpoint will be hit at this line. I also moved away from Eclipse. A lightweight editor will be just as good for Python development. I use Sublime.","Q_Score":4,"Tags":"python,eclipse,pydev,scons","A_Id":32887089,"CreationDate":"2009-07-02T16:16:00.000","Title":"How to debug SCons scripts using eclipse and pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Developing a project of mine I realize I have a need for some level of persistence across sessions, for example when a user executes the application, changes some preferences and then closes the app.  The next time the user executes the app, be it after a reboot or 15 minutes, I would like to be able to retain the preferences that had been changed.  \nMy question relates to this persistence.  Whether programming an application using the win32 API or the MFC Framework .. or using the newer tools for higher level languages such as wxPython or wxRuby, how does one maintain the type of persistence I refer to?  Is it done as a temporary file written to the disk?  Is it saved into some registry setting?  Is there some other layer it is stored in that I am unaware of?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":729,"Q_Id":1077649,"Users Score":3,"Answer":"I would advice to do it in two steps.\n\nFirst step is to save your prefs. as\nstring, for that you can\na)\nUse any xml lib or output xml by\nhand    to output string and read\nsimilarly    from string\nb) Just use pickle module to dump your prefs object as a string\nc) Somehow generate a string from prefs which you can read back as prefs e.g. use yaml, config , JSON etc actually JSON is a good option when simplejson makes it so easy.\nOnce you have your methods to convert to and from string are ready, you just need to store it somewhere where it is persisted and you can read back next time, for that you can\na) Use wx.Config which save to registry in windows and to other places depending on platform so you don't have to worry where it saves, you can just read back values in platform independent way. But if you wish you can just use wx.Config for directly saving reading prefs.\nb) Directly save prefs. string to a file in a folder assigned by OS to your app e.g. app data folder in windows.\n\nBenefit of saving to a string and than using wx.Config to save it, is that you can easily change where data is saved in future e.g. in future if there is a need to upload prefs. you can just upload prefs. string.","Q_Score":1,"Tags":"python,windows,wxpython","A_Id":1077697,"CreationDate":"2009-07-03T03:24:00.000","Title":"Windows Application Programming & wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am not very familiar with databases, and so I do not know how to partition a table using SQLAlchemy.\nYour help would be greatly appreciated.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7505,"Q_Id":1085304,"Users Score":3,"Answer":"Automatic partitioning is a very database engine specific concept and SQLAlchemy doesn't provide any generic tools to manage partitioning. Mostly because it wouldn't provide anything really useful while being another API to learn. If you want to do database level partitioning then do the CREATE TABLE statements using custom Oracle DDL statements (see Oracle documentation how to create partitioned tables and migrate data to them). You can use a partitioned table in SQLAlchemy just like you would use a normal table, you just need the table declaration so that SQLAlchemy knows what to query. You can reflect the definition from the database, or just duplicate the table declaration in SQLAlchemy code.\nVery large datasets are usually time-based, with older data becoming read-only or read-mostly and queries usually only look at data from a time interval. If that describes your data, you should probably partition your data using the date field.\nThere's also application level partitioning, or sharding, where you use your application to split data across different database instances. This isn't all that popular in the Oracle world due to the exorbitant pricing models. If you do want to use sharding, then look at SQLAlchemy documentation and examples for that, for how SQLAlchemy can support you in that, but be aware that application level sharding will affect how you need to build your application code.","Q_Score":2,"Tags":"python,sqlalchemy","A_Id":1087081,"CreationDate":"2009-07-06T03:33:00.000","Title":"how to make table partitions?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this? \nThanks!","AnswerCount":7,"Available Count":2,"Score":0.1137907297,"is_accepted":false,"ViewCount":69405,"Q_Id":1095265,"Users Score":4,"Answer":"You could write the matrix in Python to a CSV file and read it in MATLAB using csvread.","Q_Score":51,"Tags":"python,matlab,file-io,import,matrix","A_Id":1095296,"CreationDate":"2009-07-07T22:55:00.000","Title":"Matrix from Python to MATLAB","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this? \nThanks!","AnswerCount":7,"Available Count":2,"Score":0.1418931938,"is_accepted":false,"ViewCount":69405,"Q_Id":1095265,"Users Score":5,"Answer":"I would probably use numpy.savetxt('yourfile.mat',yourarray) in Python\nand then yourarray = load('yourfile.mat') in MATLAB.","Q_Score":51,"Tags":"python,matlab,file-io,import,matrix","A_Id":7737622,"CreationDate":"2009-07-07T22:55:00.000","Title":"Matrix from Python to MATLAB","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":5834,"Q_Id":1113040,"Users Score":1,"Answer":"Do you want to write a program to do it, or do you want to use a program to do it?  There are many programs that list fonts, xlsfonts comes to mind.","Q_Score":5,"Tags":"python,c,macos,fonts","A_Id":1113055,"CreationDate":"2009-07-11T05:45:00.000","Title":"List of installed fonts OS X \/ C","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"App Engine allows you 30 seconds to load your application\nMy application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this.\nIf the app is idle (does not receive a request for a while), it needs to be re-loaded. \n\nSo, to avoid the app needing to be reloaded, I want to simulate user activity by pinging the app every so often.\nBut there's a catch . . .\nIf I ping the app and it has already been unloaded by App Engine, my web request will be the first request to the app and the app will try to reload. This could take longer than 30 seconds and exceed the loading time limit.\nSo my idea is to ping the app but not wait for the response. I have simulated this manually by going to the site from a browser, making the request and immediately closing the browser - it seems to keep the app alive.\nAny suggestions for a good way to do this in a Python or Java web cron (I'm assuming a Python solution will be simpler)?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1731,"Q_Id":1113066,"Users Score":1,"Answer":"App engine also has a new PAY feature where you can have it \"always-on\".  Costs about $0.30 USD cents a day.  Just go into your billing settings and enable it if you don't mind paying for the feature.  I believe it guarantees you at least 3 instances always running.\n(I didn't realize hitting a \/ping url which caused an instance to spin up would cause it to exceed the 30 sec limit!)","Q_Score":3,"Tags":"java,python,google-app-engine,httpwebrequest,keep-alive","A_Id":4707002,"CreationDate":"2009-07-11T06:02:00.000","Title":"How to keep an App Engine\/Java app running with deaf requests from a Java\/Python web cron?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a process id in Python. I know I can kill it with os.kill(), but how do I check if it is alive ? Is there a built-in function or do I have to go to the shell?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":15728,"Q_Id":1114312,"Users Score":14,"Answer":"os.kill does not kill processes, it sends them signals (it's poorly named).\nIf you send signal 0, you can determine whether you are allowed to send other signals.  An error code will indicate whether it's a permission problem or a missing process.\nSee man 2 kill for more info.\nAlso, if the process is your child, you can get a SIGCHLD when it dies, and you can use one of the wait calls to deal with it.","Q_Score":3,"Tags":"python,process","A_Id":1114435,"CreationDate":"2009-07-11T18:11:00.000","Title":"How do I check if a process is alive in Python on Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to execute a series of commands using Pythons subprocess module, however I need to set shell variables with export before running them. Of course the shell doesn't seem to be persistent so when I run a command later those shell variables are lost.\nIs there any way to go about this? I could create a \/bin\/sh process, but how would I get the exit codes of the commands run under that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3185,"Q_Id":1126116,"Users Score":13,"Answer":"subprocess.Popen takes an optional named argument env that's a dictionary to use as the subprocess's environment (what you're describing as \"shell variables\"). Prepare a dict as you need it (you may start with a copy of os.environ and alter that as you need) and pass it to all the subprocess.Popen calls you perform.","Q_Score":8,"Tags":"python,shell,variables,subprocess,persistent","A_Id":1126137,"CreationDate":"2009-07-14T15:19:00.000","Title":"Python: Persistent shell variables in subprocess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe.  My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such.  1.  Can I simply copy the contents of an XP installation into the cygwin tree?  2.  Is the XP flavor of Python different from the cygwin flavor?  (Same CPU, he pointed out, naively.)  3.  Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done?  \nDisclaimer 1:  I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place.  Disclaimer 2:  sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2747,"Q_Id":1126842,"Users Score":0,"Answer":"This probably has little value, but... I found myself in this exact situation -- we use ActivePython2.5 in production (pure windows environment) and I was trying to do my development within cygwin and cygwin's Python... \nAfter ripping out half of my hair, I have now switched over to Console2, gvim, iPython and ActivePython2.5.\nI'm less than thrilled dealing with Windows tools (and their concomitant warts), but at least I'm not getting in my own way when it comes to development.  For a while I found I was spending more time trying to get my tools to play nice than actually getting any work done.\nGood luck on this one.","Q_Score":3,"Tags":"python,windows-xp,cygwin","A_Id":1128193,"CreationDate":"2009-07-14T17:28:00.000","Title":"Best way to have full Python install under cygwin\/XP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe.  My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such.  1.  Can I simply copy the contents of an XP installation into the cygwin tree?  2.  Is the XP flavor of Python different from the cygwin flavor?  (Same CPU, he pointed out, naively.)  3.  Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done?  \nDisclaimer 1:  I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place.  Disclaimer 2:  sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":2747,"Q_Id":1126842,"Users Score":2,"Answer":"I use Python from within cygwin, but I don't use the version that cygwin gives you the option of installing as I don't have the control over version number used that I need (we use an older version at work).  I have my python version installed via the windows installer (the xp version as you put it) and add the \/cygdrive\/c\/Python2x directory to my PATH environment variable.","Q_Score":3,"Tags":"python,windows-xp,cygwin","A_Id":1126885,"CreationDate":"2009-07-14T17:28:00.000","Title":"Best way to have full Python install under cygwin\/XP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe.  My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such.  1.  Can I simply copy the contents of an XP installation into the cygwin tree?  2.  Is the XP flavor of Python different from the cygwin flavor?  (Same CPU, he pointed out, naively.)  3.  Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done?  \nDisclaimer 1:  I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place.  Disclaimer 2:  sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2747,"Q_Id":1126842,"Users Score":0,"Answer":"Just a little off the question, but...\nHave you considered running Sun's VirtualBox with Fedora or Ubuntu inside of it?  I'm assuming you have to \/ need to use windows because you still are, but don't like it.  Then you would have python running inside a native linux desktop without any of the troubles you mentioned.\nAnd if you want something that is really easy and portable, then just use Python on Windows, not mixed in with cygwin.\n$0.02","Q_Score":3,"Tags":"python,windows-xp,cygwin","A_Id":1126874,"CreationDate":"2009-07-14T17:28:00.000","Title":"Best way to have full Python install under cygwin\/XP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe.  My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such.  1.  Can I simply copy the contents of an XP installation into the cygwin tree?  2.  Is the XP flavor of Python different from the cygwin flavor?  (Same CPU, he pointed out, naively.)  3.  Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done?  \nDisclaimer 1:  I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place.  Disclaimer 2:  sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2747,"Q_Id":1126842,"Users Score":0,"Answer":"I accidentally stumbled on this - If I launch Cygwin from the Cygwin.bat file (which is present directly under the main folder), I get access to the Python version installed under Cygwin (i.e 2.6.8)\nIf I instead launch the Cygwin from bash.exe under bin directory (C:\\Cygwin\\bin\\bash.exe for me), running \"Python -V\" shows that I have access to 2.7.3 version of Python (that was installed for Windows).\nSo, I guess you can do the same.","Q_Score":3,"Tags":"python,windows-xp,cygwin","A_Id":11792553,"CreationDate":"2009-07-14T17:28:00.000","Title":"Best way to have full Python install under cygwin\/XP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference?\nIf so how would I start trying to identify the cause for this object not being garbage collected?\nEdit: I'm not sure exactly how a code sample would help in this case - there's obviously a strong reference somewhere, but I'll be damned if I can find it. I was of the impression that all strong references to an object would be identified by get_referrers().\nEdit: Solved. I found the variable with a strong reference - It was inside the game event loop but wasn't a class variable so get_referrers wasn't picking it up.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2129,"Q_Id":1127836,"Users Score":1,"Answer":"It might also be the case that a reference was leaked by a buggy C extension, IMHO you will not see the referer, yet still the refcount does not go down to 0. You might want to check the return value of sys.getrefcount.","Q_Score":4,"Tags":"python,garbage-collection,cpython","A_Id":1128216,"CreationDate":"2009-07-14T20:29:00.000","Title":"Python object has no referrers but still accessible via a weakref?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference?\nIf so how would I start trying to identify the cause for this object not being garbage collected?\nEdit: I'm not sure exactly how a code sample would help in this case - there's obviously a strong reference somewhere, but I'll be damned if I can find it. I was of the impression that all strong references to an object would be identified by get_referrers().\nEdit: Solved. I found the variable with a strong reference - It was inside the game event loop but wasn't a class variable so get_referrers wasn't picking it up.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2129,"Q_Id":1127836,"Users Score":1,"Answer":"I am glad you have found your problem, unrelated to the initial question. Nonetheless, I have a different take on the answer for posterity, in case others have the problem.\nIt IS legal for the object to have no referrers and yet not be garbage collected.\nFrom the Python 2.7 manual: \"An implementation is allowed to postpone garbage collection or omit it altogether \u2014 it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that are still reachable.\"\nThe NO-OP garbage collector is legal.\nThe discussions about generational and reference-counting garbage collectors are referring to a particular CPython implementation (as tagged in the question)","Q_Score":4,"Tags":"python,garbage-collection,cpython","A_Id":4093658,"CreationDate":"2009-07-14T20:29:00.000","Title":"Python object has no referrers but still accessible via a weakref?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request.  \nFor example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it.  What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page.  Is it possible to do with only Django and Python with no Javascript\/AJAX knowledge?\nI have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django.\nThanks,","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":823,"Q_Id":1129210,"Users Score":1,"Answer":"Maybe a few iFrames and some Comet\/long-polling? Have the comment submission in an iFrame (so the whole page doesn't reload), and then show the result in the long-polled iFrame...\nHaving said that, it's a pretty bad design idea, and you probably don't want to be doing this. AJAX\/JavaScript is pretty much the way to go for things like this.\n\nI have heard it's possible with AJAX...but I was\n  wondering if it was possible to do\n  with Django.\n\nThere's no reason you can't use both - specifically, AJAX within a Django web application. Django provides your organization and framework needs (and a page that will respond to AJAX requests) and then use some JavaScript on the client side to make AJAX calls to your Django-backed page that will respond correctly.\nI suggest you go find a basic jQuery tutorial which should explain enough basic JavaScript to get this working.","Q_Score":0,"Tags":"python,ajax,django","A_Id":1129395,"CreationDate":"2009-07-15T03:15:00.000","Title":"creating non-reloading dynamic webapps using Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request.  \nFor example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it.  What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page.  Is it possible to do with only Django and Python with no Javascript\/AJAX knowledge?\nI have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django.\nThanks,","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":823,"Q_Id":1129210,"Users Score":8,"Answer":"You want to do that with out any client side code (javascript and ajax are just examples) and with out reloading your page (or at least part of it)?\nIf that is your question, then the answer unfortunately is you can't. You need to either have client side code or reload your page.\nThink about it, once the client get's the page it will not change unless\n\nThe client requests the same page from the server and the server returns and updated one\nthe page has some client side code (eg: javascript) that updates the page.\n\nI can not imagine a third possibility. I have not coded in Django for more than 30 mins and this is clearly obvious to me. If I am wrong plz down vote :D","Q_Score":0,"Tags":"python,ajax,django","A_Id":1129222,"CreationDate":"2009-07-15T03:15:00.000","Title":"creating non-reloading dynamic webapps using Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to embed the Python interpreter and need to customize the way the Python standard library is loaded. Our library will be loaded from the same directory as the executable, not from prefix\/lib\/.\nWe have been successful in making this work by manually modifying sys.path after calling Py_Initialize(), however, this generates a warning because Py_Initialize is looking for site.py in .\/lib\/, and it's not present until after Py_Initialize has been called and we have updated sys.path.\nThe Python c-api docs hint that it's possible to override Py_GetPrefix() and Py_GetPath(), but give no indication of how. Does anyone know how I would go about overriding them?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1585,"Q_Id":1145932,"Users Score":5,"Answer":"You could set Py_NoSiteFlag = 1, call PyInitialize and import site.py yourself as needed.","Q_Score":5,"Tags":"c++,python,api","A_Id":1146654,"CreationDate":"2009-07-17T22:18:00.000","Title":"How to override Py_GetPrefix(), Py_GetPath()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to embed the Python interpreter and need to customize the way the Python standard library is loaded. Our library will be loaded from the same directory as the executable, not from prefix\/lib\/.\nWe have been successful in making this work by manually modifying sys.path after calling Py_Initialize(), however, this generates a warning because Py_Initialize is looking for site.py in .\/lib\/, and it's not present until after Py_Initialize has been called and we have updated sys.path.\nThe Python c-api docs hint that it's possible to override Py_GetPrefix() and Py_GetPath(), but give no indication of how. Does anyone know how I would go about overriding them?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1585,"Q_Id":1145932,"Users Score":4,"Answer":"Have you considered using putenv to adjust PYTHONPATH before calling Py_Initialize?","Q_Score":5,"Tags":"c++,python,api","A_Id":1146134,"CreationDate":"2009-07-17T22:18:00.000","Title":"How to override Py_GetPrefix(), Py_GetPath()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anybody help me out in how to activate 'close' button of askquestion() of tkMessageBox??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1575,"Q_Id":1151770,"Users Score":0,"Answer":"By 'activate', do you mean make it so the user can close the message box by clicking the close ('X') button?\nI do not think it is possible using tkMessageBox. I guess your best bet is to implement a dialog box with this functionality yourself.\nBTW: What should askquestion() return when the user closes the dialog box?","Q_Score":1,"Tags":"python,tkmessagebox","A_Id":1151900,"CreationDate":"2009-07-20T05:00:00.000","Title":"tkMessageBox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple django app to simulate a stock market, users come in and buy\/sell. When they choose to trade, \n\nthe market price is read, and\nbased on the buy\/sell order the market price is increased\/decreased.\n\nI'm not sure how this works in django, but is there a way to make the view atomic? i.e. I'm concerned that user A's actions may read the price but before it's updated because of his order, user B's action reads the price.\nCouldn't find a simple, clean solution for this online. Thanks.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":2233,"Q_Id":1155513,"Users Score":-1,"Answer":"Wrap the DB queries that read and the ones that update in a transaction. The syntax depends on what ORM you are using.","Q_Score":1,"Tags":"python,database,django,locking,atomic","A_Id":1155531,"CreationDate":"2009-07-20T19:38:00.000","Title":"Django, how to make a view atomic?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python's subprocess module to interact with a program via the stdin and stdout pipes.  If I call the subprocesses readline() on stdout, it hangs because it is waiting for a newline.\nHow can I do a read of all the characters in the stdout pipe of a subprocess instance?  If it matters, I'm running in Linux.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":818,"Q_Id":1161580,"Users Score":2,"Answer":"You should loop using read() against a set number of characters.","Q_Score":1,"Tags":"python,linux","A_Id":1161599,"CreationDate":"2009-07-21T20:28:00.000","Title":"how do I read everything currently in a subprocess.stdout pipe and then return?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Java, for example, the @Override annotation not only provides compile-time checking of an override but makes for excellent self-documenting code. \nI'm just looking for documentation (although if it's an indicator to some checker like pylint, that's a bonus). I can add a comment or docstring somewhere, but what is the idiomatic way to indicate an override in Python?","AnswerCount":12,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":117488,"Q_Id":1167617,"Users Score":4,"Answer":"Python ain't Java. There's of course no such thing really as compile-time checking. \nI think a comment in the docstring is plenty.  This allows any user of your method to type help(obj.method) and see that the method is an override.  \nYou can also explicitly extend an interface with class Foo(Interface), which will allow users to type help(Interface.method) to get an idea about the functionality your method is intended to provide.","Q_Score":221,"Tags":"python,inheritance,overriding,self-documenting-code","A_Id":1167664,"CreationDate":"2009-07-22T19:26:00.000","Title":"In Python, how do I indicate I'm overriding a method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project).\nThe question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":2402,"Q_Id":1168565,"Users Score":1,"Answer":"IMHO this should probably one of the things you do earlier in the development process. I have never worked on a large-scale project, but it would make sense that you make a roadmap of what's going to be done and where. (Not trying to rib you for asking about it like you made a mistake :D )\nModules are generally grouped somehow, by purpose or functionality. You could try each implementation of an interface, or other connections.","Q_Score":7,"Tags":"python,module,package","A_Id":1168597,"CreationDate":"2009-07-22T22:05:00.000","Title":"Recommended ways to split some functionality into functions, modules and packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project).\nThe question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":2402,"Q_Id":1168565,"Users Score":1,"Answer":"I sympathize with you. You are suffering from self-doubt. Don't worry. If you can speak any language, including your mother tongue, you are qualified to do modularization on your own. For evidence, you may read \"The Language Instinct,\" or \"The Math Instinct.\"\nLook around, but not too much. You can learn a lot from them, but you can learn many bad things from them too. \n\nSome projects\/framework get a lot fo hype. Yet, some of their groupings of functionality, even names given to modules are misleading. They don't \"reveal intention\" of the programmers. They fail the \"high cohesiveness\" test.\nBooks are no better. Please apply 80\/20 rule in your book selection. Even a good, very complete, well-researched book like Capers Jones' 2010 \"Software Engineering Best Practices\" is clueless. It says 10-man Agile\/XP team would take 12 years to do Windows Vista or 25 years to do an ERP package! It says there is no method till 2009 for segmentation, its term for modularization. I don't think it will help you.\n\nMy point is: You must pick your model\/reference\/source of examples very carefully. Don't over-estimate famous names and under-estimate yourself.\nHere is my help, proven in my experience.\n\nIt is a lot like deciding what attributes go to which DB table, what properties\/methods go to which class\/object etc? On a deeper level, it is a lot like arranging furniture at home, or books in a  shelf. You have done such things already. Software is the same, no big deal!\nWorry about \"cohesion\" first.  e.g. Books (Leo Tolstoy, James Joyce, DE Lawrence) is choesive .(HTML, CSS, John Keats. jQuery, tinymce) is not. And there are many ways to arrange things. Even taxonomists are still in serious feuds over this.\nThen worry about \"coupling.\" Be \"shy\". \"Don't talk to strangers.\" Don't be over-friendly. Try to make your package\/DB table\/class\/object\/module\/bookshelf as self-contained, as independent as possible. Joel has talked about his admiration for the Excel team that abhor all external dependencies and that even built their own compiler.","Q_Score":7,"Tags":"python,module,package","A_Id":2360690,"CreationDate":"2009-07-22T22:05:00.000","Title":"Recommended ways to split some functionality into functions, modules and packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project).\nThe question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":2402,"Q_Id":1168565,"Users Score":4,"Answer":"Take out a pen and piece of paper.  Try to draw how your software interacts on a high level.  Draw the different layers of the software etc.  Group items by functionality and purpose, maybe even by what sort of technology they use.  If your software has multiple abstraction layers, I would say to group them by that.  On a high level, the elements of a specific layer all share the same general purpose.  Now that you have your software in layers, you can divide these layers into different projects based on specific functionality or specialization.  \nAs for a certain stage that you reach in which you should do this?  I'd say when you have multiple people working on the code base or if you want to keep your project as modular as possible.  Hopefully your code is modular enough to do this with.  If you are unable to break apart your software on a high level, then your software is probably spaghetti code and you should look at refactoring it.  \nHopefully that will give you something to work with.","Q_Score":7,"Tags":"python,module,package","A_Id":1168598,"CreationDate":"2009-07-22T22:05:00.000","Title":"Recommended ways to split some functionality into functions, modules and packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project).\nThe question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2402,"Q_Id":1168565,"Users Score":0,"Answer":"Actually it varies for each project you create but here is an example:\n\ncore package contains modules that are your project cant live without. this may contain the main functionality of your application.\nui package contains modules that deals with the user interface. that is if you split the UI from your console.\n\nThis is just an example. and it would really you that would be deciding which and what to go where.","Q_Score":7,"Tags":"python,module,package","A_Id":1168613,"CreationDate":"2009-07-22T22:05:00.000","Title":"Recommended ways to split some functionality into functions, modules and packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to write an application that will allow a user to launch a fairly long-running process (5-30 seconds). It should then allow the user to check the output of the process as it is generated. The output will only be needed for the user's current session so nothing needs to be stored long-term. I have two questions regarding how to accomplish this while taking advantage of the Pylons framework:\n\nWhat is the best way to launch a background process such as this with a Pylons controller?\nWhat is the best way to get the output of the background process back to the user? (Should I store the output in a database, in session data, etc.?)\n\nEdit:\nThe problem is if I launch a command using subprocess in a controller, the controller waits for the subprocess to finish before continuing, showing the user a blank page that is just loading until the process is complete.  I want to be able to redirect the user to a status page immediately after starting the subprocess, allowing it to complete on its own.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1069,"Q_Id":1182587,"Users Score":1,"Answer":"I think this has little to do with pylons. I would do it (in whatever framework) in these steps:\n\ngenerate some ID for the new job, and add a record in the database.\ncreate a new process, e.g. through the subprocess module, and pass the ID on the command line (*).\nhave the process write its output to \/tmp\/project\/ID\nin pylons, implement URLs of the form \/job\/ID or \/job?id=ID. That will look into the database whether the job is completed or not, and merge the temporary output into the page.\n\n(*) It might be better for the subprocess to create another process immediately, and have the pylons process wait for the first child, so that there will be no zombie processes.","Q_Score":3,"Tags":"python,background,pylons","A_Id":1182609,"CreationDate":"2009-07-25T17:36:00.000","Title":"How can I launch a background process in Pylons?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.5\/bin\/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":14435,"Q_Id":1185817,"Users Score":3,"Answer":"The file associations are done with the \"Get Info\".  You select your .PY file, select the File  menu; Get Info menu item.\nMid-way down the Get Info page is \"Open With\".\nYou can pick the Python Launcher.  There's a Change All.. button that changes the association for all .py files.","Q_Score":5,"Tags":"python,macos","A_Id":1185893,"CreationDate":"2009-07-26T23:01:00.000","Title":"How to associate py extension with python launcher on Mac OS X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.5\/bin\/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":14435,"Q_Id":1185817,"Users Score":0,"Answer":"The default python installation (atleast on 10.6.8) includes the Python Launcher.app in \/System\/Library\/Frameworks\/Python.framework\/Resources\/, which is aliased to the latest\/current version of Python installed on the system. This application launches terminal and sets the right environment to run the script.","Q_Score":5,"Tags":"python,macos","A_Id":28869258,"CreationDate":"2009-07-26T23:01:00.000","Title":"How to associate py extension with python launcher on Mac OS X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.5\/bin\/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":14435,"Q_Id":1185817,"Users Score":6,"Answer":"The python.org OS X Python installers include an application called \"Python Launcher.app\" which does exactly what you want.  It gets installed into \/Applications \/Python n.n\/ for n.n > 2.6 or \/Applications\/MacPython n.n\/ for 2.5 and earlier.  In its preference panel, you can specify which Python executable to launch; it can be any command-line path, including the Apple-installed one at \/usr\/bin\/python2.5. You will also need to ensure that .py is associated with \"Python Launcher\"; you can use the Finder's Get Info command to do that as described elsewhere. Be aware, though, that this could be a security risk if downloaded .py scripts are automatically launched by your browser(s). (Note, the Apple-supplied Python in 10.5 does not include \"Python Launcher.app\").","Q_Score":5,"Tags":"python,macos","A_Id":1185899,"CreationDate":"2009-07-26T23:01:00.000","Title":"How to associate py extension with python launcher on Mac OS X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how to I exit from Python without having an traceback dump on the output. \nI still want want to be able to return an error code but I do not want to display the traceback log.\nI want to be able to exit using exit(number) without trace but in case of an Exception (not an exit) I want the trace.","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":641675,"Q_Id":1187970,"Users Score":9,"Answer":"something like import sys; sys.exit(0) ?","Q_Score":300,"Tags":"python,exit,traceback","A_Id":1187976,"CreationDate":"2009-07-27T12:44:00.000","Title":"How to exit from Python without traceback?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to know how to I exit from Python without having an traceback dump on the output. \nI still want want to be able to return an error code but I do not want to display the traceback log.\nI want to be able to exit using exit(number) without trace but in case of an Exception (not an exit) I want the trace.","AnswerCount":10,"Available Count":2,"Score":0.0599281035,"is_accepted":false,"ViewCount":641675,"Q_Id":1187970,"Users Score":3,"Answer":"Use the built-in python function quit() and that's it.\nNo need to import any library.\nI'm using python 3.4","Q_Score":300,"Tags":"python,exit,traceback","A_Id":41650459,"CreationDate":"2009-07-27T12:44:00.000","Title":"How to exit from Python without traceback?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"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?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":345,"Q_Id":1188737,"Users Score":2,"Answer":"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.\nEvery language I have used, has used a dictionary type object to hold these parameters as they are inherently key\/value pairs.","Q_Score":2,"Tags":"python,http","A_Id":1188759,"CreationDate":"2009-07-27T15:11:00.000","Title":"Python POST ordered params","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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.","AnswerCount":9,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":549636,"Q_Id":1196074,"Users Score":0,"Answer":"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.","Q_Score":363,"Tags":"python,process,daemon","A_Id":71059019,"CreationDate":"2009-07-28T18:56:00.000","Title":"How to start a background process in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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. \nRight 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 \u00e1 being encoded into ASCII.\nFurthermore, 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.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8608,"Q_Id":1197981,"Users Score":2,"Answer":"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!).","Q_Score":4,"Tags":"python,ascii","A_Id":1198002,"CreationDate":"2009-07-29T04:00:00.000","Title":"Convert html entities to ascii in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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?\nIdeally, the amount of free RAM should consider only physical memory that can actually be allocated to the Python process.","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":10853,"Q_Id":1204378,"Users Score":3,"Answer":"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).","Q_Score":9,"Tags":"python,wxpython","A_Id":1204394,"CreationDate":"2009-07-30T03:52:00.000","Title":"Getting total\/free RAM from within Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types \ni 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 \nif someone could provide examples in python that would be a big help","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":671,"Q_Id":1205449,"Users Score":3,"Answer":"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])\nThe way you encode your input and the way you decode your output depends on what you want to train the neural network for.  \nMoreover, there are many \"neural networks\" algoritms and learning rules for different tasks( Back propagation, boltzman machines, self organizing maps).","Q_Score":3,"Tags":"python,neural-network","A_Id":1205509,"CreationDate":"2009-07-30T09:22:00.000","Title":"Neural net input\/output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types \ni 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 \nif someone could provide examples in python that would be a big help","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":671,"Q_Id":1205449,"Users Score":0,"Answer":"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.\nSome 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.\nOther 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.","Q_Score":3,"Tags":"python,neural-network","A_Id":20683280,"CreationDate":"2009-07-30T09:22:00.000","Title":"Neural net input\/output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types \ni 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 \nif someone could provide examples in python that would be a big help","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":671,"Q_Id":1205449,"Users Score":2,"Answer":"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\n\nInputs\nChoose as few features as are needed to accurately describe the situation, then decompose each into a set of real valued numbers.\n\nWeather: [temp today, humidity today, temp yesterday, humidity yesterday...] the association between today's temp and today's humidity is made internally\nTeam stats: [ave height, ave weight, max height, top score,...]\nDice: not sure I understand this one, do you mean how to encode discrete values?*\nComplex number: [a,ai,b,bi,...]\n\n* 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.\n\nOutputs\nYou 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.\n\nWeather: [tomorrow's chance of rain, tomorrow's temp,...] **\nTeam stats: [chance of winning, chance of winning by more than 20,...]\nComplex number: [x,xi,...]\n\n** Here your training vectors would be: 1.0 if it rained the next day, 0.0 if it didn't\n\nOf course, whether or not the problem can actually be modeled by a neural net is a different question.","Q_Score":3,"Tags":"python,neural-network","A_Id":1207505,"CreationDate":"2009-07-30T09:22:00.000","Title":"Neural net input\/output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types \ni 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 \nif someone could provide examples in python that would be a big help","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":671,"Q_Id":1205449,"Users Score":0,"Answer":"More complex data usually means adding more neurons in the input and output layers.\nYou 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.","Q_Score":3,"Tags":"python,neural-network","A_Id":1206597,"CreationDate":"2009-07-30T09:22:00.000","Title":"Neural net input\/output","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"guys, how or where is the \"join\" query in Django?\ni think that Django dont have \"join\"..but how ill make  join?\nThanks","AnswerCount":3,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":5258,"Q_Id":1210711,"Users Score":-10,"Answer":"SQL Join queries are a hack because SQL doesn't have objects or navigation among objects.\nObjects don't need \"joins\".  Just access the related objects.","Q_Score":4,"Tags":"python,django","A_Id":1211756,"CreationDate":"2009-07-31T04:38:00.000","Title":"Django ..\"join\" query?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"guys, how or where is the \"join\" query in Django?\ni think that Django dont have \"join\"..but how ill make  join?\nThanks","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5258,"Q_Id":1210711,"Users Score":4,"Answer":"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.","Q_Score":4,"Tags":"python,django","A_Id":1211769,"CreationDate":"2009-07-31T04:38:00.000","Title":"Django ..\"join\" query?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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.\nany ideas?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":170,"Q_Id":1211363,"Users Score":2,"Answer":"Don't do this.\nMost files are cached anyway.\nBut if you really want to add this (because users asked for it), make it optional (default off).","Q_Score":0,"Tags":"python,django,web-applications","A_Id":1211434,"CreationDate":"2009-07-31T08:47:00.000","Title":"downloading files to users machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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.\nany ideas?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":1211363,"Users Score":4,"Answer":"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.\nYou can do one of two things:\n\ncount on the browser to cache the media file\nserve the media via some 3rd party plugin (Flash, for example)","Q_Score":0,"Tags":"python,django,web-applications","A_Id":1211370,"CreationDate":"2009-07-31T08:47:00.000","Title":"downloading files to users machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3485,"Q_Id":1213328,"Users Score":1,"Answer":"To continue where Alex left off..\n\nDownload the uuid-1.30.tar.gz  from Alex's pypi link.\nunzip and untar.\nplace the uuid.py to your application's python path (e.g., same dir with your own .py files)","Q_Score":1,"Tags":"python","A_Id":1400264,"CreationDate":"2009-07-31T15:49:00.000","Title":"how can I get the uuid module for python 2.4.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a game engine written in pygame and I wanted to add OpenGL support.\nI 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.\nIs there something extra I need to do to tell OpenGL that it's running fullscreen or is this a limitation of OpenGL?\n(I am running in Windows XP)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3949,"Q_Id":1217939,"Users Score":0,"Answer":"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.\nUnfortunately 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.","Q_Score":2,"Tags":"python,fullscreen,pygame,pyopengl","A_Id":1218011,"CreationDate":"2009-08-02T01:22:00.000","Title":"PyOpenGL + Pygame capped to 60 FPS in Fullscreen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I try to automatically download a file from some webpage using Python, \nI 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 \nthat I don't know how to control Webpage Dialog with Python. I tried to use \nwinGuiAuto to find the controls of the window, but it fails to recognize any Button type \ncontrols... An ideas?\nSasha\nA clarification of my question:\nMy 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.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2761,"Q_Id":1225686,"Users Score":0,"Answer":"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.","Q_Score":0,"Tags":"python,dialog,webpage","A_Id":1226061,"CreationDate":"2009-08-04T04:03:00.000","Title":"How to control Webpage dialog with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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?\nIt 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.","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":10869,"Q_Id":1229068,"Users Score":1,"Answer":"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:\n1) 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.\n2) Your file-load mechanism is basically straight-out executing Python code.  Not great for security unless you fully control the input.\nIt has 1 advantage: Absurdly easy to do.","Q_Score":14,"Tags":"python,dictionary,persistence,object-persistence","A_Id":1229114,"CreationDate":"2009-08-04T18:10:00.000","Title":"With Python, can I keep a persistent dictionary and modify it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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?\nIt 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.","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":10869,"Q_Id":1229068,"Users Score":6,"Answer":"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.","Q_Score":14,"Tags":"python,dictionary,persistence,object-persistence","A_Id":1229084,"CreationDate":"2009-08-04T18:10:00.000","Title":"With Python, can I keep a persistent dictionary and modify it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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?\nIt 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.","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":10869,"Q_Id":1229068,"Users Score":0,"Answer":"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). \nif 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.","Q_Score":14,"Tags":"python,dictionary,persistence,object-persistence","A_Id":1229320,"CreationDate":"2009-08-04T18:10:00.000","Title":"With Python, can I keep a persistent dictionary and modify it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, graying out the \"X\" on windows systems.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":721,"Q_Id":1235417,"Users Score":4,"Answer":"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.","Q_Score":4,"Tags":"python,windows,gtk,pygtk","A_Id":1235424,"CreationDate":"2009-08-05T19:59:00.000","Title":"In GTK, how do I make a window unable to be closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"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.\nI 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\nCan anyone give me any advice on how to get round this?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":10281,"Q_Id":1236060,"Users Score":2,"Answer":"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.","Q_Score":22,"Tags":"python,debugging,visual-c++","A_Id":2190931,"CreationDate":"2009-08-05T22:16:00.000","Title":"Compiling python modules with DEBUG defined on MSVC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool.\nHowever, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language.\n\nHow important is an IDE to normal Python development? \nAre there good IDEs available for the language? \nIf you do use an IDE for Python, how do you use it effectively?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":1921,"Q_Id":1250295,"Users Score":1,"Answer":"In contrast to the other answers i think that IDE's are very important especially for script languages. Almost all code is bad documentated and an IDE with a good debugger gives you much insides about what is really going on what datatypes are assigned to this values. Is this a hash of lists of hashes or a list of hashs of hashs. \nAnd the easy documentation lookup will save you time.\nBut this is only important for people who need to count there time, this normally excludes beginners or hobbyists.","Q_Score":5,"Tags":"python,ide","A_Id":1273578,"CreationDate":"2009-08-09T01:02:00.000","Title":"What is the importance of an IDE when programming in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool.\nHowever, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language.\n\nHow important is an IDE to normal Python development? \nAre there good IDEs available for the language? \nIf you do use an IDE for Python, how do you use it effectively?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1921,"Q_Id":1250295,"Users Score":0,"Answer":"(1) IDEs are less important than for other languages, but if you find one that is useful, it still makes things easier. Without IDEs -- what are doing? Always running Python from command line?\n(2-3) On my Mac there's included IDLE which I keep always open for its Python shell (it's colored unlike the one in Terminal) and I use free Komodo Edit which I consider to be well-suited for Python as it doesn't go into the language deeply but rather focuses on coloring, tab management, parsing Python output, running frequent commands etc.","Q_Score":5,"Tags":"python,ide","A_Id":1252287,"CreationDate":"2009-08-09T01:02:00.000","Title":"What is the importance of an IDE when programming in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool.\nHowever, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language.\n\nHow important is an IDE to normal Python development? \nAre there good IDEs available for the language? \nIf you do use an IDE for Python, how do you use it effectively?","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":1921,"Q_Id":1250295,"Users Score":4,"Answer":"A matter of habit and personal preferences. Me, I use vim (I have to admit emacs is at least as powerful, but my fingers are deeply trained by over 30 years of vi, and any other editor gives me the jitters, especially when it tries to imitate vi and never really manages to get it 100% right;-), occasionally an interactive environment (python itself, sometimes ipython), and on even rarer occasions a debugger (pdb). A good editor gives me all I need in term of word completion, lookup, &c.\nI've tried Eclipse, its plugins, eric, and Kommodo, but I just don't like them -- Wing, I think I could get used to, and I have to admit its debugger is absolutely out of this world... but, I very rarely use (or need!) advanced debugging functionality, so after every rare occasion I'd forget, and have to learn it all over again a few months later when the need arose again... nah!-)","Q_Score":5,"Tags":"python,ide","A_Id":1250429,"CreationDate":"2009-08-09T01:02:00.000","Title":"What is the importance of an IDE when programming in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool.\nHowever, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language.\n\nHow important is an IDE to normal Python development? \nAre there good IDEs available for the language? \nIf you do use an IDE for Python, how do you use it effectively?","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":1921,"Q_Id":1250295,"Users Score":3,"Answer":"How important is an IDE to normal Python development?\n\nNot very, IMHO. It's a lightweight language with much less boilerplate and simpler idioms than in some other languages, so there's less need for an IDE for that part. \nThe standard interactive interpreter provides help and introspection functionality and a reasonable debugger (pdb). When I want a graphical look at my class hierarchies, I use epydoc to generate it. \nThe only IDE-like functionality I sometimes wish I had is something that would help automate refactoring. \n\nAre there good IDEs available for the language?\n\nSo I hear. Some of my coworkers use Wing.\n\nIf you do use an IDE for Python, how do you use it effectively?\n\nN\/A. I tried using Wing a few times but found that it interfered with my normal development process rather than supporting it.","Q_Score":5,"Tags":"python,ide","A_Id":1250364,"CreationDate":"2009-08-09T01:02:00.000","Title":"What is the importance of an IDE when programming in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am making a simple multiplayer economic game in pygame. It consists of turns of a certain length, at the end of which, data is sent to the central server. A few quick calculations are done on the data and the results are sent back to the players. My question is how I should implement the network support. I was looking at Twisted and at Pyro and any suggestions or advice would be appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3753,"Q_Id":1250739,"Users Score":1,"Answer":"I've nothing against Twisted and PyRo, but the sort of simple messages you're going to be sending don't require anything like that and might be overcomplicated by using some sort of framework. Pickling an object and sending it over a socket is actually a very easy operation and well worth trying, even if you do eventually go with a more heavyweight framework. Don't fear the network!","Q_Score":3,"Tags":"python,twisted,pygame,pyro","A_Id":1255178,"CreationDate":"2009-08-09T05:31:00.000","Title":"Network Support for Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to integrate an old PHP ad management system into a (Django) Python-based web application. The PHP and the Python code are both installed on the same hosts, PHP is executed by mod_php5 and Python through mod_wsgi, usually.\nNow I wonder what's the best way to call this PHP ad management code from within my Python code in a most efficient manner (the ad management code has to be called multiple times for each page)? \nThe solutions I came up with so far, are the following:\n\nWrite SOAP interface in PHP for the ad management code and write a SOAP client in Python which then calls the appropriate functions.\nThe problem I see is, that will slow down the execution of the Python code considerably, since for each page served, multiple SOAP client requests are necessary in the background.\nCall the PHP code through os.execvp() or subprocess.Popen() using PHP command line interface.\nThe problem here is that the PHP code makes use of the Apache environment ($_SERVER vars and other superglobals). I'm not sure if this can be simulated correctly.\nRewrite the ad management code in Python.\nThis will probably be the last resort. This ad management code just runs and runs, and there is no one remaining who wrote a piece of code for this :) I'd be quite afraid to do this ;)\n\nAny other ideas or hints how this can be done?\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3234,"Q_Id":1254802,"Users Score":0,"Answer":"I've done this in the past by serving the PHP portions directly via Apache.  You could either put them in with your media files, (\/site_media\/php\/) or if you prefer to use something more lightweight for your media server (like lighttpd), you can set up another portion of the site that goes through apache with PHP enabled.\nFrom there, you can either take the ajax route in your templates, or you can load the PHP from your views using urllib(2) or httplib(2).  Better yet, wrap the urllib2 call in a templatetag, and call that in your templates.","Q_Score":2,"Tags":"php,python","A_Id":1256684,"CreationDate":"2009-08-10T13:13:00.000","Title":"Call PHP code from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"What would be the best method to restrict access to my XMLRPC server by IP address?  I see the class CGIScript in web\/twcgi.py has a render method that is accessing the request... but I am not sure how to gain access to this request in my server.  I saw an example where someone patched twcgi.py to set environment variables and then in the server access the environment variables... but I figure there has to be a better solution.\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3265,"Q_Id":1273297,"Users Score":0,"Answer":"I'd use a firewall on windows, or iptables on linux.","Q_Score":2,"Tags":"python,twisted","A_Id":1273455,"CreationDate":"2009-08-13T17:03:00.000","Title":"Python Twisted: restricting access by IP address","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing an FTP client in Python ftplib. How do I add proxies support to it (most FTP apps I have seen seem to have it)? I'm especially thinking about SOCKS proxies, but also other types... FTP, HTTP (is it even possible to use HTTP proxies with FTP program?)\nAny ideas how to do it?","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":18202,"Q_Id":1293518,"Users Score":2,"Answer":"Standard module ftplib doesn't support proxies. It seems the only solution is to write your own customized version of the ftplib.","Q_Score":9,"Tags":"python,proxy,ftp,ftplib","A_Id":1293579,"CreationDate":"2009-08-18T12:28:00.000","Title":"Proxies in Python FTP application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Basically, I want an infinite size (more accurately, hard-drive rather than memory bound) dict in a python program I'm writing. It seems like the tempfile and shelve modules are naturally suited for this, however, I can't see how to use them together in a safe manner. I want the tempfile to be deleted when the shelve is GCed (or at guarantee deletion after the shelve is out of use, regardless of when), but the only solution I can come up with for this involves using tempfile.TemporaryFile() to open a file handle, getting the filename from the handle, using this filename for opening a shelve, keeping the reference to the file handle to prevent it from getting GCed (and the file deleted), and then putting a wrapper on the shelve that stores this reference. Anyone have a better solution than this convoluted mess?\nRestrictions: Can only use the standard python library and must be fully cross platform.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":606,"Q_Id":1298037,"Users Score":1,"Answer":"I would rather inherit from shelve.Shelf, and override the close method (*) to unlink the files. Notice that, depending on the specific dbm module being used, you may have more than one file that contains the shelf. One solution could be to create a temporary directory, rather than a temporary file, and remove anything in the directory when done. The other solution would be to bind to a specific dbm module (say, bsddb, or dumbdbm), and remove specifically those files that these libraries create.\n(*) notice that the close method of a shelf is also called when the shelf is garbage collected. The only case how you could end up with garbage files is when the interpreter crashes or gets killed.","Q_Score":1,"Tags":"python,shelve,temporary-files","A_Id":1298162,"CreationDate":"2009-08-19T06:07:00.000","Title":"Is there an easy way to use a python tempfile in a shelve (and make sure it cleans itself up)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've tried to install pip on windows, but it's not working:\ngiving me ImportError: No module named pkg_resources\neasy_install doesn't have version 3.1 or so, just 2.5, and should be replaced by pim.\nis there easy way to install it on windows?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":540,"Q_Id":1304638,"Users Score":0,"Answer":"setuptools doesn't quite work on Python 3.1 yet. Try installing packages with regular distutils, or use binary packages (.exe, .msi) provided by the package author.","Q_Score":1,"Tags":"python","A_Id":1304651,"CreationDate":"2009-08-20T07:59:00.000","Title":"how to install new packages with python 3.1.1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question regarding editing\/saving data in database using Django.\nI have template that show data from database. And after each record i have link that link you to edit page. \nBut now is the question how to edit data in db without using admin panel?\nI run thought tutorial in djangobook but i didn't see how to achieve this without using the shell\nThanks in advice!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":525,"Q_Id":1305182,"Users Score":0,"Answer":"You can use Django authenticaion system to create users and giving them permissions to modify the data.","Q_Score":0,"Tags":"python,django","A_Id":37114696,"CreationDate":"2009-08-20T10:13:00.000","Title":"Django - Edit data in db","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know how to pragmatically pull lists of apps from the iphone app store.  I'd code this in python (via the google app engine) or in an iphone app.  My goal would be to select maybe 5 of them and present them to the user.  (for instance a top 5 kind of thing, or advanced filtering or queries)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":1307322,"Users Score":1,"Answer":"Unfortunately the only API that seems to be around for Apple's app store is a commercial offering from ABTO; nobody seems to have developed a free one. I'm afraid you'll have to resort to \"screen scraping\" -- urlget things, use beautifulsoup or the like for interpreting the HTML you get, and be ready to fix breakages whenever Apple tweaks their formats &c. It seems Apple has no interest in making such a thing available to developers (although as far as I can't tell they're not actively fighting against it either, they appear to just not care).","Q_Score":0,"Tags":"python,iphone,arrays,google-app-engine,app-store","A_Id":1307656,"CreationDate":"2009-08-20T16:21:00.000","Title":"How do I programmatically pull lists\/arrays of (itunes urls to) apps in the iphone app store?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know if it is possible to submit a flash form from python and, if it is, how?\nI have done form submitting from python before, but the forms were HTML not flash. I really have no idea on how to do this. In my research about this I kept getting 'Ming'. However, Ming is only to create .swf files and that's not what I intend to do.\nAny help on this is greatly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":458,"Q_Id":1319895,"Users Score":0,"Answer":"For your flash app, there's no difference if the backend is python, php or anything, so you can follow a normal \"php + flash contact form\" guide and then build the backend using django or any other python web framework, receive the information from the http request (GET or POST, probably the last one) and do whatever you wanted to do with them.\nNotice the response from python to flash works the same as with php, it's just http content, so you can use XML or even better, JSON.","Q_Score":3,"Tags":"python,flash,forms","A_Id":1320103,"CreationDate":"2009-08-23T23:42:00.000","Title":"How to submit data of a flash form? [python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know if it is possible to submit a flash form from python and, if it is, how?\nI have done form submitting from python before, but the forms were HTML not flash. I really have no idea on how to do this. In my research about this I kept getting 'Ming'. However, Ming is only to create .swf files and that's not what I intend to do.\nAny help on this is greatly appreciated.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":458,"Q_Id":1319895,"Users Score":1,"Answer":"You can set the url attribute (I think it's url, please correct me if I'm wrong) on a Flash form control to a Python script - then it will pass it through HTTP POST like any normal HTML form.\nYou've got nothing to be afraid of, it uses the same protocol to communicate, it's just a different submission process.","Q_Score":3,"Tags":"python,flash,forms","A_Id":1319907,"CreationDate":"2009-08-23T23:42:00.000","Title":"How to submit data of a flash form? [python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a python script that will be doing some processing on text files.  As part of that process, i need to import each line of the tab-separated file into a local MS SQL Server (2008) table.  I am using pyodbc and I know how to do this.  However, I have a question about the best way to execute it.\nI will be looping through the file, creating a cursor.execute(myInsertSQL) for each line of the file.  Does anyone see any problems waiting to commit the statements until all records have been looped (i.e. doing the commit() after the loop and not inside the loop after each individual execute)?  The reason I ask is that some files will have upwards of 5000 lines.  I didn't know if trying to \"save them up\" and committing all 5000 at once would cause problems.\nI am fairly new to python, so I don't know all of these issues yet.  \nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3467,"Q_Id":1325481,"Users Score":0,"Answer":"If I understand what you are doing, Python is not going to be a problem.  Executing a statement inside a transaction does not create cumulative state in Python.  It will do so only at the database server itself.\nWhen you commit you will need to make sure the commit occurred, since having a large batch commit may conflict with intervening changes in the database.  If the commit fails, you will have to re-run the batch again.\nThat's the only problem that I am aware of with large batches and Python\/ODBC (and it's not even really a Python problem, since you would have that problem regardless.)\nNow, if you were creating all the SQL in memory, and then looping through the memory-representation, that might make more sense.  Still, 5000 lines of text on a modern machine is really not that big of a deal.  If you start needing to process two orders of magnitude more, you might need to rethink your process.","Q_Score":1,"Tags":"python,database,odbc,commit,bulkinsert","A_Id":1325524,"CreationDate":"2009-08-25T00:30:00.000","Title":"Importing a text file into SQL Server in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Anybody familiar with how I can implement a multiprocessing priority queue in python?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5791,"Q_Id":1354204,"Users Score":0,"Answer":"Depending on your requirements you could use the operating system and the file system in a number of ways.  How large will the queue grow and how fast does it have to be?  If the queue may be big but you are willing to open a couple files for every queue access you could use a BTree implementation to store the queue and file locking to enforce exclusive access.  Slowish but robust.  \nIf the queue will remain relatively small and you need it to be fast you might be able to use shared memory on some operating systems...\nIf the queue will be small (1000s of entries) and you don't need \nit to be really fast you could use something\nas simple as a directory with files containing the data with file locking.  This would be my preference if small and slow is okay.\nIf the queue can be large and you want it to be fast on average, then you probably should use a dedicated server process like Alex suggests.  This is a pain in the neck however.\nWhat are your performance and size requirements?","Q_Score":6,"Tags":"python,multiprocessing,priority-queue","A_Id":1359108,"CreationDate":"2009-08-30T16:17:00.000","Title":"How to implement a multiprocessing priority queue in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Anybody familiar with how I can implement a multiprocessing priority queue in python?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":5791,"Q_Id":1354204,"Users Score":1,"Answer":"I had the same use case. But with a finite number of priorities.\nWhat I am ending up doing is creating one Queue per priority, and my Process workers will try to get the items from those queues, starting with the most important queue to the less important one (moving from one queue to the other is done when the queue is empty)","Q_Score":6,"Tags":"python,multiprocessing,priority-queue","A_Id":1750166,"CreationDate":"2009-08-30T16:17:00.000","Title":"How to implement a multiprocessing priority queue in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a centralized desktop application using Python\/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory).\nUsers of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project.\nThe problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing\/getting sensible information from the system, because \"compiling\" with py2exe is the closest I can get to obfuscation of the code on Windows. \nI'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app.\nOne of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that.\nOf course this question is changing now and is not just \"Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?\", but \"How do you harden an scripting (Python) against wrongful modification?\"","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":272,"Q_Id":1365254,"Users Score":1,"Answer":"Possibly:\n\nThe user enters their credentials into the desktop client.\nThe client says to the server: \"Hi, my name username and my password is password\".\nThe server checks these.\nThe server says to the client: \"Hi, username.  Here is your secret token: ...\"\nSubsequently the client uses the secret token together with the username to \"sign\" communications with the server.","Q_Score":2,"Tags":"python,security,design-patterns,authentication,cracking","A_Id":1365394,"CreationDate":"2009-09-02T00:03:00.000","Title":"How to deal with user authentication and wrongful modification in scripting languages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a centralized desktop application using Python\/wxPython. One of the requirements is User authentication, which I'm trying to implement using LDAP (although this is not mandatory).\nUsers of the system will be mechanical and electrical engineers making budgets, and the biggest problem would be industrial espionage. Its a common problem that leaks occur commonly from the bottom on informal ways, and this could pose problems. The system is set up in such a way that every user has access to all and only the information it needs, so that no one person but the people on top has monetary information on the whole project.\nThe problem is that, for every way I can think to implement the authentication system, Python's openness makes me think of at least one way of bypassing\/getting sensible information from the system, because \"compiling\" with py2exe is the closest I can get to obfuscation of the code on Windows. \nI'm not really trying to hide the code, but rather make the authentication routine secure by itself, make it in such a way that access to the code doesn't mean capability to access the application. One thing I wanted to add, was some sort of code signing to the access routine, so the user can be sure that he is not running a modified client app.\nOne of the ways I've thought to avoid this is making a C module for the authentication, but I would rather not have to do that.\nOf course this question is changing now and is not just \"Could anyone point me in the right direction as to how to build a secure authentication system running on Python? Does something like this already exist?\", but \"How do you harden an scripting (Python) against wrongful modification?\"","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":272,"Q_Id":1365254,"Users Score":3,"Answer":"How malicious are your users?  Really.\nExactly how malicious?\nIf your users are evil sociopaths and can't be trusted with a desktop solution, then don't build a desktop solution.  Build a web site.\nIf your users are ordinary users, they'll screw the environment up by installing viruses, malware and keyloggers from porn sites before they try to (a) learn Python (b) learn how your security works and (c) make a sincere effort at breaking it.\nIf you actually have desktop security issues (i.e., public safety, military, etc.) then rethink using the desktop.\nOtherwise, relax, do the right thing, and don't worry about \"scripting\".\nC++ programs are easier to hack because people are lazy and permit SQL injection.","Q_Score":2,"Tags":"python,security,design-patterns,authentication,cracking","A_Id":1365422,"CreationDate":"2009-09-02T00:03:00.000","Title":"How to deal with user authentication and wrongful modification in scripting languages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21?\nI'm using Python, if that cuts the choices down.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":154753,"Q_Id":1365265,"Users Score":47,"Answer":"Bind the socket to port 0. A random free port from 1024 to 65535 will be selected. You may retrieve the selected port with getsockname() right after bind().","Q_Score":189,"Tags":"python,sockets,ipc,port","A_Id":1365281,"CreationDate":"2009-09-02T00:07:00.000","Title":"On localhost, how do I pick a free port number?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21?\nI'm using Python, if that cuts the choices down.","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":154753,"Q_Id":1365265,"Users Score":4,"Answer":"You can listen on whatever port you want; generally, user applications should listen to ports 1024 and above (through 65535).  The main thing if you have a variable number of listeners is to allocate a range to your app - say 20000-21000, and CATCH EXCEPTIONS.  That is how you will know if a port is unusable (used by another process, in other words) on your computer.  \nHowever, in your case, you shouldn't have a problem using a single hard-coded port for your listener, as long as you print an error message if the bind fails.\nNote also that most of your sockets (for the slaves) do not need to be explicitly bound to specific port numbers - only sockets that wait for incoming connections (like your master here) will need to be made a listener and bound to a port.  If a port is not specified for a socket before it is used, the OS will assign a useable port to the socket.  When the master wants to respond to a slave that sends it data, the address of the sender is accessible when the listener receives data.\nI presume you will be using UDP for this?","Q_Score":189,"Tags":"python,sockets,ipc,port","A_Id":1365283,"CreationDate":"2009-09-02T00:07:00.000","Title":"On localhost, how do I pick a free port number?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on an application written in C#, which I'm embedding IronPython in. I generally have no problems about it, but there's one thing that I don't know how to deal with. \nI want to import an external module into the script. How can I do that? Simple import ext_lib doesn't work. Should I add a path to the lib to sys.path? \nMaybe it is possible to copy the lib's .py file into app directory and import from there?\nEDIT:\nI finally chosen another solution - compiled my script with py2exe and I'm just running it from main C# app with Process (without using IronPython).\nAnyway, thanks for help ;)","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":34961,"Q_Id":1371994,"Users Score":3,"Answer":"If you have installed IronPython from NuGet packages and you want modules from the CPython Standard Library then the best way to do it is by installing the IronPython.StdLib NuGet package which is from the same authors of IronPython.","Q_Score":20,"Tags":"python,import,ironpython","A_Id":67905932,"CreationDate":"2009-09-03T07:50:00.000","Title":"Importing external module in IronPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5.  I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts.  \n=== Edit ==================\nTo specify more clearly, I want the user to input hours and minutes or just minutes.  I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours.  \nThe overall goal is to keep track of the time they have worked.  So, I will be adding the time they enter up to get a total.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2254,"Q_Id":1376835,"Users Score":0,"Answer":"First of all, you'll need some conventions. Is 3.55 five minutes to four hours, five milliseconds to four seconds, or 3 and 55\/100 of a minute\/hour\/second? The same applies to 3:55. At least have a distinction between dot and colon, specifying that a dot means a fraction and a colon, a separator of hour\/minute\/second.\nAlthough you haven't specified what \"time\" is (since or o'clock?), you'll need that too.\nThen, it's simple a matter of having a final representation of a time that you want to work with, and keep converting the input until your final representation is achieved. Let's say you decide that ultimately time should be represented as MM:SS (two digits for minutes, a colon, two digits for seconds), you'll need to search the string for allowed occurrences of characters, and act accordingly. For example, having a colon and a dot at the same time is not allowed. If there's a single colon, you have a fraction, therefore you'll treat the second part as a fraction of 60.\nKeep doing this until you have your final representation, and then just do what you gotta do with said \"time\".\nI don't know on what constraints you're working with, but the problem could be narrowed if instead of a single \"time\" input, you had two: The first, where people type the hours, and the second, where they type the minutes. Of course, that would only work if you can divide the input...","Q_Score":0,"Tags":"python,regex","A_Id":1376880,"CreationDate":"2009-09-04T01:40:00.000","Title":"calculate user inputed time with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5.  I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts.  \n=== Edit ==================\nTo specify more clearly, I want the user to input hours and minutes or just minutes.  I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours.  \nThe overall goal is to keep track of the time they have worked.  So, I will be adding the time they enter up to get a total.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2254,"Q_Id":1376835,"Users Score":0,"Answer":"There are a few possible solutions, but at some point you're gonna run into ambiguous cases that will result in arbitrary conversions.\nOverall I'd suggest taking any input and parsing the separators (whether : or . or something else) and then converting to seconds based on some schema of units you've defined.\nAlternatively you could do a series of try\/except statements to test it against different time formatting schemes to see if it matches.\nI'm not sure what will be best in your case...","Q_Score":0,"Tags":"python,regex","A_Id":1376843,"CreationDate":"2009-09-04T01:40:00.000","Title":"calculate user inputed time with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5.  I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts.  \n=== Edit ==================\nTo specify more clearly, I want the user to input hours and minutes or just minutes.  I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours.  \nThe overall goal is to keep track of the time they have worked.  So, I will be adding the time they enter up to get a total.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2254,"Q_Id":1376835,"Users Score":0,"Answer":"Can you do this with a GUI and restrict the user input?  Processing the text seems super error prone otherwise (on the part of the user, not to mention the programmer), and for hours worked... you sort-of want to get that right.","Q_Score":0,"Tags":"python,regex","A_Id":1377036,"CreationDate":"2009-09-04T01:40:00.000","Title":"calculate user inputed time with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to define a constant that should be available in all of the submodules of a package. I've thought that the best place would be in in the __init__.py file of the root package. But I don't know how to do this. Suppose I have a few subpackages and each with several modules. How can I access that variable from these modules?\nOf course, if this is totally wrong, and there is a better alternative, I'd like to know it.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":111923,"Q_Id":1383239,"Users Score":2,"Answer":"You can define global variables from anywhere, but it is a really bad idea. import the __builtin__ module and modify or add attributes to this modules, and suddenly you have new builtin constants or functions. In fact, when my application installs gettext, I get the _() function in all my modules, without importing anything. So this is possible, but of course only for Application-type projects, not for reusable packages or modules.\nAnd I guess no one would recommend this practice anyway. What's wrong with a namespace? Said application has the version module, so that I have \"global\" variables available like version.VERSION, version.PACKAGE_NAME etc.","Q_Score":165,"Tags":"python,global-variables,module,packages,init","A_Id":1383549,"CreationDate":"2009-09-05T12:33:00.000","Title":"Can I use __init__.py to define global variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm developing on Windows, and I've searched everywhere without finding anyone talking about this kind of thing.\nI made a C++ app on my desktop that embedded Python 3.1 using MSVC. I linked python31.lib and included python31.dll in the app's run folder alongside the executable. It works great. My extension and embedding code definitely works and there are no crashes.\nI sent the run folder to my friend who doesn't have Python installed, and the app crashes for him during the scripting setup phase.\nA few hours ago, I tried the app on my laptop that has Python 2.6 installed. I got the same crash behavior as my friend, and through debugging found that it was the Py_Initialize() call that fails.\nI installed Python 3.1 on my laptop without changing the app code. I ran it and it runs perfectly. I uninstalled Python 3.1 and the app crashes again. I put in code in my app to dynamically link from the local python31.dll, to ensure that it was using it, but I still get the crash.\nI don't know if the interpreter needs more than the DLL to start up or what. I haven't been able to find any resources on this. The Python documentation and other guides do not seem to ever address how to distribute your C\/C++ applications that use Python embedding without having the users install Python locally. I know it's more of an issue on Windows than on Unix, but I've seen a number of Windows C\/C++ applications that embed Python locally and I'm not sure how they do it.\nWhat else do I need other than the DLL? Why does it work when I install Python and then stop working when I uninstall it? It sounds like it should be so trivial; maybe that's why nobody really talks about it. Nevertheless, I can't really explain how to deal with this crash issue.\nThank you very much in advance.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":11259,"Q_Id":1387906,"Users Score":24,"Answer":"In addition to pythonxy.dll, you also need the entire Python library, i.e. the contents of the lib folder, plus the extension modules, i.e. the contents of the DLLs folder. Without the standard library, Python won't even start, since it tries to find os.py (in 3.x; string.py in 2.x). On startup, it imports a number of modules, in particular site.py.\nThere are various locations where it searches for the standard library; in your cases, it eventually finds it in the registry. Before, uses the executable name (as set through Py_SetProgramName) trying to find the landmark; it also checks for a file python31.zip which should be a zipped copy of the standard library. It also checks for a environment variable PYTHONHOME.\nYou are free to strip the library from stuff that you don't need; there are various tools that compute dependencies statically (modulefinder in particular).\nIf you want to minimize the number of files, you can\n\nlink all extension modules statically into your pythonxy.dll, or even link pythonxy.dll statically into your application\nuse the freeze tool; this will allow linking the byte code of the standard library into your pythonxy.dll.\n(alternatively to 2.) use pythonxy.zip for the standard library.","Q_Score":23,"Tags":"python,c++,dll,embed","A_Id":1387977,"CreationDate":"2009-09-07T06:56:00.000","Title":"C++ with Python embedding: crash if Python not installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing on Windows, and I've searched everywhere without finding anyone talking about this kind of thing.\nI made a C++ app on my desktop that embedded Python 3.1 using MSVC. I linked python31.lib and included python31.dll in the app's run folder alongside the executable. It works great. My extension and embedding code definitely works and there are no crashes.\nI sent the run folder to my friend who doesn't have Python installed, and the app crashes for him during the scripting setup phase.\nA few hours ago, I tried the app on my laptop that has Python 2.6 installed. I got the same crash behavior as my friend, and through debugging found that it was the Py_Initialize() call that fails.\nI installed Python 3.1 on my laptop without changing the app code. I ran it and it runs perfectly. I uninstalled Python 3.1 and the app crashes again. I put in code in my app to dynamically link from the local python31.dll, to ensure that it was using it, but I still get the crash.\nI don't know if the interpreter needs more than the DLL to start up or what. I haven't been able to find any resources on this. The Python documentation and other guides do not seem to ever address how to distribute your C\/C++ applications that use Python embedding without having the users install Python locally. I know it's more of an issue on Windows than on Unix, but I've seen a number of Windows C\/C++ applications that embed Python locally and I'm not sure how they do it.\nWhat else do I need other than the DLL? Why does it work when I install Python and then stop working when I uninstall it? It sounds like it should be so trivial; maybe that's why nobody really talks about it. Nevertheless, I can't really explain how to deal with this crash issue.\nThank you very much in advance.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":11259,"Q_Id":1387906,"Users Score":6,"Answer":"A zip of the Python standard library worked for me with Python27.\nI zipped the contents of Lib and dll, and made sure there was no additional python27-subfolder or Lib or dll subfolder. i.e. just a zip named python27.zip containing all the files.\nI copied that zip and the python27.dll alongside the executable.","Q_Score":23,"Tags":"python,c++,dll,embed","A_Id":9115925,"CreationDate":"2009-09-07T06:56:00.000","Title":"C++ with Python embedding: crash if Python not installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Many of my views fetch external resources. I want to make sure that under heavy load I don't blow up the remote sites (and\/or get banned).\nI only have 1 crawler so having a central lock will work fine.\nSo the details: I want to allow at most 3 queries to a host per second, and have the rest block for a maximum of 15 seconds. How could I do this (easily)?\nSome thoughts :\n\nUse django cache\n\n\nSeems to only have 1 second resolution\n\nUse a file based semaphore\n\n\nEasy to do locks for concurrency. Not sure how to make sure only 3 fetches happen a second.\n\nUse some shared memory state\n\n\nI'd rather not install more things, but will if I have to.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1777,"Q_Id":1387937,"Users Score":1,"Answer":"What about using a different process to handle scraping, and a queue for the communication between it and Django?\nThis way you would be able to easily change the number of concurrent requests, and it would also automatically keep track of the requests, without blocking the caller.\nMost of all, I think it would help lowering the complexity of the main application (in Django).","Q_Score":4,"Tags":"python,django,caching,mutex,semaphore","A_Id":1388111,"CreationDate":"2009-09-07T07:08:00.000","Title":"Django: Simple rate limiting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I could get the UUID modules working with the already installed version. What is a better option and how would I go about doing it?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":25211,"Q_Id":1388464,"Users Score":6,"Answer":"The safest way to upgrading Python is to install it to a different location (away from the default system path).\nTo do this, download the source of python and do a \n.\/configure --prefix=\/opt\n(Assuming you want to install it to \/opt which is where most install non system dependant stuff to)\nThe reason why I say this is because some other system libraries may depend on the current version of python.\nAnother reason is that as you are doing your own custom development, it is much better to have control over what version of the libraries (or interpreters) you are using rather than have a operating system patch break something that was working before. A controlled upgrade is better than having the application break on you all of a sudden.","Q_Score":2,"Tags":"python,linux","A_Id":1388552,"CreationDate":"2009-09-07T09:36:00.000","Title":"Upgrade python in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a linux VPS that uses an older version of python (2.4.3). This version doesn't include the UUID module, but I need it for a project. My options are to upgrade to python2.6 or find a way to make uuid work with the older version. I am a complete linux newbie. I don't know how to upgrade python safely or how I could get the UUID modules working with the already installed version. What is a better option and how would I go about doing it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":25211,"Q_Id":1388464,"Users Score":0,"Answer":"The best solution will be installing python2.6 in the choosen directory - It will you give you access to many great features and better memory handling (infamous python=2.4 memory leak problem).\nI have got several pythons installed onto my two computers, I found that the best solution for are two directories:\n$HOME\/usr-32\n$HOME\/usr-64\nrespectively to using operating system (I share $HOME between 32 and 64 bit versions of Linux).\nIn each I have one directory for every application\/program, for example:\n\nls ~\/usr-64\/python-2.6.2\/\nbin  include  lib  share\n\nIt leads completetely to avoiding conflicts between version and gives great portability (you can use usb pendrives etc).\nPython 2.6.2 in previously example has been installed with option:\n\n.\/configure --prefix=$HOME\/usr-64\/python-2.6.2","Q_Score":2,"Tags":"python,linux","A_Id":1391295,"CreationDate":"2009-09-07T09:36:00.000","Title":"Upgrade python in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"p = subprocess.Popen(args = \"myprog.exe\" + \" \" +\n                     str(input1) + \" \" +\n                     str(input2) + \" \" +\n                     str(input3) + \" \" +\n                     strpoints, stdout = subprocess.PIPE)\n\nin the code above, input1, input2, and input3 are all integers that get converted to strings. the variable \"strpoints\" is a list of arbitrary length of strings. input1 tells myprog the length of strpoints. of course, when i try to run the above code, i get the following error message:\n\nTypeError: Can't convert 'list' object to str implicitly\n\nhow do i pass all the elements of strpoints to myprog.exe? am i doomed to having to do str(strpoints) and then have myprog.exe parse this for commas, apostrophes, etc.? e.g.,\n\n`>>> x = ['a', 'b']\n`>>> str(x)\n\"['a', 'b']\"\n\nor should i create a huge string in advance? e.g.,\n\n'>>> x = ['a', 'b']\n'>>> stringify(x)\n' a b'\n\nwhere stringify would be something like\n\ndef stringify(strlist):\n    rlist = \"\"\n    for i in strlist:\n        rlist = rlist + i + \" \"\n    return rlist","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":656,"Q_Id":1408326,"Users Score":1,"Answer":"Avoid concatenating all arguments into one string using that string.\nIt's a lot simpler and better and safer to just pass a sequence (list or tuple) of arguments. This is specially true if any argument contains a space character (which is quite common for filenames).","Q_Score":2,"Tags":"python,executable","A_Id":1408428,"CreationDate":"2009-09-10T23:48:00.000","Title":"send an arbitrary number of inputs from python to a .exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks.\nOK I realized virtualenv is not what I'm looking for.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":10930,"Q_Id":1416005,"Users Score":3,"Answer":"Your use case doesn't actually need virtualenv. You just need to install several different Python versions.","Q_Score":9,"Tags":"python,macos,python-3.x,pygame,virtualenv","A_Id":1416162,"CreationDate":"2009-09-12T20:10:00.000","Title":"Python - Virtualenv , python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks.\nOK I realized virtualenv is not what I'm looking for.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10930,"Q_Id":1416005,"Users Score":0,"Answer":"Not sure if I understood you correctly, but here goes :) \nI don't know about OS X, but in Linux you can install both 2.6 and 3. Then you can either specify to use python25 or python3, or change the \/usr\/bin\/python symlink to the version you want to use by default.","Q_Score":9,"Tags":"python,macos,python-3.x,pygame,virtualenv","A_Id":1416051,"CreationDate":"2009-09-12T20:10:00.000","Title":"Python - Virtualenv , python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.072599319,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":4,"Answer":"I actually just discovered the easiest answer, if you use the shortcut link labeled \"IDLE (Python GUI)\". This is in Windows Vista, so I don't know if it'll work in other OS's.\n1) Right-click \"Properties\".\n2) Select \"Shortcut\" tab.\n3) In \"Start In\", write file path (e.g. \"C:\\Users...\").\nLet me know if this works!","Q_Score":9,"Tags":"python,python-idle","A_Id":20500218,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":1,"Answer":"For OS X:\nOpen a new finder window,then head over to applications.\nLocate your Python application. (For my mac,it's Python 3.5)\nDouble click on it.\nRight click on the IDLE icon,show package contents.\nThen go into the contents folder,then resources.\nNow,this is the important part:\n(Note: You must be the administrator or have the administrator's password for the below to work)\nRight click on the idlemain.py,Get Info.\nScroll all the way down. Make sure under the Sharing & Permissions tab,your \"name\"(Me) is on it with the privilege as Read & Write.\nIf not click on the lock symbol and unlock it.\nThen add\/edit yourself to have the Read & Write privilege.\nLastly,as per Ned Deily's instructions,edit the line:\nos.chdir(os.path.expanduser('~\/Documents'))\nwith your desired path and then save the changes.\nUpon restarting the Python IDLE,you should find that your default Save as path to be the path you've indicated.","Q_Score":9,"Tags":"python,python-idle","A_Id":35376000,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.0363476168,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":2,"Answer":"In Windows 10+, click the Windows Start button, then type idle, and then right-click on the IDLE desktop app and open the file location. This should bring you to the Start Menu shortcuts for Python, and you'll find a shortcut to IDLE there. Right-click on the IDLE shortcut and select properties. Set the \"Start in\" directory to be where you want default save path to be.","Q_Score":9,"Tags":"python,python-idle","A_Id":53340799,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":1,"Answer":"I am using windows 7 and by going to Start-> IDLE(Python 3.6 32-bit)\nThe click on properties and then in the shortcut tab go to \nStart in and entering the desired path worked for me kindly note if IDLE is open and running while you do this you'll have to shut it down and restart it for this to work","Q_Score":9,"Tags":"python,python-idle","A_Id":43900532,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.0363476168,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":2,"Answer":"It seems like you can get idle into the directory you want if you run any module from that directory. \nI had previously tried opening idlemain.py through the path browser. I was able to open and edit the file, but it seemed like I wasn't able to save my modifications.\nI'm just glad to hear other people are having this problem. I just thought I was being stupid.","Q_Score":9,"Tags":"python,python-idle","A_Id":5161261,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":1,"Answer":"On Windows (Vista at least, which is what I'm looking at here), shortcut icons on the desktop have a \"Start in\" field where you can set the directory used as the current working directory when the program starts.  Changing that works for me.  Anything like that on the Mac?  (Starting in the desired directory from the command line works, too.)","Q_Score":9,"Tags":"python,python-idle","A_Id":1424722,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":0,"Answer":"If you locate the idlelib directory in your Python install, it will have a few files with the .def extension. config-main.def has instructions on where to put the custom config files. However, looking through these I did not find any configurable paths (your install may vary). Looks like you might need to crack open the editor code to alter it.","Q_Score":9,"Tags":"python,python-idle","A_Id":1424502,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where or how to set the default path\/directory on saving python scripts prior to running?  \nOn a Mac it wants to save them in the top level ~\/Documents directory. I would like to specify a real location. Any ideas?","AnswerCount":11,"Available Count":8,"Score":0.0181798149,"is_accepted":false,"ViewCount":28611,"Q_Id":1424398,"Users Score":1,"Answer":"If you open a module, that sets the default working directory.\nStart IDLE.\nFile -> Open to open your file.  And set the current working directory.","Q_Score":9,"Tags":"python,python-idle","A_Id":1424507,"CreationDate":"2009-09-14T23:28:00.000","Title":"Default save path for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the integer objects up front and try to fill a list of lists with some python equivalent of pointers. I'm not sure how to do it, though. What is the best way to implement this, and should I be using lists or another data structure?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":247,"Q_Id":1425162,"Users Score":1,"Answer":"You only need to store the lower triangle of the matrix. Typically this is done with one n(n+1)\/2 length list. You'll need to overload the __getitem__ method to interpret what the entry means.","Q_Score":1,"Tags":"python,data-structures,matrix","A_Id":1425181,"CreationDate":"2009-09-15T04:48:00.000","Title":"Symmetrically adressable matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the integer objects up front and try to fill a list of lists with some python equivalent of pointers. I'm not sure how to do it, though. What is the best way to implement this, and should I be using lists or another data structure?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":247,"Q_Id":1425162,"Users Score":2,"Answer":"You're probably better off using a full square numpy matrix. Yes, it wastes half the memory storing redundant values, but rolling your own symmetric matrix in Python will waste even more memory and CPU by storing and processing the integers as Python objects.","Q_Score":1,"Tags":"python,data-structures,matrix","A_Id":1425305,"CreationDate":"2009-09-15T04:48:00.000","Title":"Symmetrically adressable matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'd like to know if it's possible to find out the \"command\" that a PID is set to. When I say command, I mean what you see in the last column when you run the command \"top\" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.\nAny help would be great. Thanks.","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":9565,"Q_Id":1440941,"Users Score":0,"Answer":"The proc filesystem exports this (and other) information.\nLook at the \/proc\/PID\/cmd symlink.","Q_Score":8,"Tags":"python,linux,process","A_Id":1440965,"CreationDate":"2009-09-17T19:44:00.000","Title":"Finding the command for a specific PID in Linux from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know if it's possible to find out the \"command\" that a PID is set to. When I say command, I mean what you see in the last column when you run the command \"top\" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.\nAny help would be great. Thanks.","AnswerCount":7,"Available Count":3,"Score":0.1418931938,"is_accepted":false,"ViewCount":9565,"Q_Id":1440941,"Users Score":5,"Answer":"Look in \/proc\/$PID\/cmdline, and then os.readlink() on \/proc\/$PID\/exe.\n\/proc\/$PID\/cmdline is not necessarily going to be correct, as a program can change its argument vector or it may not contain a full path. Three examples of this from my current process list are:\n\navahi-daemon: chroot helper\nqmgr -l -t fifo -u\n\/usr\/sbin\/postgrey --pidfile=\/var\/run\/postgrey.pid --daemonize --inet=127.0.0.1:60000 --delay=55\n\nThat first one is obvious - it's not a valid path or program name. The second is just an executable with no path name. The third looks ok, but that whole command line is actually in argv[0], with spaces separating the arguments. Normally you should have NUL separated arguments.\nAll this goes to show that \/proc\/$PID\/cmdline (or the ps(1) output) is not reliable.\nHowever, nor is \/proc\/$PID\/exe. Usually it is a symlink to the executable that is the main text segment of the process. But sometimes it has \" (deleted)\" after it if the executable is no longer in the filesystem.\nAlso, the program that is the text segment is not always what you want. For instance, \/proc\/$PID\/exe from that \/usr\/sbin\/postgrey example above is \/usr\/bin\/perl. This will be the case for all interpretted scripts (#!).\nI settled on parsing \/proc\/$PID\/cmdline - taking the first element of the vector, and then looking for spaces in that, and taking all before the first space. If that was an executable file - I stopped there. Otherwise I did a readlink(2) on \/proc\/$PID\/exe and removed any \" (deleted)\" strings on the end. That first part will fail if the executable filename actually has spaces in it. There's not much you can do about that.\nBTW. The argument to use ps(1) instead of \/proc\/$PID\/cmdline does not apply in this case, since you are going to fall back to \/proc\/$PID\/exe. You will be dependent on the \/proc filesystem, so you may as well read it with read(2) instead of pipe(2), fork(2), execve(2), readdir(3)..., write(2), read(2). While ps and \/proc\/$PID\/cmdline may be the same from the point of view of lines of python code, there's a whole lot more going on behind the scenes with ps.","Q_Score":8,"Tags":"python,linux,process","A_Id":1443544,"CreationDate":"2009-09-17T19:44:00.000","Title":"Finding the command for a specific PID in Linux from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know if it's possible to find out the \"command\" that a PID is set to. When I say command, I mean what you see in the last column when you run the command \"top\" in a linux shell. I'd like to get this information from Python somehow when I have a specific PID.\nAny help would be great. Thanks.","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":9565,"Q_Id":1440941,"Users Score":6,"Answer":"Look in \/proc\/$PID\/cmdline","Q_Score":8,"Tags":"python,linux,process","A_Id":1440969,"CreationDate":"2009-09-17T19:44:00.000","Title":"Finding the command for a specific PID in Linux from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django and Apache to serve webpages.  My JavaScript code currently includes a data object with values to be displayed in various HTML widgets based on the user's selection from a menu of choices.  I want to derive these data from a Python dictionary.  I think I know how to embed the JavaScript code in the HTML, but how do I embed the data object in that script (on the fly) so the script's functions can use it?\nPut another way, I want to create a JavaScript object or array from a Python dictionary, then insert that object into the JavaScript code, and then insert that JavaScript code into the HTML.\nI suppose this structure (e.g., data embedded in variables in the JavaScript code) is suboptimal, but as a newbie I don't know the alternatives.  I've seen write-ups of Django serialization functions, but these don't help me until I can get the data into my JavaScript code in the first place.\nI'm not (yet) using a JavaScript library like jQuery.","AnswerCount":8,"Available Count":3,"Score":0.0748596907,"is_accepted":false,"ViewCount":89362,"Q_Id":1445989,"Users Score":3,"Answer":"You can include <script> tags inside your .html templates, and then build your data structures however is convenient for you.  The template language isn't only for HTML, it can also do Javascript object literals.\nAnd Paul is right: it might be best to use a json module to create a JSON string, then insert that string into the template.  That will handle the quoting issues best, and deal with deep structures with ease.","Q_Score":59,"Tags":"javascript,python,django","A_Id":1446136,"CreationDate":"2009-09-18T17:52:00.000","Title":"Passing Python Data to JavaScript via Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django and Apache to serve webpages.  My JavaScript code currently includes a data object with values to be displayed in various HTML widgets based on the user's selection from a menu of choices.  I want to derive these data from a Python dictionary.  I think I know how to embed the JavaScript code in the HTML, but how do I embed the data object in that script (on the fly) so the script's functions can use it?\nPut another way, I want to create a JavaScript object or array from a Python dictionary, then insert that object into the JavaScript code, and then insert that JavaScript code into the HTML.\nI suppose this structure (e.g., data embedded in variables in the JavaScript code) is suboptimal, but as a newbie I don't know the alternatives.  I've seen write-ups of Django serialization functions, but these don't help me until I can get the data into my JavaScript code in the first place.\nI'm not (yet) using a JavaScript library like jQuery.","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":89362,"Q_Id":1445989,"Users Score":2,"Answer":"It is suboptimal. Have you considered passing your data as JSON using django's built in serializer for that?","Q_Score":59,"Tags":"javascript,python,django","A_Id":1446060,"CreationDate":"2009-09-18T17:52:00.000","Title":"Passing Python Data to JavaScript via Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django and Apache to serve webpages.  My JavaScript code currently includes a data object with values to be displayed in various HTML widgets based on the user's selection from a menu of choices.  I want to derive these data from a Python dictionary.  I think I know how to embed the JavaScript code in the HTML, but how do I embed the data object in that script (on the fly) so the script's functions can use it?\nPut another way, I want to create a JavaScript object or array from a Python dictionary, then insert that object into the JavaScript code, and then insert that JavaScript code into the HTML.\nI suppose this structure (e.g., data embedded in variables in the JavaScript code) is suboptimal, but as a newbie I don't know the alternatives.  I've seen write-ups of Django serialization functions, but these don't help me until I can get the data into my JavaScript code in the first place.\nI'm not (yet) using a JavaScript library like jQuery.","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":89362,"Q_Id":1445989,"Users Score":1,"Answer":"Putting Java Script embedded into Django template is rather always bad idea. \nRather, because there are some exceptions from this rule.\nEverything depends on the your Java Script code site and functionality.\nIt is better to have seperately static files, like JS, but the problem is that every seperate file needs another connect\/GET\/request\/response mechanism. Sometimes for small one, two liners code os JS to put this into template, bun then use django templatetags mechanism - you can use is in other templates ;)\nAbout objects - the same. If your site has AJAX construction\/web2.0 like favour - you can achieve very good effect putting some count\/math operation onto client side. If objects are small - embedded into template, if large - response them in another connection to avoid hangind page for user.","Q_Score":59,"Tags":"javascript,python,django","A_Id":1448178,"CreationDate":"2009-09-18T17:52:00.000","Title":"Passing Python Data to JavaScript via Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to stream a binary data using python. I do not  have any idea how to achieve it. I did created python socket program using SOCK_DGRAM. Problem with SOCK_STREAM is that it does not work over internet as our isp dont allow tcp server socket. \nI want to transmit screen shots periodically to remote computer.\nI have an idea of maintaining a Que of binary data and have two threads write and read synchronously. \nI do not want to use VNC .\nHow do I do it?\nI did written server socket and client socket using SOCK_STREAM  it was working on localhost and did not work over internet even if respective ip's are placed. We also did tried running tomcat web server on one pc and tried accessing via other pc on internet and was not working.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1737,"Q_Id":1451349,"Users Score":2,"Answer":"There are two problems here.\nFirst problem, you will need to be able to address the remote party.  This is related to what you referred to as \"does not work over Internet as most ISP don't allow TCP server socket\".  It is usually difficult because the other party could be placed behind a NAT or a firewall.\nAs for the second problem, the problem of actual transmitting of data after you can make a TCP connection, python socket would work if you can address the remote party.","Q_Score":1,"Tags":"python,sockets","A_Id":1451356,"CreationDate":"2009-09-20T16:01:00.000","Title":"How to stream binary data in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to stream a binary data using python. I do not  have any idea how to achieve it. I did created python socket program using SOCK_DGRAM. Problem with SOCK_STREAM is that it does not work over internet as our isp dont allow tcp server socket. \nI want to transmit screen shots periodically to remote computer.\nI have an idea of maintaining a Que of binary data and have two threads write and read synchronously. \nI do not want to use VNC .\nHow do I do it?\nI did written server socket and client socket using SOCK_STREAM  it was working on localhost and did not work over internet even if respective ip's are placed. We also did tried running tomcat web server on one pc and tried accessing via other pc on internet and was not working.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1737,"Q_Id":1451349,"Users Score":3,"Answer":"SOCK_STREAM is the correct way to stream data.\nWhat you're saying about ISPs makes very little sense; they don't control whether or not your machine listens on a certain port on an interface. Perhaps you're talking about firewall\/addressing issues?\nIf you insist on using UDP (and you shouldn't because you'll have to worry about packets arriving out of place or not arriving at all) then you'll need to first use socket.bind and then socket.recvfrom in a loop to read data and keep track of open connections. It'll be hard work to do correctly.","Q_Score":1,"Tags":"python,sockets","A_Id":1451365,"CreationDate":"2009-09-20T16:01:00.000","Title":"How to stream binary data in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:\n\nerror: command 'gcc' failed with exit status 1\n\nAs far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).\nDoes anybody know how to build sqlite for Python 2.4?\nAs another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.\nThank you in advance.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2825,"Q_Id":1455642,"Users Score":0,"Answer":"If you don't have root privileges, I would recommend installing a more recent version of Python in your home directory and then adding your local version to your PATH. It seems easier to go that direction than to try to make sqlite work with an old version of Python.\nYou will also be doing yourself a favor by using a recent version of Python, because you'll have access to the numerous recent improvements in the language.","Q_Score":0,"Tags":"python,sqlite,pysqlite","A_Id":1455663,"CreationDate":"2009-09-21T17:09:00.000","Title":"How to build sqlite for Python 2.4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:\n\nerror: command 'gcc' failed with exit status 1\n\nAs far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).\nDoes anybody know how to build sqlite for Python 2.4?\nAs another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.\nThank you in advance.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2825,"Q_Id":1455642,"Users Score":0,"Answer":"I had the same trouble with gcc failing with Ubuntu Karmic. I fixed this by installing the python-dev package. In my case, I'm working with python2.4, so I installed the python2.4-dev package. The python-dev package should work for python2.6.","Q_Score":0,"Tags":"python,sqlite,pysqlite","A_Id":2805287,"CreationDate":"2009-09-21T17:09:00.000","Title":"How to build sqlite for Python 2.4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Microsoft Word has \"send as attachment\" functionality which creates a new message in Outlook with the document attached. \nI would like to replace Outlook with a custom mail agent, but I do not know how to achieve this. Now my mail agent is simply a program that runs, and takes a file name as parameter. \nAs far as I know, \"send as attachment\" is using some DLL\/API called MAPI. I would need to change my app so that it does not simply accept file name arguments, but can receive MAPI(?) calls MS Word uses when \"sending as attachment\".\nFurther, I need to change the default mail agent by creating my own MAPI32.dll stub which simply redirects to my app.\nI'd appreciate if anyone had more info on how this could be achieved!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3109,"Q_Id":1458690,"Users Score":0,"Answer":"OK, to answer my own question. I need to build a DLL with \"MAPISendDocuments\" and\/or \"MAPISendMail\" functions defined.\nThis DLL can have any name, and is referenced in the registry at HKLM\/Software\/Clients\/Mail\/MyMailApp\/DLLPath.\nFound examples using Delphi...","Q_Score":1,"Tags":"c#,python,outlook,ms-word,mapi","A_Id":1483115,"CreationDate":"2009-09-22T07:53:00.000","Title":"How to create a MAPI32.dll stub to be able to \"send as attachment\" from MS Word?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them.\nHowever, I have no ideas what these headers are (where I can find them, what they are doing and how to install them).\nCan anybody, pleas, help me with that?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":17278,"Q_Id":1462565,"Users Score":0,"Answer":"pysqlite needs to compiled\/build before you can use it.  This requires C language header files (*.H) which come with the source code of sqllite itself.\ni.e. sqllite and pysqlite are two different things.  Did you install sqlite prior to trying and build pysqllte ?  (or maybe you did, but did you do so just with the binaries;  you need the source package (or at least its headers) for pysqlite purposes.","Q_Score":12,"Tags":"python,header,pysqlite","A_Id":1462623,"CreationDate":"2009-09-22T20:57:00.000","Title":"What are sqlite development headers and how to install them?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them.\nHowever, I have no ideas what these headers are (where I can find them, what they are doing and how to install them).\nCan anybody, pleas, help me with that?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":17278,"Q_Id":1462565,"Users Score":7,"Answer":"For me this worked (Redhat\/CentOS):\n$ sudo yum install sqlite-devel","Q_Score":12,"Tags":"python,header,pysqlite","A_Id":5671345,"CreationDate":"2009-09-22T20:57:00.000","Title":"What are sqlite development headers and how to install them?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a shell that runs CentOS.\nFor a project I'm doing, I need python 2.5+, but centOS is pretty dependent on 2.4.\nFrom what I've read, a number of things will break if you upgrade to 2.5.\nI want to install 2.5 separately from 2.4, but I'm not sure how to do it. So far I've downloaded the source tarball, untarred it, and did a .\/configure --prefix=\/opt which is where I want it to end up. Can I now just make, make install ? Or is there more?","AnswerCount":15,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":189056,"Q_Id":1465036,"Users Score":25,"Answer":"No, that's it. You might want to make sure you have all optional library headers installed too so you don't have to recompile it later. They are listed in the documentation I think.\nAlso, you can install it even in the standard path if you do make altinstall. That way it won't override your current default \"python\".","Q_Score":87,"Tags":"python,centos,rpath","A_Id":1465105,"CreationDate":"2009-09-23T09:53:00.000","Title":"Install python 2.6 in CentOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the best way to undo the writing to a file? If I'm going through a loop and writing one line at a time, and I want to undo the previous write and replace it with something else, how do I go about doing that? Any ideas?\nThanks in advance!","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":3715,"Q_Id":1479035,"Users Score":4,"Answer":"Try to write to your files lazily: Don't write until you are finally certain you need to do it.","Q_Score":3,"Tags":"python,file,undo","A_Id":1479049,"CreationDate":"2009-09-25T19:02:00.000","Title":"Python: undo write to file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to create XML using the ElementTree object structure in python.  It all works very well except when it comes to processing instructions.  I can create a PI easily using the factory function ProcessingInstruction(), but it doesn't get added into the elementtree.  I can add it manually, but I can't figure out how to add it above the root element where PI's are normally placed.  Anyone know how to do this?  I know of plenty of alternative methods of doing it, but it seems that this must be built in somewhere that I just can't find.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":4332,"Q_Id":1489949,"Users Score":2,"Answer":"Yeah, I don't believe it's possible, sorry. ElementTree provides a simpler interface to (non-namespaced) element-centric XML processing than DOM, but the price for that is that it doesn't support the whole XML infoset.\nThere is no apparent way to represent the content that lives outside the root element (comments, PIs, the doctype and the XML declaration), and these are also discarded at parse time. (Aside: this appears to include any default attributes specified in the DTD internal subset, which makes ElementTree strictly-speaking a non-compliant XML processor.)\nYou can probably work around it by subclassing or monkey-patching the Python native ElementTree implementation's write() method to call _write on your extra PIs before _writeing the _root, but it could be a bit fragile.\nIf you need support for the full XML infoset, probably best stick with DOM.","Q_Score":6,"Tags":"python,xml,elementtree","A_Id":1490057,"CreationDate":"2009-09-29T00:09:00.000","Title":"ElementTree in Python 2.6.2 Processing Instructions support?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a toy project in Django.\nPart of my app allows users to leave reviews.   I'd like to take the title of the review and slugify it to create a url.\nSo, if a user writes a review called \"The best thing ever!\", the url would be something like: www.example.com\/reviews\/the-best-thing-ever.  \nThat's all well and good, but what is the best way to handle case where two users pick the same title?   I don't want to make the title required to be unique.\nI've thought about adding the review id in the url somewhere, but I'd like to avoid that extra info for any urls that don't collide.\nAny ideas?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3203,"Q_Id":1490559,"Users Score":6,"Answer":"One thing I never liked about the unique slug fields\/methods is that if you have a lot of clashes for a single title, you'll end up running several queries to try and determine an available slug. I know you mentioned you don't want to show the id for non-clashing slugs, but, as far as performance, I think it's the better route to take. To make the URL a little nicer looking, I prefer also to embed the id before the slug, so that a URL takes the form of www.example.com\/reviews\/1\/the-best-thing-ever.","Q_Score":7,"Tags":"python,django,url,slug,collision","A_Id":1492882,"CreationDate":"2009-09-29T04:23:00.000","Title":"Django slugified urls - how to handle collisions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm currently working on a toy project in Django.\nPart of my app allows users to leave reviews.   I'd like to take the title of the review and slugify it to create a url.\nSo, if a user writes a review called \"The best thing ever!\", the url would be something like: www.example.com\/reviews\/the-best-thing-ever.  \nThat's all well and good, but what is the best way to handle case where two users pick the same title?   I don't want to make the title required to be unique.\nI've thought about adding the review id in the url somewhere, but I'd like to avoid that extra info for any urls that don't collide.\nAny ideas?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3203,"Q_Id":1490559,"Users Score":0,"Answer":"I would (in the form validation) just check to see if the slug is used, and then add something to it, either a number \"my-cool-idea_2\" or the actual id","Q_Score":7,"Tags":"python,django,url,slug,collision","A_Id":2340063,"CreationDate":"2009-09-29T04:23:00.000","Title":"Django slugified urls - how to handle collisions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]).\nProblem is the platforms store timestamps as 32-bit signed integers, so I can't get a timestamp for dates older than 1901 to easily subtract the present timestamp from etc..  So how do I do what I want to do?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":913,"Q_Id":1494231,"Users Score":1,"Answer":"Under WIN32, you can use SystemTimeToFileTime.\nFILETIME is a 64-bit unsigned integer that counts the number of 100-nanosecond intervals since January 1, 1601 (UTC).\nYou can convert two timestamps to FILETIME. You can convert it to ULARGE_INTEGER (t.dwLowDateTime + t.dwHighDateTime << 32), and do regular arithmetics to measure the interval.","Q_Score":3,"Tags":"javascript,c++,python,timestamp","A_Id":1494464,"CreationDate":"2009-09-29T18:41:00.000","Title":"How to get a timestamp older than 1901","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]).\nProblem is the platforms store timestamps as 32-bit signed integers, so I can't get a timestamp for dates older than 1901 to easily subtract the present timestamp from etc..  So how do I do what I want to do?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":913,"Q_Id":1494231,"Users Score":3,"Answer":"The portable, language-agnostic approach:\nStep 1. Count the number of seconds between 01\/01\/1850 00:00 and 01\/01\/1901 00:00. Save this number somewhere (call it M)\nStep 2. Use available language functionality to count the number of seconds between 01\/01\/1901 00:00 and whatever other date and time you want.\nStep 3. Return the result from Step 2 + M. Remember to cast the result as a long integer if necessary.","Q_Score":3,"Tags":"javascript,c++,python,timestamp","A_Id":1494286,"CreationDate":"2009-09-29T18:41:00.000","Title":"How to get a timestamp older than 1901","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've recently started learning\/using django; I'm trying to figure out a way to have two separate authentications systems for administrators and users. Rather than create a whole new auth system, I'd like to leverage django's built-in functionality (i.e. session management, @login_required decorator, etc.). \nSpecifically, I want to have two separate login tables - one for admins, one for users. The admin login table should be the default table that django generates with its default fields (ie. id, username, email, is_staff, etc.). The user table, on the other hand, I want to have only 5 fields - id, email, password, first_name, last_name. Furthermore, I want to use django built-in session management for both login tables and the @login_required decorator for their respective views. Lastly, I want two separate and distinct login forms for admins and users.   \nAnyone have any suggestions on how I can achieve my goal or know of any articles\/examples that could help me along?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3543,"Q_Id":1494524,"Users Score":0,"Answer":"Modify things slightly so that users have a category prefix on their username? You haven't given us much info on what you want to do, it's possible that your needs might be met by using the sites framework, or simply two separate django installs.\nIf what you're trying to do is make the user login page and the admin login page separate, just use the built in framework as detailed in the docs to create a \"user\" login page and leave the admin one alone. If you're worried that users will somehow start editing admin login stuff, don't be, they won't unless you let them.","Q_Score":8,"Tags":"python,django,authentication","A_Id":1494572,"CreationDate":"2009-09-29T19:41:00.000","Title":"Separate Admin\/User authentication system in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just upgraded the default Python 2.5 on Leopard to 2.6 via the installer on www.python.org. Upon doing so, the MySQLdb I had installed was no longer found. So I tried reinstalling it via port install py-mysql, and it succeeded, but MySQLdb was still not importable. So then I tried to python install python26 with python_select python26 and it succeeded, but it doesn't appear that it is getting precedence over the python.org install:\n$ which python\n\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/bin\/python\nWhen I would expect it to be something like \/opt\/local\/bin\/python\nMy path environment is: \/Library\/Frameworks\/Python.framework\/Versions\/2.6\/bin:\/usr\/local\/mysql\/bin\/:\/opt\/local\/bin:\/opt\/local\/sbin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin:\/usr\/local\/bin:\/usr\/X11\/bin:\/usr\/local\/mysql\/bin:\/Users\/bsr\/bin\nAnyway, when I try port install py-mysql but how does it know where to install the Python MySQL library?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1051,"Q_Id":1499572,"Users Score":1,"Answer":"You also need python_select (or is it select_python?) to change the default python used.","Q_Score":0,"Tags":"python,mysql,macos","A_Id":2302542,"CreationDate":"2009-09-30T17:32:00.000","Title":"With multiple Python installs, how does MacPorts know which one to install MySQLdb for?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using cProfile, pstats and Gprof2dot to profile a rather long python script.\nThe results tell me that the most time is spent calling a method in an object I've defined. However, what I would really like is to know exactly what line number within that function is eating up the time. \nAny idea's how to get this additional information?\n(By the way, I'm using Python 2.6 on OSX snow leopard if that helps...)","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2434,"Q_Id":1500564,"Users Score":2,"Answer":"cProfile does not track line numbers within a function; it only tracks the line number of where the function was defined.  \ncProfile attempts to duplicate the behavior of profile (which is pure Python).  profile uses pstats to store the data from running, and pstats only stores line numbers for function definitions, not for individual Python statements.\nIf you need to figure out with finer granularity what is eating all your time, then you need to refactor your big function into several, smaller functions.","Q_Score":5,"Tags":"python,scripting,numbers,profiler,line","A_Id":1500818,"CreationDate":"2009-09-30T20:46:00.000","Title":"cProfile and Python: Finding the specific line number that code spends most time on","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.\nThere is an example of running at ask every hour, but this doesn't fit because the \"start\" of that hour depends on when you deploy the application. That is, if I deploy at 4:37 PM, the cron scripts will get executed at 5:37, 6:37, ... instead of 5:00, 6:00, ...\nSo far the only way that looks like it would work is to have 24 different cron entries, one for the specific hour of each day set to run each day at that specific time. \nDoes anyone know of anything that would let me use a schedule like \"every hour at :00\" or even \"every day 00:00, 01:00, ... 23:00\"?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":3297,"Q_Id":1501907,"Users Score":-1,"Answer":"Looking over the docs, I agree that your 24 cron entry idea is the only documented way that would work.  Not ideal, but should work.","Q_Score":4,"Tags":"python,google-app-engine,cron","A_Id":1501925,"CreationDate":"2009-10-01T04:36:00.000","Title":"Run a task every hour on the hour with App Engine's cron API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.\nThere is an example of running at ask every hour, but this doesn't fit because the \"start\" of that hour depends on when you deploy the application. That is, if I deploy at 4:37 PM, the cron scripts will get executed at 5:37, 6:37, ... instead of 5:00, 6:00, ...\nSo far the only way that looks like it would work is to have 24 different cron entries, one for the specific hour of each day set to run each day at that specific time. \nDoes anyone know of anything that would let me use a schedule like \"every hour at :00\" or even \"every day 00:00, 01:00, ... 23:00\"?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3297,"Q_Id":1501907,"Users Score":1,"Answer":"The docs say you can have 20 cron entries, so you can't have one for every hour of the day.\nYou could run your task every minute and check if it is the first minute of the hour - exit otherwise.","Q_Score":4,"Tags":"python,google-app-engine,cron","A_Id":1501960,"CreationDate":"2009-10-01T04:36:00.000","Title":"Run a task every hour on the hour with App Engine's cron API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Once you have learned the basic commands in Python, you are often able to solve most programming problem you face. But the way in which this is done is not really Python-ic. \nWhat is common is to use the classical c++ or Java mentality to solve problems. But Python is more than that. It has functional programming incorporated; many libraries available; object oriented, and its own ways. In short there are often better, shorter, faster, more elegant ways to the same thing.\nIt is a little bit like learning a new language. First you learn the words and the grammar, but then you need to get fluent. \nOnce you have learned the language, how do you get fluent in Python? How have you done it?  What books mostly helped?","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":14330,"Q_Id":1507041,"Users Score":10,"Answer":"Read other people's code.  Write some of your own code.  Repeat for a year or two.\nStudy the Python documentation and learn the built-in modules.\nRead Python in a Nutshell.\nSubscribe your RSS reader to the Python tag on Stack Overflow.","Q_Score":10,"Tags":"python","A_Id":1507054,"CreationDate":"2009-10-01T23:32:00.000","Title":"How do I get fluent in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Once you have learned the basic commands in Python, you are often able to solve most programming problem you face. But the way in which this is done is not really Python-ic. \nWhat is common is to use the classical c++ or Java mentality to solve problems. But Python is more than that. It has functional programming incorporated; many libraries available; object oriented, and its own ways. In short there are often better, shorter, faster, more elegant ways to the same thing.\nIt is a little bit like learning a new language. First you learn the words and the grammar, but then you need to get fluent. \nOnce you have learned the language, how do you get fluent in Python? How have you done it?  What books mostly helped?","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":14330,"Q_Id":1507041,"Users Score":2,"Answer":"I guess becoming fluent in any programming language is the same as becoming fluent in a spoken\/written language. You do that by speaking and listening to the language, a lot.\nSo my advice is to do some projects using python, and you will soon become fluent in it. You can complement this by reading other people's code who are more experienced in the language to see how they solve certain problems.","Q_Score":10,"Tags":"python","A_Id":1507058,"CreationDate":"2009-10-01T23:32:00.000","Title":"How do I get fluent in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Once you have learned the basic commands in Python, you are often able to solve most programming problem you face. But the way in which this is done is not really Python-ic. \nWhat is common is to use the classical c++ or Java mentality to solve problems. But Python is more than that. It has functional programming incorporated; many libraries available; object oriented, and its own ways. In short there are often better, shorter, faster, more elegant ways to the same thing.\nIt is a little bit like learning a new language. First you learn the words and the grammar, but then you need to get fluent. \nOnce you have learned the language, how do you get fluent in Python? How have you done it?  What books mostly helped?","AnswerCount":8,"Available Count":3,"Score":0.0748596907,"is_accepted":false,"ViewCount":14330,"Q_Id":1507041,"Users Score":3,"Answer":"The same way you get fluent in any language - program a lot.\nI'd recommend working on a project (hopefully something you'll actually use later). While working on the project, every time you need some basic piece of functionality, try writing it yourself, and then checking online how other people did it.\nThis both lets you learn how to actually get stuff done in Python, but will also allow you to see what are the \"Pythonic\" counterparts to common coding cases.","Q_Score":10,"Tags":"python","A_Id":1507068,"CreationDate":"2009-10-01T23:32:00.000","Title":"How do I get fluent in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got several eggs I maintain on Pypi but up until now I've always focused on Python 2.5x.\nI'd like to release my eggs under both Python 2.5 & Python 2.6 in an automated fashion i.e.\n\nrunning tests \ngenerating doc\npreparing eggs\nuploading to Pypi\n\nHow do you guys achieve this?\nA related question: how do I tag an egg to be \"version independent\" ? works under all version of Python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":817,"Q_Id":1512644,"Users Score":1,"Answer":"You don't need to release eggs for anything else than Windows, and then only if your package uses C extensions so that they have compiled parts. Otherwise you simply release one source distribution. That will be enough for all Python versions on all platforms.\nRunning the tests for different versions automated is tricky if you don't have a buildbot. But once you have run the tests with both 2.5 and 2.6 releasing is just a question of running python setup.py sdist register upload and it doesn't matter what Python version you use to run that.","Q_Score":5,"Tags":"python,release-management,pypi","A_Id":1513884,"CreationDate":"2009-10-03T02:45:00.000","Title":"Python Pypi: what is your process for releasing packages for different Python versions? (Linux)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't seem to fetch the verifiedEmail field when trying to login to AOLs OpenID on my site. Every other provider that I know of provides this property, but not AOL.\nI realize that AOL somehow uses an old OpenID version, although is it feasible to just assume that their e-mail ends in @aol.com? I'm using the RPXNow library with Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":166,"Q_Id":1513543,"Users Score":0,"Answer":"I believe that OpenID lets the user decide how much information to \"share\" during the login process.  I can't say that I am an expert on the subject, but I know that my identity at myopenid.com lets me specify precisely what information to make available.\nIs it possible that the AOL default is to share nothing?  If this is the case, then you may want to do an email authorization directly with the user if the OpenID provider doesn't seem to have the information.  OpenID doesn't mandate that this information is available so I would assume that you will have to handle the case of it not being there in application code.","Q_Score":0,"Tags":"python,openid,rpxnow","A_Id":1513794,"CreationDate":"2009-10-03T11:40:00.000","Title":"verifiedEmail AOL OpenID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can someone please tell how to write a Non-Blocking server code using the socket library alone.Thanks","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2625,"Q_Id":1515686,"Users Score":2,"Answer":"Why socket alone? It's so much simpler to use another standard library module, asyncore -- and if you can't, at the very least select!\nIf you're constrained by your homework's condition to only use socket, then I hope you can at least add threading (or multiprocessing), otherwise you're seriously out of luck -- you can make sockets with timeout, but juggling timing-out sockets without the needed help from any of the other obvious standard library modules (to support either async or threaded serving) is a serious mess indeed-y...;-).","Q_Score":0,"Tags":"python,sockets,nonblocking","A_Id":1515698,"CreationDate":"2009-10-04T05:35:00.000","Title":"Non Blocking Server in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm locked in using C# and I don't like it one bit. I have to start branching out to better myself as a professional and as a person, so I've decided to start making things in my own time using Python.\nThe problem is, I've basically programmed only in C#. What IDE should I use to make programs using Python?\nMy goal is to make a sort of encyclopedic program for a game I'm playing right now, displaying hero information, names, stats, picture, etc. All of this information I'm going to parse from an XML file. \nMy plan is for this application to be able to run under Windows, Linux and Mac (I'm under the impression that any code written in Python works 100% cross-platform, right?)\nThanks a lot for your tremendous help brothers of SO. :P\nEdit:\nI guess I should clarify that I'm looking for an IDE that supports drag and drop GUI design. I'm used to using VS and I'm not really sure how you can do it any other way.","AnswerCount":11,"Available Count":2,"Score":0.0181798149,"is_accepted":false,"ViewCount":619,"Q_Id":1517428,"Users Score":1,"Answer":"Good IDE for python are Komodo or Eclipse with PyDev.\nBut even Notepad++ or any other text editor will enough to get you started, since you don't need to compile your code, just have a good editor.\nThe benefit of the above IDEs, is that you can use them to manage a large scale project and debug your code.\nAs for the cross platform issue, as long as you don't use the specific os libs (such as win32api), you are safe in being cross platform.\nSeems like a very large project for a first time. Is it going to be web based or desktop? Since it will greatly change your design and choice of python libs.","Q_Score":2,"Tags":"c#,python,vim,ide","A_Id":1517444,"CreationDate":"2009-10-04T21:29:00.000","Title":"Coming from a Visual Studio background, what do you recommend I use to start my VERY FIRST Python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm locked in using C# and I don't like it one bit. I have to start branching out to better myself as a professional and as a person, so I've decided to start making things in my own time using Python.\nThe problem is, I've basically programmed only in C#. What IDE should I use to make programs using Python?\nMy goal is to make a sort of encyclopedic program for a game I'm playing right now, displaying hero information, names, stats, picture, etc. All of this information I'm going to parse from an XML file. \nMy plan is for this application to be able to run under Windows, Linux and Mac (I'm under the impression that any code written in Python works 100% cross-platform, right?)\nThanks a lot for your tremendous help brothers of SO. :P\nEdit:\nI guess I should clarify that I'm looking for an IDE that supports drag and drop GUI design. I'm used to using VS and I'm not really sure how you can do it any other way.","AnswerCount":11,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":619,"Q_Id":1517428,"Users Score":0,"Answer":"Eclipse + Pydev is currently the gold standard IDE for Python. It's cross platform and since it's a general purpose IDE it has support for just about every other programming activity you might want to consider. \nEclipse is not bad for C++, and very mature for Java developers. It's quite amazing when you realize that all this great stuff costs nothing.","Q_Score":2,"Tags":"c#,python,vim,ide","A_Id":1517475,"CreationDate":"2009-10-04T21:29:00.000","Title":"Coming from a Visual Studio background, what do you recommend I use to start my VERY FIRST Python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've gotten omnicompletion with Pysmell to work before, but I can't seem to do it again.\nI tried following some steps online, but most, if not all, of them are to vague and assume too much that you know what you are doing to some extent. \nCan someone post a full, step-by-step tutorial on how to get code completion working properly, for complete Vim newbies (for dummies?)?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7163,"Q_Id":1520576,"Users Score":0,"Answer":"Try hitting Ctrl-p while typing mid-word. Ctrl-p inserts the most recent word that starts with the prefix you're typing and Ctrl-n inserts the next match. If you have several possibilities, you can hit ctrl-p more than once to substitute each candidate in order.","Q_Score":4,"Tags":"python,vim","A_Id":1520822,"CreationDate":"2009-10-05T14:52:00.000","Title":"Getting proper code completion for Python on Vim?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've gotten omnicompletion with Pysmell to work before, but I can't seem to do it again.\nI tried following some steps online, but most, if not all, of them are to vague and assume too much that you know what you are doing to some extent. \nCan someone post a full, step-by-step tutorial on how to get code completion working properly, for complete Vim newbies (for dummies?)?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":7163,"Q_Id":1520576,"Users Score":4,"Answer":"There's also Ctrl+n in insert mode which will autocomplete based on the words it has seen in any of the open buffers (even in other tabs).","Q_Score":4,"Tags":"python,vim","A_Id":1523392,"CreationDate":"2009-10-05T14:52:00.000","Title":"Getting proper code completion for Python on Vim?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python program (PP) that loads another Program(AP) via COM, gets its window handle and sets it to be the PP parent.\nThis works pretty well except that I can't control that AP still has their [X] button available in the top left corner.  Since this is a pretty obvious place for the user to close when they are done with the program, I tried this and it left the PP in the Task Manager running, but not visible with no possible way to kill it other than through Task Manager.  Any ideas on how to handle this?  I expect it to be rather Common that the user closes in this manner.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":181,"Q_Id":1521670,"Users Score":1,"Answer":"How's PP's control flow?  If it's event-driven it could get appropriate events upon closure of that parent window or termination of that AP process; otherwise it could \"poll\" to check if the window or process are still around.","Q_Score":0,"Tags":"python,com,wxpython,parent","A_Id":1522240,"CreationDate":"2009-10-05T18:28:00.000","Title":"Close Python when Parent is closed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been looking really hard at all of the way**(s)** one can develop web applications using Python.  For reference, we are using RHEL 64bit, apache, mod_wsgi.\nHistory:\n\nPHP + MySQL years ago\nPHP + Python 2.x + MySQL recently and current\nPython + PostgreSQL working on it\n\nWe use a great library for communicating between PHP and Python (interface in PHP, backend in Python)...  However, with a larger upcoming project starting, using 100% python may be very advantagous.\nWe typically prefer not to have a monolithic framework dictating how things are done.  A collection of useful helpers and utilities are much preferred (be it PHP or Python).\nQuestion 1:\nIn reading a number of answers from experienced Python users, I've seen Werkzeug recommended a number of times.   I would love it if several people with direct experience using Werkzeug to develop professional web applications could comment (in as much detail as their fingers feel like) why they use it, why they like it, and anything to watch out for.\nQuestion 2:\nIs there a version of Werkzeug that supports Python 3.1.1.  I've succefully installed mod_wsgi on Apache 2.2 with Python 3.1.1.\nIf there is not a version, what would it take to upgrade it to work on Python 3.1?\nNote: I've run 2to3 on the Werkzeug source code, and it does python-compile without \nEdit:\nThe project that we are starting is not slated to be finished until nearly a year from now.  At which point, I'm guessing Python 3.X will be a lot more mainstream.  Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there?\nThoughts appreciated!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2259,"Q_Id":1523706,"Users Score":1,"Answer":"I can only answer question one:\nI started using it for some small webstuff but now moved on to rework larger apps with it. Why Werkzeug? The modular concept is really helpful. You can hook in modules as you like, make stuff easily context aware and you get good request file handling for free which is able to cope with 300mb+ files by not storing it in memory.\nDisadvantages... Well sometimes modularity needs some upfront thought (django f.ex. gives you everything all at once, stripping stuff out is hard to do there though) but for me it works fine.","Q_Score":2,"Tags":"python,python-3.x,werkzeug","A_Id":1622505,"CreationDate":"2009-10-06T05:13:00.000","Title":"Werkzeug in General, and in Python 3.1","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been looking really hard at all of the way**(s)** one can develop web applications using Python.  For reference, we are using RHEL 64bit, apache, mod_wsgi.\nHistory:\n\nPHP + MySQL years ago\nPHP + Python 2.x + MySQL recently and current\nPython + PostgreSQL working on it\n\nWe use a great library for communicating between PHP and Python (interface in PHP, backend in Python)...  However, with a larger upcoming project starting, using 100% python may be very advantagous.\nWe typically prefer not to have a monolithic framework dictating how things are done.  A collection of useful helpers and utilities are much preferred (be it PHP or Python).\nQuestion 1:\nIn reading a number of answers from experienced Python users, I've seen Werkzeug recommended a number of times.   I would love it if several people with direct experience using Werkzeug to develop professional web applications could comment (in as much detail as their fingers feel like) why they use it, why they like it, and anything to watch out for.\nQuestion 2:\nIs there a version of Werkzeug that supports Python 3.1.1.  I've succefully installed mod_wsgi on Apache 2.2 with Python 3.1.1.\nIf there is not a version, what would it take to upgrade it to work on Python 3.1?\nNote: I've run 2to3 on the Werkzeug source code, and it does python-compile without \nEdit:\nThe project that we are starting is not slated to be finished until nearly a year from now.  At which point, I'm guessing Python 3.X will be a lot more mainstream.  Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there?\nThoughts appreciated!","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2259,"Q_Id":1523706,"Users Score":1,"Answer":"I haven't used Werkzeug, so I can only answer question 2:\nNo, Werkzeug does not work on Python 3. In fact, very little works on Python 3 as of today. Porting is not difficult, but you can't port until all your third-party libraries have been ported, so progress is slow.\nOne big stopper has been setuptools, which is a very popular package to use. Setuptools is unmaintained, but there is a maintained fork called Distribute. Distribute was released with Python 3 support just a week or two ago. I hope package support for Python 3 will pick up now. But it will still be a long time, at least months probably a year or so, before any major project like Werkzeug will be ported to Python 3.","Q_Score":2,"Tags":"python,python-3.x,werkzeug","A_Id":1523934,"CreationDate":"2009-10-06T05:13:00.000","Title":"Werkzeug in General, and in Python 3.1","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been looking really hard at all of the way**(s)** one can develop web applications using Python.  For reference, we are using RHEL 64bit, apache, mod_wsgi.\nHistory:\n\nPHP + MySQL years ago\nPHP + Python 2.x + MySQL recently and current\nPython + PostgreSQL working on it\n\nWe use a great library for communicating between PHP and Python (interface in PHP, backend in Python)...  However, with a larger upcoming project starting, using 100% python may be very advantagous.\nWe typically prefer not to have a monolithic framework dictating how things are done.  A collection of useful helpers and utilities are much preferred (be it PHP or Python).\nQuestion 1:\nIn reading a number of answers from experienced Python users, I've seen Werkzeug recommended a number of times.   I would love it if several people with direct experience using Werkzeug to develop professional web applications could comment (in as much detail as their fingers feel like) why they use it, why they like it, and anything to watch out for.\nQuestion 2:\nIs there a version of Werkzeug that supports Python 3.1.1.  I've succefully installed mod_wsgi on Apache 2.2 with Python 3.1.1.\nIf there is not a version, what would it take to upgrade it to work on Python 3.1?\nNote: I've run 2to3 on the Werkzeug source code, and it does python-compile without \nEdit:\nThe project that we are starting is not slated to be finished until nearly a year from now.  At which point, I'm guessing Python 3.X will be a lot more mainstream.  Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there?\nThoughts appreciated!","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":2259,"Q_Id":1523706,"Users Score":3,"Answer":"mod_wsgi for Python 3.x is also not ready. There is no satisfactory definition of WSGI for Python 3.x yet; the WEB-SIG are still bashing out the issues. mod_wsgi targets a guess at what might be in it, but there are very likely to be changes to both the spec and to standard libraries. Any web application you write today in Python 3.1 is likely to break in the future.\nIt's a bit of a shambles. Today, for webapps you can only realistically use Python 2.x.","Q_Score":2,"Tags":"python,python-3.x,werkzeug","A_Id":1525943,"CreationDate":"2009-10-06T05:13:00.000","Title":"Werkzeug in General, and in Python 3.1","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":1524713,"Users Score":0,"Answer":"You could make a Date object in javascript. Check the current time and depending on the time, you set the img src to whatever image you want for that time of day :) or hide the image through myimg.style.visibility = \"hidden\" if you dont want to display an image at that moment.","Q_Score":1,"Tags":"python,django","A_Id":1524724,"CreationDate":"2009-10-06T10:15:00.000","Title":"How do I display images at different times on webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":1524713,"Users Score":0,"Answer":"If you need to change the image before a page refresh, you could use jquery ajax call to get the correct image.  jquery has some interval functionality which would allow this.","Q_Score":1,"Tags":"python,django","A_Id":1524812,"CreationDate":"2009-10-06T10:15:00.000","Title":"How do I display images at different times on webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i create new file in \/var\/log directory using python language in OSX leopard? i tried to do it using os.open function but i get \"permission denied\"\nthanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1509,"Q_Id":1529584,"Users Score":1,"Answer":"It probably failed because \/var\/log has user set to root and group set to wheel. Try running your python code as root and it will probably work.","Q_Score":1,"Tags":"python,macos,osx-leopard","A_Id":1529596,"CreationDate":"2009-10-07T05:07:00.000","Title":"how to create new file using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.\nI am wondering how to do debugging.\nAt present the steps I follow is, \n\nI complete a large script,\nComment everything but the portion I\nwant to check\nExecute the script\n\nThough it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that.\nMy question is, is there any better way of debugging?\nNote: I guess it may be a repeated question, if so, please point me to the answer.","AnswerCount":11,"Available Count":4,"Score":0.0363476168,"is_accepted":false,"ViewCount":1224,"Q_Id":1529896,"Users Score":2,"Answer":"Script languages have no differences compared with other languages in the sense that you still have to break your problems into manageable pieces -- that is, functions. So, instead of testing the whole script after finishing the whole script, I prefer to test those small functions before integrating them.  TDD always helps.","Q_Score":6,"Tags":"python,ruby,scripting-language","A_Id":1529931,"CreationDate":"2009-10-07T06:41:00.000","Title":"Debugging a scripting language like ruby","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.\nI am wondering how to do debugging.\nAt present the steps I follow is, \n\nI complete a large script,\nComment everything but the portion I\nwant to check\nExecute the script\n\nThough it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that.\nMy question is, is there any better way of debugging?\nNote: I guess it may be a repeated question, if so, please point me to the answer.","AnswerCount":11,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":1224,"Q_Id":1529896,"Users Score":10,"Answer":"Your sequence seems entirely backwards to me.  Here's how I do it:\n\nI write a test for the functionality I want.\nI start writing the script, executing bits and verifying test results.\nI review what I'd done to document and publish.\n\nSpecifically, I execute before I complete.  It's way too late by then.\nThere are debuggers, of course, but with good tests and good design, I've almost never needed one.","Q_Score":6,"Tags":"python,ruby,scripting-language","A_Id":1529996,"CreationDate":"2009-10-07T06:41:00.000","Title":"Debugging a scripting language like ruby","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.\nI am wondering how to do debugging.\nAt present the steps I follow is, \n\nI complete a large script,\nComment everything but the portion I\nwant to check\nExecute the script\n\nThough it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that.\nMy question is, is there any better way of debugging?\nNote: I guess it may be a repeated question, if so, please point me to the answer.","AnswerCount":11,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":1224,"Q_Id":1529896,"Users Score":0,"Answer":"The debugging method you described is perfect for a static language like C++, but given that the language is so different, the coding methods are similarly different. One of the big very important things in a dynamic language such as Python or Ruby is the interactive toplevel (what you get by typing, say python on the command line). This means that running a part of your program is very easy.\nEven if you've written a large program before testing (which is a bad idea), it is hopefully separated into many functions. So, open up your interactive toplevel, do an import thing (for whatever thing happens to be) and then you can easily start testing your functions one by one, just calling them on the toplevel.\nOf course, for a more mature project, you probably want to write out an actual test suite, and most languages have a method to do that (in Python, this is doctest and nose, don't know about other languages). At first, though, when you're writing something not particularly formal, just remember a few simple rules of debugging dynamic languages:\n\nStart small. Don't write large programs and test them. Test each function as you write it, at least cursorily.\nUse the toplevel. Running small pieces of code in a language like Python is extremely lightweight: fire up the toplevel and run it. Compare with writing a complete program and the compile-running it in, say, C++. Use that fact that you can quickly change the correctness of any function.\nDebuggers are handy. But often, so are print statements. If you're only running a single function, debugging with print statements isn't that inconvenient, and also frees you from dragging along an IDE.","Q_Score":6,"Tags":"python,ruby,scripting-language","A_Id":1531112,"CreationDate":"2009-10-07T06:41:00.000","Title":"Debugging a scripting language like ruby","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.\nI am wondering how to do debugging.\nAt present the steps I follow is, \n\nI complete a large script,\nComment everything but the portion I\nwant to check\nExecute the script\n\nThough it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that.\nMy question is, is there any better way of debugging?\nNote: I guess it may be a repeated question, if so, please point me to the answer.","AnswerCount":11,"Available Count":4,"Score":0.0363476168,"is_accepted":false,"ViewCount":1224,"Q_Id":1529896,"Users Score":2,"Answer":"My question is, is there any better way of debugging?\"\nYes.\nYour approach, \"1. I complete a large script, 2. Comment everything but the portion I want to check, 3. Execute the script\" is not really the best way to write any software in any language (sorry, but that's the truth.)\nDo not write a large anything.  Ever.\nDo this.\n\nDecompose your problem into classes of objects.\nFor each class, write the class by\n2a.  Outline the class, focus on the external interface, not the implementation details.\n2b.  Write tests to prove that interface works.\n2c.  Run the tests.  They'll fail, since you only outlined the class.\n2d.  Fix the class until it passes the test.\n2e.  At some points, you'll realize your class designs aren't optimal.  Refactor your design, assuring your tests still pass.\nNow, write your final script.  It should be short.  All the classes have already been tested.\n3a.  Outline the script.  Indeed, you can usually write the script.\n3b.  Write some test cases that prove the script works.\n3c.  Runt the tests.  They may pass.  You're done.\n3d.  If the tests don't pass, fix things until they do.\n\nWrite many small things.  It works out much better in the long run that writing a large thing and commenting parts of it out.","Q_Score":6,"Tags":"python,ruby,scripting-language","A_Id":1530723,"CreationDate":"2009-10-07T06:41:00.000","Title":"Debugging a scripting language like ruby","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:\n\nAs the number of rows is unknown at the beginning of the loading, how can\na very large numpy array be most efficiently built, row by row?\n\nSimply adding the row to the array would be inefficient in memory terms, as two large arrays would momentarily co-exist. The same problem would seem to be occur if you use numpy.append. The stack functions are promising, but ideally I would want to grow the array in place.\nThis leads to the second question:\n\nWhat is the best way to observe the memory usage of a Python program that heavily\nuses numpy arrays?\n\nTo study the above problem, I've used the usual memory profiling tools - heapy and pympler - but am only getting the size of the outer array objects (80 bytes) and not the data they are containing. Asides from a crude measuring of how much memory the Python process is using, how can I get at the \"full\" size of the arrays as they grow?\nLocal details: OSX 10.6, Python 2.6, but general solutions are welcome.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":6464,"Q_Id":1530960,"Users Score":1,"Answer":"On possible option is to do a single pass through the file first to count the number of rows, without loading them.\nThe other option is to double your table size each time, which has two benefits:\n\nYou will only re-alloc memory log(n) times where n is the number of rows.\nYou only need 50% more ram than your largest table size\n\nIf you take the dynamic route, you could measure the length of the first row in bytes, then guess the number of rows by calculating (num bytes in file \/ num bytes in first row). Start with a table of this size.","Q_Score":11,"Tags":"python,numpy,memory-management","A_Id":1534340,"CreationDate":"2009-10-07T11:08:00.000","Title":"Incrementally building a numpy array and measuring memory usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"In my application I run subprocesses under several different user accounts. I need to be able to read some of the information written to the registry by these subprocesses. Each one is writing to HKEY_CURRENT_USER, and I know the user account name that they are running under.\nIn Python, how can I read values from HKEY_CURRENT_USER for a specific user? I assume I need to somehow load the registry values under the user's name, and then read them from there, but how?\nedit: Just to make sure it's clear, my Python program is running as Administrator, and I have accounts \"user1\", \"user2\", and \"user3\", which each have information in their own HKEY_CURRENT_USER. As Administrator, how do I read user1's HKEY_CURRENT_USER data?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":8899,"Q_Id":1532306,"Users Score":2,"Answer":"HKEY_CURRENT_USER maps to a HKEY_USERS\\{id} key.\nTry finding the id by matching the HKEY_USERS{id}\\Volatile Environment\\USERNAME key to the username of the user (by enumerating\/iterating over the {id}s that are present on the system). When you find the match just use HKEY_USERS{id} as if it was HKEY_CURRENT_USER","Q_Score":1,"Tags":"python,windows,registry","A_Id":1532868,"CreationDate":"2009-10-07T15:20:00.000","Title":"Reading HKEY CURRENT USER from the registry in Python, specifying the user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i need to transfer large files across network and need to create checksum for them on hourly basis. so the speed for generating checksum is critical for me.\nsomehow i can't make zlib.crc32 and zlib.adler32 working with files larger than 4GB on Windows XP Pro 64bit machine. i suspect i've hit the 32bit limitation here? using hashlib.md5 i could get a result but the problem is the speed. it takes roughly about 5 minutes to generate an md5 for 4.8GB file. task manager shows that the process is using one core only.\nmy questions are:\n\nis there a way to make crc works on large file? i prefer to use crc than md5\nif not then is there a way to speed up the md5.hexdigest()\/md5.digest? or in this case any hashlib hexdigest\/digest? maybe spliting it into multi thread process? how do i do that?\n\nPS: i'm working on somethimg similar like an \"Asset Management\" system, kind of like svn but the asset consist of large compressed image files. the files have tiny bit incremental changes. the hashing\/checksum is needed for detecting changes and error detection.","AnswerCount":6,"Available Count":5,"Score":0.1651404129,"is_accepted":false,"ViewCount":17263,"Q_Id":1532720,"Users Score":5,"Answer":"It's an algorithm selection problem, rather than a library\/language selection problem!\nThere appears to be two points to consider primarily:\n\nhow much would the disk I\/O affect the overall performance?\nwhat is the expected reliability of the error detection feature?\n\nApparently, the answer to the second question is something like 'some false negative allowed' since the reliability of any 32 bits hash, relative to a 4Gb message, even in a moderately noisy channel, is not going to be virtually absolute.\nAssuming that I\/O can be improved through multithreading, we may choose a hash that doesn't require a sequential scan of the complete message.  Instead we can maybe work the file in parallel, hashing individual sections and either combining the hash values or appending them, to form a longer, more reliable error detection device.\nThe next step  could be to formalize this handling of files as ordered sections, and to transmit them as such (to be re-glued together at the recipient's end).  This approach, along  additional information about the way the files are produced (for ex. they may be exclusively modified by append, like log files),  may even allow to limit the amount of hash calculation required.  The added complexity of this approach needs to weighted against the desire to have zippy fast CRC calculation.\nSide note: Alder32 is not limited to message sizes below a particular threshold. It may just be a limit of the zlib API.  (BTW, the reference I found about zlib.adler32 used a buffer, and well... this approach is to be avoided in the context of our huge messages, in favor of streamed processes: read a little from file, calculate, repeat..)","Q_Score":6,"Tags":"python,multithreading,md5,crc32,hashlib","A_Id":1533036,"CreationDate":"2009-10-07T16:28:00.000","Title":"the fastest way to create checksum for large files in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i need to transfer large files across network and need to create checksum for them on hourly basis. so the speed for generating checksum is critical for me.\nsomehow i can't make zlib.crc32 and zlib.adler32 working with files larger than 4GB on Windows XP Pro 64bit machine. i suspect i've hit the 32bit limitation here? using hashlib.md5 i could get a result but the problem is the speed. it takes roughly about 5 minutes to generate an md5 for 4.8GB file. task manager shows that the process is using one core only.\nmy questions are:\n\nis there a way to make crc works on large file? i prefer to use crc than md5\nif not then is there a way to speed up the md5.hexdigest()\/md5.digest? or in this case any hashlib hexdigest\/digest? maybe spliting it into multi thread process? how do i do that?\n\nPS: i'm working on somethimg similar like an \"Asset Management\" system, kind of like svn but the asset consist of large compressed image files. the files have tiny bit incremental changes. the hashing\/checksum is needed for detecting changes and error detection.","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":17263,"Q_Id":1532720,"Users Score":1,"Answer":"You cannot possibly use more than one core to calculate MD5 hash of a large file because of the very nature of MD5: it expects a message to be broken up in chunks and fed into hashing function in strict sequence. However, you can use one thread to read a file into internal queue, and then calculate hash in a separate thread so that. I do not think though that this will give you any significant performance boost.\nThe fact that it takes so long to process a big file might be due to \"unbuffered\" reads. Try reading, say, 16 Kb at a time and then feed the content in chunks to hashing function.","Q_Score":6,"Tags":"python,multithreading,md5,crc32,hashlib","A_Id":1532764,"CreationDate":"2009-10-07T16:28:00.000","Title":"the fastest way to create checksum for large files in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i need to transfer large files across network and need to create checksum for them on hourly basis. so the speed for generating checksum is critical for me.\nsomehow i can't make zlib.crc32 and zlib.adler32 working with files larger than 4GB on Windows XP Pro 64bit machine. i suspect i've hit the 32bit limitation here? using hashlib.md5 i could get a result but the problem is the speed. it takes roughly about 5 minutes to generate an md5 for 4.8GB file. task manager shows that the process is using one core only.\nmy questions are:\n\nis there a way to make crc works on large file? i prefer to use crc than md5\nif not then is there a way to speed up the md5.hexdigest()\/md5.digest? or in this case any hashlib hexdigest\/digest? maybe spliting it into multi thread process? how do i do that?\n\nPS: i'm working on somethimg similar like an \"Asset Management\" system, kind of like svn but the asset consist of large compressed image files. the files have tiny bit incremental changes. the hashing\/checksum is needed for detecting changes and error detection.","AnswerCount":6,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":17263,"Q_Id":1532720,"Users Score":3,"Answer":"First, there is nothing inherent in any of the CRC algorithms that would prevent them working on an arbitrary length of data (however, a particular implementation might well impose a limit).\nHowever, in a file syncing application, that probably doesn't matter, as you may not want to hash the entire file when it gets large, just chunks anyway. If you hash the entire file, and the hashes at each end differ, you have to copy the entire file. If you hash fixed sized chunks, then you only have to copy the chunks whose hash has changed. If most of the changes to the files are localized (e.g. database) then this will likely require much less copying (and it' easier to spread per chunk calculations across multiple cores).\nAs for the hash algorithm itself, the basic tradeoff is speed vs. lack of collisions (two different data chunks yielding the same hash). CRC-32 is fast, but with only 2^32 unique values, collisions may be seen. MD5 is much slower, but has 2^128 unique values, so collisions will almost never be seen (but are still theoretically possible). The larger hashes (SHA1, SHA256, ...) have even more unique values, but are slower still: I doubt you need them: you're worried about accidental collisions, unlike digital signature applications, where you're worried about deliberately (malicously) engineered collisions.\nIt sounds like you're trying to do something very similar to what the rsync utility does. Can you just use rsync?","Q_Score":6,"Tags":"python,multithreading,md5,crc32,hashlib","A_Id":1533255,"CreationDate":"2009-10-07T16:28:00.000","Title":"the fastest way to create checksum for large files in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i need to transfer large files across network and need to create checksum for them on hourly basis. so the speed for generating checksum is critical for me.\nsomehow i can't make zlib.crc32 and zlib.adler32 working with files larger than 4GB on Windows XP Pro 64bit machine. i suspect i've hit the 32bit limitation here? using hashlib.md5 i could get a result but the problem is the speed. it takes roughly about 5 minutes to generate an md5 for 4.8GB file. task manager shows that the process is using one core only.\nmy questions are:\n\nis there a way to make crc works on large file? i prefer to use crc than md5\nif not then is there a way to speed up the md5.hexdigest()\/md5.digest? or in this case any hashlib hexdigest\/digest? maybe spliting it into multi thread process? how do i do that?\n\nPS: i'm working on somethimg similar like an \"Asset Management\" system, kind of like svn but the asset consist of large compressed image files. the files have tiny bit incremental changes. the hashing\/checksum is needed for detecting changes and error detection.","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":17263,"Q_Id":1532720,"Users Score":2,"Answer":"You might be hitting a size limit for files in XP. The 64-bit gives you more addressing space (removing the 2GB (or so) addressing space per application), but probably does nothing for the file size problem.","Q_Score":6,"Tags":"python,multithreading,md5,crc32,hashlib","A_Id":1540992,"CreationDate":"2009-10-07T16:28:00.000","Title":"the fastest way to create checksum for large files in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i need to transfer large files across network and need to create checksum for them on hourly basis. so the speed for generating checksum is critical for me.\nsomehow i can't make zlib.crc32 and zlib.adler32 working with files larger than 4GB on Windows XP Pro 64bit machine. i suspect i've hit the 32bit limitation here? using hashlib.md5 i could get a result but the problem is the speed. it takes roughly about 5 minutes to generate an md5 for 4.8GB file. task manager shows that the process is using one core only.\nmy questions are:\n\nis there a way to make crc works on large file? i prefer to use crc than md5\nif not then is there a way to speed up the md5.hexdigest()\/md5.digest? or in this case any hashlib hexdigest\/digest? maybe spliting it into multi thread process? how do i do that?\n\nPS: i'm working on somethimg similar like an \"Asset Management\" system, kind of like svn but the asset consist of large compressed image files. the files have tiny bit incremental changes. the hashing\/checksum is needed for detecting changes and error detection.","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":17263,"Q_Id":1532720,"Users Score":1,"Answer":"md5 itself can't be run in parallel. However you can md5 the file in sections (in parallel) and the take an md5 of the list of hashes.\nHowever that assumes that the hashing is not IO-limited, which I would suspect it is. As Anton Gogolev suggests - make sure that you're reading the file efficiently (in large power-of-2 chunks). Once you've done that, make sure the file isn't fragmented.\nAlso a hash such as sha256 should be selected rather than md5 for new projects.\nAre the zlib checksums much faster than md5 for 4Gb files?","Q_Score":6,"Tags":"python,multithreading,md5,crc32,hashlib","A_Id":1532779,"CreationDate":"2009-10-07T16:28:00.000","Title":"the fastest way to create checksum for large files in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Most likely it's a dumb question for those who knows the answer, but I'm a beginner, and here it goes:\nI have a Python script which I run in a command-line with some parameter, and it prints me some results. Let's say results are some HTML code.\nI never done any Python programming for web, and couldn't figure it out... I need to have a page (OK, I know how to upload files to a server, Apache is running, Python is installed on the server...) with an edit field, which will accept that parameter, and Submit button, and I need it to \"print\" the results on a web page after the user submitted a proper parameter, or show any output that in a command-line situation are printed.\nI've read Dive Into Python's chapters about \"HTML Processing\" and \"HTTP Web Services\", but they do not describe what I'm looking for.\nIf the answer isn't short, I would very much appreciate links to the more relevant stuff to read or maybe the key words to google for it.","AnswerCount":8,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":29818,"Q_Id":1534070,"Users Score":2,"Answer":"Whose web server? If it is a web server provided by a web hosting company or someone else and you don't have control over it, you need to ascertain in what way they support the use of Python for writing web applications. It isn't enough to know just that they have Python available.\nAs pointed out by others, is likely that at least CGI scripts which use Python will be supported. CGI however is not really practical for running large Python web frameworks such as Django.\nIt is possible though that the web server might also support FASTCGI. If that is the case it becomes possible to use such larger Python web frameworks as FASTCGI uses persistent processes where as CGI creates a process for each request, where the overhead of large Python web frameworks generally makes the use of CGI impractical as a result.\nIf the Apache server is controlled by others using a standalone Python web server such as wsgiref and proxying to it from Apache isn't going to be doable either as you can't setup Apache to do it.\nSo, find out how use of Python for web applications is supported and work out whether you are just a user of the Apache instance, or whether you have some measure of control of changing its global configuration files and restarting it. This will dictate what you can do and use.","Q_Score":11,"Tags":"python","A_Id":1537103,"CreationDate":"2009-10-07T20:40:00.000","Title":"Python: how to show results on a web page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how to proceed with this task, take this string for example \"thingsandstuff\".\nHow could I generate all possible strings out of this string as to look them up individually against an english dictionary?\nThe goal is to find valid english words in a string that does not contain space.\nThanks","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3534,"Q_Id":1538589,"Users Score":0,"Answer":"What if you break it up into syllables and then use those to construct words to compare to your dictionary.  It's still a brute force method, but it would surely speed things up a bit.","Q_Score":1,"Tags":"python","A_Id":1538805,"CreationDate":"2009-10-08T15:36:00.000","Title":"How to sort all possible words out of a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how to proceed with this task, take this string for example \"thingsandstuff\".\nHow could I generate all possible strings out of this string as to look them up individually against an english dictionary?\nThe goal is to find valid english words in a string that does not contain space.\nThanks","AnswerCount":11,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3534,"Q_Id":1538589,"Users Score":0,"Answer":"Well here is my idea  \n\nFind all possible strings containing 1 character from the original\nFind all possible strings containing 2 characters from the original\n... Same thing up to the length of the original string\n\nThen add all up and go match with your dictionary","Q_Score":1,"Tags":"python","A_Id":1538687,"CreationDate":"2009-10-08T15:36:00.000","Title":"How to sort all possible words out of a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how to proceed with this task, take this string for example \"thingsandstuff\".\nHow could I generate all possible strings out of this string as to look them up individually against an english dictionary?\nThe goal is to find valid english words in a string that does not contain space.\nThanks","AnswerCount":11,"Available Count":3,"Score":0.0544914242,"is_accepted":false,"ViewCount":3534,"Q_Id":1538589,"Users Score":3,"Answer":"The brute force approach, i.e. checking every substring, is computationally unfeasible even for strings of middling lengths (a string of length N has O(N**2) substrings). Unless there is a pretty tight bound on the length of strings you care about, that doesn't scale well.\nTo make things more feasible, more knowledge is required -- are you interested in overlapping words (eg 'things' and 'sand' in your example) and\/or words which would leave unaccounted for characters (eg 'thing' and 'and' in your example, leaving the intermediate 's' stranded), or you do you want a strict partition of the string into juxtaposed (not overlapping) words with no residue?\nThe latter would be the simplest problem, because the degrees of freedom drop sharply -- essentially to trying to determine a sequence of \"breaking points\", each between two adjacent characters, that would split the string into words. If that's the case, do you need every possible valid split (i.e. do you need both \"thing sand\" and \"things and\"), or will any single valid split do, or are there criteria that your split must optimize?\nIf you clarify all of these issues it may be possible to give you more help!","Q_Score":1,"Tags":"python","A_Id":1538637,"CreationDate":"2009-10-08T15:36:00.000","Title":"How to sort all possible words out of a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to upgrade the default python installation (2.5.1) supplied with OS X Leopard to the latest version. Please let me know how I can achieve this.\nThanks","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":13472,"Q_Id":1541776,"Users Score":6,"Answer":"May I suggest you leave the \"Default\" be, and install Python in \/usr\/local\/bin.\n\nDownload python\nUnzip it\n.\/configure\nmake\nsudo make install\n\ndone.\nSince \/usr\/local\/bin comes before \/usr\/bin in the $PATH, you will invoke 2.6 when you type python, but the OS will remain stable...","Q_Score":14,"Tags":"python,macos,installation,upgrade","A_Id":1541785,"CreationDate":"2009-10-09T04:24:00.000","Title":"Upgrade Python to 2.6 on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to upgrade the default python installation (2.5.1) supplied with OS X Leopard to the latest version. Please let me know how I can achieve this.\nThanks","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":13472,"Q_Id":1541776,"Users Score":20,"Answer":"When an OS is distributed with some specific Python release and uses it for some OS functionality (as is the case with Mac OS X, as well as many Linux distros &c), you should not tamper in any way with the system-supplied Python (as in, \"upgrading\" it and the like): while Python strives for backwards compatibility within any major release (such as 2.* or 3.*, this can never be 100% guaranted; your OS supplied tested all functionality thoroughly with the specific Python version they distribute; if you manage to alter that version, \"on your head be it\" -- neither your OS supplier nor the PSF accepts any responsibility for whatever damage that might perhaps do to your system.\nRather, as other answers already suggested, install any other release you wish \"besides\" the system one -- why tamper with that crucial one, and risk breaking things, when installing others is so easy anyway?!  On typical Mac OS X 10.5 machines (haven't upgraded any of my several macs to 10.6 yet), I have the Apple-supplied 2.5, a 2.4 on the side to support some old projects not worth the bother to upgrate, the latest 2.6 for new stuff, 3.1 as well to get the very newest -- they all live together in peace and quiet, I just type the release number explicitly, i.e. using python2.6 at the prompt, when I want a specific release. What release gets used when at the shell prompt you just say python is up to you (I personally prefer that to mean \"the system-supplied Python\", but it's a matter of taste: by setting paths, or shell aliases, &c, you can make it mean whatever you wish).","Q_Score":14,"Tags":"python,macos,installation,upgrade","A_Id":1541850,"CreationDate":"2009-10-09T04:24:00.000","Title":"Upgrade Python to 2.6 on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a background in C++ and Java and Objective C programming, but i am finding it hard to learn python, basically where its \"Main Function\" or from where the program start executing. So is there any tutorial\/book which can teach python to people who have background in C++ or Java. Basically something which can show if how you were doing this in C++ and how this is done in Python.\nOK i think i did not put the question heading or question right, basically i was confused about the \"Main\" Function, otherwise other things are quite obvious from python official documentation except this concept.\nThanks to all","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":1548620,"Users Score":0,"Answer":"I started Python over a year ago too, also C++ background.  \nI've learned that everything is simpler in Python, you don't need to worry so much if you're doing it right, you probably are. Most of the things came natural.\nI can't say I've read a book or anything, I usually pested the guys in #python on freenode a lot and looked at lots of other great code out there.\nGood luck :)","Q_Score":4,"Tags":"python","A_Id":1548641,"CreationDate":"2009-10-10T17:56:00.000","Title":"Python for C++ or Java Programmer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a background in C++ and Java and Objective C programming, but i am finding it hard to learn python, basically where its \"Main Function\" or from where the program start executing. So is there any tutorial\/book which can teach python to people who have background in C++ or Java. Basically something which can show if how you were doing this in C++ and how this is done in Python.\nOK i think i did not put the question heading or question right, basically i was confused about the \"Main\" Function, otherwise other things are quite obvious from python official documentation except this concept.\nThanks to all","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":1548620,"Users Score":0,"Answer":"The pithiest comment I guess is that the entry point is the 1st line of your script that is not a function or a class. You don't necessarily need to use the if hack unless you want to and your script is meant to be imported.","Q_Score":4,"Tags":"python","A_Id":1548801,"CreationDate":"2009-10-10T17:56:00.000","Title":"Python for C++ or Java Programmer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to profile some VCS software, and to do so I want to generate a set of random files, in randomly arranged directories. I'm writing the script in Python, but my question is briefly: how do I generate a random directory tree with an average number of sub-directories per directory and some broad distribution of files per directory?\nClarification: I'm not comparing different VCS repo formats (eg. SVN vs Git vs Hg), but profiling software that deals with SVN (and eventually other) working copies and repos.\nThe constraints I'd like are to specify the total number of files (call it 'N', probably ~10k-100k) and the maximum depth of the directory structure ('L', probably 2-10). I don't care how many directories are generated at each level, and I don't want to end up with 1 file per dir, or 100k all in one dir.\nThe distribution is something I'm not sure about, since I don't know whether VCS' (SVN in particular) would perform better or worse with a very uniform structure or a very skewed structure. Nonetheless, it would be nice if I could come up with an algorithm that didn't \"even out\" for large numbers.\nMy first thoughts were: generate the directory tree using some method, and then uniformly populate the tree with files (treating each dir equally, with no regard as to nesting). My back-of-the-envelope calcs tell me that if there are 'L' levels, with 'D' subdirs per dir, and about sqrt(N) files per dir, then there will be about D^L dirs, so N =~ sqrt(N)*(D^L) => D =~ N^(1\/2L). So now I have an approximate value for 'D', how can I generate the tree? How do I populate the files?\nI'd be grateful just for some pointers to good resources on algorithms I could use.  My searching only found pretty applets\/flash.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3603,"Q_Id":1553114,"Users Score":5,"Answer":"Why not download some real open source repos and use those?\nHave you thought about what goes into the files? is that random data too?","Q_Score":2,"Tags":"python,algorithm","A_Id":1553126,"CreationDate":"2009-10-12T07:06:00.000","Title":"Generate random directories\/files given number of files and depth","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It appears to me that except for a little syntactic sugar, property() does nothing good.\nSure, it's nice to be able to write a.b=2 instead of a.setB(2), but hiding the fact that a.b=2 isn't a simple assignment looks like a recipe for trouble, either because some unexpected result can happen, such as a.b=2 actually causes a.b to be 1. Or an exception is raised. Or a performance problem. Or just being confusing.\nCan you give me a concrete example for a good usage of it? (using it to patch problematic code doesn't count ;-)","AnswerCount":8,"Available Count":4,"Score":0.1243530018,"is_accepted":false,"ViewCount":35751,"Q_Id":1554546,"Users Score":5,"Answer":"A basic reason is really simply that it looks better.  It is more pythonic.  Especially for libraries.  something.getValue() looks less nice than something.value\nIn plone (a pretty big CMS), you used to have document.setTitle() which does a lot of things like storing the value, indexing it again and so.  Just doing document.title = 'something' is nicer.  You know that a lot is happening behind the scenes anyway.","Q_Score":81,"Tags":"python,properties","A_Id":1554639,"CreationDate":"2009-10-12T13:22:00.000","Title":"When and how to use the builtin function property() in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It appears to me that except for a little syntactic sugar, property() does nothing good.\nSure, it's nice to be able to write a.b=2 instead of a.setB(2), but hiding the fact that a.b=2 isn't a simple assignment looks like a recipe for trouble, either because some unexpected result can happen, such as a.b=2 actually causes a.b to be 1. Or an exception is raised. Or a performance problem. Or just being confusing.\nCan you give me a concrete example for a good usage of it? (using it to patch problematic code doesn't count ;-)","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":35751,"Q_Id":1554546,"Users Score":1,"Answer":"getters and setters are needed for many purposes, and are very useful because they are transparent to the code. Having object Something the property height, you assign a value as Something.height = 10, but if height has a getter and setter then at the time you do assign that value you can do many things in the procedures, like validating a min or max value, like triggering an event because the height changed, automatically setting other values in function of the new height value, all that may occur at the moment Something.height value was assigned. Remember, you don't need to call them in your code, they are auto executed at the moment you read or write the property value. In some way they are like event procedures, when the property X changes value and when the property X value is read.","Q_Score":81,"Tags":"python,properties","A_Id":34562077,"CreationDate":"2009-10-12T13:22:00.000","Title":"When and how to use the builtin function property() in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It appears to me that except for a little syntactic sugar, property() does nothing good.\nSure, it's nice to be able to write a.b=2 instead of a.setB(2), but hiding the fact that a.b=2 isn't a simple assignment looks like a recipe for trouble, either because some unexpected result can happen, such as a.b=2 actually causes a.b to be 1. Or an exception is raised. Or a performance problem. Or just being confusing.\nCan you give me a concrete example for a good usage of it? (using it to patch problematic code doesn't count ;-)","AnswerCount":8,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":35751,"Q_Id":1554546,"Users Score":15,"Answer":"but hiding the fact that a.b=2 isn't a\n  simple assignment looks like a recipe\n  for trouble\n\nYou're not hiding that fact though; that fact was never there to begin with.  This is python -- a high-level language; not assembly.  Few of the \"simple\" statements in it boil down to single CPU instructions.  To read simplicity into an assignment is to read things that aren't there.\nWhen you say x.b = c, probably all you should think is that \"whatever just happened, x.b should now be c\".","Q_Score":81,"Tags":"python,properties","A_Id":1554753,"CreationDate":"2009-10-12T13:22:00.000","Title":"When and how to use the builtin function property() in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It appears to me that except for a little syntactic sugar, property() does nothing good.\nSure, it's nice to be able to write a.b=2 instead of a.setB(2), but hiding the fact that a.b=2 isn't a simple assignment looks like a recipe for trouble, either because some unexpected result can happen, such as a.b=2 actually causes a.b to be 1. Or an exception is raised. Or a performance problem. Or just being confusing.\nCan you give me a concrete example for a good usage of it? (using it to patch problematic code doesn't count ;-)","AnswerCount":8,"Available Count":4,"Score":0.0748596907,"is_accepted":false,"ViewCount":35751,"Q_Id":1554546,"Users Score":3,"Answer":"You are correct, it is just syntactic sugar. It may be that there are no good uses of it depending on your definition of problematic code.\nConsider that you have a class Foo that is widely used in your application. Now this application has got quite large and further lets say it's a webapp that has become very popular.\nYou identify that Foo is causing a bottleneck. Perhaps it is possible to add some caching to Foo to speed it up. Using properties will let you do that without changing any code or tests outside of Foo.\nYes of course this is problematic code, but you just saved a lot of $$ fixing it quickly.\nWhat if Foo is in a library that you have hundreds or thousands of users for? Well you saved yourself having to tell them to do an expensive refactor when they upgrade to the newest version of Foo.\nThe release notes have a lineitem about Foo instead of a paragraph porting guide.\nExperienced Python programmers don't expect much from a.b=2 other than a.b==2, but they know even that may not be true. What happens inside the class is it's own business.","Q_Score":81,"Tags":"python,properties","A_Id":1556870,"CreationDate":"2009-10-12T13:22:00.000","Title":"When and how to use the builtin function property() in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a sizable code base in Perl. For the forseeable future, our codebase will remain in Perl. However, we're looking into adding a GUI-based dashboard utility. We are considering writing the dashboard in Python (using tkinter or wx). The problem, however, is that we would like to leverage our existing Perl codebase in the Python GUI.\nSo... any suggestions on how achieve this? We are considering a few options:\n\nWrite executables (in Perl) that mimic function calls; invoke those Perl executables in python as system calls.\nWrite Perl executables on-the-fly inside the Python dashboard, and invoke the (temporary) Perl executable.\nFind some kind of Perl-to-Python converter or binding.\n\nAny other ideas? I'd love to hear if other people have confronted this problem. Unfortunately, it's not an option to convert the codebase itself to Python at this time.","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":406,"Q_Id":1556668,"Users Score":2,"Answer":"Well, if you really want to write the GUI in another language (which, seriously, is just a bad idea, since it will cost you more than it could ever benefit you), the thing you should do is the following:\n\nDocument your Perl app in terms of the services it provides. You should do it with XML Schema Definition - XSD - for the data types and Web Service Description Language - WSDL - for the actual service.\nImplement the services in Perl, possibly using Catalyst::Controller::SOAP, or just XML::Compile::SOAP.\nConsume the services from your whatever-language GUI interface.\nProfit.\n\nBut honestly, I really suggest you taking a look at the Perl GTK2 binding, it is awesome, including features such as implementing a Gtk class entirely in Perl and using it as argument to a function written in C - for instance, you can write a model class for a gtk tree entirely in Perl.","Q_Score":1,"Tags":"python,perl","A_Id":1557216,"CreationDate":"2009-10-12T20:22:00.000","Title":"Recommendations for perl-to-python interoperation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a sizable code base in Perl. For the forseeable future, our codebase will remain in Perl. However, we're looking into adding a GUI-based dashboard utility. We are considering writing the dashboard in Python (using tkinter or wx). The problem, however, is that we would like to leverage our existing Perl codebase in the Python GUI.\nSo... any suggestions on how achieve this? We are considering a few options:\n\nWrite executables (in Perl) that mimic function calls; invoke those Perl executables in python as system calls.\nWrite Perl executables on-the-fly inside the Python dashboard, and invoke the (temporary) Perl executable.\nFind some kind of Perl-to-Python converter or binding.\n\nAny other ideas? I'd love to hear if other people have confronted this problem. Unfortunately, it's not an option to convert the codebase itself to Python at this time.","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":406,"Q_Id":1556668,"Users Score":1,"Answer":"Interesting project: I would opt for loose-coupling and consider an XML-RPC or JSON based approach.","Q_Score":1,"Tags":"python,perl","A_Id":1560979,"CreationDate":"2009-10-12T20:22:00.000","Title":"Recommendations for perl-to-python interoperation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a sizable code base in Perl. For the forseeable future, our codebase will remain in Perl. However, we're looking into adding a GUI-based dashboard utility. We are considering writing the dashboard in Python (using tkinter or wx). The problem, however, is that we would like to leverage our existing Perl codebase in the Python GUI.\nSo... any suggestions on how achieve this? We are considering a few options:\n\nWrite executables (in Perl) that mimic function calls; invoke those Perl executables in python as system calls.\nWrite Perl executables on-the-fly inside the Python dashboard, and invoke the (temporary) Perl executable.\nFind some kind of Perl-to-Python converter or binding.\n\nAny other ideas? I'd love to hear if other people have confronted this problem. Unfortunately, it's not an option to convert the codebase itself to Python at this time.","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":406,"Q_Id":1556668,"Users Score":7,"Answer":"I hate to be another one in the chorus, but...\n\nAvoid the use of an alternate language\nUse Wx so it's native look and feel makes the application look \"real\" to non-technical audiences.\nDownload the Padre source code and see how it does Wx Perl code, then steal rampantly from it's best tricks or maybe just gut it and use the application skeleton (using the Artistic half of the Perl dual license to make it legal).\nBuild your own Strawberry Perl subclass to package the application as an MSI installer and push it out across the corporate Active Directory domain.\n\nOf course, I only say all this because you said \"Dashboard\" which I read as \"Corporate\", which then makes me assume a Microsoft AD network...","Q_Score":1,"Tags":"python,perl","A_Id":1557825,"CreationDate":"2009-10-12T20:22:00.000","Title":"Recommendations for perl-to-python interoperation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a user group using python on CentOS system. When I say 'using python' I mean I don't want to do something like os.system and give the unix command to create a new group. I would like to know if there is any python module that deals with this.\nSearching on the net did not reveal much about what I want, except for python user groups.. so I had to ask this.\nI learned about the grp module by searching here on SO, but couldn't find anything about creating a group.\nEDIT: I dont know if I have to start a new question for this, but I would also like to know how to add (existing) users to the newly created group.\nAny help appreciated.\nThank you.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":6393,"Q_Id":1570401,"Users Score":1,"Answer":"There are no library calls for creating a group. This is because there's really no such thing as creating a group. A GID is simply a number assigned to a process or a file. All these numbers exist already - there is nothing you need to do to start using a GID. With the appropriate privileges, you can call chown(2) to set the GID of a file to any number, or setgid(2) to set the GID of the current process (there's a little more to it than that, with effective IDs, supplementary IDs, etc).\nGiving a name to a GID is done by an entry in \/etc\/group on basic Unix\/Linux\/POSIX systems, but that's really just a convention adhered to by the Unix\/Linux\/POSIX userland tools. Other network-based directories also exist, as mentioned by Jack Lloyd.\nThe man page group(5) describes the format of the \/etc\/group file, but it is not recommended that you write to it directly. Your distribution will have policies on how unnamed GIDs are allocated, such as reserving certain spaces for different purposes (fixed system groups, dynamic system groups, user groups, etc). The range of these number spaces differs on different distributions. These policies are usually encoded in the command-line tools that a sysadmin uses to assign unnamed GIDs.\nThis means the best way to add a group locally is to use the command-line tools.","Q_Score":6,"Tags":"python,linux,usergroups","A_Id":1571882,"CreationDate":"2009-10-15T05:13:00.000","Title":"Create a user-group in linux using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a user group using python on CentOS system. When I say 'using python' I mean I don't want to do something like os.system and give the unix command to create a new group. I would like to know if there is any python module that deals with this.\nSearching on the net did not reveal much about what I want, except for python user groups.. so I had to ask this.\nI learned about the grp module by searching here on SO, but couldn't find anything about creating a group.\nEDIT: I dont know if I have to start a new question for this, but I would also like to know how to add (existing) users to the newly created group.\nAny help appreciated.\nThank you.","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":6393,"Q_Id":1570401,"Users Score":5,"Answer":"I think you should use the commandline programs from your program, a lot of care has gone into making sure that they don't break the groups file if something goes wrong. \nHowever the file format is quite straight forward to write something yourself if you choose to go that way","Q_Score":6,"Tags":"python,linux,usergroups","A_Id":1570429,"CreationDate":"2009-10-15T05:13:00.000","Title":"Create a user-group in linux using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a user group using python on CentOS system. When I say 'using python' I mean I don't want to do something like os.system and give the unix command to create a new group. I would like to know if there is any python module that deals with this.\nSearching on the net did not reveal much about what I want, except for python user groups.. so I had to ask this.\nI learned about the grp module by searching here on SO, but couldn't find anything about creating a group.\nEDIT: I dont know if I have to start a new question for this, but I would also like to know how to add (existing) users to the newly created group.\nAny help appreciated.\nThank you.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":6393,"Q_Id":1570401,"Users Score":11,"Answer":"I don't know of a python module to do it, but the \/etc\/group and \/etc\/gshadow format is pretty standard, so if you wanted you could just open the files, parse their current contents and then add the new group if necessary.\nBefore you go doing this, consider:\n\nWhat happens if you try to add a group that already exists on the system\nWhat happens when multiple instances of your program try to add a group at the same time\nWhat happens to your code when an incompatible change is made to the group format a couple releases down the line\nNIS, LDAP, Kerberos, ...\n\nIf you're not willing to deal with these kinds of problems, just use the subprocess module and run groupadd. It will be way less likely to break your customers machines.\nAnother thing you could do that would be less fragile than writing your own would be to wrap the code in groupadd.c (in the shadow package) in Python and do it that way. I don't see this buying you much versus just exec'ing it, though, and it would add more complexity and fragility to your build.","Q_Score":6,"Tags":"python,linux,usergroups","A_Id":1570448,"CreationDate":"2009-10-15T05:13:00.000","Title":"Create a user-group in linux using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","AnswerCount":13,"Available Count":5,"Score":0.0153834017,"is_accepted":false,"ViewCount":12544,"Q_Id":1581895,"Users Score":1,"Answer":"The way I solved this (actually I did this in Scala, not Python) was to use both a Set and a Queue, only adding links to the queue (and set) if they did not already exist in the set.\nBoth the set and queue were encapsulated in a single thread, exposing only a queue-like interface to the consumer threads.\nEdit: someone else suggested SQLite and that is also something I am considering, if the set of visited URLs needs to grow large. (Currently each crawl is only a few hundred pages so it easily fits in memory.) But the database is something that can also be encapsulated within the set itself, so the consumer threads need not be aware of it.","Q_Score":17,"Tags":"python,multithreading,queue","A_Id":1581902,"CreationDate":"2009-10-17T10:21:00.000","Title":"How check if a task is already in python Queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","AnswerCount":13,"Available Count":5,"Score":0.0153834017,"is_accepted":false,"ViewCount":12544,"Q_Id":1581895,"Users Score":1,"Answer":"SQLite is so simple to use and would fit perfectly... just a suggestion.","Q_Score":17,"Tags":"python,multithreading,queue","A_Id":1581903,"CreationDate":"2009-10-17T10:21:00.000","Title":"How check if a task is already in python Queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","AnswerCount":13,"Available Count":5,"Score":-0.0461211021,"is_accepted":false,"ViewCount":12544,"Q_Id":1581895,"Users Score":-3,"Answer":"Also, instead of a set you might try using a dictionary. Operations on sets tend to get rather slow when they're big, whereas a dictionary lookup is nice and quick.\nMy 2c.","Q_Score":17,"Tags":"python,multithreading,queue","A_Id":1581908,"CreationDate":"2009-10-17T10:21:00.000","Title":"How check if a task is already in python Queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","AnswerCount":13,"Available Count":5,"Score":0.0153834017,"is_accepted":false,"ViewCount":12544,"Q_Id":1581895,"Users Score":1,"Answer":"Why only use the array (ideally, a dictionary would be even better) to filter things you've already visited? Add things to your array\/dictionary as soon as you queue them up, and only add them to the queue if they're not already in the array\/dict. Then you have 3 simple separate things:\n\nLinks not yet seen (neither in queue nor array\/dict)\nLinks scheduled to be visited (in both queue and array\/dict)\nLinks already visited (in array\/dict, not in queue)","Q_Score":17,"Tags":"python,multithreading,queue","A_Id":1581920,"CreationDate":"2009-10-17T10:21:00.000","Title":"How check if a task is already in python Queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","AnswerCount":13,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":12544,"Q_Id":1581895,"Users Score":0,"Answer":"instead of \"array of pages already visited\" make an \"array of pages already added to the queue\"","Q_Score":17,"Tags":"python,multithreading,queue","A_Id":1582421,"CreationDate":"2009-10-17T10:21:00.000","Title":"How check if a task is already in python Queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to.\nI firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages.\nJust a simple example, using query pagination and insertion: when using Oracle one could use the FIRST_ROWS and APPEND hints(where appropriate). Going to advanced examples I could mention putting in the database lots of Stored Procedures\/Packages where it makes sense. And those are different for every RDBMS.\nBy using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers.\nSo getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines?\nI am especially interested hearing how you separate\/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it?\nLetting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":1586008,"Users Score":0,"Answer":"It would be great if code written for one platform would work on every other without any modification whatsoever, but this is usually not the case and probably never will be. What the current frameworks do is about all anyone can.","Q_Score":2,"Tags":"php,python,ruby-on-rails,database","A_Id":1586035,"CreationDate":"2009-10-18T20:56:00.000","Title":"PHP, Python, Ruby application with multiple RDBMS","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to.\nI firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages.\nJust a simple example, using query pagination and insertion: when using Oracle one could use the FIRST_ROWS and APPEND hints(where appropriate). Going to advanced examples I could mention putting in the database lots of Stored Procedures\/Packages where it makes sense. And those are different for every RDBMS.\nBy using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers.\nSo getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines?\nI am especially interested hearing how you separate\/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it?\nLetting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":369,"Q_Id":1586008,"Users Score":2,"Answer":"If you want to leverage the bells and whistles of various RDBMSes, you can certainly do it.  Just apply standard OO Principles.  Figure out what kind of API your persistence layer will need to provide.  \nYou'll end up writing a set of isomorphic persistence adapter classes.  From the perspective of your model code (which will be calling adapter methods to load and store data), these classes are identical.  Writing good test coverage should be easy, and good tests will make life a lot easier.  Deciding how much abstraction is provided by the persistence adapters is the trickiest part, and is largely application-specific.\nAs for whether this is worth the trouble: it depends.  It's a good exercise if you've never done it before.  It may be premature if you don't actually know for sure what your target databases are.  \nA good strategy might be to implement two persistence adapters to start.  Let's say you expect the most common back end will be MySQL.  Implement one adapter tuned for MySQL.  Implement a second that uses your database abstraction library of choice, and uses only standard and widely available SQL features.  Now you've got support for a ton of back ends (everything supported by your abstraction library of choice), plus tuned support for mySQL.  If you decide you then want to provide an optimized adapter from Oracle, you can implement it at your leisure, and you'll know that your application can support swappable database back-ends.","Q_Score":2,"Tags":"php,python,ruby-on-rails,database","A_Id":1586105,"CreationDate":"2009-10-18T20:56:00.000","Title":"PHP, Python, Ruby application with multiple RDBMS","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to.\nI firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages.\nJust a simple example, using query pagination and insertion: when using Oracle one could use the FIRST_ROWS and APPEND hints(where appropriate). Going to advanced examples I could mention putting in the database lots of Stored Procedures\/Packages where it makes sense. And those are different for every RDBMS.\nBy using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers.\nSo getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines?\nI am especially interested hearing how you separate\/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it?\nLetting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":369,"Q_Id":1586008,"Users Score":2,"Answer":"You cannot eat a cake and have it, choose on of the following options.\n\nUse your database abstraction layer whenever you can and in the rare cases when you have a need for a hand-made query (eg. performance reasons) stick to the lowest common denominator and don't use stored procedures or any proprietary extensions that you database has to offer. In this case deploying the application on a different RDBMS should be trivial.\nUse the full power of your expensive RDBMS, but take into account that your application won't be easily portable. When the need arises you will have to spend considerable effort on porting and maintenance. Of course a decent layered design encapsulating all the differences in a single module or class will help in this endeavor.\n\nIn other words you should consider how probable is it that your application will be deployed to multiple RDBMSes and make an informed choice.","Q_Score":2,"Tags":"php,python,ruby-on-rails,database","A_Id":1587887,"CreationDate":"2009-10-18T20:56:00.000","Title":"PHP, Python, Ruby application with multiple RDBMS","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a web server that is dynamically creating various reports in several formats (pdf and doc files). The files require a fair amount of CPU to generate, and it is fairly common to have situations where two people are creating the same report with the same input.\nInputs:\n\nraw data input as a string (equations, numbers, and\nlists of words), arbitrary length, almost 99% will be less than about 200 words \nthe version of the report creation tool\n\nWhen a user attempts to generate a report, I would like to check to see if a file already exists with the given input, and if so return a link to the file. If the file doesn't already exist, then I would like to generate it as needed.\n\nWhat solutions are already out there? I've cached simple http requests before, but the keys were extremely simple (usually database id's)\nIf I have to do this myself, what is the best way. The input can be several hundred words, and I was wondering how I should go about transforming the strings into keys sent to the cache.\n\/\/entire input, uses too much memory, one to one mapping\ncache['one two three four five six seven eight nine ten eleven...']\n\/\/short keys\ncache['one two'] => 5 results, then I must narrow these down even more\nIs this something that should be done in a database, or is it better done within the web app code (python in my case)\n\nThanks you everyone.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":1587991,"Users Score":2,"Answer":"This is what Apache is for.\nCreate a directory that will have the reports.\nConfigure Apache to serve files from that directory.\nIf the report exists, redirect to a URL that Apache will serve.\nOtherwise, the report doesn't exist, so create it.  Then redirect to a URL that Apache will serve.\n\nThere's no \"hashing\".  You have a key (\"a string (equations, numbers, and lists of words), arbitrary length, almost 99% will be less than about 200 words\") and a value, which is a file.  Don't waste time on a hash.  You just have a long key.\nYou can compress this key somewhat by making a \"slug\" out of it: remove punctuation, replace spaces with _, that kind of thing.\nYou should create an internal surrogate key which is a simple integer.\nYou're simply translating a long key to a \"report\" which either exists as a file or will be created as a file.","Q_Score":1,"Tags":"python","A_Id":1588007,"CreationDate":"2009-10-19T10:42:00.000","Title":"Caching system for dynamically created files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to learn object oriented programming, but am having a hard time overcoming my structured programming background (mainly C, but many others over time).  I thought I'd write a simple check register program as an exercise.  I put something together pretty quickly (python is a great language), with my data in some global variables and with a bunch of functions.  I can't figure out if this design can be improved by creating a number of classes to encapsulate some of the data and functions and, if so, how to change the design.\nMy data is basically a list of accounts ['checking', 'saving', 'Amex'], a list of categories ['food', 'shelter', 'transportation'] and lists of dicts that represent transactions [{'date':xyz, 'cat':xyz, 'amount':xyz, 'description':xzy].  Each account has an associated list of dicts.\nI then have functions at the account level (create-acct(), display-all-accts(), etc.) and the transaction level (display-entries-in-account(), enter-a-transaction(), edit-a-transaction(), display-entries-between-dates(), etc.)\nThe user sees a list of accounts, then can choose an account and see the underlying transactions, with ability to add, delete, edit, etc. the accounts and transactions.\nI currently implement everything in one large class, so that I can use self.variable throughout, rather than explicit globals.\nIn short, I'm trying to figure out if re-organizing this into some classes would be useful and, if so, how to design those classes.   I've read some oop books (most recently Object-Oriented Thought Process).  I like to think my existing design is readable and does not repeat itself.\nAny suggestions would be appreciated.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1625,"Q_Id":1604391,"Users Score":1,"Answer":"There are many 'mindsets' that you could adopt to help in the design process (some of which point towards OO and some that don't). I think it is often better to start with questions rather than answers (i.e. rather than say, 'how can I apply inheritance to this' you should ask how this system might expect to change over time).\nHere's a few questions to answer that might point you towards design principles:\n\nAre other's going to use this API? Are they likely to break it? (info hiding)\ndo I need to deploy this across many machines? (state management, lifecycle management)\ndo i need to interoperate with other systems, runtimes, languages? (abstraction and standards)\nwhat are my performance constraints? (state management, lifecycle management)\nwhat kind of security environment does this component live in? (abstraction, info hiding, interoperability)\nhow would i construct my objects, assuming I used some? (configuration, inversion of control, object decoupling, hiding implementation details)\n\nThese aren't direct answers to your question, but they might put you in the right frame of mind to answer it yourself. :)","Q_Score":6,"Tags":"python,oop","A_Id":1604426,"CreationDate":"2009-10-22T00:25:00.000","Title":"Object oriented design?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to learn object oriented programming, but am having a hard time overcoming my structured programming background (mainly C, but many others over time).  I thought I'd write a simple check register program as an exercise.  I put something together pretty quickly (python is a great language), with my data in some global variables and with a bunch of functions.  I can't figure out if this design can be improved by creating a number of classes to encapsulate some of the data and functions and, if so, how to change the design.\nMy data is basically a list of accounts ['checking', 'saving', 'Amex'], a list of categories ['food', 'shelter', 'transportation'] and lists of dicts that represent transactions [{'date':xyz, 'cat':xyz, 'amount':xyz, 'description':xzy].  Each account has an associated list of dicts.\nI then have functions at the account level (create-acct(), display-all-accts(), etc.) and the transaction level (display-entries-in-account(), enter-a-transaction(), edit-a-transaction(), display-entries-between-dates(), etc.)\nThe user sees a list of accounts, then can choose an account and see the underlying transactions, with ability to add, delete, edit, etc. the accounts and transactions.\nI currently implement everything in one large class, so that I can use self.variable throughout, rather than explicit globals.\nIn short, I'm trying to figure out if re-organizing this into some classes would be useful and, if so, how to design those classes.   I've read some oop books (most recently Object-Oriented Thought Process).  I like to think my existing design is readable and does not repeat itself.\nAny suggestions would be appreciated.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1625,"Q_Id":1604391,"Users Score":7,"Answer":"You don't have to throw out structured programming to do object-oriented programming. The code is still structured, it just belongs to the objects rather than being separate from them.\nIn classical programming, code is the driving force that operates on data, leading to a dichotomy (and the possibility that code can operate on the wrong data).\nIn OO, data and code are inextricably entwined - an object contains both data and the code to operate on that data (although technically the code (and sometimes some data) belongs to the class rather than an individual object). Any client code that wants to use those objects should do so only by using the code within that object. This prevents the code\/data mismatch problem.\nFor a bookkeeping system, I'd approach it as follows:\n\nLow-level objects are accounts and categories (actually, in accounting, there's no difference between these, this is a false separation only exacerbated by Quicken et al to separate balance sheet items from P&L - I'll refer to them as accounts only). An account object consists of (for example) an account code, name and starting balance, although in the accounting systems I've worked on, starting balance is always zero - I've always used a \"startup\" transaction to set the balanaces initially.\nTransactions are a balanced object which consist of a group of accounts\/categories with associated movements (changes in dollar value). By balanced, I mean they must sum to zero (this is the crux of double entry accounting). This means it's a date, description and an array or vector of elements, each containing an account code and value.\nThe overall accounting \"object\" (the ledger) is then simply the list of all accounts and transactions.\n\nKeep in mind that this is the \"back-end\" of the system (the data model). You will hopefully have separate classes for viewing the data (the view) which will allow you to easily change it, depending on user preferences. For example, you may want the whole ledger, just the balance sheet or just the P&L. Or you may want different date ranges.\nOne thing I'd stress to make a good accounting system. You do need to think like a bookkeeper. By that I mean lose the artificial difference between \"accounts\" and \"categories\" since it will make your system a lot cleaner (you need to be able to have transactions between two asset-class accounts (such as a bank transfer) and this won't work if every transaction needs a \"category\". The data model should reflect the data, not the view.\nThe only difficulty there is remembering that asset-class accounts have the opposite sign from which you expect (negative values for your cash-at-bank mean you have money in the bank and your very high positive value loan for that company sports car is a debt, for example). This will make the double-entry aspect work perfectly but you have to remember to reverse the signs of asset-class accounts (assets, liabilities and equity) when showing or printing the balance sheet.","Q_Score":6,"Tags":"python,oop","A_Id":1604427,"CreationDate":"2009-10-22T00:25:00.000","Title":"Object oriented design?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to learn object oriented programming, but am having a hard time overcoming my structured programming background (mainly C, but many others over time).  I thought I'd write a simple check register program as an exercise.  I put something together pretty quickly (python is a great language), with my data in some global variables and with a bunch of functions.  I can't figure out if this design can be improved by creating a number of classes to encapsulate some of the data and functions and, if so, how to change the design.\nMy data is basically a list of accounts ['checking', 'saving', 'Amex'], a list of categories ['food', 'shelter', 'transportation'] and lists of dicts that represent transactions [{'date':xyz, 'cat':xyz, 'amount':xyz, 'description':xzy].  Each account has an associated list of dicts.\nI then have functions at the account level (create-acct(), display-all-accts(), etc.) and the transaction level (display-entries-in-account(), enter-a-transaction(), edit-a-transaction(), display-entries-between-dates(), etc.)\nThe user sees a list of accounts, then can choose an account and see the underlying transactions, with ability to add, delete, edit, etc. the accounts and transactions.\nI currently implement everything in one large class, so that I can use self.variable throughout, rather than explicit globals.\nIn short, I'm trying to figure out if re-organizing this into some classes would be useful and, if so, how to design those classes.   I've read some oop books (most recently Object-Oriented Thought Process).  I like to think my existing design is readable and does not repeat itself.\nAny suggestions would be appreciated.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":1625,"Q_Id":1604391,"Users Score":3,"Answer":"\"My data is basically a list of accounts\"\nAccount is a class.\n\"dicts that represent transactions\"\nTransaction appears to be a class.  You happen to have elected to represent this as a dict.\nThat's your first pass at OO design.  Focus on the Responsibilities and Collaborators.\nYou have at least two classes of objects.","Q_Score":6,"Tags":"python,oop","A_Id":1604403,"CreationDate":"2009-10-22T00:25:00.000","Title":"Object oriented design?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the Python\/C API with my app and am wondering how you can get console output with a gui app. When there is a script error, it is displayed via printf but this obviously has no effect with a gui app. I want to be able to obtain the output without creating a console. Can this be done?\nEdit - Im using Windows, btw.\nEdit - The Python\/C library internally calls printf and does so before any script can be loaded and run. If there is an error I want to be able to get it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":173,"Q_Id":1604811,"Users Score":1,"Answer":"If by printf you mean exactly thqt call from C code, you need to redirect (and un-buffer) your standard output (file descriptor 0) to somewhere you can pick up the data from -- far from trivial, esp. in Windows, although maybe doable.  But why not just change that call in your C code to something more sensible?  (Worst case, a geprintf function of your own devising that mimics printf to build a string then directs that string appropriately).\nIf you actually mean print statements in Python code, it's much easier -- just set sys.stdout to an object with a write method accepting a string, and you can have that method do whatever you want, including logging, writing on a GUI windows, whatever you wish. Ah were it that simple at the C level!-)","Q_Score":0,"Tags":"python,user-interface","A_Id":1604842,"CreationDate":"2009-10-22T03:06:00.000","Title":"How to get output?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am new to python and haven't been able to find out whether this is possible or not.\nI am using the PyDev plugin under Eclipse, and basically all I want to find out is, is it possible to edit code whilst you're sitting at a breakpoint? I.e. Edit code whilst you're debugging.\nIt allows me to do this at present, but it seems to still be executing the line of code that previously existed before I made changes.\nAlso, are you able to drag program execution back like you can in VBA and C# for example?\nIf either of these are possible, how can I enable them?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1488,"Q_Id":1613927,"Users Score":2,"Answer":"You can run arbitrary commands in the console during the breakpoint.  For my needs, this typically achieves the same purpose as coding live, although I do wish it were as elegant as simply using the editor.","Q_Score":6,"Tags":"python,debugging,pydev","A_Id":6309211,"CreationDate":"2009-10-23T14:41:00.000","Title":"Python Debugging: code editing on the fly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python and haven't been able to find out whether this is possible or not.\nI am using the PyDev plugin under Eclipse, and basically all I want to find out is, is it possible to edit code whilst you're sitting at a breakpoint? I.e. Edit code whilst you're debugging.\nIt allows me to do this at present, but it seems to still be executing the line of code that previously existed before I made changes.\nAlso, are you able to drag program execution back like you can in VBA and C# for example?\nIf either of these are possible, how can I enable them?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1488,"Q_Id":1613927,"Users Score":2,"Answer":"When you start a Python program, it will be compiled into bytecode (and possibly saved as .pyc file). That means you can change the source but since you don't \"open\" the source again, the change won't be picked up.\nThere are systems like TurboGears (a web framework) which detect these changes and restart themselves but that's probably going to confuse the debugger.\nGoing back in time also isn't possible currently since the bytecode interpreter would need support for this.","Q_Score":6,"Tags":"python,debugging,pydev","A_Id":1614052,"CreationDate":"2009-10-23T14:41:00.000","Title":"Python Debugging: code editing on the fly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When writing code in Python, how can you write something next to it that explains what the code is doing, but which doesn't affect the code?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":419,"Q_Id":1614190,"Users Score":2,"Answer":"Write a comment? Python comments start with #.","Q_Score":1,"Tags":"python","A_Id":1614204,"CreationDate":"2009-10-23T15:24:00.000","Title":"How do I add text describing the code into a Python source file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know python and I'm a newibe with wx python but I would like to make a card game. \nHowever I have no idea how to make a image follow the mouse and put it in the middle of the screen when the program running. It will be nice if you guys can help me out.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":877,"Q_Id":1622884,"Users Score":2,"Answer":"Going through the wxPython demo and looking at all the examples would be a good start.  You'll likely find page Using Images | DragImage to be useful, since you'll probably want cards that you can drag.\nGenerally, the demo can help you do most things in wxPython, and also show you what wxPython can do, and it's worth the time to see every demo.  This approach works for everything except the very first step of getting an app running and putting a frame in it (since the demo itself is an app, but not a simple one).  Any of the basic tutorials can help you get started with an app and frame in just a very lines of code.","Q_Score":0,"Tags":"wxpython,drag,playing-cards","A_Id":1623027,"CreationDate":"2009-10-26T02:52:00.000","Title":"wx python card game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how I can make a script load powerpoint file, advance slides automatically and put it on full screen. Is there a way to make windows do that? Can I just load powerpoint.exe and maybe use some sort of API\/Pipe to give commands from another script.\nTo make a case: I'm making a script that automatically scans a folder in windows (using python) and loads up the powerpoint presentations and keeps playing them in order.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":4926,"Q_Id":1635565,"Users Score":1,"Answer":"Save the file with the extension \".pps\". That will make powerpoint open the file in presentation mode.\nThe presentaion needs to designed to advance slides, else you will have to script that part.","Q_Score":2,"Tags":"python,powerpoint","A_Id":1737489,"CreationDate":"2009-10-28T00:47:00.000","Title":"How do I make powerpoint play presentations\/load up ppts automatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a simple Python webserver that is easy to kill from within code. Right now, I'm playing with Bottle, but I can't find any way at all to kill it in code. If you know how to kill Bottle (in code, no Ctrl+C) that would be super, but I'll take anything that's Python, simple, and killable.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":410,"Q_Id":1643362,"Users Score":1,"Answer":"Raise exeption and handle it in main or use sys.exit","Q_Score":1,"Tags":"python","A_Id":1643387,"CreationDate":"2009-10-29T12:26:00.000","Title":"Killing Python webservers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When you have an object instance in C#, you can use the this keyword inside the instance scope. How does the compiler handles it? Is there any assistance for this at runtime?\nI am mainly wondering how C# does it vs in python you have to provide self for every function manually.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":334,"Q_Id":1645550,"Users Score":3,"Answer":"This is supported at the CLR level.  The argument variable at slot 0 represents the \"this\" pointer.  C# essentially generates calls to this as ldarg.0","Q_Score":2,"Tags":"c#,.net,python,clr","A_Id":1645603,"CreationDate":"2009-10-29T18:07:00.000","Title":"How this keyword is provided for object instances in C#?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.\nGiven the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking the inserts into chunks and compacting inbetween each, are there any techniques for avoiding the increase in file size?\nNote that no temporary tables are being created\/deleted during the process: just inserts into existing tables.\nAnd to forstall the inevitable comments: yes, I am required to store this data in Access 2003. No, I can't upgrade to Access 2007.\nIf it could help, I could preprocess in sqlite.\nEdit:\nJust to add some further information (some already listed in my comments):\n\nThe data is being generated in Python on a table by table basis, and then all of the records for that table batch inserted via odbc\nAll processing is happening in Python: all the mdb file is doing is storing the data\nAll of the fields being inserted are valid fields (none are being excluded due to unique key violations, etc.)\n\nGiven the above, I'll be looking into how to disable row level locking via odbc and considering presorting the data and\/or removing then reinstating indexes. Thanks for the suggestions.\nAny further suggestions still welcome.","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":3989,"Q_Id":1650856,"Users Score":1,"Answer":"Is your script executing a single INSERT statement per row of data? If so, pre-processing the data into a text file of many rows that could then be inserted with a single INSERT statement might improve the efficiency and cut down on the accumulating temporary crud that's causing it to bloat. \nYou might also make sure the INSERT is being executed without transactions. Whether or not that happens implicitly depends on the Jet version and the data interface library you're using to accomplish the task. By explicitly making sure it's off, you could improve the situation.\nAnother possibility is to drop the indexes before the insert, compact, run the insert, compact, re-instate the indexes, and run a final compact.","Q_Score":1,"Tags":"python,ms-access","A_Id":1652783,"CreationDate":"2009-10-30T16:21:00.000","Title":"MS-Access Database getting very large during inserts","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.\nGiven the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking the inserts into chunks and compacting inbetween each, are there any techniques for avoiding the increase in file size?\nNote that no temporary tables are being created\/deleted during the process: just inserts into existing tables.\nAnd to forstall the inevitable comments: yes, I am required to store this data in Access 2003. No, I can't upgrade to Access 2007.\nIf it could help, I could preprocess in sqlite.\nEdit:\nJust to add some further information (some already listed in my comments):\n\nThe data is being generated in Python on a table by table basis, and then all of the records for that table batch inserted via odbc\nAll processing is happening in Python: all the mdb file is doing is storing the data\nAll of the fields being inserted are valid fields (none are being excluded due to unique key violations, etc.)\n\nGiven the above, I'll be looking into how to disable row level locking via odbc and considering presorting the data and\/or removing then reinstating indexes. Thanks for the suggestions.\nAny further suggestions still welcome.","AnswerCount":6,"Available Count":4,"Score":-0.0333209931,"is_accepted":false,"ViewCount":3989,"Q_Id":1650856,"Users Score":-1,"Answer":"File --> Options --> Current Database -> Check below options\n* Use the Cache format that is compatible with Microsoft Access 2010 and later\n   * Clear Cache on Close\nThen, you file will be saved by compacting to the original size.","Q_Score":1,"Tags":"python,ms-access","A_Id":31059064,"CreationDate":"2009-10-30T16:21:00.000","Title":"MS-Access Database getting very large during inserts","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.\nGiven the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking the inserts into chunks and compacting inbetween each, are there any techniques for avoiding the increase in file size?\nNote that no temporary tables are being created\/deleted during the process: just inserts into existing tables.\nAnd to forstall the inevitable comments: yes, I am required to store this data in Access 2003. No, I can't upgrade to Access 2007.\nIf it could help, I could preprocess in sqlite.\nEdit:\nJust to add some further information (some already listed in my comments):\n\nThe data is being generated in Python on a table by table basis, and then all of the records for that table batch inserted via odbc\nAll processing is happening in Python: all the mdb file is doing is storing the data\nAll of the fields being inserted are valid fields (none are being excluded due to unique key violations, etc.)\n\nGiven the above, I'll be looking into how to disable row level locking via odbc and considering presorting the data and\/or removing then reinstating indexes. Thanks for the suggestions.\nAny further suggestions still welcome.","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":3989,"Q_Id":1650856,"Users Score":3,"Answer":"A common trick, if feasible with regard to the schema and semantics of the application, is to have several MDB files with Linked tables.\nAlso, the way the insertions take place matters with regards to the way the file size balloons...  For example: batched, vs. one\/few records at a time, sorted (relative to particular index(es)), number of indexes  (as you mentioned readily dropping some during the insert phase)...\nTentatively a pre-processing approach with say storing of new rows to a separate linked table, heap fashion (no indexes), then sorting\/indexing this data is a minimal fashion, and \"bulk loading\" it to its real destination.  Similar pre-processing in SQLite (has hinted in question) would serve the serve purpose. Keeping it \"ALL MDB\" is maybe easier (fewer languages\/processes to learn, fewer inter-op issues [hopefuly ;-)]...)\nEDIT: on why inserting records in a sorted\/bulk fashion may slow down the MDB file's growth (question from Tony Toews)\nOne of the reasons for MDB files' propensity to grow more quickly than the rate at which text\/data added to them (and their counterpart ability to be easily compacted back down) is that as information is added, some of the nodes that constitute the indexes have to be re-arranged (for overflowing \/ rebalancing etc.). Such management of the nodes seems to be implemented in a fashion which favors speed over disk space and harmony, and this approach typically serves simple applications \/ small data rather well. I do not know the specific logic in use for such management but I suspect that in several cases, node operations cause a particular node (or much of it) to be copied anew, and the old location simply being marked as free\/unused but not deleted\/compacted\/reused.  I do have \"clinical\" (if only a bit outdated) evidence that by performing inserts in bulk we essentially limit the number of opportunities for such duplication to occur and hence we slow the growth.\nEDIT again: After reading and discussing things from Tony Toews and Albert Kallal it appears that a possibly more significant source of bloat, in particular in Jet Engine 4.0, is the way locking is implemented. It is therefore important to set the database in single user mode to avoid this.  (Read Tony's and Albert's response for more details.","Q_Score":1,"Tags":"python,ms-access","A_Id":1650897,"CreationDate":"2009-10-30T16:21:00.000","Title":"MS-Access Database getting very large during inserts","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb.\nGiven the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking the inserts into chunks and compacting inbetween each, are there any techniques for avoiding the increase in file size?\nNote that no temporary tables are being created\/deleted during the process: just inserts into existing tables.\nAnd to forstall the inevitable comments: yes, I am required to store this data in Access 2003. No, I can't upgrade to Access 2007.\nIf it could help, I could preprocess in sqlite.\nEdit:\nJust to add some further information (some already listed in my comments):\n\nThe data is being generated in Python on a table by table basis, and then all of the records for that table batch inserted via odbc\nAll processing is happening in Python: all the mdb file is doing is storing the data\nAll of the fields being inserted are valid fields (none are being excluded due to unique key violations, etc.)\n\nGiven the above, I'll be looking into how to disable row level locking via odbc and considering presorting the data and\/or removing then reinstating indexes. Thanks for the suggestions.\nAny further suggestions still welcome.","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":3989,"Q_Id":1650856,"Users Score":3,"Answer":"One thing to watch out for is  records which are present in the append queries but aren't inserted into the data due to duplicate key values, null required fields, etc.  Access will allocate the space taken by the records which aren't inserted.\nAbout the only significant thing I'm aware of is to ensure you have exclusive access to the database file.  Which might be impossible if doing this during the day.   I noticed a change in behavior from Jet 3.51 (used in Access 97) to Jet 4.0 (used in Access 2000) when the Access MDBs started getting a lot larger when doing record appends.  I think that if the MDB is being used by multiple folks then records are inserted once per 4k page rather than as many as can be stuffed into a page.  Likely because this made index insert\/update operations faster. \nNow compacting does indeed put as many records in the same 4k page as possible but that isn't of help to you.","Q_Score":1,"Tags":"python,ms-access","A_Id":1651412,"CreationDate":"2009-10-30T16:21:00.000","Title":"MS-Access Database getting very large during inserts","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm interested how can be implemented recursive regexp matching in Python (I've not found any examples :( ). For example how would one write expression which matches \"bracket balanced\" string like \"foo(bar(bar(foo)))(foo1)bar1\"","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":8412,"Q_Id":1656859,"Users Score":4,"Answer":"You can't do it with a regexp. Python doesn't support recursive regexp","Q_Score":15,"Tags":"python,regex,recursion","A_Id":1656944,"CreationDate":"2009-11-01T10:48:00.000","Title":"How can a recursive regexp be implemented in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","AnswerCount":6,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":1621,"Q_Id":1666482,"Users Score":1,"Answer":"You can't assume it's installed. There are ways around that, you can fall back to distutils (but then why have setuptools in the first place) or you can install setuptools in setup.py (but I think that's evil).\nUse setuptools only if you need it.\nWhen it comes to setuptools vs distrubute, they are compatible, and choosing one over the other is mainly up to the user. The setup.py is identical.","Q_Score":3,"Tags":"python,deployment,setuptools,distutils","A_Id":1666911,"CreationDate":"2009-11-03T10:27:00.000","Title":"What if setuptools isn't installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","AnswerCount":6,"Available Count":5,"Score":0.1325487884,"is_accepted":false,"ViewCount":1621,"Q_Id":1666482,"Users Score":4,"Answer":"The standard way to distribute packages with setuptools includes an ez_setup.py script which will automatically download and install setuptools itself - on Windows I believe it will actually install an executable for easy_install. You can get this from the standard setuptools\/easy_install distribution.","Q_Score":3,"Tags":"python,deployment,setuptools,distutils","A_Id":1666595,"CreationDate":"2009-11-03T10:27:00.000","Title":"What if setuptools isn't installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":1621,"Q_Id":1666482,"Users Score":0,"Answer":"I would say it depends on what kind of user you are addressing.\nIf they are simply users and not Python programmers, or if they are basic programmers, using setuptools might be a little bit too much at first. For those the distutils is perfect.\nFor clients, I would definitely stick to distutils.\nFor more enthusiast programmers the setuptools would be fine.\nSomehow, it also depends on how you want to distribute updates, and how often. For example, do the users have an access to the Internet without a nasty proxy setup by their company that would block setuptools? - We do have one and it's an extra step to configure and make it work on every workstation.","Q_Score":3,"Tags":"python,deployment,setuptools,distutils","A_Id":1666606,"CreationDate":"2009-11-03T10:27:00.000","Title":"What if setuptools isn't installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":1621,"Q_Id":1666482,"Users Score":2,"Answer":"I have used setuptools to compile many python scripts that I have written into windows EXEs. However, it has always been my understanding (from experience) that the computer running the compiled EXE does not need to have setup tools installed.\nHope that helps","Q_Score":3,"Tags":"python,deployment,setuptools,distutils","A_Id":1698562,"CreationDate":"2009-11-03T10:27:00.000","Title":"What if setuptools isn't installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":1621,"Q_Id":1666482,"Users Score":2,"Answer":"In most librarys I ever installed for python, a warning apears \"You have to install setuptools\". You could do it as well I think, you could add a link so the user don't have to search the internet for it.","Q_Score":3,"Tags":"python,deployment,setuptools,distutils","A_Id":1666592,"CreationDate":"2009-11-03T10:27:00.000","Title":"What if setuptools isn't installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Using SUDS SOAP client how do I specify web service URL. I can see clearly that WSDL path is specified in Client constructor but what if I wan't to change web service url?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5956,"Q_Id":1670569,"Users Score":1,"Answer":"I think you have to create a new Client object for each different URL.","Q_Score":2,"Tags":"python,soap,suds","A_Id":1670775,"CreationDate":"2009-11-03T22:31:00.000","Title":"Changing web service url in SUDS library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python module re, how to get the equivalent of the \"\\w\" (which matches alphanumeric chars) WITHOUT matching the numeric characters (those which can be matched by \"[0-9]\")?\nNotice that the basic need is to match any character (including all unicode variation) without numerical chars (which are matched by \"[0-9]\").\nAs a final note, I really need a regexp as it is part of a greater regexp.\nUnderscores should not be matched.\nEDIT:\n\nI hadn't thought about underscores state, so thanks for warnings about this being matched by \"\\w\" and for the elected solution that addresses this issue.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6224,"Q_Id":1673749,"Users Score":36,"Answer":"You want [^\\W\\d]: the group of characters that is not (either a digit or not an alphanumeric). Add an underscore in that negated set if you don't want them either.\nA bit twisted, if you ask me, but it works. Should be faster than the lookahead alternative.","Q_Score":9,"Tags":"python,regex","A_Id":1673804,"CreationDate":"2009-11-04T13:30:00.000","Title":"How to match alphabetical chars without numeric chars with Python regexp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python (well, it's php now but we're rewriting) function that takes some parameters (A and B) and compute some results (finds best path from A to B in a graph, graph is read-only), in typical scenario one call takes 0.1s to 0.9s to complete. This function is accessed by users as a simple REST web-service (GET bestpath.php?from=A&to=B). Current implementation is quite stupid - it's a simple php script+apache+mod_php+APC, every requests needs to load all the data (over 12MB in php arrays), create all structures, compute a path and exit. I want to change it. \nI want a setup with N independent workers (X per server with Y servers), each worker is a python app running in a loop (getting request -> processing -> sending reply -> getting req...), each worker can process one request at a time. I need something that will act as a frontend: get requests from users, manage queue of requests (with configurable timeout) and feed my workers with one request at a time. \nhow to approach this? can you propose some setup? nginx + fcgi or wsgi or something else? haproxy? as you can see i'am a newbie in python, reverse-proxy, etc. i just need a starting point about architecture (and data flow)\nbtw. workers are using read-only data so there is no need to maintain locking and communication between them","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2509,"Q_Id":1674696,"Users Score":0,"Answer":"Another option is a queue table in the database.\nThe worker processes run in a loop or off cron and poll the queue table for new jobs.","Q_Score":4,"Tags":"python,nginx,load-balancing,wsgi,reverse-proxy","A_Id":1718183,"CreationDate":"2009-11-04T15:51:00.000","Title":"how to process long-running requests in python workers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python (well, it's php now but we're rewriting) function that takes some parameters (A and B) and compute some results (finds best path from A to B in a graph, graph is read-only), in typical scenario one call takes 0.1s to 0.9s to complete. This function is accessed by users as a simple REST web-service (GET bestpath.php?from=A&to=B). Current implementation is quite stupid - it's a simple php script+apache+mod_php+APC, every requests needs to load all the data (over 12MB in php arrays), create all structures, compute a path and exit. I want to change it. \nI want a setup with N independent workers (X per server with Y servers), each worker is a python app running in a loop (getting request -> processing -> sending reply -> getting req...), each worker can process one request at a time. I need something that will act as a frontend: get requests from users, manage queue of requests (with configurable timeout) and feed my workers with one request at a time. \nhow to approach this? can you propose some setup? nginx + fcgi or wsgi or something else? haproxy? as you can see i'am a newbie in python, reverse-proxy, etc. i just need a starting point about architecture (and data flow)\nbtw. workers are using read-only data so there is no need to maintain locking and communication between them","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2509,"Q_Id":1674696,"Users Score":0,"Answer":"I think you can configure modwsgi\/Apache so it will have several \"hot\" Python interpreters\nin separate processes ready to go at all times and also reuse them for new accesses\n(and spawn a new one if they are all busy).\nIn this case you could load all the preprocessed data as module globals and they would\nonly get loaded once per process and get reused for each new access.  In fact I'm not sure this isn't the default configuration\nfor modwsgi\/Apache.\nThe main problem here is that you might end up consuming\na lot of \"core\" memory (but that may not be a problem either).\nI think you can also configure modwsgi for single process\/multiple\nthread -- but in that case you may only be using one CPU because\nof the Python Global Interpreter Lock (the infamous GIL), I think.\nDon't be afraid to ask at the modwsgi mailing list -- they are very\nresponsive and friendly.","Q_Score":4,"Tags":"python,nginx,load-balancing,wsgi,reverse-proxy","A_Id":1675726,"CreationDate":"2009-11-04T15:51:00.000","Title":"how to process long-running requests in python workers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python (well, it's php now but we're rewriting) function that takes some parameters (A and B) and compute some results (finds best path from A to B in a graph, graph is read-only), in typical scenario one call takes 0.1s to 0.9s to complete. This function is accessed by users as a simple REST web-service (GET bestpath.php?from=A&to=B). Current implementation is quite stupid - it's a simple php script+apache+mod_php+APC, every requests needs to load all the data (over 12MB in php arrays), create all structures, compute a path and exit. I want to change it. \nI want a setup with N independent workers (X per server with Y servers), each worker is a python app running in a loop (getting request -> processing -> sending reply -> getting req...), each worker can process one request at a time. I need something that will act as a frontend: get requests from users, manage queue of requests (with configurable timeout) and feed my workers with one request at a time. \nhow to approach this? can you propose some setup? nginx + fcgi or wsgi or something else? haproxy? as you can see i'am a newbie in python, reverse-proxy, etc. i just need a starting point about architecture (and data flow)\nbtw. workers are using read-only data so there is no need to maintain locking and communication between them","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":2509,"Q_Id":1674696,"Users Score":1,"Answer":"The most simple solution in this case is to use the webserver to do all the heavy lifting. Why should you handle threads and\/or processes when the webserver will do all that for you?\nThe standard arrangement in deployments of Python is:\n\nThe webserver start a number of processes each running a complete python interpreter and loading all your data into memory.\nHTTP request comes in and gets dispatched off to some process\nProcess does your calculation and returns the result directly to the webserver and user\nWhen you need to change your code or the graph data, you restart the webserver and go back to step 1.\n\nThis is the architecture used Django and other popular web frameworks.","Q_Score":4,"Tags":"python,nginx,load-balancing,wsgi,reverse-proxy","A_Id":1682864,"CreationDate":"2009-11-04T15:51:00.000","Title":"how to process long-running requests in python workers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python (well, it's php now but we're rewriting) function that takes some parameters (A and B) and compute some results (finds best path from A to B in a graph, graph is read-only), in typical scenario one call takes 0.1s to 0.9s to complete. This function is accessed by users as a simple REST web-service (GET bestpath.php?from=A&to=B). Current implementation is quite stupid - it's a simple php script+apache+mod_php+APC, every requests needs to load all the data (over 12MB in php arrays), create all structures, compute a path and exit. I want to change it. \nI want a setup with N independent workers (X per server with Y servers), each worker is a python app running in a loop (getting request -> processing -> sending reply -> getting req...), each worker can process one request at a time. I need something that will act as a frontend: get requests from users, manage queue of requests (with configurable timeout) and feed my workers with one request at a time. \nhow to approach this? can you propose some setup? nginx + fcgi or wsgi or something else? haproxy? as you can see i'am a newbie in python, reverse-proxy, etc. i just need a starting point about architecture (and data flow)\nbtw. workers are using read-only data so there is no need to maintain locking and communication between them","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2509,"Q_Id":1674696,"Users Score":0,"Answer":"You could use nginx load balancer to proxy to PythonPaste paster (which serves WSGI, for example Pylons), that launches each request as separate thread anyway.","Q_Score":4,"Tags":"python,nginx,load-balancing,wsgi,reverse-proxy","A_Id":1676102,"CreationDate":"2009-11-04T15:51:00.000","Title":"how to process long-running requests in python workers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I get a reference to a module from within that module? Also, how can I get a reference to the package containing that module?","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":72566,"Q_Id":1676835,"Users Score":16,"Answer":"If you have a class in that module, then the __module__ property of the class is the module name of the class. Thus you can access the module via sys.modules[klass.__module__]. This is also works for functions.","Q_Score":187,"Tags":"python,self-reference","A_Id":1676861,"CreationDate":"2009-11-04T21:42:00.000","Title":"How to get a reference to a module inside the module itself?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I get a reference to a module from within that module? Also, how can I get a reference to the package containing that module?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":72566,"Q_Id":1676835,"Users Score":0,"Answer":"If all you need is to get access to module variable then use globals()['bzz'] (or vars()['bzz'] if it's module level).","Q_Score":187,"Tags":"python,self-reference","A_Id":70034466,"CreationDate":"2009-11-04T21:42:00.000","Title":"How to get a reference to a module inside the module itself?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a cross-platform function in python (or pytz) that returns a tzinfo object corresponding to the timezone currently set on the computer?\nenvironment variables cannot be counted on as they are not cross-platform","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32220,"Q_Id":1681143,"Users Score":0,"Answer":"Maybe try:\nimport time\nprint time.tzname  #or time.tzname[time.daylight]","Q_Score":34,"Tags":"python,datetime,time,timezone,pytz","A_Id":18385592,"CreationDate":"2009-11-05T15:08:00.000","Title":"how to get tz_info object corresponding to current timezone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to validate below data using regex and python.\nBelow is the dump of the data which Can be stored in string variable\n\nStart 0  .......... group=..... name=...... number=.... end=(digits)\nStart 1  .......... group=..... name=...... number=.... end=(digits)\nStart 2  .......... group=..... name=...... number=.... end=(digits)\nStart 3  .......... group=..... name=...... number=.... end=(digits)\n\nWhere ......is some random data need not to validate\n...\n..\n\nStart 100  .......... group=..... name=...... number=.... end=(digits)\n\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":1685558,"Users Score":1,"Answer":"You could use r'(Start \\d+.*?group=.*?name=.*?number=.*?end=\\d+)*'.","Q_Score":0,"Tags":"python","A_Id":1685597,"CreationDate":"2009-11-06T05:15:00.000","Title":"how to write regex for below format using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been developing in the Symfony framework for quite a time, but now I have to work with Django and I'm having problems with doing something like a \"component\" or \"partial\" in Symfony. \nThat said, here is my goal:\nI have a webpage with lots of small widgets, all these need their logic - located in a \"views.py\" I guess. But, how do I tell Django to call all this logic and render it all as one webpage?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":715,"Q_Id":1691400,"Users Score":1,"Answer":"Assuming you are going to be using the components in different places on different pages I would suggest trying {% include \"foo.html\" %}. One of the (several) downsides of the Django templating language is that there is no concept of macros, so you need to be very consistent in the names of values in the context you pass to your main template so that the included template finds things it's looking for.\nAlternatively, in the view you can invoke the template engine for each component and save the result in a value passed in the context. Then in the main template simply use the value in the context.\nI'm not fond of either of these approaches. The more complex your template needs become the more you may want to look at Jinja2. (And, no, I don't buy the Django Party Line about 'template designers' -- never saw one in my life.)","Q_Score":1,"Tags":"python,django,symfony1","A_Id":1691549,"CreationDate":"2009-11-07T00:21:00.000","Title":"How to implement Symfony Partials or Components in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to move an entity to another kind in appengine.\nSay you have a kind defines, and you want to keep a record of deleted entities of that kind.\nBut you want to separate the storage of live object and archived objects.\nKinds are basically just serialized dicts in the bigtable anyway. And maybe you don't need to index the archive in the same way as the live data.\nSo how would you make a move or copy of a entity of one kind to another kind.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":162,"Q_Id":1693815,"Users Score":1,"Answer":"Unless someone's written utilities for this kind of thing, the way to go is to read from one and write to the other kind!","Q_Score":0,"Tags":"python,google-app-engine,indexing,archive,bigtable","A_Id":1693856,"CreationDate":"2009-11-07T17:39:00.000","Title":"Move or copy an entity to another kind","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to move an entity to another kind in appengine.\nSay you have a kind defines, and you want to keep a record of deleted entities of that kind.\nBut you want to separate the storage of live object and archived objects.\nKinds are basically just serialized dicts in the bigtable anyway. And maybe you don't need to index the archive in the same way as the live data.\nSo how would you make a move or copy of a entity of one kind to another kind.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":1693815,"Users Score":1,"Answer":"No - once created, the kind is a part of the entity's immutable key. You need to create a new entity and copy everything across. One way to do this would be to use the low-level google.appengine.api.datastore interface, which treats entities as dicts.","Q_Score":0,"Tags":"python,google-app-engine,indexing,archive,bigtable","A_Id":1693979,"CreationDate":"2009-11-07T17:39:00.000","Title":"Move or copy an entity to another kind","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example...\nChicken is an animal.\nBurrito is a food.\nWordNet allows you to do \"is-a\"...the hiearchy feature.\nHowever, how do I know when to stop travelling up the tree? I want a LEVEL.\nThat is consistent.\nFor example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up.  Categorizing \"burrito\" as a \"thing\" is too broad, yet \"mexican wrapped food\" is too specific.  I want to go up the hiearchy or down..until the right LEVEL.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2585,"Q_Id":1695971,"Users Score":0,"Answer":"sorry, may I ask which tool could judge \"difficulty level\" of sentences?\nI wish to find out \"similar difficulty level\" of sentences for user to read.","Q_Score":6,"Tags":"python,text,nlp,words,wordnet","A_Id":58050062,"CreationDate":"2009-11-08T10:29:00.000","Title":"Does WordNet have \"levels\"? (NLP)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example...\nChicken is an animal.\nBurrito is a food.\nWordNet allows you to do \"is-a\"...the hiearchy feature.\nHowever, how do I know when to stop travelling up the tree? I want a LEVEL.\nThat is consistent.\nFor example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up.  Categorizing \"burrito\" as a \"thing\" is too broad, yet \"mexican wrapped food\" is too specific.  I want to go up the hiearchy or down..until the right LEVEL.","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":2585,"Q_Id":1695971,"Users Score":2,"Answer":"In order to get levels, you need to predefine the content of each level. An ontology often defines these as the immediate IS_A children of a specific concept, but if that is absent, you need to develop a method of that yourself.\nThe next step is to put a priority on each concept, in case you want to present only one category for each word. The priority can be done in multiple ways, for instance as the count of IS_A relations between the category and the word, or manually selected priorities for each category. For each word, you can then pick the category with the highest priority. For instance, you may want meat to be \"food\" rather than chemical substance.\nYou may also want to pick some words, that change priority if they are in the path. For instance, if you want some chemicals which are also food, to be announced as chemicals, but others should still be food.","Q_Score":6,"Tags":"python,text,nlp,words,wordnet","A_Id":1696133,"CreationDate":"2009-11-08T10:29:00.000","Title":"Does WordNet have \"levels\"? (NLP)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example...\nChicken is an animal.\nBurrito is a food.\nWordNet allows you to do \"is-a\"...the hiearchy feature.\nHowever, how do I know when to stop travelling up the tree? I want a LEVEL.\nThat is consistent.\nFor example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up.  Categorizing \"burrito\" as a \"thing\" is too broad, yet \"mexican wrapped food\" is too specific.  I want to go up the hiearchy or down..until the right LEVEL.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2585,"Q_Id":1695971,"Users Score":0,"Answer":"WordNet's hypernym tree ends with a single root synset for the word \"entity\". If you are using WordNet's C library, then you can get a while recursive structure for a synset's ancestors using traceptrs_ds, and you can get the whole synset tree by recursively following nextss and ptrlst pointers until you hit null pointers.","Q_Score":6,"Tags":"python,text,nlp,words,wordnet","A_Id":1717952,"CreationDate":"2009-11-08T10:29:00.000","Title":"Does WordNet have \"levels\"? (NLP)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example...\nChicken is an animal.\nBurrito is a food.\nWordNet allows you to do \"is-a\"...the hiearchy feature.\nHowever, how do I know when to stop travelling up the tree? I want a LEVEL.\nThat is consistent.\nFor example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up.  Categorizing \"burrito\" as a \"thing\" is too broad, yet \"mexican wrapped food\" is too specific.  I want to go up the hiearchy or down..until the right LEVEL.","AnswerCount":5,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":2585,"Q_Id":1695971,"Users Score":6,"Answer":"[Please credit Pete Kirkham, he first came with the reference to SUMO which may well answer the question asked by Alex, the OP]\n(I'm just providing a complement of information here; I started in a comment field but soon ran out of space and layout capabilites...)\nAlex: Most of SUMO is science or engineering? It does not contain every-day words like foods, people, cars, jobs, etc?\nPete K: SUMO is an upper ontology. The mid-level ontologies (where you would find concepts between 'thing' and 'beef burrito') listed on the page don't include food, but reflect the sorts of organisations which fund the project. There is a mid-level ontology for people. There's also one for industries (and hence jobs), including food suppliers, but no mention of burritos if you grep it.\nMy two cents\n100% of WordNet (3.0 i.e. the latest, as well as older versions) is mapped to SUMO, and that may just be what Alex need. The mid-level ontologies associated with SUMO (or rather with MILO) are effectively in specific domains, and do not, at this time, include Foodstuff, but since WordNet does (include all -well, many of- these everyday things) you do not need to leverage any formal ontology \"under\" SUMO, but instead use Sumo's WordNet mapping (possibly in addition to WordNet, which, again, is not an ontology but with its informal and loose \"hierarchy\" may also help.\nSome difficulty may arise, however, from two area (and then some ;-) ?):\n\nthe SUMO ontology's \"level\" may not be the level you'd have in mind for your particular application.  For example while \"Burrito\" brings \"Food\", at top level entity in SUMO  \"Chicken\" brings well \"Chicken\" which only through a long chain finds \"Animal\"  (specifically: Chicken->Poultry->Bird->Warm_Blooded_Vertebrae->Vertebrae->Animal).\nWordnet's coverage and metadata is impressive, but with regards to the mid-level concepts can be a bit inconsistent.  For example \"our\" Burrito's hypernym is appropriately \"Dish\", which provides it with circa 140 food dishes, which includes generics such as \"Soup\" or \"Casserole\" as well as \"Chicken Marengo\" (but omitting say \"Chicken Cacciatore\")\n\nMy point, in bringing up these issues, is not to criticize WordNet or SUMO and its related ontologies, but rather to illustrate simply some of the challenges associated with building ontology, particularly at the mid-level.\nRegardless of some possible flaws and lackings of a solution based on SUMO and WordNet, a pragmatic use of these frameworks may well \"fit the bill\" (85% of the time)","Q_Score":6,"Tags":"python,text,nlp,words,wordnet","A_Id":1698380,"CreationDate":"2009-11-08T10:29:00.000","Title":"Does WordNet have \"levels\"? (NLP)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a not-so-big project in django that will among other things incorporate a forum system.\nI have most of the system at a more or less functioning state, but I'm still missing a feature to mark unread threads for the users when there are new posts.\nThe thing is I can't really think of a way to properly store that information. My first idea was to create another model that will store a list of threads with changes in them for each user. Something with one ForeignKey(User) and one ForeignKey(Thread) and just keep adding new entries each time a thread is posted or a post is added to a thread.\nBut then, I'm not sure how well that would scale with say several hundred threads after a while and maybe 50-200 users. So add 200 rows for each new post for the users who aren't logged on? Sounds like a lot.\nHow do other forum systems do it anyway? And how can I implement a system to work these things out in Django.\nThanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":354,"Q_Id":1697045,"Users Score":1,"Answer":"You might also simply store the last time a user was reading a particular forum.  Any posts that have been updated since that date are new.  You'll only be storing one additional piece of information per user as opposed to a piece of information per post per user.","Q_Score":2,"Tags":"python,sql,django,database-design,database","A_Id":1697224,"CreationDate":"2009-11-08T16:24:00.000","Title":"Django\/SQL: keeping track of who who read what in a forum","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a not-so-big project in django that will among other things incorporate a forum system.\nI have most of the system at a more or less functioning state, but I'm still missing a feature to mark unread threads for the users when there are new posts.\nThe thing is I can't really think of a way to properly store that information. My first idea was to create another model that will store a list of threads with changes in them for each user. Something with one ForeignKey(User) and one ForeignKey(Thread) and just keep adding new entries each time a thread is posted or a post is added to a thread.\nBut then, I'm not sure how well that would scale with say several hundred threads after a while and maybe 50-200 users. So add 200 rows for each new post for the users who aren't logged on? Sounds like a lot.\nHow do other forum systems do it anyway? And how can I implement a system to work these things out in Django.\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":354,"Q_Id":1697045,"Users Score":2,"Answer":"You're much better off storing the \"read\" bit, not the \"unread\" bit.  And you can store them not as relational data, but in a giant bit-blob.  Then you don't have to modify the read data at all when new posts are added, only when a user reads posts.","Q_Score":2,"Tags":"python,sql,django,database-design,database","A_Id":1697061,"CreationDate":"2009-11-08T16:24:00.000","Title":"Django\/SQL: keeping track of who who read what in a forum","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...})\nAs this is a client-side app, I don't want to use a database server, I just want the info stored into files.\nI want the files to be readable from various languages (at least python and C++), so something language specific like python's pickle is out of the game.\nI am seeing two possibilities: sqlite and BerkeleyDB. As my use case is clearly not relational, I am tempted to go with BerkeleyDB, however I don't really know how I should use it to store my records, as it only stores key\/value pairs.\nIs my reasoning correct? If so, how should I use BDB to store my records? Can you link me to relevant info? Or am I missing a better solution?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":666,"Q_Id":1697153,"Users Score":2,"Answer":"BerkeleyDB is good, also look at the *DBM incarnations (e.g. GDBM).  The big question though is:  for what do you need to search?  Do you need to search by that URL, by a range of URLs or the dates you list?  \nIt is also quite possible to keep groups of records as simple files in the local filesystem, grouped by dates or search terms, &c.\nAnswering the \"search\" question is the biggest start.\nAs for the key\/value thingy, what you need to ensure is that the KEY itself is well defined as for your lookups.  If for example you need to lookup by dates sometimes and others by title, you will need to maintain a \"record\" row, and then possibly 2 or more \"index\" rows making reference to the original record.  You can model nearly anything in a key\/value store.","Q_Score":5,"Tags":"c++,python,database,persistence","A_Id":1697185,"CreationDate":"2009-11-08T17:01:00.000","Title":"Which database should I use to store records, and how should I use it?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...})\nAs this is a client-side app, I don't want to use a database server, I just want the info stored into files.\nI want the files to be readable from various languages (at least python and C++), so something language specific like python's pickle is out of the game.\nI am seeing two possibilities: sqlite and BerkeleyDB. As my use case is clearly not relational, I am tempted to go with BerkeleyDB, however I don't really know how I should use it to store my records, as it only stores key\/value pairs.\nIs my reasoning correct? If so, how should I use BDB to store my records? Can you link me to relevant info? Or am I missing a better solution?","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":666,"Q_Id":1697153,"Users Score":0,"Answer":"Ok, so you say just storing the data..? You really only need a DB for retrieval, lookup, summarising, etc. So, for storing, just use simple text files and append lines. Compress the data if you need to, use delims between fields - just about any language will be able to read such files. If you do want to retrieve, then focus on your retrieval needs, by date, by key, which keys, etc. If you want simple client side, then you need simple client db. SQLite is far easier than BDB, but look at things like Sybase Advantage (very fast and free for local clients but not open-source) or VistaDB or firebird... but all will require local config\/setup\/maintenance. If you go local XML for a 'sizable' number of records will give you some unnecessarily bloated file-sizes..!","Q_Score":5,"Tags":"c++,python,database,persistence","A_Id":1698109,"CreationDate":"2009-11-08T17:01:00.000","Title":"Which database should I use to store records, and how should I use it?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...})\nAs this is a client-side app, I don't want to use a database server, I just want the info stored into files.\nI want the files to be readable from various languages (at least python and C++), so something language specific like python's pickle is out of the game.\nI am seeing two possibilities: sqlite and BerkeleyDB. As my use case is clearly not relational, I am tempted to go with BerkeleyDB, however I don't really know how I should use it to store my records, as it only stores key\/value pairs.\nIs my reasoning correct? If so, how should I use BDB to store my records? Can you link me to relevant info? Or am I missing a better solution?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":666,"Q_Id":1697153,"Users Score":2,"Answer":"Personally I would use sqlite anyway.  It has always just worked for me (and for others I work with).  When your app grows and you suddenly do want to do something a little more sophisticated, you won't have to rewrite.\nOn the other hand, I've seen various comments on the Python dev list about Berkely DB that suggest it's less than wonderful; you only get dict-style access (what if you want to select certain date ranges or titles instead of URLs); and it's not even in Python 3's standard set of libraries.","Q_Score":5,"Tags":"c++,python,database,persistence","A_Id":1697239,"CreationDate":"2009-11-08T17:01:00.000","Title":"Which database should I use to store records, and how should I use it?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"does someone have an idea how to get the environment variables on Google-AppEngine ? \nI'm trying to write a simple Script that shall use the Client-IP (for Authentication) and a parameter (geturl or so) from the URL (for e.g. http:\/\/thingy.appspot.dom\/index?geturl=www.google.at)\nI red that i should be able to get the Client-IP via \"request.remote_addr\" but i seem to lack 'request' even tho i imported webapp from google.appengine.ext\nMany thanks in advance,\n Birt","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":461,"Q_Id":1700441,"Users Score":3,"Answer":"To answer the actual question from the title of your post, assuming you're still wondering: to get environment variables, simple import os and the environment is available in os.environ.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":1701239,"CreationDate":"2009-11-09T11:24:00.000","Title":"Environment on google Appengine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python's paster serve app.ini is taking longer than I would like to be ready for the first request. \nI know how to profile requests with middleware, but how do I profile the initialization time? I would like it to not fork a thread pool and quit as soon as it is ready to serve so the time after it's ready doesn't show up in the profile.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":545,"Q_Id":1702024,"Users Score":1,"Answer":"I almost always use paster serve --reload ... during development. That command executes itself as a subprocess (it executes its own script using the subprocess module, not fork()).\nThe subprocess polls for source code changes, quits when it detects a change, and gets restarted by the parent paster serve --reload.\nThat's to say if you're going to profile paster serve itself, omit the --reload argument. Profiling individual requests with middleware should work fine either way.\nMy particular problem was that pkg_resources takes an amount of time proportional to all installed packages when it is first invoked. I solved it by rebuilding my virtualenv without unnecessary packages.","Q_Score":2,"Tags":"python,performance,profiling,paster","A_Id":1710186,"CreationDate":"2009-11-09T16:11:00.000","Title":"How do I profile `paster serve`'s startup time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use Python to write a client that connects to a custom http server that uses digest authentication.  I can connect and pull the first request without problem.  Using TCPDUMP (I am on MAC OS X--I am both a MAC and a Python noob) I can see the first request is actually two http requests, as you would expect if you are familiar with RFC2617. The first results in the 401 UNAUTHORIZED.  The header information sent back from the server is correctly used to generate headers for a second request with some custom Authorization header values which yields a 200 OK response and the payload.\nEverything is great.  My HTTPDigestAuthHandler opener is working, thanks to urllib2. \nIn the same program I attempt to request a second, different page, from the same server.  I expect, per the RFC, that the TCPDUMP will show only one request this time, using almost all the same Authorization Header information (nc should increment).\nInstead it starts from scratch and first gets the 401 and regenerates the information needed for a 200.\nIs it possible with urllib2 to have subsequent requests with digest authentication recycle the known Authorization Header values and only do one request?\n[Re-read that a couple times until it makes sense, I am not sure how to make it any more plain]\nGoogle has yielded surprisingly little so I guess not.  I looked at the code for urllib2.py and its really messy (comments like: \"This isn't a fabulous effort\"), so I wouldn't be shocked if this was a bug.  I noticed that my Connection Header is Closed, and even if I set it to keepalive, it gets overwritten.  That led me to keepalive.py but that didn't work for me either.\nPycurl won't work either.\nI can hand code the entire interaction, but I would like to piggy back on existing libraries where possible.\nIn summary, is it possible with urllib2 and digest authentication to get 2 pages from the same server with only 3 http requests executed (2 for first page, 1 for second).\nIf you happen to have tried this before and already know its not possible please let me know.  If you have an alternative I am all ears.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1902,"Q_Id":1706644,"Users Score":1,"Answer":"Although it's not available out of the box, urllib2 is flexible enough to add it yourself. Subclass HTTPDigestAuthHandler, hack it (retry_http_digest_auth method I think) to remember authentication information and define an http_request(self, request) method to use it for all subsequent requests (add WWW-Authenticate header).","Q_Score":1,"Tags":"python,authentication,urllib2,digest","A_Id":1717241,"CreationDate":"2009-11-10T09:29:00.000","Title":"Client Digest Authentication Python with URLLIB2 will not remember Authorization Header Information","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to call a Python function from MATLAB. how can I do this?","AnswerCount":13,"Available Count":1,"Score":0.0461211021,"is_accepted":false,"ViewCount":132733,"Q_Id":1707780,"Users Score":3,"Answer":"Like Daniel said you can run python commands directly from Matlab using the py. command.  To run any of the libraries you just have to make sure Malab is running the python environment where you installed the libraries:\nOn a Mac:\n\nOpen a new terminal window;\ntype: which python (to find out where the default version of python is installed);\nRestart Matlab;\ntype: pyversion('\/anaconda2\/bin\/python'), in the command line (obviously replace with your path).\nYou can now run all the libraries in your default python installation. \n\nFor example:\n\n\npy.sys.version;\npy.sklearn.cluster.dbscan","Q_Score":76,"Tags":"python,matlab,language-interoperability","A_Id":50057490,"CreationDate":"2009-11-10T12:57:00.000","Title":"Call Python function from MATLAB","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Then how do I import that? I run everything in python 2.4, but one of my scripts import xml.etree.ElementTree...which is only Python 2.5","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1923,"Q_Id":1713398,"Users Score":4,"Answer":"Then it fails.\nYou can't import a python 2.5 library while you're running python 2.4. It won't work.\nWhy can't you run python 2.5+?","Q_Score":0,"Tags":"python,linux,unix","A_Id":1713411,"CreationDate":"2009-11-11T06:20:00.000","Title":"What if one of my programs runs in python 2.4, but IMPORTS something that requires python 2.5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, if I do time.sleep(100) and immediately hibernate my computer for 99 seconds, will the next statement be executed in 1 second or 100 seconds after waking up?\nIf the answer is 1 second, how do you \"sleep\" 100 seconds, regardless of the length of hibernate\/standby?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2094,"Q_Id":1725758,"Users Score":0,"Answer":"Clearly, you must sleep according to real, elapsed time.\nThe alternative (sleeping according to some other clock that \"somehow\" started and stopped) would be unmanageable.  How would your application (which is sleeping) be notified of all this starting and stopping activity?  Right, it would have to be woken up to be told that it was not supposed to run because the system was hibernating.\nOr, perhaps, some super-sophisticated OS-level scheduler could be used to determine if some time the system was \"busy\" vs. \"hibernating\" counted against the schedules of various sleeping processes.\nAll too complex.  \nIndeed, if you check carefully, sleep is pretty approximate and any Unix Signal will interrupt it.  So it's possible to wake early for lots of reasons.  Control-C being the big example.","Q_Score":2,"Tags":"python","A_Id":1725784,"CreationDate":"2009-11-12T22:07:00.000","Title":"time.sleep and suspend (ie. standby and hibernate)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can i get process id of the current process's parent?\nIn general given a process id how can I get its parent process id?\ne.g. os.getpid() can be used to get the proccess id, and os.getppid() for the parent, how do I get grandparent,\nMy target is linux(ubuntu) so platform specific answers are ok.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14912,"Q_Id":1728330,"Users Score":0,"Answer":"I do not think you can do this portably in the general case.\nYou need to get this information from the process list (e.g. through the ps command), which is obtained in a system-specific way.","Q_Score":7,"Tags":"python,linux,process,subprocess","A_Id":1728361,"CreationDate":"2009-11-13T10:13:00.000","Title":"How to get process's grandparent id","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having an issue with an embedded 64bit Python instance not liking PIL. Before i start exhausting more methods to get a compiled image editor to read the pixels for me (such as ImageMagick) i am hoping perhaps anyone here can think of a purely Python solution that will be comparable in speeds to the compiled counterparts.\nNow i am aware that the compiled friends will always be much faster, but i am hoping that because i \"just\" want to read the alpha of a group of pixels, that perhaps a fast enough pure Python solution can be conjured up. Anyone have any bright ideas?\nThough, i have tried PyPNG and that is far too slow, so i'm not expecting any magic solutions. None the less, i had to ask.\nThanks to any replies!\nAnd just for reference, the images i'll be reading will be on average around 512*512 to 2048*2048, and i'll be reading anywhere from one to all of the pixels alpha (multiplied by a few million times, but the values can be stored so reading twice isn't done).","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":955,"Q_Id":1732761,"Users Score":2,"Answer":"Getting data out of a PNG requires unpacking data and decompressing it.  These are likely going to be too slow in Python for your application.  One possibility is to start with PyPNG and get rid of anything in it that you don't need.  For example, it is probably storing all of the data it reads from the PNG, and some of the slow speed you see may be due to the memory allocations.","Q_Score":1,"Tags":"python,png","A_Id":1732962,"CreationDate":"2009-11-14T00:30:00.000","Title":"Reading Alpha of a PNG Pixel. Fast way via pure Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In ubuntu 9.10, in usr\/lib\/ there are the directories python2.4, python2.5, python2.6 and python3.0 \nOnly python 2.6 is actually working.\npython2.4 has only a lib-dynload directory,\npython2.5 has only lib-dynload and site-packages,\npython3.0 has only a dist-packages directory.  \nNow i'm wondering what is the idea behind this? \nBecause when i install python2.5 with .\/configure, make, make install | altinstall\nthis goes into usr\/local\/lib and not usr\/lib\/ so why were these directories added tu ubuntu, how am i supposed to install python to use them?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":10075,"Q_Id":1733364,"Users Score":1,"Answer":"Sounds like they're an accident from some package(s) you have installed.\nThe Python version in use determines the locations searched to find installed Python packages\/modules, and the \"system version\" of Python in Ubuntu 9.10 is 2.6, so that's what practically everything should be using.  If you were to install the python2.5 package (or it gets installed as a dependency of something else), then it would use \/usr\/lib\/python2.5\/*.  Try running which python and python --version; also which python2.6 and which python2.5.\nFrom what I understand, though I'm not sure exactly why at all, Debian (from which Ubuntu is derived) uses a dist-packages naming scheme instead of site-packages.\nTerminology: Python has packages and Debian (and so Ubuntu) has packages.  They aren't the same kind of package, though individual Debian packages will install specific Python packages.","Q_Score":3,"Tags":"python,ubuntu,installation","A_Id":1733409,"CreationDate":"2009-11-14T05:23:00.000","Title":"ubuntu9.10 : how to use python's lib-dynload and site-packages directories?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I im trying to store 30 second user mp3 recordings as Blobs in my app engine data store. However, in order to enable this feature (App Engine has a 1MB limit per upload) and to keep the costs down I would like to compress the file before upload and decompress the file every time it is requested.  How would you suggest I accomplish this (It can happen in the background by the way via a task queue but an efficient solution is always good)\nBased on my own tests and research - I see two possible approaches to accomplish this\n\nZlib \n\nFor this I need to compress a certain number of blocks at a time using a While loop.  However, App Engine doesnt allow you to write to the file system. I thought about using a Temporary File to accomplish this but I havent had luck with this approach when trying to decompress the content from a Temporary File\n\nGzip \n\nFrom reading around the web, it appears that the app engine url fetch function requests content gzipped already and then decompresses it.  Is there a way to stop the function from decompressing the content so that I can just put it in the datastore in gzipped format and then decompress it when I need to play it back to a user on demand?\nLet me know how you would suggest using zlib or gzip or some other solution to accmoplish this.  Thanks","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2545,"Q_Id":1739543,"Users Score":0,"Answer":"You can store up to 10Mb with a list of Blobs. Search for google file service.\nIt's much more versatile than BlobStore in my opinion, since I just started using BlobStore Api yesterday and I'm still figuring out if it is possible to access the data bytewise.. as in changing doc to pdf, jpeg to gif.. \nYou can storage Blobs of 1Mb * 10 = 10 Mb (max entity size I think), or you can use BlobStore API and get the same 10Mb or get 50Mb if you enable billing (you can enable it but if you don't pass the free quota you don't pay).","Q_Score":1,"Tags":"python,google-app-engine,compression,gzip,zlib","A_Id":2125539,"CreationDate":"2009-11-16T00:55:00.000","Title":"Compress data before storage on Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I im trying to store 30 second user mp3 recordings as Blobs in my app engine data store. However, in order to enable this feature (App Engine has a 1MB limit per upload) and to keep the costs down I would like to compress the file before upload and decompress the file every time it is requested.  How would you suggest I accomplish this (It can happen in the background by the way via a task queue but an efficient solution is always good)\nBased on my own tests and research - I see two possible approaches to accomplish this\n\nZlib \n\nFor this I need to compress a certain number of blocks at a time using a While loop.  However, App Engine doesnt allow you to write to the file system. I thought about using a Temporary File to accomplish this but I havent had luck with this approach when trying to decompress the content from a Temporary File\n\nGzip \n\nFrom reading around the web, it appears that the app engine url fetch function requests content gzipped already and then decompresses it.  Is there a way to stop the function from decompressing the content so that I can just put it in the datastore in gzipped format and then decompress it when I need to play it back to a user on demand?\nLet me know how you would suggest using zlib or gzip or some other solution to accmoplish this.  Thanks","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2545,"Q_Id":1739543,"Users Score":2,"Answer":"\"Compressing before upload\" implies doing it in the user's browser -- but no text in your question addresses that!  It seems to be about compression in your GAE app, where of course the data will only be after the upload.  You could do it with a Firefox extension (or other browsers' equivalents), if you can develop those and convince your users to install them, but that has nothing much to do with GAE!-)  Not to mention that, as @RageZ's comment mentions, MP3 is, essentially, already compressed, so there's little or nothing to gain (though maybe you could, again with a browser extension for the user, reduce the MP3's bit rate and thus the file's dimension, that could impact the audio quality, depending on your intended use for those audio files).\nSo, overall, I have to second @jldupont's suggestion (also in a comment) -- use a different server for storage of large files (S3, Amazon's offering, is surely a possibility though not the only one).","Q_Score":1,"Tags":"python,google-app-engine,compression,gzip,zlib","A_Id":1739598,"CreationDate":"2009-11-16T00:55:00.000","Title":"Compress data before storage on Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not familiar with PowerBuilder but I have a task to create Automatic UI Test Application for PB. We've decided to do it in Python with pywinauto and iaccesible libraries. The problem is that some UI elements like newly added lists record can not be accesed from it (even inspect32 can't get it). \nAny ideas how to reach this elements and make them testable?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3825,"Q_Id":1741023,"Users Score":2,"Answer":"I'm experimenting with code for a tool for automating PowerBuilder-based GUIs as well. From what I can see, your best bet would be to use the PowerBuilder Native Interface (PBNI), and call PowerScript code from within your NVO.\nIf you like, feel free to send me an email (see my profile for my email address), I'd be interested in exchanging ideas about how to do this.","Q_Score":6,"Tags":"python,testing,powerbuilder","A_Id":1741142,"CreationDate":"2009-11-16T09:23:00.000","Title":"How to make PowerBuilder UI testing application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not familiar with PowerBuilder but I have a task to create Automatic UI Test Application for PB. We've decided to do it in Python with pywinauto and iaccesible libraries. The problem is that some UI elements like newly added lists record can not be accesed from it (even inspect32 can't get it). \nAny ideas how to reach this elements and make them testable?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3825,"Q_Id":1741023,"Users Score":1,"Answer":"I've seen in AutomatedQa support that they a recipe recommending using msaa and setting some properties on the  controls. I do not know if it works.","Q_Score":6,"Tags":"python,testing,powerbuilder","A_Id":2328021,"CreationDate":"2009-11-16T09:23:00.000","Title":"How to make PowerBuilder UI testing application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to develop a project that uses a control model in Blender by using WinTracker machine, but I don't know how to connect it with Blender Game Engine. \nHow can I connect it with Blender Game Engine?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":1748482,"Users Score":0,"Answer":"You must write the plug-in for blender and used the wintracker driver. It is ready for c Lagrange.\nbut you have \"wintracker2\"?\nI wanted to buy it but the company said \"it's not ready to seal\".","Q_Score":0,"Tags":"python,blender","A_Id":2397249,"CreationDate":"2009-11-17T12:19:00.000","Title":"Python: Connect blender with WinTracker 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm noticing that my django development server (version 1.1.1) on my local windows7 machine is using a lot of CPU (~30%, according to task manager's python.exe entry), even in idle state, i.e. no request coming in\/going out. Is there an established way of analysing what might be responsible for this?\nThanks!\nMartin","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3645,"Q_Id":1750676,"Users Score":18,"Answer":"FWIW, you should do the profiling, but when you do I'll bet you find that the answer is \"polling for changes to your files so it can auto-reload.\" You might do a quick test with \"python manage.py runserver --noreload\" and see how that affects the CPU usage.","Q_Score":7,"Tags":"python,django,cpu","A_Id":1756874,"CreationDate":"2009-11-17T18:01:00.000","Title":"Django development server CPU intensive - how to analyse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm noticing that my django development server (version 1.1.1) on my local windows7 machine is using a lot of CPU (~30%, according to task manager's python.exe entry), even in idle state, i.e. no request coming in\/going out. Is there an established way of analysing what might be responsible for this?\nThanks!\nMartin","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3645,"Q_Id":1750676,"Users Score":4,"Answer":"Hit Control-C and crash the process. It will probably crash somewhere that it's spending a lot of time.\nOr you could use a profiler.","Q_Score":7,"Tags":"python,django,cpu","A_Id":1750793,"CreationDate":"2009-11-17T18:01:00.000","Title":"Django development server CPU intensive - how to analyse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with pysvn, and I'm trying to find a decent way to handle repositories that are only accessible via svn+ssh. Obviously SSH keys make this all incredibly easy, but I can't guarantee the end user will be using an SSH key. This also has to be able to run without user interaction, because it's going to be doing some svn log parsing.\nThe big issue is that, with svn+ssh an interactive prompt is popped up for authentication. Obviously I'd like to be able to have pysvn automatically login with a set of given credentials, but set_default_username and set_default_password aren't doing me any good in that respect. If I can't have that, I'd at least like to able to just fail out, and log a message to tell the user to setup an SSH key. However, set_interactive seems to have no bearing on this either, and I'm still prompted for a password with client.log('svn+ssh:\/\/path'). \nAny thoughts on how to tackle this issue? Is it even really possible to handle this without SSH keys, since it's SSH that's throwing the prompts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1664,"Q_Id":1772133,"Users Score":2,"Answer":"Check out ssh configuration option PasswordAuthentication.\nI'm not sure how pysvn interacts with ssh, but if you set this to no in your ~\/.ssh\/config (or maybe global config?) then it shouldn't prompt for a password.","Q_Score":5,"Tags":"python,svn,ssh,pysvn","A_Id":1773231,"CreationDate":"2009-11-20T17:41:00.000","Title":"pysvn with svn+ssh","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an existing Python 2.4 and it is working properly with tkinter as I tested it using \npython\nimport _tkinter\n\n\n\nimport Tkinter\n      Tkinter._test() \n\n\n\nNow, I have installed python 2.5.2 but when I try the same tests (with the newer version), it returns (but the same tests are working for the previous version)\nImportError: No module named _tkinter\nI know that tcl8.5 and tk8.5 are installed on my machine as the following commands return there locations\nwhereis tcl\ntcl: \/usr\/lib\/tcl8.4 \/usr\/local\/lib\/tcl8.5 \/usr\/local\/lib\/tcl8.4 \/usr\/share\/tcl8.4\nwhereis tk\ntk: \/usr\/lib\/tk8.4 \/usr\/local\/lib\/tk8.5 \/usr\/share\/tk8.4\nAny ideas how do I make my newer python version work with tkinter?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1073,"Q_Id":1773222,"Users Score":3,"Answer":"The files you found are for linking directly to tcl\/tk. Python depends on another library as well: _tkinter.so. It should be in \/usr\/lib\/python2.5\/lib-dynload\/_tkinter.so.\nHow did you install python2.5? If you are using Debian or Ubuntu you need to install the python-tk package to get Tkinter support.\nIf the _tkinter.so file is there, your environment could be causing problems.\nIf \n\npython -E -c \"import\n  Tkinter;Tkinter._test()\"\n\nsuceeds, but \n\npython -c \"import\n  Tkinter;Tkinter._test()\"\n\nfails, then the problem is with how your environment is set up. Check the value of PYTHONPATH is set correctly.","Q_Score":0,"Tags":"python,tcl,tkinter,tk","A_Id":1773435,"CreationDate":"2009-11-20T21:02:00.000","Title":"Linking Tcl\/Tk to Python 2.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am a engineering student and i have to do a lot of numerical processing, plots, simulations etc. The tool that i use currently is Matlab. I use it in my university computers for most of my assignments. However, i want to know what are the free options available. \ni have done some research and many have said that python is a worthy replacement for matlab in various scenarios. i want to know how to do all this with python. i am using a mac so how do i install the different python packages. what are those packages? is it really a viable alternative? what are the things i can and cannot do using this python setup?","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":15393,"Q_Id":1776290,"Users Score":13,"Answer":"I've been programming with Matlab for about 15 years, and with Python for about 10. It usually breaks down this way:\nIf you can satisfy the following conditions:\n    1. You primarily use matrices and matrix operations\n    2. You have the money for a Matlab license\n    3. You work on a platform that mathworks supports\nThen, by all means, use Matlab. Otherwise, if you have data structures other than matrices, want an open-source option that allows you to deliver solutions without worrying about licenses, and need to build on platforms that mathworks does not support; then, go with Python.\nThe matlab language is clunky, but the user interface is slick. The Python language is very nice -- with iterators, generators, and functional programming tools that matlab lacks; however, you will have to pick and choose to put together a nice slick interface if you don't like (or can't use) SAGE.\nI hope that helps.","Q_Score":18,"Tags":"python,matlab","A_Id":1777708,"CreationDate":"2009-11-21T18:24:00.000","Title":"replacing Matlab with python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an application running with debug=True on a remote host somewhere. Now somehow every time I access REMOTE_ADDR it returns 127.0.0.1 no matter where the request is from.\nI'm not sure where to start and why this is happening.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4509,"Q_Id":1779464,"Users Score":7,"Answer":"Do you have any kind of proxy, gateway, or load balancer running on that remote host? That's the sort of thing that would cause connections to appear to be from 127.0.0.1 (because that's where the immediate connection is from, as far as the web server is concerned).","Q_Score":2,"Tags":"python,django,http","A_Id":1779475,"CreationDate":"2009-11-22T18:10:00.000","Title":"Django: request.META['REMOTE_ADDR'] is always '127.0.0.1'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just starting out with Python and have practiced so far in the IDLE interface. Now I'd like to configure Python with MAMP so I can start creating really basic webapps \u2014\u00a0using Python inside HTML, or well, vice-versa. (I'm assuming HTML is allowed in Python, just like PHP? If not, are there any modules\/template engines for that?)\nWhat modules do I need to install to run .py from my localhost? Googling a bit, it seems there're various methods \u2014\u00a0mod_python, FastCGI etc.. which one should I use and how to install it with MAMP Pro 1.8.2?\nMany thanks","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":756,"Q_Id":1781431,"Users Score":2,"Answer":"You asked whether HTML is allowed within Python, which indicates that you still think too much in PHP terms about it. Contrary to PHP, Python was not designed to create dynamic web-pages. Instead, it was designed as a stand-alone, general-purpose programming language. Therefore you will not be able to put HTML into Python. There are some templating libraries which allow you to go the other way around, somewhat, but that's a completely different issue.\nWith things like Django or TurboGears or all the other web-frameworks, you essentially set up a small, stand-alone web-server (which comes bundled with the framework so you don't have to do anything), tell the server which function should handle what URL and then write those functions. In the simplest case, each URL you specify has its own function.\nThat 'handler function' (or 'view function' in Django terminology) receives a request object in which interesting info about the just-received request is contained. It then does whatever processing is required (a DB query for example). Finally, it produces some output, which is returned to the client. A typical way to get the output is to have some data passed to a template where it is rendered together with some HTML.\nSo, the HTML is separated in a template (in the typical case) and is not in the Python code.\nAbout Python 3: I think you will find that the vast majority of all Python development going on in the world is still with Python 2.*. As others have pointed out here, Python 3 is just coming out, most of the good stuff is not available for it yet, and you shouldn't be bothered about that.\nMy advise: Grab yourself Python 2.6 and Django 1.1 and dive in. It's fun.","Q_Score":1,"Tags":"python,html,web-applications,fastcgi,template-engine","A_Id":1784843,"CreationDate":"2009-11-23T06:28:00.000","Title":"Python for web scripting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any Python library or some sample code which demonstrates how to convert basic HTML into RML (Reportlab Markup Language www.reportlab.org)? I can think of using a regular HTML parser and adding some home grown code to generate the RML, but I guess there will be a lot of cases to handle in such a conversion.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2613,"Q_Id":1795349,"Users Score":1,"Answer":"You shouldn't have much trouble doing this.  Aside from some differences in element names, it's pretty straightforward:  just ignore any HTML elements that can't be easily converted\/you don't care about converting to RML and do the rest.  I'm sure the ReportLab folks would be glad if you contributed even a basic HTML to RML parser to the project.","Q_Score":2,"Tags":"python,reportlab","A_Id":1842295,"CreationDate":"2009-11-25T07:59:00.000","Title":"converting basic HTML to RML (Reportlab Markup Language)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"the normal behavior of urllib\/urllib2 is if an error code is sent in the header of the response (i.e 404) an Exception is raised. \nHow do you look for specific errors i.e (40x, or 50x) based on the different errors, do different things. Also, how do you read the actual data being returned HTML\/JSON etc (The data usually has error details which is different to the HTML error code)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5703,"Q_Id":1803741,"Users Score":1,"Answer":"In urllib2 HTTPError exception is also a valid HTTP response, so you can treat an HTTP error as an exceptional event or valid response. But in urllib you have to subclass URLopener and define http_error_<code> method[s] or redefine http_error_default to handle them all.","Q_Score":4,"Tags":"python,error-handling","A_Id":1803796,"CreationDate":"2009-11-26T13:43:00.000","Title":"Error codes returned by urllib\/urllib2 and the actual page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In the Python installation on my PC there is a sweet script in C:\\python26\\tools\\scripts called redemo.py. It's a simple tk application for testing regular expressions.\nI wish I could get it--or something like it--running on my Mac, but I don't know how. The script doesn't appear to be part of the Python installation on my Mac. Ideas?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":898,"Q_Id":1811236,"Users Score":0,"Answer":"Install Python on your Mac, then copy the script over? It should work fine on any Python installation.","Q_Score":4,"Tags":"python,regex","A_Id":1811244,"CreationDate":"2009-11-28T01:24:00.000","Title":"How can I run redemo.py (or equivalent) on a Mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to develop a desktop application framework in Python, much like QT, but how to go about it? Any tutorials or links related to it would be helpful!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":813,"Q_Id":1811940,"Users Score":2,"Answer":"Well the best way to start is to look at the source code of the framework the other answers are talking about.\nFirst, try to use them all to build the same application with the functionalities you expect from a framework. Them, look at how it works under the hood.\nSecondly, build your framework, starting by writing your first widgets, then notice the problems with your current architecture, and re factor. Start again, until you have something stable and usable.\nEventually, find out this was nice as training experience, but useless as a contribution to the software communities since you will never reach out the qualities of existing tools.\nThen give up and try to code your own MMORPG.","Q_Score":2,"Tags":"python,frameworks,desktop","A_Id":1813171,"CreationDate":"2009-11-28T08:04:00.000","Title":"I want to develop a framework in Python for desktop based applications. How should I go about it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Imagine you have a library for working with some sort of XML file or configuration file. The library reads the whole file into memory and provides methods for editing the content. When you are done manipulating the content you can call a write to save the content back to file. The question is how to do this in a safe way.\nOverwriting the existing file (starting to write to the original file) is obviously not safe. If the write method fails before it is done you end up with a half written file and you have lost data.\nA better option would be to write to a temporary file somewhere, and when the write method has finished, you copy the temporary file to the original file.\nNow, if the copy somehow fails, you still have correctly saved data in the temporary file. And if the copy succeeds, you can remove the temporary file.\nOn POSIX systems I guess you can use the rename system call which is an atomic operation. But how would you do this best on a Windows system? In particular, how do you handle this best using Python?\nAlso, is there another scheme for safely writing to files?","AnswerCount":8,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":9770,"Q_Id":1812115,"Users Score":4,"Answer":"The standard solution is this.\n\nWrite a new file with a similar name.  X.ext# for example.\nWhen that file has been closed (and perhaps even read and checksummed), then you two two renames.\n\nX.ext (the original) to X.ext~ \nX.ext# (the new one) to X.ext\n\n(Only for the crazy paranoids) call the OS sync function to force dirty buffer writes.  \n\nAt no time is anything lost or corruptable.  The only glitch can happen during the renames.  But you haven't lost anything or corrupted anything.  The original is recoverable right up until the final rename.","Q_Score":21,"Tags":"python,windows,file","A_Id":1812351,"CreationDate":"2009-11-28T09:46:00.000","Title":"How to safely write to a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Imagine you have a library for working with some sort of XML file or configuration file. The library reads the whole file into memory and provides methods for editing the content. When you are done manipulating the content you can call a write to save the content back to file. The question is how to do this in a safe way.\nOverwriting the existing file (starting to write to the original file) is obviously not safe. If the write method fails before it is done you end up with a half written file and you have lost data.\nA better option would be to write to a temporary file somewhere, and when the write method has finished, you copy the temporary file to the original file.\nNow, if the copy somehow fails, you still have correctly saved data in the temporary file. And if the copy succeeds, you can remove the temporary file.\nOn POSIX systems I guess you can use the rename system call which is an atomic operation. But how would you do this best on a Windows system? In particular, how do you handle this best using Python?\nAlso, is there another scheme for safely writing to files?","AnswerCount":8,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":9770,"Q_Id":1812115,"Users Score":17,"Answer":"If you see Python's documentation, it clearly mentions that os.rename() is an atomic operation. So in your case, writing data to a temporary file and then renaming it to the original file would be quite safe. \nAnother way could work like this:\n\nlet original file be abc.xml\ncreate abc.xml.tmp and write new data to it\nrename abc.xml to abc.xml.bak\nrename abc.xml.tmp to abc.xml\nafter new abc.xml is properly put in place, remove abc.xml.bak\n\nAs you can see that you have the abc.xml.bak with you which you can use to restore if there are any issues related with the tmp file and of copying it back.","Q_Score":21,"Tags":"python,windows,file","A_Id":1812604,"CreationDate":"2009-11-28T09:46:00.000","Title":"How to safely write to a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"is it possible to allow only one concurrent login per user in django application? if yes, how do you approach?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13565,"Q_Id":1814437,"Users Score":0,"Answer":"I'm going to assume that you mean logged in at once, and not one \"login\" at the same time.\nI've never written a Django application before. But one method I've used in other languages, is to store the session ID of the logged in user in their user row in the database.\nFor example, if you have a users table in your database, add a field \"session_id\" and then when the user logs in, set that to their current session_id. On every page load check to see if their current session matches the session_id in the users table. Remember whenever you regenerate their session_id in your application, you'll need to update the database so they don't get logged out.\nSome people when a user logs in, just store all the users details into a session and never re-call the database on a new page load. So for some this \"extra\" SQL query might seem wrong. For me, I always do a new query on each page load to re-authenticate the user and make sure their account wasn't removed\/suspended and to make sure their username\/password combo is still the same. (What if someone from another location changed the password, or an administrator?)","Q_Score":2,"Tags":"python,django","A_Id":1814465,"CreationDate":"2009-11-29T02:20:00.000","Title":"Allow only one concurrent login per user in django app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a script which needs the browser that selenium is operating close and re-open, without losing its cookies.\nAny idea on how to go about it?\nBasically, it's a check to see that if the user opens and closes his browser, his cookies stay intact.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1370,"Q_Id":1818969,"Users Score":3,"Answer":"You should be able to use the stop and start commands. You will need to ensure that you are not clearing cookies between sessions, and depending on the browser you're launching you may also need to use the -browserSessionReuse command line option.","Q_Score":1,"Tags":"python,selenium","A_Id":1819059,"CreationDate":"2009-11-30T10:20:00.000","Title":"Close and open a new browser in Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a script which needs the browser that selenium is operating close and re-open, without losing its cookies.\nAny idea on how to go about it?\nBasically, it's a check to see that if the user opens and closes his browser, his cookies stay intact.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1370,"Q_Id":1818969,"Users Score":0,"Answer":"This is a feature of the browser and not your concern: If there is a bug in the browser, then there is little you can do. If you need to know whether a certain version of the browser works correctly, then define a manual test (write a document that explains the steps), do it once and record the result somewhere (like \"Browser XXX version YYY works\").\nWhen you know that a certain browser (version) works, then that's not going to change, so there is no need to repeat the test.","Q_Score":1,"Tags":"python,selenium","A_Id":1819042,"CreationDate":"2009-11-30T10:20:00.000","Title":"Close and open a new browser in Selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My Application has a lot of calculation being done in JavaScript according to how and when the user acts on the application. The project prints out valuable information (through console calls) as to how this calculation is going on, and so we can easily spot any NaNs creeping in.\nWe are planning to integrate Selenium (RC with python) to test or project, but if we could get the console output messages in the python test case, we can identify any NaNs or even any miscalculations.\nSo, is there a way that Selenium can absorb these outputs (preferably in a console-less environment)?\nIf not, I would like to know if I can divert the console calls, may be by rebinding the console variable to something else, so that selenium can get that output and notify the python side. Or if not console, is there any other way that I can achieve this.\nI know selenium has commands like waitForElementPresent etc., but I don't want to show these intermediate calculations on the application, or is it the only way?\nAny help appreciated.\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2109,"Q_Id":1819903,"Users Score":1,"Answer":"If you are purely testing that the JavaScript functions are performing the correct calculations with the given inputs, I would suggest separating your JavaScript from your page and use a JavaScript testing framework to test the functionality.  Testing low level code using Selenium is a lot of unnecessary overhead.  If you're going against the fully rendered page, this would require your application to be running to a server, which should not be a dependency of testing raw JavaScript.\nWe recently converted our application from using jsUnit to use YUI Test and it has been promising so far.  We run about 150 tests in both FireFox and IE in less than three minutes.  Our testing still isn't ideal - we still test a lot of JavaScript the hard way using Selenium.  However, moving some of the UI tests to YUI Test has saved us a lot of time in our Continuous Integration environment.","Q_Score":3,"Tags":"javascript,python,testing,selenium,selenium-rc","A_Id":1902514,"CreationDate":"2009-11-30T13:42:00.000","Title":"Javascript communication with Selenium (RC)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've started messing around with Google App Engine, writing Python.\nI love Visual Studio for many reasons, but currently my .py files just look like text.\nI've searched the web looking for a way to get it to highlight python files (intellisense would be a nice bonus, but not required) but turned up nothing.\nThere are other questions on SO about this, but all the answers point at different IDEs, or installing IronPythonStudio (which seems overkill since I only want to colouring, and it might behave differently being geared at .NET anyway).\nDoes anyone know how to simple get VS to highlight Python? Is it really that uncommon? :(","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2992,"Q_Id":1828040,"Users Score":1,"Answer":"Thanks for all the responses. I did scan through some Python IDEs (and their screenshots) and decided to check out IronPythonStudio. My .py files now get colour coded nicely, and there's some intellisense :) Unfortunately Ctrl+K,D doesn't work, but it's much nicer to code than the plain yellow text I had earlier.\nFor anyone that's a massive Visual Studio fanboy like me, IronPythonStudio is definitely better than just coding it as text ;o)","Q_Score":2,"Tags":"python,visual-studio,google-app-engine","A_Id":1828477,"CreationDate":"2009-12-01T18:38:00.000","Title":"Python syntax highlighting \/ Intellisense?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1\/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.\nHow would I go about doing this?\nThere doesn't seem to be an existing free or proprietary program to do so, so I was thinking I might try and make a simple(if inefficient) one.\nThe basic idea I have is to make a function from the current hex\/decimal\/binary values used for each character to the 128 values I would have in the seven bit encoding, then scan through the file and write each modified value to a new file.\nSo if the file looked like(I'll use a decimal example because I try not to have to think in hex)\n127 254 025 212 015 015 132...\nIt would become\n001 002 003 004 005 005 006\nIf 127 mapped to 001, 254 mapped to 005, etc.\nI'm not entirely sure on a couple things, though.\n\nWould this be enough to actually shorten the filesize? I have a bad feeling this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space.\nIf this would happen, how do I get rid of the zero?\nHow do I open the file to read\/write in binary\/decimal\/hex rather than just text?\nI've mostly worked with Python, but I can muddle through C if I must.\n\nThank you.","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":2837,"Q_Id":1837686,"Users Score":18,"Answer":"Just use gzip compression, and save 60-70% with 0% effort!","Q_Score":2,"Tags":"python,c,utf-8,compression","A_Id":1837697,"CreationDate":"2009-12-03T04:43:00.000","Title":"Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1\/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.\nHow would I go about doing this?\nThere doesn't seem to be an existing free or proprietary program to do so, so I was thinking I might try and make a simple(if inefficient) one.\nThe basic idea I have is to make a function from the current hex\/decimal\/binary values used for each character to the 128 values I would have in the seven bit encoding, then scan through the file and write each modified value to a new file.\nSo if the file looked like(I'll use a decimal example because I try not to have to think in hex)\n127 254 025 212 015 015 132...\nIt would become\n001 002 003 004 005 005 006\nIf 127 mapped to 001, 254 mapped to 005, etc.\nI'm not entirely sure on a couple things, though.\n\nWould this be enough to actually shorten the filesize? I have a bad feeling this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space.\nIf this would happen, how do I get rid of the zero?\nHow do I open the file to read\/write in binary\/decimal\/hex rather than just text?\nI've mostly worked with Python, but I can muddle through C if I must.\n\nThank you.","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2837,"Q_Id":1837686,"Users Score":0,"Answer":"\"this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space.\"\nCorrect.  Your plan will do nothing.","Q_Score":2,"Tags":"python,c,utf-8,compression","A_Id":1839384,"CreationDate":"2009-12-03T04:43:00.000","Title":"Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1\/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.\nHow would I go about doing this?\nThere doesn't seem to be an existing free or proprietary program to do so, so I was thinking I might try and make a simple(if inefficient) one.\nThe basic idea I have is to make a function from the current hex\/decimal\/binary values used for each character to the 128 values I would have in the seven bit encoding, then scan through the file and write each modified value to a new file.\nSo if the file looked like(I'll use a decimal example because I try not to have to think in hex)\n127 254 025 212 015 015 132...\nIt would become\n001 002 003 004 005 005 006\nIf 127 mapped to 001, 254 mapped to 005, etc.\nI'm not entirely sure on a couple things, though.\n\nWould this be enough to actually shorten the filesize? I have a bad feeling this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space.\nIf this would happen, how do I get rid of the zero?\nHow do I open the file to read\/write in binary\/decimal\/hex rather than just text?\nI've mostly worked with Python, but I can muddle through C if I must.\n\nThank you.","AnswerCount":6,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":2837,"Q_Id":1837686,"Users Score":-2,"Answer":"What you need is UTF-7.\nEdit: UTF-7 has the advantage of bloating \"only\" special characters, so if special characters are rare in the input, you get far less bytes than by just converting UTF-8 to 7 bit. That's what UTF-7 is for.","Q_Score":2,"Tags":"python,c,utf-8,compression","A_Id":1838614,"CreationDate":"2009-12-03T04:43:00.000","Title":"Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":0,"Answer":"I'm not too familiar with Python so I'll give some general advice. Make sure to print out some reference pages of common functions. Keep them by you(or pinned to a wall or desk) at all times when your programming.. I'm traditionally a \"stone age\" developer and after developing in VS for a few months I'm finding my hobby programming is difficult without intellisense.. but keep at it to memorize the most common functions and eventually it'll just be natural\nYou'll also have to get use to a bit more \"difficult\" of debugging(not sure how that works with python)\nWhile your learning though, you should enjoy the goodness(at least compared to C#) of Python even if you don't have intellisense.. hopefully this will motivate you!","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1843265,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.024994793,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":2,"Answer":"You could always start with IronPython and continue to develop in Visual Studio.","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1843298,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.012499349,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":1,"Answer":"Same way you do anything else that doesn't have IntelliStuff.\nI'm betting you wrote that question without the aid of an IntelliEnglish computer program that showed you a list of verbs you could use and automatically added punctuation at the end of your sentences, for example.  :-)","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1844168,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":0,"Answer":"I've only ever used IDLE for python development and it is not fun in the least.  I would recommend getting your favorite text editor, mine is notepad++, and praying for a decent plugin for it.  I only ever had to go from Eclipse to Visual Studio so my opinions are generally invalid in these contexts.","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1843273,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.0624187467,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":5,"Answer":"One step at a time?\nStart off with simple programs (things you can write with your eyes closed in C#), and keep going... You will end up knowing the API by heart.","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1843269,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.012499349,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":1,"Answer":"Don't worry about intellisense. Python is really simple and there really isn't that much to know, so after a few projects you'll be conceiving of python code while driving, eating, etc., without really even trying. Plus, python's built in text editor (IDLE) has a wimpy version of intellisense that has always been more than sufficient for my purposes. If you ever go blank and want to know what methods\/properties and object has, just type this in an interactive session:\ndir(myobject)","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1843406,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.024994793,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":2,"Answer":"The python ide from wingware is pretty nice.  Thats what I ended up using going from visual studio C++\/.net to doing python.","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1843362,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.049958375,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":4,"Answer":"<rant>\nThis is sort of the reason that I think being a good visual studio user makes you a bad developer. Instead of learning an API, you look in the object browser until you find something that sounds more or less like what you are looking for, instantiate it, then hit . and start looking for what sounds like the right thing to use. While this is very quick, it also means it takes forever to learn an API in any depth, which often means you end up either re-inventing the wheel (because the wheel is buried under a mountain worth of household appliances and you had no idea it was there), or just doing things in a sub-optimal way. Just because you can find A solution quickly, doesn't mean it is THE BEST solution.\n<\/rant>\nIn the case of .NET, which ships with about a billion APIs for everything under the sun, this is actually preferred. You need to sift through a lot of noise to find what you are aiming for.\nPythonic code favors one, obvious way to do any given thing. This tends to make the APIs very straight forward and readable. The trick is to learn the language and learn the APIs. It is not terribly hard to do, especially in the case of python, and while not being able to rely on intellisense may be jarring at first, it shouldn't take more then a week or two before you get used to it not being there. \nLearn the language and the basic standard libraries with a good book. When it comes to a new library API, I find the REPL and some exploratory coding can get me to a pretty good understanding of what is going on fairly quickly.","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1843434,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.0,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":0,"Answer":"I suggest going cold turkey - languages like Python shine with great text editors. Choose one you want to become amazing at (vim, emacs, etc.) and never look back.","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":1847072,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i feel like i'm going back to the stone age.\nhow do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","AnswerCount":16,"Available Count":10,"Score":0.012499349,"is_accepted":false,"ViewCount":10335,"Q_Id":1843219,"Users Score":1,"Answer":"A mistake people coming from C# or Java make a lot is recreate a large class hierarchy like is common in those languages. With Python this is almost never useful. Instead, learn about duck typing. And don't worry too much about the lack of static typing: in practice, it's almost never an issue.","Q_Score":9,"Tags":"c#,python,visual-studio,transition","A_Id":38883895,"CreationDate":"2009-12-03T21:57:00.000","Title":"how to transition from C# to python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to learn how to use XMPP and to create a simple web application with real collaboration features.\nI am writing the application with Python(WSGI), and the application will require javascript enabled because I am going to use jQuery or Dojo.\nI have downloaded Openfire for the server and which lib to choose? SleekXMPP making trouble with tlslite module(python 2.5 and I need only python 2.6).\nWhat is your suggestion?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1373,"Q_Id":1847120,"Users Score":0,"Answer":"I have found a lot of issues with Openfire and TLS are not with the xmpp lib :( -- SleekXMPP in the trunk has been converted to Python 3.0 and the branch is maintained for Python 2.5\nUnlike Julien, I would only go with Twisted Words if you really need the power of Twisted or if you are already using Twisted.  IMO SleekXMPP offers the closest match to the current XEP's in use today.","Q_Score":3,"Tags":"javascript,python,xmpp,wsgi","A_Id":1881020,"CreationDate":"2009-12-04T14:02:00.000","Title":"Best XMPP Library for Python Web Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to pyglet and i have a problem with video..\nI'm trying to play a video using pyglet .. but instead of playing the video in the window it just exits immediately and terminates ..\ndo you guys have any solution for this problem how can i hold the window to play vedio?? \n i use windows vista 64x with python 2.5\nplease help \nand here is the code :\n\n\n\n\nvidPath=\"vid.avi\"\n      widnow = pyglet.window.Window()\n      source = pyglet.media.StreamingSource()\n      MediaLoad = pyglet.media.load(vidPath)\n      player = pyglet.media.Player()\n      player.queue(MediaLoad)\n      player.play()\n@window.event\n      ...def on_draw():\n      ...  player.get_texture.blit(0,0)\n\n\n\n\nthank u very much for your time","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4199,"Q_Id":1859195,"Users Score":0,"Answer":"I think calling \"pyglet.app.run()\" is missing.","Q_Score":1,"Tags":"python,video,pyglet","A_Id":1860559,"CreationDate":"2009-12-07T10:38:00.000","Title":"problem with pyglet playing video","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I don't see any possibility for creating a table in django-cms. I need this functionnality so I am evaluating the possibility to write my own plugin.\nI am getting started with this product. I've read the documentation carefully and I see more or less how to do that.\nHowever, I would be happy to hear some tips and tricks before starting this task. Does anybody have experience with django-cms plugin?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1710,"Q_Id":1861267,"Users Score":1,"Answer":"This all depends on your model. Plugins use standard django admin features.\nThis also depends on the source data for the table. \nIf you have a CSV or Exel sheet as source i only would make a file field and render the file in the render function with some optional caching.\nIf you want to enter data by hand:\nA Table model.\nAn Row model with a foreign key to table.\nThe row model can then be used as a django-admin Inline. So you can add new rows as needed.\nBe aware that CMSPluginBase extends ModelAdmin so you can define inlines like you would do in normal admin.","Q_Score":1,"Tags":"python,django,django-cms","A_Id":1872391,"CreationDate":"2009-12-07T16:52:00.000","Title":"Writing my own django-cms plugin. Any recommendations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Question for Python 2.6\nI would like to create an simple web application which in specified time interval will run a script that modifies the data (in database). My problem is code for infinity loop or some other method to achieve this goal. The script should be run only once by the user. Next iterations should run automatically, even when the user leaves the application. If someone have idea for method detecting apps breaks it would be great to show it too. I think that threads can be the best way to achive that. Unfortunately, I just started my adventure with Python and don't know yet how to use them. \nThe application will have also views showing database and for control of loop script.\nAny ideas?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":283,"Q_Id":1870140,"Users Score":0,"Answer":"Can you use cron to schedule the job to run at certain intervals? It's usually considered better than infinite loops, and was designed to help solve this sort of problem.","Q_Score":1,"Tags":"python,google-app-engine,cron","A_Id":1870164,"CreationDate":"2009-12-08T21:59:00.000","Title":"Render in infinity loop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a chat application. So far I am adding chat messages with jquery $.post() and this works fine.\nNow I need to retrieve the latest chat message from the table and append the list on the chat page.\nI am new to Django, so please go slow.\nSo how do I get data from the chat table back to the chat page?\nThanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":5349,"Q_Id":1879872,"Users Score":2,"Answer":"Since you're already using an AJAX post, why don't you return the data from that and insert it into the div?  The view that accepts the post can return a rendered template or JSON, and your javascript can insert it in the callback.","Q_Score":8,"Tags":"jquery,python,ajax,django,django-templates","A_Id":1879991,"CreationDate":"2009-12-10T09:42:00.000","Title":"DJANGO : Update div with AJAX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python code computing a matrix, and I would like to use this matrix (or array, or list) from C code.\nI wanted to pickle the matrix from the python code, and unpickle it from c code, but I could not find documentation or example on how to do this.\nI found something about marshalling data, but nothing about unpickling from C.\nEdit :\nCommenters Peter H asked if I was working with numpy arrays. The answer is yes.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1690,"Q_Id":1881851,"Users Score":0,"Answer":"take a look at module struct ?","Q_Score":1,"Tags":"python,c","A_Id":1881867,"CreationDate":"2009-12-10T15:41:00.000","Title":"How to unpickle from C code","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"So I know how to print a floating point number with a certain decimal places.\nMy question is how to return it with a specified number of decimal places?\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3481,"Q_Id":1896722,"Users Score":2,"Answer":"Floating point numbers have infinite number of decimal places. The physical representation on the computer is dependent on the representation of float, or double, or whatever and is dependent on a) language b) construct, e.g. float, double, etc. c) compiler implementation d) hardware.\nNow, given that you have a representation of a floating point number (i.e. a real) within a particular language, is your question how to round it off or truncate it to a specific number of digits? \nThere is no need to do this within the return call, since you can always truncate\/round afterwards. In fact, you would usually not want to truncate until actually printing, to preserve more precision. An exception might be if you wanted to ensure that results were consistent across different algorithms\/hardware, ie. say you had some financial trading software that needed to pass unit tests across different languages\/platforms etc.","Q_Score":0,"Tags":"python,floating-point","A_Id":1896737,"CreationDate":"2009-12-13T14:46:00.000","Title":"How to return a float point number with a defined number of decimal places?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I know how to print a floating point number with a certain decimal places.\nMy question is how to return it with a specified number of decimal places?\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3481,"Q_Id":1896722,"Users Score":4,"Answer":"In order to get two decimal places, multiply the number by 100, floor it, then divide by 100.\nAnd note that the number you will return will not really have only two decimal places because division by 100 cannot be represented exactly in IEEE-754 floating-point arithmetic most of the time. It will only be the closest representable approximation to a number with only two decimal places.","Q_Score":0,"Tags":"python,floating-point","A_Id":1896729,"CreationDate":"2009-12-13T14:46:00.000","Title":"How to return a float point number with a defined number of decimal places?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a collection of Unix scripts (and\/or Python modules) that each perform a long running task. I would like to provide a web interface for them that does the following:\n\nAsks for relevant data to pass into scripts.\nAllows for starting\/stopping\/killing them.\nAllows for monitoring the progress and\/or other information provided by the scripts.\nPossibly some kind of logging (although the scripts already do logging).\n\nI do know how to write a server that does this (e.g. by using Python's built-in HTTP server\/JSON), but doing this properly is non-trivial and I do not want to reinvent the wheel.\nAre there any existing solutions that allow for maintaining asynchronous server-side tasks?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":257,"Q_Id":1897748,"Users Score":1,"Answer":"Django is great for writing web applications, and the subprocess module (subprocess.Popen en .communicate()) is great for executing shell scripts. You can give it a stdin,stdout and stderr stream for communication if you want.","Q_Score":2,"Tags":"python,http,unix,asynchronous","A_Id":1897759,"CreationDate":"2009-12-13T21:07:00.000","Title":"Executing server-side Unix scripts asynchronously","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In python how to implement a thread which runs in the background (may be when the module loads) and calls the function every minute Monday to Friday 10 AM to 3 PM. For example the function should be called at:\n10:01 AM\n10:02 AM\n10:03 AM\n.\n.\n2:59 PM\nAny pointers?\nEnvironment: Django\nThanks","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3634,"Q_Id":1902338,"Users Score":4,"Answer":"Django is a server application, which only reacts to external events.\nYou should use a scheduler like cron to create events that call your django application, either calling a management subcommand or doing an HTTP request on some special page.","Q_Score":1,"Tags":"python,django,multithreading,scheduling","A_Id":1902471,"CreationDate":"2009-12-14T17:38:00.000","Title":"How to implement time event scheduler in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This might sound really crazy, but still...\nFor our revamped project site, we want to integrate Trac (as code browser, developer wiki and issue tracker) into the site design. That is, of course, difficult, since Trac is written in Python and our site in PHP. Does anybody here know a way how to integrate a header and footer (PHP) into the Trac template (preferrably without invoking a - or rather two for header and footer - PHP process from the command line)?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2293,"Q_Id":1907782,"Users Score":0,"Answer":"Your Python code will have access to your users' cookies. A template would be best, but if you don't have one available (or the header\/footer are trivially small, or whatever), you can simply port the PHP header and footer code to Python, using the cookies that are already there to query the database or whatever you need to do.\nIf you want to retain your links for logging in, registering, and whatever else might be in the PHP version, simply link to the PHP side, then redirect back to Trac once PHP's done its job.","Q_Score":4,"Tags":"php,python,integration,trac","A_Id":1909272,"CreationDate":"2009-12-15T14:21:00.000","Title":"Integrate Python app into PHP site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This might sound really crazy, but still...\nFor our revamped project site, we want to integrate Trac (as code browser, developer wiki and issue tracker) into the site design. That is, of course, difficult, since Trac is written in Python and our site in PHP. Does anybody here know a way how to integrate a header and footer (PHP) into the Trac template (preferrably without invoking a - or rather two for header and footer - PHP process from the command line)?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2293,"Q_Id":1907782,"Users Score":1,"Answer":"The best option probably is to (re)write the header and footer using python.\nIf the header and footer are relatively static you can also generate them once using php (or once every x minutes) and include them from the filesystem. (You probably already thought about this and dismissed the idea because your sites are too dynamic to use this option?)\nWhile I would not really recommend it you could also use some form of AJAX to load parts of the page, and nothing prevents you from loading this content from a php based system. That could keep all parts dynamic. Your pages will probably look ugly while loading, and you now generate more hits on the server than needed, but if it is nog a big site this might be a big.\nWarning: If you have user logins on both systems you will probably run into problems with people only being logged in to half of your site.","Q_Score":4,"Tags":"php,python,integration,trac","A_Id":1907850,"CreationDate":"2009-12-15T14:21:00.000","Title":"Integrate Python app into PHP site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem with virtualenv. I use it regulary, I use it on my development machine and on several servers. But on this last server I tried to use i got a problem.\nI created a virtualenv with the --no-site-packages argument, and then I installed some python modules inside the virtualenv. I can confirm that the modules is located inside the virtualenvs site-packages and everything seems to be fine.\nBut when i try to do:source virtualenv\/bin\/activate and then import one of the module python import modulename i get an import error that says that the module doesnt exist. How is it that this is happending? It seems like it never activates even thoug that it says it do.\nAnybody have a clue on how to fix this?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":24484,"Q_Id":1909025,"Users Score":20,"Answer":"Is there a bash alias active on this machine for \"python\", by any chance? That will take priority over the PATH-modifications made by activate, and could cause the wrong python binary to be used.\nTry running virtualenv\/bin\/python directly (no need to activate) and see if you can import your module.\nIf this fixes it, you just need to get rid of your python bash alias.","Q_Score":10,"Tags":"python,virtualenv","A_Id":1910294,"CreationDate":"2009-12-15T17:26:00.000","Title":"Import error with virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm developing on Snow Leopard and going through the various \"how tos\" to get the MySQLdb package installed and working (uphill battle).  Things are a mess and I'd like to regain confidence with a fresh, clean, as close to factory install of Python 2.6.\nWhat folders should I clean out?  \nWhat should I run?\nWhat symbolic links should I destroy or create?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":29101,"Q_Id":1909249,"Users Score":0,"Answer":"when doing an \"port selfupdate\", rsync timesout with rsync.macports.org. There are mirror sites available to use.","Q_Score":20,"Tags":"python,macos,osx-snow-leopard","A_Id":23410716,"CreationDate":"2009-12-15T18:03:00.000","Title":"How to clean up my Python Installation for a fresh start","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing on Snow Leopard and going through the various \"how tos\" to get the MySQLdb package installed and working (uphill battle).  Things are a mess and I'd like to regain confidence with a fresh, clean, as close to factory install of Python 2.6.\nWhat folders should I clean out?  \nWhat should I run?\nWhat symbolic links should I destroy or create?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":29101,"Q_Id":1909249,"Users Score":1,"Answer":"My experience doing development on MacOSX is that the directories for libraries and installation tools are just different enough to cause a lot of problems that you end up having to fix by hand. Eventually, your computer becomes a sketchy wasteland of files and folders duplicated all over the place in an effort to solve these problems. A lot of hand-tuned configuration files, too. The thought of getting my environment set up again from scratch gives me the chills.\nThen, when it's time to deploy, you've got to do it over again in reverse (unless you're deploying to an XServe, which is unlikely).\nLearn from my mistake: set up a Linux VM and do your development there. At least, run your development \"server\" there, even if you edit the code files on your Mac.","Q_Score":20,"Tags":"python,macos,osx-snow-leopard","A_Id":1909283,"CreationDate":"2009-12-15T18:03:00.000","Title":"How to clean up my Python Installation for a fresh start","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python 2.5 on windows. All I am doing is unpickling a large file (18MB - a list of dictionaries) and modifiying some of its values. Now this works fine. But when I add a couple of prints, IDLE restarts. And weirdly enough it seems to be happening where I added the print. I figured this out commenting and uncommenting things line by line. I added a try catch around the print, but am not able to catch anything. \nWhen does IDLE restart? And how do I catch any exceptions or errors it throws(if it does)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":705,"Q_Id":1911615,"Users Score":0,"Answer":"Enable the debugger and see if it tells you anything.","Q_Score":0,"Tags":"python,python-idle","A_Id":1911639,"CreationDate":"2009-12-16T01:04:00.000","Title":"Python: How do I find why IDLE restarts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm playing around with property in Python and I was wondering how this @propertyName.deleter decorator works. I'm probably missing something, I could not find clear answers by Google. \nWhat I would like to achieve is when this deleter behavior is called, I can trigger other actions (e.g: using my 3d application SDK).\nFor now just a simple print() doesn't seem to get triggered.\nIs deleter fired when I delete the property using del(instance.property) ?\nOtherwise, how can I achieve this?\n\n\nclass M():\n\n    def __init__(self):\n        self._m = None\n\n    @property\n    def mmm(self):\n        return self._m\n\n    @mmm.setter\n    def mmm(self, val):\n        self._m = val\n\n    @mmm.deleter\n    def mmm(self):\n        print('deleting') # Not printing\n        del(self._m)\n\n\n\n\nif __name__ == '__main__':\n\n    i = M()\n    i.mmm = 150\n    print(i.mmm)\n    del(i.mmm)\n    print(i.mmm)\n\n\n\nThank you very much (:","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":13562,"Q_Id":1912229,"Users Score":9,"Answer":"In Python 3 you WOULD see the print's result -- and then an AttributeError for the last print (because _m has disappeared).  You may be using Python 2.6, in which case you need to change the class clause to class M(object): to make M new-style, and then you'll get the same behavior as in Python 3.","Q_Score":16,"Tags":"python,properties,decorator","A_Id":1912265,"CreationDate":"2009-12-16T04:11:00.000","Title":"deleter decorator using Property in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":40688,"Q_Id":1912351,"Users Score":18,"Answer":"create a reusable app that include your generic functions so you can share between projects.\nuse for example a git repo to store this app and manage deployments and evolution (submodule)\nuse a public git repo so you can share with the community :)","Q_Score":80,"Tags":"python,django","A_Id":1914081,"CreationDate":"2009-12-16T04:44:00.000","Title":"Django: Where to put helper functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":40688,"Q_Id":1912351,"Users Score":13,"Answer":"If they are related to a specific app, I usually just put them in the related app folder and name the file, 'functions.py'.\nIf they're not specific to an app, I make a commons app for components (tests, models, functions, etc) that are shared across apps.","Q_Score":80,"Tags":"python,django","A_Id":1912371,"CreationDate":"2009-12-16T04:44:00.000","Title":"Django: Where to put helper functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":40688,"Q_Id":1912351,"Users Score":2,"Answer":"I am using new python file service.py in app folder. The file contains mostly helper queries for specific app. Also I used to create a folder inside Django application that contains global helper functions and constants.","Q_Score":80,"Tags":"python,django","A_Id":13270468,"CreationDate":"2009-12-16T04:44:00.000","Title":"Django: Where to put helper functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i would like to use pyPdf to split a pdf file based on the outline where each destination in the outline refers to a different page within the pdf. \nexample outline:\n\nmain       --> points to page 1\n  sect1    --> points to page 1\n  sect2    --> points to page 15\n  sect3    --> points to page 22\n\nit is easy within pyPdf to iterate over each page of the document or each destination in the document's outline; however, i cannot figure out how to get the page number where the destination points.\ndoes anybody know how to find the referencing page number for each destination in the outline?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5099,"Q_Id":1918420,"Users Score":0,"Answer":"Darrell's class can be modified slightly to produce a multi-level table of contents for a pdf (in the manner of pdftoc in the pdftk toolkit.) \nMy modification adds one more parameter to _setup_page_id_to_num, an integer \"level\" which defaults to 1. Each invocation increments the level. Instead of storing just the page number in the result, we store the pair of page number and level. Appropriate modifications should be applied when using the returned result. \nI am using this to implement the \"PDF Hacks\" browser-based page-at-a-time document viewer with a sidebar table of contents which reflects LaTeX section, subsection etc bookmarks. I am working on a shared system where pdftk can not be installed but where python is available.","Q_Score":5,"Tags":"python,pdf,pypdf","A_Id":6202708,"CreationDate":"2009-12-16T23:00:00.000","Title":"split a pdf based on outline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need some code to get the address of the socket i just created (to filter out packets originating from localhost on a multicast network)\nthis:\nsocket.gethostbyname(socket.gethostname())\nworks on mac but it returns only the localhost IP in linux... is there anyway to get the LAN address\nthanks\n--edit--\nis it possible to get it from the socket settings itself, like, the OS has to select a LAN IP to send on... can i play on getsockopt(... IP_MULTICAST_IF...) i dont know exactly how to use this though...?\n--- edit ---\nSOLVED!\nsend_sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, 0)\nputting this on the send socket eliminated packet echos to the host sending them, which eliminates the need for the program to know which IP the OS has selected to send.\nyay!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":626,"Q_Id":1925974,"Users Score":0,"Answer":"quick answer - socket.getpeername() (provided that socket is a socket object, not a module)\n(playing around in python\/ipython\/idle\/... interactive shell is very helpful)\n.. or if I read you question carefully, maybe socket.getsockname() :)","Q_Score":0,"Tags":"python,sockets,ip-address","A_Id":1926048,"CreationDate":"2009-12-18T02:49:00.000","Title":"How to get the LAN IP that a socket is sending (linux)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a python application that runs several subprocesses using subprocess.Popen objects.\nI have a glade GUI and want to display the output of these commands (running in subprocess.Popen) in the gui in real time.\nCan anyone suggest a way to do this? What glade object do I need to use and how to redirect the output?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3524,"Q_Id":1929018,"Users Score":1,"Answer":"glade is only a program to build gui with gtk so when you ask for a glade object maybe you should ask for gtk widget and in this case textbuffer and textview chould be a solution or maybe treeview and liststore.\nsubprocess.Popen has stdout and stderr arguments that can accept a file-like object. you can create an adapter that writes to the textbuffer or add items in the liststore","Q_Score":2,"Tags":"python,user-interface,glade","A_Id":1929138,"CreationDate":"2009-12-18T15:55:00.000","Title":"Python GUI (glade) to display output of shell process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a python web crawler and I want to distribute the download requests among many different proxy servers, probably running squid (though I'm open to alternatives). For example, it could work in a round-robin fashion, where request1 goes to proxy1, request2 to proxy2, and eventually looping back around. Any idea how to set this up?\nTo make it harder, I'd also like to be able to dynamically change the list of available proxies, bring some down, and add others.\nIf it matters, IP addresses are assigned dynamically.\nThanks :)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16640,"Q_Id":1934088,"Users Score":6,"Answer":"Make your crawler have a list of proxies and with each HTTP request let it use the next proxy from the list in a round robin fashion. However, this will prevent you from using HTTP\/1.1 persistent connections. Modifying the proxy list will eventually result in using a new or not using a proxy.\nOr have several connections open in parallel, one to each proxy, and distribute your crawling requests to each of the open connections. Dynamics may be implemented by having the connetor registering itself with the request dispatcher.","Q_Score":10,"Tags":"python,proxy,screen-scraping,web-crawler,squid","A_Id":1934198,"CreationDate":"2009-12-19T20:46:00.000","Title":"Rotating Proxies for web scraping","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use pywn, a python library for using WordNet. I've played about with python a little under Windows, but am completely new at MacOS X stuff. I'm running under MacOS 10.5.8, so my default Python interpreter is 2.5.1\nThe pywn instructions say: \"Put each of the .py files somewhere in your python search path.\"\nWhere is the python search path defined under the default python installation in MacOS X?\nIf I've put the pywn files in \/Users\/nick\/programming\/pywn, what is the best way of adding this to the search path?\nIs this the best place to put the files?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28430,"Q_Id":1935290,"Users Score":3,"Answer":"I think by default \/Library\/Python\/2.5\/site-packages\/ is part of your search path. This directory is usually used for third party libraries.","Q_Score":1,"Tags":"python,macos,module-search-path","A_Id":1935323,"CreationDate":"2009-12-20T08:52:00.000","Title":"how do I add a python module on MacOS X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"If I want to be able to test my application against a empty MySQL database each time my application's testsuite is run, how can I start up a server as a non-root user which refers to a empty (not saved anywhere, or in saved to \/tmp) MySQL database?\nMy application is in Python, and I'm using unittest on Ubuntu 9.10.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":287,"Q_Id":1960155,"Users Score":0,"Answer":"You can try the Blackhole and Memory table types in MySQL.","Q_Score":2,"Tags":"python,mysql,unit-testing,ubuntu","A_Id":1960164,"CreationDate":"2009-12-25T00:25:00.000","Title":"Start a \"throwaway\" MySQL session for testing code?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I want to be able to test my application against a empty MySQL database each time my application's testsuite is run, how can I start up a server as a non-root user which refers to a empty (not saved anywhere, or in saved to \/tmp) MySQL database?\nMy application is in Python, and I'm using unittest on Ubuntu 9.10.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":287,"Q_Id":1960155,"Users Score":1,"Answer":"--datadir for just the data or --basedir","Q_Score":2,"Tags":"python,mysql,unit-testing,ubuntu","A_Id":1960160,"CreationDate":"2009-12-25T00:25:00.000","Title":"Start a \"throwaway\" MySQL session for testing code?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Please let me know how to create a uml diagram along with its equivalent documentation for the source code(.py format) using enterprise architecture 7.5\nPlease help me find the solution, I have read the solution for the question on this website related to my topic but in vain","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":4824,"Q_Id":1962447,"Users Score":4,"Answer":"File \/ New Project \/ enter your project name.\nIn the Project Browser, create a package named \"source\"\nRight-click the source package, \"Code Engineering\", \"Import Source Directory\".\nPick the directory containing your module(s) as the \"Root Directory\"\nSet \"Source Type\" to Python\nEnable \"Recursively Process Subdirectories\"\nSelect \"Package Per File\"\nClick \"OK\".","Q_Score":2,"Tags":"python","A_Id":1964328,"CreationDate":"2009-12-26T02:05:00.000","Title":"python source code conversion to uml diagram with Sparx Systems Enterprise Architect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Please let me know how to create a uml diagram along with its equivalent documentation for the source code(.py format) using enterprise architecture 7.5\nPlease help me find the solution, I have read the solution for the question on this website related to my topic but in vain","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":4824,"Q_Id":1962447,"Users Score":1,"Answer":"Go to project browser\nCreate a model\nRight-click model > Add > Add View > Class\nRight-click class > Code Engineering > Import Source Directory...\nCheck \"one package per folder\"\n\nThe last one ensures you'll have an interesting diagram full of classes.","Q_Score":2,"Tags":"python","A_Id":45345997,"CreationDate":"2009-12-26T02:05:00.000","Title":"python source code conversion to uml diagram with Sparx Systems Enterprise Architect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting to learn both Python and wxPython and as part of the app I'm doing, I need to have a simple browser on the left pane of my app. I'm wondering how do I do it? Or at least point me to the right direction that'll help me more on how to do one. Thanks in advance!\nEDIT:\na sort of side question, how much of wxPython do I need to learn? Should I use tools like wxGlade?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6299,"Q_Id":1962592,"Users Score":1,"Answer":"You can take a look at the wxPython examples, they also include code samples for almost all of the widgets supported by wxPython. If you use Windows they can be found in the Start Menu folder of WxPython.","Q_Score":4,"Tags":"python,wxpython","A_Id":1962595,"CreationDate":"2009-12-26T04:02:00.000","Title":"How do I make a simple file browser in wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I use the pyglet API for sound to play subsets of a sound file e.g. from 1 second in to 3.5seconds of a 6 second sound clip?\nI can load a sound file and play it, and can seek to the start of the interval desired, but am wondering how to stop playback at the point indicated?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1156,"Q_Id":1977521,"Users Score":1,"Answer":"It doesn't appear that pyglet has support for setting a stop time.  Your options are:\n\nPoll the current time and stop playback when you've reached your desired endpoint.  This may not be precise enough for you.\nOr, use a sound file library to extract the portion you want into a temporary sound file, then use pyglet to play that sound file in its entirety.  Python has built-in support for .wav files (the \"wave\" module), or you could shell out to a command-line tool like \"sox\".","Q_Score":1,"Tags":"python,audio,pyglet","A_Id":1980577,"CreationDate":"2009-12-29T23:15:00.000","Title":"Play Subset of audio file using Pyglet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my Django app, I need to start running a few periodic background jobs when a user logs in and stop running them when the user logs out, so I am looking for an elegant way to\n\nget notified of a user login\/logout\nquery user login status\n\nFrom my perspective, the ideal solution would be\n\na signal sent by each django.contrib.auth.views.login and ... views.logout\na method django.contrib.auth.models.User.is_logged_in(), analogous to ... User.is_active() or ... User.is_authenticated()\n\nDjango 1.1.1 does not have that and I am reluctant to patch the source and add it (not sure how to do that, anyway).\nAs a temporary solution, I have added an is_logged_in boolean field to the UserProfile model which is cleared by default, is set the first time the user hits the landing page (defined by LOGIN_REDIRECT_URL = '\/') and is queried in subsequent requests. I added it to UserProfile, so I don't have to derive from and customize the builtin User model for that purpose only.\nI don't like this solution. If the user explicitely clicks the logout button, I can clear the flag, but most of the time, users just leave the page or close the browser; clearing the flag in these cases does not seem straight forward to me. Besides (that's rather data model clarity nitpicking, though), is_logged_in does not belong in the UserProfile, but in the User model.\nCan anyone think of alternate approaches ?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":38642,"Q_Id":1990502,"Users Score":0,"Answer":"Rough idea - you could use middleware for this. This middleware could process requests and fire signal when relevant URL is requested. It could also process responses and fire signal when given action actually succeded.","Q_Score":84,"Tags":"python,django,login,signals","A_Id":1991497,"CreationDate":"2010-01-02T03:19:00.000","Title":"Django: signal when user logs in?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my Django app, I need to start running a few periodic background jobs when a user logs in and stop running them when the user logs out, so I am looking for an elegant way to\n\nget notified of a user login\/logout\nquery user login status\n\nFrom my perspective, the ideal solution would be\n\na signal sent by each django.contrib.auth.views.login and ... views.logout\na method django.contrib.auth.models.User.is_logged_in(), analogous to ... User.is_active() or ... User.is_authenticated()\n\nDjango 1.1.1 does not have that and I am reluctant to patch the source and add it (not sure how to do that, anyway).\nAs a temporary solution, I have added an is_logged_in boolean field to the UserProfile model which is cleared by default, is set the first time the user hits the landing page (defined by LOGIN_REDIRECT_URL = '\/') and is queried in subsequent requests. I added it to UserProfile, so I don't have to derive from and customize the builtin User model for that purpose only.\nI don't like this solution. If the user explicitely clicks the logout button, I can clear the flag, but most of the time, users just leave the page or close the browser; clearing the flag in these cases does not seem straight forward to me. Besides (that's rather data model clarity nitpicking, though), is_logged_in does not belong in the UserProfile, but in the User model.\nCan anyone think of alternate approaches ?","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":38642,"Q_Id":1990502,"Users Score":1,"Answer":"The only reliable way (that also detects when the user has closed the browser) is to update some last_request field every time the user loads a page.\nYou could also have a periodic AJAX request that pings the server every x minutes if the user has a page open.\nThen have a single background job that gets a list of recent users, create jobs for them, and clear the jobs for users not present in that list.","Q_Score":84,"Tags":"python,django,login,signals","A_Id":1991512,"CreationDate":"2010-01-02T03:19:00.000","Title":"Django: signal when user logs in?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to upload a file from my computer to a file hoster like hotfile.com via a Python script. Because Hotfile is only offering a web-based upload service (no ftp).\nI need Python first to login with my username and password and after that to upload the file. When the file transfer is over, I need the Download and Delete-link (which is generated right after the Upload has finished).  \nIs this even possible? If so, can anybody tell me how the script looks like or even give my hints how to build it?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7457,"Q_Id":1993060,"Users Score":0,"Answer":"You mention they do not offer FTP, but I went to their site and found the following:\n\nHow to upload with FTP?\n  ftp.hotfile.com user: your hotfile\n  username pass: your hotfile password\n  You can upload and make folders, but\n  cant rename,move files\n\nTry it. If it works, using FTP from within Python will be a very simple task.","Q_Score":2,"Tags":"python,authentication,file-upload,automation","A_Id":1993139,"CreationDate":"2010-01-02T22:14:00.000","Title":"Upload file to a website via Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to start a thread when django project runserver successfully.\nwhere can I put the create-thread-and-start code? Is there any hook for the django runserver?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2758,"Q_Id":1994507,"Users Score":7,"Answer":"Why would you want to do that? runserver is for development only, it should never be used in production. And if you're running via Apache, it should manage threads\/processes for you anyway.","Q_Score":0,"Tags":"python,django,multithreading","A_Id":1994563,"CreationDate":"2010-01-03T10:14:00.000","Title":"how to start a thread when django runserver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to start a thread when django project runserver successfully.\nwhere can I put the create-thread-and-start code? Is there any hook for the django runserver?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2758,"Q_Id":1994507,"Users Score":0,"Answer":"Agree with the above answer, you probably don't want to do this. Runserver should be used for development only. Once you deploy, you'll want to move to Apache\/WSGI. On my dev machine (where I do use runserver), I usually throw it in a screen session, so it doesn't get in the way, but I can pull it back up if I need to see a traceback.","Q_Score":0,"Tags":"python,django,multithreading","A_Id":1997921,"CreationDate":"2010-01-03T10:14:00.000","Title":"how to start a thread when django runserver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a C# command-line client that I'm testing the consumption of SOAP\/WSDL via Django\/Python\/soaplib created WSDL. I've managed to successfully connect to the web service by adding a service reference. I then call one of service's methods, and the service processes the data I send, but it returns null instead of the integer I'm expecting. Any ideas on how to get back something other than a null response? Thanks for any help or suggestions!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1555,"Q_Id":2007908,"Users Score":0,"Answer":"One thing you can do is start by building a manual proxy using WebClient, or WebRequest\/WebResponse. Construct your manual proxy to send the desired data to the WS for testing.\nCouple of things to check on the WSDL implementation:\n\nThe WSDL definition needs to match exactly, including case, for the C# proxy to recognize the values\nNamespace definitions need to match exactly, including trailing slashes\nCheck the profile of the generated proxy and make sure it conforms with what your desired profile is (i.e. basic or none if needed)\n\nIf you post your generated proxy we can look at it and see if there is anything out of the ordinary.","Q_Score":3,"Tags":"c#,python,django,soap,wsdl","A_Id":2008000,"CreationDate":"2010-01-05T17:36:00.000","Title":"How to use C# client to consume Django\/Python web service (all methods are returning null)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a C# command-line client that I'm testing the consumption of SOAP\/WSDL via Django\/Python\/soaplib created WSDL. I've managed to successfully connect to the web service by adding a service reference. I then call one of service's methods, and the service processes the data I send, but it returns null instead of the integer I'm expecting. Any ideas on how to get back something other than a null response? Thanks for any help or suggestions!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1555,"Q_Id":2007908,"Users Score":0,"Answer":"We faced the similar problem while consuming a web service it was the type of data returned we were getting data in UTF-16 format. \nPlease check if you have proper data type in use.","Q_Score":3,"Tags":"c#,python,django,soap,wsdl","A_Id":2008062,"CreationDate":"2010-01-05T17:36:00.000","Title":"How to use C# client to consume Django\/Python web service (all methods are returning null)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm getting seriously frustrated at how slow python startup is.  Just importing more or less basic modules takes a second, since python runs down the sys.path looking for matching files (and generating 4 stat() calls - [\"foo\", \"foo.py\", \"foo.pyc\", \"foo.so\"] - for each check).  For a complicated project environment, with tons of different directories, this can take around 5 seconds -- all to run a script that might fail instantly.\nDo folks have suggestions for how to speed up this process?  For instance, one hack I've seen is to set the LD_PRELOAD_32 environment variable to a library that caches the result of ENOENT calls (e.g. failed stat() calls) between runs.  Of course, this has all sorts of problems (potentially confusing non-python programs, negative caching, etc.).","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":12690,"Q_Id":2010255,"Users Score":4,"Answer":"The first things that come to mind are: \n\nTry a smaller path\nMake sure your modules are pyc's so they'll load faster\nMake sure you don't double import, or import too much\n\nOther than that, are you sure that the disk operations are what's bogging you down? Is your disk\/operating system really busy or old and slow? \nMaybe a defrag is in order?","Q_Score":24,"Tags":"python","A_Id":2010309,"CreationDate":"2010-01-06T00:47:00.000","Title":"Speeding up the python \"import\" loader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm getting seriously frustrated at how slow python startup is.  Just importing more or less basic modules takes a second, since python runs down the sys.path looking for matching files (and generating 4 stat() calls - [\"foo\", \"foo.py\", \"foo.pyc\", \"foo.so\"] - for each check).  For a complicated project environment, with tons of different directories, this can take around 5 seconds -- all to run a script that might fail instantly.\nDo folks have suggestions for how to speed up this process?  For instance, one hack I've seen is to set the LD_PRELOAD_32 environment variable to a library that caches the result of ENOENT calls (e.g. failed stat() calls) between runs.  Of course, this has all sorts of problems (potentially confusing non-python programs, negative caching, etc.).","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":12690,"Q_Id":2010255,"Users Score":1,"Answer":"Something's missing from your premise--I've never seen some \"more-or-less\" basic modules take over a second to import, and I'm not running Python on what I would call cutting-edge hardware.  Either you're running on some seriously old hardware, or you're running on an overloaded machine, or either your OS or Python installation is broken in some way.  Or you're not really importing \"basic\" modules.\nIf it's any of the first three issues, you need to look at the root problem for a solution.  If it's the last, we really need to know what the specific packages are to be of any help.","Q_Score":24,"Tags":"python","A_Id":2010759,"CreationDate":"2010-01-06T00:47:00.000","Title":"Speeding up the python \"import\" loader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm getting seriously frustrated at how slow python startup is.  Just importing more or less basic modules takes a second, since python runs down the sys.path looking for matching files (and generating 4 stat() calls - [\"foo\", \"foo.py\", \"foo.pyc\", \"foo.so\"] - for each check).  For a complicated project environment, with tons of different directories, this can take around 5 seconds -- all to run a script that might fail instantly.\nDo folks have suggestions for how to speed up this process?  For instance, one hack I've seen is to set the LD_PRELOAD_32 environment variable to a library that caches the result of ENOENT calls (e.g. failed stat() calls) between runs.  Of course, this has all sorts of problems (potentially confusing non-python programs, negative caching, etc.).","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":12690,"Q_Id":2010255,"Users Score":11,"Answer":"zipping up as many pyc files as feasible (with proper directory structure for packages), and putting that zipfile as the very first entry in sys.path (on the best available local disk, ideally) can speed up startup times a lot.","Q_Score":24,"Tags":"python","A_Id":2010354,"CreationDate":"2010-01-06T00:47:00.000","Title":"Speeding up the python \"import\" loader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running into a paradigm problem here. I don't know whether I should store money as a Decimal(), or if I should store it as a string and convert it to a decimal myself. My reasoning is this:\nPayPal requires 2 decimal places, so if I have a product that is 49 dollars even, PayPal wants to see 49.00 come across the wire. Django's DecimalField() doesn't set a decimal amount. It only stores a maximum decimal places amount. So, if you have 49 in there, and you have the field set to 2 decimal places, it'll still store it as 49. I know that Django is basically type casting when it deserializes back from the database into a Decimal (since Databases don't have decimal fields), so I'm not completely concerned with the speed issues as much as I am with the design issues of this problem. I want to do what's best for extensibility.\nOr, better yet, does anyone know how to configure a django DecimalField() to always format with the TWO_PLACES formatting style.","AnswerCount":10,"Available Count":2,"Score":0.0199973338,"is_accepted":false,"ViewCount":37694,"Q_Id":2013835,"Users Score":1,"Answer":"You store it as a DecimalField and manually add the decimals if you need to, as Valya said, using basic formatting techniques.\nYou can even add a Model Method to you product or transaction model that will spit out the DecimalField as an appropriately formatted string.","Q_Score":66,"Tags":"python,django,django-models,decimal,currency","A_Id":2013893,"CreationDate":"2010-01-06T15:09:00.000","Title":"Django: How should I store a money value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running into a paradigm problem here. I don't know whether I should store money as a Decimal(), or if I should store it as a string and convert it to a decimal myself. My reasoning is this:\nPayPal requires 2 decimal places, so if I have a product that is 49 dollars even, PayPal wants to see 49.00 come across the wire. Django's DecimalField() doesn't set a decimal amount. It only stores a maximum decimal places amount. So, if you have 49 in there, and you have the field set to 2 decimal places, it'll still store it as 49. I know that Django is basically type casting when it deserializes back from the database into a Decimal (since Databases don't have decimal fields), so I'm not completely concerned with the speed issues as much as I am with the design issues of this problem. I want to do what's best for extensibility.\nOr, better yet, does anyone know how to configure a django DecimalField() to always format with the TWO_PLACES formatting style.","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":37694,"Q_Id":2013835,"Users Score":10,"Answer":"I suggest to avoid mixing representation with storage. Store the data as a decimal value with 2 places.\nIn the UI layer, display it in a form which is suitable for the user (so maybe omit the \".00\").\nWhen you send the data to PayPal, format it as the interface requires.","Q_Score":66,"Tags":"python,django,django-models,decimal,currency","A_Id":2013866,"CreationDate":"2010-01-06T15:09:00.000","Title":"Django: How should I store a money value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using cherrypy's standalone server (cherrypy.quickstart()) and sqlite3 for a database.\nI was wondering how one would do ajax\/jquery asynchronous calls to the database while using cherrypy?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3741,"Q_Id":2015065,"Users Score":2,"Answer":"The same way you would do them using any other webserver - by getting your javascript to call a URL which is handled by the server-side application.","Q_Score":1,"Tags":"jquery,python,ajax,asynchronous,cherrypy","A_Id":2015344,"CreationDate":"2010-01-06T17:57:00.000","Title":"How does one do async ajax calls using cherrypy?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am facing some problem with files with huge data.\ni need to skip doing some execution on those files.\ni get the data of the file into a variable.\nnow i need to get the byte of the variable and if it is greater than 102400 , then print a message.\nupdate : i cannot open the files , since it is present in a tar file. \n         the content is already getting copied to a variable called 'data'\n         i am able to print contents of the variable data. i just need to check if it has more than 102400 bytes.\nthanks","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1889,"Q_Id":2020318,"Users Score":0,"Answer":"This answer seems irrelevant, since I seem to have misunderstood the question, which has now been clarified. However, should someone find this question, while searching with pretty much the same terms, this answer may still be relevant:\nJust open the file in binary mode\nf = open(filename, 'rb')\nread\/skip a bunch and print the next byte(s). I used the same method to 'fix' the n-th byte in a zillion images once.","Q_Score":1,"Tags":"python,tar","A_Id":2020334,"CreationDate":"2010-01-07T12:45:00.000","Title":"how do i get the byte count of a variable in python just like wc -c gives in unix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am facing some problem with files with huge data.\ni need to skip doing some execution on those files.\ni get the data of the file into a variable.\nnow i need to get the byte of the variable and if it is greater than 102400 , then print a message.\nupdate : i cannot open the files , since it is present in a tar file. \n         the content is already getting copied to a variable called 'data'\n         i am able to print contents of the variable data. i just need to check if it has more than 102400 bytes.\nthanks","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1889,"Q_Id":2020318,"Users Score":1,"Answer":"len(data) gives you the size in bytes if it's binary data. With strings the size depends on the encoding used.","Q_Score":1,"Tags":"python,tar","A_Id":2020425,"CreationDate":"2010-01-07T12:45:00.000","Title":"how do i get the byte count of a variable in python just like wc -c gives in unix","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"can anyone please help me with creating forms in python using the reportlab lib.\ni am totally new to this and i would appreciate sample code\nthanks","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1976,"Q_Id":2021764,"Users Score":7,"Answer":"Apparently reportlab does not support creating fillable pdf forms. The only thing I found about it being present in the API dates from 2003, afterwards all statements clearly say no.\nI'm answering this so late because this is one of the highest hits when you enter 'reportlab forms' in google. I do agree with Travis you should google easy questions yourself, but this isn't really clearly answered anywhere.","Q_Score":3,"Tags":"python,pdf-generation,reportlab","A_Id":2621635,"CreationDate":"2010-01-07T16:14:00.000","Title":"how to make fillable forms with reportlab in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a payment gateway company so we can avoid tiresome PCI-DSS certification and its associated expenses. I'll get this out the way now, I don't want Paypal. It does what I want but it's really not a company I want to trust with any sort of money.\nIt needs to support the following flow:\n\nUser performs actions on our site, generating an amount that needs to be paid.\nOur server contacts the gateway asynchronously (no hidden inputs) and tells it about the user, how much they need to pay. The gateway returns a URL and perhaps a tentative transaction ID.\nOur server stores the transaction ID and redirects the user to the URL provided by the gateway.\nThe user fills out their payment details on the remote server.\nWhen they have completed that, the gateway asynchronously contacts our server with the outcome, transaction id, etc and forwards them back to us (at a predestined URL).\nWe can show the user their order is complete\/failed\/etc. Fin.\n\nIf at all possible, UK or EU based and developer friendly.\nWe don't need any concept of a shopping basket as we have that all handled in our code already.\nWe have (or at least will have by launch) a proper merchant banking account - so cover services like Paypay aren't needed.\nIf their API covers Python (we're using Django) explicitly, all the better but I think I'm capable enough to decipher any other examples and transcode them into Python myself.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":3656,"Q_Id":2022067,"Users Score":2,"Answer":"It sounds like you want something like Worldpay or even Google Checkout. But it all depends what your turnover is, because these sorts of providers (who host the payment page themselves), tend to take a percentage of every transaction, rather than a fixed monthly fee that you can get from elsewhere.\nThe other thing to consider is, if you have any way of taking orders over the phone, and the phone operators need to take customers' credit card details, then your whole internal network will need to be PCI compliant, too.\nIf you JUST need it for a website, then that makes it easier. If you have a low turnover, then check out the sites mentioned above. If you have a high turnover, then it may work out more cost effective in the long run to get PCI-DSS certified and still keep control of credit card transactions in-house, giving you more flexibility, and cheaper transaction costs.","Q_Score":9,"Tags":"python,payment-gateway,payment","A_Id":2023105,"CreationDate":"2010-01-07T17:01:00.000","Title":"Looking for a payment gateway","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a payment gateway company so we can avoid tiresome PCI-DSS certification and its associated expenses. I'll get this out the way now, I don't want Paypal. It does what I want but it's really not a company I want to trust with any sort of money.\nIt needs to support the following flow:\n\nUser performs actions on our site, generating an amount that needs to be paid.\nOur server contacts the gateway asynchronously (no hidden inputs) and tells it about the user, how much they need to pay. The gateway returns a URL and perhaps a tentative transaction ID.\nOur server stores the transaction ID and redirects the user to the URL provided by the gateway.\nThe user fills out their payment details on the remote server.\nWhen they have completed that, the gateway asynchronously contacts our server with the outcome, transaction id, etc and forwards them back to us (at a predestined URL).\nWe can show the user their order is complete\/failed\/etc. Fin.\n\nIf at all possible, UK or EU based and developer friendly.\nWe don't need any concept of a shopping basket as we have that all handled in our code already.\nWe have (or at least will have by launch) a proper merchant banking account - so cover services like Paypay aren't needed.\nIf their API covers Python (we're using Django) explicitly, all the better but I think I'm capable enough to decipher any other examples and transcode them into Python myself.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3656,"Q_Id":2022067,"Users Score":4,"Answer":"You might want to take a look at Adyen (www.adyen.com). They are European and provide a whole lot of features and a very friendly interface. They don't charge a monthly or set up fee and seem to be reasonably priced per transaction.\nTheir hosted payments page can be completely customised which was an amazing improvement for us.","Q_Score":9,"Tags":"python,payment-gateway,payment","A_Id":2258716,"CreationDate":"2010-01-07T17:01:00.000","Title":"Looking for a payment gateway","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a payment gateway company so we can avoid tiresome PCI-DSS certification and its associated expenses. I'll get this out the way now, I don't want Paypal. It does what I want but it's really not a company I want to trust with any sort of money.\nIt needs to support the following flow:\n\nUser performs actions on our site, generating an amount that needs to be paid.\nOur server contacts the gateway asynchronously (no hidden inputs) and tells it about the user, how much they need to pay. The gateway returns a URL and perhaps a tentative transaction ID.\nOur server stores the transaction ID and redirects the user to the URL provided by the gateway.\nThe user fills out their payment details on the remote server.\nWhen they have completed that, the gateway asynchronously contacts our server with the outcome, transaction id, etc and forwards them back to us (at a predestined URL).\nWe can show the user their order is complete\/failed\/etc. Fin.\n\nIf at all possible, UK or EU based and developer friendly.\nWe don't need any concept of a shopping basket as we have that all handled in our code already.\nWe have (or at least will have by launch) a proper merchant banking account - so cover services like Paypay aren't needed.\nIf their API covers Python (we're using Django) explicitly, all the better but I think I'm capable enough to decipher any other examples and transcode them into Python myself.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":3656,"Q_Id":2022067,"Users Score":2,"Answer":"I just finished something exactly like this using First Data Global Gateway (don't really want to provide a link, can find with Google).  There's no Python API because their interface is nothing but http POST.\nYou have the choice of gathering credit card info yourself before posting the form to their server, as long as the connection is SSL and the referring URL is known to them (meaning it's your form but you can't store or process the data first).\nIn the FDGG gateway \"terminal interface\" you configure your URL endpoints for authorization accepted\/failed and it will POST transaction information.\nI can't say it was fun and their \"test\" mode was buggy but it works.  Sorry, don't know if it's available in UK\/EU but it's misnamed if it isn't :)","Q_Score":9,"Tags":"python,payment-gateway,payment","A_Id":2023033,"CreationDate":"2010-01-07T17:01:00.000","Title":"Looking for a payment gateway","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Brand new to django. We have a legacy django project using django 0.96x that does authentication, ldap, etc., and it's pretty involved so we don't want to rewrite that code.\nWe want to add a forum solution (off the shelf) but all of the ones I've seen so far require django 1.x \nI'm trying to figure out how to get this working and I've narrowed it down to the following:\n\nUse an old forum solution that works w\/django 0.96 (does this exist?)\nTry to patch a forum solution to make it \"backwards compatible\" with 0.96 (possible nightmare)\nUse two different djangos: 0.96 and 1.x and (since we're using Apache w\/mod_python) have two different Location directives; adjust PYTHONPATH for each appropriately (or use virtualenv, etc.)\n\nBut will option #3 even work? I don't know enough about how django.contrib.auth and friends work so if I run two different versions of django will the user stay logged in? I didn't mention trying to patch our 0.96 project to bring it to 1.x but we don't really have the time to do that.\nAny suggestions?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":2022178,"Users Score":0,"Answer":"A user's login status is stored using sessions. As far as I can tell from comparing trunk to the 0.96 source, the sessions are committed to a cookie the same way, and auth stores the user ID and backend the same way, so as long as the two apps use the same session storage and are on the same domain, it should work. (Just to be safe, I wouldn't use secure cookies in case the backend logic has changed - I didn't check out that part.)\nHowever, 0.96 did not feature pluggable session stores like modern Django does. Probably, to get a current version of Django to work with your 0.96 sessions, you would need to write a session backend for the current Django that connects to the 0.96 database and manipulates the sessions there. I'm not sure how well that would work, though.","Q_Score":0,"Tags":"python,django,mod-python","A_Id":2022368,"CreationDate":"2010-01-07T17:18:00.000","Title":"Running Different Django Versions But Sharing Authentication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Brand new to django. We have a legacy django project using django 0.96x that does authentication, ldap, etc., and it's pretty involved so we don't want to rewrite that code.\nWe want to add a forum solution (off the shelf) but all of the ones I've seen so far require django 1.x \nI'm trying to figure out how to get this working and I've narrowed it down to the following:\n\nUse an old forum solution that works w\/django 0.96 (does this exist?)\nTry to patch a forum solution to make it \"backwards compatible\" with 0.96 (possible nightmare)\nUse two different djangos: 0.96 and 1.x and (since we're using Apache w\/mod_python) have two different Location directives; adjust PYTHONPATH for each appropriately (or use virtualenv, etc.)\n\nBut will option #3 even work? I don't know enough about how django.contrib.auth and friends work so if I run two different versions of django will the user stay logged in? I didn't mention trying to patch our 0.96 project to bring it to 1.x but we don't really have the time to do that.\nAny suggestions?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":129,"Q_Id":2022178,"Users Score":1,"Answer":"It's possible, but it may be pretty painful to do option #3.\nHow about Option 4: bite the bullet and upgrade to Django 1.1.1. I did this with a couple of 0.97pre sites and it took less time than I thought it would. The biggest pain was dealing with admin stuff. Instead of going with separate admin.py files, we simply put the Admin classes directly below the Model classes.\nI use Mercurial for my DVCS and I just cloned, hacked, merged and it worked. It took about 3-5 hours per site and that included some custom template tag munging.","Q_Score":0,"Tags":"python,django,mod-python","A_Id":2022407,"CreationDate":"2010-01-07T17:18:00.000","Title":"Running Different Django Versions But Sharing Authentication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Brand new to django. We have a legacy django project using django 0.96x that does authentication, ldap, etc., and it's pretty involved so we don't want to rewrite that code.\nWe want to add a forum solution (off the shelf) but all of the ones I've seen so far require django 1.x \nI'm trying to figure out how to get this working and I've narrowed it down to the following:\n\nUse an old forum solution that works w\/django 0.96 (does this exist?)\nTry to patch a forum solution to make it \"backwards compatible\" with 0.96 (possible nightmare)\nUse two different djangos: 0.96 and 1.x and (since we're using Apache w\/mod_python) have two different Location directives; adjust PYTHONPATH for each appropriately (or use virtualenv, etc.)\n\nBut will option #3 even work? I don't know enough about how django.contrib.auth and friends work so if I run two different versions of django will the user stay logged in? I didn't mention trying to patch our 0.96 project to bring it to 1.x but we don't really have the time to do that.\nAny suggestions?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":2022178,"Users Score":0,"Answer":"It's possible to expose Django 0.96 tables to 1.1 - you can use unmanaged models wrapped around database VIEWs. In other words you issue:\nCREATE VIEW auth_user AS SELECT * from django096db.auth_user;\n(and similar cmd for other tables)\nand then you have Django 1.1 synchronized with 0.96 (assuming 0.96 tables are compatible with 1.1, I haven't checked that).","Q_Score":0,"Tags":"python,django,mod-python","A_Id":2029226,"CreationDate":"2010-01-07T17:18:00.000","Title":"Running Different Django Versions But Sharing Authentication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I more or less know how to use select() to take a list of sockets, and only return the ones that are ready to read\/write something.  The project I'm working on now has a class called 'user'.  Each 'user' object contains its own socket.  What I would like to do is pass a list of users to a select(), and get back a list of only the users where user.socket is ready to read\/write.  Any thoughts on where to start on this?\nEdit:  Changed switch() to select().  I need to proofread better.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":547,"Q_Id":2046727,"Users Score":2,"Answer":"You should have your User class implement a fileno(self) method which returns self.thesocket.fileno() -- that's the way to make select work on your own classes (sockets only on windows, arbitrary files on Unix-like systems).  Not sure what switch is supposed to me -- don't recognize it as a standard library (or built-in) Python concept...?","Q_Score":1,"Tags":"python,sockets","A_Id":2046760,"CreationDate":"2010-01-12T04:28:00.000","Title":"Creating waitable objects in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have been in the RDBMS world for many years now but wish to explore the whole nosql movement.  so here's my first question:\nis it bad practice to have the possibility of duplicate keys?  for example, an address book keyed off of last name (most probably search item?) could have multiple entities.  is it bad practice to use the last name then?  is the key supposed to be the most \"searchable\" definition of the entity?  are there any resources for \"best practices\" in this whole new world (for me)?\ni'm intrigued by tokyo cabinet (and specifically the tc interface) but don't know how to iterate through different entities that have the same key (e.g. see above).  i can only get the first entity.  anyway, thanks in advance for the help","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":597,"Q_Id":2068473,"Users Score":1,"Answer":"This depend on no-sql implementation. Cassandra, for example, allows range queries, so you could model data to do queries on last name, or with full name (starting with last name, then first name).\nBeyond this, many simpler key-value stores would indeed require you to store a list structure (or such) for multi-valued entries. Whether this is feasible or not depends on expected number of \"duplicates\" -- with last name, number could be rather high I presume, so it does not sound like an ideal model for many cases.","Q_Score":1,"Tags":"python,tokyo-cabinet","A_Id":2384015,"CreationDate":"2010-01-15T00:04:00.000","Title":"key\/value (general) and tokyo cabinet (python tc-specific) question","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I don't know if this is a stupid question, but is there any way to not show focus in wxPython? For example, I built a simple GUI with a few buttons and I don't want the dotted rectangle to show up on the button I have just clicked. \nIf I remember correctly in Excel VBA you could just set TakeFocusOnClick tag to False. What would be the equivalent in wxPython?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":2069739,"Users Score":0,"Answer":"You could also give the focus to another control in your event handler for the buttons. Just call the SetFocus() method on any other control. This might make your application more usable as a side effect if you for example return focus to a text field that is likely to be typed in next.","Q_Score":0,"Tags":"wxpython,focus","A_Id":2135083,"CreationDate":"2010-01-15T05:46:00.000","Title":"Not showing focus in wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python unittest in order to test some other external application but it takes too much time to run the test one by one.\nI would like to know how can I speedup this process by using the power of multi-cores. \nCan I tweak unittest to execute tests in parallel? How?\nThis question is not able python GIL limitation because in fact not the python code takes time but the external application that I execute, currently via os.system().","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9389,"Q_Id":2074074,"Users Score":0,"Answer":"As the @vinay-sajip suggested, a few non-core python packages like py.test and nose provided parallel execution of unit tests via multiprocessing lib right out of the box. \nHowever, one thing to consider is that if you are testing a web app with database backend and majority of your test cases are relying on connecting to the same test database, then your unit test execution speed is bottlenecked on the DB not I\/O per se. And using multiprocess won't speed it up.\nGiven that each unit test case requires an independent setup of the database schema + data, you cannot scale out the execution speed only on CPU but restricted with a single test database connection to a single test database server (otherwise the state of the data may interfere with other other while parallel executing each test case so on and so forth).","Q_Score":13,"Tags":"python,multithreading,unit-testing,performance,multicore","A_Id":35182727,"CreationDate":"2010-01-15T19:08:00.000","Title":"How to speedup python unittest on muticore machines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state.\nNo big deal right? Just generate a list of numbers, shove them into an array and use Python \"random.shuffle(big_number_array)\" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems:\n1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers).\n2) Generate a random number and then check if it has already been used. If it has been used add or subtract one from the number and check again, keep repeating until I hit an unused number. Problem is this is no longer a random number as I have introduced bias (eventually I will get clumps of numbers and you'd be able to predict the next number with a better chance of success).\n3) Generate a random number and then check if it has already been used. If it has been used add or subtract another randomly generated random number and check again, problem is we're back to simply generating random numbers and checking as in solution 1.\n4) Suck it up and generate the random list and save it, have a daemon put them into a Queue so there are numbers available (and avoid constantly opening and closing a file, batching it instead). \n5) Generate much larger random numbers and hash them (i.e. using MD5) to get a smaller numeric value, we should rarely get collisions, but I end up with larger than needed numbers again.\n6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need.\nAnyone have any clever ideas that will reduce the chances of a \"collision\" (i.e. generating a random number that is already taken) but will also allow me to keep the number \"small\" (i.e. less than a billion (or a thousand million for your europeans =)).\nAnswer and why I accepted it:\nSo I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use \"small\" numbers (i.e. 9 digits instead of an MD5\/etc.).","AnswerCount":17,"Available Count":5,"Score":0.058755776,"is_accepted":false,"ViewCount":30464,"Q_Id":2076838,"Users Score":5,"Answer":"I think you are overestimating the problems with approach 1). Unless you have hard-realtime requirements just checking by random choice terminates rather fast. The probability of needing more than a number of iterations decays exponentially. With 100M numbers outputted (10% fillfactor) you'll have one in billion chance of requiring more than 9 iterations. Even with 50% of numbers taken you'll on average need 2 iterations and have one in a billion chance of requiring more than 30 checks. Or even the extreme case where 99% of the numbers are already taken might still be reasonable - you'll average a 100 iterations and have 1 in a billion change of requiring 2062 iterations","Q_Score":38,"Tags":"python,random,numbers","A_Id":2077313,"CreationDate":"2010-01-16T09:27:00.000","Title":"Generating non-repeating random numbers in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state.\nNo big deal right? Just generate a list of numbers, shove them into an array and use Python \"random.shuffle(big_number_array)\" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems:\n1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers).\n2) Generate a random number and then check if it has already been used. If it has been used add or subtract one from the number and check again, keep repeating until I hit an unused number. Problem is this is no longer a random number as I have introduced bias (eventually I will get clumps of numbers and you'd be able to predict the next number with a better chance of success).\n3) Generate a random number and then check if it has already been used. If it has been used add or subtract another randomly generated random number and check again, problem is we're back to simply generating random numbers and checking as in solution 1.\n4) Suck it up and generate the random list and save it, have a daemon put them into a Queue so there are numbers available (and avoid constantly opening and closing a file, batching it instead). \n5) Generate much larger random numbers and hash them (i.e. using MD5) to get a smaller numeric value, we should rarely get collisions, but I end up with larger than needed numbers again.\n6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need.\nAnyone have any clever ideas that will reduce the chances of a \"collision\" (i.e. generating a random number that is already taken) but will also allow me to keep the number \"small\" (i.e. less than a billion (or a thousand million for your europeans =)).\nAnswer and why I accepted it:\nSo I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use \"small\" numbers (i.e. 9 digits instead of an MD5\/etc.).","AnswerCount":17,"Available Count":5,"Score":0.0117641631,"is_accepted":false,"ViewCount":30464,"Q_Id":2076838,"Users Score":1,"Answer":"You can run 1) without running into the problem of too many wrong random numbers if you just decrease the random interval by one each time.\nFor this method to work, you will need to save the numbers already given (which you want to do anyway) and also save the quantity of numbers taken.\nIt is pretty obvious that, after having collected 10 numbers, your pool of possible random numbers will have been decreased by 10. Therefore, you must not choose a number between 1 and 1.000.000 but between 1 an 999.990. Of course this number is not the real number but only an index (unless the 10 numbers collected have been 999.991, 999.992, \u2026); you\u2019d have to count now from 1 omitting all the numbers already collected.\nOf course, your algorithm should be smarter than just counting from 1 to 1.000.000 but I hope you understand the method.\nI don\u2019t like drawing random numbers until I get one which fits either. It just feels wrong.","Q_Score":38,"Tags":"python,random,numbers","A_Id":2083392,"CreationDate":"2010-01-16T09:27:00.000","Title":"Generating non-repeating random numbers in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state.\nNo big deal right? Just generate a list of numbers, shove them into an array and use Python \"random.shuffle(big_number_array)\" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems:\n1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers).\n2) Generate a random number and then check if it has already been used. If it has been used add or subtract one from the number and check again, keep repeating until I hit an unused number. Problem is this is no longer a random number as I have introduced bias (eventually I will get clumps of numbers and you'd be able to predict the next number with a better chance of success).\n3) Generate a random number and then check if it has already been used. If it has been used add or subtract another randomly generated random number and check again, problem is we're back to simply generating random numbers and checking as in solution 1.\n4) Suck it up and generate the random list and save it, have a daemon put them into a Queue so there are numbers available (and avoid constantly opening and closing a file, batching it instead). \n5) Generate much larger random numbers and hash them (i.e. using MD5) to get a smaller numeric value, we should rarely get collisions, but I end up with larger than needed numbers again.\n6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need.\nAnyone have any clever ideas that will reduce the chances of a \"collision\" (i.e. generating a random number that is already taken) but will also allow me to keep the number \"small\" (i.e. less than a billion (or a thousand million for your europeans =)).\nAnswer and why I accepted it:\nSo I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use \"small\" numbers (i.e. 9 digits instead of an MD5\/etc.).","AnswerCount":17,"Available Count":5,"Score":0.0470241165,"is_accepted":false,"ViewCount":30464,"Q_Id":2076838,"Users Score":4,"Answer":"The standard Linear Congruential random number generator's seed sequence CANNOT repeat until the full set of numbers from the starting seed value have been generated.  Then it MUST repeat precisely.  \nThe internal seed is often large (48 or 64 bits).  The generated numbers are smaller (32 bits usually) because the entire set of bits are not random.  If you follow the seed values they will form a distinct non-repeating sequence.  \nThe question is essentially one of locating a good seed that generates \"enough\" numbers.  You can pick a seed, and generate numbers until you get back to the starting seed.  That's the length of the sequence.  It may be millions or billions of numbers.\nThere are some guidelines in Knuth for picking suitable seeds that will generate very long sequences of unique numbers.","Q_Score":38,"Tags":"python,random,numbers","A_Id":2077409,"CreationDate":"2010-01-16T09:27:00.000","Title":"Generating non-repeating random numbers in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state.\nNo big deal right? Just generate a list of numbers, shove them into an array and use Python \"random.shuffle(big_number_array)\" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems:\n1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers).\n2) Generate a random number and then check if it has already been used. If it has been used add or subtract one from the number and check again, keep repeating until I hit an unused number. Problem is this is no longer a random number as I have introduced bias (eventually I will get clumps of numbers and you'd be able to predict the next number with a better chance of success).\n3) Generate a random number and then check if it has already been used. If it has been used add or subtract another randomly generated random number and check again, problem is we're back to simply generating random numbers and checking as in solution 1.\n4) Suck it up and generate the random list and save it, have a daemon put them into a Queue so there are numbers available (and avoid constantly opening and closing a file, batching it instead). \n5) Generate much larger random numbers and hash them (i.e. using MD5) to get a smaller numeric value, we should rarely get collisions, but I end up with larger than needed numbers again.\n6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need.\nAnyone have any clever ideas that will reduce the chances of a \"collision\" (i.e. generating a random number that is already taken) but will also allow me to keep the number \"small\" (i.e. less than a billion (or a thousand million for your europeans =)).\nAnswer and why I accepted it:\nSo I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use \"small\" numbers (i.e. 9 digits instead of an MD5\/etc.).","AnswerCount":17,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":30464,"Q_Id":2076838,"Users Score":0,"Answer":"I'd rethink the problem itself... You don't seem to be doing anything sequential with the numbers... and you've got an index on the column which has them. Do they actually need to be numbers?\nConsider a sha hash... you don't actually need the entire thing. Do what git or other url shortening services do, and take first 3\/4\/5 characters of the hash. Given that each character now has 36 possible values instead of 10, you have 2,176,782,336 combinations instead of 999,999 combinations (for six digits). Combine that with a quick check on whether the combination exists (a pure index query) and a seed like a timestamp + random number and it should do for almost any situation.","Q_Score":38,"Tags":"python,random,numbers","A_Id":2076898,"CreationDate":"2010-01-16T09:27:00.000","Title":"Generating non-repeating random numbers in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state.\nNo big deal right? Just generate a list of numbers, shove them into an array and use Python \"random.shuffle(big_number_array)\" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems:\n1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers).\n2) Generate a random number and then check if it has already been used. If it has been used add or subtract one from the number and check again, keep repeating until I hit an unused number. Problem is this is no longer a random number as I have introduced bias (eventually I will get clumps of numbers and you'd be able to predict the next number with a better chance of success).\n3) Generate a random number and then check if it has already been used. If it has been used add or subtract another randomly generated random number and check again, problem is we're back to simply generating random numbers and checking as in solution 1.\n4) Suck it up and generate the random list and save it, have a daemon put them into a Queue so there are numbers available (and avoid constantly opening and closing a file, batching it instead). \n5) Generate much larger random numbers and hash them (i.e. using MD5) to get a smaller numeric value, we should rarely get collisions, but I end up with larger than needed numbers again.\n6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need.\nAnyone have any clever ideas that will reduce the chances of a \"collision\" (i.e. generating a random number that is already taken) but will also allow me to keep the number \"small\" (i.e. less than a billion (or a thousand million for your europeans =)).\nAnswer and why I accepted it:\nSo I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use \"small\" numbers (i.e. 9 digits instead of an MD5\/etc.).","AnswerCount":17,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":30464,"Q_Id":2076838,"Users Score":0,"Answer":"Do you need this to be cryptographically secure or just hard to guess?  How bad are collisions? Because if it needs to be cryptographically strong and have zero collisions, it is, sadly, impossible.","Q_Score":38,"Tags":"python,random,numbers","A_Id":2077000,"CreationDate":"2010-01-16T09:27:00.000","Title":"Generating non-repeating random numbers in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently joined a new company and the development team was in the progress of a project to rebuild the database categories structure as follows:\nif we have category and subcategory for items, like food category and italian food category in food category.\nThey were building a table for each category, instead of having one table and a link to the category id.\nNow we have a table called food\nand another table called food_italian\nand both tables contain the same fields.\nI have asked around and it seems that some DBA prefers this design. I would like to know why? and how this design can improve the performance?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":155,"Q_Id":2077522,"Users Score":2,"Answer":"First, the most obvious answer is that you should ask them, not us, since I can tell you this, that design seems bogus deluxe.\nThe only reason I can come up with is that you have inexperienced DBA's that does not know how to performance-tune a database, and seems to think that a table with less rows will always vastly outperform a table with more rows.\nWith good indices, that need not be the case.","Q_Score":2,"Tags":"python,mysql,database,django,performance","A_Id":2077536,"CreationDate":"2010-01-16T13:58:00.000","Title":"DB a table for the category and another table for the subcategory with similar fields, why?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Recently I've found myself testing an aplication in Froglogic's Squish, using Python to create test scripts. Just the other day, the question of how much memory the program is using has come up, and I've found myself unable to answer it.\nIt seems reasonable to assume that there's a way to query the os (windows 7) API for the information, but I've no idea where to begin. Does anyone know how I'd go about this?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":241,"Q_Id":2084063,"Users Score":0,"Answer":"Remember that Squish allows remote testing of the application. A system parameter queried via Python directly will only apply to the case of local testing.\nAn approach that works in either case is to call the currentApplicationContext() function that will give you a handle to the Application Under Test. It has a usedMemory property you can query. I don't recall which process property exactly is being queried but it should provide a rough indication.","Q_Score":1,"Tags":"python,memory-management,windows-7,squish","A_Id":2175363,"CreationDate":"2010-01-18T05:30:00.000","Title":"How would I discover the memory used by an application through a python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently I've found myself testing an aplication in Froglogic's Squish, using Python to create test scripts. Just the other day, the question of how much memory the program is using has come up, and I've found myself unable to answer it.\nIt seems reasonable to assume that there's a way to query the os (windows 7) API for the information, but I've no idea where to begin. Does anyone know how I'd go about this?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":241,"Q_Id":2084063,"Users Score":-1,"Answer":"In command line: tasklist \/FO LIST and parse the results?\nSorry, I don't know a Pythonic way. =P","Q_Score":1,"Tags":"python,memory-management,windows-7,squish","A_Id":2084070,"CreationDate":"2010-01-18T05:30:00.000","Title":"How would I discover the memory used by an application through a python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question related to some guidances to solve a problem. I have with me an xml file, I have to populate it into a database system (whatever, it might be sqlite, mysql) using scripting language: Python.\nDoes anyone have any idea on how to proceed?\n\nWhich technologies I need to read further?\nWhich environments I have to install?\nAny tutorials on the same topic?\n\nI already tried to parse xml using both by tree-based and sax method in other language, but to start with Python, I don't know where to start. I already know how to design the database I need. \nAnother question, is Python alone possible of executing database ddl queries?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":15042,"Q_Id":2085430,"Users Score":1,"Answer":"If you are accustomed to DOM (tree) access to xml from other language, you may find useful these standard library modules (and their respective docs):\n\nxml.dom \nxml.dom.minidom\n\nTo save tha data to DB, you can use standard module sqlite3 or look for binding to mysql. Or you may wish to use something more abstract, like SQLAlchemy or Django's ORM.","Q_Score":7,"Tags":"python,xml,database,sqlite,parsing","A_Id":2085657,"CreationDate":"2010-01-18T10:55:00.000","Title":"populating data from xml file to a sqlite database using python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how can I determine if a python script is executed from crontab?\nI don't want a solution that will require adding a parameter because I want to be able to detect this even from an imported module (not the main script).","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":4167,"Q_Id":2086961,"Users Score":1,"Answer":"An easier workaround would be to pass a flag to the script only from the crontab, like --crontab, and then just check for that flag.","Q_Score":5,"Tags":"python,unix,terminal,cron","A_Id":2087056,"CreationDate":"2010-01-18T15:17:00.000","Title":"How can I determine if a python script is executed from crontab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how can I determine if a python script is executed from crontab?\nI don't want a solution that will require adding a parameter because I want to be able to detect this even from an imported module (not the main script).","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4167,"Q_Id":2086961,"Users Score":0,"Answer":"If you want to detect this from an imported module, I would have the main program set a global variable in the module, which would output different things depending on the value of this global variable (and have the main program decide how to set the variable through a flag that you would use in your crontab).  This is quite robust (comparing to studying PPIDs).","Q_Score":5,"Tags":"python,unix,terminal,cron","A_Id":2087816,"CreationDate":"2010-01-18T15:17:00.000","Title":"How can I determine if a python script is executed from crontab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how can I determine if a python script is executed from crontab?\nI don't want a solution that will require adding a parameter because I want to be able to detect this even from an imported module (not the main script).","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":4167,"Q_Id":2086961,"Users Score":21,"Answer":"Not quite what you asked, but maybe what you want is os.isatty(sys.stdout.fileno()), which tells if stdout is connected to (roughly speaking) a terminal. It will be false if you pipe the output to a file or another process, or if the process is run from cron.","Q_Score":5,"Tags":"python,unix,terminal,cron","A_Id":2087031,"CreationDate":"2010-01-18T15:17:00.000","Title":"How can I determine if a python script is executed from crontab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how can I determine if a python script is executed from crontab?\nI don't want a solution that will require adding a parameter because I want to be able to detect this even from an imported module (not the main script).","AnswerCount":6,"Available Count":4,"Score":0.1651404129,"is_accepted":false,"ViewCount":4167,"Q_Id":2086961,"Users Score":5,"Answer":"Set an environment variable at the cron command invocation. That works even within a module, as you can just check os.getenv().","Q_Score":5,"Tags":"python,unix,terminal,cron","A_Id":2087053,"CreationDate":"2010-01-18T15:17:00.000","Title":"How can I determine if a python script is executed from crontab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We embed ironpython in our app sob that scripts can be executed in the context of our application.\nI use Python.CreateEngine() and ScriptScope.Execute() to execute python scripts.\nWe have out own editor(written in C#) that can load ironpython scripts and run it.\nThere are 2 problems I need to solve.\n\nIf I have a print statement in ironpython script, how can i show it my editor(how will I tell python engine to redirect output to some handler in my C# code)\nI plan to use unittest.py for running unittest. When I run the following \nrunner = unittest.TextTestRunner()\nrunner.run(testsuite)\n\nthe output is redirected to standard output but need a way for it to be redirected to my C# editor output window so that user can see the results.\nThis question might be related to 1\nAny help is appreciated\nG","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4586,"Q_Id":2089998,"Users Score":6,"Answer":"You can provide a custom Stream or TextWriter which will be used for all output.  You can provide those by using one of the ScriptRuntime.IO.SetOutput overloads.  Your implementation of Stream or TextWriter should receive the strings and then output them to your editor window (potentially marshalling back onto the UI thread if you're running the script on a 2ndary execution thread).","Q_Score":4,"Tags":"ironpython","A_Id":2090745,"CreationDate":"2010-01-18T23:31:00.000","Title":"Streaming Ironpython output to my editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am new to network programming in python. I wanted to know that what is the maximum size packet we can transmit or receive on python socket? and how to find out it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7528,"Q_Id":2091097,"Users Score":1,"Answer":"I don't think there's any Python-specific limits. UDP packets have a theoretical limit of circa 65kb and TCP no upper limit, but you'll have flow control problems if you use packets much more than a few kilobytes.","Q_Score":6,"Tags":"python,sockets,network-programming","A_Id":2091157,"CreationDate":"2010-01-19T04:35:00.000","Title":"What is the maximum packet size a python socket can handle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want use a model to save the system setting for a django app, So I want to limit the model can only have one record, how to do the limit?","AnswerCount":7,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9457,"Q_Id":2106823,"Users Score":11,"Answer":"An easy way is to use the setting's name as the primary key in the settings table. There can't be more than one record with the same primary key, so that will allow both Django and the database to guarantee integrity.","Q_Score":7,"Tags":"python,python-3.x,django,django-models,django-admin","A_Id":2106836,"CreationDate":"2010-01-21T03:58:00.000","Title":"Limit a single record in model for django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered \"thread safe\". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","AnswerCount":10,"Available Count":5,"Score":0.0199973338,"is_accepted":false,"ViewCount":3288,"Q_Id":2121617,"Users Score":1,"Answer":"Threads don't speed up applications. Algorithms speed up applications. Threads can be used in algorithms, if appropriate.","Q_Score":12,"Tags":"java,c++,python,perl,multithreading","A_Id":2121635,"CreationDate":"2010-01-23T01:06:00.000","Title":"Can Someone Explain Threads to Me?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered \"thread safe\". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","AnswerCount":10,"Available Count":5,"Score":0.0199973338,"is_accepted":false,"ViewCount":3288,"Q_Id":2121617,"Users Score":1,"Answer":"Threads are simply a way of executing multiple things simultaneously (assuming that the platform on which they are being run is capable of parallel execution).  Thread safety is simply (well, nothing with threads is truly simple) making sure that the threads don't affect each other in harmful ways.\nIn general, you are unlikely to see systems use multiple threads for rendering graphics on the screen due to the multiple performance implications and complexity issues that may arise from that.  Other tasks related to state management (or AI) can potentially be moved to separate threads however.","Q_Score":12,"Tags":"java,c++,python,perl,multithreading","A_Id":2121649,"CreationDate":"2010-01-23T01:06:00.000","Title":"Can Someone Explain Threads to Me?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered \"thread safe\". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","AnswerCount":10,"Available Count":5,"Score":0.0199973338,"is_accepted":false,"ViewCount":3288,"Q_Id":2121617,"Users Score":1,"Answer":"Well someone will probably answer this better, but threads are for the purpose of having background processing that won't freeze the user interface.  You don't want to stop accepting keyboard input or mouse input, and tell the user,  \"just a moment, I want to finish this computation, it will only be a few more seconds.\" (And yet its amazing how many times commercial programs do this.\nAs far as thread safe, it means a function that does not have some internal saved state.  If it did you couldn't have multiple threads using it simutaneously.\nAs far as thread programming you just have  to start doing it, and then you'll start encountering various issues unique to thread programming,  for example simultaneuous access to data, in which case you have to decide to use some syncronization method such as critical sections or mutexes or something else, each one having slightly different nuances in their behavior.\nAs far as the differences between processes and threads (which you didn't ask)  processes are an OS level entity, whereas threads are associated with a program.  In certain instances your program may want to create a process rather than a thread.","Q_Score":12,"Tags":"java,c++,python,perl,multithreading","A_Id":2121639,"CreationDate":"2010-01-23T01:06:00.000","Title":"Can Someone Explain Threads to Me?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered \"thread safe\". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","AnswerCount":10,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":3288,"Q_Id":2121617,"Users Score":32,"Answer":"This is a very broad topic.  But here are the things I would want to know if I knew nothing about threads:\n\nThey are units of execution within a single process that happen \"in parallel\" - what this means is that the current unit of execution in the processor switches rapidly.  This can be achieved via different means.   Switching is called \"context switching\", and there is some overhead associated with this.\nThey can share memory!  This is where problems can occur.  I talk about this more in depth in a later bullet point.\nThe benefit of parallelizing your application is that logic that uses different parts of the machine can happen simultaneously.  That is, if part of your process is I\/O-bound and part of it is CPU-bound, the I\/O intensive operation doesn't have to wait until the CPU-intensive operation is done.  Some languages also allow you to run threads at the same time if you have a multicore processor (and thus parallelize CPU-intensive operations as well), though this is not always the case.\nThread-safe means that there are no race conditions, which is the term used for problems that occur when the execution of your process depends on timing (something you don't want to rely on).  For example, if you have threads A and B both incrementing a shared counter C, you could see the case where A reads the value of C, then B reads the value of C, then A overwrites C with C+1, then B overwrites C with C+1.  Notice that C only actually increments once!\nA couple of common ways avoid race conditions include synchronization, which excludes mutual access to shared state, or just not having any shared state at all.  But this is just the tip of the iceberg - thread-safety is quite a broad topic.\n\nI hope that helps!  Understand that this was a very quick introduction to something that requires a good bit of learning.  I would recommend finding a resource about multithreading in your preferred language, whatever that happens to be, and giving it a thorough read.","Q_Score":12,"Tags":"java,c++,python,perl,multithreading","A_Id":2121638,"CreationDate":"2010-01-23T01:06:00.000","Title":"Can Someone Explain Threads to Me?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered \"thread safe\". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","AnswerCount":10,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":3288,"Q_Id":2121617,"Users Score":2,"Answer":"There are four things you should know about threads.\n\nThreads are like processes, but they share memory.\nThreads often have hardware, OS, and language support, which might make them better than processes. \nThere are lots of fussy little things that threads need to support (like locks and semaphores) so they don't get the memory they share into an inconsistent state. This makes them a little difficult to use.\nLocking isn't automatic (in the languages I know), so you have to be very careful with the memory they (implicitly) share.","Q_Score":12,"Tags":"java,c++,python,perl,multithreading","A_Id":2121691,"CreationDate":"2010-01-23T01:06:00.000","Title":"Can Someone Explain Threads to Me?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a python script that needs to do 3 things simultaneously.\nWhat is a good way to achieve this as do to what i've heard about the GIL i'm not so lean into using threads anymore.\n2 of the things that the script needs to do will be heavily active, they will have lots of work to do and then i need to have the third thing reporting to the user over a socket when he asks (so it will be like a tiny server) about the status of the other 2 processes.\nNow my question is what would be a good way to achieve this? I don't want to have three different script and also due to GIL using threads i think i won't get much performance and i'll make things worse.\nIs there a fork() for python like in C so from my script so fork 2 processes that will do their job and from the main process to report to the user? And how can i communicate from the forked processes with the main process?    \nLE:: to be more precise 1thread should get email from a imap server and store them into a database, another thread should get messages from db that needs to be sent and then send them and the main thread should be a tiny http server that will just accept one url and will show the status of those two threads in json format. So are threads oK? will the work be done simultaneously or due to the gil there will be performance issues?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":8102,"Q_Id":2123269,"Users Score":2,"Answer":"The GIL is really only something to care about if you want to do multiprocessing, that is spread the load over several cores\/processors. If that is the case, and it kinda sounds like it from your description, use multiprocessing.\nIf you just need to do three things \"simultaneously\" in that way that you need to wait in the background for things to happen, then threads are just fine. That's what threads are for in the first place. 8-I)","Q_Score":4,"Tags":"python,multithreading,multiprocess","A_Id":2123513,"CreationDate":"2010-01-23T13:27:00.000","Title":"python threading\/fork?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have an array of 27 elements,and i don't want to generate all permutations of array (27!)\ni need 5000 randomly choosed permutations,any tip will be useful...","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":38205,"Q_Id":2124347,"Users Score":1,"Answer":"You may want the itertools.permutations() function. Gotta love that itertools module!\nNOTE: New in 2.6","Q_Score":30,"Tags":"python,permutation","A_Id":2124356,"CreationDate":"2010-01-23T19:12:00.000","Title":"how to generate permutations of array in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed a TextMate bundle that I believe enables the ability for automatic closing of the \"{{\" markup (so that it will automatically close the markup with \"}}\"), but this does not seem to be possible with the other markup that uses \"{%\" and \"%}\".\nSo, I was wondering if anyone out there knows how to get TextMate to add the automatic closing tags for the {% %} just like is already done with {{ }}.\nAny help is appreciated!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":796,"Q_Id":2127956,"Users Score":2,"Answer":"It's possible - the Rails bundle does this for ERB (<% automatically gets closing %> tags).\nSo that's a place you could go look.","Q_Score":3,"Tags":"python,django,textmate","A_Id":2133642,"CreationDate":"2010-01-24T17:17:00.000","Title":"TextMate and Django Integration - Supporting {% %} markup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed a TextMate bundle that I believe enables the ability for automatic closing of the \"{{\" markup (so that it will automatically close the markup with \"}}\"), but this does not seem to be possible with the other markup that uses \"{%\" and \"%}\".\nSo, I was wondering if anyone out there knows how to get TextMate to add the automatic closing tags for the {% %} just like is already done with {{ }}.\nAny help is appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":796,"Q_Id":2127956,"Users Score":1,"Answer":"I don't think that's possible, but the Django bundle for TextMate does allow you to insert the opening and closing tags in one go, placing the cursor in the middle, with ctrl-% (ctrl-shift-5).\nClick the Bundles -> Python Django Templates menu to see all the shortcuts that are available.","Q_Score":3,"Tags":"python,django,textmate","A_Id":2128058,"CreationDate":"2010-01-24T17:17:00.000","Title":"TextMate and Django Integration - Supporting {% %} markup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"we are still pretty new to Postgres and came from Microsoft Sql Server.\nWe are wanting to write some stored procedures now. Well, after struggling to get something more complicated than a hello world to work in pl\/pgsql, we decided it's better if we are going to learn a new language we might as well learn Python because we got the same query working in it in about 15 minutes(note, none of us actually know python). \nSo I have some questions about it in comparison to pl\/psql. \n\nIs pl\/Pythonu slower than pl\/pgsql? \nIs there any kind of \"good\" reference for how to write good stored procedures using it? Five short pages in the Postgres documentation doesn't really tell us enough.\nWhat about query preparation? Should it always be used? \nIf we use the SD and GD arrays for a lot of query plans, will it ever get too full or have a negative impact on the server? Will it automatically delete old values if it gets too full?\nIs there any hope of it becoming a trusted language? \n\nAlso, our stored procedure usage is extremely light. Right now we only have 4, but we are still trying to convert little bits of code over from Sql Server specific syntax(such as variables, which can't be used in Postgres outside of stored procedures)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5869,"Q_Id":2141589,"Users Score":9,"Answer":"Depends on what operations you're doing.\nWell, combine that with a general Python documentation, and that's about what you have.\nNo. Again, depends on what you're doing. If you're only going to run a query once, no point in preparing it separately.\nIf you are using persistent connections, it might. But they get cleared out whenever a connection is closed.\nNot likely. Sandboxing is broken in Python and AFAIK nobody is really interested in fixing it. I heard someone say that python-on-parrot may be the most viable way, once we have pl\/parrot (which we don't yet).\n\nBottom line though - if your stored procedures are going to do database work, use pl\/pgsql. Only use pl\/python if you are going to do non-database stuff, such as talking to external libraries.","Q_Score":11,"Tags":"python,postgresql,stored-procedures,plpgsql","A_Id":2142128,"CreationDate":"2010-01-26T18:19:00.000","Title":"Stored Procedures in Python for PostgreSQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to know the current time at CDT when my Python script is run. However this script will be run in multiple different timezones so a simple offset won't work. \nI only need a solution for Linux, but a cross platform solution would be ideal.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1946,"Q_Id":2152471,"Users Score":4,"Answer":"You can use time.gmtime() to get time GMT (UTC) from any machine no matter the timezone, then you can apply your offset.","Q_Score":5,"Tags":"python,linux,datetime,timezone","A_Id":2152511,"CreationDate":"2010-01-28T05:19:00.000","Title":"how to find time at particular timezone from anywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently expanded the names corpus in nltk and would like to know how I can turn the two files I have (male.txt, female.txt) in to a corpus so I can access them using the existing nltk.corpus methods. Does anyone have any suggestions?\nMany thanks,\nJames.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6842,"Q_Id":2168793,"Users Score":0,"Answer":"Alex is right, start with the docs, and figure out which corpus reader will work for your corpus. The simple instantiate it, given the path to your corpus file(s). As you'll see in the docs, the builtin corpora are simply instances of particular corpus reader classes. Look thru the code in the nltk.corpus package should be helpful as well.","Q_Score":4,"Tags":"python,nlp,nltk","A_Id":2226080,"CreationDate":"2010-01-30T17:48:00.000","Title":"How can I create my own corpus in the Python Natural Language Toolkit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently expanded the names corpus in nltk and would like to know how I can turn the two files I have (male.txt, female.txt) in to a corpus so I can access them using the existing nltk.corpus methods. Does anyone have any suggestions?\nMany thanks,\nJames.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":6842,"Q_Id":2168793,"Users Score":1,"Answer":"Came to understand how corpus reading works by looking at the source code in nltk.corpus and then looking at the corpora (located in \/home\/[user]\/nltk_data\/corpora\/names - this will probably be in My Documents for XP and somewhere in User for Win7 users).\nThe structure of the corpus and its related function will give a good understanding of how to use the different corpora available in NLTK.\nIn my case I looked at the names variable in nltk.corpus' source code and was interested in the WordListCorpusReader function as the names corpus is simply a list of words.","Q_Score":4,"Tags":"python,nlp,nltk","A_Id":2355858,"CreationDate":"2010-01-30T17:48:00.000","Title":"How can I create my own corpus in the Python Natural Language Toolkit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know Ctrl + F9 runs a single file.\nHow to run them all?\nIf there is no such thing, how to bind one keyboard shortcut to it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5179,"Q_Id":2173212,"Users Score":1,"Answer":"Go to the preferences and type in keys to get to the keyboard shortcut definition page (I think it's called keys... sorry not on my dev machine right now).  In this dialog you can search for commands.  See if there is a run all tests command (it might help to find the run tests you are currently using first).  If there is check out the shortcut or define your own.","Q_Score":7,"Tags":"eclipse,unit-testing,pydev,python-unittest","A_Id":2220154,"CreationDate":"2010-01-31T20:37:00.000","Title":"What is the keyboard shortcut to run all unit tests in the current project in PyDev + Eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am planning to use Jython with Django. I want to know how stable the Jython project is, how easy to use it is, and how large its developer community is.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":462,"Q_Id":2179395,"Users Score":2,"Answer":"I use Jython in testing and rapid-development. \nFrom my point of view it is stable.","Q_Score":5,"Tags":"python,jython","A_Id":2191492,"CreationDate":"2010-02-01T19:19:00.000","Title":"Using Jython with Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am planning to use Jython with Django. I want to know how stable the Jython project is, how easy to use it is, and how large its developer community is.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":462,"Q_Id":2179395,"Users Score":3,"Answer":"I have not used Django with Jython, so I can't speak to that specific issue, but I've used Jython for other things and I've found it quite stable of late, and just as easy as plain Python.  I believe the \"core committers\" in Jython are substantially fewer than in C-Python (maybe 1\/3 the number or less), if that's what you mean by \"developer community\", but I'm not quite sure what's the point in asking about this -- are you considering joining either developer community (Jython or Core Python) and wondering where you could have the best impact?\nIf that's the case, I think the key issue isn't really how many others are already helping out, but, \"what do you bring to the party\" -- if you're a JVM wizard, or an expert at any important Java framework, you could be a real boon to the Jython community while that same skill would help much less in the C-Python community; vice versa, if you're a wizard, say, with autoconfigure and C-coded system calls, that would be precious for the C-Python community, but not as useful for the Jython community.","Q_Score":5,"Tags":"python,jython","A_Id":2181008,"CreationDate":"2010-02-01T19:19:00.000","Title":"Using Jython with Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how do you find the number of digits in an integer?","AnswerCount":28,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":610171,"Q_Id":2189800,"Users Score":427,"Answer":"If you want the length of an integer as in the number of digits in the integer, you can always convert it to string like str(133) and find its length like len(str(123)).","Q_Score":324,"Tags":"python,count,integer","A_Id":2189814,"CreationDate":"2010-02-03T04:56:00.000","Title":"How to find length of digits in an integer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how do you find the number of digits in an integer?","AnswerCount":28,"Available Count":2,"Score":0.0142847425,"is_accepted":false,"ViewCount":610171,"Q_Id":2189800,"Users Score":2,"Answer":"Assuming you are asking for the largest number you can store in an integer, the value is implementation dependent. I suggest that you don't think in that way when using python. In any case, quite a large value can be stored in a python 'integer'. Remember, Python uses duck typing!\nEdit:\nI gave my answer before the clarification that the asker wanted the number of digits. For that, I agree with the method suggested by the accepted answer. Nothing more to add!","Q_Score":324,"Tags":"python,count,integer","A_Id":2189821,"CreationDate":"2010-02-03T04:56:00.000","Title":"How to find length of digits in an integer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Previously I got a suggedtion to Install the FreeType dev files and rebuild PIL again.\nbut I have no idea how to do it.\nany help will be thanked for","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":2190711,"Users Score":0,"Answer":"You do it exactly the same way as you did before, but now with the FreeType-dev files installed.","Q_Score":0,"Tags":"python","A_Id":2190882,"CreationDate":"2010-02-03T08:54:00.000","Title":"Rebuilding PIL with FreeType","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you have a method called \"set\" in a class and want to create a standard builtin \"set\" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin \"set\", not the method \"set\"? More specifically, set() is being created in an _____exit_____ function.","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":582,"Q_Id":2195755,"Users Score":3,"Answer":"Object attributes are always accessed via a reference, so there is no way for an object attribute to shadow a builtin.","Q_Score":1,"Tags":"python","A_Id":2195789,"CreationDate":"2010-02-03T21:52:00.000","Title":"Python class has method \"set\", how to reference builtin set type?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you have a method called \"set\" in a class and want to create a standard builtin \"set\" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin \"set\", not the method \"set\"? More specifically, set() is being created in an _____exit_____ function.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":582,"Q_Id":2195755,"Users Score":2,"Answer":"Usually method names are disambiguated from global names because you have to prefix self..\nSo self.set() invokes your class method and set() invokes the global set.\nIf this doesn't help, perhaps post the code you're having trouble with.","Q_Score":1,"Tags":"python","A_Id":2195786,"CreationDate":"2010-02-03T21:52:00.000","Title":"Python class has method \"set\", how to reference builtin set type?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you have a method called \"set\" in a class and want to create a standard builtin \"set\" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin \"set\", not the method \"set\"? More specifically, set() is being created in an _____exit_____ function.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":582,"Q_Id":2195755,"Users Score":2,"Answer":"You can refer to built-in set as __builtins__.set.","Q_Score":1,"Tags":"python","A_Id":2195807,"CreationDate":"2010-02-03T21:52:00.000","Title":"Python class has method \"set\", how to reference builtin set type?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building an app on GAE that needs to report on events occurring. An event has a type and I also need to report by event type.\nFor example, say there is an event A, B and C. They occur periodically at random. User logs in and creates a set of entities to which those events can be attributed. When the user comes back to check the status, I need to be able to tell how many events of A, B and\/or C occurred during a specific time range, say a day or a month.\nThe 1000 limit is throwing a wrench into how I would normally do it. I don't need to retrieve all of the entities and present them to the user, but I do need to show the total count for a specific date range. Any suggestions?\nI'm a bit of python\/GAE noob...","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4016,"Q_Id":2201580,"Users Score":3,"Answer":"Results of datastore count() queries\n  and offsets for all datastore queries\n  are no longer capped at 1000.\n\nSince Version 1.3.6","Q_Score":4,"Tags":"python,google-app-engine,google-cloud-datastore","A_Id":4088516,"CreationDate":"2010-02-04T17:02:00.000","Title":"Need a way to count entities in GAE datastore that meet a certain condition? (over 1000 entities)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"what i want, is to receive advices to define a re-usefull Product model, for a shopping site app, nowadays I know that the store is going to commerce with \"clothing\", so the product model will have a \"season or collections\" relationship, but in the future I should use that app to commerce with X product, e.g: \"cars\" which have \"mechanical specifications\" relationships.\nSo Im thinking in metamodels, creating a generic model defined by key\/values, but, how to make the relationships?.\nBut, you are the experts community and I hope you help me to see beyond.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":580,"Q_Id":2207562,"Users Score":0,"Answer":"One, popular, option would be to use something like tags.  So you'd have the stuff that's common to all items, like an item ID, name, description, price.  Then you'd have some more generic tags or described tags in another table, associated with those items.  You could have a tag that represents the season, or automobile specifications, etc...\nOf course, it really depends on how you design the system to cope with that additional information.","Q_Score":1,"Tags":"python,django","A_Id":2207718,"CreationDate":"2010-02-05T13:44:00.000","Title":"How to write dynamic Django models?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how I would go about detected what bit version Windows is under Python.  I need to know this as a way of using the right folder for Program Files.\nMany thanks","AnswerCount":22,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":46662,"Q_Id":2208828,"Users Score":6,"Answer":"Many of these proposed solutions, such as platform.architecture(), fail because their results depend on whether you are running 32-bit or 64-bit Python.\nThe only reliable method I have found is to check for the existence of os.environ['PROGRAMFILES(X86)'], which is unfortunately hackish.","Q_Score":41,"Tags":"python,windows,64-bit","A_Id":3740665,"CreationDate":"2010-02-05T16:55:00.000","Title":"Detect 64bit OS (windows) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how I would go about detected what bit version Windows is under Python.  I need to know this as a way of using the right folder for Program Files.\nMany thanks","AnswerCount":22,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":46662,"Q_Id":2208828,"Users Score":38,"Answer":"I guess you should look in os.environ['PROGRAMFILES'] for the program files folder.","Q_Score":41,"Tags":"python,windows,64-bit","A_Id":2208869,"CreationDate":"2010-02-05T16:55:00.000","Title":"Detect 64bit OS (windows) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how I would go about detected what bit version Windows is under Python.  I need to know this as a way of using the right folder for Program Files.\nMany thanks","AnswerCount":22,"Available Count":4,"Score":-0.0181798149,"is_accepted":false,"ViewCount":46662,"Q_Id":2208828,"Users Score":-2,"Answer":"There should be a directory under Windows 64bit, a Folder called \\Windows\\WinSxS64 for 64 bit, under Windows 32bit, it's WinSxS.","Q_Score":41,"Tags":"python,windows,64-bit","A_Id":2208946,"CreationDate":"2010-02-05T16:55:00.000","Title":"Detect 64bit OS (windows) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how I would go about detected what bit version Windows is under Python.  I need to know this as a way of using the right folder for Program Files.\nMany thanks","AnswerCount":22,"Available Count":4,"Score":0.0272659675,"is_accepted":false,"ViewCount":46662,"Q_Id":2208828,"Users Score":3,"Answer":"You should be using environment variables to access this. The program files directory is stored in the environment variable PROGRAMFILES on x86 Windows, the 32-bit program files is directory is stored in the PROGRAMFILES(X86) environment variable, these can be accessed by using os.environ('PROGRAMFILES').\nUse sys.getwindowsversion() or the existence of PROGRAMFILES(X86) (if 'PROGRAMFILES(X86)' in os.environ) to determine what version of Windows you are using.","Q_Score":41,"Tags":"python,windows,64-bit","A_Id":2209113,"CreationDate":"2010-02-05T16:55:00.000","Title":"Detect 64bit OS (windows) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am seeking direction and attempting to label this problem:\nI am attempting to build a simple inference engine (is there a better name?) in Python which will take a string and -\n1 - create a list of tokens by simply creating a list of white space separated values\n2 - categorise these tokens, using regular expressions\n3 - Use a higher level set of rules to make decisions based on the categorisations\nExample:\n\"90001\" - one token, matches the zipcode regex, a rule exists for a string containing just a zipcode causes a certain behaviour to occur\n\"30 + 14\" - three tokens, regexs for numerical value and mathematical operators match, a rule exists for a numerical value followed by a mathematical operator followed by another numerical value causes a certain behaviour to occur\nI'm struggling with how best to do step #3, the higher level set of rules.  I'm sure that some framework must exist.  Any ideas?  Also, how would you characterise this problem? Rule based system, expert system, inference engine, something else?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3788,"Q_Id":2211967,"Users Score":2,"Answer":"It looks like you search for \"grammar inference\" (grammar induction) library.","Q_Score":8,"Tags":"python,parsing,rule-engine,expert-system","A_Id":7619477,"CreationDate":"2010-02-06T03:57:00.000","Title":"Building an Inference Engine in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is not a homework, I am just curious.\nINFINITE is the key word here.\nI wish to use it as for p in primes(). I believe that this is a built-in function in Haskell.\nSo, the answer cannot be as naive as \"Just do a Sieve\".\nFirst of all, you do not know how many consecutive primes will be consumed. Well, suppose you could concoct 100 of them at a time. Would you use the same Sieve approach as well as the frequency of prime numbers formula?\nI prefer non-concurrent approach.\nThank you for reading (and writing ;) )!","AnswerCount":12,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":30775,"Q_Id":2211990,"Users Score":6,"Answer":"Do a segmented sieve, where the size of a segment is determined by available memory or the maximal size of a bitset.\nFor each segment represent the numbers in some interval [n; n + segment_size) as a bit set and sieve with all prime numbers below the square root of the upper bound.\nUsing a bit set uses less memory than a hash table or tree data structure, because you are working with dense sets of numbers.","Q_Score":68,"Tags":"python,generator,primes","A_Id":2212842,"CreationDate":"2010-02-06T04:04:00.000","Title":"How to implement an efficient infinite generator of prime numbers in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't see any provision for this in the django docs, so how do people go about doing this.\nMy specific case is this.\nI have a shopping cart, each cart instance has an invoice number field, however the invoice number is only generated if the cart goes to a paid status, so not all shopping cart instances will have an invoice number. I want all invoice numbers to be sequential with no gaps between them, so the default pk isn't perfect in this case, so I want a class variable that acts as a counter for the invoice numbers, and is accessable by all instances.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":680,"Q_Id":2213595,"Users Score":1,"Answer":"The default primary key will already be a unique monotonic integer (even in SQLite if you don't delete any records), so you can just use that for it.","Q_Score":2,"Tags":"python,django-models","A_Id":2213602,"CreationDate":"2010-02-06T15:27:00.000","Title":"how do people normally deal with class variables in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own.\nIf so, how do I do it? Can you point me to good docs on the subject?","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1414,"Q_Id":2222843,"Users Score":10,"Answer":"No, you cannot add new syntax within a Python program.  The only way to alter the language is to edit and recompile the grammar file and supporting C code, to obtain a new altered interpreter, compiler and runtime.","Q_Score":6,"Tags":"python,syntax,keyword,statements","A_Id":2222867,"CreationDate":"2010-02-08T15:58:00.000","Title":"Making your own statements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own.\nIf so, how do I do it? Can you point me to good docs on the subject?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1414,"Q_Id":2222843,"Users Score":1,"Answer":"There are programming languages that let you do this (Tcl, for example), but Python isn't one of those languages.","Q_Score":6,"Tags":"python,syntax,keyword,statements","A_Id":2223039,"CreationDate":"2010-02-08T15:58:00.000","Title":"Making your own statements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own.\nIf so, how do I do it? Can you point me to good docs on the subject?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":1414,"Q_Id":2222843,"Users Score":3,"Answer":"You can't (re)define language keywords without rewriting a compiler\/interpreter\/etc.  What you could do perhaps is write a something like a DSL (domain-specific language) and something that translates your keyword statements into proper python statements, which might be an easier route.","Q_Score":6,"Tags":"python,syntax,keyword,statements","A_Id":2222909,"CreationDate":"2010-02-08T15:58:00.000","Title":"Making your own statements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to write a small gui app in pygtk which needs an html-rendering widget.  I'd like to be able to use it in a windows environment.\nCurrently I'm using pywebkitgtk on my GNU\/Linux system, and it works extremely well, but it seems it's not possible to use this on Windows at this time.\nCan anyone give me any suggestions on how to proceed?  Do I need to work out how to embed IE using COM objects under Windows, and stick with pywebkitgtk on GNU\/Linux?\nI'm at an early stage, and am prepared to jettison pygtk in favour of another toolkit, say pyqt, if it affords a simpler solution (though I'd sooner stick with pygtk if possible).","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1076,"Q_Id":2227770,"Users Score":2,"Answer":"In my experience, having developed cross-platform applications with both PyQt and PyGTK, you should consider moving to PyQt. It comes with a browser widget by default which runs fine on all platforms, and support for non-Linux platforms is outstanding compared to PyGTK. For PyGTK, you will have to be prepared building PyGObject\/PyCairo\/PyGTK, or even the full stack, yourself on Windows and Mac OS X.","Q_Score":0,"Tags":"python,cross-platform,pyqt,pygtk,html-rendering","A_Id":2227957,"CreationDate":"2010-02-09T08:48:00.000","Title":"cross-platform html widget for pygtk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie at Django and I want to do something that I'm not sure how to do.\nI have a model SimplePage, which simply stands for a webpage that is visible on the website and whose contents can be edited in the admin. (I think this is similar to FlatPage.)\nSo I have a bunch of SimplePages for my site, and I want one of them to be the main page. (a.k.a. the index page.) I know how to make it available on the url \/. But I also want it to receive slightly different processing. (It contains different page elements than the other pages.)\nWhat would be a good way to mark a page as the main page? I considered adding a boolean field is_main_page to the SimplePage model, but how could I assure that only one page could be marked as the main page?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":2229640,"Users Score":1,"Answer":"Create MAIN_PAGE setting inside settings.py with primary key. Then create view main_page nad retrieve the main_page object from the database using the setting.\nEDIT:\nYou can also do it like this: add a model, which will reference a SimplePage and point to the main page. In main page view, you will retrieve the wanted SimplePage and it can be easily changed by anyone in django admin.","Q_Score":0,"Tags":"python,django","A_Id":2229654,"CreationDate":"2010-02-09T14:13:00.000","Title":"Django: Setting one page as the main page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I get a glib gpointer to a glib gslist and would like to iterate over the latter, how would I do it?\nI don't even know how to get to the gslist with the gpointer for starters!\nUpdate: I found a workaround - the python bindings in this instance wasn't complete so I had to find another solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":647,"Q_Id":2234056,"Users Score":0,"Answer":"How is glib exposed to Python in your application? Via SWIG, ctypes or something else? \nYou should basically use glib's own functions to iterate over a list. Something like g_slist_foreach. Just pass it the pointer and its other parameters to do the job. Again, this heavily depends on how you access glib in your Python application.","Q_Score":0,"Tags":"python,glib","A_Id":2234282,"CreationDate":"2010-02-10T02:38:00.000","Title":"how do I iterate over a \"gslist\" in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a script which pulls some XML from a remote server. If this script is running on any server other than production, it works.\nUpload it to production however, and it fails. It is using cURL for the request but it doesn't matter how we do it - fopen, file_get_contents, sockets - it just times out. This also happens if I use a Python script to request the URL.\nThe same script, supplied with another URL to query, works - every time. Obviously it doesn't return the XML we're looking for but it DOES return SOMETHINg - it CAN connect to the remote server. \nIf this URL is requested via the command line using, for example, curl or wget, again, data is returned. It's not the data we're looking for (in fact, it returns an empty root element) but something DOES come back.\nInterestingly, if we strip out query string elements from the URL (the full URL has 7 query string elements and runs to about 450 characters in total) the script will return the same empty XML response. Certain combinations of the query string will once again cause the script to time out.\nThis, as you can imagine, has me utterly baffled - it seems to work in every circumstance EXCEPT the one it needs to work in. We can get a response on our dev servers, we can get a response on the command line, we can get a response if we drop certain QS elements - we just can't get the response we want with the correct URL on the LIVE server.\nDoes anyone have any suggestions at all? I'm at my wits end!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":606,"Q_Id":2236864,"Users Score":1,"Answer":"Run Wireshark and see how far the request goes. Could be a firewall issue, a DNS resolution problem, among other things.\nAlso, try bumping your curl timeout to something much higher, like 300s, and see how it goes.","Q_Score":0,"Tags":"php,python,xml,apache,curl","A_Id":2236930,"CreationDate":"2010-02-10T12:54:00.000","Title":"PHP \/ cURL problem opening remote file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project where I need to store a matrix of numbers indexed by two string keys.  The matrix is not jagged, i.e. if a column key exists for any row then it should exist for all rows.  Similarly, if a row key exists for any column then it should exist for all columns.\nThe obvious way to express this is with an associative array of associative arrays, but this is both awkward and inefficient, and it doesn't enforce the non-jaggedness property.  Do any popular programming languages provide an associative matrix either built into the language or as part of their standard libraries?  If so, how do they work, both at the API and implementation level?  I'm using Python and D for this project, but examples in other languages would still be useful because I would be able to look at the API and figure out the best way to implement something similar in Python or D.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":566,"Q_Id":2247197,"Users Score":2,"Answer":"Why not just use a standard matrix, but then have two dictionaries - one that converts the row keys to row indices and one that converts the columns keys to columns indices. You could make your own structure that would work this way fairly easily I think. You just make a class that contains the matrix and the two dictionaries and go from there.","Q_Score":6,"Tags":"python,data-structures,matrix,d,associative-array","A_Id":2247284,"CreationDate":"2010-02-11T19:39:00.000","Title":"Associative Matrices?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Downloading logs from App Engine is nontrivial. Requests are batched; appcfg.py does not use normal file IO but rather a temporary file (in reverse chronological order) which it ultimately appends to the local log file; when appending, the need to find the \"sentinel\" makes log rotation difficult since one must leave enough old logs for appcfg.py to remember where it left off. Finally, Google deletes old logs after some time (20 minutes for the app I use).\nAs an app scales, and the log generation rate grows, how can one increase the speed of fetching the logs so that appcfg.py does not fall behind?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":499,"Q_Id":2249530,"Users Score":1,"Answer":"You can increase the per-request batch size of logs. In the latest SDK (1.3.1), check out google_appengine\/google\/appengine\/tools\/appcfg.py around like 861 (RequestLogLines method of LogsRequester class). You can modify the \"limit\" parameter.\nI am using 1000 and it works pretty well.","Q_Score":1,"Tags":"python,google-app-engine,logging","A_Id":2249540,"CreationDate":"2010-02-12T03:40:00.000","Title":"How to improve the throughput of request_logs on Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A friend asked me about creating a small web interface that accepts some inputs, sends them to MATLAB for number crunching and outputs the results. I'm a Python\/Django developer by trade, so I can handle the web interface, but I am clueless when it comes to MATLAB. Specifically:\n\nI'd really like to avoid hosting this on a Windows server. Any issues getting MATLAB running in Linux with scripts created on Windows?\nShould I be looking into shelling out commands or compiling it to C and using ctypes to interact with it?\nIf compiling is the way to go, is there anything I should know about getting it compiled and working in Python? (It's been a long time since I've compiled or worked with C)\n\nAny suggestions, tips, or tricks on how to pull this off?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":23758,"Q_Id":2255942,"Users Score":1,"Answer":"Regarding OS compatibility, if you use the matlab version for Linux, the scripts written in windows should work without any changes. \nIf possible, you may also consider the possibility of doing everything with python. Scipy\/numpy with Matplotlib provide a complete Matlab replacement.","Q_Score":24,"Tags":"python,matlab,ctypes","A_Id":2257221,"CreationDate":"2010-02-13T00:12:00.000","Title":"How do I interact with MATLAB from Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Short version: How do you deploy your Django servers? What application server, front-end (if any, and by front-end I mean reverse proxy), and OS do you run it on? Any input would be greatly appreciated, I'm quite a novice when it comes to Python and even more as a server administrator.\nLong version:\nI'm migrating between server hosts, so much for weekends... it's not all bad, though. I have the opportunity to move to a different, possibly better \"deployment\" of Django.\nCurrently I'm using Django through Tornado's WSGI interface with an nginx front-end on Debian Lenny. I'm looking to move into the Rackspace Cloud so I've been given quite a few choices when it comes to OS:\n\nDebian 5.0 (Lenny)\nFC 11 or 12\nUbuntu 9.10 or 8.04 (LTS)\nCentOS 5.4\nGentoo 10.1\nArch Linux 2009.02\n\nWhat I've gathered is this:\nLinux Distributions\nDebian and CentOS are very slow to release non-bugfix updates of software, since they focus mainly on stability. Is this good or bad? I can see stability being a good thing, but the fact that I can't get Python 2.6 without quite a headache of replacing Python 2.4 is kind of a turn-off--and if I do, then I'm stuck when it comes to ever hoping to use apt\/yum to install a Python library (it'll try to reinstall Python 2.4).\nUbuntu and Fedora seem very... ready to go. Almost too ready to go, it's like everything it already done. I like to tinker with things and I prefer to know what's installed and how it's configured versus hitting the ground running with a \"cookie-cutter\" setup (no offense intended, it's just the best way to describe what I'm trying to say). I've been playing around with Fedora and I was pleasently surprised to find that pycurl, simplejson and a bunch of other libraries were already installed; that raised the question, though, what else is installed? I run a tight ship on a very small VPS, I prefer to run only what I need.\nThen there's Gentoo... I've managed to install Gentoo on my desktop (took a week, almost) and ended up throwing it out after quite a few events where I wanted to do something and had to spend 45 minutes recompiling software with new USE flags so I can parse PNG's through PIL. I've wondered though, is Gentoo good for something \"static\" like a server? I know exactly what I'm going to be doing on my server, so USE flags will change next to never. It optimizes compiles to fit the needs of what you tell it to, and nothing more--something I could appreciate running on minimal RAM and HDD space. I've heard, though, that Gentoo has a tendency to break when you attempt to update the software on it... that more than anything else has kept me away from it for now.\nI don't know anything about Arch Linux. Any opinions on this distro would be appreciated.\nWeb Server\nI've been using Tornado and I can safely say it's been the biggest hassle to get running. I had to write my own script to prefork it since, at the time I setup this server, I was probably around 10% of Tornado's user-base (not counting FriendFeed). I have to then setup another \"watchdog\" program to make sure those forks don't misbehave. The good part is, though, it uses around 40MB of RAM to run all 7 of my Django powered sites; I liked that, I liked that a lot.\nI've been using nginx as a front-end to Tornado, I could run nginx right in front of Django FastCGI workers, but those don't have the reliability of Tornado when you crank up the concurrency level. This isn't really an option for me, but I figured I might as well list it.\nThere's also Apache, which Django recommends you use through mod_wsgi. I personally don't like Apache that much, I understand it's very, very, very mature and what not, but it just seems so... fat, compared to nginx and lighttpd. Apache\/mod_python isn't even an option, as I have very limited RAM.\nSegue to Lighttpd! Not much to say here, I've never used it. I've heard you can run it in front of Apache\/mod_wsgi or run it in front of Django FastCGI workers, also. I've heard it has minor memory leaking issues, I'm sure that could be solved with a cron job, though.\nWhat I'm looking for is what you have seen as the \"best\" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.","AnswerCount":4,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":3882,"Q_Id":2256987,"Users Score":4,"Answer":"Update your question to remove the choices that don't work.  If it has Python 2.4, and an installation is a headache, just take it off the list, and update the question to list the real candidates.  Only list the ones that actually fit your requirements.  (You don't say what your requirements are, but minimal upgrades appears to be important.)\nToss a coin.  \n\nWhen choosing between two platforms which meet your requirements (which you haven't identified) tossing a coin is the absolute best way to choose.\nIf you're not sure if something matches your requirements, it's often good to enumerate what you value.  So far, the only thing in the question that you seem to value is \"no installations\".  Beyond that, I can only guess at what requirements you actually have.\nOnce you've identified the set of features you're looking for, feel free to toss a coin.  \nNote that Linux distributions all have more-or-less the same open-source code base.  Choosing among them is a preference for packaging, support and selection of pre-integrated elements of the existing Linux code base.  Just toss a coin.\nChoosing among web front-ends is entirely a question of what features you require.  Find all the web front-ends that meet your requirements and toss a coin to choose among them.\nNone of these are \"lock-in\" decisions.  If you don't like the linux distro you chose initially, you can simply chose another.  They all have the same basic suite of apps and the same API's.  The choice is merely a matter of preference.\nDon't like the web server you chose?  At the end of the mod_wsgi pipe, they all appear the same to your Django app (plus or minus a few config changes).  Don't like lighttpd?  Switch to nginx or Apache -- your Django app doesn't change.  So there's no lock-in and no negative consequences to making a sub-optimal choice.\nWhen there's no down-side risk, just toss a coin.","Q_Score":9,"Tags":"python,linux,django,deployment,webserver","A_Id":2257323,"CreationDate":"2010-02-13T08:47:00.000","Title":"Recommended Django Deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Short version: How do you deploy your Django servers? What application server, front-end (if any, and by front-end I mean reverse proxy), and OS do you run it on? Any input would be greatly appreciated, I'm quite a novice when it comes to Python and even more as a server administrator.\nLong version:\nI'm migrating between server hosts, so much for weekends... it's not all bad, though. I have the opportunity to move to a different, possibly better \"deployment\" of Django.\nCurrently I'm using Django through Tornado's WSGI interface with an nginx front-end on Debian Lenny. I'm looking to move into the Rackspace Cloud so I've been given quite a few choices when it comes to OS:\n\nDebian 5.0 (Lenny)\nFC 11 or 12\nUbuntu 9.10 or 8.04 (LTS)\nCentOS 5.4\nGentoo 10.1\nArch Linux 2009.02\n\nWhat I've gathered is this:\nLinux Distributions\nDebian and CentOS are very slow to release non-bugfix updates of software, since they focus mainly on stability. Is this good or bad? I can see stability being a good thing, but the fact that I can't get Python 2.6 without quite a headache of replacing Python 2.4 is kind of a turn-off--and if I do, then I'm stuck when it comes to ever hoping to use apt\/yum to install a Python library (it'll try to reinstall Python 2.4).\nUbuntu and Fedora seem very... ready to go. Almost too ready to go, it's like everything it already done. I like to tinker with things and I prefer to know what's installed and how it's configured versus hitting the ground running with a \"cookie-cutter\" setup (no offense intended, it's just the best way to describe what I'm trying to say). I've been playing around with Fedora and I was pleasently surprised to find that pycurl, simplejson and a bunch of other libraries were already installed; that raised the question, though, what else is installed? I run a tight ship on a very small VPS, I prefer to run only what I need.\nThen there's Gentoo... I've managed to install Gentoo on my desktop (took a week, almost) and ended up throwing it out after quite a few events where I wanted to do something and had to spend 45 minutes recompiling software with new USE flags so I can parse PNG's through PIL. I've wondered though, is Gentoo good for something \"static\" like a server? I know exactly what I'm going to be doing on my server, so USE flags will change next to never. It optimizes compiles to fit the needs of what you tell it to, and nothing more--something I could appreciate running on minimal RAM and HDD space. I've heard, though, that Gentoo has a tendency to break when you attempt to update the software on it... that more than anything else has kept me away from it for now.\nI don't know anything about Arch Linux. Any opinions on this distro would be appreciated.\nWeb Server\nI've been using Tornado and I can safely say it's been the biggest hassle to get running. I had to write my own script to prefork it since, at the time I setup this server, I was probably around 10% of Tornado's user-base (not counting FriendFeed). I have to then setup another \"watchdog\" program to make sure those forks don't misbehave. The good part is, though, it uses around 40MB of RAM to run all 7 of my Django powered sites; I liked that, I liked that a lot.\nI've been using nginx as a front-end to Tornado, I could run nginx right in front of Django FastCGI workers, but those don't have the reliability of Tornado when you crank up the concurrency level. This isn't really an option for me, but I figured I might as well list it.\nThere's also Apache, which Django recommends you use through mod_wsgi. I personally don't like Apache that much, I understand it's very, very, very mature and what not, but it just seems so... fat, compared to nginx and lighttpd. Apache\/mod_python isn't even an option, as I have very limited RAM.\nSegue to Lighttpd! Not much to say here, I've never used it. I've heard you can run it in front of Apache\/mod_wsgi or run it in front of Django FastCGI workers, also. I've heard it has minor memory leaking issues, I'm sure that could be solved with a cron job, though.\nWhat I'm looking for is what you have seen as the \"best\" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":3882,"Q_Id":2256987,"Users Score":3,"Answer":"At the place I rent server, they have shaved down the Ubuntu images to bare minimum. Presumably because they had to make a special image anyway with just the right drivers and such in it, but I don't know exactly.\nThey have even removed wget and nano. So you get all the apt-get goodness and not a whole lot of \"cookie-cutter\" OS.\nJust saying this because I would imagine that this is the way it is done almost everywhere and therefore playing around with a normal Ubuntu-server install will not provide you with the right information to make your decision.\nOther than that, I agree with the others, that it is not much of a lock-in so you could just try something.\nOn the webserver-side I would suggest taking a look at cherokee, if have not done so already.\nIt might not be your cup of joe, but there is no harm in trying it.\nI prefer the easy setup of both Ubuntu and Cherokee. Although I play around with a lot of things for fun, I prefer these for my business. I have other things to do than manage servers, so any solution that helps me do it faster, is just good. If these projects are mostly for fun then this will most likely not apply since you won't get a whole lot of experience from these easy-setup-with-nice-gui-and-very-helpfull-wizards","Q_Score":9,"Tags":"python,linux,django,deployment,webserver","A_Id":2257450,"CreationDate":"2010-02-13T08:47:00.000","Title":"Recommended Django Deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Short version: How do you deploy your Django servers? What application server, front-end (if any, and by front-end I mean reverse proxy), and OS do you run it on? Any input would be greatly appreciated, I'm quite a novice when it comes to Python and even more as a server administrator.\nLong version:\nI'm migrating between server hosts, so much for weekends... it's not all bad, though. I have the opportunity to move to a different, possibly better \"deployment\" of Django.\nCurrently I'm using Django through Tornado's WSGI interface with an nginx front-end on Debian Lenny. I'm looking to move into the Rackspace Cloud so I've been given quite a few choices when it comes to OS:\n\nDebian 5.0 (Lenny)\nFC 11 or 12\nUbuntu 9.10 or 8.04 (LTS)\nCentOS 5.4\nGentoo 10.1\nArch Linux 2009.02\n\nWhat I've gathered is this:\nLinux Distributions\nDebian and CentOS are very slow to release non-bugfix updates of software, since they focus mainly on stability. Is this good or bad? I can see stability being a good thing, but the fact that I can't get Python 2.6 without quite a headache of replacing Python 2.4 is kind of a turn-off--and if I do, then I'm stuck when it comes to ever hoping to use apt\/yum to install a Python library (it'll try to reinstall Python 2.4).\nUbuntu and Fedora seem very... ready to go. Almost too ready to go, it's like everything it already done. I like to tinker with things and I prefer to know what's installed and how it's configured versus hitting the ground running with a \"cookie-cutter\" setup (no offense intended, it's just the best way to describe what I'm trying to say). I've been playing around with Fedora and I was pleasently surprised to find that pycurl, simplejson and a bunch of other libraries were already installed; that raised the question, though, what else is installed? I run a tight ship on a very small VPS, I prefer to run only what I need.\nThen there's Gentoo... I've managed to install Gentoo on my desktop (took a week, almost) and ended up throwing it out after quite a few events where I wanted to do something and had to spend 45 minutes recompiling software with new USE flags so I can parse PNG's through PIL. I've wondered though, is Gentoo good for something \"static\" like a server? I know exactly what I'm going to be doing on my server, so USE flags will change next to never. It optimizes compiles to fit the needs of what you tell it to, and nothing more--something I could appreciate running on minimal RAM and HDD space. I've heard, though, that Gentoo has a tendency to break when you attempt to update the software on it... that more than anything else has kept me away from it for now.\nI don't know anything about Arch Linux. Any opinions on this distro would be appreciated.\nWeb Server\nI've been using Tornado and I can safely say it's been the biggest hassle to get running. I had to write my own script to prefork it since, at the time I setup this server, I was probably around 10% of Tornado's user-base (not counting FriendFeed). I have to then setup another \"watchdog\" program to make sure those forks don't misbehave. The good part is, though, it uses around 40MB of RAM to run all 7 of my Django powered sites; I liked that, I liked that a lot.\nI've been using nginx as a front-end to Tornado, I could run nginx right in front of Django FastCGI workers, but those don't have the reliability of Tornado when you crank up the concurrency level. This isn't really an option for me, but I figured I might as well list it.\nThere's also Apache, which Django recommends you use through mod_wsgi. I personally don't like Apache that much, I understand it's very, very, very mature and what not, but it just seems so... fat, compared to nginx and lighttpd. Apache\/mod_python isn't even an option, as I have very limited RAM.\nSegue to Lighttpd! Not much to say here, I've never used it. I've heard you can run it in front of Apache\/mod_wsgi or run it in front of Django FastCGI workers, also. I've heard it has minor memory leaking issues, I'm sure that could be solved with a cron job, though.\nWhat I'm looking for is what you have seen as the \"best\" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3882,"Q_Id":2256987,"Users Score":0,"Answer":"Personally I find one of the BSD systems far superior to Linux distros for server related tasks. Give OpenBSD or perhaps FreeBSD a chance. Once you do you\u00b4ll never go back.","Q_Score":9,"Tags":"python,linux,django,deployment,webserver","A_Id":2259882,"CreationDate":"2010-02-13T08:47:00.000","Title":"Recommended Django Deployment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a CLI script and want it to read data from a file. It should be able to read it in two ways :\n\ncat data.txt | .\/my_script.py\n.\/my_script.py data.txt\n\n\u2014a bit like grep, for example.\nWhat I know:\n\nsys.argv and optparse let me read any args and options easily.\nsys.stdin let me read data piped in\nfileinput make the full process automatic\n\nUnfortunately:\n\nusing fileinput uses stdin and any args as input. So I can't use options that are not filenames as it tries to open them.\nsys.stdin.readlines() works fine, but if I don't pipe any data, it hangs until I enter Ctrl + D\nI don't know how to implement \"if nothing in stdin, read from a file in args\" because stdin is always True in a boolean context.\n\nI'd like a portable way to do this if possible.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":10274,"Q_Id":2264991,"Users Score":3,"Answer":"There is no reliable way to detect if sys.stdin is connected to anything, nor is it appropriate do so (e.g., the user wants to paste the data in). Detect the presence of a filename as an argument, and use stdin if none is found.","Q_Score":20,"Tags":"python,pipe,stdin,command-line-interface","A_Id":2265010,"CreationDate":"2010-02-15T09:42:00.000","Title":"How to read from stdin or from a file if no data is piped in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to create an application that has 3-4 frames (or windows) where each frame is attached\/positioned to a side of the screen (like a task bar). When a frame is inactive I would like it to auto hide (just like the Windows task bar does; or the dock in OSX). When I move my mouse pointer to the position on the edge of the screen where the frame is hidden, I would like it to come back into focus.\nThe application is written in Python (using wxPython for the basic GUI aspects). Does anyone know how to do this in Python? I'm guessing it's probably OS dependent? If so, I'd like to focus on Windows first.\nI don't do GUI programming very often so my apologies if this makes no sense at all.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":877,"Q_Id":2268315,"Users Score":0,"Answer":"I think you could easily just make a window that is the same size as the desktop then do some while looping for an inactivity variable based on mouse position, then thread off a timer for loop for the 4 inactivity variables. I'd personally design it so that when they reach 0 from 15, they change size and position to become tabular and create a button on them to reactivate. lots of technical work on this one, but easily done if you figure it out","Q_Score":1,"Tags":"python,animation,wxpython,mouseevent","A_Id":44916099,"CreationDate":"2010-02-15T19:11:00.000","Title":"Can you auto hide frames\/dialogs using wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to create an application that has 3-4 frames (or windows) where each frame is attached\/positioned to a side of the screen (like a task bar). When a frame is inactive I would like it to auto hide (just like the Windows task bar does; or the dock in OSX). When I move my mouse pointer to the position on the edge of the screen where the frame is hidden, I would like it to come back into focus.\nThe application is written in Python (using wxPython for the basic GUI aspects). Does anyone know how to do this in Python? I'm guessing it's probably OS dependent? If so, I'd like to focus on Windows first.\nI don't do GUI programming very often so my apologies if this makes no sense at all.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":877,"Q_Id":2268315,"Users Score":0,"Answer":"Personally, I would combine the EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW that FogleBird mentioned with a wx.Timer. Then whenever it the frame or dialog is inactive for x seconds, you would just call its Hide() method.","Q_Score":1,"Tags":"python,animation,wxpython,mouseevent","A_Id":9066380,"CreationDate":"2010-02-15T19:11:00.000","Title":"Can you auto hide frames\/dialogs using wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Firstly pardon me if i've yet again failed to title my question correctly.\nI am required to build an app to manage magazine subscriptions. The client wants to enter subscriber data and then receive alerts at pre-set intervals such as when the subscription of a subscriber is about to expire and also the option to view all subscriber records at any time. Also needed is the facility to send an SMS\/e-mail to particular subscribers reminding them for subscription renewal. \nI am very familiar with python but this will be my first real project. I have decided to build it as a web app using django, allowing the admin user the ability to view\/add\/modify all records and others to subscribe. What options do I have for integrating an online payment service? Also how do I manage the SMS alert functionality? Any other pointers\/suggestions would be welcome.\nThank You","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":795,"Q_Id":2270556,"Users Score":0,"Answer":"I'd like to comment on the SMS alert part.\nFirst, I have to admit that I'm not familiar with Django, but I assume it to be just like most other web frameworks: request based.  This might be your first problem, as the alert service needs to run independently of requests.  You could of course hack together something to externally trigger a request once a day... :-)\nNow for the SMS part: much depends on how you plan to implement this.  If you are going with an SMS provider, there are many to choose from that let you send SMS with a simple HTTP request.  I wouldn't recommend the other approach, namely using a real cellphone or SMS modem and take care of the delivery yourself: it is way too cumbersome and you have to take into account a lot more issues: e.g. retry message transmission for handsets that are turned off or aren't able to receive SMS because their memory is full.  Your friendly SMS provider will probably take care of this.","Q_Score":3,"Tags":"python,django,sms,payment-gateway","A_Id":2277634,"CreationDate":"2010-02-16T04:06:00.000","Title":"Subscription web\/desktop app [PYTHON]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experienced PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework like flask or django to name a few.","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":35567,"Q_Id":2276000,"Users Score":4,"Answer":"One of the lightest-weight frameworks is mod_wsgi.  Anything less is going to be a huge amount of work parsing HTTP requests to find headers and URI's and methods and parsing the GET or POST query\/data association, handling file uploads, cookies, etc.\nAs it is, mod_wsgi will only handle the basics of request parsing and framing up results.\nSessions, cookies, using a template generator for your response pages will be a surprising amount of work.\nOnce you've started down that road, you may find that a little framework support goes a long way.","Q_Score":43,"Tags":"python","A_Id":2276041,"CreationDate":"2010-02-16T20:15:00.000","Title":"Program web applications in python without a framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm going to write my first non-Access project, and I need advice on choosing the platform. I will be installing it on multiple friends' and family's computers, so (since I'm sure many, many platforms would suffice just fine for my app), my highest priority has two parts: 1) ease of install for the non-technical user and, 2) minimizing compatibility problems.  I want to be able to fix bugs and make changes and roll them out without having to troubleshoot OS and program conflicts on their computers (or at least keeping those things to the absolute minimum-this is why these concerns are my highest priority in choosing a platform.)\nI have narrowed it down to Python or Java.  I like Java's use of the JVM, which seems like would serve to protect against incompatibilities on individual computers nicely.  And I've heard a lot of good things about Python, but I don't know how much more prone to incompatibilities it is vs Java.   In case it is important, I know the app will definitely use some flavor of a free server-enabled SQL db (server-enabled because I want to be able to run the app from multiple computers), but I don't know which to use yet.  I thought I could decide that next.\nMy experience level: I've taken a C++ (console app only) class and done some VBA in Access, but mostly I'm going to have to jump in and learn as I go.  So of course I don't know much about all of this.  I'm not in the computer field, this is just a hobby.\nSo, which would be better for this app, Java or Python?  \n(In case it comes up, I don't want to make it browser-based at all.  I've dealt with individual computers' browser settings breaking programs, and that goes against part 2 of my top priority - maximum compatibility.)\nThank you.\nUpdate: It will need a gui, and I'd like to be able to do a little bit of customization on it (or use a non-standard, or maybe a non-built-in one) to make it pop a little.\nUpdate 2: Truthfully, I really am only concerned with Windows computers.  I am considering Java only for its reliability as a platform.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":594,"Q_Id":2282360,"Users Score":1,"Answer":"The largest issue I can think of is the need to install an interpreter.\nWith Java, a lot of people will already have that interpreter installed, although you won't necessarily know which version.  It may be wise to include the installer for Java with the program.\nWith Python, you're going to have to install the interpreter on each computer, too.\nOne commenter mentioned .NET.  .NET 2.0 has a fairly high likelyhood of being installed than either Java or Python on Windows machines.  The catch is that you can't (easily) install it on OSX or Linux.","Q_Score":0,"Tags":"java,python","A_Id":2282470,"CreationDate":"2010-02-17T16:20:00.000","Title":"Help for novice choosing between Java and Python for app with sql db","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm going to write my first non-Access project, and I need advice on choosing the platform. I will be installing it on multiple friends' and family's computers, so (since I'm sure many, many platforms would suffice just fine for my app), my highest priority has two parts: 1) ease of install for the non-technical user and, 2) minimizing compatibility problems.  I want to be able to fix bugs and make changes and roll them out without having to troubleshoot OS and program conflicts on their computers (or at least keeping those things to the absolute minimum-this is why these concerns are my highest priority in choosing a platform.)\nI have narrowed it down to Python or Java.  I like Java's use of the JVM, which seems like would serve to protect against incompatibilities on individual computers nicely.  And I've heard a lot of good things about Python, but I don't know how much more prone to incompatibilities it is vs Java.   In case it is important, I know the app will definitely use some flavor of a free server-enabled SQL db (server-enabled because I want to be able to run the app from multiple computers), but I don't know which to use yet.  I thought I could decide that next.\nMy experience level: I've taken a C++ (console app only) class and done some VBA in Access, but mostly I'm going to have to jump in and learn as I go.  So of course I don't know much about all of this.  I'm not in the computer field, this is just a hobby.\nSo, which would be better for this app, Java or Python?  \n(In case it comes up, I don't want to make it browser-based at all.  I've dealt with individual computers' browser settings breaking programs, and that goes against part 2 of my top priority - maximum compatibility.)\nThank you.\nUpdate: It will need a gui, and I'd like to be able to do a little bit of customization on it (or use a non-standard, or maybe a non-built-in one) to make it pop a little.\nUpdate 2: Truthfully, I really am only concerned with Windows computers.  I am considering Java only for its reliability as a platform.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":594,"Q_Id":2282360,"Users Score":1,"Answer":"If you're going to install only (or mostly) on Windows, I'd go with .Net. \nIf you have experience with C++, then C# would be natural to you, but if you're comfortable with VBA, you can try VB.NET, but if you prefer Python, then there is IronPython or can give a try to IronRuby, but the best of all is you can mix them all as they apply to different parts of your project.\nIn the database area you'll have excellent integration with SQL Server Express, and in the GUI area, Swing can't beat the ease of use of WinForms nor the sophistication of WPF\/Silverlight.\nAs an added bonus, you can have your application automatically updated with ClickOnce.","Q_Score":0,"Tags":"java,python","A_Id":2283347,"CreationDate":"2010-02-17T16:20:00.000","Title":"Help for novice choosing between Java and Python for app with sql db","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've a PyQt 4 installed (I can't find PyQt 3 for Windows) and I would like to open a QtDesigner ui file which has been created with QtDesigner 3.3.\nWhen I open this file I've the following message:\nPlease use uic3 -convert to convert to Qt4\nUnfortunately, I don't see the uic3 tool in the bin folder of my install.\nDoes anybody know how can I can convert this file to QtDesigner 4?\nAdditional quastion: Where to download PyQy3 binaries for Windows?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":900,"Q_Id":2294956,"Users Score":1,"Answer":"Try finding pyuic3 or rather pyuic4. Since you are using PyQt all your qt tools have py in front (like pyrcc4 or pyuicc4).\nI am not sure, that there are pyqt3 binaries for windows. Are you sure that Phil Thompson did PyQt3 also for windows at the time? If so, they would be on riverbank site, I guess, but I can't find them there. Tried compiling the source yourself?","Q_Score":0,"Tags":"python,qt,pyqt,qt-designer","A_Id":2296460,"CreationDate":"2010-02-19T08:41:00.000","Title":"How to open a Pyqt 3.3 ui file with QtDesigner 4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I investigated that scope of global variables in python is limited to the module. But I need the scope to be global among different modules. Is there such a thing? I played around __builtin__ but no luck.\nthanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3316,"Q_Id":2296550,"Users Score":3,"Answer":"Python does not support globals shared between several modules: this is a feature. Code that implicitly modifies variables used far away is confusing and unmaintainable. The real solution is to encapsulate all state within a class and pass its instance to anything that has to modify it. This can make code clearer, more maintainable, more testable, more modular, and more expendable.","Q_Score":2,"Tags":"python,scope,global-variables","A_Id":2298388,"CreationDate":"2010-02-19T13:28:00.000","Title":"how to have global variables among different modules in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I investigated that scope of global variables in python is limited to the module. But I need the scope to be global among different modules. Is there such a thing? I played around __builtin__ but no luck.\nthanks in advance!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3316,"Q_Id":2296550,"Users Score":0,"Answer":"Scopes beyond the local must be written to via a reference to the scope, or after a global or nonlocal (3.x+) directive.","Q_Score":2,"Tags":"python,scope,global-variables","A_Id":2296580,"CreationDate":"2010-02-19T13:28:00.000","Title":"how to have global variables among different modules in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies.  I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev\/test cycles have to be on the order of minutes.\nI've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little \"low level\" for my target users.  Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have?  Thanks in advance.","AnswerCount":11,"Available Count":5,"Score":0.0181798149,"is_accepted":false,"ViewCount":3358,"Q_Id":2297889,"Users Score":1,"Answer":"Custom-made modules are going to be needed, no matter what you choose, that define your firm's high level constructs.  \nHere are some of the needs I envision -- you may have some of these covered already: a way to get current positions, current and historical quotes, previous performance data, etc... into the application.  Define\/backtest\/send various kinds of orders (limit\/market\/stop, what exchange, triggers) or parameters of options, etc...  You probably are going to need multiple sandboxes for testing as well as the real thing.     \nQuants want to be able to do matrix operations, stochastic calculus, PDEs.\nIf you wanted to do it in python, loading NumPy would be a start.  \nYou could also start with a proprietary system designed to do mathematical financial research such as something built on top of Mathematica or Matlab.","Q_Score":14,"Tags":"python,ruby,scripting,dsl,trading","A_Id":2297992,"CreationDate":"2010-02-19T16:31:00.000","Title":"Scripting language for trading strategy development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies.  I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev\/test cycles have to be on the order of minutes.\nI've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little \"low level\" for my target users.  Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have?  Thanks in advance.","AnswerCount":11,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3358,"Q_Id":2297889,"Users Score":0,"Answer":"Existing languages are \"a little \"low level\" for my target users.\"\nYet, all you need is \"a minimum of support for looping, simple arithmatic, logical expression evaluation\"\nI don't get the problem.  You only want a few features.  What's wrong with the list of languages you provided?  They actually offer those features?\nWhat's the disconnect?  Feel free to update your question to expand on what the problem is.","Q_Score":14,"Tags":"python,ruby,scripting,dsl,trading","A_Id":2298038,"CreationDate":"2010-02-19T16:31:00.000","Title":"Scripting language for trading strategy development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies.  I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev\/test cycles have to be on the order of minutes.\nI've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little \"low level\" for my target users.  Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have?  Thanks in advance.","AnswerCount":11,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3358,"Q_Id":2297889,"Users Score":0,"Answer":"I would use Common Lisp, which supports rapid development (you have a running image and can compile\/recompile individual functions) and tailoring the language to your domain.  You would provide functions and macros as building blocks to express strategies, and the whole language would be available to the user for combining these.","Q_Score":14,"Tags":"python,ruby,scripting,dsl,trading","A_Id":2298183,"CreationDate":"2010-02-19T16:31:00.000","Title":"Scripting language for trading strategy development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies.  I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev\/test cycles have to be on the order of minutes.\nI've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little \"low level\" for my target users.  Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have?  Thanks in advance.","AnswerCount":11,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3358,"Q_Id":2297889,"Users Score":0,"Answer":"Define the language first -- if possible, use the pseudo-language called EBN, it's very simple (see the Wikipedia entry).\nThen once you have that, pick the language.  Almost certainly you will want to use a DSL.  Ruby and Lua are both really good at that, IMO.\nOnce you start working on it, you may find that you go back to your definition and tweak it.  But that's the right order to do things, I think.","Q_Score":14,"Tags":"python,ruby,scripting,dsl,trading","A_Id":2298573,"CreationDate":"2010-02-19T16:31:00.000","Title":"Scripting language for trading strategy development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies.  I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev\/test cycles have to be on the order of minutes.\nI've looked at lua, python, ruby so far and really enjoyed all of them so far, but still found them a little \"low level\" for my target users.  Would I need to somehow write my own parser + interpreter to support a language with a minimum of support for looping, simple arithmatic, logical expression evaluation, or is there another recommendation any of you may have?  Thanks in advance.","AnswerCount":11,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":3358,"Q_Id":2297889,"Users Score":0,"Answer":"This might be a bit simplistic, but a lot of quant users are used to working with Excel & VBA macros.  Would something like VBSCript be usable, as they may have some experience in this area.","Q_Score":14,"Tags":"python,ruby,scripting,dsl,trading","A_Id":2298008,"CreationDate":"2010-02-19T16:31:00.000","Title":"Scripting language for trading strategy development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm reading a 6 million entry .csv file with Python, and I want to be able to search through this file for a particular entry.\nAre there any tricks to search the entire file? Should you read the whole thing into a dictionary or should you perform a search every time? I tried loading it into a dictionary but that took ages so I'm currently searching through the whole file every time which seems wasteful.\nCould I possibly utilize that the list is alphabetically ordered? (e.g. if the search word starts with \"b\" I only search from the line that includes the first word beginning with \"b\" to the line that includes the last word beginning with \"b\")\nI'm using import csv.\n(a side question: it is possible to make csv go to a specific line in the file? I want to make the program start at a random line)\nEdit: I already have a copy of the list as an .sql file as well, how could I implement that into Python?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":20439,"Q_Id":2299454,"Users Score":0,"Answer":"my idea is to use python zodb module to store dictionaty type data and then create new csv file using that data structure. do all your operation at that time.","Q_Score":4,"Tags":"python,dictionary,csv,large-files","A_Id":3279041,"CreationDate":"2010-02-19T20:51:00.000","Title":"How do quickly search through a .csv file in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm reading a 6 million entry .csv file with Python, and I want to be able to search through this file for a particular entry.\nAre there any tricks to search the entire file? Should you read the whole thing into a dictionary or should you perform a search every time? I tried loading it into a dictionary but that took ages so I'm currently searching through the whole file every time which seems wasteful.\nCould I possibly utilize that the list is alphabetically ordered? (e.g. if the search word starts with \"b\" I only search from the line that includes the first word beginning with \"b\" to the line that includes the last word beginning with \"b\")\nI'm using import csv.\n(a side question: it is possible to make csv go to a specific line in the file? I want to make the program start at a random line)\nEdit: I already have a copy of the list as an .sql file as well, how could I implement that into Python?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":20439,"Q_Id":2299454,"Users Score":1,"Answer":"You can't go directly to a specific line in the file because lines are variable-length, so the only way to know when line #n starts is to search for the first n newlines.  And it's not enough to just look for '\\n' characters because CSV allows newlines in table cells, so you really do have to parse the file anyway.","Q_Score":4,"Tags":"python,dictionary,csv,large-files","A_Id":2443606,"CreationDate":"2010-02-19T20:51:00.000","Title":"How do quickly search through a .csv file in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building this app in Python with Django.\nI would like to give parts of the site wiki like functionality,\nbut I don't know how to go on about reliability and security.\n\nMake sure that good content is not ruined\nCheck for quality\nPrevent spam from invading the site\n\nThe items requiring wiki like functionality are just a few: a couple of text fields. \n\nCan anyone help on this one?\nWould be very much appreciated. :)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1412,"Q_Id":2299697,"Users Score":1,"Answer":"Assuming that there will be a community of users you can provide good tools for them to spot problems and easily undo damage. The most important of these is to provide a Recent Changes page that summarizes recent edits. Then each page that can be edited should retain prior versions of the page that can be used to replace any damaging edit. This makes it easier to undo damage than it is to damage things.\nThen think about how you are going to handle either locking resources or handling simultaneous edits.\nIf you can tie edits to users you can provide some administrative functions for undoing all edits by a particular user, and banning that user.\nChecking for quality would be tied to the particular data that your application is using.","Q_Score":0,"Tags":"python,django,django-models,wiki","A_Id":2299776,"CreationDate":"2010-02-19T21:23:00.000","Title":"Building a wiki application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building this app in Python with Django.\nI would like to give parts of the site wiki like functionality,\nbut I don't know how to go on about reliability and security.\n\nMake sure that good content is not ruined\nCheck for quality\nPrevent spam from invading the site\n\nThe items requiring wiki like functionality are just a few: a couple of text fields. \n\nCan anyone help on this one?\nWould be very much appreciated. :)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1412,"Q_Id":2299697,"Users Score":1,"Answer":"Make sure that good content is not ruined = version each edit and allow roll-backs.  \nCheck for quality = get people to help with that\nPrevent spam from invading the site = get people to help with that, require login, add a captcha if need be, use nofollow for all links","Q_Score":0,"Tags":"python,django,django-models,wiki","A_Id":2299849,"CreationDate":"2010-02-19T21:23:00.000","Title":"Building a wiki application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing service in python that async ping domains. So it must be able to ping many ip's at the same time. I wrote it on epoll ioloop, but have problem with packets loss.\nWhen there are many simultaneous ICMP requests much part of replies on them didn't reach my servise. What may cause this situation and how i can make my service ping many hosts at the same time without packet loss?\nThanks)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":788,"Q_Id":2299751,"Users Score":0,"Answer":"A problem you might be having is due to the fact that ICMP is layer 3 of the OSI model and does not use a port for communication. In short, ICMP isn't really designed for this.  The desired behavior is still possible but perhaps the IP Stack you are using is getting in the way and if this is on a Windows system then 100% sure this is your problem.   I would fire up Wireshark to make sure you are actually getting incoming packets,  if this is the case then I would use libpcap to track in ICMP replies.   If the problem is with sending then you'll have to use raw sockets and build your own ICMP packets.","Q_Score":1,"Tags":"python,ping,icmp","A_Id":2299927,"CreationDate":"2010-02-19T21:32:00.000","Title":"Problem with asyn icmp ping","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Today I've been trying to bring more of the Python related modes into\nmy Emacs configuration but I haven't had much luck.\nFirst what I've noticed is that depending on how Emacs is\nlaunched (terminal vs from the desktop), the interpreter it decides to\nuse is different.\n\nlaunched from KDE menu: M-! which python gives \/usr\/bin\/python\nlaunched from terminal: M-! which python gives ~\/local\/bin\/python\n\nI can kind of accept this since I have my .bashrc appending\n~\/local\/bin to the path and I guess KDE ignores that by default. I can\nwork around this, however what I don't understand is then if I\nactivate a virtualenv, I would expect M-! which python to point to\n~\/project.env\/bin\/python however it still points to ~\/local\/bin\/python.\nThus when I M-x py-shell, I get ~\/local\/bin\/python so if I try to\nM-x py-execute-buffer on a module that resides in a package in the\nvirtualenv, py-shell will complain about not knowing about modules\nalso in the virtualenv.  \nSetting py-python-command to \"~\/project.env\/bin\/python\" seems to have no\neffect after everything is loaded.\nSo I guess the overall crux of my question is, how does one get all\nthe python related emacs stuff pointing at the right interpreter?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6786,"Q_Id":2303956,"Users Score":8,"Answer":"So it seems that python-shell does the right thing by picking up the environment settings, whereas py-shell does not. python-shell is provided by python.el and py-shell is provided by python-mode.el , There's bug reports etc related to this, so I'm just not going to use py-shell for now. Figured I'd close the loop on this in case the google machine considers this a high ranking item for one reason or another.","Q_Score":12,"Tags":"python,emacs,virtualenv","A_Id":2307435,"CreationDate":"2010-02-20T22:12:00.000","Title":"Specifying python interpreter from virtualenv in emacs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having trouble exchanging my Oauth request token for an Access Token. My Python application successfully asks for a Request Token and then redirects to the Google login page asking to grant access to my website. When I grant access I retrieve a 200 status code but exchanging this authorized request token for an access token gives me a 'The token is invalid' message. \nThe Google Oauth documentation says: \"Google redirects with token and verifier regardless of whether the token has been authorized.\" so it seems that authorizing the request token fails but then I am not sure how I should get an authorized request token. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1332,"Q_Id":2306984,"Users Score":1,"Answer":"When you're exchanging for the access token, the oauth_verifier parameter is required. If you don't provide that parameter, then google will tell you that the token is invalid.","Q_Score":2,"Tags":"python,oauth,google-api","A_Id":3110939,"CreationDate":"2010-02-21T18:50:00.000","Title":"Exchange Oauth Request Token for Access Token fails Google API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background information:\nI have created an internal site for a company. Most of the work has gone into making calculation tools that their sale persons can use to make offers for clients. Create pdf offers and contracts that can be downloaded, compare prices etc. All of this is working fine.\nNow their sale persons have been divided into two groups.\n\nOne group is sale personal that is hired by the company.\nThe other group is persons a company themselves.\n\nThe question:\nMy challenge now is, that I in some cases need to display different things depending on the type of sales person. Some of the rules for the calculation tools will have different rules as to which numbers will be allowed etc. But a big part of the site will still be the same for both groups.\nWhat I would like to know, is if there is a good way of handling this problem?\nMy own thoughts:\nI thought about managing this by using the groups that is available in contrib.auth. That way I could keep a single code base, but would have to make rules a lot of different places. Rules for validating forms to check if the numbers entered is allowed, will depend on the group the user is in. Some things will have different names, or the workflow might be a bit different. Some tools will only be available to one of the groups. This seems like a quick solution here and now, but if the two groups will need to change more and more, it seems like this would quickly become hard to manage.\nI also thought about making two different sites. The idea here was to create apps that both groups use, so I only would need to make the code for that 1 place. Then I could make the custom parts for each site and wouldn't need to check for the user in most templates and views. But I'm not sure if this is a good way to go about things. It will create a lot of extra work, and if the two groups can use a lot of the same code, this might not really be needed.\nThe biggest concern is that I don't really know how this evolve, so it could end up with the two groups being entire different or with only very few differences. What I would like to do, is write some code that can support both scenarios so I wont end up regretting my choice a half year from now.\nSo, how do you handle this case of user management. I'm looking for ideas techniques or reusable apps that address this problem, not a ready made solution.\nClarifications:\nMy issue is not pure presentation that can be done with templates, but also that certain calculation tools (a form that is filled out) will have different rules\/validation applied to them, and in some cases the calculations done will also be different. So they might see the same form, but wont be allowed to enter the same numbers, and the same numbers might not give the same result.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":439,"Q_Id":2311094,"Users Score":0,"Answer":"If I'm understanding you correctly, it seems like you want to have two different groups have access to all the same views, but they will see different numbers. You can achieve this effect by making separate templates for the different groups, and then loading the appropriate template for each view depending on the group of the current user.\nSimilarly you can use a context processor to put the current group into the context for every view, and then put conditionals in the templates to select which numbers to show.\nThe other option is to have two separate sets of views for the two different groups. Then use decorators on the views to make sure the groups only go to the views that are for them.","Q_Score":2,"Tags":"python,django,user-management","A_Id":2311740,"CreationDate":"2010-02-22T13:27:00.000","Title":"How to handle user mangement in Django for groups that has same access but different rules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?\nEdit: I just want to convert it to a string...and then back to a dictionary.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":2541,"Q_Id":2311223,"Users Score":2,"Answer":"There are any number of serialization methods out there, JSON is readable, reasonably compact, supported natively, and portable. I prefer it over pickle, since the latter can execute arbitrary code and potentially introduce security holes, and because of its portability. \nDepending on your data's layout, you may also be able to use your ORM to directly map the data into database constructs.","Q_Score":1,"Tags":"python,database,string,list,dictionary","A_Id":2312727,"CreationDate":"2010-02-22T13:49:00.000","Title":"How do I store a dict\/list in a database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?\nEdit: I just want to convert it to a string...and then back to a dictionary.","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":2541,"Q_Id":2311223,"Users Score":4,"Answer":"Options:\n1) Pickling\n2) XML\n3) JSON\nothers I am sure.  It has a lot to do on how much portability means to you.","Q_Score":1,"Tags":"python,database,string,list,dictionary","A_Id":2311245,"CreationDate":"2010-02-22T13:49:00.000","Title":"How do I store a dict\/list in a database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse?\nEdit: I just want to convert it to a string...and then back to a dictionary.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":2541,"Q_Id":2311223,"Users Score":1,"Answer":"You have two options\n\nuse a standard serialization format (json, xml, yaml, ...)\n\npros: you can access with a any language that can parse those formats (on the worst case you can write your own parser)\ncons: could be slower to save and load the data (this depends of the implementation mostly)\n\nuse cPickle:\n\npros: easy to use, fast and native python way to do serialization.\ncons: only python based apps can have access to the data.","Q_Score":1,"Tags":"python,database,string,list,dictionary","A_Id":2312726,"CreationDate":"2010-02-22T13:49:00.000","Title":"How do I store a dict\/list in a database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python, how does one parse\/access files with Linux-specific features, like \"~\/.mozilla\/firefox\/*.default\"?  I've tried this, but it doesn't work.\nThanks","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":7357,"Q_Id":2313053,"Users Score":2,"Answer":"It's important to remember:\n\nuse of the tilde ~ expands the home directory as per Poke's answer\nuse of the forward slash \/ is the separator for linux \/ *nix directories\nby default, *nix systems such as linux for example has a wild card globbing in the shell, for instance echo *.* will return back all files that match the asterisk dot asterisk (as per Will McCutcheon's answer!)","Q_Score":3,"Tags":"python,linux,path","A_Id":2313168,"CreationDate":"2010-02-22T18:17:00.000","Title":"Python: How to Access Linux Paths","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm seeking a way to let the python logger module to log to database and falls back to file system when the db is down.\nSo basically 2 things: How to let the logger log to database and how to make it fall to file logging when the db is down.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":48780,"Q_Id":2314307,"Users Score":2,"Answer":"Old question, but dropping this for others. If you want to use python logging, you can add two handlers. One for writing to file, a rotating file handler. This is robust, and can be done regardless if the dB is up or not. \nThe other one can write to another service\/module, like a pymongo integration. \nLook up logging.config on how to setup your handlers from code or json.","Q_Score":48,"Tags":"python,database,logging","A_Id":46617613,"CreationDate":"2010-02-22T21:22:00.000","Title":"python logging to database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python how do I find all the missing days in a sorted list of dates?","AnswerCount":9,"Available Count":1,"Score":0.022218565,"is_accepted":false,"ViewCount":16151,"Q_Id":2315032,"Users Score":1,"Answer":"Put the dates in a set and then iterate from the first date to the last using datetime.timedelta(), checking for containment in the set each time.","Q_Score":23,"Tags":"python","A_Id":2315052,"CreationDate":"2010-02-22T23:18:00.000","Title":"How do I find missing dates in a list of sorted dates?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to get PHP-like print_r(object) funcionality in iPython?\nI know I can use '?' to get info about an object, but how do I view the values of the object?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":497,"Q_Id":2317921,"Users Score":2,"Answer":"dir(object) will give you all its attribute names.","Q_Score":1,"Tags":"php,python,object,ipython","A_Id":2317942,"CreationDate":"2010-02-23T12:08:00.000","Title":"print_r functionality in iPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":25629,"Q_Id":2322868,"Users Score":3,"Answer":"As the other people say, just ask for input to get it to hold. However, I would recommend running your Python scripts in a different manner in Windows. Using the IDLE IDE (should have come with your distribution), just open the script you want to run and press F5. Then, not only can you see the output for as long as you like, but you can also examine any variables that were assigned interactively. This is very handy especially when you are just starting to program in Python.\nYou can also run scripts from the command line, but I would recommend use IDLE if you're just starting out.","Q_Score":3,"Tags":"python,python-2.6,python-2.x","A_Id":2322892,"CreationDate":"2010-02-24T00:34:00.000","Title":"How do I prevent my Python application from automatically closing once reaching the end of code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":25629,"Q_Id":2322868,"Users Score":0,"Answer":"ask user to enter one more variable and print \"Press enter to exit...\"","Q_Score":3,"Tags":"python,python-2.6,python-2.x","A_Id":2322884,"CreationDate":"2010-02-24T00:34:00.000","Title":"How do I prevent my Python application from automatically closing once reaching the end of code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":25629,"Q_Id":2322868,"Users Score":10,"Answer":"Well, I guess you mean the terminal that Windows opens for you when you run a python file is closed too fast. You can add raw_input('Press Enter to exit') right before your program would exit. It tells Python to wait for input before exiting.","Q_Score":3,"Tags":"python,python-2.6,python-2.x","A_Id":2322878,"CreationDate":"2010-02-24T00:34:00.000","Title":"How do I prevent my Python application from automatically closing once reaching the end of code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I love django, and I like flex. Django for it's cool debugging system (those yellow pages helps a lot to find bugs in my code), and flex for it possibilities.\nRecently I come across a problem. If I create a form in flex and then communicate with the django server, I can't see any debugging info (when the exception happens in django).\nNot sure, if there is a way to get the debugging info, because it is not accessible in command line (no error output), or in firebug....\nAlso I tried to create a quick html form, and post same data as I send from flex form, but it's a bit of pain to be honest.\nWill be happy to listen how do you solve the problem","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":2323371,"Users Score":1,"Answer":"I've used firebug to debug the flex side of things. But I've been using json or XML for communication between the two. Since flash uses the browser to do the network stuff, the request should be visible in the net tab of firebug.\nTo debug the django side of things, you have a few options.\n\nIf you're using the django dev server, you can add print statements to find out what's going on.\nYou can write a unit test to see if the django side of things is doing what you expect it to, given known data.\nYou can use the pyDev debugger to run the django dev server and step through your code.\n\nI use a combination of these to debug my code.","Q_Score":0,"Tags":"python,django,actionscript-3","A_Id":2323428,"CreationDate":"2010-02-24T02:59:00.000","Title":"django+flex: Debugging strategies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":0,"Answer":"Charlie, being a new hire and all, you shouldn't really decide on which technology to code the project. This is a management decision. \nIn fact, even though team skill can be used to determine the technology of choice for one or other project, there are many other, more important, things to take into account. \nWhich technology serves your purposes well? Assuming it can really be done in python and java:\n\nIs time-to-market really important?\nIf you need to expand your team (i.e., extend the project), will you be able to hire more Python programmers? Are they more or less expensive than Java programmers?\nAre there other projects in Python at your enterprise (or your clients enterprise)? A homogeneous environment is easier to administrate.\nLearn the differences between Java and Python and see which one applies better to the problem. For example, Python probably performs worse than Java... But Python programs can be programmed and tested way more quickly.\n\nAnd, of course, yes you can take into account that there's a learning curve. As another answer put it, Python is very simple, and so is Java and almost every common language out there. What kills you is learning API's, SDK's, debugging tools, environment differences, etc.\nAnother thing, that I draw from experience: never believe that a project is done when its done. Everything changes, so when you deliver the product, either your manager or your client (whoever will use it) will ask you to change something, and once you're done with that change, there will be more. Software are living things... they only stop changing when they are dead.","Q_Score":13,"Tags":"java,python","A_Id":2328658,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":0,"Answer":"My personal preference is to learn new languages on personal projects, and use tools I already understand on professional projects.  So if it was me, I'd do the project in Java, and do a few little Python projects at home.\nBut of course, you learn a lot more a lot faster when you are using a new language \"for real\" forty hours a week, so if you have adequate support from management and co-workers, then take advantage of the opportunity.","Q_Score":13,"Tags":"java,python","A_Id":3258221,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0166651236,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":1,"Answer":"Generally, if I'm not familiar with a language, I allow at least a month to get somewhat comfortable with it.  Two or three months if it's outside my \"comfort zone\" of C-like languages.  Having said that, I think Java and Python are similar enough that you might trim that a bit.\nAlso, based on your own history, how good are your estimates when you're familiar with a language?  If you think it will take two weeks to do it in Java, how well can you rely on that estimate?  Personally, I'm sometimes way under, even when I think I'm being pessimistic, but maybe you're better at estimating than me.\nA part of me is tempted to say \"Go for Python\".  That's at least partly because I'm a Python fan.  However, as a new hire, you probably ought to make a good impression, and I think you'll do that better by delivering on time (or early) than by learning Python.\nHowever, if there are parts that can be cleanly separated out and done in Python, maybe you could do some parts in Java and other parts in Python.","Q_Score":13,"Tags":"java,python","A_Id":2328518,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0166651236,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":1,"Answer":"I'd say if you want to avoid possible headaches, do it in Java and learn Python at home, by trying to re-create a similar application to the one you do at work, if you want something which feels real. It's likely that if you arent familiar with Python you arent going to take advantage of its capabilities anyway. Once I took a look at the first Python application I made, and it looked like I wrote an Object Pascal application in Python syntax","Q_Score":13,"Tags":"java,python","A_Id":2328430,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0831409664,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":5,"Answer":"My boss's rule of thumb is any time there's a learning curve, it can triple the time to write the application.  So, if Java would take you two weeks, then Python may take about 6.","Q_Score":13,"Tags":"java,python","A_Id":2328250,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":7,"Answer":"You have roughly 5 weeks to complete the project.  If you're confident the Java version would take 2 weeks, that leaves 3 weeks to flail around with the Python version until you have to give up.  I say go for it.  Python is relatively easy to pick up.  I think three weeks of work is enough to time to know whether you can finish by the deadline.\nIMHO, this is a great excuse for you to learn a new language.  Keep updating your manager regularly with your progress.  I think the right decision will become apparent as time goes on.","Q_Score":13,"Tags":"java,python","A_Id":2328364,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0665680765,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":4,"Answer":"It always take longer than you think. \nTry writing a small program doing just a bit of what you need.  If you are to write a program with a GUI then make small program showing a frame with Hello World and an Ok-button and see how hard that is.","Q_Score":13,"Tags":"java,python","A_Id":2328292,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":0,"Answer":"Are you just programming or are you designing\/architecting?  \nIf you are coding according to a design that an experienced Python resource has layed-out then I'd give myself 3-4 times as long since you've described this as a small, fairly simple project.\nIf you are designing\/architecting this yourself then you're taking on a big risk by trying to learn a new language at the same time.  There's too much chance that you could design something at the onset that is core to your design, only to figure-out later that it doesn't work and you need to rewrite alot of stuff because of it.\nThat being said I would present the risks and such to your manager (showing your obvious enthusiasm for learning Python) and let him make the call.","Q_Score":13,"Tags":"java,python","A_Id":2328316,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0333209931,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":2,"Answer":"If you Google for \"Pythonic\", you'll find a lot of discussion about how to do things in ways that fit well in Python, will be easy to understand by other Python users, and so on. It always takes a while to progress from code that simply works in a language to using that language well -- and in the case of Python, that learning curve is a bit longer than normal.\nIn the end, I'd say the answer depends on your age and personality (and your perception of the \"personality\" of your employer). Relatively speaking, Java is the conservative approach -- it reduces risks and probably gives the best chance of finishing the job on time and within budget. Using a language you don't know increases the risk of not delivering what's needed. Chances are that you'll end up writing it (at least) twice, once in a form that's pretty similar to what you would have done in Java, and then again in a form that's more Pythonic. That may well mean some late nights, especially if you get down to a week to go (or something on that order) and realize you need (or badly want) to rewrite almost everything you've done so far.\nIt mostly comes down to a question of whether you're comfortable with assuming that risk.","Q_Score":13,"Tags":"java,python","A_Id":2328426,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.049958375,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":3,"Answer":"Python is like baby java, you'll pick it up in a breeze.","Q_Score":13,"Tags":"java,python","A_Id":2328275,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? \nHere's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time.\nSorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate?\nAnd included in this question - from what I've heard, it seems to be pretty easy\/intuitive to switch over from Java to Python. Is this true...?\nThanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","AnswerCount":12,"Available Count":11,"Score":0.0333209931,"is_accepted":false,"ViewCount":670,"Q_Id":2328230,"Users Score":2,"Answer":"Well I would say how fast you pick up Python also depends on what other languages you know(or comfortable) apart from Java. If the only language you know is Java then I don't think the switch from Java to Python would be intuitive or smooth. To start with Java is statically typed and Python is dynamically typed, and it takes some time to get used to OO programming with Python even if you are skilled in using OO techniques using Java. So I would say honor the timeline and finish the project in time (or earlier :) using Java since this is what your work demands. \nKeep learning Python and automate some of the routine activities you do using Python so that you get a reasonable level of confidence to work on new project using Python.","Q_Score":13,"Tags":"java,python","A_Id":2328330,"CreationDate":"2010-02-24T17:53:00.000","Title":"How much leeway do I have to leave myself to learn a new language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been building a large python program for a while, and would like to know how I would go about setting the title of the program? On a mac the title of program, which has focus, is shown in the top left corner of the screen, next the apple menu. Currently this only shows the word \"Python\", but I would of course like to my program's title there instead.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":12479,"Q_Id":2330393,"Users Score":3,"Answer":"Since your program is interpreted by Python, then what actually is run is Python itself - the interpreter program. You would have to have your Python script merged with Python into a single executable and that would be able to have a separate name. For windows there is py2exe, that does that, but I have no idea if there is a similar tool for Mac OS (and if there is any need for that, there is some BSD under the hood right?).","Q_Score":9,"Tags":"python,macos,title,menubar","A_Id":2330448,"CreationDate":"2010-02-24T23:11:00.000","Title":"How to set the program title in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a string \n'''\n{\"session_key\":\"3.KbRiifBOxY_0ouPag6__.3600.1267063200-16423986\",\"uid\":164\n23386,\"expires\":12673200,\"secret\":\"sm7WM_rRtjzXeOT_jDoQ__\",\"sig\":\"6a6aeb66\n64a1679bbeed4282154b35\"}\n'''\nhow to get the value .\nthanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":2330857,"Users Score":0,"Answer":"For a simple-to-code method, I suggest using ast.parse() or eval() to create a dictionary from your string, and then accessing the fields as usual. The difference between the two functions above is that ast.parse can only evaluate base types, and is therefore more secure if someone can give you a string that could contain \"bad\" code.","Q_Score":1,"Tags":"python","A_Id":2330884,"CreationDate":"2010-02-25T01:00:00.000","Title":"which is the best way to get the value of 'session_key','uid','expires'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors.\nSo how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":58831,"Q_Id":2345607,"Users Score":0,"Answer":"Just add IDLE's path to your PATH environment variable.\nFor example I created an environment variable called IDLE_PATH and set the value to C:\\Python27\\Lib\\idlelib\nThen in my PATH variable I added ;%IDLE_PATH%; and open a new cmd prompt or in console2 just open a new tab and run idle <file_name> to open the file, you will be able to do this from any directory. In IPython console add an ! before the command, for example !idle test.py.\nCongrates, Now you're a python pimp!","Q_Score":10,"Tags":"python,windows,python-idle","A_Id":29289580,"CreationDate":"2010-02-26T23:57:00.000","Title":"starting Python IDLE from command line to edit scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors.\nSo how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?","AnswerCount":7,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":58831,"Q_Id":2345607,"Users Score":2,"Answer":"first make sure you have location of idle  in path\n I am using \"python3.5\".So mine looks like this: \nC:\\Program Files\\Python35\\Lib\\idlelib.Yours may differ.\nuse this following command:idle -r file_name.py to run the file\nor just idle file_name.py to edit\nor start idle -r file_name.py ^&exit","Q_Score":10,"Tags":"python,windows,python-idle","A_Id":39559184,"CreationDate":"2010-02-26T23:57:00.000","Title":"starting Python IDLE from command line to edit scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a question related to understanding of how python dictionaries work. \nI remember reading somewhere strings in python are immutable to allow hashing, and it is the same reason why one cannot directly use lists as keys, i.e. the lists are mutable (by supporting .append) and hence they cannot be used as dictionary keys.\nI wanted to know how does implementation of unordered_map in C++ handles these cases. (since strings in C++ are mutable)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1825,"Q_Id":2352342,"Users Score":8,"Answer":"Keys in all C++ map\/set containers are const and thus immutable (after added to the container).\nNotice that C++ containers are not specific to string keys, you can use any objects, but the constness will prevent modifications after the key is copied to the container.","Q_Score":9,"Tags":"c++,python,dictionary,hashmap,tr1","A_Id":2352356,"CreationDate":"2010-02-28T19:35:00.000","Title":"The difference between python dict and tr1::unordered_map in C++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":13254,"Q_Id":2353963,"Users Score":1,"Answer":"Find out how to do what you want using commands (on the command line) and script these commands instead.","Q_Score":13,"Tags":"python,winapi","A_Id":2354011,"CreationDate":"2010-03-01T05:02:00.000","Title":"Automate Windows GUI operations with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":13254,"Q_Id":2353963,"Users Score":0,"Answer":"PyAutoGUI can be installed with pip from PyPI. It's cross platform and can control the mouse & keyboard. It has the features of pywinauto and a few more on top. It can't identify windows or GUI controls, but it does have basic screenshot & image recognition features to click on particular buttons. And it's well-documented and maintained.\npip install pyautogui","Q_Score":13,"Tags":"python,winapi","A_Id":26197899,"CreationDate":"2010-03-01T05:02:00.000","Title":"Automate Windows GUI operations with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet.\nThanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4138,"Q_Id":2359994,"Users Score":0,"Answer":"A lot of people like eclipse with PyDev for python, although I don't know how wel it works on OS X with apple's mishandling of java.","Q_Score":3,"Tags":"python,xcode","A_Id":2360880,"CreationDate":"2010-03-01T23:49:00.000","Title":"Pure Python in Xcode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could anyone tell me how to use pure Python without Cocoa support in Xcode? I can only find the Cocoa-Python template on the Internet.\nThanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4138,"Q_Id":2359994,"Users Score":0,"Answer":"Just about the best IDE for editing and running Python code is actually still emacs.  The python-mode for emacs does a wonderful job of maintaining whitespace and, with a bit of configuration, emacs is truly a powerful editor.\nPretty radically different than your typical GUI editor, certainly, and some find it quite distasteful.  I've personally used emacs, mostly, for editing Python since 1992 or so.\nGoogle will reveal all, including a native version of Emacs for Mac OS X.","Q_Score":3,"Tags":"python,xcode","A_Id":2360692,"CreationDate":"2010-03-01T23:49:00.000","Title":"Pure Python in Xcode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using the Windmill test system and have it running using test_windmill for Django which works fine for the Python tests. I'd like this to run a suite of Javascript tests also whilst the Django test server is running. I've used the run_js_tests call from the Windmill shell which works fine but I can't find a way to have this run as part of the Python tests.\nDoes anyone know how to do this?\nThanks\nRob","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":2373446,"Users Score":0,"Answer":"Ok, so couldn't find out how to do this so I'm running the website under Apache and using the windmill standard jstests parameter to run the Javascript tests against this.","Q_Score":0,"Tags":"python,django,unit-testing,automated-tests,windmill","A_Id":2468981,"CreationDate":"2010-03-03T17:22:00.000","Title":"How do I run Javascript tests in Windmill when using test_windmill for Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The Psyco docs say:\n\nJust for reference, Psyco does not\n  work on any 64-bit systems at all.\n  This fact is worth being noted again,\n  now that the latest Mac OS\/X 10.6\n  \"Snow Leopart\" comes with a default\n  Python that is 64-bit on 64-bit\n  machines. The only way to use Psyco on\n  OS\/X 10.6 is by recompiling a custom\n  Python in 32-bit mode.\n\nIn general, porting programs from 32 to 64 bits is only really an issue when the code assumes a certain size for a pointer type and other similarly small(ish) issues. Considering that Psyco isn't a whole lot of code (~32K lines of C + ~8K lines of Python), how hard could it be? Has anyone tried this and hit a wall? I haven't really had a chance to take a good look at the Psyco sources yet, so I'd really appreciate knowing if I'm wasting my time looking into this...","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":1103,"Q_Id":2374233,"Users Score":3,"Answer":"Psyco assumes that sizeof(int) == sizeof(void*) a bit all over the place. That's much harder than just writing down 64bit calling conventions and assembler. On the sidenote, pypy has 64bit jit support these days.\nCheers,\nfijal","Q_Score":10,"Tags":"python,c,64-bit,porting,psyco","A_Id":3738027,"CreationDate":"2010-03-03T19:18:00.000","Title":"What are the possible pitfalls in porting Psyco to 64-bit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The Psyco docs say:\n\nJust for reference, Psyco does not\n  work on any 64-bit systems at all.\n  This fact is worth being noted again,\n  now that the latest Mac OS\/X 10.6\n  \"Snow Leopart\" comes with a default\n  Python that is 64-bit on 64-bit\n  machines. The only way to use Psyco on\n  OS\/X 10.6 is by recompiling a custom\n  Python in 32-bit mode.\n\nIn general, porting programs from 32 to 64 bits is only really an issue when the code assumes a certain size for a pointer type and other similarly small(ish) issues. Considering that Psyco isn't a whole lot of code (~32K lines of C + ~8K lines of Python), how hard could it be? Has anyone tried this and hit a wall? I haven't really had a chance to take a good look at the Psyco sources yet, so I'd really appreciate knowing if I'm wasting my time looking into this...","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1103,"Q_Id":2374233,"Users Score":3,"Answer":"Since psyco is a compiler, it would need to be aware of the underlying assembly language to generate useful code.  That would mean it would need to know about the 8 new registers, new opcodes for 64 bit code, etc.  \nFurthermore, to interop with the existing code, it would need to use the same calling conventions as 64 bit code.  The AMD-64 calling convention is similar to the old fast-call conventions in that some parameters are passed in registers (in the 64 bit case rcx,rdx,r8,r9 for pointers and Xmm0-Xmm3 for floating point) and the rest are pushed onto spill space on the stack.  Unlike x86, this extra space is usually allocated once for all of the possible calls.  The IA64 conventions and assembly language are different yet.\nSo in short, I think this is probably not as simple as it sounds.","Q_Score":10,"Tags":"python,c,64-bit,porting,psyco","A_Id":2374371,"CreationDate":"2010-03-03T19:18:00.000","Title":"What are the possible pitfalls in porting Psyco to 64-bit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a way to list all fonts installed on a linux\/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both:\n\nTo list all fonts on a UNIX system, xlsfonts can do the trick:\nimport os\nlist_of_fonts=os.popen(\"xslfonts\").readlines()\nTo render a string into an image using a font, I could use PIL (Python Imaging Library) and the ImageFont class.\n\nHowever, ImagesFont.load expects a file name, whereas xlsfonts gives a kind of normalized font name, and the correspondence between the two doesn't seems obvious (I tried to search my system for files named as the output of xlsfonts, without results).\nDoes anyone has an idea on how I can do that? Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":894,"Q_Id":2375125,"Users Score":1,"Answer":"you best bet is to do a find on all the fonts on the system, and then use ImagesFont.load() on the results of that list. I don't know where the fonts are on Debian, but they should be in a well known folder you can just do an os.walk and then feed the filenames in that way.","Q_Score":4,"Tags":"python,linux,fonts,debian,python-imaging-library","A_Id":2375489,"CreationDate":"2010-03-03T21:30:00.000","Title":"Generate image for each font on a linux system using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a way to list all fonts installed on a linux\/Debian system, and then generate images of some strings using these fonts. I'm looking for your advice as I kind of see how to do each part, but not to do both:\n\nTo list all fonts on a UNIX system, xlsfonts can do the trick:\nimport os\nlist_of_fonts=os.popen(\"xslfonts\").readlines()\nTo render a string into an image using a font, I could use PIL (Python Imaging Library) and the ImageFont class.\n\nHowever, ImagesFont.load expects a file name, whereas xlsfonts gives a kind of normalized font name, and the correspondence between the two doesn't seems obvious (I tried to search my system for files named as the output of xlsfonts, without results).\nDoes anyone has an idea on how I can do that? Thanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":894,"Q_Id":2375125,"Users Score":1,"Answer":"You can do this using pango, through the pygtk package.  Pango can list fonts and render them.","Q_Score":4,"Tags":"python,linux,fonts,debian,python-imaging-library","A_Id":2375457,"CreationDate":"2010-03-03T21:30:00.000","Title":"Generate image for each font on a linux system using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"(I asked this question earlier today, but I did a poor job of explaining myself.  Let me try again)\nI have a client who is an industrial maintenance company. They sell service agreements that are prepaid 20 hour blocks of a technician's time. Some of their larger customers might burn through that agreement in two weeks while customers with fewer problems might go eight months on that same contract.  I would like to use Python to help model projected sales revenue and determine how many billable hours per month that they'll be on the hook for.\nIf each customer only ever bought a single service contract (never renewed) it would be easy to figure sales as monthly_revenue = contract_value * qty_contracts_sold.  Billable hours would also be easy: billable_hrs = hrs_per_contract * qty_contracts_sold.  However, how do I account for renewals?  Assuming that 90% (or some other arbitrary amount) of customers renew, then their monthly revenue ought to grow geometrically.  Another important variable is how long the average customer burns through a contract.  How do I determine what the revenue and billable hours will be 3, 6, or 12 months from now, based on various renewal and burn rates?\nI assume that I'd use some type of recursive function but math was never one of my strong points.  Any suggestions please?\nEdit:  I'm thinking that the best way to approach this is to think of it as a \"time value of money\" problem.  I've retitled the question as such.  The problem is probably a lot more common if you think of \"monthly sales\" as something similar to annuity payments.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":987,"Q_Id":2376355,"Users Score":0,"Answer":"Thanks for the assistance even though my requirements were a bit vague.  After consulting someone who is extremely versed in financial mathematics, I determined that a simple formula was not an appropriate solution.\nWhat I ended up doing is \"exploding\" the months into the component days using xrange() and iterating over each day. When evaluating each day, I determined whether a new contract was signed on that day, and if so, which dates in future the contract would need to be renewed.  I pushed those renewal dates into a list and then summed the values.","Q_Score":0,"Tags":"python,math,finance","A_Id":2427737,"CreationDate":"2010-03-04T01:40:00.000","Title":"Python and a \"time value of money\" problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I think I have a great idea for some feature that should be in python's standard library.\nNot something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.\nHow can I suggest such a feature to the consideration of the \"python committee :)\"?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1127,"Q_Id":2386421,"Users Score":0,"Answer":"Either add it to the tracker, or join the developer mailing list and suggest it there.  Better to do that if you feel you can contribute at least to developing the specification, if  not the feature itself.","Q_Score":9,"Tags":"python,pep","A_Id":2386453,"CreationDate":"2010-03-05T11:48:00.000","Title":"how can I make a suggestion for a new feature in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I think I have a great idea for some feature that should be in python's standard library.\nNot something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.\nHow can I suggest such a feature to the consideration of the \"python committee :)\"?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1127,"Q_Id":2386421,"Users Score":0,"Answer":"An alternative to the issue tracker suggested by mpalcona: you can submit it for discussion on the python-dev mailing list.\nAnd always, a reference implementation (something that works, even if not in all cases and not efficiently) is always welcomed.","Q_Score":9,"Tags":"python,pep","A_Id":2386461,"CreationDate":"2010-03-05T11:48:00.000","Title":"how can I make a suggestion for a new feature in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I think I have a great idea for some feature that should be in python's standard library.\nNot something of the magnitude of a new keyword etc, just a suggestion for another decorator that would help a lot, IMO.\nHow can I suggest such a feature to the consideration of the \"python committee :)\"?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1127,"Q_Id":2386421,"Users Score":0,"Answer":"Don't waste time \"suggesting\" things.  Invest time doing things.\nSimply do this.\n\nBuild it.\nUse it.\nPost it to SourceForge.\nPut a link to the SourceForge project on PyPi.\n\nDone.\nIf it's actually a \"great\" idea, then everyone will use it and someone will recommend adding it to the standard library.\nIf it's not a \"great\" idea, but merely good, then everyone will use it.\nIf it's just an idea, you'll notice the number of downloads will remain small.","Q_Score":9,"Tags":"python,pep","A_Id":2387822,"CreationDate":"2010-03-05T11:48:00.000","Title":"how can I make a suggestion for a new feature in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to set properties related to Remote Desktop Services on Active Directory users in .NET (i.e., via System.DirectoryServices), but I can't see that these properties are exposed by the API? I know there is a COM interface for this purpose, IADsTSUserEx. Please show me how I can get at these properties in .NET :) Bear in mind that the programming language is Python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2366,"Q_Id":2392949,"Users Score":0,"Answer":"The problem with some of these properties is that you can see them on the UI via Active Directory Users and Computers, but you cannot set them (or see them) via ADSI Editor. \nUsually, for properties that aren't directly available from a DirectoryEntry object, you can use its Properties collection as described by Tim Robbinson\n(e.g. directoryEntry.Properties[\"PropertyName\"].Value). \nFor some properties, however, you cannot use this approach and have to use directoryEntry.InvokeSet(\"PropertyName\", new object[]{ \"SomeValue\" });, \ne.g. for TerminalServicesHomeDirectory, TerminalServicesHomeDrive and TerminalServicesProfilePath. \nAs said above, you won't see these three properties using ADSI Editor, you can only see the property values via the \"normal\" UI on the corresponding tab.\nHow you can apply all this to Python I don't know, but it seems you've got instances of the DirectoryEntry class, so you should be fine.","Q_Score":0,"Tags":".net,python,active-directory,directoryservices","A_Id":14938596,"CreationDate":"2010-03-06T15:20:00.000","Title":"How do I change Remote Desktop Services properties of AD users in .NET?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security?\nThese things are sort of omni-present in the application, so how to test them properly?\nE.g. say that I'm writing a Cherrypy web server in Python. I can use a decorator to check whether the logged-in user has the permission to access a given page. But then I'd need to write a test for every page to see whether it works oK (or more like to see that I had not forgotten to check security perms for that page).\nThis could maybe (emphasis on maybe) be bearable if logging and\/or security were implemented during the web server \"normal business implementation\". However, security and logging usually tend to be added to the app as an afterthough (or maybe that's just my experience, I'm usually given a server and then asked to implement security model :-) ).\nAny thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":2401789,"Users Score":0,"Answer":"Well... let's see. In my opinion you are testing three different things here (sorry for the \"Java AOP jargon\"):\n\nthe features implemented by the interceptors (i.e. the methods that implement the functions activated at the cutpoints)\nthe coverage of the filters (i.e. whether the intended cutpoints are activated correctly or not)\nthe interaction between the cutpoints and the interceptors (with the side effects)\n\nYou are unit testing (strictly speaking) if you can handle these three layers separatedly. You can actually unit test the first; you can use a coverage tool and some skeleton crew application with mock objects to test the second; but the third is not exactly unit testing, so you may have to setup a test environment, design an end-to-end test and write some scripts to input data in your application and gather the results (if it was a web app you could use Selenium, for example).","Q_Score":4,"Tags":"python,unit-testing,aop","A_Id":2402152,"CreationDate":"2010-03-08T14:03:00.000","Title":"Unit testing aspect-oriented features","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'd like to know what would you propose as the best way to unit test aspect-oriented application features (well, perhaps that's not the best name, but it's the best I was able to come up with :-) ) such as logging or security?\nThese things are sort of omni-present in the application, so how to test them properly?\nE.g. say that I'm writing a Cherrypy web server in Python. I can use a decorator to check whether the logged-in user has the permission to access a given page. But then I'd need to write a test for every page to see whether it works oK (or more like to see that I had not forgotten to check security perms for that page).\nThis could maybe (emphasis on maybe) be bearable if logging and\/or security were implemented during the web server \"normal business implementation\". However, security and logging usually tend to be added to the app as an afterthough (or maybe that's just my experience, I'm usually given a server and then asked to implement security model :-) ).\nAny thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":258,"Q_Id":2401789,"Users Score":1,"Answer":"IMHO, the way of testing users permissions to the pages depends on the design of your app and design of the framework you're using.\nGenerally, it's probably enough to cover your permission checker decorator with unit tests to make sure it always works as expected and then write a test that cycles through your 'views' (or whatever term cherrypy uses, haven't used it for a very long time) and just check if these functions are decorated with appropriate decorator.\nAs for logging it's not quite clear what you want test specifically. Anyway, why isn't it possible to stub the logging functionality and check what's going on there?","Q_Score":4,"Tags":"python,unit-testing,aop","A_Id":2796926,"CreationDate":"2010-03-08T14:03:00.000","Title":"Unit testing aspect-oriented features","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I wanted to know how can I make standalone application in python.\nBasically what I am doing right now is I have a template.tex file and my script generate the pdf by giving some input values.\nSo I have to make exe file for windows and same for linux.\nI can use cx_freeze for creating exe file.\nBut my problem is most of people do not contain latex on their computer.\nSO how can I make latex get install when I first run my exe.\nBasically how to make make file.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":467,"Q_Id":2409168,"Users Score":2,"Answer":"You could write a installer (using NSIS or something) that does two things : \n\ninstall LateX (or make sure there is an installation of latex available), potentially by calling another installer\nthen install your python script (which can assume latex is now available)","Q_Score":1,"Tags":"python","A_Id":2409213,"CreationDate":"2010-03-09T13:04:00.000","Title":"standalone application in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple .exe that needs to be running continuously.\nUnfortunately, sometimes it crashes unexpectedly, and there's nothing that can be done for this.\nI'm thinking of like a C# program that scans the running application tree on a timer and if the process stops running it re-launches it... ?  Not sure how to do that though....\nAny other ideas?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":221,"Q_Id":2414616,"Users Score":1,"Answer":"The first solution would be to fix your EXE, so it does not crash. If you can not fix it now, you probably need to add exception handling, so you can catch the exception, and not close the EXE.\nSecond solution is to write simple guard programm that will start your simple .exe and will monitor specific process handle. It will restart your program when it closes.","Q_Score":0,"Tags":"c#,c++,python","A_Id":2414677,"CreationDate":"2010-03-10T04:56:00.000","Title":"How to make script\/program to make it so an application is always running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've wrote a piece of code in python and pygtk for an embeded mplayer in a gui.\nI assume I use GtkSocket and the slave mode of mplayer with the -wid option.\nBut I've got an issue, when the size of my GTK window is smaller than my stream, the stream appears to be cropped. And when the size of my window is bigger than my stream, the stream appear centred inside the widget which embed MPlayer. (a gtk.Frame but I've also try with a gtk.DrawingArea)\nI would like to know how I can get my stream resize dynamically depending on the window's size.\nI don't want to use Glade or any GUI builder.\nThanks in advance for any help, and please excuse my poor english.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1512,"Q_Id":2417705,"Users Score":1,"Answer":"You need to tell mplayer to zoom video according to window size. This can be done either in command line (-zoom) or in the configuration file (zoom = 1).","Q_Score":0,"Tags":"python,gtk,pygtk,mplayer","A_Id":2944206,"CreationDate":"2010-03-10T14:39:00.000","Title":"Dynamic resize with MPlayer and PyGTK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very basic question - how to get one value from a generator in Python?\nSo far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":99132,"Q_Id":2419770,"Users Score":76,"Answer":"In Python <= 2.5, use gen.next(). This will work for all Python 2.x versions, but not Python 3.x\nIn Python >= 2.6, use next(gen). This is a built in function, and is clearer. It will also work in Python 3.\nBoth of these end up calling a specially named function, next(), which can be overridden by subclassing. In Python 3, however, this function has been renamed to __next__(), to be consistent with other special functions.","Q_Score":143,"Tags":"python,generator","A_Id":2421288,"CreationDate":"2010-03-10T19:11:00.000","Title":"How to get one value at a time from a generator function in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very basic question - how to get one value from a generator in Python?\nSo far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","AnswerCount":6,"Available Count":4,"Score":0.1651404129,"is_accepted":false,"ViewCount":99132,"Q_Id":2419770,"Users Score":5,"Answer":"To get the value associated with a generator object in python 3 and above use next(<your generator object>).\nsubsequent calls to next() produces successive object values in the queue.","Q_Score":143,"Tags":"python,generator","A_Id":60391726,"CreationDate":"2010-03-10T19:11:00.000","Title":"How to get one value at a time from a generator function in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very basic question - how to get one value from a generator in Python?\nSo far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":99132,"Q_Id":2419770,"Users Score":189,"Answer":"Yes, or next(gen) in 2.6+.","Q_Score":143,"Tags":"python,generator","A_Id":2419782,"CreationDate":"2010-03-10T19:11:00.000","Title":"How to get one value at a time from a generator function in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very basic question - how to get one value from a generator in Python?\nSo far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":99132,"Q_Id":2419770,"Users Score":1,"Answer":"In python 3 you don't have gen.next(), but you still can use next(gen).\nA bit bizarre if you ask me but that's how it is.","Q_Score":143,"Tags":"python,generator","A_Id":37890506,"CreationDate":"2010-03-10T19:11:00.000","Title":"How to get one value at a time from a generator function in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program that is going to eat a lot of memory, primarily in a dict.  This dict will be responsible for assigning a unique integer value to a very large set of keys.  As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need to map the values back to the original keys).\nI believe this amount will eventually surpass available memory.  I am wondering how this will be handled with regards to swap space.  Perhaps there is a better data structure for this purpose.","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":1227,"Q_Id":2420219,"Users Score":5,"Answer":"You need a database, if the data will exceed memory.  The indexing of dictionaries isn't designed for good performance when a dictionary is bigger than memory.","Q_Score":4,"Tags":"python,memory,data-structures,matrix,swap","A_Id":2420257,"CreationDate":"2010-03-10T20:11:00.000","Title":"How does OS handle a python dict that's larger than memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program that is going to eat a lot of memory, primarily in a dict.  This dict will be responsible for assigning a unique integer value to a very large set of keys.  As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need to map the values back to the original keys).\nI believe this amount will eventually surpass available memory.  I am wondering how this will be handled with regards to swap space.  Perhaps there is a better data structure for this purpose.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1227,"Q_Id":2420219,"Users Score":1,"Answer":"It will just end up in swap trashing, because a hash table has very much randomized memory access patterns.\nIf you know that the map exceeds the size of the physical memory, you could consider using a data structure on the disk in the first place. This especially if you don't need the data structure during the computation. When the hash table triggers swapping, it creates problems also outside the hash table itself.","Q_Score":4,"Tags":"python,memory,data-structures,matrix,swap","A_Id":2420260,"CreationDate":"2010-03-10T20:11:00.000","Title":"How does OS handle a python dict that's larger than memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have an user registration form.  In this form, I have the option for the user to upload a photo. I have an User table and Photo table.  My User table has a \"PathToPhoto\" column.  My question is how do I fill in the \"PathToPhoto\" column if the photo is uploaded and inserted into Photo table before the user is created?  Another way to phrase my question is how to get the newly uploaded photo to be associated to the user that may or may not be created next. \nI'm using python and postgresql.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":2435281,"Users Score":0,"Answer":"To make sure we're on the same page, is the following correct?\n\nYou're inserting the photo information into the Photo table immediately after the user uploads the photo but before he\/she submits the form;\nWhen the user submits the form, you're inserting a row into the User table;\nOne of the items in that row is information about the previously created photo entry.\n\nIf so, you should be able to store the \"path to photo\" information in a Python variable until the user submits the form, and then use the value from that variable in your User-table insert.","Q_Score":0,"Tags":"python,database,postgresql","A_Id":2435639,"CreationDate":"2010-03-12T19:32:00.000","Title":"Database: storing data from user registration form","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to show a webpage (a complex page with script and stuff, no static html) in a frame or something. It's for a desktop application, I'm using python 2.6 + wxPython 2.8.10.1. I need to catch some events too (mostly about changing page). I've found some samples using the webview module in a gtk application, but I couldn't have it works on wx.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":788,"Q_Id":2439039,"Users Score":1,"Answer":"You can embed IE, but I think that's about it. wxWebKit is working on a wx add-on to use WebKit as an embedded browser in wx, but I think it's still a work in progress.","Q_Score":0,"Tags":"python,wxwidgets","A_Id":2439208,"CreationDate":"2010-03-13T16:22:00.000","Title":"how to embed a webpage using wx?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to install matplotlib on my mac setup. I find that setup.py has inaccurate flags, in particular the isysroot points to an earlier SDK.\nWhere does setup.py get its info and how can i fix it?\nI'm on MacOS 10.5.8, XCode 3.1.2 and Python 2.6 (default config was 2.5)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1851,"Q_Id":2440579,"Users Score":3,"Answer":"I'm guessing you've installed 2.6 on 10.5 using the python.org OS X installer.  In that case, the flags are accurate and you should not try to change them.  The python.org installers are built using the so-called 10.4u SDK and with a deployment target of 10.3, allowing one installer image to work on Mac OS X systems from 10.3.9 up through 10.6 (and possibly beyond).  The most recent releases of Python 2.6 have been fixed to ensure that extension module building on OS X forces the C compiler options to match those of the underlying Python so you'll need to make sure you install the 10.4u SDK (or whatever) if necessary from the Xcode package (on the OS X release CD\/DVD or downloaded from the Apple Developer Connection website).  It will also make sure you are using gcc-4.0, which is also the default on 10.5.","Q_Score":2,"Tags":"python,macos,gcc,distutils,setup.py","A_Id":2440981,"CreationDate":"2010-03-13T23:53:00.000","Title":"Compiler options wrong with python setup.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1782,"Q_Id":2445193,"Users Score":7,"Answer":"Python is dynamically typed: all variables can refer to an object of any type. id and name can be anything, but the actual objects are of types like int and str. 0 is a literal that is parsed to make an int object, and 'John' a literal that makes a str object. Many object types do not have literals and are returned by a callable (like frozenset\u2014there's no way to make a literal frozenset, you must call frozenset.)\nConsequently, there is no such thing as declaration of variables, since you aren't defining anything about the variable. id = 0 and name = 'John' are just assignment.\nincrease returns an int because that's what you return in it; nothing in Python forces it not to be any other object. first and second are only ints if you make them so.\nObjects, to a certain extent, share a common interface. You can use the same operators and functions on them all, and if they support that particular operation, it works. It is a common, recommended technique to use different types that behave similarly interchangably; this is called duck typing. For example, if something takes a file object you can instead pass a cStringIO.StringIO object, which supports the same method as a file (like read and write) but is a completely different type. This is sort of like Java interfaces, but does not require any formal usage, you just define the appropriate methods.","Q_Score":6,"Tags":"python","A_Id":2445239,"CreationDate":"2010-03-15T05:04:00.000","Title":"How does Python differentiate between the different data types?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1782,"Q_Id":2445193,"Users Score":13,"Answer":"The literal objects you mention carry (pointers to;-) their own types with them of course, so when a name's bound to that object the problem of type doesn't arise -- the object always has a type, the name doesn't -- just delegates that to the object it's bound to.\nThere's no \"figuring out\" in def increase(first, second): -- name increase gets bound to a function object, names first and second are recorded as parameters-names and will get bound (quite possibly to objects of different types at various points) as increase gets called.\nSo say the body is return first + second -- a call to increase('foo', 'bar') will then happily return 'foobar' (delegating the addition to the objects, which in this case are strings), and maybe later a call to increase(23, 45) will just as happily return 68 -- again by delegating the addition to the objects bound to those names at the point of call, which in this case are ints.  And if you call with incompatible types you'll get an exception as the delegated addition operation can't make sense of the situation -- no big deal!","Q_Score":6,"Tags":"python","A_Id":2445233,"CreationDate":"2010-03-15T05:04:00.000","Title":"How does Python differentiate between the different data types?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":1782,"Q_Id":2445193,"Users Score":4,"Answer":"When it comes to assigning literal values to variables, the type of the literal value can be inferred at the time of lexical analysis.  For example, anything matching the regular expression (-)?[1-9][0-9]* can be inferred to be an integer literal.  If you want to convert it to a float, there needs to be an explicit cast.  Similarly, a string literal is any sequence of characters enclosed in single or double quotes.\nIn a method call, the parameters are not type-checked.  You only need to pass in the correct number of them to be able to call the method.  So long as the body of the method does not cause any errors with respect to the arguments, you can call the same method with lots of different types of arguments.","Q_Score":6,"Tags":"python","A_Id":2445220,"CreationDate":"2010-03-15T05:04:00.000","Title":"How does Python differentiate between the different data types?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been writing Java for the last couple of years , and now I've started to write in python (in addition). \nThe problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. \nAny tips on how to escape this pattern of \"Writing Java in Python\"? \nThanks!","AnswerCount":13,"Available Count":4,"Score":0.0153834017,"is_accepted":false,"ViewCount":7368,"Q_Id":2447118,"Users Score":1,"Answer":"Try to find algorithms that you understand well and see how they are implemented in python standard libraries.\nPersist. :)","Q_Score":34,"Tags":"java,python","A_Id":2495504,"CreationDate":"2010-03-15T12:45:00.000","Title":"Programming in Python vs. programming in Java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been writing Java for the last couple of years , and now I've started to write in python (in addition). \nThe problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. \nAny tips on how to escape this pattern of \"Writing Java in Python\"? \nThanks!","AnswerCount":13,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7368,"Q_Id":2447118,"Users Score":0,"Answer":"Learn a few other languages. It will help you make the difference between algorithms (the structure of processing, unchanged between languages) and the local syntaxic features of the language. Then you can \"write Foo in Bar\" for any combination of languages \"Foo\" and \"Bar\".","Q_Score":34,"Tags":"java,python","A_Id":2447141,"CreationDate":"2010-03-15T12:45:00.000","Title":"Programming in Python vs. programming in Java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been writing Java for the last couple of years , and now I've started to write in python (in addition). \nThe problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. \nAny tips on how to escape this pattern of \"Writing Java in Python\"? \nThanks!","AnswerCount":13,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7368,"Q_Id":2447118,"Users Score":0,"Answer":"Eat Python, Sleep Python and Drink Python. That is the only way........","Q_Score":34,"Tags":"java,python","A_Id":2495445,"CreationDate":"2010-03-15T12:45:00.000","Title":"Programming in Python vs. programming in Java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been writing Java for the last couple of years , and now I've started to write in python (in addition). \nThe problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. \nAny tips on how to escape this pattern of \"Writing Java in Python\"? \nThanks!","AnswerCount":13,"Available Count":4,"Score":0.0461211021,"is_accepted":false,"ViewCount":7368,"Q_Id":2447118,"Users Score":3,"Answer":"Definitely not a panacea but I think you should try some code golf in Python.  Obviously nobody should write \"golfed\" code IRL, but finding the most terse way to express something really forces you to exploit the built in functionality of the language.","Q_Score":34,"Tags":"java,python","A_Id":2448287,"CreationDate":"2010-03-15T12:45:00.000","Title":"Programming in Python vs. programming in Java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a web service to which users upload python scripts that are run on a server. Those scripts process files that are on the server and I want them to be able to see only a certain hierarchy of the server's filesystem (best: a temporary folder on which I copy the files I want processed and the scripts).\nThe server will ultimately be a linux based one but if a solution is also possible on Windows it would be nice to know how.\nWhat I though of is creating a user with restricted access to folders of the FS - ultimately only the folder containing the scripts and files - and launch the python interpreter using this user.\nCan someone give me a better alternative? as relying only on this makes me feel insecure, I would like a real sandboxing or virtual FS feature where I could run safely untrusted code.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1877,"Q_Id":2452488,"Users Score":3,"Answer":"You are probably best to use a virtual machine like VirtualBox or VMware (perhaps even creating one per user\/session).  \nThat will allow you some control over other resources such as memory and network as well as disk\nThe only python that I know of that has such features built in is the one on Google App Engine. That may be a workable alternative for you too.","Q_Score":4,"Tags":"python,security,filesystems,sandbox","A_Id":2452503,"CreationDate":"2010-03-16T06:24:00.000","Title":"faking a filesystem \/ virtual filesystem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been trying to add some check boxes in a pylons mako. However I don't know how to get their values in the controller. It seems that it can only get the first value of the check boxes. I tried using form encode but i got several errors. Is there an easier way to do this?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1306,"Q_Id":2456926,"Users Score":0,"Answer":"I'm assuming that \"I can only get the first value\" means you've got a series of checkboxes with the same value for the 'name' attribute within your form?    \nNow, if that's the case and you're wanting a list of boolean values based on whether or not the boxes are checked or not, you'll need to do two things:\nFirst, when you define your form elements using form encode on your checkbox, set it up such that a missing value on a checkbox element returns 'False.' This way, as the browser won't send a value over unless a checkbox is \"on\", you validation coerces the missing value to False.\n\n\n    class Registration(formencode.Schema):  \n        box = formencode.validators.StringBoolean(if_missing=False)\n\n\nNext, assuming you want a list returned, you'll not be able to name all of your elements the same.  Pylons supports a nested structure, though.  Look at formencode.variabledecode.NestedVariables. In short, you'll need to define a NestedVariables instance as one of your class attributes and your form 'name' attributes will need to change in order to contain explicit indexes.   \nEdit.. here's a complete example I did real quick:\n\n\nimport logging\nimport pprint\n\nimport formencode\nfrom pylons import request, response, session, tmpl_context as c, url\nfrom pylons.controllers.util import abort, redirect\nfrom pylons.decorators import validate\n\nfrom testproj.lib.base import BaseController, render\n\nlog = logging.getLogger(__name__)\n\nclass CheckList(formencode.Schema):\n    box = formencode.validators.StringBoolean(if_missing=False)\n    hidden = formencode.validators.String()\n\nclass EnclosingForm(formencode.Schema):\n    pre_validators = [formencode.NestedVariables()]\n    boxes = formencode.ForEach(CheckList())\n\nclass MyformController(BaseController):\n\n    def index(self):\n        schema = EnclosingForm()\n        v = schema.to_python(dict(request.params))\n        # Return a rendered template\n        #return render('\/myform.mako')\n        # or, return a response\n        response.content_type = 'text\/plain'\n        return pprint.pformat(v)\n\n\n\nAnd then the query string?\n\nboxes-0.box=true&boxes-0.hidden=hidden&boxes-1.box=true&\nboxes-1.hidden=hidden&boxes-2.hidden=hidden\nAnd lastly, the response:\n\n{'boxes': [{'box': True, 'hidden': u'hidden'},\n           {'box': True, 'hidden': u'hidden'},\n           {'box': False, 'hidden': u'hidden'}]}\n\nHTH","Q_Score":1,"Tags":"python,pylons","A_Id":2457303,"CreationDate":"2010-03-16T18:11:00.000","Title":"Checkboxes with pylons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back.\nOn other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c doesn't work...\nAre there other ways to stop the program?\nThis is IDLE on Windows, if it makes any difference.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":54617,"Q_Id":2460401,"Users Score":2,"Answer":"I had same issue in Canopy Python Editor, and I was able to interrupt python session with CTRL+. (\"dot\" button). Hope that helps, or they probably do things in a similar ways","Q_Score":11,"Tags":"python,matplotlib,tkinter,break,python-idle","A_Id":31151803,"CreationDate":"2010-03-17T07:04:00.000","Title":"How to stop Python program execution in IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back.\nOn other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c doesn't work...\nAre there other ways to stop the program?\nThis is IDLE on Windows, if it makes any difference.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":54617,"Q_Id":2460401,"Users Score":7,"Answer":"I have seen this problem with IDLE and matplotlib when using them on Windows. I don't know the exact cause, but Ctrl-c a couple times has typically worked for me. If that doesn't work for you, you can use the normal interpreter instead of write your plot directly to a file instead of the screen.\nThis is one of those (plentiful) times when IDLE doesn't behave like a normal Python script or interpreter session. Because of this, I usually avoid IDLE.","Q_Score":11,"Tags":"python,matplotlib,tkinter,break,python-idle","A_Id":2460438,"CreationDate":"2010-03-17T07:04:00.000","Title":"How to stop Python program execution in IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back.\nOn other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c doesn't work...\nAre there other ways to stop the program?\nThis is IDLE on Windows, if it makes any difference.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":54617,"Q_Id":2460401,"Users Score":7,"Answer":"Ctrl+F6\n(Restart shell)\nor Shell->Restart Shell","Q_Score":11,"Tags":"python,matplotlib,tkinter,break,python-idle","A_Id":20615556,"CreationDate":"2010-03-17T07:04:00.000","Title":"How to stop Python program execution in IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python MySQLDB, and I want to insert this into DATETIME field in Mysql .  How do I do that with cursor.execute?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9981,"Q_Id":2460491,"Users Score":1,"Answer":"Solved.\nI just did this:\ndatetime.datetime.now() ...insert that into the column.","Q_Score":5,"Tags":"python,mysql,database,datetime,date","A_Id":2460546,"CreationDate":"2010-03-17T07:28:00.000","Title":"In Python, if I have a unix timestamp, how do I insert that into a MySQL datetime field?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need it to open 10 processes, and each time one of them finishes I want to wait few seconds and start another one.\nIt seems pretty simple, but somehow I can't get it to work.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1275,"Q_Id":2464704,"Users Score":1,"Answer":"I've done this same thing to process web statistics using a semaphore.  Essentially, as processes are created, the semaphore is incremented. When they exit, it's decremented.  The creation process is blocked when the semaphore blocks.  \nThis actually fires off threads, which run external processes down execution path a bit.\nHere's an example.\n\n\n    thread_sem = threading.Semaphore(int(cfg.maxthreads))\n    for k,v in log_data.items():\n        thread_list.append(ProcessorThread(int(k), v, thread_sem))\n        thread_list[-1].start()\n\n\nAnd then in the constructor for ProcessorThread, I do this:\n\n\n    def __init__(self, siteid, data, lock_object):\n        threading.Thread.__init__(self)\n        self.setDaemon(False)\n        self.lock_object = lock_object\n        self.data = data\n        self.siteid = siteid\n        self.lock_object.acquire()\n\n\nWhen the thread finishes it's task (whether successfully or not), the lock_object is released which allows for another process to begin.\nHTH","Q_Score":2,"Tags":"python,subprocess,watchdog","A_Id":2464752,"CreationDate":"2010-03-17T18:09:00.000","Title":"How to implement a master\/watchdog script in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI.  I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it.  I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. \nI intend to run multiple server instances with 200+ persistant NPC entities that I will need to update.  Most action is slowly roaming around based on player movements\/concentrations, and attacking close range players...(you can probably guess the type of game im developing)","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1026,"Q_Id":2465056,"Users Score":2,"Answer":"If the game is turn based then it would probably be best to avoid the Cron task and just update the NPCs every time the player moves. I'm not sure how big of a map you are planning on but you may consider even having the player object find the NPCs that are close to it and call their AI routine.  That way NPCs that are out of range of a player wouldn't move at all which may save on resources.  Not sure if that matter though.","Q_Score":1,"Tags":"python,google-app-engine,artificial-intelligence","A_Id":2471015,"CreationDate":"2010-03-17T18:59:00.000","Title":"Artificial Intelligence in online game using Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI.  I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it.  I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. \nI intend to run multiple server instances with 200+ persistant NPC entities that I will need to update.  Most action is slowly roaming around based on player movements\/concentrations, and attacking close range players...(you can probably guess the type of game im developing)","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1026,"Q_Id":2465056,"Users Score":2,"Answer":"Bear in mind that you can also break up your updates into multiple requests (internally): do a bit of work, redirect to the same handler but different state; do more work; etc.  (I'm failing somehow to comment on Peter Recore's answer, which is where this really belongs.)\nI see that the free service only allows 100k task queue calls\/day, so 1 task\/NPC would probably use up your resources way too fast.  Cron job to do some work\/create task queues to update NPCs in appropriately-sized groups?  \nAnyway, just some thoughts; good luck.","Q_Score":1,"Tags":"python,google-app-engine,artificial-intelligence","A_Id":2471126,"CreationDate":"2010-03-17T18:59:00.000","Title":"Artificial Intelligence in online game using Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI.  I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it.  I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. \nI intend to run multiple server instances with 200+ persistant NPC entities that I will need to update.  Most action is slowly roaming around based on player movements\/concentrations, and attacking close range players...(you can probably guess the type of game im developing)","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1026,"Q_Id":2465056,"Users Score":3,"Answer":"Will your game be turn based or real time?\nEither way, I think you have 2 options to look into.  One is to use the Cron feature so you can schedule NPC updates at regular intervals, the other is to stick a \"update NPCs\" task into the Task Queue every time a human player moves.","Q_Score":1,"Tags":"python,google-app-engine,artificial-intelligence","A_Id":2465142,"CreationDate":"2010-03-17T18:59:00.000","Title":"Artificial Intelligence in online game using Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How would I download files (video) with Python using wget and save them locally? There will be a bunch of files, so how do I know that one file is downloaded so as to automatically start downloding another one?\nThanks.","AnswerCount":6,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":92663,"Q_Id":2467609,"Users Score":-6,"Answer":"No reason to use python. Avoid writing a shell script in Python and go with something like bash or an equivalent.","Q_Score":32,"Tags":"python,linux","A_Id":2467717,"CreationDate":"2010-03-18T04:55:00.000","Title":"Using wget via Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How would I download files (video) with Python using wget and save them locally? There will be a bunch of files, so how do I know that one file is downloaded so as to automatically start downloding another one?\nThanks.","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":92663,"Q_Id":2467609,"Users Score":9,"Answer":"No reason to use os.system.  Avoid writing a shell script in Python and go with something like urllib.urlretrieve or an equivalent.\nEdit... to answer the second part of your question, you can set up a thread pool using the standard library Queue class.  Since you're doing a lot of downloading, the GIL shouldn't be a problem.  Generate a list of the URLs you wish to download and feed them to your work queue. It will handle pushing requests to worker threads. \nI'm waiting for a database update to complete, so I put this together real quick.\n\n\n#!\/usr\/bin\/python\n\nimport sys\nimport threading\nimport urllib\nfrom Queue import Queue\nimport logging\n\nclass Downloader(threading.Thread):\n    def __init__(self, queue):\n        super(Downloader, self).__init__()\n        self.queue = queue\n\n    def run(self):\n        while True:\n            download_url, save_as = queue.get()\n            # sentinal\n            if not download_url:\n                return\n            try:\n                urllib.urlretrieve(download_url, filename=save_as)\n            except Exception, e:\n                logging.warn(\"error downloading %s: %s\" % (download_url, e))\n\nif __name__ == '__main__':\n    queue = Queue()\n    threads = []\n    for i in xrange(5):\n        threads.append(Downloader(queue))\n        threads[-1].start()\n\n    for line in sys.stdin:\n        url = line.strip()\n        filename = url.split('\/')[-1]\n        print \"Download %s as %s\" % (url, filename)\n        queue.put((url, filename))\n\n    # if we get here, stdin has gotten the ^D\n    print \"Finishing current downloads\"\n    for i in xrange(5):\n        queue.put((None, None))","Q_Score":32,"Tags":"python,linux","A_Id":2467646,"CreationDate":"2010-03-18T04:55:00.000","Title":"Using wget via Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I downloaded Pydev plugin for Eclipse (3.5.2) today on Mac OSX 10.5.8. To be able to use Pydev, I need to configure the interpreter in Eclipse. I am not clear what exactly I need to do here, or what this step does. I want to make sure that when I run programs from Eclipse using Pydev, it uses the Enthought Python Distribution (EPD) I have installed, and can use all the packages that come with EPD. Can someone please tell me simple steps that I need to follow. \nIf I click on autoconfig, it shows a bunch of folders with the path\n\/System\/Library\/Frameworks\/Python.Framework\/Versions\/2.5\/...\nBut I know that the Python that came with EPD is version 2.6.4, so autoconfig is not choosing EPD.\nThanks for any help.\n\nUPDATE - solution\nIf anyone else is interested in learning how to do this, see the first link in the answer by mlvljr below. Use the solution there EXCEPT that as suggested in the solution, Shift+Cmd+G, did not help me see inside the Python.app package. To look inside it, use the \"gear\" drop down menu in the Finder and choose \"Show Package Contents\"","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":20897,"Q_Id":2469849,"Users Score":1,"Answer":"I am running Python 3, so I had to make these changes to get python.exe as my interpreter.\nFile:\nC:\\EasyEclipse-for-LAMP-1.2.2.2\\extensions\\pydev-1.3.3\\eclipse\\plugins\\org.python.pydev_1.3.3\\PySrc\\interpreterInfo.py\nEdit all occurrences of \"print ...\" to \"print(...)\" (the ... is whatever is being printed), so wrap it in parentheses.\nComment out line 16, since True and False are considered keywords in Python 3.\nSave, and you should be able to successfully set C:\\Python32\\python.exe as the interpreter. I kept the default folders checked.","Q_Score":16,"Tags":"python,pydev,enthought","A_Id":9306753,"CreationDate":"2010-03-18T12:45:00.000","Title":"Configuring Pydev Interpreter in Eclipse to use Enthought Python Distribution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I downloaded Pydev plugin for Eclipse (3.5.2) today on Mac OSX 10.5.8. To be able to use Pydev, I need to configure the interpreter in Eclipse. I am not clear what exactly I need to do here, or what this step does. I want to make sure that when I run programs from Eclipse using Pydev, it uses the Enthought Python Distribution (EPD) I have installed, and can use all the packages that come with EPD. Can someone please tell me simple steps that I need to follow. \nIf I click on autoconfig, it shows a bunch of folders with the path\n\/System\/Library\/Frameworks\/Python.Framework\/Versions\/2.5\/...\nBut I know that the Python that came with EPD is version 2.6.4, so autoconfig is not choosing EPD.\nThanks for any help.\n\nUPDATE - solution\nIf anyone else is interested in learning how to do this, see the first link in the answer by mlvljr below. Use the solution there EXCEPT that as suggested in the solution, Shift+Cmd+G, did not help me see inside the Python.app package. To look inside it, use the \"gear\" drop down menu in the Finder and choose \"Show Package Contents\"","AnswerCount":7,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":20897,"Q_Id":2469849,"Users Score":12,"Answer":"Mac OS 10.6.4:\nSelecting the interpreter as \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Python did not work.\nI had to select \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python","Q_Score":16,"Tags":"python,pydev,enthought","A_Id":4060609,"CreationDate":"2010-03-18T12:45:00.000","Title":"Configuring Pydev Interpreter in Eclipse to use Enthought Python Distribution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im trying to write some kind of multi protocol bot (jabber\/irc) that would read messages from fifo file (one liners mostly) and then send them to irc channel and jabber contacts. So far, I managed to create two factories to connect to jabber and irc, and they seem to be working. \nHowever, I've problem with reading the fifo file - I have no idea how to read it in a loop (open file, read line, close file, jump to open file and so on) outside of reactor loop to get the data I need to send, and then get that data to reactor loop for sending in both protocols. I've been looking for information on how to do it in best way, but Im totally lost in the dark. Any suggestion\/help would be highly appreciated.\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1766,"Q_Id":2476234,"Users Score":1,"Answer":"The fifo is the problem. Read from a socket instead. This will fit info the Twisted event-driven model much better. Trying to do things outside the control of the reactor is usually the wrong approach.\n---- update based on feedback that the fifo is an external constraint, not avoidable ----\nOK, the central issue is that you can not write code in the main (and only) thread of your Twisted app that makes blocking read calls to a fifo. That will cause the whole app to stall if there is nothing to read. So you're either looking at reading the fifo asynchronously, creating a separate thread to read it, or splitting the app in two.\nThe last option is the simplest - modify the Twisted app so that it listens on a socket and write a separate little \"forwarder\" app that runs in a simple loop, reading the fifo and writing everything it hears to the socket.","Q_Score":4,"Tags":"python,twisted,xmpp,irc,fifo","A_Id":2476445,"CreationDate":"2010-03-19T09:45:00.000","Title":"Python (Twisted) - reading from fifo and sending read data to multiple protocols","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im trying to write some kind of multi protocol bot (jabber\/irc) that would read messages from fifo file (one liners mostly) and then send them to irc channel and jabber contacts. So far, I managed to create two factories to connect to jabber and irc, and they seem to be working. \nHowever, I've problem with reading the fifo file - I have no idea how to read it in a loop (open file, read line, close file, jump to open file and so on) outside of reactor loop to get the data I need to send, and then get that data to reactor loop for sending in both protocols. I've been looking for information on how to do it in best way, but Im totally lost in the dark. Any suggestion\/help would be highly appreciated.\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1766,"Q_Id":2476234,"Users Score":3,"Answer":"You can read\/write on a file descriptor without blocking the reactor as you do with sockets, by the way doesn't sockets use file descriptors?\nIn your case create a class that implements twisted.internet.interfaces.IReadDescriptor and add to reactor using twisted.internet.interfaces.IReactorFDSet.addReader. For an example of IReadDescriptor implementation look at twisted.internet.tcp.Connection.\nI cannot be more specific because i never did by my self, but i hope this could be a start point.","Q_Score":4,"Tags":"python,twisted,xmpp,irc,fifo","A_Id":2478970,"CreationDate":"2010-03-19T09:45:00.000","Title":"Python (Twisted) - reading from fifo and sending read data to multiple protocols","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a number crunching python code. The calculations involved can take hours. Is it possible somehow to compile it to binary?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2921,"Q_Id":2486737,"Users Score":3,"Answer":"First you can try psyco, that may give you a speed up as much as 10x, but 2x is more typical\nIf you can post the code up somewhere, perhaps someone can point out how to leverage numpy.\nIf your task doesn't map well only numpy then cython is a good choice to convert a intensive function or two into C code just by adding a few cdefs.\nIf you can show us the code (even just the hot spots) we can probably give you better advice.\nPerhaps you can modify your algorithm","Q_Score":0,"Tags":"python","A_Id":2486751,"CreationDate":"2010-03-21T10:41:00.000","Title":"Convert python script to binary executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am using python on ubuntu 9.04\nsay i have two usb devices connected to a single PC. how can i identify the devices in python code.....for example like\nif usb port id == A\n     write data to device 1\nif usb port id == B\n     write data to device 2\nany ideas....","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":39244,"Q_Id":2487033,"Users Score":1,"Answer":"but whatever.. someone will look for the answer at some point:\nI'm on a mac (osx 10.9)..  I successfully installed libusb with mac ports, but was getting the \"no backend available\" message.  It's because python can't find the usb dylibs.\nYou have to add the path to your libusb to your $DYLD_LIBRARY_PATH  (e.g. \/opt\/local\/lib  wherever your macport installed it).\nAs soon I as I added it, pyusb worked fine.","Q_Score":7,"Tags":"python,controls,port,device","A_Id":21833149,"CreationDate":"2010-03-21T12:22:00.000","Title":"usb device identification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed Djangobb app on my server (Debian, mod_python) by cloning original source. The only things I've changed is database options in settings.py. All needed components are installed - syncdb query was executed right.\nBut, when I'm trying to enter on my forum, it returns me error:\n\nImproperlyConfigured: Error importing middleware django_authopenid.middleware: \"No module named djangobb_forum.subscription\"\n\nI've checked - djangobb_forum\/subscription.py exist, so I don't know what can be wrong.\nMaybe someone had problems like that and know how to fix it?\nSorry for my english.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1302,"Q_Id":2488142,"Users Score":2,"Answer":"There are two obvious reasons to why this might happen:\n\ndjangobb_forum is not on your Python path\nThere is no __init__.py in the djangobb_forum folder\n\nIf the code says from djangobb_forum import ... then you need to have the parent folder of djangobb_forum on your Python path.","Q_Score":4,"Tags":"python,django,mod-python","A_Id":2488505,"CreationDate":"2010-03-21T18:17:00.000","Title":"Djangobb problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My question is rather complicated for me to explain, as i'm not really good at maths, but i'll try to be as clear as possible.\nI'm trying to code a cluster in python, which will generate words given a charset (i.e. with lowercase: aaaa, aaab, aaac, ..., zzzz) and make various operations on them. \nI'm searching how to calculate, given the charset and the number of nodes, what range each node should work on (i.e.: node1: aaaa-azzz, node2: baaa-czzz, node3: daaa-ezzz, ...). Is it possible to make an algorithm that could compute this, and if it is, how could i implement this in python?\nI really don't know how to do that, so any help would be much appreciated","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":260,"Q_Id":2488670,"Users Score":1,"Answer":"You should be able to treat your words as numerals in a strange base.  For example, let's say you have a..z as your charset (26 characters), 4 character strings, and you want to distribute among equally 10 machines.  Then there are a total of 26^4 strings, so each machine gets 26^4\/10 strings.  The first machine will get strings 0 through 26^4\/10, the next 26^4\/10 through 26^4\/5, etc.\nTo convert the numbers to strings, just write the number in base 26 using your charset as the numbers.  So 0 is 'aaaa' and 26^4\/10 = 2*26^3 + 15*26^2 + 15*26 +15 is 'cppp'.","Q_Score":1,"Tags":"python,algorithm,cluster-analysis,character-encoding","A_Id":2489898,"CreationDate":"2010-03-21T20:55:00.000","Title":"python parallel computing: split keyspace to give each node a range to work on","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Basically I am writing a simple shopping cart. Each item can have multiple prices. (i.e. shirts where each size is priced differently). I would like to have a single price field in my admin panel, where when the first price is entered, an additional price field pops up. However I am kind of at a loss as to how to do this. What would be the best way to do this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":515,"Q_Id":2488710,"Users Score":1,"Answer":"Sounds like you want two related models - Item and Option. Item would contain the name of the item, and Option would contain the option - eg size - and the price of that option. You would then set up your admin to use an inline form for Option.","Q_Score":2,"Tags":"python,django,django-admin,shopping-cart,django-nonrel","A_Id":2488729,"CreationDate":"2010-03-21T21:04:00.000","Title":"django admin - adding fields on the fly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a class with an __init__ function. \nHow can I return an integer value from this function when an object is created?\nI wrote a program, where __init__ does command line parsing and I need to have some value set. Is it OK set it in global variable and use it in other member functions? If so how to do that? So far, I declared a variable outside class. and setting it one function doesn't reflect in other function ??","AnswerCount":12,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":195099,"Q_Id":2491819,"Users Score":9,"Answer":"__init__ doesn't return anything and should always return None.","Q_Score":140,"Tags":"python,class,init","A_Id":2491843,"CreationDate":"2010-03-22T11:35:00.000","Title":"How to return a value from __init__ in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Any ideas how I can display an image file (bmp or png) centered on the screen as an application splash screen when running a Windows console script based on a batch file, vbscript\/wscript or Python console script?\nI'm not interested in a wxPython solution - that's too much overhead just to implement a cosmetic feature like a splash screen.\nThank you,\nMalcolm","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5541,"Q_Id":2502385,"Users Score":0,"Answer":"Try TK, it is included with python.  Also, PyGtk is lighter than wxPython, but I ended up bitting the bullet and using wxPython for the same purpose recently, it is heavy, but it didn't have any affect on the script performance.","Q_Score":2,"Tags":"python,image,vbscript,batch-file,console-application","A_Id":2502963,"CreationDate":"2010-03-23T18:02:00.000","Title":"Display an image as a splash screen when running Windows batch file, vbscript\/wscript or Python console script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have various models of which I would like to keep track and collect statistical data.\nThe problem is how to store the changes throughout time.\nI thought of various alternative:\n\nStoring a log in a TextField, open it and update it every time the model is saved.\nAlternatively pickle a list and store it in a TextField.\nSave logs on hard drive.\n\n\nWhat are your suggestions?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1579,"Q_Id":2504386,"Users Score":1,"Answer":"Quoth my elementary chemistry teacher: \"If you don't write it down, it didn't happen\", therefore save logs in a file.\nSince the log information is disjoint from your application data (it's meta-data, actually), keep them separate. You could log to a database table but it should be distinct from your model.\nText pickle data is difficult for humans to read, binary pickle data even more so; log in an easily parsed format and the data can be imported into analysis software easily.","Q_Score":6,"Tags":"python,django,django-models","A_Id":2504441,"CreationDate":"2010-03-23T23:27:00.000","Title":"Keeping track of changes - Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a website in django that needs to extract key words from short (twitter-like) messages.\nI've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like \"and\", \"or\", \"not\" while keeping nouns and verbs that aren't conjunctives or other parts of speech. Are there any \"simpler\" packages out there that can do this?\nEDIT: This needs to be done in near real-time on a production website, so using a keyword extraction service seems out of the question, based on their response times and request throttling.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1322,"Q_Id":2531717,"Users Score":1,"Answer":"Abbreviations like NO for navigation officer or OR for operations room need a little care lest you cause a SNAFU ;-) One suspects that better results could be obtained from \"Find the NO and send her to the OR\" by tagging the words with parts of speech using the context ... hint 1: \"the OR\" should result in \"the [noun]\" not \"the [conjunction]\". Hint 2: if in doubt about a word, keep it as a keyword.","Q_Score":1,"Tags":"python,django,keyword","A_Id":2531927,"CreationDate":"2010-03-28T02:44:00.000","Title":"Key word extraction in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a website in django that needs to extract key words from short (twitter-like) messages.\nI've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like \"and\", \"or\", \"not\" while keeping nouns and verbs that aren't conjunctives or other parts of speech. Are there any \"simpler\" packages out there that can do this?\nEDIT: This needs to be done in near real-time on a production website, so using a keyword extraction service seems out of the question, based on their response times and request throttling.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1322,"Q_Id":2531717,"Users Score":3,"Answer":"You can make a set sw of the \"stop words\" you want to eliminate (maybe copy it once and for all from the stop words corpus of NLTK, depending how familiar you are with the various natural languages you need to support), then apply it very simply.\nE.g., if you have a list of words sent that make up the sentence (shorn of punctuation and lowercased, for simplicity), [word for word in sent if word not in sw] is all you need to make a list of non-stopwords -- could hardly be easier, right?\nTo get the sent list in the first place, using the re module from the standard library, re.findall(r'\\w+', sentstring) might suffice if sentstring is the string with the sentence you're dealing with -- it doesn't lowercase, but you can change the list comprehension I suggest above to [word for word in sent if word.lower() not in sw] to compensate for that and (btw) keep the word's original case, which may be useful.","Q_Score":1,"Tags":"python,django,keyword","A_Id":2531724,"CreationDate":"2010-03-28T02:44:00.000","Title":"Key word extraction in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Tornado is a webserver + framework like Django but for real-time features.\nOn my server I don't have a python module or wsgi module so I thought \nCGI. \nIs there a way to get Tornado ( or Django ) works by using CGI folder ? \nIf yes, Could you explain me how do I do that ?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":1611,"Q_Id":2537065,"Users Score":5,"Answer":"Main feature of Tornado is that it is high performance web-server written in Python, for creating web applications using Python programming language.\nRunning Tornado as CGI application negates the very reason it exists, because running CGI scripts is expensive in terms of performance, and most probably there is no way to run Tornado as CGI script.","Q_Score":2,"Tags":"python,django,cgi,webserver,tornado","A_Id":3244176,"CreationDate":"2010-03-29T10:02:00.000","Title":"Tornado or Django works with CGI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed.\nPython would be preferred but I'm also willing to look at other languages e.g. C\/C++ or other means e.g. SQL\nFrom what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed.\nThe problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site.\nAny ideas on how best to do this welcome :)","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":3704,"Q_Id":2541702,"Users Score":3,"Answer":"The short answer is, unfortunately you will need the Notes client installed.  There are a few ways to access data from an NSF such as NotesSQL, COM, C\/C++, but all rely on the Lotus C API at the core, and you'll need a notes client and a notes ID file to gain access via that API.","Q_Score":0,"Tags":"python,lotus-notes,lotus","A_Id":2542163,"CreationDate":"2010-03-29T22:34:00.000","Title":"Access to content of Lotus Notes database without Lotus Notes software installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed.\nPython would be preferred but I'm also willing to look at other languages e.g. C\/C++ or other means e.g. SQL\nFrom what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed.\nThe problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site.\nAny ideas on how best to do this welcome :)","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3704,"Q_Id":2541702,"Users Score":0,"Answer":"Like Ken says, inevitably there has to be a server in the mix. If you're searching for specific text in a Notes \/ Domino application, and looking to replace it, there's a tool out there which does this: Teamstudio Configurator.\nConfigurator also has an API (written in Lotusscript, which is very like old-skool VB) so you can code a solution pretty quickly. I've done the exact same thing you're doing with an old Domino-based website, using this API.\nNot the answer you're looking for I guess, but always good to have choices!","Q_Score":0,"Tags":"python,lotus-notes,lotus","A_Id":2551002,"CreationDate":"2010-03-29T22:34:00.000","Title":"Access to content of Lotus Notes database without Lotus Notes software installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed.\nPython would be preferred but I'm also willing to look at other languages e.g. C\/C++ or other means e.g. SQL\nFrom what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed.\nThe problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site.\nAny ideas on how best to do this welcome :)","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":3704,"Q_Id":2541702,"Users Score":1,"Answer":"If this is a one-time need, you may be able to find sites that will do some simple Domino\/Notes hosting for free. If you could put the NSF up to a service like that, you could then use Domino URL's (REST) to extract the data and search for links, etc.","Q_Score":0,"Tags":"python,lotus-notes,lotus","A_Id":2607921,"CreationDate":"2010-03-29T22:34:00.000","Title":"Access to content of Lotus Notes database without Lotus Notes software installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"These are the techniques that I use regularly to make my views reusable:\n\ntake the template_name as an argument with a default\ntake an optional extra_context which defaults to empty {}\n\n\nright before the template is rendered the context is updated with the extra_context\nfor further re-usability, call any callable in extra_context.values()\n\nwhenever the view deals with a queryset, there is a queryset argument with a default\nwhenever the view needs a particular object from the ORM, it attempts to fetch it using any \"id\" parameter in several ways (e.g. as a slug, as a database id) (this may be a bad practice...)\n\nFirst, should I add anything to my list? Should I remove anything from my list?\nThe items accommodates a large number of cases. However, whenever an app extends a model of another in some way (e.g. adding a field or changing the behavior in some way) I end up writing my own views and only reusing the model.  Is this normal?\nEdit\/answering my own question partially:\n\nsignals: the view should emit a signal when it starts and one before it returns the response","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":2550308,"Users Score":0,"Answer":"whenever the view needs a particular object from the ORM, it attempts to fetch it using any \"id\" parameter in several ways (e.g. as a slug, as a database id) (this may be a bad practice...)\n\nSo... why not just expect a model instance to be passed in as a parameter?  Or a QuerySet from which you will take element 0?  Then you can combine it with the QuerySet case, and maybe roll it into get_object_or_404.\nMy suggestion is to look at how Django's generic views are written.  They're solving the same general class of problems you are.  You seem most of the way there, except for the last part.","Q_Score":0,"Tags":"python,django,views","A_Id":2550450,"CreationDate":"2010-03-31T03:25:00.000","Title":"how to write re-usable views in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"These are the techniques that I use regularly to make my views reusable:\n\ntake the template_name as an argument with a default\ntake an optional extra_context which defaults to empty {}\n\n\nright before the template is rendered the context is updated with the extra_context\nfor further re-usability, call any callable in extra_context.values()\n\nwhenever the view deals with a queryset, there is a queryset argument with a default\nwhenever the view needs a particular object from the ORM, it attempts to fetch it using any \"id\" parameter in several ways (e.g. as a slug, as a database id) (this may be a bad practice...)\n\nFirst, should I add anything to my list? Should I remove anything from my list?\nThe items accommodates a large number of cases. However, whenever an app extends a model of another in some way (e.g. adding a field or changing the behavior in some way) I end up writing my own views and only reusing the model.  Is this normal?\nEdit\/answering my own question partially:\n\nsignals: the view should emit a signal when it starts and one before it returns the response","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":2550308,"Users Score":0,"Answer":"I would think that doing all of those puts a large burden on your urlconf to get everything right. Perhaps making a function that takes all that and hardcoding your views to be a glorified wrapper around said function would be better.","Q_Score":0,"Tags":"python,django,views","A_Id":2550339,"CreationDate":"2010-03-31T03:25:00.000","Title":"how to write re-usable views in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to reference an existing .dll to IronPython, but is there any way to add my project as a reference like I can between Visual Studio projects?\nOr is it best practice to create a separate class library?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1069,"Q_Id":2550370,"Users Score":3,"Answer":"You can't add reference to a project since it's a Visual Studio thing. \nI suggest that during the development process, call import (IronPython) or require (IronRuby) with the full path of your project assembly like c:\\dev\\MyProject\\bin\\Debug\\MyProject.dll.","Q_Score":2,"Tags":"c#,visual-studio,ironpython,ironruby","A_Id":2550627,"CreationDate":"2010-03-31T03:45:00.000","Title":"Any way to add my C# project as a reference in IronPython \/ IronRuby?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm totally new to django, and I'm using its documentation to get help on how to use it \nbut seems like something is missing. i installed django using setup.py install command \nand i added the ( django\/bin ) to system path variable but. i still cant start a new project\ni use the following syntax to start a project :\n\ndjango-admin.py startproject myNewProject\n\n\nbut it says\n\nType 'django-admin.py help' for usage.\n1\n \nUPDATES :\ni use windows vista x64 . i checked the environment variables and i don't have DJANGO_SETTINGS_MODULE variable in there . should i add one ?? and with what value ?\n\ndo i miss anything ? \nthank u","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2582,"Q_Id":2553088,"Users Score":2,"Answer":"do you have permission to write to the directory?","Q_Score":0,"Tags":"python,django,django-admin","A_Id":2553104,"CreationDate":"2010-03-31T13:04:00.000","Title":"Django newbie question: can't start a new project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm totally new to django, and I'm using its documentation to get help on how to use it \nbut seems like something is missing. i installed django using setup.py install command \nand i added the ( django\/bin ) to system path variable but. i still cant start a new project\ni use the following syntax to start a project :\n\ndjango-admin.py startproject myNewProject\n\n\nbut it says\n\nType 'django-admin.py help' for usage.\n1\n \nUPDATES :\ni use windows vista x64 . i checked the environment variables and i don't have DJANGO_SETTINGS_MODULE variable in there . should i add one ?? and with what value ?\n\ndo i miss anything ? \nthank u","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2582,"Q_Id":2553088,"Users Score":0,"Answer":"check whether you have djagno or not and the it is in python path or not.if using linux  go to terminal type python  and then try to import django","Q_Score":0,"Tags":"python,django,django-admin","A_Id":2559610,"CreationDate":"2010-03-31T13:04:00.000","Title":"Django newbie question: can't start a new project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've been browsing documentation, but haven't been able to find a straightforward tutorial, so I apologize if this is a really simple question.\nAnyway, I have eclipse with pydev installed on MAC OSX, and I want configure wxPython to work with eclipse, how do I do this? Once I've downloaded wxpython, what steps do I take to allow wxPython development from eclipse?\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":8700,"Q_Id":2561542,"Users Score":3,"Answer":"wxPython install by default to the following path \/usr\/local\/lib\/wxPython-2.9.4.0\nWhen adding a path to the Interpreter libraries section in the eclipse preferences add this path: \n\/usr\/local\/lib\/wxPython-2.9.4.0\/lib\/python2.7\/site-packages\/wx-2.9.4-osx_cocoa","Q_Score":3,"Tags":"python,eclipse,wxpython","A_Id":12983874,"CreationDate":"2010-04-01T15:28:00.000","Title":"Configuring Eclipse with wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've been browsing documentation, but haven't been able to find a straightforward tutorial, so I apologize if this is a really simple question.\nAnyway, I have eclipse with pydev installed on MAC OSX, and I want configure wxPython to work with eclipse, how do I do this? Once I've downloaded wxpython, what steps do I take to allow wxPython development from eclipse?\nThanks!","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":8700,"Q_Id":2561542,"Users Score":7,"Answer":"Vinay's answer above is correct.  However, if code completion is not picking it up, you might need to add the WX directory to the Pydev's interpreter library path.\n\nWindow | Preferences | Pydev |\n  Interpreter - Python | Libraries\n\nIf wx is not present, New Folder and select the install directory.","Q_Score":3,"Tags":"python,eclipse,wxpython","A_Id":2562141,"CreationDate":"2010-04-01T15:28:00.000","Title":"Configuring Eclipse with wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get python to make noise when certain things happen. Preferably, i would like to play music of some kind, however some kind of distinctive beeping would be sufficient, like an electronic timer going off. I have thus far only been able to make the system speaker chime using pywin32's Beep, however this simply does not have the volume for my application.\nAny ideas on how I can do this?\nEDIT: I have been using PyAudiere for this, but unfortunately the package has been abandoned. Now I need an alternative.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1463,"Q_Id":2563788,"Users Score":0,"Answer":"PyAudiere turns out to be the most convenient. It allows me to simply play an MP3, rather than generate the sound on the fly.","Q_Score":3,"Tags":"python,windows,audio,pywin32","A_Id":10114610,"CreationDate":"2010-04-01T21:22:00.000","Title":"Making Noise with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use the google maps hand cursor in Python but I don't know how to do it.\nI've downloaded the cursor but I only get to use the hand open, I also have a event that \"closes\" the hand when clicked but I don't know how can I change the style cursor on it.\nI say this because the google maps hand cursor has two style (the open and the closed hand).\nIf you don't know how to use the other style you can also tell me how can I create another cursor where the close hand is the default style. If I have that, I only change the cursor and it's done.\nThanks in advance :)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":593,"Q_Id":2565776,"Users Score":0,"Answer":"Use two cursors and change them on events as they need to be.","Q_Score":0,"Tags":"python,wxpython,cursor","A_Id":2565793,"CreationDate":"2010-04-02T08:43:00.000","Title":"How use the google maps hand cursor in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having a hard time figuring out a reasonable way to generate a mixed-case hash in Python.\nI want to generate something like: aZeEe9E\nRight now I'm using MD5, which doesn't generate case-sensitive hashes.\nDo any of you know how to generate a hash value consisting of upper- and lower- case characters + numbers?\n-\nOkay, GregS's advice worked like a charm (on the first try!):\nHere is a simple example:\n\n>>> import hashlib, base64\n>>> s = 'http:\/\/gooogle.com'\n>>> hash = hashlib.md5(s).digest()\n>>> print hash\n46c4f333fae34078a68393213bb9272d\n>>> print base64.b64encode(hash)\nNDZjNGYzMzNmYWUzNDA3OGE2ODM5MzIxM2JiOTI3MmQ=","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1256,"Q_Id":2569503,"Users Score":3,"Answer":"you can base64 encode the output of the hash. This has a couple of additional characters beyond those you mentioned.","Q_Score":1,"Tags":"python,hash,mixed-case","A_Id":2569508,"CreationDate":"2010-04-02T22:21:00.000","Title":"How to generate a mixed-case hash in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a twitter-like note-taking web app.\nIn a page the latest 20 notes of the user will be listed, \nand when the user scroll to the bottom of the browser window more items will be loaded and rendered.\nThe initial 20 notes are part of the generated html of my django template, but the other dynamically loaded items are in json format.\nI want to know how do I do the tag-and-username converting consistently.\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":207,"Q_Id":2570193,"Users Score":0,"Answer":"I'm not sure exactly what you're asking, but what's wrong with something like {{ user.get_absolute_url }}? For the tag detail URLs, it really depends on what you're looking for, but you would have to construct the url and view for that yourself.","Q_Score":0,"Tags":"python,django,twitter","A_Id":2570547,"CreationDate":"2010-04-03T04:03:00.000","Title":"How to convert tag-and-username-like text into proper links in a twitter message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutions and also with the semantics of the language that allows such a natural flow from thoughts to workable code.\nWhat I would like to know is your answer to a kind of question I have seldom seen in this or other forums. This question seems central to me for anyone on the path to Python improvement but who wonders what his next steps should be.\nLet me sum up what I do NOT want to ask first ;)\n\nI don't want to know how to QUICKLY learn Python\nNor do I want to find out the best way to get acquainted with the language\nFinally, I don't want to know a 'one trick that does it all' approach.\n\nWhat I do want to know your opinion about, is:\nWhat are the steps YOU would recommend to a Python journeyman, from apprenticeship to guru status (feel free to stop wherever your expertise dictates it), in order that one IMPROVES CONSTANTLY, becoming a better and better Python coder, one step at a time. Some of the people on SO almost seem worthy of worship for their Python prowess, please enlighten us :)\nThe kind of answers I would enjoy (but feel free to surprise the readership :P ), is formatted more or less like this:\n\nRead this (eg: python tutorial), pay attention to that kind of details\nCode for so manytime\/problems\/lines of code\nThen, read this (eg: this or that book), but this time, pay attention to this\nTackle a few real-life problems\nThen, proceed to reading Y.\nBe sure to grasp these concepts\nCode for X time\nCome back to such and such basics or move further to...\n(you get the point :)\n\nI really care about knowing your opinion on what exactly one should pay attention to, at various stages, in order to progress CONSTANTLY (with due efforts, of course). If you come from a specific field of expertise, discuss the path you see as appropriate in this field.\nEDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","AnswerCount":19,"Available Count":5,"Score":0.0210495219,"is_accepted":false,"ViewCount":383814,"Q_Id":2573135,"Users Score":2,"Answer":"Not precisely what you're asking for, but I think it's good advice.\nLearn another language, doesn't matter too much which.  Each language has it's own ideas and conventions that you can learn from.  Learn about the differences in the languages and more importantly why they're different.  Try a purely functional language like Haskell and see some of the benefits (and challenges) of functions free of side-effects.  See how you can apply some of the things you learn from other languages to Python.","Q_Score":659,"Tags":"python","A_Id":2573225,"CreationDate":"2010-04-04T00:28:00.000","Title":"Python progression path - From apprentice to guru","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutions and also with the semantics of the language that allows such a natural flow from thoughts to workable code.\nWhat I would like to know is your answer to a kind of question I have seldom seen in this or other forums. This question seems central to me for anyone on the path to Python improvement but who wonders what his next steps should be.\nLet me sum up what I do NOT want to ask first ;)\n\nI don't want to know how to QUICKLY learn Python\nNor do I want to find out the best way to get acquainted with the language\nFinally, I don't want to know a 'one trick that does it all' approach.\n\nWhat I do want to know your opinion about, is:\nWhat are the steps YOU would recommend to a Python journeyman, from apprenticeship to guru status (feel free to stop wherever your expertise dictates it), in order that one IMPROVES CONSTANTLY, becoming a better and better Python coder, one step at a time. Some of the people on SO almost seem worthy of worship for their Python prowess, please enlighten us :)\nThe kind of answers I would enjoy (but feel free to surprise the readership :P ), is formatted more or less like this:\n\nRead this (eg: python tutorial), pay attention to that kind of details\nCode for so manytime\/problems\/lines of code\nThen, read this (eg: this or that book), but this time, pay attention to this\nTackle a few real-life problems\nThen, proceed to reading Y.\nBe sure to grasp these concepts\nCode for X time\nCome back to such and such basics or move further to...\n(you get the point :)\n\nI really care about knowing your opinion on what exactly one should pay attention to, at various stages, in order to progress CONSTANTLY (with due efforts, of course). If you come from a specific field of expertise, discuss the path you see as appropriate in this field.\nEDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","AnswerCount":19,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":383814,"Q_Id":2573135,"Users Score":24,"Answer":"If you're in and using python for science (which it seems you are)  part of that will be learning and understanding scientific libraries, for me these would be \n\nnumpy\nscipy\nmatplotlib\nmayavi\/mlab\nchaco\nCython\n\nknowing how to use the right libraries and vectorize your code is essential for scientific computing.\nI wanted to add that, handling large numeric datasets in common pythonic ways(object oriented approaches, lists, iterators) can be extremely inefficient.  In scientific computing, it can be necessary to structure your code in ways that differ drastically from how most conventional python coders approach data.","Q_Score":659,"Tags":"python","A_Id":4147969,"CreationDate":"2010-04-04T00:28:00.000","Title":"Python progression path - From apprentice to guru","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutions and also with the semantics of the language that allows such a natural flow from thoughts to workable code.\nWhat I would like to know is your answer to a kind of question I have seldom seen in this or other forums. This question seems central to me for anyone on the path to Python improvement but who wonders what his next steps should be.\nLet me sum up what I do NOT want to ask first ;)\n\nI don't want to know how to QUICKLY learn Python\nNor do I want to find out the best way to get acquainted with the language\nFinally, I don't want to know a 'one trick that does it all' approach.\n\nWhat I do want to know your opinion about, is:\nWhat are the steps YOU would recommend to a Python journeyman, from apprenticeship to guru status (feel free to stop wherever your expertise dictates it), in order that one IMPROVES CONSTANTLY, becoming a better and better Python coder, one step at a time. Some of the people on SO almost seem worthy of worship for their Python prowess, please enlighten us :)\nThe kind of answers I would enjoy (but feel free to surprise the readership :P ), is formatted more or less like this:\n\nRead this (eg: python tutorial), pay attention to that kind of details\nCode for so manytime\/problems\/lines of code\nThen, read this (eg: this or that book), but this time, pay attention to this\nTackle a few real-life problems\nThen, proceed to reading Y.\nBe sure to grasp these concepts\nCode for X time\nCome back to such and such basics or move further to...\n(you get the point :)\n\nI really care about knowing your opinion on what exactly one should pay attention to, at various stages, in order to progress CONSTANTLY (with due efforts, of course). If you come from a specific field of expertise, discuss the path you see as appropriate in this field.\nEDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","AnswerCount":19,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":383814,"Q_Id":2573135,"Users Score":41,"Answer":"I'll give you the simplest and most effective piece of advice I think anybody could give you: code.\nYou can only be better at using a language (which implies understanding it) by coding. You have to actively enjoy coding, be inspired, ask questions, and find answers by yourself.\nGot a an hour to spare? Write code that will reverse a string, and find out the most optimum solution. A free evening? Why not try some web-scraping. Read other peoples code. See how they do things. Ask yourself what you would do.\nWhen I'm bored at my computer, I open my IDE and code-storm. I jot down ideas that sound interesting, and challenging. An URL shortener? Sure, I can do that. Oh, I learnt how to convert numbers from one base to another as a side effect!\nThis is valid whatever your skill level. You never stop learning. By actively coding in your spare time you will, with little additional effort, come to understand the language, and ultimately, become a guru. You will build up knowledge and reusable code and memorise idioms.","Q_Score":659,"Tags":"python","A_Id":2576226,"CreationDate":"2010-04-04T00:28:00.000","Title":"Python progression path - From apprentice to guru","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutions and also with the semantics of the language that allows such a natural flow from thoughts to workable code.\nWhat I would like to know is your answer to a kind of question I have seldom seen in this or other forums. This question seems central to me for anyone on the path to Python improvement but who wonders what his next steps should be.\nLet me sum up what I do NOT want to ask first ;)\n\nI don't want to know how to QUICKLY learn Python\nNor do I want to find out the best way to get acquainted with the language\nFinally, I don't want to know a 'one trick that does it all' approach.\n\nWhat I do want to know your opinion about, is:\nWhat are the steps YOU would recommend to a Python journeyman, from apprenticeship to guru status (feel free to stop wherever your expertise dictates it), in order that one IMPROVES CONSTANTLY, becoming a better and better Python coder, one step at a time. Some of the people on SO almost seem worthy of worship for their Python prowess, please enlighten us :)\nThe kind of answers I would enjoy (but feel free to surprise the readership :P ), is formatted more or less like this:\n\nRead this (eg: python tutorial), pay attention to that kind of details\nCode for so manytime\/problems\/lines of code\nThen, read this (eg: this or that book), but this time, pay attention to this\nTackle a few real-life problems\nThen, proceed to reading Y.\nBe sure to grasp these concepts\nCode for X time\nCome back to such and such basics or move further to...\n(you get the point :)\n\nI really care about knowing your opinion on what exactly one should pay attention to, at various stages, in order to progress CONSTANTLY (with due efforts, of course). If you come from a specific field of expertise, discuss the path you see as appropriate in this field.\nEDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","AnswerCount":19,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":383814,"Q_Id":2573135,"Users Score":12,"Answer":"Thoroughly Understand All Data Types and Structures\nFor every type and structure, write a series of demo programs that exercise every aspect of the type or data structure.  If you do this, it might be worthwhile to blog notes on each one... it might be useful to lots of people!","Q_Score":659,"Tags":"python","A_Id":2573531,"CreationDate":"2010-04-04T00:28:00.000","Title":"Python progression path - From apprentice to guru","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning, working, and playing with Python for a year and a half now. As a biologist slowly making the turn to bio-informatics, this language has been at the very core of all the major contributions I have made in the lab. I more or less fell in love with the way Python permits me to express beautiful solutions and also with the semantics of the language that allows such a natural flow from thoughts to workable code.\nWhat I would like to know is your answer to a kind of question I have seldom seen in this or other forums. This question seems central to me for anyone on the path to Python improvement but who wonders what his next steps should be.\nLet me sum up what I do NOT want to ask first ;)\n\nI don't want to know how to QUICKLY learn Python\nNor do I want to find out the best way to get acquainted with the language\nFinally, I don't want to know a 'one trick that does it all' approach.\n\nWhat I do want to know your opinion about, is:\nWhat are the steps YOU would recommend to a Python journeyman, from apprenticeship to guru status (feel free to stop wherever your expertise dictates it), in order that one IMPROVES CONSTANTLY, becoming a better and better Python coder, one step at a time. Some of the people on SO almost seem worthy of worship for their Python prowess, please enlighten us :)\nThe kind of answers I would enjoy (but feel free to surprise the readership :P ), is formatted more or less like this:\n\nRead this (eg: python tutorial), pay attention to that kind of details\nCode for so manytime\/problems\/lines of code\nThen, read this (eg: this or that book), but this time, pay attention to this\nTackle a few real-life problems\nThen, proceed to reading Y.\nBe sure to grasp these concepts\nCode for X time\nCome back to such and such basics or move further to...\n(you get the point :)\n\nI really care about knowing your opinion on what exactly one should pay attention to, at various stages, in order to progress CONSTANTLY (with due efforts, of course). If you come from a specific field of expertise, discuss the path you see as appropriate in this field.\nEDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","AnswerCount":19,"Available Count":5,"Score":0.0315684544,"is_accepted":false,"ViewCount":383814,"Q_Id":2573135,"Users Score":3,"Answer":"Teaching to someone else who is starting to learn Python is always a great way to get your ideas clear and sometimes, I usually get a lot of neat questions from students that have me to re-think conceptual things about Python.","Q_Score":659,"Tags":"python","A_Id":4169614,"CreationDate":"2010-04-04T00:28:00.000","Title":"Python progression path - From apprentice to guru","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Qt3.3 used to allow for multiple selections in the QTextEdit widget by calling the setSelection() function and specifying a different selection id (selNum) as the last argument in that function. \nIn Qt4, to create a selection, I do it by creating a QTextCursor object and call the setPosition() or movePosition() methods. I have no problems being able to create a single selection of text. I am, however, unable to find a way to create multiple selections. The methods in Qt4 do not have an argument which allows you to set a selection id, nor can i find any other function in the QTextCursor or QTextEdit which looks like it might allow me to do so. \nHas this feature been completely removed from Qt4? or has is there a new and different way of doing it?\nThanks.\nRonny","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1173,"Q_Id":2574195,"Users Score":0,"Answer":"How about creating multiple cursors (QTextCursor), each selection a different portion of the text. Would that work for you?","Q_Score":1,"Tags":"python,qt,qt4,pyqt","A_Id":2574214,"CreationDate":"2010-04-04T10:55:00.000","Title":"how to create multiple selections in text edit box in qt4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Qt3.3 used to allow for multiple selections in the QTextEdit widget by calling the setSelection() function and specifying a different selection id (selNum) as the last argument in that function. \nIn Qt4, to create a selection, I do it by creating a QTextCursor object and call the setPosition() or movePosition() methods. I have no problems being able to create a single selection of text. I am, however, unable to find a way to create multiple selections. The methods in Qt4 do not have an argument which allows you to set a selection id, nor can i find any other function in the QTextCursor or QTextEdit which looks like it might allow me to do so. \nHas this feature been completely removed from Qt4? or has is there a new and different way of doing it?\nThanks.\nRonny","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1173,"Q_Id":2574195,"Users Score":1,"Answer":"The solution, i realise now is actually quite simple. \nTo graphically visualise all the various selections (separate QTextCursor objects), instead of calling the setTextCursor() method for the QTextEdit widget for each of the selections, i change the background color of each of those sections of text by calling the setCharFormat() method for each of those QTextCursor objects.","Q_Score":1,"Tags":"python,qt,qt4,pyqt","A_Id":2574559,"CreationDate":"2010-04-04T10:55:00.000","Title":"how to create multiple selections in text edit box in qt4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to develop a site which has to accomodate around 2000 users a day and speed is a criterion for it. Moreover, the site is a user oriented one where the user will be able to log in and check his profile, register for specific events he\/she wants to participate in. The site is to be hosted on a VPS server.Although I have pretty good experience with python and PHP but I have no idea how to use either of the framework. We have plenty of time to experiment and learn one of the above frameworks.Could you please specify which one would be preferred for such a scenario considering speed, features, and security of the site. \nThanks,\nniting","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":30143,"Q_Id":2578540,"Users Score":0,"Answer":"If for the PHP part I would choose CodeIgniter - it doesn't get too much into your way. But it doesn't have any code\/view\/model generators out of the box, you need to type a bit.\nBut languages other than PHP appear to be more sexy.","Q_Score":21,"Tags":"python,django,cakephp,web-frameworks,yii","A_Id":2844890,"CreationDate":"2010-04-05T13:18:00.000","Title":"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to develop a site which has to accomodate around 2000 users a day and speed is a criterion for it. Moreover, the site is a user oriented one where the user will be able to log in and check his profile, register for specific events he\/she wants to participate in. The site is to be hosted on a VPS server.Although I have pretty good experience with python and PHP but I have no idea how to use either of the framework. We have plenty of time to experiment and learn one of the above frameworks.Could you please specify which one would be preferred for such a scenario considering speed, features, and security of the site. \nThanks,\nniting","AnswerCount":8,"Available Count":5,"Score":0.0996679946,"is_accepted":false,"ViewCount":30143,"Q_Id":2578540,"Users Score":4,"Answer":"Codeigniter it's fast and very documented  also has a large community to and finaly friendly with the programmer.","Q_Score":21,"Tags":"python,django,cakephp,web-frameworks,yii","A_Id":10847083,"CreationDate":"2010-04-05T13:18:00.000","Title":"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to develop a site which has to accomodate around 2000 users a day and speed is a criterion for it. Moreover, the site is a user oriented one where the user will be able to log in and check his profile, register for specific events he\/she wants to participate in. The site is to be hosted on a VPS server.Although I have pretty good experience with python and PHP but I have no idea how to use either of the framework. We have plenty of time to experiment and learn one of the above frameworks.Could you please specify which one would be preferred for such a scenario considering speed, features, and security of the site. \nThanks,\nniting","AnswerCount":8,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":30143,"Q_Id":2578540,"Users Score":0,"Answer":"I am using CodeIgniter 1.7.2 and for complex websites it's very good and powerfull, but it definitely is missing some kind of code generator which will allow for example to build an IT application in one click.\nI had the impression (from watching a tutorial) that Django has it.","Q_Score":21,"Tags":"python,django,cakephp,web-frameworks,yii","A_Id":7084868,"CreationDate":"2010-04-05T13:18:00.000","Title":"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to develop a site which has to accomodate around 2000 users a day and speed is a criterion for it. Moreover, the site is a user oriented one where the user will be able to log in and check his profile, register for specific events he\/she wants to participate in. The site is to be hosted on a VPS server.Although I have pretty good experience with python and PHP but I have no idea how to use either of the framework. We have plenty of time to experiment and learn one of the above frameworks.Could you please specify which one would be preferred for such a scenario considering speed, features, and security of the site. \nThanks,\nniting","AnswerCount":8,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":30143,"Q_Id":2578540,"Users Score":31,"Answer":"This is a very subjective question but personally I'd recommend Django. Python is a very nice language to use and the Django framework is small, easy to use, well documented and also has a pretty active community.\nThis choice was made partly because of my dislike for PHP though, so take the recommendation with a pinch of salt.","Q_Score":21,"Tags":"python,django,cakephp,web-frameworks,yii","A_Id":2578635,"CreationDate":"2010-04-05T13:18:00.000","Title":"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to develop a site which has to accomodate around 2000 users a day and speed is a criterion for it. Moreover, the site is a user oriented one where the user will be able to log in and check his profile, register for specific events he\/she wants to participate in. The site is to be hosted on a VPS server.Although I have pretty good experience with python and PHP but I have no idea how to use either of the framework. We have plenty of time to experiment and learn one of the above frameworks.Could you please specify which one would be preferred for such a scenario considering speed, features, and security of the site. \nThanks,\nniting","AnswerCount":8,"Available Count":5,"Score":1.2,"is_accepted":true,"ViewCount":30143,"Q_Id":2578540,"Users Score":29,"Answer":"Most of the frameworks out there nowadays are fast enough to serve whatever needs you will have. It really depends on in which environment you feel most comfortable. Though there are nuances here and there, MVC frameworks share a lot of the same principles, so whichever you choose to use is really a matter of which you most enjoy using.\nSo, if you like Python more, there's your answer. Use a Python framework, and Django is the best. If you like PHP more (which I personally don't), you've got some more decisions to make. But any of the PHP frameworks are fine. They really are. Just pick one that looks nice with comprehensive documentation and get to work.","Q_Score":21,"Tags":"python,django,cakephp,web-frameworks,yii","A_Id":2578670,"CreationDate":"2010-04-05T13:18:00.000","Title":"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how you can turn off autocompletion on a textfield in Django? \nFor example, a form that I generate from my model has an input field for a credit card number. It is bad practice to leave autocompletion on. When making the form by hand, I'd add a autocomplete=\"off\" statement, but how do you do it in Django and still retain the form validation?","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":19773,"Q_Id":2580955,"Users Score":33,"Answer":"Add the autocomplete=\"off\" to the form tag, so you don't have to change the django.form instance.\n<form action=\".\" method=\"post\" autocomplete=\"off\">\n{{ form }}\n<\/form>","Q_Score":28,"Tags":"python,django,forms,autocomplete","A_Id":3672334,"CreationDate":"2010-04-05T20:23:00.000","Title":"Disable autocomplete on textfield in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Working with Python in Emacs if I want to add a try\/except to a block of code, I often find that I am having to indent the whole block, line by line.  In Emacs, how do you indent the whole block at once.\nI am not an experienced Emacs user, but just find it is the best tool for working through ssh.  I am using Emacs on the command line(Ubuntu), not as a gui, if that makes any difference.","AnswerCount":8,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":46535,"Q_Id":2585091,"Users Score":4,"Answer":"indent-region mapped to C-M-\\ should do the trick.","Q_Score":139,"Tags":"python,emacs,ssh","A_Id":2585123,"CreationDate":"2010-04-06T13:24:00.000","Title":"Emacs bulk indent for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Working with Python in Emacs if I want to add a try\/except to a block of code, I often find that I am having to indent the whole block, line by line.  In Emacs, how do you indent the whole block at once.\nI am not an experienced Emacs user, but just find it is the best tool for working through ssh.  I am using Emacs on the command line(Ubuntu), not as a gui, if that makes any difference.","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":46535,"Q_Id":2585091,"Users Score":10,"Answer":"In addition to indent-region, which is mapped to C-M-\\ by default, the rectangle edit commands are very useful for Python.  Mark a region as normal, then:\n\nC-x r t (string-rectangle): will prompt you for characters you'd like to insert into each line; great for inserting a certain number of spaces\nC-x r k (kill-rectangle): remove a rectangle region; great for removing indentation\n\nYou can also C-x r y (yank-rectangle), but that's only rarely useful.","Q_Score":139,"Tags":"python,emacs,ssh","A_Id":2585268,"CreationDate":"2010-04-06T13:24:00.000","Title":"Emacs bulk indent for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i delete a folder using python script?and what are the return values??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":2597501,"Users Score":0,"Answer":"you can use os.rmdir() to remove a directory. To remove a directory tree recursively, you can use shutil.rmtree. If you know that you already have empty directory nodes, you can also check out os.removedirs()","Q_Score":0,"Tags":"python,directory","A_Id":2597538,"CreationDate":"2010-04-08T04:03:00.000","Title":"deletion of folders","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I built an inventory database where ISBN numbers are the primary keys for the items. This worked great for a while as the items were books. Now I want to add non-books. some of the non-books have EANs or ISSNs, some do not.\nIt's in PostgreSQL with django apps for the frontend and JSON api, plus a few supporting python command-line tools for management. the items in question are mostly books and artist prints, some of which are self-published.\nWhat is nice about using ISBNs as primary keys is that in on top of relational integrity, you get lots of handy utilities for validating ISBNs, automatically looking up missing or additional information on the book items, etcetera, many of which I've taken advantage. some such tools are off-the-shelf (PyISBN, PyAWS etc) and some are hand-rolled -- I tried to keep all of these parts nice and decoupled, but you know how things can get.\nI couldn't find anything online about 'private ISBNs' or 'self-assigned ISBNs' but that's the sort of thing I was interested in doing. I doubt that's what I'll settle on, since there is already an apparent run on ISBN numbers.\nshould I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":1516,"Q_Id":2610000,"Users Score":3,"Answer":"I don't know postgres but normally ISBM would be a unique index key but not the primary. It's better to have an integer as primary\/foreign key. That way you only need to add a new field EAN\/ISSN as nullable.","Q_Score":2,"Tags":"python,django,postgresql,isbn","A_Id":2610094,"CreationDate":"2010-04-09T18:45:00.000","Title":"ISBNs are used as primary key, now I want to add non-book things to the DB - should I migrate to EAN?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I built an inventory database where ISBN numbers are the primary keys for the items. This worked great for a while as the items were books. Now I want to add non-books. some of the non-books have EANs or ISSNs, some do not.\nIt's in PostgreSQL with django apps for the frontend and JSON api, plus a few supporting python command-line tools for management. the items in question are mostly books and artist prints, some of which are self-published.\nWhat is nice about using ISBNs as primary keys is that in on top of relational integrity, you get lots of handy utilities for validating ISBNs, automatically looking up missing or additional information on the book items, etcetera, many of which I've taken advantage. some such tools are off-the-shelf (PyISBN, PyAWS etc) and some are hand-rolled -- I tried to keep all of these parts nice and decoupled, but you know how things can get.\nI couldn't find anything online about 'private ISBNs' or 'self-assigned ISBNs' but that's the sort of thing I was interested in doing. I doubt that's what I'll settle on, since there is already an apparent run on ISBN numbers.\nshould I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1516,"Q_Id":2610000,"Users Score":1,"Answer":"A simple solution (although arguably whether good) would be to use (isbn,title) or (isbn,author) which should pretty much guarantee uniqueness. Ideology is great but practicality also serves a purpose.","Q_Score":2,"Tags":"python,django,postgresql,isbn","A_Id":2614029,"CreationDate":"2010-04-09T18:45:00.000","Title":"ISBNs are used as primary key, now I want to add non-book things to the DB - should I migrate to EAN?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Looking at Python modules and at code in the \"lib-dnyload\" directory in the Python framework, I noticed whenever code is creating some kind of GUI or graphic it imports a non-Python file with a .so extension. And there are tons .so files in \"lib-dnyload\". \nFrom googling things I found that these files are called shared objects and are written in C or C++. I have a Mac and I use GCC. How do I make shared object files that are accessible via Python? Mainly just how to make shared objects with GCC using Mac OS X.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4363,"Q_Id":2610421,"Users Score":0,"Answer":"You can write python extensions in many ways, including Cython, SWIG, boost.python ...\nYou can also write a shared library and use the \"ctypes\" library to access it.","Q_Score":1,"Tags":"python,macos,gcc,distutils,shared-objects","A_Id":2611684,"CreationDate":"2010-04-09T19:44:00.000","Title":"How to create make .so files from code written in C or C++ that are usable from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a Python program that stores and writes data to a file.  The data is raw binary data, stored internally as str.  I'm writing it out through a utf-8 codec.  However, I get UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 25: character maps to <undefined> in the cp1252.py file.\nThis looks to me like Python is trying to interpret the data using the default code page.  But it doesn't have a default code page.  That's why I'm using str, not unicode.\nI guess my questions are:\n\nHow do I represent raw binary data in memory, in Python?\nWhen I'm writing raw binary data out through a codec, how do I encode\/unencode it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":24608,"Q_Id":2611205,"Users Score":0,"Answer":"You shouldn't normally use codecs with str, except to turn them into unicodes. Perhaps you should be looking at using the latin-1 codec if you think you want \"raw\" data in your unicodes.","Q_Score":10,"Tags":"python,codec,string","A_Id":2611227,"CreationDate":"2010-04-09T21:58:00.000","Title":"How do I write raw binary data in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a Python program that stores and writes data to a file.  The data is raw binary data, stored internally as str.  I'm writing it out through a utf-8 codec.  However, I get UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 25: character maps to <undefined> in the cp1252.py file.\nThis looks to me like Python is trying to interpret the data using the default code page.  But it doesn't have a default code page.  That's why I'm using str, not unicode.\nI guess my questions are:\n\nHow do I represent raw binary data in memory, in Python?\nWhen I'm writing raw binary data out through a codec, how do I encode\/unencode it?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":24608,"Q_Id":2611205,"Users Score":22,"Answer":"NOTE: this was written for Python 2.x.  Not sure if applicable to 3.x.\nYour use of str for raw binary data in memory is correct.\n[If you're using Python 2.6+, it's even better to use bytes which in 2.6+ is just an alias to str but expresses your intention better, and will help if one day you port the code to Python 3.]\nAs others note, writing binary data through a codec is strange.  A write codec takes unicode and outputs bytes into the file.  You're trying to do it backwards, hence our confusion about your intentions...\n[And your diagnosis of the error looks correct: since the codec expects unicode, Python is decoding your str into unicode with the system's default encoding, which chokes.]\nWhat you want to see in the output file?\n\nIf the file should contain the binary data as-is:\nThen you must not send it through a codec; you must write it \ndirectly to the file.  A codec encodes everything and can only \nemit valid encodings of unicode (in your case, valid UTF-8).\nThere is no input you can give it to make it emit arbitrary \nbyte sequences!\n\nIf you require a mixture of UTF-8 and raw binary data, you \nshould open the file directly, and intermix writes of some_data \nwith some_text.encode('utf8')...\n\nNote however that mixing UTF-8 with raw arbitrary data is very \nbad design, because such files are very inconvenient to deal \nwith!  Tools that understand unicode will choke on the binary \ndata, leaving you with not convenient way to even view (let alone \nmodify) the file.\nIf you want a friendly representation of arbitrary bytes in \nunicode:\nPass data.encode('base64') to the codec.  Base64 produces only \nclean ascii (letters, numbers, and a little punctuation) so it \ncan be clearly embedded in anything, it clearly looks to people as \nbinary data, and it's reasonably compact (slightly over 33% \noverhead).\nP.S. you may note that data.encode('base64') is strange.\n\n.encode() is supposed to take unicode but I'm giving it a \nstring?!  Python has several pseudo-codecs that convert str->str \nsuch as 'base64' and 'zlib'.\n.encode() always returns an str but you'll feed it into a codec \nexpecting unicode?!  In this case it will only contain clean \nascii, so it doesn't matter.  You may write explicitly \ndata.encode('base64').encode('utf8') if it makes you feel \nbetter.\n\nIf you need a 1:1 mapping from arbitrary bytes to unicode:\nPass data.decode('latin1') to the codec.  latin1 maps \nbytes 0-255 to unicode characters 0-255, which is kinda elegant.\nThe codec will, of course, encode your characters - 128-255 are \nencoded as 2 or 3 bytes in UTF-8 (surprisingly, the average \noverhead is 50%, more than base64!).  This quite kills the \n\"elegance\" of having a 1:1 mapping.\nNote also that unicode characters 0-255 include nasty \ninvisible\/control characters (newline, formfeed, soft hyphen, etc.)\nmaking your binary data annoying to view in text editors.\nConsidering these drawbacks, I do not recommend latin1 unless \nyou understand exactly why you want it.\nI'm just mentioning it as the other \"natural\" encoding that springs \nto mind.","Q_Score":10,"Tags":"python,codec,string","A_Id":2617930,"CreationDate":"2010-04-09T21:58:00.000","Title":"How do I write raw binary data in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I was taught at school is all about programming languages, software design, but hardly anything about how to automatically build a software, probably with something like unit testing integrated.\nPlease tell me how do one start learning to set up a build process for his project.\nIf this is too abstract to make any sense, I would add that I use Python and do web programming with Django.\nThanks in advance.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":354,"Q_Id":2615923,"Users Score":0,"Answer":"While this is certainly not a complete answer to your question, I would like to recommend very highly the learning of the tool 'make'.  I find myself using it on a VERY regular basis, for a wide variety of tasks, including (but by no means limited to) building, testing, and deploying software.","Q_Score":6,"Tags":"python,ci-server","A_Id":2615976,"CreationDate":"2010-04-11T03:15:00.000","Title":"How can I learn to set up a build process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I was taught at school is all about programming languages, software design, but hardly anything about how to automatically build a software, probably with something like unit testing integrated.\nPlease tell me how do one start learning to set up a build process for his project.\nIf this is too abstract to make any sense, I would add that I use Python and do web programming with Django.\nThanks in advance.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":354,"Q_Id":2615923,"Users Score":1,"Answer":"For Python projects you should use setuptools.  Setuptools has all the stuff to pack things up into .eggs, compile C modules, run unit tests, etc...  If you've ever done \"python setup.py [build|install|test]\" then you've used setuptools.","Q_Score":6,"Tags":"python,ci-server","A_Id":2616079,"CreationDate":"2010-04-11T03:15:00.000","Title":"How can I learn to set up a build process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed virtualenv and virtualenvwrapper on Windows using easy_install. But mkvirtualenv is missing. I tried to search on my machine but I couldn't find it. I don't know how to solve it. Do you have any idea?","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":34056,"Q_Id":2615968,"Users Score":11,"Answer":"mkvirtualenv is a bash script so you need to run bash shell to make use of it.\nmkvirtualenv is a bash function in the mkvirtualenv_bashrc script\nYou will need to run this from cygwin under Windows. (You can call a native python from this and not need a cygwin python)","Q_Score":39,"Tags":"python,windows,virtualenv,virtualenvwrapper","A_Id":2616482,"CreationDate":"2010-04-11T03:42:00.000","Title":"Installing virtualenvwrapper on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed virtualenv and virtualenvwrapper on Windows using easy_install. But mkvirtualenv is missing. I tried to search on my machine but I couldn't find it. I don't know how to solve it. Do you have any idea?","AnswerCount":6,"Available Count":2,"Score":0.1651404129,"is_accepted":false,"ViewCount":34056,"Q_Id":2615968,"Users Score":5,"Answer":"In windows we need to use virtualenv not mkvirtualenv while creating virtual environments","Q_Score":39,"Tags":"python,windows,virtualenv,virtualenvwrapper","A_Id":49574221,"CreationDate":"2010-04-11T03:42:00.000","Title":"Installing virtualenvwrapper on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"e.g., how can I find out that the executable has been installed in \"\/usr\/bin\/python\" and the library files in \"\/usr\/lib\/python2.6\"?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":91,"Q_Id":2616190,"Users Score":1,"Answer":"You want the sys module:\n>>> print sys.executable\n\/usr\/bin\/python\n>>> print sys.path\n['', '\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python26.zip',\n '\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/plat-darwin', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/plat-mac', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/plat-mac\/lib-scriptpackages', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/Extras\/lib\/python', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/lib-tk', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/lib-old', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/lib\/python2.6\/lib-dynload', \n'\/Library\/Python\/2.6\/site-packages', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/Extras\/lib\/python\/PyObjC', \n'\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/Extras\/lib\/python\/wx-2.8-mac-unicode']","Q_Score":2,"Tags":"python,installation,metadata","A_Id":2616194,"CreationDate":"2010-04-11T06:01:00.000","Title":"Python: what package contains the installation metadata?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python-memcached is the official supported memcached driver for Django.\nDoes it support  \n\nConsistent hashing\nBinary protocol\n\nIf it does, how do I use those features within Django? I couldn't find any documentation.","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2396,"Q_Id":2616610,"Users Score":2,"Answer":"Looking at the _get_server method on python-memcached v1.45, it seems it doesn't use consistent hashing, but a simple hash % len(buckets).\nSame goes for binary protocol, python-memcache uses, as far as I can see in the source, only text commands.","Q_Score":4,"Tags":"python,django,memcached,python-memcached,consistent-hashing","A_Id":2616824,"CreationDate":"2010-04-11T09:45:00.000","Title":"Does python-memcached support consistent hashing & binary protocol?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website.  Where and how do I start learning this?\nExample usages are: connecting to databases, and retrieving and storing information from forms.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":2627775,"Users Score":0,"Answer":"there are numerous options for learning python for web. I learned python to access web data from courser.org, and the tutorial was very interesting. If you want to learn python for web then I suggest you to learn python to access web data in courser.org\nyou can also learn python for everybody which is a specialization course with 5 courses in which each and every thing about python is given.\nThe fun part of courser.org is that they provide assignments with due dates which means you have to complete an assessment of each week in that week itself. They also provide quiz. You have to pass all the assignments and quizzes to get the certificate which is very easy, you can easily complete the assessment and quizzes.","Q_Score":2,"Tags":"python","A_Id":43765937,"CreationDate":"2010-04-13T07:41:00.000","Title":"How do I start learn Python for web","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website.  Where and how do I start learning this?\nExample usages are: connecting to databases, and retrieving and storing information from forms.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":612,"Q_Id":2627775,"Users Score":0,"Answer":"There are numerous frameworks for making websites in Python. Once you are familiar with Python and the general nature of websites which would include the knowledge of HTTP, HTML you can proceed by using any of the following to make websites using Python:\n\nWebapp2 - A simple framework to get you started with making websites and using this framework you can easily make websites and cloud services and host them on the Google App Engine service. Follow these links for more information on use and hosting: Welcome to webapp2!, Google App Engine\nDjango - As Alex Remedios has mentioned Django is also a very popular and widely used MVC web framework for Python. It is very comprehensive and follows the MVC web design principles. Various hosting options are also available for the same. You can learn more about Django here - The Web framework for perfectionists with deadlines, The Django Book (for learning the use of Django)\nFlask - Flask is a simplistic framework for making webapplications and websites using Python. I do not extensive experience using it but from what I have read it is similar to Webapp2 in many ways but is not as comprehensive as Django. But, it is very easy to pickup and use. Flask (A Python Microframework)\n\nAs far as my knowledge goes these are the best ways to use Python in the web. To answer your second question, it is not implicitly possible to use Python in cohesion with HTML content like you would with PHP. However, there are libraries to do that too like the following:\n\nPython Wiki - Digi Developer\nKarrigell 3.1.1\n\nIf you are making extensive applications\/websites the above two frameworks will pose major problems in doing simple tasks.","Q_Score":2,"Tags":"python","A_Id":42923113,"CreationDate":"2010-04-13T07:41:00.000","Title":"How do I start learn Python for web","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on am Android Scripting Environment (ASE) script in Python to replicate an iPhone app.\nI need a device UID of some sort. My thoughts where a salted MD5 hash of the MAC address or device phone number, but I can't figure out how to access either of those using the Python APIs within ASE.\nWhat can I do to create a UID in Python in ASE?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":234,"Q_Id":2633029,"Users Score":0,"Answer":"The newer versions of ASE now include a function call to create these identifiers.","Q_Score":2,"Tags":"python,android,ase,android-scripting","A_Id":5914317,"CreationDate":"2010-04-13T20:38:00.000","Title":"How to get a Device Specific UID using Python in ASE on Android?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's consider 3 situations:\n1) I write a pyhon module in Eclipse (pydev) and run it Ctrl-F11. The module runs and I don't have any control or access (AFAIK) to the module variables and functions.\n2) I have defined a python interpreter as an external tool in Eclipse, so I can run it within Eclipse. It works fine, but it does not have tab completion. \n3) I open my module with python IDLE (not eclipse) and press f5 (run). It runs on the IDLE opened window and when it finishes I have all the variables and functions form the module to play with.\nSo I have 2 questions:\na) how to enable, if possible, tab completion in python interpreter in Eclipse? If it's not possible, do I have any alternative to standard Python interpreter?\nb) I would like to run step 1) and then be able to continue developing \/ testing with python interpreter, just like I do with IDLE, but all inside Eclipse. Any suggestion?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2456,"Q_Id":2638327,"Users Score":0,"Answer":"If you run it as a debug operation in Eclipse, you should be able to set a breakpoint, and you can then examine variables, etc. But you can evaluate random python scripts via the watch functionality.","Q_Score":0,"Tags":"python,eclipse,interactive","A_Id":2640761,"CreationDate":"2010-04-14T14:46:00.000","Title":"Python and Eclipse: How to use interactive console after running a module, with the module variables and functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm from Brazil and study at FATEC (college located in Brazil).\nI'm trying to learn about AppEngine.\nNow, I'm trying to load a large database from MySQL to AppEngine to perform some queries, but I don't know how i can do it. I did some testing with CSV files,but is there any way to perform the direct import from MySQL?\nThis database is from Pentaho BI Server (www.pentaho.com).\nThank you for your attention.\nRegards,\nDaniel Naito","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1278,"Q_Id":2650499,"Users Score":0,"Answer":"If you're using Pentaho BI Server as your data source, why don't you consider using Pentaho Data Integration (ETL tool) to move the data over? At the very least PDI automate any movement of data between your data source and any AppEngine bulk loader tool (it can easily trigger any app with a shell step).","Q_Score":0,"Tags":"python,mysql,google-app-engine,bulk-load","A_Id":2662880,"CreationDate":"2010-04-16T03:57:00.000","Title":"MySQL to AppEngine","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to include a rich text editor in a pygtk drawing area for an application i am developing. The editor ( a small resizable widget ) should be able to move around the drawing area like a rectangle. I am not sure how to start as I am pretty new to PyGTK. thank you !","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2291,"Q_Id":2650591,"Users Score":0,"Answer":"gtk.TextView is \"rich\", in that it can display all types of formatting and even embedded widgets.\nIf you want the functionality of editing rich text, you will have to write something yourself, though others have tried in applications like BloGTK. From which you could steal codes.","Q_Score":1,"Tags":"python,pygtk","A_Id":2788540,"CreationDate":"2010-04-16T04:21:00.000","Title":"Py GTK Drawing area and Rich Text Editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have this encryption algorithm written in C++ , but the values that has to be encrypted are being taken input and stored in a file by a python program . Thus how can i call this c++ program from python?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":83,"Q_Id":2651466,"Users Score":2,"Answer":"Look for the subprocess module.  It is the recommended way to invoke processes from within Python.  The os.system function is a viable alternative sometimes, if your needs are very simple (no pipes, simple arguments, etc.)","Q_Score":0,"Tags":"python","A_Id":2651534,"CreationDate":"2010-04-16T07:58:00.000","Title":"how to call a c++ file from python without using any of the spam bindings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have this encryption algorithm written in C++ , but the values that has to be encrypted are being taken input and stored in a file by a python program . Thus how can i call this c++ program from python?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":2651466,"Users Score":0,"Answer":"The os.system function will invoke an arbitrary command-line from python.","Q_Score":0,"Tags":"python","A_Id":2651490,"CreationDate":"2010-04-16T07:58:00.000","Title":"how to call a c++ file from python without using any of the spam bindings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"PdfFileReader reads the content from a pdf file to create an object.\nI am querying the pdf from a cdn via urllib.urlopen(), this provides me a file like object, which has no seek. PdfFileReader, however uses seek.\nWhat is the simple way to create a PdfFileReader object from a pdf downloaded via url.\nNow, what can I do to avoid writing to disk and reading it again via file().\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":275,"Q_Id":2653079,"Users Score":1,"Answer":"I suspect you may be optimising prematurely here.\nMost modern systems will cache files in memory for a significant period of time before they flush them to disk, so if you write the data to a temporary file, read it back in, then close and delete the file you may find that there's no significant disc traffic (unless it really is 100MB).\nYou might want to look at using tempfile.TemporaryFile() which creates a temporary file that is automatically deleted when closed, or else tempfile.SpooledTemporaryFile() which explicitly holds it all in memory until it exceeds a particular size.","Q_Score":2,"Tags":"python,file,urllib,file-type","A_Id":2653447,"CreationDate":"2010-04-16T12:59:00.000","Title":"Inexpensive ways to add seek to a filetype object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me.\ncan someone help me, how to access the variables from one function to another function.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1692,"Q_Id":2654484,"Users Score":1,"Answer":"If you want to share data between functions then create a class and turn the functions into methods on the class.","Q_Score":0,"Tags":"python,function,variables,global-variables","A_Id":2654582,"CreationDate":"2010-04-16T16:11:00.000","Title":"access variables of other functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me.\ncan someone help me, how to access the variables from one function to another function.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1692,"Q_Id":2654484,"Users Score":0,"Answer":"Don't try to do this. Explicit is better than implicit - if your function needs access to certain variables, pass them in. If it needs to change a value in the calling function, return the new value.","Q_Score":0,"Tags":"python,function,variables,global-variables","A_Id":2654647,"CreationDate":"2010-04-16T16:11:00.000","Title":"access variables of other functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing simple site that requires users and profiles to be handled. The first initial thought is to use django's build in user handling, but then the user model is too narrow and does not contain fields that I need. The documentation mentions user profiles, but user profiles section has been removed from djangobook covering django 1.0 (ideally, the solution should work with django 1.2), and the Internet is full of different solutions, not making the choice easier (like user model inheritance, user profiles and django signals, and so on).\nI would like to know, how to write this in good, modern, fast and secure way. Should I try to extend django builtin user model, or maybe should I create my own user model wide enough to keep all the information I need? Below you may find some specifications and expectations from the working solution:\n\nusers should be able to register and authenticate\nevery user should have profile (or model with all required fields)\nusers dont need django builtin admin panel, but they need to edit their profiles\/models via simple web form\n\nPlease, let me know how do you solve those issues in your applications, and what is the best current way to handle users with django. Any links to articles\/blogs or code examples are highly appreciated!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2938,"Q_Id":2654689,"Users Score":0,"Answer":"Thank you all for your answers! I know that django dev documentation mentions user profiles, but does it very briefly (roughly few lines) and links to djangobook containing information about user profiles, but... to its first version, covering django 0.96. The second version of djangobook, covering django 1.0 (that is way closer to 1.2 than 0.96) no longer has that information anywhere, what makes me highly confused - has anything changed? Is there other, better, more secure way to handle users and their profiles? Therefore this question asked.","Q_Score":3,"Tags":"python,django,profiles","A_Id":2657984,"CreationDate":"2010-04-16T16:43:00.000","Title":"Django - how to write users and profiles handling in best way?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a python script that calls a bunch of functions, each of which writes output to stdout.  Sometimes when I run it, I'd like to send the output in an e-mail (along with a generated file).  I'd like to know how I can capture the output in memory so I can use the email module to build the e-mail.\nMy ideas so far were:\n\nuse a memory-mapped file (but it seems like I have to reserve space on disk for this, and I don't know how long the output will be)\nbypass all this and pipe the output to sendmail (but this may be difficult if I also want to attach the file)","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4960,"Q_Id":2654834,"Users Score":4,"Answer":"You said that your script \"calls a bunch of functions\" so I'm assuming that they're python functions accessible from your program. I'm also assuming you're using print to generate the output in all these functions. If that's the case, you can just replace sys.stdout with a StringIO.StringIO which will intercept all the stuff you're writing. Then you can finally call the .getValue method on your StringIO to get everything that has been sent to the output channel. This will also work for external programs using the subprocess module which write to sys.stdout.\nThis is a cheap way. I'd recommend that you do your output using the logging module. You'll have much more control over how it does it's output and you can control it more easily as well.","Q_Score":7,"Tags":"python,stream","A_Id":2654886,"CreationDate":"2010-04-16T17:04:00.000","Title":"Capturing stdout within the same process in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now.\nI've googled this question and only found one related one but it was too confusing. I am currently running Mac OS X Snow Leopard.\nAny help is much appreciated.\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3985,"Q_Id":2660291,"Users Score":1,"Answer":"This really is independent of python.  It depends entirely on which file browser you're using and how it supports drag and drop.","Q_Score":4,"Tags":"python,scripting,drag-and-drop,arguments","A_Id":2660314,"CreationDate":"2010-04-17T22:24:00.000","Title":"In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now.\nI've googled this question and only found one related one but it was too confusing. I am currently running Mac OS X Snow Leopard.\nAny help is much appreciated.\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3985,"Q_Id":2660291,"Users Score":1,"Answer":"Usually when you drag a file onto a script\/executable, the OS passes the path to that file as a command-line argument. Check sys.argv","Q_Score":4,"Tags":"python,scripting,drag-and-drop,arguments","A_Id":2660293,"CreationDate":"2010-04-17T22:24:00.000","Title":"In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have installed pexpect with the following command \"python setup.py install\" but when i try to run a program it says \"AttributeError: 'module' object has no attribute 'spawn'\". how to settle the matter?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1337,"Q_Id":2661069,"Users Score":1,"Answer":"Pexpect has not been ported to python3, and apparently the author has no plans on doing so. \nI tried converting it with the python 2to3 program, but could not get it to work.","Q_Score":2,"Tags":"python-3.x","A_Id":8859319,"CreationDate":"2010-04-18T03:56:00.000","Title":"pexpect install problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have installed pexpect with the following command \"python setup.py install\" but when i try to run a program it says \"AttributeError: 'module' object has no attribute 'spawn'\". how to settle the matter?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1337,"Q_Id":2661069,"Users Score":2,"Answer":"It looks like pexpect wasn't ported yet to python 3 (quite a late answer, but still usable for people googling here)","Q_Score":2,"Tags":"python-3.x","A_Id":4926558,"CreationDate":"2010-04-18T03:56:00.000","Title":"pexpect install problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is a m2m relation in my models,  User and Role.   \nI want to merge a role, but i DO NOT want this merge has any effect on user and role relation-ship.  Unfortunately, for some complicate reason, role.users if not empty.  \nI tried to set role.users = None, but SA complains None is not a list.\nAt this moment, I use sqlalchemy.orm.attributes.del_attribute, but I don't know if it's provided for this purpose.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":396,"Q_Id":2665253,"Users Score":0,"Answer":"You'd better fix your code to avoid setting role.users for the item you are going to merge. But there is another way - setting cascade='none' for this relation. Then you lose an ability to save relationship from Role side, you'll have to save User with roles attribute set.","Q_Score":0,"Tags":"python,sqlalchemy","A_Id":2667004,"CreationDate":"2010-04-19T05:01:00.000","Title":"In SqlAlchemy, how to ignore m2m relationship attributes when merge?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to validate that the fields given to sphinx are valid, but I'm having difficulty.\nImagine that valid fields are cat, mouse, dog, puppy.\nValid searches would then be:\n\n@cat search terms \n@(cat) search terms\n@(cat, dog) search term\n@cat searchterm1 @dog searchterm2 \n@(cat, dog) searchterm1 @mouse searchterm2\n\nSo, I want to use a regular expression to find terms such as cat, dog, mouse in the above examples, and check them against a list of valid terms.\nThus, a query such as:\n@(goat)\nWould produce an error because goat is not a valid term.\nI've gotten so that I can find simple queries such as @cat with this regex: (?:@)([^( ]*)\nBut I can't figure out how to find the rest.\nI'm using python & django, for what that's worth.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":700,"Q_Id":2677713,"Users Score":3,"Answer":"To match all allowed fields, the following rather fearful looking regex works:\n\n@((?:cat|mouse|dog|puppy)\\b|\\((?:(?:cat|mouse|dog|puppy)(?:, *|(?=\\))))+\\))\n\nIt returns these matches, in order: @cat, @(cat), @(cat, dog), @cat, @dog, @(cat, dog), @mouse.\nThe regex breaks down as follows:\n\n@                               # the literal character \"@\"\n(                               # match group 1\n  (?:cat|mouse|dog|puppy)       #  one of your valid search terms (not captured)\n  \\b                            #  a word boundary\n  |                             #  or...\n  \\(                            #  a literal opening paren\n  (?:                           #  non-capturing group\n    (?:cat|mouse|dog|puppy)     #   one of your valid search terms (not captured)\n    (?:                         #   non-capturing group\n      , *                       #    a comma \",\" plus any number of spaces\n      |                         #    or...\n      (?=\\))                    #    a position followed by a closing paren\n    )                           #   end non-capture group\n  )+                            #  end non-capture group, repeat\n  \\)                            #  a literal closing paren\n)                               # end match group one.\n\nNow to identify any invalid search, you would wrap all that in a negative look-ahead:\n\n@(?!(?:cat|mouse|dog|puppy)\\b|\\((?:(?:cat|mouse|dog|puppy)(?:, *|(?=\\))))+\\))\n--^^\n\nThis would identify any @ character after which an invalid search term (or term combination) was attempted. Modifying it so that it also matches the invalid attempt instead of just pointing at it is not that hard anymore.\nYou would have to prepare (?:cat|mouse|dog|puppy) from your field dynamically and plug it into the static rest of the regex. Should not be too hard to do either.","Q_Score":2,"Tags":"python,regex,django,sphinx","A_Id":2678057,"CreationDate":"2010-04-20T18:41:00.000","Title":"Regex for finding valid sphinx fields","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm pretty new to Python programming and would appreciate some help to a problem I have...\nBasically I have multiple text files which contain velocity values as such:\n0.259515E+03  0.235095E+03  0.208262E+03  0.230223E+03  0.267333E+03  0.217889E+03  0.156233E+03  0.144876E+03  0.136187E+03  0.137865E+00\netc for many lines...\nWhat I need to do is convert all the values in the text file that are less than 1 (e.g. 0.137865E+00 above) to an arbitrary value of 0.100000E+01. While it seems pretty simple to replace specific values with the 'replace()' method and a while loop, how do you do this if you want to replace a range?\nthanks","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":5818,"Q_Id":2685015,"Users Score":4,"Answer":"typical technique would be:\n\nread file line by line\nsplit each line into a list of strings\nconvert each string to the float\ncompare converted value with 1\nreplace when needed\nwrite back to the new file\n\nAs I don't see you having any code yet, I hope that this would be a good start","Q_Score":6,"Tags":"python,replace","A_Id":2685038,"CreationDate":"2010-04-21T17:09:00.000","Title":"python: find and replace numbers < 1 in text file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python in Linux to automate an excel. I have finished writing data into excel by using pyexcelerator package. \nNow comes the real challenge. I have to add another tab to the existing sheet and that tab should contain the macro run in the first tab. All these things should be automated. I Googled a lot and found win32come to do a job in macro, but that was only for windows.\nAnyone have any idea of how to do this, or can you guide me with few suggestions.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1093,"Q_Id":2697701,"Users Score":0,"Answer":"Excel Macros are per sheets, so, I am afraid, you need to copy the macros explicitly if you created new sheet, instead of copying existing sheet to new one.","Q_Score":1,"Tags":"python,linux,excel,automation","A_Id":2697769,"CreationDate":"2010-04-23T10:08:00.000","Title":"Automating Excel macro using python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python in Linux to automate an excel. I have finished writing data into excel by using pyexcelerator package. \nNow comes the real challenge. I have to add another tab to the existing sheet and that tab should contain the macro run in the first tab. All these things should be automated. I Googled a lot and found win32come to do a job in macro, but that was only for windows.\nAnyone have any idea of how to do this, or can you guide me with few suggestions.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1093,"Q_Id":2697701,"Users Score":0,"Answer":"Maybe manipulating your .xls with Openoffice and pyUno is a better way. Way more powerful.","Q_Score":1,"Tags":"python,linux,excel,automation","A_Id":3596123,"CreationDate":"2010-04-23T10:08:00.000","Title":"Automating Excel macro using python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a very large file editor (where the editor only stores a part of the buffer in memory at a time), but I'm stuck while building my textview object.  Basically- I know that I have to be able to update the text view buffer dynamically, and I don't know hot to get the scrollbars to relate to the full file while the textview contains only a small buffer of the file.\nI've played with Gtk.Adjustment on a Gtk.ScrolledWindow and ScrollBars, but though I can extend the range of the scrollbars, they still apply to the range of the buffer and not the filesize (which I try to set via Gtk.Adjustment parameters) when I load into textview.  I need to have a widget that \"knows\" that it is looking at a part of a file, and can load\/unload buffers as necessary to view different parts of the file.  So far, I believe I'll respond to the \"change_view\" to calculate when I'm off, or about to be off the current buffer and need to load the next, but I don't know how to get the scrollbars to have the top relate to the beginning of the file, and the bottom relate to the end of the file, rather than to the loaded buffer in textview.\nAny help would be greatly appreciated, thanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":494,"Q_Id":2698533,"Users Score":1,"Answer":"You probably should create your own Gtk.TextBuffer implementation, as the default one relies on storing whole buffer in memory.","Q_Score":4,"Tags":"python,gtk,pygtk","A_Id":2698565,"CreationDate":"2010-04-23T12:43:00.000","Title":"Gtk: How can I get a part of a file in a textview with scrollbars relating to the full file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently, I have a parser with multiple classes that work together.\nFor Instance: TreeParser creates multiple Product and Reactant modules which in turn create multiple Element classes. The TreeParser is called by a render method within the same module, which is called from the importer.\nFinally, if the package has dependencies (such as re and another another module within the same folder), where is the best place to require those modules? Within the __init__.py file or within the module itself? \nEDIT:\nWhen importing a part of a module that calls another def within the module, how do you call that def if it isn't imported?\nlib\/toolset.py => def add(){ toolset.show(\"I'm Add\"); } def show(text){print text};\nif that file is called from main.py => import lib.toolset then,  the show method wouldn't be loaded, or main.py => from lib.toolset import show wouldn't work.\nCan an import toolset be put at the top of toolset.py?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":185,"Q_Id":2699987,"Users Score":3,"Answer":"I think this is the key statement in your question.\n\nI don't really want to add the module name in front of every call to the class\n\nMy response: I hear what you're saying, but this is standard practice in Python.\nAny Python programmer reading code like \"result = match(blah)\" will presume you're calling a local function inside your own module. If you're actually talking about the function match() in the re module they'll expect to see \"result = re.match(blah)\". That's just how it is.\nIf it helps, I didn't like this style either when I came to Python first, but now I appreciate that it removes any ambiguity over exactly which of the many functions called \"match\" I am calling, especially when I come back to read code that I wrote six months ago.","Q_Score":1,"Tags":"python,namespaces,module","A_Id":2700321,"CreationDate":"2010-04-23T15:52:00.000","Title":"Importing Classes Within a Module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently, I have a parser with multiple classes that work together.\nFor Instance: TreeParser creates multiple Product and Reactant modules which in turn create multiple Element classes. The TreeParser is called by a render method within the same module, which is called from the importer.\nFinally, if the package has dependencies (such as re and another another module within the same folder), where is the best place to require those modules? Within the __init__.py file or within the module itself? \nEDIT:\nWhen importing a part of a module that calls another def within the module, how do you call that def if it isn't imported?\nlib\/toolset.py => def add(){ toolset.show(\"I'm Add\"); } def show(text){print text};\nif that file is called from main.py => import lib.toolset then,  the show method wouldn't be loaded, or main.py => from lib.toolset import show wouldn't work.\nCan an import toolset be put at the top of toolset.py?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":185,"Q_Id":2699987,"Users Score":2,"Answer":"I'm not really sure what your problem is, is it that you just want to type less?\n\nget a decent source editor with autocomplete!\nyou can do import longmodulename as ln and use ln.something instead of longmodulename.something\nyou can do from longmodulename import ( something, otherthing ) and use something directly\n\nimport * is never a good idea, it messes with coding tools, breaks silently, makes readers wonder stuff was defined and so on ...","Q_Score":1,"Tags":"python,namespaces,module","A_Id":2700126,"CreationDate":"2010-04-23T15:52:00.000","Title":"Importing Classes Within a Module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make an executable file (.exe) of my Python application.\nI want to know how to do it but have this in mind: I use a C++ DLL!\nDo I have to put the DLL along side with the .exe or is there some other way?","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":22332,"Q_Id":2709925,"Users Score":1,"Answer":"I've built exe files from Python 2.7 code using each of these tools:\n\nCython (with --embed option)\nNuitka \nPy2exe \n\nThese all will produce a standalone exe. Your installer will have to include the requisite CRT dlls. Your end result will be indistinguishable from any other exe to the typical user.\nThe first two compile to C first, then compile that to a final exe using whatever compiler you have installed. Py2Exe bundles Python and all your .pyo files into a zip which it embeds in the exe. When launched it unzips to the temp directory and runs the python from there. You'll need to add your dll to the .spec file so it is included in the zip resource. Alternatively, install your dll alongside the exe and load it using an absolute path in python.","Q_Score":10,"Tags":"python,executable","A_Id":23118279,"CreationDate":"2010-04-25T20:55:00.000","Title":"How to make an executable file in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A rather confusing sequence of events happened, according to my log-file, and I am about to put a lot of the blame on the Python logger, which is a bold claim. I thought I should get some second opinions about whether what I am saying could be true.\nI am trying to explain why there is are several large gaps in my log file (around two minutes at a time) during stressful periods for my application when it is missing deadlines.\nI am using Python's logging module on a remote server, and have set-up, with a configuration file, for all logs of severity of ERROR or higher to be emailed to me. Typically, only one error will be sent at a time, but during periods of sustained problems, I might get a dozen in a minute - annoying, but nothing that should stress SMTP.\nI believe that, after a short spurt of such messages, the Python logging system (or perhaps the SMTP system it is sitting on) is encountering errors or congestion. The call to Python's log is then BLOCKING for two minutes, causing my thread to miss its deadlines. (I was smart enough to move the logging until after the critical path of the application - so I don't care if logging takes me a few seconds, but two minutes is far too long.)\nThis seems like a rather awkward architecture (for both a logging system that can freeze up, and for an SMTP system (Ubuntu, sendmail) that cannot handle dozens of emails in a minute**), so this surprises me, but it exactly fits the symptoms.\nHas anyone had any experience with this? Can anyone describe how to stop it from blocking? \n** EDIT # 2 : I actually counted. 170 emails in two hours. Forget the previous edit. I counted wrong. It's late here...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":701,"Q_Id":2722036,"Users Score":2,"Answer":"Stress-testing was revealing:\nMy logging configuration sent critical messages to SMTPHandler, and debug messages to a local log file.\nFor testing I created a moderately large number of threads (e.g. 50) that waited for a trigger, and then simultaneosly tried to log either a critical message or a debug message, depending on the test.\nTest #1: All threads send critical messages: It revealed that the first critical message took about .9 seconds to send. The second critical message took around 1.9 seconds to send. The third longer still, quickly adding up. It seems that the messages that go to email block waiting for each other to complete the send.\nTest #2: All threads send debug messages: These ran fairly quickly, from hundreds to thousands of microseconds.\nTest #3: A mix of both. It was clear from the results that debug messages were also being blocked waiting for critical message's emails to go out.\nSo, it wasn't that 2 minutes meant there was a timeout. It was the two minutes represented a large number of threads blocked waiting in the queue.\nWhy were there so many critical messages being sent at once? That's the irony. There was a logging.debug() call inside a method that included a network call. I had some code monitoring the speed of the of the method (to see if the network call was taking too long). If so, it (of course) logged a critical error that sent an email. The next thread then blocked on the logging.debug() call, meaning it missed the deadline, triggering another email, triggering another thread to run slowly.\nThe 2 minute delay in one thread wasn't a network timeout. It was one thread waiting for another thread, that was blocked for 1 minute 57 - because it was waiting for another thread blocked for 1 minute 55, etc. etc. etc.\nThis isn't very pretty behaviour from SMTPHandler.","Q_Score":2,"Tags":"python,logging,smtp","A_Id":2734655,"CreationDate":"2010-04-27T14:27:00.000","Title":"Could Python's logging SMTP Handler be freezing my thread for 2 minutes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on a project in which I have to develop bio-passwords based on user's keystroke style. \nSuppose a user types a password for 20 times, his keystrokes are recorded, like \nholdtime : time for which a particular key is pressed. \ndigraph time : time it takes to press a different key.\nsuppose a user types a password  \" COMPUTER\".  I need to know the time for which every key is pressed. something like :\nholdtime for the above password is\nC-- 200ms\nO-- 130ms\nM-- 150ms\nP-- 175ms\nU-- 320ms\nT-- 230ms\nE-- 120ms\nR-- 300ms\nThe rational behind this is , every user will have a different holdtime. Say a old person is typing the password, he will take more time then a student. And it will be unique to a particular person. \nTo do this project, I need to record the time for each key pressed. \nI would greatly appreciate if anyone can guide me in how to get these times. \nEditing from here..\nLanguage is not important, but I would prefer it in C. I am more interested in getting the dataset.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3012,"Q_Id":2726176,"Users Score":0,"Answer":"The answer is conditionally \"yes\".\nIf your languages\/environment has interactive keyboard support that offers Key-Down and Key-Up events, then you catch both events and time the difference between them.\nThis would be trivially easy in JavaScript on a web page, which would also be the easiest way to show off your work to a wider audience.","Q_Score":4,"Tags":"c++,python,c,linux,unix","A_Id":2726201,"CreationDate":"2010-04-28T00:55:00.000","Title":"Can I get the amount of time for which a key is pressed on a keyboard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project in which I have to develop bio-passwords based on user's keystroke style. \nSuppose a user types a password for 20 times, his keystrokes are recorded, like \nholdtime : time for which a particular key is pressed. \ndigraph time : time it takes to press a different key.\nsuppose a user types a password  \" COMPUTER\".  I need to know the time for which every key is pressed. something like :\nholdtime for the above password is\nC-- 200ms\nO-- 130ms\nM-- 150ms\nP-- 175ms\nU-- 320ms\nT-- 230ms\nE-- 120ms\nR-- 300ms\nThe rational behind this is , every user will have a different holdtime. Say a old person is typing the password, he will take more time then a student. And it will be unique to a particular person. \nTo do this project, I need to record the time for each key pressed. \nI would greatly appreciate if anyone can guide me in how to get these times. \nEditing from here..\nLanguage is not important, but I would prefer it in C. I am more interested in getting the dataset.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3012,"Q_Id":2726176,"Users Score":0,"Answer":"If you read from the terminal in conical mode, you can read each keystroke as it's pressed. You won't see keydown keyup events, like you could if you trapped X events, but it's probably easier, especially if you're just running in a console or terminal.","Q_Score":4,"Tags":"c++,python,c,linux,unix","A_Id":2726199,"CreationDate":"2010-04-28T00:55:00.000","Title":"Can I get the amount of time for which a key is pressed on a keyboard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how would one find all integer points common to two circles?\nFor example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2).\nHow would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":4391,"Q_Id":2730969,"Users Score":1,"Answer":"You may also want to look into the various clipping algorithms used in graphics development.  I have used clipping algorithms to solve alot of problems similar to what you are asking here.","Q_Score":6,"Tags":"python,geometry,intersection,points","A_Id":2731060,"CreationDate":"2010-04-28T15:37:00.000","Title":"Finding all points common to two circles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how would one find all integer points common to two circles?\nFor example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2).\nHow would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":4391,"Q_Id":2730969,"Users Score":1,"Answer":"If the locations and radii of your circles can vary with a granularity less than your grid, then you'll be checking a bunch of points anyway.\nYou can minimize the number of points you check by defining the search area appropriately.  It has a width equal to the distance between the points of intersection, and a height equal to\nr1 + r2 - D\nwith D being the separation of the two centers.  Note that this rectangle in general is not aligned with the X and Y axes.  (This also gives you a test as to whether the two circles intersect!)\nActually, you'd only need to check half of these points.  If the radii are the same, you'd only need to check a quarter of them.  The symmetry of the problem helps you there.","Q_Score":6,"Tags":"python,geometry,intersection,points","A_Id":2731095,"CreationDate":"2010-04-28T15:37:00.000","Title":"Finding all points common to two circles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how would one find all integer points common to two circles?\nFor example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2).\nHow would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":4391,"Q_Id":2730969,"Users Score":1,"Answer":"You're almost there.\nIterating over the points in the box should be fairly good, but you can do better if for the second coordinate you iterate directly between the limits.\nSay you iterate along the x axis first, then for the y axis, instead of iterating between bounding box coords figure out where each circle intersects the x line, more specifically you are interested in the y coordinate of the intersection points, and iterate between those (pay attention to rounding)\nWhen you do this, because you already know you are inside the circles you can skip the checks entirely.\nIf you have a lot of points then you skip a lot of checks and you might get some performance improvements.\nAs an additional improvement you can pick the x axis or the y axis to minimize the number of times you need to compute intersection points.","Q_Score":6,"Tags":"python,geometry,intersection,points","A_Id":32522118,"CreationDate":"2010-04-28T15:37:00.000","Title":"Finding all points common to two circles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how would one find all integer points common to two circles?\nFor example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2).\nHow would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4391,"Q_Id":2730969,"Users Score":0,"Answer":"So you want to find the lattice points that are inside both circles? \nThe method you suggested of drawing a box and iterating through all the points in the box seems the simplest to me. It will probably be efficient, as long as the number of points in the box is comparable to the number of points in the intersection.\nAnd even if it isn't as efficient as possible, you shouldn't try to optimize it until you have a good reason to believe it's a real bottleneck.","Q_Score":6,"Tags":"python,geometry,intersection,points","A_Id":2731015,"CreationDate":"2010-04-28T15:37:00.000","Title":"Finding all points common to two circles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written up a python script that allows a user to input a message, his email and the time and  they would like the email sent. This is all stored in a mysql database.\nHowever, how do I get the script to execute on the said time and date? will it require a cron job? I mean say at 2:15 on april 20th, the script will search the database for all times of 2:15, and send out those emails. But what about for emails at 2:16?\nI am using a shared hosting provided, so cant have a continously running script.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2308,"Q_Id":2732407,"Users Score":1,"Answer":"A cronjob every minute or so would do it. If you're considering this, you might like to mind two things:\n1 - How many e-mails are expected to be sent per minute? If it takes you 1 second to send an e-mail and you have 100 e-mails per minute, you won't finish your queue. \n2 - What will happen if one job starts before the last one finishes? Be careful not to send e-mails twice. You need either to make sure first process ends (risk: you can drop an e-mail eventually), avoid next process to start (risk: first process hangs whole queue) or make them work in parallel (risk: synchronization problems).\nIf you take daramarak's suggestion - make you script add a new cron job at end - you have the risk of whole system colapsing if one error occurs.","Q_Score":1,"Tags":"python,mysql,email,reminders","A_Id":2733383,"CreationDate":"2010-04-28T19:06:00.000","Title":"Timed email reminder in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written up a python script that allows a user to input a message, his email and the time and  they would like the email sent. This is all stored in a mysql database.\nHowever, how do I get the script to execute on the said time and date? will it require a cron job? I mean say at 2:15 on april 20th, the script will search the database for all times of 2:15, and send out those emails. But what about for emails at 2:16?\nI am using a shared hosting provided, so cant have a continously running script.\nThanks","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2308,"Q_Id":2732407,"Users Score":2,"Answer":"If you cannot have a continuously running script, something must trigger it, so that would have to rely on your OS internals. In a unix environment a cron job, as you self state, would do the trick.\nSet cron to run the script, and make the script wait for a given time and then continue running and sending until the next email is more than this given time away. Then make your script add a new cron job for a new wakeup time.","Q_Score":1,"Tags":"python,mysql,email,reminders","A_Id":2732645,"CreationDate":"2010-04-28T19:06:00.000","Title":"Timed email reminder in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got 10+ years in C\/C++, and it appears Visual Studio has spoilt me during that time. In Visual Studio, debbuging issimple: I just add a breakpoint to a line of code, and as soon as that code is executed, my breakpoint triggers, at which point I can view a callstack, local\/member variables, etc. \nI'm trying to achieve this functionality under App Engine. I assume that is possible?\nAll the searching I've done to this point has led me to using Pydev in Eclipse. As best I can tell, I am successfully launching my simple 'hello world' program in Debug mode.\nBut the IDE doesn't even seem to have an option to set a breakpoint? I must be missing something.\nI've googled long and hard about this, but am having no luck. Most results trace back to the same old threads that don't deal directly with my issue. \nCan anyone shed some light on how you get basic debugging setup using Pydev\/Eclipse with App Engine? \nAlternatively, if there's an easier way to debug App Engine than using Pydev\/Eclipse, I'd love to hear about it.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":865,"Q_Id":2735968,"Users Score":1,"Answer":"In fact setting a breakpoint in eclipse is very easy. You have two options:\nIn the grey area next to your line numbers, doubleclick or right mouseclick -> toggle breakpoint.","Q_Score":3,"Tags":"python,eclipse,debugging,google-app-engine,pydev","A_Id":2735992,"CreationDate":"2010-04-29T09:00:00.000","Title":"How to get debugging of an App Engine application working?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a django project that uses a sqlite database that can be written to by an external tool. The text is supposed to be UTF-8, but in some cases there will be errors in the encoding. The text is from an external source, so I cannot control the encoding. Yes, I know that I could write a \"wrapping layer\" between the external source and the database, but I prefer not having to do this, especially since the database already contains a lot of \"bad\" data.\nThe solution in sqlite is to change the text_factory to something like:\n\nlambda x: unicode(x, \"utf-8\", \"ignore\")\n\nHowever, I don't know how to tell the Django model driver this.\nThe exception I get is:\n\n'Could not decode to UTF-8 column 'Text' with text'\nin\n\/var\/lib\/python-support\/python2.5\/django\/db\/backends\/sqlite3\/base.py in execute\n\nSomehow I need to tell the sqlite driver not to try to decode the text as UTF-8 (at least not using the standard algorithm, but it needs to use my fail-safe variant).","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4701,"Q_Id":2744632,"Users Score":0,"Answer":"Incompatible Django version. Check Django version for solving this error first. I was running on Django==3.0.8 and it was producing an error. Than I ran virtualenv where I have Django==3.1.2 and the error was removed.","Q_Score":6,"Tags":"python,django,sqlite,pysqlite","A_Id":64263492,"CreationDate":"2010-04-30T13:00:00.000","Title":"Change text_factory in Django\/sqlite","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython).\nIn particular, I am interested in getting \"build\" and \"run\" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about.\nAlso, can the \"build\" command be made to run py2exe or similar exe packagers?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":437,"Q_Id":2747017,"Users Score":0,"Answer":"You can create custom project that will execute a bat file when building. I remember that I used this method to generate a Inoosetup installer so that you should work to run the py2exe script.\nI have no idea for the rest of the features. The syntax highlighting and the auto-complete should be much more challenging. I would recommend to give a try to Komodo Edit or Eclipse\/Pydev. It works out of the box","Q_Score":2,"Tags":"python,visual-studio,visual-studio-2010","A_Id":2747130,"CreationDate":"2010-04-30T19:13:00.000","Title":"Running CPython Applications With Visual Studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython).\nIn particular, I am interested in getting \"build\" and \"run\" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about.\nAlso, can the \"build\" command be made to run py2exe or similar exe packagers?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":437,"Q_Id":2747017,"Users Score":1,"Answer":"Are you trying to build CPython itself?  Doesn't it come with project files suitable for use with Visual Studio?  (I seem to remember that it did.)\nIf you mean that you want to use CPython but not build it, then just type c:\\pythonxx\\python.exe into the debugging executable and in the arguments put your script's full path name.\nCreate a makefile project and you can do whatever you want with the build rules to get \"build\" to function.","Q_Score":2,"Tags":"python,visual-studio,visual-studio-2010","A_Id":2747733,"CreationDate":"2010-04-30T19:13:00.000","Title":"Running CPython Applications With Visual Studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython).\nIn particular, I am interested in getting \"build\" and \"run\" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about.\nAlso, can the \"build\" command be made to run py2exe or similar exe packagers?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":437,"Q_Id":2747017,"Users Score":1,"Answer":"Eclipse and PyDev already provide an excellent development environment for Python. Is there any reason you cannot use them?","Q_Score":2,"Tags":"python,visual-studio,visual-studio-2010","A_Id":2747097,"CreationDate":"2010-04-30T19:13:00.000","Title":"Running CPython Applications With Visual Studio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) \nI'm in the design\/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. \nHere's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","AnswerCount":7,"Available Count":5,"Score":0.1137907297,"is_accepted":false,"ViewCount":1814,"Q_Id":2748084,"Users Score":4,"Answer":"MUDs actions are usually performed on 'ticks' rather than immediately - this allows for limited affect of latency and for monster's commands to be inserted in the queue and processed fairly.\nPersonally, I don't like this approach, but pretty much 99% of MUDs use it. You need to design a robust command queue & event queue which can handle both AI and user commands. You can then add \"virtual latency\" to AI commands which may be predefined or an average of all users latency, or whatever you like.","Q_Score":4,"Tags":"python,mud","A_Id":2748104,"CreationDate":"2010-04-30T22:37:00.000","Title":"MUD (game) design concept question about timed events","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) \nI'm in the design\/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. \nHere's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","AnswerCount":7,"Available Count":5,"Score":0.0855049882,"is_accepted":false,"ViewCount":1814,"Q_Id":2748084,"Users Score":3,"Answer":"AI's are clients.\nThey're \"part of the server\" only in the most distant view.  They're actually outside the main game engine.  They're specialized clients with no human being. \nAn AI client has the same interface with the server that a human's client would.","Q_Score":4,"Tags":"python,mud","A_Id":2749799,"CreationDate":"2010-04-30T22:37:00.000","Title":"MUD (game) design concept question about timed events","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) \nI'm in the design\/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. \nHere's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","AnswerCount":7,"Available Count":5,"Score":0.057080742,"is_accepted":false,"ViewCount":1814,"Q_Id":2748084,"Users Score":2,"Answer":"You could use threads to handle specific types of Mobs, and put all the instances into an array of some sort.  Then, the thread simply goes through the list repeatedly applying logic.  DelayTimeStart and Delay could be attributes of the parent Mob class, and when the thread goes through the loop, it can put off processing any instances of the Mob in which there is time remaining in the delay.","Q_Score":4,"Tags":"python,mud","A_Id":4190774,"CreationDate":"2010-04-30T22:37:00.000","Title":"MUD (game) design concept question about timed events","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) \nI'm in the design\/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. \nHere's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":1814,"Q_Id":2748084,"Users Score":0,"Answer":"A basic approach would be to have a data structure representing the evil monster's instance of its spell, with a cooldown timer on it.  When the power is used, the cooldown is set (presumably to a number of seconds defined by the master definition of the spell); an attempt to use it again will fail just like with the player ability.  This can be integrated with an event queue by having the queue check cooldown, and if it hasn't expired, to wait for it to expire, or abort the action, or reschedule the action, as appropriate.","Q_Score":4,"Tags":"python,mud","A_Id":4879667,"CreationDate":"2010-04-30T22:37:00.000","Title":"MUD (game) design concept question about timed events","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) \nI'm in the design\/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. \nHere's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":1814,"Q_Id":2748084,"Users Score":0,"Answer":"I'll provide you an answer from an LPMud\/LDMud point of view.\nEvery player in the MUD is an instance of player.c.  Player.c inherits from living.c.  Things that are living have a heartbeat.  The heartbeat function is processed once every 2 seconds for every living object on the mud (or anything that has a heartbeat() function).  Timing events is not typically done based on seconds, but instead based on the number of heartbeats that have elapsed through counters within the object.\nThe wonderful news that applies to your question is that monsters also inherit from living.c.  This means that if you had actions that can only be performed periodically this can all be managed within the heartbeat based on the number of ticks that have occurred.","Q_Score":4,"Tags":"python,mud","A_Id":21559958,"CreationDate":"2010-04-30T22:37:00.000","Title":"MUD (game) design concept question about timed events","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm curious about how others have approached the problem of maintaining and synchronizing database changes across many (10+) developers without a DBA? What I mean, basically, is that if someone wants to make a change to the database, what are some strategies to doing that? (i.e. I've created a 'Car' model and now I want to apply the appropriate DDL to the database, etc..)\nWe're primarily a Python shop and our ORM is SQLAlchemy. Previously, we had written our models in such a way to create the models using our ORM, but we recently ditched this because:\n\nWe couldn't track changes using the ORM\nThe state of the ORM wasn't in sync with the database (e.g. lots of differences primarily related to indexes and unique constraints)\nThere was no way to audit database changes unless the developer documented the database change via email to the team.\n\nOur solution to this problem was to basically have a \"gatekeeper\" individual who checks every change into the database and applies all accepted database changes to an accepted_db_changes.sql file, whereby the developers who need to make any database changes put their requests into a proposed_db_changes.sql file. We check this file in, and, when it's updated, we all apply the change to our personal database on our development machine. We don't create indexes or constraints on the models, they are applied explicitly on the database.\nI would like to know what are some strategies to maintain database schemas and if ours seems reasonable.\nThanks!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":930,"Q_Id":2748946,"Users Score":2,"Answer":"The solution is rather administrative then technical :)\nThe general rule is easy, there should only be tree-like dependencies in the project:\n- There should always be a single master source of schema, stored together with the project source code in the version control\n- Everything affected by the change in the master source should be automatically re-generated every time the master source is updated, no manual intervention allowed never, if automatic generation does not work -- fix either master source or generator, don't manually update the source code\n- All re-generations should be performed by the same person who updated the master source and all changes including the master source change should be considered a single transaction (single source control commit, single build\/deployment for every affected environment including DBs update)\nBeing enforced, this gives 100% reliable result.\nThere are essentially 3 possible choices of the master source\n1) DB metadata, sources are generated after DB update by some tool connecting to the live DB\n2) Source code, some tool is generating SQL scheme from the sources, annotated in a special way and then SQL is run on the DB\n3) DDL, both SQL schema and source code are generated by some tool\n4) some other description is used (say a text file read by a special Perl script generating both SQL schema and the source code)\n1,2,3 are equally good, providing that the tool you need exists and is not over expensive\n4 is a universal approach, but it should be applied from the very beginning of the project and has an overhead of couple thousands lines of code in a strange language to maintain","Q_Score":9,"Tags":"python,database,postgresql,sqlalchemy,database-schema","A_Id":2768187,"CreationDate":"2010-05-01T04:57:00.000","Title":"What are some strategies for maintaining a common database schema with a team of developers and no DBA?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm almost afraid to post this question, there has to be an obvious answer I've overlooked, but here I go:\nContext: I am creating a blog for educational purposes (want to learn python and web.py). I've decided that my blog have posts, so I've created a Post class. I've also decided that posts can be created, read, updated, or deleted (so CRUD). So in my Post class, I've created methods that respond to POST, GET, PUT, and DELETE HTTP methods). So far so good. \nThe current problem I'm having is a conceptual one, I know that sending a PUT HTTP message (with an edited Post) to, e.g., \/post\/52 should update post with id 52 with the body contents of the HTTP message. \nWhat I do not know is how to conceptually correctly serve the (HTML) edit page.\nWill doing it like this: \/post\/52\/edit violate the idea of URI, as 'edit' is not a resource, but an action? \nOn the other side though, could it be considered a resource since all that URI will respond to is a GET method, that will only return an HTML page?\nSo my ultimate question is this: How do I serve an HTML page intended for user editing in a RESTful manner?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":267,"Q_Id":2750341,"Users Score":2,"Answer":"Instead of calling it \/post\/52\/edit, what if you called it \/post\/52\/editor?\nNow it is a resource. Dilemma averted.","Q_Score":4,"Tags":"python,rest,web.py","A_Id":2750368,"CreationDate":"2010-05-01T14:43:00.000","Title":"Is www.example.com\/post\/21\/edit a RESTful URI? I think I know the answer, but have another question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm almost afraid to post this question, there has to be an obvious answer I've overlooked, but here I go:\nContext: I am creating a blog for educational purposes (want to learn python and web.py). I've decided that my blog have posts, so I've created a Post class. I've also decided that posts can be created, read, updated, or deleted (so CRUD). So in my Post class, I've created methods that respond to POST, GET, PUT, and DELETE HTTP methods). So far so good. \nThe current problem I'm having is a conceptual one, I know that sending a PUT HTTP message (with an edited Post) to, e.g., \/post\/52 should update post with id 52 with the body contents of the HTTP message. \nWhat I do not know is how to conceptually correctly serve the (HTML) edit page.\nWill doing it like this: \/post\/52\/edit violate the idea of URI, as 'edit' is not a resource, but an action? \nOn the other side though, could it be considered a resource since all that URI will respond to is a GET method, that will only return an HTML page?\nSo my ultimate question is this: How do I serve an HTML page intended for user editing in a RESTful manner?","AnswerCount":4,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":267,"Q_Id":2750341,"Users Score":4,"Answer":"Another RESTful approach is to use the query string for modifiers: \/post\/52?edit=1\nAlso, don't get too hung up on the purity of the REST model.  If your app doesn't fit neatly into the model, break the rules.","Q_Score":4,"Tags":"python,rest,web.py","A_Id":2750379,"CreationDate":"2010-05-01T14:43:00.000","Title":"Is www.example.com\/post\/21\/edit a RESTful URI? I think I know the answer, but have another question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to write some Python unit tests for my Google App Engine.  How can I set that up?  Does someone happen to have some sample code which shows how to write a simple test?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5767,"Q_Id":2750911,"Users Score":1,"Answer":"Since, gae is based on webhooks it can be easy to set your own testing framework for all relevant urls in your app.yaml. You can test it on sample dataset on development server ( start devel server with --datastore_path option ) and assert writes to database or webhook responses.","Q_Score":17,"Tags":"python,unit-testing,google-app-engine","A_Id":4059206,"CreationDate":"2010-05-01T17:32:00.000","Title":"Google App Engine Python Unit Tests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm downloading a long list of my email subject lines , with the intent of finding email lists that I was a member of years ago, and would want to purge them from my Gmail account (which is getting pretty slow.)\nI'm specifically thinking of newsletters that often come from the same address, and repeat the product\/service\/group's name in the subject.\nI'm aware that I could search\/sort by the common occurrence of items from a particular email address (and I intend to), but I'd like to correlate that data with repeating subject lines....\nNow, many subject lines would fail a string match, but \n\"Google Friends : Our latest news\"\n\"Google Friends : What we're doing today\"\nare more similar to each other than a random subject line, as is:\n\"Virgin Airlines has a great sale today\"\n\"Take a flight with Virgin Airlines\"\nSo -- how can I start to automagically extract trends\/examples of strings that may be more similar. \nApproaches I've considered and discarded ('because there must be some better way'):\n\nExtracting all the possible substrings and ordering them by how often they show up, and manually selecting relevant ones\nStripping off the first word or two and then count the occurrence of each sub string\nComparing Levenshtein distance between entries\nSome sort of string similarity index ...\n\nMost of these were rejected for massive inefficiency or likelyhood of a vast amount of manual intervention required. I guess I need some sort of fuzzy string matching..?\nIn the end, I can think of kludgy ways of doing this, but I'm looking for something more generic so I've added to my set of tools rather than special casing for this data set.\nAfter this, I'd be matching the occurring of particular subject strings with 'From' addresses - I'm not sure if there's a good way of building a data structure that represents how likely\/not two messages are part of the 'same email list' or by filtering all my email subjects\/from addresses into pools of likely 'related' emails and not -- but that's a problem to solve after this one.\nAny guidance would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":768,"Q_Id":2752022,"Users Score":4,"Answer":"I would first turn each string of characters into a set or multiset of words (ignoring punctuation and differences in lower\/upper case).  (If that's not powerful enough, in a second pass I could try pairs or even triples of adjacent words, known as bigrams and trigrams).  The key measure of similarity between strings thus reduced is, what words that are not high frequency overall (not the, and, etc;-) are common to both strings, so a simple set intersection (or multiset intersection, but for your simple use case I think just sets would work fine, esp. sets of bigrams) should suffice to measure the \"commonality\".  A word that's common to the two strings should be worth more the rarer it is, so negative log of frequency of the word across the whole corpus is an excellent starting point for this heuristics.","Q_Score":3,"Tags":"python,string,email,data-mining,fuzzy-search","A_Id":2752090,"CreationDate":"2010-05-02T00:27:00.000","Title":"Algorithm detect repeating\/similiar strings in a corpus of data -- say email subjects, in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to write a recursive function that can add two numbers (x, y), assuming y is not negative. I need to do it using two functions which return x-1 and x+1, and I can't use + or - anywhere in the code. I have no idea how to start, any hints?","AnswerCount":6,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":6761,"Q_Id":2755403,"Users Score":-4,"Answer":"This sounds like homework. So this is probably cheating:\na+b is the same as a.__add__(b), and\na-b is the same as a.__sub__(b).\nSo you can easily add or subtract two numbers without using +\/-. No need for any recursion.","Q_Score":0,"Tags":"python,function,recursion","A_Id":2755421,"CreationDate":"2010-05-02T23:17:00.000","Title":"Using recursion to sum two numbers (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the effort to learn python and\/or ruby, I was wondering how a file shredder would be implemented? I would like it to take in a file as an argument and then employ an algorithm to make that file unrecoverable. Would possibly add the support for multiple files or even whole directories later.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2151,"Q_Id":2758868,"Users Score":1,"Answer":"Since this is a learning exercise and not a professional attempt to secure data. How about this:\n1. Discover the length of the file.\n2. Write 0's to the same length of the file.\n3. Save the file.\n4. Delete the file.\nThen make another program that tries to recover the file.\nBut yes, if looking to make something professional and not just an exercise, look into kitsune's answer.","Q_Score":4,"Tags":"python,ruby,shred","A_Id":2761186,"CreationDate":"2010-05-03T14:48:00.000","Title":"Writing a file shredder in python or ruby?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to change some characters that are not ASCII to '_'.\nFor example, \n\nTannh\u2030user -> Tannh_user\n\n\nIf I use regular expression with Python, how can I do this?\nIs there better way to do this not using RE?","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":17450,"Q_Id":2758921,"Users Score":2,"Answer":"I'd rather just call ord on every character in the string, 1 by 1.  If ord([char]) >= 128 the character is not an ascii character and should be replaced.","Q_Score":7,"Tags":"python,regex","A_Id":2759044,"CreationDate":"2010-05-03T14:54:00.000","Title":"Regular expression that finds and replaces non-ascii characters with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"short version: how can I get rid of the multiple-versions-of-python nightmare ?\nlong version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac).\nNowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in \/usr\/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. \nBut that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost.\nFor example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib\/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess !\nObviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":737,"Q_Id":2759623,"Users Score":1,"Answer":"What I usually do is trying to (progressively) keep up with the Python versions as they come along (and once all of the external dependencies have correct versions available).\nMost of the time the Python code itself can be transferred as-is with only minor needed modifications.\nMy biggest Python project @ work (15.000+ LOC) is now on Python 2.6 a few months (upgrading everything from Python 2.5 did take most of a day due to installing \/ checking 10+ dependencies...)\nIn general I think this is the best strategy with most of the interdependent components in the free software stack (think the dependencies in the linux software repositories): keep your versions (semi)-current (or at least: progressing at the same pace).","Q_Score":10,"Tags":"python,installation,dependencies,multiple-versions","A_Id":2759708,"CreationDate":"2010-05-03T16:41:00.000","Title":"How to maintain long-lived python projects w.r.t. dependencies and python versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"short version: how can I get rid of the multiple-versions-of-python nightmare ?\nlong version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac).\nNowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in \/usr\/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. \nBut that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost.\nFor example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib\/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess !\nObviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","AnswerCount":8,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":737,"Q_Id":2759623,"Users Score":4,"Answer":"Some tips:\n\non Mac OS X, use only the python installation in \/Library\/Frameworks\/Python.framework.\nwhenever you use numpy\/scipy\/matplotlib, install the enthought python distribution\nuse virtualenv and virtualenvwrapper to keep those \"system\" installations pristine; ideally use one virtual environment per project, so each project's dependencies are fulfilled. And, yes, that means potentially a lot of code will be replicated in the various virtual envs.\n\nThat seems like a bigger mess indeed, but at least things work that way. Basically, if one of the projects works in a virtualenv, it will keep working no matter what upgrades you perform, since you never change the \"system\" installs.","Q_Score":10,"Tags":"python,installation,dependencies,multiple-versions","A_Id":2759813,"CreationDate":"2010-05-03T16:41:00.000","Title":"How to maintain long-lived python projects w.r.t. dependencies and python versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"short version: how can I get rid of the multiple-versions-of-python nightmare ?\nlong version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac).\nNowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in \/usr\/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. \nBut that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost.\nFor example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib\/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess !\nObviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":737,"Q_Id":2759623,"Users Score":1,"Answer":"install the python versions you need, better if from sources\nwhen you write a script, include the full python version into it (such as #!\/usr\/local\/bin\/python2.6)\n\nI can't see what could go wrong.\nIf something does, it's probably macports fault anyway, not yours (one of the reasons I don't use macports anymore).\nI know I'm probably missing something and this will get downvoted, but please leave at least a little comment in that case, thanks :)","Q_Score":10,"Tags":"python,installation,dependencies,multiple-versions","A_Id":2844226,"CreationDate":"2010-05-03T16:41:00.000","Title":"How to maintain long-lived python projects w.r.t. dependencies and python versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"short version: how can I get rid of the multiple-versions-of-python nightmare ?\nlong version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac).\nNowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in \/usr\/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. \nBut that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost.\nFor example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib\/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess !\nObviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":737,"Q_Id":2759623,"Users Score":0,"Answer":"At least under Linux, multiple pythons can co-exist fairly happily. I use Python 2.6 on a CentOS system that needs Python 2.4 to be the default for various system things. I simply compiled and installed python 2.6 into a separate directory tree (and added the appropriate bin directory to my path) which was fairly painless. It's then invoked by typing \"python2.6\".\nOnce you have separate pythons up and running, installing libraries for a specific version is straightforward. If you invoke the setup.py script with the python you want, it will be installed in directories appropriate to that python, and scripts will be installed in the same directory as the python executable itself and will automagically use the correct python when invoked.\nI also try to avoid using too many libraries. When I only need one or two functions from a library (eg scipy), I'll often see if I can just copy them to my own project.","Q_Score":10,"Tags":"python,installation,dependencies,multiple-versions","A_Id":2853892,"CreationDate":"2010-05-03T16:41:00.000","Title":"How to maintain long-lived python projects w.r.t. dependencies and python versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a Python script and compiled it into a MS Windows EXE file. I can modify the code, but how do I make it remove itself after running?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":608,"Q_Id":2763541,"Users Score":3,"Answer":"I think the easiest solution is make an external .bat file that executes your exe file and deletes it when finished.","Q_Score":1,"Tags":"python,windows,scripting","A_Id":2763663,"CreationDate":"2010-05-04T07:26:00.000","Title":"I am using Python on Windows. How do I delete my script after it is run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python.\nDoes anyone know how to do this?\nJoe","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":3999,"Q_Id":2767854,"Users Score":2,"Answer":"From your comments, it appears you a interested in a secure way of executing untrusted code.\nRedifining python builtins, as you suggested in a comment, is a horrible way to secure code.\nWhat you want is sandboxing, there are solutions for python, but I wouldn't recommend them.  You would be much better of using Jython or IronPython, because the JVM and .NET clr, were designed with sandboxing in mind.\nI personally believe that in most cases, if you need to execute untrusted code, then you are putting too much or not enough trust in your users.","Q_Score":2,"Tags":"python,lua,eval","A_Id":2768130,"CreationDate":"2010-05-04T18:14:00.000","Title":"Lua parser in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python.\nDoes anyone know how to do this?\nJoe","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3999,"Q_Id":2767854,"Users Score":1,"Answer":"@the_drow\nFrom Lua's web site: \n\nLua is a fast language engine with small footprint that you can embed\n  easily into your application. Lua has a simple and well documented API\n  that allows strong integration with code written in other languages.\n  It is easy to extend Lua with libraries written in other languages. It\n  is also easy to extend programs written in other languages with Lua.\n  Lua has been used to extend programs written not only in C and C++, but also in Java, C#, Smalltalk, Fortran, Ada, Erlang, and even in\n  other scripting languages, such as Perl and Ruby.\n\n@Joe Simpson\nCheck out Lunatic Python, it might have what you want.  I know it's an old question, but other people might be looking for this answer, as well.  It's a good question that deserves a good answer.","Q_Score":2,"Tags":"python,lua,eval","A_Id":18090375,"CreationDate":"2010-05-04T18:14:00.000","Title":"Lua parser in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python application which need a gui HTML editor, I know FCKeditor is nice, so how to embed the FCKeditor in a python desktop app?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":340,"Q_Id":2777919,"Users Score":1,"Answer":"To embed FCKeditor (or maybe better the current CKeditor?), you basically need to embed a full-fledged browser (with Javascript) -- I believe wxPython may currently be the best bet for that, as I hear it has wxIE for Windows and wxWebKitCtrl for the Mac (I don't know if old summer-of-code ideas about making something suitable for Linux ever panned out, though).  Most \"HTML viewer\" widgets, in most GUIs, don't support Javascript, and that's a must for (F?)CKeditor.","Q_Score":0,"Tags":"python,html,editor","A_Id":2778024,"CreationDate":"2010-05-06T01:41:00.000","Title":"Embed FCKeditor in python app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python application which need a gui HTML editor, I know FCKeditor is nice, so how to embed the FCKeditor in a python desktop app?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":340,"Q_Id":2777919,"Users Score":0,"Answer":"In order of difficulty:\nIf you just need to support Windows, you can embed IE in wx - see the docs and demos.\nwxWebKit is looking a bit more mature, but it's still in development.\nYou could just use the web-browser using webbrowser.open(url). Things will be very crude, and interaction will be a pain.\nA fourth option - you could try out pyjamas for your whole GUI, then run it all in a web-browser.","Q_Score":0,"Tags":"python,html,editor","A_Id":2778087,"CreationDate":"2010-05-06T01:41:00.000","Title":"Embed FCKeditor in python app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"for example the following:\nstr(u'\u05dc\u05e9\u05d5\u05dd')\nwill throw an error.\nhow can i prevent these?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":218,"Q_Id":2780413,"Users Score":7,"Answer":"Calling str() on a unicode is the same as calling .encode(sys.getdefaultencoding()) on it. If the unicode contains characters that can't be encoded in the default encoding then it will throw a UnicodeEncodeError. The fix is to explicitly encode the unicode in a useful encoding, such as 'utf-8'.","Q_Score":2,"Tags":"python,unicode,string","A_Id":2780474,"CreationDate":"2010-05-06T10:43:00.000","Title":"why in python giving to str func a unicode string will throw an exception?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"for example the following:\nstr(u'\u05dc\u05e9\u05d5\u05dd')\nwill throw an error.\nhow can i prevent these?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":2780413,"Users Score":0,"Answer":"If you're running on Python 3, the u'' notation is a syntax error. Is this your problem? Because in Python <3, your code is absolutely correct, and since 'test' is plain ASCII there are no decoding issues.","Q_Score":2,"Tags":"python,unicode,string","A_Id":2780957,"CreationDate":"2010-05-06T10:43:00.000","Title":"why in python giving to str func a unicode string will throw an exception?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In my app users can upload files for other users.\nTo make the uploaded files accesible only for the addresse I need some kind of static files authentication system.\nMy idea, is to create the apache hosted directory for each user and to limit access to this derectory using .htaccess.\nThis means that each time new django user is created, I need to create a directory and the appropriate .htaccess file in it. I know I should do it using post_save signals on User model but I don't know how to create the .htaccess in the user's directory from python level. Can you help me with that?\nOr perhaps you have better solution to my problem?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":1305,"Q_Id":2780893,"Users Score":1,"Answer":"Use python to rewrite the .htaccess automatically?\nUse a database with users and use a Apache sessions to authenticate?","Q_Score":2,"Tags":"python,django,apache","A_Id":2780948,"CreationDate":"2010-05-06T12:03:00.000","Title":"django authentication .htaccess static","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does httplib.HTTPException have error codes?  If so how do I get at them from the exception instance?  Any help is appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3303,"Q_Id":2791946,"Users Score":5,"Answer":"The httplib module doesn't use exceptions to convey HTTP responses, just genuine errors (invalid HTTP responses, broken headers, invalid status codes, prematurely broken connections, etc.) Most of the httplib.HTTPException subclasses just have an associated message string (stored in the args attribute), if even that. httplib.HTTPException itself may have an \"errno\" value as the first entry in args (when raised through httplib.FakeSocket) but it's not a HTTP error code.\nThe HTTP response codes are conveyed through the httplib.HTTPConnection object, though; the getresponse method will (usually) return a HTTPResponse instance with a status attribute set to the HTTP response code, and a reason attribute set to the text version of it. This includes error codes like 404 and 500. I say \"usually\" because you (or a library you use) can override httplib.HTTPConnection.response_class to return something else.","Q_Score":2,"Tags":"python,http,exception,tcp","A_Id":2792030,"CreationDate":"2010-05-07T22:05:00.000","Title":"python httplib httpexception error codes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"If so, how can I do this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":848,"Q_Id":2810235,"Users Score":1,"Answer":"when you create a prepared statement, the \"template\" SQL code is sent to the DBMS already, which compiles it into an expression tree. When you pass the values, the corresponding library (python sqlite3 module in your case) doesn't merge the values into the statement. The DBMS does.\nIf you still want to produce a normal SQL string, you can use string replace functions to replace the placeholders by the values (after escaping them).\nWhat do you need this for?","Q_Score":0,"Tags":"python,sqlite,pysqlite","A_Id":2810300,"CreationDate":"2010-05-11T11:28:00.000","Title":"Can I get the raw SQL generated by a prepared statement in Python\u2019s sqlite3 module?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If so, how can I do this?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":848,"Q_Id":2810235,"Users Score":2,"Answer":"When executing a prepared statement, no new SQL is generated.\nThe idea of prepared statements is that the SQL query and its data are transmitted separately (that's why you don't have to escape any arguments) - the query is most likely only stored in an optimized form after preparing it.","Q_Score":0,"Tags":"python,sqlite,pysqlite","A_Id":2810250,"CreationDate":"2010-05-11T11:28:00.000","Title":"Can I get the raw SQL generated by a prepared statement in Python\u2019s sqlite3 module?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to create an ASP.NET MVC web application which has extensible logic that does not require a re-build. I was thinking of creating a filter which had an instance of the IronPython engine. What I would like to know is: how much overhead is there in creating a new engine during each web request, and would it be a better idea to keep a static engine around? However, if I were to keep a single static engine around, what are the issues I might run into as far as locking and script scope? Is it possible to have multiple scopes in the same IropPython engine so I don't get variable collision and security issues between web requests?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":310,"Q_Id":2819134,"Users Score":3,"Answer":"I've just started using IronPython as extensibility point in my ASP.NET MVC aplication. I have one ipy engine (in static property) and for each request I create new scope and execute the script in that scope.\n\nEach scope should be independent on other scopes, no locking is needed.\nIf I run into issues, I'll post it here. However, I don't expect any ;)","Q_Score":2,"Tags":"asp.net,asp.net-mvc,ironpython,dynamic-language-runtime","A_Id":2820043,"CreationDate":"2010-05-12T13:21:00.000","Title":"Eval IronPython Scripts during ASP.NET Web Request; Static Engine or Not","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My problem is that i want to do something like this in linux console\ntelnet 192.168.255.28 > process.py\ni.e i would  like to do some transformation with console telnet output using python script. I'm see Popen in python for this case, but i can't understand how can i get input from telnet if it do not stop all time..\nPleas any ideas.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1408,"Q_Id":2825100,"Users Score":1,"Answer":"As xitrium mentioned, it would be better if you used telnetlib. You can dispense with the whole mess of shell redirection etc.\nIf you do something like telnet foo | process.py, you can read your programs stdin (sys.stdin) to get the output of the telnet program. When you're happy, you can exit and terminate the pipeline. subprocess.Popen would be used if you're trying to open the telnet program as a subprocess of the interpreter. I'm not sure you wanted that. \nIn any case, telnetlib is the right way to go it seems. If you simply want an output text processor, consider perl. It's strengths lean in that direction.","Q_Score":1,"Tags":"python","A_Id":2825228,"CreationDate":"2010-05-13T07:38:00.000","Title":"catch output from linux telnet to a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make my component faster, I am using Javascript and JQuery to build that.\nI am using JSON object to communicate with component and back-end is python.\nIs there any suggestion to make component faster?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":2832064,"Users Score":0,"Answer":"If speed is the issue, and you by profiling discover that js is the culprit, then I would look into replacing the jQuery with vanilla javascript, or a more optimized library.\nAs jQuery tries to do 'everything' and trains its users into wrapping everything in $(), its bound to introduce unnecessary method calls (I've seen that a single call to $() can result in upto 100+ method calls).","Q_Score":3,"Tags":"javascript,jquery,python,google-apps","A_Id":2832539,"CreationDate":"2010-05-14T05:45:00.000","Title":"how to increase Speed of a component made from Javascript or JQuery?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make my component faster, I am using Javascript and JQuery to build that.\nI am using JSON object to communicate with component and back-end is python.\nIs there any suggestion to make component faster?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":2832064,"Users Score":1,"Answer":"Setup some analysis to see what takes time to process. Then decide if you want to try to optimize the javascript and client code, the communication up\/down with the server or the actual speed of the python execution. When you have decided what you want to make faster, you can post samples of that to this site and people will probably be willing to help you.","Q_Score":3,"Tags":"javascript,jquery,python,google-apps","A_Id":2832159,"CreationDate":"2010-05-14T05:45:00.000","Title":"how to increase Speed of a component made from Javascript or JQuery?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to write some scripts to carry out some tasks on my server (running Ubuntu server 8.04 TLS). The tasks are to be run periodically, so I will be running the scripts as cron jobs.\nI have divided the tasks into \"group A\" and \"group B\" - because (in my mind at least), they are a bit different.\nTask Group A\n\nimport data from a file and possibly reformat it - by reformatting, I mean doing things like santizing the data, possibly normalizing it and or running calculations on 'columns' of the data\nImport the munged data into a database. For now, I am mostly using mySQL for the vast majority of imports - although some files will be imported into a sqlLite database.\n\nNote: The files will be mostly text files, although some of the files are in a binary format (my own proprietary format, written by a C++ application I developed).\nTask Group B\n\nExtract data from the database\nPerform calculations on the data and either insert or update tables in the database.\n\nMy coding experience is is primarily as a C\/C++ developer, although I have been using PHP as well for the last 2 years or so (+ a few other languages which are not relevant for the purpose of this question). I am from a Windows background, so I am still finding my feet in the Linux environment.\nMy question is this - I need to write scripts to perform the tasks I described above. Although I suppose I could write a few C++ applications to be used in the shell scripts, I think it may be better to write them in a scripting language, but this may be a flawed assumption. My thinking is that it would be easier to modify things in a script - no need to rebuild etc for changes to functionality. Additionally, C++ data munging in C++ tends to involve more lines of code than \"natural\" scripting languages such as Perl, Python etc.\nAssuming that the majority of people on here agree that scripting is the way to go, herein lies my dilemma. Which scripting language do I use to perform the tasks above (giving my background)?\nMy gut instinct tells me that Perl (shudder) would be the most obvious choice for performing all of the above tasks. BUT (and that is a big BUT). The mere mention of Perl makes my toes curl, as I had a very, very bad experience with it a while back (bought the Perl Camel book + 'data munging with Perl' many years ago, but could still not 'grok' it just felt too alien. The syntax seems quite unnatural to me - despite how many times I have tried to learn it - so if possible, I would really like to give it a miss. PHP (which I already know), also am not sure is a good candidate for scripting on the CLI (I have not seen many examples on how to do this etc - so I may be wrong). \nThe last thing I must mention is that IF I have to learn a new language in order to do this, I cannot afford (time constraint) to spend more than a day, in learning the key commands\/features required in order to do this (I can always learn the details of the language later, once I have actually deployed the scripts).\nSo, which scripting language would you recommend (PHP, Python, Perl, [insert your favorite here]) - and most importantly WHY? Or, should I just stick to writing little C++ applications that I call in a shell script?\nLastly, if you have suggested a scripting language, can you please show with a FEW lines (Perl mongers - I'm looking in your direction [nothing too cryptic!]) how I can use the language you suggested to do what I am trying to do i.e.\n\nload a CSV file into some kind of data structure where you can access data columns easily for data manipulation\ndump the columnar data into a mySQL table\nload data from mySQL table into a data structure that allows columns\/rows to be accessed in the scripting language\n\nHopefully, the snippets will allow me to quickly spot the languages that will pose the steepest learning curve for me - as well as those that simple, elegant and efficient (hopefully those two criteria [elegance and shallow learning curve] are not orthogonal - though I suspect they might be).","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":2833312,"Users Score":3,"Answer":"import data from a file and possibly reformat it \n\nPython excels at this.  Be sure to read up on the csv module so you don't waste time inventing it yourself.\nFor binary data, you may have to use the struct module.   [If you wrote the C++ program that produces the binary data, consider rewriting that program to stop using binary data.  Your life will be simpler in the long run.  Disk storage is cheaper than your time; highly compressed binary formats are more cost than value.]\n\nImport the munged data into a database. \n  Extract data from the database\n  Perform calculations on the data and either insert or update tables in the database.\n\nUse the mysqldb module for MySQL.  SQLite is built-in to Python.\nOften, you'll want to use Object-Relational mapping rather than write your own SQL.  Look at sqlobject and sqlalchemy for this.\nAlso, before doing too much of this, buy a good book on data warehousing.  Your two \"task groups\" sound like you're starting down the data warehousing road.  It's easy to get this all fouled up through poor database design.  Learn what a \"Star Schema\" is before you do anything else.","Q_Score":0,"Tags":"php,python,perl,shell,data-munging","A_Id":2833559,"CreationDate":"2010-05-14T10:10:00.000","Title":"Data munging and data import scripting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?","AnswerCount":5,"Available Count":4,"Score":0.1586485043,"is_accepted":false,"ViewCount":835,"Q_Id":2840932,"Users Score":4,"Answer":"It's frequently helpful to learn programming languages in the order they were created.  The folks that wrote Objective-C clearly had C and its syntax, peculiarities, and features in mind when they defined the language.  It can't hurt you to learn C now.  You may have some insight into why Objective-C is structured the way it is later.\nC has a great, classic book on it, The C Programming Language by Kernighan & Ritchie, which is short and easy to digest if you already have another language under your belt.","Q_Score":0,"Tags":"python,c,objective-c,linux,macos","A_Id":2840981,"CreationDate":"2010-05-15T16:54:00.000","Title":"If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":835,"Q_Id":2840932,"Users Score":1,"Answer":"Sure Objective-C is quite easier to learn if you know C and quite a few books on Objective-C even asume you know C.\nAlso consider learning a bit about MacRuby for GUI development ;)","Q_Score":0,"Tags":"python,c,objective-c,linux,macos","A_Id":2840961,"CreationDate":"2010-05-15T16:54:00.000","Title":"If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":835,"Q_Id":2840932,"Users Score":0,"Answer":"Learning C will definitely be of help, as Objective C inherits its many properties and adds to it.\nYou could learn Objective C either from 'Learn Objective C on the Mac', this one's really a great book, and then if you plan to learn cocoa, get 'Learn Cocoa on the Mac' or the one by James Davidson, they should give you a fine head start, you can then consider moving to the one by Hillegass, and for a stunner 'Objective C developer handbook' by David Chisnall, this is a keeper, you can read it in a month or two.\nFor the compiler I would point you to clang  though a gcc and gnustep combination will work. clang is a better choice if you want to work on Obj C 2.0 features and it is under heavy development.","Q_Score":0,"Tags":"python,c,objective-c,linux,macos","A_Id":2909728,"CreationDate":"2010-05-15T16:54:00.000","Title":"If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know Ruby right now, however I want to learn a new language. I am running Ubuntu 10.04 right now but I am going to get a Mac later this summer. Anyways I want something more for GUI development. I was wondering if I should learn C on Ubuntu right now, and then learn Objective-C when I get an iMac? Will learning C give me an edge? Or should I just learn Python on Ubuntu and then learn Objective-C when I get a new computer?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":835,"Q_Id":2840932,"Users Score":0,"Answer":"Yes. Learn how to program in C.","Q_Score":0,"Tags":"python,c,objective-c,linux,macos","A_Id":5783941,"CreationDate":"2010-05-15T16:54:00.000","Title":"If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am traditionally a Perl and C++ programmer, so apologies in advance if I am misunderstanding something trivial about Python!\nI would like to create a reference to a reference.\nHuh?  Ok.  All objects in Python are actually references to the real object.\nSo, how do I create a reference to this reference?\nWhy do I need\/want this?  I am overriding sys.stdout and sys.stderr to create a logging library.  I would like a (second-level) reference to sys.stdout.\nIf I could create a reference to a reference, then I could create a generic logger class where the init function receives a reference to a file handle reference that will be overrided, e.g., sys.stdout or sys.stderr.  Currently, I must hard-code both values.\nCheers,\nKevin","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":382,"Q_Id":2846308,"Users Score":0,"Answer":"This can't be done. Pass the desired attribute as a string and use getattr() and setattr().","Q_Score":1,"Tags":"python,reference,stdout","A_Id":2846344,"CreationDate":"2010-05-17T02:14:00.000","Title":"Python: How do I create a reference to a reference?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a website which is aimed at being a GUI for several image processing algorithms (referred to as 'tasks').\nAt the moment, only one of these algorithms is finished, but there are more to come (which will have a similar, but not quite the same, workflow)\nBasically, the algorithm works as follows (not that it matters a lot, but just for the sake of clarity):\n1) Enter some parameters and an input image\n2) run algorithm part one\n--algorithm runs--\n3) review an interim result\n4) edit the parameters if needed, and go to 2.\n5) run algorithm part two\n--algorithm runs--\n6) review the result\n7) adjust some of the interim results if needed, and go to 5\n8) all done\nI expect some of the additional tasks to have a rather similar work flow, though it is perfectly possible that they won't.\nSo, the easy way to implement this would be to create a separate django application for each algorithm. \nHowever, I'd like to be able to browse through a sorted list (by time of completion) of completed tasks, and for each of these task display a summary (name, description, start time, thumbnail).\nIs there anyone that can provide me with some suggestions on how I can implement this? I'd like to keep it as simple as possible, so additional task can be 'plugged' in as easy as possible.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":2849118,"Users Score":0,"Answer":"I would make an app with a very abstract definition of a Task model. The Task model might contain properties for:\n\nthe input arguments, \nthe function to run, \nthe time that the task was submitted, \nthe time that the task has been actually running, and \nthe result (which would be something like a singleton Task.NotFinished until finished).\n\nYou could consider using twisted to run the tasks because:\n\ntwisted has a well designed and tested implementation of asynchronous tasks; and\nyou could run the tasks on other processors or machines.","Q_Score":0,"Tags":"python,django,plugins","A_Id":2849724,"CreationDate":"2010-05-17T12:48:00.000","Title":"Suggestions for a pluggable task framework in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Since I have Django 1.1x on my Debian setup - how can I use virtualenv or similar and not have it mess up my system's default django version which in turn would break all my sites?\nDetailed instructions or a great tutorial link would very much be appreciated - please don't offer vague advice since I'm still a noob.\nCurrently I store all my django projects in ~\/django-sites and I am using Apache2 + mod_wsgi to deploy.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":2851632,"Users Score":2,"Answer":"If you have easy_install, or better yet pip installed, should be as easy as:\n\neasy_install\/pip install virtualenv\nmkdir django1.2\nvirtualenv django1.2\n\nThis will put the python binary in a bin folder inside the django1.2 folder. Just use that python binary, and you've got a nice little self-contained environment. You can then install easy_install\/pip into that environment, and then install django 1.2 as well, and hack away.","Q_Score":1,"Tags":"python,django,virtualenv","A_Id":2851741,"CreationDate":"2010-05-17T18:21:00.000","Title":"Using virtualenv to install different versions of same package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There are many sites with instructions on installing ropemacs, but so far I couldn't find any with instructions on how to use it after it's already installed. I have it installed, or at least it seems so, Emacs has \"Rope\" menu in it's top menu bar. Now what? So far I could use only \"Show documentation\" (C-c d by default). An attempt to use code assist (which is auto-complete, I presume?) only causes Emacs to ask about \"Rope project root folder\" (what's that?) in the minibuffer and then showing nothing.\nSo, once ropemacs is installed, what are the steps to see it in action on some simple python scripts? Something like \"if you have this script in your emacs and put the blinking square here and press this, it does that\" would be an answer.\n(I've been thinking if I should ask this or not for some time, because nobody else seems to have the same problem)","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":18010,"Q_Id":2855378,"Users Score":10,"Answer":"You can set the root folder with rope-open-project . Once you've set the root project a .ropeproject dir will be created. \nInside it, a config.py file has hooks where you can run (python) code once the project is set. The project_opened(project): function is a good place to run code. I usually activate the virtual environment imp.load_source('\/path-to-env\/activate_this.py') , so that I can get source coverage for other libs in the virtual env.","Q_Score":78,"Tags":"python,emacs,ide,autocomplete","A_Id":2858148,"CreationDate":"2010-05-18T07:52:00.000","Title":"ropemacs USAGE tutorial","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to write an app in python to control a motor using serial. This all works in a CLI situation fine and is generally stable. but I was wondering how simple it was to add a GUI on top of this code base?\nI assume there will be more code, but is there a simple way of detecting something like GTK, so it only applied the code when GTK was present?\nAlso, GUI creation in Python in general: is it best to keep as little GUI specifics out of the code and use something like GTK's XML based approach (using gtk.glade.XML() function)? Are there other GUI toolkits that have a similar approach to the Glade \/ XML \/ \"Explode in Code\" approach?\nThanks for any advice.\nAndy","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1570,"Q_Id":2857634,"Users Score":0,"Answer":"I don't recommend doing a GUI in XML. All the XML does is give you a mini language for describing a layout. Why use a mini language when you can have the full power of python?\nAs for detecting GTK, I wouldn't suggest that. Instead, add a command line argument to determine whether to create a GUI or not (eg: myprogram -g). It then becomes easy to create a desktop shortcut or command line alias to start in GUI mode, while still being able to use the command line tool from any terminal.\nYou do, however, want to keep the GUI code separate from the bits that do the real work. Give youself a class that contains all the business logic, then have the GUI and CLI both access this object to do work.","Q_Score":2,"Tags":"python,xml,user-interface,gtk,glade","A_Id":2857711,"CreationDate":"2010-05-18T13:24:00.000","Title":"How can I create a GUI on top of a Python APP so it can do either GUI or CLI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm not sure if this is a bug or I'm just missing something (although I have already parsed the documentation about inlines), but:\nLet's say I have a model A. Model A is an inline of model B. User U has full access to model B, but only change permissions to model A (so, no add, nor delete).\nHowever, when editing model B, user U can still see the \"Add another A\" link at the bottom, although U hasn't add permissions for that respective model.\nWhat's wrong? Why does that link keep on showing? My logic says that if U does not have permissions to add A, the link shouldn't appear anymore.\nAlso, ideally, I would like to give U only view rights to model A (so no add, delete or change - only view), but I've read about that (strange, if you ask me) philosophy according to which \"If you don't trust U, just deny him access to the admin area all together\". Kind of a stupid doctrine.\nRight now, I'm trying to simulate this 'view only permissions' by leaving U with just change rights and set all fields as read only. But I think this is kind of a stupid approach and may also cause problems like the permissions thing above...\nHow does an average Django programmer like me achieve view-only permissions, and most of all how should I get rid of the \"Add another A\" link at the bottom of the admin edit form?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1938,"Q_Id":2858040,"Users Score":2,"Answer":"If I want a read-only version of what's in the admin, I just write some normal Django views and keep them out of the admin.\nI don't think the kind of thing you're talking about (allowing changes to an object but not its inlines) is really supported by the admin.  Don't get me wrong: the admin is very flexible and useful, but it's not intended to do everything for you.\nThe only way I see you being able to have this much control in the admin is to not inline A.\n\n\"If you don't trust U, just deny him access to the admin area all together\". Kind of a stupid doctrine.\n\nNot really, when you consider that the admin isn't intended to have the required level of security hardening to guarantee that fine-grain level of access control.  There are many, many places in the admin, due to its open and extensible nature, where bugs can lurk (usually in user-written code) that can be exploited by bad actors.  This is why untrusted users should always see all admin URLs return 404.\nAnyway, when access control requirements are that fine-grained, it becomes unlikely that a general (i.e. django.contrib) solution will fit.","Q_Score":9,"Tags":"python,django,permissions,inlines","A_Id":3090090,"CreationDate":"2010-05-18T14:14:00.000","Title":"Django Inlines user permissions + view only - permissions issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm doing a little program and I want to distribute it using this recipe:\n\nsingle directory with __main__.py in it\nzip this directory and adding a shebang on it #!\/usr\/bin\/env python\nmaking it executable\n\nThe problem is that in this package I have also extra files (I'm using pygtk toolkit and I need images and ui xml files). When I try to access these files I have the error that the resource is unavailable (the path that I'm trying to open is something like file.zip\/gui\/gui.ui ).\nHow can I handle this situation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2816,"Q_Id":2859413,"Users Score":8,"Answer":"I figured out by myself, It's sufficient to use pkgutil.get_data to access the data inside a package.","Q_Score":4,"Tags":"python,packaging,zipapp","A_Id":2861524,"CreationDate":"2010-05-18T17:06:00.000","Title":"Distributing an executable zip file with __main__.py, how to access extra data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"The strength of Twisted (for python) is its asynchronous framework (I think). I've written an image processing server that takes requests via Perspective Broker. It works great as long as I feed it less than a couple hundred images at a time. However, sometimes it gets spiked with hundreds of images at virtually the same time. Because it tries to process them all concurrently the server crashes.\nAs a solution I'd like to queue up the remote_calls on the server so that it only processes ~100 images at a time. It seems like this might be something that Twisted already does, but I can't seem to find it. Any ideas on how to start implementing this? A point in the right direction? Thanks!","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":6156,"Q_Id":2861858,"Users Score":-2,"Answer":"You might also like the txRDQ (Resizable Dispatch Queue) I wrote. Google it, it's in the tx collection on LaunchPad. Sorry I don't have more time to reply - about to go onstage.\nTerry","Q_Score":11,"Tags":"python,asynchronous,twisted","A_Id":2899163,"CreationDate":"2010-05-18T23:22:00.000","Title":"Queue remote calls to a Python Twisted perspective broker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a web application that takes file uploads for some parts.  The file uploads aren't terribly big (mostly word documents and such), but they're much larger than your typical web request and they tend to tie up our threaded servers (zope 2 servers running behind an Apache proxy). \nI'm mostly in the brainstorming phase right now and trying to figure out a general technique to use.  Some ideas I have are:\n\nUsing a python asynchronous server like tornado or diesel or gunicorn.\nWriting something in twisted to handle it.\nJust using nginx to handle the actual file uploads.\n\nIt's surprisingly difficult to find information on which approach I should be taking.  I'm sure there are plenty of details that would be needed to make an actual decision, but I'm more worried about figuring out how to make this decision than anything else.  Can anyone give me some advice about how to proceed with this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":672,"Q_Id":2876181,"Users Score":0,"Answer":"See if you can push the files straight from the user's browser to a static file store, like Amazon S3 or rackspace's cloudfiles service.\nThen you can handle a ton of parallel users.","Q_Score":3,"Tags":"python,asynchronous,file-upload","A_Id":19850039,"CreationDate":"2010-05-20T17:17:00.000","Title":"What's the most scalable way to handle somewhat large file uploads in a Python webapp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"After running a bunch of simulations I'm going to be outputting the results into a table created using SQLAlchemy. I plan to use this data to generate statistics - mean and variance being key. These, in turn, will be used to generate some graphs - histograms\/line graphs, pie-charts and box-and-whisker plots specifically.\nI'm aware of the Python graphing libraries like matplotlib. The thing is, I'm not sure how to have this integrate with the information contained within the database tables. \nAny suggestions on how to make these two play with each other?\nThe main problem is that I'm not sure how to supply the information as \"data sets\" to the graphing library.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1415,"Q_Id":2890564,"Users Score":1,"Answer":"It looks like matplotlib takes simple python data types -- lists of numbers, etc, so you'll be need to write custom code to massage what you pull out of mysql\/sqlalchemy for input into the graphing functions...","Q_Score":1,"Tags":"python,matplotlib,sqlalchemy","A_Id":2891001,"CreationDate":"2010-05-23T03:10:00.000","Title":"How to generate graphs and statistics from SQLAlchemy tables?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know what a pyc file(python bytecode) is. I want to know all the details.\nI want to know about how pyc files interface with the compiler. Is it a replacement for exe?\nDoes it need to be run by python?\nIs it as portable as the .py file is?\nWhere should I use this?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":9508,"Q_Id":2893686,"Users Score":9,"Answer":"Python bytecode requires Python to run, cannot be ran standalone without Python, and is specific to a particular x.y release of Python. It should be portable across platforms for the same version. There is not a common reason for you to use it; Python uses it to optimize out parsing of your .py file on repeated imports. Your life will be fine ignoring the existence of pyc files.","Q_Score":14,"Tags":"python","A_Id":2893714,"CreationDate":"2010-05-23T22:09:00.000","Title":"Where to use a pyc file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"scenario: a modular app that loads .py modules on the fly as it works. programmer (me) wishes to edit the code of a module and then re-load it into the program without halting execution.\ncan this be done?\ni have tried running import a second time on an updated module.py, but the changes are not picked up","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":325,"Q_Id":2894235,"Users Score":0,"Answer":"Alex's answer and the others cover the general case. \nHowever, since these modules you're working on are your own and you'll edit only them, it's possible to implement some kind of a local reloading mechanism rather than rely on the builtin reload. You can architect your module loader as something that loads up the files, compiles it and evals them into a specific namespace and tells the calling code that it's ready. You can take care of reloading by making sure that there's a decent init function which reinitialises the module properly. I assume you'll be editing only these.\nIt's a bit of work but might be interesting and worth your time.","Q_Score":2,"Tags":"python,import,modular","A_Id":2896137,"CreationDate":"2010-05-24T01:07:00.000","Title":"how do i edit a running python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried to use mlab.path(path,'\/my\/path') but failed. Got NameError: name 'path' is not defined in python. Anyone has an idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":408,"Q_Id":2900358,"Users Score":3,"Answer":"Never mind. I found out how. Use mlab.addpath().","Q_Score":2,"Tags":"python,matlab,mlabwrap","A_Id":2900462,"CreationDate":"2010-05-24T21:11:00.000","Title":"how to set MATLABPATH in Python and using mlabwrap?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning about metaclasses in Python. I think it is a very powerful technique, and I'm looking for good uses for them. I'd like some feedback of good useful real-world examples of using metaclasses. I'm not looking for example code on how to write a metaclass (there are plenty examples of useless metaclasses out there), but real examples where you have applied the technique and it was really the appropriate solution. The rule is: no theoretical possibilities, but metaclasses at work in a real application.\nI'll start with the one example I know: \n\nDjango models, for declarative programming, where the base class Model uses a metaclass to fill the model objects of useful ORM functionality from the attribute definitions.\n\nLooking forward to your contributions.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2053,"Q_Id":2907498,"Users Score":0,"Answer":"SQLalchemy also uses them for declarative database models.  \nSorry my answer isn't very different from your example, but if you're looking for example code, I found declarative to be pretty readable.","Q_Score":13,"Tags":"python,metaprogramming","A_Id":2907750,"CreationDate":"2010-05-25T18:43:00.000","Title":"Good real-world uses of metaclasses (e.g. in Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a shell-like environment. My original method of handleing user input was to use a dictionary mapping commands (strings) to methods of various classes, making use of the fact that functions are first class objects in python.\nFor flexibility's sake (mostly for parsing commands), I'm thinking of changing my setup such that I'm using getattr(command), to grab the method I need and then passing arguments to it at the end of my parser. Another advantage of this approach is not having to update my (currently statically implemented) command dictionary every time I add a new method\/command. \nMy question is two fold. First, does getattr have the same problems as eval? Second, will I be taking a hit to the efficiency of my shell? Does it matter how many methods\/commands I have? I'm currently looking at 30 some commands, which could eventually double.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6796,"Q_Id":2909423,"Users Score":10,"Answer":"does getattr have the same problems as eval? \n\nNo -- code using eval() is terribly annoying to maintain, and can have serious security problems. Calling getattr(x, \"foo\") is just another way to write x.foo.\n\nwill I be taking a hit to the efficiency of my shell\n\nIt will be imperceptibly slower if the command isn't found, but not enough to matter. You'd only notice it if doing benchmarks, with tens of thousands of entries.","Q_Score":10,"Tags":"python,shell,performance,getattr","A_Id":2909510,"CreationDate":"2010-05-26T00:21:00.000","Title":"Is it bad practice to use python's getattr extensively?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a working QListView, but from the documentation, I can't figure out how to get a signal to fire with the index of the newly selected item. Any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3622,"Q_Id":2911991,"Users Score":1,"Answer":"Imho, an easier way to achieve this would be to use a QListWidget instead of a QListView, this way you could use the itemClicked signal, which sends the selected item to the callback function.","Q_Score":1,"Tags":"python,pyqt4,qlistview","A_Id":2912399,"CreationDate":"2010-05-26T10:16:00.000","Title":"clicked() signal for QListView in PyQt4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For my project I would be using the argparse library. My question is, how do I distribute it with my project. I am asking this because of the technicalities and legalities involved.\nDo I just: \n\nPut the argparse.py file along with\nmy project. That is, in the tar file for my project.\nCreate a package for it for my\ndistro?\nTell the user to install it himself?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":228,"Q_Id":2916116,"Users Score":1,"Answer":"It would be best for the user to install it so that only one copy is present on the system and so that it can be updated if there are any issues, but including it with your project is a viable option if you abide by all requirements specified in the license.\nTry to import it from the public location, and if that fails then resort to using the included module.","Q_Score":2,"Tags":"python,argparse","A_Id":2916155,"CreationDate":"2010-05-26T19:30:00.000","Title":"Distributing a Python library (single file)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm still a bit slow with Python, so I haven't got this figured out beyond what's obviously in the docs, etc. \nI've worked with Django a bit, where they've added some datetime formatting options via template tags, but in regular python code how can I get the 12-hour hour without a leading zero? \nIs there a straightforward way to do this? I'm looking at the 2.5 and 2.6 docs for \"strftime()\" and there doesn't seem to be a formatting option there for this case. \nShould I be using something else? \nFeel free to include any other time-formatting tips that aren't obvious from the docs. =)","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":13086,"Q_Id":2925230,"Users Score":1,"Answer":"I know it's pretty cheap, but you could just discard the first character if it's a zero :)","Q_Score":29,"Tags":"python,datetime,time,formatting","A_Id":2925269,"CreationDate":"2010-05-27T21:48:00.000","Title":"Get \"2:35pm\" instead of \"02:35PM\" from Python date\/time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We're writing a web-based tool to configure our services provided by multiple servers. This includes interfaces configuration, dhcp configs etc. etc.\nHaving configs in database and views that generate proper output, how to send it\/make it available for servers?\nI'm thinking about sending it through scp and invoking reload command to services through ssh. I'm also thinking about using Func to do all the job, as this is Python tool and will seemingly integrate with python-based (django) config tool.\nAny other proposals?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":2932007,"Users Score":0,"Answer":"It really depends what you're intending to do, as the question is a little vague.  The other answers cover the tools available; choosing one over the other comes down to purpose.\nAre you intending to manage servers, and services on those servers?  If so, try Puppet, CFEngine, or some other tool for managing server configurations.\nOr, more specifically, are you looking for a deployment\/buildout tool that talks to servers?  So that you can type in something along the lines of \"mytool deploy myproject\", and have your project propagate to all the servers?  In which case, fabric would be the tool to use.\nGenerally a good configuration will consist of both anyway... but for what it's worth, from the sound of it (managing DHCP\/network\/etc.), Puppet's the way to go.","Q_Score":0,"Tags":"python,linux,administration,func","A_Id":3130135,"CreationDate":"2010-05-28T19:46:00.000","Title":"Methods of sending web-generated config files to servers and restarting services","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was playing with Goole App Engine Task Queue API to learn how to use it. But I couldn't make it trigger locally. My application is working like a charm when I upload to Google servers. But it doesn't trigger locally. All I see from the admin is the list of the tasks. But when their ETA comes, they just pass it. It's like they runs but they fails and waiting for the retries. But I can't see these events on command line.\nWhen I try to click \"Run\" on admin panel, it runs successfuly and I can see these requests from the command line. I'm using App Engine SDK 1.3.4 on Linux with google-app-engine-django. I'm trying to find the problem from 3 hours now and I couldn't find it. It's also very hard to debug GAE applications. Because debug messages do not appear on console screen.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":2935631,"Users Score":1,"Answer":"The development server won't run tasks automatically, you have to set them off yourself.\nIt's a design feature, so you can see what happens when you run them, instead of them running at any point.\nEssentially, there's nothing wrong with your application, it's a feature of development server.","Q_Score":1,"Tags":"python,google-app-engine,task-queue","A_Id":2935659,"CreationDate":"2010-05-29T15:35:00.000","Title":"Task Queue stopped working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to prevent multiple instances of the same long-running python command-line script from running at the same time, and I'd like the new instance to be able to send data to the original instance before the new instance commits suicide.  How can I do this in a cross-platform way?\nSpecifically, I'd like to enable the following behavior:\n\n\"foo.py\" is launched from the command line, and it will stay running for a long time-- days or weeks until the machine is rebooted or the parent process kills it.\nevery few minutes the same script is launched again, but with different command-line parameters\nwhen launched, the script should see if any other instances are running.\nif other instances are running, then instance #2 should send its command-line parameters to instance #1, and then instance #2 should exit.\ninstance #1, if it receives command-line parameters from another script, should spin up a new thread and (using the command-line parameters sent in the step above) start performing the work that instance #2 was going to perform.\n\nSo I'm looking for two things: how can a python program know another instance of itself is running, and then how can one python command-line program communicate with another?\nMaking this more complicated, the same script needs to run on both Windows and Linux, so ideally the solution would use only the Python standard library and not any OS-specific calls. Although if I need to have a Windows codepath and an *nix codepath (and a big if statement in my code to choose one or the other), that's OK if a \"same code\" solution isn't possible.\nI realize I could probably work out a file-based approach (e.g. instance #1 watches a directory for changes and each instance drops a file into that directory when it wants to do work) but I'm a little concerned about cleaning up those files after a non-graceful machine shutdown. I'd ideally be able to use an in-memory solution. But again I'm flexible, if a persistent-file-based approach is the only way to do it, I'm open to that option.\nMore details: I'm trying to do this because our servers are using a monitoring tool which supports running python scripts to collect monitoring data (e.g. results of a database query or web service call) which the monitoring tool then indexes for later use.  Some of these scripts are very expensive to start up but cheap to run after startup (e.g. making a DB connection vs. running a query). So we've chosen to keep them running in an infinite loop until the parent process kills them. \nThis works great, but on larger servers 100 instances of the same script may be running, even if they're only gathering data every 20 minutes each. This wreaks havoc with RAM, DB connection limits, etc. We want to switch from 100 processes with 1 thread to one process with 100 threads, each executing the work that, previously, one script was doing. \nBut changing how the scripts are invoked by the monitoring tool is not possible. We need to keep invocation the same (launch a process with different command-line parameters) but but change the scripts to recognize that another one is active, and have the \"new\" script send its work instructions (from the command line params) over to the \"old\" script.\nBTW, this is not something I want to do on a one-script basis. Instead, I want to package this behavior into a library which many script authors can leverage-- my goal is to enable script authors to write simple, single-threaded scripts which are unaware of multi-instance issues, and to handle the multi-threading and single-instancing under the covers.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3867,"Q_Id":2935836,"Users Score":1,"Answer":"Perhaps try using sockets for communication?","Q_Score":14,"Tags":"python,multithreading,command-line,ipc,interprocess","A_Id":2935858,"CreationDate":"2010-05-29T16:46:00.000","Title":"can a python script know that another instance of the same script is running... and then talk to it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to prevent multiple instances of the same long-running python command-line script from running at the same time, and I'd like the new instance to be able to send data to the original instance before the new instance commits suicide.  How can I do this in a cross-platform way?\nSpecifically, I'd like to enable the following behavior:\n\n\"foo.py\" is launched from the command line, and it will stay running for a long time-- days or weeks until the machine is rebooted or the parent process kills it.\nevery few minutes the same script is launched again, but with different command-line parameters\nwhen launched, the script should see if any other instances are running.\nif other instances are running, then instance #2 should send its command-line parameters to instance #1, and then instance #2 should exit.\ninstance #1, if it receives command-line parameters from another script, should spin up a new thread and (using the command-line parameters sent in the step above) start performing the work that instance #2 was going to perform.\n\nSo I'm looking for two things: how can a python program know another instance of itself is running, and then how can one python command-line program communicate with another?\nMaking this more complicated, the same script needs to run on both Windows and Linux, so ideally the solution would use only the Python standard library and not any OS-specific calls. Although if I need to have a Windows codepath and an *nix codepath (and a big if statement in my code to choose one or the other), that's OK if a \"same code\" solution isn't possible.\nI realize I could probably work out a file-based approach (e.g. instance #1 watches a directory for changes and each instance drops a file into that directory when it wants to do work) but I'm a little concerned about cleaning up those files after a non-graceful machine shutdown. I'd ideally be able to use an in-memory solution. But again I'm flexible, if a persistent-file-based approach is the only way to do it, I'm open to that option.\nMore details: I'm trying to do this because our servers are using a monitoring tool which supports running python scripts to collect monitoring data (e.g. results of a database query or web service call) which the monitoring tool then indexes for later use.  Some of these scripts are very expensive to start up but cheap to run after startup (e.g. making a DB connection vs. running a query). So we've chosen to keep them running in an infinite loop until the parent process kills them. \nThis works great, but on larger servers 100 instances of the same script may be running, even if they're only gathering data every 20 minutes each. This wreaks havoc with RAM, DB connection limits, etc. We want to switch from 100 processes with 1 thread to one process with 100 threads, each executing the work that, previously, one script was doing. \nBut changing how the scripts are invoked by the monitoring tool is not possible. We need to keep invocation the same (launch a process with different command-line parameters) but but change the scripts to recognize that another one is active, and have the \"new\" script send its work instructions (from the command line params) over to the \"old\" script.\nBTW, this is not something I want to do on a one-script basis. Instead, I want to package this behavior into a library which many script authors can leverage-- my goal is to enable script authors to write simple, single-threaded scripts which are unaware of multi-instance issues, and to handle the multi-threading and single-instancing under the covers.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3867,"Q_Id":2935836,"Users Score":0,"Answer":"Sounds like your best bet is sticking with a pid file but have it not only contain the process Id - have it also include the port number that the prior instance is listening on.  So when starting up check for the pid file and if present see if a process with that Id is running - if so send your data to it and quit otherwise overwrite the pid file with the current process's info.","Q_Score":14,"Tags":"python,multithreading,command-line,ipc,interprocess","A_Id":2936096,"CreationDate":"2010-05-29T16:46:00.000","Title":"can a python script know that another instance of the same script is running... and then talk to it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing\/averaging + additional transformations) over observations\/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to \n\nwrite the whole thing in C (or\nFortran)\nimport the files (tables) into a\nrelational database directly and\nthen pull off chunks in R or Python\n(some of the transformations are not\namenable for pure SQL solutions)\nwrite the whole thing in Python\n\nWould (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I\/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks\nEdit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":5360,"Q_Id":2937619,"Users Score":2,"Answer":"When you say \"accumulating\" then solution (2) looks most suitable to problem.\nAfter initial load up to database you only update database with new files (daily, weekly? depends how often you need this).\nIn cases (1) and (3) you need to process files each time (what was stated earlier as most time\/resources-consuming), unless you find a way to stored results and update them with new files.\nYou could use R to process files from csv to, for example, SQLite database.","Q_Score":32,"Tags":"python,sql,r,large-files,large-data-volumes","A_Id":2942419,"CreationDate":"2010-05-30T05:06:00.000","Title":"large amount of data in many text files - how to process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing\/averaging + additional transformations) over observations\/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to \n\nwrite the whole thing in C (or\nFortran)\nimport the files (tables) into a\nrelational database directly and\nthen pull off chunks in R or Python\n(some of the transformations are not\namenable for pure SQL solutions)\nwrite the whole thing in Python\n\nWould (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I\/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks\nEdit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","AnswerCount":8,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":5360,"Q_Id":2937619,"Users Score":4,"Answer":"With terabytes, you will want to parallelize your reads over many disks anyway; so might as well go straight into Hadoop.\nUse Pig or Hive to query the data; both have extensive support for user-defined transformations, so you should be able to implement what you need to do using custom code.","Q_Score":32,"Tags":"python,sql,r,large-files,large-data-volumes","A_Id":2937664,"CreationDate":"2010-05-30T05:06:00.000","Title":"large amount of data in many text files - how to process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing\/averaging + additional transformations) over observations\/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to \n\nwrite the whole thing in C (or\nFortran)\nimport the files (tables) into a\nrelational database directly and\nthen pull off chunks in R or Python\n(some of the transformations are not\namenable for pure SQL solutions)\nwrite the whole thing in Python\n\nWould (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I\/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks\nEdit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":5360,"Q_Id":2937619,"Users Score":1,"Answer":"Yes. You are right! I\/O would cost most of your processing time. I don't suggest you to use distributed systems, like hadoop, for this task. \nYour task could be done in a modest workstation. I am not an Python expert, I think it has support for asynchronous programming. In F#\/.Net, the platform has well support for that. I was once doing an image processing job, loading 20K images on disk and transform them into feature vectors only costs several minutes in parallel. \nall in all, load and process your data in parallel and save the result in memory (if small), in database (if big).","Q_Score":32,"Tags":"python,sql,r,large-files,large-data-volumes","A_Id":2937660,"CreationDate":"2010-05-30T05:06:00.000","Title":"large amount of data in many text files - how to process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing\/averaging + additional transformations) over observations\/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to \n\nwrite the whole thing in C (or\nFortran)\nimport the files (tables) into a\nrelational database directly and\nthen pull off chunks in R or Python\n(some of the transformations are not\namenable for pure SQL solutions)\nwrite the whole thing in Python\n\nWould (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I\/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks\nEdit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","AnswerCount":8,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":5360,"Q_Id":2937619,"Users Score":14,"Answer":"(3) is not necessarily a bad idea -- Python makes it easy to process \"CSV\" file (and despite the C standing for Comma, tab as a separator is just as easy to handle) and of course gets just about as much bandwidth in I\/O ops as any other language.  As for other recommendations, numpy, besides fast computation (which you may not need as per your statements) provides very handy, flexible multi-dimensional arrays, which may be quite handy for your tasks; and the standard library module multiprocessing lets you exploit multiple cores for any task that's easy to parallelize (important since just about every machine these days has multi-cores;-).","Q_Score":32,"Tags":"python,sql,r,large-files,large-data-volumes","A_Id":2937630,"CreationDate":"2010-05-30T05:06:00.000","Title":"large amount of data in many text files - how to process?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I bumped into a case where I need a big (=huge) python dictionary, which turned to be quite memory-consuming.\nHowever, since all of the values are of a single type (long) - as well as the keys,  I figured I can use python (or numpy, doesn't really matter) array for the values ; and wrap the needed interface (in: x ; out: d[x]) with an object which actually uses these arrays for the keys and values storage.\nI can use a index-conversion object (input --> index, of 1..n, where n is the different-values counter), and return array[index]. I can elaborate on some techniques of how to implement such an indexing-methods with reasonable memory requirement, it works and even pretty good. \nHowever, I wonder if there is such a data-structure-object already exists (in python, or wrapped to python from C\/++), in any package (I checked collections, and some Google searches).\nAny comment will be welcome, thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1303,"Q_Id":2942375,"Users Score":0,"Answer":"You might try using std::map. Boost.Python provides a Python wrapping for std::map out-of-the-box.","Q_Score":3,"Tags":"python,arrays,data-structures,dictionary","A_Id":2943067,"CreationDate":"2010-05-31T08:47:00.000","Title":"python dictionary with constant value-type","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"lets say you run third party program on your computer whitch create a process named example.exe\nhow do i determinate if this process is running and how many windows does he open? How do i intercept network communication between this windows and server?\nmy goal is to create an app whitch will be monitoring network trafic between example.exe and its home server in order to analyze data and save to database, and finally simulate user interaction to get more relevant data","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":620,"Q_Id":2945074,"Users Score":0,"Answer":"You could use wireshark from wireshark.org to sniff the network traffic (or any other packet sniffer).","Q_Score":2,"Tags":"python,networking,communication","A_Id":2945291,"CreationDate":"2010-05-31T17:30:00.000","Title":"python intercepting communication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a word that will be putted on a image but the problem is that the word continues even though the word exceeds the width of the image\nis there anyway that the word shift's down if the word exceeds the width of the image or on a certain point the word shift's down if it exceeds the given point","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1435,"Q_Id":2947049,"Users Score":6,"Answer":"PIL won't automatically do this, but you could easily do it yourself using the getsize method in the ImageFont module.  That is, if the text is too big, just split it so that it's not, and put the rest on the next line.  (You may want to do this recursively in case the text spans multiple lines.)","Q_Score":2,"Tags":"python-imaging-library","A_Id":7326477,"CreationDate":"2010-06-01T02:54:00.000","Title":"python imaging library draw text new line how to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's my background:\nDecent experience with PHP\/MySql. \nBeginner's experience with OOP\n\nWhy I want to learn Python Django?\nI gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes that are shorter than with PHP\nQuestions\n\nCan i do everything in Django as in PHP? \nIs Django a \"big\" hit in web development as PHP? I know Python is a\ngreat general-purpose language but I'm\nfocused on web development and would\nlike to know how Django ranks in terms\nof web development.\nWith PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql? \nIn PHP, you can easily switch between HTML, CSS, PHP all in one script. Does Python offer this type of ease between other languages? Or how do I incorporate HTML, CSS, javascript along with Python?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3852,"Q_Id":2961402,"Users Score":1,"Answer":"No. You can only do a LOT better.\nAwesome, popular. Supported by best hosters like Mediatemple.\nNo. You can just change 'mysql' to 'postgresql' or 'sqlite' in your settings.py.\nNO! Python would never give you the right to mix up everything in one file and make the shittest shit in the world. Templates, static server.\n\nDjango is a Model-Template-View framework, great for any applications, from small to huge. PHP works fine only with small apps. Yeah, PHP == Personal Home Page, lol.\nP.S. Also you can minify your CSS and JS. And compile to one single file (one js, one css). All with django-assets. And yeah, there's a lot more reusable Django apps (for registration, twi\/facebook\/openid auth, oembed, other stuff). Just search Bitbucket and Github for \"django\". No need to reinvent a bicycle, like you do with PHP.","Q_Score":4,"Tags":"php,python,django","A_Id":2961525,"CreationDate":"2010-06-02T20:36:00.000","Title":"How to transition from PHP to Python Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's my background:\nDecent experience with PHP\/MySql. \nBeginner's experience with OOP\n\nWhy I want to learn Python Django?\nI gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes that are shorter than with PHP\nQuestions\n\nCan i do everything in Django as in PHP? \nIs Django a \"big\" hit in web development as PHP? I know Python is a\ngreat general-purpose language but I'm\nfocused on web development and would\nlike to know how Django ranks in terms\nof web development.\nWith PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql? \nIn PHP, you can easily switch between HTML, CSS, PHP all in one script. Does Python offer this type of ease between other languages? Or how do I incorporate HTML, CSS, javascript along with Python?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3852,"Q_Id":2961402,"Users Score":6,"Answer":"Can i do everything in Django as in PHP?\n\nAlways\n\nIs Django a \"big\" hit in web development as PHP?\n\nOnly time will tell.\n\nWith PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql?\n\nDjango supports several RDBMS interfaces.  MySQL is popular, so is SQLite and Postgres.\n\nIn PHP, you can easily switch between HTML, CSS, PHP all in one script.\n\nThat doesn't really apply at all to Django.\n\nOr how do I incorporate HTML, CSS, javascript along with Python?\n\nActually do the Django tutorial.  You'll see how the presentation (via HTML created by templates) and the processing (via Python view functions) fit together.  It's not like PHP.","Q_Score":4,"Tags":"php,python,django","A_Id":2961490,"CreationDate":"2010-06-02T20:36:00.000","Title":"How to transition from PHP to Python Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to start learning OpenGL but I don't really want to have to learn another language to do it. I already am pretty proficient in python and enjoy the language. I just want to know how close it is to the regular api? Will I be able to pretty easily follow tutorials and books without too much trouble?\nI know C++ gives better performance, but for just learning can I go wrong with PyOpenGL?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3573,"Q_Id":2962571,"Users Score":13,"Answer":"With the caveat that I have done very little OpenGL programming myself, I believe that for the purposes of learning, PyOpenGL is a good choice.  The main reason is that PyOpenGL, like most other OpenGL wrappers, is just that: a thin wrapper around the OpenGL API. \nOne large benefit of PyOpenGL is that while in C you have to worry about calling the proper glVertex3{dfiX} command, Python allows you to just write glVertex3(x,y,z) without worrying about telling Python what type of argument you passed in.  That might not sound like a big deal, but it's often much simpler to use Python's duck-typing instead of being overly concerned with static typing.\nThe OpenGL methods are almost completely all wrapped into Python methods, so while you'll be writing in Python, the algorithms and method calls you'll use are identical to writing OpenGL in any other language.  But since you're writing in Python, you'll have many fewer opportunities to make \"silly\" mistakes with proper pointer usage, memory management, etc. that would just eat up your time if you were to study the API in C or C++, for instance.","Q_Score":9,"Tags":"python,graphics,pyopengl","A_Id":2962599,"CreationDate":"2010-06-03T00:28:00.000","Title":"Is PyOpenGL a good place to start learning opengl programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to start learning OpenGL but I don't really want to have to learn another language to do it. I already am pretty proficient in python and enjoy the language. I just want to know how close it is to the regular api? Will I be able to pretty easily follow tutorials and books without too much trouble?\nI know C++ gives better performance, but for just learning can I go wrong with PyOpenGL?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3573,"Q_Id":2962571,"Users Score":0,"Answer":"PyOpenGL\n\nI don't think it is a good choice. In my opinon in C\/C++ it is easier to play around around with your OpenGL code - start with simple app, then add shader, then add some geometry functions, make a texture\/geometry generator, build scene via CSG, etc. You know - to have fun, play around with code, experiment and learn something in process. I honestly just don't see myself doing this in python. Surely it is possible to do OpenGL programming in Python, but I see no reason to actually do it. Plus several OpenGL functions take memory pointers as arguments, and although there probably a class (or dozen of alternatives) for that case, I don't see a reason to use them when a traditional way of doing things is available in C\/C++, especially when I think about amount of wrappers python code uses to pass vector or array of those into OpenGL function. It just looks like making things more complicated without a real reason to do that. Plus there is a noticeable performance drop, especially when you use \"RAW\" OpenGL.\nBesides, if you're going to make games, it is very likely that you'll have to use C++ or some other \"non-python\" language.\nP.S. I've done enough OpenGL programming, a lot of DirectX programming, but I specialize on C++, and use python only for certain algorithmic tests, tools and scripts.","Q_Score":9,"Tags":"python,graphics,pyopengl","A_Id":2963034,"CreationDate":"2010-06-03T00:28:00.000","Title":"Is PyOpenGL a good place to start learning opengl programming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone point me to some documentation on how to write scripts in Python (or Perl or any other Linux friendly script language) that generate C++ code from XML or py files from the command line.  I'd like to be able to write up some xml files and then run a shell command that reads these files and generates .h files with fully inlined functions, e.g. streaming operators, constructors, etc.","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":23299,"Q_Id":2966618,"Users Score":1,"Answer":"A few years ago I worked on a project to simplify interprocess shared memory management for large scale simulation systems. We used a related approach where the layout of data in shared memory was defined in XML files and a code generator, written in python, read the XML and spit out a set of header files defining structures and associated functions\/operators\/etc to match the XML description. At the time, I looked at several templating engines and, to my surprise, found it was easier and very straight-forward to just do it \"by hand\".\nAs you read the XML, just populate a set of data structures that match your code. Header file objects contain classes and classes contain variables (which may be of other class types). Give each object a printSelf() method that iterates over its contents and calls printSelf() for each object it contains.\nIt seems a little daunting at first but once you get started, it's pretty straight-forward. Oh, and one tip that helps with the generated code, add an indentation argument to printSelf() and increase it at each level. It makes the generated code much easier to read.","Q_Score":12,"Tags":"c++,python,code-generation","A_Id":2966999,"CreationDate":"2010-06-03T13:57:00.000","Title":"C++ code generation with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am streaming some data down from a webcam. When I get all of the bytes for a full image (in a string called byteString) I want to display the image using OpenCV. Done fast enough, this will \"stream\" video from the webcam to an OpenCV window.\nHere's what I've done to set up the window:\ncvNamedWindow('name of window', CV_WINDOW_AUTOSIZE)\nAnd here's what I do when the byte string is complete:\nimg = cvCreateImage(IMG_SIZE,PIXEL_DEPTH,CHANNELS)\nbuf = ctypes.create_string_buffer(byteString)\nimg.imageData = ctypes.cast(buf, ctypes.POINTER(ctypes.c_byte))\ncvShowImage('name of window', img)\ncvWaitKey(0)\nFor some reason this is producing an error:\nFile \"C:\\Python26\\lib\\site-packages\\ctypes_opencv\\highgui_win32.py\", line 226, in execute\n     return func(*args, **kwargs)\nWindowsError: exception: access violation reading 0x015399E8\nDoes anybody know how to do what I'm trying to do \/ how to fix this crazy violation error?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1712,"Q_Id":2970207,"Users Score":2,"Answer":"I actually solved this problem and forgot to post the solution. Here's how I did it, though it may not be entirely robust:\nI analyzed the headers coming from the MJPEG of the network camera I was doing this to, then I just read from the stream 1 byte at a time, and, when I detected that the header of the next image was also in the bytestring, I cut the last 42 bytes off (since that's the length of the header).\nThen I had the bytes of the JPEG, so I simply created a new Cv Image by using the open(...) method and passing it the byte string wrapped in a StringIO class.","Q_Score":3,"Tags":"python,string,image,opencv,byte","A_Id":2980849,"CreationDate":"2010-06-03T22:20:00.000","Title":"from string of bytes to OpenCV's IplImage in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i've a small user defined function in python, say fib(n), how do i use that in other programs or modules?\ndef fib(n):\nshould i use import or is there any other feature?\nAlso i'm learning python in eclipse IDE, it wont support\n\nprint \"any string\"\n\nbut i'm forced to use like, \nprint(\"string\") \nin python manual online, its given its cross platform and same syntax, but why like above?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":2975473,"Users Score":2,"Answer":"You use import to include the function in other programs. Just say import mymodule where the code is located in file mymodule.py. Then say mymodule.fib to use the function.\nTo answer your second question: The syntax print \"any string\" is acceptable in Python 2, but is no longer allowed in Python 3.","Q_Score":0,"Tags":"python,import,cross-platform","A_Id":2975495,"CreationDate":"2010-06-04T15:19:00.000","Title":"include udf in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I wonder if it is better add an element by opening file, search 'good place' and add string which contains xml code.\nOr use some library... i have no idea. I know how can i get nodes and properties from xml through for example lxml but what's the simpliest and the best way to add?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4733,"Q_Id":2977779,"Users Score":1,"Answer":"The safest way to add nodes to an XML document is to load it into a DOM, add the nodes programmatically and write it out again. There are several Python XML libraries. I have used minidom, but I have no reason to recommend it specifically over the others.","Q_Score":4,"Tags":"python,xml","A_Id":2977799,"CreationDate":"2010-06-04T21:01:00.000","Title":"add xml node to xml file with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a dense set of points in the plane. I want them colored so that points that are close to each other have the same color, and a different color if they're far away. For simplicity assume that there are, say, 5 different colors to choose from. Turns out I've not the slightest idea how to do that ..\nI'm using Tkinter with Python, by the way","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":2979697,"Users Score":0,"Answer":"I'd start with identifying the concentrations of the spots in the plane. Find the centers of those agglomerations and assign them each unique color. Then for other spots you could simply calculate the color using the linear principle. For example, if one center is red and the other is yellow, a point somewhere in the middle would become orange.\nI'd probably use some exponential function instead of a linear principle. This will keep the point groups more or less of the same color only giving a noticeable color change to far away points, or, to be more exact, to far away and somewhere in between points.","Q_Score":4,"Tags":"python,geometry,tkinter","A_Id":2979705,"CreationDate":"2010-06-05T08:31:00.000","Title":"Coloring close points","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dense set of points in the plane. I want them colored so that points that are close to each other have the same color, and a different color if they're far away. For simplicity assume that there are, say, 5 different colors to choose from. Turns out I've not the slightest idea how to do that ..\nI'm using Tkinter with Python, by the way","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":270,"Q_Id":2979697,"Users Score":0,"Answer":"One approach is to go through your points and partition them into sets with a \"center\". Since you have 5 colours, you'll have 5 sets. You compare the distance of the new point from each of the centers and then put it in the same group as the closest one.\nEach set corresponds to a different colour so you can just plot it after this partitioning is done.","Q_Score":4,"Tags":"python,geometry,tkinter","A_Id":2979707,"CreationDate":"2010-06-05T08:31:00.000","Title":"Coloring close points","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"just a quick question, how to add percent sign to numbers without modifying number. I have tried format percent with myStyleFont.num_format_str = '0.00%' but it multiplies with 100 but I need just to append percent.\nTy in advance.\nRegards.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":5708,"Q_Id":2985678,"Users Score":1,"Answer":"The 00.0% number format expects percentages, so multiplying by 100 to display it is the correct behavior.  To get the results you want, you could either put the data in the cell as a string in whatever format you choose or you could divide by 100.0 before you store the value in the cell.","Q_Score":2,"Tags":"python,xlwt,pyexcelerator","A_Id":2985689,"CreationDate":"2010-06-06T19:53:00.000","Title":"Adding percentage in python - xlwt \/ pyexcelerator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"just a quick question, how to add percent sign to numbers without modifying number. I have tried format percent with myStyleFont.num_format_str = '0.00%' but it multiplies with 100 but I need just to append percent.\nTy in advance.\nRegards.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5708,"Q_Id":2985678,"Users Score":5,"Answer":"Note carefully: \"modifying\" and \"multiplies with 100\" affect the displayed result, they  affect neither the value stored in the file nor the value used in formula calculations.\nThe technique of making an operator be treated as a literal is known as \"escaping\".\nThe escape character in Excel number format strings is the backslash.\nTo do what you want, your format should be r\"0.00\\%\" or \"0.00\\\\%\"\nThe above is a property of Excel, not restricted to Python or xlwt etc. You can test this using one of the UIs (Excel, OpenOffice Calc, Gnumeric).\nNote that unless you have a restricted set of users who will read and understand the documentation that you will write [unlikely * 3], you shouldn't do that; it will be rather confusing -- the normal Excel user on seeing 5.00% assumes that the underlying number is 0.05. To see this, in Excel etc type these into A1, A2, A3: 5% then .05 then =A1=A2 ... you will see TRUE in A3.\npyExcelerator is abandonware; why do you mention it???\nAbout myStyleFont.num_format_str = '0.00%' (1) \"font\" and \"num_format_str\" are quite independent components of a style aka XF; your variable name \"myStyleFont\" is confused\/confusing. (2) Setting up XFs by poking attributes into objects is old hat in xlwt; use easyxf instead.","Q_Score":2,"Tags":"python,xlwt,pyexcelerator","A_Id":2986184,"CreationDate":"2010-06-06T19:53:00.000","Title":"Adding percentage in python - xlwt \/ pyexcelerator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to integration local user and openid(or facebook twitter) user ,\ndid you know some framework have already done this ,\nupdated\nmy mean is : how to deal with 'local user' and 'openid user',\nand how to mix them in one model .\nplease give me a framework  that realize  'local user' and 'openid user'","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":264,"Q_Id":2986766,"Users Score":1,"Answer":"I understand your question.\nYou wish to be able to maintain a list of users that have signed up with your service, and also want to record users using OpenID to authenticate.\nIn order to solve this I would do either of the following:\n\nCreate a new user in your users table for each new user logged in under OpenID, and store their OpenID in this table to allow you to join the two.\nMove your site to OpenID and change all references to your current users to OpenID users.\n\nI'd probably go with Option 1 if you already have this app in production.\nNote: More experienced Open ID users will probably correct me!","Q_Score":0,"Tags":"python,google-app-engine,openid,integration","A_Id":2988807,"CreationDate":"2010-06-07T02:24:00.000","Title":"what should i do after openid (or twitter ,facebook) user login my site ,on gae","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Can anyone tell me how can I do this?","AnswerCount":14,"Available Count":1,"Score":0.0142847425,"is_accepted":false,"ViewCount":190751,"Q_Id":2988211,"Users Score":1,"Answer":"You should try f.read(1), which is definitely correct and the right thing to do.","Q_Score":90,"Tags":"python,file-io,character","A_Id":2988272,"CreationDate":"2010-06-07T09:11:00.000","Title":"How to read a single character at a time from a file in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a datastore with around 1,000,000 entities in a model. I want to fetch 10 random entities from this. \nI am not sure how to do this? can someone help?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5002,"Q_Id":3002999,"Users Score":23,"Answer":"Assign each entity a random number and store it in the entity. Then query for ten records whose random number is greater than (or less than) some other random number.\nThis isn't totally random, however, since entities with nearby random numbers will tend to show up together. If you want to beat this, do ten queries based around ten random numbers, but this will be less efficient.","Q_Score":21,"Tags":"python,google-app-engine,google-cloud-datastore","A_Id":3003170,"CreationDate":"2010-06-09T03:55:00.000","Title":"Fetching a random record from the Google App Engine Datastore?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I make a simple clipboard monitor in Python using the PyGTK GUI?\nI found gtk.clipboard class and but I couldn't find any solution to get the \"signals\" to trigger the event when the clipboard content has changed.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1505,"Q_Id":3005522,"Users Score":4,"Answer":"Without a proper notification API, such as WM_DrawClipboard messages, you would probably have to resort to a polling loop.  And then you will cause major conflicts with other apps that are trying to use this shared resource.\nDo not resort to a polling loop.","Q_Score":6,"Tags":"python,clipboard,pygtk,monitor","A_Id":3010018,"CreationDate":"2010-06-09T11:54:00.000","Title":"PyGTK: how to make a clipboard monitor?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.\nI approximatily need to call this method about 10,000 times.which is making my program very slow?\nany method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?\nI can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...\nthanks in advance","AnswerCount":5,"Available Count":4,"Score":0.1194272985,"is_accepted":false,"ViewCount":209,"Q_Id":3006769,"Users Score":3,"Answer":"As a general strategy, it's best to keep this data in an in-memory cache if it's static, and relatively small. Then, the 10k calls will read an in-memory cache rather than a file. Much faster.\nIf you are modifying the data, the alternative might be a database like SQLite, or embedded MS SQL Server (and there are others, too!).\nIt's not clear what kind of data this is. Is it simple config\/properties data? Sometimes you can find libraries to handle the loading\/manipulation\/storage of this data, and it usually has it's own internal in-memory cache, all you need to do is call one or two functions.\nWithout more information about the files (how big are they?) and the data (how is it formatted and structured?), it's hard to say more.","Q_Score":1,"Tags":"python,optimization","A_Id":3006810,"CreationDate":"2010-06-09T14:28:00.000","Title":"how to speed up the code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.\nI approximatily need to call this method about 10,000 times.which is making my program very slow?\nany method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?\nI can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...\nthanks in advance","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":209,"Q_Id":3006769,"Users Score":2,"Answer":"Opening, closing, and reading a file 10,000 times is always going to be slow.  Can you open the file once, do 10,000 operations on the list, then close the file once?","Q_Score":1,"Tags":"python,optimization","A_Id":3006800,"CreationDate":"2010-06-09T14:28:00.000","Title":"how to speed up the code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.\nI approximatily need to call this method about 10,000 times.which is making my program very slow?\nany method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?\nI can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...\nthanks in advance","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":209,"Q_Id":3006769,"Users Score":0,"Answer":"Call the open to the file from the calling method of the one you want to run. Pass the data as parameters to the method","Q_Score":1,"Tags":"python,optimization","A_Id":3006875,"CreationDate":"2010-06-09T14:28:00.000","Title":"how to speed up the code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation.\nI approximatily need to call this method about 10,000 times.which is making my program very slow?\nany method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list?\nI can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question...\nthanks in advance","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":209,"Q_Id":3006769,"Users Score":0,"Answer":"If the files are structured, kinda configuration files, it might be good to use ConfigParser library, else if you have other structural format then I think it would be better to store all this data in JSON or XML and perform any necessary operations on your data","Q_Score":1,"Tags":"python,optimization","A_Id":3006895,"CreationDate":"2010-06-09T14:28:00.000","Title":"how to speed up the code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"i want to speed my code compilation..I have searched the internet and heard that psyco is a very tool to improve the speed.i have searched but could get a site for download.\ni have installed any additional libraries or modules till date in my python..\ncan psyco user,tell where we can download the psyco and its installation and using procedures??\ni use windows vista and python 2.6 does this work on this ??","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1091,"Q_Id":3007678,"Users Score":2,"Answer":"So it seems you don't want to speed up the compile but want to speed up the execution.\nIf that is the case, my mantra is \"do less.\"  Save off results and keep them around, don't re-read the same file(s) over and over again.  Read a lot of data out of the file at once and work with it.\nOn files specifically, your performance will be pretty miserable if you're reading a little bit of data out of each file and switching between a number of files while doing it.  Just read in each file in completion, one at a time, and then work with them.","Q_Score":0,"Tags":"python,optimization","A_Id":3008037,"CreationDate":"2010-06-09T16:11:00.000","Title":"how to speed up code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i want to make a chat room on gae ,(audio chat)\nhas any framework to do this  ?\nthanks","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":749,"Q_Id":3012661,"Users Score":0,"Answer":"You'll need two things:\nA browser plugin to get audio. You could build this on top of eg. http:\/\/code.google.com\/p\/libjingle\/'>libjingle which has the advantage of being cross-platform and allowing P2P communication, not to mention being able to talk to arbitrary other XMPP endoints. Or you could use Flash to grab the audio and bounce the stream off a server you build (I think trying to do STUN in Flash for P2P would be impossible), but this would be very tricky to do in App Engine because you'd need it to be long-running.\nA way to get signaling messages between your clients. You'll have to poll until the Channel API is released (soon).\nThis is a big hairy problem, to put it mildly, but it would be awesome if you did it.","Q_Score":0,"Tags":"python,google-app-engine,audio,chat","A_Id":3020384,"CreationDate":"2010-06-10T08:07:00.000","Title":"how to make a chat room on gae ,has any audio python-framework to do this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i want to make a chat room on gae ,(audio chat)\nhas any framework to do this  ?\nthanks","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":749,"Q_Id":3012661,"Users Score":1,"Answer":"Try Adobe Stratus (it works with p2p connections) and you could use Google App Engine only for exchanging peer ids.","Q_Score":0,"Tags":"python,google-app-engine,audio,chat","A_Id":3080160,"CreationDate":"2010-06-10T08:07:00.000","Title":"how to make a chat room on gae ,has any audio python-framework to do this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i want to make a chat room on gae ,(audio chat)\nhas any framework to do this  ?\nthanks","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":749,"Q_Id":3012661,"Users Score":1,"Answer":"App Engine doesn't directly support audio chat of any sort, and since it's based around a request-response system with (primarily) HTTP requests, you can't implement it yourself.","Q_Score":0,"Tags":"python,google-app-engine,audio,chat","A_Id":3013054,"CreationDate":"2010-06-10T08:07:00.000","Title":"how to make a chat room on gae ,has any audio python-framework to do this?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"im doing a project as part of academic programme.Im doing this in linux platform.here i wanted to create a application which retrieve some information from some pdf files .for eg i have  pdfs of subject2,subject1,in both the whole pdf is divided in to 4 modules and i want to get the data of module 1 from pdf..for this purpose my tutor told me to use pdftohtml application and convert pdf files to html and jpeg images.now i want to create a Python script which will combine the pages(which have been coverted in to jpeg images) under module 1 and merge it into a single file and then i will convert it back to pdf . how can i do this?.if anyone can  provide any such python script which have done any functions similar to this then it will be very helpful.\n....\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":634,"Q_Id":3013134,"Users Score":2,"Answer":"Not exactly knowing what you mean my sequence - ImageMagick, esp. its 'montage' is probably the tool you need. IM has python interface, too, altough I have never used it. \nEDIT: As after your edit I do not get the point of this any more, I cannot recommend anything, either. :(","Q_Score":1,"Tags":"python,linux,pdf,merge,jpeg","A_Id":3013162,"CreationDate":"2010-06-10T09:21:00.000","Title":"Sequence and merge jpeg images using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a way of programmatically testing a script written with the asyncore Python module. My test consists of launching the script in question -- if a TCP listen socket is opened, the test passes. Otherwise, if the script dies before getting to that point, the test fails.\nThe purpose of this is knowing if a nightly build works (at least up to a point) or not. \nI was thinking the best way to test would be to launch the script in some kind of sandbox wrapper which waits for a socket request. I don't care about actually listening for anything on that port, just intercepting the request and using that as an indication that my test passed.\nI think it would be preferable to intercept the open socket request, rather than polling at set intervals (I hate polling!). But I'm a bit out of my depths as far as how exactly to do this.\nCan I do this with a shell script? Or perhaps I need to override the asyncore module at the Python level?\nThanks in advance,\n- B","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":838,"Q_Id":3014686,"Users Score":0,"Answer":"Another option is to mock the socket module before importing the asyncore module. Of course, then you have to make sure that the mock works properly first.","Q_Score":0,"Tags":"python,testing,sockets,wrapper","A_Id":3019494,"CreationDate":"2010-06-10T13:19:00.000","Title":"How can I build a wrapper to wait for listening on a port?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on Enterprise Search and we are using Fast ESP and for now i have 4 projects but i have no information about stages and python. But i realize that i have learn custom stage development. Because we have a lot of difficulties about document processing. I want to know how can i develop custom stage and especially i wanna know about how i can find  Attributefilter stage source code. I am waiting your answers","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":816,"Q_Id":3015874,"Users Score":0,"Answer":"The FAST documentation (ESP Document Processor Integration Guide) has a pretty good example of how to write a custom document processor.  FAST does not provide the source code to any of it's software, but the AttributeFilter stage functionality should be very straightforward.","Q_Score":0,"Tags":"python,stage,fast-esp","A_Id":3421127,"CreationDate":"2010-06-10T15:31:00.000","Title":"Fast Esp Custom Stage Development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on Enterprise Search and we are using Fast ESP and for now i have 4 projects but i have no information about stages and python. But i realize that i have learn custom stage development. Because we have a lot of difficulties about document processing. I want to know how can i develop custom stage and especially i wanna know about how i can find  Attributefilter stage source code. I am waiting your answers","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":816,"Q_Id":3015874,"Users Score":0,"Answer":"I had worked with FAST ESP for document processing and we used to modify the python files. you can modify them but you need to restart the document processor each time you modify any file. You need to search for document processing in the admin UI, there you go to the pipelines, and you can create a custom pipeline based on standard pipelines included in FAST ESP. Once you create your pipeline, then you can select the stage (python program) that you want to modify and the UI shows you the path of each script. I highly recommend you to create your custom stages for each pipeline you modify.","Q_Score":0,"Tags":"python,stage,fast-esp","A_Id":47027134,"CreationDate":"2010-06-10T15:31:00.000","Title":"Fast Esp Custom Stage Development","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to make a python script portable to both linux and windows? \nOne problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux?\nAre there other problems besides shebang that I should know?\nIs the solution same for perl script?\nThanks and regards!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":5770,"Q_Id":3020267,"Users Score":2,"Answer":"The shebang line will be interpreted as a comment by Perl or Python. The only thing that assigns it a special meaning is the UNIX\/Linux shell; it gets ignored on Windows. The way Windows knows which interpreter to use to run the file is through the file associations in the registry, a different mechanism altogether.","Q_Score":11,"Tags":"python,perl,scripting,cross-platform,shebang","A_Id":3020285,"CreationDate":"2010-06-11T04:53:00.000","Title":"how to make a python or perl script portable to both linux and windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to make a python script portable to both linux and windows? \nOne problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux?\nAre there other problems besides shebang that I should know?\nIs the solution same for perl script?\nThanks and regards!","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5770,"Q_Id":3020267,"Users Score":14,"Answer":"Windows will just ignore the shebang (which is, after all, a comment); in Windows you need to associate the .py extension to the Python executable in the registry, but you can perfectly well leave the shebang on, it will be perfectly innocuous there.\nThere are many bits and pieces which are platform-specific (many only exist on Unix, msvcrt only on Windows) so if you want to be portable you should abstain from those; some are subtly different (such as the detailed precise behavior of subprocess.Popen or mmap) -- it's all pretty advanced stuff and the docs will guide you there.  If you're executing (via subprocess or otherwise) external commands you'd better make sure they exist on both platforms, of course, or check what platform you're in and use different external commands in each case.\nRemember to always use \/, not \\, as path separator (forward slash works in both platforms, backwards slash is windows-only), and be meticulous as to whether each file you're opening is binary or text.\nI think that's about it...","Q_Score":11,"Tags":"python,perl,scripting,cross-platform,shebang","A_Id":3020286,"CreationDate":"2010-06-11T04:53:00.000","Title":"how to make a python or perl script portable to both linux and windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i send an xml file on my system to an http server using python standard library??","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5264,"Q_Id":3020979,"Users Score":1,"Answer":"You can achieve that through a standard http post request.","Q_Score":7,"Tags":"python,xml,http","A_Id":3021000,"CreationDate":"2010-06-11T07:35:00.000","Title":"send xml file to http using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is a general question, or perhaps a request for pointers to other open source projects to look at:\nI'm wondering how people merge an anonymous user's session data into the authenticated user data when a user logs in. For example, someone is browsing around your websites saving various items as favourites. He's not logged in, so they're saved to an anonymous user's data. Then he logs in, and we need to merge all that data into their (possibly existing) user data.\nIs this done different ways in an ad-hoc fashion for different applications? Or are there some best practices or other projects people can direct me to?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":140,"Q_Id":3024191,"Users Score":1,"Answer":"If very much depends on your system ofcourse. But personally I always try to merge the data and immediately store it in the same way as it would be stored as when the user would be logged in.\nSo if you store it in a session for an anonymous user and in the database for any authenticated user. Just merge all data as soon as you login.","Q_Score":0,"Tags":"python,session,e-commerce,web.py","A_Id":3024470,"CreationDate":"2010-06-11T15:44:00.000","Title":"How to merge or copy anonymous session data into user data when user logs in?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded and install a python library, via setup.py , python2.5 setup.py install ...\nnow the version is changed at the source . a newer library is available. originally , i have clone it via mercurial, and install it. right now , i have updated repository. \nhow do i use the newer version ? overwrite the installation ?\nby simply doing setup.py install again ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":3028561,"Users Score":1,"Answer":"Yes, just do setup.py install again.","Q_Score":2,"Tags":"python","A_Id":3028597,"CreationDate":"2010-06-12T11:52:00.000","Title":"Newbie : installing and upgrading python module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a tricky Django problem which didn't occur to me when I was developing it. My Django application allows a user to sign up and store his login credentials for a sites. The Django application basically allows the user to search this other site (by scraping content off it) and returns the result to the user. For each query, it does a couple of queries of the other site. This seemed to work fine but sometimes, the other site slaps me with a CAPTCHA. I've written the code to get the CAPTCHA image and I need to return this to the user so he can type it in but I don't know how.\nMy search request (the query, the username and the password) in my Django application gets passed to a view which in turn calls the backend that does the scraping\/search. When a CAPTCHA is detected, I'd like to raise a client side event or something on those lines and display the CAPTCHA to the user and wait for the user's input so that I can resume my search. I would somehow need to persist my backend object between calls. I've tried pickling it but it doesn't work because I get the Can't pickle 'lock' object error. I don't know to implement this though. Any help\/ideas?\nThanks a ton.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":267,"Q_Id":3031483,"Users Score":2,"Answer":"Something else to remember: You need to maintain a browser session with the remote site so that site knows which CAPTCHA you're trying to solve. Lots of webclients allow you to store your cookies and I'd suggest you dump them in the Django Session of the user you're doing the screen scraping for. Then load them back up when you submit the CAPTCHA.\nHere's how I see the full turn of events:\n\nUser places search request\nQuery remote site\nIf not CAPTCHA, GOTO #10\nSave remote cookies in local session\nDownload image captcha (perhaps to session too?)\nPresent CAPTCHA to your user and a form\nUser Submits CAPTCHA\nYou load up cookies from #4 and submit the form as a POST\nGOTO #3\nProcess the data off the page, present to user, high-five yourself.","Q_Score":1,"Tags":"python,django","A_Id":3031565,"CreationDate":"2010-06-13T07:47:00.000","Title":"Raising events and object persistence in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a tricky Django problem which didn't occur to me when I was developing it. My Django application allows a user to sign up and store his login credentials for a sites. The Django application basically allows the user to search this other site (by scraping content off it) and returns the result to the user. For each query, it does a couple of queries of the other site. This seemed to work fine but sometimes, the other site slaps me with a CAPTCHA. I've written the code to get the CAPTCHA image and I need to return this to the user so he can type it in but I don't know how.\nMy search request (the query, the username and the password) in my Django application gets passed to a view which in turn calls the backend that does the scraping\/search. When a CAPTCHA is detected, I'd like to raise a client side event or something on those lines and display the CAPTCHA to the user and wait for the user's input so that I can resume my search. I would somehow need to persist my backend object between calls. I've tried pickling it but it doesn't work because I get the Can't pickle 'lock' object error. I don't know to implement this though. Any help\/ideas?\nThanks a ton.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":267,"Q_Id":3031483,"Users Score":0,"Answer":"request.session['name'] = variable will store it\nthen,\nvariable = request.session['name'] will retrieve it.\nRemember though, its not a database, just a simple session store and shouldn't be relied on for anything critical","Q_Score":1,"Tags":"python,django","A_Id":6689964,"CreationDate":"2010-06-13T07:47:00.000","Title":"Raising events and object persistence in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix and Windows.\nI am unsure how I do this. Specifically how do I detect if the process is already running and open a pipe to it? Should I use sockets (e.g. registering the server process on a known port and then check if it responds) or should I use \"named pipes\"? Or is there some easier way?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":317,"Q_Id":3032378,"Users Score":0,"Answer":"Well here is an idea...\n\nplace a status somewhere else, that\ncan be polled\/queried.   \nwhen the process starts, post the\n'running' status.\nhave the script check here to see if the process is running.\nI would also use a seperate place to\npost control values.  e.g. set a\nvalue to the 'control set' and have\nthe process look for those values\nwhenever it gets to decision points\nin its runtime behavior.","Q_Score":0,"Tags":"python","A_Id":3032409,"CreationDate":"2010-06-13T13:29:00.000","Title":"Detecting and interacting with long running process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix and Windows.\nI am unsure how I do this. Specifically how do I detect if the process is already running and open a pipe to it? Should I use sockets (e.g. registering the server process on a known port and then check if it responds) or should I use \"named pipes\"? Or is there some easier way?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":317,"Q_Id":3032378,"Users Score":2,"Answer":"Sockets are easier to make portable between Windows and any other OS, so that's what I would recommend it over named pipes (that's why e.g. IDLE uses sockets rather than named pipes -- the latter require platform-dependent code on Windows, e.g. via ctypes [[or third-party win32all or cython &c]], while sockets just work).","Q_Score":0,"Tags":"python","A_Id":3032536,"CreationDate":"2010-06-13T13:29:00.000","Title":"Detecting and interacting with long running process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if anyone had tips on how to completely remove a python installation form Mac OSX (10.5.8) ... including virtual environments and its related binaries.  Over the past few years I've completely messed up the installed site-packages, virtual-environments, etc. and the only way I can see to fix it is to just uninstall everything and re-install.\nI'd like to completely re-do everything and use virtualenv, pip, etc. from the beginning.\nOn the other hand if anyone knows a way to do this without removing python and re-installing I'd be happy to here about it.\nThanks,\nWill","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6935,"Q_Id":3034304,"Users Score":0,"Answer":"You should be able to delete the packages you've installed from \/Library\/Python\/2.*\/site-packages\/. I do not think any package installers will install by default to \/System\/Library, which should save you from needing to remove Python itself.\nThat said, you could also use virtualenv with --no-site-packages, and just ignore whatever packages you've installed system-wide without needing to remove them.","Q_Score":3,"Tags":"python,macos,installation","A_Id":3034631,"CreationDate":"2010-06-13T23:32:00.000","Title":"Removing python and then re-installing on Mac OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"During setup, I'm like missing vcvarsall.bat\n\nrunning build\n  running build_py\n  running build_ext\n  building '_zope_interface_coptimizations' extension\n  error: Unable to find vcvarsall.bat","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1515,"Q_Id":3035152,"Users Score":0,"Answer":"vcvarsall.bat is a batch file that comes with MSVC. Make sure that it is in your %PATH%.","Q_Score":2,"Tags":"python,zope.interface","A_Id":3035237,"CreationDate":"2010-06-14T05:41:00.000","Title":"how do i install zope interface with python 2.6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"There's photologue application, simple photo gallery for django, implementing Photo and Gallery objects.\nGallery object has ManyToMany field, which references Photo objects.\nI need to be able to get list of all Photos for a given Gallery.  Is it possible to add Gallery filter to Photo's admin page?\nIf it's possible, how to do it best?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2800,"Q_Id":3036680,"Users Score":0,"Answer":"Well, that's how I've done it.\nI made custom admin template \"change_list.html\". Custom template tag creates a list of all existing galleries. Filtering is made like this:\n\nclass PhotoAdmin(admin.ModelAdmin):\n    ...\n    def queryset(self, request):\n        if request.COOKIES.has_key(\"gallery\"):\n            gallery = Gallery.objects.filter(title_slug=request.COOKIES[\"gallery\"])\n            if len(gallery)>0:\n            return gallery[0].photos.all()\n            return super(PhotoAdmin, self).queryset(request)\n\n\nCookie is set with javascript.","Q_Score":1,"Tags":"python,django,django-admin","A_Id":3052792,"CreationDate":"2010-06-14T11:05:00.000","Title":"Django admin, filter objects by ManyToMany reference","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a raw query and i'm having trouble finding out how to get the number of results it returns. Is there a way?\nedit\n.count() doesnt work. it returns: 'RawQuerySet' object has no attribute 'count'","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":10644,"Q_Id":3037273,"Users Score":2,"Answer":"Count Works on RawQuerySet \n \n\nModelName.objects.raw(\"select 1 as id , COUNT(*) from modelnames_modelname\")","Q_Score":10,"Tags":"python,django,django-orm","A_Id":42020136,"CreationDate":"2010-06-14T12:44:00.000","Title":"Get number of results from Django's raw() query function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a CGI script that is getting an \"IOError: [Errno 13] Permission denied\" error in the stack trace in the web server's error log.\nAs part of debugging this problem, I'd like to add a little bit of code to the script to print the user and (especially) group that the script is running as, into the error log (presumably STDERR).\nI know I can just print the values to sys.stderr, but how do I figure out what user and group the script is running as?\n(I'm particularly interested in the group, so the $USER environment variable won't help; the CGI script has the setgid bit set so it should be running as group \"list\" instead of the web server's \"www-data\" - but I need code to see if that's actually happening.)","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":29300,"Q_Id":3042304,"Users Score":1,"Answer":"os.getgid() and os.getuid() can be useful.  For other environment variables, look into os.getenv.  For example, os.getenv('USER') on my Mac OS X returns the username. os.getenv('USERNAME') would return the username on Windows machines.","Q_Score":31,"Tags":"python,unix,permissions","A_Id":3042340,"CreationDate":"2010-06-15T03:15:00.000","Title":"How to determine what user and group a Python script is running as?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"When you write an application using Qt, can it just be run right away in different operating systems? And (correct me if I'm wrong) you don't need to have Qt already installed in all of the different platforms where you want to execute your application?\nHow exactly does this work? Does Qt compile to the desired platform, or does it bundle some \"dlls\" (libs), or how does it do it? Is it different from programming a Java application,  that runs cross-platform.\nIf you use Python to write a Qt application with Python bindings, does your end user need to have Python installed?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3747,"Q_Id":3045745,"Users Score":15,"Answer":"Qt (ideally) provides source compatibility, not binary compatibility.  You still have to compile the application separately for each platform, and use the appropriate dynamic Qt libraries (which also need to be compiled separately, and have some platform-specific code).  \nFor your final question, the user would need Python, the Qt libraries, and the binding library (e.g. pyqt), but there are various ways to bundle these.","Q_Score":13,"Tags":"python,qt","A_Id":3045754,"CreationDate":"2010-06-15T13:49:00.000","Title":"How does Qt work (exactly)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create an application for the company where I can create sites dynamically. For example, I need an admin interface (Django's admin is enough) where I can setup a new site and add some settings to it.\nEach site must hold a domain (domains can be manually added to apache conf, but if Django can handle it too would be awesome). Each site must be independent of the others, I mean, I shouldn't be able to see the data content of other sites but I can share same applications\/models.\nI've seen the Django's Sites framework, but I'm not sure if it's possible to implement that way.\nShould I use Sites framework or create a new app that can handle sites better?\nWhat do you think?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":737,"Q_Id":3046036,"Users Score":0,"Answer":"The django site framework will do that, but it can't server the site according to the domain name. You'll have to do that using you server such as Apache, Nginx, etc.","Q_Score":1,"Tags":"python,django,sites","A_Id":8602597,"CreationDate":"2010-06-15T14:19:00.000","Title":"Django: how to create sites dynamically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I enter in python in Terminal it loads up Python 2.6.2. However there are folders by the name of Python 2.6 in different places on my drive. I'm not sure if that's because Python 2.6 has been installed in different places or because Python just likes to have lots of folers in different places.\nIf there are multiple installations, I could really do with being able to set which one should be used.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1464,"Q_Id":3046183,"Users Score":4,"Answer":"When you run python in a shell or command prompt it will execute the first executable file which is found in your PATH environment variable.\nTo find out what file is being executed use which python or where python.","Q_Score":1,"Tags":"python,macos,terminal","A_Id":3046210,"CreationDate":"2010-06-15T14:37:00.000","Title":"I suspect I have multiple version of Python 2.6 installed on Mac OS X 10.6.3; how do I set which one Terminal should launch?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"just wonder how those air ticket booking website redirect the user to the airline booking website and then fill up(i suppose doing POST) the required information so that the users will land on the booking page with origin\/destination\/date selected?\nIs the technique used is to open up new browser window and do a ajax POST from there?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":3050477,"Users Score":0,"Answer":"It can work like this:\non air ticket booking system you have a html form pointing on certain airline booking website (by action parameter). If user submits data then data lands on airline booking website and this website proceed the request.\nUsuallly people want to get back to the first site. This can be done by sending return url with request data. Of course there must be an API on the airline booking site to handle such url.\nThis is common mechanism when you do online payments, all kind of reservations, etc.\nNot sure about your idea to use ajax calls. Simple html form is enough here. Note that also making ajax calls between different domains can be recognized as attempt to access the restricted url.","Q_Score":0,"Tags":"javascript,python","A_Id":3051343,"CreationDate":"2010-06-16T03:07:00.000","Title":"redirection follow by post","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background:\n\nI am using Ubuntu\nThe newer python version is not in the apt-get repository (or synaptic)\nI plan on keeping the old version as the default python when you call \"python\" from the command line\nI plan on calling the new python using pythonX.X (X.X is the new version).\n\nGiven the background, how do you install a newer version of python and keep the older python version?\n\nI have downloaded from python.org the \"install from source\" *.tgz package. The readme is pretty simple and says \"execute three commands: .\/configure; make; make test; sudo make install;\"\nIf I do the above commands, will the installation overwrite the old version of python I have (I definitely need the old version)?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11229,"Q_Id":3050512,"Users Score":10,"Answer":"When you install from source, by default, the installation goes in \/usr\/local -- the executable in particular becomes \/usr\/local\/bin\/pythonX.Y with a symlink to it that's named \/usr\/local\/python. Ubuntu's own installation is in \/usr\/ (e.g., \/usr\/bin\/python), so the new installation won't overwrite it.  Take care that the PATH environment variable doesn't have \/usr\/local\/bin before \/usr\/bin, or else simple mentions of python would execute the new one, not the old one.","Q_Score":8,"Tags":"python,ubuntu,installation,gnu,configure","A_Id":3050521,"CreationDate":"2010-06-16T03:18:00.000","Title":"On Ubuntu, how do you install a newer version of python and keep the older python version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In case of views that contain login or logout,\nthis sessionid is different from the one submitted in request's Coockie header.\nI need to retrieve it before returning response for some purpose.\nHow can I do this ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":501,"Q_Id":3053923,"Users Score":1,"Answer":"I think you should be able to access this via request.session.session_key","Q_Score":0,"Tags":"python,django,cookies,django-authentication","A_Id":3054422,"CreationDate":"2010-06-16T14:01:00.000","Title":"Django : In a view how do I obtain the sessionid which will be part of the Set-Cookie header of following response?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If possible I would like to use the following structure for a command however I can't seem to figure out how to achieve this in Python:\n.\/somescript.py arg <optional argument> -- \"some long argument\"\nWould it be possible to achieve this in a feasible manner without too much dirty code? Or should I just reconsider the syntax (which is primarily preference).\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":3057805,"Users Score":0,"Answer":"You just need to stick something like this on the first line:\n    #\/usr\/local\/bin\/python\nJust make yours be wherever your python binary is located.\nAs for args look at getopt or optparser \nAnd remember to chmod your file to make it executable.","Q_Score":3,"Tags":"python,shell,command-line-interface","A_Id":3057864,"CreationDate":"2010-06-16T23:04:00.000","Title":"Python CLI tool - general parsing question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal.\nI've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1489,"Q_Id":3066438,"Users Score":1,"Answer":"I can't think of any way to do strictly what you want off the top of my head other than the registry, at least not without even more drastic measures. But doing this registry modification isn't a big deal; just change the autologon username\/password and reboot the computer. To have the computer reboot when the user logs off, give them a \"logoff\" option that actually reboots rather than logging off; I've seen other places do that.\n(edit)FYI: for registry edits, Windows has a REG command that will be useful if you decide to go with that route.(\/edit)\nAlso, what kind of process are you trying to run? If it's not a GUI app that needs your interaction, you don't have to go through any great pains; just run the app remotely. At my work, we use psexec to do it very simply, and I've also created C++ programs that run code remotely. It's not that difficult, the way I do it is to have C++ call the WinAPI function to remotely register a service on the remote PC and start it, the service then does whatever I want (itself, or as a staging point to launch other things), then unregisters itself. I have only used Python for simple webpage stuff, so I'm not sure what kind of support it has for accessing the DLLs required, but if it can do that, you can still use Python here.\nOr even better yet, if you don't need to do this remotely but just want it done every night, you can just use the Windows scheduler to run whatever application you want run during the night. You can even do this programmatically as there are a couple Windows commands for that: one is the \"at\" command, and I don't recall right now what the other is but just a little Googling should find it for you.","Q_Score":1,"Tags":"python,login,restart,boot","A_Id":3066480,"CreationDate":"2010-06-18T00:05:00.000","Title":"Reboot windows machines at a certain time of day and automatically login with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal.\nI've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1489,"Q_Id":3066438,"Users Score":0,"Answer":"Thanks for the responses. To be more clear on what I'm doing, I have a program that automatically starts on bootup, so getting logged in would be preferred. I'm coding a manager for a render-farm for work which will take all the machines that our guys use during the day and turn them into render servers at night (or whenever they log off for a period of time, for example).\nI'm not sure if I necessarily require a GUI app, but the computer would need to boot and login to launch a server application that does the rendering, and I'm not certain if that can be done without logging in. What i'm needing to run is Autodesk's Backburner Server.exe\nMaybe that can be run without needing to be logged in specifically, but I'm unfamiliar with doing things of that nature.","Q_Score":1,"Tags":"python,login,restart,boot","A_Id":3076111,"CreationDate":"2010-06-18T00:05:00.000","Title":"Reboot windows machines at a certain time of day and automatically login with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set up a Bonjour (or Ahavi) chatbot for our helpdesk system that would answer basic questions based on a menu system. The basis of my question is how do I get python to create the bot so that it connects to the network as a chat client.\nBasically, anyone on my network with iChat or Empathy (or any chat program able to view users over the local network) should see the bot just as they see another user. The actual bot part would be quite simple to program, but I have no idea how to get it on the network. \nI have looked into ZeroConf, but I'm not exactly sure how it works, or how to get a chat service running with python. I have seen references to pybonjour, python bindings for avahi, and pyzeroconf, but again, I have no idea how to set them up.\nIf anyone could give an example, or reference, or even a good article to read on the subject, it would be much appreciated. Thanks!\nKory","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1923,"Q_Id":3072934,"Users Score":0,"Answer":"The easiest thing to do is to use Telepathy Salut or Pidgin\/libpurple, and talk with it over D-Bus.","Q_Score":0,"Tags":"python,linux,bonjour,zeroconf,chatbot","A_Id":3072977,"CreationDate":"2010-06-18T20:43:00.000","Title":"ZeroConf Chat with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.\nNow, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I already have some games ideas. It would be simple 2d plataform games, and I would like to know what is the best way to start.\nI don't want to start with Flash. I'm looking for working with other stuff. I already started to look around for the Unity 3D framework and UDK, but I just don't know how to get started.\nSo, any hints, tips or sugestions to make?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":3074103,"Users Score":0,"Answer":"Looking at your tags, web games are mostly client side, and since you aren't going to use flash, i would say JavaScript would work for 2D.  With all the libraries and plug-ins out there, JavaScript can actually handle it.","Q_Score":6,"Tags":"php,javascript,python","A_Id":3074113,"CreationDate":"2010-06-19T02:38:00.000","Title":"From the web to games","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.\nNow, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I already have some games ideas. It would be simple 2d plataform games, and I would like to know what is the best way to start.\nI don't want to start with Flash. I'm looking for working with other stuff. I already started to look around for the Unity 3D framework and UDK, but I just don't know how to get started.\nSo, any hints, tips or sugestions to make?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":3074103,"Users Score":0,"Answer":"Taking a look at OpenGL may not be a terrible idea. You can use the library in many languages,  and is supported with  in HTML5 (WebGL). There are several excellent tutorials out there.","Q_Score":6,"Tags":"php,javascript,python","A_Id":3074138,"CreationDate":"2010-06-19T02:38:00.000","Title":"From the web to games","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.\nNow, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I already have some games ideas. It would be simple 2d plataform games, and I would like to know what is the best way to start.\nI don't want to start with Flash. I'm looking for working with other stuff. I already started to look around for the Unity 3D framework and UDK, but I just don't know how to get started.\nSo, any hints, tips or sugestions to make?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":3074103,"Users Score":0,"Answer":"If you want to learn more Python while doing so, you may want to take PyGame or an equivalent program. PHP, Ruby and JavaScript aren't going to help you in the video game section, though. They're all related to the internet. \nIf you want to start of real easy, try out Genesis3D. you can make awesome 3D FPS games, and its quite easy to get the hang of too. Took me only 5 days :D\nUnity made me sick to my stomach, and so did Blender3D's game engine, so I personally say not to use those. It intimidated me.","Q_Score":6,"Tags":"php,javascript,python","A_Id":3074736,"CreationDate":"2010-06-19T02:38:00.000","Title":"From the web to games","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a basic web developer. I know PHP, a little bit of Python and Ruby. JavaScript as well [some stuff]. I'm not a hardcore developer. I know what it takes do develop most of web cases.\nNow, I have this desire to go deeper and start developing games. I know it sounds a huge leap, but that is why I'm asking here. I already have some games ideas. It would be simple 2d plataform games, and I would like to know what is the best way to start.\nI don't want to start with Flash. I'm looking for working with other stuff. I already started to look around for the Unity 3D framework and UDK, but I just don't know how to get started.\nSo, any hints, tips or sugestions to make?","AnswerCount":6,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":471,"Q_Id":3074103,"Users Score":3,"Answer":"Python's Pygame is certainly a good choice as others have said. If you want to get in to deep video game programming though.. move on to something like C++ or another lower level language.. from experience, most higher level languages tend to put artificial hurdles up in regards to decent video games. Though for a simple 2d game you cant go wrong with python.\nanother decent environment to use is Ogre3d, but you would need C++ or the PyOgre bindings (which are not up to date, but I hear they do work okay).\nGoing from web to game design really is a decent step, as long as you have a good sense of design. the physics and game logic can be learned, but ive yet to see anyone who could properly learn how to write a decent GUI.. as is seen in most cases these days, the final GUI lay out tends to be a process of elimination or beta with trial and error.\nOnly suggestion i have left is keep your game logic as far away as possible from your graphics. Be Modular.\n-edit-\noh and a note.. stay away from Tkinter in python for anything more than a simple tool.. I have found it most frustrating to use. there is wxPython, GTK, pygame, and PyQT.. and all of them (in my opinion) are far better graphic frameworks.","Q_Score":6,"Tags":"php,javascript,python","A_Id":3075334,"CreationDate":"2010-06-19T02:38:00.000","Title":"From the web to games","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically?\nregards,","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":282,"Q_Id":3077156,"Users Score":4,"Answer":"An object has a Key, part of which is either an automatically-generated numeric ID, or an assigned key name.  IDs are not guaranteed to be increasing, and they're almost never going to be consecutive because they're allocated to an instance in big chunks, and IDs unused by the instance to which they're allocated will never be used by another instance (at least, not currently).  They're also only unique within the same entity group for a kind; they're not unique to the entire kind if you have parent relationships.","Q_Score":1,"Tags":"python,google-app-engine,gql","A_Id":3078018,"CreationDate":"2010-06-19T20:38:00.000","Title":"Does GQL automatically add an \"ID\" Property","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically?\nregards,","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":282,"Q_Id":3077156,"Users Score":3,"Answer":"Yes, they have id's by default, and it is named ID as you mentioned.","Q_Score":1,"Tags":"python,google-app-engine,gql","A_Id":3077170,"CreationDate":"2010-06-19T20:38:00.000","Title":"Does GQL automatically add an \"ID\" Property","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok, so I really love HAML.  Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML.\nI also love Python and Django.\nSo, I would like to use HAML with Django.  Now, I already understand that there are some attempts at cloning HAML-like syntax in Python (SHPAML and others).  I've tried these, and while they aren't bad, I've found that I really just want the real HAML.  Partially for its syntax, but also for things like RedCloth and BlueCloth.\nSo, my question is, how to make HAML and Django work together?\nOne solution, I think, would be to create HAML templates, and then compile them into HTML using the command line tool every time they're updated.\nQuesiton 1: Will I run into any problems here?\nI also wonder if there's a way to get Python and Ruby to play together a little more.  One idea I had was actually forking out Ruby processes.  This is probably a bad idea, but anyone have any thoughts about this?\nQuestion 2: What about using Python to call the real Ruby HAML?\nFinally, if anyone knows of a Python implementation of HAML that is complete, and that supports either Textile or Markdown, as well as plaintext passthru, then let me know.  \nQuestion 3: Is there a full translation of HAML to Python including Markdown or Textile support?\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3831,"Q_Id":3079368,"Users Score":0,"Answer":"While this could end up being more trouble than it is worth, it is PROBABLY possible to leverage the Java or .NET platform and still run your Django application in Jython or IronPython (with some minor adjustments I'm sure) and also be able to leverage Ruby's HAML gem via jRuby or IronRuby.\nI'm sure there will be some quirks in getting this to work, but I'm sure it would be possible.\nAgain, this is probably a lot more trouble than it's worth (considering that you'd have to move your application to a completely new platform), but it would be a pretty fun project to work on.","Q_Score":19,"Tags":"python,ruby,django,haml","A_Id":3144408,"CreationDate":"2010-06-20T13:24:00.000","Title":"Ruby HAML with Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok, so I really love HAML.  Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML.\nI also love Python and Django.\nSo, I would like to use HAML with Django.  Now, I already understand that there are some attempts at cloning HAML-like syntax in Python (SHPAML and others).  I've tried these, and while they aren't bad, I've found that I really just want the real HAML.  Partially for its syntax, but also for things like RedCloth and BlueCloth.\nSo, my question is, how to make HAML and Django work together?\nOne solution, I think, would be to create HAML templates, and then compile them into HTML using the command line tool every time they're updated.\nQuesiton 1: Will I run into any problems here?\nI also wonder if there's a way to get Python and Ruby to play together a little more.  One idea I had was actually forking out Ruby processes.  This is probably a bad idea, but anyone have any thoughts about this?\nQuestion 2: What about using Python to call the real Ruby HAML?\nFinally, if anyone knows of a Python implementation of HAML that is complete, and that supports either Textile or Markdown, as well as plaintext passthru, then let me know.  \nQuestion 3: Is there a full translation of HAML to Python including Markdown or Textile support?\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3831,"Q_Id":3079368,"Users Score":1,"Answer":"I strongly recommend that you do not fork any processes out of your django views, because the overhead is significant. \nYou should have a persistent ruby process to serve your templates for you, and invoke it from your django code. I leave the IPC technology to you, but the obvious choices would either be some kind of message queuing technology, or speaking HTTP over a socket to the ruby process.","Q_Score":19,"Tags":"python,ruby,django,haml","A_Id":7147104,"CreationDate":"2010-06-20T13:24:00.000","Title":"Ruby HAML with Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i tried to figure out what tags were in canvas however i am having a hard time understanding it. can someone explain what tags do and how to use them in canvas when using python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":3081749,"Users Score":0,"Answer":"Every object in a canvas has an id. You can reference that object by that id to delete it, modify it, move it, etc.\nObjects can also have one or more tags. A tag can be associated with a single object, in which case it is just another name for that object. For example, if you draw a red rectangle and a blue rectangle, you can give the first one the tag \"red_rect\" and the second \"blue_rect\". Then, anywhere you might need the id you could instead use the tag. \nOne tag can be associated with more than a single item. So, for example, in addition to the \"red_rect\" and \"blue_rect\" tags, you could also give each item a \"rect\" tag. Then, when you use \"rect\" where  you might use an id (such as to move the object), this will affect all objects with the tag. In this way you can move, configure or delete whole groups of items at a time. \nYou can use tags to implement such common features as letting the user name objects that they draw interactively, or to logically group multiple objects into a single composite object.","Q_Score":1,"Tags":"python,tkinter","A_Id":3084235,"CreationDate":"2010-06-21T02:05:00.000","Title":"can someone help me with tags in canvas?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If it doesn't use ironpython, how C# use cpython program(py file)?\nBecause there are some bugs that ironpython load cpython code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":189,"Q_Id":3083167,"Users Score":0,"Answer":"If you need strict CPython behavior and do not want to change Python program I am afraid that in this case you should spawn separate CPython process and interact with it via  some RPC protocol (there are plenty to choose from) via pipe or network connection to localhost.\nAs alternative to \"serialized\" RPC you might use system's facilities e.g. COM if you're on Windows or D-Bus on Linux - but this would make code platform dependent and not necessarily simpler.","Q_Score":0,"Tags":"c#,python,cpython","A_Id":3083261,"CreationDate":"2010-06-21T08:47:00.000","Title":"How C# use python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to build a tag cloud out of a webpage\/feed. Once you get the word frequency table of tags, it's easy to build the tagcloud. But my doubt is how do I retrieve the tags\/keywords from the webpage\/feed? \nThis is what I'm doing now:\nGet the content -> strip HTML -> split them with \\s\\n\\t(space,newline,tab) -> Keyword list\nBut this does not work great.\nIs there a better way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":3083784,"Users Score":0,"Answer":"What you have is a rough 1st order approximation. I think if you then go back through the data and search for frequency of 2-word phrases, then 3 word phrases, up till the total number of words that can be considered a tag, you'll get a better representation of keyword frequency.\nYou can refine this rough search pattern by specifying certain words that can be contained as part of a phrase (pronouns ect).","Q_Score":1,"Tags":"python,tags,visualization,keyword","A_Id":3250807,"CreationDate":"2010-06-21T10:17:00.000","Title":"How do I get tags\/keywords from a webpage\/feed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have file about 4MB (which i called as big one)...this file has about 160000 lines..in a specific format...and i need to cut them at regular interval(not at equal intervals) i.e at the end of a certain format and write the part into another file..\nBasically,what i wanted is to copy the information for the big file into the many smaller files ...as i read the big file keep writing  the information into one file and after the a certain pattern occurs then end this and starting writing for that line into another file...\nNormally, if it is a small file i guess it can be done dont know if i can perform file.readline() to read each line check if pattern end if not then write it to a file if patter end then change the file name open new file..so on but how to do it for this big file..\nthanks in advance..\ndidnt mention the file format as i felt it is not neccesary will mention if required..","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":246,"Q_Id":3094618,"Users Score":1,"Answer":"A 4MB file is very small, it fits in memory for sure. The fastest approach would be to read it all and then iterate over each line searching for the pattern, writing out the line to the appropriate file depending on the pattern (your approach for small files.)","Q_Score":1,"Tags":"python,file","A_Id":3094661,"CreationDate":"2010-06-22T15:29:00.000","Title":"how to load a big file and cut it into smaller files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS).  I need the difference between the two times.  I've been looking through documentation for Python and searching online and I would imagine it would have something to do with the datetime and\/or time modules.  I can't get it to work properly and keep finding only how to do this when a date is involved.\nUltimately, I need to calculate the averages of multiple time durations. I got the time differences to work and I'm storing them in a list. I now need to calculate the average. I'm using regular expressions to parse out the original times and then doing the differences.  \nFor the averaging, should I convert to seconds and then average?","AnswerCount":16,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":542575,"Q_Id":3096953,"Users Score":0,"Answer":"you could try this:\nfrom datetime import datetime\nstart = datetime.now()\nprint(start)\n#some code here\nend = datetime.now()\nprint(end)\nprint(end - start)","Q_Score":224,"Tags":"python,time,python-datetime","A_Id":72463310,"CreationDate":"2010-06-22T20:38:00.000","Title":"How to calculate the time interval between two time strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS).  I need the difference between the two times.  I've been looking through documentation for Python and searching online and I would imagine it would have something to do with the datetime and\/or time modules.  I can't get it to work properly and keep finding only how to do this when a date is involved.\nUltimately, I need to calculate the averages of multiple time durations. I got the time differences to work and I'm storing them in a list. I now need to calculate the average. I'm using regular expressions to parse out the original times and then doing the differences.  \nFor the averaging, should I convert to seconds and then average?","AnswerCount":16,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":542575,"Q_Id":3096953,"Users Score":2,"Answer":"Take a look at the datetime module and the timedelta objects.  You should end up constructing a datetime object for the start and stop times, and when you subtract them, you get a timedelta.","Q_Score":224,"Tags":"python,time,python-datetime","A_Id":3096997,"CreationDate":"2010-06-22T20:38:00.000","Title":"How to calculate the time interval between two time strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a dialog which contains a pygtk.treeview for listing tasks by priority. Each row has the background colour set based on that priority, so for example the highest priority has a light red background.\nThe row selection color is not so easy to change. I can set it using treeview.modify_base(gtk.STATE_SELECTED, \"#C4C4C4\"), but no colours work well with the colours used to enhance the concept of priority.\nI had the idea to change the selection colour to be a slightly darker version of the colour used as the normal row background, so in the example above, that would be a darker red. I tried calling the function above in response to the treeselection's changed signal, and it works, but with heavy flickering.\nAnother idea was to change the selection to transparent and put a border around it instead, but as far as I can tell, this isn't possible.\n\nHow can I change the selection colour in the way described above without the flickering?\nCan I change show the selection by having only a border around the row?\n\nNote: I'm aware that this violates the theme selected by the user. I feel I have a good reason for it. Having the priority indicated by colour makes it instantly recognisable. The selection colour hides this. If you have alternative suggestions, I am open to them, but it needs to retain the ease at which a user can identify the priority.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3920,"Q_Id":3099244,"Users Score":0,"Answer":"Calling both ModifyBase and ModifyText worked for me. Calling just ModifyBase changes the text color to White\nExample in GTK C#:\ntreeViewList.ModifyBase(StateType.Selected, treeViewList.Style.Base(StateType.Normal));\ntreeViewList.ModifyText(StateType.Selected, treeViewList.Style.Text(StateType.Normal));","Q_Score":9,"Tags":"python,user-interface,gtk,pygtk,gtktreeview","A_Id":60073336,"CreationDate":"2010-06-23T05:58:00.000","Title":"Changing the selected item colour in a GtkTreeview using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a dialog which contains a pygtk.treeview for listing tasks by priority. Each row has the background colour set based on that priority, so for example the highest priority has a light red background.\nThe row selection color is not so easy to change. I can set it using treeview.modify_base(gtk.STATE_SELECTED, \"#C4C4C4\"), but no colours work well with the colours used to enhance the concept of priority.\nI had the idea to change the selection colour to be a slightly darker version of the colour used as the normal row background, so in the example above, that would be a darker red. I tried calling the function above in response to the treeselection's changed signal, and it works, but with heavy flickering.\nAnother idea was to change the selection to transparent and put a border around it instead, but as far as I can tell, this isn't possible.\n\nHow can I change the selection colour in the way described above without the flickering?\nCan I change show the selection by having only a border around the row?\n\nNote: I'm aware that this violates the theme selected by the user. I feel I have a good reason for it. Having the priority indicated by colour makes it instantly recognisable. The selection colour hides this. If you have alternative suggestions, I am open to them, but it needs to retain the ease at which a user can identify the priority.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3920,"Q_Id":3099244,"Users Score":0,"Answer":"Not sure what you mean by flickering. A border would require subclassing TreeView.\nI'd make the STATE_SELECTED color identical to STATE_NORMAL to disable the built-in highlighting. Then set a data_func on each column and change some color on the cell renderer depending on whether it's in the selection or not.\nYou're probably already doing this for your priority, so just multiply the color with something to highlight a row.","Q_Score":9,"Tags":"python,user-interface,gtk,pygtk,gtktreeview","A_Id":3099780,"CreationDate":"2010-06-23T05:58:00.000","Title":"Changing the selected item colour in a GtkTreeview using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I had one machine with my commonly used python package installed.\nand i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":824,"Q_Id":3106736,"Users Score":9,"Answer":"Pip has some great features for this.\nIt lets you save all requirements from an environment in a file using pip freeze > reqs.txt\nYou can then later do : pip install -r reqs.txt and you'll get the same exact environnement.\nYou can also bundle several libraries into a .pybundle file with the command pip bundle MyApp.pybundle -r reqs.txt, and later install it with pip install MyApp.pybundle.\nI guess that's what you're looking for :)","Q_Score":2,"Tags":"python,pip","A_Id":3106793,"CreationDate":"2010-06-24T01:43:00.000","Title":"Any productive way to install a bunch of packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had one machine with my commonly used python package installed.\nand i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":824,"Q_Id":3106736,"Users Score":0,"Answer":"I keep a requirements.txt file in one of my repositories that has all my basic python requirements and use PIP to install them on any new machine.\nEach of my projects also has it's own requirements.txt file that contains all of it's dependencies for use w\/virtualenv.","Q_Score":2,"Tags":"python,pip","A_Id":3106755,"CreationDate":"2010-06-24T01:43:00.000","Title":"Any productive way to install a bunch of packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to set it in my \/etc\/profile and in my environment variables.\nBut what if I want to set it during a script?\nIs it import os, sys? How do I do it?","AnswerCount":6,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":173492,"Q_Id":3108285,"Users Score":-4,"Answer":"you can set PYTHONPATH, by os.environ['PATHPYTHON']=\/some\/path, then you need to call os.system('python') to restart the python shell to make the newly added path effective.","Q_Score":146,"Tags":"python,linux,unix,environment-variables","A_Id":48543222,"CreationDate":"2010-06-24T08:25:00.000","Title":"In Python script, how do I set PYTHONPATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if there was a ternary operator (condition ? true-value : false-value) that could be used in a Django template.  I see there is a python one (true-value if condition else false-value) but I'm unsure how to use that inside a Django template to display the html given by one of the values.  Any ideas?","AnswerCount":6,"Available Count":1,"Score":0.1651404129,"is_accepted":false,"ViewCount":35699,"Q_Id":3110166,"Users Score":5,"Answer":"You don't. The Django {% if %} templatetag has only just started supporting ==, and, etc. {% if cond %}{% else %}{% endif %} is as compact as it gets for now.","Q_Score":70,"Tags":"python,django,templates,ternary-operator","A_Id":3110234,"CreationDate":"2010-06-24T13:05:00.000","Title":"Django Template Ternary Operator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently maintaining two of my own applications. They both share some common aspects, and as a result, share some code. So far, I've just copied the modules from one project to the other, but now it's becoming a maintenance issue. I'd rather have the common code in one place, outside of both of the projects, which they can both import. Then, any changes to the common code would be reflected in both project.\nMy question is: how can I do this? Do I create a library out of this code? If so, how do the dependent projects use the library? I think one thing I struggle with here is that the common code isn't really useful to anyone else, or at least, I don't want to make it a supported modules that other people can use.\nIf my question isn't clear, please let me know.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":10091,"Q_Id":3118008,"Users Score":4,"Answer":"There are a lot of ways to factor code so it is reusable.  It really depends on your specific situation as far as what will work best.  Factoring your code into separate packages and modules is always a good idea, so related code stays bundled together and can be reused from other packages and modules.  Factoring your code into classes within a module can also help in keeping related code grouped together.\nI would say that putting common code into a module or package that is on your PYTHONPATH and available to both applications would probably be your best solution.","Q_Score":19,"Tags":"python,module","A_Id":3118063,"CreationDate":"2010-06-25T12:35:00.000","Title":"How can I use common code in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been working with a few RAD gui builders lately. I absolutely despise CSS ( camel is a horse designed by committee etc.) What algorithms are used by packing managers(java\/tk). Most GUI toolkits I've used have some alternative to absolute positioning, sorry for the ambiguity but how do you start thinking about implementing a  packing manger in language X.\n\nThanks for the replies, to clarify - I want to create a generic text file that defines a 'form' this form file can then be used to generated a native(ish) GUI form (eg tk) and also an HTML form.\nWhat I'm looking for is some pointers on how a grid based packing manager is implemented so I can formulate my generic text file based on some form of established logic.\nIf this doesn't make sense to you then you understand me:). Some notes\n1. XML lives in the same stable as the zebra and the camel but not the horse.\n2. Think lightweight markup languages (Markdown\/ReStructuredText) but for simple forms.\n3. This has probably already been implemented, do you know where?\n4. Yes, I have Googled it (many,many times),answer was not between G1 and o2 \nThks","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":306,"Q_Id":3122291,"Users Score":3,"Answer":"Tk has three methods. One is absolute positioning, the other two are called \"grid\" and \"pack\". \ngrid is just what it sounds like: you lay out your widgets in a grid. There are options for spanning rows and columns, expanding (or not) to fill a cell, designating rows or columns which can grow, etc. You can accomplish probably 90% of all layout issues with the grid geometry manager.\nThe other manager is \"pack\" and it works by requesting that widgets be placed on one side or another (top, bottom, left, right). It is remarkably powerful, and with the use of nested containers (called frames in tk) you can accomplish pretty much any layout as well. Pack is particularly handy when you have things stacked in a single direction, such as horizontally for a toolbar, vertically for a main app (toolbar, main area, statusbar). \nBoth grid and pack are remarkably powerful and simple to use, and between them can solve any layout problem you have. It makes me wonder why Java and wxPython have so many and such complicated geometry managers when its possible to get by with no more than three.","Q_Score":0,"Tags":"python,grid,tcl,rad","A_Id":3122400,"CreationDate":"2010-06-26T00:55:00.000","Title":"GUI layout -how?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"My two main requirements for the site are related to degrees of separation and graph matching (given two graphs, return some kind of similarity score).\nMy first thought was to use MySql to do it, which would probably work out okay for storing how I want to manage 'friends' (similar to Twitter), but I'm thinking if I want to show users results which will make use of graphing algorithms (like shortest path between two people) maybe it isn't the way to go for that.\nMy language of choice for the front end, would be Python using something like Pylons but I haven't committed to anything specific yet and would be willing to budge if it fitted well with a good backend solution.\nI'm thinking of using MySQL for storing user profile data, neo4j for the graph information of relations between users and then have a Python application talk to both of them.\nMaybe there is a simpler\/more efficient way to do this kind of thing. At the moment for me it's more getting a suitable prototype done than worrying about scalability but I'm willing to invest some time learning something new if it'll save me time rewriting\/porting in the future.\nPS: I'm more of a programmer than a database designer, so I'd prefer having rewrite the frontend later rather than say porting over the database, which is the main reason I'm looking for advice.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":749,"Q_Id":3126155,"Users Score":2,"Answer":"MySQL is really your best choice for the database unless you want to go proprietary.\nAs for the actual language, pick whatever you are familiar with. While Youtube and Reddit are written in python, many of the other large sites use Ruby (Hulu, Twitter, Techcrunch) or C++ (Google) or PHP (Facebook, Yahoo, etc).","Q_Score":4,"Tags":"python,sql,mysql,database","A_Id":3126208,"CreationDate":"2010-06-27T02:19:00.000","Title":"What should I use for the backend of a 'social' website?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am having a problem with widget Gtk.Table - I would like to know, if there is a way how to get a current size of the table (number of rows and columns).\nThank you, very much for help, Tomas","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":881,"Q_Id":3126802,"Users Score":0,"Answer":"In most recent versions of PyGTK you can get\/set those values via table.props.n_columns and table.props.n_rows, which is synonymous with the get_property() (mentioned in the other answers) and set_property() methods.","Q_Score":0,"Tags":"python,gtk,pygtk","A_Id":3128879,"CreationDate":"2010-06-27T08:17:00.000","Title":"Getting size of Gtk.Table in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like:\n\nDelete a message\nMark a message as read\nReport a message as spam\n\nWith all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic.\nOption 1)\nHave a separate URL and view for each action. So, \/inbox\/delete-message\/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to \/inbox\/.\nI like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to \/inbox\/delete-message\/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?).\nOption 2)\nUse the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever.\nThis option feels less clean to me, but I also feel like it's more common.\nWhich would be preferred by Djangonauts? Or is there another option that's better than either of the above?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":334,"Q_Id":3126969,"Users Score":2,"Answer":"A modified option #1 is the best approach.  Consider this: suppose we weren't talking about a web app, but instead were just designing an inbox class.  Which do you like better, a number of methods (delete_message(), mark_as_spam(), etc), or one big method (do_stuff(action))?  Of course you would use the separate methods.\nA separate URL for each action, each with a separate view, is far preferable. If you don't like the redirect at the end, then don't use it.  Instead, have a render_inbox(request) method that returns an HttpResponse, and call the method at the end of each of your views.  Of course, redirecting after a POST is a good way to prevent double-actions, and always leaves the user with a consistent URL.\nEven better might be to use Ajax to hide the actions, but that is more involved.","Q_Score":4,"Tags":"python,django,url,post,django-views","A_Id":3127296,"CreationDate":"2010-06-27T09:36:00.000","Title":"URLs and side effects (Django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like:\n\nDelete a message\nMark a message as read\nReport a message as spam\n\nWith all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic.\nOption 1)\nHave a separate URL and view for each action. So, \/inbox\/delete-message\/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to \/inbox\/.\nI like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to \/inbox\/delete-message\/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?).\nOption 2)\nUse the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever.\nThis option feels less clean to me, but I also feel like it's more common.\nWhich would be preferred by Djangonauts? Or is there another option that's better than either of the above?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":334,"Q_Id":3126969,"Users Score":1,"Answer":"If you're writing a web 2.0 messaging app, you would be using AJAX calls and wouldn't be loading a new page at all. The process would proceed like so:\n\nUser clicks [delete] for a message. This button has a javascript action bound to it. This action does the following:\ni. Change the UI to indicate that something is happening (grey the message or put up an hourglass).\nii. Send a request to \/messages\/inbox\/1234\/delete. (where 1234 is some identifier that indicates which message)\niii. When the response from the server comes back, it should indicate success or failure. Reflect this status in the current UI. For example, on success, refresh the inbox view (or just remove the deleted item).\n\nOn the server side, now you can create a URL handler for each desired action (i.e. \/delete, \/flag, etc.).\nIf want to use an even more RESTful approach, you would use the HTTP action itself to indicate the action to perform. So instead of including delete in your URL, it would be in the action.  So instead of GET or POST, use DELETE \/messages\/inbox\/1234. To set a flag for having been read, use SET \/messages\/inbox\/1234?read=true.\nI don't know how straightforward it is in Django to implement this latter recommendation, but in general, it's a good idea utilize the protocol (in this case HTTP), rather than work around it by encoding your actions into a URL or parameter.","Q_Score":4,"Tags":"python,django,url,post,django-views","A_Id":3127290,"CreationDate":"2010-06-27T09:36:00.000","Title":"URLs and side effects (Django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like:\n\nDelete a message\nMark a message as read\nReport a message as spam\n\nWith all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic.\nOption 1)\nHave a separate URL and view for each action. So, \/inbox\/delete-message\/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to \/inbox\/.\nI like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to \/inbox\/delete-message\/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?).\nOption 2)\nUse the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever.\nThis option feels less clean to me, but I also feel like it's more common.\nWhich would be preferred by Djangonauts? Or is there another option that's better than either of the above?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":3126969,"Users Score":0,"Answer":"I agree that #2 is a better approach. \nBut take care with overloading the submit <input \/> with different methods -- if a user is using it with keyboard input and hits enter, it won't necessarily submit the <input \/> you're expecting. Either disable auto-submit-on-enter, or code things up so that if there is more than one thing that submit can do, there's another field that sets what the action should be (eg a 'delete' checkbox, which is tested during a request.POST) \nIf you went with #1 I'd say that a GET to a POST-only view should be met with a 405 (method not supported) - or, failing that, a 404.","Q_Score":4,"Tags":"python,django,url,post,django-views","A_Id":3127284,"CreationDate":"2010-06-27T09:36:00.000","Title":"URLs and side effects (Django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like:\n\nDelete a message\nMark a message as read\nReport a message as spam\n\nWith all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic.\nOption 1)\nHave a separate URL and view for each action. So, \/inbox\/delete-message\/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to \/inbox\/.\nI like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to \/inbox\/delete-message\/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?).\nOption 2)\nUse the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever.\nThis option feels less clean to me, but I also feel like it's more common.\nWhich would be preferred by Djangonauts? Or is there another option that's better than either of the above?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":334,"Q_Id":3126969,"Users Score":1,"Answer":"I don't think there's anything wrong with either option, but #2 is potentially better from a performance standpoint. After the action is posted you can render the inbox without a redirect, so it cuts down on the HTTP traffic.","Q_Score":4,"Tags":"python,django,url,post,django-views","A_Id":3127022,"CreationDate":"2010-06-27T09:36:00.000","Title":"URLs and side effects (Django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5.\nBeing mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine.  Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":758,"Q_Id":3127915,"Users Score":0,"Answer":"OK, I figured out the answer to my own question, partly with the help of Nicholas Knight who pointed out that you just install different Python version to different Python directories.  I was left scratching my head on how to get Google App Engine to use Python 2.5 (the required version) instead of Python 2.6.  This is the answer:\n1) Install Python 2.5.\n2) Install Python 2.6 (or a more recent version), afterwards.  This will be the system default.\n3) Install the Google App Engine SDK.\n4) Launch, \"Google App Engine Launcher\" from the Start Menu\n5) Click Edit > Preferences, and enter the path to the pythonw.exe executable.  Usually c:\\Python25\\pythonw.exe","Q_Score":4,"Tags":"python,google-app-engine","A_Id":3130801,"CreationDate":"2010-06-27T16:07:00.000","Title":"Is it possible to run two versions of Python side-by-side?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5.\nBeing mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine.  Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":758,"Q_Id":3127915,"Users Score":5,"Answer":"Absolutely.\nIf you're on *nix, you'd usually just use make altinstall instead of make install, that way the \"python\" binary won't get installed\/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course.\nSome Linux distributions will have multiple versions available via their package managers. They'll similarly be installed as python2.5 etc. (With the distribution's blessed\/native version also installed as the regular python binary.)\nWindows users generally just install to different directories.","Q_Score":4,"Tags":"python,google-app-engine","A_Id":3127950,"CreationDate":"2010-06-27T16:07:00.000","Title":"Is it possible to run two versions of Python side-by-side?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I hope this is trivial and I just didn't find it in the tutorials. I am writing python code that 'supervises' c code, aka I run the  c code with ctypes from python. Now I want to 'catch' the c 'printfs' to process the data that is output by the c code. Any idea how one would do this?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2287,"Q_Id":3131977,"Users Score":0,"Answer":"Well printf simply writes its output to whatever the stdout file pointer refers to. Im not sure how you're executing the C program, but it should be possible to redirect the C program's stdout to something that you can read in Python.","Q_Score":5,"Tags":"python,c,printf,ctypes","A_Id":3133108,"CreationDate":"2010-06-28T11:38:00.000","Title":"How to 'catch' c printf in python with ctypes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have Python 2.6 & 3.1 installed on Leopard via mac ports with no problems. I want to install Django 1.2 via mac ports for Python 2.6, but a google search of how to do it seems to point me in the wrong direction. Can anyone point me in the right direction? Thanks again.....","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":936,"Q_Id":3136423,"Users Score":0,"Answer":"Just \"throw\" the django tarball within the site-packages (dist-packages in py2.6+) and you are done. What for do you need macports etc, with a pure python library?","Q_Score":2,"Tags":"python,django","A_Id":3139071,"CreationDate":"2010-06-28T21:52:00.000","Title":"Trying to install Django via Macports on Leopard","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to install:\nA. Mod python on a regular Macbookpro (MacOSX 10.6.4)\nB. And MySQL for Python on the same computer.\nAnd the installation is constantly failing.\n\nQuestion 1: Is there a tutorial on how to achieve this on Mac OS?\nI also hoped that I could use Macports for this. \nI had bad experience with Macports and installing python.\nI am sure this is due to my not understanding the concept of:\n\nports \nprofile (pythonpath)\n\n\nQuestion 2: What would I have to write in the .profile to make packages be recognized by python?\n\nQuestion 3: What exactly is a port?\nIn general it would be awesome to get an understanding on how to install packages in python quick and effectively.\nAlso the build in version of Python by Apple seems to have settings, that, if changed can make your life difficult. \n\nQuestion 4: Any detailed experience or advice on this issues would he very helpful.\nFor a quick start into programming.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":285,"Q_Id":3147213,"Users Score":0,"Answer":"This answer is outdated, see Mark's response below\nI had trouble installing python and python libraries on osx, and this is what I ended up doing to fix it:\nUsing macports I installed python26 and python_select. Then use python_select to change from the default python26-apple to python26 (which is from macports). Now when you use macports to install any python26 library it will just work.\nOne of the main drawbacks of this approach is that macports installs everything from source, which is slow and buggy compared to using pre-build binaries, but for me it's worth it to be able to manage most of my FOSS software through macports.","Q_Score":0,"Tags":"python,macports,installation","A_Id":5876565,"CreationDate":"2010-06-30T07:29:00.000","Title":"Python library installing macports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"sometime due to wrong input from user side, mail bounce and did not reach the recipient. ( sent from google app engine.) \nHow to detect such email ?\nedit:\nmay be i was not clear in my question : \nI want to know to which mail i have sent the mail which was return ( so that i may alert the user or delete the email id ). this is more related to how email bounce works. normally the bounce mail does not come exactly same as sent but with different information, is there any particular header or something there to know which email id was that ? ... i think i have figure out while writing these, i am keeping this question so it might help somebody. \ni will simply mail from base64encodedrecipientemailaddress@myapp.appspot.com and create a mail receive handler. :)\nso one more question : what is the maximum length does app-engine ( or any mail server ) allows for email address ?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1227,"Q_Id":3147267,"Users Score":0,"Answer":"easiest is to encode an email address via base64 or simiar encoding and prefixed it to from address.\nall address from something@myapp.appspotmail.com are valid email address for from in gae.\nsimply create a mail receive handler. decode the from string and get the email address to whom you send the email originally. \nsad thing is maximum 64 character length allowed for local part. in that case storing email address in datastore and using its key as a local part to email can be a option.","Q_Score":3,"Tags":"python,google-app-engine,email","A_Id":3194130,"CreationDate":"2010-06-30T07:38:00.000","Title":"how to detect bounce mail in google app engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Py2exe to package a Python application with quite a few dependant packages. While Py2exe works flawlessly the resulting dist\/ folder with the executable contains a large number (10-15) of support files (.dll, .pyd, .zip).\nIdeally I would like to be able to place all of these dependant files in a folder called support\/ or lib\/ or something to that effect. This way when people download the application and extract the archive they are only presented with an executable and some folders.\nDoes Py2exe support placing dependant files in a sub-folder? If so, how can one accomplish this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":564,"Q_Id":3148483,"Users Score":2,"Answer":"An effective solution is to bundle everything in an standalone executable using\nbundle_files:1\nin your setup.py py2exe options.","Q_Score":2,"Tags":"python,py2exe","A_Id":5093220,"CreationDate":"2010-06-30T10:50:00.000","Title":"Py2exe Directory Structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need. \nEvery time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the template, the lists items, the the column views etc. But that should not be called Django Customization. \nIf I need to make even a small change in the User functionality or any modification to the auth module. It takes a lots of efforts even in figuring out how that can be done.\nIs Django that difficult to customize or its just lack of the help available over internet for this or its me who is moving in the wrong direction ?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":21336,"Q_Id":3155624,"Users Score":1,"Answer":"Django Admin is easy to customize if your requirements match what is customizable in Django. If you need fancy features that are not out-of-the-box functionality you either need to find a plugin that does it, or implement it yourself by subclassing the appropriate classes. Which can be difficult, and requires good understanding of the internals of Django.\nSo in summary: it makes it easier to setup an admin, but if you need anything special that's not out of the box: you got a steep learning curve.\nDepending on your requirements you can choose to use django or not. Anything that requires a lot of functional speccing is better of implemented manually.","Q_Score":25,"Tags":"python,django,django-admin,customization","A_Id":33733949,"CreationDate":"2010-07-01T06:52:00.000","Title":"Is Django admin difficult to customize?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need. \nEvery time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the template, the lists items, the the column views etc. But that should not be called Django Customization. \nIf I need to make even a small change in the User functionality or any modification to the auth module. It takes a lots of efforts even in figuring out how that can be done.\nIs Django that difficult to customize or its just lack of the help available over internet for this or its me who is moving in the wrong direction ?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":21336,"Q_Id":3155624,"Users Score":3,"Answer":"Personally, if you want a site to look like the admin, why not pull the templates and styles and use them, build your own views for what you need.  Gobs of documentation and forum help is there for that.  I like the idea of customizing the admin, but honestly, I have been doing it for awhile on a project and time and time again I think to myself, if this was built in the standard MVC (or MTV) manner with free templates online, copied admin ones, or some professionally made ones, and built with the plethora of addons and my code, it would be much easier!!! And, when you decide that request\/response isn't cutting it, and you want to add lots of JavaScript, you'll be glad.  I know.  I have had to put all sorts of JavaScript on our Admin project.  Mostly because it's impossible to make the admin do what we want, so we fix it with JavaScript once it is on screen.   When you find yourself writing an Ajax based system, you'll wonder why you have the admin at all.  \nIf I could start this project over, I might not even use Django, but I probably would.  I most certainly won't used the Admin.  \nNow, if you are building an basic CRUD type site that doesn't have style-eyed users, then Django with grappelli, and some elbow grease will get the job done.  Remember, Django is a collection of Python scripts.  Just override everything you can, and you'll get there, if you aren't too ambitious.","Q_Score":25,"Tags":"python,django,django-admin,customization","A_Id":11705960,"CreationDate":"2010-07-01T06:52:00.000","Title":"Is Django admin difficult to customize?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to track\/log activity on the Django admin.\nI know there are messages stored by admin somewhere, but I don't know how to access them in order to use them as a simple log.\n\nI'm trying to track the following:\n\nUser performing the action\nAction committed\nDatetime of action\n\nThanks guys.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":30210,"Q_Id":3157875,"Users Score":17,"Answer":"Log is in django_admin_log table in database used by django.","Q_Score":32,"Tags":"python,django,logging,django-admin","A_Id":3157915,"CreationDate":"2010-07-01T12:45:00.000","Title":"Logging activity on Django's admin - Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I use a progress bar when my script is doing some task that is likely to take time?\nFor example, a function which takes some time to complete and returns True when done. How can I display a progress bar during the time the function is being executed?\nNote that I need this to be in real time, so I can't figure out what to do about it. Do I need a thread for this? I have no idea.\nRight now I am not printing anything while the function is being executed, however a progress bar would be nice. Also I am more interested in how this can be done from a code point of view.","AnswerCount":42,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":744169,"Q_Id":3160699,"Users Score":0,"Answer":"You should link the progress bar to the task at hand (so that it measures the progress :D). For example, if you are FTPing a file, you can tell ftplib to grab a certain size buffer, let's say 128K, and then you add to your progress bar whatever percentage of the filesize 128k represents. If you are using the CLI, and your progress meter is 20 characters long, you would add one character when 1\/20th of the file had transferred.","Q_Score":476,"Tags":"python,progress-bar","A_Id":3160926,"CreationDate":"2010-07-01T18:39:00.000","Title":"Python Progress Bar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to automate the changing of the hostname of a computer, but I can't figure out how to do it inside a program. My options are open; I would be happy with a solution in any of the following:\nCommand line\nJava\nPython\nC# (would prefer one of the other 3, but this is ok)\nIt would be helpful to learn how to do this on both Linux and Windows.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2734,"Q_Id":3167469,"Users Score":0,"Answer":"In Windows you have to modify registry keys and the reboot the system.\nYou actually have to change two entries:\nHostName under HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters\nand\nComputerName under HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName\nPlease note that if the computer ha joined an NT Domain this change could be harmful (and in this case you have an additional entry to change under TcpIp\\Parameters).","Q_Score":1,"Tags":"c#,java,python,hostname","A_Id":3167542,"CreationDate":"2010-07-02T16:27:00.000","Title":"Rename a computer programmatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"As the title says, how do you remember the order of super's arguments? Is there a mnemonic somewhere I've missed?\nAfter years of Python programming, I still have to look it up :(\n(for the record, it's super(Type, self))","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":631,"Q_Id":3171824,"Users Score":10,"Answer":"Simply remember that the self is optional - super(Type) gives access to unbound superclass methods - and optional arguments always come last.","Q_Score":7,"Tags":"python,super","A_Id":3171872,"CreationDate":"2010-07-03T14:40:00.000","Title":"Python: how do you remember the order of `super`'s arguments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose you know the three vertices for a spherical triangle. \nThen how do you draw the sides on a sphere in 3D?\nI need some python code to use in Blender 3d modelisation software.\nI already have the sphere done in 3D in Blender.\nThanks & happy blendering.\nnote  1:\ni have the 3 points \/ vertices (p1,p2,p3 ) on the sphere for a spherical triangle\nbut i need to trace the edges  on the sphere in 3D\nso what would be the equations needed to determine  all vertices  between each points pair of the triangle on the sphere\n3 edges  from p1 to p2  -  p2 to p3  and o3  to p1\ni know it has something to do with the Great circle   for Geodesic  on a sphere\nbut cannot   find the proper equations to do the calculations in spherical coordinates!\nThanks\n\nGreat circles\nit   would  have been interesting to see a solution with great circle and see tehsolution in spherical coordinates directly !\nbut still interesting to do it in the euclidiens space \nThanks \n\nok i used this idea of line segment between 2 points \nbut did not do it as  indicated before\ni used an alternative method - Bezier line interpolation**\ni parametrize the line with a bezier line\nthen subdivided  and calculated as shonw ealier the ratio and angle for each of the subdivided bezier point on the chord\nand it works very well and very precise \nbut it would be interesting to see how it is done whit the earlier method\nbut not certain how to do the iteration loop?\nhow do you load up the python code  here\njust past it  with Ctrl-V?\nThanks and happy 2.5\n\ni do use the blenders' forum\nbut no guaranti to get a clear answer all the time!\nthat's why i tried here - took a chance\ni did the first edge seems to work \nnow got to make a loop to  get  multi segment for first edge and then do the other edges also\n2- other subject\n  i open here a post on bezier triangle patch\n i know it's not a usfull tool\nbut just to show how it is done\nhave youeseen a python sript to do theses triangel patch\nand i did ask this questin on blender's foum and no answer\nalso on IRC python and sems to be dead right now \nprobably guys are too busy finishing the 2.5 Beta vesion which should come out  in a week or 2\nHey Thanks a lot  for this math discussion \nif i have problem be back tomorrow\nhappy math and 2.5","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3171,"Q_Id":3172535,"Users Score":0,"Answer":"One cheap and easy method for doing this would be to create the triangle and subdivide the faces down to the level of detail you want, then normalize all the vertices to the radius you want.","Q_Score":3,"Tags":"python,blender","A_Id":3172669,"CreationDate":"2010-07-03T19:03:00.000","Title":"How to draw a spherical triangle on a sphere in 3D?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've recently started using a mac, and I'm curious about how to make a mac app that uses PyQt and is self-contained.\nCan anyone give me any pointers on where to start and what I'll need?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1222,"Q_Id":3173047,"Users Score":1,"Answer":"I've tried the same for some weeks now. Finally i have to say py2app just wont do. I was lucky with pyinstaller1.4. Although you need to add some minor modifications to run flawlessly on OS X. Furthermore the apps it creates are only 1\/4 of the size compared to py2app. And most important it works :) And yet another goodie ... it works with the python framework which ships with OS X so there is no need to install python via MacPorts etc.","Q_Score":2,"Tags":"python,macos,qt","A_Id":4022382,"CreationDate":"2010-07-03T22:26:00.000","Title":"How to create a self contained Python Qt app on mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how do I move an item to a definite index in a list?","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":162145,"Q_Id":3173154,"Users Score":1,"Answer":"I profiled a few methods to move an item within the same list with timeit. Here are the ones to use if j>i:\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 14.4usec \u2502 x[i:i]=x.pop(j),     \u2502\n\u2502 14.5usec \u2502 x[i:i]=[x.pop(j)]    \u2502\n\u2502 15.2usec \u2502 x.insert(i,x.pop(j)) \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\nand here the ones to use if j<=i:\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 14.4usec \u2502 x[i:i]=x[j],;del x[j]     \u2502\n\u2502 14.4usec \u2502 x[i:i]=[x[j]];del x[j]    \u2502\n\u2502 15.4usec \u2502 x.insert(i,x[j]);del x[j] \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\nNot a huge difference if you only use it a few times, but if you do heavy stuff like manual sorting, it's important to take the fastest one. Otherwise, I'd recommend just taking the one that you think is most readable.","Q_Score":126,"Tags":"python,list","A_Id":62608192,"CreationDate":"2010-07-03T23:14:00.000","Title":"Move an item inside a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I download a remote file into several chunks using twisted? Lets say if the file is 100 bytes, I want to spawn 10 connection which will read 10 bytes each but in no particular order and then later on merge them all.\nI was able to do this using threads in Python but I don't have any idea how to use twisted's reactor + manager + protocol to achieve the same. Any advice as to how should I design this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":3174374,"Users Score":0,"Answer":"I don't think this really provides the direction the user requires - the question seems to be clear in how to use Twisted to achieve this - the answer implies reasonable knowledge of Twisted.","Q_Score":2,"Tags":"python,twisted","A_Id":3175439,"CreationDate":"2010-07-04T10:28:00.000","Title":"How to design a twisted solution to download a file by reading on certain portion?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Several laptops on the market have problems with Linux for brightness controls. However, recently I found out that you can use CompizConfig settings to dim at least a particular window. Many people, however, want to dim all windows. I know Compiz can do this in the API somewhere because look what happens when you do Super + Tab in Compiz.\nSo this got me thinking...what I need to build is a GNOME applet in either Python, or perhaps this new Vala language, that interfaces with the Compiz API and lets me dim the entire screen.\nDoes anyone know where I might find some programming resources to learn how to use Compiz API in Python or Vala to dim the screen?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":579,"Q_Id":3177057,"Users Score":1,"Answer":"You want to look into gnome-compiz especially into gtk-window-decorator and gnome-xgl-settings.","Q_Score":0,"Tags":"python,gnome,vala,compiz","A_Id":3185814,"CreationDate":"2010-07-05T03:02:00.000","Title":"Controlling Linux Compiz Brightness Programmatically with Python or Vala","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have just received a task to implement a software that paints over pictures (pretty much like microsoft paint )\ni have no idea where to start or how to do that. do anyone have a good reference or idea for painting in qt or pyqt ?\n\nthis will be highly appreciated \nthanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1562,"Q_Id":3179469,"Users Score":0,"Answer":"Have you looked at the scribble example included in PyQt? It does basic drawing, saving, loading, etc.","Q_Score":0,"Tags":"python,qt,pyqt,paint","A_Id":3497327,"CreationDate":"2010-07-05T12:34:00.000","Title":"making paint in pyqt or qt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Forms have Fields, Fields have a value. However, they only get a value after the form has been submitted.\n\nHow should I store this value? Should I give every field a value attribute, field.value, \n\n\nleave it as None prior to posting, and fill it in afterwords? \nOmit it completely, and dynamically add it? \nStore it on the form instead, like form.data['field']. \nCreate a a wrapper class FieldWithData to avoid any inconsistent states (if you have an object of this type, you know it has data) and allows me to set the data in the initializer rather than accessing attributes directly (although I guess this isn't so different from using a setter)\n\nHow should I provide access to the field data through the Form object? Options:\n\n\nform.fields['name'].value (how it's presently being stored internally)\nform.data['field'] (create a proxy \"data\" class that retrieves the real data off the field, or re-arrange the internals to actually store the data like this)\nform.field.value - looks fairly nice, but then I'd have two references to the same field, one as form.field and one as form.fields['field'] which I need internally so that I can iterate over them\n\n\nToo many design decisions. Driving me nuts. This is what sucks about solo'ing a project.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":3183431,"Users Score":1,"Answer":"It really depends on how you interact with the structures in question. Do you manipulate Form and Field objects prior to assigning them values? Do you need to frequently iterate over all the given Fields? Do you need Form once it's been submitted? Etc.\nI'd suggest writing some\/all of the code that uses Form and figure out how you want to interact with Form data, and what your ideal interface would look like.","Q_Score":1,"Tags":"python,design-patterns","A_Id":3183465,"CreationDate":"2010-07-06T04:03:00.000","Title":"Where to store field data and how to provide access to it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"1. Print a-n: a b c d e f g h i j k l m n\n2. Every second in a-n: a c e g i k m\n3. Append a-n to index of urls{hello.com\/, hej.com\/, ..., hallo.com\/}: hello.com\/a hej.com\/b ... hallo.com\/n","AnswerCount":18,"Available Count":1,"Score":0.0111106539,"is_accepted":false,"ViewCount":323159,"Q_Id":3190122,"Users Score":1,"Answer":"This is your 2nd question: string.lowercase[ord('a')-97:ord('n')-97:2] because 97==ord('a') -- if you want to learn a bit you should figure out the rest yourself ;-)","Q_Score":142,"Tags":"python,string,list,range,ascii","A_Id":3190229,"CreationDate":"2010-07-06T20:51:00.000","Title":"Python: how to print range a-z?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there anyone that has some ideas on how to implement the AdaBoost (Boostexter) algorithm in python?\nCheers!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4289,"Q_Id":3193756,"Users Score":2,"Answer":"Thanks a million Steve! In fact, your suggestion had some compatibility issues with MacOSX (a particular library was incompatible with the system) BUT it helped me find out a more interesting package : icsi.boost.macosx. I am just denoting that in case any Mac-eter finds it interesting! \nThank you again!\nTim","Q_Score":5,"Tags":"python,machine-learning,adaboost","A_Id":3207845,"CreationDate":"2010-07-07T10:07:00.000","Title":"AdaBoost ML algorithm python implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It seems like my Eclipse PyDev does not recognize that Twisted is installed on my system. I can't make auto suggest working. Does anyone know how to solve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1684,"Q_Id":3199702,"Users Score":12,"Answer":"go to preferences->Pydev->Interpreter - Python and hit the apply button. That will rescan your modules directory and add any missing modules.\nThat should fix any normal import errors. Some modules do some runtime magic that PyDev cant follow.","Q_Score":5,"Tags":"python,eclipse,twisted,pydev","A_Id":3199728,"CreationDate":"2010-07-07T23:40:00.000","Title":"pydev and twisted framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create an automated program in Python that deals with Flash. Right now I am using Python Mechanize, which is great for filling forms, but when it comes to flash I don't know what to do. Does anyone know how I can interact with flash forms (set and get variables, click buttons, etc.) via Python mechanize or some other python library?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1702,"Q_Id":3215062,"Users Score":0,"Answer":"Nice question but seems unfortunately mechanize can't be used for flash objects","Q_Score":2,"Tags":"python,flash,forms,mechanize,code-injection","A_Id":3849851,"CreationDate":"2010-07-09T17:26:00.000","Title":"Interact with Flash using Python Mechanize","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently my program updates itself by downloading the latest .tar.gz file containing the source code, and extracting it over the current directory where the program lives. There are 2 \"modes\" of update - one for users running the Python source, and one if the user is running the program as a Windows exe. \nOver time my program's filesize is becoming larger with each release, due to new images, libraries, documentation and code. However, sometimes only code changes occur from one release to another, so the user ends up re-downloading all the images, documentation etc over and over, when only there are only small code changes.\nI was thinking that a more efficient approach would be to use a patch\/diff based system where the program incrementally updates itself from one version to another by only downloading small change sets.\nHowever, how should I do this? If the user is running version 0.38, and there is a 0.42 available, do they download 0.38->39; 0.39->40; 0.40->41, 0.41->42? How would I handle differences in binary files? (images, in my case). \nI'd also have to maintain some repository containing all the patches, which isn't too bad. I'd just generate the diffs with each new release. But I guess it would be harder to do this to executables than to pure python code?\nAny input is appreciated. Many thanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":535,"Q_Id":3219772,"Users Score":1,"Answer":"Your update manager can know which version the current app is, and which version is the most recent one and apply only the relevant patches.\nSuppose the user runs 0.38, and currently there is 0.42 available. The update for 0.42 contains patches for 0.39, 0.40, 0.41 and 0.42 (and probably farther down the history). The update manager downloads the 0.42 update, knows it's at 0.38 and applies all the relevant patches. If it currently runs 0.41, it only applies the latest patch, and so on.","Q_Score":3,"Tags":"python,diff,patch","A_Id":3219785,"CreationDate":"2010-07-10T15:25:00.000","Title":"Updating my program, using a diff-based patch approach","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to install some specific version of a package (in this case Django) inside the virtual environment. I can't figure it out.\nI'm on Windows XP, and I created the virtual environment successfully, and I'm able to run it, but how am I supposed to install the Django version I want into it? I mean, I know to use the newly-created easy_install script, but how do I make it install Django 1.0.7? If I do easy_install django, it will install the latest version. I tried putting the version number 1.0.7 into this command in various ways, but nothing worked.\nHow do I do this?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":80239,"Q_Id":3220280,"Users Score":2,"Answer":"pip install \"django>=2.2,<3\"\nTo install djnago 2.2","Q_Score":96,"Tags":"python,django,setuptools,virtualenv","A_Id":66091958,"CreationDate":"2010-07-10T17:55:00.000","Title":"How do I install an old version of Django on virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry for the kind of general question. More details about what I want:\nI want the user to be able to write some Python code and execute it. Once there is an exception which is not handled, I want the debugger to pause the execution, show information about the current state\/environment\/stack\/exception and make it possible to edit the code.\nI only want to have the special code block editable where the exception occurred and nothing else (for now). I.e. if it occurred inside a for loop, I only want to have the code block inside the for loop editable. It should be the latest\/most recent code block which is in the user editor scope (and not inside some other libs or the Python libs). Under this conditions, it is always clear what code block to edit.\n\nI already tried to investigate a bit how to do this, though I feel a bit lost.\nThe Python traceback doesn't give me directly the code block, just the function and the code line. I could calculate that back but that seems a bit hacky to me. Better (and more natural) would be if I could somehow get a reference to the code block in the AST of the code.\nTo get the AST (and operate on it, i.e. manipulate\/edit), I probably will use the compiler (which is deprecated?) and\/or the parser module. Or the ast module. Not sure though how I could recompile special nodes \/ code blocks in the AST. Or if I only can recompile whole functions.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2309,"Q_Id":3229102,"Users Score":1,"Answer":"From what I have figured out in the meantime, this is not possible. At least not block-wise. It is possible to recompile the code per function but not per code-block because Python generates the code objects per function.\nSo the only way is to write an own Python compiler.","Q_Score":3,"Tags":"python,compiler-construction,parsing,stack-trace,abstract-syntax-tree","A_Id":3498493,"CreationDate":"2010-07-12T13:44:00.000","Title":"how to write a Python debugger\/editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a directory with a large number of files (~1mil). I need to choose a random file from this directory. Since there are so many files, os.listdir naturally takes an eternity to finish.\nIs there a way I can circumvent this problem? Maybe somehow get to know the number of files in the directory (without listing it) and choose the 'n'th file where n is randomly generated?\nThe files in the directory are randomly named.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":1774,"Q_Id":3247202,"Users Score":1,"Answer":"I'm not sure this is even possible. Even at the VFS or filesystem level, there is no guarantee that a directory entry count is even maintained. For instance many filesystems simply record the combined byte size of the directory entry structures contained in a given directory.\nEstimation may be made if directory entries are fixed size structures, but this is uncommon now (consider LFN for FAT32). Even if a given filesystem did provide an entry count without needing to iterate through a directory, or if the VFS cached a record of a directories length, these would definitely be operating system, filesystem, and kernel specific.","Q_Score":12,"Tags":"python,file","A_Id":3247393,"CreationDate":"2010-07-14T14:35:00.000","Title":"Choosing a random file from a directory (with a large number of files) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to put 3 items in the list.\n\nstate..eg(1,2)\naction...eg..west\ncost....5\n\nlist=[(state,action,cost), (state,action,cost).........]\nhow can i make it in a form of list. For a particular state , action and cost is there. Moreover, if i need only state from the list, i should be able to extract it from the list.same thing goes for action too.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":390,"Q_Id":3252725,"Users Score":0,"Answer":"The code you listed above is a list of tuples - which pretty much matches what you're asking for.\nFrom the example above, list[0][0] returns the state from the first tuple, list[0][1] the action, and list[0][2] the cost. \nYou can extract the values with something like (state, action, cost)= list[i] too.","Q_Score":2,"Tags":"python","A_Id":3252763,"CreationDate":"2010-07-15T05:34:00.000","Title":"List formation in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to install the new Python 2.7 on my Windows XP 32bit PC.\nhaving CDO (thats OCD with initials sorted in alphabetical order) I want to install it multiple times on the same computer (to different TARGETDIRs).\nhow do i do that ? double clicking on the installer, or running msiexec multiple times did not work for me\nCoincidentally, I noticed that the windows python installation does not ask me if I want to add a Start Menu option. I want my installations of python not to show up on the Start Menu. How do I do that?\nbe well","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":479,"Q_Id":3263769,"Users Score":0,"Answer":"Based on one of your comments, it looks like you don't actually need to install it, you just need it on the computer so your program can run. In that case you can take a page from Dropbox's book and include the interpreter, DLL, and standard library in one of your directories, and just use it from there.","Q_Score":4,"Tags":"python,installation,windows-installer","A_Id":3264133,"CreationDate":"2010-07-16T10:06:00.000","Title":"Multiple Python Installations of the same python version on a single computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id).\nThese events would essentially contain an event type like \"click\" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including items like referrer etc...\nI have tried mixpanel, but for now the data api they are offering seems too limiting as I can't seem to find a way to get all of my data out by a unique id (apart from the event itself).\nI'm looking into using django-eventracker, but curious about any others thought on the best way to do this.  Mongo or CouchDb seem like a great choice here, but the celery\/rabbitmq looks really attractive with mongo.  Pumping these events into the existing applications db seems limiting at this point.\nAnyways, this is just a thread to see what others thoughts are on this and how they have implemented something like this...\nshoot","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3366,"Q_Id":3267081,"Users Score":1,"Answer":"If by click, you mean a click on a link that loads a new page (or performs an AJAX request), then what you aim to do is fairly straightforward. Web servers tend to keep plain-text logs about requests - with information about the user, time\/date, referrer, the page requested, etc. You could examine these logs and mine the statistics you need.\nOn the other hand, if you have a web application where clicks don't necessarily generate server requests, then collecting click information with javascript is your best bet.","Q_Score":7,"Tags":"python,django,events,mongodb,tracking","A_Id":3267422,"CreationDate":"2010-07-16T16:40:00.000","Title":"Recommendation for click\/event tracking mechanisms (python, django, celery, mongo etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id).\nThese events would essentially contain an event type like \"click\" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including items like referrer etc...\nI have tried mixpanel, but for now the data api they are offering seems too limiting as I can't seem to find a way to get all of my data out by a unique id (apart from the event itself).\nI'm looking into using django-eventracker, but curious about any others thought on the best way to do this.  Mongo or CouchDb seem like a great choice here, but the celery\/rabbitmq looks really attractive with mongo.  Pumping these events into the existing applications db seems limiting at this point.\nAnyways, this is just a thread to see what others thoughts are on this and how they have implemented something like this...\nshoot","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3366,"Q_Id":3267081,"Users Score":3,"Answer":"I am not familiar with the pre-packaged solutions you mention.  Were I to design this from scratch, I'd have a simple JS collecting info on clicks and posting it back to the server via Ajax (using whatever JS framework you're already using), and on the server side I'd simply append that info to a log file for later \"offline\" processing -- so that would be independent of django or other server-side framework, essentially.\nAppending to a log file is a very light-weight action, while DBs for web use are generally way optimized for read-intensive (not write-intensive) operation, so I agree with you that force fitting that info (as it trickes in) into the existing app's DB is unlikely to offer good  performance.","Q_Score":7,"Tags":"python,django,events,mongodb,tracking","A_Id":3267157,"CreationDate":"2010-07-16T16:40:00.000","Title":"Recommendation for click\/event tracking mechanisms (python, django, celery, mongo etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to setup a website in django which allows the user to send queries to a database containing information about their representatives in the European Parliament. I have the data in a comma seperated .txt file with the following format:\n\nParliament, Name, Country, Party_Group, National_Party,  Position\n7, Marta Andreasen, United Kingdom, Europe of freedom and democracy Group, United Kingdom Independence Party, Member\netc....\n\nI want to populate a SQLite3 database with this data, but so far all the tutorials I have found only show how to do this by hand. Since I have 736 observations in the file I dont really want to do this.\nI suspect this is a simple matter, but I would be very grateful if someone could show me how to do this.\nThomas","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7034,"Q_Id":3270952,"Users Score":2,"Answer":"You asked what the create(**dict(zip(fields, row))) line did.\nI don't know how to reply directly to your comment, so I'll try to answer it here.\nzip takes multiple lists as args and returns a list of their correspond elements as tuples. \nzip(list1, list2) => [(list1[0], list2[0]), (list1[1], list2[1]), .... ]\ndict takes a list of 2-element tuples and returns a dictionary mapping each tuple's first element (key) to its second element (value).\ncreate is a function that takes keyword arguments. You can use **some_dictionary to pass that dictionary into a function as keyword arguments. \ncreate(**{'name':'john', 'age':5}) => create(name='john', age=5)","Q_Score":13,"Tags":"python,django,sqlite","A_Id":3275298,"CreationDate":"2010-07-17T09:38:00.000","Title":"Populating a SQLite3 database from a .txt file with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a application, and my job just is  to develop a sample Python interface for the application. The application can provide XML-based document, I can get the document via HTTP Get method, but the problem is the XML-based document is endless which means there will be no end element. I know that the document should be handled by SAX, but how to deal with the endless problem? Any idea, sample code?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1933,"Q_Id":3284289,"Users Score":0,"Answer":"If the document is endless why not add end tag (of main element) manually before opening it in parser? I don't know Python but why not add <\/endtag> to string?","Q_Score":5,"Tags":"python,xml","A_Id":3284880,"CreationDate":"2010-07-19T19:24:00.000","Title":"python handle endless XML","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What's the maximum level of recursion and how do I change it in Python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9205,"Q_Id":3289430,"Users Score":31,"Answer":"The default is 1000 levels deep and you can change that using the setrecursionlimit function in the sys module. \nWarning:\nBeware that some operating systems may start running into problems if you go much higher due to limited stack space.","Q_Score":27,"Tags":"python,recursion","A_Id":3289437,"CreationDate":"2010-07-20T11:30:00.000","Title":"Maximum level of recursion in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is my first questions here, so I hope it will be done correctly ;)\nI've been assigned the task to give a web interface to some \"home made\" python script.\nThis script is used to check some web sites\/applications availability, via curl commands. A very important aspect of this script is that it gives its results in real-time, writing line by line to the standard output.\nBy giving a web interface to this script, the main goal is that the script can be easily used from anywhere, for example via a smartphone. So the web interface must be quite basic, and work \"plugin-free\".\nMy problem is that most solutions I thought or found on the web (ajax, django, even a simple post) seem to be needing a full generation of the page before sending it to the browser, losing this important \"real-time\" aspect.\nAny idea on how to do this properly ?\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3095,"Q_Id":3289584,"Users Score":0,"Answer":"Your task sounds interesting. :-) A scenario that just came into mind: You continuosly scrape the resources with your home-brew scripts, and push the results into your persistent database and a caching system -- like Redis -- simultanously. Your caching system\/layer serves as primary data source when serving client requests. Redis f.e. is a high-performant key-value-store that is capable to handle 100k connections per second. Though only the n latest (say f.e. 50k entries) matter the caching system will only hold these entries and let you solely focus on developing the server-side API (handling connections, processing requests, reading from Redis) and the frontend. The communication between frontend and backend-API could be driven by WebSocket connections. A pretty new part of the HTML5 spec. Though, however, already supported by many browser versions released these days. Alternatively you could fallback on some asynchronous Flash Socket-stuff. Websockets basically allow for persistent connections between a client and a server; you can register event listener that are called for every incoming data\/-packet -- no endless polling or other stuff.","Q_Score":8,"Tags":"python","A_Id":3289731,"CreationDate":"2010-07-20T11:50:00.000","Title":"Web-ifing a python command line script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to access UV Layer in Blender from Python and basically API returns UV Layer only as a string. Thing is I want to assign new Image object to current UV Layer ( I use TexFace on the side of material ) and then just bake lighting. All meshes are currently unwrapped, the only thing which is missing is an Image and I have no idea how to add image I will bake lighting to from Python level.\nThanks,\nJ","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1058,"Q_Id":3290443,"Users Score":0,"Answer":"What you could do is (if you are using Blender 2.49b) set the image of the Texture object and the uvlayer property of the MTex object.","Q_Score":0,"Tags":"python,textures,blender","A_Id":5252616,"CreationDate":"2010-07-20T13:31:00.000","Title":"Blender, UV Layer, Image and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am developing an online browser game, based on google maps, with Django backend, and I am getting close to the point where I need to make a decision on how to implement the (backend) timed events - i.e. NPC possession quantity raising (e.g. city population should grow based on some variables - city size, application speed).\nThe possible solutions I found are:\n\nPutting the queued actions in a table and processing them along with every request.\n\nProblems: huge overhead, harder to implement\n\n\nUsing cron or something similar\n\nProblem: this is an external tool, and I want as little external tools as possible.\n\n\n\nAny other solutions?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":770,"Q_Id":3294682,"Users Score":5,"Answer":"Running a scheduled task to perform updates in your game, at any interval, will give you a spike of heavy database use. If your game logic relies on all of those database values to be up to date at the same time (which is very likely, if you're running an interval based update), you'll have to have scheduled downtime for as long as that cronjob is running. When that time becomes longer, as your player base grows, this becomes extremely annoying.\nIf you're trying to reduce database overhead, you should store values with their last update time and growth rates, and only update those rows when the quantity or rate of growth changes. \nFor example, a stash of gold, that grows at 5 gold per minute, only updates when a player withdraws gold from it. When you need to know the current amount, it is calculated based on the last update time, the current time, the amount stored at the last update, and the rate of growth.\nData that changes over time, without requiring interaction, does not belong in the database. It belongs in the logic end of your game. When a player performs an activity you need to remember, or a calculation becomes too cumbersome to generate again, that's when you store it.","Q_Score":3,"Tags":"python,django,cron","A_Id":3294995,"CreationDate":"2010-07-20T21:50:00.000","Title":"Browser-based MMO best-practice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been programming using Python for slightly more than half an year now and I am more interested in Python internals rather than using Python to develop applications. Currently I am working on porting a few libraries from Python2 to Python3. However, I have a rather abstract view on how to make port stuff over from Python2 to Python3 as most of the changes deal with design issues in Python2.x\nI'd like to learn more about Python internals; should I go for a top-down or a bottom-up approach? Are there any references you could recommend?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":22228,"Q_Id":3298464,"Users Score":1,"Answer":"should I go for a top-down or a bottom-up approach?\n\nBoth! Seriously.","Q_Score":57,"Tags":"python,python-3.x,internals","A_Id":3299533,"CreationDate":"2010-07-21T10:59:00.000","Title":"How can I learn more about Python\u2019s internals?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I edit two modules, eggs and ham, and module eggs imports ham, how do I run module eggs such that IDLE stops at breakpoints set in ham? So far, I have only been able to get IDLE to recognize breakpoints set in the module actually being run, not those being imported.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5900,"Q_Id":3300665,"Users Score":8,"Answer":"start IDLE\nopen eggs, open ham\nset desired breakpoints in both files\ngo to IDLE's shell, select Debug=>Debugger\ngo back to eggs and  to run.\n\nYou should stop at break points in each file.  (It works, I just tested it.)","Q_Score":5,"Tags":"python,python-idle","A_Id":3301128,"CreationDate":"2010-07-21T14:59:00.000","Title":"How do I set a breakpoint in a module other than the one I am running in Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result\ni am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1704,"Q_Id":3309695,"Users Score":3,"Answer":"It is not possible to get the 'final' URL by parsing, in order to resolve it, you would need to at least perform an HTTP HEAD operation","Q_Score":1,"Tags":"python,google-app-engine,feedparser","A_Id":3309766,"CreationDate":"2010-07-22T14:05:00.000","Title":"how to get final redirected url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result\ni am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1704,"Q_Id":3309695,"Users Score":0,"Answer":"You can do this by handling redirects manually. When calling fetch, pass in follow_redirects=False. If your response object's HTTP status is a redirect code, either 301 or 302, grab the Location response header and fetch again until the HTTP status is something else. Add a sanity check (perhaps 5 redirects max) to avoid redirect loops.","Q_Score":1,"Tags":"python,google-app-engine,feedparser","A_Id":3309853,"CreationDate":"2010-07-22T14:05:00.000","Title":"how to get final redirected url","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I didn't expect this to occur [since I didn't know when django changed to allow _ and . in usernames], but when I attempt\n{% url feed_user entry.username %}\nI will get a 500 error when the username contains a '.'\nIn this case rob.e as a username will fail.\nAny ideas how to deal with this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":3311973,"Users Score":4,"Answer":"The problem will be in whatever regex you are using in your urls.py to match feed_user. Presumably you are using something like r'(?P<username>\\w+)\/$', which only matches on alphanumeric characters and doesn't match on punctuation.\nInstead, use this: r'(?P<username>[\\w.]+)\/$'","Q_Score":2,"Tags":"python,django,url,reverse","A_Id":3312255,"CreationDate":"2010-07-22T18:13:00.000","Title":"django URL reverse: When URL reversig a username it fails when username has a '.' literal in it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm a java developer\/python beginner, and I'm missing my maven features, particularly dependency management and build automation (I mean you don't build, but how to create a package for deployment?)  \nIs there a python equivalent to achieve these features?\nNote: I use python 2.x\nThanks.","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":113883,"Q_Id":3324108,"Users Score":6,"Answer":"It's good to use virtualenv to create standalone project environment and use pip\/easy_install to management dependencies.","Q_Score":162,"Tags":"python,deployment,dependency-management","A_Id":4560558,"CreationDate":"2010-07-24T06:41:00.000","Title":"Maven equivalent for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In limits.h, and in various places in the POSIX manpages, there are references to PATH_MAX and NAME_MAX.\nHow do these relate to one another?\nWhere is the official documentation for them?\nHow can I obtain them at run time, and (where relevant) compile time for the C, Python, and GNU (shell) environments?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2365,"Q_Id":3325602,"Users Score":6,"Answer":"PATH_MAX is the maximum length of a filesystem path.  NAME_MAX is the maximum length of a filename (in a particular spot).  So, \/foo\/bar is restricted by PATH_MAX, and only the bar portion has its length limited by NAME_MAX.\nYou can get these at run time via pathconf, as _PC_PATH_MAX and _PC_NAME_MAX, although standard practice is generally just to use the static macros at compile time.  I suppose it would be better to use the run-time option because you could potentially support longer values that way, but I'm not sure what (if any) systems actually provide a return from pathconf which is greater than the value of the POSIX_FOO_MAX values.","Q_Score":6,"Tags":"python,c,posix,gnu,limits","A_Id":3325616,"CreationDate":"2010-07-24T15:12:00.000","Title":"What is the relation between PATH_MAX and NAME_MAX, and how do I obtain?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"hey guys, im trying to internationalize my site, so i have the django cms multilingual middleware class in my settings.py , when viewed from brasil, the url changes to\nwww.ashtangayogavideo.com\/pt\/ash\/homepage\/ resulting in a 404, because my site is in www.ashtangayogavideo.com\/ash\/en\/homepage, how can i configure the middleware, or settings.py, so that the language code is added after the \/ash\/ ? .","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":444,"Q_Id":3327590,"Users Score":2,"Answer":"Sounds like you need to modify your urls.py, not your settings or middleware.","Q_Score":2,"Tags":"python,django,django-cms","A_Id":3356666,"CreationDate":"2010-07-25T01:12:00.000","Title":"How to modify django cms multilingual middleware","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to make an image a button in Tkinter, now how do I make th image a toggle button similar to a radio button?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1795,"Q_Id":3327799,"Users Score":2,"Answer":"Use a checkbutton with \"indicatoron\" set to False. This will turn off the little checkbox so you only see the image (or text), and the relief will toggle between raised and sunken each time it is clicked. \nAnother way is to use a label widget and manage the button clicks yourself. Add a binding for <1> and change the relief to sunken if raised, and raised if sunken. It's easier to use the built-in features of the checkbutton, since it also handles keyboard traversal, activation, etc.","Q_Score":0,"Tags":"python,radio-button,toggle,tkinter","A_Id":3327963,"CreationDate":"2010-07-25T02:49:00.000","Title":"Making a Toggle Button with an image in Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a gtk TextView in a maximized window and I want to know how many characters a line can fit before you have to scroll.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":3328241,"Users Score":0,"Answer":"(Friendly reminder, please stop putting answers in the comments, people.)\nTo summarize:\nIt depends on the size of the TextView, size of the window, size of the font, and as Alex Martelli said, the particular font and the usage of letters...\"i\" is a narrow letter, \"m\" is a wide letter, thus you can fit more \"i\"s than you can \"m\"s in a given space.\nSo, in short, there is no way to know for sure.","Q_Score":0,"Tags":"python,gtk,pygtk","A_Id":8647405,"CreationDate":"2010-07-25T06:03:00.000","Title":"Get the length in characters of a PyGTK TextView","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to this post as well as to python GUI programming.I want to make a realtime graphical GUI in wxpython.My requirement is that i have to catch signals from a device and i have to display the data in graphical as well as in textual form.The system should be accurate and be specific with the time constraints.Please can any one guide me in this,and if this be possible in wxpython and if yes how can i and if no what i can use for this is python.\nHoping someone will help me out soon.Thanks in advance and for your concern.\nregards,\nAnil ph","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":3332263,"Users Score":0,"Answer":"If you can connect to this mysterious device and receive data from it from Python, then you can display said data with wxPython or any other GUI toolkit. You don't really say what kind of data it is or what you want to display? Lines? Graphs? Or what? If it's just tabular data, use the wx.ListCtrl (or ObjectListView) widget. If you need graphs, see the Plot widget or Matplotlib.","Q_Score":0,"Tags":"user-interface,wxpython,real-time","A_Id":5598605,"CreationDate":"2010-07-26T04:48:00.000","Title":"Help : Realtime graphical interface in wxpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7.\nI'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just \"work\" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages.\nSo I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how--\nHow would I do this?\nI have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4281,"Q_Id":3333095,"Users Score":6,"Answer":"download the latest version of sqlite3.dll from sqlite website and replace the the sqlite3.dll in the python dir.","Q_Score":9,"Tags":"python,build,linker,sqlite","A_Id":3341117,"CreationDate":"2010-07-26T07:54:00.000","Title":"How can I upgrade the sqlite3 package in Python 2.6?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7.\nI'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just \"work\" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages.\nSo I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how--\nHow would I do this?\nI have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4281,"Q_Id":3333095,"Users Score":1,"Answer":"I decided I'd just give this a shot when I realized that every library I've ever installed in python 2.6 resided in my site-packages folder. I just... copied site-packages to my 2.7 installation, and it works so far. This is by far the easiest route for me if this works -- I'll look further into it but at least I can continue to develop now.\nI won't accept this answer, because it doesn't even answer my question, but it does solve my problem, as far as I can tell so far.","Q_Score":9,"Tags":"python,build,linker,sqlite","A_Id":3333348,"CreationDate":"2010-07-26T07:54:00.000","Title":"How can I upgrade the sqlite3 package in Python 2.6?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am leasing a dedicated web server.\nI have a Python web-application.\nWhich configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way?\nUPDATE:\nNote, I'm not using a Python framework such as Django or Pylons.","AnswerCount":6,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":5769,"Q_Id":3336787,"Users Score":4,"Answer":"Don't get carried away with trying to work out what is the fastest web server. All you will do in doing that is waste your time. This is because the web server is nearly never the bottleneck if you set them up properly. The real bottleneck is your web application, database access etc.\nAs such, choose whatever web hosting system you think meets your general requirements and which you find easy to setup and manage. Using something you understand and which doesn't require lots of time devoted to it, means you can then focus your valuable time on making your application perform better, thus reducing the real bottleneck.","Q_Score":2,"Tags":"python,webserver,mod-wsgi","A_Id":3339594,"CreationDate":"2010-07-26T16:21:00.000","Title":"Python\/Web: What's the best way to run Python on a web server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am leasing a dedicated web server.\nI have a Python web-application.\nWhich configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way?\nUPDATE:\nNote, I'm not using a Python framework such as Django or Pylons.","AnswerCount":6,"Available Count":2,"Score":-0.0333209931,"is_accepted":false,"ViewCount":5769,"Q_Id":3336787,"Users Score":-1,"Answer":"You don't usually just serve Python, you serve a specific web server or framework based on Python. eg. Zope, TurboGears, Django, Pylons, etc. Although they tend to be able to operate on different web server back-ends (and some provide an internal web server themselves), the best solution will depend on which one you use.","Q_Score":2,"Tags":"python,webserver,mod-wsgi","A_Id":3336816,"CreationDate":"2010-07-26T16:21:00.000","Title":"Python\/Web: What's the best way to run Python on a web server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i was wondering how to update a StaticText dynamically in wxpython?\nI have a script that goes every five minutes and reads a status from a webpage, then prints using wxpython the status in a static input.\nHow would i dynamically, every 5 minutes update the statictext to reflect the status?\nthanks alot\n-soule","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":12769,"Q_Id":3339263,"Users Score":1,"Answer":"Call the SetLabel method in your static text instance.  So you don't run into conflict with the size, make sure your StaticText instance is created with enough space to write the future labels you'll want to write to it.","Q_Score":5,"Tags":"python,wxpython,refresh","A_Id":3339765,"CreationDate":"2010-07-26T21:50:00.000","Title":"Dynamically update wxPython staticText","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"say i want to ask the many users to give me their ID number and their name, than save it.\nand than i can call any ID and get the name. can someone tell me how i can do that by making a class and using the _ _ init _ _ method?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":250,"Q_Id":3340803,"Users Score":2,"Answer":"The \"asking\" part, as @Zonda's answer says, could use raw_input (or Python 3's input) at a terminal (\"command window\" in Windows); but it could also use a web application, or a GUI application -- you don't really tell us enough about where the users will be (on the same machine you're using to run your code, or at a browser while your code runs on a server?) and whether GUI or textual interfaces are preferred, so it's impossible to give more precise advice.\nFor storing and retrieving the data, a SQL engine as mentioned in @aaron's answer is a possibility (though some might consider it overkill if this is all you want to save), but his suggested alternative of using pickle directly makes little sense -- I would instead recommend the shelf module, which offers (just about) the equivalent of a dictionary persisted to disk.  (Keys, however, can only be strings -- but even if your IDs are integers instead, that's no problem, just use str(someid) as the key both to store and to retrieve).\nIn a truly weird comment I see you ask...:\n\nis there any way to do it by making a\n  class? and using the __init__\n  method?\n\nOf course there is a way to do \"in a class, using the __init__ method\" most anything you can do in a function -- at worst, you write all the code that would (in a sensible program) be in the function, in the __init__ method instead (in lieu of return, you stash the result in self.result and then get the .result attribute of the weirdly useless instance you have thus created).\nBut it makes any sense to use a class only when you need special methods, or want to associate state and behavior, and you don't at all explain why either condition should apply here, which is why I call your request \"weird\" -- you provide absolutely no context to explain why you would at all want that in lieu of functions.\nIf you can clarify your motivations (ideally by editing your question, or, even better, asking a separate one, but not by extending your question in sundry comments!-) maybe it's possible to help you further.","Q_Score":0,"Tags":"python","A_Id":3340981,"CreationDate":"2010-07-27T04:44:00.000","Title":"saving data and calling data python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can I ask for few question in one post to XML-RPC server?\nIf yes, how can I do it in python and xmlrpclib?\nI'm using XML-RPC server on slow connection, so I would like to call few functions at once, because each call costs me 700ms.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":3343082,"Users Score":0,"Answer":"Whether or not possible support of multicall makes any difference to you depends on where the 700ms is going.\nHow did you measure your 700ms?\nRun a packet capture of a query and analyse the results. It should be possible to infer roughly round-trip-time, bandwidth constraints, whether it's the application layer of the server or even the name resolution of your client machine.","Q_Score":0,"Tags":"python,soap,xml-rpc,xmlrpclib","A_Id":3343497,"CreationDate":"2010-07-27T11:25:00.000","Title":"Does XML-RPC in general allows to call few functions at once?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating Windows service class in Python that will eventually display a Window when certain conditions are met. Since (as I understand it) services cannot have GUIs, I'm trying to start up a GUI in a seperate process (using subprocess.Popen) when the conditions are right. This isn't working, presumably because the child process has the same privileges as the service.\nSo how do I start a process from a Python Windows Service that has the ability to display GUIs on the screen?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1456,"Q_Id":3343793,"Users Score":3,"Answer":"If you give your Service the Allow service to interact with desktop permission it will be able to create windows without the need to launch a subprocess.","Q_Score":0,"Tags":"python,user-interface,windows-services","A_Id":3343894,"CreationDate":"2010-07-27T12:54:00.000","Title":"Starting a GUI process from a Python Windows Service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","AnswerCount":19,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":184194,"Q_Id":3345785,"Users Score":0,"Answer":"This is against the very definition of an iterator, which is a pointer to an object, plus information about how to get to the next object.\nAn iterator does not know how many more times it will be able to iterate until terminating.  This could be infinite, so infinity might be your answer.","Q_Score":192,"Tags":"python,iterator","A_Id":19849720,"CreationDate":"2010-07-27T16:32:00.000","Title":"Getting number of elements in an iterator in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","AnswerCount":19,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":184194,"Q_Id":3345785,"Users Score":0,"Answer":"It's common practice to put this type of information in the file header, and for pysam to give you access to this.  I don't know the format, but have you checked the API?\nAs others have said, you can't know the length from the iterator.","Q_Score":192,"Tags":"python,iterator","A_Id":3346287,"CreationDate":"2010-07-27T16:32:00.000","Title":"Getting number of elements in an iterator in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","AnswerCount":19,"Available Count":5,"Score":0.0315684544,"is_accepted":false,"ViewCount":184194,"Q_Id":3345785,"Users Score":3,"Answer":"There are two ways to get the length of \"something\" on a computer.\nThe first way is to store a count - this requires anything that touches the file\/data to modify it (or a class that only exposes interfaces -- but it boils down to the same thing).\nThe other way is to iterate over it and count how big it is.","Q_Score":192,"Tags":"python,iterator","A_Id":3345950,"CreationDate":"2010-07-27T16:32:00.000","Title":"Getting number of elements in an iterator in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","AnswerCount":19,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":184194,"Q_Id":3345785,"Users Score":9,"Answer":"An iterator is just an object which has a pointer to the next object to be read by some kind of buffer or stream, it's like a LinkedList where you don't know how many things you have until you iterate through them. Iterators are meant to be efficient because all they do is tell you what is next by references instead of using indexing (but as you saw you lose the ability to see how many entries are next).","Q_Score":192,"Tags":"python,iterator","A_Id":3345902,"CreationDate":"2010-07-27T16:32:00.000","Title":"Getting number of elements in an iterator in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","AnswerCount":19,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":184194,"Q_Id":3345785,"Users Score":8,"Answer":"Regarding your original question, the answer is still that there is no way in general to know the length of an iterator in Python.\nGiven that you question is motivated by an application of the pysam library, I can give a more specific answer: I'm a contributer to PySAM and the definitive answer is that SAM\/BAM files do not provide an exact count of aligned reads.  Nor is this information easily available from a BAM index file.  The best one can do is to estimate the approximate number of alignments by using the location of the file pointer after reading a number of alignments and extrapolating based on the total size of the file.  This is enough to implement a progress bar, but not a method of counting alignments in constant time.","Q_Score":192,"Tags":"python,iterator","A_Id":3505917,"CreationDate":"2010-07-27T16:32:00.000","Title":"Getting number of elements in an iterator in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been getting more and more interested in using Pylons as my Python web framework and I like the idea of MVC but, coming from a background of never using 'frameworks\/design patterns\/ what ever it\\'s called', I don't really know how to approach it.\nFrom what I've read in the Pylons Book, so far, it seems I do the following:\n\nCreate my routes in .\/config\/routes.py\nThis is where I map URLs to controllers.\nCreate a controller for the URL\nThis is where the main body of the code lies. It does all the work and prepares it for viewing\nCreate my template\nI create a template and assign the data from the controller to it\n\nModels... I have no idea what they're for :\/\nSo my question is, can you recommend any reading materials for someone who clearly has no idea what they're doing?\nI really want to start using Pylons but I think in a few months time I'll come back to my code and think \"...what the F was I thinking :\/\"\nEDIT: A better, summarized, question came to mind:\nWhat code should be placed in the Controller?\nWhat code should I put in the Model?\nThe view is just the templating, right?\nAnd, in terms of Pylons, the 'lib' folder will contain code shared among Controllers or misc code that doesn't fit anywhere else - Right?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":3350972,"Users Score":0,"Answer":"Model is for your db-related code. All queries go there, including adding new records\/updating existing ones.\nControllers are somewhat ambigous, different projects use different approaches to it. Reddit for example does fair bit of what should be View in controllers.\nI, for one, prefer to limit my controllers to request processing and generation of some result object collections, which are then delivered to XHTML\/XML\/JSON views, depending on the type of request (so each controller should be used for both static page generation and AJAX handling).\n\nI really want to start using Pylons but I think in a few months time I'll come back to my code and think \"...what the F was I thinking :\/\"\n\nWell, thats inevitable, you should try different approaches to find the one which suits you best.","Q_Score":0,"Tags":"python,model-view-controller,design-patterns,pylons","A_Id":3410261,"CreationDate":"2010-07-28T08:06:00.000","Title":"Getting started with Pylons and MVC - Need some guidance on design","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"Does any one know how we can do this?\nI have python code in eclipse and whenever it calls c++ functions, i want the break point to go to the visual studio c++ project.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1619,"Q_Id":3351110,"Users Score":2,"Answer":"If the C++ app runs as a separate process then its pretty easy. You can run the process yourself or attach visual studio to existing running process and put break points. \nIf C++ code  is an embedded DLL\/LIB then you can use python as debug\/launch process. As soon as python will load the DLL\/LIB into your python code visual studio will activate your break points.\nAlternatively you can also add windows debugger launcher calls to your code. As soon as your code gets executed, you will see a dialog box asking if you want to attach a debugger.","Q_Score":4,"Tags":"c++,python,visual-studio,eclipse","A_Id":3776671,"CreationDate":"2010-07-28T08:28:00.000","Title":"Debug C++ code in visual studio from python code running in eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to scrape and submit information to websites that heavily rely on Javascript to do most of its actions. The website won't even work when i disable Javascript in my browser.\nI've searched for some solutions on Google and SO and there was someone who suggested i should reverse engineer the Javascript, but i have no idea how to do that. \nSo far i've been using Mechanize and it works on websites that don't require Javascript.\nIs there any way to access websites that use Javascript by using urllib2 or something similar? \nI'm also willing to learn Javascript, if that's what it takes.","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":23351,"Q_Id":3362859,"Users Score":6,"Answer":"I would actually suggest using Selenium.  Its mainly designed for testing Web-Applications from a \"user perspective however it is basically a \"FireFox\" driver.  I've actually used it for this purpose ... although I was scraping an dynamic AJAX webpage.  As long as the Javascript form has a recognizable \"Anchor Text\" that Selenium can \"click\" everything should sort itself out.\nHope that helps","Q_Score":17,"Tags":"javascript,python,screen-scraping","A_Id":3364608,"CreationDate":"2010-07-29T13:18:00.000","Title":"Scraping websites with Javascript enabled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the Bottle framework. I have set the @error decorator so I am able to display my customized error page, and i can also send email if any 500 error occurs, but I need the complete traceback to be sent in the email. Does anyone know how to have the framework include that in the e-mail?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":894,"Q_Id":3363167,"Users Score":3,"Answer":"in the error500 function written after the @error decorator to serve my customized error page, wrote error.exception and error.traceback, these two give the exception and complete traceback of the error message.","Q_Score":2,"Tags":"python,error-handling,bottle","A_Id":3393377,"CreationDate":"2010-07-29T13:47:00.000","Title":"E-mail traceback on errors in Bottle framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was wondering how to hide\/delete a StaticText in wxPython?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3670,"Q_Id":3367986,"Users Score":0,"Answer":"statictext.Show to show\nand \nstatictext.Hide to hide","Q_Score":4,"Tags":"python,wxpython,hide","A_Id":22358518,"CreationDate":"2010-07-30T00:37:00.000","Title":"Hide\/Delete a StaticText in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to hide\/delete a StaticText in wxPython?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3670,"Q_Id":3367986,"Users Score":5,"Answer":"Have you tried control.Hide() or control.Show(False)?","Q_Score":4,"Tags":"python,wxpython,hide","A_Id":3368074,"CreationDate":"2010-07-30T00:37:00.000","Title":"Hide\/Delete a StaticText in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to hide\/delete a StaticText in wxPython?","AnswerCount":3,"Available Count":3,"Score":0.3215127375,"is_accepted":false,"ViewCount":3670,"Q_Id":3367986,"Users Score":5,"Answer":"The widget's Hide\/Show methods should work. If the widget is in a sizer, then you can use the sizer's Detach method to \"hide\" it but not destroy it. Otherwise, the sizer has a Remove method that will remove the widget and destroy it. And there's the widget's own Destroy method.","Q_Score":4,"Tags":"python,wxpython,hide","A_Id":3371640,"CreationDate":"2010-07-30T00:37:00.000","Title":"Hide\/Delete a StaticText in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple application in Python which displays images.I need to implement Zoom In and Zoom Out by scaling the image.\nI think the Image.transform method will be able to do this, but I'm not sure how to use it, since it's asking for an affine matrix or something like that :P\nHere's the quote from the docs:\n\nim.transform(size, AFFINE, data, filter) => image\nApplies an affine transform to the image, and places the result in a new image with the given size.\nData is a 6-tuple (a, b, c, d, e, f) which contain the first two rows from an affine transform matrix. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c, d x + e y + f) in the input image, rounded to nearest pixel.\nThis function can be used to scale, translate, rotate, and shear the original image.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7941,"Q_Id":3368740,"Users Score":6,"Answer":"You would be much better off using the EXTENT rather than the AFFINE method. You only need to calculate two things: what part of the input you want to see, and how large it should be. For example, if you want to see the whole image scaled down to half size (i.e. zooming out by 2), you'd pass the data (0, 0, im.size[0], im.size[1]) and the size (im.size[0]\/2, im.size[1]\/2).","Q_Score":7,"Tags":"python,image-processing,python-imaging-library","A_Id":3368847,"CreationDate":"2010-07-30T04:43:00.000","Title":"Zooming With Python Image Library","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a LAMP developer trying out Python for the first time.. I'm okay with picking up the syntax, but I can't figure out how to run it on the server! I've tried the following\n\nuploading filename.py to a regular web\/public directory. chmod 777, 711, 733, 773... (variations of execute)\nputting the filename.py in cgi-bin, chmod same as above..\n\nTyping up example.com\/filename.py simply loads a textfile - nothing appears to have been compiled\/parsed\/etc!\n(I believe python is installed, as \nwhereis python on my server shows  \/usr\/bin\/python  among several other directories)\nMany words for a simple question - how do you run a python file on a CentOS server?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5711,"Q_Id":3369080,"Users Score":1,"Answer":"you can use cgi, but that will not have great performance as it starts a new process for each request.\nMore efficient alternatives are to use fastcgi or wsgi\nA third option is to run a mini Python webserver and proxy the requests from apache using rewrite rules","Q_Score":0,"Tags":"python,centos","A_Id":3369157,"CreationDate":"2010-07-30T06:17:00.000","Title":"Running a .py file on LAMP (CentOS) server - from a PHP developer's perspective","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I completed my first proper project in Python and now my task is to write tests for it.\nSince this is the first time I did a project, this is the first time I would be writing tests for it.\nThe question is, how do I start? I have absolutely no idea. Can anyone point me to some documentation\/ tutorial\/ link\/ book that I can use to start with writing tests (and I guess unit testing in particular)\nAny advice will be welcomed on this topic.","AnswerCount":7,"Available Count":1,"Score":0.0855049882,"is_accepted":false,"ViewCount":258822,"Q_Id":3371255,"Users Score":3,"Answer":"nosetests is a brilliant solution for unit testing in Python. It supports both unittest based testcases and doctests, and gets you started with it with just a simple configuration file.","Q_Score":545,"Tags":"python,unit-testing,testing","A_Id":3371690,"CreationDate":"2010-07-30T12:10:00.000","Title":"Writing unit tests in Python: How do I start?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Are there any examples how to authenticate your desktop Facebook application using PyQT and embedded webkit? \nThis is to provide better user experience than opening Facebook authentication page in a separate browser window.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":640,"Q_Id":3371549,"Users Score":0,"Answer":"I don't believe you can open an \"authentication page\" in a separate window under Facebook's terms (I used to work for Zynga, and we couldn't then, so I don't know how you'd achieve this now legally). \nSecond, you're looking into the QWebkit backwards I believe. From a UI perspective this is supposed to provide access to websites, and interact with them. If you want a good looking page, with all the bells and whistle, it pains me to say it ~ but use Actionscript 3, or Ajax and it's bundle.\nThis post would probably be answered better if tagged in the javascript, php, and as3 sections. As the php guys will know the correct hacks to get your intended result, if possible","Q_Score":4,"Tags":"python,facebook,webkit,pyqt","A_Id":5099848,"CreationDate":"2010-07-30T12:51:00.000","Title":"pyqt, webkit and facebook authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Howdy.  I'm working on migrating an internal system to Django and have run into a few wrinkles.\nIntro\nOur current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc.\nBase Objects\nSo I have two base objects\/models:\nJournalEntry\nJournalEntryItems\n\ndefined as follows:\n\nclass JournalEntry(models.Model):\n    gjID = models.AutoField(primary_key=True)\n    date = models.DateTimeField('entry date');\n    memo = models.CharField(max_length=100);\n\nclass JournalEntryItem(models.Model):\n\n    journalEntryID = models.AutoField(primary_key=True)\n    gjID = models.ForeignKey(JournalEntry, db_column='gjID')\n    amount = models.DecimalField(max_digits=10,decimal_places=2)\n\nSo far, so good.  It works quite smoothly on the admin side (inlines work, etc.)\nOn to the next section.\nWe then have two more models\nInvoiceEntry\nInvoiceEntryItem\n\nAn InvoiceEntry is a superset of \/ it inherits from JournalEntry, so I've been using a OneToOneField (which is what we're using in the background on our current site).  That works quite smoothly too.\n\nclass InvoiceEntry(JournalEntry):\n    invoiceID = models.AutoField(primary_key=True, db_column='invoiceID', verbose_name='')\n    journalEntry = models.OneToOneField(JournalEntry, parent_link=True, db_column='gjID')\n    client = models.ForeignKey(Client, db_column='clientID')\n\n    datePaid = models.DateTimeField(null=True, db_column='datePaid', blank=True, verbose_name='date paid')\n\n\nWhere I run into problems is when trying to add an InvoiceEntryItem (which inherits from JournalEntryItem) to an inline related to InvoiceEntry.  I'm getting the error:\n\n<class 'billing.models.InvoiceEntryItem'> has more than 1 ForeignKey to <class 'billing.models.InvoiceEntry'>\n\nThe way I see it, InvoiceEntryItem has a ForeignKey directly to InvoiceEntry.  And it also has an indirect ForeignKey to InvoiceEntry through the JournalEntry 1->M JournalEntryItems relationship.\nHere's the code I'm using at the moment.\n\nclass InvoiceEntryItem(JournalEntryItem):\n    invoiceEntryID = models.AutoField(primary_key=True, db_column='invoiceEntryID', verbose_name='')\n    invoiceEntry = models.ForeignKey(InvoiceEntry, related_name='invoiceEntries', db_column='invoiceID')\n    journalEntryItem = models.OneToOneField(JournalEntryItem, db_column='journalEntryID')\n\n\nI've tried removing the journalEntryItem OneToOneField.  Doing that then removes my ability to retrieve the dollar amount for this particular InvoiceEntryItem (which is only stored in journalEntryItem).\nI've also tried removing the invoiceEntry ForeignKey relationship.  Doing that removes the relationship that allows me to see the InvoiceEntry 1->M InvoiceEntryItems in the admin inline.  All I see are blank fields (instead of the actual data that is currently stored in the DB).\n\nIt seems like option 2 is closer to what I want to do.  But my inexperience with Django seems to be limiting me.  I might be able to filter the larger pool of journal entries to see just invoice entries.  But it would be really handy to think of these solely as invoices (instead of a subset of journal entries).\nAny thoughts on how to do what I'm after?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":709,"Q_Id":3376479,"Users Score":0,"Answer":"All fields in the superclass also exist on the subclass, so having an explicit relation is unnecessary.\nModel inheritance in Django is terrible. Don't use it. Python doesn't need it anyway.","Q_Score":2,"Tags":"python,django,inheritance,inline,admin","A_Id":3376487,"CreationDate":"2010-07-31T02:08:00.000","Title":"Django object extension \/ one to one relationship issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Howdy.  I'm working on migrating an internal system to Django and have run into a few wrinkles.\nIntro\nOur current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc.\nBase Objects\nSo I have two base objects\/models:\nJournalEntry\nJournalEntryItems\n\ndefined as follows:\n\nclass JournalEntry(models.Model):\n    gjID = models.AutoField(primary_key=True)\n    date = models.DateTimeField('entry date');\n    memo = models.CharField(max_length=100);\n\nclass JournalEntryItem(models.Model):\n\n    journalEntryID = models.AutoField(primary_key=True)\n    gjID = models.ForeignKey(JournalEntry, db_column='gjID')\n    amount = models.DecimalField(max_digits=10,decimal_places=2)\n\nSo far, so good.  It works quite smoothly on the admin side (inlines work, etc.)\nOn to the next section.\nWe then have two more models\nInvoiceEntry\nInvoiceEntryItem\n\nAn InvoiceEntry is a superset of \/ it inherits from JournalEntry, so I've been using a OneToOneField (which is what we're using in the background on our current site).  That works quite smoothly too.\n\nclass InvoiceEntry(JournalEntry):\n    invoiceID = models.AutoField(primary_key=True, db_column='invoiceID', verbose_name='')\n    journalEntry = models.OneToOneField(JournalEntry, parent_link=True, db_column='gjID')\n    client = models.ForeignKey(Client, db_column='clientID')\n\n    datePaid = models.DateTimeField(null=True, db_column='datePaid', blank=True, verbose_name='date paid')\n\n\nWhere I run into problems is when trying to add an InvoiceEntryItem (which inherits from JournalEntryItem) to an inline related to InvoiceEntry.  I'm getting the error:\n\n<class 'billing.models.InvoiceEntryItem'> has more than 1 ForeignKey to <class 'billing.models.InvoiceEntry'>\n\nThe way I see it, InvoiceEntryItem has a ForeignKey directly to InvoiceEntry.  And it also has an indirect ForeignKey to InvoiceEntry through the JournalEntry 1->M JournalEntryItems relationship.\nHere's the code I'm using at the moment.\n\nclass InvoiceEntryItem(JournalEntryItem):\n    invoiceEntryID = models.AutoField(primary_key=True, db_column='invoiceEntryID', verbose_name='')\n    invoiceEntry = models.ForeignKey(InvoiceEntry, related_name='invoiceEntries', db_column='invoiceID')\n    journalEntryItem = models.OneToOneField(JournalEntryItem, db_column='journalEntryID')\n\n\nI've tried removing the journalEntryItem OneToOneField.  Doing that then removes my ability to retrieve the dollar amount for this particular InvoiceEntryItem (which is only stored in journalEntryItem).\nI've also tried removing the invoiceEntry ForeignKey relationship.  Doing that removes the relationship that allows me to see the InvoiceEntry 1->M InvoiceEntryItems in the admin inline.  All I see are blank fields (instead of the actual data that is currently stored in the DB).\n\nIt seems like option 2 is closer to what I want to do.  But my inexperience with Django seems to be limiting me.  I might be able to filter the larger pool of journal entries to see just invoice entries.  But it would be really handy to think of these solely as invoices (instead of a subset of journal entries).\nAny thoughts on how to do what I'm after?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":709,"Q_Id":3376479,"Users Score":1,"Answer":"First, inheriting from a model creates an automatic OneToOneField in the inherited model towards the parents so you don't need to add them. Remove them if you really want to use this form of model inheritance. \nIf you only want to share the member of the model, you can use Meta inheritance which will create the inherited columns in the table of your inherited model. This way would separate your JournalEntry in 2 tables though but it would be easy to retrieve only the invoices.","Q_Score":2,"Tags":"python,django,inheritance,inline,admin","A_Id":3396991,"CreationDate":"2010-07-31T02:08:00.000","Title":"Django object extension \/ one to one relationship issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i have a scene with a multiple (QGraphicsTextItem)s, and  i need to have control over their colors , so how to change a color of a QGraphicsTextItem ? is it possible anyway? i've been trying for 3 days until now . please help\n\nthanks in advance","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":8684,"Q_Id":3377439,"Users Score":2,"Answer":"setDefaultTextColor(col) \"Sets the color for unformatted text to col.\" The documentation is not clear about what \"unformatted text\" means.  I think it means: \"all portions of the contents of the item that have not been styled.\"\nThe contents is a QTextDocument.\nYou style a part of a document using a QTextCursor.  You can't style the QTextDocument per se, only a part that is selected by a QTextCursor (but you can select the whole document.)\nYou can style a QTextCursor using method mergeCharFormat(QTextCharFormat)\nThe QTextCharFormat has methods:\n\nforeground().setColor(QColor)  \nsetForeground(QBrush)\nsetTextOutline(QPen)\n\nForeground is a QBrush that paints several things including \"text\" (but better said: the fill of characters?)\nOne nuance is that certain newly constructed QBrush have (default to) QBrushStyle.NoBrush, which is transparent, even if you setColor().","Q_Score":10,"Tags":"python,qt,qt4,pyqt","A_Id":12565371,"CreationDate":"2010-07-31T08:52:00.000","Title":"how to change the color of a QGraphicsTextItem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written an app in python that depends on wxPython and some other python libraries. I know about pyexe for making python scripts executable on Windows, but what would be the easiest way to share this with my Mac using friends who wouldn't know how to install the required dependencies? One option would be to bundle my dependencies in the same package, but that seems kind of clunky. How do people usually deploy such apps? For once I miss Java...","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":523,"Q_Id":3379032,"Users Score":0,"Answer":"How do people usually deploy such apps?\n\n2 choices.\n\nWith instructions.\nAll bundled up.\n\nYou write simple instructions like this.  Folks can follow these pretty reliably, unless they don't have enough privileges.  Sometimes they need to sudo in linux environments.\n\nDownload easy_install (or pip)\neasy_install this, easy_install that (or pip this, pip that)\neasy_install whatever package you wrote.\n\nIt works really well.  If you download some Python packages you'll see this in action.\nSphinx requires docutils.  Django requires docutils and PIL.  It works out really well to simply document the dependencies.  Other folks seem to do it without serious problems.  Follow their lead.\nBundling things up means you have to \n(a) provide the entire original distribution (as required by most open source licenses)\n(b) provide a compatible open source license with the licenses of the things you bundled.  This can be easy if you depend on things that all of the same license.  Otherwise, you basically can't redistribute them and have to resort to installation instructions.","Q_Score":2,"Tags":"python,deployment","A_Id":3379058,"CreationDate":"2010-07-31T17:03:00.000","Title":"Deploying python app to Mac and Windows users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a WxPython app that, among other things, has a integrated file-browser.\nI want to be able to create a system-default file context menu (e.g. what you get if you right-click on a file in windows explorer) when a user right clicks on one of the items within my application.\nNote: I already know how to create my own context menu (e.g. wx.EVT_LIST_ITEM_RIGHT_CLICK), I want the Windows context menu.\nTo clarify, I do not want, or need to modify the existing system context menu, I want to be able to display it for a specific file within my application. \nBasically, I know what was right clicked on, and where the mouse pointer is (if it's needed). I want to create the system context menu there, just like it works in windows explorer.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":741,"Q_Id":3380986,"Users Score":0,"Answer":"If you have python win32 installed, then look under the directory <PYTHON>\/lib\/site-packages\/win32comext\/shell\/demos\/servers.  This contains a file context_menu.py which has sample code for creating a shell extension.\nUpdate: I think you want the folder_view.py sample.","Q_Score":0,"Tags":"python,user-interface,windows-xp,wxpython","A_Id":3380995,"CreationDate":"2010-08-01T06:20:00.000","Title":"Create Explorer.exe's File - Context Menu in WxPython application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project using Tkinter and Python. In order to have native theming and to take advantage of the new widgets I'm using ttk in Python 2.6. My problem is how to allow the user to scroll through the tabs in the notebook widget (a la firefox). Plus, I need a part in the right edge of the tabs for a close button. The frame for the active tab would need to fill the available horizontal space (including under the scroll arrows).\nI thought I could do this using the Place geometry manager, but I was wondering if there was a better way? The ttk python docs don't have any methods to deal with this that I could see. \nEdit: looks like there are difficulties for even trying to implement this using place. For one, I'd still need the tabs to scroll and the active panel to stay in the one place.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1350,"Q_Id":3386098,"Users Score":0,"Answer":"I've never used these widgets so I have no idea how possible this is, but what I would try is something akin to the grid_remove() method. If you can move the tabs to an invisible widget, or just make them invisible without losing content, that's what I'd look for\/try.","Q_Score":1,"Tags":"python,user-interface,tkinter,ttk","A_Id":3389225,"CreationDate":"2010-08-02T08:20:00.000","Title":"Using the ttk (tk 8.5) Notebook widget effectively (scrolling of tabs)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project using Tkinter and Python. In order to have native theming and to take advantage of the new widgets I'm using ttk in Python 2.6. My problem is how to allow the user to scroll through the tabs in the notebook widget (a la firefox). Plus, I need a part in the right edge of the tabs for a close button. The frame for the active tab would need to fill the available horizontal space (including under the scroll arrows).\nI thought I could do this using the Place geometry manager, but I was wondering if there was a better way? The ttk python docs don't have any methods to deal with this that I could see. \nEdit: looks like there are difficulties for even trying to implement this using place. For one, I'd still need the tabs to scroll and the active panel to stay in the one place.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1350,"Q_Id":3386098,"Users Score":2,"Answer":"The notebook widget doesn't do scrolling of tabs (or multiple layers of them either) because the developer doesn't believe that they make for a good GUI. I can see his point; such GUIs tend to suck. The best workaround I've seen is to have a panel on the side that allows the selection of which pane to display. You can then apply tricks to that panel to manage the amount of information there (e.g., by making it a treeview widget and holding the info hierarchically, much like most email clients handle mail folders; treeview widgets are scrollable).","Q_Score":1,"Tags":"python,user-interface,tkinter,ttk","A_Id":3650157,"CreationDate":"2010-08-02T08:20:00.000","Title":"Using the ttk (tk 8.5) Notebook widget effectively (scrolling of tabs)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Do you know how I could get one of the IPv6 adress of one of my interface in python2.6. I tried something with the socket module which lead me nowhere.\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3133,"Q_Id":3388911,"Users Score":0,"Answer":"You could just simply run 'ifconfig' with a subprocess.* call and parse the output.","Q_Score":6,"Tags":"python,linux,ipv6","A_Id":3388966,"CreationDate":"2010-08-02T14:53:00.000","Title":"How to get the IPv6 address of an interface under linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a thumbnail, and the width has to be either fixed or no bigger than 200 pixels wide (the length can be anything).\nThe images are either .jpg or .png or .gif\nI am using python.\nThe reason it has to be fixed is so that it fits inside a html table cell.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":405,"Q_Id":3391558,"Users Score":3,"Answer":"Look at PyMagick, the python interface for the ImageMagick libraries.  It's fairly simple to resize an image, retaining proportion, while limiting the longest side.\nedit: when I say fairly simple, I mean you can describe your resize in terms of the longest acceptable values for each side, and ImageMagick will preserve the proportions automatically.","Q_Score":1,"Tags":"python,image","A_Id":3391578,"CreationDate":"2010-08-02T20:40:00.000","Title":"Need to create thumbnail, how to ensure proportions and set fixed width?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have this line:\nNSWorkspace.sharedWorkspace().setIcon_forFile_options_(unicode(icon),unicode(target),0)\nWhy does it give that error and how do I fix it?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":318,"Q_Id":3391692,"Users Score":1,"Answer":"I misread the documentation. I need to do this:\nNSWorkspace.sharedWorkspace().setIcon_forFile_options_(NSImage.alloc().initWithContentsOfFile_(icon),target,0)\nUnfortunately the error is what confused me.","Q_Score":0,"Tags":"python,objective-c,unicode,pyobjc","A_Id":3391733,"CreationDate":"2010-08-02T20:58:00.000","Title":"PyObjC giving strange error - [OC_PythonUnicode representations]: unrecognized selector sent to instance 0x258ae2a0","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"The website says:\n\nClosing connections: Fabric\u2019s\n  connection cache never closes\n  connections itself \u2013 it leaves this up\n  to whatever is using it. The fab tool\n  does this bookkeeping for you: it\n  iterates over all open connections and\n  closes them just before it exits\n  (regardless of whether the tasks\n  failed or not.)\nLibrary users will need to ensure they\n  explicitly close all open connections\n  before their program exits, though we\n  plan to makes this easier in the\n  future.\n\nI have searched everywhere, but I can't find out how to disconnect or close the connections.  I am looping through my hosts and setting env.host_string.  It is working, but hangs when exiting.  Any help on how to close?  Just to reiterate, I am using the library, not a fabfile.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4881,"Q_Id":3392333,"Users Score":4,"Answer":"If you don't want to have to iterate through all open connections, fabric.network.disconnect_all() is what you're looking for. The docstring reads\n\n\"\"\"\nDisconnect from all currently connected servers.\nUsed at the end of fab's main loop, and also intended for use by library users.\n\"\"\"","Q_Score":6,"Tags":"python,fabric","A_Id":5531404,"CreationDate":"2010-08-02T22:34:00.000","Title":"Disconnecting from host with Python Fabric when using the API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project that requires password protected downloading, but I'm not exactly sure how to implement that. If the target file has a specific extension (.exe, .mp3, .mp4, etc), I want to prompt the user for a username and password. Any ideas on this?\nI am using Python 26 on Windows XP.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":450,"Q_Id":3393314,"Users Score":2,"Answer":"This is best implemented at the web server level.\nIf you are using Apache, this can be done by placing the files you desire to protect in a directory with an htaccess file which requires user authentication.\nThen, implement HTTP Basic Auth in your Python script to download the files.  Make sure to use an SSL connection; basic auth sends the user's password over the wire in the clear.","Q_Score":0,"Tags":"python,windows,passwords,download","A_Id":3393326,"CreationDate":"2010-08-03T02:57:00.000","Title":"Prevent A User From Downloading Files from Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a website where files are uploaded through the admin and this will then store them on Amazon S3. I'm using django-storages and boto for this, and it seems to be working just fine.\nThing is, I'm used to use my easy_thumbnails (the new sorl.thumbnail) on the template side to create thumbnails on the fly. I prefer this approach, rather than the model side, as it allows for easier maintenance if ever I decide to change the thumbnail size at a later date etc.\nBut I'm realising that easy_thumbnails doesn't seem to like reading the image now it's stored on Amazon S3. Also, I realised, where exactly would it be putting the thumbnails once made anyhow? Obviously, I'd prefer these to be on Amazon S3 as well. But how do I get these two technologies to play nice?\nHow would I get easy_thumbnails to store the thumb it creates back on Amazon S3? Or am I just looking at this all wrong?!\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1958,"Q_Id":3397599,"Users Score":17,"Answer":"easy_thumbnails will do S3-based image thumbnailing for you - you just need to set settings.THUMBNAIL_DEFAULT_STORAGE, so that easy_thumbnails knows which storage to use (in your case, you probably want to set it to the same storage you're using for your ImageFields).","Q_Score":5,"Tags":"python,django,amazon-s3,thumbnails","A_Id":5262932,"CreationDate":"2010-08-03T14:38:00.000","Title":"In Django, how to get django-storages, boto and easy_thumbnail to work nicely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested.\nSo my question is can i verify the links in a loop or i need to try  every link on my own?\ni tried to do this with __iter__ but  it didn't get any close ,there may be a reason that i'm poor at oop, but i still think that there must me another way of testing links than clicking them and recording one by one.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":3397850,"Users Score":0,"Answer":"What exactly is \"Testing links\"?\nIf it means they lead to non-4xx URIs, I'm afraid You must visit them.\nAs for existence of given links (like \"Contact\"), You may look for them using xpath.","Q_Score":2,"Tags":"python,testing,black-box","A_Id":3397887,"CreationDate":"2010-08-03T15:05:00.000","Title":"how can i verify all links on a page as a black-box tester","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested.\nSo my question is can i verify the links in a loop or i need to try  every link on my own?\ni tried to do this with __iter__ but  it didn't get any close ,there may be a reason that i'm poor at oop, but i still think that there must me another way of testing links than clicking them and recording one by one.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":3397850,"Users Score":0,"Answer":"You could (as yet another alternative), use BeautifulSoup to parse the links on your page and try to retrieve them via urllib2.","Q_Score":2,"Tags":"python,testing,black-box","A_Id":3399490,"CreationDate":"2010-08-03T15:05:00.000","Title":"how can i verify all links on a page as a black-box tester","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible?\n\nInfo:\nI wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type \"python SQLsap args\" and would rather just type \"SQLsap args\". I don't know if this is even possible, but it would be good to know if it is. For more than just this program.","AnswerCount":6,"Available Count":2,"Score":0.1651404129,"is_accepted":false,"ViewCount":14699,"Q_Id":3400381,"Users Score":5,"Answer":"You want a shebang. #!\/path\/to\/python. Put that on the first line of your python script. The #! is actually a magic number that tells the operating system to interpret the file as a script for the program named. You can supply \/usr\/bin\/python or, to be more portable, \/usr\/bin\/env python which calls the \/usr\/bin\/env program and tells it you want the system's installed Python interpreter.\nYou'll also have to put your script in your path, unless you're okay with typing .\/SQLsap args.","Q_Score":12,"Tags":"python,linux,shell,command-line","A_Id":3400402,"CreationDate":"2010-08-03T20:08:00.000","Title":"Calling a python script from command line without typing \"python\" first","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible?\n\nInfo:\nI wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type \"python SQLsap args\" and would rather just type \"SQLsap args\". I don't know if this is even possible, but it would be good to know if it is. For more than just this program.","AnswerCount":6,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":14699,"Q_Id":3400381,"Users Score":4,"Answer":"Assuming this is on a unix system, you can add a \"shebang\" on the top of the file like this:\n#!\/usr\/bin\/env python\nAnd then set the executable flag like this:\nchmod +x SQLsap","Q_Score":12,"Tags":"python,linux,shell,command-line","A_Id":3400404,"CreationDate":"2010-08-03T20:08:00.000","Title":"Calling a python script from command line without typing \"python\" first","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have 10 arbitrary letters and need to check the max length match from words file\n\nI started to learn RE just some time ago, and can't seem to find suitable pattern\n\nfirst idea that came was using set: [10 chars] but it also repeats included chars and I don't know how to avoid that\n\nI stared to learn Python recently but before RE and maybe RE is not needed and this can be solved without it\n\nusing \"for this in that:\" iterator seems inappropriate, but maybe itertools can do it easily (with which I'm not familiar)\n\n\nI guess solution is known even to novice programmers\/scripters, but not to me\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1499,"Q_Id":3402574,"Users Score":0,"Answer":"I assume you are trying to find out what is the longest word that can be made from your 10 arbitrary letters.\nYou can keep your 10 arbitrary letters in a dict along with the frequency they occur.\ne.g., your 4 (using 4 instead of 10 for simplicity) arbitrary letters are:  e, w, l, l.  This would be in a dict as:\n{'e':1, 'w':1, 'l':2}\nThen for each word in the text file, see if all of the letters for that word can be found in your dict of arbitrary letters.  If so, then that is one of your candidate words.\nSo:\nwe\nwall\nwell\nall of the letters in well would be found in your dict of arbitrary letters so save it and its length for comparison against other words.","Q_Score":0,"Tags":"python,puzzle,iterator","A_Id":3402637,"CreationDate":"2010-08-04T04:31:00.000","Title":"Find max length word from arbitrary letters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm scraping a html page, then using xml.dom.minidom.parseString() to create a dom object.\nhowever, the html page has a '&'.  I can use cgi.escape to convert this into &amp; but it also converts all my html <> tags into &lt;&gt; which makes parseString() unhappy.\nhow do i go about this?  i would rather not just hack it and straight replace the \"&\"s\nthanks","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":576,"Q_Id":3403168,"Users Score":0,"Answer":"You shouldn't use an XML parser to parse data that isn't XML.  Find an HTML parser instead, you'll be happier in the long run.  The standard library has a few (HTMLParser and htmllib), and BeautifulSoup is a well-loved third-party package.","Q_Score":1,"Tags":"python,escaping,html-entities","A_Id":3405525,"CreationDate":"2010-08-04T06:40:00.000","Title":"need to selectively escape html entities (&)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":3548,"Q_Id":3409226,"Users Score":2,"Answer":"I'm using eclipse 3.6 and pydev with python 2.6 and it's the best one I've tested up to now. I didn't try 3.5 so not sure if it's the same as yours but I think it autocompletes well compared to others I tried but I didn't try any of the paid ones.","Q_Score":0,"Tags":"python,eclipse,intellisense,pydev","A_Id":3409335,"CreationDate":"2010-08-04T19:41:00.000","Title":"How do you get Intellisense for Python in Eclipse\/Aptana\/Pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":3548,"Q_Id":3409226,"Users Score":3,"Answer":"You are probably never going to get something as good as intellisense for python. Due to the dynamic nature of python, it is often impossible to be able to know the type of some variables. \nAnd if you don't know their types, you can't do auto-complete on things like class members.\nPersonally, I think the auto-complete in PyDev is pretty good, given the nature of python. It isn't as good as for Java and probably won't be, but it sure beats not having anything.\nHaving said that, I haven't tried if PyDev is able to use the parameter types you can specify in python 3.x. Otherwise, that might be an improvement that could make life a little easier.\nUpdate: Got curious and did a quick test, Looks like optional type information in python 3 is not used by PyDev.","Q_Score":0,"Tags":"python,eclipse,intellisense,pydev","A_Id":3409439,"CreationDate":"2010-08-04T19:41:00.000","Title":"How do you get Intellisense for Python in Eclipse\/Aptana\/Pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3548,"Q_Id":3409226,"Users Score":0,"Answer":"In Aptana I added the reference to the .egg file to the system PYTHONPATH in Preferences menu. I am not sure if this works for every library out there.\nPreferences --> PyDev --> Interpreter Python --> Libraries tab on the right.","Q_Score":0,"Tags":"python,eclipse,intellisense,pydev","A_Id":9141159,"CreationDate":"2010-08-04T19:41:00.000","Title":"How do you get Intellisense for Python in Eclipse\/Aptana\/Pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently moved a django app from c:\\Users\\user\\django-projects\\foo\\foobar to c:\\Python25\\Lib\\site-packages\\foo\\foobar (which is on the python path). I started a new app in the django-projects directory, and added foo.foobar to the INSTALLED_APPS setting. When I try to run the dev server (manage.py runserver) for my new app, I get the error ImportError: No module named foobar.\nLooking through the traceback, it's looking in the c:\\Users\\user\\django-projects\\foo\\..\\foo\\foobar for the foobar app. I checked my PATH and PYTHONPATH environment variables, and neither point to c:\\Users\\user\\django-projects\\foo and It doesn't show up in sys.path when I run the python interpreter.\nI'm guessing I somehow added c:\\Users\\user\\django-projects\\foo to django's path sometime along the development of foo but I don't remember how I did it.\nSo, with all that lead up, my question is \"how do I make manage.py look in c:\\Python25\\Lib\\site-packages instead of c:\\Users\\user\\django-projects\\foo?\"\nThanks,\n\nLexo","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2351,"Q_Id":3411131,"Users Score":1,"Answer":"manage.py imports settings.py from the current directory and pass settings as parameter to execute_manager. You probably defined project root in settings.py.","Q_Score":0,"Tags":"python,django,path,django-manage.py,devserver","A_Id":3411300,"CreationDate":"2010-08-05T01:30:00.000","Title":"Where does django dev server (manage.py runserver) get its path from?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have the following problem: I have a local .zip file and a .zip file located on a server. I need to check if the .zip file on the server is different from the local one; if they are not I need to pull the new one from the server. My question is how do I compare them without downloading the file from the server and comparing them locally?\nI could create an MD5 hash for the zip file on the server when creating the .zip file and then compare it with the MD5 of my local .zip file, but is there a simpler way?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4055,"Q_Id":3423510,"Users Score":0,"Answer":"You can log in using ssh and make a md5 hash for the file remotely and a md5 hash for the current local file. If the md5s are matching the files are identicaly, else they are different.","Q_Score":2,"Tags":"python,comparison,md5","A_Id":3423577,"CreationDate":"2010-08-06T11:58:00.000","Title":"Comparing local file with remote file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following problem: I have a local .zip file and a .zip file located on a server. I need to check if the .zip file on the server is different from the local one; if they are not I need to pull the new one from the server. My question is how do I compare them without downloading the file from the server and comparing them locally?\nI could create an MD5 hash for the zip file on the server when creating the .zip file and then compare it with the MD5 of my local .zip file, but is there a simpler way?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4055,"Q_Id":3423510,"Users Score":0,"Answer":"I would like to know how you intend to compare them locally, if it were the case. You can apply the same logic to compare them remotely.","Q_Score":2,"Tags":"python,comparison,md5","A_Id":3423559,"CreationDate":"2010-08-06T11:58:00.000","Title":"Comparing local file with remote file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?","AnswerCount":12,"Available Count":7,"Score":0.049958375,"is_accepted":false,"ViewCount":509,"Q_Id":3427795,"Users Score":3,"Answer":"I'd recommend purchasing a copy of \"Clean Code\" by Robert C. Martin. It is full of great suggstions ranging from naming conventions to how to write easy-to-understand functions and much more. Definitely worth a read. I know it influenced my coding style since reading it.","Q_Score":4,"Tags":".net,python,language-agnostic,naming-conventions","A_Id":3427822,"CreationDate":"2010-08-06T21:05:00.000","Title":"are there tutorials on how to name variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?","AnswerCount":12,"Available Count":7,"Score":0.0333209931,"is_accepted":false,"ViewCount":509,"Q_Id":3427795,"Users Score":2,"Answer":"Have you read Code Complete? He does a full treatise on this in the book. Definitely the best naming strategy I've seen in print... And it's easy to find like 1000 programmers at the drop of a hat who name this one of the top 5 resources for programmers and program design.\nJust my $.05","Q_Score":4,"Tags":".net,python,language-agnostic,naming-conventions","A_Id":3427834,"CreationDate":"2010-08-06T21:05:00.000","Title":"are there tutorials on how to name variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?","AnswerCount":12,"Available Count":7,"Score":0.049958375,"is_accepted":false,"ViewCount":509,"Q_Id":3427795,"Users Score":3,"Answer":"There are many different views on the specifics of naming conventions, but the overall gist could be summed up as:\n\nEach variable name should be relevant\n  to whatever data is stored in the\n  variable. \nYour naming scheme should be consistent.\n\nSo a major no-no would be\nsingle letter variables (some people\nuse i and j for indexing loops, which\nis OK because every programmer knows\nwhat they are. Nevertheless, I prefer\n'idx' instead of 'i'). Also out are\nnames like 'method1', it means nothing\n- it should indicate what the variable holds.\nAnother (less common) convention is the 'Hungarian' notation where the data type is prefixed to the variable name such as 'int i_idx'. This is quite useless in modern, object oriented programming languages. Not to mention a blatant violation of the DRY principle.\nThe second point, consistency, is just as important. camelCase, UpperCamelCase, whatever - just don't switch between them for no reason.\nYou'll find that naming conventions vary from language to language and often, a company will have their own rules on naming. \nIts a worthwhile investment to properly name your variables because when you come to maintain your code much later on and you have forgotten what everything means, it will pay dividends.","Q_Score":4,"Tags":".net,python,language-agnostic,naming-conventions","A_Id":3427856,"CreationDate":"2010-08-06T21:05:00.000","Title":"are there tutorials on how to name variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?","AnswerCount":12,"Available Count":7,"Score":0.0166651236,"is_accepted":false,"ViewCount":509,"Q_Id":3427795,"Users Score":1,"Answer":"It's not clear if your question relates to Python naming conventions.\nIf so, for starters I would try to follow just these simple rules:\n\nClassName - upper case for class names\nvariable_name - lower case and underscore for variables (I try to keep them at two words maximum)","Q_Score":4,"Tags":".net,python,language-agnostic,naming-conventions","A_Id":3428775,"CreationDate":"2010-08-06T21:05:00.000","Title":"are there tutorials on how to name variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?","AnswerCount":12,"Available Count":7,"Score":0.0831409664,"is_accepted":false,"ViewCount":509,"Q_Id":3427795,"Users Score":5,"Answer":"A bad convention followed fully is better than a combination of different good \"conventions\" (which aren't conventions at all any more, if they aren't kept to).\nHowever, a convention that is making something less clear than if it had been ignored, should be ignored.\n\nThose are the only two I would state as any sort of rule. Beyond that convention preferences are a matter of opinions quickly turning into rants. The rest of this post is exactly that, and shouldn't be read as anything else.\n\nFor collections, use natural language plurals. In English, this means data, schemata, children, indices, criteria, formulae (and indeed foci, geese, feet, men, women, teeth) not made-up words like datums schemas, childs, indexes, criterions, formulas (and likewise focuses, gooses, foots, mans, womans, tooths, believe it or not I've actually seen some of those in use). Camel-casing and abbreviatiating does enough damage to English as it is, without doing more. Okay, I've never seen datums, but I have seen the meta-plural datas. Sweet Aradia, why?\nThat said, use American English for names, even if you use a different dialect of English. Most coders with such dialects have learnt to think of \"color\" as a word for colours in a computer context by the age of 12, and the principle applies more widely. If we can deal with \"color\" (one of Webster's worse bastardisations) we can deal with -ize and -ization (-ise and -isation is a pseudo-French 18th C affectation anyway, the Americans are the traditionalists on this one).\nSimilarly, if you aren't sure how to spell a word that you are using as the whole or part of a name, look it up (google it and see what google says). Somebody may spend a long time distracted by your misspelling that is so liberally distributed throughout running code as to make fixing it daunting.\nHungarian is bad (in many modern languages, though in some it has its place) but the principle is good. If you can tell a const, static, instance, local and parameter variable from each other in a split-second, that's good. If you can tell something of the intent immediately, that's good too.\nRelated to that, _ before public variables makes them non CLR compiant. That's actually a good thing for private variables (if you make them public for a quick experiment, and forget to fix the visibility, the compiler will warn you).\nRemember Postel's Law, \"be conservative in what you do, be liberal in what you accept from others\". One example of this is to act as if you are using a case-sensitive langauge, even if you're using a case-insensitive one. A related one is to be more of a stickler in public names than private ones. Yet another is to pay more attention to following conventions well than to complaining about those who don't.","Q_Score":4,"Tags":".net,python,language-agnostic,naming-conventions","A_Id":3428433,"CreationDate":"2010-08-06T21:05:00.000","Title":"are there tutorials on how to name variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?","AnswerCount":12,"Available Count":7,"Score":1.2,"is_accepted":true,"ViewCount":509,"Q_Id":3427795,"Users Score":4,"Answer":"All the answers here are quite valid. Most important: be consistent.\nThat said, here are my rules (C#):\n\ncamelCase identifiers -- I personally\nfind this much easier to read than\nunderscores \nPublic properties start\nwith a capital letter\nSomething I\nshould never touch starts with an\nunderscore -- example, the backing\nfield to a property should only be\ntouched from the property. If I have\nunderscores elsewhere, I know I'm\nwrong\nApps Hungarian where\nappropriate -- ints describing row\nIDs perhaps could be named\nrowSelected, rowNextUnread, et\ncetera. This is different than\nSystems Hungarian, which would mark\nthem as ints such as iSelected,\niNextUnread. Systems Hungarian\ndoesn't add much if anything, where\nApps Hungarian gives information the\ntype doesn't: it tells me adding\nrowItemsPerPage and colSelected is a\nmeaningless operation, even though it\ncompiles just fine.","Q_Score":4,"Tags":".net,python,language-agnostic,naming-conventions","A_Id":3428164,"CreationDate":"2010-08-06T21:05:00.000","Title":"are there tutorials on how to name variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?","AnswerCount":12,"Available Count":7,"Score":0.0166651236,"is_accepted":false,"ViewCount":509,"Q_Id":3427795,"Users Score":1,"Answer":"Can I make a shameless plug for the \"Names\" chapter in my book, \"A Sane Approach to Database Design\" ? I'm specifically talking about names for things in databases, but most of the same considerations apply to variables in programs.","Q_Score":4,"Tags":".net,python,language-agnostic,naming-conventions","A_Id":3428577,"CreationDate":"2010-08-06T21:05:00.000","Title":"are there tutorials on how to name variables?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I use Eclipse for programming in PHP (PDT), Python and sometimes Android. Each of this programming languages requires to run many things after Eclipse start.\nOf course I do not use all of them at one moment, I have different workspace for each of those. Is there any way, or recommendation, how to make Eclipse to run only neccessary tools when opening defined workspace?\ne.g.:\n\nI choose \/workspace\/www\/, so then only PDT tools will run\nI choose \/workspace\/android\/, so then only Android tools and buttons in toolbars will appears\n\nDo I have to manually remove all unneccessary things from each of the workspace? Or it is either possible to remove all?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":741,"Q_Id":3429887,"Users Score":3,"Answer":"The plug-ins are stored in the Eclipse installation, not in the workspace folder. So one solution would be to different Eclipse installations for every task, in this case only the required plug-ins would load (and the others not available), on the other hand, you have to maintain at least three parallel Eclipse installations.\nAnother solution is to disable plug-in activation on startup: in Preferences\/General\/Startup and Shutdown you can disable single plug-ins not loading. The problem with this approach is, that this only helps to not load plug-ins, but its menu and toolbar contributions will be loaded.","Q_Score":4,"Tags":"python,android,eclipse,workspace,eclipse-pdt","A_Id":3430003,"CreationDate":"2010-08-07T09:23:00.000","Title":"How to organize Eclipse - Workspace VS Programming languages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how to call a function after a certain time. I have tried  time.sleep()  but this halts the whole script. I want the script to carry on, but after ???secs call a function and run the other script at the same time","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":55176,"Q_Id":3433559,"Users Score":2,"Answer":"If the non-block feature is not needed, just use time.sleep(5) which will work anywhere and save your life.","Q_Score":57,"Tags":"python,time","A_Id":67426999,"CreationDate":"2010-08-08T08:09:00.000","Title":"Python Time Delays","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how to call a function after a certain time. I have tried  time.sleep()  but this halts the whole script. I want the script to carry on, but after ???secs call a function and run the other script at the same time","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":55176,"Q_Id":3433559,"Users Score":5,"Answer":"If you want a function to be called after a while and not to stop your script you are inherently dealing with threaded code. If you want to set a function to be called and not to worry about it, you have to either explicitly use multi-threading - like em Mark Byers's answr, or use a coding framework that has a main loop which takes care of function dispatching for you - like twisted, qt, gtk, pyglet, and so many others. Any of these would require you to rewrite your code so that it works from that framework's main loop.\nIt is either that, or writing some main loop from event checking yourself on your code -\nAll in all, if the only thing you want is single function calls, threading.Timer is the way to do it. If you want to use these timed calls to actually loop the program as is usually done with javascript's setTimeout, you are better of selecting one of the coding frameworks I listed above and refactoring your code to take advantage of it.","Q_Score":57,"Tags":"python,time","A_Id":3434738,"CreationDate":"2010-08-08T08:09:00.000","Title":"Python Time Delays","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a GUI with Tkinter, now how do I make it so when a key command will execute a command even if the Tkinter window is not in focus? Basically I want it so everything is bound to that key command. \nExample: \nSay I was browsing the internet and the focus was on my browser, I then type Ctrl + U. An event would then run on my program.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":515,"Q_Id":3445867,"Users Score":2,"Answer":"Tkinter, on its own, cannot grab keystrokes that (from the OS's\/WM's viewpoint) were directed to other, unrelated windows -- you'll need to instruct your window manager, desktop manager, or \"operating system\", to direct certain keystrokes differently than it usually does.  So, what platform do you need to support for this functionality?  Each platform has different ways to perform this kind of functionality, of course.","Q_Score":1,"Tags":"python,binding,tkinter","A_Id":3445919,"CreationDate":"2010-08-10T03:43:00.000","Title":"Key commands in Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"OK, I'm trying to explain what I want to achieve in another way. Here's an example:\nSay if it's an anti virus program, and user can choose between two ways to run the program, choice one, automatically start to scan disks for virus when the program starts up, choice two, hit the start button to make the program scan disks for virus after the program starts up any time the user wants. So, as a wxpython beginner, I know how to bind wx.EVT_BUTTON to let scanning start after the user hit the start button, but I don't know how to make the scanning start once the program starts up. I wonder if there's a program_start event I can bind? Hope you guys can help me out. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":372,"Q_Id":3450525,"Users Score":0,"Answer":"In your init or OnInit method, do some kind of check to see if the program should run the startup process on startup (i.e. check a config file or some such). If yes, call the \"scan\" method using wx.CallAfter or wx.CallLater or call it after you Show() the frame.","Q_Score":0,"Tags":"python,event-handling,wxpython","A_Id":3451727,"CreationDate":"2010-08-10T15:19:00.000","Title":"Is there a wxpython event like program_start?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"OK, I'm trying to explain what I want to achieve in another way. Here's an example:\nSay if it's an anti virus program, and user can choose between two ways to run the program, choice one, automatically start to scan disks for virus when the program starts up, choice two, hit the start button to make the program scan disks for virus after the program starts up any time the user wants. So, as a wxpython beginner, I know how to bind wx.EVT_BUTTON to let scanning start after the user hit the start button, but I don't know how to make the scanning start once the program starts up. I wonder if there's a program_start event I can bind? Hope you guys can help me out. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":372,"Q_Id":3450525,"Users Score":1,"Answer":"Why don't you run it just in module code? This way it will be run only once, because code in module is run only once per program instance.","Q_Score":0,"Tags":"python,event-handling,wxpython","A_Id":3450557,"CreationDate":"2010-08-10T15:19:00.000","Title":"Is there a wxpython event like program_start?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning Python (and it's my first programming language so don't be too intense with your reasons) and I wanted to know how it stacks up to other scripting languages, like Perl and Ruby. What is Python better in comparison to other scripting languages, and what is it worse for?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1331,"Q_Id":3452729,"Users Score":6,"Answer":"I'm learning Python (and it's my first programming language so don't be too  intense with your reasons) and I wanted to know how it stacks up to other scripting languages, like Perl and Ruby. What is Python better in comparison to other scripting languages, and what is it worse for?\n\nIMO.\nI have tried Python 2.x for some time and went back to the Perl and C++.\nWhat is good about Python. Python features better portability and has modern GUI libraries. Standard library in some places is also very very nice (I esp. liked random). Execution speed of arithmetic expressions beats that of Perl.\nWhat is bad about Python. Poor documentation. No warnings, no typing whatsoever combined with weak typing\/language's dynamic nature is a hell. Learning easy - using hard, mainly due to immature optimizer driving the need to think about performance edge cases quite early in the development cycle. (That some times reminded me of the Pascal.) OO is a mess at the moment: distinct features and differences between old-style and new-style classes are not spelled out very well; libraries do not mention what type of classes they do define.\nPoor documentation probably should be highlighted. There are piles of standard functions but their purpose in life isn't really specified nor decent examples are given. And better half of those standard functions in Perl land would have been sitting somewhere in the perldoc perlguts. Anyhow, looking up stuff is much faster with Google.\nLack of warnings and lack of typing (and that compared to the weak Perl's use warnings\/use strict and sub prototypes) is what in the end drove me back. Partially it is because that I write code faster than I can read it thus I like to rely on the compiler\/interpreter to tell me where I might have wrote something I haven't really meant.\nAlso excuse me, but I would throw that at Python again: using indentation to denote code structure is kind'a kinky. I do not mind it per se and for short functions it is very nice. But after one week I have found that I do read Python code slower (compared to C++ or Perl) in greater part because I have to always extra check whether the statement really closed or it still goes on. If code doesn't fit one screen, it becomes a chore to always press PgDown\/PgUp just to check. Never before I were that appreciative of the {}s.\nAll considered, Python is at the moment a mess. Worthy contender I do keep an eye on, but not mature enough for my daily needs. If I were making decision about learning Python now, I would have instead waited for Python 3.x to mature. Many things one would learn now with Python 2.x might be useless in Python 3.x. And Python 3.x is at the moment isn't very useful since many libraries were not yet ported to it.\nP.S. Most bogus part I have encountered is the function pointers. I have discovered them sooner than I needed them by writing start_time = time.time and time_elapsed = time.time() - start_time. Half hour later when script finished instead of results I was presented with nice interpreter exception telling me that I cannot subtract function object. And the half hour was due to the standard for loop, as tutorials have taught me. Optimizations I have looked up later (range vs. xrange, manual loop unrolling) made the script run in less than one minute.","Q_Score":1,"Tags":"python,ruby,perl,comparison","A_Id":3454618,"CreationDate":"2010-08-10T19:35:00.000","Title":"How does Python stack up to other scripting languages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The file is uploaded through a Django form. The contents of the file need to be saved into a models.TextField(), for editors to review it before publication.\nI am already checking UploadedFile.content_type. I have considered using a regular input field, but as the text is going to be quite long, it would be unwieldy for users to cut and paste.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":3462951,"Users Score":0,"Answer":"Not all sequences of bytes are valid for ex. UTF-8, maybe you should check this?","Q_Score":0,"Tags":"python,django","A_Id":3463019,"CreationDate":"2010-08-11T21:21:00.000","Title":"In Python, how do I check that a file is a text file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for the most elegant way to notify users of my library that they need a specific unix command to ensure that it will works...\nWhen is the bet time for my lib to raise an error:\n\nInstallation ?\nWhen my app call the command ?\nAt the import of my lib ?\nboth?\n\nAnd also how should you detect that the command is missing (if not commands.getoutput(\"which CommandIDependsOn\"): raise Exception(\"you need CommandIDependsOn\")).\nI need advices.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":629,"Q_Id":3465295,"Users Score":4,"Answer":"I wouldn't have any check at all. Document that your library requires this command, and if the user tries to use whatever part of your library needs it, an exception will be raised by whatever runs the command. It should still be possible to import your library and use it, even if only a subset of functionality is offered.\n(PS: commands is old and broken and shouldn't be used in new code. subprocess is the hot new stuff.)","Q_Score":3,"Tags":"python,command,packaging,distutils","A_Id":3466094,"CreationDate":"2010-08-12T06:41:00.000","Title":"How to depends of a system command with python\/distutils?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am setting up a virtualenv for django deployment.  i want an isolated env without access to the global site-packages.  i used the option --no-site-packages, then installed a local pip instance for that env.\nafter using pip and a requirements.txt file i noticed that most packages were installed in a \"build\" folder that is not in sys.path so i am getting an error such as \n\"no module named django.conf\"\ni also installed virtualenvwrapper after the base virtualenv package.\nas far i as i can recall i have not seen a \"build\" folder before, and am curious why these packages weren't simply installed in my local env's site-packages folder.  how should i go about pointing to that build folder and why does it exist?\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1443,"Q_Id":3469551,"Users Score":1,"Answer":"it seems that the pip process quit prematurely due to a package in requirements that could not be found.  this left things in limbo, stuck in the temp-like \"build\" folder before having a chance to complete the process which gets them into the proper \"site-packages\" location.","Q_Score":4,"Tags":"python,django,virtualenv,pip","A_Id":3470317,"CreationDate":"2010-08-12T15:52:00.000","Title":"virtualenv, sys.path and site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was wondering whether or not it is considered a good style to call bash commands within a Python script using os.system(). I was also wondering whether or not it is safe to do so as well.\nI know how to implement some of the functionality I need in Bash and in Python, but it is much simpler and more intuitive to implement it in Bash. However, I feel like it is very hackish to write os.system(\"bash code\").\nSpecifically, I want to move all files that end with a certain extension to a directory.\nIn bash: *mv .ext \/path\/to\/destination\nIn Python (Pseudocode):\n for file in directory:\n    if file.endswith(\"ext\"):\n        move file to destination\nIn this case, what should I do?","AnswerCount":7,"Available Count":3,"Score":0.0855049882,"is_accepted":false,"ViewCount":3091,"Q_Id":3479728,"Users Score":3,"Answer":"It always better and better style to use Python functions to do this kind of stuff. With Python it's not that hard to write a script in an OS-independent way instead of using bash.","Q_Score":8,"Tags":"python,security,bash,scripting,embedding","A_Id":3479760,"CreationDate":"2010-08-13T18:35:00.000","Title":"Is it good style to call bash commands within a Python script using os.system(\"bash code\")?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering whether or not it is considered a good style to call bash commands within a Python script using os.system(). I was also wondering whether or not it is safe to do so as well.\nI know how to implement some of the functionality I need in Bash and in Python, but it is much simpler and more intuitive to implement it in Bash. However, I feel like it is very hackish to write os.system(\"bash code\").\nSpecifically, I want to move all files that end with a certain extension to a directory.\nIn bash: *mv .ext \/path\/to\/destination\nIn Python (Pseudocode):\n for file in directory:\n    if file.endswith(\"ext\"):\n        move file to destination\nIn this case, what should I do?","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":3091,"Q_Id":3479728,"Users Score":1,"Answer":"It's not idea, since it makes your script a lot less portable.  A native python script can run on any unix or windows machine that has the proper python libraries installed.  When you add shell commands into the mix, you break that, and suddenly are locked down to a much narrower subset.\nSometimes you don't have a choice, but if it's something as simple as that, writing the code natively in python would make a lot more sense, and also be faster to boot (since the python process won't have to spawn a new shell just to execute the one command).","Q_Score":8,"Tags":"python,security,bash,scripting,embedding","A_Id":3479763,"CreationDate":"2010-08-13T18:35:00.000","Title":"Is it good style to call bash commands within a Python script using os.system(\"bash code\")?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering whether or not it is considered a good style to call bash commands within a Python script using os.system(). I was also wondering whether or not it is safe to do so as well.\nI know how to implement some of the functionality I need in Bash and in Python, but it is much simpler and more intuitive to implement it in Bash. However, I feel like it is very hackish to write os.system(\"bash code\").\nSpecifically, I want to move all files that end with a certain extension to a directory.\nIn bash: *mv .ext \/path\/to\/destination\nIn Python (Pseudocode):\n for file in directory:\n    if file.endswith(\"ext\"):\n        move file to destination\nIn this case, what should I do?","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":3091,"Q_Id":3479728,"Users Score":1,"Answer":"The quoting issues alone suggest that a pure Python solution is preferable.","Q_Score":8,"Tags":"python,security,bash,scripting,embedding","A_Id":3479838,"CreationDate":"2010-08-13T18:35:00.000","Title":"Is it good style to call bash commands within a Python script using os.system(\"bash code\")?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being \"clicked\" once the program starts, how do I do it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":3483675,"Users Score":0,"Answer":"In the __init__( )\u00a0for your main frame put this:\n\nwx.CallAfter( func_name )","Q_Score":0,"Tags":"python,event-handling,wxpython","A_Id":41389878,"CreationDate":"2010-08-14T14:11:00.000","Title":"How to make a event run immediately after a GUI program starts in wxpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being \"clicked\" once the program starts, how do I do it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":3483675,"Users Score":1,"Answer":"In the main frame constructor set a one-shot timer with interval 0 that fires the event.","Q_Score":0,"Tags":"python,event-handling,wxpython","A_Id":3483688,"CreationDate":"2010-08-14T14:11:00.000","Title":"How to make a event run immediately after a GUI program starts in wxpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can seem to find a substring function in python.\nSay I want to output the first 100 characters in a string, how can I do this?\nI want to do it safely also, meaning if the string is 50 characters it shouldn't fail.","AnswerCount":8,"Available Count":1,"Score":0.0748596907,"is_accepted":false,"ViewCount":174305,"Q_Id":3486384,"Users Score":3,"Answer":"Most of previous examples will raise an exception in case your string is not long enough.\nAnother approach is to use \n'yourstring'.ljust(100)[:100].strip().\nThis will give you first 100 chars.\nYou might get a shorter string in case your string last chars are spaces.","Q_Score":121,"Tags":"python","A_Id":46546045,"CreationDate":"2010-08-15T05:54:00.000","Title":"Output first 100 characters in a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things:\n\nDoes each cluster contain the correct elements (and maybe other properties as well)?\nDoes each cluster point to the correct children?\nDoes each cluster point to the correct parent?\n\nI have two problems here. First, how do I specify the expected output in a readable format. Second, how do I write a test-assertion accepts isomorphic variants of the expected data I provide? Suppose one cluster in the expected hierarchy has two children, A and B. Now suppose that cluster is represented by an object with the properties child1 and child2. I do not care whether child1 corresponds to cluster A or B, just that it corresponds to one of them, and that child2 corresponds to the other. The solution should be somewhat general because I will write several tests with different input data.\nActually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":72,"Q_Id":3487507,"Users Score":0,"Answer":"It feels like there maybe some room for breaking your method into smaller pieces.  Ones focused on dealing with parsing input and formatting output, could be separate from the actual clustering logic.  This way tests around your clustering methods would be fewer and dealing with easily understood and testable data structures like dicts and lists.","Q_Score":4,"Tags":"python,unit-testing,readability","A_Id":3488720,"CreationDate":"2010-08-15T13:16:00.000","Title":"Writing unittests for a function that returns a hierarchy of objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things:\n\nDoes each cluster contain the correct elements (and maybe other properties as well)?\nDoes each cluster point to the correct children?\nDoes each cluster point to the correct parent?\n\nI have two problems here. First, how do I specify the expected output in a readable format. Second, how do I write a test-assertion accepts isomorphic variants of the expected data I provide? Suppose one cluster in the expected hierarchy has two children, A and B. Now suppose that cluster is represented by an object with the properties child1 and child2. I do not care whether child1 corresponds to cluster A or B, just that it corresponds to one of them, and that child2 corresponds to the other. The solution should be somewhat general because I will write several tests with different input data.\nActually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":3487507,"Users Score":2,"Answer":"If there are isomorphic results, you should probably have a predicate that can test for logical equivalence. This would likely be good for your code unit as well as helping to implement the unit test.\nThis is the core of Manoj Govindan's answer without the string intermediates and since you aren't interested in string intermediates (presumably) then adding them to the test regime would be an unnecessary source of error.\nAs to the readability issue, you'd need to show what you consider unreadable for a proper answer to be given. Perhaps the equivalence predicate will obviate this.","Q_Score":4,"Tags":"python,unit-testing,readability","A_Id":3487617,"CreationDate":"2010-08-15T13:16:00.000","Title":"Writing unittests for a function that returns a hierarchy of objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In a Python project I'm working on, I'd like to be able to get a \"human-readable\" timezone name of the form America\/New_York, corresponding to the system local timezone, to display to the user. Every piece of code I've seen that accesses timezone information only returns either a numeric offset (-0400) or a letter code (EDT) or sometimes both. Is there some Python library that can access this information, or if not that, convert the offset\/letter code into a human-readable name? \nIf there's more than one human-readable name corresponding to a particular timezone, either a list of the possible results or any one of them is fine, and if there is no human-readable name corresponding to the current time zone, I'll take either an exception or None or [] or whatever.\n\nA clarification: I don't remember exactly what I had in mind when I originally wrote this question, but I think what I really wanted was a way to turn a timezone into a human-readable name. I don't think this question was meant to focus on how to get the system local timezone specifically, but for the specific use case I had in mind, it just happened that the local timezone was the one I wanted the name for. I'm not editing the bit about the local timezone out of the question because there are answers focusing on both aspects.","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22635,"Q_Id":3489183,"Users Score":0,"Answer":"Working with the latest version of tzlocal which is 4.1 as of today, tzlocal.get_localzone().key produces the following error: AttributeError: '_PytzShimTimezone' object has no attribute 'key'. But tzlocal.get_localzone().zone works lovely.","Q_Score":24,"Tags":"python,timezone","A_Id":71177623,"CreationDate":"2010-08-15T20:47:00.000","Title":"How can I get a human-readable timezone name in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I get a widget's \"name\"?\nWhen I define a GUI using Glade, I can \"name\" the widgets of the window but how do I recover that property when I have a widget object instance?\nI've tried get_property(), get_name() and $widget.name to no avail.\nUpdate: I am using GtkBuilder file format (i.e. XML format).\nResolution: a fix I have used: use the set_property(\"name\", name) method on the widget just after getting it from GtkBuilder.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4906,"Q_Id":3489520,"Users Score":0,"Answer":"Given the widget w, what does w.get_name() return?  If None, that means the widget has no name property.  Maybe you want gtk.glade.get_widget_name(w) instead?  (I'm not sure if the name property of the widget and the name for it in the Glade XML from which it was created are the same thing...).","Q_Score":10,"Tags":"python,gtk","A_Id":3489566,"CreationDate":"2010-08-15T22:25:00.000","Title":"Python GTK+ widget name","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to develop mobile versions of webpages using Turbogears? Can someone please show me an example and how it is done?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":254,"Q_Id":3493244,"Users Score":0,"Answer":"The simplest version of a \"mobile site\" is simply CSS.  Display a simplified version of the site to USERAGENTS that are identified as mobile.","Q_Score":1,"Tags":"python,mobile-website,turbogears","A_Id":3562868,"CreationDate":"2010-08-16T12:51:00.000","Title":"Can I use Turbogears to develop mobile sites?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to open a file with Python, but I'm unsure how to find the correct filename to use.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":965,"Q_Id":3498587,"Users Score":2,"Answer":"You can specify the path to the file in either a complete way (e.g. 'c:\/wher\/ever\/the.txt'), also known as \"absolute\" because it's taken exactly as you specify it, or a partial one (e.g., just \"the.txt\", or \"ever\/the.txt\", or \"..\/ever\/the.txt\", and so on), also known as \"relative\" because it's taken relatively to the current working directory of your process.  If you don't know that working directory, an absolute path is usually simplest to find and specify.\nSo, find out where the file lives (e.g. c:\/wher\/ever) and use that absolute path (with \"rightside up slashes\", instead of windows-style backslashes, as I just explained in another answer) to open the file in question.","Q_Score":2,"Tags":"python,file","A_Id":3498742,"CreationDate":"2010-08-17T01:00:00.000","Title":"How do you find the filename that you pass to open()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been working on a huge project for work for a while now, and it is almost done. However, in an effort to prevent the program was being pirated (I already know there is pretty much no method that can't be cracked ), the software needs to be able to validate. I'm not exactly sure how to do this. Could some sort of software validation server be written in Python? How would the software communicate with the server? Would the softwre check each time it is launched to see if it is valid? The program requires internet access to run anyway, so checking for validation at each launch might not be so bad. \nI am programming in Python 2.6 on Windows 7. Any help would be great!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":3498904,"Users Score":0,"Answer":"I would really urge you not to do this.  As you said, whatever you do will be broken, and you may actually cause more copies of your software to be pirated by including this barrier.  Asking your users nicely not to steal may do better...\nThat said, implementing this in a way that discourages the most casual piracy is easy: just have the program send a serial number encrypted with the server's public key to your validation script, and have the server return a version of the number encrypted using its private key.  Instant validation.  Yes, this server could be written in Python easily.","Q_Score":0,"Tags":"python,windows,validation","A_Id":3498920,"CreationDate":"2010-08-17T02:28:00.000","Title":"Software Validation Server in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been working on a huge project for work for a while now, and it is almost done. However, in an effort to prevent the program was being pirated (I already know there is pretty much no method that can't be cracked ), the software needs to be able to validate. I'm not exactly sure how to do this. Could some sort of software validation server be written in Python? How would the software communicate with the server? Would the softwre check each time it is launched to see if it is valid? The program requires internet access to run anyway, so checking for validation at each launch might not be so bad. \nI am programming in Python 2.6 on Windows 7. Any help would be great!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":3498904,"Users Score":2,"Answer":"The software, when starting, should launch an https (so it can't just be sniffed easily;-) request to your server, identifying itself (however it is that you choose to identify, e.g. a serial number or whatever), and the server's response will tell it what to do (run normally, or terminate, or ask the user to register -- whatever).\nOf course, any competent hacker will find and disable the part of your code where you're sending the request and dispatching on the answer, but then you already do know that everything can easily be cracked;-).\nA less-easily crackable approach would be to keep some crucial part of the functionality on your server, so that the client's basically useless (or at least less useful) if it hasn't checked in with your server and obtained a token to be used in other \"functionality requests\" during a session.\nHard to tell, without knowing a lot more about your app, if there are bits and pieces of functionality in your app that lend themselves well to this treatment, but for example you could delegate in this way any kind of cryptographic functionality (encrypting, decrypting, signing, ...) -- if only your server knows the secret\/private keys to be used for such purposes, and only performs the functionality for application sessions that have properly registered and been authorized, suddenly it's become very hard for even a good hacker to work around your registration and authorization system.","Q_Score":0,"Tags":"python,windows,validation","A_Id":3498935,"CreationDate":"2010-08-17T02:28:00.000","Title":"Software Validation Server in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I render a huge SVG file with a lot of elements with Cairo, OpenGL and rsvg. I draw svg on cairo surface via rsvg and create an OpenGL texture to draw it. Everything is fine. And now I have to interact with elements from SVG. For example, I want to guess an element by coordinates. And I want to change the background of some path in SVG. In the case of changing background I think, I can change SVG DOM and somehow re-render a part of SVG. But in the case of hit testing elements I'm totally embarrassed.\nSo, is there some python library to interact with SVG? Is it possible to stay with cairo and rsvg and how can I implement it myself? Or is there a better way to render SVG in OpenGL and interact with it in python? All I want is load SVG, manipulate its DOM and render it","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3978,"Q_Id":3501215,"Users Score":0,"Answer":"I had to do the same (changing element color for instance), and had to modify rsvg library because all those nice features exist but they are hidden. You have to make a new interface to link to the nice features.","Q_Score":3,"Tags":"python,opengl,svg,cairo,rsvg","A_Id":37703846,"CreationDate":"2010-08-17T09:51:00.000","Title":"SVG interaction in python with cairo, opengl and rsvg","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I would like to know how i can select a pixel with a mouse click in an image (QImge) and get pixel position and value.\nThanks","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":19296,"Q_Id":3504522,"Users Score":2,"Answer":"First you have to draw the image. You can do this my making a QLabel widget and call setPixmap. You need to convert your QImage to QPixmap before doing this (you can use QPixmap.fromImage(img)).\nYou can get mouse clicks by subclassing the QImage and intercepting mousePressEvent. Look up the pixel value with QImage.pixel().","Q_Score":9,"Tags":"python,image,pyqt,selection,pixel","A_Id":3543483,"CreationDate":"2010-08-17T16:05:00.000","Title":"Pyqt get pixel position and value when mouse click on the image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. \nFor example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the second step while the first step is still being run, using the part of the data that has already been processed through the first step.\nFrom my understanding, neither Python nor R is the ideal language for this type of work (at least, I don't know how to implement it in either language). What would be the best language\/implementation for this type of data processing?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":657,"Q_Id":3507451,"Users Score":0,"Answer":"If I remember correctly (but I might be wrong here) one of the main purposes of Ada95 was parallel processing. Funny language, that was.\nJokes aside I'm not quite sure how good performance wise it would be (but seeing you are using Python now then it shouldn't be that bad) but I'd suggest Java since the basics of multithreading are quite simple there (but making a well written, complex multithreaded application is rather hard). Heard the Concurrency library is also quite nice, I haven't tried it out myself yet, though.","Q_Score":6,"Tags":"python,multithreading,r","A_Id":3507504,"CreationDate":"2010-08-17T22:22:00.000","Title":"Recommended language for multithreaded data work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. \nFor example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the second step while the first step is still being run, using the part of the data that has already been processed through the first step.\nFrom my understanding, neither Python nor R is the ideal language for this type of work (at least, I don't know how to implement it in either language). What would be the best language\/implementation for this type of data processing?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":657,"Q_Id":3507451,"Users Score":1,"Answer":"On the Python side, your best bet is probably to separate the two steps in two different processes. There are a couple of modules that help you to achieve that. You would couple the two processes through pipes. In order to pass arbitrary data through the pipe, you need to serialize and deserialize it. The pickle module would be a good candidate for this.\nIf you want to jump ship, languages like Erlang, Haskell, Scala or Clojure have probably the concurrency features you are looking for, but I don't know how well they would integrate with R or some other statistical package that suits you.","Q_Score":6,"Tags":"python,multithreading,r","A_Id":3507522,"CreationDate":"2010-08-17T22:22:00.000","Title":"Recommended language for multithreaded data work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to send integers greater than 255? Does anyone know how to do this?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":14924,"Q_Id":3507732,"Users Score":3,"Answer":"Encode them into binary strings with Python's struct module.  I don't know if arduino wants them little-endian or big-endian, but, if its docs aren't clear about this, a little experiment should easily settle the question;-).","Q_Score":1,"Tags":"python,arduino","A_Id":3507854,"CreationDate":"2010-08-17T23:20:00.000","Title":"Sending integer values to Arduino from PySerial","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.\nI've seen several questions on how to learn Python, but most of them were from folks who were looking to start programming for the first time. I don't need a tutorial that will tell me what a string is, but I do need one that can tell me how to make a string in Python. Any help on some good sources to look through? Bonus points if the source is free :)","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":22778,"Q_Id":3516560,"Users Score":1,"Answer":"As someone who has worked with Java for over 12 years, I found that picking up a problem and solving it in a new language is the best way to learn. I don't believe in reading - it wastes a huge amount of time, and you can easily end up reading for too long.\nMy advice is to find a problem and set off to solve it with Python. You will learn alot in the process.\nGood luck","Q_Score":18,"Tags":"python,c","A_Id":6150403,"CreationDate":"2010-08-18T20:49:00.000","Title":"Coming from C, how should I learn Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.\nI've seen several questions on how to learn Python, but most of them were from folks who were looking to start programming for the first time. I don't need a tutorial that will tell me what a string is, but I do need one that can tell me how to make a string in Python. Any help on some good sources to look through? Bonus points if the source is free :)","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":22778,"Q_Id":3516560,"Users Score":1,"Answer":"Diveintopython, official docs, \"Learning python\" by Mark Lutz(4th edition)  is one of the best books.","Q_Score":18,"Tags":"python,c","A_Id":3517315,"CreationDate":"2010-08-18T20:49:00.000","Title":"Coming from C, how should I learn Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.\nI've seen several questions on how to learn Python, but most of them were from folks who were looking to start programming for the first time. I don't need a tutorial that will tell me what a string is, but I do need one that can tell me how to make a string in Python. Any help on some good sources to look through? Bonus points if the source is free :)","AnswerCount":7,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":22778,"Q_Id":3516560,"Users Score":32,"Answer":"I knew C before I knew Python. No offence intended, but I don't think that your C knowledge is that big a deal. Unless you read very, very slowly, just set out to learn Python. It won't take that long to skim through the material you're familiar with, and it's not as if a Python tutorial aimed at C programmers will make you a better Python programmer - it might teach you things in a different order, is all, and raise some specific things that you would do in C but that you should not do in Python.\nStrings in Python actually are somewhat different from strings in C, and they're used differently. I strongly recommend learning them \"from scratch\", rather than thinking about them in terms of their differences from C strings. For one thing, in Python 2 it's best not to use Python's \"string\" class to represent strings: there's a separate unicode string class and for practical Python apps (pretty much anything involving user data), you need that. (Python 3 fixes this, making the str class a unicode string). You need to establish a good working practice for unicode\/byte data and decode\/encode.\nA common mistake when learning a second programming language, is to think \"I know how to program, I just need to translate what I do in C into Python\". No, you don't. While it's true that an algorithm can be basically the same in different languages, the natural way to do a particular thing can be completely different in different languages. You will write better Python code if you learn to use Python idiomatically, than if you try to write Python like a C programmer. Many of the \"tricks\" you know that make sense in C will be either pointless or counter-productive in Python. Conversely many things that you should do happily in a typical Python program, like allocating and freeing a lot of memory, are things that in C you've probably learned to think twice about. Partly because the typical C program has different restrictions from the typical Python program, and partly because you just have to write more code and think harder to get that kind of thing right in C than you do in Python.\nIf you're learning the language because you urgently need to program a system\/platform which has Python but doesn't have C, then writing Python programs that work like C programs is a reasonable interim measure. But that probably doesn't apply to you, and even if it did it's not the ultimate goal.\nOne thing you might be interested to look at because of your C experience, is the Python\/C API. Python is great for many things, but it doesn't result in the fastest possible computational core of scientific apps [neither does C, probably, but let's not go into FORTRAN for now ;-)]. So if you're aiming to continue with scientific programming through your move in Python, and your programs are typically memory-bus- and CPU-bound doing immense amounts of number-crunching (billions of ops), then you might like to know how to escape into C if you ever need to. Consider it a last resort, though.\nYou do need to understand Python reasonably well before the Python\/C API makes much sense, though.\nOh yes, and if you want to understand OOP in general, remember later on to take a look at something like Java, Objective-C, C++, or D. Python isn't just an OO language, it's a dynamic OO language. You might not realise it from comparing just C with Python, but dynamic vs static types is a completely independent issue from the OOP-ness of Python. Python objects are like hashtables that allow you to attach new fields willy-nilly, but objects in many other OO languages store data in ways which are much more like a C struct.","Q_Score":18,"Tags":"python,c","A_Id":3516905,"CreationDate":"2010-08-18T20:49:00.000","Title":"Coming from C, how should I learn Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Here is what I would like to do, and I want to know how some people with experience in this field do this:\nWith three POST requests I get from the http server:\n\nwidgets and layout\nand then app logic (minimal)\ndata\n\nOr maybe it's better to combine the first two or all three. I'm thinking of using pyqt. I think I can load .ui files. I can parse json data. I just think it would be rather dangerous to pass code over a network to be executed on the client. If someone can hijack the connection, or can change the apps setting to access a bogus server, that is nasty.\nI want to do it this way because it keeps all the clients up-to-date. It's sort of like a webapp but simpler because of Qt. Essentially the \"thin\" app is just a minimal compiled python file that loads data from a server.\nHow can I do this without introducing security issues on the client? Is https good enough? Is there a way to get pyqt to run in a sandbox of sorts?\nPS. I'm not stuck on Qt or python. I do like the concept though. I don't really want to use Java - server or client side.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1647,"Q_Id":3517841,"Users Score":1,"Answer":"Your desire to send \"app logic\" from the server to the client without sending \"code\" is inherently self-contradictory, though you may not realize that yet -- even if the \"logic\" you're sending is in some simplified ad-hoc \"language\" (which you don't even think of as a language;-), to all intents and purposes your Python code will be interpreting that language and thereby execute that code.  You may \"sandbox\" things to some extent, but in the end, that's what you're doing.\nTo avoid hijackings and other tricks, instead, use HTTPS and validate the server's cert in your client: that will protect you from all the problems you're worrying about (if somebody can edit the app enough to defeat the HTTPS cert validation, they can edit it enough to make it run whatever code they want, without any need to send that code from a server;-).\nOnce you're using https, having the server send Python modules (in source form if you need to support multiple Python versions on the clients, else bytecode is fine) and the client thereby save them to disk and import \/ reload them, will be just fine.  You'll basically be doing a variant of the classic \"plugins architecture\" where the \"plugins\" are in fact being sent from the server (instead of being found on disk in a given location).","Q_Score":0,"Tags":"python,qt,networking,pyqt,thin","A_Id":3517886,"CreationDate":"2010-08-19T00:33:00.000","Title":"how to implement thin client app with pyqt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a built-in method to do it? If not how can I do this without costing too much overhead?","AnswerCount":11,"Available Count":1,"Score":0.0181798149,"is_accepted":false,"ViewCount":98440,"Q_Id":3540288,"Users Score":1,"Answer":"Seek to a random position, read a line and discard it, then read another line. The distribution of lines won't be normal, but that doesn't always matter.","Q_Score":51,"Tags":"python","A_Id":3540307,"CreationDate":"2010-08-22T05:23:00.000","Title":"How do I read a random line from one file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do i set a timeout value for python's mechanize?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":9833,"Q_Id":3552928,"Users Score":3,"Answer":"If you're using Python 2.6 or better, and a correspondingly updated version of mechanize, mechanize.urlopen should accept a timeout=... optional argument which seems to be what you're looking for.","Q_Score":15,"Tags":"python,timeout,mechanize","A_Id":3553063,"CreationDate":"2010-08-24T01:22:00.000","Title":"how do i set a timeout value for python's mechanize?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some bash scripts, some simple ones to copy, search, write lines to files and so on.\nI am an Ubuntu. and I've searched in google, but it seems that everybody is doing that on python.\nI could do these on python, but since I am not a python programmer, I just know the basics.\nI have no idea of how calling a sh script from a GUI written on python.\nIf someone has a link or something to say, please drop a line.\nregards, \nMario","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2093,"Q_Id":3556027,"Users Score":0,"Answer":"basically, all bash does is start other programs (and do symbolic math on the command line). So no, you're going to have to involve some other program.","Q_Score":3,"Tags":"python,user-interface,bash","A_Id":3556046,"CreationDate":"2010-08-24T11:41:00.000","Title":"Is there a way of having a GUI for bash scripts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating one-click python installer (integrated with my application). Is there any way to force Python MSI installer to add python's path to SYSTEM PATH variable?\nI'm using MSI installer because it is very easy to specify (using command line) how it should interact with the user.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1668,"Q_Id":3557949,"Users Score":0,"Answer":"There has to be a way, but what some people do is provide batch files that set up the environment before invoking Python. That's what BZR does, anyway. If you can write that batch file somewhere that's already normally in the path, so much the better.\nIf you're just worried about invoking Python, the normal Python installer does file associations, so you can work it that way.","Q_Score":1,"Tags":"python,python-install","A_Id":3558004,"CreationDate":"2010-08-24T15:11:00.000","Title":"add Python path to PATH system variable automatically under Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just starting to work on a tornado application that is having some CPU issues.  The CPU time will monotonically grow as time goes by, maxing out the CPU at 100%.  The system is currently designed to not block the main thread.  If it needs to do something that blocks and asynchronous drivers aren't available, it will spawn another thread to do the blocking operation.\nThus we have the main thread being almost totally CPU-bound and a bunch of other threads that are almost totally IO-bound.  From what I've read, this seems to be the perfect way to run into problems with the GIL.  Plus, my profiling shows that we're spending a lot of time waiting on signals (which I'm assuming is what __semwait_signal is doing), which is consistent with the effects the GIL would have in my limited understanding.\nIf I use sys.setcheckinterval to set the check interval to 300, the CPU growth slows down significantly.  What I'm trying to determine is whether I should increase the check interval, leave it at 300, or be scared with upping it.  After all, I notice that CPU performance gets better, but I'm a bit concerned that this will negatively impact the system's responsiveness.\nOf course, the correct answer is probably that we need to rethink our architecture to take the GIL into account.  But that isn't something that can be done immediately.  So how do I determine the appropriate course of action to take in the short-term?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":765,"Q_Id":3559457,"Users Score":1,"Answer":"The first thing I would check for would be to ensure that you're properly exiting threads. It's very hard to figure out what's going on with just your description to go from, but you use the word \"monotonically,\" which implies that CPU use is tied to time rather than to load.\nYou may very well be running into threading limits of Python, but it should vary up and down with load (number of active threads,) and CPU usage (context switching costs) should reduce as those threads exit. Is there some reason for a thread, once created, to live forever? If that's the case, prioritize that rearchitecture. Otherwise, short term would be to figure out why CPU usage is tied to time and not load. It implies that each new thread has a permanent, irreversible cost in your system - meaning it never exits.","Q_Score":8,"Tags":"python,multithreading,tornado,gil","A_Id":3562109,"CreationDate":"2010-08-24T17:55:00.000","Title":"How do I determine the appropriate check interval?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have prepared a project in python language ie a TEXT TO SPEECH synthesizer. Which took a total on 1500 lines of code.\nBut there few parts of code due to which it is taking so much time to run the code, i want to replace that parts of code in C\/c++ lang so that it runs faster.\nSo i want to know how can i run these parts of code in C++ or improve its speed in any other way??\nplease suggest,","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":106,"Q_Id":3568371,"Users Score":3,"Answer":"You have a few options:\nAs Radomir mentioned, Cython might be a good choice: it's essentially a restricted Python with type declarations, automatically translated into C then compiled for execution.\nIf you want to use pure C, you can write a Python extension module using the Python C API.  This is a good way to go if you need to manipulate Python data structures in your C code.  Using the Python C API, you write in C, but with full access to the Python types and methods.\nOr, you can write a pure C dll, then invoke it with ctypes.  This is a good choice if you don't need any access to Python data structures in your C code.  With this technique, your C code only deals with C types, and your Python code has to understand how to use ctypes to get at that C data.","Q_Score":0,"Tags":"python","A_Id":3568664,"CreationDate":"2010-08-25T16:54:00.000","Title":"how to replicate parts of code in python into C to execution faster?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not sure how to find this information, I have found a few tutorials so far about using Python with selenium but none have so much as touched on this.. I am able to run some basic test scripts through python that automate selenium but it just shows the browser window for a few seconds and then closes it.. I need to get the browser output into a string \/ variable (ideally) or at least save it to a file so that python can do other things on it (parse it, etc).. I would appreciate if anyone can point me towards resources on how to do this. Thanks","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4318,"Q_Id":3571233,"Users Score":2,"Answer":"There's a Selenium.getHtmlSource() method in Java, most likely it is also available in Python. It returns the source of the current page as string, so you can do whatever you want with it","Q_Score":3,"Tags":"python,selenium,browser-automation","A_Id":3573288,"CreationDate":"2010-08-26T00:22:00.000","Title":"Selenium with Python, how do I get the page output after running a script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"A sever I can't influence sends very broken XML.\nSpecifically, a Unicode WHITE STAR would get encoded as UTF-8 (E2 98 86) and then translated using a Latin-1 to HTML entity table. What I get is &acirc; 98 86 (9 bytes) in a file that's declared as utf-8 with no DTD.\nI couldn't configure W3C tidy in a way that doesn't garble this irreversibly. I only found how to make lxml skip it silently. SAX uses Expat, which cannot recover after encountering this. I'd like to avoid BeautifulSoup for speed reasons.\nWhat else is there?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1950,"Q_Id":3577652,"Users Score":2,"Answer":"BeautifulSoup is your best bet in this case. I suggest profiling before ruling out BeautifulSoup altogether.","Q_Score":4,"Tags":"python,xml","A_Id":3577694,"CreationDate":"2010-08-26T17:18:00.000","Title":"How to parse broken XML in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made an application using Glade and Python and I would like to make several localizations.\nI know how to localize strings that are in the Python code, I just encapsule all the strings that are supposed to be localized with _() and than specify the translation of the string in a .po file.\nBut how do I tell a string that is built with Glade that it should be localizable (for example labels, menu items, button labels, ...)?\nI am using gettext for the localization.\nThank you, Tomas","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1203,"Q_Id":3586071,"Users Score":4,"Answer":"You should be able to create a *.pot file from a *.glade file using intltool-extract --type=gettext\/glade foo.glade, and intltool supposedly knows what is translatable.\nAlso, I suggest you look into GtkBuilder if you didn't do that already (you can save GtkBuilder interface files from recent Glade 3 versions, and you won't need the extra libglade anymore).","Q_Score":7,"Tags":"python,user-interface,pygtk,gettext,glade","A_Id":3588790,"CreationDate":"2010-08-27T16:05:00.000","Title":"Localization of GUI built with Glade and Python (Gtk)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the database as soon as another blotter has updated some data in the database?\nI would rather like to avoid complexity in setting up some client-server protocol. Is it possible to create some form of client-only protocol where a simple refresh message is passed along straight to the other blotters when they need to update their information?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":3594631,"Users Score":0,"Answer":"To receive messages (e.g. the UDP package suggested by the other poster or an http request), the clients would have to run a basic server on the client machine. You could use the Python xmlrpc module for example. However, a local firewall may block the inward communication. \nThe easiest solution, if the number of clients is moderate,  will be to frequently poll the database for changes: add a column \"last modification time\" to your drawing table and have the clients check this field. This way the clients can find out whether they need to reload the drawing without wasting too many resources.\nEdit: The last modification field could either be actively updated by the client that made a change to the drawing, or automatically updated by a database trigger.","Q_Score":1,"Tags":"python,network-programming","A_Id":3594735,"CreationDate":"2010-08-29T12:04:00.000","Title":"Keeping multiple clients showing up-to-date information in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the database as soon as another blotter has updated some data in the database?\nI would rather like to avoid complexity in setting up some client-server protocol. Is it possible to create some form of client-only protocol where a simple refresh message is passed along straight to the other blotters when they need to update their information?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":3594631,"Users Score":0,"Answer":"You could use triggers. When an information is updated send a signal (is up to you choose how, maybe just an udp packet) to all blotters that will update their information consequentially. Postgresql could be scripted using python.","Q_Score":1,"Tags":"python,network-programming","A_Id":3594712,"CreationDate":"2010-08-29T12:04:00.000","Title":"Keeping multiple clients showing up-to-date information in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to write a simple GTD-style todo list app with python and gtk to learn python.  I want a container that can select an individual list from a lot of choices.  It would be something like the list of notebooks area in tomboy.  Not a combobox.\nAs you can probably tell I'm a beginner and the terminology is probably off.\nCan you please tell me what it is I'm looking for and an overview of how to implement it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":3604357,"Users Score":0,"Answer":"You mean a widget to filter a large collection into multiple subsets \/ views? \nI would guess you have to implement this yourself - a list of options on the left and filtered results on the right, I don't know of any existing (gtk) widgets.","Q_Score":1,"Tags":"python,user-interface,gtk","A_Id":3604511,"CreationDate":"2010-08-30T21:28:00.000","Title":"Python PyGTK. What's this component?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running GAE SDK on a Windows Vista laptop. It keeps reminding me to install the SSL module. I've been having great difficulty on how to do that.\nI've downloaded the SSL module.\nI've done 'python setup.py install' in cmd, but it just says \"python is not recognized as an internal...\"\nI've added C:\\Python2.5.2 to my PATH.\nStill the same message \"python is not recognized as an internal or external command...\"\nWhat else should I do?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":530,"Q_Id":3606743,"Users Score":0,"Answer":"Why don't you provide the complete path to python executable. That should work.\nC:\\\"Python2.5.2\"\\python.exe setup.py install","Q_Score":1,"Tags":"python,google-app-engine,ssl","A_Id":3606827,"CreationDate":"2010-08-31T07:07:00.000","Title":"Installing Python SSL module on Windows Vista","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My first \"serious\" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class.\nNow I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules\/classes.\nI understand that one module corresponds to one knowledge domain, one module should ba able to test separately... \nShould I apprehend module as namespace(c++) only?","AnswerCount":4,"Available Count":4,"Score":0.1488850336,"is_accepted":false,"ViewCount":4745,"Q_Id":3607020,"Users Score":3,"Answer":"It is matter of taste. If you use modules your 'program' will be more procedural oriented. If you choose classes it will be more or less object oriented. I'm working with Excel for couple of months and personally I choose classes whenever I can because it is more comfortable to me. If you stop thinking about objects and think of them as Components you can use them with elegance. The main reason why I prefer classes is that you can have it more that one. You can't have two instances of module. It allows me use encapsulation and better code reuse.\nFor example let's assume that you like to have some kind of logger, to log actions that were done by your program during execution. You can write a module for that. It can have for example a global variable indicating on which particular sheet logging will be done. But consider the following hypothetical situation: your client wants you to include some fancy report generation functionality in your program. You are smart so you figure out that you can use your logging code to prepare them. But you can't do log and report simultaneously by one module. And you can with two instances of logging Component without any changes in their code.","Q_Score":5,"Tags":"python,vba","A_Id":3627197,"CreationDate":"2010-08-31T07:46:00.000","Title":"Module vs object-oriented programming in vba","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My first \"serious\" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class.\nNow I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules\/classes.\nI understand that one module corresponds to one knowledge domain, one module should ba able to test separately... \nShould I apprehend module as namespace(c++) only?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":4745,"Q_Id":3607020,"Users Score":3,"Answer":"I don't do VBA but in python, modules are fundamental. As you say, the can be viewed as namespaces but they are also objects in their own right. They are not classes however, so you cannot inherit from them (at least not directly).\nI find that it's a good rule to keep a module concerned with one domain area. The rule that I use for deciding if something is a module level function or a class method is to ask myself if it could meaningfully be used on any objects that satisfy the 'interface' that it's arguments take. If so, then I free it from a class hierarchy and make it a module level function. If its usefulness truly is restricted to a particular class hierarchy, then I make it a method.\nIf you need it work on all instances of a class hierarchy and you make it a module level function, just remember that all the the subclasses still need to implement the given interface with the given semantics. This is one of the tradeoffs of stepping away from methods: you can no longer make a slight modification and call super.  On the other hand, if subclasses are likely to redefine the interface and its semantics, then maybe that particular class hierarchy isn't a very good abstraction and should be rethought.","Q_Score":5,"Tags":"python,vba","A_Id":3607773,"CreationDate":"2010-08-31T07:46:00.000","Title":"Module vs object-oriented programming in vba","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My first \"serious\" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class.\nNow I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules\/classes.\nI understand that one module corresponds to one knowledge domain, one module should ba able to test separately... \nShould I apprehend module as namespace(c++) only?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":4745,"Q_Id":3607020,"Users Score":1,"Answer":"VBA also allows the use of classes. Unfortunately, those classes don't support all the features of a full-fleged object oriented language. Especially inheritance is not supported.\nBut you can work with interfaces, at least up to a certain degree.\nI only used modules like \"one module = one singleton\". My modules contain \"static\" or even stateless methods. So in my opinion a VBa module is not namespace. More often a bunch of classes and modules would form a \"namespace\". I often create a new project (DLL, DVB or something similar) for such a \"namespace\".","Q_Score":5,"Tags":"python,vba","A_Id":3607379,"CreationDate":"2010-08-31T07:46:00.000","Title":"Module vs object-oriented programming in vba","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My first \"serious\" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class.\nNow I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules\/classes.\nI understand that one module corresponds to one knowledge domain, one module should ba able to test separately... \nShould I apprehend module as namespace(c++) only?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":4745,"Q_Id":3607020,"Users Score":1,"Answer":"Idioms of languages are different and thats the reason a problem solved in different languages take different approaches. \n\n\"C\" is all about procedural decomposition. \nMain idiom in Java is about \"class or Object\" decomposition. Functions are not absent, but they become a part of exhibited behavior of these classes.\n\"Python\" provides support for both Class based problem decomposition as well as procedural based. \n\nAll of these uses files, packages or modules as concept for organizing large code pieces together. There is nothing that restricts you to have one module for one knowledge domain.\nThese are decomposition and organizing techniques and can be applied based on the problem at hand.\nIf you are comfortable with OO, you should be able to use it very well in Python.","Q_Score":5,"Tags":"python,vba","A_Id":3607193,"CreationDate":"2010-08-31T07:46:00.000","Title":"Module vs object-oriented programming in vba","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use all the data in my python app engine memcache.  I do not know the keys in advance.\nHow do I go about getting all data?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3350,"Q_Id":3611830,"Users Score":0,"Answer":"as in comments above, I guess I could stick all data in a single memcache entry with a known key.\nStill for non-static data there are scenarios where it would be useful.","Q_Score":4,"Tags":"python,google-app-engine,memcached,python-memcached","A_Id":3611908,"CreationDate":"2010-08-31T17:59:00.000","Title":"how do I return all memcached values in Google App Engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use all the data in my python app engine memcache.  I do not know the keys in advance.\nHow do I go about getting all data?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3350,"Q_Id":3611830,"Users Score":1,"Answer":"I am using a 'well known key' called \"config\" where I store a list of all other keys and use that to enumerate the rest of the items.","Q_Score":4,"Tags":"python,google-app-engine,memcached,python-memcached","A_Id":4524611,"CreationDate":"2010-08-31T17:59:00.000","Title":"how do I return all memcached values in Google App Engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I don't get what Clyther is or how to use it.  \nMy stuff:\n  ATI OpenCl SDK (just dl'd)\n  clyther beta (just dl'd)\n  windows 7 pro 64 bit\n  active python 3.1.2\n  Xfxs Ati radeon 5850 video card\nI downloaded the ATI OpenCl SDK and the clyther beta from sourceforge. Then I tooke the sample 'reduce' function from the sourceforge documents and pasted the code into notepad and named it clythersample.py.  When I double-click the file or open it in the interactiveshell, it gives an error message on the first line.\nIs naming the file .py wrong? I guess clyther is its own lqnguage and not really python? Can I write python code and in the middle of the program, write a chunk of clyther code? Will python IDEs (esp. Wing understand and debug it?) Will it work with python 3 or do I need 2.6?  Is 64 bit os ok?   \n(I'm not a programme or technically competent, so things like its a python API for OpenCl or it had C bindings for python don't mean a whole lot).","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":507,"Q_Id":3612410,"Users Score":2,"Answer":"Clyther is a Python package for High-Performance Computing (HPC) using, for example, video cards with multiple Graphics Packaging Units (GPUs) or (less frequently) multi-core processors.  Clyther is for parallel processing of algorithms or data sets that would normally take a lot of time to process serially.  Meaning, if you have a problem that can be split into many smaller problems, then Clyther is a useful package to use.  Additionally, your problem must be something that can use numpy arrays.\nClyther is a nice package to use if you have the problem it is intended to solve.  It makes it fairly easy to write Python code to run on multiple processes.\nIf that's not the problem you need to solve, then Clyther probably won't help you.","Q_Score":2,"Tags":"python,python-3.x,gpu","A_Id":10986086,"CreationDate":"2010-08-31T19:18:00.000","Title":"Clyther-how to get started?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I don't get what Clyther is or how to use it.  \nMy stuff:\n  ATI OpenCl SDK (just dl'd)\n  clyther beta (just dl'd)\n  windows 7 pro 64 bit\n  active python 3.1.2\n  Xfxs Ati radeon 5850 video card\nI downloaded the ATI OpenCl SDK and the clyther beta from sourceforge. Then I tooke the sample 'reduce' function from the sourceforge documents and pasted the code into notepad and named it clythersample.py.  When I double-click the file or open it in the interactiveshell, it gives an error message on the first line.\nIs naming the file .py wrong? I guess clyther is its own lqnguage and not really python? Can I write python code and in the middle of the program, write a chunk of clyther code? Will python IDEs (esp. Wing understand and debug it?) Will it work with python 3 or do I need 2.6?  Is 64 bit os ok?   \n(I'm not a programme or technically competent, so things like its a python API for OpenCl or it had C bindings for python don't mean a whole lot).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":507,"Q_Id":3612410,"Users Score":1,"Answer":"When you name the file .py (the file extension associated with python.exe) and double-click it, how is windows supposed to know it's supposed to run the file with CLyther?\n\nIs naming the file .py wrong? I guess clyther is its own lqnguage and not really python?\n\nDocumentation compares it with Cython - so I suppose it's an extension to the language, i.e. they take Python and bolt more features on it.\n\nCan I write python code and in the middle of the program, write a chunk of clyther code?\n\nFrom the goals of the project, it should (like Cython) ultimately be able to accept all or most Python code. So, yes - but of course you'd have to run the whole program with CLyther.\n\nWill python IDEs (esp. Wing understand and debug it?)\n\nNot natively, I suppose.\nSide note: The project is in a very early stage of developement (very first beta-release), so don't expect things to run smoothly right now.","Q_Score":2,"Tags":"python,python-3.x,gpu","A_Id":3612526,"CreationDate":"2010-08-31T19:18:00.000","Title":"Clyther-how to get started?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a python script bundled into a application (I'm on a mac) and have the application set to be able to open .zip files. But when I say \"open foo.zip with bar.py\" how do I access the file that I have passed to it? \nAdditional info:\nUsing tkinter.\nWhat's a good way to debug this, as there is no terminal to pass info to?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":310,"Q_Id":3614609,"Users Score":0,"Answer":"If I'm not greatly mistaken, it should pass the name of the file as the first argument to the script - sys.argv[1].","Q_Score":0,"Tags":"python,macos,tkinter","A_Id":3614650,"CreationDate":"2010-09-01T02:17:00.000","Title":"Python: open a file *with* script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a Python extension in C, and my python program uses that extension. In order for it to work, I would have to install the extension on the user's system before my program can run. Is there a way to bypass that installation step and somehow just have the extension in my python package? The only compiled part obviously is the extension (since it's in C).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":3619990,"Users Score":2,"Answer":"You can avoid having some one to install it independently but you can not avoid installation completely. If his computing platform differs from yours, he will have to build the extension.\nWhat can be done is that you setup a package distribution using distutils. This way the package could be installed or built. You can include the \"C\" extension in your package. \nFor some standard platform, you can then provide binary package distribution. The user should have the ability to rebuild, if the binary package is not working out for him.","Q_Score":4,"Tags":"python,c,installation","A_Id":3620269,"CreationDate":"2010-09-01T16:04:00.000","Title":"Is there a way to package a python extension written in C into a binary so I don't have to python-install it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a Python extension in C, and my python program uses that extension. In order for it to work, I would have to install the extension on the user's system before my program can run. Is there a way to bypass that installation step and somehow just have the extension in my python package? The only compiled part obviously is the extension (since it's in C).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":112,"Q_Id":3619990,"Users Score":1,"Answer":"just put the .d compiled python dll in the same directory as your python script. then you'll be able to import it.","Q_Score":4,"Tags":"python,c,installation","A_Id":3621206,"CreationDate":"2010-09-01T16:04:00.000","Title":"Is there a way to package a python extension written in C into a binary so I don't have to python-install it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I remove \/ inspect \/ modify handlers configured for my loggers using the fileConfig() function?\nFor removing there is Logger.removeHandler(hdlr) method, but how do I get the handler in first place if it was configured from file?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":46204,"Q_Id":3630774,"Users Score":78,"Answer":"logger.handlers contains a list with all handlers of a logger.","Q_Score":70,"Tags":"python,logging","A_Id":3630800,"CreationDate":"2010-09-02T20:05:00.000","Title":"logging remove \/ inspect \/ modify handlers configured by fileConfig()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is a module I'd love to download, but it is only available in a zip file, how do I get such a file to work properly in python, so That I can import what I want? \nThis is in Windows 7 BTW.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":3632046,"Users Score":1,"Answer":"Just insert the whole path to the zipfile, c:\/what\/ever\/itis.zip, in your sys.path, and import themodule (assuming it's at the top \"level\" of the zipfile's simulated directory-tree structure).","Q_Score":0,"Tags":"python,import,zip","A_Id":3632086,"CreationDate":"2010-09-02T23:33:00.000","Title":"Getting modules from a zip file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering if it is possible for the ctypes package to interface with mmap.\nCurrently, my module allocates a buffer (with create_string_buffer) and then passes that using byref to my libraries mylib.read function. This, as the name suggests, reads data into the buffer. I then call file.write(buf.raw) to write the data to disk. My benchmarks, however, show this to be far from optimal (time spent in file.write is time better spent in mylib.read).\nI am therefore interested in knowing if ctypes can interoperate with mmap. Given an mmap.mmap instance and an offset how can I get a pointer (c_void_p) into the address space?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3930,"Q_Id":3640092,"Users Score":1,"Answer":"Be aware that the operating system is going to be doing readahead for read() anyway.  You're going to be blocking either in read() or write()--one or the other will bottleneck the operation--but even though you're blocking in one, that doesn't mean the other isn't taking place for you behind the scenes.  That's the job of every multitasking operating system.\nIf you use mmap for this, you're very likely making things more complicated for the OS--making it harder for it to determine that you're really just streaming data in and out, and making it more complicated for it to do read-ahead.  It may still figure it out (operating systems are very good at this), but you're probably not helping.\nThe only benefit in principle is avoiding the cost of a memory copy, but it doesn't sound like that's your goal here (and unless profiling clearly says otherwise, I'd strongly doubt that would help performance).","Q_Score":12,"Tags":"python,ctypes","A_Id":3640616,"CreationDate":"2010-09-03T22:51:00.000","Title":"Python, ctypes and mmap","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that if you want to include external packages you have to include them in your project. So I was wondering how do you do this? \nDo people use one general script that auto imports them from a location. Maybe some kind of config file that lists all the external packages? Do you always zip the packages and use zipimporter?\nAnway, I guess I am looking for a good general strategy for import external packages. I learned some already from looking at source code but extra info\/examples would be super.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":506,"Q_Id":3641538,"Users Score":2,"Answer":"Just place the package's folder in the root directory of your GAE application, easy!","Q_Score":2,"Tags":"python,google-app-engine","A_Id":3643164,"CreationDate":"2010-09-04T08:54:00.000","Title":"Google App Engine: Including external packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. \nI have a few limitations: \n\nI have only 3 months. \nI want to do it in Python. \nI can put in say 20-30 hours every week into it. \n\nI want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?\nIs there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)\nIf the idea is not feasible, can anyone tell me how much do I need to scale down my idea? \nAny help is much appreciated!","AnswerCount":11,"Available Count":7,"Score":-0.0544914242,"is_accepted":false,"ViewCount":13899,"Q_Id":3643500,"Users Score":-3,"Answer":"Buddy, here is the answer you have been looking for:\nWritting an Operating System is not different than writting any other application, actually it is far easier than writing any other code for the reason an Operating System is an ALL-PURPOSE software or what is meant as a platform... and you know it!.\nAll of the previous asnwers are EXTREMELY USEFUL!, and ALL OF THE PREVIOUS INCLUDING THIS ONE WILL HELP YOU IN CODING YOUR O.S. actually in less than three months.\nPlease, try to be objective and get rid of negative answers (that is just mindblocking...)\nA Software Developer actually CODE EVERYTHING that comes to his mind! (in my case I was a SUPERB software developer until I had a brain accident and suffered hypoxia for a considerably period... not want to talk further about it... me traumatized...)...\nLet's speak clear:\nIf you want to build an O.S. do the following and start TODAY!:\n\nDefine if you want to write a SHELL or if you want to write a CORE O.S.;\nPlan main functions of the O.S., processes, etc.;\nChoose the level you want to build it on:\n\nVERY LOW LEVEL (Assembly Language required and MEMORY, CPU, AND HARDWARE RESOURCES KNOWLEDGE REQUIRED ALSO -NOT TO BE ACQUIRED IN MERELY THREE MONTHS... OH NO!...)...\nMedium Level (Here you can use the STANDARD solution, that is C programming Language!);\n\nHigh Level (This is the level you may want to use Python, it means you will use ALL of the same resources and shells you operating systems offer to you, whether it is any Linux Distribution, or a UNIX(R), Windows(R), CP\/M(R) or any other known up to date);\n\n\n\nBecause of the time required for you to build it I must assume you are delivering a College work to earn credits... and yet in case you work for a Corporation or in case you are self employed or your own C.E.O., you must have resources assigned to this project... I will assume you are building it for a Academic's!.\nImagine you are writing a shell, that will ease the start-up of your work, and while you are writing the shell your mind should be drawing the real core of it, along with the addressing and along with the lowest level routines...\nI think you may know MS(R)-DOS(R). The version 3.3 is one of the easiest and enriching (pedagogically speaking) Operating Systems ever designed and published by Microsoft(r) Corp. Please, be creative, DO NOT CLONE IT, just inspire your mind on it, and then build something your Professor or end-consumer will admire and enjoy!.\nDo not forget we are in the age of Graphical User's Interface, so do not go into texting, although ASCII is still the most beautiful expression of computer age, you can play with both interfaces.\nOnce you work this from Top to Dowm you will find out how easy it is to build routines in High Level language, and once you build it, and debug it, may be you will speed up a CORE os. that is: Bootstrapping, Memory management, etcetera... \nDo not get to involved in dealing with interruptions or you may end up loosing you enthusiasm INMEDIATELY!... leave the UNDERGROUND O.S. to deal and take care of the interruptions.\nIn less than three months you will have your first prototype, and then you need to make it work good (To Debug it, I mean!). Exceed yourself!.\nIf you work SOLO, you will need to write a manual, IT TAKES CONSIDERABLY PRECIOUS TIME YOU DO NOT WANT TO LOOSE... My advice (please, do not laugh, I used this technique and it made today's Magnate's earn BILLIONS) WRITE DOWN IN PAPER, HANDWRITTEN, ALL OF THE DOCUMENTATION (THIS IS BECAUSE YOUR FINE MOTRICE COORDINATION IS FASSST! AND EVEN IT WILL NOT EQUAL THE SPEED OF YOUR THOUGHTS IT IS A HARD COPY TO DELIVER TO A WELL PAID ASSISTANT TO TYPE IT INTO A COMPUTER AND EDIT IT MARVELOUS -MAYBE A .PDF WITH ILLUSTRATIONS, ALONG WITH A VIDEO WILL SHARPEN AND DELIGHT THE EYES OF THE END-CONSUMER!.\nRemember, the build up of the first month must be actually a SHELL of the basic functions a BASIC operating system must deliver to the user:\n\nCommands Processor;\nFile Directory listup;\nCreate\/Edit and Delete files;\nCreate\/Edit and Delete Directories;\nAccessing drive units (floppies, Compact Discs, HardDrives, Flash Drives, etc...);\nUpdate and Display of information through the screen!;\n\nI would focus mainly in the previous, and then ANYTHING else comes up easily through the creation of enriching routines (trust me this phase is addictive and you will have NO MORE life when you reach to this poit for you will be married to this project and you will never leave it anymore), do not fear, it wil work!.\nPresent your Operating System, and if your expecting upcomming funds show up, or if your expecting grade gets the higher rated you expect, you may want to keep enlarging your project and then build it into a more solid, robust and steady application!.\nJust imagine yourself using this platform as a plaintiff for any kind of hardware you may want to work with: ROBOTS, AUTOS; AIRPLANES; REMOTE CONTROL; ETC...\nI know you will enjoy this assignment and I know you will entertain yourself greatly! Only a real programmer has this kind of ambitions!\nGod bless America!\nKnowBuddy","Q_Score":15,"Tags":"python,operating-system","A_Id":8959919,"CreationDate":"2010-09-04T18:35:00.000","Title":"Operating System from scratch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. \nI have a few limitations: \n\nI have only 3 months. \nI want to do it in Python. \nI can put in say 20-30 hours every week into it. \n\nI want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?\nIs there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)\nIf the idea is not feasible, can anyone tell me how much do I need to scale down my idea? \nAny help is much appreciated!","AnswerCount":11,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":13899,"Q_Id":3643500,"Users Score":16,"Answer":"Scale this down a lot.  I would recommend looking at one very small piece of an operating system that you would want to do, perhaps parallel processing.  There is no feasible way you will be able to write an entire operating system in under 500 hours, let only 5000 hours. The real question is is this for an undergraduate course or a graduate course?  The answer to that will greatly reflect what is needed to pass.\nAdding\nGrab a book on a topic about the operating system that interests you and focus intently on that for 3 months and you may just produce something that is good.  Operating systems may seem like they don't do much on the outside, but think of it this way Windows has ~50 million lines of code.","Q_Score":15,"Tags":"python,operating-system","A_Id":3643520,"CreationDate":"2010-09-04T18:35:00.000","Title":"Operating System from scratch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. \nI have a few limitations: \n\nI have only 3 months. \nI want to do it in Python. \nI can put in say 20-30 hours every week into it. \n\nI want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?\nIs there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)\nIf the idea is not feasible, can anyone tell me how much do I need to scale down my idea? \nAny help is much appreciated!","AnswerCount":11,"Available Count":7,"Score":1.0,"is_accepted":false,"ViewCount":13899,"Q_Id":3643500,"Users Score":9,"Answer":"Does your professor require a \"low-level\" component in the project? For example, anything that deals with the hardware or the instruction architecture. If so, your professor will not allow you to do the project in Python. The project must be written in C and assembly. And you will invariably be working on modifying the Linux kernel.\nHowever, nowadays Operating System is no longer confined to the low-level aspect. Virtualization, database, parallelization are all built on top of the Operating System. If your professor is \"old school\" then he\/she may not consider those new topics to be part of Operating System. So, you may need to bring some sample ideas to your professor and seek clarification.\nWhether to go into low-level, as some have suggested, depends entirely on the professor's educational goals.\n\nTo teach basic concurrent programming constructs, such as events, semaphors and mutex. This can be taught by writing some multi-thread applications. It is arguably too easy as a goal for an OS class. Nevertheless, this is in fact the most \"marketable\" skill you will get from the class.\n\n\nA variation on this theme is to teach how to \"use\" a particular flavor of OS API.\n\nTo teach how to write applications that make efficient use of the operating system. This may require you to implement some entry-level OS-related algorithms inside a \"simulated OS project\" (say, in Java or Python, could also be in C++). Each aspect can be studied in separate projects\/simulators, without using a full-blown OS.\n\n\nFor example, to teach how to use the file cache efficiently, it is necessary to make students play with a \"toy\" file cache using a simple algorithm.\n\nTo teach the hardware aspect of operating system (including the ugliness of it), namely, how it interacts with the instruction set architecture and hardware I\/O. This is usually done with \"embedded system\", with a small prototyping board.\nTo teach real-world algorithms used inside modern operating system. This will require lots of paper reading, as well as implementing a non-trivial algorithm inside a real Linux kernel. This level is appropriate for graduate studies.\n\nA good project would include one or more of:\n\nInput \/ Output\nStorage\n\n\nDeciding what to cache \/ predicting what to pre-load\n\nStarting \/ managing \/ logging tasks (processes, threads or Python functions), locally or remotely\nManaging resources\n\n\nRequire each process to give estimates of how much peak memory will be used, and to report a \"progress\" percentage regularly throughout their execution, which can then be used together to make estimates about resource usage\n\nCommunication\nConcurrency \n\nA project that does not directly interact with hardware, but would still be good project, will be:\n\nIf your project provides an abstraction of the operating system to the apps that will run \"inside\" your project \n\n\nIn other words, the \"apps\" rely solely on your \"operating system project\" for their I\/O, storage, task management, resource, communication needs\n\nYour project makes good (efficient, measurable) use of the real operating system (Windows, Linux etc)\n\nThen it will be a good Operating Systems project, regardless of the language used.\nI would suggest implementing your own memcached, map-reduce or a simple version control system as good project examples.\nEdited: removed ranting","Q_Score":15,"Tags":"python,operating-system","A_Id":3643598,"CreationDate":"2010-09-04T18:35:00.000","Title":"Operating System from scratch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. \nI have a few limitations: \n\nI have only 3 months. \nI want to do it in Python. \nI can put in say 20-30 hours every week into it. \n\nI want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?\nIs there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)\nIf the idea is not feasible, can anyone tell me how much do I need to scale down my idea? \nAny help is much appreciated!","AnswerCount":11,"Available Count":7,"Score":0.0181798149,"is_accepted":false,"ViewCount":13899,"Q_Id":3643500,"Users Score":1,"Answer":"You could probably code a small embedded-system OS in the timeframe you indicate, using concepts that are over a decade old.  Many newer operating systems require many more complicated scheduling and memory-management heuristics than would be typical in a small embedded OS; designing an entire modern OS would not be a practical single-person project, but one might be able to do something interesting with some subsystem of it.  I personally think there's some room for improvement in flash file systems, but I don't know what your prof would think.  What is your prof really looking for?","Q_Score":15,"Tags":"python,operating-system","A_Id":3644442,"CreationDate":"2010-09-04T18:35:00.000","Title":"Operating System from scratch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. \nI have a few limitations: \n\nI have only 3 months. \nI want to do it in Python. \nI can put in say 20-30 hours every week into it. \n\nI want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?\nIs there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)\nIf the idea is not feasible, can anyone tell me how much do I need to scale down my idea? \nAny help is much appreciated!","AnswerCount":11,"Available Count":7,"Score":0.0,"is_accepted":false,"ViewCount":13899,"Q_Id":3643500,"Users Score":0,"Answer":"Developing an operating system in Python is possible. However, you might want to choose C or Assembly because there's an huge code base developed in those languages.","Q_Score":15,"Tags":"python,operating-system","A_Id":3643741,"CreationDate":"2010-09-04T18:35:00.000","Title":"Operating System from scratch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. \nI have a few limitations: \n\nI have only 3 months. \nI want to do it in Python. \nI can put in say 20-30 hours every week into it. \n\nI want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?\nIs there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)\nIf the idea is not feasible, can anyone tell me how much do I need to scale down my idea? \nAny help is much appreciated!","AnswerCount":11,"Available Count":7,"Score":0.0363476168,"is_accepted":false,"ViewCount":13899,"Q_Id":3643500,"Users Score":2,"Answer":"I don't get how you think you can write an operating system in Python. You need native code to at least load an interpreter during bootup, not to mention hardware communication, drivers etc., all of which would be nearly impossible to do given current Python interpreters when running on a bare machine. I'm also pondering if you are aware that you'd have to port a given Python interpreter to compile and run without an underlying operating system, which alone would keep you busy for a time.\nIt's good that you are ambitious, but I honestly think you could not even finish the basic operating system, let alone \"some very basic apps running\".","Q_Score":15,"Tags":"python,operating-system","A_Id":3643534,"CreationDate":"2010-09-04T18:35:00.000","Title":"Operating System from scratch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. \nI have a few limitations: \n\nI have only 3 months. \nI want to do it in Python. \nI can put in say 20-30 hours every week into it. \n\nI want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?\nIs there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)\nIf the idea is not feasible, can anyone tell me how much do I need to scale down my idea? \nAny help is much appreciated!","AnswerCount":11,"Available Count":7,"Score":0.0181798149,"is_accepted":false,"ViewCount":13899,"Q_Id":3643500,"Users Score":1,"Answer":"In our university we have operating systems course where we too are supposed to develop something on linux. Not entire OS. We did our own scheduling policy and file system for linux. But this will be done in C since linux is in C.","Q_Score":15,"Tags":"python,operating-system","A_Id":3644477,"CreationDate":"2010-09-04T18:35:00.000","Title":"Operating System from scratch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a project in mind that makes it worth to finally take the plunge into programming.\nAfter reading a lot of stuff, here and elsewhere, I'm set on making Python the one I learn for now, over C# or java.  What convinced me the most was actually Paul Graham's excursions on programming languages and Lisp, though Arc is in the experimental stage, which wouldn't help me do this web app right now.\nAs for web app fast, I've checked out Django, Turbo Gears and Py2Web. In spite of spending a lot of time reading, I still have no clue which one I should use.\n1)  Django certainly has the nicest online presence, and a nicely done onsite tutorial, they sure know how to show off their thing.\n2)  Web2Py attracted me with its no-install-needed and the claim of making Django look complicated. But when you dig around on their website, you quickly find content that hasn't been updated in years with broken external links...  There's ghosts on that website that make someone not intimately familiar with the project worry if it might be flatlining.\n3)  Turbo Gears  ...I guess its modular too. People who wrote about it loved it...  I couldn't find anything specific that might make it special over Django.  \nI haven't decided on an IDE yet, though I read all the answers to the Intellisense code completion post here. Showing extra code snippets would be cool too for noobs like me, but I suppose I should choose my web frame work first and then pick an editor that will work well with it.\nSince probably no framework is hands down the best at everything, I will give some specifics on the app I want to build:\nIt will use MySQL, it needs register\/sign-in, and there will be a load of simple math operations on data from input and SQL queries.  I've completed a functional prototype in Excel, so I know exactly what I want to build, which I hope will help me overcome my noobness.  I'll be a small app, nothing big.\nAnd I don't want to see any HTML while building it ;-) \nPS: thanks to the people running Stackoverflow, found this place just at the right moment too!","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":15591,"Q_Id":3646002,"Users Score":6,"Answer":"I have to say as not particularly skilled developer, the speed at which I have been able to create using web2py has blown my mind. In large part due to the amazing community and the core value Massimo has of making the framework accessible.\nWhen I started I had written 0 lines of code in Python\nNever heard of web2py\nI've been at it seriously for about a month and have progressed (in my usual fashion) from asking questions that no one could answer (because they didn't make any sense) to coding for hours at a time without picking up a book or asking a question.\nI'm really impressed.","Q_Score":20,"Tags":"python,django,frameworks,web2py,turbogears","A_Id":4338367,"CreationDate":"2010-09-05T12:11:00.000","Title":"Django, Turbo Gears, Web2Py, which is better for what?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a project in mind that makes it worth to finally take the plunge into programming.\nAfter reading a lot of stuff, here and elsewhere, I'm set on making Python the one I learn for now, over C# or java.  What convinced me the most was actually Paul Graham's excursions on programming languages and Lisp, though Arc is in the experimental stage, which wouldn't help me do this web app right now.\nAs for web app fast, I've checked out Django, Turbo Gears and Py2Web. In spite of spending a lot of time reading, I still have no clue which one I should use.\n1)  Django certainly has the nicest online presence, and a nicely done onsite tutorial, they sure know how to show off their thing.\n2)  Web2Py attracted me with its no-install-needed and the claim of making Django look complicated. But when you dig around on their website, you quickly find content that hasn't been updated in years with broken external links...  There's ghosts on that website that make someone not intimately familiar with the project worry if it might be flatlining.\n3)  Turbo Gears  ...I guess its modular too. People who wrote about it loved it...  I couldn't find anything specific that might make it special over Django.  \nI haven't decided on an IDE yet, though I read all the answers to the Intellisense code completion post here. Showing extra code snippets would be cool too for noobs like me, but I suppose I should choose my web frame work first and then pick an editor that will work well with it.\nSince probably no framework is hands down the best at everything, I will give some specifics on the app I want to build:\nIt will use MySQL, it needs register\/sign-in, and there will be a load of simple math operations on data from input and SQL queries.  I've completed a functional prototype in Excel, so I know exactly what I want to build, which I hope will help me overcome my noobness.  I'll be a small app, nothing big.\nAnd I don't want to see any HTML while building it ;-) \nPS: thanks to the people running Stackoverflow, found this place just at the right moment too!","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":15591,"Q_Id":3646002,"Users Score":2,"Answer":"I've used both web2py and RoR extensively, and while RoR has gotten a lot of popularity and support in the past few years, web2py is simpler, cleaner, less \"magical\", and yet also offers more (useful) out-of-the-box functionality. I'd say that web2py has more potential than RoR, but it is a relatively new framework and does yet not have the maturity of RoR. (Despite that, though, I'd choose web2py over RoR any day...)","Q_Score":20,"Tags":"python,django,frameworks,web2py,turbogears","A_Id":15945257,"CreationDate":"2010-09-05T12:11:00.000","Title":"Django, Turbo Gears, Web2Py, which is better for what?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a project in mind that makes it worth to finally take the plunge into programming.\nAfter reading a lot of stuff, here and elsewhere, I'm set on making Python the one I learn for now, over C# or java.  What convinced me the most was actually Paul Graham's excursions on programming languages and Lisp, though Arc is in the experimental stage, which wouldn't help me do this web app right now.\nAs for web app fast, I've checked out Django, Turbo Gears and Py2Web. In spite of spending a lot of time reading, I still have no clue which one I should use.\n1)  Django certainly has the nicest online presence, and a nicely done onsite tutorial, they sure know how to show off their thing.\n2)  Web2Py attracted me with its no-install-needed and the claim of making Django look complicated. But when you dig around on their website, you quickly find content that hasn't been updated in years with broken external links...  There's ghosts on that website that make someone not intimately familiar with the project worry if it might be flatlining.\n3)  Turbo Gears  ...I guess its modular too. People who wrote about it loved it...  I couldn't find anything specific that might make it special over Django.  \nI haven't decided on an IDE yet, though I read all the answers to the Intellisense code completion post here. Showing extra code snippets would be cool too for noobs like me, but I suppose I should choose my web frame work first and then pick an editor that will work well with it.\nSince probably no framework is hands down the best at everything, I will give some specifics on the app I want to build:\nIt will use MySQL, it needs register\/sign-in, and there will be a load of simple math operations on data from input and SQL queries.  I've completed a functional prototype in Excel, so I know exactly what I want to build, which I hope will help me overcome my noobness.  I'll be a small app, nothing big.\nAnd I don't want to see any HTML while building it ;-) \nPS: thanks to the people running Stackoverflow, found this place just at the right moment too!","AnswerCount":7,"Available Count":3,"Score":0.057080742,"is_accepted":false,"ViewCount":15591,"Q_Id":3646002,"Users Score":2,"Answer":"Django: Heard it has the best administrative\ninterface.  But uses it's own ORM, i.e. doesn't use SQL-Alchemy.\nWeb2py: Didn't research this.\nTurbogears2:\nUses SQL-Alchemy by default, uses Catwalk for admin\ninterface, but documentation isn't as\ngreat.\n\nI chose Turbogears2 because it uses popular components, so I didn't have to learn anything new...","Q_Score":20,"Tags":"python,django,frameworks,web2py,turbogears","A_Id":3757753,"CreationDate":"2010-09-05T12:11:00.000","Title":"Django, Turbo Gears, Web2Py, which is better for what?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma.  PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names.\nSo on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent.  Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency.\nI realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3416,"Q_Id":3647518,"Users Score":33,"Answer":"In your shoes, I wouldn't fight your framework, just like, as a general principle, I don't fight City Hall;-).  I happen to share your preference for lowercase-with-underscore function names as PEP 8 specifies, but when I'm programming in a framework that forces a different capitalization style, I resign myself to adopting that style too, since I can't convince the framework to adopt the \"better\" style, and style inconsistencies (haphazard mixes of different styles) are really worse.\nOf course, some mixage is inevitable if you're using more than one framework... e.g., PyQt with its camelcase, and standard Python library functions with their lowercase and underscores!-).  But since frameworks like Qt are often intended to be extended by subclassing, while the standard Python library has less aspects of such a design, in most case where the capitalization style is forced (because you need to override a method, so you can't choose a different capitalization), it will be forced to camelcase (by Qt), only rarely to lowercase (by the standard Python library).  So, I think that adopting Qt style in this case is still the lesser evil.","Q_Score":35,"Tags":"python,coding-style,pyqt,pyqt4,pep8","A_Id":3647541,"CreationDate":"2010-09-05T19:46:00.000","Title":"PEP8 and PyQt, how to reconcile function capitalization?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma.  PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names.\nSo on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent.  Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency.\nI realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3416,"Q_Id":3647518,"Users Score":6,"Answer":"Use what fits best.\nIf you're subclassing Qt classes, or have a function heavily integrated with them UseCamelCase.\nOtherwise, use_underscores.","Q_Score":35,"Tags":"python,coding-style,pyqt,pyqt4,pep8","A_Id":3647555,"CreationDate":"2010-09-05T19:46:00.000","Title":"PEP8 and PyQt, how to reconcile function capitalization?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma.  PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names.\nSo on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent.  Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency.\nI realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":3416,"Q_Id":3647518,"Users Score":14,"Answer":"The pep8 document says what to do in this case (emphasis mine):\n\nNew modules and packages (including third party frameworks) should be written to these standards, but where an existing library has a different style, internal consistency is preferred.","Q_Score":35,"Tags":"python,coding-style,pyqt,pyqt4,pep8","A_Id":5201198,"CreationDate":"2010-09-05T19:46:00.000","Title":"PEP8 and PyQt, how to reconcile function capitalization?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma.  PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names.\nSo on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent.  Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency.\nI realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3416,"Q_Id":3647518,"Users Score":0,"Answer":"Maybe sensible use of modules to separate the styles in different modules can help. At least try to modularize basic PEP8 style code to own module of helper functions.","Q_Score":35,"Tags":"python,coding-style,pyqt,pyqt4,pep8","A_Id":3647955,"CreationDate":"2010-09-05T19:46:00.000","Title":"PEP8 and PyQt, how to reconcile function capitalization?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Specifically, I need to get at some objects and globals from the main module in an imported module. I know how to find those things when the parent module wants some particular thing from a child module, but I can't figure out how to go in the other direction.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":8627,"Q_Id":3648339,"Users Score":1,"Answer":"Not sure if it is a good practice but maybe you could pass the objects and variables you need as parameters to the methods or classes you call in the imported module.","Q_Score":21,"Tags":"python,namespaces,module","A_Id":3648494,"CreationDate":"2010-09-06T00:04:00.000","Title":"In Python, how can I access the namespace of the main module from an imported module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently building a web application and I would like my users to have their own URLs to identify them. I could either do this using subdomains or using folders and am wondering what are the advantages and disadvantages of either one.\nI really like the folder solution because my URL mapping would be fairly easy. I have read about auto-generating subdomains and one solution was to create virtual hosts and then restart my nginx. It's a solution but I would prefer not to have to restart my web server everytime a new account is created. If there are any other ways on how to do automated subdomain creation, that would be great as well!\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":286,"Q_Id":3653239,"Users Score":1,"Answer":"I think directories are the way to go. I believe it would be easier to adapt Django to the directories way much easier than to subdomains. And as one user commented you can avoid restarting your server each time.\nI prefer to keep subdomains reserved for system use. Users should get their own directories instead. This is not a rule, just my preference.","Q_Score":3,"Tags":"python,django,nginx,subdomain","A_Id":3653270,"CreationDate":"2010-09-06T17:26:00.000","Title":"Subdomains vs folders\/directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently building a web application and I would like my users to have their own URLs to identify them. I could either do this using subdomains or using folders and am wondering what are the advantages and disadvantages of either one.\nI really like the folder solution because my URL mapping would be fairly easy. I have read about auto-generating subdomains and one solution was to create virtual hosts and then restart my nginx. It's a solution but I would prefer not to have to restart my web server everytime a new account is created. If there are any other ways on how to do automated subdomain creation, that would be great as well!\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":286,"Q_Id":3653239,"Users Score":0,"Answer":"Use something like mod_wsgi instead of cgi scripts, they allow you to use arbitrary URL configs (example: Django, web.py, Zope ...)","Q_Score":3,"Tags":"python,django,nginx,subdomain","A_Id":3653257,"CreationDate":"2010-09-06T17:26:00.000","Title":"Subdomains vs folders\/directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I update the kernel, after that the Ubuntu doesn't work well, PS: I try to exec \"meld\" command, it will report that \"\/usr\/bin\/env: python: No such file or directory\", \nthen I exec \"sudo apt-get install python\" and get the result \"python is already the newest version.\", what should I do for it.\n\nI'm not good at linux, can you tell me how to revert my linux to the last right status, or reinstall the python normally.","AnswerCount":7,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":161757,"Q_Id":3655306,"Users Score":7,"Answer":"@mchid's answer is the one you should go for it.\njust FYI,\nif you do this:\n$ python\nit will say Command 'python' not found ...\nBut if you do this:\n$ python3, it should work.\nSo, just modify the shebang line\nfrom !#\/usr\/bin\/env python\nto !#\/usr\/bin\/env python3, you're good to go.\n(which is automatically done by doing\nsudo apt install python-is-python3)","Q_Score":91,"Tags":"python,ubuntu-9.04","A_Id":66512967,"CreationDate":"2010-09-07T02:06:00.000","Title":"ubuntu \/usr\/bin\/env: python: No such file or directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to write a python script which reads the '.bash_history' file and prints the statistics. Also, I would like to print the command which was used the most. I was able to read the bash history through the terminal but I'm not able to do it through python programming. Can someone please help me with how to start with it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":696,"Q_Id":3656500,"Users Score":0,"Answer":"Just some basic ideas, with important python functions for that:\n\nread the file; open\ngo through all lines and sum up the number of occurences of a line; for, dict\nin case you only want to check parts of a command (for example treat cd XY and cd .. the same), normalize the lines by removing the command arguments after the space; split\nsort the sums and print out the command with the highest sum.","Q_Score":1,"Tags":"python","A_Id":3656550,"CreationDate":"2010-09-07T07:16:00.000","Title":"reading .bash_history file through python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm installing an environment where I had two Zope\/Plone servers:\n\nplone1 -> for web content & user authentication\nplone2 -> for web applications\n\nI want to implement SSO around both servers but I don't know how to do it. I try to modify login_next and setAuthCookie(..) to share the __ac cookie in the domain, but didn't work.\nAnyone know the best way to achieve it!\nThanks in advance,\nOscar S\u00e1nchez.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":3666676,"Users Score":0,"Answer":"If both sites are on the same domain (but different subdomain), you can try to set the cookie on \".domain.tld\". But I'm not sure if that will work - sending the original credentials as cookies is highly insecure, a session should be used in stead, and you can't share this session between two different instances.\nHave you considered something like openid, possibly with your own private OpenID provider? That basically implements simple SSO out of the box.","Q_Score":2,"Tags":"python,single-sign-on,plone,zope","A_Id":3698638,"CreationDate":"2010-09-08T10:17:00.000","Title":"Two Zope\/Plone machines and SSO","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an officially updated recommendation indicating which versions of Python should be supported by released modules?  Or perhaps a page giving a survey of production usage of various versions?  It's difficult to know how much use to make of newish features like context managers, class decorators, etc. when writing a module.\nNote that learning which versions of Python are in common usage now is only part of my question; I'd like to find a resource which will provide up-to-date information for future readers of this thread (and myself).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":3666750,"Users Score":0,"Answer":"Mac OS X 10.6 (Snow Leopard) has 2.6.1 as the installed version.\nIIRC, 10.5 (Leopard) has 2.5 as the installed version.","Q_Score":5,"Tags":"python,version,backwards-compatibility","A_Id":3668628,"CreationDate":"2010-09-08T10:27:00.000","Title":"earliest commonly used version of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Beginner here, stuck wondering what I need to do to learn development in different web environments.  Say, for instance I want to play around in PHP & MySQL.  But I also want to try things with Ruby on Rails and maybe even server things with Python.  Do I need a different environment for each platform?  Am I required to have a virtual machine to do so?  Is it easy to uninstall and start over for each endeavor for a Windows 7 machine?\nOr, better yet, would it just be easier to throw Linux in a virtual environment?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":3674568,"Users Score":0,"Answer":"I would go the vitual road (VMware or virtual box). Multiple enviroments have a lot of dependencies, so its just much much easier with vitual hosts.","Q_Score":0,"Tags":"php,python,mysql,ruby-on-rails","A_Id":3675235,"CreationDate":"2010-09-09T07:27:00.000","Title":"Multiple Web Development Environments on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Beginner here, stuck wondering what I need to do to learn development in different web environments.  Say, for instance I want to play around in PHP & MySQL.  But I also want to try things with Ruby on Rails and maybe even server things with Python.  Do I need a different environment for each platform?  Am I required to have a virtual machine to do so?  Is it easy to uninstall and start over for each endeavor for a Windows 7 machine?\nOr, better yet, would it just be easier to throw Linux in a virtual environment?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":225,"Q_Id":3674568,"Users Score":1,"Answer":"I started off with php and mysql, it's a lower-level then the rest of the environments like Django and Ruby on Rails; so it's much easier to understand what is really happening. \nIf you want to get into web development, php is a solid foundation and has easy bundle installers such as WAMP, and has a massive community.\nHowever if understanding the core of web applications is not your goal and you want some magic to make your application quicker and speed through development, you would want to use a web application framework environment, my favorite here is Ruby on Rails. \nRuby on Rails is a little difficult for the newbie to setup, it typically sucks running in Windows, so you'd be better off with an install on top of a UNIX environment such as Linux, Mac OS, BSD.\nIf you do want to go the rails route, I suggest installing Ruby with a ruby manager called RVM which is very helpful for playing around with Ruby environments. \nDjango is a good solid framework but it's playing catch up with Rails and in my honest opinion, doesn't have all those power magic that Rails has such as database migrations.","Q_Score":0,"Tags":"php,python,mysql,ruby-on-rails","A_Id":3675212,"CreationDate":"2010-09-09T07:27:00.000","Title":"Multiple Web Development Environments on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have textmate, but honestly the only thing I can do with it is simply edit a file.\nThe handy little file browser is aslo useful. (how can I show\/hide that file browser anyhow!)\nBut I have no other knowledge\/tricks up my sleeve, care to help me out?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":274,"Q_Id":3678221,"Users Score":2,"Answer":"If you look under the Bundles menu in TextMate there is a Python-specific sub-menu that exposes a bunch of helpful things like syntax checking, script debugging, insertion of oft used code blocks, manual look ups and so on. Most of them are bound to keyboard shortcuts (or can be bound if they are not).\nAlso, under the Bundles are sort of general-to-code or general-to-text-editing tasks in sub-menus.\nYou can set up templates for new file creation that let you start new files with all the little bits and pieces you like to see in new files (copyright notice, author, SCC tags, etc.) See the File -> New From Template -> Edit Templates... menu option to do that. It ships with 4 Python templates already.\nFinally, that browser is called the Project Drawer. View -> Show Project Drawer to get it to show up. It'll only be available when the window you're viewing is a project window, not a single document window.","Q_Score":0,"Tags":"python,pylons,textmate","A_Id":3679180,"CreationDate":"2010-09-09T15:49:00.000","Title":"How can textmate make my python (pylons) development easier?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I print the tuple (u'1S\u00b2') I get the predicted output of 1S\u00b2 \nHowever, when I print the tuple (u'1S\u00b2',u'2S\u00b9') I get the output (u'1S\\xb2', u'2S\\xb9').\nWhy is this? What can I do about this?\nAlso, how do I get the number of items in a tuple?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1290,"Q_Id":3680245,"Users Score":1,"Answer":"(u'1S\u00b2') is not a tuple.\n(u'1S\u00b2',) is a tuple containing u'1S\u00b2'.\nlen((u'1S\u00b2',)) returns the length of the tuple, that is, 1.\nalso, when printing variables, beware there are 2 types of output :\n\nthe programmer friendly string representation of the object : that is repr(the_object)\nthe text representation of the object, mostly applicable for strings\n\nif the second is not availlable, the first is used. unlike strings, tuples don't have a text representation, hence the programmer friendly representation is used to represent the tuple and its content.","Q_Score":1,"Tags":"python,tuples","A_Id":3680293,"CreationDate":"2010-09-09T20:17:00.000","Title":"Need help with tuples in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project on Info Retrieval.\nI have made a Full Inverted Index using Hadoop\/Python. \nHadoop outputs the index as (word,documentlist) pairs which are written on the file.\nFor a quick access, I have created a dictionary(hashtable) using the above file.\nMy question is, how do I store such an index on disk that also has quick access time.\nAt present I am storing the dictionary using python pickle module and loading from it\nbut it brings the whole of index into memory at once (or does it?). \nPlease suggest an efficient way of storing and searching through the index.\nMy dictionary structure is as follows (using nested dictionaries)\n{word : {doc1:[locations], doc2:[locations], ....}}\nso that I can get the documents containing a word by\ndictionary[word].keys() ... and so on.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3666,"Q_Id":3687715,"Users Score":0,"Answer":"You could store the repr() of the dictionary and use that to re-create it.","Q_Score":5,"Tags":"python,information-retrieval,inverted-index","A_Id":3688556,"CreationDate":"2010-09-10T19:29:00.000","Title":"Storing an inverted index","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project on Info Retrieval.\nI have made a Full Inverted Index using Hadoop\/Python. \nHadoop outputs the index as (word,documentlist) pairs which are written on the file.\nFor a quick access, I have created a dictionary(hashtable) using the above file.\nMy question is, how do I store such an index on disk that also has quick access time.\nAt present I am storing the dictionary using python pickle module and loading from it\nbut it brings the whole of index into memory at once (or does it?). \nPlease suggest an efficient way of storing and searching through the index.\nMy dictionary structure is as follows (using nested dictionaries)\n{word : {doc1:[locations], doc2:[locations], ....}}\nso that I can get the documents containing a word by\ndictionary[word].keys() ... and so on.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3666,"Q_Id":3687715,"Users Score":0,"Answer":"I am using anydmb for that purpose. Anydbm provides the same dictionary-like interface, except it allow only strings as keys and values. But this is not a constraint since you can use cPickle's loads\/dumps to store more complex structures in the index.","Q_Score":5,"Tags":"python,information-retrieval,inverted-index","A_Id":5341353,"CreationDate":"2010-09-10T19:29:00.000","Title":"Storing an inverted index","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've developed a website in Pylons (Python web framework) and have it running, on my production server, under Apache + mod_wsgi.\nI've been hearing a lot of good things about nginx recently and wanted to give it a try. Currently, it's running as  a forwarding proxy to create a front end to Paste. It seems to be running pretty damn fast... Though, I could probably contribute that to me being the only one accessing it.\nWhat I want to know is, how will Paste hold up under a heavy load? Am I better off going with nginx + mod_wsgi ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":693,"Q_Id":3689766,"Users Score":1,"Answer":"Your app will be the bottleneck in performance not Apache or Paste.\nNginx is used in lots of production servers so that bit will be fine. I don't know about mod_wsgi but uWSGI is used in production environments and plays well with both nginx and Paste applications.\nI currently run a server using Apache + Paste using Apache to serve static content and Paste to handle Pylons. When I stress tested the setup (using default settings on Apache) I got a lot of variation in the time it took to handle requests (varying from 0.5 to 10 secs).\nAs a test I setup Nginx + uWSGI. Nginx is known to be very good for handling static content and I saw a 10x improvement in the number of files it could serve. The average response time for the Pylons app didn't change (it's DB bound) but the variability dropped to almost zero. \nNeither setup dropped a connection or failed to respond so based on this I'll be moving to Nginx + uWSGI for our next app, especially as it has a lot more static content.","Q_Score":2,"Tags":"python,nginx,pylons,production-environment,paste","A_Id":3711301,"CreationDate":"2010-09-11T04:11:00.000","Title":"Will nginx+paste hold up in a production environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how python dictionaries store key: value tuples. In the project I'm working on, I'm required to store key associated with a value that's a list. \nex: \nkey -> [0,2,4,5,8]\nwhere,\nkey is a word from text file\nthe list value contains ints that stand for the DocIDs in which the word occurs.\nas soon as I find the same word in another doc, i need to append that DocID to the list.\nHow can I achieve this?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14894,"Q_Id":3694031,"Users Score":0,"Answer":"Something like this?\n\n\nword = 'something'\nl = [0,2,4,5,8]\nmyDict = {}\nmyDict[word] = l\n\n#Parse some more\n\nmyDict[word].append(DocID)","Q_Score":2,"Tags":"python,information-retrieval","A_Id":3694041,"CreationDate":"2010-09-12T06:55:00.000","Title":"Python: Storing a list value associated with a key in dictionary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to remove a incorrectly installed program and reinstall it. I can remove the program with subprocess.Popen calling the msiexe on it and install new program the same way BUT ONLY with two independent scripts. But i also need to remove some folders in C:\\Programs files and also in C:\\Doc& Settings. How can i traverse through the directory structure and remove the folders?Also how can i continue the script after restart the PC from the next line to install the new program.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":472,"Q_Id":3694051,"Users Score":1,"Answer":"In a nutshell, here's what you'll need to do.\nYou can delete the files and folders by using the remove() and rmdir() or removedirs() methods in the os module (assuming your user\/program has administrative rights).\nTo restart your script you will first need to add some command line argument handling to it that allows it to be told whether to start from the beginning or continue from the other point. \nTo get the script to run after restart, you'll need to set a value in the Windows registry. I believe they're stored under the HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceand HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOncekeys. There you can add a string value (type REG_SZ) which contains a command line to invoke your script and pass it the appropriate command line argument(s) which will tell it to continue and re-install the program.","Q_Score":0,"Tags":"python,windows,directory,traversal","A_Id":3696438,"CreationDate":"2010-09-12T07:07:00.000","Title":"windows python script to traverse directory to remove folders, restart PC and continue the next line of the script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i receive the console output of any python file (errors, everything printed using the print() command)?\nexample:\nmain.py starts test.py and gets its output","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1180,"Q_Id":3694226,"Users Score":0,"Answer":"You can use sys.stderr from the sys module. print() uses sys.stdout by default.\n\nimport sys\n\n# Print to standard output stream\nprint(\"Normal output...\")\n\n# Print to standard error stream\nprint(\"Error output...\", file=sys.stderr)","Q_Score":0,"Tags":"python-3.x","A_Id":3701970,"CreationDate":"2010-09-12T08:35:00.000","Title":"get console output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to change my PATH from Python 2.6.1 to 3.1.2. I  have both versions installed on my computer, but when I type python --version in the terminal I get Python 2.6.1. So, thats the current version it's \"pointing\" to. Now if I type python3.1 it loads the  version I want to use, although the PATH is still pointing to 2.6.1. Downloaded along with the Python 3.1 package comes an Update Shell Profile.command - when I run it and then run nano  ~\/.bash_profile it says:\n\nSetting PATH for Python 3.1 the orginal version is saved in .bash_profile.pysave\nPATH=\"\/Library\/Frameworks\/Python.framework\/Versions\/3.1\/bin:${PATH}\"\nexport PATH.\n\nDoes this mean that I have changed the PATH, or does it just giving me instructions how to?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":91910,"Q_Id":3696124,"Users Score":0,"Answer":"i managed to fixed mine by removing python2, i don't if it's a good practice","Q_Score":18,"Tags":"python,macos","A_Id":61142084,"CreationDate":"2010-09-12T18:56:00.000","Title":"changing python path on mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a block of code selected, I want to un-indent this selected code.\nOn a pc, I would do a shift-tab and it would un-indent.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4349,"Q_Id":3697628,"Users Score":7,"Answer":"Option+Shift+Tab (or Cmd+]).\nOmitting shift (or changing ] to [) will indent instead of reverse-indent.","Q_Score":4,"Tags":"python,textmate","A_Id":3697633,"CreationDate":"2010-09-13T02:57:00.000","Title":"In textmate, how do I reverse indent a block of selected code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script receiveing data from a socket, each data contains a sessionid that a have to keep track of, foreach incomming message, i'm opening a new process with the multiprocessing module, i having trouble to figure out a way to keep track of the new incoming messages having the same sessionid. For example:\n100100|Hello -- \n(open a new process)\n100100|Hello back at you\n(proccess replies)\n100101|Hello\n(open a new process)\n100101|Hello back at you\n(new proccess replies)\n100100|wasap? -- \n(open a new process)\nwhen a new message from sessionid 100100 comes... how could i sent it to the process that is handling those particular messages?\nuntil know the main process is opening a new process for each incomming message another process is writing data on the socket, but is giving me real trouble finding out a way to handle each session process and sending data to them...\nI need some guidance cause a never work with multiprocessing before...\nThanks...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1058,"Q_Id":3698051,"Users Score":0,"Answer":"I am not sure about the requirement to open a separate process for every message received from the sockets. I guess, you have a reason for doing all that you have mentioned.\nMy understanding is, you have written a server side socket that listens for client connection, accepts the client connection, receives the data and dispatch these data to various processes you have created to handle these messages. \nI am assuming that session id remains same for a client connection. Each client sends data tagged with it's session id. If this is the case, then you can solve easily by the fact that in unix - forks duplicate file \/ socket descriptors. when you launch a multiprocessing.Process(), you can pass it the socket descriptor. Ensure that you close the socket in parent process or the process in which you listen for client connections. This way each process will handle the connection and will receive only messages for the single client tagged with the same session id. \nI hope this answers your need.","Q_Score":0,"Tags":"python,session,queue,multiprocessing","A_Id":3698555,"CreationDate":"2010-09-13T05:46:00.000","Title":"Python multiprocessing handling sessions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can we call the CLI executables commands using Python\nFor example i have 3 linux servers which are at the remote location and i want to execute some commands on those servers like finding the version of the operating system or executing any other commands. So how can we do this in Python. I know this is done through some sort of web service (SOAP or REST) or API but i am not sure....... So could you all please guide me.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":3699268,"Users Score":0,"Answer":"Depends on how you want to design your software.\nYou could do stand-alone scripts as servers listening for requests on specific ports,\nor you could use a webserver which runs python scripts so you just have to access a URL.\nREST is one option to implement the latter.\nYou should then look for frameworks for REST development with python, or if it\u2019s simple logic with not so many possible requests can do it on your own as a web-script.","Q_Score":1,"Tags":"python,django,web-services,api,soap","A_Id":3699299,"CreationDate":"2010-09-13T09:41:00.000","Title":"How can we call the CLI executables commands using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"What are the top gotchas for someone moving from a static lang (java\/c#) to dynamic language like python?\nIt seems cool how things can be done, but renaming a method, or adding\/removing parameters seems so risky!\nIs the only solution to write tests for each method?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":248,"Q_Id":3703704,"Users Score":2,"Answer":"Some things that struck me when first trying out Python (coming from a mainly Java background):\n\nWrite Pythonic code. Use idioms recommended for Python, rather than doing it the old Java\/C way. This is more than just a cosmetic or dogmatic issue. Pythonic code is actually hugely faster in practice than C-like code practically all the time. As a matter of fact, IMHO a lot of the \"Python is slow\" notion floating around is due to the fact that inexperienced coders tried to code Java\/C in Python and ended up taking a big performance hit and got the idea that Python is horribly slow. Use list comprehensions and map\/filter\/reduce whenever possible.\nGet comfortable with the idea that functions are truly objects. Pass them around as callbacks, make functions return functions, learn about closures etc.\nThere are a lot of cool and almost magical stuff you can do in Python like renaming methods as you mention. These things are great to show off Python's features, but really not necessary if you don't need them. Indeed, as S. Lott pointed out, its better to avoid things that seem risky.","Q_Score":6,"Tags":"java,python,dynamic-languages","A_Id":3703964,"CreationDate":"2010-09-13T19:29:00.000","Title":"top gotchas for someone moving from a static lang (java\/c#) to dynamic language like python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What are the top gotchas for someone moving from a static lang (java\/c#) to dynamic language like python?\nIt seems cool how things can be done, but renaming a method, or adding\/removing parameters seems so risky!\nIs the only solution to write tests for each method?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":248,"Q_Id":3703704,"Users Score":3,"Answer":"\"Is the only solution to write tests for each method?\"\n\nAre you saying you didn't write tests for each method in Java?\nIf you wrote tests for each method in Java, then -- well -- nothing changes, does it?\n\nrenaming a method, seems so risky!\n\nCorrect.  Don't do it.\n\nadding\/removing parameters seems so risky!\n\nWhat?  Are you talking about optional parameters?  If so, then having multiple overloaded names in Java seems risky and confusing.  Having optional parameters seems simpler.\n\nIf you search on SO for the most common Python questions, you'll find that some things are chronic questions.\n\nHow to update the PYTHONPATH.\nWhy some random floating-point calculation isn't the same as a mathematical abstraction might indicate.\nUsing Python 3 and typing code from a Python 2 tutorial.\nWhy Python doesn't have super-complex protected, private and public declarations.\nWhy Python doesn't have an enum type.\n\nThe #1 chronic problem seems to be using mutable objects as default values for a function.  Simply avoid this.","Q_Score":6,"Tags":"java,python,dynamic-languages","A_Id":3703732,"CreationDate":"2010-09-13T19:29:00.000","Title":"top gotchas for someone moving from a static lang (java\/c#) to dynamic language like python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I get the window name?\nI want to make a script where I have some keyboard event, and I want it to happens only if the window name has something in the name, like, Firefox.\nhow can I do it?\nthe simplest way","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4493,"Q_Id":3706128,"Users Score":0,"Answer":"If you are using pyhook, event.WindowName in your OnKeyboardEvent etc function contains the value xx","Q_Score":1,"Tags":"python,windows","A_Id":5380835,"CreationDate":"2010-09-14T04:25:00.000","Title":"how can I get the window name? [Python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So of course I'm new to Python and to programming in general...\nI am trying to get OS version information from the network. For now I only care about the windows machines.\nusing PyWin32 I can get some basic information, but it's not very reliable. This is an example of what I am doing right now: win32net.NetWkstaGetInfo(myip, 100)\nHowever, it appears as though this would provide me with more appropriate information: platform.win32_ver()\nI have no idea how get the info from a remote machine using this. I need to specify an IP or a range of IP's... I intend on using Google's ipaddr to get a list of network ranges to scan. I will eventually need to scan a large network for this info.\nCan someone provide an example?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1156,"Q_Id":3712992,"Users Score":0,"Answer":"I had to use remote registry...\nHKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\nProductName, EditionID, CurrentVersion, CurrentBuild","Q_Score":1,"Tags":"python,windows","A_Id":3954806,"CreationDate":"2010-09-14T21:17:00.000","Title":"Python: How to use platform.win32_ver() on a remote machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to pass a string which has a '%' in it (its actually a sql query string). How do I pass the % (do I have to use a specific escape character?\neg:\ncompute_answertime(\"%how do I%\")","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":179,"Q_Id":3718322,"Users Score":1,"Answer":"use %%..........","Q_Score":1,"Tags":"python","A_Id":3718337,"CreationDate":"2010-09-15T13:56:00.000","Title":"What is the escape character for % in python's string method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I know is there my child process got hang while operating?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2476,"Q_Id":3724238,"Users Score":1,"Answer":"I guess, you are asking, how do you find if the child process is hung while operating. You can't tell easily. A process could be doing a long running operation. The context is important to understand when a process is hung.\nIf you are expecting a process to respond to a user input and is not responsive for a long period then we consider it hung. Process is running probably waiting for some thing that will never happen. \"Hung Process\" is humanly way of saying that a program has reached a dead end and will be no more useful.\nYou could have a program calculating prime numbers one after another and can run for eons and can not be called a hung process.","Q_Score":2,"Tags":"python,process,subprocess,parent-child","A_Id":3724308,"CreationDate":"2010-09-16T06:35:00.000","Title":"Python subprocess how to determine if child process hangs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I know is there my child process got hang while operating?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2476,"Q_Id":3724238,"Users Score":2,"Answer":"Well, how do you tell the difference between a stuck process and a process that takes longer than usual to complete? The short answer is: No, you can't detect if your child process is stuck.\nI would say that to be able to detect this you need some kind of continuous communication with the process (e.g. look at log files, IPC or similar). Based on this communication you might be able to tell when and if a process is stuck.","Q_Score":2,"Tags":"python,process,subprocess,parent-child","A_Id":3724322,"CreationDate":"2010-09-16T06:35:00.000","Title":"Python subprocess how to determine if child process hangs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have x64 Windows XP machine.\nI use Netbeans to code Java.\nI am now trying to use it for Python, but I get this error:\n\\NetBeans was unexpected at this time.\nAny idea how to fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":486,"Q_Id":3728310,"Users Score":0,"Answer":"You probably want to ask this question on www.serverfault.com rather than stackoverflow as it is more of a configuration issue rather than a programming issue.\nInclude the version of Netbeans and the Java you are using - and whether you using native python and\/or Jython as well.\nAlso include at which point you see the error message - when you create a new file, new project etc - does Netbeans start up ok etc ?","Q_Score":1,"Tags":"python,netbeans","A_Id":3743725,"CreationDate":"2010-09-16T15:42:00.000","Title":"Using Python in Netbeans","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is there a way to send an interrupt to a python module when the user inputs something in the console? For example, if I'm running an infinite while loop, i can surround it with a try\/except for KeyboardInterrupt and then do what I need to do in the except block.\nIs there a way to duplicate this functionality with any arbitrary input? Either a control sequence or a standard character?\nEdit: Sorry, this is on linux","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2997,"Q_Id":3731681,"Users Score":2,"Answer":"You need a separate process (or possibly a thread) to read the terminal and send it to the process of interest via some form of inter-process communication (IPC) (inter-thread communication may be harder -- basically the only thing you do is send a KeyboardInterrupt from a secondary thread to the main thread).  Since you say \"I was hoping there would be a simple way to inject user input into the loop other than just ^C\", I'm sad to disappoint you, but that's the truth: there are ways to do what you request, but simple they aren't.","Q_Score":3,"Tags":"python,linux,input,interrupt","A_Id":3731809,"CreationDate":"2010-09-16T23:41:00.000","Title":"Capturing user input at arbitrary times in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to send an interrupt to a python module when the user inputs something in the console? For example, if I'm running an infinite while loop, i can surround it with a try\/except for KeyboardInterrupt and then do what I need to do in the except block.\nIs there a way to duplicate this functionality with any arbitrary input? Either a control sequence or a standard character?\nEdit: Sorry, this is on linux","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":2997,"Q_Id":3731681,"Users Score":1,"Answer":"KeyboardInterrupt is special in that it can be trapped (i.e. SIGINT under operating systems with respective POSIX support, SetConsoleCtrlHandler on Windows) and handled accordingly. If you want to process user input while at the same time doing work in a otherwise blocking loop, have a look at the threading or subprocess modules, taking a look at how to exchange data between two different threads \/ processes. Also be sure to get an understanding of the issues that go hand in hand with parallel computing (i.e. race conditions, thread safety \/ synchronization etc.)","Q_Score":3,"Tags":"python,linux,input,interrupt","A_Id":3731716,"CreationDate":"2010-09-16T23:41:00.000","Title":"Capturing user input at arbitrary times in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"One of the modules I import into my python project triggers lots of warnings under Pychecker. Fixing up this external module isn't really an option, so I want to tell Pychecker to ignore it.\nDoes anyone know how to do this? I'm sure it's possible, and probably quite simple, but after trawling Google for a while I've not found any documentation or examples.\nThanks,\nSam\nEdit: I can't tag this with 'pychecker' unfortunately as that tag doesn't exist yet and my rep is too low to create.\nEdit 2 Bonus extra question: does pychecker check ignored modules anyway, and just not print anything it finds? or do you get some speedup by ignoring some modules?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1754,"Q_Id":3736311,"Users Score":1,"Answer":"On the bonus extra question:\n\npychecker always imports the files you pass it, which causes it to import whatever those import.  This is just like Python.  This is a first pass in pychecker.\nThen pychecker will actually go through the loaded modules, disassemble the code, and run through all the opcodes.  This is a second pass.\nIn both cases, it tracks all warnings generated even by ignored modules.  Then it filters out those warnings before showing them.\n\nI am considering if it is worth it to change pychecker to not even look at blacklisted modules at all, or make it possible to only disassemble the one file (for integration in an editor for example).","Q_Score":1,"Tags":"python,pychecker","A_Id":4782453,"CreationDate":"2010-09-17T14:39:00.000","Title":"How can I tell Pychecker to ignore an imported library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible that CherryPy, in its default configuration, is caching the responses to one or more of my request handlers?  And, if so, how do I turn that off?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2007,"Q_Id":3736606,"Users Score":4,"Answer":"CherryPy has a caching Tool, but it's never on by default. Most HTTP responses are cacheable by default, though, so look for an intermediate cache between your client and server. Look at the browser first.\nIf you're not sure whether or not your content is being cached, compare the Date response header to the current time.","Q_Score":3,"Tags":"python,http,cherrypy","A_Id":3737124,"CreationDate":"2010-09-17T15:15:00.000","Title":"How to determine if CherryPy is caching responses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple workflow [Step 0]->[1]->[2]->...->[Step N]. The master program knows the step (state) it is currently at.\nI want to stream this in real time to a website (in the local area network) so that when my colleagues open, say, http:\/\/thecomputer:8000, they can see a real time rendering of the current state of our workflow with any relevant details.\nI've tought about writing the state of the script to an StringIO object (streaming to it) and use Javascript to refresh the browser, but I honestly have no idea how to actually do this.\nAny advice?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":880,"Q_Id":3739296,"Users Score":1,"Answer":"You could have the python script write an xml file that you get with an ajax request in your web page, and get the status info from that.","Q_Score":4,"Tags":"javascript,python,streaming,real-time","A_Id":3739311,"CreationDate":"2010-09-17T21:47:00.000","Title":"Streaming the state of a Python script to a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In all python dbus documentations there are info on how to export objects, interfaces, signals, but there is nothing how to export interface property.\nAny ideas how to do that ?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5868,"Q_Id":3740903,"Users Score":2,"Answer":"this example does not work I think because : \n'''\nThe available properties and whether they are writable can be determined by calling org.freedesktop.DBus.Introspectable.Introspect, see the section called \u201corg.freedesktop.DBus.Introspectable\u201d.\n'''\nand in introspection data the property are missing:\n\nI use dbus-python-1.1.1","Q_Score":6,"Tags":"python,dbus","A_Id":13629355,"CreationDate":"2010-09-18T08:29:00.000","Title":"Python Dbus : How to export Interface property","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a Python script to index a large set of Windows installers into a DB.\nI would like top know how to read the metadata information (Company, Product Name, Version, etc) from EXE, MSI and ZIP files using Python running on Linux.\nSoftware\nI am using Python 2.6.5 on Ubuntu 10.04 64-bit with Django 1.2.1.\nFound so far:\nWindows command line utilities that can extract EXE metadata (like filever from SysUtils), or other individual CL utils that only work in Windows.  I've tried running these through Wine but they have problems and it hasn't been worth the work to go and find the libs and frameworks that those CL utils depend on and try installing them in Wine\/Crossover.\nWin32 modules for Python that can do some things but won't run in Linux (right?)\nSecondary question:\nObviously changing the file's metadata would change the MD5 hashsum of the file.  Is there a general method of hashing a file independent of the metadata besides locating it and reading it in (ex: like skipping the first 1024 byes?)","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":4161,"Q_Id":3742583,"Users Score":1,"Answer":"To answer your second question: no, there is no way to hash a PE file or ZIP file, ignoring the metadata, without locating and reading the metadata.  This is because the metadata you're interested in is stored at variable locations in the file.\nIn the case of PE files (EXE, DLL, etc), it's stored in a resource block, typically towards the end of the file, and a series of pointers and tables at the start of the file gives the location.\nIn the case of ZIP files, it's scattered throughout the archive -- each included file is preceded by its own metadata, and then there's a table at the end giving the locations of each metadata block.  But it sounds like you might actually be wanting to read the files within the ZIP archive and look for EXEs in there if you're after program metadata; the ZIP archive itself does not store company names or version numbers.","Q_Score":7,"Tags":"python,windows-installer,metadata,md5","A_Id":3742782,"CreationDate":"2010-09-18T16:55:00.000","Title":"Read EXE, MSI, and ZIP file metadata in Python in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django and want to be able to store classes in a database for things like forms and models so that I can easily make them creatable through a user interface since they are just stored in the database as opposed to a regular file. I don't really know a whole lot about this and am not sure if this is a situation where I need to use exec in python or if there is some other way. My searches on this aren't turning up much of anything.\nBasically, it would just be where I do a database call and get the contents of a class, then I want to instantiate it. Any advice is appreciated on how to best do this sort of thing.\nEDIT: In response to the idea of a malicious __init__ in the class, these are only for things like forms or models where it is tightly controlled through validation what goes in the class, there would never be an __init__ in the class and it would be basically impossible, since I would validate everything server side, to put anything malicious in the class.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":262,"Q_Id":3743329,"Users Score":5,"Answer":"Do not store code in the database!!!\nImagine a class with a malicious __init__ method finding it's way in your \"class repository\" in the database. This means whoever has write access to those database tables has the ability to read any file from your web server and even nuke it's file system, since they have the ability to execute any python code on it.","Q_Score":2,"Tags":"python,database,django,class","A_Id":3743351,"CreationDate":"2010-09-18T20:13:00.000","Title":"Python, how to instantiate classes from a class stored in a database?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can someone tell me how to make my script callable in any directory?\nMy script simply returns the number of files in a directory. I would like it to work in any directory by invoking it, instead of first being copied there and then typing python myscript.py\nI am using Mac OS X, but is there a common way to get it installed on Windows and Linux?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3533,"Q_Id":3743812,"Users Score":0,"Answer":"All of those operating systems should support a PATH environment variable which specifies directories that have executables that should be available everywhere. Make your script executable by chmod +x and place it into one of those directories (or add a new one to your PATH - I have ~\/bin for instance).\nI don't know how to make new kinds of files directly executable on Windows, though, but I guess you could use a .bat file as a proxy.","Q_Score":3,"Tags":"python,linux,windows,shell,osx-leopard","A_Id":3743825,"CreationDate":"2010-09-18T22:43:00.000","Title":"Making Python script accessible system wide","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to keep some global settings for my project in Django. I need to have access to these settings from the code. For example, I need to set a current theme for my site that I can set using admin console or from the code. Or I need to set a tagline that will show in the header of all pages. I suppose I should use models for keeping the settings but I can't realize how I should better do it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":3746790,"Users Score":0,"Answer":"If you are okay with changing these setting programmatically via settings.py you should do that. However, if you want to change these settings via the Admin Console, you should use models.","Q_Score":1,"Tags":"python,django,django-models","A_Id":3746881,"CreationDate":"2010-09-19T17:50:00.000","Title":"How to work with settings in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been wanting to get into Python for a while now and have accumulated quite a few links to tutorials, books, getting started guides and the like. I have done a little programming in PERL and PHP, but mostly just basic stuff.\nI'd like to be able to set expectations for myself, so based on the following requirements how long do you think it will take to get this app up and running?\nOnline Collection DB\n\nUsers can create accounts that are authenticated through token sent via e-mail\nOnce logged in, users can add items to pre-created collections (like \"DVD\" or \"Software\")\nEach collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc)\nUsers can list all items in collections (all DVDs, all Software), sort by various attributes\n\nAlso: Yes I know there are lots of online tools like this, but I want to build it on my own with Python","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":221,"Q_Id":3748720,"Users Score":7,"Answer":"Assuming you're already familiar with another programming language: \n\nTime to learn python basics: 1 week. \nTotal time to figure out email module: 2 days. \nTotal time to figure out httplib module: 1 days. \nTotal time to figure out creating database: 3 days.\nTotal time to learn about SQL: 2 weeks.\nTotal time to figure out that you probably don't need SQL: 1 week.\nTotal time writing the rest of the logic in python: 1 week.\n\nProbably...","Q_Score":1,"Tags":"python","A_Id":3748735,"CreationDate":"2010-09-20T04:31:00.000","Title":"Complete newbie excited about Python. How hard would this app be to build?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been wanting to get into Python for a while now and have accumulated quite a few links to tutorials, books, getting started guides and the like. I have done a little programming in PERL and PHP, but mostly just basic stuff.\nI'd like to be able to set expectations for myself, so based on the following requirements how long do you think it will take to get this app up and running?\nOnline Collection DB\n\nUsers can create accounts that are authenticated through token sent via e-mail\nOnce logged in, users can add items to pre-created collections (like \"DVD\" or \"Software\")\nEach collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc)\nUsers can list all items in collections (all DVDs, all Software), sort by various attributes\n\nAlso: Yes I know there are lots of online tools like this, but I want to build it on my own with Python","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":221,"Q_Id":3748720,"Users Score":0,"Answer":"Assuming that you don't write everything from the ground up and reuse basic components, this shouldn't be too hard. Probably the most difficult aspect will be authentication, because that requires domain specific knowledge and is hard to get right in any language. I would suggest starting with the basic functionality, even maybe learn how to get it up and running on App Engine, and then once you have the basic functionality, then you can deal with the business of authentication and users.","Q_Score":1,"Tags":"python","A_Id":3748731,"CreationDate":"2010-09-20T04:31:00.000","Title":"Complete newbie excited about Python. How hard would this app be to build?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote the sentence as follows:\nallLinkValues = ie.getLinksValue('class')\nbut the return values are all None, don't know why...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":3752154,"Users Score":0,"Answer":"should be 'className' in IE...","Q_Score":0,"Tags":"python","A_Id":3777996,"CreationDate":"2010-09-20T13:58:00.000","Title":"how to get the value of the 'class' attribute in a link?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have wxpython application that run over a list of files on some directory and proccess the files line by line\nI need to build a progress bar that show the status how records already done  with wx.gauge control\nI need to count the number of the records before i use the wx.guage in order to build the progress bar ,\nis this the way to do this and if yes what is the best method to count the number of lines of all the files on some directory with pyhon ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":222,"Q_Id":3758468,"Users Score":1,"Answer":"I think you could do 2 progress bars, one for files, and second for line in just read file. This will be similar to copy progress in TotalCommander.\nIf you want one progress bar you could just count file sizes using os.path.getsize(path) and then show how many bytes have you processed\/bytes total.","Q_Score":0,"Tags":"python,wxpython","A_Id":3758497,"CreationDate":"2010-09-21T08:20:00.000","Title":"counting records of files on directory with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am new to django and have gotten a bit stuck on trying to make the admin site work as I'd like it to.  I am wondering if for making the admin functionality I want it is better to make a custom admin app with a template inheriting from admin\/base_site.html, using the frontend login with a redirect when is_staff is true.  \nThe initial details that make me think this:\n\nI have a chain of foreignkeys and would like to display nested inlines on the parent admin page.  I have tried using easymode, but it's got its own issues and requirements that may cause headaches later i can do without. \nI would like to add a function allowing the admin to add an instance of a model, which triggers the creation of instances its related models and redirects etc.  This requires adding some callables at least, which I havent figured out yet how to really do with any success in the admin model, and at the moment seems easier to just quickly do this in the views.py of my own app rather than trying to toy with the admin views.  \n\nIn general, creating a custom admin app (using a is_staff=true redirect on the FrontEnd login) seems more flexible in the long run, and will result in a more designed and intuitive admin interface for the client - so I suppose my question is, what are the semi-pros doing?  (if you know how to hack the admin views and templates to your heart's content you are not a semi-pro :)   ) \nThanks for any advice you can offer, Im still getting my feet wet and this kind of advice could save me alot of time and headache.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4748,"Q_Id":3758509,"Users Score":9,"Answer":"Slow down.  Relax.  Follow the Django philosophy.\n\nYou have an \"app\".  It presents data.  Focus on presentation.\nYou have a default, built-in admin for your \"app\".  It updates data and it's already there.\nIf the admin app doesn't meet your needs update Forms and update Models to get close.  But don't strain yourself messing with admin.  Get as close as you can.  But relax about it.  \n\n[Also, \"more intuitive admin\" is sometimes not an accurate description of what you're trying to do.  It could be, but I've seen some \"more intuitive\" that actually wasn't.]\n\na more designed and intuitive admin interface for the client.\n\nIs this part of the app?  Does the app do more than simply present data?  \nIf the app is transactional -- add, change, delete -- crud rules -- that kind of thing,  then that's your app.  If you want a fancy UI, that's not admin any more.  There's no redirect.  That's your app.\nIt's  just coding.  Stop messing with admin and start writing your app.  \nHint: Use generic views as much as possible.\nOther than that, you're talking about your app, not hacking the admin stuff that already works.\n\nif you know how to hack the admin views and templates to your heart's content you are not a semi-pro\n\nWrong.  All the source is there.  You can read it, also.  That's what the pros do.  We read the source.  And we don't hack the admin app.\nIf you have complex transactions, you have a first-class, for-real, actual application.  Not default admin, but a part of your app that has forms.\nIf you have forms, then, well, you have forms.  This does not require hacking the admin app, it's just coding more of your app.","Q_Score":1,"Tags":"python,django,customization,admin","A_Id":3759347,"CreationDate":"2010-09-21T08:28:00.000","Title":"Customizing Django Admin Interface functionality","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been looking for how to do this and I've found places where the subject comes up, but none of the suggestions actually work for me, even though they seem to work out okay for the questioner (they don't even list what to import). I ran across self.setWindowFlags(Qt.FramelessWindowHint) but it doesn't seem to work regardless of the import I try (QtGui.FramelessWindowHint, QtCore.FramelessWindowHint, etc.).\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6028,"Q_Id":3758648,"Users Score":13,"Answer":"u need to import  QtCore\n\n\nso the code will look like this : \n self.setWindowFlags(QtCore.Qt.FramelessWindowHint) \nwhenever you see Qt.something put in mind that they are talking about the Qt class inside QtCore module .\nhope this helps","Q_Score":7,"Tags":"python,pyqt,pyside","A_Id":3761216,"CreationDate":"2010-09-21T08:48:00.000","Title":"Setting window style in PyQT\/PySide?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do a pie chart in matplotlib.\nThis pie chart will be a representation of two variables: male and female.\nThat's easy to do :)\nWhat I would like to do next, I'm not even sure if it's possible to do with matplotlib, I would like to make these two variables clickable so if I click on male, I would see another page with information about this, same thing with female.\nImage map isn't a solution since this variables may change in the future.\nAnyone has any idea how to do this? If it's possible with matplotlib or what program would you recommend.\nThank you!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1491,"Q_Id":3758658,"Users Score":1,"Answer":"You can do this with an imagemap or HTML element overlay controlled by JavaScript\/jQuery.\nEssentially, send your chart data to the page along with the chart image, and use JS to create the elements with the links according to the specification of the data.\nIt's a bit harder than the bar graphs I've done this to before, but should work fine.","Q_Score":3,"Tags":"javascript,jquery,python,matplotlib,hyperlink","A_Id":3759346,"CreationDate":"2010-09-21T08:49:00.000","Title":"how to create hyperlink in piechart","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue  is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that.\nCan someone please suggest how that can be done?\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":3759003,"Users Score":0,"Answer":"Two possible solutions:\n\nCheck if the reference still exists, before you access it:\nif not obj.reference:\n # Referenced entity was deleted\nWhen you delete a model object that may be referenced, query all models that might reference it, and set their reference property to None.","Q_Score":1,"Tags":"python,django,google-app-engine,django-models,google-cloud-datastore","A_Id":3808459,"CreationDate":"2010-09-21T09:37:00.000","Title":"Django Google app engine reference issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue  is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that.\nCan someone please suggest how that can be done?\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":249,"Q_Id":3759003,"Users Score":0,"Answer":"When I have the same problem ago, I could not find a general solution. The only way I found is to do try\/except for every reference property. If you find another answer post it here.","Q_Score":1,"Tags":"python,django,google-app-engine,django-models,google-cloud-datastore","A_Id":3759035,"CreationDate":"2010-09-21T09:37:00.000","Title":"Django Google app engine reference issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue  is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that.\nCan someone please suggest how that can be done?\nThanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":249,"Q_Id":3759003,"Users Score":1,"Answer":"You could also just set a flag, say deleted, on the entity you're deleting, and then leave it in the datastore. This has the advantage of avoiding all referential integrity problems in the first place, but it comes at the cost of two main disadvantages:\n\nAll your existing queries need to be changed to deal with entities that have the deleted property set, either by omitting them from the result set or by special casing them somehow.\n\"Deleted\" data stays in the datastore; this can bloat the datastore, and also may not be an option for sensitive information.\n\nThis doesn't really solve your problem at all, but I thought I'd mention it for completeness's sake.","Q_Score":1,"Tags":"python,django,google-app-engine,django-models,google-cloud-datastore","A_Id":3808505,"CreationDate":"2010-09-21T09:37:00.000","Title":"Django Google app engine reference issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"When I try to use cron to execute my python script in a future time, I found there is a command at, AFAIK, the cron is for periodically execute, but what my scenario is only execute for once in specified time.\nand my question is how to add python script to at command,\nalso it there some python package for control the at command\nMy dev os is ubuntu 10.04 lucid,and my product server is ubuntu-server 10.04 lucid version.\nin fact, I want through python script add python script tasks to at command, which file's change can effect at command add or remove new jobs","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2030,"Q_Id":3774772,"Users Score":2,"Answer":"type man at, it will explain how to use it. Usage will slighty differ from system to system, so there's no use to tell you here exactly.","Q_Score":2,"Tags":"python,cron,package,execute,at-job","A_Id":3774794,"CreationDate":"2010-09-23T01:21:00.000","Title":"How to use at command to set python script execute at specified time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use a module that requires sys._getframe(), which, as I understand it, is not enabled by default.  I've seen a lot of material that suggests that there is a way to enable _getframe(), but I've yet to find anything that tells me how to do so.  What is the proper method for enabling this function in IronPython 2.6.1?  Does one even exist?  Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":905,"Q_Id":3780379,"Users Score":0,"Answer":"Resolved.  Turns out that you need to rebuild IronPython from source, with the command line options \u2013X:Frames or \u2013X:FullFrames.","Q_Score":0,"Tags":"ironpython","A_Id":3780791,"CreationDate":"2010-09-23T16:14:00.000","Title":"How can I enable sys._getframe in IronPython 2.6.1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have python as an embedded scripting environment in my application. I supply the python bits (python26.dll, DLLs & Lib folders) with my application. All this to avoid asking users to install python (you know how it goes in big corporations).\nAll works nice except pywin32. It installs pythoncom26.dll and pywintypes26.dll to the system32 directory. I want to keep these dlls in my Python directory. One option is to add my Python directory to the PATH env variable. But would like to avoid it for obvious reasons (windows DLL search path priorities issues). \nIs there a way to tell Windows (a windows API is also fine) to look at my directories to load these pywin32 dlls? From what I understand these dlls get called by Windows COM.\nThanks. \nEdit1:\nNote that python is deployed embedded with my application.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":573,"Q_Id":3781873,"Users Score":0,"Answer":"I previously used py2exe to freeze the application and all the DLLs. Then use Innosetup to create an installer. Work like a charm.","Q_Score":2,"Tags":"python,pywin32,python-embedding","A_Id":3782055,"CreationDate":"2010-09-23T19:33:00.000","Title":"pywin32 captive installation (avoid py*.dll getting installed in system32 directory)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wanted to know how is it possible in django to bind an already uploaded file (stored in the file system of server) to a Model FileField. This way I want to have my edit page of that model to prepopulate the FileField with this file.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":669,"Q_Id":3785502,"Users Score":2,"Answer":"Well I found the answer. It was quite easy actually. you just need to set the FileField value to some string and it will point to that file.\nThe point is that the path specified should be correct otherwise you get a 404 error when trying to access it.","Q_Score":1,"Tags":"python,django","A_Id":3787861,"CreationDate":"2010-09-24T08:48:00.000","Title":"Prepopulating a Django FileField","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What are the best practices and solutions for managing dynamic subdomains in different technologies and frameworks? I am searching for something to implement in my Django project but those solutions that I saw, don't work. I also tried to use Apache rewrite mod to send requests from subdomain.domain.com to domain.com\/subdomain but couldn't realize how to do it with Django.\nUPDATE: What I need is to create virtual subdomains for my main domain using usernames from the site. So, if I have a new registered user that is called jack, when I go to jack.domain.com, it would operate make some operations. Like if I just went to domain.com\/users\/jack. But I don't want to create an actual subdomain for each user.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":347,"Q_Id":3793424,"Users Score":1,"Answer":"You may be able to do what you need with apache mod_rewrite.\nObviously I didn't read the question clearly enough.\nAs for how to do it in django: you could have some middleware that looks at the server name, and redirects according to that (or even sets a variable). You can't do it with the bare url routing system, as that only has path information, not hostname info.","Q_Score":2,"Tags":"python,django,subdomain","A_Id":3794000,"CreationDate":"2010-09-25T10:34:00.000","Title":"Managing subdomains","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Specifically I'm talking about Python. I'm trying to hack something (just a little) by seeing an object's value without ever passing it in, and I'm wondering if it is thread safe to use thread local to do that. Also, how do you even go about doing such a thing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":718,"Q_Id":3794868,"Users Score":8,"Answer":"No -- thread local means that each thread gets its own copy of that variable. Using it is (at least normally) thread-safe, simply because each thread uses its own variable, separate from  variables by the same name that's accessible to other threads. OTOH, they're not (normally) useful for communication between threads.","Q_Score":5,"Tags":"python,multithreading,thread-safety,thread-local","A_Id":3794914,"CreationDate":"2010-09-25T17:54:00.000","Title":"Does thread-local mean thread safe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do i run a python program that is received by a client from server without writing it into a new python file?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":387,"Q_Id":3798067,"Users Score":0,"Answer":"Dcolish's answer is good. I'm not sure the idea of executing code that comes in on a network interface is good in itself, though - you will need to take care to verify that you can trust the sending party, especially if this interface is going to be exposed to the Internet or really any production network.","Q_Score":0,"Tags":"python","A_Id":3805092,"CreationDate":"2010-09-26T13:49:00.000","Title":"network programming in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've heard of redis-cache but how exactly does it work? Is it used as a layer between django and my rdbms, by caching the rdbms queries somehow? \nOr is it supposed to be used directly as the database? Which I doubt, since that github page doesn't cover any login details, no setup.. just tells you to set some config property.","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":75541,"Q_Id":3801379,"Users Score":61,"Answer":"Just because Redis stores things in-memory does not mean that it is meant to be a cache. I have seen people using it as a persistent store for data.\nThat it can be used as a cache is a hint that it is useful as a high-performance storage. If your Redis system goes down though you might loose data that was not been written back onto the disk again. There are some ways to mitigate such dangers, e.g. a hot-standby replica.\nIf your data is 'mission-critical', like if you run a bank or a shop, Redis might not be the best pick for you. But if you write a high-traffic game with persistent live data or some social-interaction stuff and manage the probability of data-loss to be quite acceptable, then Redis might be worth a look.\nAnyway, the point remains, yes, Redis can be used as a database.","Q_Score":107,"Tags":"python,django,redis","A_Id":7722260,"CreationDate":"2010-09-27T05:48:00.000","Title":"How can I use redis with Django?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a project where I'm trying to control an embedded device through an Internet facing website. The idea is is that a user can go to a website and tell this device to preform some kind of action. An action on the website would be translated into a series of CLI commands and then sent to the device. Communication could potentially go both ways in the future, but right now I'm focusing on server-to-device.\nThe web server is a LAMP stack using Python (Django) and the device I'm trying to communicate with is a Beagle Board running eLinux. There would be only one device existing at any time communicating to the server.\nI have all the functional parts written on the server and device side, but I'm having a bit of trouble figuring out how to write the communication layer. One of my big issues is that the device will be mobile and will be moving locations every few days. So, I can't guarantee a static IP address for the device. My networking programming knowledge is pretty minimal so I don't have that great an idea on where to start.\nDoes anyone have any ideas\/resources on how I can start developing this kind of communication?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1776,"Q_Id":3808581,"Users Score":0,"Answer":"the device will be mobile and will be moving locations every few days. So, I can't guarantee a static IP address for the device. \n\nYour device can be a client of the web site.\nYour web site has two interfaces.\n\nHTML interface to people.\nA non-HTML interface to the device.  As a client of a web site, the device will need an HTTP client-side library to send a request to the web site.  This request will include the device's IP address, plus all the usual malarky buried in an HTTP request.  (There are a bunch of standard headers that are sent in a request)\n\nOnce the device has made it's initial request, then your web site can save the device's current status and communicate with it through another protocol if you want to do that.\n(I'm guessing that \"I have all the functional parts written on the server and device side\" means you have some other protocol for controlling the device, and this protocol isn't based on HTTP.)\nIt might be simplest in the long run to have the device poll the web site for commands or updates or things.  That way the device is a pure web client using only HTTP, and your web site is a pure web server, using only HTTP.  Then you don't need your more specialized second protocol.  Using only HTTP means you can use SSL to assure a secure communication.\nIf your device uses HTTP to get commands and updates, you'll need to work out a usable representation for data that can easily be encoded into HTTP requests and responses.  Choices include XML, JSON and YAML.  You can always invent your own data format; however, you'll probably be happier debugging a standardized format like JSON.\nBuilding these two interfaces in Django is pretty trivial.  You'll simply have some URL's which are for people and some which are for your device.  You'll have view functions for people that return HTML pages, and view functions for your device that return JSON or XML messages.","Q_Score":5,"Tags":"python,apache,embedded,beagleboard","A_Id":3811703,"CreationDate":"2010-09-27T23:17:00.000","Title":"Creating a website to communicate with an embedded device","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":0.0315684544,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":3,"Answer":"You can install multiple versions of Python one machine, and during setup, you can choose to have one of them associate itself with Python file extensions. If you install modules, there will be different setup packages for different versions, or you can choose which version you want to target. Since they generally install themselves into the site-packages directory of the interpreter version, there shouldn't be any conflicts (but I haven't tested this). To choose which version of python, you would have to manually specify the path to the interpreter if it is not the default one. As far as I know, they would share the same PATH and PYTHONPATH variables, which may be a problem.\nNote: I run Windows XP. I have no idea if any of this changes for other versions, but I don't see any reason that it would.","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":3809331,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":81,"Answer":"What I did was download both 2.7.6 and 3.3.4. Python 3.3.4 has the option to add the path to it in the environment variable so that was done. So basically I just manually added Python 2.7.6.\nHow to...\n\nStart > in the search type in environment select \"Edit environment variables to your account\"1\nScroll down to Path, select path, click edit.\nAdd C:\\Python27;\nso you should have paths to both versions of Python there, but if you don't this you can easily edit it so that you do..... C:\\Python27;C:\\Python33;\nNavigate to the Python27 folder in C:\\ and rename a copy of python.exe to python2.exe\nNavigate to the Python34 folder in C:\\ and rename a copy of python.exe to python3.exe\nTest: open up commmand prompt and type python2 ....BOOM! Python 2.7.6. exit out.\nTest: open up commmand prompt and type python3 ....BOOM! Python 3.4.3. exit out.\n\nNote: (so as not to break pip commands in step 4 and 5, keep copy of python.exe in the same directory as the renamed file)","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":22626734,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":1.0,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":13,"Answer":"To install and run any version of Python in the same system follow my guide below. \n\nFor example say you want to install Python 2.x and Python 3.x on the same Windows system. \n\nInstall both of their binary releases anywhere you want. \n\nWhen prompted do not register their file extensions and \ndo not add them automatically to the PATH environment variable \n\nRunning simply the command python the executable that is first met in PATH will be chosen for launch. In other words, add the Python directories manually. The one you add first will be selected when you type python. Consecutive python programs (increasing order that their directories are placed in PATH) will be chosen like so: \n\npy -2 for the second python \npy -3 for the third python etc.. \n\nNo matter the order of \"pythons\" you can: \n\nrun Python 2.x scripts using the command: py -2 (Python 3.x functionality) (ie. the first Python 2.x installation program found in your PATH will be selected) \nrun Python 3.x scripts using the command: or py -3 (ie. the first Python 3.x installation program found in your PATH will be selected) \n\n\n\nIn my example I have Python 2.7.14 installed first and Python 3.5.3. This is how my PATH variable starts with: \nPATH=C:\\Program Files\\Microsoft MPI\\Bin\\;C:\\Python27;C:\\Program Files\\Python_3.6\\Scripts\\;C:\\Program Files\\Python_3.6\\;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Common Files\\Intel\\Shared\n... \nNote that Python 2.7 is first and Python 3.5 second. \n\nSo running python command will launch python 2.7 (if Python 3.5 the same command would launch Python 3.5). \nRunning py -2 launches Python 2.7 (because it happens that the second Python is Python 3.5 which is incompatible with py -2). \nRunning py -3 launches Python 3.5 (because it's Python 3.x)  \nIf you had another python later in your path you would launch like so: py -4. This may change if\/when Python version 4 is released. \n\nNow py -4 or py -5 etc. on my system outputs: Requested Python version (4) not installed or Requested Python version (5) not installed etc. \nHopefully this is clear enough.","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":48239658,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":0,"Answer":"I use a simple solution to switch from a version to another version of python, you can install all version you want. All you have to do is creating some variable environment.\nIn my case, I have installed python 2.7 and python 3.8.1, so I have created this environment variables:\n\nPYTHON_HOME_2.7=<path_python_2.7>\nPYTHON_HOME_3.8.1=<path_python_3.8.1>\nPYTHON_HOME=%PYTHON_HOME_2.7%\n\nthen in my PATH environment variable I put only %PYTHON_HOME% and %PYTHON_HOME%\\Scripts. In the example above I'm using the version 2.7, when I want to switch to the other version I have only to set the PYTHON_HOME=%PYTHON_HOME_3.8.1%.\nI use this method to switch quickly from a version to another also for JAVA, MAVEN, GRADLE,ANT, and so on.","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":64577951,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":-0.010525927,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":-1,"Answer":"I have installed both python 2.7.13 and python 3.6.1 on windows 10pro and I was getting the same \"Fatal error\" when I tried pip2 or pip3. \nWhat I did to correct this was to go to the location of python.exe for python 2 and python 3 files and create a copy of each, I then renamed each copy to python2.exe and python3.exe depending on the python version in the installation folder. I therefore had in each python installation folder both a python.exe file and a python2.exe or python3.exe depending on the python version. \nThis resolved my problem when I typed either pip2 or pip3.","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":43160074,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":0.010525927,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":1,"Answer":"Check your system environment variables after installing Python, python 3's directories should be first in your PATH variable, then python 2.\nWhichever path variable matches first is the one Windows uses.\nAs always py -2 will launch python2 in this scenario.","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":33527329,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":-0.010525927,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":-1,"Answer":"Only Works if your running your code in your Python IDE\nI have both Python 2.7 and Python 3.3 installed on my windows operating system. If I try to launch a file, it will usually open up on the python 2.7 IDE. How I solved this issue, was when I choose to run my code on python 3.3, I open up python 3.3 IDLE(Python GUI), select file, open my file with the IDLE and save it. Then when I run my code, it runs to the IDLE that I currently opened it with. It works vice versa with 2.7.","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":21692110,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x.\nCan I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I \"choose\" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail.\nThanks.","AnswerCount":19,"Available Count":8,"Score":0.0,"is_accepted":false,"ViewCount":242246,"Q_Id":3809314,"Users Score":0,"Answer":"Install the one you use most (3.3 in my case) over the top of the other. That'll force IDLE to use the one you want.\nAlternatively (from the python3.3 README):\nInstalling multiple versions\nOn Unix and Mac systems if you intend to install multiple versions of Python\nusing the same installation prefix (--prefix argument to the configure script)\nyou must take care that your primary python executable is not overwritten by the\ninstallation of a different version.  All files and directories installed using\n\"make altinstall\" contain the major and minor version and can thus live\nside-by-side.  \"make install\" also creates ${prefix}\/bin\/python3 which refers to\n${prefix}\/bin\/pythonX.Y.  If you intend to install multiple versions using the\nsame prefix you must decide which version (if any) is your \"primary\" version.\nInstall that version using \"make install\".  Install all other versions using\n\"make altinstall\".\nFor example, if you want to install Python 2.6, 2.7 and 3.3 with 2.7 being the\nprimary version, you would execute \"make install\" in your 2.7 build directory\nand \"make altinstall\" in the others.","Q_Score":234,"Tags":"python,windows,compatibility,backwards-compatibility,build-environment","A_Id":17660471,"CreationDate":"2010-09-28T02:40:00.000","Title":"How to install both Python 2.x and Python 3.x in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I m using shutil.copy from python to copy a list of files. But when i copy the files to \/usr\/lib\/ location, i m getting permission denied as i need to be an administrator to do that.\nSo How could i copy files with admin permission or \nhow could i get the admin password from the user to copy the files?\nIdeas would be appreciated","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":7772,"Q_Id":3811197,"Users Score":1,"Answer":"Start your program with a user that is allowed to write there. For example login to root first (su) or run the script with sudo myscript.py.","Q_Score":6,"Tags":"python,file-permissions","A_Id":3811219,"CreationDate":"2010-09-28T09:04:00.000","Title":"Getting admin password while copy file using shutil.copy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to set the namespace prefix in xml.etree. I found register_namespace(prefix, url) on the Web but this threw \"unknown attribute\". I have also tried nsmap=NSMAP but this also fails. I'd be grateful for example syntax that shows how to add specified namespace prefixes","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1128,"Q_Id":3814365,"Users Score":1,"Answer":"register_namespace was only introduced in lxml 2.3 (still beta)\nI believe you can provide an nsmap parameter (dictionary with prefix-uri mappings) when creating an element, but I don't think you can change it for an existing element. (there is an .nsmap property on the element, but changing that doesn't seem to work. There is also a .prefix property on the element, but that's read-only)","Q_Score":3,"Tags":"python,xml.etree","A_Id":3814788,"CreationDate":"2010-09-28T15:28:00.000","Title":"how to set namespace prefixes in xml.etree","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to import some data to show it for user but page execution time exceeds 30 second limit. So I decided to split my big code into several tasks and try Task Queues. I add about 10-20 tasks to queue and app engine executes tasks in parallel while user is waiting for data. How can I determine that my tasks are completed to show user data ASAP? Can I somehow iterate over active tasks?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":3821636,"Users Score":2,"Answer":"I've solved this in the past by keeping the status for the tasks in memcached, and polling (via Ajax) to determine when the tasks are finished.  \nIf you go this way, it's best if you can always \"manually\" determine the status of the tasks without looking in memcached, since there's always the (slim) chance that memcache will go down or will get cleared or something as a task is running.","Q_Score":1,"Tags":"python,google-app-engine","A_Id":3823052,"CreationDate":"2010-09-29T12:41:00.000","Title":"Python App Engine: Task Queues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a Django admin filter that will get random groups of users. At this point, I have two problems:\n\nApplying a custom filter to the User model, and\nDisplaying a random set of users.\n\nOn #1, I've tried using User.username.random_filter = True, but it comes back with an AttributeError saying that User has no attribute username.\nOn #2, I know I can get 50 random users with User.objects.order_by('?')[:50], but I have not been able to figure out how to get the result of such a query to show up in the admin listing. As far as I can tell, the listing is generated by the URL's GET request, but I've not had any luck ordering with it.\nAny suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":235,"Q_Id":3822857,"Users Score":1,"Answer":"If I were you (and I am), I would stop trying to integrate this functionality with the Django admin site. Speaking from experience, you'll find that what you're trying to do is much easier to implement as regular views. Sure, it isn't be as pretty, but something that works beats something that's pretty but doesn't work, right?","Q_Score":0,"Tags":"python,django-admin,customization","A_Id":3831573,"CreationDate":"2010-09-29T14:55:00.000","Title":"Django randomly order users in admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The situation is that I have a small datacenter, with each server running python instances. It's not your usual distributed worker setup, as each server has a specific role with an appropriate long-running process.\nI'm looking for good ways to implement the the cross-server communication. REST seems like overkill. XML-RPC seems nice, but I haven't played with it yet. What other libraries should I be looking at to get this done?\nRequirements:\nComputation servers crunch numbers in the background. Other servers would like to occasionally ask them for values, based upon their calculation sets. I know this seems pretty well aligned with a REST mentality, but I'm curious about other options.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":196,"Q_Id":3823420,"Users Score":1,"Answer":"It wasn't obvious from your question but if getting answers back synchronously doesn't matter to you (i.e., you are just asking for work to be performed) you might want to consider just using a job queue. It's generally the easiest way to communicate between hosts. If you don't mind depending on AWS using SQS is super simple. If you can't depend on AWS then you might want to try something like RabbitMQ. Many times problems that we think need to be communicated synchronously are really just queues in disguise.","Q_Score":0,"Tags":"python,network-protocols","A_Id":3824612,"CreationDate":"2010-09-29T15:57:00.000","Title":"What are good specs\/libraries for closed network communication in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project where I have been logging to a file using the standard library logging module.  For a variety of reasons I would like to change it so that it writes to the Apache log files.  I've seen quite a bit of discussion of how to do this with mod_python, but not mod_wsgi.  How do I do this for a project running under mod_wsgi?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3241,"Q_Id":3824923,"Users Score":13,"Answer":"Mostly, we use logging and write to sys.stderr.  That seems to write to the Apache error_log.","Q_Score":12,"Tags":"python,apache,logging,mod-wsgi","A_Id":3825257,"CreationDate":"2010-09-29T18:59:00.000","Title":"How do I write to the apache log files when using mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to write a web-based code generator for a Python crawler. Its aim is to automatically generate code so a developer doesn't need to write it, but I've run into this problem: in one of my project's webpages, there are some checkboxes, buttons, etc. Each of them generates some Python code and writes it to a common textarea. However, when I uncheck boxes I can't figure out how to remove the corresponding code from the textarea, because it's all been mixed together. For example:\n\nCheck box 1 -- it writes code snippet 1 to the textarea\nCheck box 2 -- it writes code snippet 2 to the textarea\nCheck box 3 -- it writes code snippet 3 to the textarea\nUncheck box 2 -- it needs to somehow remove code snippet 2 from the text area, but leave behind code snippets 1 and 3\n\nIs there some way to fix this problem, or any better solution for the whole code generator project?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":3829405,"Users Score":0,"Answer":"You need to separate out the idea of what code to generate from the events triggering generation.\nWhat code is generated is governed by the combined set of all the checkboxes that are checked.\nTriggering code generation occurs each time any of them are changed. You need to regenerate everything at that time.\nIn detail:\n\nCheck box 1 -- triggers generation, just code for snippet 1 included\nCheck box 2 -- triggers generation, code for snippets 1 & 2 included\nCheck box 3 -- triggers generation, code for snippets 1, 2 & 3 included\nUncheck box 2 -- triggers generation, code for snippets 1 & 3 included","Q_Score":1,"Tags":"python,code-generation,web-crawler,robot","A_Id":3829743,"CreationDate":"2010-09-30T09:40:00.000","Title":"Problem with web code generator designer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script that runs continuously when invoked and every 5 minutes checks my gmail inbox. To get it to run every 5 minutes I am using the time.sleep() function. However I would like user to end the script anytime my pressing q, which it seems cant be done when using time.sleep(). Any suggestions on how i can do this?\nAli","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5470,"Q_Id":3836620,"Users Score":0,"Answer":"If you really wanted to (and wanted to waste a lot of resources), you could cut your loop into 200 ms chunks. So sleep 200 ms, check input, repeat until five minutes elapse, and then check your inbox. I wouldn't recommend it, though.\nWhile it's sleeping, though, the process is blocked and won't receive input until the sleep ends.\nOh, as an added note, if you hit the key while it's sleeping, it should still go into the buffer, so it'll get pulled out when the sleep ends and input is finally read, IIRC.","Q_Score":4,"Tags":"python,continuous","A_Id":3836650,"CreationDate":"2010-10-01T04:51:00.000","Title":"Continous loop and exiting in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Different languages have different GUI toolkits, but it looks very difficult to achieve attractive user interfaces as good as we can using HTML and CSS with less effort. \nI don't do my application in javascript as I doubt if it has all the required libraries and I want to do it in python.\nHow do I use rendering engines like gecko, webkit etc in python? Which one will be more suited to work with python?.Is there any 'only html\/css' rendering engine without javascript? \nWill it be easy to write event handlers for DOM events and manipulate DOM in python?","AnswerCount":10,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4636,"Q_Id":3839216,"Users Score":0,"Answer":"update: This is an old answer, nowadays you want to go with an embedded browser in your app (*webkit projects etc.), but at the time of writing, no such technology existed. The answer is still valid if you don't want to add quite a few megabytes to your packaged app though.\n\nFind a lightweight server, or better - embed one in Your application. That's it.\nJava has classes for serving http. Python does it well also.\nSee how mercurial's hg serve works. [python]\nI once did a tiny app that served aspell spellcheck via http on localhost in java with the httprequest class. [worked on win and linux]\nCreate Your application as a server that outputs some html and uses POST to do actions. Do the interface thing in HTML+CSS+JS. Nice and easy.\nAfter running point the user to localhost:somesillyport or trigger opening localhost:somesillyport in a browser.","Q_Score":11,"Tags":"javascript,python,html,css,user-interface","A_Id":3839449,"CreationDate":"2010-10-01T12:41:00.000","Title":"how to write a desktop application which uses HTML and CSS for user interface and python\/perl\/c++\/java for the processing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just want to know how I can call certian classes in design pattern here, like which type are they classified in OO design\n(1) I use a class that has just named constants , this class is used directly other classes to get values of constants in it.I dont instantiate the class.\n(2) I use a class with full of static methods, this class is basically used by other classes as a holder of methods that are used by them. So again i dont instantiate the class. \nWhat are these kinda classes classified under OOdesign?\nCan I do it in a more elegant way?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":705,"Q_Id":3844158,"Users Score":8,"Answer":"What are these kinda classes classified under OOdesign? Can I do it in a more elegant way?\n\nYou do have better alternatives, IMHO.\n\nI use a class that has just named constants , this class is used directly other classes to get values of constants in it.I dont instantiate the class.\n\nFor e.g. in this case you don't necessarily need a class. You can have a settings module that defines the various \"constants\". I put constants in quotes because there are no constants in Python the way there are in say, Java. \n\n(2) I use a class with full of static methods, this class is basically used by other classes as a holder of methods that are used by them. So again i dont instantiate the class.\n\nAgain, no need for a class. You can have one or more modules that contain these methods or rather, functions. They can be logically grouped as you see fit.\nI'd like to add a note that you don't have to stick to (Java style?) \"classes only\" approach (for lack of a better phrase). Rather try to write code that doesn't go against the grain of the language. In Python's case I'd argue that such classes as you described above are best avoided. They seem to me like a carry over from Java.","Q_Score":2,"Tags":"python,oop","A_Id":3844175,"CreationDate":"2010-10-02T02:49:00.000","Title":"Static or constant or what are they?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For great help from stackoverflow, the development for the Mac version of my program is done. \nNow I need to deploy my program, and I was wondering if there is any way to \"hide\" my running Python code (it also runs .so library and it seems it makes a dock item to appear).\nThe program is supposed to be running in the background and it would be great if I can hide any terminal or dock items. In Windows or linux, it was easy, but I am still not that used to Mac and could not figure out how to do this.\nThank you,\nJoon","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1064,"Q_Id":3853038,"Users Score":0,"Answer":"have you tried using the nohup? lets say you have a launch script to start your program:\nlaunch.sh:\nnohup your_program & \nexit","Q_Score":2,"Tags":"python,macos,command-line","A_Id":3853095,"CreationDate":"2010-10-04T05:22:00.000","Title":"Run a python script and a compiled c code without terminal or dock item in Mac OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"While I'm familiar with making .net assemblies with the PythonModule assembly attribute, I'm a little curious as to how you could make submodules.  Would this be a class within a class?  i.e: if I have a class defined as an IronPython module such as:\n[assembly: PythonModule(mymodule),typeof(namespace.mymodule)]\nHow could I define a submodule within mymodule, so that from python I could do:\nimport mymodule.submodule\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":3867377,"Users Score":3,"Answer":"It's interesting, there's actually no support for this at all right now.  For the most part this has been used to implement built-in modules that exist in CPython and there's simply been no need for submodules yet.  You could have a nested static class in the class used for the module but it wouldn't import as a module - it'd show up as a type object in Python.","Q_Score":2,"Tags":"ironpython","A_Id":3869625,"CreationDate":"2010-10-05T20:17:00.000","Title":"submodules in ironpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"HI, guys. I am developing a GUI to configure and call several external programs with Python and I use wxPython for the GUI toolkits. Basically, instead of typing commands and parameters in each shell for each application (one application via one shell), the GUI is visualizing these parameters and call them as subprocesses. I have built the data model and the relevant view\/gui controls (mainly by using the observer pattern or try to separate model with the gui widgets), and it is OK. \nNow there is a request from my colleagues and many other people (even including myself), is it possible to have a command line interface for the subprocesses, or even for the whole configuration GUI, based on the data model I already have? This is due to the fact that many people prefer CLI, CLI is better in reliability, and also needs of programmer debugging and interfacing. \nAs I am rather new to developing a CLI, I really need some help from you. I appreciate any advice and information from you. \nto be more specific, \n\nIf I completely forget about the data model built for GUI, start from scratch. Is there some good materials or samples to have a reference?\nIf I still want to utilize the data model built for GUI, is it possible? If possible, what shall I do and any samples to follow? Do I need to refactor the data model?\nIs it possible to have the CLI and GUI at the same time? I mean, can I take the CLI as another view of the data model? Or there is other right approach? \n\nThank you very much for your help!!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":440,"Q_Id":3867500,"Users Score":1,"Answer":"If you can call your data model's methods from your GUI and they don't depend on anything in the GUI, then yes, you should be able to call those same methods from another GUI, be it CLI, pyGTK or whatever.","Q_Score":0,"Tags":"python,user-interface,wxpython,wxwidgets,command-line-interface","A_Id":3867843,"CreationDate":"2010-10-05T20:34:00.000","Title":"how to make a Command Line Interface from a given data model used for GUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Since it's possible using the IsNumeric() and others VB.NET functions from IronPython by importing Microsoft.VisualBasic and using it as an object method, is it possible somehow to use the Year() VB.NET function from IronPython?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":3873212,"Users Score":1,"Answer":"The full name for the method is Microsoft.VisualBasic.DateAndTime.Year(DateTime).  This is a compat function.  Since you need to pass a DateTime argument anyway, you might as well use its Year property.\nAlbeit that the VB version can be different because it uses the current culture calendar's GetYear() method.  In other words, in Israel your program might get the year since the destruction of the temple in Jerusalem (I think).  Not sure if that should be intentional in your case.","Q_Score":0,"Tags":".net,vb.net,ironpython","A_Id":3873713,"CreationDate":"2010-10-06T13:56:00.000","Title":"using the VB.NET Year function from IronPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating Python software that compresses files\/folders... How would I create a section of the code that asks for the user input of the folder location and then compresses it. I currently have the code for a single file but not a folder full of files. Please explain in detail how to do this.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24451,"Q_Id":3874837,"Users Score":0,"Answer":"As larsmans says, gzip compression is not used for directories, only single files. The usual way of doing things with linux is to put the directory in a tarball first and then compress it.","Q_Score":12,"Tags":"python,compression,gzip,tar","A_Id":3874884,"CreationDate":"2010-10-06T16:37:00.000","Title":"How do I compress a folder with the Python GZip module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In order to make the registration process on my website easy, I allow users to enter their email address which I will send a verification code to or alternatively they can solve a captcha.\nThe problem is that in order to prevent robots from registering accounts (with fake emails) I limit the number of registrations allowed per IP address and if this limit is exceeded I trigger a warning in the logs.\nHowever ... what seems to be happening is that I am using os.environ['REMOTE_ADDR'] to check the remote address -- but it seems that I am triggering warnings on addresses that are owned by Google (66.249.65.XXX). It is possible that this is happening only after I change the version (but not confirmed). Does anyone know how\/why this might be happening? Shouldn't the REMOTE_ADDR return the address of the client computer (and hopefully in all cases it would do this)?\nI am curious if there is some behind the scenes re-directions going on, and if this is a normal event or if it only happens when a new version is installed (perhaps when a new version is installed the original server then proxies the user to the new server, therefore creating the illusion that the IP address is an internal IP?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":438,"Q_Id":3877631,"Users Score":0,"Answer":"I believe that I have figured out the reason for seeing so many warnings from google server IP addresses. It seems that immediately after a new user registers, the google crawlers are going to the same (registration) webpage (which I send information to as a GET instead of a POST for reasons which I will not get into). Of course, since many users are registering, but there are only a few crawler computers that are checking periodic updates to my website, I am triggering warning messages that a particular (google) IP is accessing a registration area repeatedly.","Q_Score":0,"Tags":"python,google-app-engine,ip-address","A_Id":3877766,"CreationDate":"2010-10-06T23:28:00.000","Title":"Google App Engine (Python)- Strange behaviour of REMOTE_ADDR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am running my code on multiple VPSes (with more than one IP, which are set up as aliases to the network interfaces) and I am trying to figure out a way such that my code acquires the IP addresses from the network interfaces on the fly and bind to it. Any ideas on how to do it in python without adding a 3rd party library ?\nEdit I know about socket.gethostbyaddr(socket.gethostname()) and about the 3rd party package netifaces, but I am looking for something more elegant from the standard library ... and parsing the output of the ifconfig command is not something elegant :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":3881951,"Users Score":0,"Answer":"The IP addresses are assigned to your VPSes, no possibility to change them on the fly.\nYou have to open a SSH tunnel to or install a proxy on your VPSes.\nI think a SSH tunnel would be the best way how to do it, and then use it as SOCKS5 proxy from Python.","Q_Score":1,"Tags":"python","A_Id":3882193,"CreationDate":"2010-10-07T13:10:00.000","Title":"figuring out how to get all of the public ips of a machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could someone tell me how I can run Django on two ports simultaneously? The default Django configuration only listens on port 8000. I'd like to run another instance on port xxxx as well. I'd like to redirect all requests to this second port to a particular app in my Django application. \nI need to accomplish this with the default Django installation and not by using a webserver like nginx, Apache, etc.\nThank you\n\nLet's say I two applications in my Django application. Now i don't mean two separate Django applications but the separate folders inside the 'app' directory. Let's call this app1 and app2\nI want all requests on port 8000 to go to app1 and all requests on port XXXX to go to app2\nHTH.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":14240,"Q_Id":3883497,"Users Score":18,"Answer":"Just run two instances of .\/manage.py runserver. You can set a port by simply specifying it directly: .\/manage.py runserver 8002 to listen on port 8002.\nEdit I don't really understand why you want to do this. If you want two servers serving different parts of your site, then you have in effect two sites, which will need two separate settings.py and urls.py files. You'd then run one instance of runserver with each, passing the settings flag appropriately: .\/manage.py runserver 8002 --settings=app1.settings","Q_Score":8,"Tags":"python,django","A_Id":3883556,"CreationDate":"2010-10-07T15:57:00.000","Title":"Run Django on multiple ports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could someone tell me how I can run Django on two ports simultaneously? The default Django configuration only listens on port 8000. I'd like to run another instance on port xxxx as well. I'd like to redirect all requests to this second port to a particular app in my Django application. \nI need to accomplish this with the default Django installation and not by using a webserver like nginx, Apache, etc.\nThank you\n\nLet's say I two applications in my Django application. Now i don't mean two separate Django applications but the separate folders inside the 'app' directory. Let's call this app1 and app2\nI want all requests on port 8000 to go to app1 and all requests on port XXXX to go to app2\nHTH.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":14240,"Q_Id":3883497,"Users Score":2,"Answer":"The built-in web-server is intended for development only, so you should really be using apache or similar in an situation where you need to run on multiple ports.\nOn the other hand you should be able to start up multiple servers just by starting multiple instances of runserver. As long as you are using a separate database server I don't think that will have any extra problems.","Q_Score":8,"Tags":"python,django","A_Id":3883557,"CreationDate":"2010-10-07T15:57:00.000","Title":"Run Django on multiple ports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I work in the django IPython-shell, which can be started with manage.py shell.\nWhen i load an extern function in the shell for testing, everything is alright. But when i make changes to the function, the shell still has the old version of the function. Even if i make a new import.\nDoes anyone know how to reload the actual version of the function?\nThanks in regards!\nEdit: I use windows - if that makes a difference.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8233,"Q_Id":3883619,"Users Score":0,"Answer":"The easiest solution I've found is combination of shell_plus and iPython which automatically reloads functions.\n\npip install ipython\npip install django-extensions\nadd 'django_extensions' to your INSTALLED_APPS\npython manage.py shell_plus","Q_Score":6,"Tags":"python,django,shell,ipython","A_Id":34309424,"CreationDate":"2010-10-07T16:12:00.000","Title":"django, python: reload function in shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I open a Python interpreter at a specific network path in Windows?\nIn the Explorer address bar the path is in UNC form: \\\\myhost\\myshare\\....\nI can't work out how to change to this directory from the Windows command line, nor in what format I could pass it as an argument to os.chdir.\nI'm running Python 2.5 on Windows XP. IDLE is installed.\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2258,"Q_Id":3884881,"Users Score":0,"Answer":"You need to map it as a drive.","Q_Score":2,"Tags":"python,windows-xp","A_Id":3884931,"CreationDate":"2010-10-07T18:53:00.000","Title":"How can I open a Python shell at a network path in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"On my linux machine, 1 of 3 network interfaces may be actually connected to the internet. I need to get the IP address of the currently connected interface, keeping in mind that my other 2 interfaces may be assigned IP addresses, just not be connected.\nI can just ping a website through each of my interfaces to determine which one has connectivity, but I'd like to get this faster than waiting for a ping time out. And I'd like to not have to rely on an external website being up.\nUpdate:\nAll my interfaces may have ip addresses and gateways. This is for an embedded device. So we allow the user to choose between say eth0 and eth1. But if there's no connection on the interface that the user tells us to use, we fall back to say eth2 which (in theory) will always work.\nSo what I need to do is first check if the user's selection is connected and if so return that IP. Otherwise I need to get the ip of eth2. I can get the IPs of the interfaces just fine, it's just determining which one is actually connected.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2443,"Q_Id":3885160,"Users Score":0,"Answer":"If the default gateway for the system is reliable, then grab that from the output from route -n the line that contains \" UG \" (note the spaces) will also contain the IP of the gateway and interface name of the active interface.","Q_Score":1,"Tags":"python,linux,networking,ip-address","A_Id":3885255,"CreationDate":"2010-10-07T19:24:00.000","Title":"Determine IP address of CONNECTED interface (linux) in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I get the numbers after a decimal point?\nFor example, if I have 5.55, how do i get .55?","AnswerCount":36,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":285621,"Q_Id":3886402,"Users Score":7,"Answer":"To make it work with both positive and negative numbers:\ntry  abs(x)%1. For negative numbers, without with abs, it will go wrong.\n5.55 % 1\noutput 0.5499999999999998\n-5.55 % 1\noutput 0.4500000000000002","Q_Score":164,"Tags":"python,floating-point,decimal","A_Id":66605212,"CreationDate":"2010-10-07T22:38:00.000","Title":"How to get numbers after decimal point?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a programs that runs several threads (on a while loop until \nCtrl  C  is pressed). The app also has a GUI that I developed in PyQt. However, I am facing the following problem:\nIf I press Ctrl C on the console, and then close the GUI, the program exits fine. However, if I close the GUI first, the other threads won't stop and the program keeps running after Ctrl C. Anyone knows how I could address this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":722,"Q_Id":3886500,"Users Score":0,"Answer":"In Qt you would overload the OnClose method for the widget\/frame or hook the lastwindowsdclosed signal to do whatever you need to shut down the app - don't know if it's diiferent from python","Q_Score":0,"Tags":"python,multithreading,pyqt,copy-paste","A_Id":3886510,"CreationDate":"2010-10-07T22:56:00.000","Title":"PyQT4 and Ctrl C","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wonder how is generated the grammar of the Python language and how it is understood by the interpreter.\nIn python, the file graminit.c seems to implement the grammar, but i don't clearly understand it.\nMore broadly, what are the different ways to generate a grammar and are there differences between how the grammar is implemented in languages such as Perl, Python or Lua.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":841,"Q_Id":3890321,"Users Score":8,"Answer":"Grammars are generally of the same form: Backus-Naur Form (BNF) is typical.\nLexer\/parsers can take very different forms.  \nThe lexer breaks up the input file into tokens.  The parser uses the grammar to see if the stream of tokens is \"valid\" according to its rules.\nUsually the outcome is an abstract syntax tree (AST) that can then be used to generate whatever you want, such as byte code or assembly.","Q_Score":4,"Tags":"python,grammar","A_Id":3890344,"CreationDate":"2010-10-08T12:11:00.000","Title":"How is generated the python grammar and how the interpreter understand it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"OK so im using websockets to let javascript talk to python and that works very well BUT the data i need to send often has several parts like an array, (username,time,text) but how could i send it ? I originally though to encode each one in base64 or urlencode then use a character like | which those encoding methods will never use and then split the information. Unfortunately i cant find a method which both python and javascript can both do.\nSo the question, is there a encoding method which bath can do OR is there a different better way i can send the data because i havent really done anything like this before. (I have but AJAX requests and i send that data URL encoded). Also im not sending miles of text, about 100bytes at a time if that.\nthankyou !\nedit\nMost comments point to JSON,so, Whats the best convert to use for javascript because javascript stupidly cant convert string to JSON,or the other way round.\nFinished\nWell jaascript does have a native way to convert javascript to string, its just hidden form the world. JSON.stringify(obj, [replacer], [space]) to convert it to a string and JSON.parse(string, [reviver]) to convert it back","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1908,"Q_Id":3890390,"Users Score":7,"Answer":"JSON is definitely the way to go. It has a very small overhead and is capable of storing almost any kind of data. I am not a python expert, but i am sure that there is some kind of en\/decoder available.","Q_Score":1,"Tags":"javascript,python,sockets,encoding","A_Id":3890407,"CreationDate":"2010-10-08T12:22:00.000","Title":"Python to javascript communication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I have a CGI script (pwyky) that I called index.cgi, put in directory wiki\/, and setup Apache to call localhost\/wiki\/index.cgi when I access localhost\/wiki.\nI'm getting errors when I'm trying to use this application -- it creates a page with links like \"http:\/\/localhost\/wiki\/@edit\/index\", but when I click that link, Apace is trying to serve \"wiki\/@edit\/index\" as a file. I suspect that I need to get Apache to pass \/@edit\/index into index.cgi.\nIn particular, looking through index.cgi, its looking for strings like \"@edit\" in REQUEST_URI environment variable.\nAny idea how to fix this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":762,"Q_Id":3897140,"Users Score":0,"Answer":"You'd need to show your apache configuration to say for certain, but it seems that Apache isn't actually using mod_cgi to serve the index.cgi script. In your configuration there should be something like 'LoadModule mod_cgi'. It should be uncommented (i.e., it shouldn't have a '#' at the beginning of the line). \nIf you want to test this, then write a 'Hello World' cgi script and put it (temporarily) in place of index.cgi and see if you can get that to run. Let us know the results.","Q_Score":0,"Tags":"python,apache","A_Id":3898807,"CreationDate":"2010-10-09T17:31:00.000","Title":"URL rewriting question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a CGI script (pwyky) that I called index.cgi, put in directory wiki\/, and setup Apache to call localhost\/wiki\/index.cgi when I access localhost\/wiki.\nI'm getting errors when I'm trying to use this application -- it creates a page with links like \"http:\/\/localhost\/wiki\/@edit\/index\", but when I click that link, Apace is trying to serve \"wiki\/@edit\/index\" as a file. I suspect that I need to get Apache to pass \/@edit\/index into index.cgi.\nIn particular, looking through index.cgi, its looking for strings like \"@edit\" in REQUEST_URI environment variable.\nAny idea how to fix this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":762,"Q_Id":3897140,"Users Score":0,"Answer":"I found the problem, it turned out this is done through RewriteEngine. Pwyky puts .htaccess file in the directory with all the settings for RewriteEngine, but because AllowOverride is \"None\" by default on MacOS, they were ignored. The solution was to change all \"AllowOverride\" directives to \"All\"","Q_Score":0,"Tags":"python,apache","A_Id":3908016,"CreationDate":"2010-10-09T17:31:00.000","Title":"URL rewriting question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm writing a small app which has 2 separate frames.\nThe first frame is like a video player controller. It has Play\/Stop\/Pause buttons etc. It's named controller.py.\nThe second frame contains OpenGL rendering and many things inside it, but everything is wrapped inside a Frame() class as the above. It's named model.py.\nI'm up to the final part where I have to \"join\" these two together.\nDoes anyone know how to control a frame (model.py) from another frame (controller.py)?\nI would like to do something like a movie player when you clicks play it pops up a new window and play until the stop button is clicked. \nIf you know how, please let me know. (Just tell me in general no need to specific).","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":669,"Q_Id":3898988,"Users Score":1,"Answer":"I'd definitely use PubSub as it's probably the cleanest way I can think of to do it. You can also do it with wx.PostEvent or use a modal frame.","Q_Score":1,"Tags":"python,wxpython,frame,send","A_Id":3906746,"CreationDate":"2010-10-10T04:11:00.000","Title":"How to control a frame from another frame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to expose an RS232 connection to clients via a network socket. I plan to write in python a TCP socket server which will listen on some port, allow client to connect and handle outgoing and manage and control requests and replies to from the R2232 port. \nMy question is, how do I synchronize the clients, each client will send some string to the serial port and after the reply is sent back I need to return that client the result. Only then do I need to process the next request. \nHow to I synchronize access to the serial port ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1048,"Q_Id":3900403,"Users Score":1,"Answer":"The simplest way is to simply accept a connection, handle the request, and close the connection. This way, your program handles only one request at a time.\nAn alternative is to use locking or semaphores, to prevent multiple clients accessing the RS232 port simultaneously.","Q_Score":1,"Tags":"python,sockets,serial-port","A_Id":3900446,"CreationDate":"2010-10-10T13:03:00.000","Title":"Writing a TCP to RS232 driver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program.\nShould coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","AnswerCount":6,"Available Count":4,"Score":-0.0665680765,"is_accepted":false,"ViewCount":7387,"Q_Id":3902996,"Users Score":-2,"Answer":"To start coding in a file, just open a new file and start typing.","Q_Score":3,"Tags":"python,debugging,ide","A_Id":3903016,"CreationDate":"2010-10-11T01:28:00.000","Title":"How to get out of interactive mode in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program.\nShould coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7387,"Q_Id":3902996,"Users Score":0,"Answer":"use new window tool in the file icon,in the python idle itself to write a program","Q_Score":3,"Tags":"python,debugging,ide","A_Id":16851751,"CreationDate":"2010-10-11T01:28:00.000","Title":"How to get out of interactive mode in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program.\nShould coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":7387,"Q_Id":3902996,"Users Score":0,"Answer":"Push new to start making your own script file.  Then when you are ready to test click run and then you can watch the results in the interactive mode, and even try new things as if you were adding code to the end of your script file, its a very useful app for debugging, testing and trying new things.\nAlso in the options you can change the way python opens your scripts when you click edit from windows, you can set it so that it opens the interactive shell or just the editor.","Q_Score":3,"Tags":"python,debugging,ide","A_Id":3903066,"CreationDate":"2010-10-11T01:28:00.000","Title":"How to get out of interactive mode in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program.\nShould coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":7387,"Q_Id":3902996,"Users Score":2,"Answer":"Yes, coding should be done in a different program.  The interactive shell is very useful but it's not an editor.","Q_Score":3,"Tags":"python,debugging,ide","A_Id":3903006,"CreationDate":"2010-10-11T01:28:00.000","Title":"How to get out of interactive mode in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey, I got a ReconnectingClientFactory and I wonder if I can somehow define protocol-instance-based connectionMade\/connectionLost callbacks so that i can use the factory to connect to different hosts ans distinguish between each connection.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":499,"Q_Id":3905791,"Users Score":1,"Answer":"No. Write a class that does the interaction with one user. In connectionMade you check if a instance of this class already exists, if not you make a new one and store it on the factory, ie in a { addr : handler } dict. If the connection exists alreay you get the old handler from the factory.","Q_Score":0,"Tags":"python,twisted,factory","A_Id":3906174,"CreationDate":"2010-10-11T11:33:00.000","Title":"Twisted factory protocol instance based callback","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got an issue when installing Django.\nThe official guide says open cmd with administrator privileges and run \"setup.py install\"\nI did this but then the system default python editor came out, I don't know how to do anymore, please  help me~","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":494,"Q_Id":3912579,"Users Score":2,"Answer":"It is very likely that the py extension is linked with the editor rather than the Python interpreter.\nRight-click on a py file and click \"Open with\" then select the default program and choose 'C:...\\Python2x\\python.exe'\nThat should fix the pb","Q_Score":1,"Tags":"python,django,installation","A_Id":3912677,"CreationDate":"2010-10-12T07:53:00.000","Title":"Issue happens when installing Django on Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just started learning Python & have come across \"namespaces\" concept in Python. While I got the jist of what it is, but am unable to appreciate the gravity of this concept. \nSome browsing on the net revealed that one of the reasons going against PHP is that it has no native support for namespaces.\nCould someone explain how to use namespaces & how this feature makes programming better (not just in Python, as I assume namespaces in not a concept limited to a particular language). \nI am predominantly coming from Java and C programming backgrounds.","AnswerCount":6,"Available Count":2,"Score":-0.0333209931,"is_accepted":false,"ViewCount":29735,"Q_Id":3913217,"Users Score":-1,"Answer":"If you make a big program with someone else, you could write your own part of the program as you want. All variables in the file will be private, there will be no collisions.\nWhen you write PHP programs, it is easy to rewrite global variables by mistake. In python you can import other modules variables if you want, and they will be \"global\" on your module.\nYou could think one file one object in Python. When you write PHP programs you can achieve the same by writing classes with instance variables.","Q_Score":47,"Tags":"python,programming-languages,namespaces","A_Id":3913281,"CreationDate":"2010-10-12T09:30:00.000","Title":"What are Python namespaces all about","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just started learning Python & have come across \"namespaces\" concept in Python. While I got the jist of what it is, but am unable to appreciate the gravity of this concept. \nSome browsing on the net revealed that one of the reasons going against PHP is that it has no native support for namespaces.\nCould someone explain how to use namespaces & how this feature makes programming better (not just in Python, as I assume namespaces in not a concept limited to a particular language). \nI am predominantly coming from Java and C programming backgrounds.","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":29735,"Q_Id":3913217,"Users Score":49,"Answer":"Namespace is a way to implement scope.\nIn Java (or C) the compiler determines where a variable is visible through static scope analysis.  \n\nIn C, scope is either the body of a function or it's global or it's external.  The compiler reasons this out for you and resolves each variable name based on scope rules.  External names are resolved by the linker after all the modules are compiled.\nIn Java, scope is the body of a method function, or all the methods of a class.  Some class names have a module-level scope, also.  Again, the compiler figures this out at compile time and resolves each name based on the scope rules.\n\nIn Python, each package, module, class, function and method function owns a \"namespace\" in which variable names are resolved.  Plus there's a global namespace that's used if the name isn't in the local namespace.\nEach variable name is checked in the local namespace (the body of the function, the module, etc.), and then checked in the global namespace.\nVariables are generally created only in a local namespace.  The global and nonlocal statements can create variables in other than the local namespace.\nWhen a function, method function, module or package is evaluated (that is, starts execution) a namespace is created.  Think of it as an \"evaluation context\".  When a function or method function, etc., finishes execution, the namespace is dropped.  The variables are dropped.  The objects may be dropped, also.","Q_Score":47,"Tags":"python,programming-languages,namespaces","A_Id":3913488,"CreationDate":"2010-10-12T09:30:00.000","Title":"What are Python namespaces all about","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to shorten the float result I got? I only need 2 digits after the dot. Sorry I really don't know how to explain this better in English... \nThanks","AnswerCount":8,"Available Count":1,"Score":0.1243530018,"is_accepted":false,"ViewCount":103306,"Q_Id":3914725,"Users Score":5,"Answer":"x = round(293.4662543, 2)","Q_Score":32,"Tags":"python,number-formatting","A_Id":3914765,"CreationDate":"2010-10-12T12:35:00.000","Title":"How to turn a float number like 293.4662543 into 293.47 in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem with my python application, and I think it's related to the python garbage collection, even if I'm not sure...\nThe problem is that my application takes a lot of time to exit and to switch to one function to the next one.\nIn my application I handle very large dictionaries, containing thousands of large objects which are instantiated from wrapped C++ classes.\nI put some timestamp outputs in my program, and I saw that at the end of each function, when objects created inside the function should go out of scope, a lot of time is spent by the interpreter before calling the next function. And I observe the same problem at the end of the application, when the program should exit: a lot of time (~ hours!) is spent between the last timestamp on screen and the appearance of the fresh prompt.\nThe memory usage is stable, so I don't really have memory leaks.\nAny suggestions?\nCan be the garbage collection of thousands of large C++ objects that slow?\nIs there a method to speed up that?\nUPDATE:\nThanks a lot for all your answers, you gave me a lot of hints to debug my code :-)\nI use Python 2.6.5 on Scientific Linux 5, a customized distribution based on Red Hat Enterprise 5.\nAnd actually I'm not using SWIG to get Python bindings for our C++ code, but the Reflex\/PyROOT framework. I know, it's not very known outside particle physics (but still open source and freely available) and I have to use it because it's the default for our main framework.\nAnd in this context the DEL command from the Python side does not work, I had already tried it. DEL only deletes the python variable linked to the C++ object, not the object itself in memory, which is still owned by the C++ side...\n...I know, it's not-standard I guess, and a bit complicated, sorry :-P\nBut following your hints, I'll profile my code and I'll come back to you with more details, as you suggested.\nADDITIONAL UPDATE:\nOk, following your suggestions, I instrumented my code with cProfile, and I discovered that actually the gc.collect() function is the function taking the most of the running time!!\nHere the output from cProfile + pstats  print_stats():\n\n\n    >>> p.sort_stats(\"time\").print_stats(20)\nWed Oct 20 17:46:02 2010    mainProgram.profile\n\n         547303 function calls (542629 primitive calls) in 548.060 CPU seconds\n\n   Ordered by: internal time\n   List reduced from 727 to 20 due to restriction \n\n   ncalls  tottime  percall  cumtime  percall filename:lineno(function)\n        4  345.701   86.425  345.704   86.426 {gc.collect}\n        1  167.115  167.115  200.946  200.946 PlotD3PD_v3.2.py:2041(PlotSamplesBranches)\n       28   12.817    0.458   13.345    0.477 PlotROOTUtils.py:205(SaveItems)\n     9900   10.425    0.001   10.426    0.001 PlotD3PD_v3.2.py:1973(HistoStyle)\n     6622    5.188    0.001    5.278    0.001 PlotROOTUtils.py:403(__init__)\n       57    0.625    0.011    0.625    0.011 {built-in method load}\n      103    0.625    0.006    0.792    0.008 dbutils.py:41(DeadlockWrap)\n       14    0.475    0.034    0.475    0.034 {method 'dump' of 'cPickle.Pickler' objects}\n     6622    0.453    0.000    5.908    0.001 PlotROOTUtils.py:421(CreateCanvas)\n    26455    0.434    0.000    0.508    0.000 \/opt\/root\/lib\/ROOT.py:215(__getattr__)\n[...]\n\n>>> p.sort_stats(\"cumulative\").print_stats(20)\nWed Oct 20 17:46:02 2010    mainProgram.profile\n\n         547303 function calls (542629 primitive calls) in 548.060 CPU seconds\n\n   Ordered by: cumulative time\n   List reduced from 727 to 20 due to restriction \n\n   ncalls  tottime  percall  cumtime  percall filename:lineno(function)\n        1    0.001    0.001  548.068  548.068 PlotD3PD_v3.2.py:2492(main)\n        4    0.000    0.000  346.756   86.689 \/usr\/lib\/\/lib\/python2.5\/site-packages\/guppy\/heapy\/Use.py:171(heap)\n        4    0.005    0.001  346.752   86.688 \/usr\/lib\/\/lib\/python2.5\/site-packages\/guppy\/heapy\/View.py:344(heap)\n        1    0.002    0.002  346.147  346.147 PlotD3PD_v3.2.py:2537(LogAndFinalize)\n        4  345.701   86.425  345.704   86.426 {gc.collect}\n        1  167.115  167.115  200.946  200.946 PlotD3PD_v3.2.py:2041(PlotBranches)\n       28   12.817    0.458   13.345    0.477 PlotROOTUtils.py:205(SaveItems)\n     9900   10.425    0.001   10.426    0.001 PlotD3PD_v3.2.py:1973(HistoStyle)\n    13202    0.336    0.000    6.818    0.001 PlotROOTUtils.py:431(PlottingCanvases)\n     6622    0.453    0.000    5.908    0.001 \/root\/svn_co\/rbianchi\/SoftwareDevelopment\n\n[...]\n\n>>>\n\nSo, in both outputs, sorted by \"time\" and by \"cumulative\" time respectively, gc.collect() is the function consuming the most of the running time of my program! :-P\nAnd this is the output of the memory profiler Heapy, just before returning the main() program.\n\nmemory usage before return:\nPartition of a set of 65901 objects. Total size = 4765572 bytes.\n Index  Count   %     Size   % Cumulative  % Kind (class \/ dict of class)\n     0  25437  39  1452444  30   1452444  30 str\n     1   6622  10   900592  19   2353036  49 dict of PlotROOTUtils.Canvas\n     2    109   0   567016  12   2920052  61 dict of module\n     3   7312  11   280644   6   3200696  67 tuple\n     4   6622  10   238392   5   3439088  72 0xa4ab74c\n     5   6622  10   185416   4   3624504  76 PlotROOTUtils.Canvas\n     6   2024   3   137632   3   3762136  79 types.CodeType\n     7    263   0   129080   3   3891216  82 dict (no owner)\n     8    254   0   119024   2   4010240  84 dict of type\n     9    254   0   109728   2   4119968  86 type\n  Index  Count   %     Size   % Cumulative  % Kind (class \/ dict of class)\n    10   1917   3   107352   2   4264012  88 function\n    11   3647   5   102116   2   4366128  90 ROOT.MethodProxy\n    12    148   0    80800   2   4446928  92 dict of class\n    13   1109   2    39924   1   4486852  93 __builtin__.wrapper_descriptor\n    14    239   0    23136   0   4509988  93 list\n    15     87   0    22968   0   4532956  94 dict of guppy.etc.Glue.Interface\n    16    644   1    20608   0   4553564  94 types.BuiltinFunctionType\n    17    495   1    19800   0   4573364  94 __builtin__.weakref\n    18     23   0    11960   0   4585324  95 dict of guppy.etc.Glue.Share\n    19    367   1    11744   0   4597068  95 __builtin__.method_descriptor\n\n\nAny idea why, or how to optimize the garbage collection?\nIs there any more detailed check I can do?","AnswerCount":3,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":13216,"Q_Id":3916553,"Users Score":-5,"Answer":"If your problem really is the garbage collection, try explicitly freeing your objects when you're done with them using del().\nIn general, this doesn't sound like a garbage collection problem, unless we're talking about terabytes of memory.\nI agree with S.Lott... profile your app, then bring code snippets and the results of that back and we can be much more helpful.","Q_Score":18,"Tags":"python,garbage-collection,root,performance","A_Id":3919321,"CreationDate":"2010-10-12T15:50:00.000","Title":"Python garbage collection can be that slow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to create automated integration tests for this hardware+software test subject which runs a SNMP agent as it's command interface. Our test setup looks like this: We're using Fitnesse as a test runner and PyFit to be able to write the tests in Python. We then use netsnmp with Python bindings to send SNMP commands. This works pretty well.\nHowever, when I try to run a suite the SNMP agent (the test subject) is restarted (and usually at a different simulated time) which makes the internals of netsnmp get all sorts of interesting errors.\nTurns out there is a lot of global state stored inside the netsnmp library like community and context names and problematically EngineTime and EngineBootCnt, which is used to prevent replay attacks in SNMP v3. This causes the agent to reject my snmp commands.\nMy problems is how do I reinitialise the netsnmp library (from the Python bindings) in a way that the internal global state are reset? The netsnmp.Session object in the Python bindings do take the parameter EngineTime and EngineBoots and setting them to 0 should reset them, but actually it doesn't seem to do that. I also do not know if there is other global state in there which needs to be reset.\nI'm at a point where I think I need to rewrite the tests to use the pure python snmp library pysnmp, but I was hoping to avoid it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":731,"Q_Id":3940057,"Users Score":1,"Answer":"The engineTime and engineBoots values are probably what is messing you up because SNMPv3 requires they not go backwards.  If you have an agent that is restarting from scratch and not incrementing it's boots count (which is illegal, but under tests I could see why you'd be doing that) then you'd need to reset the internal notion of boots and time.\nHowever, setting them to 0 and 0 won't help because it'll assume those are defaults.  You should, instead, change one of them to '1' which should trigger the override clause to actually use the values.  Set the time to 1 and try it and I think it'll work (and if it doesn't, set them both to 1 instead and try that).","Q_Score":1,"Tags":"python,snmp,fitnesse,net-snmp,pysnmp","A_Id":3968271,"CreationDate":"2010-10-15T06:45:00.000","Title":"Resetting all global internal state of the net-snmp library from the Python bindings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I can traverse generic tags easily with BS, but I don't know how to find specific tags. For example, how can I find all occurances of <div style=\"width=300px;\">? Is this possible with BS?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":62029,"Q_Id":3945750,"Users Score":9,"Answer":"with bs4 things have changed a little. so the code should look like this\nsoup = BeautifulSoup(htmlstring,'lxml')\nsoup.find_all('div', {'style':\"width=300px;\"})","Q_Score":29,"Tags":"python,beautifulsoup","A_Id":45193575,"CreationDate":"2010-10-15T20:11:00.000","Title":"Find a specific tag with BeautifulSoup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I always found links in html source stored in such format, the question is how do I change such links back to what it's normally like?\nThanks a lot!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":797,"Q_Id":3949739,"Users Score":0,"Answer":"urllib.unquote() on its own may still cause problems by throwing the exception:\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position n: ordinal not in range(128)\nIn that case try:\nprint urllib.unquote(\"Ober%C3%B6sterreich.txt\").decode(\"utf8\")","Q_Score":0,"Tags":"python,html","A_Id":5693726,"CreationDate":"2010-10-16T16:33:00.000","Title":"How to turn an encoded link such as \"http%3A%2F%2Fexample.com%2Fwhatever\" into \"http:\/\/example.com\/whatever\" in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how I would go about performing image analysis in R. My goal is to convert images into matrices (pixel-wise information), extract\/quantify color, estimate the presence of shapes and compare images based on such metrics\/patterns.\nI am aware of relevant packages available in Python (suggestions relevant to Python are also welcome), but I am looking to accomplish these tasks in R.\nThank you for your feedback.\n-Harsh","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":4953,"Q_Id":3955077,"Users Score":1,"Answer":"Try the rgdal package. You will be able to read (import) and write (export) GeoTiff image files from\/to R.\nMarcio Pupin Mello","Q_Score":15,"Tags":"python,image,r,analysis","A_Id":3964945,"CreationDate":"2010-10-17T20:12:00.000","Title":"Image analysis in R","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am not running Django on AppEngine. I just want to use AppEngine as a content delivery network, basically a place I can host and serve images for free. It's for a personal side project.\nThe situation is this: I have the URL of an image hosted on another server\/provider. Instead of hotlinking to that image its better to save it on AppEngine and serve it from there - this applies mostly for thumbnails.\nMy questions are these:\n\nHow do I authenticate from my Django app (let's say A) to my AppEngine app (B), so that only I can upload images\nHow do I make a request from A to B saying \"Fetch the image on this URL, create a thumbnail and save it.\"\nHow do I tell B that \"For this url return that image\"\nHow can I handle errors or timeouts? And how can this be done asynchronously?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":269,"Q_Id":3958224,"Users Score":1,"Answer":"Afaik you can not store files in App Engine programmatically. You can just store them, when uploading your app.\nYou can however store information in its data store. So you would need to deploy an app, that authenticates your user and then writs the image to the gae's data store","Q_Score":1,"Tags":"python,google-app-engine","A_Id":3959150,"CreationDate":"2010-10-18T10:24:00.000","Title":"Uploading images from a django application to a Google AppEngine application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm going to reveal my ignorance here, but in my defense, I'm an accounting major, and I've never taken a computer science class.\nI'm about to start a new project, and I'm considering using Python instead of PHP, even though I am much more adept with PHP, because I have heard that Python is a more powerful language. That got me wondering, what makes one programming language more powerful than another? I figure javascript isn't very powerful because it (generally) runs inside a browser. But, why is Python more powerful than PHP? In each case, I'm giving instructions to the computer, so why are some languages better at interpreting and executing these instructions? How do I know how much \"power\" I actually need for a specific project?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6357,"Q_Id":3963438,"Users Score":0,"Answer":"The stock answer is the only features that make certain languages more powerful than others are language features that cannot be easily replaced by adding libraries.\nThis definition will almost always list LISP on the top, but has the odd side effect of listing assembly near the top unless special care is taken to exclude it.","Q_Score":5,"Tags":"python,programming-languages","A_Id":3963524,"CreationDate":"2010-10-18T21:12:00.000","Title":"What makes some programming languages more powerful than others?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm going to reveal my ignorance here, but in my defense, I'm an accounting major, and I've never taken a computer science class.\nI'm about to start a new project, and I'm considering using Python instead of PHP, even though I am much more adept with PHP, because I have heard that Python is a more powerful language. That got me wondering, what makes one programming language more powerful than another? I figure javascript isn't very powerful because it (generally) runs inside a browser. But, why is Python more powerful than PHP? In each case, I'm giving instructions to the computer, so why are some languages better at interpreting and executing these instructions? How do I know how much \"power\" I actually need for a specific project?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":6357,"Q_Id":3963438,"Users Score":1,"Answer":"I would not say that there are computer languages \"more powerful\", just languages more suited for your specific problem domain.\nThat said, PHP is a language that evolved from a hack and tailored for a very specific problem domain; this shows up in several places, like for example inconsistent parameter order across database interfaces. IMHO PHP community has made some very sad decisions for new syntax enhancements over the time.\nIMHO Python is much more general, well designed and elegant, but your question is one that usually starts flamewars.","Q_Score":5,"Tags":"python,programming-languages","A_Id":3963547,"CreationDate":"2010-10-18T21:12:00.000","Title":"What makes some programming languages more powerful than others?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm going to reveal my ignorance here, but in my defense, I'm an accounting major, and I've never taken a computer science class.\nI'm about to start a new project, and I'm considering using Python instead of PHP, even though I am much more adept with PHP, because I have heard that Python is a more powerful language. That got me wondering, what makes one programming language more powerful than another? I figure javascript isn't very powerful because it (generally) runs inside a browser. But, why is Python more powerful than PHP? In each case, I'm giving instructions to the computer, so why are some languages better at interpreting and executing these instructions? How do I know how much \"power\" I actually need for a specific project?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6357,"Q_Id":3963438,"Users Score":0,"Answer":"Its an interesting topic and in my line of word I come across this a lot. But I've discovered 'power' in the literal sense no longer has value when it comes to the language. What I fear those telling you 'python is more' powerful are getting mixed up with the language and the implementation.\nI'm a recent convert to python (last 2 weeks) previously I was a PHP coder. The libraries made on top of the language of python - namely django -help make the language more powerful - as its faster to use and build upon. \nPHP has the fable 'if you want to do something. there is a function for it' and the documentation is brilliant - therefore powerful in that sense.\nAnd in regards to interpreting the language - again dependant upon who has been coding it - its no matter. By general consensus python may be considered quicker and less CPU intensive, is it creates compiled versions of your code. But PHP can have a good caching system.\nIn short - Pick you favorite.","Q_Score":5,"Tags":"python,programming-languages","A_Id":3963564,"CreationDate":"2010-10-18T21:12:00.000","Title":"What makes some programming languages more powerful than others?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm going to reveal my ignorance here, but in my defense, I'm an accounting major, and I've never taken a computer science class.\nI'm about to start a new project, and I'm considering using Python instead of PHP, even though I am much more adept with PHP, because I have heard that Python is a more powerful language. That got me wondering, what makes one programming language more powerful than another? I figure javascript isn't very powerful because it (generally) runs inside a browser. But, why is Python more powerful than PHP? In each case, I'm giving instructions to the computer, so why are some languages better at interpreting and executing these instructions? How do I know how much \"power\" I actually need for a specific project?","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":6357,"Q_Id":3963438,"Users Score":4,"Answer":"I hate statements of the sort \"language X is more powerful than Y.\" The real question is which language makes you more powerful. If language X allows you to write better code (that works) faster than Y does then, yes, X is more \"powerful\". \nIf you are looking for an objective explanation of language powerful-ness ... well, good luck with that.","Q_Score":5,"Tags":"python,programming-languages","A_Id":3963482,"CreationDate":"2010-10-18T21:12:00.000","Title":"What makes some programming languages more powerful than others?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can I set width to a tk.Frame (post-initialization ?)\nIn other words, is there a member function to do it ? Sometheing like frame.setWidth()\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4026,"Q_Id":3968275,"Users Score":3,"Answer":"frame.config(width=100)\nBe aware that if there are children in the frame that are managed by grid or pack, your changes may have no effect. There are solutions to this, but it is rarely needed. Generally speaking you should let widgets be their natural size. If you do need to resize a frame that is a container of other widgets you need to turn \"geometry propagation\" off.","Q_Score":3,"Tags":"python,tkinter","A_Id":3968351,"CreationDate":"2010-10-19T12:26:00.000","Title":"TKinter: how to change Frame width dynamically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say if I have  multiple forms with multiple submit button in a single page, can I somehow make all of these buttons work using webapp as backend handler? If not, what are the alternatives?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1373,"Q_Id":3976368,"Users Score":7,"Answer":"The framework you use is irrelevant to how you handle forms. You have a couple of options: you can distinguish the forms by changing the URL they submit to - in which case, you can use the same handler or a different handler for each form - or you can distinguish them based on the contents of the form. The easiest way to do the latter is to give your submit buttons distinct names or values, and check for them in the POST data.","Q_Score":2,"Tags":"python,google-app-engine,web-applications","A_Id":3976759,"CreationDate":"2010-10-20T09:23:00.000","Title":"How to handle multiple forms in google app engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm building a web site from the old one and i need to show a lot of .pdf files.\nI need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database).\nI'm using Pylons with Python.\nThank for you help.\nIf you have any question, ask me! :)","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":3980878,"Users Score":0,"Answer":"Maybe filename with md5 key will be enough?\n48cd84ab06b0a18f3b6e024703cfd246-myfilename.pdf\nYou can use filename and datetime.now to generate md5 key.","Q_Score":1,"Tags":"python,html,pdf,permissions,pylons","A_Id":4025388,"CreationDate":"2010-10-20T18:01:00.000","Title":"Show pdf only to authenticated users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a web site from the old one and i need to show a lot of .pdf files.\nI need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database).\nI'm using Pylons with Python.\nThank for you help.\nIf you have any question, ask me! :)","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":216,"Q_Id":3980878,"Users Score":2,"Answer":"Paul's suggestion of X-Sendfile is excellent - this is truly a great way to deal with actually getting the document back to the user. (+1 for Paul :)\nAs for the front end, do something like this:\n\nStore your pdfs somewhere not accessible by the web (say \/secure)\nOffer a URL that looks like \/unsecure\/filename.pdf\nHave your HTTP server (if it's Apache, see Mod Rewrite) convert that link into \/normal\/php\/path\/authenticator.php?file=filename.pdf\nauthenticator.php confirms that the file exists, that the user is legit (i.e. via a cookie), and then uses X-Sendfile to return the PDF.","Q_Score":1,"Tags":"python,html,pdf,permissions,pylons","A_Id":3980973,"CreationDate":"2010-10-20T18:01:00.000","Title":"Show pdf only to authenticated users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a web site from the old one and i need to show a lot of .pdf files.\nI need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database).\nI'm using Pylons with Python.\nThank for you help.\nIf you have any question, ask me! :)","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":216,"Q_Id":3980878,"Users Score":2,"Answer":"You want to use the X-Sendfile header to send those files. Precise details will depend on which Http server you're using.","Q_Score":1,"Tags":"python,html,pdf,permissions,pylons","A_Id":3980896,"CreationDate":"2010-10-20T18:01:00.000","Title":"Show pdf only to authenticated users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Well i want to input a python function as an input in run time and execute that part of code 'n' no of times. For example using tkinter i create a textbox where the user writes the  function and submits it , also mentioning how many times it wants to be executed. My program should be able to run that function as many times as mentioned by the user.\nPs: i did think of an alternative method where the user can write the program in a file and then i can simply execute it as python filename as a system cmd inside my python program , but i dont want it that way.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":6779,"Q_Id":3981357,"Users Score":2,"Answer":"Python provides number of ways to do this using function calls:\n- eval()\n- exec()\nFor your needs you should read about exec.","Q_Score":1,"Tags":"python","A_Id":3981399,"CreationDate":"2010-10-20T19:02:00.000","Title":"how to input python code in run time and execute it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My question was not specific enough last time, and so this is second question about this topic. \nI'm running some experiments and I need to precisely measure participants' response time to questions in millisecond unit. \nI know how to do this with the time module, but I was wondering if this is reliable enough or I should be careful using it. I was wondering if there are possibilities of some other random CPU load will interfere with the measuring of time.\nSo my question is, will the response time measure with time module be very accurate or there will be some noise associate with it?\nThank you,\nJoon","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":533,"Q_Id":3989952,"Users Score":2,"Answer":"CPU load will affect timing. If your application is startved of a slice of CPU time, then timing would get affected. You can not help that much. You can be as precise and no more. Ensure that your program gets a health slice of cpu time and the result will be accurate. In most cases, the results should be accurate to milliseconds.","Q_Score":3,"Tags":"python,time","A_Id":3990021,"CreationDate":"2010-10-21T16:55:00.000","Title":"Is python time module reliable enough to use to measure response time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My question was not specific enough last time, and so this is second question about this topic. \nI'm running some experiments and I need to precisely measure participants' response time to questions in millisecond unit. \nI know how to do this with the time module, but I was wondering if this is reliable enough or I should be careful using it. I was wondering if there are possibilities of some other random CPU load will interfere with the measuring of time.\nSo my question is, will the response time measure with time module be very accurate or there will be some noise associate with it?\nThank you,\nJoon","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":533,"Q_Id":3989952,"Users Score":1,"Answer":"If you benchmark on a *nix system (Linux most probably), time.clock() will return CPU time in seconds. On its own, it's not very informative, but as a difference of results (i.e. t0 = time.clock(); some_process(); t = time.clock() - t0), you'd have a much more load-independent timing than with time.time().","Q_Score":3,"Tags":"python,time","A_Id":3990976,"CreationDate":"2010-10-21T16:55:00.000","Title":"Is python time module reliable enough to use to measure response time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone tell me how can I get the length of a string without using the len() function or any string methods. Please anyone tell me as I'm tapping my head madly for the answer.\nThank you.","AnswerCount":17,"Available Count":1,"Score":-0.0235250705,"is_accepted":false,"ViewCount":43653,"Q_Id":3992192,"Users Score":-2,"Answer":"Create a for loop\nstyx = \"How do I count this without using Lens function\"\nnumber = 0\nfor c in styx:\nnumber = 0 + 1\nprint(number)","Q_Score":3,"Tags":"python,string-length","A_Id":65062702,"CreationDate":"2010-10-21T21:37:00.000","Title":"String length without len function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"And what is it called? I don't know how to search for it; I tried calling it ellipsis with the Google.  I don't mean in interactive output when dots are used to indicate that the full array is not being shown, but as in the code I'm looking at, \nxTensor0[...] = xVTensor[..., 0]\nFrom my experimentation, it appears to function the similarly to : in indexing, but stands in for multiple :'s, making x[:,:,1] equivalent to x[...,1].","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1449,"Q_Id":3993125,"Users Score":7,"Answer":"Yes, you're right.  It fills in as many : as required.  The only difference occurs when you use multiple ellipses.  In that case, the first ellipsis acts in the same way, but each remaining one is converted to a single :.","Q_Score":7,"Tags":"python,numpy","A_Id":3993156,"CreationDate":"2010-10-22T00:50:00.000","Title":"What does ... mean in numpy code?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the output streams from the io module and writing to files. I want to be able to detect when I have written 1G of data to a file and then start writing to a second file. I can't seem to figure out how to determine how much data I have written to the file.\nIs there something easy built in to io? Or might I have to count the bytes before each write manually?","AnswerCount":6,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":17308,"Q_Id":3999007,"Users Score":3,"Answer":"See the tell() method on the stream object.","Q_Score":11,"Tags":"python,file-io","A_Id":3999039,"CreationDate":"2010-10-22T16:41:00.000","Title":"How to limit file size when writing one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the output streams from the io module and writing to files. I want to be able to detect when I have written 1G of data to a file and then start writing to a second file. I can't seem to figure out how to determine how much data I have written to the file.\nIs there something easy built in to io? Or might I have to count the bytes before each write manually?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":17308,"Q_Id":3999007,"Users Score":1,"Answer":"I noticed an ambiguity in your question. Do you want the file to be (a) over (b) under (c) exactly 1GiB large, before switching?\nIt's easy to tell if you've gone over. tell() is sufficient for that kind of thing; just check if tell() > 1024*1024*1024: and you'll know.\nChecking if you're under 1GiB, but will go over 1GiB on your next write, is a similar technique. if len(data_to_write) + tell > 1024*1024*1024: will suffice.\nThe trickiest thing to do is to get the file to exactly 1GiB. You will need to tell() the length of the file, and then partition your data appropriately in order to hit the mark precisely.\nRegardless of exactly which semantics you want, tell() is always going to be at least as slow as doing the counting yourself, and possibly slower. This doesn't mean that it's the wrong thing to do; if you're writing the file from a thread, then you almost certainly will want to tell() rather than hope that you've correctly preempted other threads writing to the same file. (And do your locks, etc., but that's another question.)\nBy the way, I noticed a definite direction in your last couple questions. Are you aware of #twisted and #python IRC channels on Freenode (irc.freenode.net)? You will get timelier, more useful answers.\n~ C.","Q_Score":11,"Tags":"python,file-io","A_Id":4766092,"CreationDate":"2010-10-22T16:41:00.000","Title":"How to limit file size when writing one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know you can view the currently queued and running tasks in the Dashboard or development server console. However, is there any way to get that list programmatically? The docs only describe how to add tasks to the queue, but not how to list and\/or cancel them.\nIn python please.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2402,"Q_Id":4002514,"Users Score":1,"Answer":"A workaround, since they don't seem to support this yet, would be to model a Task datastore object. Create one on task queue add, update it when running, and delete it when your task fires. This can also be a nice way to get around the payload limits of the task queue api.","Q_Score":6,"Tags":"python,google-app-engine,task,dashboard,task-queue","A_Id":4059302,"CreationDate":"2010-10-23T04:42:00.000","Title":"Getting the Tasks in a Google App Engine TaskQueue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to build an internal search engine (I have a very large collection of thousands of XML files) that is able to map queries to concepts.  For example, if I search for \"big cats\", I would want highly ranked results to return documents with \"large cats\" as well.  But I may also be interested in having it return \"huge animals\", albeit at a much lower relevancy score.  \nI'm currently reading through the Natural Language Processing in Python book, and it seems WordNet has some word mappings that might prove useful, though I'm not sure how to integrate that into a search engine.  Could I use Lucene to do this? How?\nFrom further research, it seems \"latent semantic analysis\" is relevant to what I'm looking for but I'm not sure how to implement it.  \nAny advice on how to get this done?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1997,"Q_Id":4003840,"Users Score":0,"Answer":"First , write a piece of python code that will return you pineapple , orange , papaya when you input apple. By focusing on \"is\" relation of semantic network. Then continue with has a relationship and so on.\nI think at the end , you might get a fairly sufficient piece of code for a school project.","Q_Score":5,"Tags":"python,search,lucene,nlp,lsa","A_Id":4004384,"CreationDate":"2010-10-23T11:58:00.000","Title":"How to build a conceptual search engine?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to build an internal search engine (I have a very large collection of thousands of XML files) that is able to map queries to concepts.  For example, if I search for \"big cats\", I would want highly ranked results to return documents with \"large cats\" as well.  But I may also be interested in having it return \"huge animals\", albeit at a much lower relevancy score.  \nI'm currently reading through the Natural Language Processing in Python book, and it seems WordNet has some word mappings that might prove useful, though I'm not sure how to integrate that into a search engine.  Could I use Lucene to do this? How?\nFrom further research, it seems \"latent semantic analysis\" is relevant to what I'm looking for but I'm not sure how to implement it.  \nAny advice on how to get this done?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1997,"Q_Id":4003840,"Users Score":1,"Answer":"This is an incredibly hard problem and it can't be solved in a way that would always produce adequate results. I'd suggest to stick to some very simple principles instead so that the results are at least predictable. I think you need 2 things: some basic morphology engine plus a dictionary of synonyms.\nWhenever a search query arrives, for each word you\n\nLook for a literal match\n\"Normalize\/canonicalze\" the word using the morphology engine, i.e. make it singular, first form, etc and look for matches\nLook for synonyms of the word\n\nThen repeat for all combinations of the input words, i.e. \"big cats\", \"big cat\", \"huge cats\" huge cat\" etc.\nIn fact, you need to store your index data in canonical form, too (singluar, first form etc) along with the literal form.\nAs for concepts, such as cats are also animals - this is where it gets tricky. It never really worked, because otherwise Google would have been returning conceptual matches already, but it's not doing that.","Q_Score":5,"Tags":"python,search,lucene,nlp,lsa","A_Id":4004024,"CreationDate":"2010-10-23T11:58:00.000","Title":"How to build a conceptual search engine?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to build an internal search engine (I have a very large collection of thousands of XML files) that is able to map queries to concepts.  For example, if I search for \"big cats\", I would want highly ranked results to return documents with \"large cats\" as well.  But I may also be interested in having it return \"huge animals\", albeit at a much lower relevancy score.  \nI'm currently reading through the Natural Language Processing in Python book, and it seems WordNet has some word mappings that might prove useful, though I'm not sure how to integrate that into a search engine.  Could I use Lucene to do this? How?\nFrom further research, it seems \"latent semantic analysis\" is relevant to what I'm looking for but I'm not sure how to implement it.  \nAny advice on how to get this done?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1997,"Q_Id":4003840,"Users Score":9,"Answer":"I'm not sure how to integrate that into a search engine. Could I use Lucene to do this? How?\n\nStep 1.  Stop.\nStep 2.  Get something to work.\nStep 3.  By then, you'll understand more about Python and Lucene and other tools and ways you might integrate them.\nDon't start by trying to solve integration problems.  Software can always be integrated.  That's what an Operating System does.  It integrates software.  Sometimes you want \"tighter\" integration, but that's never the first problem to solve.\nThe first problem to solve is to get your search or concept thing or whatever it is to work as a dumb-old command-line application.  Or pair of applications knit together by passing files around or knit together with OS pipes or something.\nLater, you can try and figure out how to make the user experience seamless.\nBut don't start with integration and don't stall because of integration questions.  Set integration aside and get something to work.","Q_Score":5,"Tags":"python,search,lucene,nlp,lsa","A_Id":4004314,"CreationDate":"2010-10-23T11:58:00.000","Title":"How to build a conceptual search engine?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got class A wrapped with method foo implemented using %extend:\nclass A {\n  ...\n  %extend {\n  void foo()\n  {\n    self->foo_impl();\n  }\n  }\nNow I want to increase ref count to an A inside foo_impl, but I only got A* (as self). \nQuestion: how can I write\/wrap function foo, so that I have an access both to A* and underlying PyObject*?\nThank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":619,"Q_Id":4005355,"Users Score":1,"Answer":"I think it's not possible.  If you need to increase the refcount, it's because you don't want the C++ object to be destroyed when it goes out of scope because there is a pointer to that object elsewhere.  In that case, look at using the DISOWN typemap to ensure the target language doesn't think it \"owns\" the C++ object, so it won't get destroyed.","Q_Score":1,"Tags":"c++,python,swig","A_Id":4026127,"CreationDate":"2010-10-23T18:02:00.000","Title":"Python Swig wrapper: how access underlying PyObject","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Our product model can have multiple campaigns. Our customers change these campaigns frequently and generally on multiple products. So what we need right now seems that we need to show a multiple select widget on a change-list of Product model where our customers can easily change the campaigns. \nAny idea on this? Maybe another way to achieve this kind of UI interaction?\nThanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":559,"Q_Id":4013733,"Users Score":0,"Answer":"say you have a product model\n\n\nclass Product(models.Model):\n  name=models.CharField(max_length=20)\n  cost=models.DecimalField(max_length=10)\n\n\n\n\nyou can subclass the admin's Modeladmin to show a list display for the products  or you can do a custom modelform for the product which you can call in the product's admin\n\n\nfrom django.contrib import admin\nfrom django import forms\n\nclass PropertyInline(admin.TabularInine):\n   model=Property\n   extra=1\n\nclass PropertyForm(admin.ModelAdmin):\n   inlines=(PropertyInline,)","Q_Score":0,"Tags":"python,django,django-models,django-admin","A_Id":4030636,"CreationDate":"2010-10-25T10:38:00.000","Title":"django multiple select in admin change-list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've have asked these questions before with no proper answer. I hope I'll get some response here. \nI'm developing an instant messenger in python and I'd like to handle video\/audio streaming with VLC. Tha basic idea right now is that in each IM client I'm running one VLC instance that acts as a server that streams to all the users I want, and another VLC instance that's a client and recieves and displays all the streams that other users are sending to me. As you can see, it's kind of a P2P connection and I am having lots of problems.\nMy first problem was VLC can handle only one stream per port, but I solved this using VLM, the Videolan Manager which allows multiple streams with one instance and on one port. \nMy second problem was this kind of P2P take has several drawbacks as if someone is behind NAT or a router, you have to do manual configurations to forward the packages from the router to your PC, and it also has another drawback, you can only forward to 1 PC, so you would be able to use the program in only one workstation. \nAlso, the streams were transported in HTTP protocol, which uses TCP and it's pretty slow. When I tried to do the same with RTSP, I wasn't able to get the stream outside my private LAN.\nSo, this P2P take is very unlikely to be implemented successfully by an amateur like me, as it has all the typical NAT traversal problems, things that I don't want to mess with as this is not a commercial application, just a school project I must finish in order to graduate as a technician. Finally, I've been recommended to a use a server in a well known IP and that would solve the problem, only one router configuration and let both ends of the conversations be clients. I have no idea how to implement this idea, please any help is useful. Thanks in advance. Sorry for any error, I am not a programming\/networking expert nor am I an english-speaking person.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":224,"Q_Id":4015227,"Users Score":0,"Answer":"I think they were suggesting you run your program on a LAN which has no ports blocked.","Q_Score":0,"Tags":"python,streaming,p2p,vlc,instant-messaging","A_Id":4200613,"CreationDate":"2010-10-25T13:53:00.000","Title":"Problems with VLC and instant messaging","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is a situation I've run into several times, not sure what the best approach is.\nLet's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax.\nThe question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to \"know\" what the html looks like. \nIs this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?)\nThanks!\nEDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":261,"Q_Id":4027508,"Users Score":1,"Answer":"The reason to update all of the comments is to take in account other comments that other people may have also submitted in the meantime. to keep the site truly dynamic, you can do either that, or even, when the page is loaded, load up a variable with the newest submitted comment ID, and set a timer that goes back to check if there are more comments since then. if there are, return them as a JSON object and append them onto the current page a DIV at a time. That would be my preferred way to handle it, because you can then target actions based on each DIV's id or rel, which directly relates back to the comment's ID in the database...","Q_Score":2,"Tags":"javascript,python,ajax,django","A_Id":4027614,"CreationDate":"2010-10-26T20:02:00.000","Title":"Loading New Content with Ajax","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"This is a situation I've run into several times, not sure what the best approach is.\nLet's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax.\nThe question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to \"know\" what the html looks like. \nIs this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?)\nThanks!\nEDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":261,"Q_Id":4027508,"Users Score":1,"Answer":"I am not proficient neither with Django nor Python but I suppose the basic logic is similar for all server-side languages.\nWhen weighing the pros and cons of either approach things depend on what you want to optimize. If bandwidth is important then obviously using pure JSON in communication reduces latency when compared to transmitting ready-made HTML.\nHowever, duplicating the server-side view functionality to Javascript is a tedious and error-prone process. It simply takes a lot of time.\nI personally feel that in most cases (for small and medium traffic sites) it's perfectly fine to put the HTML fragment together on server side and simply replace the contents of a container (e.g. contents of a div) inside an AJAX callback function. Of course, replacing the whole page would be silly, hence your Django application needs to support outputting specific regions of the document.","Q_Score":2,"Tags":"javascript,python,ajax,django","A_Id":4027641,"CreationDate":"2010-10-26T20:02:00.000","Title":"Loading New Content with Ajax","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"This is a situation I've run into several times, not sure what the best approach is.\nLet's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax.\nThe question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to \"know\" what the html looks like. \nIs this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?)\nThanks!\nEDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":261,"Q_Id":4027508,"Users Score":4,"Answer":"If the content is simple, I would get JSON and build the HTML in jQuery. If it's complex, I would create a template and call render() on it on the server and return the HTML (which jQuery could either append to other content or replace existing content).","Q_Score":2,"Tags":"javascript,python,ajax,django","A_Id":4029103,"CreationDate":"2010-10-26T20:02:00.000","Title":"Loading New Content with Ajax","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"does the file which is sent as an argument to execfile runs as an independent process \/ thread or is the code imported and then executed ? . Also i wanted to know how efficient is it compared to running threads \/ process .","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":793,"Q_Id":4033669,"Users Score":2,"Answer":"The file is not run in a separate thread or process, it runs synchronously with the caller.","Q_Score":2,"Tags":"python","A_Id":4033706,"CreationDate":"2010-10-27T13:19:00.000","Title":"how does execfile() work in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been experimenting with Appcelerator Titanum yesterday and I think it's cool when it comes to Javascript.  \nPython features on Appcelerator Titanum are so limited (can't use some modules for example).  \nMy question is How can I use html & javascript as a GUI tool for a real python application ? \nI am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python.  \nI am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":24264,"Q_Id":4034169,"Users Score":0,"Answer":"If you are thinking about real desktop applications that are multi-threaded and\/or use multiple system component - forget about JavaScript. That requires a very good SDK (like PyQt4), and not a basic wrapper like Appcelerator Titanium. Note that developing such applications takes a lot of time.\nSecond option is to drop the desktop binding and make a web application with an advanced frontend UI made with one of JavaScript frameworks & friends (Ember, Angular... up to things like dhtmlx and alike widgets). Those can't use system components (like access some hardware), but they can provide nice services.","Q_Score":22,"Tags":"python,webkit","A_Id":17223197,"CreationDate":"2010-10-27T14:09:00.000","Title":"How can I use HTML + Javascript to build a python GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been experimenting with Appcelerator Titanum yesterday and I think it's cool when it comes to Javascript.  \nPython features on Appcelerator Titanum are so limited (can't use some modules for example).  \nMy question is How can I use html & javascript as a GUI tool for a real python application ? \nI am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python.  \nI am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":24264,"Q_Id":4034169,"Users Score":0,"Answer":"I assume you are mobilizing a web-application for cross platform access.\nIf so have you considered abstracting the cross platform access at the web-app presentation layer ?\nAppcelerator \/ Webkit does not provide true native look-and-feel on mobile devices but this is where a new technology can help.","Q_Score":22,"Tags":"python,webkit","A_Id":4064133,"CreationDate":"2010-10-27T14:09:00.000","Title":"How can I use HTML + Javascript to build a python GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to have some constants in a Django Projects. For example, let's say a constant called MIN_TIME_TEST.\nI would like to be able to access this constant in two places: from within my Python code, and from within any Templates.\nWhat's the best way to go about doing this?\nEDIT:\nTo clarify, I know about Template Context Processors and about just putting things in settings.py or some other file and just importing.\nMy question is, how do I combine the two approaches without violating the \"Don't Repeat Yourself\" rule? Based on the answers so far, here's my approach:\nI'd like to create a file called global_constants.py, which will have a list of constants (things like MIN_TIME_TEST = 5). I can import this file into any module to get the constants. \nBut now, I want to create the context processor which returns all of these constants. How can I go about doing this automatically, without having to list them again in a dictionary, like in John Mee's answer?","AnswerCount":7,"Available Count":1,"Score":0.0855049882,"is_accepted":false,"ViewCount":31657,"Q_Id":4042407,"Users Score":3,"Answer":"Consider putting it into settings.py of your application. Of course, in order to use it in template you will need to make it available to template as any other usual variable.","Q_Score":23,"Tags":"python,django,constants","A_Id":4042429,"CreationDate":"2010-10-28T11:27:00.000","Title":"Defining Constants in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I automate a test to enforce that a body of Python 2.x code contains no string instances (only unicode instances)?\nEg.\nCan I do it from within the code?\nIs there a static analysis tool that has this feature?\nEdit:\nI wanted this for an application in Python 2.5, but it turns out this is not really possible because:\n\n2.5 doesn't support unicode_literals\nkwargs dictionary keys can't be unicode objects, only strings\n\nSo I'm accepting the answer that says it's not possible, even though it's for different reasons :)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":4046853,"Users Score":1,"Answer":"You can't enforce that all strings are Unicode; even with from __future__ import unicode_literals in a module, byte strings can be written as b'...', as they can in Python 3.\nThere was an option that could be used to get the same effect as unicode_literals globally: the command-line option -U. However it was abandoned early in the 2.x series because it basically broke every script.\nWhat is your purpose for this? It is not desirable to abolish byte strings. They are not \u201cbad\u201d and Unicode strings are not universally \u201cbetter\u201d; they are two separate animals and you will need both of them. Byte strings will certainly be needed to talk to binary files and network services.\nIf you want to be prepared to transition to Python 3, the best tack is to write b'...' for all the strings you really mean to be bytes, and u'...' for the strings that are inherently Unicode. The default string '...' format can be used for everything else, places where you don't care and\/or whether Python 3 changes the default string type.","Q_Score":5,"Tags":"python,automated-tests,static-analysis,enforcement","A_Id":4047303,"CreationDate":"2010-10-28T20:20:00.000","Title":"Python 2.x: how to automate enforcing unicode instead of string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a problem with file uploading. I'm using FastCGI on Apache2 (unix) to run a WSGI-compliant application. File uploads, in the form of images, are begin saved in a MySQL database. However, larger images are being truncated at 65535 bytes. As far as I can tell, nothing should be limiting the size of the files and I'm not sure which one of the pieces in my solution would be causing the problem.\nIs it FastCGI; can it limit file upload sizes?\nIs it Python? The cgi.FieldStorage object gives me a file handle to the uploaded file which I then read: file.read(). Does this limit file sizes in any way?\nIs it MySQL? The type of the column for saving the image data is a longblob. I figured this could store a couple of GB worth of data. So a few MB shouldn't be a problem, right?\nIs it the flups WSGIServer? I can't find any information regarding this.\nMy file system can definitely handle huge files, so that's not a problem. Any ideas?\nUPDATE:\nIt is MySQL. I got python to output the number of bytes uploaded and it's greater than 65535. So I looked into max_allowed_packet for mysqld and set it to 128M. Overkill, but wanting to be sure for the moment. \nMy only problem now is getting python's MySQLdb to allow the transfer of more than 65535 bytes. Does anyone know how to do this? Might post as a separate question.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1279,"Q_Id":4047899,"Users Score":2,"Answer":"If the web server\/gateway layer were truncating incoming form submissions I'd expect an error from FieldStorage, since the truncation would not just interrupt the file upload but also the whole multipart\/form-data structure. Even if cgi.py tolerated this, it would be very unlikely to have truncated the multipart at just the right place to leave exactly 2**16-1 bytes of file upload.\nSo I would suspect MySQL. LONGBLOB should be fine up to 2**32-1, but 65535 would be the maximum length of a normal BLOB. Are you sure the types are what you think? Check with SHOW CREATE TABLE x. Which database layer are you using to get the data in?","Q_Score":3,"Tags":"python,mysql,file-upload,apache2,fastcgi","A_Id":4047955,"CreationDate":"2010-10-28T23:16:00.000","Title":"Does FastCGI or Apache2 limit upload sizes?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"what I am struggling with is testing predefined conditions which takes user provided parameters like in example below: \n\ncond = \"if ( 1 is yes and 2 is no ) or ( 1 is yes and 2 is no )\"  \ncond2 = \"if (3 is no or 1 is no )\"  \nvars = []  \n\nlst = cond.split()  \nlst += cond2.split()  \n\nfor l in lst:  \n   if l.isdigit():  \n      if l not in vars:  \n         vars.append(l)  \n# ... sort \n# ... read user answers => x = no, y = no, y = yes \n# ... replace numbers with input (yes or no)\n\n# ... finally I have \n\ncond = \"if ( no is yes and no is no ) or ( no is yes and no is no )\"\ncond2 = \"if (yes is no or no is no )\" \n\n\nFirst of all, is this the right approach?\nSecondly, how do I validate above conditions if True or False ?\nThank You in advance.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":618,"Q_Id":4059691,"Users Score":1,"Answer":"Use Python's language services to parse and compile the string, then execute the resulting AST.","Q_Score":0,"Tags":"python,validation,conditional-statements","A_Id":4059701,"CreationDate":"2010-10-30T16:53:00.000","Title":"python: how to validate userdefined condition?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"what I am struggling with is testing predefined conditions which takes user provided parameters like in example below: \n\ncond = \"if ( 1 is yes and 2 is no ) or ( 1 is yes and 2 is no )\"  \ncond2 = \"if (3 is no or 1 is no )\"  \nvars = []  \n\nlst = cond.split()  \nlst += cond2.split()  \n\nfor l in lst:  \n   if l.isdigit():  \n      if l not in vars:  \n         vars.append(l)  \n# ... sort \n# ... read user answers => x = no, y = no, y = yes \n# ... replace numbers with input (yes or no)\n\n# ... finally I have \n\ncond = \"if ( no is yes and no is no ) or ( no is yes and no is no )\"\ncond2 = \"if (yes is no or no is no )\" \n\n\nFirst of all, is this the right approach?\nSecondly, how do I validate above conditions if True or False ?\nThank You in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":618,"Q_Id":4059691,"Users Score":0,"Answer":"so, after some reading based on Ignacio's tip, I think I have it after some string modifications.  However, still not quite sure if this is the right approach.\nSo, my condition variable is defined as below  \n\ncond = \"\"\"if ( 'no' is 'yes' and 'no' is 'no' ):\n   result.append[1]\nelse:\n   result.append[0]\n\"\"\"\n\nAdditionally I create variable to store condition result to evaluate it later\n\nresult = []\n\nI run exec on my string \n\nexec(cond)\n\nFinally, I can evaluate result.\n\nif result[0] == 1\n   print \"Condition was met\"\nelse: \n   print \"Condition wasn't met\"\n\nAny thoughts or comments highly appreciated.","Q_Score":0,"Tags":"python,validation,conditional-statements","A_Id":4060569,"CreationDate":"2010-10-30T16:53:00.000","Title":"python: how to validate userdefined condition?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm experimenting with PyQT, and I was trying to figure out how to get it to work with Firebird. I built the Firebird driver, but couldn't get it to work, so I was thinking maybe I wasn't putting it in the right place. So I tried experimenting with the SQLite driver, since PyQT came with it already installed, with working examples. I figured if I renamed all the qsqlite4.dll driver files I could find, eventually the example program would stop working when I renamed the one it was actually using. That didn't work. So I tried renaming the \"site-packages\\pyqt4\\plugins\\sqldrivers\" folder to \"site-packages\\pyqt4\\plugins\\sqldrivers-old\", and that did it. The example program stopped working. So I changed the folder name back, and tried renaming all the files in the folder. But the example program started working again. Then I moved the qsqlite4.dll file to a subdirectory, and it stopped working. So I moved it back, and renamed it to blah.blah.blah. And it worked again. Then I opened up blah.blah.blah with notepad++, and deleted some stuff at the top of the file, and that kept the example program from working. So I'm confused. As far as I can tell, either Python, PyQT, QT, or Windows Vista is finding the dll, no matter what I rename it to, as long as it's in the right folder. I even tried renaming it to the name of one of the other dll's, thinking maybe that would confuse it. But it only confused me. Is this normal?\nedit: I'm thinking this has something to do with plugins","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":4068906,"Users Score":0,"Answer":"Yes, Qt plugin infrastructure is a fairly simple and robust one.\nIt attempts to load every file in sqldrivers directory. If it is successful, each dll then runs a function that registers all the features such a plugin supports.\nThen, you application initalizes. If all the features it needs are available, it works properly, otherwise, some form of error or exception handling occurs.","Q_Score":0,"Tags":"python,dll,windows-vista,qt4,pyqt4","A_Id":4453952,"CreationDate":"2010-11-01T12:37:00.000","Title":"Either Python, PyQT, QT, or Windows Vista is finding my dll, no matter what I rename it to. Is this normal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently making a 2D side-scrolling run'n'jump platform game in PyGame. Most of the stuff is working OK and very well in fact - I am exploiting the fast pyGame Sprite objects & groups.\nWhat I'm interested to know is how people usually deal with Rects for scrolling games. I obviously have a level that is much bigger than visible area, and the player, enemies, bullets etc each have their own (x,y) coordinates which describe where they are in the level.\nBut now, since we use the \"spriteGroup.draw(surface)\" call, it will not display them in the right spot unless each objects Rects have been adjusted so that the right part displays on the screen. In other words, everytime a player\/enemy\/bullet\/whatever else is updated, the Camera information needs to be passed, so that their Rect can be updated.\nIs this the best method to use? It works but I don't really like passing the camera information to every single object at every update to offset the Rects.\nObviously the ideal method (I think) is to use Rects with \"real\" coordinates, blit everything to a buffer as big as the level, and then just blit the visible part to the screen, but in practice that slows the game down A LOT.\nAny comments\/insight would be appreciated.\nThanks","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1235,"Q_Id":4073928,"Users Score":0,"Answer":"You can have a 2 variables level_landlevel_d which see where you are in the level, Then check which sprites are in the visible area\nlevel_d+height and level_l+width,\n and draw them on the screen.","Q_Score":2,"Tags":"python,scroll,2d,pygame","A_Id":14293575,"CreationDate":"2010-11-01T23:21:00.000","Title":"Pygame: Updating Rects with scrolling levels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm currently making a 2D side-scrolling run'n'jump platform game in PyGame. Most of the stuff is working OK and very well in fact - I am exploiting the fast pyGame Sprite objects & groups.\nWhat I'm interested to know is how people usually deal with Rects for scrolling games. I obviously have a level that is much bigger than visible area, and the player, enemies, bullets etc each have their own (x,y) coordinates which describe where they are in the level.\nBut now, since we use the \"spriteGroup.draw(surface)\" call, it will not display them in the right spot unless each objects Rects have been adjusted so that the right part displays on the screen. In other words, everytime a player\/enemy\/bullet\/whatever else is updated, the Camera information needs to be passed, so that their Rect can be updated.\nIs this the best method to use? It works but I don't really like passing the camera information to every single object at every update to offset the Rects.\nObviously the ideal method (I think) is to use Rects with \"real\" coordinates, blit everything to a buffer as big as the level, and then just blit the visible part to the screen, but in practice that slows the game down A LOT.\nAny comments\/insight would be appreciated.\nThanks","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1235,"Q_Id":4073928,"Users Score":0,"Answer":"One method I found is to keep track of a scrollx and a scrolly. Then, just add scrollx and scroll y to the coordinates when you move the rectangles.","Q_Score":2,"Tags":"python,scroll,2d,pygame","A_Id":14189213,"CreationDate":"2010-11-01T23:21:00.000","Title":"Pygame: Updating Rects with scrolling levels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm currently making a 2D side-scrolling run'n'jump platform game in PyGame. Most of the stuff is working OK and very well in fact - I am exploiting the fast pyGame Sprite objects & groups.\nWhat I'm interested to know is how people usually deal with Rects for scrolling games. I obviously have a level that is much bigger than visible area, and the player, enemies, bullets etc each have their own (x,y) coordinates which describe where they are in the level.\nBut now, since we use the \"spriteGroup.draw(surface)\" call, it will not display them in the right spot unless each objects Rects have been adjusted so that the right part displays on the screen. In other words, everytime a player\/enemy\/bullet\/whatever else is updated, the Camera information needs to be passed, so that their Rect can be updated.\nIs this the best method to use? It works but I don't really like passing the camera information to every single object at every update to offset the Rects.\nObviously the ideal method (I think) is to use Rects with \"real\" coordinates, blit everything to a buffer as big as the level, and then just blit the visible part to the screen, but in practice that slows the game down A LOT.\nAny comments\/insight would be appreciated.\nThanks","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":1235,"Q_Id":4073928,"Users Score":1,"Answer":"You could extend de Sprite.Group so it recives the camera information.\nThen do one of these options:\nA. Override the update method so it updates the on-screen coordinates of every sprite.\nB. Override the draw method so it updates the on-screen coordinates of every sprite and then calls its parent draw method.\nI think A it's easier and cleaner.","Q_Score":2,"Tags":"python,scroll,2d,pygame","A_Id":4077600,"CreationDate":"2010-11-01T23:21:00.000","Title":"Pygame: Updating Rects with scrolling levels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've got a problem. I Have a tool(threads manager) that receives some data and do some computation. I need to write Python client to send data to that tool...I thing I should use .NET Remoting, but how to do that?\npls share some links where I can read or post some code...I can't google info about that...\nP.S Python 2.7, NOT IronPython","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":987,"Q_Id":4076114,"Users Score":0,"Answer":"I would use XML-RPC for communication. It is very simple to implement (a couple lines of code in Python, not sure about .NET but it shouldn't be difficult there either) and should be enough in your scenario.","Q_Score":1,"Tags":"c#,python,remoting","A_Id":4077076,"CreationDate":"2010-11-02T08:49:00.000","Title":"How implement .NET server and Python client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a problem. I Have a tool(threads manager) that receives some data and do some computation. I need to write Python client to send data to that tool...I thing I should use .NET Remoting, but how to do that?\npls share some links where I can read or post some code...I can't google info about that...\nP.S Python 2.7, NOT IronPython","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":987,"Q_Id":4076114,"Users Score":1,"Answer":".Net Remoting is designed for when you have .net at both ends so will be very hard to use from the Python end.  (Event the XML encoding of .net remoting is not easy to use from other platforms)\nI am assuming that Python has support for soap, if so I would look at using WCF at the .net end running over the \u201cbasic profile\u201d.  JSON is another option, there are lots of open source projects that add JSON support to .net, I assume that Python also has JSON surport.","Q_Score":1,"Tags":"c#,python,remoting","A_Id":4076158,"CreationDate":"2010-11-02T08:49:00.000","Title":"How implement .NET server and Python client?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to extend a python code which has plenty of hard coded path\nIn order not to mess everything, I want to create unit-tests for the code before my modifications: it will serve as non-regression tests with my new code (that will not have hard-coded paths)\nBut because of hard coded system path, I shall run my test inside a chroot tree (I don't want to pollute my system dir)\nMy problem is that I want to set up the chroot only for test, and this can be done with os.chroot only with root privileges (and I don't want to run the test scripts as root)\nIn fact, I just need a fake tree diretory so that when the code that open('\/etc\/resolv.conf) retrieves a fake resolv.conf and not my system one\nI obviously don't want to replace myself the hard coded path in the code because it would not be real regression test\nDo you have any idea how to achieve this?\nThanks\nNote that all the path accessed are readable with a user accout","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":4077338,"Users Score":0,"Answer":"You could use a helper application that is setuid root to run the chroot; that would avoid the need to run the tests as root. Of course, that would probably still open up a local root exploit, so should only be done with appropriate precautions (e.g. in a VM image).\nAt any rate, any solution with chroot is inherently platform-dependent, so it's rather awkward. I actually like the idea of Dave Webb (override open) better, I must admit...","Q_Score":3,"Tags":"python,linux,unit-testing,regression","A_Id":4078021,"CreationDate":"2010-11-02T11:52:00.000","Title":"regression test dealing with hard coded path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, I have files generated by ReportLab. Now, i need to extract some pages from that PDF and hide confidential information.\nI can create a PDF file with blacked-out spots and use pyPdf to mergePage, but people can still select and copy-paste the information under the blacked-out spots.\nIs there a way to make those spots completely confidential?\nPer example, I need to hide addresses on the pages, how would i do it?\nThanks,","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1789,"Q_Id":4082725,"Users Score":1,"Answer":"Basically you'll have to remove the corresponding text drawing commands in the PDF's page content stream. It's much easier to generate the pages twice, once with the confidential information, once without them.\nIt might be possible (I don't know ReportLab enough) to specially craft the PDF in a way that the confidential information is easier accessible (e.g. as separate XObjects) for deletion. Still you'd have to do pretty low-level operations on the PDF -- which I would advise against.","Q_Score":1,"Tags":"python,reportlab,pypdf","A_Id":4082827,"CreationDate":"2010-11-02T22:37:00.000","Title":"Hide information in a PDF file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, I have files generated by ReportLab. Now, i need to extract some pages from that PDF and hide confidential information.\nI can create a PDF file with blacked-out spots and use pyPdf to mergePage, but people can still select and copy-paste the information under the blacked-out spots.\nIs there a way to make those spots completely confidential?\nPer example, I need to hide addresses on the pages, how would i do it?\nThanks,","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1789,"Q_Id":4082725,"Users Score":0,"Answer":"(Sorry, I was not able to log on when I posted the question...)\nUnfortunately, the document cannot be regenerated at will (context sensitive), and those PDF files (about 35) are 3000+ pages.\nI was thinking about using pdf2ps and pdf2ps back, but there is a lot of quality.\npdf2ps -dLanguageLevel=3 input.pdf - | ps2pdf14 - output.pdf\nAnd if i use \"pdftops\" instead, the text is still selectable. If there is a way to make it non-selectable like with \"pdf2ps\" but with better quality, it will do too.","Q_Score":1,"Tags":"python,reportlab,pypdf","A_Id":4083017,"CreationDate":"2010-11-02T22:37:00.000","Title":"Hide information in a PDF file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to look at some good web-app code written in python, just so I can learn some of the patterns \/ see how I can improve my code.\nI've already googled around a bit, used google code search and run a search on github too - but haven't come across a well built, comprehensive app.\nPerhaps a book could work as well. Basically, I'm just trying to find a way to learn the basic programming patterns for web-applications.\nAny suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1700,"Q_Id":4083440,"Users Score":0,"Answer":"IMHO your time would be better invested learning something like Django, because much of what you could improve in a micro framework is already builtin on a bigger framework.","Q_Score":0,"Tags":"python,web-applications,flask","A_Id":4083522,"CreationDate":"2010-11-03T01:07:00.000","Title":"Great flask \/ other python micro framework code I could learn from","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable.\nI know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too.\nMany thanks","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":1743,"Q_Id":4086675,"Users Score":3,"Answer":"The Python scripts are reasonably portable, as long as the interpreter and relevant libraries are installed. Generated .exe and .app files are not.","Q_Score":1,"Tags":"python,portability,pygame","A_Id":4086715,"CreationDate":"2010-11-03T11:44:00.000","Title":"Portable Python (Mac -> Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable.\nI know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too.\nMany thanks","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1743,"Q_Id":4086675,"Users Score":0,"Answer":"If you are planning to include Linux in your portability criteria, it's worth remembering that many distributions still package 2.6 (or even 2.5), and will probably be a version behind in the 3.x series as well (I'm assuming your using 2.x given the PyGame requirement though).\nVersions of PyGame seem to vary quite heavily between distros as well.","Q_Score":1,"Tags":"python,portability,pygame","A_Id":4087087,"CreationDate":"2010-11-03T11:44:00.000","Title":"Portable Python (Mac -> Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable.\nI know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too.\nMany thanks","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1743,"Q_Id":4086675,"Users Score":0,"Answer":"Personally I experienced huge difficult with all the Exe builder, py2exe , cx_freeze etc. Bugs and errors all the time , keep displaying an issue with atexit module.\nI find just by including the python distro way more convinient. There is one more advantage beside ease of use. \nEach time you build an EXE for a python app, what you essential do is include the core of the python installation but only with the modules your app is using. But even in that case your app may increase from a mere few Kbs that the a python module is to more than 15 mbs because of the inclusion of python installation. \nOf course installing the whole python will take more space but each time you send your python apps they will be only few kbs long. Plus you want have to go to the hussle of bundling the exe each time you change even a coma to your python app. Or I think you do , I dont know if just replacing the py module can help you avoid this.\nIn any case installing python and pygame is as easy as installing any other application in windows. In linux via synaptic is also extremly easy. \nMACOS is abit tricky though. MACOS already come with python pre installed, Snow leopard has 2.6.1 python installed. However if you app is using a python later than that and include the install of python with your app, you will have to instruct the user to set via \"GET INFO -> open with\" the python launcher app which is responsible for launcing python apps to use your version of python and not the onboard default 2.6.1 version, Its not difficult and it only takes a few seconds, even a clueless user can do this. \nPython is extremely portable, python pygame apps cannot only run unchanged to the three major platform , Windows , MACOS ,Linux . They can even run on mobile and portable devices as well. If you need to build app that runs across platform , python is dead easy and highly recomended.","Q_Score":1,"Tags":"python,portability,pygame","A_Id":4153679,"CreationDate":"2010-11-03T11:44:00.000","Title":"Portable Python (Mac -> Windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a rather simple program that writes HTML code ready for use. \nIt works fine, except that if one were to run the program from the Python command line, as is the default, the HTML file that is created is created where python.exe is, not where the program I wrote is. And that's a problem.   \nDo you know a way of getting the .write() function to write a file to a specific location on the disc (e.g. C:\\Users\\User\\Desktop)? \nExtra cool-points if you know how to open a file browser window.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2983,"Q_Id":4093387,"Users Score":0,"Answer":"I'll admit I don't know Python 3, so I may be wrong, but in Python 2, you can just check the __file__ variable in your module to get the name of the file it was loaded from. Just create your file in that same directory (preferably using os.path.dirname and os.path.join to remain platform-independent).","Q_Score":0,"Tags":"python","A_Id":4093406,"CreationDate":"2010-11-04T02:22:00.000","Title":"Python3:Save File to Specified Location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a file dialog that allows the user to save a file after editing it in my app. I want to add a checkbox to the dialog so the user can make some choices about what format the file is saved in. I think I need to make some new class that inherits from FileDialog and inserts a checkbox into the frame created by the filedialog, but I don't really know how to do that. Can anyone help me out?\n(I also want to create an analogous file dialog for opening a file, but I assume that will just mean replacing the SAVE style with the OPEN style.)","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2300,"Q_Id":4093819,"Users Score":2,"Answer":"In wxWidgets 2.9 custom controls can be added to file dialogs using wxFileDialog::SetExtraControlCreator(). It's implemented for GTK, MSW and generic dialogs.\nAlternatively, you may use the wxFileCtrl class. It has native implementation only in wxGTK.\nI don't know if these features is available from Python wrappers, though.","Q_Score":2,"Tags":"wxpython,wxwidgets,openfiledialog,savefiledialog,filedialog","A_Id":5943314,"CreationDate":"2010-11-04T04:07:00.000","Title":"How do I add widgets to a file dialog in wxpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a file dialog that allows the user to save a file after editing it in my app. I want to add a checkbox to the dialog so the user can make some choices about what format the file is saved in. I think I need to make some new class that inherits from FileDialog and inserts a checkbox into the frame created by the filedialog, but I don't really know how to do that. Can anyone help me out?\n(I also want to create an analogous file dialog for opening a file, but I assume that will just mean replacing the SAVE style with the OPEN style.)","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2300,"Q_Id":4093819,"Users Score":2,"Answer":"I have to disagree with the sentiment that you should use standard dialogs only how they were designed.\nI take another view and would rather look at using subclassing the way that subclassing was intended.  And to me, it is to add additional functionality\/specialization to a class.\nSo it is not changing the behavior of the standard dialog.  It is creating a new dialog BASED ON the standard dialog with a little additional functionality.\nIn my case, I want to add two buttons to the wx.MultiChoiceDialog to provide a Select All and\/or Unselect All functions.","Q_Score":2,"Tags":"wxpython,wxwidgets,openfiledialog,savefiledialog,filedialog","A_Id":12428450,"CreationDate":"2010-11-04T04:07:00.000","Title":"How do I add widgets to a file dialog in wxpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"could anyone please provide on how to achieve below scenario ?\n2 queues - destination queue, response queue\nthread picks task up from destination queue\nfinds out needs more details\nsubmits new task to destination queue\nwaits for his request to be processed and result appear in response queue\nor\nmonitors response queue for response to his task but does not actually pick any response so it is available to the other threads waiting for other responses ? \nthank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1230,"Q_Id":4095925,"Users Score":1,"Answer":"If a threads waits for a specific task completion, i.e it shouldn't pick any completed task except that one it put, you can use locks to wait for the task:\n\n  def run(self):\n    # get a task, do somethings, put a new task\n    newTask.waitFor()\n    ...\nclass Task:\n  ...\n  def waitFor(self):\n    self._lock.acquire()\ndef complete(self):\n    self._lock.release()\ndef failedToComplete(self, err):\n    self._error = err\n    self._lock.release()\n\nThis will help to avoid time.sleep()-s on response queue monitoring. Task completion errors handling should be considered here. But this is uncommon approach. Is it some specific algorithm where the thread which puts a new task, should wait for it? Even so, you can implement that logic into a Task class, and not in the thread that processes it. And why the thread picks a task from the destination queue and puts a new task back to the destination queue? If you have n steps of processing, you can use n queues for it. A group of threads serves the first queue, gets a task, processes it, puts the result (a new task) to the next queue. The group of final response-handler threads gets a response and sends it back to the client. The tasks encapsulate details concerning themselves, the threads don't distinguish a task from another. And there is not need to wait for a particular task.","Q_Score":0,"Tags":"python,multithreading,queue","A_Id":4096149,"CreationDate":"2010-11-04T10:55:00.000","Title":"python: how to make threads wait for specific response?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing an app in Python for Google App Engine.\nWhen I run the deployed app from appspot, it works fine unless I'm accessing it for the first time in over, say, 5 minutes.  The problem is that if I haven't accessed the app for a while, the page renders with the message \n\nStatus: 200 OK Content-Type: text\/html; charset=utf-8 Cache-Control: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Content-Length: 15493\n\nprepended at the top.  Usually that text is displayed for a second or two before the rest of the page is displayed.\nIf I check the server Logs, I see the info message\n\nThis request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time.\n\nThe problem is easily corrected by refreshing the page.  In this case, the page is delivered correctly, and works for subsequent refreshes.  But if I wait 5 minutes, the problem comes back.\nAny explanations, or suggestions on how to troubleshoot this?  I've got a vague notion that when GAE \"wakes up\" after being inactive, there is an incorrect initialization going on.  Or perhaps a header from a previous bout of activity is lingering in a buffer somewhere.  But self.response.out seems to be empty when the request handler is invoked.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":108,"Q_Id":4098119,"Users Score":6,"Answer":"Somewhere in your top level module code is something that uses Python print statements. Print outputs to standard out, which is what is returned as the response body; if it outputs a pair of newlines, the content before that is treated by the browser as the response header. The 'junk' you're seeing is the real response headers being produced by your webapp.\nIt's only happening on startup requests, because that's the only time the code in question gets executed.","Q_Score":1,"Tags":"python,google-app-engine","A_Id":4098417,"CreationDate":"2010-11-04T15:15:00.000","Title":"Google App Engine gives spurious content at beginning of page after quiescent period","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing and distributed image processing application using hadoop streaming, python, matlab, and elastic map reduce. I have compiled a binary executable of my matlab code using the matlab compiler. I am wondering how I can incorporate this into my workflow so the binary is part of the processing on Amazon's elastic map reduce?\nIt looks like I have to use the Hadoop Distributed Cache?\nThe code is very complicated (and not written by me) so porting it to another language is not possible right now.\nTHanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1138,"Q_Id":4101815,"Users Score":0,"Answer":"The following is not exactly an answer to your Hadoop question, but I couldn't resist not asking why you don't execute your processing jobs on the Grid resources? There are proven solutions for executing compute intensive workflows on the Grid. And as far as I know matlab runtime environment is usually available on these resources. You may also consider using the Grid especially if you are in academia.\nGood luck","Q_Score":1,"Tags":"python,matlab,amazon-web-services,hadoop,mapreduce","A_Id":4101917,"CreationDate":"2010-11-04T22:01:00.000","Title":"Hadoop\/Elastic Map Reduce with binary executable?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using windows for the first time in quite awhile and have picked up notepad++ and am using the nppexec plugin to run python scripts. However, I noticed that notepad++ doesn't pick up the directory that my script is saved in. For example, I place \"script.py\" in 'My Documents' however os.getcwd() prints \"Program Files \\ Notepad++\"\nDoes anyone know how to change this behavior? Not exactly used to it in Mac.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4494,"Q_Id":4103085,"Users Score":15,"Answer":"Notepad++ >nppexec >follow $(current directory)","Q_Score":6,"Tags":"python,notepad++,nppexec","A_Id":4106339,"CreationDate":"2010-11-05T02:15:00.000","Title":"Getting NppExec to understand path of the current file in Notepad++  (for Python scripts)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you take things like the poll app from the tutorial and display them in an iframe or frameset? The tutorial is great and the app is very nice, but, how often do you go to a site with a whole page dedicated to a poll? I was trying to think about how you do it using the urls.py file, but couldn't wrap my head around it. Just wondering if anyone has done this or knows of any tutorials that cover this issue? Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":4107644,"Users Score":0,"Answer":"Put the poll page in its own view, connect to the view via urls.py, and set up your frame or iframe to source from that URL.","Q_Score":0,"Tags":"python,django","A_Id":4107663,"CreationDate":"2010-11-05T15:57:00.000","Title":"Django Question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I don't really want to know Django I am actually more interested in the administrator. The thing that interests me is how they introspect the models to create the administrator back-end.\nI browsed through the Django source code and found a little info but since it's such a big project I was wondering if there are smaller examples of how they do it? \nThis is just a personal project to get to understand Python better. I thought that learning about introspecting objects would be a good way to do this.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":4108852,"Users Score":4,"Answer":"With Django it's a bit more than introspection actually. The models use a metaclass to register themselves, I will spare you the complexities of everything involved but the admin does not introspect the models as you browse through it.\nInstead, the registering process creates a _meta object on the model with all the data needed for the admin and ORM. You can see the ModelBase metaclass in django\/db\/models\/base.py, as you can see in the __new__ function it walks through all the fields to add them to the _meta object. The _meta object itself is generated dynamically using the Meta class definition on the model.\nYou can see the result with print SomeModel._meta or print SomeModel._meta.fields","Q_Score":0,"Tags":"python,django","A_Id":4108925,"CreationDate":"2010-11-05T18:22:00.000","Title":"Django's introspecting administrator: How does it work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for suggestions on how one might implement a toolbar that provides edit cut, copy, paste commands using the Tkinter framework. I understand how to build a toolbar and bind the toolbar commands, but I'm confused over how the toolbar button bound commands will know which widget to apply the cut, copy, or paste action because the widget with edit activity will lose focus when the toolbar button is clicked. My first thought was to have each widget with potential edit activity set a global variable when the widget gains focus and have other widgets (without edit activity, eg. buttons, sliders, checkbox\/radiobox, etc) clear this global variable. But this sounds complicated to maintain unless I build a framework of widgets that inherit this behavior.\nIs there a simpler way to go about this or am I on the right track?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1053,"Q_Id":4111049,"Users Score":2,"Answer":"You don't have to maintain a big framework, you can create a single binding on the root widget for <FocusIn> and put all the logic in that binding. Or, use focus_class and bind to the class all. \nBinding on the root will only affect children of the root, binding to all will affect all widgets in the entire app.  That only matters if you have more than one toplevel widget.","Q_Score":0,"Tags":"python,tkinter,clipboard,toolbar","A_Id":4111218,"CreationDate":"2010-11-05T23:48:00.000","Title":"Python\/Tkinter: Building a toolbar that provides edit cut, copy, paste commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for suggestions on how one might implement a toolbar that provides edit cut, copy, paste commands using the Tkinter framework. I understand how to build a toolbar and bind the toolbar commands, but I'm confused over how the toolbar button bound commands will know which widget to apply the cut, copy, or paste action because the widget with edit activity will lose focus when the toolbar button is clicked. My first thought was to have each widget with potential edit activity set a global variable when the widget gains focus and have other widgets (without edit activity, eg. buttons, sliders, checkbox\/radiobox, etc) clear this global variable. But this sounds complicated to maintain unless I build a framework of widgets that inherit this behavior.\nIs there a simpler way to go about this or am I on the right track?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1053,"Q_Id":4111049,"Users Score":1,"Answer":"You can tell the toolbar buttons to not take the focus; it's a configuration option and no UI guidelines I've ever seen have had toolbar buttons with focus. (Instead, the functionality is always available through some other keyboard-activatable mechanism, e.g., a hotkey combo.)","Q_Score":0,"Tags":"python,tkinter,clipboard,toolbar","A_Id":4111334,"CreationDate":"2010-11-05T23:48:00.000","Title":"Python\/Tkinter: Building a toolbar that provides edit cut, copy, paste commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i update a shared variable between different threading.Thread in python?\nlets say that i have 5 threads working down a Queue.Queue(). after the queue is done i want to do an other operation but i want it to happen only once.\nis it possible to share and update a variable betweeen the threads. so when Queue.empty() is True this event gets fired but if one of the threads is doing it i dont want the others to do do that too because i would get wrong results. \nEDIT\ni have a queue which reflects files on the filesystem. \nthe files are uploaded to a site by the threads and while each thread is uploading the file it updates a set() of keywords i got from the files.\nwhen the queue is empty i need to contact the site and tell it to update the keyword counts. right now each thread does this and i get an update for each thread which is bad. \ni also tried to empty the set but it doesnt work.\n    keywordset = set()\n    hkeywordset = set()\n    def worker():\n        while queue:\n            if queue.empty():\n                if len(keywordset) or len(hkeywordset):\n                    # as soon as the queue is empty we send the keywords and hkeywords to the\n                    # imageapp so it can start updating \n                    apiurl   = update_cols_url\n                    if apiurl[-1] != '\/':\n                        apiurl = apiurl+'\/'\n                    try:\n                        keywords = []\n                        data = dict(keywords=list(keywordset), hkeywords=list(hkeywordset))\n                        post = dict(data=simplejson.dumps(data))\n                        post = urllib.urlencode(post)\n                        urllib2.urlopen(apiurl, post)\n                        hkeywordset.clear()\n                        keywordset.clear()\n                        print 'sent keywords and hkeywords to imageapp...'\n                    except Exception, e: print e\n            # we get the task form the Queue and process the file based on the action\n            task = queue.get()\n            print str(task)\n            try:\n                reindex = task['reindex']\n            except:\n                reindex = False\n            data = updater.process_file(task['filename'], task['action'], task['fnamechange'], reindex)\n            # we parse the images keywords and hkeywords and add them to the sets above for later \n            # processing\n            try:\n                for keyword in data['keywords']:\n                    keywordset.add(keyword)\n            except: pass\n            try:\n                for hkw in data['hkeywords']:\n                        hkeywordset.add(hkw)\n            except:pass\n            queue.task_done()\n\n\n    for i in range(num_worker_threads):\n        t = threading.Thread(target=worker)\n        t.daemon = True\n        t.start()\n\n    while 1:\n        line = raw_input('type \\'q\\' to stop filewatcher... or \\'qq\\' to force quit...\\n').strip()\nthis is what i was trying basically. but of course the part of queue.empty() gets exectued as many times as threads i have.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3372,"Q_Id":4115033,"Users Score":0,"Answer":"Why can't you just add the final step to the queue ?","Q_Score":0,"Tags":"python,thread-safety,queue","A_Id":4115106,"CreationDate":"2010-11-06T20:34:00.000","Title":"python threading and shared variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i update a shared variable between different threading.Thread in python?\nlets say that i have 5 threads working down a Queue.Queue(). after the queue is done i want to do an other operation but i want it to happen only once.\nis it possible to share and update a variable betweeen the threads. so when Queue.empty() is True this event gets fired but if one of the threads is doing it i dont want the others to do do that too because i would get wrong results. \nEDIT\ni have a queue which reflects files on the filesystem. \nthe files are uploaded to a site by the threads and while each thread is uploading the file it updates a set() of keywords i got from the files.\nwhen the queue is empty i need to contact the site and tell it to update the keyword counts. right now each thread does this and i get an update for each thread which is bad. \ni also tried to empty the set but it doesnt work.\n    keywordset = set()\n    hkeywordset = set()\n    def worker():\n        while queue:\n            if queue.empty():\n                if len(keywordset) or len(hkeywordset):\n                    # as soon as the queue is empty we send the keywords and hkeywords to the\n                    # imageapp so it can start updating \n                    apiurl   = update_cols_url\n                    if apiurl[-1] != '\/':\n                        apiurl = apiurl+'\/'\n                    try:\n                        keywords = []\n                        data = dict(keywords=list(keywordset), hkeywords=list(hkeywordset))\n                        post = dict(data=simplejson.dumps(data))\n                        post = urllib.urlencode(post)\n                        urllib2.urlopen(apiurl, post)\n                        hkeywordset.clear()\n                        keywordset.clear()\n                        print 'sent keywords and hkeywords to imageapp...'\n                    except Exception, e: print e\n            # we get the task form the Queue and process the file based on the action\n            task = queue.get()\n            print str(task)\n            try:\n                reindex = task['reindex']\n            except:\n                reindex = False\n            data = updater.process_file(task['filename'], task['action'], task['fnamechange'], reindex)\n            # we parse the images keywords and hkeywords and add them to the sets above for later \n            # processing\n            try:\n                for keyword in data['keywords']:\n                    keywordset.add(keyword)\n            except: pass\n            try:\n                for hkw in data['hkeywords']:\n                        hkeywordset.add(hkw)\n            except:pass\n            queue.task_done()\n\n\n    for i in range(num_worker_threads):\n        t = threading.Thread(target=worker)\n        t.daemon = True\n        t.start()\n\n    while 1:\n        line = raw_input('type \\'q\\' to stop filewatcher... or \\'qq\\' to force quit...\\n').strip()\nthis is what i was trying basically. but of course the part of queue.empty() gets exectued as many times as threads i have.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3372,"Q_Id":4115033,"Users Score":0,"Answer":"Have another queue where you place this event after first queue is empty.\nOr have special thread for this event.","Q_Score":0,"Tags":"python,thread-safety,queue","A_Id":4115111,"CreationDate":"2010-11-06T20:34:00.000","Title":"python threading and shared variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey, I'd like to know how to upload my zope site on my ftp. I have a domain, and I like to upload it, like a upload normal files on my ftp. \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":175,"Q_Id":4126247,"Users Score":2,"Answer":"You can upload zope the same way you would upload anything else, but it's not suitable for deploying on many shared webhosts as many of them would not like you running the zope process due to the ammount of resources it can consume\nYou are best off trying to find a webhost that supports zope or to use a VPS","Q_Score":0,"Tags":"python,frameworks,zope,zope.interface","A_Id":4126734,"CreationDate":"2010-11-08T17:19:00.000","Title":"How to upload zope site on my ftp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I noticed that a significant part of my (pure Python) code deals with tables. Of course, I have class Table which supports the basic functionality, but I end up adding more and more features to it, such as queries, validation, sorting, indexing, etc.\nI to wonder if it's a good idea to remove my class Table, and refactor the code to use a regular relational database that I will instantiate  in-memory.\nHere's my thinking so far:\n\nPerformance of queries and indexing would improve but communication between Python code and the separate database process might be less efficient than between Python functions. I assume that is too much overhead, so I would have to go with sqlite which comes with Python and lives in the same process. I hope this means it's a pure performance gain (at the cost of non-standard SQL definition and limited features of sqlite).\nWith SQL, I will get a lot more powerful features than I would ever want to code myself. Seems like a clear advantage (even with sqlite).\nI won't need to debug my own implementation of tables, but debugging mistakes in SQL are hard since I can't put breakpoints or easily print out interim state. I don't know how to judge the overall impact of my code reliability and debugging time.\nThe code will be easier to read, since instead of calling my own custom methods I would write SQL (everyone who needs to maintain this code knows SQL). However, the Python code to deal with database might be uglier and more complex than the code that uses pure Python class Table. Again, I don't know which is better on balance.\n\nAny corrections to the above, or anything else I should think about?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":903,"Q_Id":4136800,"Users Score":5,"Answer":"SQLite does not run in a separate process. So you don't actually have any extra overhead from IPC. But IPC overhead isn't that big, anyway, especially over e.g., UNIX sockets. If you need multiple writers (more than one process\/thread writing to the database simultaneously), the locking overhead is probably worse, and MySQL or PostgreSQL would perform better, especially if running on the same machine. The basic SQL supported by all three of these databases is the same, so benchmarking isn't that painful.\nYou generally don't have to do the same type of debugging on SQL statements as you do on your own implementation. SQLite works, and is fairly well debugged already. It is very unlikely that you'll ever have to debug \"OK, that row exists, why doesn't the database find it?\" and track down a bug in index updating. Debugging SQL is completely different than procedural code, and really only ever happens for pretty complicated queries.\nAs for debugging your code, you can fairly easily centralize your SQL calls and add tracing to log the queries you are running, the results you get back, etc. The Python SQLite interface may already have this (not sure, I normally use Perl). It'll probably be easiest to just make your existing Table class a wrapper around SQLite.\nI would strongly recommend not reinventing the wheel. SQLite will have far fewer bugs, and save you a bunch of time. (You may also want to look into Firefox's fairly recent switch to using SQLite to store history, etc., I think they got some pretty significant speedups from doing so.)\nAlso, SQLite's well-optimized C implementation is probably quite a bit faster than any pure Python implementation.","Q_Score":4,"Tags":"python,performance,sqlite","A_Id":4136841,"CreationDate":"2010-11-09T17:49:00.000","Title":"Pros and cons of using sqlite3 vs custom table implementation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I noticed that a significant part of my (pure Python) code deals with tables. Of course, I have class Table which supports the basic functionality, but I end up adding more and more features to it, such as queries, validation, sorting, indexing, etc.\nI to wonder if it's a good idea to remove my class Table, and refactor the code to use a regular relational database that I will instantiate  in-memory.\nHere's my thinking so far:\n\nPerformance of queries and indexing would improve but communication between Python code and the separate database process might be less efficient than between Python functions. I assume that is too much overhead, so I would have to go with sqlite which comes with Python and lives in the same process. I hope this means it's a pure performance gain (at the cost of non-standard SQL definition and limited features of sqlite).\nWith SQL, I will get a lot more powerful features than I would ever want to code myself. Seems like a clear advantage (even with sqlite).\nI won't need to debug my own implementation of tables, but debugging mistakes in SQL are hard since I can't put breakpoints or easily print out interim state. I don't know how to judge the overall impact of my code reliability and debugging time.\nThe code will be easier to read, since instead of calling my own custom methods I would write SQL (everyone who needs to maintain this code knows SQL). However, the Python code to deal with database might be uglier and more complex than the code that uses pure Python class Table. Again, I don't know which is better on balance.\n\nAny corrections to the above, or anything else I should think about?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":903,"Q_Id":4136800,"Users Score":4,"Answer":"You could try to make a sqlite wrapper with the same interface as your class Table, so that you keep your code clean and you get the sqlite performences.","Q_Score":4,"Tags":"python,performance,sqlite","A_Id":4136876,"CreationDate":"2010-11-09T17:49:00.000","Title":"Pros and cons of using sqlite3 vs custom table implementation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I noticed that a significant part of my (pure Python) code deals with tables. Of course, I have class Table which supports the basic functionality, but I end up adding more and more features to it, such as queries, validation, sorting, indexing, etc.\nI to wonder if it's a good idea to remove my class Table, and refactor the code to use a regular relational database that I will instantiate  in-memory.\nHere's my thinking so far:\n\nPerformance of queries and indexing would improve but communication between Python code and the separate database process might be less efficient than between Python functions. I assume that is too much overhead, so I would have to go with sqlite which comes with Python and lives in the same process. I hope this means it's a pure performance gain (at the cost of non-standard SQL definition and limited features of sqlite).\nWith SQL, I will get a lot more powerful features than I would ever want to code myself. Seems like a clear advantage (even with sqlite).\nI won't need to debug my own implementation of tables, but debugging mistakes in SQL are hard since I can't put breakpoints or easily print out interim state. I don't know how to judge the overall impact of my code reliability and debugging time.\nThe code will be easier to read, since instead of calling my own custom methods I would write SQL (everyone who needs to maintain this code knows SQL). However, the Python code to deal with database might be uglier and more complex than the code that uses pure Python class Table. Again, I don't know which is better on balance.\n\nAny corrections to the above, or anything else I should think about?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":903,"Q_Id":4136800,"Users Score":0,"Answer":"If you're doing database work, use a database, if your not, then don't. Using tables, it sound's like you are. I'd recommend using an ORM to make it more pythonic. SQLAlchemy is the most flexible (though it's not strictly just an ORM).","Q_Score":4,"Tags":"python,performance,sqlite","A_Id":4136862,"CreationDate":"2010-11-09T17:49:00.000","Title":"Pros and cons of using sqlite3 vs custom table implementation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Anybody know how this can be done?  I took a look at cx_Freeze, but it seems that it doesn't compile everything necessary into one binary (i.e., the python builtins aren't present).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3222,"Q_Id":4138886,"Users Score":4,"Answer":"The standard freeze tool (from Tools\/freeze) can be used to make fully-standalone binaries on Unix, including all extension modules and builtins (and omitting anything that is not directly or indirectly imported).","Q_Score":2,"Tags":"python,linux,unix,cross-compiling","A_Id":4139691,"CreationDate":"2010-11-09T21:35:00.000","Title":"How to create Unix and Linux binaries from Python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do I change the version of Python that emacs uses in the python-mode to the latest version that I just installed ?\nI tried setting the PATH in my init.el file to the path where the latest version of python resides but its not working.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":811,"Q_Id":4140943,"Users Score":0,"Answer":"PATH is only searched when a program is launched via the shell.\nFor programs that are launched directly by Emacs (for example, via call-process), it's the exec-path variable that is searched.","Q_Score":1,"Tags":"python,emacs","A_Id":4143655,"CreationDate":"2010-11-10T03:20:00.000","Title":"Emacs on Mac for Python - python-mode keeps using the default Python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do I change the version of Python that emacs uses in the python-mode to the latest version that I just installed ?\nI tried setting the PATH in my init.el file to the path where the latest version of python resides but its not working.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":811,"Q_Id":4140943,"Users Score":1,"Answer":"Set the variable python-python-command. This can be done via customize:\n\nM-x customize-option RET python-python-command RET\nChange the value to point to the appropriate binary.","Q_Score":1,"Tags":"python,emacs","A_Id":4141003,"CreationDate":"2010-11-10T03:20:00.000","Title":"Emacs on Mac for Python - python-mode keeps using the default Python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to access any element in a web page. I know how to do that when I have a form (form = cgi.FieldStorage()), but not when I have, for example, a table.\nHow can I do that?\nThanks","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":4149598,"Users Score":0,"Answer":"You can access only data, posted by form (or as GET parameters).\nSo, you can extract data you need using JavaScript and post it through form","Q_Score":0,"Tags":"python,cgi,html-parsing","A_Id":4149742,"CreationDate":"2010-11-10T22:07:00.000","Title":"How can I access any element in a web page with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some script that loads a lot of data to memory.\nI want to know how efficient the data stored in memory. \nSo, I want to be able to know how many memory was used by python before I loaded data, and after I loaded data.\nAlso I wondering, if it is some way to check memory usage of complex object.\nLet say i have nested dictionary with different types of data inside. How can i know how many memory used by all data in this dictionary.\nThanks,\nAlex","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":950,"Q_Id":4155126,"Users Score":5,"Answer":"As far as I know there is no easy way to see what the memory consumption of a certain object is. It would be a non-trivial thing to do because references could be shared among objects.\nHere are my two favourite workarounds:\n\nUse the process manager. Have the program pause for before allocation. Write down the memory used before allocation. Allocate. Write down memory after allocation. It's a low-tech method but it works.\nAlternatively you can use pickle.dump to serialize your data structure. The resulting pickle will be comparable (not identical!) in size to the space needed to store the data structure in memory. For better results, use the binary pickle protocol.","Q_Score":3,"Tags":"python,windows,memory-management","A_Id":4155299,"CreationDate":"2010-11-11T14:00:00.000","Title":"How to find total amount of memory used by python process\/object in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some script that loads a lot of data to memory.\nI want to know how efficient the data stored in memory. \nSo, I want to be able to know how many memory was used by python before I loaded data, and after I loaded data.\nAlso I wondering, if it is some way to check memory usage of complex object.\nLet say i have nested dictionary with different types of data inside. How can i know how many memory used by all data in this dictionary.\nThanks,\nAlex","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":950,"Q_Id":4155126,"Users Score":0,"Answer":"An alternative is that you could use windows's performance counters through pywin32","Q_Score":3,"Tags":"python,windows,memory-management","A_Id":4187961,"CreationDate":"2010-11-11T14:00:00.000","Title":"How to find total amount of memory used by python process\/object in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to get more than 9 subplots in matplotlib?\nI am on the subplots command pylab.subplot(449); how can I get a 4410 to work?\nThank you very much.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28836,"Q_Id":4158367,"Users Score":72,"Answer":"It was easier than I expected, I just did: pylab.subplot(4,4,10) and it worked.","Q_Score":51,"Tags":"python,charts,matplotlib","A_Id":4158455,"CreationDate":"2010-11-11T19:19:00.000","Title":"more than 9 subplots in matplotlib","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to convert my homegrown task queue system into a Celery-based task queue, but one feature I currently have is causing me some distress.\nRight now, my task queue operates very coarsely; I run the job (which generates data and uploads it to another server), collect the logging using a variant on Nose's log capture library, and then I store the logging for the task as a detailed result record in the application database.\nI would like to break this down as three tasks:\n\ncollect data\nupload data\nreport results (including all logging from the preceding two tasks)\n\nThe real kicker here is the logging collection. Right now, using the log capture, I have a series of log records for each log call made during the data generation and upload process. These are required for diagnostic purposes.  Given that the tasks are not even guaranteed to run in the same process, it's not clear how I would accomplish this in a Celery task queue.\nMy ideal solution to this problem will be a trivial and ideally minimally invasive method of capturing all logging during the predecessor tasks (1, 2) and making it available to the reporter task (3)\nAm I best off remaining fairly coarse-grained with my task definition, and putting all of this work in one task? or is there a way to pass the existing captured logging around in order to collect it at the end?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1306,"Q_Id":4158758,"Users Score":0,"Answer":"It sounds like some kind of 'watcher' would be ideal. If you can watch and consume the logs as a stream you could slurp the results as they come in. Since the watcher would be running seperately and therefore have no dependencies with respect to what it is watching I believe this would satisfy your requirements for a non-invasive solution.","Q_Score":5,"Tags":"python,logging,message-queue,task,celery","A_Id":4440220,"CreationDate":"2010-11-11T20:03:00.000","Title":"How can I capture all of the python log records generated during the execution of a series of Celery tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create new work document from sketch with Python on Linux platform, but do not know how to do that.\nI do not willing to use RTF or use pythondocx to create docx document. Is there any other way to do so? Remember, I need the document keeps the formatting. \nThanks everyone's help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4741,"Q_Id":4171555,"Users Score":1,"Answer":"Openoffice has some Python scripting ability. I only heard about it, haven't studied it nor used it.","Q_Score":1,"Tags":"python,linux,ms-word","A_Id":4171572,"CreationDate":"2010-11-13T08:01:00.000","Title":"How to create a well-formatted word document(.DOC) in python on Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for tutorials and\/or examples of certain components of a social network web app that may include Python code examples of:\n\nuser account auto-gen function(database)\nfriend\/follow function (Twitter\/Facebook style)\nmessaging\/reply function (Twitter style)\nlive chat function (Facebook style)\nblog function\npublic forums (like Get Satisfaction or Stack Overflow)\nprofile page template auto-gen function\n\nI just want to start getting my head around how Python can be used to make these features. I am not looking for a solution like Pinax since  it is built upon Django and I will be ultimately using Pylons or just straight up Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2075,"Q_Id":4173883,"Users Score":5,"Answer":"So you're not interested in a fixed solution but want to program it yourself, do I get that correctly? If not: Go with a fixed solution. This will be a lot of programming effort, and whatever you want to do afterwards, doing it in another framework than you intended will be a much smaller problem.\nBut if you're actually interested in the programming experience, and you haven't found any tutorials googling for, say \"messaging python tutorial\", then that's because these are large-scale projects,- if you describe a project of this size, you're so many miles above actual lines of code that the concrete programming language almost doesn't matter (or at least you don't get stuck with the details). So you need to break these things down into smaller components. \nFor example, the friend\/follow function: How to insert stuff into a table with a user id, how to keep a table of follow-relations, how to query for a user all texts from people she's following (of course there's also some infrastructural issues if you hit >100.000 people, but you get the idea ;). Then you can ask yourself, which is the part of this which I don't know how to do in Python? If your problem, on the other hand, is breaking down the problems into these subproblems, you need to start looking for help on that, but that's probably not language specific (so you might just want to start googling for \"architecture friend feed\" or whatever). Also, you could ask that here (beware, each bullet point makes for a huge question in itself ;). Finally, you could get into the Pinax code (don't know it but I assume it's open source) and see how they're doing it. You could try porting some of their stuff to Pylons, for example, so you don't have to reinvent their wheel, learn how they do it, end up in the framework you wanted and maybe even create something reusable by others.\nsorry for tl;dr, that's because I don't have a concrete URL to point you to!","Q_Score":3,"Tags":"python,social-networking,pylons,get-satisfaction","A_Id":4174212,"CreationDate":"2010-11-13T17:49:00.000","Title":"Where can I find Python code examples, or tutorials, of social networking style functions\/components?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django-nonrel for Google App Engine and I was wondering if it's possible to use Django's built-in mail API instead of GAE's mail API for sending mail. If it is, how do I do it?\nSorry if this seems like a noob question. I just started learning Django and GAE recently and I can't work out this problem that I have by myself.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":670,"Q_Id":4177907,"Users Score":3,"Answer":"Yes, djangoappengine has a mail backend for GAE and it's enabled by default in your settings.py via \"from djangoappengine.settings_base import *\". You can take a look at the settings_base module to see all backends and default settings.","Q_Score":2,"Tags":"python,django,google-app-engine,django-nonrel","A_Id":4180124,"CreationDate":"2010-11-14T14:27:00.000","Title":"Can I use Django's mail API in Google App Engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've built a very simple TCP server (in python) that when queried, returns various system level statistics of the host OS running said script. \nAs part of my experimentation and goal to gain knowledge of python and its available libraries; i would like to build on an administration interface that a) binds to a separate TCP socket b) accepts remote connections from the LAN and c) allows the connected user to issue various commands. The Varnish application is an example of a tool that offers similar administrative functionality.\nMy knowledge of threads is limited, and I am looking for pointers on how to accomplish something similar to the following :\n\nuser connects to admin port (telnet remote.host 12111), and issues  \"SET LOGGING DEBUG\", or \"STOP SERVICE\".\n\nMy confusion relates to how i would go about sharing data between threads. If the service is started on for example thread-1 , how can i access data from that thread?\nAlternatively, a list of python applications that offer such a feature would be a great help. I'd gladly poke through code, in order to reuse their ideas.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":178,"Q_Id":4179077,"Users Score":1,"Answer":"python includes some multi-threading servers (SocketServer, BaseHTTPServer, xmlrpclib). You might want to look at Twisted as well, it is a powerful framework for networking.","Q_Score":1,"Tags":"python,multithreading,sockets,admin-interface","A_Id":4179129,"CreationDate":"2010-11-14T18:57:00.000","Title":"Suggestions for developing a threaded tcp based admin interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've built a very simple TCP server (in python) that when queried, returns various system level statistics of the host OS running said script. \nAs part of my experimentation and goal to gain knowledge of python and its available libraries; i would like to build on an administration interface that a) binds to a separate TCP socket b) accepts remote connections from the LAN and c) allows the connected user to issue various commands. The Varnish application is an example of a tool that offers similar administrative functionality.\nMy knowledge of threads is limited, and I am looking for pointers on how to accomplish something similar to the following :\n\nuser connects to admin port (telnet remote.host 12111), and issues  \"SET LOGGING DEBUG\", or \"STOP SERVICE\".\n\nMy confusion relates to how i would go about sharing data between threads. If the service is started on for example thread-1 , how can i access data from that thread?\nAlternatively, a list of python applications that offer such a feature would be a great help. I'd gladly poke through code, in order to reuse their ideas.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":4179077,"Users Score":0,"Answer":"Probably the easiest starting point would involve Python's xmlrpclib.\nRegarding threading, all threads can read all data in a Python program; only one thread at a time can modify any given object, so primitives such as lists and dicts will always be in a consistent state. Data structures (i.e. class objects) involving multiple primitives will require a little more care. The safest way to coordinate between threads is to pass messages\/commands between threads via something like Queue.Queue; this isn't always the most efficient way but it's far less prone to problems.","Q_Score":1,"Tags":"python,multithreading,sockets,admin-interface","A_Id":4179107,"CreationDate":"2010-11-14T18:57:00.000","Title":"Suggestions for developing a threaded tcp based admin interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a function that is supposed to take a string, append things to it where necessary, and return the result. \nMy natural inclination is to just return the result, which involved string concatenation, and if it failed, let the exception float up to the caller. However, this function has a default value, which I just return unmodified. \nMy question is: What if someone passed something unexpected to the method, and it returns something the user doesn't expect? The method should fail, but how to enforce that?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":4179831,"Users Score":5,"Answer":"It's not necessary to do so, but if you want you can have your method raise a TypeError if you know that the object is of a type that you cannot handle. One reason to do this is to help people to understand why the method call is failing and to give them some help fixing it, rather than giving them obscure error from the internals of your function.\nSome methods in the standard library do this:\n\n>>> [] + 1\nTraceback (most recent call last):\n  File \"\", line 1, in \nTypeError: can only concatenate list (not \"int\") to list","Q_Score":5,"Tags":"python","A_Id":4179849,"CreationDate":"2010-11-14T21:38:00.000","Title":"What is the proper python way to write methods that only take a particular type?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do a test load for a web page. I want to do it in python with multiple threads.\nFirst POST request would login user (set cookies).\nThen I need to know how many users doing the same POST request simultaneously can server take.\nSo I'm thinking about spawning threads in which requests would be made in loop.\nI have a couple of questions:\n1. Is it possible to run 1000 - 1500 requests at the same time CPU wise? I mean wouldn't it slow down the system so it's not reliable anymore?\n2. What about the bandwidth limitations? How good the channel should be for this test to be reliable?\nServer on which test site is hosted is Amazon EC2 script would be run from another server(Amazon too).\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8721,"Q_Id":4179879,"Users Score":1,"Answer":"too many variables. 1000 at the same time... no. in the same second... possibly. bandwidth may well be the bottleneck. this is something best solved by experimentation.","Q_Score":4,"Tags":"python,multithreading,load-testing","A_Id":4180003,"CreationDate":"2010-11-14T21:46:00.000","Title":"Python script load testing web page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to execute a Python script on several (15+) remote machine using SSH. After invoking the script\/command I need to disconnect ssh session and keep the processes running in background for as long as they are required to. \nI have used Paramiko and PySSH in past so have no problems using them again. Only thing I need to know is how to disconnect a ssh session in python (since normally local script would wait for each remote machine to complete processing before moving on).","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":51995,"Q_Id":4180390,"Users Score":4,"Answer":"On Linux machines, you can run the script with 'at'. \necho \"python scriptname.py\" \u00a6 at now","Q_Score":23,"Tags":"python,ssh","A_Id":4180771,"CreationDate":"2010-11-14T23:40:00.000","Title":"Execute remote python script via SSH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This should be simple, but I'm just not seeing it.\nIf I have a process ID, how can I use that to grab info about the process such as the process name.","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":26492,"Q_Id":4189717,"Users Score":20,"Answer":"Under Linux, you can read proc filesystem. File \/proc\/<pid>\/cmdline contains the commandline.","Q_Score":26,"Tags":"python,process,pid","A_Id":4189752,"CreationDate":"2010-11-15T23:00:00.000","Title":"Get process name by PID","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program which provides a command line input like this:\npython2.6 prog.py -p a1 b1 c1\nNow, we can have any number of input parameters i.e. -p a1 and -p a1 c1 b1 e2 are both possibilities.\nI want to create a tuple based on the variable input parameters. Any suggestions on how to do this would be very helpful! A fixed length tuple would be easy, but I am not sure how to implement a variable length one.\nthanks.","AnswerCount":8,"Available Count":1,"Score":0.024994793,"is_accepted":false,"ViewCount":5466,"Q_Id":4196389,"Users Score":1,"Answer":"Iterate through sys.argv until you reach another flag.","Q_Score":2,"Tags":"python,command,command-line-arguments,tuples","A_Id":4196432,"CreationDate":"2010-11-16T16:25:00.000","Title":"Python: Create a tuple from a command line input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like the subject says: Does the latest stable pygame release work with python2.7?\nI've got both versions installed on my OSX Snow Leopard, but import pygame only works on python2.6 - That's the official distro which is 2.6.6, not the pre-installed one which is 2.6.1).\nAnd if it does work, how can I make it work on my machine? What am I doing wrong?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":324,"Q_Id":4200644,"Users Score":0,"Answer":"My guess is that you installed it for 2.6 and so it is residing in 2.6's library directory. Install it in 2.7's library directory and you should be good to go. I don't know OSX so I can't help with the details but a little bit of googling shouldn't be too hard. The problem is that the two python installations have distinct import paths.","Q_Score":0,"Tags":"python,macos,pygame","A_Id":4200863,"CreationDate":"2010-11-17T01:10:00.000","Title":"Does the latest stable pygame release work with python2.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a class that wants to be initialized from a few possible inputs. However a combination of no function overloading and my relative inexperience with the language makes me unsure of how to proceed. Any advice?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2458,"Q_Id":4201590,"Users Score":1,"Answer":"No, don't check for types explicitly. Python is a duck typed language. If the wrong type is passed, a TypeError will be raised. That's it. You need not bother about the type, that is the responsibility of the programmer.","Q_Score":0,"Tags":"python","A_Id":4201648,"CreationDate":"2010-11-17T04:46:00.000","Title":"Is it good form to have an __init__ method that checks the type of its input?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"is there a way to run syncdb without loading fixtures?\nxo","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1286,"Q_Id":4202358,"Users Score":-1,"Answer":"Rename the fixture to something else than initial_data","Q_Score":5,"Tags":"python,django,django-models","A_Id":4203124,"CreationDate":"2010-11-17T07:34:00.000","Title":"how do run syncdb without loading fixtures?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"is there a way to run syncdb without loading fixtures?\nxo","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1286,"Q_Id":4202358,"Users Score":0,"Answer":"best to name your fixtures something_else.json, then run syncdb (and migrate if needed), followed by manage.py loaddata something_else.json","Q_Score":5,"Tags":"python,django,django-models","A_Id":15206734,"CreationDate":"2010-11-17T07:34:00.000","Title":"how do run syncdb without loading fixtures?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok, Tornado is non-blocking and quite fast and it can handle a lot of standing requests easily.\nBut I guess it's not a silver bullet and if we just blindly run Django-based or any other site with Tornado it won't give any performance boost.\nI couldn't find comprehensive explanation of this, so I'm asking it here:\n\nWhen should Tornado be used?\nWhen is it useless?\nWhen using it, what should be taken into account?\nHow can we make inefficient site using Tornado?\nThere is a server and a webframework.\nWhen should we use framework and when can we replace it with other one?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29364,"Q_Id":4212877,"Users Score":50,"Answer":"There is a server and a webframework. When should we use framework and when can we replace it with other one?\n\nThis distinction is a bit blurry. If you are only serving static pages, you would use one of the fast servers like lighthttpd. Otherwise, most servers provide a varying complexity of framework to develop web applications. Tornado is a good web framework. Twisted is even more capable and is considered a good networking framework. It has support for lot of protocols. \nTornado and Twisted are frameworks that provide support non-blocking, asynchronous web \/ networking application development. \n\nWhen should Tornado be used?\n  When is it useless?\n  When using it, what should be taken into account?\n\nBy its very nature, Async \/ Non-Blocking I\/O works great when it is I\/O intensive and not computation intensive. Most web \/ networking applications suits well for this model. If your application demands certain computational intensive task to be done then it has to be delegated to some other service that can handle it better. While Tornado \/ Twisted can do the job of web server, responding to web requests.\n\nHow can we make inefficient site using Tornado?\n\n\nDo any thing computational intensive task \nIntroduce blocking operations\n\n\nBut I guess it's not a silver bullet and if we just blindly run Django-based or any other site with Tornado it won't give any performance boost.\n\nPerformance is usually a characteristic of complete web application architecture. You can bring down the performance with most web frameworks, if the application is not designed properly. Think about caching, load balancing etc. \nTornado and Twisted provide reasonable performance and they are good for building performant web applications. You can check out the testimonials for both twisted and tornado to see what they are capable of.","Q_Score":87,"Tags":"python,asynchronous,nonblocking,tornado","A_Id":4213777,"CreationDate":"2010-11-18T08:29:00.000","Title":"When and how to use Tornado? When is it useless?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Imagine a script is running in these 2 sets of \"conditions\":\n\nlive action, set up in sudo crontab\ndebug, when I run it from console .\/my-script.py\n\nWhat I'd like to achieve is an automatic detection of \"debug mode\", without me specifying an argument (e.g. --debug) for the script.\nIs there a convention about how to do this? Is there a variable that can tell me who the script owner is? Whether script has a console at stdout?  Run a ps | grep to determine that?\nThank you for your time.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4781,"Q_Id":4213091,"Users Score":3,"Answer":"Use a command line option that only cron will use.\nOr a symlink to give the script a different name when called by cron. You can then use sys.argv[0]to distinguish between the two ways to call the script.","Q_Score":15,"Tags":"python,bash,environment-variables,crontab","A_Id":4213327,"CreationDate":"2010-11-18T09:01:00.000","Title":"Detect if python script is run from console or by crontab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in dire need of a classification task example using LibSVM in python. I don't know how the Input should look like and which function is responsible for training and which one for testing\nThanks","AnswerCount":8,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":50030,"Q_Id":4214868,"Users Score":13,"Answer":"LIBSVM reads the data from a tuple containing two lists. The first list contains the classes and the second list contains the input data. create simple dataset with two possible classes\nyou also need to specify which kernel you want to use by creating svm_parameter.\n\n\n>> from libsvm import *\n>> prob = svm_problem([1,-1],[[1,0,1],[-1,0,-1]])\n>> param = svm_parameter(kernel_type = LINEAR, C = 10)\n  ## training  the model\n>> m = svm_model(prob, param)\n#testing the model\n>> m.predict([1, 1, 1])","Q_Score":25,"Tags":"python,machine-learning,svm,libsvm","A_Id":4215056,"CreationDate":"2010-11-18T12:44:00.000","Title":"An example using python bindings for SVM library, LIBSVM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in dire need of a classification task example using LibSVM in python. I don't know how the Input should look like and which function is responsible for training and which one for testing\nThanks","AnswerCount":8,"Available Count":2,"Score":0.0748596907,"is_accepted":false,"ViewCount":50030,"Q_Id":4214868,"Users Score":3,"Answer":"Adding to @shinNoNoir :\nparam.kernel_type represents the type of kernel function you want to use,\n0: Linear\n1: polynomial\n2: RBF\n3: Sigmoid\nAlso have in mind that, svm_problem(y,x) : here y is the class labels and x is the class instances and x and y can only be lists,tuples and dictionaries.(no numpy array)","Q_Score":25,"Tags":"python,machine-learning,svm,libsvm","A_Id":8302624,"CreationDate":"2010-11-18T12:44:00.000","Title":"An example using python bindings for SVM library, LIBSVM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to embed some python code in a c++ application i am developing with ms visual studio c++ 2010. But when i run the program, it exits with code 0x01 when i call Py_initialize().\nI dont know how to find out what went wrong. the help file says, Py_Initialize can't return an error value, it only fails fataly.\nBut, why did it fail?\nI am using a self-compiled python27_d.dll, which i created with the msvs project files in the source downloads from python.org.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1264,"Q_Id":4216988,"Users Score":0,"Answer":"Well, i finally found out what went wrong.\nI did compile my python27_d.dll with the same VC10 as my program itself.\nBut my program is normally compiled as 64 bit executable. I just forgot to compile the dll for x64, too. I didnt think this would lead to such annoying behavoiur, as i believed i would get a linkr error then.","Q_Score":1,"Tags":"c++,python,visual-studio-2010,python-c-api,python-embedding","A_Id":4277222,"CreationDate":"2010-11-18T16:16:00.000","Title":"Tried to embed python in a visual studio 2010 c++ file, exits with code 1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to embed some python code in a c++ application i am developing with ms visual studio c++ 2010. But when i run the program, it exits with code 0x01 when i call Py_initialize().\nI dont know how to find out what went wrong. the help file says, Py_Initialize can't return an error value, it only fails fataly.\nBut, why did it fail?\nI am using a self-compiled python27_d.dll, which i created with the msvs project files in the source downloads from python.org.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1264,"Q_Id":4216988,"Users Score":0,"Answer":"Is there  simple 'hello world' type example of the Py_Initilize code in the python sdk you can start with?\nThat will at least tell you if you have the compiler environment setup correctly, or if the error is in your usage.","Q_Score":1,"Tags":"c++,python,visual-studio-2010,python-c-api,python-embedding","A_Id":4217625,"CreationDate":"2010-11-18T16:16:00.000","Title":"Tried to embed python in a visual studio 2010 c++ file, exits with code 1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to write a python script that takes 3 parameters. The first parameter is a string, the second is an integer, and the third is also an integer.\nI want to put conditional checks at the start to ensure that the proper number of arguments are provided, and they are the right type before proceeding.\nI know we can use sys.argv to get the argument list, but I don't know how to test that a parameter is an integer before assigning it to my local variable for use.\nAny help would be greatly appreciated.","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27532,"Q_Id":4228757,"Users Score":0,"Answer":"You can cast the argument and try... except the ValueError.\nIf you are using sys.argv, also investigate argparse.","Q_Score":12,"Tags":"python,validation,parameters","A_Id":4228788,"CreationDate":"2010-11-19T19:43:00.000","Title":"Python: Test if an argument is an integer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The widgets in my application are the old style mac widgets.  How do I make them become the new style ones.  I am using pyqt 4.6.3-1 with python 2.7 on os x 10.6.  Everything was installed using fink and I installed both qt4-mac and qt4-x11.  Not sure which is being used or how to select one or the other.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":475,"Q_Id":4232228,"Users Score":1,"Answer":"I switched from Fink to Macports, and I got the nice widgets.","Q_Score":0,"Tags":"python,cocoa,qt4,pyqt","A_Id":4365030,"CreationDate":"2010-11-20T10:16:00.000","Title":"getting pyqt to use cocoa widgets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"is there any way how to use Mechanize with Python 3.x?\nOr is there any substitute which works in Python 3.x?\nI've been searching for hours, but I didn't find anything :(\nI'm looking for way how to login to the site with Python, but the site uses javascript.\nThanks in advance,\nAdam.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":3776,"Q_Id":4237164,"Users Score":3,"Answer":"lxml.html provides form handling facilities and supports Python 3.","Q_Score":10,"Tags":"python,login,screen-scraping,screen,mechanize","A_Id":4238162,"CreationDate":"2010-11-21T09:18:00.000","Title":"Mechanize for Python 3.x","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a series of buttons(Or windows) etc on RUN time.\nNow how do i identify when user clicks on these buttons?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":77,"Q_Id":4239896,"Users Score":1,"Answer":"HI,\nI did an R&D on wx.Event(GetEventObject) and found out that i can get object details. \nSO i solved my problem using this.","Q_Score":0,"Tags":"python,wxpython","A_Id":4240158,"CreationDate":"2010-11-21T19:36:00.000","Title":"How to Identify Dynamically created window\/buttons in wxpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing an email parsing application using python POP3 library on a linux server using Dovecot email server. I have parsed the emails to get the contents and the attachments etc. using POP3 library.\nNow the issue is how to notify a user or actually the application that a new email has arrived? I guess there should be some notification system on email server itself which I am missing or something on linux which we can use to implement the same.\nPlease suggest.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":240,"Q_Id":4242540,"Users Score":2,"Answer":"POP3 does not have push ability.  Like a regular ol' post office you need to actually go to check your e-mail.  IMAP does have functionality similar to (but not exactly the same as) mail pushing.  I'd suggest taking a look at it.","Q_Score":0,"Tags":"python,linux,email","A_Id":4242804,"CreationDate":"2010-11-22T05:28:00.000","Title":"Linux email server, how to know a new email has arrived","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Question: Where is a good starting point for learning to write server applications?\n\nInfo:\nI'm looking in to writing a distributed computing system to harvest the idle cycles of the couple hundred computers sitting idle around my college's campus. There are systems that come close, but don't quite meet all the requirements I need. (most notable all transactions have to be made through SSH because the network blocks everything else)  So I've decided to write my own application. partly to get exactly what I want, but also for experience.\nImportant features:\n\nWritten in python\nAll transaction made through ssh(this is solved through the simple use of pexpect)\nServer needs to be able to take potentially hundreds of hits. I'll optimize later, the point being simulation sessions.\n\nI feel like those aren't to ridiculous of things to try and accomplish. But with the last one I'm not certain where to even start. I've actually already accomplished the first 2 and written a program that will log into my server, and then print ls -l to a file locally. so that isn't hard. but how do i attach several clients asking the server for simulation data to crunch all at the same time? obviously it feels like threading comes in to play here, but more than that I'm sure.\nThis is where my problem is. Where does one even start researching how to write server applications? Am I even using the right wording? What information is there freely available on the internet and\/or what books are there on such? again, specifically python, but a step in the right direction is one more than where i am now.\np.s. this seeemed more fitting for stackoverflow than serverfault. Correct me if I am wrong.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":4253557,"Users Score":0,"Answer":"Here's an approach.\n\nWrite an \"agent\" in Python.  The agent is installed on the various computers.  It does whatever processing your need locally.  It uses urllib2 to make RESTful HTTP requests of the server.  It either posts data or requests work to do or whatever is supposed to go on.\nWrite a \"server\" in Python.  The server is installed on one computer.  This is written using wsgiref and is a simple WSGI-based server that serves requests from the various agents scattered around campus.\n\nWhile this requires agent installation, it's very, very simple.   It can be made very, very secure (use HTTP Digest Authentication).  And the agent's privileges define the level of vulnerability.  If the agent is running in an account with relatively few privileges, it's quite safe.  The agent shouldn't run as root and the agent's account should not be allowed to su or sudo.","Q_Score":4,"Tags":"python","A_Id":4255361,"CreationDate":"2010-11-23T07:04:00.000","Title":"where to start programing a server application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python with urllib2 & cookielib and such to open a url. This url set's one cookie in it's header and two more in the page with some javascript. It then redirects to a different page.\nI can parse out all the relevant info for the cookies being set with the javascript, but I can't for the life of me figure out how to get them into the cookie-jar as cookies.\nEssentially, when I follow to the site being redirected too, those two cookies have to be accessible by that site.\nTo be very specific, I'm trying to login in to gomtv.net by using their \"login in with a Twitter account\" feature in python.\nAnyone?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":255,"Q_Id":4258278,"Users Score":0,"Answer":"You can't set cookies for another domain - browsers will not allow it.","Q_Score":2,"Tags":"python,authentication,cookies,cookielib","A_Id":4258354,"CreationDate":"2010-11-23T16:25:00.000","Title":"How do I manually put cookies in a jar?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some url to parse, and they used some javascript to create it dynamicly. So if i want to parse the result generated page with python... how can i do that ?\nFirefox do that well with web developer... so i think it possible ... but i don't know where to start...\nThx for help\nlo","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":4264076,"Users Score":0,"Answer":"I you want generated source you'll need a browser, I don't think you can with only python.","Q_Score":2,"Tags":"javascript,python,parsing,url,dynamically-generated","A_Id":4264223,"CreationDate":"2010-11-24T06:35:00.000","Title":"How to see generated source from an URL page with python script and not anly source?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some url to parse, and they used some javascript to create it dynamicly. So if i want to parse the result generated page with python... how can i do that ?\nFirefox do that well with web developer... so i think it possible ... but i don't know where to start...\nThx for help\nlo","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":212,"Q_Id":4264076,"Users Score":2,"Answer":"I've done this by doing a POST of document.body.innerHTML, after the page is loaded, to a CGI script in Python.\nFor the parsing, BeautifulSoup is a good choice.","Q_Score":2,"Tags":"javascript,python,parsing,url,dynamically-generated","A_Id":4264239,"CreationDate":"2010-11-24T06:35:00.000","Title":"How to see generated source from an URL page with python script and not anly source?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Well, I have created a python script, which checks the number of uncompleted tasks of tasque and displays it using pynotify periodically. My question is how do I implement this timer. I can think of two things. A Cron job to execute a python script periodically or using a python script which uses a gtk loop to call the specified function for checking periodically.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":383,"Q_Id":4268374,"Users Score":2,"Answer":"Cron job. It's more likely to be \"in line\" with actual time, since it's a more stable and time-tested choice. It's also less demanding on resources than using a loop in Python since it doesn't require a constant Python interpreter process, and is probably better optimized than pyGTK (choice is mature, stable software vs. less mature, less stable).","Q_Score":2,"Tags":"python","A_Id":4268840,"CreationDate":"2010-11-24T15:19:00.000","Title":"Gtk loop or Cron for timer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to remove focus from a widget manually.","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":16266,"Q_Id":4299432,"Users Score":2,"Answer":"My solution is root.focus() it will remove widget focus.","Q_Score":11,"Tags":"python,tkinter","A_Id":64151502,"CreationDate":"2010-11-28T22:15:00.000","Title":"In Tkinter how do i remove focus from a widget?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to remove focus from a widget manually.","AnswerCount":6,"Available Count":2,"Score":0.1651404129,"is_accepted":false,"ViewCount":16266,"Q_Id":4299432,"Users Score":5,"Answer":"Set focus to another widget to remove focus from the target widget is a good idea. There are two methods for this: w.focus_set() and w.focus_force(). However, method w.focus_force() is impolite. It's better to wait for the window manager to give you the focus. Setting focus to parent widget or to the root window removes focus from the target widget.\nSome widgets have takefocus option. Set takefocus to 0 to take your widget out of focus traversal (when user hits <Tab> key).","Q_Score":11,"Tags":"python,tkinter","A_Id":47823400,"CreationDate":"2010-11-28T22:15:00.000","Title":"In Tkinter how do i remove focus from a widget?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So we want to program a 3d game for school, we can probably use blender for the 3d models, however we are totally clueless as to how to use them in a game\/application.\nAre there any recommended guides\/documents we should read on general 3d game programming and perhaps python specific stuff.\nWe are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":56291,"Q_Id":4303851,"Users Score":0,"Answer":"I would implement the time-critical stuff as 3D and its object handling + rendering in raw C\/C++ and let an embedded Python with external modules handle the game logic (object movement, object properties, scripting and so on).","Q_Score":15,"Tags":"c++,python,3d","A_Id":4303972,"CreationDate":"2010-11-29T12:49:00.000","Title":"3d game with Python, starting from nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So we want to program a 3d game for school, we can probably use blender for the 3d models, however we are totally clueless as to how to use them in a game\/application.\nAre there any recommended guides\/documents we should read on general 3d game programming and perhaps python specific stuff.\nWe are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":56291,"Q_Id":4303851,"Users Score":2,"Answer":"If you want to write a 3D game you might want to start by understanding the basics of programming and computer science. Starting with the top and learning a language, then find yourself a good graphics library for example Panda, Pygame are all good choices, then there are other parts to consider like networking with twisted for example or a physics engine. It might also be a good choice to consider using a working engine like the unreal engine as often game designers get too wrapped up in game mechanics and not the game itself","Q_Score":15,"Tags":"c++,python,3d","A_Id":4303913,"CreationDate":"2010-11-29T12:49:00.000","Title":"3d game with Python, starting from nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So we want to program a 3d game for school, we can probably use blender for the 3d models, however we are totally clueless as to how to use them in a game\/application.\nAre there any recommended guides\/documents we should read on general 3d game programming and perhaps python specific stuff.\nWe are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","AnswerCount":8,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":56291,"Q_Id":4303851,"Users Score":2,"Answer":"You should be aware that 3D game consists of\n\nanimated 3D models\n3D environment (including NPCs and objects)\nsimulation of interaction between the environment and the models (game logic and game mechanics)\nuser interface (starting, saving and game settings)\n\nThe game logic and mechanics is going to usually the biggest and most complicated part and you should try to wrap your head against that first.\nModeling 3D objects and environment should be much easier after that.","Q_Score":15,"Tags":"c++,python,3d","A_Id":4304000,"CreationDate":"2010-11-29T12:49:00.000","Title":"3d game with Python, starting from nothing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a medium sized project in django and i want to be able to access the current user from within my query manager.  I need to be able to design a custom manager to limit the results and querysets so that the current user only get's information related to him\/her.\nI've received a few suggestions, I've also seen the not so supported example of using threadlocals from a django middleware. However, i'm very confused as this seems to be most promising solution now. I am looking for a better way to do this, so i can gain access to the current user from within a model manager.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":7107,"Q_Id":4303897,"Users Score":3,"Answer":"There is no sane way to get the user outside of the request. If the current user matters then pass it to any functions that need it.","Q_Score":6,"Tags":"python,django","A_Id":4303960,"CreationDate":"2010-11-29T12:54:00.000","Title":"How can i access the current user outside a request in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been a long time user of R and have recently started working with Python. Using conventional RDBMS systems for data warehousing, and R\/Python for number-crunching, I feel the need now to get my hands dirty with Big Data Analysis.\nI'd like to know how to get started with Big Data crunching.\n- How to start simple with Map\/Reduce and the use of Hadoop\n\nHow can I leverage my skills in R and Python to get started with Big Data analysis. Using the Python Disco project for example.\nUsing the RHIPE package and finding toy datasets and problem areas.\nFinding the right information to allow me to decide if I need to move to NoSQL from RDBMS type databases\n\nAll in all, I'd like to know how to start small and gradually build up my skills and know-how in Big Data Analysis.\nThank you for your suggestions and recommendations.\nI apologize for the generic nature of this query, but I'm looking to gain more perspective regarding this topic.\n\nHarsh","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18227,"Q_Id":4322559,"Users Score":29,"Answer":"Using the Python Disco project for example.\n\nGood.  Play with that.\n\nUsing the RHIPE package and finding toy datasets and problem areas.\n\nFine.  Play with that, too.\nDon't sweat finding \"big\" datasets.  Even small datasets present very interesting problems.  Indeed, any dataset is a starting-off point.\nI once built a small star-schema to analyze the $60M budget of an organization.  The source data was in spreadsheets, and essentially incomprehensible.  So I unloaded it into a star schema and wrote several analytical programs in Python to create simplified reports of the relevant numbers.\n\nFinding the right information to allow me to decide if I need to move to NoSQL from RDBMS type databases\n\nThis is easy.\nFirst, get a book on data warehousing (Ralph Kimball's The Data Warehouse Toolkit) for example.\nSecond, study the \"Star Schema\" carefully -- particularly all the variants and special cases that Kimball explains (in depth)\nThird, realize the following:  SQL is for Updates and Transactions.  \nWhen doing \"analytical\" processing (big or small) there's almost no update of any kind.  SQL (and related normalization) don't really matter much any more.\nKimball's point (and others, too) is that most of your data warehouse is not in SQL, it's in simple Flat Files.  A data mart (for ad-hoc, slice-and-dice analysis) may be in a relational database to permit easy, flexible processing with SQL.\nSo the \"decision\" is trivial.  If it's transactional (\"OLTP\") it must be in a Relational or OO DB.  If it's analytical (\"OLAP\") it doesn't require SQL except for slice-and-dice analytics; and even then the DB is loaded from the official files as needed.","Q_Score":41,"Tags":"python,r,hadoop,bigdata","A_Id":4323638,"CreationDate":"2010-12-01T08:45:00.000","Title":"How to get started with Big Data Analysis","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a database full of data, including a date and time string, e.g. Tue, 21 Sep 2010 14:16:17 +0000\nWhat I would like to be able to do is extract various documents (records) from the database based on the time contained within the date string, Tue, 21 Sep 2010 14:16:17 +0000.\nFrom the above date string, how would I use python and regex to extract documents that have the time 15:00:00? I'm using MongoDB by the way, in conjunction with Python.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":563,"Q_Id":4325194,"Users Score":1,"Answer":"I agree with the other poster. Though this doesn't solve your immediate problem, if you have any control over the database, you should seriously consider creating a time\/column, with either a DATE or TIMESTAMP datatype. That would make your system much more robust, & completely avoid the problem of trying to parse dates from string (an inherently fragile technique).","Q_Score":3,"Tags":"python,regex,mongodb,datetime,database","A_Id":4325260,"CreationDate":"2010-12-01T14:10:00.000","Title":"Extracting Date and Time info from a string.","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I would like to install a python package to windows. I have tried to run setup.py install  on command prompt but it returned an error:\ncould not create 'C:\\Program Files\\Python...': access is denied.\nPlease, help.\n\u0160pela","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":240,"Q_Id":4329330,"Users Score":2,"Answer":"My first question would be, do you have administration rights when you try to run setup.py?","Q_Score":0,"Tags":"python,windows,installation","A_Id":4329365,"CreationDate":"2010-12-01T21:28:00.000","Title":"how to install a python package to windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to figure out how to use the unicode support in python;\nI would like to convert this string to unicode :\n\"ABCDE\"\n-->\n\"\\x00A\\x00B\\x00C\\x00D\\x00E\"\nAny built-in functionnality can do that, or shall i use join() ?\nThanks !","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":759,"Q_Id":4330580,"Users Score":2,"Answer":"The key to understanding unicode in python is that unicode means UNICODE. A unicode object is an idealized representation to the characters, not actual bytes.","Q_Score":1,"Tags":"python,unicode","A_Id":4330599,"CreationDate":"2010-12-02T00:31:00.000","Title":"python unicode support","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to figure out how to use the unicode support in python;\nI would like to convert this string to unicode :\n\"ABCDE\"\n-->\n\"\\x00A\\x00B\\x00C\\x00D\\x00E\"\nAny built-in functionnality can do that, or shall i use join() ?\nThanks !","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":759,"Q_Id":4330580,"Users Score":0,"Answer":"the str object should be firstly converted to unicode object by decode method.\nthen convert the unicode object to str object using encode method with character-encoding you want.","Q_Score":1,"Tags":"python,unicode","A_Id":9630913,"CreationDate":"2010-12-02T00:31:00.000","Title":"python unicode support","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I met a problem while using python(2.6) cgi to show a mime data in windows(apache).\nFor example, to show a image, here is my code:\nimage.py\n\n#!E:\/program files\/Python26\/python.exe\n# -*- coding: UTF-8 -*-\ndata = open('logo.png','rb').read()\nprint 'Content-Type:image\/png;Content-Disposition:attachment;filename=logo.png\\n'\nprint data\n\nBut it dose not work in windows(xp or 7)+apache or IIS.\n(I try to write these code in diferent way, and also try other file format, jpg and rar, but no correct output, the output data seems to be disorder in the begining lines.)\nAnd I test these code in linux+apache, and it is Ok!\n\n#!\/usr\/bin\/env python\n# -*- coding: UTF-8 -*-\ndata = open('logo.png','rb').read()\nprint 'Content-Type:image\/png;Content-Disposition:attachment;filename=logo.png\\n'\nprint data\n\nI just feel confused why it does not work in windows.\nCould anybody give me some help and advice?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":4332293,"Users Score":0,"Answer":"Now I know how to solve this problem: \n\nFor windows+IIS:\nWhile adding the application mapping(IIS), write C:\\Python20\\python.exe -u %s %s. I used to write like this c:\\Python26\\python.exe %s %s, that will create wrong mime data. And \"-u\" means unbuffered binary stdout and stderr. \nFor windows+Apache:\nAdd #!E:\/program files\/Python26\/python.exe -u to the first line of the python script.\n\nThank Ignacio Vazquez-Abrams all the same!","Q_Score":0,"Tags":"python,windows,apache,cgi,mime","A_Id":5335384,"CreationDate":"2010-12-02T06:26:00.000","Title":"how to show mime data using python cgi in windows+apache","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going to let new users register on my service. Here is the way I think it should go:\n1. User enters his email in a field and clicks Register button.\n2. User receives a confirmation email with a link containing a verification code.\n3. User goes by that link from the email message where he sees a message that his account is activated now.\nSo, the main point I am to figure out how to implement is the second one. How do I better generate that code? Should I generate it when the user clicks Register button and save it in the field, say \"verification_code\" near the field \"email\" and then when he goes to the verification link, compare the values? Then, if that's fine, clear the \"verification_code\" field and set \"user_is_active\" field to \"True\". Or may be I don't have to keep that code in the database at all, but make a just in time verification with some algorithm? May be there are other things I should consider?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":4333711,"Users Score":2,"Answer":"I've found it useful to put a verification code in the database and use it as you've suggested. The same field can do double duty for e.g. password reset requests.\nI also use an expiry timeout field, where registrations or password resets need to be dealt with by the user in a timely fashion.","Q_Score":1,"Tags":"python,registration","A_Id":4333979,"CreationDate":"2010-12-02T10:05:00.000","Title":"What is the best practice for registering a new user in my case?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite new to python programming (C\/C++ background).\nI'm writing code where I need to use complex data structures like dictionaries of dictionaries of lists.\nThe issue is that when I must use these objects I barely remember their structure and so how to access them.\nThis makes it difficult to resume working on code that was untouched for days.\nA very poor solution is to use comments for each variable, but that's very inflexible.\nSo, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":716,"Q_Id":4337736,"Users Score":0,"Answer":"Include an example somewhere in your code, or in your tests.","Q_Score":3,"Tags":"python,data-structures,types","A_Id":4338035,"CreationDate":"2010-12-02T17:11:00.000","Title":"Declaring types for complex data structures in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite new to python programming (C\/C++ background).\nI'm writing code where I need to use complex data structures like dictionaries of dictionaries of lists.\nThe issue is that when I must use these objects I barely remember their structure and so how to access them.\nThis makes it difficult to resume working on code that was untouched for days.\nA very poor solution is to use comments for each variable, but that's very inflexible.\nSo, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":716,"Q_Id":4337736,"Users Score":1,"Answer":"I believe you should take a good look some of your complex structures, what you are doing with them, and ask... Is This Pythonic?  Ask here on SO.  I think you will find some cases where the complexity is an artifact of C\/C++.","Q_Score":3,"Tags":"python,data-structures,types","A_Id":4337932,"CreationDate":"2010-12-02T17:11:00.000","Title":"Declaring types for complex data structures in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am trying to use scapy in python\nwhile i try to import the scapy import scapy\nits just fine but the line scapy.ARP() causes a\n\nTraceback (most recent call last):\n    File \"\", line 1, in \n  AttributeError: 'module' object has no attribute 'ARP'\n\na dir(scapy) produces \n'['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']'\nwhat might be the problem here ? do i need to install the packages separately if yes how to do it  ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1937,"Q_Id":4339745,"Users Score":2,"Answer":"got it , from the version v.2 onward the it should be used as from scapy.all import *","Q_Score":1,"Tags":"python,scapy","A_Id":4339911,"CreationDate":"2010-12-02T20:53:00.000","Title":"ARP missing from the module scapy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to quantize a 24bit image to 16bit color depth using Python Imaging.\nPIL used to provide a method im.quantize(colors, **options) however this has been deprecated for out = im.convert(\"P\", palette=Image.ADAPTIVE, colors=256)\nUnfortunately 256 is the MAXIMUM number of colors that im.convert() will quantize to (8 bit only).\nHow can I quantize a 24bit image down to 16bit using PIL (or similar)?\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4447,"Q_Id":4345337,"Users Score":3,"Answer":"You might want to look into converting your image to a numpy array, performing your quantisation, then converting back to PIL.\nThere are modules in numpy to convert to\/from PIL images.","Q_Score":4,"Tags":"python,python-imaging-library,imaging","A_Id":4345485,"CreationDate":"2010-12-03T12:04:00.000","Title":"Python Imaging, how to quantize an image to 16bit depth?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use python urllib2 to simulate a login action, I use Fiddler to catch the packets and got that the login action is just an ajax request and the username and password is sent as  json data, but I have no idea how to use urllib2 to send json data, help...","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":32746,"Q_Id":4348061,"Users Score":21,"Answer":"For Python 3.x\nNote the following\n\nIn Python 3.x the urllib and urllib2 modules have been combined. The module is named urllib. So, remember that urllib in Python 2.x and urllib in Python 3.x are DIFFERENT modules.\nThe POST data for urllib.request.Request in Python 3 does NOT accept a string (str) -- you have to pass a bytes object (or an iterable of bytes)\n\nExample\npass json data with POST in Python 3.x\n\nimport urllib.request\nimport json\n\njson_dict = { 'name': 'some name', 'value': 'some value' }\n\n# convert json_dict to JSON\njson_data = json.dumps(json_dict)\n\n# convert str to bytes (ensure encoding is OK)\npost_data = json_data.encode('utf-8')\n\n# we should also say the JSON content type header\nheaders = {}\nheaders['Content-Type'] = 'application\/json'\n\n# now do the request for a url\nreq = urllib.request.Request(url, post_data, headers)\n\n# send the request\nres = urllib.request.urlopen(req)\n\n# res is a file-like object\n# ...\n\n\nFinally note that you can ONLY send a POST request if you have SOME data to send.\nIf you want to do an HTTP POST without sending any data, you should send an empty dict as data.\n\ndata_dict = {}\npost_data = json.dumps(data_dict).encode()\n\nreq = urllib.request.Request(url, post_data)\nres = urllib.request.urlopen(req)","Q_Score":16,"Tags":"python,json,urllib2","A_Id":7469725,"CreationDate":"2010-12-03T17:15:00.000","Title":"How to use python urllib2 to send json data for login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded sqlite3.exe. It opens up as a command prompt. I created a table test & inserted a few entries in it. I used .backup test just in case. After I exit the program using .exit and reopened it I don't find the table listed under .tables nor can I run any query on it.\nI need to quickly run an open source python program that makes use of this table & although I have worked with MySQL, I have no clue about sqlite. I need the minimal basics of sqlite. Can someone guide me through this or at least tell me how to permanently store my tables.\nI have put this sqlite3.exe in Python folder assuming that python would then be able to read the sqlite files. Any ideas on this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2598,"Q_Id":4348658,"Users Score":0,"Answer":"Just execute sqlite3 foo.db? This will permanently store everything you do afterwards in this file. (No need for .backup.)","Q_Score":0,"Tags":"python,sqlite","A_Id":4348768,"CreationDate":"2010-12-03T18:30:00.000","Title":"How to create tables in sqlite 3?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing some heavy commandline stuff (not really web based) and am new to Python, so I was wondering how to set up my files\/folders\/etc. Are there \"header\" files where I can keep all the DB connection stuff?\nHow\/where do I define classes and objects?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1866,"Q_Id":4349714,"Users Score":0,"Answer":"You can organize it in whatever way makes the most sense for your application. I don't exactly know what you're doing so I can't be certain what the best organization would be for you, but you can pretty much split it up as you see fit and just import what you need.\nYou can define classes in any file, and you can define as many classes as you would like in a script (unlike Java). There are no official header files (not like C or C++), but you can use config files to store info about connecting to a DB, whatever, and use configparser (a standard library function) to organize them.\nIt makes sense to keep like things in the same file, so if you have a GUI, you might have one file for the interface, and if you have a CLI, you might keep that in a file by itself. It's less important how your files are organized and more important how the source is organized into classes and functions.","Q_Score":1,"Tags":"python,class","A_Id":4349752,"CreationDate":"2010-12-03T20:46:00.000","Title":"How is a Python project set up?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to degrade the quality of the image to a few kilobytes.\nWhat's the best way to do this?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":11769,"Q_Id":4353019,"Users Score":1,"Answer":"a) change the size: Image.resize(size, filter) b) explicitly convert it to JPEG (if it is not) and set the desired quality. c) use a combination of a) and b)\nWhatever you do, there is a trade-off between size and quality.","Q_Score":8,"Tags":"python,image,compression,python-imaging-library","A_Id":4353063,"CreationDate":"2010-12-04T10:08:00.000","Title":"In Python's PIL, how do I change the quality of an image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i love gae(google app engine),because it is easy to create a user interface for user login and signup,\nbut now , my boss want me to create a site use django ,\nso the first is to create a site that someone can be login ,\nwhich is the esaist way to create a user interface ?\nthanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":888,"Q_Id":4356234,"Users Score":1,"Answer":"Django auth also provide generic views for login\/logout etc. You can use build-in templates or expand it.\nSee in documentation for generic views: django.contrib.auth.views.login, django.contrib.auth.views.logout","Q_Score":0,"Tags":"python,django,user-interface,login","A_Id":4361550,"CreationDate":"2010-12-04T22:43:00.000","Title":"how to create a user interface that a user can signup and login using django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole \"dot\" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going.\nAm I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":594,"Q_Id":4362902,"Users Score":2,"Answer":"Don't forget that you aren't limited to Django's template language.  You're free to use whatever templating system you like in your view functions.  However you want to create the HTML to return from your view function is fine.  There are many templating implementations in the Python world: choose one that suits you better, and use it.","Q_Score":9,"Tags":"python,django,django-templates","A_Id":4366241,"CreationDate":"2010-12-06T03:20:00.000","Title":"Why don't django templates just use python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole \"dot\" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going.\nAm I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":594,"Q_Id":4362902,"Users Score":1,"Answer":"Django templates don\u2019t just use Python code for the same reason Django uses the MVC paradigm:\n\u00a0\u00a0\u00a0\u00a0No particular reason.\n\u00a0\u00a0\u00a0\u00a0(ie: The same reason anyone utilizes MVC at all, and that reason is just that certain people prefer this rigid philosophical pattern.)\nIn general I\u2019d suggest you avoid Django if you don\u2019t like things like this, because the Django people won\u2019t be changing this approach. You could also, however, do something silly (in that it\u2019d be contradictory to the philosophy of the chosen software), like put all the markup and anything else you can into the \"view\" files, turning Django from its \"MVC\" (or \"MTV\" ) paradigm into roughly what everything else is (a boring but straightforward lump).","Q_Score":9,"Tags":"python,django,django-templates","A_Id":50607955,"CreationDate":"2010-12-06T03:20:00.000","Title":"Why don't django templates just use python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole \"dot\" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going.\nAm I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":594,"Q_Id":4362902,"Users Score":1,"Answer":"Seperation of concerns.\nDesigner does design. Developer does development. Templates are written by the designers.\nDesign and development are independent and different areas of work typically handled by different people.\nI guess having template code in python would work very well if one is a developer and their spouse is a designer. Otherwise, let each do his job, with least interference.","Q_Score":9,"Tags":"python,django,django-templates","A_Id":4366273,"CreationDate":"2010-12-06T03:20:00.000","Title":"Why don't django templates just use python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"so i am developing my own download manager for educational purpose. I have multiple connections\/threads downloading a file, each connection works on a particular range of the file. Now after they have all fetched their chunks, i dont exact  know how to i bring this chunks together to re-make the original file. \nWhat i did:\nFirst, i created a temporary file in 'wb' mode, and allowed each connections\/threads to dump their chunks. But everytime a connection does this, it overwrites previously saved chunks. I figured this was because i used the 'wb' file descriptor. I changed it to 'ab', but i can no longer perform seek() operations  \nWhat i am looking for:\nI need an elegant way of re-packaging this chunk to the original file. I would like to know how other download managers do it.\nThank in advance.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":542,"Q_Id":4379160,"Users Score":2,"Answer":"You need to write chunks it different temporary files and then join them in the original order. If you open one file for all the threads, you should make the access to it sequential to preserve to correct order of data, which discards thread usage since a thread should wait for the previous one. BTW, you should open files in wb mode.","Q_Score":0,"Tags":"python,urllib2,connection,chunks","A_Id":4379274,"CreationDate":"2010-12-07T16:42:00.000","Title":"Download Manager: How to re-construct chunks fetched by multiple connections","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"so i am developing my own download manager for educational purpose. I have multiple connections\/threads downloading a file, each connection works on a particular range of the file. Now after they have all fetched their chunks, i dont exact  know how to i bring this chunks together to re-make the original file. \nWhat i did:\nFirst, i created a temporary file in 'wb' mode, and allowed each connections\/threads to dump their chunks. But everytime a connection does this, it overwrites previously saved chunks. I figured this was because i used the 'wb' file descriptor. I changed it to 'ab', but i can no longer perform seek() operations  \nWhat i am looking for:\nI need an elegant way of re-packaging this chunk to the original file. I would like to know how other download managers do it.\nThank in advance.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":542,"Q_Id":4379160,"Users Score":1,"Answer":"You were doing it just fine: seek() and write(). That should work!\nNow, if you want a cleaner structure, without so many threads moving their hands all over a file, you might want to consider having downloader threads and a disk-writing thread. This last one may just sleep until woken by one of the others, write some kb to disk, and go back to sleep.","Q_Score":0,"Tags":"python,urllib2,connection,chunks","A_Id":4379227,"CreationDate":"2010-12-07T16:42:00.000","Title":"Download Manager: How to re-construct chunks fetched by multiple connections","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently I have tasks running in background. After the tasks are done executing I need to show output. How do I do this in Google App Engine?\nOnce the tasks are done the only thing I can do is create another task which is supposed to show output or is there any other way?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":282,"Q_Id":4379200,"Users Score":0,"Answer":"This won't work directly as you describe it.\nOnce a background task is started, it's a background task for its entire existence.  If you want to return some information from the background task to the user, you'll have to add it to the datastore, and have a foreground handler check the datastore for that information.\nYou may also be able to use the Channel API to have a background task send messages directly to the browser, but I'm not sure if this will work or not (I haven't tried it).\nIf you give a little more information about exactly what you're trying to accomplish I can try to give more details about how to get it done.","Q_Score":2,"Tags":"python,google-app-engine,task-queue","A_Id":4379300,"CreationDate":"2010-12-07T16:46:00.000","Title":"how to bring a background task to foreground in google app engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently I'm drawing some things in a subclass of DrawingArea, where I get a cairo context inside an expose-event and call a draw method from there. (according to some PyGTK tutorial I found)\nI'm used to doing a repaint() with java, but how can I get the same effect here?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3673,"Q_Id":4383614,"Users Score":0,"Answer":"I found a solution that uses the queue_draw() method (callable from the Gtk.DrawingArea but seems like a method every gtk widget must have), but there are probably alternatives since this one implies it might get delayed, even though in my tests it didn't happen.","Q_Score":2,"Tags":"python,gtk,drawing,pygtk","A_Id":4383675,"CreationDate":"2010-12-08T02:15:00.000","Title":"(Py)GTK: How can I force my window to be repainted \/ call expose-event?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sometimes when developing using open source software, you need to read it's source code (specially zope\/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try\/except clauses, you name it.\nSometimes I have a lot of files opened when trying to find an issue, and sometimes I forget to remove these print\/debug alterations.\nSo, my question is: how do you keep yourself organized when doing it? Do you write \"TODOs\" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about?\nI'm using Vim. I'm just interested to know how other programmers treat this issue.","AnswerCount":5,"Available Count":3,"Score":0.1586485043,"is_accepted":false,"ViewCount":991,"Q_Id":4402536,"Users Score":4,"Answer":"In case of my own projects, the source code is always in version control. Before committing, I always check the graphical diff so that I can see what has changed, what the commit message should be and whether I can split up into smaller commits. That way, I almost always recognize temporary garbage like print statements. If not, I usually notice it shortly afterwards and can do an uncommit if I haven't yet pushed (works for DVCS like git and bzr, not with subversion).\nConcerning problems that take multiple days, it's just the same thing. I don't commit until the problem is solved and then look at the diff again.\nA text editor that allows editing within the graphical diff view would be really helpful in these cases, but I'm mostly using Eclipse, which doesn't support that.","Q_Score":4,"Tags":"python,debugging,vim","A_Id":4402775,"CreationDate":"2010-12-09T19:58:00.000","Title":"How do you avoid leaving debugger print\/pdb statements in python open source apps when you're debugging them and just finish?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sometimes when developing using open source software, you need to read it's source code (specially zope\/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try\/except clauses, you name it.\nSometimes I have a lot of files opened when trying to find an issue, and sometimes I forget to remove these print\/debug alterations.\nSo, my question is: how do you keep yourself organized when doing it? Do you write \"TODOs\" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about?\nI'm using Vim. I'm just interested to know how other programmers treat this issue.","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":991,"Q_Id":4402536,"Users Score":2,"Answer":"Well +1 for starting this discussion. Yes sometime this happen to me. I left those pdb and commit the code to the central code base, git. I use 'emacs'. So, Before commit the code I usually search for pdb in the file. But it is hectic checking each file.So, Before committing the code I usually check the diff very carefully. I am also finding the better way to resolve this issue.","Q_Score":4,"Tags":"python,debugging,vim","A_Id":4402792,"CreationDate":"2010-12-09T19:58:00.000","Title":"How do you avoid leaving debugger print\/pdb statements in python open source apps when you're debugging them and just finish?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sometimes when developing using open source software, you need to read it's source code (specially zope\/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try\/except clauses, you name it.\nSometimes I have a lot of files opened when trying to find an issue, and sometimes I forget to remove these print\/debug alterations.\nSo, my question is: how do you keep yourself organized when doing it? Do you write \"TODOs\" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about?\nI'm using Vim. I'm just interested to know how other programmers treat this issue.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":991,"Q_Id":4402536,"Users Score":1,"Answer":"I also develop Python with Vim. I have never had to substantially modify the source code for debugging. I do sometimes put debugging print statements, and I have the habit of putting \"# XXX\" after every one. Then when I want to remove them (before a commit), and just search for the XXX and delete those lines. \nFor exceptions, I have arranged to run my code in the Vim buffer with an external interpreter that is set up to automatically enter the debugger on any uncaught exception. Then I'm placed automatically in the code at the point the exception occured. I use a modified debugger that can also signal Vim (actually GTK Gvim) to open that source at that line. \nCaught exceptions should report meaningful errors, anyway. It is considered by many to be bad practice to do things like:\ntry:\n   ... some code\nexcept:\n  handle everything\nSince you probably aren't actually handling every possible error case. By not doing that you also enable the automatic debugging.","Q_Score":4,"Tags":"python,debugging,vim","A_Id":4402892,"CreationDate":"2010-12-09T19:58:00.000","Title":"How do you avoid leaving debugger print\/pdb statements in python open source apps when you're debugging them and just finish?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Python's BaseHTTPRequestHandler class to build a web server.  I want to add an endpoint for WebSockets.  This means that I need to read whatever is available from the handler's rfile, so that I can process messages one by one, as I'm receiving them (instead of having to read the while input).\nI tried using different combinations of 'read' (eg. with a big buffer, thinking that it'd return early with less data if less data was available; with no parameter, but then it just means to read until EOF) but couldn't get this to work.\nI can think of two solutions:\n\nTo call read(1): to read bytes one by one. I'd rather not do this, as I'm not sure what the buffering semantics are (eg. I wouldn't want a syscall per byte read).\nTo temporally make the file non-blocking, then attempt a read for a chunk of data, then make it blocking, then attempt a read for 1 byte.  This seems rather messy.  Another option I can think of is to just use non-blocking sockets, but this wouldn't seem to work so well with my current threaded framework.\n\nAny ideas of how to get read to return whatever data is available?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1273,"Q_Id":4414611,"Users Score":1,"Answer":"WebSockets aren't HTTP, so you can't really handle them with an HTTP request handler.\nHowever, using BaseHTTPRequestHandler with HTTP, you would normally be reading only the exact amount of data you expect (for instance, as specified in the Content-length header.)","Q_Score":0,"Tags":"python,blocking,websocket,httpserver","A_Id":15036544,"CreationDate":"2010-12-11T01:07:00.000","Title":"Python, BaseHTTPRequestHandler: how to read what's available on file from socket?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?","AnswerCount":5,"Available Count":3,"Score":-0.0399786803,"is_accepted":false,"ViewCount":86168,"Q_Id":4416642,"Users Score":-1,"Answer":"You can,,go to options then configure IDE, then on the settings window select highlights, on the rightside press the button below a builtin theme, then choose your choice theme","Q_Score":4,"Tags":"python,shell","A_Id":67948618,"CreationDate":"2010-12-11T12:17:00.000","Title":"Change background color of python shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":86168,"Q_Id":4416642,"Users Score":2,"Answer":"If you are reffering to the window idle for example for version 2.6 there is now way to change the background color from withe to another one. But you can change the background color of your text if you go to options.\nAnother thing you can do is to use other gui for python which could be more elaborated such as eclipse pydev or to use a text editor you like and configure it the way you want to write your scripts and then run them into the idle.","Q_Score":4,"Tags":"python,shell","A_Id":4417082,"CreationDate":"2010-12-11T12:17:00.000","Title":"Change background color of python shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":86168,"Q_Id":4416642,"Users Score":2,"Answer":"just go through simple steps\n - go to options\n - configure IDLE\n - highlighting\n - then select background and click on choose color for: \n - you can change the color to any color but becareful if u change only the background color the foreground color may not be visible because they both might be black\nEnjoy","Q_Score":4,"Tags":"python,shell","A_Id":17314925,"CreationDate":"2010-12-11T12:17:00.000","Title":"Change background color of python shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok i have these commands used in batch and i wanted to know the commands in python that would have a similar affect, just to be clear i dont want to just use os.system(\"command here\") for each of them. For example in batch if you wanted a list of commands you would type help but in python you would type help() and then modules... I am not trying to use batch in a python script, i just wanna know the similarities in both languages. Like in english you say \" Hello\" but in french you say \"Bonjour\" not mix the two languages. (heres the list of commands\/functions id like to know:\n\nchange the current directory\nclear the screen in the console \nchange the prompt to something other than >>>\nhow to make a loop function\nredirections\/pipes\nstart an exteral program (like notepad or paint) from within a script\nhow to call or import another python script\nhow to get help with a specific module without having to type help() \n\n@8: (in batch it would be command \/?)\nEDITED COMPLETELY\nThanks in Adnvance!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2645,"Q_Id":4418252,"Users Score":1,"Answer":"Python is not a system shell, Python is a multi-paradigm programming language.\nIf you want to compare .bat with anything, compare it with sh or bash. (You can have those on various platforms too - for example, sh for windows is in the MinGW package).","Q_Score":1,"Tags":"python,syntax,batch-file,equivalent","A_Id":4418349,"CreationDate":"2010-12-11T18:30:00.000","Title":"comparing batch to python commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok i have these commands used in batch and i wanted to know the commands in python that would have a similar affect, just to be clear i dont want to just use os.system(\"command here\") for each of them. For example in batch if you wanted a list of commands you would type help but in python you would type help() and then modules... I am not trying to use batch in a python script, i just wanna know the similarities in both languages. Like in english you say \" Hello\" but in french you say \"Bonjour\" not mix the two languages. (heres the list of commands\/functions id like to know:\n\nchange the current directory\nclear the screen in the console \nchange the prompt to something other than >>>\nhow to make a loop function\nredirections\/pipes\nstart an exteral program (like notepad or paint) from within a script\nhow to call or import another python script\nhow to get help with a specific module without having to type help() \n\n@8: (in batch it would be command \/?)\nEDITED COMPLETELY\nThanks in Adnvance!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2645,"Q_Id":4418252,"Users Score":0,"Answer":"I am pretty much facing the same problem as you, daniel11. As a solution, I am learning BATCH commands and their meaning. After I understand those, I am going to write a program in Python that does the same or accomplishes the same task.\nThanks to Adam V. and katrielatex for their insight and suggestions.","Q_Score":1,"Tags":"python,syntax,batch-file,equivalent","A_Id":17412938,"CreationDate":"2010-12-11T18:30:00.000","Title":"comparing batch to python commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having trouble figuring out how to best implement a document (paragraph-) revision system in Django.\nI want to save a revision history of a document, paragraph-by-paragraph. In other words, there will be a class Document, which has a ManyToManyField to Paragraph. To maintain the order of the paragraphs, a third class ParagraphContainer can be created.\nMy question is, what is a good way to implement this in Django so that the order of paragraphs is maintained when someone adds a new paragraph in-between existing paragraphs? \nOne obvious way would be to have a position attribute in the ParagraphContainer class, but then this field will have to be updated in all paragraphs following the inserted (or deleted) paragraph. A linked list is another option, but I'm scared that might be very slow for retrieval of the whole document. Any advice?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":304,"Q_Id":4418461,"Users Score":2,"Answer":"Editors often solve this problem with a Piece Table. The table is a list of objects that point to spans of characters that are a) contiguous in memory, and b) share common attributes. The order of the pieces in the table is used for mapping character-in-document addresses to memory and vice versa. By reordering the piece table you effectively reorder the document without moving anything around. The key point is that the piece table itself is independent of the objects that make up the content of the document.\nSo one way of mapping your paragraph order would be to have a simplified version of a peice table. This could be as simple as a list of para-ids in document order. When you need to change something, you fetch the list, unpickle it, make you edits on the list, pickle and save.\nAnother advantage of the table is that it greatly simplifies implementing undo. The history file is a simple list of edits to the table, and undoing\/redoing is a matter of reversing or reapplying a particular edit to the table, the data itself doesn't change. This should play well with any versioning you want to do.","Q_Score":1,"Tags":"python,django,database-design","A_Id":4418851,"CreationDate":"2010-12-11T19:17:00.000","Title":"How to maintain order of paragraphs in a Django document revision system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Has anyone figured out a way to change the brace matching colours in WingIDE?  I have managed to manually port my favourite colour scheme across from my text editor and the default green just doesn't do it for me.  I've been unable to find instructions on how to do this in the UI, user manual and mailing lists.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":4418839,"Users Score":1,"Answer":"I've contacted Wingware support and they have confirmed that there is no way to set the brace matching colour.","Q_Score":3,"Tags":"python,wing-ide","A_Id":4431943,"CreationDate":"2010-12-11T20:40:00.000","Title":"WingIDE brace matching colours","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to go about finding a string you don't know what is, in a string. I am writing an IRC bot and i need this function. I want to be able to write:\n!greet Greg\nand then my bot is supposed to say \"Hi, Greg!\". So what comes after greet is variable. And if i wrote !greet Matthew it would say \"Hi, Matthew!\".\nIs this possible?\nThanks a lot.\nAndesay","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":361,"Q_Id":4422948,"Users Score":-1,"Answer":"if \"Greg\" in greet:\n  doSomething(\"Hi Greg\")\nthe key is that strings take the in operator","Q_Score":2,"Tags":"python,irc","A_Id":4422957,"CreationDate":"2010-12-12T17:35:00.000","Title":"How to find x in a string in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that calls a USB-based data-acquisition C# dotnet executable. The main python script does many other things, e.g. it controls a stepper motor.  We would like to check the relative timing of various operations, for that purpose the dotnet exe generates a log with timestamps from C# Stopwatch.GetTimestamp(), which as far as I know yields the same number as calls to win32 API QueryPerformanceCounter().\nNow I would like to get similar numbers from the python script.  time.clock() returns such values, unfortunately it subtracts the value obtained at the time of 1st call to time.clock().  How can I get around this?  Is it easy to call QueryPerformanceCounter() from some existing python module or do I have to write my own python extension in C?\nI forgot to mention, the python WMI module by Tim Golden does this:\nwmi.WMI().Win32_PerfRawData_PerfOS_System()[0].Timestamp_PerfTime\n, but it is too slow, some 48ms overhead. I need something with <=1ms overhead.  time.clock() seems to be fast enough, as is c# Stopwatch.GetTimestamp().\nTIA,\nRadim","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1794,"Q_Id":4430227,"Users Score":0,"Answer":"You could just call the C# StopWatch class directly from Python couldn't you?  Maybe a small wrapper is needed (don't know Python\/C# interop details - sorry) - if you are already using C# for data acquisition, doing the same for timings via Stopwatch should be simpler than anything else you can do.","Q_Score":4,"Tags":"python,winapi,api,performancecounter","A_Id":4430461,"CreationDate":"2010-12-13T15:10:00.000","Title":"python on win32: how to get absolute timing \/ CPU cycle-count","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script, called test.py, that does the following:\nwhile (1):\n....print \"hello world\"\n(this script simply prints 'hello world' continuously).\n\nNow, I am using two machines (machine A and machine B). Same user is used for both machines. I would like to do the following:\n(1)   [working with machine A]   run test.py programatically on machine A {  meaning, a local python script will be running test.py using say os.system(....)  }\n       ( at this point, the script test.py is printing \"hello world\" to the screen of machine A )\n(2)   [working with machine B]   I now want to log in into machine A using ssh and 'view' the output of the script that we ran in (1)\nHow do I achieve this?  I know how to write the script that will be running and starting test.py on machine A. I also know how to ssh from machine B to machine A.\nWhat I don't know is:\n(*)    What command should I use in (1) in order to run the python script so that its output can be easily viewed while logging from a different machine (machine B) to machine A?\n(*)    Following the ssh from machine B to machine A, how do I 'navigate' to the screen that shows the output of test.py?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1034,"Q_Id":4430408,"Users Score":1,"Answer":"A very quick alternative is to pipe the output of your python program to a file, and then simply using tail with the second user to see the output as it's being written to the file. However, with a program like you have there, the file will very quickly become massive.","Q_Score":2,"Tags":"python,linux,ubuntu,ssh","A_Id":4430456,"CreationDate":"2010-12-13T15:26:00.000","Title":"View Script Output Over SSH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"On the front-end, I have a PHP webapp that allows users to create a list of their websites (5 max).\nOn the back-end, a Python script runs daily (and has ~10 iterations) for each website that the user registers. Each script per website takes about 10 seconds to run through all iterations and finish its scraping. It then makes a CSV file with its findings.\nSo, in total, that's up to (5 websites * 10 iterations =) 50 iterations at 8.3 total minutes per user.\nRight now, the script works when I manually feed it a URL, so I'm wondering how to make it dynamically part of the webapp.\n\nHow do I programmatically add and remove scripts that run daily depending on the number of users and the websites each user has each day?\nHow would I schedule this script to run for each website of each user, passing in the appropriate parameters?\n\nI'm somewhat acquainted with cronjobs, as it's the only thing I know of that is made for routine processes.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":772,"Q_Id":4441933,"Users Score":0,"Answer":"Do you need to run the script 50 times per user, or only when the user has logged into your service to check on things?","Q_Score":0,"Tags":"php,python,design-patterns,cron,screen-scraping","A_Id":4441983,"CreationDate":"2010-12-14T17:06:00.000","Title":"Best practice for running a daily Python screen-scraping script 50 times (8.3 minutes total) per user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"On the front-end, I have a PHP webapp that allows users to create a list of their websites (5 max).\nOn the back-end, a Python script runs daily (and has ~10 iterations) for each website that the user registers. Each script per website takes about 10 seconds to run through all iterations and finish its scraping. It then makes a CSV file with its findings.\nSo, in total, that's up to (5 websites * 10 iterations =) 50 iterations at 8.3 total minutes per user.\nRight now, the script works when I manually feed it a URL, so I'm wondering how to make it dynamically part of the webapp.\n\nHow do I programmatically add and remove scripts that run daily depending on the number of users and the websites each user has each day?\nHow would I schedule this script to run for each website of each user, passing in the appropriate parameters?\n\nI'm somewhat acquainted with cronjobs, as it's the only thing I know of that is made for routine processes.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":772,"Q_Id":4441933,"Users Score":0,"Answer":"Assuming you're using a database to store the users' web sites, you can have just 1 script that runs as a daily cron job and queries the database for the list of sites to process.","Q_Score":0,"Tags":"php,python,design-patterns,cron,screen-scraping","A_Id":4441994,"CreationDate":"2010-12-14T17:06:00.000","Title":"Best practice for running a daily Python screen-scraping script 50 times (8.3 minutes total) per user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a wxPython listbox on Windows to get a choice from the user, and I would like them to be able to select an item using the ENTER key, as if they had double-clicked. I know how to do this in C or C++ using the Windows API directly, but can't seem to find how to do it using wxPython. Anyone know how? It seems like an obvious thing to want to do.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":721,"Q_Id":4451166,"Users Score":1,"Answer":"The simple answer is that the wx.ListBox doesn't support that. Try using a one column wx.ListCtrl (in Report mode) instead.","Q_Score":2,"Tags":"python,windows,wxpython","A_Id":4465221,"CreationDate":"2010-12-15T14:50:00.000","Title":"Keyboard interface to wxPython listbox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a wxPython listbox on Windows to get a choice from the user, and I would like them to be able to select an item using the ENTER key, as if they had double-clicked. I know how to do this in C or C++ using the Windows API directly, but can't seem to find how to do it using wxPython. Anyone know how? It seems like an obvious thing to want to do.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":721,"Q_Id":4451166,"Users Score":1,"Answer":"Maybe I'm missing some nuance, there wasn't much info to go on, but it sounds like you could accomplish this by catching the keydown event, matching for enter and then calling your on_doubleclick function. Unless there's an implicit double-click handling you should be good to go.","Q_Score":2,"Tags":"python,windows,wxpython","A_Id":4451586,"CreationDate":"2010-12-15T14:50:00.000","Title":"Keyboard interface to wxPython listbox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I send several forms to a template, and I want to put all required media in the <head> tag. Some forms might require the same media (for instance, the same JS file), so I would like to unify all medias before putting them in the <head>. Question is, how do I do that? I know you can unify two medias by doing m1 + m2, but this will look ugly in the generic case where I have an unknown number of forms. Is there some shortcut?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":4456591,"Users Score":0,"Answer":"What happens if you just use {{ form.media }} for each form, and link up the media in the form's Meta? I seem to remember that making sure that it didn't insert anything twice, but it's been a while.\nHave you tried that yet?","Q_Score":2,"Tags":"python,django,django-forms,media","A_Id":4462233,"CreationDate":"2010-12-16T01:14:00.000","Title":"Django: correct way to group a bunch of media's","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say that in the python shell (IDLE) I have defined some classes, functions, variables. Also created objects of the classes. Then I deleted some of the objects and created some others. At a later point in time, how can I get to know what are the currently active objects, variables, and methods definitions active in the memory?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":51812,"Q_Id":4458701,"Users Score":8,"Answer":"How about dir() which will output instantiated objects as a list? I just used this just now:\n[x for x in dir() if x.lower().startswith('y')]","Q_Score":53,"Tags":"python,memory,python-idle","A_Id":62961863,"CreationDate":"2010-12-16T08:24:00.000","Title":"How to get the list of all initialized objects and function definitions alive in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create a mapping from objects of my own custom class (derived from dict) to objects of another custom class. As I see it there are two ways of doing this:\n\nI can make the objects hashable. I'm not sure how I would do this. I know I can implement __hash__() but I'm unsure how to actually calculate the hash (which should be an integer).\nSince my objects can be compared I can make a list [(myobj, myotherobj)] and then implement a lookup which finds the tuple where the first item in the tuple is the same as the lookup key. Implementing this is trivial (the number of objects is small) but I want to avoid reinventing the wheel if something like this already exists in the standard library.\n\nIt seems to me that wanting to look up unhashables would be a common problem so I assume someone has already solved this problem. Any suggestions on how to implement __hash()__ for a dict-like object or if there is some other standard way of making lookup tables of unhashables?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":682,"Q_Id":4462119,"Users Score":2,"Answer":"A simple solution seems to be to do lookup[id(myobj)] = myotherobj instead of lookup[myobj] = myotherobj. Any commente on this approach?","Q_Score":6,"Tags":"python,hash,lookup,lookup-tables","A_Id":4462498,"CreationDate":"2010-12-16T15:00:00.000","Title":"Lookup table for unhashable in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently in the process of discovering OpenCL via the Python binding Clyther. So\nfar I am messing with a very simple script to get the sin or cos of a buffer of 65536. \nApparently 65536 is the limit for buffers on my card but say I'd have 16 million numbers in my buffer how would I go about it without constantly bringing the CPU into it to retrieve\/send data?\nWhat I have do so far is, fill buffer, run kernel, retrieve buffer, in a loop but that also\nhits the CPU badly.\nI looked a bit at OpenCL docs but I just failed to understand how that is achieved. \nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":156,"Q_Id":4470246,"Users Score":2,"Answer":"This awfully looks like you are using __constant memory. The solution is to use __global memory instead, but you have to be careful about how you access it for best performance.\n__constant memory is a special address space for often used constant values, but is restricted in size on current GPUs.","Q_Score":0,"Tags":"python,opencl","A_Id":4478655,"CreationDate":"2010-12-17T12:02:00.000","Title":"Processing buffers bigger than 65536 in Clyther\/OpenCL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to get it in views.py....\nrequest.META['REMOTE_ADDR']\nHowever, how do I get it in models.py when one of my forms is being validateD?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":179,"Q_Id":4476430,"Users Score":1,"Answer":"You can pass the request object to the form\/model code that is being called: this will then provide access to request.META['REMOTE_ADDR']. Alternatively, just pass that in.","Q_Score":0,"Tags":"python,django,validation,forms,ip","A_Id":4477440,"CreationDate":"2010-12-18T03:19:00.000","Title":"Inside Django's models.py, if I am validating a form, how do I get the user's IP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to get it in views.py....\nrequest.META['REMOTE_ADDR']\nHowever, how do I get it in models.py when one of my forms is being validateD?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":4476430,"Users Score":0,"Answer":"If you are validating at form level or at model level, both instances know nothing about the HTTP request (where the client IP info is stored).\nI can think of two options:\n\nValidate at the view level where you can insert errors into the form error list.\nYou can put the user IP (may be encrypted) in a hidden field at your form.","Q_Score":0,"Tags":"python,django,validation,forms,ip","A_Id":4476456,"CreationDate":"2010-12-18T03:19:00.000","Title":"Inside Django's models.py, if I am validating a form, how do I get the user's IP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been reading a lot of stackoverflow questions about how to use the breadth-first search, dfs, A*, etc, the question is what is the optimal usage and how to implement it in reality verse simulated graphs. E.g.\nConsider you have a social graph of Twitter\/Facebook\/Some social networking site, to me it seems a search algorithm would work as follows:\nIf user A had 10 friends, then one of those had 2 friends and another 3. The search would first figure out who user A's friends were, then it would have to look up who the friends where to each of the ten users. To me this seems like bfs?\nHowever, I'm not sure if that's the way to go about implementing the algorithm.\nThanks,","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1271,"Q_Id":4488783,"Users Score":0,"Answer":"I have around 300 friends in facebook and some of my friends also have 300 friends on an average. If you gonna build a graph out of it , it's gonna be huge . Correct me , if I am wrong ? . A BFS will be quit lot demanding in this scenario ?\nThanks\nJ","Q_Score":2,"Tags":"python,algorithm,social-networking,traversal,breadth-first-search","A_Id":6335027,"CreationDate":"2010-12-20T10:32:00.000","Title":"Python usage of breadth-first search on social graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to install in python 2.6 or 2.7 for windows the library PyWeka0.3dev, It says it requires setuptools, which I installed but then they told me it was a deprecated instalation library and I installed distribute, then I downloaded the PyWeka compressed package and each time I try to install it neither with setup.py nor with easy_install (where it says something like no module ez_setup). Can anybody give me a clue about how to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1152,"Q_Id":4493871,"Users Score":0,"Answer":"A punk\/goth approach to programming probably has the right to be.. \nTo get the C-compliation part to work on windows you either need (1) to have Visual Studio of the same version that was used to compile the python version you are using, or (2) mingw which is a bit trickier to set up.","Q_Score":0,"Tags":"python,windows,setuptools,distribute","A_Id":4498345,"CreationDate":"2010-12-20T20:55:00.000","Title":"Has anybody been able to install PyWeka?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With wxPython, how does one trigger an event whenever the whole window goes into\/out of focus?  \nTo elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground.  My application is just a single window derived from wx.Frame.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2304,"Q_Id":4505097,"Users Score":2,"Answer":"In addition to what these fellows are saying, you might also want to try EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW. I think these are fired when you move the mouse into and out of the frame widget, although I don't think the frame has to be in focus for those events to fire.\n@ Hugh - thanks for the readership!","Q_Score":1,"Tags":"python,wxpython,wxwidgets","A_Id":4510733,"CreationDate":"2010-12-22T00:01:00.000","Title":"wxPython Whole Window Focus Event","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With wxPython, how does one trigger an event whenever the whole window goes into\/out of focus?  \nTo elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground.  My application is just a single window derived from wx.Frame.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2304,"Q_Id":4505097,"Users Score":2,"Answer":"as WxPerl programmer i know there is \nEVT_SET_FOCUS(\nEVT_KILL_FOCUS(\nif you initialize this event by listening to the frame as first parameter it should work as in Perl since the API is almost the same","Q_Score":1,"Tags":"python,wxpython,wxwidgets","A_Id":4505382,"CreationDate":"2010-12-22T00:01:00.000","Title":"wxPython Whole Window Focus Event","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With wxPython, how does one trigger an event whenever the whole window goes into\/out of focus?  \nTo elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground.  My application is just a single window derived from wx.Frame.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2304,"Q_Id":4505097,"Users Score":5,"Answer":"The correct answer for this case is to use an EVT_ACTIVATE handler bound to the frame.  There will be an event whenever the frame is activated (brought into the foreground relative to other windows currently open) or deactivated.  You can use the event object's GetActive method to tell which just happened.","Q_Score":1,"Tags":"python,wxpython,wxwidgets","A_Id":4521758,"CreationDate":"2010-12-22T00:01:00.000","Title":"wxPython Whole Window Focus Event","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough?\nedit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":356,"Q_Id":4506008,"Users Score":1,"Answer":"The common Python platforms all support directory and file names of 32 characters or more, but I personally feel that if you find yourself breaking 11 characters often that you need to rethink things.","Q_Score":4,"Tags":"python","A_Id":4506023,"CreationDate":"2010-12-22T03:47:00.000","Title":"How important is it to use short names for Python packages and modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough?\nedit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":356,"Q_Id":4506008,"Users Score":0,"Answer":"Long names make it easy to make stupid typing mistakes later on. Any modern computer shouldn't have a problem with long filenames, but it's good practice to pick short, descriptive names. Abbreviations are your friend, especially when you like knowing what a function does off the bat,etc.","Q_Score":4,"Tags":"python","A_Id":4509044,"CreationDate":"2010-12-22T03:47:00.000","Title":"How important is it to use short names for Python packages and modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough?\nedit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":356,"Q_Id":4506008,"Users Score":1,"Answer":"The issue is with old(er) file systems (used before Windows 95 and fat16) that don't support names larger than, say, 32 characters (it varies with the file system). It's only an issue if your scripts need to run on old computers.","Q_Score":4,"Tags":"python","A_Id":4506409,"CreationDate":"2010-12-22T03:47:00.000","Title":"How important is it to use short names for Python packages and modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough?\nedit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":356,"Q_Id":4506008,"Users Score":2,"Answer":"If you need to make sure your code works on DOS, use 8 characters. :p\nOtherwise, it's a free world. But nobody likes to type insanely long strings. (See powershell = fail). So use your best judgement, and be reasonable.","Q_Score":4,"Tags":"python","A_Id":4506026,"CreationDate":"2010-12-22T03:47:00.000","Title":"How important is it to use short names for Python packages and modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a website with a limited number of cities in the database, and need to show the user the nearest city to his current location.\nI can get the location by MaxMind API, but I want to get the nearest city in my database to user city.\nFor example, if I have these cities in the database: Los Angeles, San Francisco and New York City, and I'm accessing from other city like Miami, I should see NYC selected because it's the nearest geographically.\nWhat's the best way to do this quick and performance aware?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4549,"Q_Id":4512329,"Users Score":0,"Answer":"Have it such that whenever you add a city to your database, a piece of code is run (off-line) that calculates the closest city to every city that you have. You can have each city point to another city as its closest city with a foreignkey.\nNow that you have everything pre-calculated, whenever there is a live request, with a name of a city, you just hit the database with the city name and you can get to the closest city by the foreignkey you have specified.  (city ---foreignkey---> city )\nNow that is going to be very fast as you have pre-calculated the closest city off-line and can return the result right away on each live request.\nBut how often do you plan to add a city? Probably not that often. So, the off-line pre-calculation would be rare even if it takes a bit of time to do. But live requests are responded to very fast. (others have already recommend the formula to use to calculate the distance, so I am going to skip that part!)","Q_Score":4,"Tags":"python,django,geolocation,geoip","A_Id":9200451,"CreationDate":"2010-12-22T18:23:00.000","Title":"Best way to get user nearest city? Python\/Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running Pylons on my local machine with paster, and on a Debian server using WSGI. I want to add some print statements to debug a problem: am not a Pylons or Python expert.\nOn my local machine this works fine: print statements go to the terminal. On the server, the statements don't print to the log files: instead the log file says \"IOError: failed to write data\" whenever a print statement is called.\nUntil I can fix this, I can't debug anything on the server. \nCould someone advise how to get printing running on the server? Thanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1041,"Q_Id":4517397,"Users Score":1,"Answer":"Don't use print statements, use the logging module. We can't help you without knowing the setup of the server.","Q_Score":1,"Tags":"python,pylons","A_Id":4517414,"CreationDate":"2010-12-23T09:26:00.000","Title":"Print statements on server give IOError: failed to write data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running Pylons on my local machine with paster, and on a Debian server using WSGI. I want to add some print statements to debug a problem: am not a Pylons or Python expert.\nOn my local machine this works fine: print statements go to the terminal. On the server, the statements don't print to the log files: instead the log file says \"IOError: failed to write data\" whenever a print statement is called.\nUntil I can fix this, I can't debug anything on the server. \nCould someone advise how to get printing running on the server? Thanks!","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1041,"Q_Id":4517397,"Users Score":3,"Answer":"It's wrong for a WSGI application to use sys.stdout or sys.stderr. If you want to spit debug to a server error log, use environ['wsgi.errors'].write().","Q_Score":1,"Tags":"python,pylons","A_Id":4517657,"CreationDate":"2010-12-23T09:26:00.000","Title":"Print statements on server give IOError: failed to write data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a small script that will need to read and write to text files on Windows and Linux and perhaps Mac even. The script will be used by users on all perhaps all of these platforms (Windows for sure) and interchangeably - so a user who wrote to a file X on Windows, may read the file on Linux with the script.\nWhat precautions should I take or how should I implement my code that it is able to handle line endings across various platforms? (reading and writing) \nOr this is a non-issue and Python handles everything?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":573,"Q_Id":4522026,"Users Score":3,"Answer":"It's a non-issue, Python is smart like that. It handles line endings across platforms very well.","Q_Score":2,"Tags":"python,file-io,line-endings","A_Id":4522035,"CreationDate":"2010-12-23T19:56:00.000","Title":"Line endings and reading and writing to text files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What would be the best way of separating program logic to the GUI code?\nI wanted different GUI (GTK, KDE, CLI) code using the same program logic.\nI was thinking of using different python module (winecellar-common, winecellar-gtk, winecellar-cli) not sure how I would do this and if its the best way.\n*EDITED*\nJust to add to my question what would be the best way to organize the projects file structure and build platform with different modules. Keep in mind its mainly being used on Ubuntu.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4986,"Q_Id":4522218,"Users Score":12,"Answer":"Define functions or classes for your business logic in one module, and define your presentation in another, using those functions to get your presentation. You should almost entirely be using functions and classes from the main module in the GUI module. You should do the same thing for your CLI. That way, you can have different distributions with different interfaces, and not have to create a different \"logic\" file for each one.\nBasically, you have the right idea. Just keep them as separate as possibility so that a.) you can support multiple interfaces easily and b.) you can easily make changes to the interfaces.","Q_Score":14,"Tags":"pygtk,python","A_Id":4522244,"CreationDate":"2010-12-23T20:24:00.000","Title":"Python - Separate program logic and GUI code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm PHP\/MySQL developper \nI studied python well as a desktop programming two years ago but I don't use it on the web how can I use python to build dynamic web sites and easily uploads these sites to any hosting providers","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":529,"Q_Id":4525562,"Users Score":1,"Answer":"You cant' upload python files and use it on any webhosting.\nYou can use them if the host allows it.\nSome frameworks are Django or Pylons.","Q_Score":0,"Tags":"python","A_Id":4525588,"CreationDate":"2010-12-24T09:58:00.000","Title":"how can I use python to build dynamic web sites?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm PHP\/MySQL developper \nI studied python well as a desktop programming two years ago but I don't use it on the web how can I use python to build dynamic web sites and easily uploads these sites to any hosting providers","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":529,"Q_Id":4525562,"Users Score":1,"Answer":"there are many web frameworks such as Django & web2py , you should check them out","Q_Score":0,"Tags":"python","A_Id":4525568,"CreationDate":"2010-12-24T09:58:00.000","Title":"how can I use python to build dynamic web sites?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if someone here had written\/uses a script which parses the output of objdump and extracts opcodes from it? I have a very very trivial implementation but I'm looking for something better.\nThe problem I am facing with this script is simply that it does simple string parsing; this is more of a utility script, and thats why I haven't written tests for these. I was wondering if the same could be done by writing a custom made parser or a simple yet efficient regular expression.\nThis query is for the purpose of learning, so that I can approach such a problem in a (hopefully)better manner next time.\nI don't mind the specifics of the implementation(shell,ruby,python,perl; anything would do). The code does not even matter that much, really, I'd like a few hints on how you would do it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4442,"Q_Id":4527313,"Users Score":1,"Answer":"The BEST solution would be to build objdump from source and make a python or other language swig wrapper that gets the output directly.  You CAN do it with string parsing, but that's often buggy(read as implemented poorly).  It is definitely possible to do the string parsing properly...I have a utility that relies on this.","Q_Score":3,"Tags":"python,parsing,objdump","A_Id":7283510,"CreationDate":"2010-12-24T16:28:00.000","Title":"parsing objdump output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to write a simple program that logs on to a site, does something and logs out. The problem is that the login form has three inputs: username, password and a recaptcha. I input all of them manually. The problem is I don't know how to display the captcha image or how to send the text.\nCan someone explain how to do it?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":799,"Q_Id":4533879,"Users Score":3,"Answer":"It is unreasonable to except that someone will post a complete solution for your problem.\nHere are the steps, just start by trying to complete them, post questions if you get stuck.\nvery generally speaking:\n\nGet the content of the site (use the urllib2 to fetch the page)\nParse the recaptcha image link and download the image (BeautifulSoup for parsing the link, urllib2 again for downloading the image)\nprompt yourself with the image and input for the code (use Tkinter for example)\nsend login info & captcha( urllib2)\ndo stuff (urllib2 again)\n\nThere's probably some token that you also have to fetch that identifies your Captcha image. Use firebug to watch for the requests sent when submitting the Captcha.","Q_Score":3,"Tags":"python","A_Id":4534157,"CreationDate":"2010-12-26T12:52:00.000","Title":"Handling reCaptcha forms?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a PyQt application that reads and writes data files. I am including a 'version number' in each file written.  This is a simple number similar to: 1.2  or something (major and minor versions).\nI am doing this so that I can change the format of these data files in future versions and then still correctly parse them simply by checking to see what the version is inside the file.\nMy question is what is the best practice for keeping this number stored inside the app itself.  I.e. do I just hard-code the app version number into the class that is responsible for reading and writing files?  Or should I have some sort of object\/variable stored at the top-level of the app and somehow access it from the class responsible for reading and writing these files.  If the latter, how do I store it and how do I access it?\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3932,"Q_Id":4535895,"Users Score":0,"Answer":"Personally, I wouldn't do it manually this way.  I'd save my code in Subversion and let it maintain the revision numbers for me.","Q_Score":5,"Tags":"python,version,global-variables","A_Id":4535921,"CreationDate":"2010-12-26T23:43:00.000","Title":"Python: Best practice for including a version number in an app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"i have a application which use rails to do the CRUD operation,it's handy\nnow i want to write a crawler use python,after that i want to save the data to db,\nso my question is how to python communicate with ror program?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":148,"Q_Id":4537434,"Users Score":0,"Answer":"Via the CRUD interface, seems the obvious solution.","Q_Score":0,"Tags":"python,web-services,rest,ruby-on-rails-3","A_Id":4537518,"CreationDate":"2010-12-27T08:21:00.000","Title":"how to communicate with ror program in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a application which use rails to do the CRUD operation,it's handy\nnow i want to write a crawler use python,after that i want to save the data to db,\nso my question is how to python communicate with ror program?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":148,"Q_Id":4537434,"Users Score":1,"Answer":"I don't have any idea about python or rails (only grails :) but the easiest solution (if you don't want the python script to touch the DB) would be to implement a controller action for the REST PUT method in your rails application and call it from your python crawler with the crawled data.\nNow, all the rails controller has to do is to inster the data into your database.","Q_Score":0,"Tags":"python,web-services,rest,ruby-on-rails-3","A_Id":4537524,"CreationDate":"2010-12-27T08:21:00.000","Title":"how to communicate with ror program in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I meet a problem when I try to install module omniORB&omniORBpy to a system, I don't have the root permission so I use --prefix to installed them to my user dir.\nmy question is : how can I make python load this module? I try add my user path to sys.path, but it still doesn't work.\nBr,\nJ.K.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1009,"Q_Id":4537975,"Users Score":4,"Answer":"You can add it to the search path by adding the directory to the environment variable PYTHONPATH or by adding it to sys.path in your Python script. Both work; if they don't, then you're using the wrong path.","Q_Score":2,"Tags":"python,module","A_Id":4537989,"CreationDate":"2010-12-27T10:14:00.000","Title":"add a python module with out root permission","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I meet a problem when I try to install module omniORB&omniORBpy to a system, I don't have the root permission so I use --prefix to installed them to my user dir.\nmy question is : how can I make python load this module? I try add my user path to sys.path, but it still doesn't work.\nBr,\nJ.K.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1009,"Q_Id":4537975,"Users Score":1,"Answer":"I usually use the --user option instead of --prefix, since it installs it in ${HOME}\/.local\/lib\/pythonx\/site-packages and thus it does not require to add the path to sys.path.\nI think this option is available only for python 2.6 + but I am not sure.\nIf you have to install it in an other place, then you have no choice and I don't know what could be wrong.\nBy the way, maybe posting some sample code(just to see where exactly are the files and how you try to import them) would make clearer the \"error\".","Q_Score":2,"Tags":"python,module","A_Id":4540025,"CreationDate":"2010-12-27T10:14:00.000","Title":"add a python module with out root permission","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose you have a client\/server application, say a webserver component and a qt gui. How do you layout your python code?\n\nPackages foo.server and foo.client?\nPackages fooserver and fooclient, with both importing from foocommon?\nEverything together with no clear distinction?\n\nHaving subpackages for server and client code (foo.server and foo.client) seems the best approach to me, but then how do you handle your distutils setup if you don't want the server code to be shipped along with the client code? If you use setuptools (I would rather not), how do you create separate eggs?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":513,"Q_Id":4541603,"Users Score":-1,"Answer":"Having subpackages for server and client code (foo.server and foo.client) seems the best approach to me, \n\nWhy?  No single user (except you the developer) will ever use both sides.  They're completely separate.\n\nbut then how do you handle your distutils setup if you don't want the server code to be shipped along with the client code? \n\nPrecisely.  They're almost completely unrelated.\nFor guidance, look at other client-server applications.\nThe World Wide Web, for example.\nThe Apache HTTPD server and the Firefox browser do not have any common code that I can see.  Maybe a few underlying libraries, but they're clearly not htttpd.client and httpd.server.  They're clearly utterly separate.\nThe Sendmail server and the pop\/imap libraries in Python seem to be utterly separated with almost nothing in common.\nThe MySQL database server and the MySQLDB interface in Python seem to be utterly and completely separated with almost nothing in common.\nI can't see any examples of foo.server and foo.client anywhere.  Perhaps you could share an example as part of your question to help clarify your thinking on this subject.","Q_Score":2,"Tags":"python,distutils","A_Id":4541879,"CreationDate":"2010-12-27T20:29:00.000","Title":"Python client\/server project code layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose you have a client\/server application, say a webserver component and a qt gui. How do you layout your python code?\n\nPackages foo.server and foo.client?\nPackages fooserver and fooclient, with both importing from foocommon?\nEverything together with no clear distinction?\n\nHaving subpackages for server and client code (foo.server and foo.client) seems the best approach to me, but then how do you handle your distutils setup if you don't want the server code to be shipped along with the client code? If you use setuptools (I would rather not), how do you create separate eggs?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":513,"Q_Id":4541603,"Users Score":0,"Answer":"I like namespaces, so yes. foo.client and foo.server and foo.common and foo.anythingelsethatcanbeusedseparately. But it's all a matter of taste, really.\nAnd I'd release them as separate packages, and yes, I'd use Distribute.","Q_Score":2,"Tags":"python,distutils","A_Id":4541657,"CreationDate":"2010-12-27T20:29:00.000","Title":"Python client\/server project code layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to figure out how can i make my code more asynchronous using twisted.\n\nA function returns a deferred object\nthen i add a list of callbacks\nthe first callback will be called after the deferred function provides some result through deferred_obj.callback\nthen, in the chain of callbacks, the first callback will do something with the data and call the second callback\nand etc. \n\nhowever chained callbacks will not be considered asynchronous because they're chained and the event loop will keep firing each one of them concurrently until there is no more, right?\nHowever, if I have a deferred object, and I attach as its callback the deferred_obj.callback as in d.addCallback(deferred_obj.callback) then this will be considered asynchronous, because the deferred_obj is waiting for the data, and then the method that will pass the data is waiting on data as well, however once i d.callback 'd' object processes the data then it call deferred_obj.callback however since this object is deferred, unlike the case of chained callbacks, it will execute asynchronously... correct?\nAssuming all of my code is non-blocking, this means that chained callbacks are NOT asynchronous while chained deferreds are, correct?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":11007,"Q_Id":4541853,"Users Score":2,"Answer":"Sort of, but there is no concurrency in this type of event processing. No new callback will be called until the code gets back to the event loop. So the chain of callbacks is synchronous. It's only asynchronous in the event loop.\nThis is one caveat of this type of programming, the handlers most execute quickly, and get back to the event loop ASAP. It should not do any time consuming task in a handler.","Q_Score":6,"Tags":"python,asynchronous,callback,twisted,deferred","A_Id":4541923,"CreationDate":"2010-12-27T21:07:00.000","Title":"twisted deferred\/callbacks and asynchronous execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have Python 2.6.1 which came on the Mac I have, but I'd recently downloaded and installed the disk image of 3.1.3 and I'd like to have it available in Terminal, how can I do this?  For instance when I do $ python -V in Terminal I get 2.6.1.\nThanks for any help.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":4542014,"Users Score":0,"Answer":"First, I'm not a Mac user, so I don't know a couple of specifics (default PATH, etc). \nAlso, a bit of clarity - when you use the installer, it lets you customize the installation to install in a specific location - do you know where that is. If you didn't select a location, it defaults to \/usr\/local\/bin.\nFrom Terminal, try \"python3\".  If that fails, try \"\/usr\/local\/bin\/python3\".\nOutside of that, wherever it's found, you'll want that in your path statement if it isn't there already.\nIt's not recommended that you \"replace\" the system python with python 3.x, as you'll definitely have problems.","Q_Score":2,"Tags":"python","A_Id":4542064,"CreationDate":"2010-12-27T21:38:00.000","Title":"Updated Python from disk image, want to make it available in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Python 2.6.1 which came on the Mac I have, but I'd recently downloaded and installed the disk image of 3.1.3 and I'd like to have it available in Terminal, how can I do this?  For instance when I do $ python -V in Terminal I get 2.6.1.\nThanks for any help.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":151,"Q_Id":4542014,"Users Score":1,"Answer":"The default Python version in Mac OS X needs to stay the default Python version, or things will break. You want to install it alongside with Python 2. This is most likely exactly what happened, but you start Python 3 with python3.","Q_Score":2,"Tags":"python","A_Id":4542091,"CreationDate":"2010-12-27T21:38:00.000","Title":"Updated Python from disk image, want to make it available in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some code which depends on Greenlets, and need to remove this dependency. \nCan anyone explain to me exactly what I'll need to do? \nThey would preferably be replaced with threads or (better yet) processes from the multiprocessing module, but anything that relies solely on the Python standard library would be sufficient for my needs. \nFunctionality can be sacrificed, as I don't need asynchronous code, nor does the code that I am converting (for my uses, not the original implementation). \nUPDATE:\nSpecifically, I need to know of alternatives to Greenlet.spawn()","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":194,"Q_Id":4547096,"Users Score":1,"Answer":"It really depends on the structure of your code and high level architecture of your system. If you think that whatever you are using greenlets for can be done using multiprocessing module in the Python Standard library, then you can do that. I think, if you post specific instances than you can get the specific ways to those using multiprocessing. But beware these are two different ways to solve a generic problem of concurrency.","Q_Score":0,"Tags":"python,multithreading,multiprocessing","A_Id":4547398,"CreationDate":"2010-12-28T15:24:00.000","Title":"Removing code dependency on Greenlets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been working on this for a long time, and I feel very worn out; I'm hoping for an [obvious?] insight from SO community that might get my pet project back on the move, so I can stop kicking myself. I'm using Cloudera CDH3, HBase .89 and Hadoop .20.\nI have a Python\/Django app that writes data to a single HBase table using the Thrift interface, and that works great. Now I want to Map\/Reduce it into some more HBase tables. \nThe obvious answer here is either Dumbo or Apache PIG, but with Pig, the HBaseStorage adapter support isn't available for my version yet (Pig is able to load the classes and definitions, but freezes at the \"Map\" step, complaining about \"Input Splits\"; Pig mailing lists suggest this is fixed in Pig 0.8, which is incompatible with CDH3 Hadoop, so I'd have to use edge versions of everything [i think]). I can't find any information on how to make Dumbo use HBaseStorage as a data sink.\nI don't care if it's Python, Ruby, Scala, Clojure, Jython, JRuby or even PHP, I just really don't want to write Java (for lots of reasons, most of them involving the sinking feeling I get every time I have to convert an Int() to IntWritable() etc).\nI've tried literally every last solution and example I can find (for the last 4 weeks) for writing HBase Map\/Reduce jobs in alternative languages, but everything seems to be either outdated or incomplete. Please, Stack Overflow, save me from my own devices!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1322,"Q_Id":4557045,"Users Score":0,"Answer":"It's not precisely an answer, but it's the closest I got --\nI asked in #hbase on irc.freenode.net yesterday, and one of the Cloudera employees responded.\nThe \"Input Splits\" problem I'm having with Pig is specific to Pig 0.7, and Pig 0.8 will be bundled with Cloudera CDH3 Beta 4 (no ETA on that). Therefore, what I want to do (easily write M\/R jobs using HBase tables as both sink and source) will be possible in their next release. It also seems that the HBaseStorage class will be generally improved to help with read\/write operations from ANY JVM language, as well, making Jython, JRuby, Scala and Clojure all much more feasible as well.\nSo the answer to the question, at this time, is \"Wait for CDH3 Beta 4\", or if you're impatient, \"Download the latest version of Pig and pray that it's compatible with your HBase\"","Q_Score":1,"Tags":"python,hadoop,mapreduce,hbase","A_Id":4567653,"CreationDate":"2010-12-29T19:12:00.000","Title":"Easiest non-Java way to write HBase MapReduce on CDH3?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"When using Django for html templating how do I create good html markup formatting.\nI am trying to make use of content blocks.  But the content blocks show up at different levels of indentation in different templates.  How do I get the content blocks to show indented like it would be if someone was to hand write the html.\nI am having the same problem with newlines; I can smash all the blocks together in the template. At that point the html looks better, but the templates are unmaintainable.\nI guess the question is how to you create pretty html markup with the django templating system?\nI am surprised by the answers so far. I find that nicely formatted HTML aids in writing the corresponding CSS and JavaScript. As well as making it easier to add content later on.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5075,"Q_Id":4567031,"Users Score":0,"Answer":"The readability of HTML doesn't matter.  In a system like Django or Rails, HTML is an output format, not a source format.  When people edit HTML by hand, they are right to be concerned about indentation and spacing, because it is a source format, and someone will have to edit it in the future.  But the output of templates is just that: output.  The browser doesn't care about the indentation.  At this point the only people who read the HTML are people looking at View - Source.","Q_Score":15,"Tags":"python,html,django,templates","A_Id":4567219,"CreationDate":"2010-12-30T23:20:00.000","Title":"Creating readable html with django templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm porting some Python code to Java, and I am having trouble dealing with the following problem:\nI have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future.\nI solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way.\nThanks!","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":4567692,"Users Score":0,"Answer":"You can define the abilities in interfaces and implement them in your classes.","Q_Score":1,"Tags":"java,python,multiple-inheritance","A_Id":4567713,"CreationDate":"2010-12-31T02:30:00.000","Title":"Multiple inheritance in Python; how to do so in Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm porting some Python code to Java, and I am having trouble dealing with the following problem:\nI have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future.\nI solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way.\nThanks!","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":4567692,"Users Score":0,"Answer":"If what you need is interface inheritance, then as mentioned before, you can always implement multiple interfaces.\nIf you're looking for implementation inheritance, you're somewhat out of luck. The best solution is probably to use delegation \u2014 replace the extra superclasses with fields, and implement methods that just delegate to those fields. It does require writing a lot of repetitive delegation methods, but it's rather unavoidable in Java (without resorting to AspectJ or other bytecode-munging tricks; careful, this way madness lies \u2026).","Q_Score":1,"Tags":"java,python,multiple-inheritance","A_Id":4567774,"CreationDate":"2010-12-31T02:30:00.000","Title":"Multiple inheritance in Python; how to do so in Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm porting some Python code to Java, and I am having trouble dealing with the following problem:\nI have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future.\nI solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way.\nThanks!","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":4567692,"Users Score":0,"Answer":"This is a bit tangential, but you can have python code running in Java via Jython (http:\/\/www.jython.org\/). This addresses the porting to Java part, not the solving multiple inheritance part (I think you need to determine which is relevant)","Q_Score":1,"Tags":"java,python,multiple-inheritance","A_Id":4567861,"CreationDate":"2010-12-31T02:30:00.000","Title":"Multiple inheritance in Python; how to do so in Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm porting some Python code to Java, and I am having trouble dealing with the following problem:\nI have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future.\nI solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way.\nThanks!","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":4567692,"Users Score":0,"Answer":"In java you don't have multiple inheritance, instead you can implement multiple interfaces.\nSo your class 1 will implement interface A and B. Class 2 will implement interface A, B and C. Class 3 will implement B and C.","Q_Score":1,"Tags":"java,python,multiple-inheritance","A_Id":4567720,"CreationDate":"2010-12-31T02:30:00.000","Title":"Multiple inheritance in Python; how to do so in Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i got this error while running my function.   \n\"socket.error: [Errno 98] Address already in use\"  \nhow can i close the address already in use and start new connection with port in python?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2831,"Q_Id":4568040,"Users Score":0,"Answer":"Stop the program or the service which is the port which you are trying to use. Alternatively, for whatever program which you are trying to write, use a PORT number which is a sufficiently high number (> 1024 for sure) and is unused.","Q_Score":2,"Tags":"python,sockets","A_Id":4568045,"CreationDate":"2010-12-31T04:17:00.000","Title":"python socket programming error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i got this error while running my function.   \n\"socket.error: [Errno 98] Address already in use\"  \nhow can i close the address already in use and start new connection with port in python?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":2831,"Q_Id":4568040,"Users Score":3,"Answer":"These scenarios will raise error \"[Errno 98] Address already in use\" when you create a socket at certain port:\n\nThe port was't closed. When you created a socket, but forgot to close it, or annother program hold that.\nYou have close the socket(or kill the process), but the port stay at TIME_WAIT status in 2 MSL(about 2 minutes).\n\nTry \"netstat\" command to view port usage\nsuch as\n\nnetstat  -na\n\nor \n\nnetstat -na |grep 54321","Q_Score":2,"Tags":"python,sockets","A_Id":4568824,"CreationDate":"2010-12-31T04:17:00.000","Title":"python socket programming error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm interested in getting into C to get close to the metal performance, but would like to write in a Pythonic style and don't want to roll my own dynamic strings, lists, and dictionaries. Cython is pretty good, but would like to know how to use dynamic variables in straight C if possible. \nWith C++ there is of course the STL, which will give you String, Vector, and Map. Certainly one possibility is to program in a C-like style in C++, using only those features. Is that the standard practice if you need dynamic variables in C?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":380,"Q_Id":4571807,"Users Score":3,"Answer":"Use C++; it has standard and highly-optimized versions of all of these.  There's absolutely no reason or benefit to limit yourself to C.\n(ed: In other words, yes, that's a very standard practice.  Remember, there's no requirement to use any of C++'s features when using C++; by design, you can pick and choose.  I often disable exceptions, for example, since it leads to massively bloated executables.  There's simply no reason to write code in C.)","Q_Score":0,"Tags":"c++,python,c,cython","A_Id":4571848,"CreationDate":"2010-12-31T18:52:00.000","Title":"Is there a standard set of libraries for dynamic strings, lists, and dictionaries in C?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can someone suggest some basic advice on dealing with web applications that interact with configuration files like httpd.conf, bind zone files, etc.\nI understand that it's bad practice, in fact very dangerous to allow arbitrary execution of code without fully validating it and so on. But say you are tasked to write a small app that allows one to add vhosts to an apache configuration.\nDo you have your code execute with full privileges, do you write future variables into a database and have a cron job (with full privileges) execute a script that pulls the vars from the database and throws them into a template config file, etc.\nSome thoughts & contributions on this issue would be appreciated.\ntl;dr - how can you securely write a web app to update\/create entries in a config file like apache's httpd.conf, etc.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":332,"Q_Id":4573468,"Users Score":1,"Answer":"I'm not a Unix security guru, but some basic things to think of:\n\nMake sure your web app runs as a specific user, and make sure that user has privileged rights only to those files which it is supposed to modify.\nDo not allow arbitrary inputs to be added to the files, have strict forms where each field is validated to contain only things it should contain, like a-z and 0-9 only, etc.\nUse HTTPS to access the site.\n\nI'm sure there is more to come from the real gurus.","Q_Score":5,"Tags":"php,python,ruby-on-rails,system-administration,database-administration","A_Id":4573569,"CreationDate":"2011-01-01T07:34:00.000","Title":"What is good practice for writing web applications that control daemons (and their config files)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Has anybody got a working example of using the curses.textpad.Textbox widget to edit existing text? This is, of course, in a Linux terminal (e.g. xterm).","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":16216,"Q_Id":4581441,"Users Score":6,"Answer":"textpad.Textbox(win, insert_mode=True) provides basic insert support. Backspace needs to be added though.","Q_Score":11,"Tags":"python,ncurses","A_Id":8763488,"CreationDate":"2011-01-03T01:05:00.000","Title":"Edit text using Python and curses Textbox widget?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created the number of schedulers using python in windows which are running in background.\nCan anyone tell me any command to check how many schedulers running on windows and also how can I remove them?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":361,"Q_Id":4585237,"Users Score":0,"Answer":"All your schedulers are part of your a single Python process, then you won't be able to count the the individual timers which are scheduled. As the python schedulers are something you write, you can choose to keep a file which would be updated periodically.\nIf each scheduler is a separate python process, then count the many python processes from your Windows task manager.","Q_Score":1,"Tags":"python","A_Id":4585382,"CreationDate":"2011-01-03T14:25:00.000","Title":"problems in Python Sched","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a PyQt3 (Or 4) Windows binary installer for Python 2.3? I've googled around for an hour now but to no avail. Why am I using version 2.3? With my project file size is paramount. Without the interface, un-needed modules and compressing using UPX the resulting .exe size is a mear 750KB's. Just need to add the interface which will beaf the size up considerably I know but it will still be a good size.\nSo anyone know how I can install PyQt3 or 4 with Python2.3?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":209,"Q_Id":4588045,"Users Score":3,"Answer":"Python 2.3 is extremely old. You really shouldn't be using it at all. I seriously doubt there's any qt bindings for it that would even compile. Why do you think using python 2.3 will save you so much file size?\nAdding pyqt will probably increase your file size by 10s of megabytes at least. Just use python at least 2.6. This is definitely a case of premature optimization. And optimizing something stupid like file size.","Q_Score":0,"Tags":"python,pyqt,python-2.3","A_Id":4588075,"CreationDate":"2011-01-03T20:24:00.000","Title":"PyQt & Python2.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After 2 days of debug, I nailed down my time-hog: the Python garbage collector.\nMy application holds a lot of objects in memory. And it works well.\nThe GC does the usual rounds (I have not played with the default thresholds of (700, 10, 10)).\nOnce in a while, in the middle of an important transaction, the 2nd generation sweep kicks in and reviews my ~1.5M generation 2 objects.\nThis takes 2 seconds!\nThe nominal transaction takes less than 0.1 seconds.\nMy question is what should I do?\nI can turn off generation 2 sweeps (by setting a very high threshold - is this the right way?) and the GC is obedient.\nWhen should I turn them on?\nWe implemented a web service using Django, and each user request takes about 0.1 seconds.\nOptimally, I will run these GC gen 2 cycles between user API requests. But how do I do that?\nMy view ends with return HttpResponse(), AFTER which I would like to run a gen 2 GC sweep.\nHow do I do that? Does this approach even make sense?\nCan I mark the object that NEVER need to be garbage collected so the GC will not test them every 2nd gen cycle?\nHow can I configure the GC to run full sweeps when the Django server is relatively idle?\nPython 2.6.6 on multiple platforms (Windows \/ Linux).","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":4978,"Q_Id":4594522,"Users Score":1,"Answer":"An alternative might be to disable GC altogether, and configure mod_wsgi (or whatever you're using) to kill and restart processes more frequently.","Q_Score":11,"Tags":"python,django,garbage-collection","A_Id":4595172,"CreationDate":"2011-01-04T14:12:00.000","Title":"Django Python Garbage Collection woes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am an amateur using Python on and off for some time now. Sorry if this is a silly question, but I was wondering if anyone knew an easy way to grab a bunch of lines if the format in the input file is like this:\n\"\nHeading 1\nLine 1\nLine 2\nLine 3\nHeading 2\nLine 1\nLine 2\nLine 3\n\"\nI won't know how many lines are after each heading, but I want to grab them all. All I know is the name, or a regular expression pattern for the heading.\nThe only way I know to read a file is the \"for line in file:\" way, but I don't know how to grab the lines AFTER the line I'm currently on. Hope this makes sense, and thanks for the help!\n*Thanks for all the responses! I have tried to implement some of the solutions, but my problem is that not all the headings are the same name, and I'm not sure how to work around it. I need a different regular expression for each... any suggestions?*","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":16585,"Q_Id":4595197,"Users Score":-1,"Answer":"I don't really know Python, but here's a bit of pseudocode.\nint header_found=0;\n[start where loop where you're looping through lines of file]\nif(header_found==1)\n    [grab line];\n    header_found=0;\nif(line=~\/[regexp for header]\/)\n    header_found=1;\nThe idea is to have a variable that keeps track of whether or not you've found a header, and if you have, to grab the next line.","Q_Score":7,"Tags":"python,text,file-io","A_Id":4595284,"CreationDate":"2011-01-04T15:19:00.000","Title":"How to grab the lines AFTER a matched line in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.\nNow initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.\nBut i am confused how can we make make separate modules in diff languages and combine to make one website\nAny ideas","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":4605243,"Users Score":0,"Answer":"If they're different pages, they can easily be created by different software. So if a mail application written in Java offers a link to an address book, the address book can easily be Python--that's just a matter of configuring the server.\nIf you need an addressbook component within the mail application, that's a bit more complicated, but still doable. Especially with Java and .NET it's possible to run various languages on the same platform (e.g. Jython and Ironpython run Python on the JAVA and .NET VMs respectively).","Q_Score":0,"Tags":"python,web,yahoo","A_Id":4605453,"CreationDate":"2011-01-05T14:37:00.000","Title":"Is it possible to use different technologies in one website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.\nNow initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.\nBut i am confused how can we make make separate modules in diff languages and combine to make one website\nAny ideas","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":4605243,"Users Score":2,"Answer":"Phisical architecture of web application can be different from the logical one visible through browser. Basically it is achieved by putting front web server (think of apache with mod_proxy, but it can be any other moder web server supporting reverse proxying) and mounting web application servers (java\/python\/whatever) to different paths (like \/app1 for java app, \/app1\/subapp for python app, \/app2 for php app). Of course those applications work independently by default, so if you want to pass some data between you have to establish some communication between (direct socket-to-socket or indirect with some messaging middleware or database). \nIn general it is very broad topic, so if you're interested, try with some basic keywords: application servers, load balancing, reverse proxy, url rewriting.","Q_Score":0,"Tags":"python,web,yahoo","A_Id":4605394,"CreationDate":"2011-01-05T14:37:00.000","Title":"Is it possible to use different technologies in one website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.\nNow initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.\nBut i am confused how can we make make separate modules in diff languages and combine to make one website\nAny ideas","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":4605243,"Users Score":0,"Answer":"I know in Ruby on Rails, you can execute bash commands.\nExample: puts ls","Q_Score":0,"Tags":"python,web,yahoo","A_Id":4605290,"CreationDate":"2011-01-05T14:37:00.000","Title":"Is it possible to use different technologies in one website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was watching the tutorials for python and the guy told that he coded the Address books and spell checker for yahoo mail in python.\nNow initially i was thinking that if i build the website then i have to use one language either php or java or asp or anything.\nBut i am confused how can we make make separate modules in diff languages and combine to make one website\nAny ideas","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":99,"Q_Id":4605243,"Users Score":1,"Answer":"You can use any language to provide a web service, so you can for example provide a REST\/SOAP web service that returns JSON or XML. The web service can be written in any language, and the language used to interact with the web service can be any language, as all languages nowadays have JSON and XML parsers.\nYou can setup different subdomains to be used by different servers and setup those applications in any language you'd like.","Q_Score":0,"Tags":"python,web,yahoo","A_Id":4605266,"CreationDate":"2011-01-05T14:37:00.000","Title":"Is it possible to use different technologies in one website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a web app that uses stock data. The stock data can be stored in:\n\nFiles \nDB\n\nThe structure of the data is simple: there's a daily set and a weekly set. If files are used, then I can store a file per symbol\/set, such as GOOGLE_DAILY and GOOGLE_WEEKLY. Each set includes a simple list of (Date, open\/hight\/low\/close, volume, dividend) fields.\nBut how can I do it with DB? Should I use relational or other db? I thought about using 2 tables per each symbol, but that would generate thousands of tables, which doesn't feel right.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":4613251,"Users Score":3,"Answer":"You don't need a table per stock symbol, you just need one of the fields in the table to be the stock symbol. The table might be called StockPrices and its fields might be\n\nticker_symbol - the stock ticker symbol\ntime - the time of the stock quote\nprice - the price of the stock at that time\n\nAs long as ticker_symbol is an indexed field you can do powerful queries like SELECT time,price FROM StockPrices WHERE ticker_symbol='GOOG' ORDER BY time DESC and they will be very efficient. You can also store as many symbols as you like in this table.\nYou could add other tables for dividends, volume information and such. In all cases you probably have a composite key of ticker_symbol and time.","Q_Score":0,"Tags":"python,django,data-structures","A_Id":4613300,"CreationDate":"2011-01-06T09:02:00.000","Title":"Help needed with db structure","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im setting a VM. \nBoth host and VM machine have Mysql. \nHow do keep the VM Mysql sync'd to to the host Mysql. \nHost is using MYsql 5.5 on XP.\nVM is Mysql 5.1 on Fedora 14. \n1) I could DUMP to \"shared,\" Restore. Not sure if this will work.\n2) I could network Mysql Host to Mysql VM. Not how to do this \nHow would I do this with python 2.7?   \nI dont want them in sync after set-up phase. But, maybe sync some tables or SP occasionly on-rewrites. After I build out Linux Env. I would like to be able to convert V2P and have a dual-boot system.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2319,"Q_Id":4619392,"Users Score":0,"Answer":"Do you want it synced in realtime?\nWhy not just connect the guest's mysql process to the host?","Q_Score":1,"Tags":"python,mysql,virtual-machine","A_Id":4621472,"CreationDate":"2011-01-06T20:15:00.000","Title":"How to Sync MySQL with python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im setting a VM. \nBoth host and VM machine have Mysql. \nHow do keep the VM Mysql sync'd to to the host Mysql. \nHost is using MYsql 5.5 on XP.\nVM is Mysql 5.1 on Fedora 14. \n1) I could DUMP to \"shared,\" Restore. Not sure if this will work.\n2) I could network Mysql Host to Mysql VM. Not how to do this \nHow would I do this with python 2.7?   \nI dont want them in sync after set-up phase. But, maybe sync some tables or SP occasionly on-rewrites. After I build out Linux Env. I would like to be able to convert V2P and have a dual-boot system.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2319,"Q_Id":4619392,"Users Score":1,"Answer":"You can use mysqldump to make snapshots of the database, and to restore it to known states after tests. \nBut instead or going into the complication of synchronizing different database instances, it would be best to open the host machine's instance to local network access, and have the applications in the virtual machine access that as if it was a remote server. Overall performance should improve too. \nEven if you decide to run different databases for the host and the guest, run then both on the host's MySQL instance. Performance will be better, configuration management will be easier, and the apps in the guest will be tested against a realistic deployment environment.","Q_Score":1,"Tags":"python,mysql,virtual-machine","A_Id":4619503,"CreationDate":"2011-01-06T20:15:00.000","Title":"How to Sync MySQL with python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had a bad problem with these two: \"\\\" and \"\/\" in Windows, obviously :\\\nI need to replace all \\ occurrence  in \/, so I can use replace() because doesn't work with this \"\\6\" for example.\nWhat I have to do? I want \"only\" use mkdir() to replicate a structure of folders (without files) from one location to another. So I use mainly os.walk() and mkdir(); everything work well till is found a folder named with numeber. Infact mkdir can do this:\nmkdir(\"C:\\folder\") and also mkdir(\"C:\\newfolder\") but NOT mkdir(\"C:\\6\") for example, because it would mkdir(\"C:\/6\").\nBut I don't know how to pass to it a path with slash and not backslash, because, as I said, I don't write manually the path, but come from \"dirname\" of  os.walk().\nI know that exist os.path.normcase and os.path.normpath, but they convert forward slashes to backward slashes.\nI need \"only\" to replicate a structure of folders, and unfortunately, many folders are named with number....What can I do?\nThank You Very Much\nP.S.: Path are not simple like example... a more realistic example could be \"D:\\main\\folder\\blue\\sky\\34\"","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5295,"Q_Id":4621447,"Users Score":3,"Answer":"construct your paths with os.path, then it's platform agnostic and you'll avoid these issues.\nFor example, mkdir(os.path.join(r\"C:\\\", \"6\"))\nor os.path.join(r\"D:\\\", \"main\", \"folder\", \"red\", \"34\")","Q_Score":1,"Tags":"python,string,mkdir","A_Id":4621460,"CreationDate":"2011-01-07T00:28:00.000","Title":"From backslash to slash (to create folders named with number)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program sitting in server side managing user location informations, each friend has a pair of (longtitude, latitude), given a (longtitude, latitude) point, how I can find the nearby(say within 5KM) friends efficiently?\nI have 10K users online...\nThanks.\nBin","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2000,"Q_Id":4622988,"Users Score":2,"Answer":"Make a dict {graticule: [users]} (a \"graticule\" is a block of 1 degree latitude x 1 degree longitude; so you can basically just round the values). To find nearby users, first get users from the same and adjacent graticules (since the target could be near an edge), then filter them with a basic bounding-box test (i.e. what are the minimum longitude\/latitude that are possible for someone within the desired radius), then do a detailed test (if you need accuracy then you are in for some more complex math than just Pythagoras).","Q_Score":4,"Tags":"python,algorithm","A_Id":4623782,"CreationDate":"2011-01-07T06:18:00.000","Title":"algorithm to find the nearby friends?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I work with Oracle Database and lastest Django but when i use the default user model is the query very slow\nwhat can i do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":305,"Q_Id":4625835,"Users Score":2,"Answer":"The solution was to add an index.","Q_Score":2,"Tags":"python,django,oracle,django-models,model","A_Id":6583775,"CreationDate":"2011-01-07T13:18:00.000","Title":"how can i optimize a django oracle connection?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"i am learning python with GAE and for interface use jquery so i want to know calling python function using jquery.","AnswerCount":3,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1919,"Q_Id":4625844,"Users Score":-3,"Answer":"I believe you need to create a route for the app engine, and call that route with jQuery.\n--EDIT-- The below turns out to be really really untrue, so don't mind it!!! I'm not going to remove it 'cause that would be lame. I have done some work with the Python SDK and tiny bit with the Java SDK, and doing so I felt the Python SDK was falling behind. More experienced programmers seem to disagree, hence this edit.\nHave to warn you though, Google is focussing more on the Java platform than the Python platform; very often extra work is involved to achieve the same results as with Java, and sometimes things are simply unsupported.\nWhat is your focus here? To learn Python or to learn Python with GAE?","Q_Score":1,"Tags":"python,google-app-engine,jquery","A_Id":4625942,"CreationDate":"2011-01-07T13:19:00.000","Title":"how to call python function using jquery?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's the problem: I try to randomize n times a choice between two elements (let's say [0,1] -> 0 or 1), and my final list will have n\/2 [0] + n\/2 [1]. I tend to have this kind of result: [0 1 0 0 0 1 0 1 1 1 1 1 1 0 0, until n]: the problem is that I don't want to have serially 4 or 5 times the same number so often. I know that I could use a quasi randomisation procedure, but I don't know how to do so (I'm using Python).","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":588,"Q_Id":4630723,"Users Score":4,"Answer":"To guarantee that there will be the same number of zeros and ones you can generate a list containing n\/2 zeros and n\/2 ones and shuffle it with random.shuffle.\nFor small n, if you aren't happy that the result passes your acceptance criteria (e.g. not too many consecutive equal numbers), shuffle again. Be aware that doing this reduces the randomness of the result, not increases it.\nFor larger n it will take too long to find a result that passes your criteria using this method (because most results will fail). Instead you could generate elements one at a time with these rules:\n\nIf you already generated 4 ones in a row the next number must be zero and vice versa.\nOtherwise, if you need to generate x more ones and y more zeros, the chance of the next number being one is x\/(x+y).","Q_Score":1,"Tags":"python,random","A_Id":4630743,"CreationDate":"2011-01-07T22:07:00.000","Title":"Using Python for quasi randomization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's the problem: I try to randomize n times a choice between two elements (let's say [0,1] -> 0 or 1), and my final list will have n\/2 [0] + n\/2 [1]. I tend to have this kind of result: [0 1 0 0 0 1 0 1 1 1 1 1 1 0 0, until n]: the problem is that I don't want to have serially 4 or 5 times the same number so often. I know that I could use a quasi randomisation procedure, but I don't know how to do so (I'm using Python).","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":588,"Q_Id":4630723,"Users Score":1,"Answer":"Having 6 1's in a row isn't particularly improbable -- are you sure you're not getting what you want?\nThere's a simple Python interface for a uniformly distributed random number, is that what you're looking for?","Q_Score":1,"Tags":"python,random","A_Id":4630745,"CreationDate":"2011-01-07T22:07:00.000","Title":"Using Python for quasi randomization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having problem with drawing in pydot. \nThe problem lies in defining the layout of the nodes created. Currently everything is drawn vertically and is not spread. This gives me the problem of going down to see the nodes created.\nIs there any way I can define the nodes to be created horizontally whenever they are very large in number??\nAlso I want to display mathematical symbols in the labels. But I have not been able to find how to do that. \nIf anyone knows please do tell how I can write epsilon and lambda in the labels from one node to another....\nThanks a lot...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":419,"Q_Id":4638806,"Users Score":0,"Answer":"I found out that writing the string in unicode representation shows mathematical symbols as edges...\nFor example you can write node = pydot.Node(\"&#949;\",shape = \"ellipse\", style=\"filled\", fillcolor=\"turquoise\")\nUsing this we get epsilon as label of the node....\nSimilarly we can get rest of the mathematical symbols....","Q_Score":1,"Tags":"python,pydot","A_Id":4844143,"CreationDate":"2011-01-09T11:07:00.000","Title":"changing layout and inserting mathematical symbols with pydot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a wxPython application that is almost done & I would like to place it in my portfolio. I have to consider when someone attempts to run my app that they may not have Python, or wxPython, so if they just click the main script\/python file its not going to run, right?\nHow should I distribute my app (how do you distribute ur apps) so that it can be run & also so that it could be run on the 3 major OS's (Unix, Windows, MacOSX)?\nI know of py2exe for releasing under windows, but what can I use for Unix & MacOSX to compile the program? Whats the easiest way?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1685,"Q_Id":4643247,"Users Score":1,"Answer":"I suggest both, script for all platforms and frozen binary for lazy windows users.\nTo answer your latest question, you don't compile python. Python is an interpreted language, it gets compiled on the fly when run. A python frozen binary is actually the python interpreter with your script hardcoded in it. And frozen binaries are windows-only, AFAIK. Besides, Unix and MacOS (usually) come with python pre-installed.","Q_Score":3,"Tags":"python,wxpython","A_Id":4643279,"CreationDate":"2011-01-10T02:33:00.000","Title":"Releasing a wxPython App: Give out scripts or compile in Exe, etc?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"This may be simple, but I looked around and couldn't find an answer.  What's the best way to reference a single item in a list from a Django template?\nIn other words, how do I do the equivalent of {{ data[0] }} within the template language?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":132262,"Q_Id":4651172,"Users Score":24,"Answer":"{{ data.0 }} should work.\nLet's say you wrote data.obj django tries data.obj and data.obj(). If they don't work it tries data[\"obj\"]. In your case data[0] can be written as {{ data.0 }}. But I recommend you to pull data[0] in the view and send it as separate variable.","Q_Score":137,"Tags":"python,django,django-templates","A_Id":4651237,"CreationDate":"2011-01-10T20:27:00.000","Title":"Reference list item by index within Django template?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating an alarm clock in python and have a simple question:\nMy alarm clock's resolution needs to be down to the second. Currently I have a thread that wakes every 0.5 seconds, and checks whether its time to start making noise.\nMy only concern is that somehow the system gets completely overloaded at some point and the alarm does not sound because the alarm clock thread was still sleeping during the second it was supposed to check the time.\nSo my question is, would checking every 0.05 seconds be better? Or is there a way to register an event handler with python for a specific time, so I dont have to keep checking the time myself.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1365,"Q_Id":4651239,"Users Score":2,"Answer":"That's not the best solution. It's no guarantee you are locked out for more than one second. \nYou should stick to 0.5 second resolution (or worse if no lives depend on it) and fire the event whenever it is at or past the due time, and keep a flag per event if it has been fired. Then it will always be fired at exactly once, and as close to the target time as achievable.","Q_Score":1,"Tags":"python,scheduler","A_Id":4651287,"CreationDate":"2011-01-10T20:33:00.000","Title":"Simple alarm clock and checking time every second","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently started programming in python and have fallen in love with Vim over the past few weeks. I know want to use Vim as my primary editor for python files. I know there are python plugins for Vim, but I am very confused as to where\/how I can install these. I don't really understand where Vim is installed. I'm running the latest version of Mac OS X Snow Leopard.\nAny help would be greatly appreciated. Thanks!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":21812,"Q_Id":4652472,"Users Score":28,"Answer":"To best answer your initial question: \"How to install python syntax support in Vim\":\nThere is no need to install anything! If you have not made any modifications (e.g. no configuration changes for vim in ~\/.vimrc) try the following:\n\nOpen a Python file with vim \ntype the following command :syntax on\n\nYou should now have VIM properly highlight your Python file.\nTo avoid having to re-type those command over and over again, I would suggest you keep a configuration file for VIM. This is usually located in your home directory, if there is not one there already, create a ~\/.vimrc file and add the syntax on directive there to \nhave VIM automatically highlight your Python files.\nIf you need to know more about structure\/installation of plugins, then Senthil's answer is better suited :)","Q_Score":14,"Tags":"python,vim","A_Id":4661417,"CreationDate":"2011-01-10T22:56:00.000","Title":"How to install python syntax support for Vim on Mac OSX?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently started programming in python and have fallen in love with Vim over the past few weeks. I know want to use Vim as my primary editor for python files. I know there are python plugins for Vim, but I am very confused as to where\/how I can install these. I don't really understand where Vim is installed. I'm running the latest version of Mac OS X Snow Leopard.\nAny help would be greatly appreciated. Thanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":21812,"Q_Id":4652472,"Users Score":0,"Answer":"for mac os x, the vimrc file is located in \/usr\/share\/vim directory\nedit the vimdc file with any text editor. Add the syntax on to the last line of the file. Then next time you start a file you can see color. This is a system wide setting.  In other linux flavor it may be located in \/etc\/ you can find this file by find \/etc -name vimdc.  The edit will affect all the users on the machine.\nThese setting can overwritten by the $HOME\/.vimrc file.  In your home you may also have a .vim directory.  To check that you have these, do ls -a in your home directory.","Q_Score":14,"Tags":"python,vim","A_Id":36414972,"CreationDate":"2011-01-10T22:56:00.000","Title":"How to install python syntax support for Vim on Mac OSX?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Every time a user logs in to the application, I want to perform a certain task, say, record the time of login. So I wanted to know if a hook is fired on login by default? If yes, how can I make my module respond to it.\nEdit - Assume there are multiple entry points in the application to login.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":345,"Q_Id":4656923,"Users Score":0,"Answer":"I'm using Python on GAE (so it may be different for Java) but have seen no documentation about such a hook for a user logging in. If you used one of the session management frameworks you'd probably get some indication for that, but otherwise I do this kind of house keeping on my opening page itself which requires login. (What do you want to do about an already logged in user returning to your site a few days later... that is, do you really want to record logins or the start time of a visit\/session??)\nIf I wanted to do this but with multiple landing pages, and without using a session framework, \nI'd use memcache to do a quick check on every page request and then only write to the datastore when a new visit starts.","Q_Score":7,"Tags":"python,events,google-app-engine,login,hook","A_Id":4663607,"CreationDate":"2011-01-11T11:06:00.000","Title":"Login hook on Google Appengine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I received a project recently and I am wondering how to do something in a correct and secure manner.\nThe situation is the following:\nThere are classes to manage linux users, mysql users and databases and apache virtual hosts. They're used to automate the addition of users in a small shared-hosting environnement. These classes are then used in command-line scripts to offer a nice interface for the system administrator.\nI am now asked to build a simple web interface to offer a GUI to the administrator and then offer some features directly to the users (change their unix password and other daily procedures).\nI don't know how to implement the web application. It will run in Apache (with the apache user) but the classes need to access files and commands that are only usable by the root user to do the necessary changes (e.g useradd and virtual hosts configuration files). When using the command-line scripts, it is not a problem as they are run under the correct user. Giving permissions to the apache user would probably be dangerous.\nWhat would be the best technique to allow this through the web application ? I would like to use the classes directly if possible (it would be handier than calling the command line scripts like external processes and parsing output) but I can't see how to do this in a secure manner.\nI saw existing products doing similar things (webmin, eBox, ...) but I don't know how it works.\nPS: The classes I received are simple but really badly programmed and barely commented. They are actually in PHP but I'm planning to port them to python. Then I'd like to use the Django framework to build the web admin interface.\nThanks and sorry if the question is not clear enough.\nEDIT: I read a little bit about webmin and saw that it uses its own mini web server (called miniserv.pl). It seems like a good solution. The user running this server should then have permissions to modify the files and use the commands. How could I do something similar with Django? Use the development server? Would it be better to use something like CherryPy?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":474,"Q_Id":4680693,"Users Score":0,"Answer":"Hello\nYou can easily create web applications in Python using WSGI-compliant web frameworks such as CherryPy2 and templating engines such as Genshi. You can use the 'subprocess' module to manadge external commands...","Q_Score":3,"Tags":"python,security,apache,root,privileges","A_Id":4710807,"CreationDate":"2011-01-13T13:44:00.000","Title":"Modify system configuration files and use system commands through web interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I received a project recently and I am wondering how to do something in a correct and secure manner.\nThe situation is the following:\nThere are classes to manage linux users, mysql users and databases and apache virtual hosts. They're used to automate the addition of users in a small shared-hosting environnement. These classes are then used in command-line scripts to offer a nice interface for the system administrator.\nI am now asked to build a simple web interface to offer a GUI to the administrator and then offer some features directly to the users (change their unix password and other daily procedures).\nI don't know how to implement the web application. It will run in Apache (with the apache user) but the classes need to access files and commands that are only usable by the root user to do the necessary changes (e.g useradd and virtual hosts configuration files). When using the command-line scripts, it is not a problem as they are run under the correct user. Giving permissions to the apache user would probably be dangerous.\nWhat would be the best technique to allow this through the web application ? I would like to use the classes directly if possible (it would be handier than calling the command line scripts like external processes and parsing output) but I can't see how to do this in a secure manner.\nI saw existing products doing similar things (webmin, eBox, ...) but I don't know how it works.\nPS: The classes I received are simple but really badly programmed and barely commented. They are actually in PHP but I'm planning to port them to python. Then I'd like to use the Django framework to build the web admin interface.\nThanks and sorry if the question is not clear enough.\nEDIT: I read a little bit about webmin and saw that it uses its own mini web server (called miniserv.pl). It seems like a good solution. The user running this server should then have permissions to modify the files and use the commands. How could I do something similar with Django? Use the development server? Would it be better to use something like CherryPy?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":4680693,"Users Score":0,"Answer":"You can use sudo to give the apache user root permission for only the commands\/scripts you need for your web app.","Q_Score":3,"Tags":"python,security,apache,root,privileges","A_Id":4684335,"CreationDate":"2011-01-13T13:44:00.000","Title":"Modify system configuration files and use system commands through web interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wanted to ask if you could call in a program written in Ocaml a program written in python , and if the answer is yes how do I do?","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":849,"Q_Id":4683639,"Users Score":2,"Answer":"You can execute commands using Sys.command, so you can just do Sys.command \"python foo.py\", assuming python is in your path and foo.py is in the current directory.","Q_Score":3,"Tags":"python,ocaml","A_Id":4684135,"CreationDate":"2011-01-13T18:17:00.000","Title":"Call a program written in python in a program written in Ocaml","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wanted to ask if you could call in a program written in Ocaml a program written in python , and if the answer is yes how do I do?","AnswerCount":6,"Available Count":2,"Score":-0.0333209931,"is_accepted":false,"ViewCount":849,"Q_Id":4683639,"Users Score":-1,"Answer":"It depends on your exact requirements, but you can use pythons os.system() to execute an program in the same way you would call it from the command line. That should be a good starting point.","Q_Score":3,"Tags":"python,ocaml","A_Id":4683673,"CreationDate":"2011-01-13T18:17:00.000","Title":"Call a program written in python in a program written in Ocaml","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a python script checking\/monitoring several server\/websites status(response time and similar stuff), it's a GUI program and I use separate thread to check different server\/website, and the basic structure of each thread is using an infinite while loop to request that site every random time period(15 to 30 seconds), once there's changes in website\/server each thread will start a new thread to do a thorough check(requesting more pages and similar stuff). \nThe problem is, my internet connection always got blocked\/jammed\/messed up after several hours running of this script, the situation is, from my script side I got urlopen error timed out each time it's requesting a page, and from my FireFox browser side I cannot open any site. But the weird thing is, the moment I close my script my Internet connection got back on immediately which means now I can surf any site through my browser, so it must be the script causing all the problem. \nI've checked the program carefully and even use del to delete any connection once it's used, still get the same problem. I only use urllib2, urllib, mechanize to do network requests. \nAnybody knows why such thing happens? How do I debug this problem? Is there a tool or something to check my network status once such situation occurs? It's really bugging me for a while...\nBy the way I'm behind a VPN, does it have something to do with this problem? Although I don't think so because my network always get back on once the script closed, and the VPN connection never drops(as it appears) during the whole process. \n[Updates:]\nJust found more info about this problem, when my program brings down the internet connection, well, it's not totally \"down\", I mean, I cannot open any site in my browser or always get urlopen error timed out, but I still can get reply using \"ping google.com\" in cmd line. And when I manually dropped the VPN connection then redial, without closing my program it starts to work again and also I can surf the net through my browser. Why this happening?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":643,"Q_Id":4690890,"Users Score":0,"Answer":"You could possibly be creating more threads than you expect - monitor the result of threading.active_count() to test this.\nIf possible try to rule out the VPN at your end (or post the relevant guts of the code so we can test it).\n(Nettiquete) If you're not doing so already, only use network.http.max-connections-per-server threads per monitored site\/host.\n(For reference) urlopen returns a file-like object - use .close() or del on this object or the socket will be sat in a CLOSE_WAIT state until a timeout.\n\nHopefully these points are, well, pointers.","Q_Score":2,"Tags":"python,multithreading,network-programming,urllib2,mechanize","A_Id":4691668,"CreationDate":"2011-01-14T12:10:00.000","Title":"My python program always brings down my internet connection after several hours running, how do I debug and fix this problem?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Background:\nI have a gtk client that uses twisted and perspective broker to perform remote object execution and server\/client communication. This works great for me and was a breeze to start working with.\nI have amqp (Message Queue\/MQ)  services that I also need to communicate from the client.\nI have a security model in place around the client and server through twisted, and I don't want the clients to talk to the Message Queue Server directly, nor do I want another dependency on amqp libraries for the clients.\nIdeally I would like the client to send a request to the server through perspective broker, the Perspective Broker Server to send an amqp request to another server on behalf of the client, and the client to receive an acknowledgment when the PB server receives a response from the Message Queue Server.\nQuestion:\nOn the server side, how do I defer the response inside one of the servers pb methods?\nMore importantly what's the most efficient way to connect an outgoing request back to an incoming request and still preserve the Twisted event driven paradigms?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":323,"Q_Id":4694706,"Users Score":3,"Answer":"On the server side, how do I defer the response inside one of the servers pb methods?\n\nEasy.  Return the Deferred from the remote_ method.  Done.","Q_Score":2,"Tags":"python,pygtk,twisted,amqp,deferred","A_Id":4695170,"CreationDate":"2011-01-14T18:45:00.000","Title":"Python Twisted - Prospective Broker and Server-Side Deffereds","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It's a GUI program I wrote in python checking website\/server status running on my XP SP3, multi threads are used to check different site\/server. After several hours running, the program starts to get urlopen error timed out all the time, and this always happens right after a POST request from a server(not a certain one, might be A or B or C), and it's also not the first POST request causing the problem, normally after several hours running and it happens to make a POST request at an unknown moment, all you get from then on is urlopen error timed out.\nI'm still able to ping but cannot browse any site, once the program closed everything's fine. It's definitely the program causing this problem, well I just don't know how to debug\/check what the problem is, also don't know if it's from OS side or my program wasting too many resources\/connections(are you still able to ping when too many connections used?), would anybody please help me out?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":204,"Q_Id":4697623,"Users Score":3,"Answer":"Are you sure you are closing TCP sessions after each request? Try to check netstat information from time to time and if you'll see that the number of active\/established sessions is rising it means that you have some problems in your script.\nYes, usually you can ping even if you are out of free TCP sockets.","Q_Score":0,"Tags":"python,multithreading,network-programming,urllib2,python-multithreading","A_Id":4697664,"CreationDate":"2011-01-15T01:55:00.000","Title":"Able to ping but cannot browse after several hours running of my python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am having a difficult time finding documentation on how to write a custom widget.\nMy questions are:\n\nIf I build a custom widget, can it be used equivalently for the admin interface or for normal forms?\nIf I want to allow the user to edit a list of items, what widget should I subclass? What methods of the widget do I need to override\/implement?\nWhat widget method is responsible for going from the user's input back to the data model?\n\nThanks.","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":51410,"Q_Id":4707192,"Users Score":7,"Answer":"NOTE: There are three questions here. For the first two questions, see the fuller answer by AndiDog. I'm only answering the third question here:\nQ. What widget method is responsible for going from the user's input back to the data model?\nA. The value_from_datadict method -- it's sort of the inverse of a widget's render method. This method is presumably what the Django docs on widgets are referring to when it says \"The widget handles the rendering of the HTML, and the extraction of data from a GET\/POST dictionary that corresponds to the widget.\" There's nothing further on this point in the docs, but you can see how it works from the code for the built-in widgets.","Q_Score":63,"Tags":"python,django,forms","A_Id":11547550,"CreationDate":"2011-01-16T18:27:00.000","Title":"Django: How to build a custom form widget?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to find out the latest file in a huge filesystem. One way to do this is to go through all directories - one at a time, read its contents, select the latest file etc.\nThe obvious drawback is I have to get all the files in a specific directory. I was wondering whether there was a 'magic' call in Python [1] which Unix supports to get just the latest file in a directory.\n[1]. My application is in Python, but if a readymade solution doesnt exist in stdlib, please provide C (lanuage) alternatives using system calls. I'm willing to write a C-extension and make this work.\nThanks\nupdate: I suppose I should offer an explanation on why an inotify type solution wont work for me. I was simply looking for a system call using Python\/C which could give me the latest file. Yes, one could have inotify (or a similar overarching setup) which monitors FS changes but given a random directory how do I find the latest file is the essence of the question.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":1636,"Q_Id":4709968,"Users Score":3,"Answer":"No portable API exists to do this in Unix.  Most filesystems don't index files inside directories by their mtime (or ctime), so even if it did it probably wouldn't be any faster than doing it yourself.","Q_Score":4,"Tags":"python,c,unix","A_Id":4709984,"CreationDate":"2011-01-17T04:07:00.000","Title":"Find the most recent file in a directory without reading all the contents of it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any library to show progress when adding files to a tar archive in python or alternativly would be be possible to extend the functionality of the tarfile module to do this?\nIn an ideal world I would like to show the overall progress of the tar creation as well as an ETA as to when it will be complete. \nAny help on this would be really appreciated.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3242,"Q_Id":4718588,"Users Score":0,"Answer":"How are you adding files to the tar file? Is is through \"add\" with recursive=True? You could build the list of files yourself and call \"add\" one-by-one, showing the progress as you go. If you're building from a stream\/file then it looks like you could wrap that fileobj to see the read status and pass that into addfile.\nIt does not look like you will need to modify tarfile.py at all.","Q_Score":4,"Tags":"python,progress-bar,tar","A_Id":4718870,"CreationDate":"2011-01-17T22:23:00.000","Title":"Python tarfile progress","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a .sql file containing thousands of individual insert statements.  It takes forever to do them all.  I am trying to figure out a way to do this more efficiently.  In python the sqlite3 library can't do things like \".read\" or \".import\" but executescript is too slow for that many inserts.  \nI installed the sqlite3.exe shell in hopes of using \".read\" or \".import\" but I can't quite figure out how to use it.  Running it through django in eclipse doesn't work because it expects the database to be at the root of my C drive which seems silly.  Running it through the command line doesn't work because it can't find my database file (unless I'm doing something wrong)\nAny tips?\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1859,"Q_Id":4719836,"Users Score":1,"Answer":"Use a parameterized query \nand\nUse a transaction.","Q_Score":6,"Tags":"python,sql,django,sqlite","A_Id":4724461,"CreationDate":"2011-01-18T02:01:00.000","Title":"Python and sqlite3 - adding thousands of rows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a .sql file containing thousands of individual insert statements.  It takes forever to do them all.  I am trying to figure out a way to do this more efficiently.  In python the sqlite3 library can't do things like \".read\" or \".import\" but executescript is too slow for that many inserts.  \nI installed the sqlite3.exe shell in hopes of using \".read\" or \".import\" but I can't quite figure out how to use it.  Running it through django in eclipse doesn't work because it expects the database to be at the root of my C drive which seems silly.  Running it through the command line doesn't work because it can't find my database file (unless I'm doing something wrong)\nAny tips?\nThanks!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1859,"Q_Id":4719836,"Users Score":2,"Answer":"In addition to running the queries in bulk inside a single transaction, also try VACUUM and ANALYZEing the database file. It helped a similar problem of mine.","Q_Score":6,"Tags":"python,sql,django,sqlite","A_Id":13787939,"CreationDate":"2011-01-18T02:01:00.000","Title":"Python and sqlite3 - adding thousands of rows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a loop that runs for up to a few hours at a time. how could I have it tell me how long it has been at a set interval?\njust a generic...question\nEDIT: it's a while loop that runs permutations, so can i have it print the time running every 10 seconds?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":9699,"Q_Id":4720073,"Users Score":1,"Answer":"There's a very hacky way to do this by using time.asctime(). You store the asctime before entering the while loop and somewhere in the loop itself. Calculate the time difference between the stored time and the current time and if that difference is 10 seconds, then update the stored time to the current time and print that it's been running.\nHowever, that's a very hacky way to do it as it requires some twisted and boring math.\nIf your aim is to check the runtime of a specific algorithm, then you're better off using the timeit module\nHope this Helps","Q_Score":7,"Tags":"python,loops,time,permutation,while-loop","A_Id":4720112,"CreationDate":"2011-01-18T02:52:00.000","Title":"python -> time a while loop has been running","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i decided to write a brute force function to show people how vulnerable a password is. right now, i can show them the list it goes through to find the password, but how do i tell them how long it took?\nhere's the code:\n\n\n#!\/usr\/bin\/python\nimport itertools\n\nlower_a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\nupper_a = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\nnum = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']\n\nalllet = []\nalllet = lower_a + upper_a# + num\npwd = raw_input(\"What pwd?\\t\\t\")\n\ntry:\n        for r in range(1, len(pwd)+1):\n                for s in itertools.product(alllet, repeat=r):\n                        print ''.join(s)\n                        if ''.join(s) == pwd:\n                                raise NameError()\n\nexcept KeyboardInterrupt:\n        print \"Hey! You stopped me!\"\n\nexcept NameError:\n        print \"DONE! CRACKED!\"\n        print \"\\n\\nPassword is:\\t\" + ''.join(s) + \"\\n\\n\"","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":521,"Q_Id":4720363,"Users Score":0,"Answer":"How long as in time?\nfrom time import time on top, at the start of the program do start = time(). at the nameerror part do print time() - start\nplease be a bit more specific","Q_Score":1,"Tags":"python,time,brute-force,combinations","A_Id":4720383,"CreationDate":"2011-01-18T04:00:00.000","Title":"python -> password safety program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an initial_data fixture that I want to load everytime except for production. I already have different settings file for production and non-production deployments.\nAny suggestions on how to accomplish this?\nClarification: I do not want test fixtures. Basically, I just need the fixture to be loaded based on a setting change of some sort. I'll be digging into the Django code to see if I could figure out an elegant way to accomplish this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":490,"Q_Id":4731352,"Users Score":0,"Answer":"The easiest way is to use manage.py testserver [fixture ...]\nIf this is a staging (rather than dev) deployment, though, you may not want to use django's builtin server. In that case, a quick (if hacky) way of doing what you're after is to have the fixtures in an app (called, for example, \"undeployed\") that is only installed in your non-production settings.","Q_Score":2,"Tags":"python,django,django-models,django-settings,django-fixtures","A_Id":4731825,"CreationDate":"2011-01-19T03:00:00.000","Title":"Have different initial_data fixtures for different stages (testing v. production)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Python and am currently reading a chapter on String manipulation in \"Dive into Python.\"\nI was wondering what are some of the best (or most clever\/creative) ways to do the following:\n1)  Extract from this string: \"stackoverflow.com\/questions\/ask\"  the word 'questions.'  I did string.split(\/)[0]-- but that isn't very clever.\n2) Find the longest palindrome in a given number or string\n3) Starting with a given word (i.e. \"cat\")-- find all possible ways to get from that to another three- letter word (\"dog\"), changing one letter at a time such that each change in letters forms a new, valid word.  \nFor example-- cat, cot, dot, dog","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":975,"Q_Id":4737814,"Users Score":0,"Answer":"No 3:\nIf your string is s:\nmax((j-i,s[i:j]) for i in range(len(s)-1) for j in range(i+2,len(s)+1) if s[i:j]==s[j-1:i-1:-1])[1]\nwill return the answer.","Q_Score":2,"Tags":"python,string","A_Id":4738130,"CreationDate":"2011-01-19T16:24:00.000","Title":"Python: Clever ways at string manipulation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Java, this question is easy (if a little tedious) - every class requires its own file. So the number of .java files in a project is the number of classes (not counting anonymous\/nested classes).\nIn Python, though, I can define multiple classes in the same file, and I'm not quite sure how to find the point at which I split things up. It seems wrong to make a file for every class, but it also feels wrong just to leave everything in the same file by default. How do I know where to break a program up?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8928,"Q_Id":4743497,"Users Score":0,"Answer":"Python actually gives you the choice to package your code in the way you see fit.\nThe analogy between Python and Java is that a file i.e., the .py file in Python is \nequivalent to a package in Java as in it can contain many related classes and functions.\nFor good examples, have a look in the Python built-in modules.\nJust download the source and check them out, the rule of thumb I follow is \nwhen you have very tightly coupled classes or functions you keep them in a single file\nelse you break them up.","Q_Score":30,"Tags":"python,coding-style,conventions","A_Id":4743712,"CreationDate":"2011-01-20T04:40:00.000","Title":"When should a Python script be split into multiple files\/modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Java, this question is easy (if a little tedious) - every class requires its own file. So the number of .java files in a project is the number of classes (not counting anonymous\/nested classes).\nIn Python, though, I can define multiple classes in the same file, and I'm not quite sure how to find the point at which I split things up. It seems wrong to make a file for every class, but it also feels wrong just to leave everything in the same file by default. How do I know where to break a program up?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":8928,"Q_Id":4743497,"Users Score":3,"Answer":"As I see it, this is really a question about reuse and abstraction. If you have a problem that you can solve in a very general way, so that the resulting code would be useful in many other programs, put it in its own module. \nFor example: a while ago I wrote a (bad) mpd client. I wanted to make configuration file and option parsing easy, so I created a class that combined ConfigParser and optparse functionality in a way I thought was sensible. It needed a couple of support classes, so I put them all together in a module. I never use the client, but I've reused the configuration module in other projects.\nEDIT: Also, a more cynical answer just occurred to me: if you can only solve a problem in a really ugly way, hide the ugliness in a module. :)","Q_Score":30,"Tags":"python,coding-style,conventions","A_Id":4744148,"CreationDate":"2011-01-20T04:40:00.000","Title":"When should a Python script be split into multiple files\/modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Java, this question is easy (if a little tedious) - every class requires its own file. So the number of .java files in a project is the number of classes (not counting anonymous\/nested classes).\nIn Python, though, I can define multiple classes in the same file, and I'm not quite sure how to find the point at which I split things up. It seems wrong to make a file for every class, but it also feels wrong just to leave everything in the same file by default. How do I know where to break a program up?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":8928,"Q_Id":4743497,"Users Score":2,"Answer":"In Java ... every class requires its own file.\n\nOn the flipside, sometimes a Java file, also, will include enums or subclasses or interfaces,  within the main class because they are \"closely related.\"\n\nnot counting anonymous\/nested classes\n\nAnonymous classes shouldn't be counted, but I think tasteful use of nested classes is a choice much like the one you're asking about Python.\n(Occasionally a Java file will have two classes, not nested, which is allowed, but yuck don't do it.)","Q_Score":30,"Tags":"python,coding-style,conventions","A_Id":4743655,"CreationDate":"2011-01-20T04:40:00.000","Title":"When should a Python script be split into multiple files\/modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I receive some data as a string.  I need to write the data to a file, but the problem is that sometimes the data is compressed\/zipped and sometimes it's just plain text.  I need to determine the content-type so I know whether to write it to a .txt file or a .tgz file.  Any ideas on how to accomplish this?  Can I use mime type somehow even though my data is a string, not a file?\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2383,"Q_Id":4752451,"Users Score":1,"Answer":"If the file is downloaded from a webserver, you should have a content-type to look at, however you are at the mercy of the webserver whether or not it truly describes the type of the file.\nAnother alternative would be to use a heuristic to guess the file type. This can often be done by looking at the first few bytes of the file","Q_Score":2,"Tags":"python,string,content-type","A_Id":4752526,"CreationDate":"2011-01-20T20:52:00.000","Title":"How to determine content type of a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I receive some data as a string.  I need to write the data to a file, but the problem is that sometimes the data is compressed\/zipped and sometimes it's just plain text.  I need to determine the content-type so I know whether to write it to a .txt file or a .tgz file.  Any ideas on how to accomplish this?  Can I use mime type somehow even though my data is a string, not a file?\nThanks.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2383,"Q_Id":4752451,"Users Score":1,"Answer":"Both gzip and zip use distinct headers before compressed data, rather unlikely for human-readable strings. If the choice is only between these, you can make a faster check than mimetypes would provide.","Q_Score":2,"Tags":"python,string,content-type","A_Id":4752565,"CreationDate":"2011-01-20T20:52:00.000","Title":"How to determine content type of a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use the function os.listdir(path) to get a list of files from the directory I'm running the script in, but how do I say the current directory in the \"path\" argument?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6837,"Q_Id":4758855,"Users Score":3,"Answer":"You'd typically use os.listdir('.') for this purpose. If you need a standard module, the variable os.curdir is available.","Q_Score":0,"Tags":"python,path,working-directory","A_Id":4758914,"CreationDate":"2011-01-21T12:36:00.000","Title":"How do I refer to the current directory in functions from the Python 'os' module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say, I have some scope with variables, and a function called in this scope wants to change some immutable variables:\n\ndef outer():\n    s = 'qwerty'\n    n = 123\n    modify()\n\ndef modify():\n    s = 'abcd'\n    n = 456\n\nIs it possible somehow to access the outer scope? Something like nonlocal variables from Py3k.\nSure I can do s,n = modify(s,n) in this case, but what if I need some generic 'injection' which executes there and must be able to reassign to arbitrary variables?\nI have performance in mind, so, if possible, eval & stack frame inspection is not welcome :)\n\nUPD: It's impossible. Period. However, there are some options how to access variables in the outer scope:\n\nUse globals. By the way, func.__globals__ is a mutable dictionary ;)\nStore variables in a dict\/class-instance\/any other mutable container\nGive variables as arguments & get them back as a tuple: a,b,c = innerfunc(a,b,c)\nInject other function's bytecode. This is possible with byteplay python module.","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11146,"Q_Id":4763965,"Users Score":3,"Answer":"This is not how nonlocal works. It doesn't provide dynamic scoping (which is just a huge PITA waiting to happen and even more rarely useful than your average \"evil\" feature). It just fixes up lexical scoping.\nAnyway, you can't do what you have in mind (and I would say that this is a good thing). There's not even a dirty but easy hack (and while we're at it: such hacks are not discouraged because they generally perform a bit worse!). Just forget about it and solve the real problem properly (you didn't name it, so we can't say anything on this).\nThe closest you could get is defining some object that carries everything you want to share and pass that around explicitly (e.g. make a class and use self, as suggested in another answer). But that's relatively cumbersome to do everywhere, and still hackery (albeit better than dynamic scoping, because \"explicit is better than implicit\").","Q_Score":8,"Tags":"python,scope","A_Id":4764004,"CreationDate":"2011-01-21T21:27:00.000","Title":"Accessing the outer scope in Python 2.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey everyone, \nI am expanding my team and I have recently added an additional front end engineer on my site. I am currently using django to run my site but my site is using a lot of plugins, namely: django-celery, django-mailer, django-notification, and django-socialregistration.\nLet me describe my situation:\n\nHe is using Mac OS X, and I have no experience in installing stuff on mac os X or configuration on that platform\nI believe that getting my backend to run on his computer might be somewhat troublesome, i.e. I have to install a bunch of plugins (which are not available on pip or easy_install as they are the latest version) and I have also made heavy modification to django-socialregistration which I am currently using by symlinking to the modified code in my repos in my python path\nI tried to look into solutions like pip and easy_install but I have not been able to get them to install code from github\n\nI think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":181,"Q_Id":4777262,"Users Score":1,"Answer":"Get him to set up a virtual machine on his Mac, using VMWare Fusion or Parallels, running the same operating system that you currently use for your back end.  If he prefers developing using Mac tools he can do still that by sharing his local changes to the virtual machine via a shared directory.","Q_Score":1,"Tags":"python,django,installation","A_Id":4777646,"CreationDate":"2011-01-23T23:25:00.000","Title":"Easiest way to share work between backend and front end","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey everyone, \nI am expanding my team and I have recently added an additional front end engineer on my site. I am currently using django to run my site but my site is using a lot of plugins, namely: django-celery, django-mailer, django-notification, and django-socialregistration.\nLet me describe my situation:\n\nHe is using Mac OS X, and I have no experience in installing stuff on mac os X or configuration on that platform\nI believe that getting my backend to run on his computer might be somewhat troublesome, i.e. I have to install a bunch of plugins (which are not available on pip or easy_install as they are the latest version) and I have also made heavy modification to django-socialregistration which I am currently using by symlinking to the modified code in my repos in my python path\nI tried to look into solutions like pip and easy_install but I have not been able to get them to install code from github\n\nI think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":4777262,"Users Score":0,"Answer":"An alternative, if that's possible, would be to set up a testing\/development environment on a machine with an OS you're familiar with, then install something like Dropbox on his local machine where he can develop the frontend code, and install Dropbox on that other environment with the backend components. Dropbox would sync his local changes to that testing environment for him to run the code on.\nThat way, he would be able to use that environment to test his code, you wouldn't need to set up a backend on his machine (or keep it up to date) and you'd still be getting the same functionality.\nAgain, if that's an option.","Q_Score":1,"Tags":"python,django,installation","A_Id":4777381,"CreationDate":"2011-01-23T23:25:00.000","Title":"Easiest way to share work between backend and front end","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a custom group in Django's admin site.\nIn my code, I want to check if a user is in this group. How do I do that?","AnswerCount":13,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":149841,"Q_Id":4789021,"Users Score":0,"Answer":"User.objects.filter(username='tom', groups__name='admin').exists()\nThat query will inform you user : \"tom\" whether belong to group \"admin \" or not","Q_Score":179,"Tags":"python,django,django-authentication","A_Id":50211377,"CreationDate":"2011-01-25T01:09:00.000","Title":"In Django, how do I check if a user is in a certain group?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a custom group in Django's admin site.\nIn my code, I want to check if a user is in this group. How do I do that?","AnswerCount":13,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":149841,"Q_Id":4789021,"Users Score":11,"Answer":"If a user belongs to a certain group or not, can be checked in django templates using:\n{% if group in request.user.groups.all %}\n\"some action\"\n{% endif %}","Q_Score":179,"Tags":"python,django,django-authentication","A_Id":32197405,"CreationDate":"2011-01-25T01:09:00.000","Title":"In Django, how do I check if a user is in a certain group?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a multi threaded Python app that makes many TCP connections to servers. Each connection is done on a separate thread. Sometimes the thread hangs for a long time which I don't want. How can I get the thread to kill itself after some given time period? From the main thread how can I determine that the child thread killed itself?\nIf possible I would appreciate a snippet of code showing how to do this. Thanks.\nUpdate\nThe system is Ubuntu 9:10","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":8125,"Q_Id":4791815,"Users Score":5,"Answer":"Short answer: Just make the def run() end.\nSo, if you are waiting for data from a socket, do it with timeout, then if timeout occur just break the while that you should have, and the thread will be killed.\nYou can check from main thread if a thread is alive with isAlive() method.","Q_Score":7,"Tags":"python,multithreading,ubuntu-9.10","A_Id":4794288,"CreationDate":"2011-01-25T09:35:00.000","Title":"Python: how can I get a thread to kill itself after a timeout?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made an application using Python and recently i found that i can use py2exe to make executables for windows.\nThe problem is that a library i am using (xmpppy) produces this error\n\nDeprecationWarning: the md5 module is deprecated; use hashlib instead\n\nand when i try to run the executable a dialog appears saying this\n\nSee the logfile 'C:\\Python26\\P2E\\MyApp\\dist\\MyApp.exe.log' for details\n\nany ideas how to fix that?","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":974,"Q_Id":4793250,"Users Score":-2,"Answer":"when a python script .py has any error it shows in console but when you run python .exe file it genrates .exe.log file when error accured.so go to your folder and see that there is a .exe.log file is there showing errors.","Q_Score":0,"Tags":"python,pyqt4,xmpppy","A_Id":50261727,"CreationDate":"2011-01-25T12:03:00.000","Title":"PyQt4 - \"See the log file for details\" error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"If I have a list with say 10 million objects, how do I filter the list quickly. It takes about 4-5 seconds for a complete iteration thru a list comprehension. Are there any efficient data structures or libraries for this in python? Or is python not suited for large sets of data?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":6918,"Q_Id":4800858,"Users Score":4,"Answer":"If you have uniform types of numbers & if speed is your primary goal (and you want to use python), use a Numpy array.","Q_Score":4,"Tags":"python,data-structures","A_Id":4800884,"CreationDate":"2011-01-26T02:16:00.000","Title":"Filtering \/ iterating through very large lists in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to configure a simple webapplication to support an iphone app to connect with it in RESTFUL ways. Initially have a user login session enabled from the iphone to the web app. I'd like the iphone app to send a NSURL call to the webapp, with user and password and have the webapp respond if the suer exists or not. Pretty simple. And I want to do it with web2py. Is this possible? Any clues?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":990,"Q_Id":4801216,"Users Score":2,"Answer":"I think you should post it to web2py group on google groups.\nweb2py@googlegroups.com","Q_Score":2,"Tags":"iphone,python,cocoa,restful-authentication,web2py","A_Id":4809129,"CreationDate":"2011-01-26T03:40:00.000","Title":"can web2py support RESTful api calls? if so any pointers on how to build one?I","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to build my first wx application\nI have a browse button in my panel, the user adds his file. i do some processing on the file.\nNow i want to show the information in a TextCtrl so that the user may modify it. Then i need to write it in a file.\nBut I dont know how many TextCtrl box is needed before processing the file. \nUsing the browse button event i have got the file, extracted the information also. But i dont know how to show the information back to the user. \nany suggestion is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":439,"Q_Id":4802134,"Users Score":0,"Answer":"If all you're doing is showing one file, then all you need is one TextCtrl. I would give the widget the wx.TE_MULTILINE style and add it to a sizer with an EXPAND flag:\nsizer.Add(myTxtCtrl, 0, wx.EXPAND)\nThen the user can see the file and you can save the data with a Save button or menu item. The handler for that would basically just grab the text control's contents using it's GetValue() method.","Q_Score":0,"Tags":"wxpython,textctrl","A_Id":4807514,"CreationDate":"2011-01-26T07:10:00.000","Title":"wxPython: TextCtrl problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how Python does string comparison, more specifically how it determines the outcome when a less than < or greater than > operator is used.\nFor instance if I put print('abc' < 'bac') I get True. I understand that it compares corresponding characters in the string, however its unclear as to why there is more, for lack of a better term, \"weight\" placed on the fact that a is less thanb (first position) in first string rather than the fact that a is less than b in the second string (second position).","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":132841,"Q_Id":4806911,"Users Score":8,"Answer":"Python and just about every other computer language use the same principles as (I hope) you would use when finding a word in a printed dictionary:\n(1) Depending on the human language involved, you have a notion of character ordering: 'a' < 'b' < 'c' etc   \n(2) First character has more weight than second character: 'az' < 'za' (whether the language is written left-to-right or right-to-left or boustrophedon is quite irrelevant)   \n(3) If you run out of characters to test, the shorter string is less than the longer string: 'foo' < 'food'\nTypically, in a computer language the \"notion of character ordering\" is rather primitive: each character has a human-language-independent number ord(character) and characters are compared and sorted using that number. Often that ordering is not appropriate to the human language of the user, and then you need to get into \"collating\", a fun topic.","Q_Score":82,"Tags":"python,string,comparison","A_Id":4809303,"CreationDate":"2011-01-26T16:17:00.000","Title":"How are strings compared?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how Python does string comparison, more specifically how it determines the outcome when a less than < or greater than > operator is used.\nFor instance if I put print('abc' < 'bac') I get True. I understand that it compares corresponding characters in the string, however its unclear as to why there is more, for lack of a better term, \"weight\" placed on the fact that a is less thanb (first position) in first string rather than the fact that a is less than b in the second string (second position).","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":132841,"Q_Id":4806911,"Users Score":0,"Answer":"The comparison uses lexicographical ordering\nFor Python 3: Convert it into Unicode to get its order or number that is being used as \"weightage\" here\nFor Python 2: Use ASCII to get its order or number that is being used as \"weightage\" here\nPeople already answered it in detail, I am leaving it here for anyone who is in a hurry :)","Q_Score":82,"Tags":"python,string,comparison","A_Id":69465704,"CreationDate":"2011-01-26T16:17:00.000","Title":"How are strings compared?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The google app engine python sdk offers an Expando type object which can be used for adding dynamic properties to an object that can be persisted to the datastore.\nThe app engine also requires that for any property on which the objects need to be searched or sorted, an index must be created before uploading the app to google's servers.  This is really strange because it means that i am supposed to know before hand what properties my users will create on my objects.  If i knew that in advance, why would i not define them as static properties in my existing model?\nDoes anyone know how to automatically create indexes for dynamic properties of Expando models after uploading to the app engine?  If not, can anyone tell me why does the gae tout Expando as dynamic construct when it can not let you create new properties that can be searched on or sorted by, only properties that arent searchable or sortable.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":663,"Q_Id":4807957,"Users Score":4,"Answer":"All properties are automatically indexed for simple queries. Simple queries, in this case, are those that either:\n\nUse only equality filters, with no sort orders or inequality filters.\nHave an inequality filter or sort order on a single field, with no other filters.\n\nIf you want to do more complex queries - such as ones that mix inequality and equality filters, only then do you need to build a custom index.\nIt's not possible to build custom indexes at runtime. If you want to use expandos, you need to make sure that you restrict the queries you execute to those that are satisfiable under one of the situations above.","Q_Score":3,"Tags":"python,google-app-engine,expando","A_Id":4812503,"CreationDate":"2011-01-26T17:46:00.000","Title":"Automatic indexes for expando properties in the google app engine for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to fill in a document and then try and convert it into a PDF.\nAny idea how I can do this?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":13293,"Q_Id":4818342,"Users Score":2,"Answer":"Install a PDF printer driver like CutePDF.\nUse COM automation to run MS Word; open the file, fill in the data, print the file as a PDF.\nAlternatively: convert the Word file into a PDF form; use ReportLab to fill in the form.\nAlternatively: print the Word file to a PDF file; use ReportLab to overlay text on the file.","Q_Score":4,"Tags":"python,pdf,ms-word","A_Id":4819159,"CreationDate":"2011-01-27T15:33:00.000","Title":"Convert Word doc to PDF - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hello\nI'm have a task - create script, what will walk in internet and change proxy from list.\nI'm see in module urllib2: ProxyHandler and HTTPPasswordMgr, but manual is poor.\n1. In documentation ProxyHandler get dict with many proxy-server, how to I'm can select from list and use for url_open?\n2. HTTPPasswordMgr have method add_password, but for what it? How to it will select auth-data for proxy, for what it have: realm?\n3. How to right use multiple proxy in urllib2? I'm think only create a list with all my proxy and create new 'opener' for each request.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1084,"Q_Id":4822860,"Users Score":-1,"Answer":"ProxyHandler can use a different proxy for different protocols (HTTP, etc.) but I don't think it will help you.  You should be able to write your own class for your needs without much difficulty.","Q_Score":0,"Tags":"python,proxy,urllib2","A_Id":4823009,"CreationDate":"2011-01-27T22:48:00.000","Title":"How to use multiple proxy in urllib2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Will it continue the code after it's run? Or will it stop at that line until the script is done?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":32061,"Q_Id":4826686,"Users Score":1,"Answer":"You can use os.system or subprocess.Popen or subprocess.call but when using subprocess methods make sure you use shell=True. And executing it via system call in all these methods is blocking. The python script will complete and then go the next step.","Q_Score":5,"Tags":"python,bash,shell","A_Id":4826733,"CreationDate":"2011-01-28T09:36:00.000","Title":"Inside python code, how do I run a .sh script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to optimize the interaction between two scripts I have.\nTwo things I thought of are the c++ program not terminating unless you manually kill it, or generating all info in python before feeding it to c++.\nExplanation of the problem:\nWhat the scripts do:\nC++ program (not made by me, and I can't program in c++ very well): takes a 7 number array and returns a single number, simple. \nPython script (mine, and I can program a bit in python): generates those 7 number arrays, feeds them to the c++ program, waits for an answer and adds it to a list. It then makes the next array. \nIn theory, this works. However, as it is right now, it opens and closes the c++ program for each call. For one array that is no problem, but I'm trying to upscale to 25k arrays, and in the future to 6+ million arrays. Obviously it is then no longer feasible to open\/close it each time, especially since the c++ program first has to load a 130mb VCD file to function.\nTwo options I thought of myself were to generate all arrays first in python, then feed them to the c++ program and then analyze all results. However, I wouldn't know how to do this with 6M arrays. It is not important however that the results I get back are in the same order as the arrays I feed in.\nSecond option I thought of was to make the c++ program not quit after each call. I can't program in c++ though so I don't know if this is possible, keeping it 'alive' so you can just feed arrays into it at times and get an answer.\n(Note: I cannot program in anything else than python, and want to do this project in python. The c++ program cannot be translated to python for speed reasons.)\nThanks in advance, Max.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":2200,"Q_Id":4826896,"Users Score":1,"Answer":"Firstly, just to be pedantic, there are no C++ scripts in normal use. C++ compiles, ultimately, to machine code, and the C++ program is properly referred to as a \"program\" and not a \"script\".\nBut to answer your question, you could indeed set up the C++ program to stay in memory, where it listens for connections and sends responses to your Python script. You'd want to study Unix IPC, particularly sockets.\nAnother way to approach it would be to incorporate what the C++ program does into your Python script, and forget about C++ altogether.","Q_Score":1,"Tags":"c++,python,optimization,interaction","A_Id":4827083,"CreationDate":"2011-01-28T09:59:00.000","Title":"Python and C++ script interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've updated a Python egg that is only being used locally. The update proceeded correctly and installed into \/usr\/lib\/python2.5\/site-packages\/eggName-UpdatedVersionNumber-py2.5.egg\nHowever, when I open iPython and try to import the egg, I still get the old version. \nRunning egg_name.__file__ gives me:\n\n\/usr\/local\/FOLDER\/lib\/python2.5\/site-packages\/eggName-OldVersionNumber-py2.5.egg\/egg\/__init__.pyc\n\nRunning easy_install --upgrade EGG shows:\n\n... EGG UpdatedVersionNumber is\n  already the active version in\n  easy-install.pth\\\n\nAny idea on how to get the system to call the new version installed at \/usr\/lib\/python2.5\/site-packages\/...?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":593,"Q_Id":4834533,"Users Score":1,"Answer":"Note that you have 2 different site-packages locations; one is \/usr\/lib\/python2.5\/site-packages and the other is \/usr\/local\/FOLDER\/lib\/python2.5\/site-packages.\nThe egg in the latter location is being preferred over the egg in the first location when the latter location comes first in your PYTHON_PATH. In iPython, you can check the python path by printing import sys; sys.path; install the new egg in the second location to have iPython use it, or remove the old egg from that location altogether.\nIf you do this manually, don't forget to update the .pth file in the affected site-packages directory.","Q_Score":0,"Tags":"python,module,egg","A_Id":6228872,"CreationDate":"2011-01-29T01:33:00.000","Title":"How to get iPython to use Updated Egg\/Module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am running a Python script which downloads PDF files from the FTP. The script when run manually works perfectly but when i put it in crontab in my ubuntu machine and execute it i get a an error [Errno 32] Broken pipe. Any idea why this happens and how do i handle this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1316,"Q_Id":4836450,"Users Score":1,"Answer":"Hi I dnt know y the error occurs but when i directed the print statements from my script to another file this error did not come and my script ran successfully \nExample: Myscript.py > test.log","Q_Score":2,"Tags":"python","A_Id":4851152,"CreationDate":"2011-01-29T10:49:00.000","Title":"[Errno 32]Broken pipe in Python Script in Crontab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"If I have a list and want to truncate it so it is no more than 100 items, how do I do this?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":58602,"Q_Id":4838504,"Users Score":7,"Answer":"The items[:100] other mentioned gives you a new list which contains the first 100 items of items. If you want to modify the list in-place, either use items[:] = items[:100] (slice assignment) or while len(items) > 100: items.pop()use del items[100:] as proposed by Ned Batchelder.","Q_Score":47,"Tags":"python,list","A_Id":4838530,"CreationDate":"2011-01-29T18:04:00.000","Title":"How do I truncate a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't figure out how to make setup.py add a scrip to the the user's \/bin or \/usr\/bin or whatever.\nE.g., I'd like to add a myscript.py to \/usr\/bin so that the user can call myscript.py from any directory.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":48656,"Q_Id":4840182,"Users Score":15,"Answer":"If you're willing to build and install the entire python package, this is how I would go about it:\n\nEdit the setup() function in setup.py to contain a parameter named scripts and set its argument as the location of the file(s) you wish to run from anywhere. e.g. \n\nsetup(name='myproject',author='',author_email='',scripts=['bin\/myscript.py'])\n\nWithin the directory that contains setup.py, create a bin directory by typing mkdir bin\nAdd myscript.py to this newly-created bin directory (and make sure it's executable!)\ncd into the directory that contains setup.py again, and install the entire python package by typing python setup.py install\nOnce the package is installed, you should be able to run myscript.py from anywhere on the system!","Q_Score":81,"Tags":"python","A_Id":9478011,"CreationDate":"2011-01-29T23:41:00.000","Title":"setup.py and adding file to \/bin\/","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to convert 1\/2 in python so that when i say print x (where x = 1\/2) it returns 0.5\nI am looking for the most basic way of doing this, without using any split functions, loops or maps\nI have tried float(1\/2) but I get 0...\ncan someone explain me why and how to fix it?\nIs it possible to do this without modifying the variable x= 1\/2 ?","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":52481,"Q_Id":4841732,"Users Score":3,"Answer":"There is no quantity 1\/2 anywhere. Python does not represent rational numbers with a built-in type - just integers and floating-point numbers. 1 is divided by 2 - following the integer division rules - resulting in 0. float(0) is 0.","Q_Score":14,"Tags":"python,python-2.x","A_Id":4842269,"CreationDate":"2011-01-30T07:33:00.000","Title":"Convert fraction to decimal in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite confused about the stdin and the key_events of GUI widget.\nUsually in my mind, I thought stdin is the ordinary way to get the keyboard input for a process. E.g., If I have a process, then I could use stdin to have the keyboard inputs. And this is usually used to make I\/O direction for the subprocess to get keyboard inputs. E.g., I could make subprocess.Popen(stdin=PIPE)\nOn the other hand for GUI, I am using wx.TexCtrl or py.Shell.shell, to catch the key events, like inputs. \nSo I am quite confused here, if I have a GUI or pyShell running, when I am typing via the keyboard, is it via the stdin or via the GUI key event catching system? If via the GUI key events system, how can I get the keyboard stdin? Can I still simply redirect the keyboard inputs to my child process (inside the GUI) as the ordinary non-GUI programming?\nThanks a lot for any comments.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":405,"Q_Id":4854486,"Users Score":2,"Answer":"When you type, the input comes from the GUI event mechanism, not from stdin. You asked how to get the \"keyboard stdin\", and the answer to that is the same as for any other type of program: you read it (but it will almost certainly be empty). It's important to realize that the GUI probably doesn't have a stdin if it was started by double-clicking on an icon on the desktop.\nAnd no, you can't \"redirect keyboard inputs to [your] child process\", if I understand your question. Stdin really has absolutely nothing to do with GUIs at all. How keyboard input is read via a GUI is completely disconnected from stdin.","Q_Score":0,"Tags":"user-interface,redirect,event-handling,wxpython,stdin","A_Id":4854744,"CreationDate":"2011-01-31T18:18:00.000","Title":"key_events of GUI widget and stdin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a program that create files in a specific directory.\nWhen those files are ready, I run Latex to produce a .pdf file.\nSo, my question is, how can I use this directory change as a trigger\nto call Latex, using a shell script or a python script?\nBest Regards","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":4757,"Q_Id":4862346,"Users Score":1,"Answer":"Not much of a python man myself. But in a pinch, assuming you're on linux, you could periodically shell out and \"ls -lrt \/path\/to\/directory\" (get the directory contents and sort by last modified), and compare the results of the last two calls for a difference. If so, then there was a change. Not very detailed, but gets the job done.","Q_Score":6,"Tags":"python,shell,latex","A_Id":4862410,"CreationDate":"2011-02-01T12:08:00.000","Title":"Check if the directory content has changed with shell script or python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a new MacBook Pro running OS X 10.6.6 \/ Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1\nUnfortunately, this doesn't seem to see the Twisted install in the 2.6\/Extras\/lib\/python\/twisted directory, as I find I'm unable to import modules that I can see are present in that directory.\n\"which python\" returns \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python\"\nand running python returns the same: \"Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)\"\nI have added the twisted directory (absolute) to sys.path, and I have added it to .bash_profile, which now consists of the following:\nPATH=\"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin:${PATH}\"\nPATH=$PATH:\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/Extras\/lib\/python\/twisted\nexport PATH\nAny ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done?\nthanks.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2965,"Q_Id":4869315,"Users Score":3,"Answer":"You'll need to install Twisted into your Python 2.7 installation somehow.  The \"2.6\" in that path should be a hint that you shouldn't be trying to tell Python 2.7 about it.  Among other things: \n\nExtension modules are not compatible between python versions.  You may get a segfault if you try to use them.\nBytecode formats are not compatible between python versions.  Python will fall back to parsing '.py' files, which is slower.\nIf you're using an operating system that ships with Python 2.6, there is a good chance that the version of Twisted included is not compatible with Python 2.7, since Python 2.7 may not have been out yet when it was released.","Q_Score":1,"Tags":"python,bash,osx-snow-leopard,twisted,.bash-profile","A_Id":4869690,"CreationDate":"2011-02-01T23:46:00.000","Title":"Python 2.7.1 can't see Twisted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a new MacBook Pro running OS X 10.6.6 \/ Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1\nUnfortunately, this doesn't seem to see the Twisted install in the 2.6\/Extras\/lib\/python\/twisted directory, as I find I'm unable to import modules that I can see are present in that directory.\n\"which python\" returns \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python\"\nand running python returns the same: \"Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)\"\nI have added the twisted directory (absolute) to sys.path, and I have added it to .bash_profile, which now consists of the following:\nPATH=\"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin:${PATH}\"\nPATH=$PATH:\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/Extras\/lib\/python\/twisted\nexport PATH\nAny ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done?\nthanks.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2965,"Q_Id":4869315,"Users Score":2,"Answer":"Create an environment using virtualenv.\nInstall Twisted in your newly created environment using pip.","Q_Score":1,"Tags":"python,bash,osx-snow-leopard,twisted,.bash-profile","A_Id":4869359,"CreationDate":"2011-02-01T23:46:00.000","Title":"Python 2.7.1 can't see Twisted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a new MacBook Pro running OS X 10.6.6 \/ Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1\nUnfortunately, this doesn't seem to see the Twisted install in the 2.6\/Extras\/lib\/python\/twisted directory, as I find I'm unable to import modules that I can see are present in that directory.\n\"which python\" returns \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python\"\nand running python returns the same: \"Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)\"\nI have added the twisted directory (absolute) to sys.path, and I have added it to .bash_profile, which now consists of the following:\nPATH=\"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin:${PATH}\"\nPATH=$PATH:\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.6\/Extras\/lib\/python\/twisted\nexport PATH\nAny ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done?\nthanks.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":2965,"Q_Id":4869315,"Users Score":3,"Answer":"You'll have to install twisted using python 2.7.\nAlso, python doesn't look up what's in the PATH variable for imports, it looks in PYTHONPATH. But just putting your python 2.6 folder in your pythonpath isn't a very good solution.","Q_Score":1,"Tags":"python,bash,osx-snow-leopard,twisted,.bash-profile","A_Id":4869332,"CreationDate":"2011-02-01T23:46:00.000","Title":"Python 2.7.1 can't see Twisted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently started to work with Scrapy. I am trying to gather some info from a large list which is divided into several pages(about 50). I can easily extract what I want from the first page including the first page in the start_urls list. However I don't want to add all the links to these 50 pages to this list. I need a more dynamic way. Does anyone know how I can iteratively scrape web pages? Does anyone have any examples of this? \nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1171,"Q_Id":4876799,"Users Score":0,"Answer":"Why don't you want to add all the links to 50 pages? Are the URLs of the pages consecutive like www.site.com\/page=1, www.site.com\/page=2 or are they all distinct? Can you show me the code that you have now?","Q_Score":1,"Tags":"python,web-scraping,scrapy","A_Id":4889635,"CreationDate":"2011-02-02T16:08:00.000","Title":"Recursive use of Scrapy to scrape webpages from a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently started to work with Scrapy. I am trying to gather some info from a large list which is divided into several pages(about 50). I can easily extract what I want from the first page including the first page in the start_urls list. However I don't want to add all the links to these 50 pages to this list. I need a more dynamic way. Does anyone know how I can iteratively scrape web pages? Does anyone have any examples of this? \nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1171,"Q_Id":4876799,"Users Score":1,"Answer":"use urllib2 to download a page. Then use either re (regular expressions) or BeautifulSoup (an HTML parser) to find the link to the next page you need. Download that with urllib2. Rinse and repeat.\nScapy is great, but you dont need it to do what you're trying to do","Q_Score":1,"Tags":"python,web-scraping,scrapy","A_Id":4940212,"CreationDate":"2011-02-02T16:08:00.000","Title":"Recursive use of Scrapy to scrape webpages from a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use PyQt4. I have downloaded its LINUX version and trying to install it with Cygwin(because I have windows on my PC and I want to use linux, therefore I am using Cygwin). I don't know how to install it ? please guide me . There is no such file like setup.py, install....what should I do??","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":526,"Q_Id":4877959,"Users Score":2,"Answer":"PyQt4 and Qt are cross-platform. If you write cross-platform code, you don't need to develop on any specific OS. Testing on different platforms from time to time is a good idea, but good cross-platform code will usually just work.\nDon't use any Windows-specific features, Windows-specific code. In particular, don't use subprocess unless calling shell commands is part of your app, use os.path instead of writing paths yourself, don't hardcode any paths, verify that each library that you're using is cross-platform, and you'd be fine.\nAnd when you're testing on Linux, test on actual Linux. Cygwin is another, different platform. You can try using a virtual machine with VirtualBox.\nP.S. You might also look at Nokia's new PySide which has more liberal license than PyQt4 and supports most of what PyQt4 supports with nearly the same interface. It's a bit young, but by the time you complete your application, it would probably be more common.","Q_Score":1,"Tags":"python,linux,pyqt4","A_Id":4878854,"CreationDate":"2011-02-02T17:53:00.000","Title":"pyqt4 on Linux environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to learn how to use the rpm-python module (i.e. \"import rpm\" on RHEL5). I can't find any tutorials that are complete or recent. Specifically regarding how to install and manage rpm's on a system. Anyone?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":658,"Q_Id":4880818,"Users Score":0,"Answer":"If you are on RHEL then you could seriously consider using the yum APIs instead of rpm-python directly ... the API is much easier to use.","Q_Score":1,"Tags":"python,rpm,rhel5","A_Id":4935001,"CreationDate":"2011-02-02T22:45:00.000","Title":"Where is the most authoritative\/complete source of documentation on rpm-python module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"hi everybody\ni wanna take a dir from one directory and os doesn't allow me to do this work(for example \/etc\/openvpn in linux) and i know i should be root but i don't know how can i do this with python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":757,"Q_Id":4883541,"Users Score":1,"Answer":"you have to start the process as root.  You can run \"sudo yourscript.py\" as your normal user account or log in as root or run \"su -\" to become root and then run your script.\nYour script cannot obtain root privileges after it starts running.  That's just not how unix\/linux systems work.","Q_Score":1,"Tags":"python","A_Id":4883551,"CreationDate":"2011-02-03T07:41:00.000","Title":"access denied in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on a project to create simple file uploader site that will update the user of the progress of an upload. \nI've been attempting this in pure python (with CGI) on the server side but to get the progress of the file I obviously need send requests to the server continually. I was looking to use AJAX to do this but I was wondering how hard it would be to, instead of changing to some other framerwork (web.py for instance), just write my own web server for receiving the XML HTTP Requests?\nMy main problem is that sending the request is done from HTML and Javascript so it all seems like magic trickery at the moment.\nCan anyone advise me as to the best way to go about receiving these requests on the server? \nEDIT: It seems that a framework would be the way to go. Would web.py be a good route to take?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1735,"Q_Id":4898066,"Users Score":0,"Answer":"There's absolutely no need to write your own web server. Plenty of options exist, including  lightweight ones like nginx.\nYou should use one of those, and either your own custom WSGI code to receive the request, or (better) one of the microframeworks like Flask or Bottle.","Q_Score":1,"Tags":"python,http,xmlhttprequest","A_Id":4898364,"CreationDate":"2011-02-04T12:39:00.000","Title":"Creating a python web server to recieve XML HTTP Requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am thinking in starting a personal pet web project to experiment with different things and extend my knowledge.\nI use Java a lot at work (for web applications :D) and was thinking in making my own in Python since I kinda like this language but never passed the simple scripts stages. \nI want to  step up a gear regarding Python (using 2.6.5) and don't know what to expect or what framework to choose from: Django, Pylons, web2py etc.\nI also don't know how much these frameworks will offer me and how much will I have to write from scratch. \nI could use a comparison with Java if somebody can provide me with. I'm thinking at filter functionalities such as sitemesh, custom tags like JSTL; In Python, can I write clean pages of HTML with tags in them or write a lot of print statements (something like servlets did in Java etc?\nI don't know exactly how to phrase this question. \nI actually need a presentation of how web development is performed in Python, at what level, and what the web frameworks bring to the table.\nCan you share from your experience?\nTIA!","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":5940,"Q_Id":4909306,"Users Score":2,"Answer":"It may sound strange, but there's no need to know \"how web development is performed in Python\" to start doing it.\nIn fact, working with language\/framework\/etc is a single most reliable way to get understanding of it. You won't gain a lot from one-page summaries.\nAlso, comparing it with Java isn't likely to help. There's no point in doing \"Java-style development in Python\". If you want to benefit, you'll need to clear your mind and do everything \"Python-way\".\nAs to what Python framework to choose, Django seems like like a good starting point. It's very popular, which means you won't be left without tutorials\/documentation\/help.\nPS Short version: just do it.","Q_Score":6,"Tags":"java,python,templates,web-frameworks","A_Id":4909342,"CreationDate":"2011-02-05T19:57:00.000","Title":"Python web frameworks vs Java web frameworks (how is web development in Python done?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am thinking in starting a personal pet web project to experiment with different things and extend my knowledge.\nI use Java a lot at work (for web applications :D) and was thinking in making my own in Python since I kinda like this language but never passed the simple scripts stages. \nI want to  step up a gear regarding Python (using 2.6.5) and don't know what to expect or what framework to choose from: Django, Pylons, web2py etc.\nI also don't know how much these frameworks will offer me and how much will I have to write from scratch. \nI could use a comparison with Java if somebody can provide me with. I'm thinking at filter functionalities such as sitemesh, custom tags like JSTL; In Python, can I write clean pages of HTML with tags in them or write a lot of print statements (something like servlets did in Java etc?\nI don't know exactly how to phrase this question. \nI actually need a presentation of how web development is performed in Python, at what level, and what the web frameworks bring to the table.\nCan you share from your experience?\nTIA!","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":5940,"Q_Id":4909306,"Users Score":3,"Answer":"hi try bottle python framework (bottle.paws.de \/ bottlepy.org) its really nice to use blistering fast and gets out of your way + the best thing about it is that its one single file to import, i recently migrated from PHP and i have to tell you am so ... loving it!","Q_Score":6,"Tags":"java,python,templates,web-frameworks","A_Id":6586407,"CreationDate":"2011-02-05T19:57:00.000","Title":"Python web frameworks vs Java web frameworks (how is web development in Python done?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got 2 questions on analyzing a GPS dataset.\n1) Extracting trajectories I have a huge database of recorded GPS coordinates of the form (latitude, longitude, date-time). According to date-time values of consecutive records, I'm trying to extract all trajectories\/paths followed by the person. For instance; say from time M, the (x,y) pairs are continuously changing up until time N. After N, the change in (x,y) pairs decrease, at which point I conclude that the path taken from time M to N can be called a trajectory. Is that a decent approach to follow when extracting trajectories? Are there any well-known approaches\/methods\/algorithms you can suggest? Are there any data structures or formats you would like to suggest me to maintain those points in an efficient manner? Perhaps, for each trajectory, figuring out the velocity and acceleration would be useful?\n2) Mining the trajectories Once I have all the trajectories followed\/paths taken, how can I compare\/cluster them? I would like to know if the start or end points are similar, then how do the intermediate paths compare? \nHow do I compare the 2 paths\/routes and conclude if they are similar or not. Furthermore; how do I cluster similar paths together?\nI would highly appreciate it if you can point me to a research or something similar on this matter.\nThe development will be in Python, but all kinds of library suggestions are welcome.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6451,"Q_Id":4910510,"Users Score":1,"Answer":"1) Extracting trajectories \nI think you are in right direction. There are probably will be some noise in gps data, and random walking, you should do some smooth like splines to overcome it. \n\n2) Mining the trajectories\nIs there are any business sense in similar trajectories? (This will help build distance metric and then you can use some of mahoot clustering algorithms)\n 1. I think point where some person stoped are more interesting so you can generate statistics for popularity of places.\n 2. If you need route similarity to find different paths to same start-end you need to cluster first start end location and then similare curves by (maximum distance beetween, integral distance - some of well known functional metrics)","Q_Score":10,"Tags":"python,algorithm,gps,gis,data-mining","A_Id":4919289,"CreationDate":"2011-02-05T23:48:00.000","Title":"Comparing\/Clustering Trajectories (GPS data of (x,y) points) and Mining the data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to run php or python scripts from eclipse that will create folders and files and give them content. I think I know what to write for the php or python code but I am having trouble on what I need to do in eclipse to run my script. I would also like to provide my script with arguments such as folder names through a prompt on the eclipse side.\nI think I have to do something from Run-> External Tools -> External Tools Configuration. \nPlease Help, Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":4910541,"Users Score":1,"Answer":"you shouldn't have to do anything to eclipse, or any editor, if php\\python is installed you can call them from the command line.","Q_Score":1,"Tags":"php,python,eclipse,configuration","A_Id":4910592,"CreationDate":"2011-02-05T23:54:00.000","Title":"configurations eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using PyBluez on Ubuntu 10.10. I would like to know how is possible to change the bluetooth name of the local device in software. I couldn't find any command related..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1096,"Q_Id":4931244,"Users Score":1,"Answer":"Invoke org.bluez.Adapter.SetProperty(u'Name', u'New name here') in the \/org\/bluez\/<pid>\/<device> object path on the org.bluez D-Bus bus.","Q_Score":0,"Tags":"python,bluetooth,ubuntu-10.10","A_Id":4931264,"CreationDate":"2011-02-08T09:10:00.000","Title":"Change Bluetooth name Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute.\nWhat would you recommend as the best approach for that?\nThe things I considered are:\n1. Creating a Windows service\n2. Using a script in python (I have cygwin installed)\n3. Scheduled task using a batch file (although I don't want the black cmd window to pop up in my face every minute) \nThanks for any additional ideas or hints on how to best implement it.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2416,"Q_Id":4935257,"Users Score":1,"Answer":"This is trivially easy with a scheduled task which is the native Windows way to schedule tasks! There's no need for cygwin or Python or anything like that.\nI have such a task running on my machine which pokes my Wordpress blog every few hours. The script is just a .bat file which calls wget. The task is configured to \"Run whether user is logged on or not\" which ensures that it runs when I'm not logged on. There's no \"black cmd window\".\nYou didn't say which version of Windows you are on and if you are on XP (unlucky for you if you are) then the configuration is probably different since the scheduled task interface changed quite a bit when Vista came out.","Q_Score":1,"Tags":"python,http,windows-services,scheduled-tasks","A_Id":4955373,"CreationDate":"2011-02-08T15:56:00.000","Title":"How to periodically create an HTTP POST request from windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute.\nWhat would you recommend as the best approach for that?\nThe things I considered are:\n1. Creating a Windows service\n2. Using a script in python (I have cygwin installed)\n3. Scheduled task using a batch file (although I don't want the black cmd window to pop up in my face every minute) \nThanks for any additional ideas or hints on how to best implement it.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2416,"Q_Id":4935257,"Users Score":2,"Answer":"If you have cygwin, you probably have cron - run a python script from your crontab.","Q_Score":1,"Tags":"python,http,windows-services,scheduled-tasks","A_Id":4935443,"CreationDate":"2011-02-08T15:56:00.000","Title":"How to periodically create an HTTP POST request from windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have 2 video streams\n(1) VLC Generated Compressed MP4 UDP stream\n(2) DV Uncompressed UDP Stream\nBoth are destined to a host. At this Unix receiving host, I would like to detect type of stream coming using Bash or Python Scripting (without tcpdump, I do not have root priv.)\nANY idea guys how to implement ? \nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":281,"Q_Id":4935387,"Users Score":1,"Answer":"what about trying pyffmpeg out. you should be able to get the container info from that.","Q_Score":0,"Tags":"python,bash,streaming,video-streaming,multimedia","A_Id":4935406,"CreationDate":"2011-02-08T16:08:00.000","Title":"Detecting Type of Video Stream","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having problem when I do a query to mongodb using pymongo.\nI do not know how to avoid getting the _id for each record.\nI am doing something like this,\nresult = db.meta.find(filters, [\n                                   'model',\n                                'fields.parent',\n                                'fields.status',\n                               'fields.slug',\n                               'fields.firm',\n                               'fields.properties'])\nI do not want to iterate the cursor elements only to delete a field.\nThanks,\nJoaquin","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":803,"Q_Id":4937817,"Users Score":0,"Answer":"Does make any sense. The object id is core part of each document. Convert the BSON\/JSON document to a native datastructure (depending on your implementation language) and remove _id on this level. Apart from that it does not make much sense what you are trying to accomplish.","Q_Score":1,"Tags":"python,mongodb,pymongo","A_Id":4941686,"CreationDate":"2011-02-08T20:08:00.000","Title":"PYMongo: Keep returning _id in every record after quering, How can I exclude this record?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a program in Python.  The first thing that happens is a window is displayed (I'm using wxPython) that has some buttons and text.  When the user performs some actions, a plot is displayed in its own window.  This plot is made with R, using rpy2.  The problem is that the plot usually pops up on top of the main window, so the user has to move the plot to see the main window again.  This is a big problem for the user, because he's lazy and good-for-nothing.  He wants the plot to simply appear somewhere else, so he can see the main window and the plot at the same time, without having to lift a finger.\nTwo potential solutions to my problem are:\n(1) display the plot within a wxPython frame (which I think I could control the location of), or\n(2) be able to specify where on the screen the plot window appears.\nI can't figure out how to do either.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":757,"Q_Id":4938556,"Users Score":5,"Answer":"Plot to a graphics file using jpeg(), png() or another device, then display that file on your wxWidget.","Q_Score":3,"Tags":"python,r,plot,rpy2","A_Id":4938599,"CreationDate":"2011-02-08T21:17:00.000","Title":"How do I control where an R plot is displayed, using python and rpy2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Assuming I have different profiles for different user types - staff, teacher,students:\nHow do I specify AUTH_PROFILE_MODULE in order to get back the appropriate profile with get_profile?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1474,"Q_Id":4941125,"Users Score":0,"Answer":"It may be more hassle to try to use multiple profiles with the simplistic configuration of UserProfile.\nI would suggest using UserProfile with generic foreign key, or completely ditch UserProfile and create separate models with a User foreign key.  \nIf you are going to have a lot of data attached to these extra user profiles, I would keep them in models separate from UserProfile.  My personal opinion about UserProfile is that it can quickly become the dumping ground for user data that doesn't have a nice home.\nDon't think that you have to use UserProfile just because your data sounds like it is profile information.  I don't think UserProfile was ever intended to solve all the problems. I see it as a way to make up for the fact that the code for the User model is under django code and we don't generally mess with it to add user data.","Q_Score":2,"Tags":"python,django,django-models","A_Id":4966022,"CreationDate":"2011-02-09T03:50:00.000","Title":"django how to use AUTH_PROFILE_MODULE with multiple profiles?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can draw matplotlib graph in command line(shell) environment, but I find that I could not draw the same graph inside the eclipse IDE. such as plot([1,2,3]) not show in eclipse, I writed show() in the end but still not show anything \nmy matplotlib use GTKAgg as backend, I use Pydev as plugin of eclipse to develop python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3911,"Q_Id":4941162,"Users Score":1,"Answer":"import matplotlib.pyplot as mp\nmp.ion()\nmp.plot(x,y)\nmp.show()","Q_Score":1,"Tags":"python,eclipse,matplotlib","A_Id":5640511,"CreationDate":"2011-02-09T03:56:00.000","Title":"How to draw matplotlib graph in eclipse?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some C++ methods that have std::set<std::string> as argument or return value.\nI would like to map this to a Python frozenset (or regular set) but there does not seem to be a straightforward way to do this.\nDoes anyone know how one may accomplish this task.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":741,"Q_Id":4946837,"Users Score":0,"Answer":"Unfortunately, the standard indexing_suite from Boost.Python does not support std::set. There is a indexing_suite v2, that works on all stl containers. (http:\/\/mail.python.org\/pipermail\/cplusplus-sig\/2009-July\/014704.html)\nIt may not have made it to the official distribution, but you can find it by asking around. \n(http:\/\/mail.python.org\/pipermail\/cplusplus-sig\/2009-July\/014691.html)\nI found it to be harder to use then the original indexing_suite, but it might fit your needs.\nIf that does not work, you can just manually wrap std::set<std::string> like you would any other class. This will get you a std::set<std::string> into python, where you can turn it into a python set fairly easily. \n\nI think that both of those are more work then is called for though. Here is what I would do:\nFirst, wrap the function in C++ with one that has the same signature, but stuffs the returned data in to a std::vector<std::string> instead of a std::set<std::string>. expose that function rather then the original \nNow you have the data in python.\nSecond, wrap the c++ function in python function that takes the data in that std::vector<std::string> and stuffs it into a python set. \nYes, this is rather silly from a design aesthetics point of view, and not the most performant code in the world, but is gets you to where you are going with a minimum of code, and it is fairly robust.","Q_Score":5,"Tags":"c++,python,boost-python","A_Id":4959254,"CreationDate":"2011-02-09T15:21:00.000","Title":"Create and access frozenset with Boost Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some C++ methods that have std::set<std::string> as argument or return value.\nI would like to map this to a Python frozenset (or regular set) but there does not seem to be a straightforward way to do this.\nDoes anyone know how one may accomplish this task.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":741,"Q_Id":4946837,"Users Score":1,"Answer":"Or you can use std::map<YourType, int> instead of std::set<YourType>, the value can be for example 0. std::map has the same insert\/search time complexity as std::set, it also keeps the keys ordered, it will only bloat the memory a little. Then you can use map indexing suite and in python you can hide the difference in some wrapper class if needed. The disanvantage is that you have to modify your existing c++ code a little bit.","Q_Score":5,"Tags":"c++,python,boost-python","A_Id":13380546,"CreationDate":"2011-02-09T15:21:00.000","Title":"Create and access frozenset with Boost Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I have a simple function, it connects to a database (or a queue), gets a url that hasn't been visited, and then fetches the HTML at the given URL.\nNow this process is serial, i.e. it will only fetch the html from a given url one at a time, how can I make this faster by doing this in a group of threads?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1238,"Q_Id":4962022,"Users Score":0,"Answer":"You can do this using any of:\n\nthe thread module (if your task is a function)\nthe threading module (if you want to write your task as a subclass of threading.Thread)\nthe multiprocessing module (which uses a similar interface to threading)\n\nAll of these are available in the Python standard library (2.6 and later), and you can get the multiprocessing module for earlier versions as well (it just wasn't packaged with Python yet).","Q_Score":2,"Tags":"python,multithreading","A_Id":4962704,"CreationDate":"2011-02-10T20:02:00.000","Title":"In python, is it easy to call a function multiple times using threads?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to implement Dijkstra's Algorithm in Python. However, I have to use a 2D array to hold three pieces of information - predecessor, length and unvisited\/visited.\nI know in C a Struct can be used, though I am stuck on how I can do a similar thing in Python, I am told it's possible but I have no idea to be honest","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":5571,"Q_Id":4962202,"Users Score":1,"Answer":"Encapsulate that information in a Python object and you should be fine.","Q_Score":0,"Tags":"python,dijkstra","A_Id":4962223,"CreationDate":"2011-02-10T20:21:00.000","Title":"Python - Dijkstra's Algorithm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to implement Dijkstra's Algorithm in Python. However, I have to use a 2D array to hold three pieces of information - predecessor, length and unvisited\/visited.\nI know in C a Struct can be used, though I am stuck on how I can do a similar thing in Python, I am told it's possible but I have no idea to be honest","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5571,"Q_Id":4962202,"Users Score":0,"Answer":"Python is object oriented language. So think of it like moving from Structs in C to Classes of C++. You can use the same class structure in Python as well.","Q_Score":0,"Tags":"python,dijkstra","A_Id":4962291,"CreationDate":"2011-02-10T20:21:00.000","Title":"Python - Dijkstra's Algorithm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I apologize for not giving this question a better title; the reason that I am posting it is that I don't even have the correct terminology to know what I am looking for.\nI have defined a class with an attribute 'spam':\n\ndef SpamClass(object):\n    def __init__(self, arg):\n        self.spam = arg\n    def __str__(self):\n        return self.spam\n\nI want to create a (sub\/sibling?)class that has exactly the same functionality, but with an attribute named 'eggs' instead of 'spam':\n\ndef EggsClass(object):\n    def __init__(self, arg):\n        self.eggs = arg\n    def __str__(self):\n        return self.eggs\n\nTo generalize, how do I create functionally-identical classes with arbitrary attribute names? When the class has complicated behavior, it seems silly to duplicate code.\nUpdate: I agree that this smells like bad design. To clarify, I'm not trying to solve a particular problem in this stupid way. I just want to know how to arbitrarily name the (non-magic) contents of an object's __dict__ while preserving functionality. Consider something like the keys() method for dict-like objects. People create various classes with keys() methods that behave according to convention, and the naming convention is a Good Thing. But the name is arbitrary. How can I make a class with a spam() method that exactly replaces keys() without manually substituting \/keys\/spam\/ in the source?\nOverloading __getattr__ and friends to reference the generic attribute seems inelegant and brittle to me. If a subclass reimplements these methods, it must accommodate this behavior. I would rather have it appear to the user that there is simply a base class with a named attribute that can be accessed naively.\nActually, I can think of a plausible use case. Suppose that you want a mixin class that confers a special attribute and some closely related methods that manipulate or depend upon this attribute. A user may want to name this special attribute differently for different classes (to match names in the real-world problem domain or to avoid name collisions) while reusing the underlying behavior.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":722,"Q_Id":4966509,"Users Score":0,"Answer":"To create attributes during runtime, just add them in self.__dict__['foo'] = 'I'm foo' in the class code.","Q_Score":0,"Tags":"python,attributes,introspection,metaclass","A_Id":4967128,"CreationDate":"2011-02-11T07:16:00.000","Title":"creating Python classes with arbitrarily substituted attribute name","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to read data from a text field. The name of the text field is not defined of found in the other class with methods of reading the text field. The textfield is defined in the Design class. now how do I access this field from another class, so I can read data from it. Thanks!!\nEdit:\nI have 2 Classes: FeatureImportCommonWidget(QtGui.QWidget) and MetaDataBrowser. FeatureImportCommonWidget contains a Text Field called placesGroupBox. I want to access this text field in the MetaDataBrowser Class.\nI tried it using \"filename = get_metadata.placesGroupBox.text()\", but it gives an error about placesGroupBox not being defined in the MetaDataBrowser class.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":4967179,"Users Score":0,"Answer":"If the field's an ordinary attribute called text and your Design instance is called design, you can access (read\/write) it from anywhere as design.text.","Q_Score":0,"Tags":"python,pyqt","A_Id":4968555,"CreationDate":"2011-02-11T09:01:00.000","Title":"Python Referencing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to read data from a text field. The name of the text field is not defined of found in the other class with methods of reading the text field. The textfield is defined in the Design class. now how do I access this field from another class, so I can read data from it. Thanks!!\nEdit:\nI have 2 Classes: FeatureImportCommonWidget(QtGui.QWidget) and MetaDataBrowser. FeatureImportCommonWidget contains a Text Field called placesGroupBox. I want to access this text field in the MetaDataBrowser Class.\nI tried it using \"filename = get_metadata.placesGroupBox.text()\", but it gives an error about placesGroupBox not being defined in the MetaDataBrowser class.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":4967179,"Users Score":0,"Answer":"1.  if object of FeatureImportCommonWidget class is created inside of MetaDataBrowser class, you can access your text field anywhere inside MetaDataBrowser class like this: FeatureImportCommonWidgetObjectName.placesGroupBox.text()\n2   if object of FeatureImportCommonWidget class is created before MetaDataBrowser class, you can pass that object as parameter to MetaDataBrowser class and then access your text field anywhere inside MetaDataBrowser class like in step 1","Q_Score":0,"Tags":"python,pyqt","A_Id":17676533,"CreationDate":"2011-02-11T09:01:00.000","Title":"Python Referencing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been learning python for use in ArcGIS and some other non-web applications. However, now that I've taken on building a personal website I am interested in using it for web development (as it is the only scripting language I currently know).\nI've noticed that there are a lot of these things called \"frameworks\", such as Django. From what I understand they are just a collection of packages to save you from re-inventing the wheel but I don't really know how they work.\nFurthermore, I do not like GUIs, if I need a framework I would like to find one that could be used through a terminal, starts out simple and can be scaled for more complexity when I'm ready. Any advice or ideas on frameworks and why I would want to use one?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":553,"Q_Id":4980756,"Users Score":2,"Answer":"The Python web frameworks have nothing to do with GUIs, and can all be used via the terminal. \nThe benefits of a framework, as you say, are all to do with making your life easier by supplying the components you need to build a website: the main ones are database interaction through an ORM, a templating system, and URL routing. On top of that, the big frameworks also included optional extras like user authentication, administration interface, and so on.\nPersonally I like Django, but your mileage may vary: I would say, though, that whatever you do with Python and the web will require some sort of framework, even if it's one of the absolute minimal ones like Flask which basically do just the routing part. There's simply no point in writing all this stuff from scratch when it's been done for you.","Q_Score":1,"Tags":"python,web,web-frameworks,web-scripting","A_Id":4980831,"CreationDate":"2011-02-12T21:30:00.000","Title":"I'm learning python and am interested in using it for web-scripting. What frameworkes are out there and do I need one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning python for use in ArcGIS and some other non-web applications. However, now that I've taken on building a personal website I am interested in using it for web development (as it is the only scripting language I currently know).\nI've noticed that there are a lot of these things called \"frameworks\", such as Django. From what I understand they are just a collection of packages to save you from re-inventing the wheel but I don't really know how they work.\nFurthermore, I do not like GUIs, if I need a framework I would like to find one that could be used through a terminal, starts out simple and can be scaled for more complexity when I'm ready. Any advice or ideas on frameworks and why I would want to use one?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":553,"Q_Id":4980756,"Users Score":0,"Answer":"Personnally, I don't use any framework, I write either from scratch on BaseHTTPServer, or using WSGI (with mod_wsgi).\nIt is a bit long to write the skeleton, but I think it is faster (I mean at runtime), there is less constraints, and there is lesser to learn.","Q_Score":1,"Tags":"python,web,web-frameworks,web-scripting","A_Id":4981185,"CreationDate":"2011-02-12T21:30:00.000","Title":"I'm learning python and am interested in using it for web-scripting. What frameworkes are out there and do I need one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A user can perform an action, which may trigger dependent actions (which themselves may have dependent actions) and I want to be able to cancel the whole thing if the user cancels a dependent action.\nThe typical way I've seen this done is some variant of an undo stack and each action will need to know how to undo itself, and then if a child action is cancelled the undo's cascade their way up.  Sometimes writing undo methods are tricky and there isn't always enough information in context to properly know how to undo an action in an isolated manner.\nI just thought of a (potentially) easier way which is to just pickle the state of the (relevant parts of) program, and then the cancel would just restore to it's former state, without needing to create separate undo logic for each action.\nHas anyone tried this?  Any gotchas to watch out for?  Any reason not to do this?\nEdit: The dependent actions must happen after the parent action (and even whether there are dependent actions may depend on the result of the parent action), so just checking all the dependencies before doing anything isn't an option.  I guess you could say an action triggers other actions, but if one of the triggered actions cannot be performed, then none of it happened.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":310,"Q_Id":4986467,"Users Score":1,"Answer":"Well, as you mentioned the data design is loosely coupled, so you I don't think you need to pickle it if it's in memory. Just take a copy of all the relevant variables, and the transaction.abort() would just copy them back, and transaction.commit() would then just remove the copy of the data.\nThere are issues, but none that you don't have with the pickle solution.","Q_Score":1,"Tags":"python,transactions,pickle,undo","A_Id":4986678,"CreationDate":"2011-02-13T19:50:00.000","Title":"Using pickle for in-memory \"transaction\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A user can perform an action, which may trigger dependent actions (which themselves may have dependent actions) and I want to be able to cancel the whole thing if the user cancels a dependent action.\nThe typical way I've seen this done is some variant of an undo stack and each action will need to know how to undo itself, and then if a child action is cancelled the undo's cascade their way up.  Sometimes writing undo methods are tricky and there isn't always enough information in context to properly know how to undo an action in an isolated manner.\nI just thought of a (potentially) easier way which is to just pickle the state of the (relevant parts of) program, and then the cancel would just restore to it's former state, without needing to create separate undo logic for each action.\nHas anyone tried this?  Any gotchas to watch out for?  Any reason not to do this?\nEdit: The dependent actions must happen after the parent action (and even whether there are dependent actions may depend on the result of the parent action), so just checking all the dependencies before doing anything isn't an option.  I guess you could say an action triggers other actions, but if one of the triggered actions cannot be performed, then none of it happened.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":310,"Q_Id":4986467,"Users Score":1,"Answer":"You can use pickle to store your state if all elements of state are serializable (usually they are). The only reasons for not doing so:\n\nif you have to store pointers to any objects that are not saved in state, you will have problems with these    pointers after performing undo    operation.\nthis method could be expensive,       depending on the size of your state.\n\nAlso you can use zip() to lower memory usage in exchange of raising CPU usage.","Q_Score":1,"Tags":"python,transactions,pickle,undo","A_Id":4986707,"CreationDate":"2011-02-13T19:50:00.000","Title":"Using pickle for in-memory \"transaction\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a small cross-platform wxPython app, however on every platform I need to use some platform-specific API. On Mac OS it can be done using PyObjC. \nI'm searching for tutorial on how to use PyObjC. However, all I found so far were tutorials with Xcode. I want my app to be able to run on mac\/win\/lin, without changes, and I don't want to develop it in Xcode. Is there a way?\nUPD. To be more specific I need to access some pen-tablet events from Mac OS X and I wanted to use PyObjC for that (I don't see any other ways).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3791,"Q_Id":4994058,"Users Score":0,"Answer":"What do you need Xcode for? If you need it for the windows\/gui (*.nib, *.xib files), then you should perhaps search for 'creating *.nib, *xib without Xcode'.\nThat's only a search hint and no satisfying answer.","Q_Score":6,"Tags":"python,macos,wxpython,pyobjc","A_Id":5071853,"CreationDate":"2011-02-14T15:39:00.000","Title":"PyObjC tutorial without Xcode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am using TG2.1 on WinXP.\nPython ver is 2.6.\nTrying to use sqlautocode (0.5.2) for working with my existing MySQL schema.\nSQLAlchemy ver is 0.6.6\n\n\nimport sqlautocode  # works OK\n\n\nWhile trying to reflect the schema ----\n\n\nsqlautocode mysql:\\\\username:pswd@hostname:3306\\schema_name -o tables.py\n\n\nSyntaxError: invalid syntax\nis raised.\nCan someone please point out what's going wrong, & how to handle the same?\nThanks,\nVineet.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":659,"Q_Id":4994838,"Users Score":1,"Answer":"Hey, I got it right somehow.\nThe problem seems to be version mismatch between SA 0.6 & sqlautocode 0.6\nSeems that they don't work in tandom.\nSo I removed those & installed SA 0.5\nNow it's working.\nThanks,\nVineet Deodhar.","Q_Score":2,"Tags":"python,web-applications,turbogears2","A_Id":5003413,"CreationDate":"2011-02-14T16:55:00.000","Title":"sqlautocode for mysql giving syntax error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to make a small game that supports Python scripting. I've no problems with using the Python C-API, but I don't know how to ensure that the game will run on a computer with no Python installed.\nI know I need pythonXY.dll -- what else is there? When I try to run the program it tells me it cannot find encodings.utf_8. I tried copying the encodings\/utf_8.py file in the same directory as my program, but the error still pops up.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":258,"Q_Id":4995336,"Users Score":0,"Answer":"You need the encodings\/__init__.py file, otherwise encodings is a folder and not a python package.\nChances are that you'll need a lot of stuff from within the python standard library. To make everything just work you'll need to include the entire standard library along with your program.\nYou can make this a bit better by putting the library in a zip file and adding that to sys.path. Also, you can include only pyc not the original py files.","Q_Score":2,"Tags":"python,embed,python-c-api","A_Id":4995435,"CreationDate":"2011-02-14T17:40:00.000","Title":"C++ Python embedding: Run on machine with no Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"What's the simplest way to set up a JSON-RPC server in python and make it secure?  I'm very interested Pyjamas for python\/javascript - but the documentation doesn't explain how to implement security with the JSON-RPC.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":934,"Q_Id":4999078,"Users Score":2,"Answer":"I've played with pyjamas a little and am currently implementing json-rpc with django.\nHave you considered using ssl to secure the site. Short of implementing your own (basic) encryption routine, its probably the best way forward.","Q_Score":2,"Tags":"python,json,pyjamas","A_Id":5659587,"CreationDate":"2011-02-15T01:20:00.000","Title":"Easy secure JSON-RPC in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a web app that needs both functionality and performance tested, and part of the test suite that we plan on using is already written in Python. When I first wrote this, I used mechanize as my means of web-scraping, but it seems to be too bulky for what I'm trying to do (either that or I'm missing something).\nThe basic layout of what I'm trying to do is as follows. All are objects.\n\nUser has Comm (used to be the interface between my stuff and mechanize)  \nComm has Browser (holds my CookieJar, urllib2, and BeautifulSoup objects, used to be mechanize)  \nBrowser has Form(s) (used to be mechanize-handled)\n\nNow, as far as threading goes, I have that down. Adjustment between dealing with the GIL and having separate instances of Python running will be made as needed, but suggestions will be taken.\nSo what I need to do is thread users hitting the application and doing various things (logging in, filling out forms, submitting forms for processing, etc.) while not making the testing box scream too loudly. My current problem with mechanize seems to be RAM.\nPart of what's causing the RAM issue is the need for separate browser instances for each user to keep from overwriting the JSESSIONID cookie every time I do something with a different user.\nMuch of this might seem trivial, but I'm trying to run thousands of threads here, so little tweaks can mean a lot. Any input is appreciated.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":929,"Q_Id":5002986,"Users Score":0,"Answer":"I actually went without using mechanize and used the Threading module. This allowed for fairly quick transactions, and I also made sure not to have too much inside of each thread. Login information, and getting the webapp in the state necessary before I threaded helped the threads to run shorter and therefore more quickly.","Q_Score":2,"Tags":"python,automated-tests,web-scraping,urllib2,mechanize-python","A_Id":5462848,"CreationDate":"2011-02-15T11:22:00.000","Title":"Python web-scraping threaded performance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a web app that needs both functionality and performance tested, and part of the test suite that we plan on using is already written in Python. When I first wrote this, I used mechanize as my means of web-scraping, but it seems to be too bulky for what I'm trying to do (either that or I'm missing something).\nThe basic layout of what I'm trying to do is as follows. All are objects.\n\nUser has Comm (used to be the interface between my stuff and mechanize)  \nComm has Browser (holds my CookieJar, urllib2, and BeautifulSoup objects, used to be mechanize)  \nBrowser has Form(s) (used to be mechanize-handled)\n\nNow, as far as threading goes, I have that down. Adjustment between dealing with the GIL and having separate instances of Python running will be made as needed, but suggestions will be taken.\nSo what I need to do is thread users hitting the application and doing various things (logging in, filling out forms, submitting forms for processing, etc.) while not making the testing box scream too loudly. My current problem with mechanize seems to be RAM.\nPart of what's causing the RAM issue is the need for separate browser instances for each user to keep from overwriting the JSESSIONID cookie every time I do something with a different user.\nMuch of this might seem trivial, but I'm trying to run thousands of threads here, so little tweaks can mean a lot. Any input is appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":929,"Q_Id":5002986,"Users Score":0,"Answer":"Have you considered Twisted, the asynchronous library, for at least doing interaction with users?","Q_Score":2,"Tags":"python,automated-tests,web-scraping,urllib2,mechanize-python","A_Id":5236735,"CreationDate":"2011-02-15T11:22:00.000","Title":"Python web-scraping threaded performance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just started using Natural Language Toolkit (NLTK) as a part of my Engineering college project. Can anybody please tell me how do I read an input paragraph text and\n1) break it down into textual components i.e into number of sentences, number of words, number of characters and number of polysyllabic or complex words in the given paragraph\nand\n2) Also print the above determined values","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":255,"Q_Id":5006424,"Users Score":0,"Answer":"Where's the input paragraph coming from? File? Console? That's more of a python issue than NLTK.\nFor the rest, look at the nltk.tokenize module & nltk.probability.FreqDist.","Q_Score":2,"Tags":"python,nltk","A_Id":5009683,"CreationDate":"2011-02-15T16:30:00.000","Title":"How do I find text features and print them?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The python unit testing framework called nosetest has a plugin for sqlalchemy, however there is no documentation for it that I can find. I'd like to know how it works, and if possible, see a code example.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":340,"Q_Id":5009112,"Users Score":0,"Answer":"It is my understanding that this plugin is only meant for unit testing SQLAlchemy itself and not as a general tool. Perhaps that is why there are no examples or documentation? Posting to the SQLAlchemy mailing list is likely to give you a better answer \"straight from the horse's mouth\".","Q_Score":3,"Tags":"python,sqlalchemy,nosetests","A_Id":10268378,"CreationDate":"2011-02-15T20:26:00.000","Title":"How does the nosetests sqlalchemy plugin work?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)\nTornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":4348,"Q_Id":5011135,"Users Score":1,"Answer":"Use Django. \nI'm a hardcore Tornado fan but if you need to ask, Django is the best tool for you. Tornado is great but Django is much easier to build when you need a MySQL database thanks to its awesome ORM.","Q_Score":5,"Tags":"python,tornado","A_Id":12342342,"CreationDate":"2011-02-16T00:25:00.000","Title":"python tornado setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)\nTornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4348,"Q_Id":5011135,"Users Score":0,"Answer":"If you are using tornado follow nginx.","Q_Score":5,"Tags":"python,tornado","A_Id":31242703,"CreationDate":"2011-02-16T00:25:00.000","Title":"python tornado setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)\nTornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":4348,"Q_Id":5011135,"Users Score":1,"Answer":"if you using tornado for websockets you can use ha-proxy for proxying socket request to tornado (ngnix not support this)","Q_Score":5,"Tags":"python,tornado","A_Id":8414532,"CreationDate":"2011-02-16T00:25:00.000","Title":"python tornado setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)\nTornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":4348,"Q_Id":5011135,"Users Score":0,"Answer":"If you setup tornado via LAMP (apache with mod_wsgi for example) you will lose every single async option in tornado, significant amount of memory and speed.\nIt's highly recomended to use nginx for serving static files and proxying dynamic requests to the tornado application instance.","Q_Score":5,"Tags":"python,tornado","A_Id":7278376,"CreationDate":"2011-02-16T00:25:00.000","Title":"python tornado setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a wxPython app with one frame and one panel.  On that panel are a number of static boxes, each of which has buttons and textboxes.\nI have just begun reading about sizers, but they seem like they might be more than what I need, or it could that they are exactly what I need but I don't know how to use them correctly!\nThe frame currently opens at 1920 x 1080.  If the user drags the bottom right corner to resize the app, I just want everything to get smaller or larger as needed to keep the same size ratio.\nIs this possible?\nThank you!\nedit: additional info: I used wxPython 2.8 and Boa to construct the GUI.  I am contemplating trying another gui ide.\nSo after reading some more about sizers, I am thinking about doing the following:\nadd a gridsizer and basically divide my window's elements into rows and columns, then set each row and column's size as necessary until I achieve the original layout.  Then I guess set the rows and columns to resize correctly?  Is this a decent idea?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":301,"Q_Id":5012257,"Users Score":1,"Answer":"For complex layouts, I sketch it out on a piece of paper. Then I draw boxes around the widgets in different ways to decide what sizers to use. You can nest pretty much any sizer inside another one. If the controls naturally fit in a grid, then using a grid sizer of some sort is probably alright. If not, then use BoxSizers. I tend to use those the most.","Q_Score":1,"Tags":"python,wxpython,boxsizer","A_Id":5018264,"CreationDate":"2011-02-16T03:31:00.000","Title":"Simple wxPython Frame Contents Resizing - Ratio?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any way to find out what seed Python used to seed its random number generator?\nI know I can specify my own seed, but I'm quite happy with Python managing it.  But, I do want to know what seed it used, so that if I like the results I'm getting in a particular run, I could reproduce that run later.  If I had the seed that was used then I could.\nIf the answer is I can't, then what's the best way to generate a seed myself?  I want them to always be different from run to run---I just want to know what was used.\nUPDATE: yes, I mean random.random()!  mistake...  [title updated]","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":41980,"Q_Id":5012560,"Users Score":2,"Answer":"The seed is an internal variable in the random package which is used to create the next random number. When a new number is requested, the seed is updated, too. \nI would simple use 0 as a seed if you want to be sure to have the same random numbers every time, or make i configurable. \nCorelDraw once had a random pattern generator, which was initialized with a seed. Patterns varied drastically for different seeds, so the seed was important configuration information of the pattern. It should be part of the config options for your runs.\nEDIT: As noted by ephemient, the internal state of a random number generator may be more complex than the seed, depending on its implementation.","Q_Score":59,"Tags":"python,random,seed","A_Id":5012654,"CreationDate":"2011-02-16T04:32:00.000","Title":"how to query seed used by random.random()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Im currently working on a project with pygame and am in need of being able to view part of a surface, moving around, zooming in and out ect\nCan anyone recommend a way of achieving this efficently, i have it working in a convoluted method at the moment but it is too slow and reduces the game to about 1fps when zoomed out to view the whole area. (my version of only scrolling and no zooming works fine with no lagging)\nLooking though the docs pygame.transform.scroll looks promising but i am unsure how i would correctly implement it with pygame.transform.scale for zooming in and out\nAny help welcome\nupdate:\nI fiddled around for a bit and got it working scaleing objects and their positions before bliting them. I have now hit the problem that the scaling looks unatural because of the low resolution of the pygame scroll wheel events so I am now trying to impliment some kind of smoothing.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7328,"Q_Id":5014993,"Users Score":0,"Answer":"For a game that I have never finished I used trigonometry to get the new drawing positions with a freely zoomed and turned camera (bit complicated). It didn't really take to much time to calculate but I think it is more efficient to use other libraries. But if you want some examples just ask.","Q_Score":5,"Tags":"python,scroll,zooming,transform,pygame","A_Id":13349846,"CreationDate":"2011-02-16T10:02:00.000","Title":"Pygame zooming\/scrolling window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im currently working on a project with pygame and am in need of being able to view part of a surface, moving around, zooming in and out ect\nCan anyone recommend a way of achieving this efficently, i have it working in a convoluted method at the moment but it is too slow and reduces the game to about 1fps when zoomed out to view the whole area. (my version of only scrolling and no zooming works fine with no lagging)\nLooking though the docs pygame.transform.scroll looks promising but i am unsure how i would correctly implement it with pygame.transform.scale for zooming in and out\nAny help welcome\nupdate:\nI fiddled around for a bit and got it working scaleing objects and their positions before bliting them. I have now hit the problem that the scaling looks unatural because of the low resolution of the pygame scroll wheel events so I am now trying to impliment some kind of smoothing.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7328,"Q_Id":5014993,"Users Score":0,"Answer":"You can use pygame with OpenGL, since you are already familiar with pygame. Otherwise pyglet is a similar opengl library.","Q_Score":5,"Tags":"python,scroll,zooming,transform,pygame","A_Id":7509780,"CreationDate":"2011-02-16T10:02:00.000","Title":"Pygame zooming\/scrolling window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a \"method\" to get a formula, formula which comes from fitting a set of data (3000 point). I was using Legendre polynomial, but for > 20 points it gives not exact values. I can write chi2 test, but algorithm needs a loot of time to calculate N parameters, and at the beginning I don't know how the function looks like, so it takes time. I was thinking about splines... Maybe ...\nSo the input is: 3000 pints\nOutput         : f(x) = ... something\nI want to have a formula from fit. What is a best way to do this in python?\nLet the force would be with us!\nNykon","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":2988,"Q_Id":5021921,"Users Score":3,"Answer":"Except, a spline does not give you a \"formula\", at least not unless you have the wherewithal to deal with all of the piecewise segments. Even then, it will not be easily written down, or give you anything that is at all pretty to look at.\nA simple spline gives you an interpolant. Worse, for 3000 points, an interpolating spline will give you roughly that many cubic segments! You did say interpolation before. OF course, an interpolating polynomial of that high an order will be complete crapola anyway, so don't think you can just go back there.\nIf all that you need is a tool that can provide an exact interpolation at any point, and you really don't need to have an explicit formula, then an interpolating spline is a good choice.\nOr do you really want an approximant? A function that will APPROXIMATELY fit your data, smoothing out any noise? The fact is, a lot of the time when people who have no idea what they are doing say \"interpolation\" they really do mean approximation, smoothing. This is possible of course, but there are entire books written on the subject of curve fitting, the modeling of empirical data. You first goal is then to choose an intelligent model, that will represent this data. Best of course is if you have some intelligent choice of model from physical understanding of the relationship under study, then you can estimate the parameters of that model using a nonlinear regression scheme, of which there are many to be found.\nIf you have no model, and are unwilling to choose one that roughly has the proper shape, then you are left with generic models in the form of splines, which can be fit in a regression sense, or with high order polynomial models, for which I have little respect.\nMy point in all of this is YOU need to make some choices and do some research on a choice of model.","Q_Score":1,"Tags":"python,numpy,scipy,data-fitting","A_Id":5022089,"CreationDate":"2011-02-16T20:48:00.000","Title":"large set of data, interpolation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a \"method\" to get a formula, formula which comes from fitting a set of data (3000 point). I was using Legendre polynomial, but for > 20 points it gives not exact values. I can write chi2 test, but algorithm needs a loot of time to calculate N parameters, and at the beginning I don't know how the function looks like, so it takes time. I was thinking about splines... Maybe ...\nSo the input is: 3000 pints\nOutput         : f(x) = ... something\nI want to have a formula from fit. What is a best way to do this in python?\nLet the force would be with us!\nNykon","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2988,"Q_Id":5021921,"Users Score":0,"Answer":"The only formula would be a polynomial of order 3000.\nHow good does the fit need to be? What type of formula do you expect?","Q_Score":1,"Tags":"python,numpy,scipy,data-fitting","A_Id":5022008,"CreationDate":"2011-02-16T20:48:00.000","Title":"large set of data, interpolation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying automatically generate buttons to a menu using PIL in python.\nThe button should be small rectangular and have a little gradient from one color to another, and a little text in it.\nIs PIL the best way to do this, or is Cairo a better alternative? Any suggestion to how I can accomplish this without having a image to start with..?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":413,"Q_Id":5022891,"Users Score":1,"Answer":"You can do this entirely with PIL if you start with a single pre-made white-to-black gradient image (that you've made in some other program) and then use the ImageChops module to manipulate this together with your primary image to get what you want.\nFor example to if you want to fade from red to blue: multiply red by the gradient, flip the gradient and multiply blue by this, and add these together.\nIf your images vary in size, you can scale the gradient image appropriately in PIL.","Q_Score":1,"Tags":"python,python-imaging-library,cairo","A_Id":5024687,"CreationDate":"2011-02-16T22:25:00.000","Title":"Generating a shaded button using PIL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Commonly on most unix systems there is a distinction between $PREFIX\/bin and $PREFIX\/sbin. When installing a piece of software the administrator decides about what $PREFIX is, but the author decides which programs are suitable for regular users and which are not. With Python's distutils a set of scripts can be defined and they are installed to $PREFIX\/bin. So how to install a script to the corresponding sbin directory?\nNote that in this case solutions targeting only Linux are welcome, because other parts of the software in question depend on iptables.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2055,"Q_Id":5028075,"Users Score":1,"Answer":"For distutils, we are working on support to install scripts into prefix\/sbin.","Q_Score":5,"Tags":"python,installation,distutils","A_Id":7715650,"CreationDate":"2011-02-17T11:02:00.000","Title":"How to install scripts to sbin with python's distutils?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to figure out an elegant way to share a variable between a windows form app and a python script running in the background.  The variable would be used solely to update a progress bar in the windows form based on the the long running process in the python script.  More specifically, a windows timer will fire every n seconds, check the variable, then update the progress bar value.  Sound stupid enough yet?  I'll try to explain the need for this below.\nI have a windows app that lets a user define a number of parameters to fire off a long running process (python script).  Without getting into unnecessary detail, this long running process will insert many (100k+ records) into a sqlite database over a significant period of time.  In order to make the python script as performant as possible, I don't call commit on the sqlite database until the very end of the python script.  Trying to query the sqlite database from the windows app (via System.Data.Sqlite) before the commit occurs always yields 0 records, regardless of far along the process is.\nThe windows app will know how many total records will be inserted by the python process, so determining progress will be straight-forward enough, assuming I can get access to a record count in the python script.  \nI know I could do this with a text file, but is there any better way?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":580,"Q_Id":5030586,"Users Score":1,"Answer":"Easiest solution is probably to just have the python script print to stdout: say each time an item is processed, print a line with a number representing how many items have been processed (or a percentage). Then have the forms application read the output line by line, updating the progressbar based on that information.","Q_Score":3,"Tags":"python,winforms,global-variables","A_Id":5031228,"CreationDate":"2011-02-17T14:58:00.000","Title":"Elegant Way To Share Variable Between Windows Form and Python Script Running In Background Process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to add a function to my python script that checks if the current script is already running. If it is then it will quit, if not it continues running the script. I've looked into methods of doing this but I cant figure out how to do it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5538,"Q_Id":5048515,"Users Score":1,"Answer":"You need to communicate using a shared resource.  In the simplest sense, you use the resource as a mutex.  Lock or pid files are commonly used this way on *nix by using the filesystem as that shared resource.\nDepending on need, you can use a shared resource that allows communication; e.g. a web browser executed to open a given URL will communicate the URL to an existing process, if there is one.\nThe type of shared resources available is platform-specific.","Q_Score":5,"Tags":"python,process","A_Id":5048580,"CreationDate":"2011-02-19T02:49:00.000","Title":"Check if current process is running using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a problem with a simple Notepad application I'm writing to teach myself basic Python\/PyQt.\nSpecifically, I want to know how to change the multi-touch pan gesture sensitivity on a QListWidget. \nAs it is now, when I drag up and down with 2 fingers, it seems like the list is moving up\/down one step for each pixel I move with my fingers. This is nothing I've implemented myself, it seems to work out of the box for list widgets\nI want the movement to mimic the speed of my fingers i.e one move up\/down of the widget items for every x*height_of_item_in_pixels. Is this doable without major hacking into the gesture system?\nHow would I go about this?\nI'm using PyQt 4.8.3 with Python 2.6","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1586,"Q_Id":5050817,"Users Score":0,"Answer":"More than likely this functionality exists because the multitouch event is being interpreted by your operating system as a scroll of some type and QT is recieving the scroll action, rather than the multitouch action directly.","Q_Score":3,"Tags":"python,qt4,pyqt,pyqt4,qlistwidget","A_Id":18070801,"CreationDate":"2011-02-19T12:40:00.000","Title":"Customize PyQt multi-touch pan gestures on QListWidget","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey I am trying to create a survey that asks the users to create his own question and list 5 multiple choices. My first sense is that I create two datastores and one to store the user quesiton and one to to store 5 choices mapping to the question just created.  but i dont know how exactly I should do with the 5 multiple choices and how to map them with the question. anybody has an idea? Thank you a lot","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2507,"Q_Id":5058333,"Users Score":1,"Answer":"If you are presenting the survey question in a browser, I would definitely go with one model (in one datastore as noted by Peter) having questions and answers properties. Serialize the questions and answers into two TextProperties (be sure to escape them first). From this point, everything can be done inside Javascript by splitting the text into an array, and building any type of innerHTML you want. You may want to include a third field with meta-data about whether the question is single-answer only (radio buttons or dropdown list), or multi-select (checkboxes). One GAE entity, one get_by_id, auto-memcache if you use ndb, no additional processing costs (e.g. Django template). This is fastest and cheapest, and very flexible imho. HTH. -stevep.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":17245724,"CreationDate":"2011-02-20T16:30:00.000","Title":"how to create a survey that has 5 multiple choices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently felt the urge to generate documentation for my little project. I thought it would be fairly easy since I had a set of nice docstrings. Turns out the whole process is much more complicated in python 3.1. \nHere's what I tried:\n\nepydoc: Fails because it's for python 2. 2to3 didn't solve the problems\npydoc: I can't find any information how can you generate documentation for your own modules, seems like a server for reading python docs offline\nsphinx: Most promising so far, I have built it from their repository however it fails with a very cryptic error message (jinja2.exceptions.UndefinedError: b'b\"\\'sphinx.jinja2glue.idgen object\\' has no attribute \\'next\\'\")\n\nMy question is: what should I do now? Are there any other non-commercial documentation generators that work with python3?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":872,"Q_Id":5059567,"Users Score":1,"Answer":"Apparently in Jinja, something is doing X.next(). In Python 3 that's next(x) instead. It should be a simple fix.","Q_Score":3,"Tags":"documentation,python-3.x,documentation-generation","A_Id":5059933,"CreationDate":"2011-02-20T19:49:00.000","Title":"Documentation generator for python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to MySQL for Python (MySQLdb package) in Windows so that I can use it in the Django web frame.\nI have just installed MySQL Community Server 5.5.9 and I have managed to run it and test it using the testing procedures suggested in the MySQL 5.5 Reference Manual. However, I discovered that I still don't have the MySQL AB folder, the subsequent MySQL Server 5.5 folder and regkey in the HKEY_LOCAL_MACHINE, which is needed to build the MySQLdb package.\nFrom the MySQL 5.5 Reference Manual, it says that:\n\nThe MySQL Installation Wizard creates one Windows registry key in a typical install situation, located in HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB.\n\nHowever, I do have the Start Menu short cut and all the program files installed. I have used the msi installation and installed without problems. Should I be getting the MySQL AB folder? Does anyone know what has happened and how I should get the MySQL AB\/MySQL Server 5.5 folder and the regkey?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":854,"Q_Id":5059883,"Users Score":2,"Answer":"I found that the key was actually generated under HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE. Thanks.","Q_Score":5,"Tags":"python,mysql,django","A_Id":5412380,"CreationDate":"2011-02-20T20:43:00.000","Title":"MySQL AB, MySQL Server 5.5 Folder in HKEY_LOCAL_MACHINE not present","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a small website with Django, and I need to calculate statistics with data taken from several tables in the database.\nFor example (nothing to do with my actual models), for a given user, let's say I want all birthday parties he has attended, and people he spoke with in said parties. For this, I would need a wide query, accessing several tables.\nNow, from the object-oriented perspective, it would be great if the User class implemented a method that returned that information. From a database model perspective, I don't like at all the idea of adding functionality to a \"row instance\" that needs to query other tables. I would like to keep all properties and methods in the Model classes relevant to that single row, so as to avoid scattering the business logic all over the place.\nHow should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":5063658,"Users Score":1,"Answer":"I recommend extending Django's Model-Template-View approach with a controller. I usually have a controller.py within my apps which is the only interface to the data sources. So in your above case I'd have something like get_all_parties_and_people_for_user(user).\nThis is especially useful when your \"data taken from several tables in the database\" becomes \"data taken from several tables in SEVERAL databases\" or even \"data taken from various sources, e.g. databases, cache backends, external apis, etc.\".","Q_Score":3,"Tags":"python,database,django,django-models,coding-style","A_Id":5064564,"CreationDate":"2011-02-21T08:17:00.000","Title":"Correct way of implementing database-wide functionality","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a small website with Django, and I need to calculate statistics with data taken from several tables in the database.\nFor example (nothing to do with my actual models), for a given user, let's say I want all birthday parties he has attended, and people he spoke with in said parties. For this, I would need a wide query, accessing several tables.\nNow, from the object-oriented perspective, it would be great if the User class implemented a method that returned that information. From a database model perspective, I don't like at all the idea of adding functionality to a \"row instance\" that needs to query other tables. I would like to keep all properties and methods in the Model classes relevant to that single row, so as to avoid scattering the business logic all over the place.\nHow should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":5063658,"Users Score":0,"Answer":"User.get_attended_birthday_parties() or Event.get_attended_parties(user) work fine: it's an interface that makes sense when you use it. Creating an additional \"all-purpose\" object will not make your code cleaner or easier to maintain.","Q_Score":3,"Tags":"python,database,django,django-models,coding-style","A_Id":5065280,"CreationDate":"2011-02-21T08:17:00.000","Title":"Correct way of implementing database-wide functionality","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an old project, it written under Python 2.5\/2.6, Windows. \nWe had Python 2.6\/Win7\/x64 now, and I tried to start it. \nI got the old project that running nondebug mode in a server, and \ncopied into local folder. \nWhen I tried to yesterday start it, I got this error: \n15:44:58,038 DEBUG [pylons.configuration] Loaded None template engine \nas the default template renderer \nI see the google, but they are points to config.init_app, that is does \nnot exists. \nTOday I reinstalled Python, but with Py2.7, pylons and mako. \nBut when I tried to stat it, I got only this message: \n07:36:36,377 DEBUG [pylons.configuration] Initializing configuration, \npackage: 'x' \nAnd no more information about die... :-( \nSo what do you meaning, how can I raise this \"undead\" project to debug \nsome things? \n( it was good experience with Python\/Pylons, but I'm sad now that I \nnot choose PHP previously, because of package changes). \nThanks: \n   dd","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":5066530,"Users Score":1,"Answer":"might be obvious but did you run \"python setup.py develop\" on the application package so that the dependencies could be installed?","Q_Score":2,"Tags":"python,project,upgrade,pylons","A_Id":5067114,"CreationDate":"2011-02-21T13:28:00.000","Title":"Pylons - how to use an old project in a new environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Have anyone used these 2 django apps together? I want to know how well these 2 gel together along with Django's User Authentication system.\nWhen I mean Django's User Authentication System, I mean I should be able to use decorators like @login_required or grant permission to specific views (or functions in views.py) based on who the user is.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":529,"Q_Id":5074537,"Users Score":1,"Answer":"There shouldn`t be any problems there. Django-Socialauth adda new auth backends, and it should works fine with permissions and decorators. And Django resistration just register a user on site, so unless you remove standard auth backend, it will work fine too.","Q_Score":0,"Tags":"python,django,django-authentication,django-apps","A_Id":5085483,"CreationDate":"2011-02-22T05:52:00.000","Title":"Django-registration & Django-Socialauth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm \"new school\" meaning that i've never really used the command prompt(they didn't teach us anything but IDE's in school). I would like to setup Python using Notepad++ for the editor, and winpdb as my debugger.\nI want stuff to work really easy from the cmd prompt but it is not.\nThis is what I put in my System Environment:\nC:\\PYTHON27;C:\\PYTHON27\\DLLs;C:\\PYTHON27\\LIB;C:\\PYTHON27\\LIB\\LIB-TK;C:\\PYTHON27\\LIB\\SITE-PACKAGES;\nThis is what i want to have happen (but it doesn't work, doesn't load python or the script):\npython myscript.py\nThen it should run the interpreter.  I'd like it to find my script file wherever it may be.\nCan someone baby-step me through this command line setup (the docs expect the user to know how to fluently use the cmd prompt)\nI just don't want to have to manually put in path every single time I want to do something\nAlso I have Console2, I would rather use this than the standard cmd.  How do i get it to have the same functionality that i'm looking for?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":548,"Q_Id":5081501,"Users Score":2,"Answer":"The PATH doesn't affect where data files are found. (And your script is a data file as far as Windows is concerned). You should cd C:\\Path\\to\\folder\\with\\your\\scripts when you open your command prompt, and then you'll be able to python myscript.py from there.\n(You might like to make a dedicated shortcut to the command prompt with \"Start in\" set to your script directory, so you don't have to cd every time.)\nThe same should apply to Console2.","Q_Score":0,"Tags":"python","A_Id":5081579,"CreationDate":"2011-02-22T17:19:00.000","Title":"Python command line SETUP for ABSOLUTE BEGINNER with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try to do named entity recognition in python using NLTK.\nI want to extract personal list of skills.\nI have the list of skills and would like to search them in requisition and tag the skills.\nI noticed that NLTK has NER tag for predefine tags like Person, Location etc.\nIs there a external gazetter tagger in Python I can use?\nany idea how to do it more sophisticated than search of terms ( sometimes multi words term )?\nThanks,\nAssaf","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2226,"Q_Id":5084578,"Users Score":1,"Answer":"I haven't used NLTK enough recently, but if you have words that you know are skills, you don't need to do NER- just a text search.\nMaybe use Lucene or some other search library to find the text, and then annotate it? That's a lot of work but if you are working with a lot of data that might be ok. Alternatively, you could hack together a regex search which will be slower but probably work ok for smaller amounts of data and will be much easier to implement.","Q_Score":4,"Tags":"python,nlp,nltk,named-entity-recognition","A_Id":6637984,"CreationDate":"2011-02-22T22:07:00.000","Title":"Named Entity Recognition from personal Gazetter using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been developing a django web-application for three months now, and I'd like to set it to production. I'm currently using South as database schema manager and I haven't got any clue on how to export my application databases schemas and content, and my project code to another directory; in order to set my production environment. \nAny clue on how to do this? \nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2805,"Q_Id":5085099,"Users Score":0,"Answer":"Steps to get your Django App from development to Production \n\nopen your project folder then find settings.py find the following line, \nSECURITY WARNING: don't run with debug turned on in production!\nDEBUG = False\nChange the debug to false.\nChange your db credentials with the actual production server db credentials\nin your settings.py \nDATABASES = {\n        'default': {\n            'ENGINE': 'django.db.backends.mysql',\n            'NAME': 'seocrawler',\n            'USER': '',\n            'PASSWORD': '',\n            'HOST': 'localhost',\n            'PORT': ''\n        }\n    }\nonce done upload your project folder to the folder in server \nopen putty enter your server credentials, then a terminal or cmd will pop \nup.\ncheck python is installed on your server by executing below command in terminal  python -V\nthen check whether django is installed by running django-admin --version, \nmake sure that the django version you used to develop the project matches the one on server if not the install the specific version.\nnow using the cd command to go to the project folder which contains manage.py file.\nnow run python manage.py showmigrations this will list if any db migration is pending for your project.\nnow run python manage.py makemigrations this will migrate the db tables to production server database. \nnow run python manage.py runserver 0.0.0.0:8000 then go to your domain like www.example.com:8000 in browser, to test whether your site is working.\nonce your site is up and working we want python manage.py runserver command to run even after the terminal is closed (means python manage.py runserver command in as background task\/process). \nto do that run nohup python manage.py runserver & this will run command in background and will never die the process even when putty terminal is closed.\nAll done! now your server is up and your site too.\nEnjoy!","Q_Score":1,"Tags":"python,django,production-environment","A_Id":48786643,"CreationDate":"2011-02-22T23:02:00.000","Title":"Exporting a development django application to production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use selenium-rc to test an asp.net website, test script is written in Python and the browser is Firefox 3.6. But When selenium open the first page of the website, A download dialog appear, not the web page, seems the page is proccessed as application\/octet-stream, this cause my test script can not run successfully.\nSeems this behavior happened on some asp.net websites, I select other asp sites to test, and found some asp sites have the same issue.\nMy question is why this happend? and how to fix this?\nEdit: I use IE to do this test again, seems it's ok. So is this an issue of Firefox?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":5086524,"Users Score":0,"Answer":"Ok, I upgrade my selenium-server to 2.0b2, now it's ok.","Q_Score":0,"Tags":"asp.net,python,selenium-rc","A_Id":5086635,"CreationDate":"2011-02-23T02:54:00.000","Title":"Why selenium can not open some asp page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have installed MySqldb through .exe(precompiled). Its is stored in site-packages. But now i don't know how to test, that it is accessable or not. And major problem how to import in my application like import MySqldb. Help me i am very new techie in python i just want to work with my existing Mysql. Thanks in advance...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":5090870,"Users Score":3,"Answer":"Just open your CMD\/Console, type python, press Enter, type import MySQLdb and then press Enter again.\nIf no error is shown, you're ok!","Q_Score":0,"Tags":"python,mysql","A_Id":5090944,"CreationDate":"2011-02-23T12:23:00.000","Title":"how to import mysqldb","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how to go about implementing a macro recorder for a python gui (probably PyQt, but ideally agnostic). Something much like in Excel but instead of getting VB macros, it would create python code. Previously I made something for Tkinter where all callbacks pass through a single class that logged actions.  Unfortunately my class doing the logging was a bit ugly and I'm looking for a nicer one. While this did make a nice separation of the gui from the rest of the code, it seems to be unusual in terms of the usual signals\/slots wiring. Is there a better way?\nThe intention is that a user can work their way through a data analysis procedure in a graphical interface, seeing the effect of their decisions. Later the recorded procedure could be applied to other data with minor modification and without needing the start up the gui.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1816,"Q_Id":5093153,"Users Score":1,"Answer":"Thinking in high level, this is what I'd do:\nDevelop a decorator function, with which I'd decorate every event-handling functions.\nThis decorator functions would take note of thee function called, and its parameters  (and possibly returning values) in a unified data-structure - taking care, on this data structure, to mark Widget and Control instances as a special type of object. That is because in other runs these widgets won't be the same instances - ah, you can't even serialize a toolkit widget instances, be it Qt or otherwise.\nWhen the time comes to play a macro, you fill-in the gaps replacing the widget-representating object with the instances of the actually running objects, and simply call the original functions with the remaining parameters.\nIn toolkits that have an specialized \"event\" parameter that is passed down to event-handling functions, you will have to take care of serializing and de-serializing this event as well.\nI hope this can help. I could come up with some proof of concept code for that (although I am in a mood to use tkinter today - would have to read a lot to come up with a Qt4 example).","Q_Score":2,"Tags":"python,user-interface,macros,recorder","A_Id":5093338,"CreationDate":"2011-02-23T15:41:00.000","Title":"Implementing a macro recorder for a python gui?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how to go about implementing a macro recorder for a python gui (probably PyQt, but ideally agnostic). Something much like in Excel but instead of getting VB macros, it would create python code. Previously I made something for Tkinter where all callbacks pass through a single class that logged actions.  Unfortunately my class doing the logging was a bit ugly and I'm looking for a nicer one. While this did make a nice separation of the gui from the rest of the code, it seems to be unusual in terms of the usual signals\/slots wiring. Is there a better way?\nThe intention is that a user can work their way through a data analysis procedure in a graphical interface, seeing the effect of their decisions. Later the recorded procedure could be applied to other data with minor modification and without needing the start up the gui.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1816,"Q_Id":5093153,"Users Score":1,"Answer":"You could apply the command design pattern: when your user executes an action, generate a command that represents the changes required.  You then implement some sort of command pipeline that executes the commands themselves, most likely just calling the methods you already have.  Once the commands are executed, you can serialize them or take note of them the way you want and load the series of commands when you need to re-execute the procedure.","Q_Score":2,"Tags":"python,user-interface,macros,recorder","A_Id":5093408,"CreationDate":"2011-02-23T15:41:00.000","Title":"Implementing a macro recorder for a python gui?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on a project that involves the google apps provisioning api.\nWithout getting too detailed about the purpose or inner workings of the project, I would like to ask a very simple question:\nIs there a way to programmatically create a google apps for business domain (especially as a reseller)?\nAfter tooling around the provisioning api for a while all i could find are ways to add and remove users but nothing pertaining to whole domains.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":671,"Q_Id":5095117,"Users Score":1,"Answer":"There is an API only available to Google Apps Resellers, if you are one of them you should get access to it.","Q_Score":1,"Tags":"java,python,google-app-engine","A_Id":5271776,"CreationDate":"2011-02-23T18:13:00.000","Title":"Programmatically create Google Apps Domain","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my Main model I have a total_value and I sort with this value. When a user enters a value I wish to tell the user the order of his total_value. How do I do this?\nIn other words, if total_values in database are 5,8,10,25 and a user enters a total_value of 15 how do I tell him that he will be in the 4th place? \nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":95,"Q_Id":5099012,"Users Score":1,"Answer":"You could get the count of number of entities that have total_value less than or equal to the current users total_value.\nYou could use the count() method to do so (on a Query object).","Q_Score":2,"Tags":"python,google-app-engine,sorting","A_Id":5099184,"CreationDate":"2011-02-24T00:23:00.000","Title":"Google App Engine: how to tell sort location for a user value?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anybody know how to make http request from Google App Engine without waiting a response?\nIt should be like a push data with http without latency for response.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1253,"Q_Id":5107675,"Users Score":2,"Answer":"Use the taskqueue. If you're just pushing data, there's no sense in waiting for the response.","Q_Score":4,"Tags":"python,http,google-app-engine,asynchronous,request","A_Id":5111470,"CreationDate":"2011-02-24T16:43:00.000","Title":"async http request on Google App Engine Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anybody know how to make http request from Google App Engine without waiting a response?\nIt should be like a push data with http without latency for response.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1253,"Q_Id":5107675,"Users Score":0,"Answer":"I've done this before by setting doing a URLFetch and setting a very low value for the deadline parameter. I put 0.1 as my value, so 100ms. You need to wrap the URLFetch in a try\/catch also since the request will timeout.","Q_Score":4,"Tags":"python,http,google-app-engine,asynchronous,request","A_Id":5111384,"CreationDate":"2011-02-24T16:43:00.000","Title":"async http request on Google App Engine Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"well i've seen some code to convert RGB to HSL; but how to do it fast in python.\nIts strange to me, that for example photoshop does this within a second on a image, while in python this often takes forever. Well at least the code i use; so think i'm using wrong code to do it\nIn my case my image is a simple but big raw array [r,g,b,r,g,b,r,g,b ....]\nI would like this to be [h,s,l,h,s,l,h,s,l .......]\nAlso i would like to be able to do hsl to rgb\nthe image is actually 640x 480 pixels; \nWould it require some library or wrapper around c code (i never created a wrapper) to get it done fast ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6609,"Q_Id":5112248,"Users Score":1,"Answer":"One option is to use OpenCV. Their Python bindings are pretty good (although not amazing). The upside is that it is a very powerful library, so this would just be the tip of the iceberg.\nYou could probably also do this very efficiently using numpy.","Q_Score":3,"Tags":"python,c,rgb","A_Id":5112349,"CreationDate":"2011-02-25T00:26:00.000","Title":"Python RGB array to HSL and back","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Edit: Looks like a duplicate, but I assure you, it's not. I'm looking to kill the current running process cleanly, not to kill a separate process.\nThe problem is the process I'm killing isn't spawned by subprocess or exec. It's basically trying to kill itself.\nHere's the scenario: The program does cleanup on exit, but sometimes this takes too long. I am sure that I can terminate the program, because the first step in the quit saves the Database. How do I go about doing this?\n\ncannot use taskkill, as it is not available in some Windows installs e.g. home editions of XP\ntskill also doesn't work\nwin32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit.\n\nI'm currently doing the last one, as it just works. I'm concerned though about the unfreed handle. Any thoughts\/suggestions would be very much appreciated!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2588,"Q_Id":5113791,"Users Score":1,"Answer":"win32api.TerminateProcess(handle, 0)\n  works, but i'm concerned it may cause\n  memory leaks because i won't have the\n  opportunity to close the handle\n  (program immediately stops after\n  calling TerminateProcess). note: Yup,\n  I am force quitting it so there are\n  bound to be some unfreed resources,\n  but I want to minimize this as much as\n  possible (as I will only do it only if\n  it is taking an unbearable amount of\n  time, for better user experience) but\n  i don't think python will handle gc if\n  it's force-quit.\n\nIf a process self-terminates, then you don't need to worry about garbage collection. The OS will automatically clean up all memory resources used by that process, so you don't have to worry about memory leaks. Memory leaks are when a process is running and using more and more memory as time goes by.\nSo yes terminating your process this way isn't very \"clean\", but there wont be any ill side-effects.","Q_Score":1,"Tags":"python,windows,winapi,pywin32","A_Id":5114093,"CreationDate":"2011-02-25T04:57:00.000","Title":"In Windows using Python, how do I kill my process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Edit: Looks like a duplicate, but I assure you, it's not. I'm looking to kill the current running process cleanly, not to kill a separate process.\nThe problem is the process I'm killing isn't spawned by subprocess or exec. It's basically trying to kill itself.\nHere's the scenario: The program does cleanup on exit, but sometimes this takes too long. I am sure that I can terminate the program, because the first step in the quit saves the Database. How do I go about doing this?\n\ncannot use taskkill, as it is not available in some Windows installs e.g. home editions of XP\ntskill also doesn't work\nwin32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit.\n\nI'm currently doing the last one, as it just works. I'm concerned though about the unfreed handle. Any thoughts\/suggestions would be very much appreciated!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2588,"Q_Id":5113791,"Users Score":1,"Answer":"TerminateProcess and taskkill \/f do not free resources and will result in memory leaks.\nHere is the MS quote on terminateProcess:\n{ ... Terminating a process does not cause child processes to be terminated. \nTerminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed. ... }\n   MS heavily uses COM and DCOM, which share handles and resources the OS does not and can not track. ExitProcess should then be used instead, if you do not intend to reboot often.  That allows a process to properly free the resources it used.  Linux does not have this problem because it does not use COM or DCOM.","Q_Score":1,"Tags":"python,windows,winapi,pywin32","A_Id":14405624,"CreationDate":"2011-02-25T04:57:00.000","Title":"In Windows using Python, how do I kill my process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When creating zip archive using python ZipFile, how can i set file mime types?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1396,"Q_Id":5120558,"Users Score":0,"Answer":"This question does not make any sense. Files are stored as binary content inside the ZIP archive together with the filesize (and flags afaik). But there is absolutely no mimetype information involved here.","Q_Score":0,"Tags":"python,mime,zip","A_Id":5120702,"CreationDate":"2011-02-25T17:31:00.000","Title":"Set ZipInfo mime type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When creating zip archive using python ZipFile, how can i set file mime types?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1396,"Q_Id":5120558,"Users Score":3,"Answer":"The ZIP format doesn't carry MIME content-type for the individual files contained in the archive, though the ZIP format itself has a MIME content-type: application\\zip.\nThe only way you've got to determine the appropriate MIME content-type for a file contained in a ZIP archive is by examination of the file name and using its file extension to determine the likely MIME content-type.","Q_Score":0,"Tags":"python,mime,zip","A_Id":5120648,"CreationDate":"2011-02-25T17:31:00.000","Title":"Set ZipInfo mime type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm constructing a program where the user clicks two points in the graphics window and the length of x and y must be shown. I've creating a clone and multiplying it by itself, but no luck. Any ideas? Thanks!\nEdit:\nMy program is supposed to create a 'money bin' based off the users data and 2 point clicks in the graphics window. I need help figuring out how to get the 'length in x direction' after the user clicks 2 points on the graphics window.\n-Here's the example inputs-\nEnter shape of money bin:\n1 cube\/prism\n2 cylinder\n3 cone\n4 pyramid\nShape: 4\nEnter height of money bin: 96.5\nEnter cost per cubic foot to build: 2.75\nAfter clicking on the window, click the mouse at two points in the window to determine the money bin base\npoint 1 coordinates: 16.5258215962 45.7202505219\npoint 2 coordinates: 60.2190923318 13.4029227557\nLength in x direction: 43.6932707355 feet\nLength in y direction: 32.3173277662 feet\nVolume: 45420.9336744 cubic feet\nCost to build money bin rounded to nearest dollar: 124908\nPress  to quit","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1821,"Q_Id":5123363,"Users Score":1,"Answer":"Do you mean you want to calculate the distance between the two points? If so, you just use the Pythagorean theorem: \u221a((y1-y2)2+(x1-x2)2).","Q_Score":0,"Tags":"python,computer-science","A_Id":5123398,"CreationDate":"2011-02-25T22:22:00.000","Title":"How do I calculate the length of an x\/y coordinate in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want use send_mass_mail() in django and then want receive list of delivery mail\nlist with email address and problem for failed or delivered ok status\nhow i can make this modules ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":415,"Q_Id":5125544,"Users Score":4,"Answer":"List of delivered emails is outside of the scope of Django, which is a web framework and not a replacement for services like Mailchimp.","Q_Score":1,"Tags":"python,django,email,smtp,email-confirmation","A_Id":5126778,"CreationDate":"2011-02-26T06:58:00.000","Title":"receive delivery list of send mail in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to figure how to use mmap with a gzip compressed file. Is that even possible ?\n\nimport mmap\nimport os\nimport gzip\n\nfilename = r'C:\\temp\\data.gz'\n\nfile = gzip.open(filename, \"rb+\")\nsize = os.path.getsize(filename)\n\nfile = mmap.mmap(file.fileno(), size)\n\nprint file.read(8)\n\nThe output data is compressed.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4463,"Q_Id":5127921,"Users Score":17,"Answer":"Well, not the way you want.\nmmap() can be used to access the gzipped file if the compressed data is what you want.\nmmap() is a system call for mapping disk blocks into RAM almost as if you were adding swap.\nYou can't map the uncompressed data into RAM with mmap() as it is not on the disk.","Q_Score":13,"Tags":"python,gzip,mmap","A_Id":5127976,"CreationDate":"2011-02-26T15:57:00.000","Title":"Can mmap and gzip collaborate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"the same problem haunting me a month ago is still haunting me now. i know ive asked several questions regarding this on this site and i am truly sorry for that. your suggestions have all been excellent but the answer is still elusive. i now realize that this is a direct result of me not being able to phrase my question properly and for that i am sorry.\nto give you guys a generalized view of things, here i go: the situation is like this, i have 2 server side scripts that i want to run.\n\na python program\/script that continuously spouts some numbers\nbased on the output from that python script, a javascript script will perform some action on a webpage (e.g., change background color, display alert message, change some text)\n\nive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. \ntwo different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. \nthe problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one?\nthank you!","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":950,"Q_Id":5128454,"Users Score":0,"Answer":"I don't know Javascript or json, but...\nif you've ever seen an Unix-like operating system, you know about pipes. Like program1 | program2 | program3 ... Why don't you just connect Python and Javascript programs with pipes? The first one writes to stdout, and the next one reads from stdin.","Q_Score":1,"Tags":"javascript,python,json","A_Id":5128524,"CreationDate":"2011-02-26T17:18:00.000","Title":"is json the answer to this: python program will talk and javascript will listen?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"the same problem haunting me a month ago is still haunting me now. i know ive asked several questions regarding this on this site and i am truly sorry for that. your suggestions have all been excellent but the answer is still elusive. i now realize that this is a direct result of me not being able to phrase my question properly and for that i am sorry.\nto give you guys a generalized view of things, here i go: the situation is like this, i have 2 server side scripts that i want to run.\n\na python program\/script that continuously spouts some numbers\nbased on the output from that python script, a javascript script will perform some action on a webpage (e.g., change background color, display alert message, change some text)\n\nive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. \ntwo different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. \nthe problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one?\nthank you!","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":950,"Q_Id":5128454,"Users Score":0,"Answer":"This probably isn't the answer that you are looking for, and without links to your previous posts, I don't have much to go on, but nonetheless...\njavascript is client side. I can interpret your question 2 different ways... \n\nYour python script is running on your computer, and you want a script to actually alter your current browser window. \nNot too sure, but writing a browser plugin may be the answer here.\nYour python script is running on the server, and as a result of the script running, you want the display of your site to be changed for viewing persons. \nIn this case, you will could use ajax polling (or similar) on your site. Have your site be polling the server with ajax, call a server method that checks the output of the script (maybe written to a file?), and see if it has changed.","Q_Score":1,"Tags":"javascript,python,json","A_Id":5128547,"CreationDate":"2011-02-26T17:18:00.000","Title":"is json the answer to this: python program will talk and javascript will listen?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"the same problem haunting me a month ago is still haunting me now. i know ive asked several questions regarding this on this site and i am truly sorry for that. your suggestions have all been excellent but the answer is still elusive. i now realize that this is a direct result of me not being able to phrase my question properly and for that i am sorry.\nto give you guys a generalized view of things, here i go: the situation is like this, i have 2 server side scripts that i want to run.\n\na python program\/script that continuously spouts some numbers\nbased on the output from that python script, a javascript script will perform some action on a webpage (e.g., change background color, display alert message, change some text)\n\nive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. \ntwo different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. \nthe problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one?\nthank you!","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":950,"Q_Id":5128454,"Users Score":1,"Answer":"I assume you mean: Python is on the web server, and Javascript is running in the client's web browser.\nBecause browsers are all different (IE6 is terrible, Chrome is great), there are a huge number of ways people found to \"hack\" this \"cellphone\" into place. These techniques are called AJAX and COMET techniques. There is no one \"cellphone\", but a whole bunch of them! Hopefully, you can find a library to select the right technique for the browser, and you just have to worry about the messages.\nComet is harder to do, but lets the server \"push\" messages to the client.\nAjax can be easier - you just periodically \"pull\" messages from the server.\nStart with Ajax, then look at comet if you really need it. Just start by have the client (javascript) make a \"GET\" request, to see if the number has changed.","Q_Score":1,"Tags":"javascript,python,json","A_Id":5128601,"CreationDate":"2011-02-26T17:18:00.000","Title":"is json the answer to this: python program will talk and javascript will listen?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know where I can find a tutorial on how to use GStreamer with Jython? I have tried searching but with no luck. Using the Gstreamer-Python bindings I can get a python file to run with python but jython gives me ImportError: No module named pygst.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":278,"Q_Id":5130057,"Users Score":0,"Answer":"I suspect that it uses c bindings so you can not use in jython, sorry.","Q_Score":3,"Tags":"python,jython,gstreamer","A_Id":5130162,"CreationDate":"2011-02-26T22:05:00.000","Title":"Jython Gstreamer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ. \nCould you please provide a scenario or an example using RabbitMQ?\nAlso, where can I find a tutorial on how to use RabbitMQ?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":20812,"Q_Id":5132648,"Users Score":39,"Answer":"Let me tell you a few reasons that makes using MOM (Message Oriented Middleware) probably the best choice.\nDecoupling:\nIt can decouple\/separate the core components of the application. There is no need to bring all the benefits of the decoupled architecture here. I just want to point it out that this is one of the main requirement of writing a quality and maintainable software.\nFlexibility:\nIt is actually very easy to connect two totally different applications written on different languages together by using AMQP protocol. These application will talk to each other by the help of a \"translator\" which is MOM.\nScalability:\nBy using MOM we can scale the system horizontally. One message producer can transmit to unlimited number of message consumers a task, a command or a message for processing and for scaling this system all we need to do is just create new message consumers. Lets say we are getting 1000 pictures per second and we must resize them. Solving this problem with traditional methods could be a headache. With MOM we can transmit images to the message consumers which can do their job asynchronously and make sure data integrity is intact.\nThey are other benefits of using MOM as well but these 3 are the most significant in my opinion.","Q_Score":68,"Tags":"python,django,twisted,rabbitmq","A_Id":19206575,"CreationDate":"2011-02-27T10:26:00.000","Title":"Why do we need to use rabbitmq","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ. \nCould you please provide a scenario or an example using RabbitMQ?\nAlso, where can I find a tutorial on how to use RabbitMQ?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":20812,"Q_Id":5132648,"Users Score":6,"Answer":"RabbitMQ is a bit more than mere messaging... It's a common platform that has ability to inter-connect applications. Using RabbitMQ a Java application can speak to a Linux server and\/or a .NET app, to a Ruby & rails + almost anything that finds its place in the corporate web development. And most importantly it implements the \"fire and forget\"   model proposed by AMQP. Its just a perfect replacement for JMS or ESB, especially if you are dealing with cross platform architecture, with a guaranty of reliability. There is even a special feature called RPC (Remote procedure call) that adds to the ease of development in the distributed arch. \nApart from all these, in the world financial services like Stock-exchange or share-market where a lot of reliable and efficient routing is required (suppose you don't know the actual number of people subscribed to your services, but want to ensure that who ever does so, receives your pings whether they are connected in this moment, or will connect later), RabbitMQ rules because it's based on ERLANG & the Open-telecom platform that assures high performance while using minimum resources. For the most convenient introduction to RabbitMQ, see rabbitmq.com\/getstarted.html for your native development language.","Q_Score":68,"Tags":"python,django,twisted,rabbitmq","A_Id":27416485,"CreationDate":"2011-02-27T10:26:00.000","Title":"Why do we need to use rabbitmq","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Why do we need RabbitMQ when we have a more powerful network framework in Python called Twisted. I am trying to understand the reason why someone would want to use RabbitMQ. \nCould you please provide a scenario or an example using RabbitMQ?\nAlso, where can I find a tutorial on how to use RabbitMQ?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":20812,"Q_Id":5132648,"Users Score":14,"Answer":"Twisted is not a queue implementation. Apart from that RabbitMQ offers enterprise-level queuing features and implements the AMQP protocol which is often needed in an enterprise world.","Q_Score":68,"Tags":"python,django,twisted,rabbitmq","A_Id":5132740,"CreationDate":"2011-02-27T10:26:00.000","Title":"Why do we need to use rabbitmq","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a bit of a project in Python. I have a list of files that I want to get the md5checksums for. Then it stores the checksums in another list. Then it checks again and checks to see if they're different. I have the function for getting the checksums working but now I can't figure out how I'd add them to a list. Here is what I'm trying\n\nimport sys, hashlib\nfiles = ['\/home\/file1', '\/home\/file2', '\/home\/file3', '\/etc\/passwd']\nmd5s = []\ndef getmd5(file, ex=\"\", inc=\"\"):\n    m = hashlib.md5()\n    try:\n        fd = open(file,\"rb\")\n    except IOError:\n        print \"Can't retrieve MD5sum for \", file\n        pass\n    content = fd.readlines()\n    fd.close()\n    for eachLine in content:\n        if ex and eachLine.startswith(ex):\n            continue\n        m.update(eachLine)\n    m.update(inc)\n    a = m.hexdigest()\n    md5s.append(a)\nfor i in lists:\n    getmd5(i)\n    print md5s\n\nBut when I try this I get 4 lists like so:\n\n['729aebf5b3a841d3ef815e297ae2ce07']\n['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad']\n['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad', '0c01d98119386db13beb1bfdbae7ba2b']\n['729aebf5b3a841d3ef815e297ae2ce07', '1c9bc3339234fa7d551bdb8da004c8ad', '0c01d98119386db13beb1bfdbae7ba2b', 'b51c93a2f965b75de903d159720dd6e6']\n\nWhat I'd like to do is store each hash checksum in the md5s list and then read to see if they're different.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2384,"Q_Id":5134860,"Users Score":1,"Answer":"You don't have 4 lists. You're printing the contents of the md5s each time after you call getmd5 which adds one md5 hash to the list. You just happen to be doing this 4 times, because you have 4 items in your files list.\nThis means you have one list and it contains all the digests at the end of last for loop. You are printing inside the for loop constructing the list and hence you are not able to understand it. Remove the indent before the print to see the result in the format that you want.","Q_Score":0,"Tags":"python,list,hash,md5,checksum","A_Id":5134890,"CreationDate":"2011-02-27T18:00:00.000","Title":"Computing MD5 checksums for files in a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey I need to know how to sleep in Python without interfering with the current script. I've tried using time.sleep() but it makes the entire script sleep. \nLike for example \n\nimport time\ndef func1():\n    func2()\n    print(\"Do stuff here\")\ndef func2():\n    time.sleep(10)\n    print(\"Do more stuff here\")\nfunc1()\n\nI want it to immediately print Do stuff here, then wait 10 seconds and print Do more stuff here.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":14596,"Q_Id":5136266,"Users Score":3,"Answer":"If you're running your script on command line, try using the -u parameter. It runs the script in unbuffered mode and did the trick for me.\nFor example:\npython -u my_script.py","Q_Score":8,"Tags":"python,function,time,sleep","A_Id":10023537,"CreationDate":"2011-02-27T21:54:00.000","Title":"Python sleep without interfering with script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had a postgresql query where I need to take column defined as character from table and then pass this value to the function where it only accepts integer.So in this case, how can i solve the problem??Can anyone help??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":5148790,"Users Score":0,"Answer":"ord(val) will give you the integer value of a character. int(val) will cast a value into an integer.","Q_Score":0,"Tags":"python,casting","A_Id":5148795,"CreationDate":"2011-02-28T23:23:00.000","Title":"how to convert value of column defined as character into integer in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"AppEngine needs Python2.5.\nUbuntu 2010.10 comes with Python 2.6.6 and I didn't want to interfere with it, so I downloaded and compiled Python 2.5 in my home directory.\nThen I downloaded Django-1.2.5.tar.gz, and ran \"sudo python setup.py install\". \nProblem: \"import django\" says \"ImportError: No module named django\"\nI guess django got installed to the system's Python2.6.6, how to install it into my local Python2.5 directory?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":5154479,"Users Score":0,"Answer":"Install python2.5 with synaptic, then you will be able to use easy_install2.5 to install django. If you don't have the python2.5 in your package list you can put django on your python2.5 system path and be with it\nto view the system path do:\n\npython2.5 \n  import sys\n  sys.path","Q_Score":0,"Tags":"python,django,ubuntu-10.10","A_Id":5154551,"CreationDate":"2011-03-01T12:25:00.000","Title":"Django on python2.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how in django find list of post related with special many to many field?\nfor example \ncatagory have title\npost have many to many relation to catagory\nhow find all post from category title","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":5164307,"Users Score":0,"Answer":"Post.objects.all(catagory__title=\"My catagory title\")?","Q_Score":1,"Tags":"python,django","A_Id":5164550,"CreationDate":"2011-03-02T06:50:00.000","Title":"many to many problem django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to store users preferences for day(s) of week he might be available. e.g. A user can be available on saturday, sunday but not on other days.\nCurrently I am using array of 7 checkboxes(values=1,2,...7) so that user can select individual days of his availability.\nNow the first question is how can i store this in database. I am thinking of using a string(length=7) and storing preferences like 1100010 where 1 will signify available and 0 not available. Is it good practice?\nSecond question, how can I convert POST data ([\"1\",\"2\",\"7\"]) into string (1100010)","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1639,"Q_Id":5168207,"Users Score":0,"Answer":"I'd go for separate boolean columns.\nIt'll be a lot easier for you to then query, say, for users that are available on mondays; or to count the number of users that available through every weekday, or whatever.","Q_Score":5,"Tags":"python,django","A_Id":5168529,"CreationDate":"2011-03-02T13:36:00.000","Title":"Best way to save availability of user over days of week in python\/django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to store users preferences for day(s) of week he might be available. e.g. A user can be available on saturday, sunday but not on other days.\nCurrently I am using array of 7 checkboxes(values=1,2,...7) so that user can select individual days of his availability.\nNow the first question is how can i store this in database. I am thinking of using a string(length=7) and storing preferences like 1100010 where 1 will signify available and 0 not available. Is it good practice?\nSecond question, how can I convert POST data ([\"1\",\"2\",\"7\"]) into string (1100010)","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":1639,"Q_Id":5168207,"Users Score":1,"Answer":"One other option is the more-or-less obvious one: define a table of the days of the week, and have a ManyToManyField map one to the other. The admin would just work, you can do searches based on dates, and it works on SQLite unlike some of the functions in django-bitfield. Searches can be fast, since they're within the database and you don't have to use SQL's LIKE (which ignores indexes if there are wildcards at the start of the string, which would be the case for CommaSeparatedIntegerField or a seven-character string).\nSure, it takes more storage, but how many users do you have, anyway?  Millions?\nP.S. if you have an ordering field in your weekday table, you can also make the database sort by day of week for you with something like queryset.order_by('available__order').","Q_Score":5,"Tags":"python,django","A_Id":5168522,"CreationDate":"2011-03-02T13:36:00.000","Title":"Best way to save availability of user over days of week in python\/django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I update the title\/description of a previously updated video?  I am using python and pyfacebook... but any starting point would be fine and I can write it in python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":5172735,"Users Score":0,"Answer":"I don't think it's possible to edit a Video object at all with the Graph API at the moment.  You can't create objects through the API, therefore I don't think you can edit or modify existing ones either.","Q_Score":1,"Tags":"python,facebook,facebook-graph-api,facebook-fql","A_Id":5365134,"CreationDate":"2011-03-02T20:02:00.000","Title":"how do I use the facebook api to modify a video title or description?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As part of artifacts delivery, our developers give the data and structure scripts in .sql files. I usually \"double click\" on these files to open in \"Microsoft SQL Server Management Studio\". Management studio will prompt me for entering database server and user\/pwd. I enter them manually and click on Execute button to execute these scripts.\nThese scripts contain structure and data sql commands. Each script may contain more than one data command (like select, insert, update, etc). Structure and data scripts are provided in separate .sql files.\nThese scripts also contain stored procedures and functions, etc. They also contain comments \/ description.\nI want to automate execution of these scripts through python. I looked at pyodbc and pymssql but they dont look like solve my issue.\nThrough pyodbc, i need to read each .sql file and read the sql commands and execute them one by one. As the files may have comments \/ description \/ SPs \/ etc, reading the files will be little difficult.\nCan anyone give suggestion on how to automate this?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3938,"Q_Id":5174269,"Users Score":4,"Answer":"You could just run them using sqlcmd. Sqlcmd is a command line utility that will let you run .sql scripts from the command line, which I'm sure you can kick off through python.","Q_Score":1,"Tags":"python,sql,sql-server","A_Id":5174307,"CreationDate":"2011-03-02T22:22:00.000","Title":"Execute .sql files that are used to run in SQL Management Studio in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python script that sends output to a DOS command window (I am using Windows 7) using the print() function, but I would like to prevent (or hide) the cursor from blinking at the next available output position.  Has anyone any idea how I can do this?  I have looked at a list of DOS commands but I cannot find anything suitable.\nAny help would be appreciated.\nAlan","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":16984,"Q_Id":5174810,"Users Score":9,"Answer":"I'm surprised nobody mentioned that before, but you actually don't need any library to do that.\nJust use print('\\033[?25l', end=\"\") to hide the cursor.\nYou can show it back with print('\\033[?25h', end=\"\").\nIt's as easy as that :)","Q_Score":16,"Tags":"python,text-cursor,command-window","A_Id":70550803,"CreationDate":"2011-03-02T23:25:00.000","Title":"How to turn off blinking cursor in command window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My problem is\nmy python binaries not running as 64bits program on my amd64(Opteron 8214, 4 cpu) server.\nThe machine is a Dual-Core, so there are 8 core shown in taskmgr.\nIt shown no \"*32\" in taskmgr(so it probably already in 64bits mode), but use only one core.\nAnd I take same code(project) to compiled and executed on an Intel Xeon machine, it will use all of processor core.   \nSo how do I fix this? Anyone have some other idea? I need to make it running 64bit to use mutli-core to get job done ASAP. It's a data parser, it took most of runtime to parsing data records(via regex) then insert into mssql db.\nAny comment is welcome. I've been working on this many weeks.\nOfficial & third-party packages I used listed here.\npython-2.7.1.amd64.msi\npywin32-214.win-amd64-py2.7.exe\npyodbc-2.1.8.win-amd64-py2.7.exe\npy2exe-0.6.9.win64-py2.7.amd64.exe\nwxPython2.8-win64-unicode-2.8.11.0-py27.exe\nbuild binary via GUI2exe-0.5.0.zip\nOn Windows Server 2003 Standard x64 Edition SP2\nI ever built exactly same code(project) on Intel Xeon CPU machine(win2003x64 of course),\nAnd it was worked(work means no \"*32\" tailing on process name of taskmgr, and also use each of CPU\/Core).\np.s. I cannot provide whole source code since it is a large project.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":5179743,"Users Score":0,"Answer":"You might want to check out the subprocess and threading modules that come with the standard Python library with regards to your multi-core issue. As for the 64bit issue, are you sure you need the additional memory space? I've never had any issue with 32bit python.","Q_Score":0,"Tags":"python,windows-server-2003,py2exe,pywin32,x86-64","A_Id":6172840,"CreationDate":"2011-03-03T10:53:00.000","Title":"My python build binaries not really running as 64bit program in AMD Win2003r2x64 machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a small music database. Learning SQL lies quite a long time in my past and I always wanted to give Django a try. But there is one thing I couldn't wrap my head around.\nRight now, my models only consist of two Classes, Album and Song.\nSong has a foreign key pointing to the album it belongs to. Now if I would delete that Album, all Songs \"belonging\" to it, would be deleted due to the cascading effect.\nAlbums are kinda virtual in my database, only songs are actually represented on the filesystem and the albums are constructed according to the songs tags, therefore I can only know an album doesn't exist anymore if there are no more songs pointing to it (as they no longer exist in the filesystem).\nOr in short, how can I achieve a cascade in reverse, that means, if no more songs are pointing to an album, the album should be deleted as well?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1807,"Q_Id":5185563,"Users Score":1,"Answer":"I've had a similar problem and I've ended up adding a counter into the Album equivalent. If the count is 0 and the operation is delete(), then the album object is delete()d.\nOther solution os to overload the delete() method in the song model, or use post-delete to delete the album.","Q_Score":6,"Tags":"python,django","A_Id":5185748,"CreationDate":"2011-03-03T19:34:00.000","Title":"What is the reverse equivalent of cascade?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":43483,"Q_Id":5190030,"Users Score":0,"Answer":"The statements which represent a block of code below end with a colon(:) in Python. \nBy doing that way, you can add extra statements under a single block and execute them at once.","Q_Score":12,"Tags":"python,macos,terminal","A_Id":5190101,"CreationDate":"2011-03-04T05:25:00.000","Title":"How do I create a line-break in Terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":43483,"Q_Id":5190030,"Users Score":1,"Answer":"The answer here is far more simple. If you want to continue in the next line after a loop like \nwhile b<1:\nwhen you press enter you get prompted with \n...\nthen you \"have to make an indent\" by space of tab and only then you can put more code after the three dots like\n...   (tab or space)   print b\nthen when you press enter the code is not going to be executed but you get another ... where you can keep typing you code by making the new indent\nkeep the indent the same\nthat is it","Q_Score":12,"Tags":"python,macos,terminal","A_Id":25158836,"CreationDate":"2011-03-04T05:25:00.000","Title":"How do I create a line-break in Terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"whats is the current best practice for installing multiple versions of python on snow leopard?\n\nhave setup python 2.7.1 via Homebrew, very easy process, all great.\nbut now I need to setup python 2.5 to develop an appengine project..  Initially created a new virtualenv against system python2.5 .. but finding I have all kinds of PATH issues. Seems at this point it would be better not to use Homebrew and go with a more standard setup?\n\nany thoughts ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1005,"Q_Id":5194343,"Users Score":0,"Answer":"I use the python_select utility to switch between versions (it takes care of all the paths and links).  It's easy to install with MacPorts or fink, so I would guess you can install the same utility with Homebrew.","Q_Score":0,"Tags":"python,osx-snow-leopard,virtualenv,homebrew","A_Id":5195551,"CreationDate":"2011-03-04T13:30:00.000","Title":"how to install multiple python versions on snow leopard?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"whats is the current best practice for installing multiple versions of python on snow leopard?\n\nhave setup python 2.7.1 via Homebrew, very easy process, all great.\nbut now I need to setup python 2.5 to develop an appengine project..  Initially created a new virtualenv against system python2.5 .. but finding I have all kinds of PATH issues. Seems at this point it would be better not to use Homebrew and go with a more standard setup?\n\nany thoughts ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1005,"Q_Id":5194343,"Users Score":2,"Answer":"Snow leopard already contains python 2.5 and python 2.6, no issues there.\nIf you require obscure modifications to the python installations, just compile your own, and put it in some place where it won't conflict with the system python. (I suggest \/opt\/your-pythonx.y).\nAs an aside, check: \"man python\" on mac to see how to use the 32-bit, or 64-bit options if that turns out to be neccessary. (Sometimes it is for c modules)","Q_Score":0,"Tags":"python,osx-snow-leopard,virtualenv,homebrew","A_Id":5194593,"CreationDate":"2011-03-04T13:30:00.000","Title":"how to install multiple python versions on snow leopard?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have little working knowledge of python. I know that there is something called a Twitter search API, but I'm not really sure what I'm doing. I know what I need to do:\nI need point data for a class. I thought I would just pull up a map of the world in a GIS application, select cities that have x population or larger, then export those selections to a new table. That table would have a key and city name.\nnext i randomly select 100 of those cities. Then I perform a search of a certain term (in this case, Gaddafi) for each of those 100 cities. All I need to know is how many posts there were on a certain day (or over a few days depending on amount of tweets there were).\nI just have a feeling there is something that already exsists that does this, and I'm having a hard time finding it. I've dowloaded and installed python-twitter but have no idea how to get this search done. Anyone know where I can find or how I can make this tool? Any suggestions would really help. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":268,"Q_Id":5209003,"Users Score":0,"Answer":"A tweet itself comes with a geo tag. But it is a new feature and majority tweets do not have it. So it is not possible to search for all tweets containing \"Gaddafi\" from a city given the city name.\nWhat you could do is the reverse, you search for \"Gaddafi\" first (regardless of geo location), using search api. Then, for each tweet, find the location of the poster (either thru the RESTful api or use some sort of web scraping).\nso basically you can classify the tweets collected according to the location of the poster.\nI think only tweepy have access to both twitter search API as well as RESTful API.","Q_Score":0,"Tags":"python,api,twitter","A_Id":5209588,"CreationDate":"2011-03-06T06:00:00.000","Title":"Performing multiple searches of a term in Twitter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Well main question of the day will django work correctly under python 2.5.2 ?\nSo why i am asking this question?\nFirst of all  i have some test class written , nothing special which renders a page. The problem is that everytime i access this page i get random 3 different responses :\n1)exceptions must be classes, instances, or strings (deprecated), not type\n2) Http404 \n3) page renders normally .\nAnd generally i can refresh until i get the result i want , well in my case normally rendered page. I am a little bit confused what even to think . Because my written class does pretty much nothing.Just a test class to test some things.\nI run Django 1.2.3 under python 2.5.2 on Debian .\nAlso what i noticed . I use PyCharm 1.1.1 through remote host with auto upload every time change is made , it uploads but somehow changes are not always applied after initial upload . What i mean is that it feels like files are not compiled ~~ if u can say it this way ...\nWhat's teh chance that it has basically nothing to do with python and django O_O and that are some other weird bugz ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":5211338,"Users Score":0,"Answer":"By default mod_python decides when to reload, so you'll get what you get when you get it.\nMaybe I am mistaken, but I thought there was a directive you could send that would explicitly force the python reload now.  That should (in theory) help with achieving consistent but perhaps not ideal, behavior.\nOff topic, this sounds like a good opportunity to enhance your app's logging so you'll have better breadcrumbs to follow next time things hang.","Q_Score":0,"Tags":"python,django,rendering","A_Id":5216170,"CreationDate":"2011-03-06T15:26:00.000","Title":"Django 1.2.3 compatible with python 2.5.2 ? Weird django behaviour","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not sure if this is an issue specific to sqlite databases but after adding some properties I executed syncdb successfully but still the the columns were not added to the database and when I try the access the model in admin I get no such column error.\nWhy is this happening and how do I overcome this issue?\nDetails: Django 1.3, Python 2.6, OSX 10.6, PyCharm.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5639,"Q_Id":5211340,"Users Score":3,"Answer":"As always, syncdb does not migrate the existing schema.","Q_Score":4,"Tags":"python,django,sqlite","A_Id":5211417,"CreationDate":"2011-03-06T15:26:00.000","Title":"Django manage.py syncdb doing nothing when used with sqlite3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read).\n\nIs there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)?  I've read good things about Spyder, but does it have a profiler?\nWhen you change a function on the path in MATLAB, it is automatically reloaded.  Do you have to manually re-import libraries when you change them, or can this been done automatically?  This is a minor thing, but actually greatly improves my productivity.","AnswerCount":11,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":47020,"Q_Id":5214369,"Users Score":12,"Answer":"I've been getting on very well with the Spyder IDE in the Python(x,y) distribution. I'm a long term user of Matlab and have known of the existence of Python for 10 years or so but it's only since I installed Python(x,y) that I've started using Python regularly.","Q_Score":26,"Tags":"python,matlab,ide","A_Id":6088759,"CreationDate":"2011-03-06T23:52:00.000","Title":"Python vs Matlab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read).\n\nIs there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)?  I've read good things about Spyder, but does it have a profiler?\nWhen you change a function on the path in MATLAB, it is automatically reloaded.  Do you have to manually re-import libraries when you change them, or can this been done automatically?  This is a minor thing, but actually greatly improves my productivity.","AnswerCount":11,"Available Count":5,"Score":0.0363476168,"is_accepted":false,"ViewCount":47020,"Q_Id":5214369,"Users Score":2,"Answer":"after long long tryouts with many editors,\ni have settled for aptana ide + ipython (including notebook in internet browser)\ngreat for editing, getting help easy, try fast new things\naptana is the same as eclipse (because of pydev) but aptana has themes and different little things eclipse lacks\nabout python a little,\ndon't forget pandas, as it's (i believe) extremely powerful tool for data analysis\nit will be a beast in the future, my opinion\ni'm researching matlab, and i see some neat things there, especially gui interfaces and some other nice things\nbut python gives you flexibility and ease,\nanyway, you still have to learn the basics of python, matplotlib, numpy (and eventually pandas)\nbut from what i see, numpy and matplotlib are similar to matplotlib concepts (probably they were created with matlab in mind, right?)","Q_Score":26,"Tags":"python,matlab,ide","A_Id":10388279,"CreationDate":"2011-03-06T23:52:00.000","Title":"Python vs Matlab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read).\n\nIs there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)?  I've read good things about Spyder, but does it have a profiler?\nWhen you change a function on the path in MATLAB, it is automatically reloaded.  Do you have to manually re-import libraries when you change them, or can this been done automatically?  This is a minor thing, but actually greatly improves my productivity.","AnswerCount":11,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":47020,"Q_Id":5214369,"Users Score":6,"Answer":"I've been in the engineering field for a while now and I've always used MATLAB for high-complexity math calculations. I never really had an major problems with it, but I wasn't super enthusiastic about it either. A few months ago I found out I was going to be a TA for a numerical methods class and that it would be taught using Python, so I would have to learn the language. \n   What I at first thought would be extra work turned out to be an awesome hobby. I can't even begin to describe how bad MATLAB is compared to Python! What used to to take me all day to code in Matlab takes me only a few hours to write in Python. My code looks infinitely more appealing as well. Python's performance and flexibility really surprised me. With Python I can literally do anything I used to do in MATLAB and I can do it a lot better. \nIf anyone else is thinking about switching, I suggest you do it. It made my life a lot easier. I'll quote \"Python Scripting for Computational Science\" because they describe the pros of Python over MATLAB better than I do:\n\n\nthe python programming language is more powerful\nthe python environment is completely open and made for integration\n       with external tools,\na complete toolbox\/module with lots of functions and classes can be    contained in a single file (in contrast to a bunch of M-files),\ntransferring functions as arguments to functions is simpler,\nnested, heterogeneous data structures are simple to construct and     use,\nobject-oriented programming is more convenient,\ninterfacing C, C++, and fortran code is better supported and     therefore simpler,\nscalar functions work with array arguments to a larger extent (without modifications of arithmetic operators),\nthe source is free and runs on more platforms.","Q_Score":26,"Tags":"python,matlab,ide","A_Id":41910220,"CreationDate":"2011-03-06T23:52:00.000","Title":"Python vs Matlab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read).\n\nIs there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)?  I've read good things about Spyder, but does it have a profiler?\nWhen you change a function on the path in MATLAB, it is automatically reloaded.  Do you have to manually re-import libraries when you change them, or can this been done automatically?  This is a minor thing, but actually greatly improves my productivity.","AnswerCount":11,"Available Count":5,"Score":0.0363476168,"is_accepted":false,"ViewCount":47020,"Q_Id":5214369,"Users Score":2,"Answer":"almost everything is covered by others .. i hope you don't need any toolboxes like optimizarion toolbox , neural network etc.. [ I didn't find these for python  may be there are some .. i seriously doubt they might be better than Matlab ones..]\nif u don't need symbolic manipulation capability and are using windows python(x,y) is the way to go[they don't have much activity on their linux port (older versions are available)]\n(or need some minor symbolic manipulations use sympy , i think it comes with EPD and python(x,y) supersedes\/integrates  EPD)\nif you need symbolic capabilities sage is the way to go, IMHO sage stands up good with Matlab as well as Mathematica ..\ni'm also trying to make a switch  ...(need for my engg projs)\ni hope it helps ..","Q_Score":26,"Tags":"python,matlab,ide","A_Id":5214892,"CreationDate":"2011-03-06T23:52:00.000","Title":"Python vs Matlab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read).\n\nIs there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)?  I've read good things about Spyder, but does it have a profiler?\nWhen you change a function on the path in MATLAB, it is automatically reloaded.  Do you have to manually re-import libraries when you change them, or can this been done automatically?  This is a minor thing, but actually greatly improves my productivity.","AnswerCount":11,"Available Count":5,"Score":0.0181798149,"is_accepted":false,"ViewCount":47020,"Q_Id":5214369,"Users Score":1,"Answer":"I have recently switched from MATLAB to Python (I am about 2 months into the transition), and am getting on fairly well using Sublime Text 2, using the SublimeRope and SublimeLinter plugins to provide some IDE-like capabilities, as well as pudb to provide some graphical interactive debugging capabilities.\nI have not yet explored profilers or variable editors. (I never really used the MATLAB variable editor, anyway).","Q_Score":26,"Tags":"python,matlab,ide","A_Id":9317942,"CreationDate":"2011-03-06T23:52:00.000","Title":"Python vs Matlab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Lettuce BDD framework for python, and I am wondering how to run one scenario from within another scenario.. \nFor example, say there is a \"registration\" scenario that establishes some pre-conditions which will be used by a subsequent scenario (say \"action\" scenario\") - how do I refer and call the \"registration\" scenario from \"action\" scenario?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":822,"Q_Id":5215883,"Users Score":3,"Answer":"There is a \"behave_as\" feature for Lettuce which should do this.  Though there were some bugs with it last time I tried to use it.  May be fixed now.  I opened a bug on it with Gabriel, the author.","Q_Score":3,"Tags":"python,bdd,lettuce","A_Id":5665792,"CreationDate":"2011-03-07T04:38:00.000","Title":"Lettuce BDD : How to refer scenarios?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to change my computer's local date to an earlier date (e.g. 2010). I couldnt do that in BIOS. Does anybody know how to do this task, for example by writing a Python snippet?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":666,"Q_Id":5217033,"Users Score":1,"Answer":"If you use Windows, you should be able to do that in the time and date control panel (should be self explaining). \nIf you use Linux, use the date command, and maybe hwclock (more info in the man pages).\nIf you use AmigaOS, use the appropriate settings window in the system Preferences folder.\nIf you use any other OS, you should have mentioned here which one you use...","Q_Score":0,"Tags":"python,date","A_Id":5217076,"CreationDate":"2011-03-07T07:34:00.000","Title":"Change system date","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to change my computer's local date to an earlier date (e.g. 2010). I couldnt do that in BIOS. Does anybody know how to do this task, for example by writing a Python snippet?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":666,"Q_Id":5217033,"Users Score":1,"Answer":"If you are not permitted to do this via the operating system, then you will not be permitted to do it from a scripting language like Python, either.","Q_Score":0,"Tags":"python,date","A_Id":5375660,"CreationDate":"2011-03-07T07:34:00.000","Title":"Change system date","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to modify the guestbook example webapp to reduce the amount of database writes.\nWhat I am trying to achieve is to load all the guestbook entries into memcache which I have done. \nHowever I want to be able to directly update the memcache with new guestbook entries and then write all changes to the database as a batch put.() every 30 seconds.\nHas anyone got an example of how I could achieve the above? it would really help me!\nThanks :)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1124,"Q_Id":5221977,"Users Score":6,"Answer":"This is a recipe for lost data. I have a hard time believing that a guest book is causing enough write activity to be an issue. Also, the bookkeeping involved in this would be tricky, since memcache isn't searchable.","Q_Score":2,"Tags":"python,google-app-engine,caching,memcached,google-cloud-datastore","A_Id":5222081,"CreationDate":"2011-03-07T16:12:00.000","Title":"Limit amount of writes to database using memcache","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using sqlalchemy with reflection, a couple of partial indices in my DB make it dump warnings like this:\nSAWarning: Predicate of partial index i_some_index ignored during reflection\ninto my logs and keep cluttering. It does not hinder my application behavior. I would like to keep these warnings while developing, but not at production level. Does anyone know how to turn this off?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":14820,"Q_Id":5225780,"Users Score":12,"Answer":"the warning means you did a table or metadata reflection, and it's reading in postgresql indexes that have some complex condition which the SQLAlchemy reflection code doesn't know what to do with.   This is a harmless warning, as whether or not indexes are reflected doesn't affect the operation of the application, unless you wanted to re-emit CREATE statements for those tables\/indexes on another database.","Q_Score":35,"Tags":"python,postgresql,sqlalchemy","A_Id":5331129,"CreationDate":"2011-03-07T22:00:00.000","Title":"Turn off a warning in sqlalchemy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just start to learn python and web2py. Because of web2py's web interface development, I am wondering how can web2py work with svn? If a team wants to build a website,how do they work together? How to control the iteration of source code?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":742,"Q_Id":5240646,"Users Score":5,"Answer":"Yes, it works fine with svn, hg, whatever source control you need to use. \nSometimes people think that you have to code with web2py's admin interface, but that really is not the case, once you realize it can be edited with any of your regular tools, you will see that you don't have to treat it any differently when it comes to source control either.\nIf you use the source version of web2py, you'll have a single folder on disk that contains an entire web2py application server (that in turn contains your 'application' folders). Just check that whole folder into source control. \nNow, on the machine that is running web2py, you can make changes either with web2py's web interface, or by just editing the python files directly with another editor (I use WingIDE for example). You'll have the normal svn update\/modify\/commit cycle at this point. \nIf multiple people are editing code using web2py's admin interface, all of their changes will be made on the machine running web2py... just periodically do a commit from that system and you are all set.\nUsing the admin interface to modify the source code is convenient, but for for bigger changes, each member of your team should have their own local copy of the svn branch. They make changes to their local files and commit them. Then from the server running web2py, just do an 'svn up' to get modifications from the rest of the team.","Q_Score":1,"Tags":"python,web2py","A_Id":5240964,"CreationDate":"2011-03-09T02:27:00.000","Title":"Can web2py work with svn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a TCP server, a Python app, that gets the information from the connected devices. This information I am trying to show using Django web app. So, basically my model objects reside within the TCP server process.\nI can modify the TCP server to put the information into SQLite database and have my Django web app take it from there. But, it is not the most natural way of sharing information in this case because this information is not persistent i.e. not suitable for database. When my TCP server exists, it has to clear this information.\nHow do I model this scenario using Django?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":5242230,"Users Score":0,"Answer":"i think better to use `memcached (http:\/\/memcached.org\/) in mem cached server and each server see this server\nalso you can serialize your data and send it like udp and other method","Q_Score":0,"Tags":"python,django,web-applications,django-models","A_Id":5245050,"CreationDate":"2011-03-09T06:37:00.000","Title":"django - how to get model objects from another process instead of database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a TCP server, a Python app, that gets the information from the connected devices. This information I am trying to show using Django web app. So, basically my model objects reside within the TCP server process.\nI can modify the TCP server to put the information into SQLite database and have my Django web app take it from there. But, it is not the most natural way of sharing information in this case because this information is not persistent i.e. not suitable for database. When my TCP server exists, it has to clear this information.\nHow do I model this scenario using Django?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":246,"Q_Id":5242230,"Users Score":1,"Answer":"You may be able to serialise your model and pass the serialised data.","Q_Score":0,"Tags":"python,django,web-applications,django-models","A_Id":5244998,"CreationDate":"2011-03-09T06:37:00.000","Title":"django - how to get model objects from another process instead of database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have to write a program to calculate a**b % c where b and c are both very large numbers. If I just use a**b % c, it's really slow. Then I found that the built-in function pow() can do this really fast by calling pow(a, b, c).\n I'm curious to know how does Python implement this? Or where could I find the source code file that implement this function?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37922,"Q_Id":5246856,"Users Score":0,"Answer":"Python uses C math libraries for general cases and its own logic for some of its concepts (such as infinity).","Q_Score":56,"Tags":"python,algorithm,math","A_Id":5246963,"CreationDate":"2011-03-09T14:01:00.000","Title":"How did Python implement the built-in function pow()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a string \"Mikael H\u00e5fstr\u00f6m\" which contains some special characters how do i remove this using python?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":12590,"Q_Id":5258623,"Users Score":5,"Answer":"For example using the encode method: u\"Mikael H\u00e5fstr\u00f6m\".encode(\"ascii\", \"ignore\")","Q_Score":10,"Tags":"python","A_Id":5258931,"CreationDate":"2011-03-10T10:52:00.000","Title":"remove special characters from string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Mornink!\nI need to design, write and implement wide system consisting of multiple unix servers performing different roles and running different services. The system must be bullet proof, robust and fast. Yeah, I know. ;) Since I dont know how to approach this task, I've decided to ask you for your opinion before I leave design stage. Here is how the workflow is about to flow:\n\nusers are interacting with website, where they set up demands for service\nthis demand is being stored (database?) and some kind of message to central system (clustered) is being sent about new demand in database\/queue\ncentral system picks up the demand and sends signals to various other systems (clusters) to perform their duties (parts of the demanded service setup)\nwhen they are done, they send up message to central system or the website that the service is now being served\n\nNow, what is the modern, robust, clean and efficient way of storing these requests in some kind of queue, and executing them? Should I send some signals, or should I let all subsystems check the queue\/db of any sort for new data? What could be that queue, should it be a database? How to deal with the messages? I thought about opening single tcp connection and sending data over that, along with comands triggering actions\/functions on the other end, but at closer inspection, there has to be other, better way. So I found Spring Python, that has been criticized for being so 90's-ish.\nI know its a very wide question, but I really hope you can help me wrap my head around that design and not make something stupid here :)\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":219,"Q_Id":5264414,"Users Score":0,"Answer":"Some general ideas for you:\nYou could have a master-client approach. Requests would be inserted in the master, stored in a database. Master knows the state of each client (same db). Whenever there is a request, the master redirects it to a free client. The client reports back when has finished the task (including answers if any), making it able to receive a new task from the master (this removes the need for pooling). \nCommunication could be done using web-services. An HTTP request\/post should solve every cases. No need to actually go down to the TCP level.\nJust general ideas, hope they're useful.","Q_Score":0,"Tags":"python,django,unix,tcp,communication","A_Id":5264700,"CreationDate":"2011-03-10T18:58:00.000","Title":"What is best pythonic way to communicate between spreaded services\/unix machines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed the django-newsletter application, and customized the subscribing form. But, right now, I'd like to print it through a Jquery Overlay, instead of a flatpage containing that form. \nProblem is I don't know how to include this flatpages elements into every page where the link calling the overlay will be present; and I don't know which approach would be the most performant.\nPlease light my way :)\nThank you!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":830,"Q_Id":5266425,"Users Score":2,"Answer":"Create a Django view which renders just the HTML for the form using your preferred template. Then use $.ajax() with dataType: \"html\" to get the code for the form for use in your overlay.","Q_Score":1,"Tags":"jquery,python,django,forms","A_Id":5266823,"CreationDate":"2011-03-10T21:59:00.000","Title":"How to call django template in order to use it through Jquery?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do people handle timezones in Tornado so that users see time formatted relative to their timezone? I know there's locale.format_date which defaults to GMT, but how do I set the right timezone based on the user?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1179,"Q_Id":5275488,"Users Score":0,"Answer":"Pardon my dimness but why do you mean to format the date based on the user in the context of Tornado? Tornado is a server. The user is a client.","Q_Score":2,"Tags":"python,timezone,tornado","A_Id":5275903,"CreationDate":"2011-03-11T16:21:00.000","Title":"Setting timezone in Tornado","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create an Admin-only page for my GAE application. But I found there's no way to set a Admin user, so I cannot log on the page I created and test the function. I tried the local Admin console, but no luck. How can I do this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":924,"Q_Id":5283506,"Users Score":0,"Answer":"When you log in (the blue box where you enter the email) there is a checkbox to apply the administrator flag to your session.","Q_Score":3,"Tags":"python,google-app-engine","A_Id":5283536,"CreationDate":"2011-03-12T15:44:00.000","Title":"how to set the admin user with GAE dev app server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get the query string in a CGI python script because for some reason the .FieldStorage and .getvalue functions are returning \"None\". The query is being generated correctly. I checked it in Wireshark and it is correctly produced.\nAny ideas on how I can just get the string itself correctly?\nI was trying to use os.environ('QUERY_STRING') but that didn't work either.\nJosh","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":669,"Q_Id":5287113,"Users Score":1,"Answer":"I think I figured it out. I need to use the environ variable passed to the application function by mod_wsgi.\nThanks!","Q_Score":0,"Tags":"python,apache,cgi","A_Id":5287233,"CreationDate":"2011-03-13T03:02:00.000","Title":"Get the GET query in a Python CGI script (Apache, mod_cgi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"hi everyone :)\nmy problem is, up until now, i have exclusively used tabs to indent python, as i find it easier than spaces, but for no reason i know, python interactive prompt, the basic python.exe one, suddenly refuses to accept the tab button, all it does is flash the cursor. all i can think of is that my computer in suddenly treading the window like any other, using tab to cycle input things, in this case the single one. also, before now, i could use the up button to reach previously typed code, the if i submit that line with no changes, use the down button to access the line that came after it, but now up works, but as if i had changed the line, eg moves me back to the \"bottom\" of the list of inputs, so down doesn't work.... my question simply is: how do i get my good old tab and down button to work like i want them to again? :(\nthanks xxx","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5644,"Q_Id":5291479,"Users Score":0,"Answer":"I recently observed this behavior too, on Windows, using cmd.exe. It also happens with Console2 - an alternate shell I sometimes use.\nThough I do always use spaces in normal code in an editor, I had been accustomed to using the Tab key to indent in short multi-line inputs in the interactive python.exe interpreter. Recently that stopped working - pressing the Tab key flashes the cursor and doesn't indent. Using spaces does work fine here, though it's not as convenient past a couple of indentations.\nI suspect (but am not certain) that the cause was installation of pyreadline or rlcompleter - I had been messing with trying to get tab completion in an interpreter in an embedded application on Windows. Of course in your case another installation could have included those packages.","Q_Score":2,"Tags":"python,indentation,prompt","A_Id":26475538,"CreationDate":"2011-03-13T18:36:00.000","Title":"indent with 'tab' button in python commandline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"hi everyone :)\nmy problem is, up until now, i have exclusively used tabs to indent python, as i find it easier than spaces, but for no reason i know, python interactive prompt, the basic python.exe one, suddenly refuses to accept the tab button, all it does is flash the cursor. all i can think of is that my computer in suddenly treading the window like any other, using tab to cycle input things, in this case the single one. also, before now, i could use the up button to reach previously typed code, the if i submit that line with no changes, use the down button to access the line that came after it, but now up works, but as if i had changed the line, eg moves me back to the \"bottom\" of the list of inputs, so down doesn't work.... my question simply is: how do i get my good old tab and down button to work like i want them to again? :(\nthanks xxx","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":5644,"Q_Id":5291479,"Users Score":1,"Answer":"If you are using Windows with the standard cmd.exe console (and it would have been helpful for you to have stated this up front) then you can use the TAB and arrow keys exactly as you desire.","Q_Score":2,"Tags":"python,indentation,prompt","A_Id":5291864,"CreationDate":"2011-03-13T18:36:00.000","Title":"indent with 'tab' button in python commandline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to make a program in python that chooses cars from an array, that is filled with the mass of 10 cars. The idea is that it fills a barge, that can hold ~8 tonnes most effectively and minimum space is left unfilled. My idea is, that it makes variations of the masses and chooses one, that is closest to the max weight. But since I'm new to algorithms, I don't have a clue how to do it","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":230,"Q_Id":5299280,"Users Score":1,"Answer":"I'd solve this exercise with dynamic programming. You should be able to get the optimal solution in O(m*n) operations (n beeing the number of cars, m beeing the total mass).\nThat will only work however if the masses are all integers.\nIn general you have a binary linear programming problem. Those are very hard in general (NP-complete).\nHowever, both ways lead to algorithms which I wouldn't consider to be beginners material. You might be better of with trial and error (as you suggested) or simply try every possible combination.","Q_Score":2,"Tags":"python,algorithm,variations","A_Id":5299434,"CreationDate":"2011-03-14T13:35:00.000","Title":"Program, that chooses the best out of 10","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent.\nThanks!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1772,"Q_Id":5322445,"Users Score":5,"Answer":"first instance of StreamServer could be started with: server.start() and second with server2.serve_forever()","Q_Score":3,"Tags":"python,gevent","A_Id":5338718,"CreationDate":"2011-03-16T08:00:00.000","Title":"gevent multiple StreamServer listeners","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent.\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1772,"Q_Id":5322445,"Users Score":0,"Answer":"I think the problem will come from the StreamServer's stop() method.\nIt kills the pool, so, finishing one of listeners will drop all connections, from both listeners.\nIf this is does not frighten you, you can simply pass the same Pool object to both StreamServers, running each of them in the separate greenlet.","Q_Score":3,"Tags":"python,gevent","A_Id":8439364,"CreationDate":"2011-03-16T08:00:00.000","Title":"gevent multiple StreamServer listeners","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"my datetime property is saving in mysql in this format 2011-03-17 00:00:00 but after fetchind the data with filter function it is giving March 17,2011 midnight but i have not say to do any this type of task. My question is how can i insist django to stic to show same value what is saved in MYSQL.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":699,"Q_Id":5335845,"Users Score":0,"Answer":"I have a feeling your database schema knows this is a date, right? In that case it's not being stored in the format you describe, but as some representation such as seconds since the era. \nThis means that when you retreave it your code has to do something with it to make it look right. If you don't tell it how to look it'll default to the format you see, but if you use strftime in your python code and a filter in your templates you can make it look however you like, including the original format how you saw it.\nOf course the easy way out is to store it in the db as text...","Q_Score":0,"Tags":"python,mysql,django","A_Id":5336126,"CreationDate":"2011-03-17T06:57:00.000","Title":"django autoconverting datetime property","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am attemping to install OpsCenter for Cassandra, and using the the standard REHL image.  I can't figure out how to get this to work.  Another version of EPEL perhaps?\nyum install opscenter....\nError: Package: python26-rrdtool-1.2.27-1.i386 (opscenter)\n           Requires: librrd.so.2","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":410,"Q_Id":5344641,"Users Score":0,"Answer":"Try installing rrdtool via yum, that should contain librrd.so.2 and correct your issue.","Q_Score":2,"Tags":"python,linux,centos,cassandra,yum","A_Id":5344716,"CreationDate":"2011-03-17T20:10:00.000","Title":"Amazon Linux AMI EC2 - librrd.so.2 dependency issue","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Webserver running in Python. He is getting some Data from some Apps and need to store these in MongoDB. My MongoDB is sharded. \nNow i want that my Webserver know how much Shards MongoDB has. At the moment he reads this from a cfg file. There is an Statement in MongoDb named printshardingstatus where u can see all shards. So i tried to call this statement from my Pythonserver. But it seems that it is not possible.I dont find such a function in the Pymongo API. \nSo my question is, is there an chance to run an MongoDB Statement in Python, so that it is directly passed and executed in MongoDB ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1576,"Q_Id":5350599,"Users Score":0,"Answer":"You can simply get config databasr and\n  execute find() on shards collection\n  just like normal collection.","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":5377084,"CreationDate":"2011-03-18T10:21:00.000","Title":"Execute MongoDb Statements in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have soap webservice built with soaplib,\nbut if client sent chunked request it fails on \n\nlength = req_env.get(\"CONTENT_LENGTH\")\nbody = input.read(int(length))\n\nbecause length is '' (empty string), any ideas how to fix soaplib?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":279,"Q_Id":5351250,"Users Score":0,"Answer":"a bit ugly, but looks like it works:\n\n            if '' != length:\n                body = input.read(int(length))\n            elif req_env.get(\"HTTP_TRANSFER_ENCODING\").lower() == 'chunked':\n\n                chunk_size = int(input.readline(), 16)\n                while chunk_size > 0:\n                    chunk_read_size = 0\n                    tmp  = input.read(chunk_size)\n                    chunk_read_size += len(tmp)\n                    body += tmp\n                    while chunk_read_size","Q_Score":0,"Tags":"python,web-services,soap,soaplib","A_Id":5389161,"CreationDate":"2011-03-18T11:23:00.000","Title":"fix soaplib to support chunked requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Scenario\nI have a server process implemented in Python and gevent, which is connecting to a backend service over TCP\/IP and serving many Web clients (~1000 per process) with fast changing dynamic content based on the changes delivered by the backend service. The service is running on Ubuntu 10.04 and won't run on Windows, so the target platform is fixed. We're using Python 2.6.6, currently.\nProblem\nServing the changes to that many clients can cause a lag in processing the changes sent by the backend, so my plan is to split the server into multiple processes. A number of worker processes would serve the Web clients, while the main process would still be connected to the backend service. I'm already using a separate pool of greenlets to serve the Web clients, but they need to be put into worker processes.\nQuestion\nCould you please point me to a working process pool implementation for gevent or figure out how can I use Python's own multiprocessing module with gevent the right way?\nRestrictions\nI would like to avoid introducing Python threads into our processes, since that would give room for GIL contention, which would reduce performance by introducing latencies. So it would be a clean multiprocessing + gevent solution, if possible.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1761,"Q_Id":5360050,"Users Score":2,"Answer":"I'd consider custom socket IPC or using ZeroMQ.","Q_Score":2,"Tags":"python,linux,asynchronous,multiprocessing,gevent","A_Id":6671124,"CreationDate":"2011-03-19T04:22:00.000","Title":"What is the best way to implement a pool of worker processes compatible with gevent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm using Pythons SocketServer.ThreadingTCPServer. Now I want to know how many clients are connected at a certain moment.\nHow to solve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4268,"Q_Id":5370778,"Users Score":0,"Answer":"In a thread that \"serves\" client use some global count that is increased when client connects and decreased when disconnects.\nIf you want to count from OS level then use nestat -an with proper grep filter and wc -l (on Windows uses ports of grep and wc)","Q_Score":4,"Tags":"python,tcp,network-programming","A_Id":5370827,"CreationDate":"2011-03-20T19:12:00.000","Title":"How to count connected clients in TCPServer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This one is a little tricky to explain. I would like to create a file, lets say, a .test file. Now, this is ridiculously easy to create and write, but I would like to encode the information so I could only interpret the information with the Test Program.\nSo, this Test Program would be able to create and read the .test files. And the point is that, only that program can read the file, you can't really interpret the information just by opening the file with Notepad as it wouldn't be read-able.\nI would just like some direction as to how I could accomplish this. If you really didn't understand what I just said, I would like to know how to create or how does it work something similar to Bencode used in BitTorrent.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":5371632,"Users Score":1,"Answer":"If you want a really simply version, use python's base64 module. The file won't be recognizable opening in notepad anymore, but it'll be easy to decode if you know what you are doing.\nIf you actually want to prevent any other program from being able to encode it: don't. You can spend a lot of effort and the only thing you can really accomplish is annoying the person who wants the data.","Q_Score":0,"Tags":"python,encoding,wxpython","A_Id":5371727,"CreationDate":"2011-03-20T21:27:00.000","Title":"Encoding a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I interact with a select box using PAMIE?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":5371808,"Users Score":0,"Answer":"It is ie.listBoxSelect, using the source code as documentation.","Q_Score":0,"Tags":"python,windows,internet-explorer,automation,pamie","A_Id":5372020,"CreationDate":"2011-03-20T21:59:00.000","Title":"how to interact with a `select` input with PAMIE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have read the topic: How do I calculate a trendline for a graph? \nWhat I am looking for though is how to find the line that touches the outer extreme points of a graph. The intended use is calculation of support, resistance lines for stock charts. So it is not a merely simple regression but it should also limit the number of touch points and there should be a way to find the relevant interval.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2927,"Q_Id":5377347,"Users Score":0,"Answer":"You could think about using a method that calculates the concave hull of your data. There are probably existing python implementations you could find. This will give you the boundary that encloses your timeseries. If there are outliers in your dataset that you wish to exclude, you could apply some sort of filter or smoothing to your data before you calculate the concave hull. I'm not 100% sure what you mean by \"limit the number of touch points\" and \"find the relevant interval\", but hopefully this will get you started.","Q_Score":0,"Tags":"python,stocks","A_Id":5377789,"CreationDate":"2011-03-21T12:07:00.000","Title":"how to calculate trendline for stock charts","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been looking into microframeworks for Python, and have come across two interesting options, Flask and Bottle. each have some similar features. One thing I noticed is that all the example sites show all the application code located inside a single Python file. Obviously, for even moderately sized sites, this would become difficult to manage quite quickly. Do either (or both) of these frameworks support being broken up among different files, and if so how would that be accomplished?\nI'm familiar with Django, and like how its a little more structured, but i would rather use something more lightweight, but still powerful.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":7590,"Q_Id":5381208,"Users Score":2,"Answer":"I can't see how there could be any way of stopping this from working. Flask and Bottle, like Django, are just Python underneath, and Python allows you to break up files into modules. As long as you importing the relevant functions into the main script, they will just work exactly as if they were defined there.","Q_Score":11,"Tags":"python,flask","A_Id":5381900,"CreationDate":"2011-03-21T17:17:00.000","Title":"Flask\/Bottle project organization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been looking into microframeworks for Python, and have come across two interesting options, Flask and Bottle. each have some similar features. One thing I noticed is that all the example sites show all the application code located inside a single Python file. Obviously, for even moderately sized sites, this would become difficult to manage quite quickly. Do either (or both) of these frameworks support being broken up among different files, and if so how would that be accomplished?\nI'm familiar with Django, and like how its a little more structured, but i would rather use something more lightweight, but still powerful.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7590,"Q_Id":5381208,"Users Score":0,"Answer":"It really depends what you are trying to achieve, for micro service\/applications\/websites bottle is very straight forward and light weight. If you plan your application to grow by the time then Flask might be good option for you coz it has lot of extensions. We have about 40 to 50 micro services written in bottle and never faced any issues.","Q_Score":11,"Tags":"python,flask","A_Id":26026153,"CreationDate":"2011-03-21T17:17:00.000","Title":"Flask\/Bottle project organization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have quite a lot of experience with python and gst-python, but no experience with plain gstreamer.\ndoes anyone know (well, someone on earth probably does but...) how to create a custom element? i got as far as\nclass MyElement(Element):\nby intuition, but i have no idea what next...\nsimply what i was hoping for was a \"replace this function with the thing you want to happen to every unit that this element is passed\", but i am pretty certain that it will be FAR more complicated than that....","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1272,"Q_Id":5382305,"Users Score":0,"Answer":"If you're creating a source element, you probably want to subclass gst.BaseSrc. Then, IIRC, the main thing you need to do is implement the do_create() virtual method. Don't forget to gobject.type_register() your class; you may also need to set the time format using set_format().\nI second the recommendation to look at the Pitivi source code; it contains several GStreamer elements implemented in Python.","Q_Score":0,"Tags":"python,gstreamer","A_Id":8164493,"CreationDate":"2011-03-21T19:00:00.000","Title":"How to make a custom element im gst-python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am parsing an XSL file using xlrd. Most of the things are working fine. I have a dictionary where keys are strings and values are lists of strings. All the keys and values are Unicode. I can print most of the keys and values using str() method. But some values have the Unicode character \\u2013 for which I get the above error.\nI suspect that this is happening because this is Unicode embedded in Unicode and the Python interpreter cannot decode it. So how can I get rid of this error?","AnswerCount":7,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":137788,"Q_Id":5387895,"Users Score":2,"Answer":"I had exactly this issue in a recent project which really is a pain in the rear. I finally found it's because the Python we used in Docker has encoding \"ansi_x3.4-1968\" instead of \"utf-8\". So if anyone out there using Docker and got this error, following these steps may thoroughly solve your problem.\n\ncreate a file and name it default_locale in the same directory of your Dockerfile, put this line in it,\nenvironment=LANG=\"es_ES.utf8\", LC_ALL=\"es_ES.UTF-8\", LC_LANG=\"es_ES.UTF-8\"\nadd these to your Dockerfile,\nRUN apt-get clean && apt-get update && apt-get install -y locales\nRUN locale-gen en_CA.UTF-8\nCOPY .\/default_locale \/etc\/default\/locale\nRUN chmod 0755 \/etc\/default\/locale\nENV LC_ALL=en_CA.UTF-8\nENV LANG=en_CA.UTF-8\nENV LANGUAGE=en_CA.UTF-8\n\nThis thoroughly solved my issue when I built and run my Docker again, hopefully this solve your issue also.","Q_Score":78,"Tags":"python,character-encoding","A_Id":58780738,"CreationDate":"2011-03-22T07:09:00.000","Title":"UnicodeEncodeError: 'ascii' codec can't encode character u'\\u2013' in position 3 2: ordinal not in range(128)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am parsing an XSL file using xlrd. Most of the things are working fine. I have a dictionary where keys are strings and values are lists of strings. All the keys and values are Unicode. I can print most of the keys and values using str() method. But some values have the Unicode character \\u2013 for which I get the above error.\nI suspect that this is happening because this is Unicode embedded in Unicode and the Python interpreter cannot decode it. So how can I get rid of this error?","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":137788,"Q_Id":5387895,"Users Score":0,"Answer":"for me this works\nunicode(data).encode('utf-8')","Q_Score":78,"Tags":"python,character-encoding","A_Id":47410460,"CreationDate":"2011-03-22T07:09:00.000","Title":"UnicodeEncodeError: 'ascii' codec can't encode character u'\\u2013' in position 3 2: ordinal not in range(128)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a gtk.Window. How do I set it to be the active window? I can call is_active() to see whether it already is, but I don't see where to make it active.\nBonus points: given a gtk.Widget, how do I make the window it is a part of the active window?","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":4336,"Q_Id":5393185,"Users Score":-1,"Answer":"You can also use gtk.Dialog.run (if it's a Dialog) aditional to gtk.Window.present","Q_Score":3,"Tags":"python,window,pygtk,gtk","A_Id":5441492,"CreationDate":"2011-03-22T14:58:00.000","Title":"gtk: set active window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a server with Apache2 + mod_python + Django for development and would like to know how to use Mercurial to manage application development.\nMy idea is to make the folder where the Mercurial stores the project be the same folder to deploy Django.\nThank you for your attention!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":627,"Q_Id":5397528,"Users Score":0,"Answer":"I thought about this, good idea for development.\nUse mercurial in common way. And of course you need deploy mercurial server before.\nIf you update your django project, it will be compiled on the fly.\n\n\nMy workflow:\n\nSet up mercurial server or use bitbucket\nInit repo locally\nPush repo to central repo\nOn server pull repo in some target dir\nEdit smth locally and push to central repo\nPull repo on server and everything is fine","Q_Score":0,"Tags":"python,django,mercurial,apache2,mod-python","A_Id":5397870,"CreationDate":"2011-03-22T20:37:00.000","Title":"How to use Mercurial to deploy Django applications?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to start with Django.\nI'm developing an App. This App is called \"Directory\" and will store\ninfo about websites.\nI must to create a database table called \"Genders\", but this is a\ngeneric database table and could be used in other App.\nMy question... how to deal with this kind of situation in Django? And\nin wich model I shuld put this database table?\nBest Regards,","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":5402847,"Users Score":0,"Answer":"Django doesn't really offer you place where things that are commonly used all over the project can live. I think the most common approach to solve this is to create a 'project'-app, which holds such project-relevant things like models, templatetags or widgets for example...","Q_Score":0,"Tags":"python,django","A_Id":5403151,"CreationDate":"2011-03-23T09:02:00.000","Title":"Where to put generic Database Tables on Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to start with Django.\nI'm developing an App. This App is called \"Directory\" and will store\ninfo about websites.\nI must to create a database table called \"Genders\", but this is a\ngeneric database table and could be used in other App.\nMy question... how to deal with this kind of situation in Django? And\nin wich model I shuld put this database table?\nBest Regards,","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":208,"Q_Id":5402847,"Users Score":1,"Answer":"In django, you don't (generally) create database tables. You create models, and let the django ORM create tables for you.\nTo prevent having two tables in your database called gender, django will prefix the model name with the name of the app. Thus, if your app was called foo, your model class was Gender, you would have foo_gender. But, you don't need to know this.\nAs for the specific case of Gender: I wouldn't bother storing this in the database in a special table. They don't make new genders anymore. If you need to store a field containing a gender, then just use django.db.models.CharField, with a choices=(('M',\"Male\"),('F',\"Female\")).  Or if you do it lots, then create a new field.\nIf it is something you do need to be able to add dynamically to the database, then either abstract it out into a reusable app, or as someone else mentioned, create a sundry\/project\/utils app.","Q_Score":0,"Tags":"python,django","A_Id":5403490,"CreationDate":"2011-03-23T09:02:00.000","Title":"Where to put generic Database Tables on Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a python project I am trying an IDE, coming from vim but I have troube how my code is shown resp. indentation. Many lines should be indented because they are inside if-then-else statements. \nIn SPE and netbeans there are many lines where the indention-space (four) are collapsed. \nBut I checked the files with tabnanny and pylint and cant see indention problems. ANd the code has been running up to now. \n\nHow can i check that?\nWhere is the \"show whitespace\" toggle in netbeans?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":310,"Q_Id":5407664,"Users Score":0,"Answer":"...Netbeans want to switch from spaces\n  to tabs, not the other way around...\n  ergh \u2013 Rafe Kettler Mar 23 at 15:36\n\nI use netbeans meanwhile and like it. \nYes I converted all spaces to tabs and retab it to 4 in php and python\nregards","Q_Score":0,"Tags":"python,netbeans,ide,tabstop","A_Id":5512865,"CreationDate":"2011-03-23T15:30:00.000","Title":"Tab\/spaces indention issues in IDE's vs vim","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have to open the result page using render_to_response on a new tab","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":28137,"Q_Id":5415600,"Users Score":7,"Answer":"Most the time, loading the page in a new tab can be a real pain in the ar** for the user. Nevertheless it can still be necessary sometimes. If you really need to render your POST results in a new tab, use the target=\"_blank\" as an attribute of your <form>.","Q_Score":13,"Tags":"python,django","A_Id":29631137,"CreationDate":"2011-03-24T06:37:00.000","Title":"how to open url in new tab from django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to know how to do this on a mac because whenever I try quitting it, I have to force quit it. Is there a proper way when the user clicks the exit button that Tkinter will exit normally?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":888,"Q_Id":5427875,"Users Score":2,"Answer":"I figured out how. I just put a simple exit() command after the main loop.","Q_Score":2,"Tags":"python,macos,tkinter,exit","A_Id":5427950,"CreationDate":"2011-03-25T02:21:00.000","Title":"Python: How can I make my tkinter app exit properly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to write a live data sniffer in Python which extracts the originating IP address and the full URL that was being accessed? I have looked at pulling data from urlsnarf however IPv6 is not supported (and the connections will be to IPv6 hosts).\nWhile I can pull data from tcpdump and greping for GET\/POST that would leave me with simply the path on the webserver, and I would not obtain the associated FQDN. Unfortunately using SQUID w\/ IPv6 TPROXY is not an option due to the configuration of the environment.\nDoes anyone have any ideas on how to do this with Python bindings for libpcap? Your help would be most appreciated :)\nThanks :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1843,"Q_Id":5436185,"Users Score":2,"Answer":"Unfortunately, with IPv6 you are stuck doing your own TCP re-assembly. The good news that you are only concerned with URL data which should (generally) be in one or two packets.\nYou should be able to get away with using pylibpcap to do this. You'll want to use setfilter  on your pcap object to make sure you are only looking at TCP traffic. As you move forward in your pcap loop you'll apply some HTTP regular expressions to the payload. If you have what looks like HTTP traffic go ahead and try to parse the header to get at the URL data. Hopefully, you'll get full URL with a line break before the end of the packet. If not, you are going to have to do some lightweight TCP reassembly.\nOh, and you'll want to use socket.inet_ntop and socket.getaddrinfo to print out info about the IPv6 host.","Q_Score":5,"Tags":"python,url,ipv6,libpcap,sniffing","A_Id":5446765,"CreationDate":"2011-03-25T17:49:00.000","Title":"URL Sniffing in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to match a url that:\nbegins with \/signup\nand ends with password=goodbye\nThat's it. If something begins with that and ends with that, how do I match that in regex?\nI understand that I should do this in urls.py, but I have to because of certain reasons.\nPlease answer how I would match it this way. I have to because a iPhone client (which cannot be changed) hardcoded it this way. I know it's not ideal, but I have to match it this way now.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1876,"Q_Id":5445994,"Users Score":6,"Answer":"Don't ever send passwords in the URL. They belong in the POST body, which is not stored by browsers (you can repeat POSTs in browsers, but POST data is not stored in the history).","Q_Score":0,"Tags":"python,regex,django","A_Id":5446040,"CreationDate":"2011-03-26T23:07:00.000","Title":"How do I match this URL in Django's urls.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite new with development. In some programming language such as python and PHP there is not a good debugger. How is the development going on without a debugger? just put the logs in the source code? Especially for the framework developers, how do they test their codes?\nThank you very much.\n-Stefan-","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":5447482,"Users Score":0,"Answer":"Python has a debugger: pdb. If you use Werkzeug, then you can also access each frame of a stack trace and debug there on an error","Q_Score":0,"Tags":"php,python,debugging","A_Id":5447505,"CreationDate":"2011-03-27T05:42:00.000","Title":"How a framework development works without a debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite new with development. In some programming language such as python and PHP there is not a good debugger. How is the development going on without a debugger? just put the logs in the source code? Especially for the framework developers, how do they test their codes?\nThank you very much.\n-Stefan-","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":94,"Q_Id":5447482,"Users Score":2,"Answer":"Your answer concerning the debugging in Python is truly nonsense. Python has a reasonable \"pdb\" debugger which is useful since years. Apart from that you can have a powerful IDE as WingIDE giving you all debugging and inspection power you need. Making such wild claims about Python is not appropriate. That's why this question deserves a clear downvote.","Q_Score":0,"Tags":"php,python,debugging","A_Id":5447522,"CreationDate":"2011-03-27T05:42:00.000","Title":"How a framework development works without a debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite new with development. In some programming language such as python and PHP there is not a good debugger. How is the development going on without a debugger? just put the logs in the source code? Especially for the framework developers, how do they test their codes?\nThank you very much.\n-Stefan-","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":5447482,"Users Score":0,"Answer":"python -m pdb foo.py\nAnd even without using that, usually you get detailed tracebacks when an error happens so many people don't know about pdb because they can just read the error message containing everything they ever wanted to know. It's not like C where it just goes boom and says \"Segmentation fault\" and leaves you with nothing to work on.","Q_Score":0,"Tags":"php,python,debugging","A_Id":5452043,"CreationDate":"2011-03-27T05:42:00.000","Title":"How a framework development works without a debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using GAE send mail- but I dont want the sender of the mail to get a coppy of the mail.\nas for now, when a user is sending mail he gets a mail saying that he sent a mail to someone and the body of the sent mail, how do I disable that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":288,"Q_Id":5448698,"Users Score":6,"Answer":"You can't.  Sending email from someone without their knowledge isn't permitted by App Engine.\nYou can send email from any administrator address; you could add a \"donotreply@yourapp.com\" type address as an administrator and send email from that address.","Q_Score":3,"Tags":"python,google-app-engine,sendmail","A_Id":5450093,"CreationDate":"2011-03-27T10:38:00.000","Title":"how to have google apps engine send mail- not send a copy of the mail to the sender","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wanted to know if this was possible- I want to use Python to retweet every tweet a person sends out. If yes then how can I implement this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4449,"Q_Id":5449091,"Users Score":0,"Answer":"The newest version of python-twitter allows you to retweet with the command\napi.PostRetweet(tweet_id)\nwhere api is a logged-in api and tweet_id is the id of the tweet you want to retweet.","Q_Score":4,"Tags":"python,twitter","A_Id":16450651,"CreationDate":"2011-03-27T12:05:00.000","Title":"Sending out twitter retweets with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to monitor the presence of USB devices and have found modules such as PyUSB that serve this purpose. However, I don't know how to run USB detection services alongside the Tkinter main loop. Is this possible?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":874,"Q_Id":5453256,"Users Score":0,"Answer":"Might I suggest that instead of trying to constantly monitor the presence of a USB device you include a search or refresh button that will check just once.","Q_Score":2,"Tags":"python,tkinter,pyusb","A_Id":5489197,"CreationDate":"2011-03-27T23:36:00.000","Title":"Tkinter and detection of USB devices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to write something into an XLS file with python while keeping the initial format of this XLS file unchanged (such as font size, cell background color, etc)Thanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":763,"Q_Id":5473301,"Users Score":0,"Answer":"If the available tools like xlrd, xlwt, and xlutils don't work, you may have to fall back to programmatically editing the file with Excel via COM.  Of course, you'll need a copy of Excel, have to work from Windows, and it will be slower than other approaches.","Q_Score":2,"Tags":"python,format,xls","A_Id":5473492,"CreationDate":"2011-03-29T13:29:00.000","Title":"how to write into XLS with python with format unchanged?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a Django newbie. I created an app which has a user login\/registration page. Now I want to include CAPTCHA also in the registration page. Can somebody guide me how to implement this in Django as i am quite new to it. On googling I found there are many modules which do the function out of the box. If this is the way to go, then which application is a better choice? Also I found most of them were explained on the basis of using Django Forms. But I used simple HTML forms instead of Django forms. Any help would be appreciated.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":2880,"Q_Id":5473340,"Users Score":3,"Answer":"Your question about which 3rd party solution is \"better\" is subjective, and stackoverflow doesn't generally like to answer subjective questions. Take some time and evaluate each in light of your needs.\nYou often don't need a fancy image captcha. Even a simple question like \"what color is an orange?\" will stop most spam bots. I posed a simple question on my registration form, asking the user to type the domain name of the site. Simple but very effective. You can also include an input box on the form, and hide it with CSS (display: none). If this input comes back to you filled out, chances are good a bot is trying to register.\nIt doesn't really matter that these 3rd party solutions are using Django forms, and you are using \"simple HTML\". In your registration view, you simply process request.POST. It doesn't matter how the form was generated.","Q_Score":0,"Tags":"python,django,django-models,django-templates,captcha","A_Id":5473845,"CreationDate":"2011-03-29T13:31:00.000","Title":"Including CAPTCHA on user registration page with Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We need to handle massive file uploads without spending resources on an IIS 7 server. To emphasize how light-weight this needs to be, let's say that we need to handle file uploads of sizes that are completely insane, like 100GB uploads, or something that can continue running for an extremely long time without consuming additional resources. Basically we need something that gives us control over the reception of the file from the moment it starts to the moment it ends.\nA bit of background:\nWe're using ColdFusion as the server-side processor, but it has failed us when handling uploads beyond about 1GB and we've exhausted our configuration options. There's a long story behind that, but essentially, if a .cfm page (ColdFusion) is the destination of the file upload and it goes over about 1GB, it gives a 503 error... even if the target file doesn't exist. So clearly too much is going on merely by telling the server that we intend to process the file with a .cfm page.\nWe suspect that this is due to Java limitations because the server (or really, the workstation in this case) does not show any signs of load on CPU or memory. Since we have limited memory and this website is intended for  a lot of concurrent uploads, we can't trust simply raising the virtual machine memory usage, especially because that simply doesn't work currently, even for a single connection... let alone the hundreds of concurrent connections we expect when we go live.\nSo we're down to writing a specialized solution using CGI that will handle file uploads only. Basically, we need control on the server-side that we don't get with ColdFusion or ASP.NET because those technologies do so many things on their own, behind the scenes, without giving us the control we need. They always end up spending up too many resources one way or the other for an arguably obvious reason; what we're trying to do is completely insane and not the intended function of those technologies. That's why we want a specialized uploader through CGI that bypasses all that ColdFusion\/ASP.NET magic that keeps getting in the way, hoping it gives us the control we need.\nBut before we spent countless hours on this, I figured I'd ask around and see if anyone knows of a proper solution to this problem that might be viable in our case.\nThe only real restriction here is that it has to be CGI, and it has to run on IIS 7, therefore a Windows \"Server\" environment. We're fine with it being written in Python, Perl, name it... provided it can run as a CGI, but it has to run as a CGI... unless of course someone has better ideas on how to do this.\nSo the magic question is; are there CGI solutions out there that already do this or are we stuck with writing it on our own, hoping that the reason no one else has done it already is some other than it being impossible?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":300,"Q_Id":5479387,"Users Score":-1,"Answer":"the windows TCP stack is limited to 4GB file uploads. Anymore than that is not possible.","Q_Score":1,"Tags":"python,perl,iis,iis-7,cgi","A_Id":5479573,"CreationDate":"2011-03-29T21:52:00.000","Title":"Need CGI (or another solution compatible with IIS 7) to handle *massive* uploads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"We need to handle massive file uploads without spending resources on an IIS 7 server. To emphasize how light-weight this needs to be, let's say that we need to handle file uploads of sizes that are completely insane, like 100GB uploads, or something that can continue running for an extremely long time without consuming additional resources. Basically we need something that gives us control over the reception of the file from the moment it starts to the moment it ends.\nA bit of background:\nWe're using ColdFusion as the server-side processor, but it has failed us when handling uploads beyond about 1GB and we've exhausted our configuration options. There's a long story behind that, but essentially, if a .cfm page (ColdFusion) is the destination of the file upload and it goes over about 1GB, it gives a 503 error... even if the target file doesn't exist. So clearly too much is going on merely by telling the server that we intend to process the file with a .cfm page.\nWe suspect that this is due to Java limitations because the server (or really, the workstation in this case) does not show any signs of load on CPU or memory. Since we have limited memory and this website is intended for  a lot of concurrent uploads, we can't trust simply raising the virtual machine memory usage, especially because that simply doesn't work currently, even for a single connection... let alone the hundreds of concurrent connections we expect when we go live.\nSo we're down to writing a specialized solution using CGI that will handle file uploads only. Basically, we need control on the server-side that we don't get with ColdFusion or ASP.NET because those technologies do so many things on their own, behind the scenes, without giving us the control we need. They always end up spending up too many resources one way or the other for an arguably obvious reason; what we're trying to do is completely insane and not the intended function of those technologies. That's why we want a specialized uploader through CGI that bypasses all that ColdFusion\/ASP.NET magic that keeps getting in the way, hoping it gives us the control we need.\nBut before we spent countless hours on this, I figured I'd ask around and see if anyone knows of a proper solution to this problem that might be viable in our case.\nThe only real restriction here is that it has to be CGI, and it has to run on IIS 7, therefore a Windows \"Server\" environment. We're fine with it being written in Python, Perl, name it... provided it can run as a CGI, but it has to run as a CGI... unless of course someone has better ideas on how to do this.\nSo the magic question is; are there CGI solutions out there that already do this or are we stuck with writing it on our own, hoping that the reason no one else has done it already is some other than it being impossible?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":300,"Q_Id":5479387,"Users Score":3,"Answer":"You want WebDAV, not CGI. It provides all the nice bits that make file transfers not suck, like resuming and pausing.","Q_Score":1,"Tags":"python,perl,iis,iis-7,cgi","A_Id":5483933,"CreationDate":"2011-03-29T21:52:00.000","Title":"Need CGI (or another solution compatible with IIS 7) to handle *massive* uploads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Folks,\nMight find this on searching, but need this rather quickly done:\nI have the path like this: \/mnt\/path1\/path2\/path3\/\nI need to chown all the directories such as \/mnt, \/mnt\/path1, \/mnt\/path1\/path2, \/mnt\/path1\/path2\/path3, how to get this done in python?\nI cannot do 'chown -R \/mnt\/' since it tries to chown all the files\/directories that exist beneath path3, but I wish to chown only upto path3 here for example.\nThank you for any suggestions!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":292,"Q_Id":5479897,"Users Score":1,"Answer":"You need to use the os.path library. If you start off with directory d then os.path.abspath(os.path.join(d, '..')) will return that directory's parent. You do this until you get to \/mnt, for each directory running chown on it.","Q_Score":1,"Tags":"python","A_Id":5479995,"CreationDate":"2011-03-29T22:56:00.000","Title":"Python: How to do this string manipulation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just noticed that when I have a running instance of my GAE application, there nothing happens with the datastore file when I add or remove entries using Python code or in admin console. I can even remove the file and still have all data safe and sound in admin area and accessible from code. But when I restart my application, all data obviously goes away and I have a blank datastore. So, the question - does GAE reads all data from the file only when it starts and then deals with it in the memory, saving the data after I stop the application? Does it make any requests to the datastore file when the application is running? If it doesn't save anything to the file while it's running, then, possibly, data may be lost if the application unexpectedly stops? Please make it clear for me if you know how it works in this aspect.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":5484900,"Users Score":3,"Answer":"How the datastore reads and writes its underlying files varies - the standard datastore is read on startup, and written progressively, journal-style, as the app modifies data. The SQLite backend uses a SQLite database.\nYou shouldn't have to care, though - neither backend is designed for robustness in the face of failure, as they're development backends. You shouldn't be modifying or deleting the underlying files, either.","Q_Score":0,"Tags":"python,google-app-engine,local-storage","A_Id":5486121,"CreationDate":"2011-03-30T10:09:00.000","Title":"Does local GAE read and write to a local datastore file on the hard drive while it's running?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The python-couchdb package ( used as import couchdb ) provides a db.view() function to access a couchdb \"_view\", but how do you access a \"_show\" or \"_list\" function?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":429,"Q_Id":5491851,"Users Score":4,"Answer":"I just added show\/list support to couchdb-python. Any problems, please use the mailing list.","Q_Score":2,"Tags":"python,couchdb","A_Id":5498961,"CreationDate":"2011-03-30T20:19:00.000","Title":"CouchDB and Python: how to use \"_show\" and \"_list\" functions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"lets say that some files were renamed by Python script, is it possible to get this 'rename time' using Python (It can be seen in Far Manager)? (Windows)\nIt seems it is not possible through STAT, etc\nAny ideas ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":239,"Q_Id":5498704,"Users Score":0,"Answer":"It is impossible, OS does not store such info about files. Answered by 'atzz' in comment","Q_Score":0,"Tags":"python,file-management","A_Id":5631968,"CreationDate":"2011-03-31T10:54:00.000","Title":"python file was renamed, how to get 'rename time'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I am trying to do is that I want to read a file using python, and then with the data in the file, create a variable in c\/c++(I don't want to read var from the file :) ).\nIs this possible?\nIf this is possible, then how would you do it?\nThank you guys!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5001,"Q_Id":5502787,"Users Score":2,"Answer":"Yes. Open the first file in Python, process it and save the results to a second file.\nThen open the second file in your C or C++ program and use the data.","Q_Score":3,"Tags":"c++,python,c,connection,io","A_Id":5502815,"CreationDate":"2011-03-31T16:01:00.000","Title":"connecting c\/c++ and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just a quick question,\nCould someone link me to the documentation for the use of @ in python?\nDue not being able to google @ and not knowing the use or name of it I'm not sure how to find it on my own :)\nMany thanks!!","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":366,"Q_Id":5514330,"Users Score":2,"Answer":"Google for python decorator and you will find enough answers to your question.","Q_Score":1,"Tags":"python","A_Id":5514359,"CreationDate":"2011-04-01T13:51:00.000","Title":"Python documentation for @?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on an academic project aimed at studying people behavior.\nThe project will be divided in three parts: \n\nA program to read the data from some remote sources, and build a local data pool with it.\nA program to validate this data pool, and to keep it coherent \nA web interface to allow people to read\/manipulate the data.\n\nThe data consists of a list of people, all with an ID #, and with several characteristics: height, weight, age, ... \nI need to easily make groups out of this data (e.g.: all with a given age, or a range of heights) and the data is several TB big (but can reduced in smaller subsets of 2-3 gb).\nI have a strong background on the theoretical stuff behind the project, but I'm not a computer scientist. I know java, C and Matlab, and now I'm learning python.\nI would like to use python since it seems easy enough and greatly reduce the verbosity of Java. The problem is that I'm wondering how to handle the data pool.\nI'm no expert of databases but I guess I need one here. What tools do you think I should use? \nRemember that the aim is to implement very advanced mathematical functions on sets of data, thus we want to reduce complexity of source code. Speed is not an issue.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1451,"Q_Id":5529075,"Users Score":3,"Answer":"Go with a NoSQL database like MongoDB which is much easier to handle data in such a case than having to learn SQL.","Q_Score":4,"Tags":"python,large-data,database","A_Id":5529194,"CreationDate":"2011-04-03T10:38:00.000","Title":"Handle large data pools in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a little parser using HTMLparser and I would like to know where a link is redirected. I don't know how to explain this, so please look this example:\nOn my page I have a link on the source: http:\/\/www.myweb.com?out=147, which redirects to http:\/\/www.mylink.com. I can parse http:\/\/www.myweb.com?out=147 without any problems, but I don't know how to get http:\/\/www.mylink.com.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":8180,"Q_Id":5538280,"Users Score":3,"Answer":"You can not get hold of the redirection URL through parsing the HTML source code. \nRedirections are triggered by the server and NOT by the client. You need to perform a HTTP request to the related URL and check the HTTP response of the server - in particular for the HTTP status code 304 (Redirection) and the new URL.","Q_Score":6,"Tags":"python,parsing,redirect","A_Id":5538415,"CreationDate":"2011-04-04T12:14:00.000","Title":"Determining redirected URL in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a bit of trouble finding a guide that allows me to integrate the Boost.Python compilation into VS 8.  It seems like it depends heavily on this bjam utility to build the source, but there isn't any mention of how this can integrate into VS 8 interface.\nI can see that the bjam program calls VS 8 to do much of the compilation.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1049,"Q_Id":5553798,"Users Score":3,"Answer":"bjam is used for compiling boost itself (although your can use it as configuration tool for your code aswell). Running the utility should compile the library and does not require any further work, afaik.\nThe include and library paths you have listed in your second post are correct, as far as I can tell (assuming the path to the directories you listed is correct, e.g: C:\\Python27\\include).\nWhile I was playing around with boost.python, I found out I was not able to compile any C++\/Python libraries with a 64 bit version of Python installed. I first had to remove the 64 bit version and install the 32 bit version.\nAlso the compilation was only successful if I included #define BOOST_PYTHON_STATIC_LIB before the #include statements. I still have not figured out why.\nI hope my answer (my first one ever on this site, so don't be too harsh with me ;) ) was of any use.","Q_Score":4,"Tags":"c++,python,boost","A_Id":5951300,"CreationDate":"2011-04-05T14:46:00.000","Title":"Integrating Boost.Python with Visual Studio 8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a bit of trouble finding a guide that allows me to integrate the Boost.Python compilation into VS 8.  It seems like it depends heavily on this bjam utility to build the source, but there isn't any mention of how this can integrate into VS 8 interface.\nI can see that the bjam program calls VS 8 to do much of the compilation.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1049,"Q_Id":5553798,"Users Score":0,"Answer":"I found the issue, thanks for the suggestion Phillip.  It turns out I just needed to provide the correct header and library directories to VS 8 and compile as a DLL (not a console program).\nInclude Directories:\n\n\\boost-python\\boost_1_46_1\n\\Python27\\include`\n\nLibrary Directories:\n\n\\Python27\\libs\n\\boost-python\\boost_1_46_1\\stage\\lib`\n\nCan anyone confirm these are the right directories to be used for including and linking?","Q_Score":4,"Tags":"c++,python,boost","A_Id":5556549,"CreationDate":"2011-04-05T14:46:00.000","Title":"Integrating Boost.Python with Visual Studio 8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python 2.5 came installed on my Mac. I downloaded Python 3.2 and have it running in my IDE.  When I open the terminal in Mac and type in Python, it tells me I'm working with 2.5.\n1) What do I enter in the command line to change from 2.5 to 3.2? \n2) Once I get to 3.2 (using your answer), how do I get back to 2.5 if I want to?\nThanks for your help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3806,"Q_Id":5568330,"Users Score":5,"Answer":"You can simply type python3.2 instead of just python to use python 3.2.","Q_Score":6,"Tags":"python,macos","A_Id":5568374,"CreationDate":"2011-04-06T14:48:00.000","Title":"Changing versions of Python in command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing an application which has to be able to print a couple of pages with Python. Now I am searching for a method to create these pages and print them. It should work on Linux and Windows. The pages contain tables, images and text.\nI developed the GUI with PyGtk, but I think it's convenient to create an image or PDF and print it. I have no idea how to do this. Anyone knows a good way for this?\nNote: The problem isn't the generation. It is the printing of that file.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2696,"Q_Id":5572489,"Users Score":1,"Answer":"Have you considered generating HTML?","Q_Score":2,"Tags":"python,pdf,printing,pygtk","A_Id":5572506,"CreationDate":"2011-04-06T20:22:00.000","Title":"OS independent printing with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm supplying a Django project to a client, who has requested a 'debugging' page that will show useful information. \n[UPDATE for clarity: We'd like this page so we can use it for debugging in future: the clients are not very technical and I won't have direct access to their servers. In the event of future issues, it would be very useful if I could check out this page without asking them to edit the Debug setting or do any other server-side fiddling.]\nThe project will be running in production, so I can't set DEBUG=True.\nWhat I would like is a page similar to the Django debugging page but without any sensitive information in.\nI guess I can simply write my own, but does anyone have any ideas? Anything standard in Django I could use?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":94,"Q_Id":5581005,"Users Score":1,"Answer":"You can use Django Debug Toolbar and enable it only for choosen IPs","Q_Score":1,"Tags":"python,django","A_Id":5581104,"CreationDate":"2011-04-07T12:28:00.000","Title":"Add a debugging page to a Django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a table like so - \n\nCREATE TABLE trial_xml (\nid int(11) DEFAULT NULL,\npid int(11) DEFAULT NULL,\nsid varchar(256) CHARACTER SET utf8 NOT NULL,\ndata blob,\n  PRIMARY KEY (soid), \n  KEY suid_index (suid) )\n  ENGINE=MyISAM DEFAULT CHARSET=latin1\n\nmy question is how do I set \"data\" field as \"blob\" in django's models.py ??\nI mean what's the syntax? \nUPDATE: I dont want to set data field as longtext. I want only blob datafield.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4606,"Q_Id":5581466,"Users Score":1,"Answer":"Django's ORM has no field for binary large objects. Either use something like a FileField, or search for candidate field classes using a search engine.","Q_Score":2,"Tags":"python,mysql,django,django-models,django-blob","A_Id":5581586,"CreationDate":"2011-04-07T12:59:00.000","Title":"Django models \"blob\" field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know similar questions have been asked, but this is kind of a trivial case.\nGiven a text file endcoded with a substitution cipher, I need to decode it using python. I am not given any examples of correctly deciphered words. The relationship is 1-to-1 and case doesn't make a difference. Also, punctuation isn't changed and spaces are left where they are. I don't need help with the code as much as I need help with a general idea of how this could be done in code. My main approaches involve:\n\nNarrowing down the choices by first solving 1, 2 or 3 character words.\nI could use an list of English words of different sizes to compare.\nI could use frequency distributions of the letters.\n\nDoes anyone have an idea of a general approach I could take to do this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6917,"Q_Id":5587280,"Users Score":1,"Answer":"I would first get a list of English words for reference.  Next construct a list of possible 2 and 3 letter words.  Then just start testing those small words in your cipher.  Once you guess at a small word, check the larger words against your word list.  If some of the words no longer have possible completions in the list, you're on the wrong track.  If a word only has one possible completion, accept it as correct and continue.  Eventually, you'll either reach a solution where all words are in your English word list, or you'll reach a point where there is no solution for a word.","Q_Score":1,"Tags":"python,substitution,encryption","A_Id":5587409,"CreationDate":"2011-04-07T20:34:00.000","Title":"Solving a substitution cipher with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am reading Chapter 3 of \"Practical Django Projects\", on how to make a CMS. I have improved the search function and everything works fine. However I am wondering why everythings works...\nOn page 35, I have added an admin.py file in the cms\/search\/ directory. How does the compiler know that he needs to take this file into account ?\nOn page 36-37, there is an improved version of the cms\/search\/models.py. It seems that the new file adds not just 1 keyword, but 3 ! How come ?\nThanks a lot","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":179,"Q_Id":5588081,"Users Score":0,"Answer":"If you are calling admin.autodiscover() in your urls.py Django's admin.site will be looking for admin.py files in all packages of your INSTALLED_APPS and import all found ModelAdmin classes and add them to the admin.site.\nYou have three inputs for SearchKeyword appearing in the admin because the there are three InlineAdmin's added.","Q_Score":0,"Tags":"python,django","A_Id":5588180,"CreationDate":"2011-04-07T21:50:00.000","Title":"\"Practical Django Projects\" - Search function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I make a PHP 5.3 webserver using Python? \nI know how to make a simple HTTP server, but how can I include PHP?\nThanks.","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":1908,"Q_Id":5591230,"Users Score":-3,"Answer":"After some clarifications at last it came clear that your question was\n\"how to connect PHP to HTTP server\"\nSo, actually you were interested in three letters: CGI.\nHowever I still doubt you will get any good from it.","Q_Score":1,"Tags":"php,python","A_Id":5591381,"CreationDate":"2011-04-08T06:20:00.000","Title":"PHP Webserver in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to randomly pick all the results, one by one (no repeats) from itertools.permutations(k)? Or this: how to build a generator of randomized permutations? Something like shuffle(permutations(k)).  I\u2019m using Python 2.6.\nYeah, shuffle(r) could be used if r = list(permutations(k)), but such a list will take up too much time and memory when len(k) raises above 10.\nThanks.","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4221,"Q_Id":5602488,"Users Score":2,"Answer":"I don't know how python implements its shuffle algorithm, but the following scales in linear time, so I don't see why a length of 10 is such a big deal (unless I misunderstand your question?):\n\nstart with the list of items;\ngo through each index in the list in turn, swapping the item at that index it for an item at a random index (including the item itself) in the remainder of the list.\n\nFor a different permutation, just run the same algorithm again.","Q_Score":3,"Tags":"python,permutation,random-sample","A_Id":5602512,"CreationDate":"2011-04-09T02:22:00.000","Title":"Random picks from permutation generator?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to randomly pick all the results, one by one (no repeats) from itertools.permutations(k)? Or this: how to build a generator of randomized permutations? Something like shuffle(permutations(k)).  I\u2019m using Python 2.6.\nYeah, shuffle(r) could be used if r = list(permutations(k)), but such a list will take up too much time and memory when len(k) raises above 10.\nThanks.","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4221,"Q_Id":5602488,"Users Score":2,"Answer":"There's no way of doing what you have asked for without writing your own version of permutations.\nConsider this:\n\nWe have a generator object containing the result of permutations.\nWe have written our own function to tell us the length of the generator.\nWe then pick an entries at random between the beginning of the list and the end.\n\nSince I have a generator if the random function picks an entry near the end of the list the only way to get to it will be to go through all the prior entries and either throw them away, which is bad, or store them in a list, which you have pointed out is problematic when you have a lot of options.\nAre you going to loop through every permutation or use just a few?  If it's the latter it would make more sense to generate each new permutation at random and store then ones you've seen before in a set.  If you don't use that many the overhead of having to create a new permutation each time you have a collision will be pretty low.","Q_Score":3,"Tags":"python,permutation,random-sample","A_Id":5603207,"CreationDate":"2011-04-09T02:22:00.000","Title":"Random picks from permutation generator?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering if anyone has experienced problems with Google-App Engine's logging facility. Everything was working fine for me until this morning, I ran my local server and no logging messages were being displayed (well, none of my logging messages, the server GET messages etc.. are being displayed). Even errors are not being reported. I have no idea what is going on.\nIf this has happened to anyone, can you please advise on how to fix it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":252,"Q_Id":5612390,"Users Score":0,"Answer":"Thanks Abdul you made me realize what the problem is. I had changed a URL in my application to point to the application that I had deployed to Google-App Engine. It should have been pointing to my local application. I had myapp.appspot.com\/move instead of localhost\/move","Q_Score":1,"Tags":"python,django,google-app-engine","A_Id":5612643,"CreationDate":"2011-04-10T14:24:00.000","Title":"Google-App Engine logging problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can i change character encoding of a string to UTF-8? I am making some execv calls to a python program but python returns the strings with the some characters cut of. I don't know if this a python issue or c issue but i thought if i can change the strings encoding in c and then pass it to python, it should do the trick. So how can i do that?\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1560,"Q_Id":5614372,"Users Score":3,"Answer":"C as a language does not facilitate string encoding.  A C string is simply a null-terminated sequence of characters (8-bit signed integers, on most systems).\nA wide string (with characters of type wchar_t, typically 16-bit integers) can also be used to hold larger character values; however, again, C standard library functions and data types are in no way aware of any concept of string encoding.\nThe answer to your question is to ensure that the strings you're passing into Python are encoded as UTF-8.\nIn order to help you accomplish that in any detailed capacity, however, you will have to provide more information about how your strings are currently formed, what they contain, and how you're constructing your argument list for exec.","Q_Score":0,"Tags":"python,c,encoding","A_Id":5614405,"CreationDate":"2011-04-10T20:07:00.000","Title":"How to change a strings encoding as utf 8 in C","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python code which imports dll's created by f2py (from fortran routines). Now the python program crashes if the arrays in fortran are too large. How do I manage with this? By increasing stack size? Or heap? I've tried to study the matter, but I still do not understand how I can increase the stack or should I use the heap instead and how I should do that..??? Python always crashes on the line where I try to import the dll, i.e., at line \"import f90_routine\". Someone also mentioned threads, but I do not know how to use them. Hope someone can help me!!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":295,"Q_Id":5617641,"Users Score":2,"Answer":"Your basic problem is that you are storing large arrays of data on the stack. This is bad design and is probably due to the way the Fortran code is implemented.\nLarge arrays need to be stored on the heap and dynamically allocated there.  To solve this problem you will need to understand and modify your Fortran code accordingly.\nThe ALLOCATE keyword is how you create heap allocated data in Fortran 90.  However, many compilers have options that for arrays to be allocated on the heap and that may be the most expedient route for you right now.","Q_Score":0,"Tags":"python,fortran","A_Id":5618401,"CreationDate":"2011-04-11T06:40:00.000","Title":"dll load error in python due to insufficient stack size?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"According to the documentation from python.org, python 3.2 install on mac os requires an upgrade to tcl\/tk 8.5.9 (for use of IDLE). In my haste, I have done both. Now my friend told me that python 3 is not recommended yet because only the built-ins and a few modules have been released for 3. The stable one so far is 2.7 (especially if one wants to make extensive use of a variety of modules). My machine has both 2.6.1 and 3.2 (because some OS services make use of 2.6.1 that comes as default with the OS).\n1. How do i remove 3.2 completely to avoid any compatibility issues?\ntcl\/tk 8.5.9 was also installed and this is not the default. There was no verbose mode during installation, so I don't know whether it replaced the default one. If it did how bad can it be for the OS? and hence\n2. If the above is really bad, how do i downgrade to the old version of tcl\/tk?\nIn short, how do i bring my machine back to its original state? If anyone knows all the paths to the directories and files I can do it manually.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":19603,"Q_Id":5621952,"Users Score":0,"Answer":"just uninstall 3x version of python if you have already installed it. Eclipse  has that option when you click \"see whats already installed\". \nInstall later 2.7 version. It works for me on my OS X 10.9.2 with Eclipse Juno.","Q_Score":10,"Tags":"macos,uninstallation,python-3.2","A_Id":23726032,"CreationDate":"2011-04-11T13:20:00.000","Title":"Uninstall python 3.2 on mac os x 10.6.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"According to the documentation from python.org, python 3.2 install on mac os requires an upgrade to tcl\/tk 8.5.9 (for use of IDLE). In my haste, I have done both. Now my friend told me that python 3 is not recommended yet because only the built-ins and a few modules have been released for 3. The stable one so far is 2.7 (especially if one wants to make extensive use of a variety of modules). My machine has both 2.6.1 and 3.2 (because some OS services make use of 2.6.1 that comes as default with the OS).\n1. How do i remove 3.2 completely to avoid any compatibility issues?\ntcl\/tk 8.5.9 was also installed and this is not the default. There was no verbose mode during installation, so I don't know whether it replaced the default one. If it did how bad can it be for the OS? and hence\n2. If the above is really bad, how do i downgrade to the old version of tcl\/tk?\nIn short, how do i bring my machine back to its original state? If anyone knows all the paths to the directories and files I can do it manually.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":19603,"Q_Id":5621952,"Users Score":4,"Answer":"I did the same (3.2 on a mac 10.6) and:\n-Moved both the Python 3.2 folder and the ActiveState ActiveTcl folder from the Applications Folder to the Trash.\n-Moved the Python.framework folder from the Library\/Frameworks folder to the Trash.\nRunning System profiler shows only the 2.6 version of Python.\nMarcos","Q_Score":10,"Tags":"macos,uninstallation,python-3.2","A_Id":5627279,"CreationDate":"2011-04-11T13:20:00.000","Title":"Uninstall python 3.2 on mac os x 10.6.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to have a set of models just for testing purposes? The idea is that I've written an app that contains some helper abstract model HelperBase. Now I'd like to provide some models that would inherit from it in order to test it, say DerivedTest1, DerivedTest2. However I wouldn't really like those test models to appear in the production database in the end. I just want their tables to be constructed in the test database. Is it possible and if so - how to do it? I've already tried creating models in the tests.py file but this doesn't seem to work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":292,"Q_Id":5626672,"Users Score":0,"Answer":"You could try creating a whole new app that you only use on your development server.\nE.g., if your app is called myapp you would call your testing app myapp_test.\nThen in myapp_test's models.py you would from myapp import models and then subclass your models in there.\nThen in your settings.py you either just try and remember to comment out the myapp_test application from INSTALLED_APPS when deploying to your production server. Or you can use the local_settings.py methodology to only have the myapp_test included in INSTALLED_APPS on your test machine.","Q_Score":1,"Tags":"python,django,testing,django-models,django-testing","A_Id":5626840,"CreationDate":"2011-04-11T19:46:00.000","Title":"Test specific models in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Scrapy and Python (as part of a Django project) to scrape a site with German content. I have libxml2 installed as the backend for Scrapy selectors. \nIf I extract the word 'H\u00fcftsitz' (this is how it is displayed on the site) through selectors, I get: u'H\\ufffd\\ufffdftsitz' (Scrapy XPath selectors return Unicode strings). \nIf I encode this into UTF-8, I get: 'H\\xef\\xbf\\xbd\\xef\\xbf\\xbdftsitz'. And if I print that, I get 'H??ftsitz' which isn't correct. I am wondering why this may be happening.\nThe character-set on the site is set to UTF-8. I am testing the above on a Python shell with sys.getdefaultencoding set to UTF-8. Using the Django application where the data from XPath selectors is written to a MySQL database with UTF-8 character set, I see the same behaviour. \nAm I overlooking something obvious here? Any clues or help will be greatly appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":15989,"Q_Id":5627868,"Users Score":1,"Answer":"U+FFFD is the replacement character that you get when you do some_bytes.decode('some-encoding', 'replace') and some substring of some_bytes can't be decoded.\nYou have TWO of them: u'H\\ufffd\\ufffdftsitz' ... this indicates that the u-umlaut was represented as TWO bytes each of which failed to decode. Most likely, the site is encoded in UTF-8 but the software is attempting to decode it as ASCII. Attempting to decode as ASCII usually happens when there is an unexpected conversion to Unicode, and ASCII is used as the default encoding. However in that case one would not expect the 'replace' arg to be used. More likely the code takes in an encoding and has been written by someone who thinks \"doesn't raise an exception\" means the same as \"works\".\nEdit your question to provide the URL, and show the minimum code that produces u'H\\ufffd\\ufffdftsitz'.","Q_Score":3,"Tags":"python,django,unicode,utf-8,scrapy","A_Id":5628065,"CreationDate":"2011-04-11T21:37:00.000","Title":"Unicode and UTF-8 encoding issue with Scrapy XPath selector text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a Digi 3G router that can be programmed with python, and I want it to make periodic SSH connections to another device. I've read everything about paramiko, but don't know how to install it in the router.\nI want to know if there is any other way of including paramiko into a device, apart from installing (i.e. including some library), or if it exist another possibility apart from paramiko for this particular case.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":5636251,"Users Score":0,"Answer":"The description for the Digi 3G states that it is capable of python scripting, using a custom development environment.  To make this work, you would have to use the python source code from paramiko; the executable would not be installable directly on the router (since the executable is designed to be run on a computer, not a router).  \nThe source code would probably have to be  modified, since the APIs for this sort of thing are most likely different than those in a computer, and the router would have to be capable of what you are asking of it.","Q_Score":0,"Tags":"python","A_Id":5639270,"CreationDate":"2011-04-12T13:47:00.000","Title":"SSH connection with python from a device (not computer)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a relative newbie with Python and was trying to install wxPython 2.9 using Python 2.6. I did a build from source and then installed the package both being done in a non-standard (local) path. When I try and import wx (having provided the path to the installation folder in my environment variable), I get the following error message:  \n\n\"ImportError:\n  libwx_gtk2u_xrc-2.9.so.1: cannot open\n  shared object file: No such file or\n  directory\".  \n\nCan someone please tell me if I need to build gtk separately? And if yes, how do I go about doing it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":380,"Q_Id":5660354,"Users Score":0,"Answer":"Add the directory containing the library given in the error to your ld search paths. See the ldconfig(8) man page for details.","Q_Score":0,"Tags":"python,gtk,wxpython","A_Id":5660469,"CreationDate":"2011-04-14T08:14:00.000","Title":"Error while installing wxPython package in a non-standard path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have the task of packaging and shipping a commercial application bundle, which will include:\n\na python library (developed by us)\nsome python programs depending on the library above\nadditional libraries not developed by us, but which are dependencies of our library.\na complete python installation (python 2.6)\nadditional stuff, libs and programs in other languages. Not a concern here, as they are not hooked into the above machinery, and the current shipping process works already.\n\nThe bundle is shipped to Linux, OSX and Windows. On Linux, it's distributed as a simple tar.gz. The user just unpacks the tar.gz and source a provided bash script in .bashrc, so that the environment is correctly set. On mac, it's a dmg. On windows, I have no idea. The windows guy is not here today, but what I see is that an exe is created somehow.\nI will now explain in more detail the above points.\nOur Python Library\nWe don't want to give out sources, so we want to provide only compiled python files. A better strategy to make them even more tamper-proof is welcome, even if it involves some deep hacking (e.g. I once saw magic done importing stuff from a .zip which was \"corrupted\" ad-hoc). The library at the moment does not have C level code or similar platform dependent code, but this is going to change soon. We will therefore have to provide platform-specific compiled .so together with the pyc.\nClearly, this library will be shipped in the package, together with the rest of our application. It will therefore be installed on the downloaded bundle. For this reason, it must be fully relocatable, and the user must in some way (either manually or via our env script) add the location of the untarred package to PYTHONPATH, so that the interpreter can find it.\nOur Python Programs\nWe will ship applications in our bundle, and these applications will depend on our library. The code of these applications must be either visible by the user (so that he can learn how to use the library interface), or not visible (for those utilities we want to keep closed-source), so a double approach is called for.\nAdditional Libraries\nOur library depends on 3rd party libraries we will have to ship, so that the user is up and running without any dependency hunting. Clearly, these libraries will be installed by us in the bundle, but we must hope these don't store the install path somewhere during the build, because that would make them non relocatable.\nOur python\nWe will ship our version of python, which we assume the user will run in order to access our script. This is because we want to be sure of the python version running. Also, we may tinker a bit the executable or the standard library. We may have a concern about the interaction of this python with the standard python, and if the user wants a specific library on our python it will have to install it within our bundled package, and not on the standard place for libraries.\nRequest\nI need to make my mind around this task. I've seen it done, but never done it personally, so I need your point of view. What I presented above is how I think things should work, according to how things are working right now, but it may be wrong. Any hint, quirk, suggestion, or strategy for a successful deployment is welcome. Given the complexity of the question, I already announce a high bounty on it, according to the best answer I can get.","AnswerCount":9,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":8155,"Q_Id":5661385,"Users Score":3,"Answer":"This will vary depending on your target market.  In specialized niche industries there is more variety in how stuff is distributed.  In heavily commoditized areas I would expect native OS package (at least if I were a customer).  I tend to take the quality of the deployment package as indicative of the quality of the software in general. I associate native OS packages as higher quality than other formats largely because the dependency information can be complete.  This makes it easier to do some compliance testing and change management.\nNative OS Packages\n\nFor Unices consider creating native OS packages. They provide better integration and visibility with processes like compliance, change management, dependency management, etc. \nFor OSX others have already suggested py2app.  You may also be able to leverage MacPorts package format or the Fink package format.\nFor Windows others have already suggested py2exe. \n\nRelocation and Config Requirements\n\nPut your Python executable under ...\/libexec.  This prevents it from accidentally being called.\nChange the name of the Python executable to prevent confusion.  ie. \/usr\/local\/libexec\/<pkg>_python\nDistribute the .py for the bins to make them easily relocatable. You can change the Magic Cookie at install time to whatever the location your Python was installed in via an install script.  The only code you need in the bin is a line that calls into your lib which is a pyc.\nInstall your libs in the correct location under \/usr\/local\/lib\/app_python\/site_package\/... and you won't need to use PYTHONPATH.\n\nShared Libraries\n\nIf I remember correctly you'll want to make sure you strip any rpath entries from the libs as this can mess with their ability to be relocated.\nThe native OS packaging should help with any dependencies the shared libs require.","Q_Score":37,"Tags":"python","A_Id":5733166,"CreationDate":"2011-04-14T09:49:00.000","Title":"Packaging and shipping a python library and scripts, the professional way","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the task of packaging and shipping a commercial application bundle, which will include:\n\na python library (developed by us)\nsome python programs depending on the library above\nadditional libraries not developed by us, but which are dependencies of our library.\na complete python installation (python 2.6)\nadditional stuff, libs and programs in other languages. Not a concern here, as they are not hooked into the above machinery, and the current shipping process works already.\n\nThe bundle is shipped to Linux, OSX and Windows. On Linux, it's distributed as a simple tar.gz. The user just unpacks the tar.gz and source a provided bash script in .bashrc, so that the environment is correctly set. On mac, it's a dmg. On windows, I have no idea. The windows guy is not here today, but what I see is that an exe is created somehow.\nI will now explain in more detail the above points.\nOur Python Library\nWe don't want to give out sources, so we want to provide only compiled python files. A better strategy to make them even more tamper-proof is welcome, even if it involves some deep hacking (e.g. I once saw magic done importing stuff from a .zip which was \"corrupted\" ad-hoc). The library at the moment does not have C level code or similar platform dependent code, but this is going to change soon. We will therefore have to provide platform-specific compiled .so together with the pyc.\nClearly, this library will be shipped in the package, together with the rest of our application. It will therefore be installed on the downloaded bundle. For this reason, it must be fully relocatable, and the user must in some way (either manually or via our env script) add the location of the untarred package to PYTHONPATH, so that the interpreter can find it.\nOur Python Programs\nWe will ship applications in our bundle, and these applications will depend on our library. The code of these applications must be either visible by the user (so that he can learn how to use the library interface), or not visible (for those utilities we want to keep closed-source), so a double approach is called for.\nAdditional Libraries\nOur library depends on 3rd party libraries we will have to ship, so that the user is up and running without any dependency hunting. Clearly, these libraries will be installed by us in the bundle, but we must hope these don't store the install path somewhere during the build, because that would make them non relocatable.\nOur python\nWe will ship our version of python, which we assume the user will run in order to access our script. This is because we want to be sure of the python version running. Also, we may tinker a bit the executable or the standard library. We may have a concern about the interaction of this python with the standard python, and if the user wants a specific library on our python it will have to install it within our bundled package, and not on the standard place for libraries.\nRequest\nI need to make my mind around this task. I've seen it done, but never done it personally, so I need your point of view. What I presented above is how I think things should work, according to how things are working right now, but it may be wrong. Any hint, quirk, suggestion, or strategy for a successful deployment is welcome. Given the complexity of the question, I already announce a high bounty on it, according to the best answer I can get.","AnswerCount":9,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8155,"Q_Id":5661385,"Users Score":15,"Answer":"This is not a complete answer but just a bunch of ideas. I wrote an installer for a client that incorporated some ideas that might be useful to you. \nIt was Linux only so I focussed on just that. We needed to ship specific custom versions of mySQL, lighttpd, python, memcached, a few 3rd party Python modules and some custom scripts. We needed to launch all these services without any problems and let the user control them using regular initscripts. It should work fine on a bunch of popular distros and therefore shouldn't rely on distro specific stuff. \nWhat I did was as follows. \n\nCreated a 500MB (I'm don't recollect the size) file and formatted it as an ext3fs file system.\nMounted it at a point using a loopback device. \nRan deb-bootstrap on the mountpoint to create a custom Debian install.\nChrooted inside the partition and then ran a bunch of scripts which did an apt-get install on all our dependencies, installed all the eggs and other packages which were necessary for the app, installed the app itself in \/opt (inside the chroot), installed supervisord (to do process management) and set things up. Now, this partition was a completely self contained Linux filesystem that contained the application and everything needed to run it. You could dump it anywhere, chroot inside it and launch the app. The only dependency it had with the outside world were the ports it would use for its services and the supervisord control socket. This was the main point. We were able to include exactly what we needed (compiled files, .pycs only etc.) for a few of the applications and didn't have to bother with any limitations in standard installation tools. \nAfter this, we packaged a few extra scripts that would go into the external operating system. These were custom made for each distro that we would have to support. This part was distro specific. There were scripts that would go into \/etc\/init.d and some scripts that would setup the database and stuff at the beginning. \nWe then created an archive of the entire filesystem using makeself. It would checksum stuff and all that and provide a self extracting archive which if run would untar the whole thing into \/opt on the host machine, chroot inside the directory and run a setup script that would ask the user a few questions like db username\/password etc. and set things up. After that, it would fetch the scripts I mentioned in step 5 and put them on the host OS.\n\nThe initscripts would simply chroot into the partition and start supervisord. It would then take care of launching all the services we cared about. Shutting down the application was simply a matter of connecting to running supervisord and running a command. We wrapped this in the initscript so that the user experience was UNIX like. \nNow, we'd give clients the self extracting .run file. They'd run it, get asked a few questions and it would create a directory under \/opt which contained our app and all it's dependencies. The init scripts would be modified to start our app on bootup and things would work as expected.\nI think step 4 gives you the freedom to install whatever you want, however you want so that things would work fine.","Q_Score":37,"Tags":"python","A_Id":5731719,"CreationDate":"2011-04-14T09:49:00.000","Title":"Packaging and shipping a python library and scripts, the professional way","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of redesigning\/refactoring my Python quantum chemistry package (pyquante). One of the things I don't like about the existing release is that I have to install the package to run the test suite. That is, the test suite has statements like from PyQuante import SCF, and, of course, this PyQuante could refer to the installed version or a local version.\nI know about virtualenv, and realize this is an option for me. But I was wondering whether anything else might be appropriate. In the past I've hacked sys.path for things like this, and have been told by better Python programmers that I shouldn't ever to this.\nDoes anyone have any suggestions for how I can do this? The point is that I want to test the current version of the code without installing it. \nThanks in advance for anyone who can see through my babbling and offer suggestions!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":10868,"Q_Id":5677809,"Users Score":1,"Answer":"Altering sys.path much in production environment may be unwise. Altering it for testing is usually OK. \nIf you don't want to tinker with the variable from sys, use an environment variable named PYTHONPATH, it's a clean and documented way.","Q_Score":20,"Tags":"python,testing","A_Id":5677921,"CreationDate":"2011-04-15T13:54:00.000","Title":"How can I test my python module without installing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of redesigning\/refactoring my Python quantum chemistry package (pyquante). One of the things I don't like about the existing release is that I have to install the package to run the test suite. That is, the test suite has statements like from PyQuante import SCF, and, of course, this PyQuante could refer to the installed version or a local version.\nI know about virtualenv, and realize this is an option for me. But I was wondering whether anything else might be appropriate. In the past I've hacked sys.path for things like this, and have been told by better Python programmers that I shouldn't ever to this.\nDoes anyone have any suggestions for how I can do this? The point is that I want to test the current version of the code without installing it. \nThanks in advance for anyone who can see through my babbling and offer suggestions!","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":10868,"Q_Id":5677809,"Users Score":6,"Answer":"I would honestly insist on using virtualenv, its designed for this exact reason in mind. very small overhead, and if you ever mess up just delete directory. I am sure as you grow, things won't be as simple as they are now for your current situation. Take it as an opportunity to learn.","Q_Score":20,"Tags":"python,testing","A_Id":5678267,"CreationDate":"2011-04-15T13:54:00.000","Title":"How can I test my python module without installing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have around 250 identical linux server which runs a business critical web application for a bank. Basically we do a lot of scripting work but now i want to centralize that only in one location. That means run on one server and and deploy it in many. I know you guys must be thinking that this is an easy task and can be done with a shell script. But again we need to create many different different scripts to do our work\nI know python has a big library and this can be possible but i dont know how. To cut in short i need all scripts in one file and based on the argument it will execute it according.\nFor example in a python program we have a function where we can mix them to perform different result.\nSo you please let me know how to go about it","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":304,"Q_Id":5679203,"Users Score":0,"Answer":"You could also try any of the distributed computing packages.  Pyro is one of them that might interest you.","Q_Score":1,"Tags":"python,django,linux,fabric","A_Id":5680308,"CreationDate":"2011-04-15T15:44:00.000","Title":"Python scripting in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Which is the most efficient method to display a grid of about 1000 clickable images in wxPython ?\nCurrently i am using a GridSizer filled with StaticBitmap objects. But its quite slow for 500+ images. \nOne more thing is that, i have a listbox of categories on the left. That is to filter the images. Categories will be like \"All\", \"Cat 1\", \"Cat 2\" etc. When i click \"All\", all the image have to be displayed.\nHow i am doing this currently :\n\nA VERTICAL BoxSizer will contain n\nGridSizer objects, one for each\ncategory. I add the StaticBitmap\nobjects to multiple GridSizers\ndepending on the categories it\nbelongs to. \nThen i display only that    GridSizer\ndepending on which category    is\nselected\n\nThis method is also terribly slow for anything over 300 images. So, how do i achieve the same effect efficiently ?\n.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":796,"Q_Id":5680487,"Users Score":0,"Answer":"I would think a ListCtrl in ICON style would be the best way to do this.\nIf you look at the wxPython Demos, the UltimateListCtrl sample in the wx.LC_ICON style is a good example of what you could create.","Q_Score":1,"Tags":"python,image,performance,wxpython","A_Id":5681008,"CreationDate":"2011-04-15T17:50:00.000","Title":"Efficient method for a grid of clickable images in wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i wonder how to know , a position inside the .txt when I read.\nthis is my txt\n\ncat dog monkey bird \n\nthis my printing\n\nWord: cat  Position:  line 1 , word 1 (1,1)\n\nany idea?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":262,"Q_Id":5681407,"Users Score":1,"Answer":"Basic idea\n\nOpen the file\nIterate over the lines\nFor every line read, increment some counter, e.g. line_no += 1;\nSplit the line by whitespace (you will get a list)\nCheck if the list contains the word (use in), then use list.index(word) to get the index, store that index in some variable word_no = list.index(word)\nprint line_no and word_no if the word was found\n\nThere are a lot better solutions out there (and more pythonic ones) but this gives you an idea.","Q_Score":1,"Tags":"python","A_Id":5681599,"CreationDate":"2011-04-15T19:26:00.000","Title":"How to know a position (.txt)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just broke my environment because of django 1.3. None of my sites are able to run. \nSo, i decided to use virtualenv to set virtual environment with different python version as well as django.\nBut, seems like if i download the package and install using \"sudo python setup.py install\" this does not get added to my virtual environment, but my original environment. \nI tried \"easy_install django\" in virtual environment virtualenv_name\/bin folder, and it worked, but the problem is django1.3 was chosen automatically and got added.\nI want to install django 1.2.5, is there a way that i can install easily to my virtual env?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":12466,"Q_Id":5688053,"Users Score":5,"Answer":"Since the question was about easy_install, it's useful to know that (with setuptools v2.1) you can specify version numbers with easy_install like you can with pip.  Thus:\n$ easy_install django==1.3\nwill install django 1.3. \nThis was important for my problem (which Google directed me here to solve), when I needed to install an old version of pip with easy install.  Obviously \"just install pip and do it there\" doesn't work for that problem.","Q_Score":8,"Tags":"python,django,virtualenv","A_Id":21246463,"CreationDate":"2011-04-16T16:51:00.000","Title":"how do you install django older version using easy_install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using PyQt4 and Python 3 do you know how I can change the color of a QLcdNumber during the runtime ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1466,"Q_Id":5692968,"Users Score":1,"Answer":"Didn't use this for some thime, but I think you had to change paletteForegroundColor and change segmentStyle to QLCDNumber::Filled or QLCDNumber::Flat","Q_Score":0,"Tags":"python,qt,python-3.x,pyqt4","A_Id":5693049,"CreationDate":"2011-04-17T10:22:00.000","Title":"Change the color of the text of QLcdNumber","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple client code using xmlrpclib.\n\ntry:\n       Server.func1\n       Server.func2\n       .....\n       Server.funcN\nexcept:\n    pass\n, where Server - ServerProxy from xmlrpclib. How to do this on twisted ?\nI see this example:\n\nfrom twisted.web.xmlrpc import Proxy\nfrom twisted.internet import reactor\n\ndef printValue(value):\n    print repr(value)\n    reactor.stop()\n\ndef printError(error):\n    print 'error', error\n    reactor.stop()\n\nServer = Proxy('http:\/\/advogato.org\/XMLRPC')\nServer.callRemote('func1',).addCallbacks(printValue, printError)\nreactor.run()\n\nbut how to add several nesting callRemote functions ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":305,"Q_Id":5705420,"Users Score":1,"Answer":"You have code in the sample you pasted which takes an action when an XML-RPC call completes.  printValue prints the result of a call and printError print an error which occurs during a call.\nIf you want to make another call after one finishes, then maybe instead of just printing something in printValue, you could issue another Server.callRemote there.","Q_Score":1,"Tags":"python,twisted","A_Id":5707345,"CreationDate":"2011-04-18T15:41:00.000","Title":"using several xmlrpc commands on twisted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program that sets up a wordpress site on my server. It downloads the zip and unzips it into a directory, sets up the database and user, configures the config file. Now I would like to call the the wp_install function in wp-admin\/include\/upgrade.php and pass it the parameters it needs $weblog_title, $user_name, $admin_email ... \nMy question is how can I call this function from python? Can I do a urllib.urlopen and if so how do I call the wp_install function with the right parameters?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1206,"Q_Id":5732384,"Users Score":0,"Answer":"Urllib is an option, but because your script is running on the local machine anyway, I would probably use os.system. That way you can execute the php script like from a shell. You have to look into the php file on how to pass the parameters.","Q_Score":3,"Tags":"python,wordpress","A_Id":5732608,"CreationDate":"2011-04-20T14:56:00.000","Title":"Automate WordPress Install from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program that sets up a wordpress site on my server. It downloads the zip and unzips it into a directory, sets up the database and user, configures the config file. Now I would like to call the the wp_install function in wp-admin\/include\/upgrade.php and pass it the parameters it needs $weblog_title, $user_name, $admin_email ... \nMy question is how can I call this function from python? Can I do a urllib.urlopen and if so how do I call the wp_install function with the right parameters?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1206,"Q_Id":5732384,"Users Score":1,"Answer":"It looks like wp_install() gets called inside of \/wp-admin\/install.php during step 1, and after form data has been validated.  If you submit ?step=1& ... (all of the other required form fields) it should result in calling wp_install.  So yes, you should be able to use urllib(2) for this.","Q_Score":3,"Tags":"python,wordpress","A_Id":5732698,"CreationDate":"2011-04-20T14:56:00.000","Title":"Automate WordPress Install from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As in the title I want to know how to have a self instance in a staticmethod in python.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":213,"Q_Id":5736264,"Users Score":6,"Answer":"By definition, a static method does not have a self parameter. That's what makes it static. If it did have a self parameter, it would be a regular method and not a static method.","Q_Score":1,"Tags":"python,singleton,static-methods","A_Id":5736285,"CreationDate":"2011-04-20T20:31:00.000","Title":"How to have a self instance in a staticmethod in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a small bug tracker written in django.  I'd like to integrate it with an svn repository so that when someone commits to svn it will automatically add a note to an issue in the bug tracker.  Does anyone have any input on how to best approach this?  Should I setup svn hooks?  use a cron job and pull from the log?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":478,"Q_Id":5737483,"Users Score":6,"Answer":"You can have a post-commit hook in the svn repo that uses, ideally, a restful interface to your Django app and adds the note. That way your app remains very simple.","Q_Score":1,"Tags":"python,django,svn","A_Id":5737523,"CreationDate":"2011-04-20T22:42:00.000","Title":"SVN Integration with django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am dealing with unicode strings returned by the python-lastfm library.\nI assume somewhere on the way, the library gets the encoding wrong and returns a unicode string that may contain invalid characters.\nFor example, the original string i am expecting in the variable a is \"Gl\u00fcck\"\n\n>>> a\nu'Gl\\xfcck'\n>>> print a\nTraceback (most recent call last):\n  File \"\", line 1, in \nUnicodeEncodeError: 'ascii' codec can't encode character u'\\xfc' in position 2: ordinal not in range(128)\n\n\\xfc is the escaped value 252, which corresponds to the latin1 encoding of \"\u00fc\". Somehow this gets embedded in the unicode string in a way python can't handle on its own.\nHow do i convert this back a normal or unicode string that contains the original \"Gl\u00fcck\"? I tried playing around with the decode\/encode methods, but either got a UnicodeEncodeError, or a string containing the sequence \\xfc.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41975,"Q_Id":5760936,"Users Score":0,"Answer":"Do not str() cast to string what you've got from model fields, as long as it is an unicode string already.\n(oops I have totally missed that it is not django-related)","Q_Score":19,"Tags":"python,string,unicode,character-encoding","A_Id":27403026,"CreationDate":"2011-04-22T23:18:00.000","Title":"Handle wrongly encoded character in Python unicode string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"In Python, is there a way to get notified that a specific table in a MySQL database has changed?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":30571,"Q_Id":5771925,"Users Score":1,"Answer":"Not possible with standard SQL functionality.","Q_Score":10,"Tags":"python,mysql","A_Id":5771943,"CreationDate":"2011-04-24T17:03:00.000","Title":"python: how to get notifications for mysql database changes?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, is there a way to get notified that a specific table in a MySQL database has changed?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":30571,"Q_Id":5771925,"Users Score":10,"Answer":"It's theoretically possible but I wouldn't recommend it:\nEssentially you have a trigger on the the table the calls a UDF which communicates with your Python app in some way.\nPitfalls include what happens if there's an error?  \nWhat if it blocks?  Anything that happens inside a trigger should ideally be near-instant.\nWhat if it's inside a transaction that gets rolled back?\nI'm sure there are many other problems that I haven't thought of as well.\nA better way if possible is to have your data access layer notify the rest of your app.  If you're looking for when a program outside your control modifies the database, then you may be out of luck.\nAnother way that's less ideal but imo better than calling an another program from within a trigger is to set some kind of \"LastModified\" table that gets updated by triggers with triggers.  Then in your app just check whether that datetime is greater than when you last checked.","Q_Score":10,"Tags":"python,mysql","A_Id":5771988,"CreationDate":"2011-04-24T17:03:00.000","Title":"python: how to get notifications for mysql database changes?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can someone point me in the right direction on how to use Django-filer? I have installed the necessary tools for the filer to work and I get the Filer tab in the admin interface, but when I upload an image to the app I am not able to get the preview thumbimage. The image is also uploaded to the Media_root path(Public files default path). What else have I missed?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1363,"Q_Id":5780397,"Users Score":0,"Answer":"Had a similar problem. I had missed that when easy_thumbnails is automatically pulled in by pip, you still have to explicitly add it to your INSTALLED_APPS in settings.py.\nI spotted this because when I was uploading images, they weren't appearing in the clipboard, and when inspecting the response from the upload, there was an internal server error complaining that an easy_thumbnails table wasn't available.\ntl;dr; check you added easy_thumbnails to your settings and did a migration \/ syncdb","Q_Score":3,"Tags":"python,django,django-filer","A_Id":13129716,"CreationDate":"2011-04-25T16:17:00.000","Title":"How to use Django-filer(asset file manager)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to run a command in Python Shell to execute a file with an argument.\nFor example: execfile(\"abc.py\") but how to add 2 arguments?","AnswerCount":13,"Available Count":1,"Score":0.0153834017,"is_accepted":false,"ViewCount":186617,"Q_Id":5788891,"Users Score":1,"Answer":"Besides subprocess.call, you can also use subprocess.Popen. Like the following\nsubprocess.Popen(['.\/script', arg1, arg2])","Q_Score":74,"Tags":"python,shell","A_Id":33261131,"CreationDate":"2011-04-26T10:18:00.000","Title":"Execute a file with arguments in Python shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone use a scripting language only solution to produce a binary (.exe) to produce a commercial desktop application for windows or mac? e.g. Java, python etc. If so how do you distribute your app and does using a scripting language cause any problems with the installation?\nI'm asking about users that can download an application and install it, they don't know about setting path variables, or changing there JAVA_HOME. The assumption for the PC are users with a consumer PC with windows (XP\/Vista\/7), not power users. (Or alternatively a mac type solution would be interesting to hear about to)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":525,"Q_Id":5789455,"Users Score":0,"Answer":"Does anyone use anything else for shrink wrap apps on windows? e.g. Java, python etc.\n\nYes. I assume you're not really asking about Java, since that is so wide-spread. I can count quite a few Java applications that I use, and I don't operate in the \"Enterprise\" environment.\nThere are tools that allow you to ship Python code without shipping actual .py files and without needing the to actually have Python installed, so there are solutions for that as well. Since such tools exist I assume people do ship Python applications.\n\nIf so how do you distribute your app and does using a scripting language cause any problems with the installation?\n\nWhat scripting language?","Q_Score":2,"Tags":"python,windows,delphi,lua,desktop-application","A_Id":5789728,"CreationDate":"2011-04-26T11:12:00.000","Title":"desktop development language compiled binary or scripting language (windows)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some database structure; as most of it is irrelevant for us, i'll describe just some relevant pieces. Let's lake Item object as example:\nitems_table = Table(\"invtypes\", gdata_meta,\n                    Column(\"typeID\", Integer, primary_key = True),\n                    Column(\"typeName\", String, index=True),\n                    Column(\"marketGroupID\", Integer, ForeignKey(\"invmarketgroups.marketGroupID\")),\n                    Column(\"groupID\", Integer, ForeignKey(\"invgroups.groupID\"), index=True))\n\nmapper(Item, items_table,\n       properties = {\"group\" : relation(Group, backref = \"items\"),\n                     \"_Item__attributes\" : relation(Attribute, collection_class = attribute_mapped_collection('name')),\n                     \"effects\" : relation(Effect, collection_class = attribute_mapped_collection('name')),\n                     \"metaGroup\" : relation(MetaType,\n                                            primaryjoin = metatypes_table.c.typeID == items_table.c.typeID,\n                                            uselist = False),\n                     \"ID\" : synonym(\"typeID\"),\n                     \"name\" : synonym(\"typeName\")})\nI want to achieve some performance improvements in the sqlalchemy\/database layer, and have couple of ideas:\n1) Requesting the same item twice:\nitem = session.query(Item).get(11184)\nitem = None (reference to item is lost, object is garbage collected)\nitem = session.query(Item).get(11184)\nEach request generates and issues SQL query. To avoid it, i use 2 custom maps for an item object:\nitemMapId = {}\nitemMapName = {}\n\n@cachedQuery(1, \"lookfor\")\ndef getItem(lookfor, eager=None):\n    if isinstance(lookfor, (int, float)):\n        id = int(lookfor)\n        if eager is None and id in itemMapId:\n            item = itemMapId[id]\n        else:\n            item = session.query(Item).options(*processEager(eager)).get(id)\n            itemMapId[item.ID] = item\n            itemMapName[item.name] = item\n    elif isinstance(lookfor, basestring):\n        if eager is None and lookfor in itemMapName:\n            item = itemMapName[lookfor]\n        else:\n            # Items have unique names, so we can fetch just first result w\/o ensuring its uniqueness\n            item = session.query(Item).options(*processEager(eager)).filter(Item.name == lookfor).first()\n            itemMapId[item.ID] = item\n            itemMapName[item.name] = item\n    return item\nI believe sqlalchemy does similar object tracking, at least by primary key (item.ID). If it does, i can wipe both maps (although wiping name map will require minor modifications to application which uses these queries) to not duplicate functionality and use stock methods. Actual question is: if there's such functionality in sqlalchemy, how to access it?\n2) Eager loading of relationships often helps to save alot of requests to database. Say, i'll definitely need following set of item=Item() properties:\nitem.group (Group object, according to groupID of our item)\nitem.group.items (fetch all items from items list of our group)\nitem.group.items.metaGroup (metaGroup object\/relation for every item in the list)\nIf i have some item ID and no item is loaded yet, i can request it from the database, eagerly loading everything i need: sqlalchemy will join group, its items and corresponding metaGroups within single query. If i'd access them with default lazy loading, sqlalchemy would need to issue 1 query to grab an item + 1 to get group + 1*#items for all items in the list + 1*#items to get metaGroup of each item, which is wasteful.\n2.1) But what if i already have Item object fetched, and some of the properties which i want to load are already loaded? As far as i understand, when i re-fetch some object from the database - its already loaded relations do not become unloaded, am i correct?\n2.2) If i have Item object fetched, and want to access its group, i can just getGroup using item.groupID, applying any eager statements i'll need (\"items\" and \"items.metaGroup\"). It should properly load group and its requested relations w\/o touching item stuff. Will sqlalchemy properly map this fetched group to item.group, so that when i access item.group it won't fetch anything from the underlying database?\n2.3) If i have following things fetched from the database: original item, item.group and some portion of the items from the item.group.items list some of which may have metaGroup loaded, what would be best strategy for completing data structure to the same as eager list above: re-fetch group with (\"items\", \"items.metaGroup\") eager load, or check each item from items list individually, and if item or its metaGroup is not loaded - load them? It seems to depend on the situation, because if everything has already been loaded some time ago - issuing such heavy query is pointless. Does sqlalchemy provide a way to track if some object relation is loaded, with the ability to look deeper than just one level?\nAs an illustration to 2.3 - i can fetch group with ID 83, eagerly fetching \"items\" and \"items.metaGroup\". Is there a way to determine from an item (which has groupID of an 83), does it have \"group\", \"group.items\" and \"group.items.metaGroup\" loaded or not, using sqlalchemy tools (in this case all of them should be loaded)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3854,"Q_Id":5795492,"Users Score":7,"Answer":"To force loading lazy attributes just access them. This the simplest way and it works fine for relations, but is not as efficient for Columns (you will get separate SQL query for each column in the same table). You can get a list of all unloaded properties (both relations and columns) from sqlalchemy.orm.attributes.instance_state(obj).unloaded.\nYou don't use deferred columns in your example, but I'll describe them here for completeness. The typical scenario for handling deferred columns is the following:\n\nDecorate selected columns with deferred(). Combine them into one or several groups by using group parameter to deferred().\nUse undefer() and undefer_group() options in query when desired.\nAccessing deferred column put in group will load all columns in this group.\n\nUnfortunately this doesn't work reverse: you can combine columns into groups without deferring loading of them by default with column_property(Column(\u2026), group=\u2026), but defer() option won't affect them (it works for Columns only, not column properties, at least in 0.6.7).\nTo force loading deferred column properties session.refresh(obj, attribute_names=\u2026) suggested by Nathan Villaescusa is probably the best solution. The only disadvantage I see is that it expires attributes first so you have to insure there is not loaded attributes among passed as attribute_names argument (e.g. by using intersection with state.unloaded).\nUpdate\n1) SQLAlchemy does track loaded objects. That's how ORM works: there must be the only object in the session for each identity. Its internal cache is weak by default (use weak_identity_map=False to change this), so the object is expunged from the cache as soon as there in no reference to it in your code. SQLAlchemy won't do SQL request for query.get(pk) when object is already in the session. But this works for get() method only, so query.filter_by(id=pk).first() will do SQL request and refresh object in the session with loaded data.\n2) Eager loading of relations will lead to fewer requests, but it's not always faster. You have to check this for your database and data.\n2.1) Refetching data from database won't unload objects bound via relations.\n2.2) item.group is loaded using query.get() method, so there won't lead to SQL request if object is already in the session.\n2.3) Yes, it depends on situation. For most cases it's the best is to hope SQLAlchemy will use the right strategy :). For already loaded relation you can check if related objects' relations are loaded via state.unloaded and so recursively to any depth. But when relation is not loaded yet you can't get know whether related objects and their relations are already loaded: even when relation is not yet loaded the related object[s] might be already in the session (just imagine you request first item, load its group and then request other item that has the same group). For your particular example I see no problem to just check state.unloaded recursively.","Q_Score":7,"Tags":"python,sqlalchemy,eager-loading","A_Id":5819858,"CreationDate":"2011-04-26T19:35:00.000","Title":"Completing object with its relations and avoiding unnecessary queries in sqlalchemy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I would like have additional settings tied to each user in my application (beyond, is_staff, is_admin etc etc). Basically I'd like to have different settings to customize their user experience (ie: don't show tooltips, how many rows to display in results tables, other flags for turning things on or off).\nAre there best practices for adding these types of settings, or example model to do this without touching the django user object (in the past when i needed a quick user property, i just added it to my django source code, but obviously know that this is a horrible idea).\nSo when someone sucessfully logs in, I would grab the settings for the user and add them to the session.\nI wasn't sure if there was a pretty way, or best practice for doing this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6716,"Q_Id":5797038,"Users Score":0,"Answer":"Either put them in the user profile model, or create another model with a one-to-one to User.","Q_Score":9,"Tags":"python,django,settings","A_Id":5797047,"CreationDate":"2011-04-26T22:06:00.000","Title":"modeling user settings in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a website that allows you to setup a photo gallery with a custom domain name.\nUsers of the site don't know how to register or configure domain names, so this has to be done for them.\nUser enters desired domain name in a box (we check if it's available) and click 'register' button and our website registers the domain name for them and sets up the website automatically (when user goes to that domain name, the photo gallery just works, no technical skills needed).","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4713,"Q_Id":5814837,"Users Score":2,"Answer":"There is no general API for this. You have to check back with your own domain registration organization. This is specific to the related domain provider.","Q_Score":6,"Tags":"python,api,hosting,dns,registration","A_Id":5814951,"CreationDate":"2011-04-28T06:59:00.000","Title":"What is the best API for registering and configuring domain names?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I have a list of restaurants (e.g. McDonalds, etc), with menus (e.g Lunch Menu, Dinner Menu), submenus (e.g. Appetizers, Sandwidches, etc.) and dishes (Angus Burger, Chicken Burger, etc.)\nThey are all linked by foreign keys.\nIs there a way, so that in the Restaurant admin, I have Menu as a tabular inline, with a link to go edit that menu (in it's own admin page, not inline) so that there I can display the submenus inline with the menu admin. Each submenu has a link to edit that submenu item (in it's own admin page, not inline) so that there I can display the dishes inline.\nTHanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":5819205,"Users Score":0,"Answer":"If you just want to append some links like in the Restaurant change view, you don't really need to use an inline as this provides a form for changing data. I would probably override change_view in RestaurantAdmin to get a list of the related menus and pass it as an extra_context. And then override the model specific change_form.html template to render the menu links.","Q_Score":0,"Tags":"python,django","A_Id":5821241,"CreationDate":"2011-04-28T13:14:00.000","Title":"In Django Admin, how do you have cascaded InlineModelAdmin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a histogram I'm drawing in matplotlib with some 260,000 values or so.\nThe problem is that the frequency axis (y axis) on the histogram reaches high numbers such as 100,000... What I'd really like is to have the y labels as thousands, so instead of, for instance:\n\n100000\n75000\n50000\n25000\n0\n\nTo have this:\n\n100\n75\n50\n25\n0\n\nAnd then I can simply change the y axis to \"Frequency (000s)\" -- it makes it much easier to read that way. Anyone with any ideas how that can be achieved?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3743,"Q_Id":5821895,"Users Score":0,"Answer":"Just convert the values yourself before they are entered. In numpy, you can do just array\/1000 instead of array.","Q_Score":3,"Tags":"python,graph,matplotlib,histogram","A_Id":5821933,"CreationDate":"2011-04-28T16:27:00.000","Title":"Matplotlib histogram, frequency as thousands","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So i had to write a program that asks for a user input (which should be a 3 letter string) and it outputs the six permutations of the variations of the placements of the letters inside the string. However, my professor wants the output to be surrounded by curly brackets whereas mine is a list (so it is square brackets). How do i fix this? Also, how do I check if none of the letters in the input repeat so that the main program keeps asking the user to enter input and check it for error?\nThank you","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":121,"Q_Id":5826697,"Users Score":1,"Answer":"The answer to both question is to use a loop. \nPrint the \"{\" and then loop through all the elements printing them.\nBut the input inside a loop and keep looping until you get what you want.","Q_Score":2,"Tags":"python","A_Id":5826729,"CreationDate":"2011-04-29T00:48:00.000","Title":"Advice on python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I have few jar files which are few calculations compiled into jar files. I have a python web app which is supposed to interact with these jar files and get me the data. I have heard that it can be done using the java bridge. Can someone let me know how this could be done or at least point me to the right link.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":5830706,"Users Score":0,"Answer":"You could always run the jar files in a subprocess and use PIPE for IO (or temp files). This works pretty well for us (we are generating PDF from our Django app with flying saucer and iText)","Q_Score":0,"Tags":"java,python","A_Id":5835814,"CreationDate":"2011-04-29T10:09:00.000","Title":"Integrating python webapp with some jar files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In MySQL, I have two different databases -- let's call them A and B.\nDatabase A resides on server server1, while database B resides on server server2.\nBoth servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).\nIn such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B?\nIf so, how do I go about it, programatically, in python? (I am using python's MySQLDB to separately interact with each one of the databases).","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":32061,"Q_Id":5832787,"Users Score":4,"Answer":"It is very simple - select data from one server, select data from another server and aggregate using Python. If you would like to have SQL query with JOIN - put result from both servers into separate tables in local SQLite database and write SELECT with JOIN.","Q_Score":29,"Tags":"python,mysql","A_Id":5832825,"CreationDate":"2011-04-29T13:36:00.000","Title":"MySQL -- Joins Between Databases On Different Servers Using Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In MySQL, I have two different databases -- let's call them A and B.\nDatabase A resides on server server1, while database B resides on server server2.\nBoth servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).\nIn such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B?\nIf so, how do I go about it, programatically, in python? (I am using python's MySQLDB to separately interact with each one of the databases).","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":32061,"Q_Id":5832787,"Users Score":3,"Answer":"No. It is not possible to do the join as you would like. But you may be able to sort something out by replicating one of the servers to the other for the individual database. \nOne data set is under the control of one copy of MySQL and the other dataset is under the control of the other copy of MySQL. The query can only be processed by one of the (MySQL) servers.\nIf you create a copy of the second database on the first server or vice versa (the one that gets the fewest updates is best) you can set up replication to keep the copy up to date. You will then be able to run the query as you want.","Q_Score":29,"Tags":"python,mysql","A_Id":5832954,"CreationDate":"2011-04-29T13:36:00.000","Title":"MySQL -- Joins Between Databases On Different Servers Using Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Xcode 3 had templates for building Cocoa subclasses in Python. I've recently upgraded to Xcode 4 but I cannot find out how I can use other languages besides the C family (C, C++, Obj-C) in Xcode 4.\nDoes anyone know?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":7826,"Q_Id":5843508,"Users Score":2,"Answer":"I've successfully built a MacRuby GUI app in XCode 4.2 on Lion today following a MacRuby tutorial on Apple's site. MacRuby also includes a template in XCode 4.2. I'm a Python programmer and really hoped to use it, but at this point I've given up on PyObjC. I use Tk in Python for quick little apps and maybe switch to MacRuby, but will likely just switch to Objective-c. Ruby is a pretty nice language though. Maybe MacRuby will interest you.","Q_Score":13,"Tags":"python,xcode,xcode4,pyobjc","A_Id":7815044,"CreationDate":"2011-04-30T17:39:00.000","Title":"PyObjC on Xcode 4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been hearing the buzz about virtualenv lately, and I'm interested. But all I've heard is a smattering of praise, and don't have a clear understanding of what it is or how to use it.\nI'm looking for (ideally) a follow-along tutorial that can take me from Windows or Linux with no Python on it, and explain every step of (in no particular order):\n\nwhat I should do to be able to start using virtualenv\nspecific reasons why using virtualenv is a good idea\nsituations where I can\/can't use virtualenv\nsituations where I should\/shouldn't use virtualenv\n\nAnd step through (comprehensively) a couple sample situations of the should+can variety.\nSo what are some good tutorials to cover this stuff? Or if you have the time and interest, perhaps you can answer a few of those questions here. Either in your answer, or as a link to tutorials that answer it, these are the things I'd like to know.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":149425,"Q_Id":5844869,"Users Score":35,"Answer":"Virtualenv is a tool to create isolated Python environments.\nLet's say you're working in 2 different projects, A and B.\nProject A is a web project and the team is using the following packages:\n\nPython 2.8.x\nDjango 1.6.x\n\nThe project B is also a web project but your team is using:\n\nPython 2.7.x\nDjango 1.4.x\n\nThe machine that you're working doesn't have any version of django, what should you do? Install django 1.4? django 1.6? If you install django 1.4 globally would be easy to point to django 1.6 to work in project A?\nVirtualenv is your solution! You can create 2 different virtualenv's, one for project A and another for project B. Now, when you need to work in project A, just activate the virtualenv for project A, and vice-versa. \nA better tip when using virtualenv is to install virtualenvwrapper to manage all the virtualenv's that you have, easily. It's a wrapper for creating, working, removing virtualenv's.","Q_Score":358,"Tags":"python,virtualenv","A_Id":13261064,"CreationDate":"2011-04-30T21:56:00.000","Title":"Comprehensive beginner's virtualenv tutorial?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I download python 3.2 and my first thought was that I need to uninstall the python 2.6.1 pre-installed in my computer. But later I found in python.org \"You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software\". I used \"sudo rm -rf \/Library\/Frameworks\/Python.Framework\" to delete python 2.6.1. Now I truly want to undo this command(I want python 2.6.1 back!). What should I do?\n(or the question can be expressed as follows: how can I re-install the pre-installed python 2.6.1 in my mac?)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1053,"Q_Id":5846022,"Users Score":0,"Answer":"Reinstalling would work. In the future, don't delete Frameworks you didn't install.","Q_Score":0,"Tags":"python","A_Id":5846054,"CreationDate":"2011-05-01T02:33:00.000","Title":"how to recover python 2.6.1 that was pre-installed in my macbook pro?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose there is a web app name thesite.com. I need to give every user\na url of his own. For eg- if alice signs up, she gets a space of her\nown at the url \"alice.thesite.com\".. How do I achieve this.\nThanks\nAlice","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":5848496,"Users Score":0,"Answer":"By pointing all the subdomains of that domain to the same website via DNS, and then inspecting the HTTP 1.1 Host header to determine which user website is being viewed.","Q_Score":2,"Tags":"python,url,flask","A_Id":5848509,"CreationDate":"2011-05-01T12:59:00.000","Title":"how to map url with usernames prefixed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running Python2.7.1 and OpenCV 2.2 without problems in my WinXP laptop and wrote a tracking program that is working without a glitch. But for some strange reason I cannot get the same program to run in any other computer where I tried to install OpenCV and Python (using the same binaries or appropriate 64 bit binaries). In those computers OpenCV seems to be correctly installed (although I have only tested and CaptureFromCamera() in the webcam of the laptop), but CaptureFromFile() return 'None' and give \"error: Array should be CvMat or IplImage\" after a QueryFrame, for example.\nThis simple code:\nimport cv   \/\nvideofile = cv.CaptureFromFile('a.avi')   \/\nframe = cv.QueryFrame(videofile)   \/\nprint type(videofile)   \/\nprint type(frame)\nreturns:\ntype 'cv.Capture'  \/\ntype 'NoneType'\n\nOpenCV and Python are in the windows PATH...\nI have moved the OpenCV site-packages content back and forth to the Pyhton27 Lib\\Site-packages folder.\nI tried different avi files (just in case it was some CODEC problem). This AVI uses MJPEG encoding (and GSpot reports that ffdshow Video Decoder is used for reading).\nImages work fine (I think): the simple convert code:\nim = cv.LoadImageM(\"c:\\tests\\colormap3.tif\")\ncv.SaveImage(\"c:\\tests\\colormap3-out.png\", im)\nopens, converts and saves the new image...\nI have tested with AVI files in different folders, using \"c:\\\", \"c:\/\", \"c:\\\" and \"c:\/\/\".\n\nI am lost here... Anyone has any idea of what stupid and noob mistake may be the cause of this? Thanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1705,"Q_Id":5858446,"Users Score":0,"Answer":"This must be an issue with the default codecs. OpenCV uses brute force methods to open video files or capture from camera. It goes by trial and error through all sources\/codecs\/apis it can find in some reasonable order. (at least 1.1 did so).\nThat means that on n different systems (or days) you may get n different ways of accessing the same video. The order of multiple webcams for instance, is also non-deterministic and may depend on plugging order or butterflies.\nFind out what your laptop uses, (re)install that on all the systems and retry.\nAlso, in the c version, you can look at the capture's properties\nlook for cvGetCaptureProperty and cvSetCaptureProperty where you might be able to hint to the format.\n[EDIT]\nJust looked i tup in the docs, these functions are also available in Python. Take a look, it should help.","Q_Score":1,"Tags":"opencv,python-2.7,iplimage","A_Id":5859924,"CreationDate":"2011-05-02T14:34:00.000","Title":"IplImage 'None' error on CaptureFromFile() - Python 2.7.1 and OpenCV 2.2 WinXP","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm working with Tornado and MongoDB and I would like to send a confirmation email to the user when he creates an account in my application.\nFor the moment, I use a simple XHTML page with a form and I send information to my MongoDB database using Tornado. I would like to have an intermediate step which sends an email to the user before inserting the data into the database.\nI would like to know how could I send this email and insert the user account only after the user receives the email and confirms his registration.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3734,"Q_Id":5862238,"Users Score":6,"Answer":"I wonder why you would handle registration like that. The usual way to handle registration is:\n\nWrite the user info to the database, but with an 'inactive' label attached to the user.\nSend an email to the user.\nIf the user confirms the registration, then switch the user to 'active'.\n\nIf you don't want to write to the database, you can write to a cache (like memcache, redis), then when the user confirms the registration, you can get the user info from the cache and write it to the database.","Q_Score":5,"Tags":"python,email,tornado","A_Id":7483440,"CreationDate":"2011-05-02T20:41:00.000","Title":"How can I send a user registration confirmation email using Tornado and MongoDB?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"lets say i have a python programm whitch i want to run always max 10 times in parallel using celery \/ rabbigmq and if some of the process finish i want to know about it so i can start a new process. how can i do so? some examples would be nice","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":485,"Q_Id":5880867,"Users Score":1,"Answer":"Giving an example is difficult as messaging is a bit complex, but what you can do basically is:\n\nrewrite your program to be a task or write a task that calls your program using subprocess\nconfigure celery to have 10 workers\nexecute as many tasks as you need to get your job done, Celery will add them to its queue\nCelery will do the rest for you, once a task finished, another one is started till the queue is empty\n\nAlternatively, if your want to start a task manually after one finished, you can configure Celery to send a message after its finished (I didn't try it yet, but have a look at CELERY_RESULT_BACKEND) You can then consume these messages and start your task.","Q_Score":0,"Tags":"python,parallel-processing,celery","A_Id":5882479,"CreationDate":"2011-05-04T08:49:00.000","Title":"python create celery task job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a string\n\"THIS IS, A STRING, FROM\"\nHow can I remove a comma before the FROM statement?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":411,"Q_Id":5889111,"Users Score":0,"Answer":"Replace using regular expression \\,\\s*FROM and replace with FROM.","Q_Score":2,"Tags":"python,regex,perl","A_Id":5889138,"CreationDate":"2011-05-04T19:53:00.000","Title":"Regexp beginner: how to remove comma before a keyword?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"now I have a site which based on django(the python framework) which can run stable.\nin this site we need to use wordpress as a cms.\nthe server config on ubuntu and nginx,\nbut i don't know how to combine the django and wordpress\ntogether.any tips is wonderful.\nthanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1879,"Q_Id":5895707,"Users Score":1,"Answer":"If you can get away with running Django and Wordpress as separate apps, you can just use nginx to handle which requests go to which app.\nFor example, if the CMS portion you'd like Wordpress for is only a blog, you could have nginx send example.com\/blog\/ to wordpress, and anything else to django.","Q_Score":1,"Tags":"python,django,wordpress","A_Id":5914160,"CreationDate":"2011-05-05T09:50:00.000","Title":"how to combine django and wordpress based on ubuntu and nginx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed a web application in Django and would like to go online i have an FTP access to the hosting server I am a beginner to \"setting up a website\" i would like to know how to install apache on that server and have my application working\nKindly provide detailed info as i am newbie, any links or tutorials would help a lot\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":347,"Q_Id":5907312,"Users Score":1,"Answer":"If you only have user level access to the machine (ie: you don't have root), then you won't be able to control what web server runs and you can only control its settings to a limited regard. You will have to consider contacting your provider or looking for a different hosting package if the server doesn't meet you needs.\nTypically, if it is a hosting server, the administrators will already have web server software like Apache running. You simply just have to upload what you would like to have displayed (typically to a directory called \"public_html\" or something like that), and it will display when someone visits your site. Hopefully they support things like Django, otherwise you might need to look at other options.\nYour hosting provider is most likely to have specific and the most relevant instructions for how to upload your website.","Q_Score":1,"Tags":"django,apache,apache2,mod-python","A_Id":5907442,"CreationDate":"2011-05-06T05:51:00.000","Title":"How to set up Apache server via an FTP account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I use the Python (2.7) package VideoCapture. When I try to instantiate the Device, I get an Exception:\n\nError: Capture Graph could not be created.\n\nI use cam = Device(), so nothing special there. I have one laptop where this works without a problem, and another where I get the Exception. They are different, but both have internal USB-Webcams.\nOne week ago it worked, but now I only get the exception. Both use Windows 7.\nDoes anybody have an idea how to resolve this, or how I could get more information what is wrong?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1280,"Q_Id":5911382,"Users Score":1,"Answer":"I know this is a really old thread. I kept getting this error after instantiating the Device a second time. Moving the code to the main thread fixed the problem for me.","Q_Score":1,"Tags":"python,exception,video-capture","A_Id":24388352,"CreationDate":"2011-05-06T12:25:00.000","Title":"VideoCapture: Capture Graph Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have countrynames and utcoffset of that country\nHow to find out out local time in that country using utcoffset?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":1509,"Q_Id":5913049,"Users Score":1,"Answer":"call datetime.now() with the time zone (as a tzinfo object) as an argument.","Q_Score":0,"Tags":"python,timezone","A_Id":5913087,"CreationDate":"2011-05-06T14:44:00.000","Title":"how to findout local time using utcoffset and countryname in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Some details of my machine and installed packages before proceeding further:\nMac OSX version: 10.6.6\nPython version: Activestate Python 2.7.1\nwxpython version: wxpython 2.8 (uses Carbon API hence limited to 32-bit mode arch only)\nI installed wxPython2.8-osx-unicode-py2.7 from wxpython website using their .dmg installer file. This package uses the Carbon API and hence is limited to 32-bit mode only. I have to write my applications using \"arch -i386\" in order to import wx, and due to this limitation I am unable to import certain other packages likes \"MySQLdb\" which are not available in 32-bit mode. So, my best option is to uninstall wxpython 2.8 and install wxpython 2.9 because version 2.9 uses Cocoa API which has both 32-bit and 64-bit support. \nI don't know how to uninstall wxpython2.8 on my Mac OSX. Can anyone please help me?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4762,"Q_Id":5920764,"Users Score":8,"Answer":"If you look in the .dmg for wxPython, there is an uninstall_wxPython.py unininstall script. Just drag it to your desktop and run python ~\/Desktop\/uninstall_wxPython.py in a terminal.","Q_Score":5,"Tags":"python,macos,wxpython,uninstallation","A_Id":5922093,"CreationDate":"2011-05-07T11:33:00.000","Title":"How to uninstall wxpython 2.8 on Mac OSX 10.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The original framework of my app (using Python) is below:\n\nuser key in keywords in forms.\nApp use the data in forms as parameter to get some results from third-party website.\nThe result which is from third-party website will be analyzed in my app.\nThen show the result of analyze to user.\n\nBut there are some problems between my app and third-party website, so I want to change the framework of my app.\n\nuser key in keywords in forms.\nstore the keywords which in forms as cookie.\nautomatically download one javascript which in my app (website), and run the javascript in user's computer.\nthe javascript will get result from third-party website, and then sent the result to my app.\nmy app will analyze the result (from third-party website) and then show the result of analyze to user.\n\nI want to know how can I do this, or what keyword should I search in Google.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":248,"Q_Id":5922032,"Users Score":0,"Answer":"It's very unclear what you are looking for. If the question is about server push keywords are WebSockets,Socket.io,Ajax,Comet,Bayeux to start with","Q_Score":1,"Tags":"javascript,python","A_Id":5922070,"CreationDate":"2011-05-07T15:29:00.000","Title":"Load form data in JavaScript and run something client side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've searched for ages on how to use Python 3 under Apache. If there is a walkthrough anywhere, it's very well hidden. Thus, hopefully, one of you Python professionals could make a quick 1-2-3 on how it's done!\nI'm on Windows 7 using the newest version of XAMPP.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1328,"Q_Id":5930982,"Users Score":1,"Answer":"Python 3.0 is only supported via CGI. Put your CGI script in cgi-bin\\. If you're willing to look at newer versions, preliminary support is available in mod_wsgi (but you'll probably have to build it yourself).","Q_Score":3,"Tags":"python,windows,apache,python-3.x","A_Id":5931096,"CreationDate":"2011-05-08T23:06:00.000","Title":"How do I use Python 3.0 under Apache?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am writing an Android app using Python and SL4A. The app uses a webview that I wish to refresh. I plan on doing this by utilising javascript location.replace() within a wrapping doRefresh() javascript function. The problem I have is that I do not know how to call the javascript function from within my main event loop within the Python code.\nIs there a way to directly call the method?\nor\nIs there a way to indirectly call the method say via a button's onClick and a mimic screen tap?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":618,"Q_Id":5934326,"Users Score":2,"Answer":"You'll need to wait for a refresh event (this would be a custom event) in your JavaScript that is waiting for an event posted from your Python script. The only communication layer between JavaScript and Python is via events.","Q_Score":1,"Tags":"javascript,android,python,sl4a","A_Id":5939196,"CreationDate":"2011-05-09T08:20:00.000","Title":"How to call a javascript method from python on SL4A?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his desktop.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":5953657,"Users Score":0,"Answer":"You can tell your friend to make *.py files to be executed by the interpreter.  Change it from Explorer:Tools:Folder Options:File Types.","Q_Score":2,"Tags":"python","A_Id":5953799,"CreationDate":"2011-05-10T17:02:00.000","Title":"Python path help","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his desktop.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":312,"Q_Id":5953657,"Users Score":1,"Answer":"f = open(os.path.join(os.environ['USERPROFILE'], 'DESKTOP', my_filename))","Q_Score":2,"Tags":"python","A_Id":5953805,"CreationDate":"2011-05-10T17:02:00.000","Title":"Python path help","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his desktop.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":5953657,"Users Score":0,"Answer":"If you place your Python script in the same directory as the files your script is going to open, then you don't need to specify any paths. Be sure to allow the Python installer to \"Register Extensions\", so Python is called when you double-click on a Python script.","Q_Score":2,"Tags":"python","A_Id":5953763,"CreationDate":"2011-05-10T17:02:00.000","Title":"Python path help","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey there, I have a rather large file that I want to process using Python and I'm kind of stuck as to how to do it.  \nThe format of my file is like this:\n0 xxx xxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n1 xxx xxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nSo I basically want to read in the chunk up from 0-1, do my processing on it, then move on to the chunk between 1 and 2.\nSo far I've tried using a regex to match the number and then keep iterating, but I'm sure there has to be a better way of going about this.  Any suggestion\/info would be greatly appreciated.","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":8205,"Q_Id":5953949,"Users Score":2,"Answer":"Why don't you just read the file char by char using file.read(1)? \nThen, you could - in each iteration - check whether you arrived at the char 1. Then you have to make sure that storing the string is fast.","Q_Score":4,"Tags":"python","A_Id":5954080,"CreationDate":"2011-05-10T17:27:00.000","Title":"Python: Read large file in chunks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey there, I have a rather large file that I want to process using Python and I'm kind of stuck as to how to do it.  \nThe format of my file is like this:\n0 xxx xxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n1 xxx xxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nSo I basically want to read in the chunk up from 0-1, do my processing on it, then move on to the chunk between 1 and 2.\nSo far I've tried using a regex to match the number and then keep iterating, but I'm sure there has to be a better way of going about this.  Any suggestion\/info would be greatly appreciated.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8205,"Q_Id":5953949,"Users Score":0,"Answer":"If the format is fixed, why not just read 3 lines at a time with readline()","Q_Score":4,"Tags":"python","A_Id":5954012,"CreationDate":"2011-05-10T17:27:00.000","Title":"Python: Read large file in chunks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a web interface for some python scripts. The thing is I have to use PHP (and not CGI) and some of the scripts I execute take quite some time to finish: 5-10 minutes. Is it possible for PHP to communicate with the scripts and display some sort of progress status? This should allow the user to use the webpage as the task runs and display some status in the meantime or just a message when it's done.\nCurrently using exec() and on completion I process the output. The server is running on a Windows machine, so pcntl_fork will not work.\nLATER EDIT:\nUsing another php script to feed the main page information using ajax doesn't seem to work because the server kills it (it reaches max execution time, and I don't really want to increase this unless necessary)\nI was thinking about socket based communication but I don't see how is this useful in my case (some hints, maybe?\nThank you","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":16013,"Q_Id":5965655,"Users Score":2,"Answer":"I think you would have to use a meta refresh and maybe have the python write the status to a file and then have the php read from it.\nYou could use AJAX as well to make it more dynamic.\nAlso, probably shouldn't use exec()...that opens up a world of vulnerabilities.","Q_Score":10,"Tags":"php,python,ajax,ipc","A_Id":5965679,"CreationDate":"2011-05-11T14:12:00.000","Title":"Communication between PHP and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using this javascript library (http:\/\/valums.com\/ajax-upload\/) to upload file to a tornado web server, but I don't know how to get the file content. The javascript library is uploading using XHR, so I assume I have to read the raw post data to get the file content. But I don't know how to do it with Tornado. Their documentation doesn't help with this, as usual :(\nIn php they have something like this:\n$input = fopen(\"php:\/\/input\", \"r\");\nso what's the equivalence in tornado?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1836,"Q_Id":5983032,"Users Score":2,"Answer":"I got the answer.\nI need to use self.request.body to get the raw post data.\nI also need to pass in the correct _xsrf token, otherwise tornado will fire a 403 exception.\nSo that's about it.","Q_Score":3,"Tags":"python,file-upload,tornado,ajax-upload","A_Id":5989216,"CreationDate":"2011-05-12T19:00:00.000","Title":"asynchronous file upload with ajaxupload to a tornado web server","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently trying to set up nginx + uWSGI server for my Django homepage. Some tutorials advice me to create specific UNIX users for certain daemons. Like nginx user for nginx daemon and so on. As I'm new to Linux administration, I thought just to create second user for running all the processes (nginx, uWSGI etc.), but it turned out that I need some --system users for that.\nMain question is what users would you set up for nginx + uWSGI server and how to work with them? Say, I have server with freshly installed Debian Squeeze.\nShould I install all the packages, virtual environment and set up all the directories as root user and then create system ones to run the scripts?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":925,"Q_Id":5986472,"Users Score":2,"Answer":"I like having regular users on a system:\n\nmultiple admins show up in sudo logs -- there's nothing quite like asking a specific person why they made a specific change.\nnot all tasks require admin privileges, but admin-level mistakes can be more costly to repair\nit is easier to manage the ~\/.ssh\/authorized_keys if each file contains only keys from a specific user -- if you get four or five different users in the file, it's harder to manage. Small point :) but it is so easy to write cat ~\/.ssh\/id_rsa.pub | ssh user@remotehost \"cat - > ~\/.ssh\/authorized_keys\" -- if one must use >> instead, it's precarious. :)\n\nBut you're right, you can do all your work as root and not bother with regular user accounts.","Q_Score":6,"Tags":"python,django,linux,nginx,uwsgi","A_Id":5986912,"CreationDate":"2011-05-13T01:51:00.000","Title":"Linux user scheme for a Django production server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you are in the view and want to retrieve the app name using Python ( the app name will be used for further logic ), how would you do it ?","AnswerCount":9,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":31008,"Q_Id":6000205,"Users Score":0,"Answer":"I believe the updated solution is view.__module__. This returns your app_name both from Django and Django Rest Framework.\nMy scenario was working with dynamically module or app_name from view call so that I can work with access permission check for that particular module.","Q_Score":26,"Tags":"python,django,django-views","A_Id":68934242,"CreationDate":"2011-05-14T06:32:00.000","Title":"How to get an app name using python in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have setup an Apache server with mod_wsgi, python_sql, mysql and django.\nEverything works fine, except the fact that if I make some code changes, they do not reflect immidiately, though I thing that everything is compiled on the fly when it comes to python\/mod_wsgi.\nI have to shut down the server and come back again to see the changes.\nCan someone point me to how hot-deployment can be achieved with the above setup??\nThanks,\nNeeraj","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":768,"Q_Id":6006666,"Users Score":3,"Answer":"Just touching the wsgi file allways worked for me.","Q_Score":4,"Tags":"python,django,apache2,mod-wsgi,hotdeploy","A_Id":6007285,"CreationDate":"2011-05-15T05:26:00.000","Title":"Hot deployment using mod_wsgi,python and django on Apache","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to use python pypdf to read pdf and get highlighted words? I highlighted the unknown words in a pdf and I want to extract them for referencing later.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":864,"Q_Id":6013930,"Users Score":1,"Answer":"Short answer: not possible with pypdf and not with any PDF tool for Python I know.","Q_Score":0,"Tags":"python,pdf,pypdf","A_Id":6013951,"CreationDate":"2011-05-16T06:37:00.000","Title":"python pypdf to read pdf and get highlighted words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to show a slider in one column of a grid. I was able to create a custom CellEditor which displays the slider when I double click into a cell of the appropriate column so it enters the edit mode. But I don't know how to create a custom CellRenderer that displays the slider in all cell that are not in edit mode.\nUnfortunately the wx.RendererNative does not offer such a method like DrawSlider() :-(\nI appreciate any suggestion. \nBelow you can see an example of what is working so far. You can see the one cell with the sl","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":337,"Q_Id":6020070,"Users Score":1,"Answer":"Maybe you could use the editor to set the numeric value of the cell, then on the renderer draw a vertical bar by dividing the value by the maximum possible value and multiplying it by the width of the cell (in px, to get the proportion of the cell that the slider needs to appear at) and drawing a narrow vertical rectangle at this point that would act as the indicator, something like:\n\n+---------------+\n|    |-|        |\n+---------------+\n\nNote that this is untested, but I plan to do something similar on my current project. Just out of curiosity, how did you get the slider to appear in the editor?","Q_Score":1,"Tags":"wxpython,wxwidgets","A_Id":6641179,"CreationDate":"2011-05-16T16:01:00.000","Title":"wx\/wxPython: How to add a slider to a grid cell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Maybe I'm being irrational but I really really hate it when a command opens a new window in emacs.  I'm using emacs on Ubuntu which came with python-mode and when I start an interpreter with C-c ! it pops up in a new window.\nWhat I want is for emacs to switch to a new buffer in the same window.  So far I've tried adding Jython(I set the interpreter to jython) to same-window-buffer-names and even going into python-mode.el and changing switch-to-buffer-other-window calls to switch-to-buffer(which I since changed back).  So far I've gotten no change.\nI have emacs 23.1.1 and python-mode 5.1.0\nEdit: The actual name of the jython buffer is bracketed by asterisks and I don't know how to let stackoverflow know that they aren't styling information.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1148,"Q_Id":6025305,"Users Score":0,"Answer":"I use python-mode 5.2.0.\nI went into python-mode.el and changed the switch-to-buffer-other-window to switch-to-buffer.\nI evaluated it and now the interpreter opens up in the same window (regardless of the number of other windows I have).\nDid you evaluate the function when you changed the above line?\nBtw, opening the interpreter in another window is a feature, not a bug, IMHO. We want to be able to see the interpreter when we evaluate a region of code using C-c | or the buffer using C-c C-c.","Q_Score":1,"Tags":"emacs,buffer,python-mode","A_Id":6401182,"CreationDate":"2011-05-17T01:27:00.000","Title":"making python interpreter open in same window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance.\nAnd now I would like to execute a Python code in this instance, and I don't know how to proceed. Is it necessary to load the code somewhere in the instance? Or in Amazon's S3 and to link it to the instance?\nWhere is there a guide that explain the usages of instance that are possible? I feel like a man before a flying saucer's dashboard without user's guide.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66912,"Q_Id":6030115,"Users Score":0,"Answer":"simply add your code to Github and take clone on EC2 instance and run that code.","Q_Score":71,"Tags":"python,amazon-ec2","A_Id":71252207,"CreationDate":"2011-05-17T11:29:00.000","Title":"How to run a code in an Amazone's EC2 instance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance.\nAnd now I would like to execute a Python code in this instance, and I don't know how to proceed. Is it necessary to load the code somewhere in the instance? Or in Amazon's S3 and to link it to the instance?\nWhere is there a guide that explain the usages of instance that are possible? I feel like a man before a flying saucer's dashboard without user's guide.","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":66912,"Q_Id":6030115,"Users Score":4,"Answer":"Launch your instance through Amazon's Management Console -> Instance Actions -> Connect \n(More details in the getting started guide)\nLaunch the Java based SSH CLient\nPlugins-> SCFTP File Transfer\nUpload your files\nrun your files in the background (with '&' at the end or use nohup)\n\nBe sure to select an AMI with python included, you can check by typing 'python' in the shell. \nIf your app require any unorthodox packages you'll have to install them.","Q_Score":71,"Tags":"python,amazon-ec2","A_Id":12026840,"CreationDate":"2011-05-17T11:29:00.000","Title":"How to run a code in an Amazone's EC2 instance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have taken an initial DOT file and modified the pos attributes of some nodes using pydot. Now I want to render an image file that shows the nodes in their new positions. The catch is, I don't want a layout program to mess with the positions! I just want to see the nodes exactly where the pos attribute indicates. I don't care about how the edges look. \nI can produce a DOT file with my positions easily using pydot, but I can't figure out how to make an image file, either in pydot or on the command line with dot. Help would be really appreciated! Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":672,"Q_Id":6040603,"Users Score":2,"Answer":"dot.write_png('filename.png')? Or is there something I'm missing?\nAlso, the neato command-line program has a -n option for graph files that already have layout. The program description says it is for undirected graphs, but I tried it with a digraph and it produced the correct result.","Q_Score":1,"Tags":"python,dot,pydot","A_Id":6040922,"CreationDate":"2011-05-18T06:14:00.000","Title":"How to render DOT file using only pos attributes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering whether someone might know the answer to the following.\nI'm using Python to build a character-based suffix tree.  There are over 11 million nodes in the tree which fits in to approximately 3GB of memory.  This was down from 7GB by using the slot class method rather than the Dict method.\nWhen I serialise the tree (using the highest protocol) the resulting file is more than a hundred times smaller.\nWhen I load the pickled file back in, it again consumes 3GB of memory.  Where does this extra overhead come from, is it something to do with Pythons handling of memory references to class instances?\nUpdate\nThank you larsmans and Gurgeh for your very helpful explanations and advice.  I'm using the tree as part of an information retrieval interface over a corpus of texts.\nI originally stored the children (max of 30) as a Numpy array, then tried the hardware version (ctypes.py_object*30), the Python array (ArrayType), as well as the dictionary and Set types. \nLists seemed to do better (using guppy to profile the memory, and __slots__['variable',...]), but I'm still trying to squash it down a bit more if I can. The only problem I had with arrays is having to specify their size in advance, which causes a bit of redundancy in terms of nodes with only one child, and I have quite a lot of them. ;-)\nAfter the tree is constructed I intend to convert it to a probabilistic tree with a second pass, but may be I can do this as the tree is constructed.  As construction time is not too important in my case, the array.array() sounds like something that would be useful to try, thanks for the tip, really appreciated.\nI'll let you know how it goes.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":415,"Q_Id":6041395,"Users Score":3,"Answer":"Do you construct your tree once and then use it without modifying it further? In that case you might want to consider using separate structures for the dynamic construction and the static usage.\nDicts and objects are very good for dynamic modification, but they are not very space efficient in a read-only scenario. I don't know exactly what you are using your suffix tree for, but you could let each node be represented by a 2-tuple of a sorted array.array('c') and an equally long tuple of subnodes (a tuple instead of a vector to avoid overallocation). You traverse the tree using the bisect-module for lookup in the array. The index of a character in the array will correspond to a subnode in the subnode-tuple. This way you avoid dicts, objects and vector.\nYou could do something similar during the construction process, perhaps using a subnode-vector instead of subnode-tuple. But this will of course make construction slower, since inserting new nodes in a sorted vector is O(N).","Q_Score":10,"Tags":"python,class,serialization,memory-management,pickle","A_Id":6046352,"CreationDate":"2011-05-18T07:42:00.000","Title":"Python memory serialisation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a software with user + password. After autentification, the user can access some semi public services, but also encrypt some files that only the user can access.\nThe user must be stored as is, without modification, if possible. After auth, the user and the password are kept in memory as long as the software is running (i don't know if that's okay either).\nThe question is how should i store this user + password combination in a potentially unsecure database?\nI don't really understand what should i expose.\nLet's say I create an enhanced key like this:\n\nsalt = random 32 characters string (is it okay?)\nkey = hash(usr password + salt)\nfor 1 to 65000 do\n  key = hash(key + usr password + salt)\n\nShould I store the [plaintext user], [the enhanced key] and [the salt] in the database ?\nAlso, what should I use to encrypt (with AES or Blowfish) some files using a new password everytime ?\nShould I generate a new salt and create a new enhanced key using (the password stored in memory of the program + the salt) ?\nAnd in this case, if i store the encrypted file in the database, i should probably only store the salt.\nThe database is the same as where i store the user + password combination.\nThe file can only be decrypted if someone can generate the key, but he doesn't know the password. Right ?\nI use Python with PyCrypto, but it's not really important, a general example is just fine.\nI have read a few similar questions, but they are not very explicit.\nThank you very very much!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3307,"Q_Id":6058019,"Users Score":2,"Answer":"If you use a different salt for each user, you must store it somewhere (ideally in a different place). If you use the same salt for every user, you can hardcode it in your app, but it can be considered less secure. \nIf you don't keep the salt, you will not be able to match a given password against the one in your database.\nThe aim of the salt is to make bruteforce or dictionnary attacks a lot harder. That is why it is more secure if store separately, to avoid someone having both hash passwords and corresponding salts.","Q_Score":10,"Tags":"python,security,passwords","A_Id":6058858,"CreationDate":"2011-05-19T11:37:00.000","Title":"Storing user and password in a database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need a button that has a bitmap, toggles, and to which I can add a menu (I realize this is asking a lot).  I can't figure out a way to do this in wx python.  Here are the things I've tried and why they don't work:\nplate buttons: don't toggle\ngenbitmaptogglebuttons: for some reason, these buttons kill my tooltips (I posted this problem earlier and never got an answer)\ntoolbar buttons: can't add a drop down menu to a button.  I would make a separate button for the drop down menu, but the toolbar has to be oriented vertically, and I don't know how to get the drop down button to show up beside its corresponding button, rather than beneath it with vertical a toolbar orientation.  \nbitmap buttons: won't toggle\nAm I missing something obvious?  If not I'm just going to resort to faking a toggle by changing the border\/background color, unless someone has a better suggestion.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":618,"Q_Id":6064044,"Users Score":0,"Answer":"Per Mark's suggestion, if you have wx 2.8.12 you can use a plate button to get the toggle\/bitmap\/menu functionality.  Since it is not easy for me to update to the newer wx at this point, I'll use a bitmap button and fake the toggle.","Q_Score":0,"Tags":"button,menu,bitmap,wxpython,toggle","A_Id":6073070,"CreationDate":"2011-05-19T19:46:00.000","Title":"wx python bitmap\/toggle\/menu button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need a button that has a bitmap, toggles, and to which I can add a menu (I realize this is asking a lot).  I can't figure out a way to do this in wx python.  Here are the things I've tried and why they don't work:\nplate buttons: don't toggle\ngenbitmaptogglebuttons: for some reason, these buttons kill my tooltips (I posted this problem earlier and never got an answer)\ntoolbar buttons: can't add a drop down menu to a button.  I would make a separate button for the drop down menu, but the toolbar has to be oriented vertically, and I don't know how to get the drop down button to show up beside its corresponding button, rather than beneath it with vertical a toolbar orientation.  \nbitmap buttons: won't toggle\nAm I missing something obvious?  If not I'm just going to resort to faking a toggle by changing the border\/background color, unless someone has a better suggestion.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":618,"Q_Id":6064044,"Users Score":0,"Answer":"I don't see a pre-built button with all those features. I would think that you can use the generic toggle button or maybe the ShapedButton for your bitmap toggle functionality and attach a right-click popup menu. I'm not really sure what you mean by a menu, so that may not work. If you're talking about a menu implementation similar to the one that the PlateButton has, then you'll probably have to roll your own button. The guys on the wxPython mailing list can tell you how to do that.","Q_Score":0,"Tags":"button,menu,bitmap,wxpython,toggle","A_Id":6064311,"CreationDate":"2011-05-19T19:46:00.000","Title":"wx python bitmap\/toggle\/menu button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a Canvas which manipulates objects in the mouse event handler. After modifying the objects, I want to trigger the OnPaint() event for the same Canvas to show (rerender) the changes. What is the right way to do this? It doesn't let me call OnPaint() directly. Also, is triggering an event from another event \"wrong\" in some sense, or likely to lead to trouble?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3642,"Q_Id":6076014,"Users Score":4,"Answer":"I would just call self.Refresh() or maybe RefreshRect() and pass the area that needs to be repainted.","Q_Score":4,"Tags":"python,drawing,wxpython","A_Id":6076453,"CreationDate":"2011-05-20T18:11:00.000","Title":"Force repaint in wxPython Canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering is there any tutorial out there that can teach you how to push multiple files from desktop to a PHP based web server with use of Python application?\nEdited\nI am going to be writing this so I am wondering in general what would be the best method to push files from my desktop to web server. As read from some responses about FTP so I will look into that (no sFTP support sadly) so just old plain FTP, or my other option is to push the data and have PHP read the data thats being send to it pretty much like Action Script + Flash file unloader I made which pushes the files to the server and they are then fetched by PHP and it goes on from that point on.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2176,"Q_Id":6085280,"Users Score":1,"Answer":"I think you're referring to a application made in php running on some website in which case thats just normal HTTP stuff.\nSo just look at what name the file field has on the html form generated by that php script and then do a normal post. (urllib2 or whatever you use)","Q_Score":2,"Tags":"php,python,file-upload","A_Id":6085309,"CreationDate":"2011-05-22T00:27:00.000","Title":"how to upload files to PHP server with use of Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I have an 2d array, A that is 6x6.  I would like to take the first 2 values (index 0,0 and 0,1) and take the average of the two and insert the average into a new array that is half the column size of A (6x3) at index 0,0.  Then i would get the next two indexes at A, take average and put into the new array at 0,1.\nThe only way I know how to do this is using a double for loop, but for performance purposes (I will be using arrays as big as 3000x3000) I know there is a better solution out there! Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1976,"Q_Id":6090288,"Users Score":1,"Answer":"I don't think there is a better solution, unless you have some extra information about what's in those arrays.  If they're just random numbers, you have to do (n^2)\/2 calculations, and your algorithm is reflecting that, running in O((n^2)\/2).","Q_Score":1,"Tags":"python,arrays,indexing,numpy,slice","A_Id":6090407,"CreationDate":"2011-05-22T19:43:00.000","Title":"python numpy array slicing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning wxpython right now and one thing that helps me ALOT is when I'm typing in the text editor I sometimes press the tab key to give me a hint on what I'm looking for...This is great when it works but I notice sometimes it doesn't work and I get lost looking for a syntax I can't remember...\nQuestion is how can I get the suggestion box to pop back up again, Or what am I doing that causes it to stop coming up...\nif it matters I backtracked to 2.7 to learn wx, Windows 7\nEdit: More specifically... when I type: wx.(Here is normally when I would press tab)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":320,"Q_Id":6093313,"Users Score":0,"Answer":"What editor do you use??\nWithout knowing that there's no way we can possibly help you.\nFWIW in vim I use C-x [onp]","Q_Score":0,"Tags":"python","A_Id":6093396,"CreationDate":"2011-05-23T05:51:00.000","Title":"Anyway to bring up suggestion box when typing python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed south and tried a few changes using it, which didn't exactly work out the way I wanted it to. Thankfully, my data is safe but locked into south. I want to remove south and use syncdb normally now, how do I do that without affecting my data?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":4611,"Q_Id":6107978,"Users Score":5,"Answer":"Remove 'south' from INSTALLED_APPS, remove south_migrations table from\n  DB.\n\nAlso, you'll need to delete the Migrations folders from your app folders.","Q_Score":6,"Tags":"python,django,django-south","A_Id":6886466,"CreationDate":"2011-05-24T08:55:00.000","Title":"How do I remove south from a django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I installed south and tried a few changes using it, which didn't exactly work out the way I wanted it to. Thankfully, my data is safe but locked into south. I want to remove south and use syncdb normally now, how do I do that without affecting my data?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":4611,"Q_Id":6107978,"Users Score":3,"Answer":"What does it mean for your data to be \"locked into\" South? The data lives in the database, and South simply creates the schema for you and migrates it when necessary. If you remove South, the data will stay exactly the same.","Q_Score":6,"Tags":"python,django,django-south","A_Id":6108006,"CreationDate":"2011-05-24T08:55:00.000","Title":"How do I remove south from a django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I installed south and tried a few changes using it, which didn't exactly work out the way I wanted it to. Thankfully, my data is safe but locked into south. I want to remove south and use syncdb normally now, how do I do that without affecting my data?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4611,"Q_Id":6107978,"Users Score":10,"Answer":"Remove 'south' from INSTALLED_APPS, remove south_migrations table from DB.","Q_Score":6,"Tags":"python,django,django-south","A_Id":6108042,"CreationDate":"2011-05-24T08:55:00.000","Title":"How do I remove south from a django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"just wondering if anyone of you has come across this. I'm playing around with the Python mail API on Google App Engine and I created an app that accepts a message body and address via POST, creates an entity in the datastore, then a cron job is run every minute, grabs 200 entities and sends out the emails, then deletes the entities.\nI ran an experiment with 1500 emails, had 1500 entities created in the datastore and 1500 emails were sent out. I then look at my stats and see that approx. 45,000 recipients were used from the quota, how is that possible?\nSo my question is at which point does the \"Recipients Emailed\" quota actually count? At the point where I create a mail object or when I actually send() it? I was hoping for the second, but the quotas seem to show something different. I do pass the mail object around between crons and tasks, etc. Anybody has any info on this?\nThanks.\nUpdate: Turns out I actually was sending out 45k emails with a queue of only 1500. It seems that one cron job runs until the previous one is finished and works out with the same entities. So the question changes to \"how do I lock the entities and make sure nobody selects them before sending the emails\"?\nThanks again!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":467,"Q_Id":6109602,"Users Score":2,"Answer":"Instantiating an email object certainly does not count against your \"recipients emailed\" quota. Like other App Engine services, you consume quota when you trigger an RPC, i.e. call send().\nIf you intended to email 1500 recipients and App Engine says you emailed 45,000, your code has a bug.","Q_Score":5,"Tags":"python,google-app-engine","A_Id":6112067,"CreationDate":"2011-05-24T11:21:00.000","Title":"Google App Engine Locking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"just wondering if anyone of you has come across this. I'm playing around with the Python mail API on Google App Engine and I created an app that accepts a message body and address via POST, creates an entity in the datastore, then a cron job is run every minute, grabs 200 entities and sends out the emails, then deletes the entities.\nI ran an experiment with 1500 emails, had 1500 entities created in the datastore and 1500 emails were sent out. I then look at my stats and see that approx. 45,000 recipients were used from the quota, how is that possible?\nSo my question is at which point does the \"Recipients Emailed\" quota actually count? At the point where I create a mail object or when I actually send() it? I was hoping for the second, but the quotas seem to show something different. I do pass the mail object around between crons and tasks, etc. Anybody has any info on this?\nThanks.\nUpdate: Turns out I actually was sending out 45k emails with a queue of only 1500. It seems that one cron job runs until the previous one is finished and works out with the same entities. So the question changes to \"how do I lock the entities and make sure nobody selects them before sending the emails\"?\nThanks again!","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":467,"Q_Id":6109602,"Users Score":3,"Answer":"Use tasks to send the email.\nCreate a task that takes a key as an argument, retrieves the stored entity for that key, then sends the email.\nWhen your handler receives the body and address, store that as you do now but then enqueue a task to do the send and pass the key of your datastore object to the task so it knows which object to send an email for.\nYou may find that the body and address are small enough that you can simply pass them as arguments to a task and have the task send the email without having to store anything directly in the datastore.\nThis also has the advantage that if you want to impose a limit on the number of emails sent within a given amount of time (quota) you can set up a task queue with that rate.","Q_Score":5,"Tags":"python,google-app-engine","A_Id":6141535,"CreationDate":"2011-05-24T11:21:00.000","Title":"Google App Engine Locking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My company has decided to implement a datamart using [Greenplum] and I have the task of figuring out how to go on about it. A ballpark figure of the amount of data to be transferred from the existing [DB2] DB to the Greenplum DB is about 2 TB.\nI would like to know :\n1) Is the Greenplum DB the same as vanilla [PostgresSQL]? (I've worked on Postgres AS 8.3)\n2) Are there any (free) tools available for this task (extract and import)\n3) I have some knowledge of Python. Is it feasible, even easy to do this in a resonable amount of time?\nI have no idea how to do this. Any advice, tips and suggestions will be hugely welcome.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2294,"Q_Id":6110384,"Users Score":0,"Answer":"Many of Greenplum's utilities are written in python and the current DBMS distribution comes with python 2.6.2 installed, including the pygresql module which you can use to work inside the GPDB.\nFor data transfer into greenplum, I've written python scripts that connect to the source (Oracle) DB using cx_Oracle and then dumping that output either to flat files or named pipes.  gpfdist can read from either sort of source and load the data into the system.","Q_Score":0,"Tags":"python,postgresql,db2,datamart,greenplum","A_Id":7550497,"CreationDate":"2011-05-24T12:28:00.000","Title":"Transferring data from a DB2 DB to a greenplum DB","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My company has decided to implement a datamart using [Greenplum] and I have the task of figuring out how to go on about it. A ballpark figure of the amount of data to be transferred from the existing [DB2] DB to the Greenplum DB is about 2 TB.\nI would like to know :\n1) Is the Greenplum DB the same as vanilla [PostgresSQL]? (I've worked on Postgres AS 8.3)\n2) Are there any (free) tools available for this task (extract and import)\n3) I have some knowledge of Python. Is it feasible, even easy to do this in a resonable amount of time?\nI have no idea how to do this. Any advice, tips and suggestions will be hugely welcome.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2294,"Q_Id":6110384,"Users Score":0,"Answer":"Generally, it is really slow if you use SQL insert or merge to import big bulk data.\nThe recommended way is to use the external tables you define to use file-based, web-based or gpfdist protocol hosted files.\nAnd also greenplum has a utility named gpload, which can be used to define your transferring jobs, like source, output, mode(inert, update or merge).","Q_Score":0,"Tags":"python,postgresql,db2,datamart,greenplum","A_Id":23668974,"CreationDate":"2011-05-24T12:28:00.000","Title":"Transferring data from a DB2 DB to a greenplum DB","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm reading text in terminal with\ndescription = raw_input()\nIt works if I write the text and press enter. The problem is when I paste the text from somewhere with Ctrl+Shift+V or with right click + paste. My program immediately ends, description contains only part of the text (I can see it in database).\nDo you know how to do this so paste works? I'm using xfce4-terminal in Ubuntu.\nthank you","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":121,"Q_Id":6115347,"Users Score":3,"Answer":"Make sure that your pasted text doesn't contain any embedded control characters (such as a newline), which could end the input.","Q_Score":0,"Tags":"python,terminal","A_Id":6115447,"CreationDate":"2011-05-24T18:50:00.000","Title":"Problem with reading pasted text in terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a bash script that fires up python and then enters some simple commands before exiting. I've got it firing up python ok, but how do I make the script simulate keyboard input in the python shell, as though a person were doing it?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":500,"Q_Id":6119038,"Users Score":2,"Answer":"Have you tried echo \"Something for input\" | python myPythonScript.py ?","Q_Score":2,"Tags":"python,bash","A_Id":6119079,"CreationDate":"2011-05-25T02:55:00.000","Title":"How to write a bash script that enters text into programs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing some simple programs with opencv in python.  I want to write a few algorithms myself, so need to get at the 'raw' image data inside an image.  I can't just do image[i,j] for example, how can I get at the numbers?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7276,"Q_Id":6127314,"Users Score":0,"Answer":"I do not know opencv python bindings, but in C or C++ you have to get the buffer pointer stored in IplImage. This buffer is coded according to the image format (also stored in IplImage). For RGB you have a byte for R, a byte for G, a byte for B, and so on.\nLook at the API of python bindings,you will find how to access the buffer and then you can get to pixel info.\nmy2c","Q_Score":4,"Tags":"python,opencv,iplimage","A_Id":6127643,"CreationDate":"2011-05-25T15:53:00.000","Title":"Opencv... getting at the data in an IPLImage or CvMat","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know very well how to select a random item from a list with random.choice(seq) but how do I know the index of that element?","AnswerCount":7,"Available Count":1,"Score":0.057080742,"is_accepted":false,"ViewCount":26292,"Q_Id":6127524,"Users Score":2,"Answer":"If the values are unique in the sequence, you can always say:  list.index(value)","Q_Score":28,"Tags":"python,random,indexing,choice","A_Id":6127555,"CreationDate":"2011-05-25T16:11:00.000","Title":"python: how to know the index when you randomly select an element from a sequence with random.choice(seq)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In python I have read in a file into a list using file.readlines() , later on after some logic, I would like to put it back together in a string using fileString = ''.join(file), for some reason, even without a print function, it prints the fileString out to the console up to a certain point, then it just stops. It does not run the rest of the program which is not useful for me.\nWhy does join do this, how do I perhaps pre-allocate how much memory I would like my list\/string to use so that it does not stop. Or some other solution too.\nThank you","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1190,"Q_Id":6130438,"Users Score":1,"Answer":"You should also consider what you are going to do with the resulting string. If you just want to write the contents back to a file, there is no need to join the parts first, you can use file.writelines(strings) directly.","Q_Score":2,"Tags":"python,string,list,memory,join","A_Id":6130864,"CreationDate":"2011-05-25T20:25:00.000","Title":"python join \"large\" file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been thinking about how to implement mirror picking in Python. When I call on service API I get response with IP address. Now I want to take that address and check if it's close to me or not. If not, retry. I thought about pinging, as I have only ~1ms ping to the IP addresses hosted in same data center, but much higher across the world. I looked up some examples of how to implement pinging in Python, but it seems fairly complicated and feels a bit hackish (like checking if target IP is less than 10ms). There may be better ways to tackle this issue, that I may not be aware of.\nWhat are your ideas? I can't download any test file each time to test speed. GeoIP or ping? Or something else?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":881,"Q_Id":6159173,"Users Score":1,"Answer":"Call all the service API instances and use which ever responds quickest.","Q_Score":2,"Tags":"python,ping,geo,geoip","A_Id":6159184,"CreationDate":"2011-05-28T01:47:00.000","Title":"How to choose closest\/fastest mirror in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I want to run my python applications from commandline (under ubuntu) I have to be in the directory where is the source code app.py and run the application with command\npython app.py\nHow can I make it (how is it conventionally done) to run the application from arbitrary directory with the command: app ? Similarly as you type ls, mkdir and other commands?\nthank you","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3763,"Q_Id":6163087,"Users Score":2,"Answer":"Add a shebang: as the top line of the file: #!\/usr\/bin\/python or #!\/usr\/bin\/python3 (you can use the python -B to prevent generation of .pyc files, which is why I don't use \/usr\/bin\/env)\nMake it executable: You will need to do chmod +x app.py\n(optional) Add directory to path, so can call it anywhere: Add a directory with your executable to your $PATH environment variable. How you do so depends on your shell, but is either export PATH=$PATH:\/home\/you\/some\/path\/to\/myscripts (e.g. Linux distros which use bash) or setenv PATH $PATH:\/home\/you\/some\/path\/to\/myscripts (e.g. tcsh like in Mac OS X). You will want to put this, for example, in your .bashrc or whatever startup script you have, or else you will have to repeat this step every time you log in.\n\napp.py will need to be in the myscripts (or whatever you name it) folder. You don't even need to call it app.py, but you can just rename it app.\nIf you wish to skip step #3, you can still do .\/app to run it if you are in the same directory.","Q_Score":6,"Tags":"python,shell,command-line","A_Id":6163126,"CreationDate":"2011-05-28T17:04:00.000","Title":"Turn an application or script into a shell command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I want to run my python applications from commandline (under ubuntu) I have to be in the directory where is the source code app.py and run the application with command\npython app.py\nHow can I make it (how is it conventionally done) to run the application from arbitrary directory with the command: app ? Similarly as you type ls, mkdir and other commands?\nthank you","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3763,"Q_Id":6163087,"Users Score":0,"Answer":"I'm pretty sure you have to make the script executable via chmod +x and put it in the PATH variable of your system.","Q_Score":6,"Tags":"python,shell,command-line","A_Id":6163117,"CreationDate":"2011-05-28T17:04:00.000","Title":"Turn an application or script into a shell command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a client and a server, both written in Python 2.7.\nLets say I wanted to make a multiplayer game server (which I don't at the moment but I'm working towards it). I would need to keep the server up to date (and other clients) on my characters whereabouts, correct?\nHow would I do this with sockets? Send or request information only when it is needed (e.g the character moves, or another players character moves and the server sends the information to other clients) or would I keep a constant socket open to send data real-time of EVERYBODY's movement regardless of if they have actually done something since the last piece of data was sent or not.\nI won't struggle coding it, I just need help with the concept of how I would actually do it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":83,"Q_Id":6171112,"Users Score":1,"Answer":"With TCP sockets it is more typical to leave the connections open, given the teardown & rebuild cost. \nEventually when scaling you will do look into NewIO\\RawIO.\nIf you do not, imagine that the game client might take a step & not get confirmation if sending it to the server & other players.","Q_Score":0,"Tags":"python,sockets","A_Id":6171227,"CreationDate":"2011-05-29T23:29:00.000","Title":"How would I keep a constant piece of data updated through a socket in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a troublesome problem socket.error error: [Errno 10048]: Address already in use. Only one usage of each socket address (protocol\/IP address\/port) is normally permitted during automated tests using Selenium with Python. The problem is so interesting that it runs on one machine (Linux) works correctly, but on another machine (WindowsXP) generates this error.\nI would add that the problem arose after the reinstallation of the system and set up all over again - with the previous configuration everything worked properly.\nIs there maybe something I forgot? Has anyone come up with such a problem before?\nDoes anyone have an idea of \u200b\u200bhow to deal with this problem?\nThe current configuration \/ libraries:\npython 2.7, numpy, selenium.py","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":15849,"Q_Id":6176445,"Users Score":0,"Answer":"There are several possibilities. If none of your tests can listen on some port (you don't say what port) then perhaps your Windows machine is running something on a port that you previously had open; this new service may have appeared during the reinstall. If, on the other hand, it's only a problem for some tests, or it's a little sporadic, then it may be either a programming issue (forgetting to close a socket in an early test which interferes with a later one) or a timing issue  (the earlier test's socket isn't quite through closing before the new one tries to open up). Obviously there are different ways to address each of these problems, but I don't think we can help more than this without more details.","Q_Score":2,"Tags":"python,selenium-rc,socketexception","A_Id":6176514,"CreationDate":"2011-05-30T12:44:00.000","Title":"problem: Socket error [Address already in use] in python\/selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a troublesome problem socket.error error: [Errno 10048]: Address already in use. Only one usage of each socket address (protocol\/IP address\/port) is normally permitted during automated tests using Selenium with Python. The problem is so interesting that it runs on one machine (Linux) works correctly, but on another machine (WindowsXP) generates this error.\nI would add that the problem arose after the reinstallation of the system and set up all over again - with the previous configuration everything worked properly.\nIs there maybe something I forgot? Has anyone come up with such a problem before?\nDoes anyone have an idea of \u200b\u200bhow to deal with this problem?\nThe current configuration \/ libraries:\npython 2.7, numpy, selenium.py","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":15849,"Q_Id":6176445,"Users Score":0,"Answer":"Maybe there is a software on your Windows that already use port 4444, can you try set Selenium to another port and try again?","Q_Score":2,"Tags":"python,selenium-rc,socketexception","A_Id":6176956,"CreationDate":"2011-05-30T12:44:00.000","Title":"problem: Socket error [Address already in use] in python\/selenium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am new to PyDev, written scripts using mainly notepad++ and jedit where I never had these issues.\nIn a module, I have defined a function - get_user_inputs(self). I used the argument self as PyDev would not let me define the function othewise (and apparently it is the right thing to do).\nNow my question is how do I call this function and what argument should I pass?\nfunction(self) does not work and self.function does not work as well.\nThis issue I am seeing only in PyDev. In jedit and notepad++ I am able to execute same code with no issues.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":214,"Q_Id":6188464,"Users Score":1,"Answer":"The argument self is only necessary for class methods. It doesn't make sense for normal functions.\nThat means you either omitted a vital information in your question or there is a bug in PyDev.","Q_Score":0,"Tags":"python,pydev","A_Id":6188499,"CreationDate":"2011-05-31T13:39:00.000","Title":"pydev - call a function with only self as argument","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The simple study is:\nAnt life simulation\nI'm creating an OO structure that see a Class for the Anthill, a Class for the Ant and a Class for the whole simulator.\nNow I'm brainstorming on \"how to\" make Ants 'live'...\nI know that there are projects like this just started but I'm brainstorming, I'm not looking for a just-ready-to-eat-dish.\nSincerely I have to make some tests for understand on \"what is better\", AFAIK Threads, in Python, use less memory than Processes.\nWhat \"Ants\" have to do when you start the simulation is just: moving around with random direction, if they found food ->eat\/bring to the anthill, if they found another ant from another anthill that is transporting food -> attack -> collect food -> do what have to do.... and so on...that means that I have to \"share\" information across ants and across the whole enviroment.\nso I rewrite:\nIt's better to create a Process\/Thread for each Ant or something else?\nEDIT:\nIn cause of my question \"what is better\", I'd upvoted all the smart answers that I received, and I also put a comment on them.\nAfter my tests, I'll accept the best answer.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":1030,"Q_Id":6189398,"Users Score":2,"Answer":"I wrote an ant simulation (for finding a good TSP-solution) and a wouldnt recommend a Thread-Solution. I use a loop to calculate for each ant the next step, so my ants do not really behave concurrently (but synchronize after each step). \nI don't see any reason to model those ants with Threads. Its no advantage in terms of run-time behavior nor is it an advantage in terms of elegancy (of the code)!\nIt might be, admittedly, slightly more realistic to use Threads since real ants are concurrent, but for simulations purposes this is IMHO neglectable.","Q_Score":6,"Tags":"python,multithreading,resources,simulation,multiprocess","A_Id":6189789,"CreationDate":"2011-05-31T14:49:00.000","Title":"Ant simulation: it's better to create a Process\/Thread for each Ant or something else?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The simple study is:\nAnt life simulation\nI'm creating an OO structure that see a Class for the Anthill, a Class for the Ant and a Class for the whole simulator.\nNow I'm brainstorming on \"how to\" make Ants 'live'...\nI know that there are projects like this just started but I'm brainstorming, I'm not looking for a just-ready-to-eat-dish.\nSincerely I have to make some tests for understand on \"what is better\", AFAIK Threads, in Python, use less memory than Processes.\nWhat \"Ants\" have to do when you start the simulation is just: moving around with random direction, if they found food ->eat\/bring to the anthill, if they found another ant from another anthill that is transporting food -> attack -> collect food -> do what have to do.... and so on...that means that I have to \"share\" information across ants and across the whole enviroment.\nso I rewrite:\nIt's better to create a Process\/Thread for each Ant or something else?\nEDIT:\nIn cause of my question \"what is better\", I'd upvoted all the smart answers that I received, and I also put a comment on them.\nAfter my tests, I'll accept the best answer.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1030,"Q_Id":6189398,"Users Score":1,"Answer":"I agree with @delan - it seems like overkill to allocate a whole thread per Ant, especially if you are looking to scale this to a whole anthill with thousands of the critters running around.\nInstead you might consider using a thread to update many ants in a single \"cycle\". Depending on how you write it - you need to carefully consider what data needs to be shared - you might even be able to use a pool of these threads to scale up your simulation.\nAlso keep in mind that in CPython the GIL prevents multiple native threads from executing code at the same time.","Q_Score":6,"Tags":"python,multithreading,resources,simulation,multiprocess","A_Id":6189548,"CreationDate":"2011-05-31T14:49:00.000","Title":"Ant simulation: it's better to create a Process\/Thread for each Ant or something else?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I coded a python application which was running OK as a cron job. Later I added some libraries (e.g. pynotify and other *) because I wanted to be notified with the message describing what is happening, but it seems that cron can't run such an application.\nDo you know some alternative how to run this application every five minutes? I'm using Xubuntu.\n\nimport gtk, pygtk, os, os.path, pynotify\n\nI can run the application without cron without problems.\nCron seems to run the application but it won't show the notification message. In \/var\/log\/cron.log there are no errors. The application executed every minute without problems.\nmy crontab:\n*\/1 * * * * \/home\/xralf\/pythonsrc\/app\nthank you","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":728,"Q_Id":6191624,"Users Score":1,"Answer":"If the cron job runs as \"you\", and if you set the DISPLAY var (export DISPLAY=:0) you should have no issues.","Q_Score":3,"Tags":"python,cron","A_Id":6192123,"CreationDate":"2011-05-31T18:06:00.000","Title":"Notification as a cron job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I coded a python application which was running OK as a cron job. Later I added some libraries (e.g. pynotify and other *) because I wanted to be notified with the message describing what is happening, but it seems that cron can't run such an application.\nDo you know some alternative how to run this application every five minutes? I'm using Xubuntu.\n\nimport gtk, pygtk, os, os.path, pynotify\n\nI can run the application without cron without problems.\nCron seems to run the application but it won't show the notification message. In \/var\/log\/cron.log there are no errors. The application executed every minute without problems.\nmy crontab:\n*\/1 * * * * \/home\/xralf\/pythonsrc\/app\nthank you","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":728,"Q_Id":6191624,"Users Score":0,"Answer":"I don't see any problem in cron job with pynotify? What is the error you are getting?\nCan you run your python code separately to check whether your python code is working really well but only fails with cron?\nCelery is distributed job queue & task manager written in Python but it may be too much for your needs.\nSupervisord also can do some sort of cron task if you know that your program shall close in 5 minutes. So you can configure supervisord to start the task soon after. None of them are not easier like cron job.","Q_Score":3,"Tags":"python,cron","A_Id":6191715,"CreationDate":"2011-05-31T18:06:00.000","Title":"Notification as a cron job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My (rather small) company develops a popular Windows application, but one thing we've always struggled with is testing - it frequently is only tested by the developers on a system similar to the one they developed it on, and when an update is pushed out to customers, there is a segment of our base that experiences issues due to some weird functionality with a Windows patch, or in the case of certain paranoid antivirus applications (I'm looking at you, Comodo and Kaspersky!), they will false-positive on our app. \nWe do manual testing on what 70% of our users use, but it's slow and painful, and sometimes isn't as complete as it should be. Management keeps insisting that we need to do better, but they keep punting on the issue when it comes time to release (testing will take HOW LONG? Just push it out and we'll issue a patch to customers who experience issues!). \nI'd like to design a better system of automated testing using VMs, but could use some ideas on how to implement it, or if there's a COTS product out there, any suggestions would be great. I'm hacking a Python script together that \"runs\" every feature of our product, but I'm not sure how to go about testing if we get a Windows crash (besides just checking to see if it's still in the process list), or worse yet, if Comodo has flagged it for some stupid reason.\nTo best simulate the test environment, I'm trying to keep the VM as \"pure\" as possible and not load a lot of crap on it outside of the OS and the antivirus, and some common apps (Acrobat Reader, Firefox etc).\nAny ideas would be most appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1381,"Q_Id":6208385,"Users Score":1,"Answer":"Interesting problem. One thing to avoid is using the antivirus APIs to check to see if your application triggers them. You want a real live deployment of your application, on the expected operating system, with a real live AV install monitoring it. That way you'll trigger the heuristics monitoring as well as the simple \"does this code match that checksum\" that the API works with.\nYou haven't told us what your application is written in, but if your test suite for your application actually exercises portions of the application, rather than testing single code paths, that may be a good start. Ideally, your integration test suite is the same test suite you use to check for problems on your deploy targets. Your integration testing should verify the input AND the output for each test in a live environment, which SHOULD catch crashes and the like. Also, don't forget to check for things that take much longer than they should, that's an unfortunately common failure mode. Most importantly, your test suite needs to be easy enough to write, change, and improve that it actually stays in sync with the product. Tests that don't test everything are useless, and tests that aren't run are even worse. If we had more information about how your program works, we could give better advice about how to automate that. \nYou'll probably want a suite of VM images across your intended deploy targets, in various states of patch (and unpatch). For some applications, you'll need a separate VM for each variant of IE, since that changes other aspects of the system. Be very careful about which combination of things you have in each VM. Don't test more than one AV at a time. Update the AVs in your snapshots before running your tests. If you have a large enough combination software in your images, you might need to automate image creation - get a base system build, update to the latest patch level, then script the installation of AV and other application combinations.\nYes, maintaining this farm of VMs will be a pain, but if you script the deploy of your application, and have good snapshots and a plan for patching and updating the snapshots, the actual test suite itself shouldn't take all that long to run given appropriate hardware. You'll need to investigate the VM solutions, but I'd probably start with VMWare.","Q_Score":5,"Tags":"python,testing,automation,functional-testing,cots","A_Id":6208551,"CreationDate":"2011-06-01T22:14:00.000","Title":"How can I automate antivirus\/WSUS patch testing of my Windows driver and binary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a program that upload files from my nokia cell phone files to the web server which I am already done writing that. But, my program only does his job only one time and what I want is that I want to call that function for let's say every 5 mins again and again which I do not know how to do it.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":244,"Q_Id":6219063,"Users Score":2,"Answer":"You can use the time module and the sleep function.","Q_Score":2,"Tags":"python,mobile","A_Id":6219095,"CreationDate":"2011-06-02T18:59:00.000","Title":"Repeating function over certain amount of time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a couple different versions of Python installed on my Mac. The default version is 2.5, so when I install a module it gets installed to 2.5. I need to be able to install some modules to a different version of Python because I am working on projects that use different versions. Any one know how to accomplish this? Thanks for your help.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4874,"Q_Id":6220274,"Users Score":3,"Answer":"If you're installing through setuptools (ie python setup.py), it will install to the lib directory for the python executable you use (unless it's a broken package).","Q_Score":8,"Tags":"python,module","A_Id":6220717,"CreationDate":"2011-06-02T20:54:00.000","Title":"Install python module to non default version of python on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am now trying some stuff with PCA but it's very important for me to know which are the features responsible for each eigenvalue. \nnumpy.linalg.eig gives us the diagonal matrix already sorted but I wanted this matrix with them at the original positions. Does anybody know how I can make it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1121,"Q_Id":6227589,"Users Score":1,"Answer":"What Sven mentioned in his comments is correct. There is no \"default\" ordering of the eigenvalues. Each eigenvalue is associated with an eigenvector, and it is important is that the eigenvalue-eigenvector pair is matched correctly. You'll find that all languages and packages will do so. \nSo if R gives you eigenvalues [e1,e2,e3 and eigenvectors [v1,v2,v3], python probably will give you (say) [e3,e2,e1] and [v3,v2,v1].\nRecall that an eigenvalue tells you how much of the variance in your data is explained by the eigenvector associated with it. So, a natural sorting of the eigenvalues (that is intuitive to us) that is useful in PCA, is by size (either ascending or descending). That way, you can easily look at the eigenvalues and identify which ones to keep (large, as they explain most of the data) and which ones to throw (small, which could be high frequency features or just noise)","Q_Score":1,"Tags":"python,pca","A_Id":6229101,"CreationDate":"2011-06-03T13:18:00.000","Title":"Non sorted eigenvalues for finding features in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to grab some data from websites in my django website.\nNow i am confused whether i should use python parsing libraries or web crawling libraries. Does search engine libraries also fall in same category\nI want to know how much is the difference between the two and if i want to use those functions  inside my website which should i use","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2480,"Q_Id":6236794,"Users Score":1,"Answer":"HTML parse will parse the page and you can collect the links present in it. These links you can add to queue and visit these pages. Combine these steps in a loop and you made a basic crawler.\nCrawling libraries are the ready to use solutions which do the crawling. They provide more features like detection of recursive links, cycles etc. A lot of features you would want to code would have already been done within these libraries.\nHowever first option is preferred if you have some special requirements which libraries do not satisfy.","Q_Score":4,"Tags":"python,django,web-crawler","A_Id":6236831,"CreationDate":"2011-06-04T12:41:00.000","Title":"How much is the difference between html parsing and web crawling in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have two trees in python. I need to compare them in a customized way according to the following specifications. Suppose I have a tree for entity E1 and a tree for entity E2. I need to traverse both the trees starting from E1 and E2 and moving upwards till I get to a common root. (Please note that I have to start the traversal from node E1 on the first tree and node E2 on the second tree.)  Then I need to compare the count of the lengths of both their paths.\nCan someone provide me an insight as to how to do this in Python? Can the classical tree traversal algorithms be useful here?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":332,"Q_Id":6241245,"Users Score":1,"Answer":"That they are trees is not even relevant to the solution. You're looking for how long it takes for two single-linked (the parent link) lists to converge into the same list. \nSimply follow the links, but keep a length count for each visited node. Once you reach an already visited node, sum the previously found count and the new one. This won't work if either list ends up circular, but if they do it's not a proper tree anyway. A way to fix that case is to track separate visited dictionaries for either branch; if you reach a node visited in its own branch, you can stop traversing that branch as there's no point recounting the loop.\nThis all naturally assumes you can find the parent of any node. The simplest tree structures don't actually have that link.","Q_Score":1,"Tags":"python,tree","A_Id":6242721,"CreationDate":"2011-06-05T05:49:00.000","Title":"Tree traversal in a customised way in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to be able to set breakpoints to every method of a C++ class in gdb.\nI think the easiest way to do this is probably python, since now python has complete access to gdb.  I know very little python, and with gdb on top of it, it's even harder.  I am wondering if anyone knows how to write a class python code that sets breakpoints to every method of a named class in gdb.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":605,"Q_Id":6267308,"Users Score":0,"Answer":"You can generate (for example using python) a .gdbrc file with a line containing \n'break C::foo'\nfor every function of your class C and then start gdb.","Q_Score":4,"Tags":"c++,python,debugging,gdb","A_Id":6658184,"CreationDate":"2011-06-07T15:06:00.000","Title":"gdb python programming: how to write code that will set breakpoints to every method of a C++ class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a website that I'm trying to scrape using Python & BeautifulSoup. The site itself can be viewed in 2 languages(Thai or English); all you have to do is to click on either the Thai or UK flag on the upper right corner of the screen and the data is displayed in the selected language. When in comes to the script though, I can only scrape the data in Thai (which is the default language) and I couldn't figure out how to get the data in English because the URL doesn't change when you click on either the Thai or UK flag. Looking at the source for the page, there are no href associated with either flag. I turned on Firebug tracing and tried to search for something to give me a clue but haven't found anything (then again you'd have to know exactly what to look for in order to know what's going on and that's my problem).\nThanks,\nGlenn","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":6268580,"Users Score":2,"Answer":"You haven't said what the site is so impossible to answer for sure. But a couple of suggestions. If the url does not change when you click the flag, then either:\na) The english is already in the html document, and the relevant content is being switched with javascript\nb) The english content is being fetched via an ajax request and javascript is being used to edit the DOM\nc) The page fully reloads with english content. \nPresumably in all these cases the language preference must be stored either server-side in the session or client-side with cookies.\nFirst tests are try turning off cookies and javascript to see what happens. Then with cookies, js back on use Firebug or Firefox to view network requests being made.","Q_Score":0,"Tags":"python,beautifulsoup","A_Id":6268759,"CreationDate":"2011-06-07T16:36:00.000","Title":"Could not scrape data in English, help!","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would expect the pydev package to rename all references in a project when rafactoring a module name. However, this is not the case. Anyone knows how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":616,"Q_Id":6269493,"Users Score":0,"Answer":"delete the project in eclipse and then create a new project in eclipse with the projects new name. This will automatically add the projects contents into the new project","Q_Score":6,"Tags":"python,eclipse,refactoring,pydev","A_Id":17780872,"CreationDate":"2011-06-07T17:49:00.000","Title":"Pydev for Eclipse does not change all reference when renaming package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to simulate touch event, keyboard event on mobile device. Can I do it with MonkeyRunner? Also, I have the impression that it only works with SDK?\nI want the application to be installed on mobile, which will perform some random touch, keyboard events. Is it possible with MonkeyRunner?\nIf yes, please provide me help on how to start writing python for mobile, and how to make project for android in Python. I have used Eclipse for java for android, but not for python.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1492,"Q_Id":6275277,"Users Score":1,"Answer":"I want to simulate touch event, keyboard event on mobile device. Can I do it with MonkeyRunner? \n\nFrom your development machine, yes. Per your question title, you cannot use MonkeyRunner on a device.\n\nAlso, I have the impression that it only works with SDK?\n\nYes.\n\nI want the application to be installed on mobile, which will perform some random touch, keyboard events. Is it possible with MonkeyRunner?\n\nFortunately, no, as this would be a massive security hole.","Q_Score":0,"Tags":"android,python,monkeyrunner","A_Id":6278753,"CreationDate":"2011-06-08T07:02:00.000","Title":"Can I use MonkeyRunner tool to work in mobile as application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an urgent problem because my time is running out: I let my calculations process on a server with 8 cores therefore I'm using openMP in my c++ code and it works fine. Of course I'm not the only one who is using the server, so my capacity is not always 800%CPU. \nBut it happened now several times that someone who started his python prog on the machine paralyzed mine and his prog completely: Although I was still using around 500%CPU the code was running approx. 100x slower - for me and the other guy. Do you have an idea what the reason could be, how to prevent it?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":290,"Q_Id":6289668,"Users Score":5,"Answer":"There can be a number of reasons for this, for example:\n\nIncreased failure rate in the branch prediction\nExhausted CPU cache\nFilled up the memory bus\nToo much context switching (this have an effect on many things, including all the previous points)","Q_Score":1,"Tags":"c++,python,openmp","A_Id":6289692,"CreationDate":"2011-06-09T07:50:00.000","Title":"programs paralyzing each other on the server (c++ with openMP and python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a django web app in which I would like to have a registration process. In this  registration process I have of course a form asking for name, email and password. What I would like to do is, send the form via post to 2 different places. One of which is of course the registration database which saves the password and the like, and the other being the Emencia newsletter app. In the case it helps, Emencia only needs email and a name (optional).\nSo how can I do this with only one form, 2 places to send it to and, taking just some of the data of the form and not all?\nThank you!","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2961,"Q_Id":6298813,"Users Score":0,"Answer":"You can't. There is no way to send a form to two ressources.\nWhat you CAN do is send a HTTP request in your register script to the newsletter script, e.g. using urllib2.","Q_Score":2,"Tags":"javascript,python,html,django,http-post","A_Id":6298838,"CreationDate":"2011-06-09T20:25:00.000","Title":"html post form different destinations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I saw you posting around decorators. I am having a hard time finding out how to Mock a decorator. Most searches show me how to write a decorate to help tes, but to be clear, I already have decorators and when I am unittesting a function that HAS a decorator I would like to mock it so its response is not part of the test.\nAny guidance?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":488,"Q_Id":6311705,"Users Score":0,"Answer":"You can't mock a decorator.  A decorator replaces your function at compile time with the decorated function.  If a function is decorated, you cannot test that function without the decorator without pulling the guts of the function out into another (non-decorated) function.","Q_Score":0,"Tags":"python,unit-testing,testing,mocking,decorator","A_Id":6312040,"CreationDate":"2011-06-10T20:25:00.000","Title":"Python\/Django Patching\/Mocking a functions current decorator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've made a program that calculates the flat rate interest of a loan based on the amount borrowed, the %\/year (interest), and the length of time to pay it back... \nhere's where my problem starts:\nI let the user input the years to pay it back, BUT, if the length of time is under a year the user is forced to use a decimal like \"0.5\" for example and it reads as an error \"invalid literal for int() with base 10: '0.5'\", am I forgetting to do something???","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":6315109,"Users Score":0,"Answer":"Maybe float(\"0.5\")? that might be more suited to your problem.","Q_Score":0,"Tags":"python,decimal","A_Id":6315223,"CreationDate":"2011-06-11T09:17:00.000","Title":"I don't know how to change an input into integer with decimals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm a newbie to developing with Python and I'm piecing together the information I need to make intelligent choices in two other open questions. (This isn't a duplicate.)\nI'm not developing using a framework but building a web app from scratch using the gevent library. As far as front-end web servers go, it seems I have three choices: nginx, apache, and lighttpd.\nFrom all accounts that I've read, nginx's mod_wsgi isn't suitable.\nThat leaves two choices - lighttpd and Apache. Under heavy load, am I going to see major differences in performance and memory consumption characteristics? I'm under the impression Apache tends to be memory hungry even when not using prefork, but I don't know how suitable lighttp is for Python apps.\nAre there any caveats or benefits to using lighttpd over apache? I really want to hear all the information you can possibly bore me with!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2472,"Q_Id":6319575,"Users Score":1,"Answer":"That you have mentioned gevent is important. Does that mean you are specifically trying to implement a long polling application? If you are and that functionality is the bulk of the application, then you will need to put your gevent server behind a front end web server that is implemented using async techniques rather that processes\/threading model. Lighttd is an async server and fits that bill whereas Apache isn't. So use of Apache isn't good as front end proxy for long polling application. If that is the criteria though, would actually suggest you use nginx rather than Lighttpd.\nNow if you are not doing long polling or anything else that needs high concurrency for long running requests, then you aren't necessarily going to gain too much by using gevent, especially if intention is to use a WSGI layer on top. For WSGI applications, ultimately the performance difference between different servers is minimal because your application is unlikely to be a hello world program that the benchmarks all use. The real bottlenecks are not the server but your application code, database, external callouts, lack of caching etc etc. In light of that, you should just use whatever WSGI hosting mechanism you find easier to use initially and when you properly work out what the hosting requirements are for your application, based on having an actual real application to test, then you can switch to something more appropriate if necessary.\nIn summary, you are just wasting your time trying to prematurely optimize by trying to find what may be the theoretically best server when in practice your application is what you should be concentrating on initially. After that, you also should be looking at application monitoring tools, because without monitoring tools how are you even going to determine if one hosting solution is better than another.","Q_Score":3,"Tags":"python,apache,lighttpd","A_Id":6319726,"CreationDate":"2011-06-12T01:31:00.000","Title":"Apache + mod_wsgi \/ Lighttpd + wsgi - am I going to see differences in performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie to developing with Python and I'm piecing together the information I need to make intelligent choices in two other open questions. (This isn't a duplicate.)\nI'm not developing using a framework but building a web app from scratch using the gevent library. As far as front-end web servers go, it seems I have three choices: nginx, apache, and lighttpd.\nFrom all accounts that I've read, nginx's mod_wsgi isn't suitable.\nThat leaves two choices - lighttpd and Apache. Under heavy load, am I going to see major differences in performance and memory consumption characteristics? I'm under the impression Apache tends to be memory hungry even when not using prefork, but I don't know how suitable lighttp is for Python apps.\nAre there any caveats or benefits to using lighttpd over apache? I really want to hear all the information you can possibly bore me with!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2472,"Q_Id":6319575,"Users Score":5,"Answer":"Apache...\nApache is by far the most widely used web server out there. Which is a good thing. There is so much more information on how to do stuff with it, and when something goes wrong there are a lot of people who know how to fix it. But, it is also the slowest out of the box; requring a lot of tweaking and a beefier server than Lighttpd. In your case, it will be a lot easier to get off the ground using Apache and Python. There are countless AMP packages out there, and many guides on how to setup python and make your application work. Just a quick google search will get you on your way. Under heavy load, Lighttpd will outshine Apache, but Apache is like a train. It just keeps chugging along.\nPros\n\nWide User Base\nUniversal support\nA lot of plugins\n\nCons\n\nSlow out of the box\nRequires performance tweaking \nMemory whore (No way you could get it working on a 64MB VPS)\n\nLighttpd...\nLighttpd is the new kid on the block. It is fast, powerful, and kicks ass performance wise (not to mention use like no memory). Out of the box, Lighttpd wipes the floor with Apache. But, not as many people know Lighttpd, so getting it to work is harder. Yes, it is the second most used webserver, but it does not have as much community support behind it. If you look here, on stackoverflow, there is this dude who keeps asking about how to get his Python app working but nobody has helped him. Under heavy load, if configured correctly, Lighttpd will out preform Apache (I did some tests a while back, and you might see a 200-300% performance increase in requests per second).  \nPros\n\nFast out of the box\nUses very little memory\n\nCons\n\nNot as much support as Apache\nSometimes just does not work \n\nNginx\nIf you were running a static website, then you would use nginx. you are correct in saying nginx's mod_wsgi isn't suitable.\nConclusion\nBenefits? There are both web servers; designed to be able to replace one another. If both web servers are tuned correctly and you have ample hardware, then there is no real benefit of using one over another. You should try and see which web server meets your need, but asking me; I would say go with Lighttpd. It is, in my opinion, easier to configure and just works.\nAlso, You should look at Cherokee Web Server. Mad easy to set up and, the performance aint half bad. And you should ask this on Server Fault as well.","Q_Score":3,"Tags":"python,apache,lighttpd","A_Id":6319667,"CreationDate":"2011-06-12T01:31:00.000","Title":"Apache + mod_wsgi \/ Lighttpd + wsgi - am I going to see differences in performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I found this in an interview questions forum:\n\nWrite a function to return well formed\n  numbers of size n. A well formed\n  number is one in which digit i is less\n  than digit i+1, for example 123, 246, 349 etc\n\nSo here's how I would do it in Python:\n\n\ninput number of digits (x)\nloop over all the numbers of x digits\nfor each number n, if str(n) == \"\".join(sorted(str(n))), print number\n\n\nSo my question is... Is this method efficient and pythonic? I'm sure there should be a more elegant way out there, so any tips would be great appreciated.\nCraig","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":371,"Q_Id":6319583,"Users Score":0,"Answer":"1) You are trying to return well formed numbers 'up to' n digits in your approach, that is probably not the thing they were asking for\n2) Sorting each number in that range is a bit silly. You may check whether each number is a well formed one by comparing the consecutive digits, which will take O(d) time for each number. However, sorting will definitely take more than that.","Q_Score":0,"Tags":"algorithm,performance,python","A_Id":6319610,"CreationDate":"2011-06-12T01:33:00.000","Title":"Return well-formed numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I found this in an interview questions forum:\n\nWrite a function to return well formed\n  numbers of size n. A well formed\n  number is one in which digit i is less\n  than digit i+1, for example 123, 246, 349 etc\n\nSo here's how I would do it in Python:\n\n\ninput number of digits (x)\nloop over all the numbers of x digits\nfor each number n, if str(n) == \"\".join(sorted(str(n))), print number\n\n\nSo my question is... Is this method efficient and pythonic? I'm sure there should be a more elegant way out there, so any tips would be great appreciated.\nCraig","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":371,"Q_Id":6319583,"Users Score":2,"Answer":"In my opinion, you've already lost if you're checking every number.\nI'd implement this with a stack. Start by putting 1-9 on the stack. When you take a number off of the stack, add another number to it if you can following those rules. If it's n digits, then print it. If it's not n digits, put it back on the stack.\nLet's say you grab 7 from the stack. 8 and 9 are the only numbers bigger than 7, so in o(1) time you can put 78 and 79 on the stack.","Q_Score":0,"Tags":"algorithm,performance,python","A_Id":6319609,"CreationDate":"2011-06-12T01:33:00.000","Title":"Return well-formed numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system. \nI'd like for the items in the game to descend from one base Item class, containing some attributes that every item has, such as damage and weight. My problems begin when I try to add some functionality to these items. When an item's damage gets past a threshold, it should be destroyed. And there lies my problem: I don't really know how to accomplish that.\nSince del self won't work for a million different reasons, (Edit: I am intentionally providing the use of 'del' as something that I know is wrong. I know what garbage collection is, and how it is not what I want.) how should I do this (And other similar tasks)? Should each item contain some kind of reference to it's container (The player, I guess) and 'ask' for itself to be deleted? \nThe first thing that comes to mind is a big dictionary containing every item in the game, and each object would have a reference to this list, and both have and know it's own unique ID. I don't like this solution at all and I don't think that it's the right way to go at all. Does anybody have any suggestions?\nEDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":1852,"Q_Id":6325775,"Users Score":1,"Answer":"You're conflating two meanings of the \"destroying\" idea.  The Item should get destroyed in a \"gameplay\" sense.  Let the garbage collector worry about when to destroy it as an object.\nWho has a reference to the Item?  Perhaps the player has it in his inventory, or it is in a room in the game.  In either case your Inventory or Room objects know about the Item. Tell them the Item has been destroyed (in a gameplay sense) and let them handle that.  Perhaps they'll now keep a reference to a \"broken\" Item.  Perhaps they'll keep track of it, but not display it to the user.  Perhaps they'll delete all references to it, in which case the object in memory will soon be deleted.\nThe beauty of object-oriented programming is that you can abstract these processes away from the Item itself: pass the messages to whoever needs to know, and let them implement in their own way what it means for the Item to be destroyed.","Q_Score":5,"Tags":"python,oop","A_Id":6325854,"CreationDate":"2011-06-13T01:02:00.000","Title":"Managing Items in an Object Oriented game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system. \nI'd like for the items in the game to descend from one base Item class, containing some attributes that every item has, such as damage and weight. My problems begin when I try to add some functionality to these items. When an item's damage gets past a threshold, it should be destroyed. And there lies my problem: I don't really know how to accomplish that.\nSince del self won't work for a million different reasons, (Edit: I am intentionally providing the use of 'del' as something that I know is wrong. I know what garbage collection is, and how it is not what I want.) how should I do this (And other similar tasks)? Should each item contain some kind of reference to it's container (The player, I guess) and 'ask' for itself to be deleted? \nThe first thing that comes to mind is a big dictionary containing every item in the game, and each object would have a reference to this list, and both have and know it's own unique ID. I don't like this solution at all and I don't think that it's the right way to go at all. Does anybody have any suggestions?\nEDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1852,"Q_Id":6325775,"Users Score":0,"Answer":"Assuming you call a method when the item is used, you could always return a boolean value indicating whether it's broken.","Q_Score":5,"Tags":"python,oop","A_Id":6325828,"CreationDate":"2011-06-13T01:02:00.000","Title":"Managing Items in an Object Oriented game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system. \nI'd like for the items in the game to descend from one base Item class, containing some attributes that every item has, such as damage and weight. My problems begin when I try to add some functionality to these items. When an item's damage gets past a threshold, it should be destroyed. And there lies my problem: I don't really know how to accomplish that.\nSince del self won't work for a million different reasons, (Edit: I am intentionally providing the use of 'del' as something that I know is wrong. I know what garbage collection is, and how it is not what I want.) how should I do this (And other similar tasks)? Should each item contain some kind of reference to it's container (The player, I guess) and 'ask' for itself to be deleted? \nThe first thing that comes to mind is a big dictionary containing every item in the game, and each object would have a reference to this list, and both have and know it's own unique ID. I don't like this solution at all and I don't think that it's the right way to go at all. Does anybody have any suggestions?\nEDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","AnswerCount":6,"Available Count":3,"Score":-0.0333209931,"is_accepted":false,"ViewCount":1852,"Q_Id":6325775,"Users Score":-1,"Answer":"at first: i don't have any python experience, so think about this in a more general way\nyour item should neither know or care ... your Item should have an interface that says it is something destroyable. containers and other objects that care about things that can be destroyed, can make use of that interface\nthat destroyable interface could have some option for consuming objects to register a callback or event, triggered when the item gets destroyed","Q_Score":5,"Tags":"python,oop","A_Id":6325868,"CreationDate":"2011-06-13T01:02:00.000","Title":"Managing Items in an Object Oriented game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having trouble figuring out how to do this.\nI'm trying to run a python script for a set duration. And every 1\/10 of the duration I need it to run something. The problem is this step can take any amount of time to complete. I cannot go over the maximum duration set at the start. \nExample:\nDuration 20 hours\nInterval = 20\/10 = 2 hours (This can change if it needs to)\nEvery two hours it runs function(). function() takes between 0-60 minutes to complete. And then it sleeps. How can I make it so that it continues to run 9 more times, but doesn't go over the max duration?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":363,"Q_Id":6335548,"Users Score":0,"Answer":"Fork a subprocess to do the actual job; kill the job if it exceeds your run-time limit.","Q_Score":0,"Tags":"python,time","A_Id":6336220,"CreationDate":"2011-06-13T19:53:00.000","Title":"Python Time Problem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do the following:\n\nHave a software running written in Python 2.7\nThis software connects to a database (Currently a MySQL database)\nThis software listen for connections on a port X on TCP\nWhen a connection is established, a client x request or command something, then the software use the database to store, remove or fetch information (Based on the request or command).\n\nWhat I currently have in head is the classic approach of connecting to the database, store the connection to the database in an object (as a variable) that is passed in the threads that are spawned by the connection listener, then these threads use the variable in the object to do what they need to do with the database connection. (I know that multi-processing is better then multi-threading in Python, but it's not related to my question at this time)\nNow my question, how should I use SQLAlchemy in this context? I am quite confused even although I have been reading quite a lot of documentation about it and there doesn't seem to be \"good\" examples on how to handle this kind of situation specifically even although I have been searching quite a lot.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":6337812,"Users Score":1,"Answer":"What is the problem here? SQLAlchemy maintains a thread-local connection pool..what else do you need?","Q_Score":0,"Tags":"python,sqlalchemy","A_Id":6338431,"CreationDate":"2011-06-14T00:14:00.000","Title":"How to use SQLAlchemy in this context","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to run a script on a folder full of word documents that reads through the documents and pulls out images and their captions (text right below the images). From the research I've done, I think pywin32 might be a viable solution. I know how to use pywin32 to find strings and pull them out, but I need help with the images part. How can I read through a docx file and have an event occur when an image is found? Thank you for any help! I am using Python 2.7.","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":8790,"Q_Id":6345156,"Users Score":4,"Answer":"Docx files can be unzipped for extracting the images.","Q_Score":6,"Tags":"python,image,ms-word,extract,pywin32","A_Id":6932276,"CreationDate":"2011-06-14T14:29:00.000","Title":"Using Python to extract images and text from a word document","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question list for a questionnaire which are stored in database but some questions has to be modified by certain parameters.\nFor example, if someone selects an employer name from previous page, some questions should have employer's name \"Do you like to work for ........ company ?\".\nOne solution might be savinf question like \"Do you like to work for {0}\" and formatting it but I am not sure how I can implement it with python.\nBut how can I detect which questions need to be modified ?\nIs there any easy way to do it in django ?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":6355449,"Users Score":1,"Answer":"The most flexible way - is to create custom template filter. If string needs formatting, it will do that, if it doesn't - just output it.","Q_Score":1,"Tags":"python,django,string","A_Id":6355486,"CreationDate":"2011-06-15T09:09:00.000","Title":"Formatting strings with python in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python function registered as a View in Plone.  I need to be able to call another function from within this registered function.  I'm not sure if it would be best to register this other function as a view as well and try to call that (don't know how to call other views), or if there is a better way to handle this.\nBasically I'm creating a function in Python that needs to be callable from other Python functions (that are registered as Views).\n\nEdit -\nI have tried calling it like any other function:\n\n(pytest.py)\ndef Test(self):\n    return \"TEST\"\nAnd in my Python script registered as a view:\nimport pytest\ndef PageFunction(self):\n    return pytest.Test()\nHowever, this always seems to crash.  If I leave the pytest.Test() out and return a simple string, it seems to work fine (so I don't think the import pytest line is causing any problems...)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":327,"Q_Id":6359581,"Users Score":1,"Answer":"Just import it and call it as any other function.  You don't want to make it a view - that requires you to do a MultiAdapter lookup which is a real pain, and completely unnecessary.\n[Edit - strictly using a view is a MultiAdapter lookup, but you can shortcut it via traversal, but that still isn't worth the effort]","Q_Score":0,"Tags":"python,views,plone","A_Id":6360580,"CreationDate":"2011-06-15T14:44:00.000","Title":"Python Plone views call others","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been wondering lately how various operations I perform on basic types like strings and integers work in terms of performance, and I figure I could get a much better idea of this if I knew how those basic types were implemented (i.e. I've heard strings and integers are immutable in Python. Does that mean any operation that modifies one character in a string is O(n) because a completely new string has to be created? How about adding numbers?)\nI'm curious about this in both Python and Perl, and felt silly asking basically the same question twice, so I'm just wrapping it into one.\nIf you can include some example operation costs with your answer, that would make it even more helpful.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1412,"Q_Id":6364430,"Users Score":6,"Answer":"Perl strings definitely are not immutable.  Each string has a buffer, the initial offset of the string in the buffer, the length of buffer, and the amount of the buffer used.  Additionally, for utf8 strings, the character length is cached when it needs to be calculated.  At one point, there was some caching of additional character offset to byte offset information too, but I'm not certain that's still in place.\nIf the buffer needs to be increased, it reallocs it.  Perl on many platforms knows the granularity of the system malloc, so it can allocate a, say, 14 byte buffer for a 11 byte string, knowing that that won't actually take any additional memory.\nThe initial offset allows O(1) removal of data from the beginning of the string.","Q_Score":12,"Tags":"python,perl","A_Id":6368606,"CreationDate":"2011-06-15T21:10:00.000","Title":"How are basic data types (strings and integers) implemented in Python and Perl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a web page that uses a Python cgi script to store requested information for later retrieval by me. As an example, the web page has a text box that asks \"What is your name?\" When the user inputs his name and hits the submit button, the web page calls the Python cgi script which writes the user's name to mytextfile.txt on the web site. The problem is that if anyone goes to www.mydomain.com\/mytextfile.txt, they can see all of the information written to the text file. Is there a solution to this? Or am I using the wrong tool? Thanks for your time.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":6371097,"Users Score":2,"Answer":"Definitely the wrong tool. Multiple times.\n\nStore the file outside of the document root.\nStore a key to the file in the user's session.\nUse a web framework.\nUse WSGI.","Q_Score":1,"Tags":"python,cgi","A_Id":6371127,"CreationDate":"2011-06-16T11:30:00.000","Title":"Python CGI how to save requested information securely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a web page that uses a Python cgi script to store requested information for later retrieval by me. As an example, the web page has a text box that asks \"What is your name?\" When the user inputs his name and hits the submit button, the web page calls the Python cgi script which writes the user's name to mytextfile.txt on the web site. The problem is that if anyone goes to www.mydomain.com\/mytextfile.txt, they can see all of the information written to the text file. Is there a solution to this? Or am I using the wrong tool? Thanks for your time.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":6371097,"Users Score":0,"Answer":"Store it outside the document root.","Q_Score":1,"Tags":"python,cgi","A_Id":6371124,"CreationDate":"2011-06-16T11:30:00.000","Title":"Python CGI how to save requested information securely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to access my linkedin account from command prompt and then i wanted to send mails from my account using command.\nAlso, I need the delivery reports of the mails.\nCan anyone knows how can use that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1130,"Q_Id":6373779,"Users Score":4,"Answer":"The Member to Member API will return a 2xx status code if your message is accepted by LinkedIn. And a 4xx status code if there's an error.\nThis means the message was put into the LinkedIn system, not that it has been opened, read, emailed, etc. You cannot get that via the API.","Q_Score":0,"Tags":"python,command,linkedin","A_Id":6393078,"CreationDate":"2011-06-16T14:43:00.000","Title":"How to access linkedin from python command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller?\nFurther, how can one rotate it from horizontal to vertical?","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":870128,"Q_Id":6390393,"Users Score":23,"Answer":"In current versions of Matplotlib, you can do axis.set_xticklabels(labels, fontsize='small').","Q_Score":421,"Tags":"python,matplotlib","A_Id":34919615,"CreationDate":"2011-06-17T18:49:00.000","Title":"Matplotlib make tick labels font size smaller","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller?\nFurther, how can one rotate it from horizontal to vertical?","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":870128,"Q_Id":6390393,"Users Score":16,"Answer":"For smaller font, I use \nax1.set_xticklabels(xticklabels, fontsize=7)\nand it works!","Q_Score":421,"Tags":"python,matplotlib","A_Id":37869225,"CreationDate":"2011-06-17T18:49:00.000","Title":"Matplotlib make tick labels font size smaller","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a huge text file, each line seems like this:\n\nSome sort of general menu^a_sub_menu_title^^pagNumber\n\nNotice that the first \"general menu\" has white spaces, the second part (a subtitle) each word is separate with \"_\" character and finally a number (a pag number). I want to split each line in 3 (obvious) parts, because I want to create some sort of directory in python.\nI was trying with re module, but as the caret character has a strong meaning in such module, I couldn't figure it out how to do it.\nCould someone please help me????","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2372,"Q_Id":6393620,"Users Score":0,"Answer":"It's also possible that your file is using a format that's compatible with the csv module, you could also look into that, especially if the format allows quoting, because then line.split would break. If the format doesn't use quoting and it's just delimiters and text, line.split is probably the best.\nAlso, for the re module, any special characters can be escaped with \\, like r'\\^'. I'd suggest before jumping to use re to 1) learn how to write regular expressions, 2) first look for a solution to your problem instead of jumping to regular expressions - \u00abSome people, when confronted with a problem, think \"I know, I'll use regular expressions.\" Now they have two problems. \u00bb","Q_Score":0,"Tags":"python,regex,text,split","A_Id":6393773,"CreationDate":"2011-06-18T03:13:00.000","Title":"Split string with caret character in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using selenium2 RC with the python client (selenium.py) and I need to get the version of the selenium on the server. (for example \"2rc2\",\"2rc3\" etc.)\nis there any command i can send to the server to get its version?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":10529,"Q_Id":6424975,"Users Score":5,"Answer":"I know this was already answered but it may help someone else. Another way to get your selenium server's version is right click the selenium-server.jar, and open it was any file archiver software such as 7zip or winrar. There you should find a file called VERSION.txt which will tell you your servers version","Q_Score":2,"Tags":"python,python-2.7,selenium-webdriver,selenium-rc","A_Id":7946600,"CreationDate":"2011-06-21T12:08:00.000","Title":"how to get the version of Selenium RC server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.\nI want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django\u2019s ORM for an alternative? Now I have to re-write my domain entity classes from scratch.\nSo it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this.\nDoes anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","AnswerCount":4,"Available Count":4,"Score":0.1973753202,"is_accepted":false,"ViewCount":2441,"Q_Id":6425535,"Users Score":4,"Answer":"Can you seriously envisage a possibility that you're going to just ditch the Django ORM, but keep everything else? Or that if you ditched Django totally, any of your code is still going to be applicable?\nYou don't complain that if you ditched Django, you'll have to rewrite all your templates. Of course you will, that's to be expected. So why is it OK for the presentation layer to be bound up with the framework, but not the persistence layer?\nThis sort of up-front over-analysis to be avoided. Django is a RAD tool, and is best suited to quick, iterative development. For all that, it's capable of building some powerful, long-lived applications, as plenty of large companies will testify. But it's not Java, and it's not \"enterprisey\", and it doesn't conform particularly well to OO principles. In the Python world, that's seen as a feature, not a bug.","Q_Score":15,"Tags":"python,django,model","A_Id":6426206,"CreationDate":"2011-06-21T12:54:00.000","Title":"Decoupling Domain classes from Django Model Classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.\nI want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django\u2019s ORM for an alternative? Now I have to re-write my domain entity classes from scratch.\nSo it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this.\nDoes anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2441,"Q_Id":6425535,"Users Score":0,"Answer":"You would not have to \"rewrite your models from scratch\" if you wanted a different persistence mechanism. The whole point of an activerecord-style persistence system is that it imposes minimal constraints on the model classes, and acts largely transparently.\nIf you're really worried, abstract out any code that relies on queries into their own methods.","Q_Score":15,"Tags":"python,django,model","A_Id":6426280,"CreationDate":"2011-06-21T12:54:00.000","Title":"Decoupling Domain classes from Django Model Classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.\nI want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django\u2019s ORM for an alternative? Now I have to re-write my domain entity classes from scratch.\nSo it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this.\nDoes anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":2441,"Q_Id":6425535,"Users Score":0,"Answer":"I think that there's no implemented solution for decoupling Django models and the domain classes, at least I haven't found any. In fact, the only ORM with such decoupling that I know exists only in Smalltalk world and it's called GLORP. It allows you to persist your domain model in a relational DB without having to modify domain classes. I'm currently trying to implement similar ideas to decouple from Django ORM. My motivation is that current strong coupling between DB tables and domain classes hurts software evolution badly. I'll post again if I succeed :)","Q_Score":15,"Tags":"python,django,model","A_Id":20776976,"CreationDate":"2011-06-21T12:54:00.000","Title":"Decoupling Domain classes from Django Model Classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django.\nI want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django\u2019s ORM for an alternative? Now I have to re-write my domain entity classes from scratch.\nSo it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this.\nDoes anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","AnswerCount":4,"Available Count":4,"Score":0.1488850336,"is_accepted":false,"ViewCount":2441,"Q_Id":6425535,"Users Score":3,"Answer":"Well, the way to go with Django is to inherit from Django's base model classes. This is the 'active record' pattern. Your django models will have all CRUD and query methods along with you business logic (if you decide to add it of course). This is seen as an anti-pattern in the java world, but the cool thing about it is that it can speed up development really really fast.","Q_Score":15,"Tags":"python,django,model","A_Id":6426080,"CreationDate":"2011-06-21T12:54:00.000","Title":"Decoupling Domain classes from Django Model Classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Given a list of tuples where each tuple consists of a probability and an item I'd like to sample an item according to its probability. For example, give the list [ (.3, 'a'), (.4, 'b'), (.3, 'c')] I'd like to sample 'b' 40% of the time. \nWhat's the canonical way of doing this in python?\nI've looked at the random module which doesn't seem to have an appropriate function and at numpy.random which although it has a multinomial function doesn't seem to return the results in a nice form for this problem. I'm basically looking for something like mnrnd in matlab.\nMany thanks.\nThanks for all the answers so quickly. To clarify, I'm not looking for explanations of how to write a sampling scheme, but rather to be pointed to an easy way to sample from a multinomial distribution given a set of objects and weights, or to be told that no such function exists in a standard library and so one should write one's own.","AnswerCount":9,"Available Count":2,"Score":0.022218565,"is_accepted":false,"ViewCount":12259,"Q_Id":6432499,"Users Score":1,"Answer":"Howabout creating 3 \"a\", 4 \"b\" and 3 \"c\" in a list an then just randomly select one. With enough iterations you will get the desired probability.","Q_Score":29,"Tags":"python,statistics,numpy,probability,random-sample","A_Id":6432586,"CreationDate":"2011-06-21T21:56:00.000","Title":"How to do weighted random sample of categories in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a list of tuples where each tuple consists of a probability and an item I'd like to sample an item according to its probability. For example, give the list [ (.3, 'a'), (.4, 'b'), (.3, 'c')] I'd like to sample 'b' 40% of the time. \nWhat's the canonical way of doing this in python?\nI've looked at the random module which doesn't seem to have an appropriate function and at numpy.random which although it has a multinomial function doesn't seem to return the results in a nice form for this problem. I'm basically looking for something like mnrnd in matlab.\nMany thanks.\nThanks for all the answers so quickly. To clarify, I'm not looking for explanations of how to write a sampling scheme, but rather to be pointed to an easy way to sample from a multinomial distribution given a set of objects and weights, or to be told that no such function exists in a standard library and so one should write one's own.","AnswerCount":9,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":12259,"Q_Id":6432499,"Users Score":0,"Answer":"I'm not sure if this is the pythonic way of doing what you ask, but you could use\n    random.sample(['a','a','a','b','b','b','b','c','c','c'],k)\nwhere k is the number of samples you want. \nFor a more robust method, bisect the unit interval into sections based on the cumulative probability and draw from the uniform distribution (0,1) using random.random().  In this case the subintervals would be (0,.3)(.3,.7)(.7,1).  You choose the element based on which subinterval it falls into.","Q_Score":29,"Tags":"python,statistics,numpy,probability,random-sample","A_Id":6432588,"CreationDate":"2011-06-21T21:56:00.000","Title":"How to do weighted random sample of categories in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a new programmer with little experience but I am in the process of learning Python 2.7. I use Python(x,y) or Spydar as the programs are called on Windows 7. \nThe main packages I'm using are numpy, pil and potentially win32gui. \nI am currently trying to write a program to mine information from a 3rd-party software. This is against their wishes and they have made it difficult. I'm using ImageGrab and then numpy to get some results. This however, or so i belive, forces me to keep the window I want to read in focus, which is not optimal.\nI'm wondering if there is any way to hijack the whole window and redirect the output directly into a \"virtual\" copy, just so I can have it running in the background?\nWhen looking at the demos for win32api, there is a script called desktopmanager. I never got it to work, probably since I'm running Windows 7, that's supposed to create new desktops. I don't really know how multiple desktops work but if they run in parallel, there may be a way to create a new desktop around a current window. I don't know how, it's just a thought so far.\nThe reason it's not working for me is not that it's not creating a new desktop, it's that once it's been created, I can't return from it. The taskbar icon nor the taskbar itself ever appears.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":287,"Q_Id":6445620,"Users Score":0,"Answer":"One approach that might work would be to do something like so:\n\nget the window handle (FindWindow() or something similar, there are a few ways to do this)\nget the window dimensions (GetClientRect() or GetWindowRect())\nget the device context for the window (GetWindowDC())\nget the image data from the window (BitBlt() or similar)\n\nIt is possible that you will need elevated privelages to access another processes window dc, if so you may need to inject code\/dll into the target process space to do this.\nHTH.","Q_Score":1,"Tags":"python,python-2.7,winapi","A_Id":6448014,"CreationDate":"2011-06-22T19:48:00.000","Title":"Hijacking, redirecting, display output with Python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to figure out how to use python's mysqldb. I can do my job with my current knownledge, but I want to use the best practices.\nShould I close properly my cursor? Exiting the program isn't close it autmatically? (Shouldn't I expect the object destructor to do it anyway?)\nShould I create new cursors for every query, or one cursor is enough for multiple different queries in the same DB?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":742,"Q_Id":6453067,"Users Score":2,"Answer":"Should I close properly my cursor?\n\nYes, you should.  Explicit is better than implicit.\n\nShould I create new cursors for every\n  query, or one cursor is enough for\n  multiple different queries in the same\n  DB?\n\nThis depends on how you use this cursor.  For simple tasks it is enough to use one cursor.  For some complex application it is better to create separate cursor for each batch of SQL-queries.","Q_Score":2,"Tags":"python,cursor,mysql-python","A_Id":6453159,"CreationDate":"2011-06-23T11:08:00.000","Title":"How to properly use mysqldb in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I finally managed to get my script to login to a website and download a file... however, in some instances I will have a url like \"http:\/\/www.test.com\/index.php?act=Attach&type=post&id=3345\".  Firefox finds the filename ok... so I should be able to.\nI am unable to find the \"Content-Disposition\" header via something like remotefile.info()['Content-Disposition']\nAlso, remotefile.geturl() returns the same url.\nWhat am I missing?  How do I get the actual filename?  I would prefer using the built-in libraries.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":580,"Q_Id":6463179,"Users Score":2,"Answer":"It is the task of the remote server\/Service to provide the content-disposition header.\nThere is nothing you can do unless the remote server\/service is under your own control..","Q_Score":0,"Tags":"python,url,login,download,urllib2","A_Id":6463190,"CreationDate":"2011-06-24T04:00:00.000","Title":"Using python (urllib) to download a file, how to get the real filename?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to write a program that capture audio stream from the microphone and in the same time mix this stream with a playing audio file.\nI'm lookig for library, api, etc..etc... but my concern is about the implementation, should I use threading programming? I don't know how to use a thread yet.\nThe operating system is windows, the language is c++ or python.\nthanks","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1037,"Q_Id":6467651,"Users Score":0,"Answer":"py2.6 comes with processed-based threading as well so you don't have todo just green-threads","Q_Score":1,"Tags":"c++,python,windows,multithreading,audio","A_Id":6468189,"CreationDate":"2011-06-24T12:15:00.000","Title":"Should I use threading programming for mixing 2 audio stream?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to read incoming data from a barcode scanner using pyserial. Then I have to store the contents into a MySQL database. I have the database part but not the serial part. can someone show me examples of how to do this. I'm using a windows machine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":916,"Q_Id":6471569,"Users Score":1,"Answer":"You will find it easier to use a USB scanner. These will decode the scan, and send it as if it were typed on the keyboard, and entered with a trailing return. \nThe barcode is typically written with leading and trailing * characters, but these are not sent with the scan. \nThus you print  \"*AB123*\" using a 3 of 9 font, and when it is scanned sys.stdin.readline().stript() will return \"AB123\".\nThere are more than a few options that can be set in the scanner, so you need to read the manual. I have shown the factory default above for a cheap nameless scanner I bought from Amazon.","Q_Score":1,"Tags":"python,pyserial","A_Id":6474062,"CreationDate":"2011-06-24T17:35:00.000","Title":"Reading incoming data from barcode","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I couldn't find any information about this in the documentation, but how can I get a list of tables created in SQLAlchemy?\nI used the class method to create the tables.","AnswerCount":14,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":133023,"Q_Id":6473925,"Users Score":99,"Answer":"There is a method in engine object to fetch the list of tables name. engine.table_names()","Q_Score":133,"Tags":"python,mysql,sqlalchemy,pyramid","A_Id":30554677,"CreationDate":"2011-06-24T21:25:00.000","Title":"SQLAlchemy - Getting a list of tables","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"The program I am writing can edit a single project at a time. This means that opening a new file\/project implies closing the previous one. Now what I want to achieve is the following workflow:\n\nUser has uncommitted changes to a project he never previously saved, so the project doesn't have a file name yet.\nUser presses \"open saved project\".\nA dialogue \"A\" pops up and says: \"Your current project has uncommitted changes, what would you like to do? Abort new project operation, discard changes to current project, or save them?\".\nUser selects \"save\" dialogue.\nDialogue A closes.\nDialogue B1 (file chooser configured for save operation) pops up.\nUser select file name for project to save.\nDialogue B1 closes, project gets saved.\nDialogue B2 (same file chooser but configured for load operation) pops up.\nUser select file to open.\nDialogue B2 closes, project is loaded.\n\nSo really, in the above example steps 3 to 8 are a sort of \"interruption\" in the obvious workflow of opening a saved project, so when dialogue A and B1 open, the obvious workflow is halted, and it is resumed when those dialogue get responded.\nMy question is: how to implement this mechanism of halting\/resuming the normal flow of operation? So far the way I implemented it is via a stack on which - any time I open a popup dialogue - I push the \"resume-from-here callback\", and any time I respond I pop the callback from.\n...yet it seems as mine is a very common scenario for which there should be an easier method (maybe a specific function of PyGTK!).\nMany thanks in advance for your help\/time!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":6483466,"Users Score":2,"Answer":"Would GtkDialog.run() be the method you need? You \"run\" the dialog, at the point where you need to ask the user, and when it returns you have your answer.","Q_Score":0,"Tags":"python,user-interface,gtk,pygtk,modal-dialog","A_Id":6483508,"CreationDate":"2011-06-26T10:50:00.000","Title":"How to resume program workflow at the right place after dialogue response?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to write a cgi page which will act like a reverse proxy between the user and another page (mbean).  The issue is that each mbean uses different port and I do not know ahead of time which port user will want to hit.\nTherefore want I need to do is following:\nA) Give user a page which will allow him to choose which application he wants to hit\nB) spawn a reverse proxy base on information above (which gives me port, server, etc..)\nC) the user connects to the remote mbean page via the reverse proxy and therefore never \"leaves\" the original page.\nThe reason for C is that user does not have direct access to any of the internal apps only has access to initial port 80.\nI looked at twisted and it appears to me like it can do the job.  What I don't know is how to spawn twisted process from within cgi so that it can establish the connection and keep further connection within the reverse proxy framework.\nBTW I am not married to twisted, if there is another tool that would do the job better, I am all ears.  I can't do things like mod_proxy (for instance) since the wide range of ports would make configuration rather silly (at around 1000 different proxy settings).","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":488,"Q_Id":6488806,"Users Score":2,"Answer":"You don't need to spawn another process, that would complicate things a lot. Here's how I would do it based on something similar in my current project : \n\nCreate a WSGI application, which can live behind a web server.\nCreate a request handler (or \"view\") that is accessible from any URL mapping as long as the user doesn't have a session ID cookie.\nIn the request handler, the user can choose the target application and with it, the hostname, port number, etc. This request handler creates a connection to the target application, for example using httplib and assigns a session ID to it. It sets the session ID cookie and redirects the user back to the same page.\nNow when your user hits the application, you can use the already open http connection to redirect the query. Note that WSGI supports passing back an open file-like object as response, including those provided by httplib, for increased performance.","Q_Score":1,"Tags":"python","A_Id":6531642,"CreationDate":"2011-06-27T05:10:00.000","Title":"python reverse proxy spawning via cgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I want to search for a file name \"myfile\" in a folder named \"myfolder\", how can I do it without knowing the format of the file?\nAnother question: how to list all files of a folder and all the files of it's subfolders (and so on)?\nThank you.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3120,"Q_Id":6489663,"Users Score":0,"Answer":"I do not know the logic of python for this but I would do the following:\nLoop through each file in the directory, get the names as strings and check to see if they begin with \"myfile\" by splitting the string on the \".\" you can compare what you are looking for with what you have.","Q_Score":3,"Tags":"python,file,search,directory,match","A_Id":6489701,"CreationDate":"2011-06-27T07:10:00.000","Title":"Find file in folder without knowing the extension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My goal is to inject some HTML-Code in front of every Plone article (between the page's header and the first paragraph)? I'm running Plone 4. Does anyone have a hint on how to realize that?\nThe other question is: is it possible to place some HTML code randomly in every Plone article?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":667,"Q_Id":6503861,"Users Score":-1,"Answer":"Perhaps you could approach this from a Javascript way? A lot of applications have like a global js file, that's included in all pages. Starting from that you could modify the DOM easily.","Q_Score":1,"Tags":"python,html,templates,plone,zope","A_Id":6503962,"CreationDate":"2011-06-28T08:44:00.000","Title":"How to inject template code in Plone?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working through a Selenium test where I want to assert a particular HTML node is an exact match as far as what attributes are present and their values (order is unimportant) and also that no other attributes are present. For example given the following fragment: \n<input name=\"test\" value=\"something\"\/>\nI am trying to come up with the a good way of asserting its presence in the HTML output, such that the following (arbitrary) examples would not match:\n\n<input name=\"test\" value=\"something\" onlick=\"doSomething()\"\/>\n<input name=\"test\" value=\"something\" maxlength=\"75\"\/>\n<input name=\"test\" value=\"something\" extraneous=\"a\" unwanted=\"b\"\/>\n\nI believe I can write an XPath statement as follows to find all of these, for example: \n\/\/input[value='something' and @name='test'] \nBut, I haven't figured out how to write in such a way that it excludes not exact matches in a generalize fashion. Note, it doesn't have to be an XPath solution, but that struck me as the most likely elegant possibility.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":6506372,"Users Score":0,"Answer":"There is no way to exclude unexpected attributes with XPath.\nSo you must find a safer way to locate elements you want. Things that you should consider:\n\nIn a form, each input should have a distinct name. The same is true for the form itself. So you can try \/\/form[@name='...']\/input[@name='...']\nAdd a class to the fields that you care about. Classes don't have be mentioned in any stylesheet. In fact, I used this for form field validation by using classes like decimal number or alpha number","Q_Score":1,"Tags":"python,xpath,selenium,beautifulsoup,lxml","A_Id":6506453,"CreationDate":"2011-06-28T12:28:00.000","Title":"Finding Only HTML Nodes Whose Attributes Match Exactly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a pyramid project that uses mongodb for storage. Now I'm trying to write a test but how do I specify connection to the mongodb?\nMore specifically, which database should I connect to (test?) and how do I use fixtures? In Django it creates a temporary database but how does it work in pyramid?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":594,"Q_Id":6515160,"Users Score":2,"Answer":"Just create a database in your TestCase.setUp and delete in TestCase.tearDown\nYou need mongodb running because there is no mongolite3 like sqlite3 for sql\nI doubt that django is able to create a temporary file to store a mongodb database. It probably just use sqlite:\/\/\/ which create a database with a memory storage.","Q_Score":2,"Tags":"python,mongodb,pyramid","A_Id":6934811,"CreationDate":"2011-06-29T02:30:00.000","Title":"How do i create unittest in pyramid with mongodb?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a long-running Python program that starts and stops a Postgres server as part of its operation.  I stop the server by using subprocess to spawn pg_ctl -m fast.  As a fall-back, I check the return code and, if it failed, I then run pg_ctl -m immediate.\nThe problem is that sometimes both fail.  I haven't been able to reproduce this myself, but it happens with some frequency for users of my program.  I log stdout\/stderr from the pg_ctl calls, but don't get any useful info there.  As far as I can tell, either the master process or its children have stopped responding to SIGQUIT, and the only way to terminate them is with SIGKILL, which pg_ctl does not use.\nI've basically exhausted ideas on the Postgres side.  I'm using Postgres 8.3, so I'm sure upgrading to a more recent version would resolve this, but unfortunately that is not an option for me.  The only solution I can come up with is to kill the children manually.  But I don't know how to distinguish between the children spawned by my pg_ctl start and other postgres processes that might be running on the machine.\nIs there a way to identify a process as a child of another process that I spawned?  A cross-platform method of doing this from Python would be ideal, but I'm willing to write a C extension if there exist APIs on Windows\/Linux\/UNIX to do this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":6523883,"Users Score":0,"Answer":"The C++ standard does not know of multiprocess systems. There is, therefore, no API for interacting with processes. (After all, how would the standard mandate a multiprocess system on an 8 bit microcontroller?)\nMoreover, some platforms (e.g. the Win32 Subsystem on Windows NT) do not keep track of process parent child relationships. (NT does under the hood but you'd have to call undocumented APIs to get at the information)\nI'm fairly certain POSIX does define APIs like this, but I have not used them myself.","Q_Score":1,"Tags":"c++,python,postgresql,process,cross-platform","A_Id":6524149,"CreationDate":"2011-06-29T16:18:00.000","Title":"How can one identify children of a child process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm 'hacking' my router, and I need to rewrite one JS function that takes date in hexdec format and convert it into Y m d\nJS code looks like:\n\nreturn [(((n >> 16) & 0xFF) + 1900), ((n >>> 8) & 0xFF), (n & 0xFF)];\n\nwhere n is variable in format 0x123456 (e.g. 6 hexdec digits after 0x sign)\nfound that python has operators like >> but does't have >>> operator.\nAny idea how to do that ?\nthanks","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":664,"Q_Id":6535373,"Users Score":5,"Answer":"Use >>. You are removing the sign anyway with the & 0xFF. Note, that you cannot leave out the & part, i.e., (n >> 8) & 0xff, or you'll get the wrong result, as you have already noted.","Q_Score":0,"Tags":"python","A_Id":6535397,"CreationDate":"2011-06-30T13:19:00.000","Title":"Special JS operators in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"for example from bash:\n\nkill -9 -PID \n\nos.kill(pid, signal.SIGKILL) kill only parent process.","AnswerCount":7,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63568,"Q_Id":6549669,"Users Score":35,"Answer":"When you pass a negative PID to kill, it actually sends the signal to the process group by that (absolute) number. You do the equivalent with os.killpg() in Python.","Q_Score":27,"Tags":"python","A_Id":6549740,"CreationDate":"2011-07-01T15:00:00.000","Title":"how to kill process and child processes from python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I looking for the way to get parent ID or name from child thread.\nIn example, I have main thread as MainThread. In this thread i create a few new threads. Then I use threading.enumerate() to get references to all running thread, pick one of child threads and somehow get ID or name of MainThread. Is any way to do that?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7432,"Q_Id":6552097,"Users Score":1,"Answer":"You can have a reference to parent thread on child thread.. and then get it's ID","Q_Score":6,"Tags":"python,multithreading","A_Id":6552616,"CreationDate":"2011-07-01T18:51:00.000","Title":"threading - how to get parent id\/name?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From the c-api, I would like to call a python function by name.  I would then be calling the function with a list of python objects as arguments.\nIt is not clear to me in the Python documentation how I would get a \"Callable\" object from the main python interpreter.\nAny help appreciated in:\n\nGetting the address from the function\nCalling the function with my PythonObject's as arguments.\n\nI'm using Python 2.x series for my development.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1070,"Q_Id":6558957,"Users Score":3,"Answer":"Basically, you use the Python C API to get the module the function is contained in, then query the module dictionary for the function. That's more or less the same what the Python runtime does internally when your Python code invokes a function from somewhere.\nRelevant functions from the API to look at are PyImport_ImportModule, PyModule_GetDict, PyDict_GetItem and the PyObject_CallXXX family of functions.","Q_Score":2,"Tags":"python,python-c-api","A_Id":6558981,"CreationDate":"2011-07-02T18:57:00.000","Title":"How to call a python function by name from the C-API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have dev and production systems.\nMy production system is different from my dev system in that that it adds one directory to the beginning path.\nfor eg. on dev system:\nmain->module1->module2\nbecomes on production:\nproject_name->main->module1->module2.\nBecause of that I have to change all my imports to accommodate for this change.\nI wanted to make settings file in the main folder and include it in every file and call exec(\"import %s.modulexxx\" % path).\nBut the problem is how to access settings file (because I also need to know my directory path).\nIs there a way to include some file below, for eg. :\nif it is main->module1->module2 , in module2 I could include ..\/..\/settings.py\nso if it changes to project_name->main->module1->module2 it would still work because it would still be 2 level below.\nAny help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":6559656,"Users Score":4,"Answer":"Why not just modify sys.path to include the directory one level down? Then the same imports will work in both places.","Q_Score":0,"Tags":"python","A_Id":6559698,"CreationDate":"2011-07-02T21:17:00.000","Title":"Importing modules with variable paths?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to write a tiny calendar-like application for someone as a birthday present (to be run on Ubuntu). All it should do is display a separate picture each day, so whenever it's invoked it should check the date and select the appropriate picture from the collection I would provide, but also, in case it just keeps running, it should switch to the next picture when the next day begins.\nThe date-checking on invocation isn't the problem; my question pertains to the second case: how can I have the program notice the beginning of the next day? My clumsy approach would be to make it check the current date at regular intervals and let it change the displayed picture once there was a change in date, but that strikes me as very roundabout and not particularly elegant.\nIn case any of you have got some idea of how I could accomplish this, please don't hesitate to reply. I would aim to write the application in either Perl or Python, so suggestions concerning those two languages would be most welcome, but any other suggestions would be appreciated as well.\nThanks a lot for your time!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":328,"Q_Id":6570892,"Users Score":1,"Answer":"Did you think about scheduling the invoke of your script?\nFor me, the best approach is this:\n1.Have two options to run the script:\n\nrun_script\nrun_script --update\n\n2.Schedule the update run in some task scheduler (for example Cron) to be executed daily.\n3.When you would want to check the image for current day, simply run the script without update option.\nIf you would like me to extend any part of these, simply ask about it.","Q_Score":3,"Tags":"python,perl,date,calendar","A_Id":6571157,"CreationDate":"2011-07-04T11:33:00.000","Title":"How to periodically check for the current date from within a program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am very new to programming.  I am familiar with HTML, C++ and learning PHP to start a database.\nI want to make a website which tracks a stock price.  I have written various algorithms in Matlab however, MATLAB only has a to-Java conversion.\nI was wondering what language would be the best to do a lot of calculations.  I want my calculations to be done in real time and plotted.  Would Java be the best language for this?\nI can do the calculations in C++ but I don't know how to put the plots on the website.  Likewise I believe I can do everything in Matlab but the conversion looks a little sketchy.  \nI would be very thankful if someone with experience with Java, or I also heard python, would comment on my post.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1004,"Q_Id":6574740,"Users Score":0,"Answer":"I think you can use PHP or Java Web.","Q_Score":3,"Tags":"java,c++,python,math,matlab","A_Id":6574755,"CreationDate":"2011-07-04T18:04:00.000","Title":"Math Intensive, Calculation Based Website - Which Language Should I Use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am very new to programming.  I am familiar with HTML, C++ and learning PHP to start a database.\nI want to make a website which tracks a stock price.  I have written various algorithms in Matlab however, MATLAB only has a to-Java conversion.\nI was wondering what language would be the best to do a lot of calculations.  I want my calculations to be done in real time and plotted.  Would Java be the best language for this?\nI can do the calculations in C++ but I don't know how to put the plots on the website.  Likewise I believe I can do everything in Matlab but the conversion looks a little sketchy.  \nI would be very thankful if someone with experience with Java, or I also heard python, would comment on my post.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1004,"Q_Id":6574740,"Users Score":0,"Answer":"I would do C++ and write them to a database, then using php you can grab them from the same database and show them online, otherwise then java can do all that but make sure all calculations aren't done on the fly since that will kill your server, especially with stocks that can turn into a lot of data.","Q_Score":3,"Tags":"java,c++,python,math,matlab","A_Id":6574803,"CreationDate":"2011-07-04T18:04:00.000","Title":"Math Intensive, Calculation Based Website - Which Language Should I Use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I use pyplot.clabel to attach the file names to the lines being plotted?\nplt.clabel(data) line gives the error","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1086,"Q_Id":6577807,"Users Score":0,"Answer":"You may use plt.annotate or plt.text. \nAnd, as an aside, 1) you probably want to use different variables for the file names and numpy arrays you're loading your data into (what is data in data=plb.loadtxt(data)), \n2) you probably want to move the label positioning into the loop (in your code, what is data in the plt.clabel(data)).","Q_Score":0,"Tags":"python,matplotlib","A_Id":6580497,"CreationDate":"2011-07-05T03:49:00.000","Title":"matplotlib.pyplot how to add labels with .clabel?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":13175,"Q_Id":6578452,"Users Score":13,"Answer":"I would suggest you go back into thinking about this, considering:\n\nUse the right tool for the job\nObfuscation is hard\nOther means to achieve your goals\n\nFirstly, Python was not designed to be obfuscated. Every aspect of the language is free and accessible to anybody who wants to inspect or modify it. Being a bytecode language makes it difficult to lock down, and Python bytecode is easy to understand. If you want to build something you can't see inside, you will have to use another tool.\nSecondly, everything (literally) can be reverse-engineered eventually, so do not assume you'll be able to fully protect any piece of code.\nYou must be able to understand the tradeoff between the importance of hiding a piece of code (for an estimate amount X of resources) versus how useful hiding it actually is (also in terms of effort). Try and realistically evaluate how important your \"design and implementation\" really is, to justify all this.\nConsider having legal requirements. If you expect people will misuse your code, maybe it would be more useful if you could easily discover the ones that do and turn this into a legal issue.","Q_Score":7,"Tags":"python,obfuscation","A_Id":6578598,"CreationDate":"2011-07-05T05:59:00.000","Title":"how to encrypt python source code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":13175,"Q_Id":6578452,"Users Score":3,"Answer":"Anything can be reverse engineered. It is not possible to give a user's machine information without the possibility for the user to examine that information. All you can do is make it take more effort.\nPython is particularly bad if you have this requirement, because Python bytecode is much easier to read than fully assembled machine code. Ultimately whatever you do to make it more obfuscated, the user's computer will have to be able to de-obfuscate it to turn it into normal Python bytecode in order for the Python interpreter to exectute it. Therefore a motivated user is going to be able to de-obfuscate whatever you give them into Python bytecode as well.\nIf you really have rivals who are likely to want to figure out how your programs work, you must assume that any code you release to end users in any form will be fully understood by your rivals. There is no possible way to absolutely guard against this.\nThe only way you can get around this is to not give your users this code either, if you can run your code on a server under your control, and only give your users a dumb program that makes requests to your server for the real work.","Q_Score":7,"Tags":"python,obfuscation","A_Id":6579423,"CreationDate":"2011-07-05T05:59:00.000","Title":"how to encrypt python source code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":13175,"Q_Id":6578452,"Users Score":4,"Answer":"separate confidential functionality in C functions and develop SWIG wrappers. If you are using C++, you can consider boost python.","Q_Score":7,"Tags":"python,obfuscation","A_Id":6578518,"CreationDate":"2011-07-05T05:59:00.000","Title":"how to encrypt python source code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a wxlistbox in a class and i want to update the data inside the listbox from a different class.Is i possible to reload the class while leave the control from another class?if yes ,how?\neg:\ni have two classes,Class A and Class B.In class A there is a wxlistbox.while starting the program class A initilise the wxlistbox and bind some values.when a button inside class A clicked it call another frame class B.while close the frame B the wxlistbox inside class A should update.\nMy question is how to refresh listbox while close the frame B?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":6581744,"Users Score":1,"Answer":"I would use the SetItems() method, which according to the docs does the following: \"Clear and set the strings in the control from a list\".\nEdit: myListCtrl.SetItems(ListOfStrings)\nThat will replace all the items in the control with whatever is in the list.","Q_Score":0,"Tags":"python,wxpython","A_Id":6584095,"CreationDate":"2011-07-05T11:13:00.000","Title":"how to update a wxlistbox from a different class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my Django app very often I need to do something similar to get_or_create(). E.g.,\n\nUser submits a tag. Need to see if\n  that tag already is in the database.\n  If not, create a new record for it. If\n  it is, just update the existing\n  record.\n\nBut looking into the doc for get_or_create() it looks like it's not threadsafe. Thread A checks and finds Record X does not exist. Then Thread B checks and finds that Record X does not exist. Now both Thread A and Thread B will create a new Record X.\nThis must be a very common situation. How do I handle it in a threadsafe way?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9325,"Q_Id":6586552,"Users Score":11,"Answer":"This must be a very common situation. How do I handle it in a threadsafe way?\n\nYes.\nThe \"standard\" solution in SQL is to simply attempt to create the record.  If it works, that's good.  Keep going.\nIf an attempt to create a record gets a \"duplicate\" exception from the RDBMS, then do a SELECT and keep going.\nDjango, however, has an ORM layer, with it's own cache.  So the logic is inverted to make the common case work directly and quickly and the uncommon case (the duplicate) raise a rare exception.","Q_Score":24,"Tags":"python,database,django,concurrency,thread-safety","A_Id":6586594,"CreationDate":"2011-07-05T17:31:00.000","Title":"Django: how to do get_or_create() in a threadsafe way?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Maybe there's someone out there with the right interests that will know how to answer this. Basically the question is: What are the differences between the multiprocessing module in Python, and the parallelism in Haskell. For instance: are threads created in Python mapped to OS threads? If so, what if there are more threads than cores? Are they multiplexed into the OS threads? Who schedules these threads? Thanks for all the info: documentation\/insights greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":926,"Q_Id":6587095,"Users Score":6,"Answer":"The Python multiprocessing module has nothing to do with threads. It tries to provide an API similar to threading (which does expose threads) with processes underneath.\nPython threads are mapped to OS threads, and if you create more threads than cores the exact same thing happens as if you'd do it in C (pthreads, Win API threads, etc.) - the OS juggles the threads between cores.\nThere's a lot of information online about Python threads, just Google it.","Q_Score":6,"Tags":"python,haskell,multicore","A_Id":6587378,"CreationDate":"2011-07-05T18:22:00.000","Title":"Haskell vs. Python threading model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a simple file parser and writer, but then I came across an article talking about the importance of unicode and then it occurred to me that I'm assuming the input file is ascii encoded, which may not be the case all the time, though it would be rare in my situation.\nIn those rare cases, I would expect UTF-8 encoded files.\nIs there a way to work with UTF-8 files by simply changing how I read and write? All I do with the strings is store them and then write them out, so I just need to make sure I can read them, store them, and write them properly.\nFurthermore, would I have to treat ascii and UTF-8 files separately and write different functions for each? I have not worked with anything other than ascii files yet and only read about handling unicode.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":669,"Q_Id":6588041,"Users Score":3,"Answer":"Python natively supports Unicode. If you directly read and write from the first file to the second, then no data is lost as it copies the bytes verbatim. However, if you decode the string and then re-encode it, you'll need to make sure you use the right encoding.","Q_Score":0,"Tags":"python,unicode-string,python-2.7","A_Id":6588072,"CreationDate":"2011-07-05T19:46:00.000","Title":"Writing UTF-8 friendly parsers in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a simple file parser and writer, but then I came across an article talking about the importance of unicode and then it occurred to me that I'm assuming the input file is ascii encoded, which may not be the case all the time, though it would be rare in my situation.\nIn those rare cases, I would expect UTF-8 encoded files.\nIs there a way to work with UTF-8 files by simply changing how I read and write? All I do with the strings is store them and then write them out, so I just need to make sure I can read them, store them, and write them properly.\nFurthermore, would I have to treat ascii and UTF-8 files separately and write different functions for each? I have not worked with anything other than ascii files yet and only read about handling unicode.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":669,"Q_Id":6588041,"Users Score":2,"Answer":"If you are using Python 2.6 or later, you can use the io library and its io.open method to open the files you want. It has an encoding argument which should be set to 'utf-8' in your case. When you read or write the returned file objects, string are automatically en-\/decoded.\nAnyway, you don't need to do something special for ASCII, because UTF-8 is a superset of ASCII.","Q_Score":0,"Tags":"python,unicode-string,python-2.7","A_Id":6588187,"CreationDate":"2011-07-05T19:46:00.000","Title":"Writing UTF-8 friendly parsers in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to have a purely in-memory SQLite database in Django, and I think I have it working, except for an annoying problem:\nI need to run syncdb before using the database, which isn't too much of a problem. The problem is that it needs to create a superuser (in the auth_user table, I think) which requires interactive input.\nFor my purposes, I don't want this -- I just want to create it in memory, and I really don't care about the password because I'm the only user. :) I just want to hard-code a password somewhere, but I have no idea how to do this programmatically.\nAny ideas?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1200,"Q_Id":6599716,"Users Score":3,"Answer":"Disconnect django.contrib.auth.management.create_superuser from the post_syncdb signal, and instead connect your own function that creates and saves a new superuser User with the desired password.","Q_Score":1,"Tags":"python,database,django,sqlite,in-memory-database","A_Id":6600219,"CreationDate":"2011-07-06T16:20:00.000","Title":"Django In-Memory SQLite3 Database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a batch file that runs a python script. When the python script is invoked, it starts a second windows console and then disappears when it is completed. This is a problem because I am editing the PYTHONPATH environment variable in the batch file, but because the python script is running in a second window, it cannot see the edited PYTHONPATH environment variable. It used to work just fine (everything would run in the same windows console). I just installed Vista SP2 and this problem showed up. Any thoughts on how to fix what might be broken?\nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2124,"Q_Id":6602341,"Users Score":0,"Answer":"Have you tried changing the extension of the python script to .pyw, or just invoke it with pythonw.exe?","Q_Score":2,"Tags":"python,batch-file,command-prompt","A_Id":6602895,"CreationDate":"2011-07-06T20:12:00.000","Title":"Calling python script from batch file opens second console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a batch file that runs a python script. When the python script is invoked, it starts a second windows console and then disappears when it is completed. This is a problem because I am editing the PYTHONPATH environment variable in the batch file, but because the python script is running in a second window, it cannot see the edited PYTHONPATH environment variable. It used to work just fine (everything would run in the same windows console). I just installed Vista SP2 and this problem showed up. Any thoughts on how to fix what might be broken?\nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2124,"Q_Id":6602341,"Users Score":0,"Answer":"It could be that the .py filetype is associated to pythonw.exe, therefore causing it to open in a new process.   Find any .py file, right click it, select properties, and check to see under \"Opens with:\" what the default interpreter is.","Q_Score":2,"Tags":"python,batch-file,command-prompt","A_Id":6603729,"CreationDate":"2011-07-06T20:12:00.000","Title":"Calling python script from batch file opens second console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a batch file that runs a python script. When the python script is invoked, it starts a second windows console and then disappears when it is completed. This is a problem because I am editing the PYTHONPATH environment variable in the batch file, but because the python script is running in a second window, it cannot see the edited PYTHONPATH environment variable. It used to work just fine (everything would run in the same windows console). I just installed Vista SP2 and this problem showed up. Any thoughts on how to fix what might be broken?\nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2124,"Q_Id":6602341,"Users Score":0,"Answer":"Ok, so I decided to reinstall python. If I uninstall and reinstall (I was using the windows installer) in the default location, it seems to have no effect. I cleaned out the registry and reinstalled. Still no different. However, if I install python in a different location (other than the default) it seems to run fine. Something is obviously corrupt somewhere, but I don't know where. So I am going to just reinstall all of my other modules in a different location and go from there. \nThank you all for your responses.","Q_Score":2,"Tags":"python,batch-file,command-prompt","A_Id":6612528,"CreationDate":"2011-07-06T20:12:00.000","Title":"Calling python script from batch file opens second console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on building a web interface for a Python tool. It's being designed using J2EE (Spring).\nIn the process, I need to make calls to Python functions and hence I am using Jython for the same.\nBut for some modules I don't have the Python source files, I only have the .pyc files, and a document listing the methods of that file. I need to know how I can call these functions inside the .pyc file using jython.\nI have tried to de-compile the Python files but since they have been complied with Python 2.7, I am not able find a decompiler to do the job","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1308,"Q_Id":6607858,"Users Score":3,"Answer":"The 'compiled' python code '.pyc' files are implementation-specific. Even CPython (the standard Python implementation) is not able to import .pyc files generated by a different version of CPython. And is not supposed to. So, I would be surprised if Jython had an ability to run .pyc files created by any of CPython version.\n'.pyc' files are not the same as Java bytecode (which is designed to be portable).\nDecompilation seems the only way. I think there are some .pyc decompilers available, they should be able to generate Python code that could be run by Jython.","Q_Score":0,"Tags":"java,python,jython,pyc","A_Id":6609145,"CreationDate":"2011-07-07T08:34:00.000","Title":"use .pyc files via Jython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get reproducible results with the genetic programming code in chapter 11 of \"Programming Collective Intelligence\" by Toby Segaran. However, simply setting seed \"random.seed(55)\" does not appear to work, changing the original code \"from random import ....\" to \"import random\" doesn't help, nor does changing Random().  These all seem to do approximately the same thing, the trees start out building the same, then diverge.\nIn reading various entries about the behavior of random, I can find no reason, given his GP code, why this divergence should happen.  There doesn't appear to be anything in the code except calls to random, that has any variability that would account for this behavior.  My understanding is that calling random.seed() should set all the calls correctly and since the code isn't threaded at all, I'm not sure how or why the divergence is happening.\nHas anyone modified this code to behave reproducibly? Is there some form of calling random.seed() that may work better?\nI apologize for not posting an example, but the code is obviously not mine (I'm adding only the call to seed and changing how random is called in the code) and this doesn't appear to be a simple issue with random (I've read all the entries on Python random here and many on the web in general).\nThanks.\nMark L.","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":2656,"Q_Id":6614447,"Users Score":5,"Answer":"I had the same problem just now with some completely unrelated code. I believe my solution was similar to that in eryksun's answer, though I didn't have any trees. What I did have were some sets, and I was doing random.choice(list(set)) to pick values from them. Sometimes my results (the items picked) were diverging even with the same seed each time and I was close to pulling my hair out. After seeing eryksun's answer here I tried random.choice(sorted(set)) instead, and the problem appears to have disappeared. I don't know enough about the inner workings of Python to explain it.","Q_Score":7,"Tags":"python","A_Id":9271325,"CreationDate":"2011-07-07T17:12:00.000","Title":"Python random seed not working with Genetic Programming example code","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a pygame application window, the minimize, resize and close buttons are present. Is there a way to disable the close(X) button?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1851,"Q_Id":6619923,"Users Score":6,"Answer":"I don't think there is, because some window managers don't give you the ability to remove the close button. But you can write an event handler such that the close button does whatever you want, including nothing.\nWhy do you want to prevent the user from closing? If it's just a matter that you would rather provide an in-game \"quit\" button that confirms and\/or saves before quitting, you can perform the same task when the user hits the close button.","Q_Score":4,"Tags":"python,pygame","A_Id":6619966,"CreationDate":"2011-07-08T04:17:00.000","Title":"how to disable the window close button in pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a pygame application window, the minimize, resize and close buttons are present. Is there a way to disable the close(X) button?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1851,"Q_Id":6619923,"Users Score":0,"Answer":"Just for the record, another option would be to pass the following argument to the set_mode() method call:\npygame.display.set_mode(..., flags = pygame.NOFRAME)\nThis however makes the whole frame go away, including the top strip to move the window around and the other buttons, such as minimize, so it's rather overkill for just getting rid of the X button.","Q_Score":4,"Tags":"python,pygame","A_Id":49826543,"CreationDate":"2011-07-08T04:17:00.000","Title":"how to disable the window close button in pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a large amount of static data that needs to offer random access. Since, I'm using Disco to digest it, I'm using the very impressive looking Discodex (key, value) store on top of the Disco Distributed File System. However, Disco's documentation is rather sparse, so I can't figure out how to use my Discodex indices as an input into a Disco job.\nIs this even possible? If so, how do I do this?\nAlternatively, I am thinking about this incorrectly? Would it be better to just store that data as a text file on DDFS?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":567,"Q_Id":6628506,"Users Score":0,"Answer":"Never mind, it appears that what I'm doing isn't really meant to be done. It might be possible, but it would be far better to merely use semantic DDFS tags to refer to blobs of data.\nThe correct use case for Discodex is to store indexes constructed by a Disco map-reduce program that does not need be the input of another map-reduce program.","Q_Score":1,"Tags":"python,mapreduce,disco","A_Id":6628861,"CreationDate":"2011-07-08T18:05:00.000","Title":"Running a Disco map-reduce job on data stored in Discodex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm on windows, but I'm using a putty shell to connect to a linux machine, and want to install python 2.7. Can't figure out how to do it. How can I download python from command line?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127053,"Q_Id":6630873,"Users Score":0,"Answer":"Well if you are getting into a linux machine you can use the package manager of that linux distro.\nIf you are using Ubuntu just use apt-get search python, check the list and do apt-get install python2.7 (not sure if python2.7 or python-2.7, check the list)\nYou could use yum in fedora and do the same.\nif you want to install it on your windows machine i dont know any package manager, i would download the wget for windows, donwload the package from python.org and install it","Q_Score":30,"Tags":"python,linux,command-line,download","A_Id":6630925,"CreationDate":"2011-07-08T21:46:00.000","Title":"How to download python from command-line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I make a live countdown clock like ebay, how do I do this with django and sql?  I'm assuming running a function in django or in sql over and over every second to check the time would be horribly inefficient.  \nIs this even a plausible strategy?\nOr is this the way they do it:\nWhen a page loads, it takes the end datetime from the server and runs a javascript countdown clock against it on the user machine?\nIf so, how do you do the countdown clock with javascript? And how would I be able to delete\/move data once the time limit is over without a user page load? Or is it absolutely necessary for the user to load the page to check the time limit to create an efficient countdown clock?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2127,"Q_Id":6639247,"Users Score":2,"Answer":"I don't think this question has anything to do with SQL, really--except that you might retrieve an expiration time from SQL.  What you really care about is just how to display the timeout real-time in the browser, right?\nObviously the easiest way is just to send a \"seconds remaining\" counter to the page, either on the initial load, or as part of an AJAX request, then use Javascript to display the timer, and update it every second with the current value.  I would opt for using a \"seconds remaining\" counter rather than an \"end datetime\", because you can't trust a browser's clock to be set correctly--but you probably can trust it to count down seconds correctly.\nIf you don't trust Javascript, or the client's clock, to be accurate, you could periodically re-send the current \"seconds remaining\" value to the browser via AJAX. I wouldn't do this every second, maybe every 15 or 60 seconds at most.\nAs for deleting\/moving data when the clock expires, you'll need to do all of that in Javascript.\nI'm not 100% sure I answered all of your questions, but your questions seem a bit scattered anyway. If you need more clarification on the theory of operation, please ask.","Q_Score":0,"Tags":"javascript,python,django,time,countdown","A_Id":6639561,"CreationDate":"2011-07-10T04:52:00.000","Title":"Live countdown clock with django and sql?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I make a live countdown clock like ebay, how do I do this with django and sql?  I'm assuming running a function in django or in sql over and over every second to check the time would be horribly inefficient.  \nIs this even a plausible strategy?\nOr is this the way they do it:\nWhen a page loads, it takes the end datetime from the server and runs a javascript countdown clock against it on the user machine?\nIf so, how do you do the countdown clock with javascript? And how would I be able to delete\/move data once the time limit is over without a user page load? Or is it absolutely necessary for the user to load the page to check the time limit to create an efficient countdown clock?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2127,"Q_Id":6639247,"Users Score":0,"Answer":"I have also encountered the same problem a while ago.\nFirst of all your problem is not related neither django nor sql. It is a general concept and it is not very easy to implement because of overhead in server.\nOne solution come into my mind is keeping start time of the process in the database.\nWhen someone request you to see remaingn time, read it from database, subtract the current time and server that time and in your browser initialize your javascript function with that value and countdown like 15 sec. After that do the same operation with AJAX without waiting user's request.\nHowever, there would be other implementations depending your application. If you explain your application in detail there could be other solutions.\nFor example, if you implement a questionnaire with limited time, then for every answer submit, you should pass the calculated javascript value for that second.","Q_Score":0,"Tags":"javascript,python,django,time,countdown","A_Id":6639878,"CreationDate":"2011-07-10T04:52:00.000","Title":"Live countdown clock with django and sql?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, you can get the numbers in a range by calling range(x,y). But given two ranges, say 5-15, and 10-20 how can you get all the numbers 5-20 without duplicates? The ranges may also be disjoint.\nI could concat all the results and then uniquify the list, but is that the fastest solution?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":292,"Q_Id":6643747,"Users Score":1,"Answer":"Sort the ranges (x, y) by increasing x values. Now, for each range, if it overlaps the previous range, set your current \"big range\"'s y value to the current range's y value. If it doesn't, start a new \"big range\": this one won't overlap any of the previous ones. If the current range is completely included in the current big one, ignore it.","Q_Score":2,"Tags":"python,algorithm","A_Id":6644412,"CreationDate":"2011-07-10T21:15:00.000","Title":"Given a bunch of ranges of numbers, get all the numbers within those ranges?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, Iv'e got a pygame application. Right now, it takes a command line argument to specify which display to show the main screen on. However, I'm running it on windows, where it's hard to specify command line input to a graphical application.\nSo, I'd like to have a very very very simple dialog box which pops up, prompts the user for an integer, then closes. My research has shown that pygame can't do a dialog box like this, and I can't get input in a pygame window, because the program doesn't know yet which monitor to draw the pygame window to.\nSo, my question is, what is the simplest way to create a dialog box for input? I've looked into wx and tkinter. I could use either of them, but what I'm wondering is, but I want to import the least number of extra toolkits. i.e. I don't want to have to start the wx main loop just so I can make 1 dialog, then close it, then start a whole new pygame window.\nI know how to do this in wx, so I'm mostly looking for advice\/ideas as to which toolkit would be simplest, as opposed to instruction on how to actually do it (though that's always nice too).","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2527,"Q_Id":6656750,"Users Score":1,"Answer":"Since tkinter is built into Python, it might be better. I prefer wx, but if you just want a few dialogues, tkinter is fine.\nYou could also just try raw_input('type \"1\" for low res, \"2\" for high res'). I think it brings up a dialog window in Windows.","Q_Score":1,"Tags":"python,user-interface,tkinter,pygame","A_Id":6657099,"CreationDate":"2011-07-11T21:22:00.000","Title":"Simplest way to get initial text input in pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use OpcDaNet.dll in python, I use for that ctypes, but to be able to use the functions I'm intersted in, I have to create an instance of OpcServer Object, how can I do that with Ctypes?\nthanks for your answres","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":533,"Q_Id":6666162,"Users Score":1,"Answer":"In fact,you can't create an instance of OpcServer Object if you use the moudle ctypes.Because C is not Object-Oriented language.If you use C++ to make a .dll file,you should make a C interface,in program such as extern \"C\",if you return an object in this .dll file,python' function can't recieve this object.If I'm not mistaken.If you really want to return an object in the dll file,maybe you can use boost.python to develop the dll file.","Q_Score":0,"Tags":"python,ctypes","A_Id":28210864,"CreationDate":"2011-07-12T14:51:00.000","Title":"ctypes lib in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try to connect to database in a domain from my virtual machine. \nIt works on XP, but somehow does not work on Win7 and quitting with:\n\"OperationalError: (1042, \"Can't get hostname for your address\")\"\nNow I tried disable Firewall and stuff, but that doesn't matter anyway.\nI don't need the DNS resolving, which will only slow everything down.\nSo I want to use the option \"skip-name-resolve\", but there is no my.ini\nor my.cnf when using MySQLdb for Python, so how can I still use this option?\nThanks for your help\n-Alex","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":60490,"Q_Id":6668073,"Users Score":1,"Answer":"This is an option which needs to be set in the MySQL configuration file on the server. It can't be set by client APIs such as MySQLdb. This is because of the potential security implications.\nThat is, I may want to deny access from a particular hostname. With skip-name-resolve enabled, this won't work. (Admittedly, access control via hostname is probably not the best idea anyway.)","Q_Score":12,"Tags":"python,mysql,mysql-python,resolve","A_Id":6668116,"CreationDate":"2011-07-12T17:00:00.000","Title":"How to use the option skip-name-resolve when using MySQLdb for Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking to keep a summary of both the number of times a specific thing happens and when something very important arises. I'll give an example...\nMy code establishes a ssh connection and runs commands. An exception is raised and handled every time the script loses connection to the ssh server. Let's say this type of exception is handled in different ways across multiple files. How can I keep a record of the number of times this is handled? This is not specific to exceptions. If, for example, I run a command and get a certain response back, I want to make note that this occurred. I need all of this to be logged (I already know how to set up the logger) when the script ends.\nThe reason for doing this is because my script logs a large amount of information and I want to be able to have a quick summary of important things that happened at the end of the log file.\ntldr; How can I keep a record of the number of times something occurs \/ when something occurs across multiple files so I can log it when the script ends?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":6680695,"Users Score":0,"Answer":"I assume by multiple files you mean you have multiple separate scripts running and you want to log some consolidated summary of events occurring in all those scripts.\nIf you have a single script it is easy to do by maintaining a dict and dumping it to a log file or may be overwrite a single summary file, for multiple scripts you can run a separate logging server , which is used by all scripts for logging or at-least to add and dump summary info, alternatively you can use a common database with table locking","Q_Score":1,"Tags":"python,logging","A_Id":6681434,"CreationDate":"2011-07-13T14:39:00.000","Title":"How can I record the number of times something happens over several files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to upload my application on google app engine\nand want to use this by only selected user\nso want to know how it possible.\nwant to use users gmail account.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":755,"Q_Id":6694662,"Users Score":2,"Answer":"You basically need to do it in two steps:\n\nDo what systempuntoout's answer said to only allow logged-in users to see your site.\nOn each of your routes (URL handlers), the first step should be to get their user object and check if they are on a list you're keeping of users allowed to see your app. For a first run, you could just have the list be a global variable, but this isn't very flexible (it makes you redeploy your app every time you want to update the list), so for a second run you should refactor it to perhaps read from the Datastore to see if a user is in the allowed list or not.","Q_Score":3,"Tags":"python,google-app-engine,google-cloud-datastore","A_Id":6697664,"CreationDate":"2011-07-14T14:17:00.000","Title":"How to allow only selected user login in gae+python application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used matplotlib to create some plot, which depends on 8 variables. I would like to study how the plot changes when I change some of them. I created some script that calls the matplotlib one and generates different snapshots that later I convert into a movie, it is not bad, but a bit clumsy. \n\nI wonder if somehow I could interact with the plot regeneration using keyboard keys to increase \/ decrease values of some of the variables and see instantly how the plot changes. \nWhat is the best approach for this? \nAlso if you can point me to interesting links or a link with a plot example with just two sliders?","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":98213,"Q_Id":6697259,"Users Score":2,"Answer":"Use waitforbuttonpress(timeout=0.001) then plot will see your mouse ticks.","Q_Score":70,"Tags":"python,keyboard,matplotlib,interactive","A_Id":11928786,"CreationDate":"2011-07-14T17:10:00.000","Title":"Interactive matplotlib plot with two sliders","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'd like to write a python script (call it parent) that does the following:\n(1) defines a multi-dimensional numpy array\n(2) forks 10 different python scripts (call them children). Each of them must be able to read the contents of the numpy array from (1) at any single point in time (as long as they are alive).\n(3) each of the child scripts will do it's own work (children DO NOT share any info with each other)\n(4) at any point in time, the parent script must be able to accept messages from all of its children. These messages will be parsed by the parent and cause the numpy array from (1) to change.\n\nHow do I go about this, when working in python in a Linux environment? I thought of using zeroMQ and have the parent be a single subscriber while the children will all be publishers; does it make sense or is there a better way for this?\nAlso, how do I allow all the children to continuously read the contents of the numpy array that was defined by the parent ?","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":14920,"Q_Id":6700149,"Users Score":-2,"Answer":"In ZeroMQ there can only be one publisher per port. The only (ugly) workaround is to start each child PUB socket on a different port and have the parent listen on all those ports. \nbut the pipeline pattern describe on 0MQ, user guide is a much better way to do this.","Q_Score":9,"Tags":"python,zeromq","A_Id":6831300,"CreationDate":"2011-07-14T21:29:00.000","Title":"Python zeromq -- Multiple Publishers To a Single Subscriber?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have two lists:\neg.\na = [1,8,3,9,4,9,3,8,1,2,3]\nand\nb = [1,8,1,3,9,4,9,3,8,1,2,3]\nBoth contain ints. There is no meaning behind the ints (eg. 1 is not 'closer' to 3 than it is to 8). \nI'm trying to devise an algorithm to calculate the similarity between two ORDERED lists. Ordered is keyword right here (so I can't just take the set of both lists and calculate their set_difference percentage). Sometimes numbers do repeat (for example 3, 8, and 9 above, and I cannot ignore the repeats).\nIn the example above, the function I would call would tell me that a and b are ~90% similar for example. How can I do that? Edit distance was something which came to mind. I know how to use it with strings but I'm not sure how to use it with a list of ints. Thanks!","AnswerCount":7,"Available Count":1,"Score":0.0855049882,"is_accepted":false,"ViewCount":38544,"Q_Id":6709693,"Users Score":3,"Answer":"Just use the same algorithm for calculating edit distance on strings if the values don't have any particular meaning.","Q_Score":27,"Tags":"python,algorithm","A_Id":6709749,"CreationDate":"2011-07-15T15:45:00.000","Title":"Calculating the similarity of two lists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently I've begun working on exploring ways to convert about 16k Corel Paradox 4.0 database tables (my client has been using a legacy platform over 20 years mainly due to massive logistical matters) to more modern formats (i.e.CSV, SQL, etc.) en mass and so far I've been looking at PHP since it has a library devoted to Paradox data processing however while I'm fairly confident in how to write the conversion code (i.e. simply calling a few file open, close, and write functions) I'm concerned about error detection and ensuring that when running the script, I don't spend hours waiting for it to run only to see 16k corrupt files exported.\nAlso, I'm not fully sure about the logic loop for calling the files. I'm thinking of having the program generate a list of all the files with the appropriate extension and then looping through the list, however I'm not sure if that's ideal for a directory of this size.\nThis is being run on a local Windows 7 x64 system with XAMPP setup (the database is all internal use) so I'm not sure if pure PHP is the best idea -- so I've been wondering if Python or some other lightweight scripting language might be better for handling this.\nThanks very much in advance for any insights and assistance,","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":734,"Q_Id":6709833,"Users Score":0,"Answer":"If you intend to just convert the data which I guess is a process you do only once you will run the script locally as a command script. For that you don't need a web site and thus XAMPP. What language you take is secondary except you say that PHP has a library. Does python or others have one?\nAbout your concern of error detection why not test your script with only one file first. If that conversion is successful you can build your loop and test this on maybe five files, i.e. have a counter that ends the process after that number. It that is still okay you can go on with the rest. You can also write log data and dump a result for every 100 files processed. This way you can see if your script is doing something or idling.","Q_Score":1,"Tags":"php,python,mysql,xampp,php-gtk","A_Id":6711276,"CreationDate":"2011-07-15T15:56:00.000","Title":"Batch converting Corel Paradox 4.0 Tables to CSV\/SQL -- via PHP or other scripts","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Recently I've begun working on exploring ways to convert about 16k Corel Paradox 4.0 database tables (my client has been using a legacy platform over 20 years mainly due to massive logistical matters) to more modern formats (i.e.CSV, SQL, etc.) en mass and so far I've been looking at PHP since it has a library devoted to Paradox data processing however while I'm fairly confident in how to write the conversion code (i.e. simply calling a few file open, close, and write functions) I'm concerned about error detection and ensuring that when running the script, I don't spend hours waiting for it to run only to see 16k corrupt files exported.\nAlso, I'm not fully sure about the logic loop for calling the files. I'm thinking of having the program generate a list of all the files with the appropriate extension and then looping through the list, however I'm not sure if that's ideal for a directory of this size.\nThis is being run on a local Windows 7 x64 system with XAMPP setup (the database is all internal use) so I'm not sure if pure PHP is the best idea -- so I've been wondering if Python or some other lightweight scripting language might be better for handling this.\nThanks very much in advance for any insights and assistance,","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":734,"Q_Id":6709833,"Users Score":1,"Answer":"This is doubtless far too late to help you, but for posterity...\nIf one has a Corel Paradox working environment, one can just use it to ease the transition.\nWe moved the Corel Paradox 9 tables we had into an Oracle schema we built by connecting to the schema (using an alias such as SCHEMA001) then writing this Procedure in a script from inside Paradox:\nProc writeTable(targetTable String)\n   errorTrapOnWarnings(Yes)\n   try\n    tc.open(targetTable)\n    tc.copy(\":SCHEMA001:\" + targetTable) \n    tc.close()\n   onFail\n    errorShow()\n   endTry\nendProc\nOne could highly refine this with more Paradox programming, but you get the idea.  One thing we discovered, though, is that Paradox uses double quotes for the column names when it creates the Oracle version, which means you can get lower-case letters in column names in Oracle, which is a pain.  We corrected that by writing a quick Oracle query to upper() all the resulting column names.\nWe called the procedure like so:\nVar\n   targetTable  String\n   tc           TCursor\nendVar\nmethod run(var eventInfo Event)\n    targetTable = \"SomeTableName\" \n    writeTable(targetTable)\n    msgInfo(\"TransferData.ssl--script finished\",\n            \"That's all, folks!\" )\n    return\nendMethod","Q_Score":1,"Tags":"php,python,mysql,xampp,php-gtk","A_Id":39728385,"CreationDate":"2011-07-15T15:56:00.000","Title":"Batch converting Corel Paradox 4.0 Tables to CSV\/SQL -- via PHP or other scripts","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have some python modules to copy into my Linux computer.\nI found out that I need to copy them into one of the directory that python searches or else show a new path for it.\n1. when I tried to copy files into \/usr\/bin\/....\/python2.6 .. its not allowing me.\n   how do I make it.\n2. Also do tell me how do I add a new search path ?\n\nplease guide me in detail. I have very less knowledge in linux\nAlso please tell me how do I get over this kind of problems myself. Is there any small book or a kind of to learn?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1248,"Q_Id":6711365,"Users Score":2,"Answer":"Make it a proper Python package on top of setuptools and register your command-line frontends using the 'console_scripts' entry-point.","Q_Score":1,"Tags":"python,linux,module,copy","A_Id":6711450,"CreationDate":"2011-07-15T18:08:00.000","Title":"how to copy python modules into python lib directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a very simple CGI webserver running using python CGIHTTPServer class.\nThis class spawns and executes a cgi-php script.\nIf the webpage sends POST request, how can I access the POST request data in the php script?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1199,"Q_Id":6712092,"Users Score":1,"Answer":"When you say your Python process \"spawns and executes\" a cgi-php script, I believe what you mean is \"it calls my PHP script by executing the PHP CLI executable, passing it the name of my script.\"\nUsing the PHP CLI executable, HTTP-specific superglobals and environment values will not be set automatically.  You would have to read in all HTTP request headers and GET\/POST data in your Python server process, and then set them in the environment used by your PHP script.\nThe whole experiment sounds interesting, but this is what mod_php does already.","Q_Score":0,"Tags":"php,python,cgi,webserver,cgihttprequesthandler","A_Id":6712146,"CreationDate":"2011-07-15T19:16:00.000","Title":"Accessing POST request data from CGIHTTPServer (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to design an application that reads some a folder of text files and shows the user its contents. Three problems arise: I need the folder containing the text files to be encrypted which I don't know how to do, two, I need a way to read the encrypted files without revealing the key in the python code, so I guess C would be the best way to do that even if I don't like that way(any suggestions are welcome,using python if possible), and three, I need a way to add files to the folder and then send the encrypted folder along with the program.\nIs there any way to do those things without ever revealing the key or giving the user the possibility to read the folder except using my program?\nThanks in advance for any help!\nEDIT:  Also, is there a way to use C to encrypt and decrypt files so that I can put the key in the compiled file and distribute that with my program?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":870,"Q_Id":6721138,"Users Score":1,"Answer":"I think the best thing to do would be to encrypt the individual text files using GPG, one of the strongest encryption systems available(and for free!) You can get several python libraries to do this, and I recommend python-gnupg. Also, you can probably just reference the file where the key is located and distribute it along with the application? If you want to include a preset key and not have your users be able to see where that key is, you are going to have a very hard time. How about using a key on a server you control that somehow only accepts requests for the key from copies of your application? I don't know how you'd make this secure though through Python. \nAbout adding files to the folder and sending it along with the program, perhaps you aren't thinking of the most optimal solution? There are plenty of python data structures that can be serialized and accomplish most of the things you are talking about in your post.","Q_Score":0,"Tags":"python,c,encryption,directory","A_Id":6721220,"CreationDate":"2011-07-17T00:21:00.000","Title":"How to use python to read an encrypted folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let me start with an example:\nThere is a c++ program which can be run on my server, the program is named \"Guess the Number\" which means every time it runs,  \n\nfirst it will generate an integer between 1 and 100 randomly.\nthen i need the user to guess a number and pass it to me though a web page, form or something. \nnow i want pass the number to the program and then the program will tell me whether it's bigger or smaller. \nthen i put the information on the web page to let the user know and then make his next guess.\n\ni am able to write the program. and i know how pass the first argument and give back the information, but don't know how to interact in the next steps. i.e.  \nHow to pass the arguments to the program REAL-TIME and get the output?\nto make this more clearly:\n\ni use subprocess in python to run the program with the first argument and get the output.\nthe c++ program use std inputs and outputs, like while (!check(x)) scanf(\"%d\",&x);, and in check(int x), i use if (x>rand_num) printf(\"too big\\n\"); to output.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":233,"Q_Id":6736152,"Users Score":0,"Answer":"This sounds a lot like a homework question, but even with this list, you have a lot of work ahead of you for a dubious reward, so here we go.\n\nYour C++ program should listen on a socket\nYour python program needs to listen on a web socket, and also have a connection open to the C++ program through the C++ socket. \nI'd suggest something like web.py for your web framework\nYour web.py program is going to accept XMLHTTP Requests at a URL\nyour web page is going to submit requests through that XMLHTTP request, and send results back into the web page.\n\nAn easy way to do this on the frontend is to you jquery ajax commands; they will hit your web.py URL, which will validate the input, call a function to send it off to the C++ socket, get a response and send it back as a response to your jquery request.\nGood luck.","Q_Score":1,"Tags":"python,ajax,cgi,subprocess,pipe","A_Id":6737020,"CreationDate":"2011-07-18T16:30:00.000","Title":"How to INTERACT between a program on the server and the user via a web page REAL-TIME","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to programming and thought Python would be a good language to learn. Most of the tutorials I found were 2.7 based so I started to learn using that version. I've recently found a tkinter tutorial that I'd like to try out but I'm having a problem. If I run a script it will use Python 2.7 which contains Tkinter and not tkinter.\nThis problem made me think, how can I get my two versions to co-exist so I can program in both 2.x and 3.x?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15701,"Q_Id":6737694,"Users Score":0,"Answer":"It depends on what you are trying to do. You can have them coexist because 3.2 is backwards-compatible. Now you can install both versions on your computer 3.2 and 2.7, but 3.2 unfortunately will have to be used in IDLE....ugh.... Just install both and then depending on which one you want to use. Run that IDLE for either one or the other.\nNow if you are meaning that you want more stable version that can be professionally done, go with 2.7 ( I have done otherwise, but if you run into problems 2.7 is more supported.\nIf you want the more cutting edge stuff, go with 3.2. Either one you go with works with about eveyrthing. If it doesn't, give it a month or two and the rest of the world will catch up.","Q_Score":10,"Tags":"python","A_Id":6738871,"CreationDate":"2011-07-18T18:40:00.000","Title":"How to I get Python 2.x and 3.x to co-exist?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Apologies if this is straight forward, but I have not found any help in the python manual or google.\nI am trying to find the inverse cosine for a value using python.\ni.e. cos\u207b\u00b9(x)\nDoes anyone know how to do this?\nThanks","AnswerCount":7,"Available Count":1,"Score":0.0855049882,"is_accepted":false,"ViewCount":117730,"Q_Id":6745464,"Users Score":3,"Answer":"You're looking for the math.acos() function.","Q_Score":52,"Tags":"python,math,trigonometry","A_Id":6745509,"CreationDate":"2011-07-19T10:05:00.000","Title":"Inverse Cosine in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a python library or a command line tool for downloading multiple files in parallel. My current solution is to download the files sequentially which is slow. I know you can easily write a half-assed threaded solution in python, but I always run into annoying problem when using threading. It is for polling a large number of xml feeds from websites.\nMy requirements for the solution are:\n\nShould be interruptable. Ctrl+C should immediately terminate all downloads.\nThere should be no leftover processes that you have to kill manually using kill, even if the main program crashes or an exception is thrown.\nIt should work on Linux and Windows too.\nIt should retry downloads, be resilient against network errors and should timeout properly.\nIt should be smart about not hammering the same server with 100+ simultaneous downloads, but queue them in a sane way.\nIt should handle important http status codes like 301, 302 and 304. That means that for each file, it should take the Last-Modified value as input and only download if it has changed since last time. \nPreferably it should have a progress bar or it should be easy to write a progress bar for it to monitor the download progress of all files.\nPreferably it should take advantage of http keep-alive to maximize the transfer speed.\n\nPlease don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution.\nI guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. \nThen the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","AnswerCount":10,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":6882,"Q_Id":6750619,"Users Score":7,"Answer":"You can try pycurl, though the interface is not easy at first, but once you look at examples, its not hard to understand. I have used it to fetch 1000s of web pages in parallel on meagre linux box. \n\nYou don't have to deal with threads, so it terminates gracefully, and there are no processes left behind\nIt provides options for timeout, and http status handling.\nIt works on both linux and windows.\n\nThe only problem is that it provides a basic infrastructure (basically just a python layer above the excellent curl library). You will have to write few lines to achieve the features as you want.","Q_Score":19,"Tags":"python,http,parallel-processing,download,feed","A_Id":6882144,"CreationDate":"2011-07-19T16:28:00.000","Title":"Library or tool to download multiple files in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm looking for a python library or a command line tool for downloading multiple files in parallel. My current solution is to download the files sequentially which is slow. I know you can easily write a half-assed threaded solution in python, but I always run into annoying problem when using threading. It is for polling a large number of xml feeds from websites.\nMy requirements for the solution are:\n\nShould be interruptable. Ctrl+C should immediately terminate all downloads.\nThere should be no leftover processes that you have to kill manually using kill, even if the main program crashes or an exception is thrown.\nIt should work on Linux and Windows too.\nIt should retry downloads, be resilient against network errors and should timeout properly.\nIt should be smart about not hammering the same server with 100+ simultaneous downloads, but queue them in a sane way.\nIt should handle important http status codes like 301, 302 and 304. That means that for each file, it should take the Last-Modified value as input and only download if it has changed since last time. \nPreferably it should have a progress bar or it should be easy to write a progress bar for it to monitor the download progress of all files.\nPreferably it should take advantage of http keep-alive to maximize the transfer speed.\n\nPlease don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution.\nI guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. \nThen the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","AnswerCount":10,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":6882,"Q_Id":6750619,"Users Score":5,"Answer":"There are lots of options but it will be hard to find one which fits all your needs.\nIn your case, try this approach:\n\nCreate a queue.\nPut URLs to download into this queue (or \"config objects\" which contain the URL and other data like the user name, the destination file, etc).\nCreate a pool of threads\nEach thread should try to fetch a URL (or a config object) from the queue and process it.\n\nUse another thread to collect the results (i.e. another queue). When the number of result objects == number of puts in the first queue, then you're finished.\nMake sure that all communication goes via the queue or the \"config object\". Avoid accessing data structures which are shared between threads. This should save you 99% of the problems.","Q_Score":19,"Tags":"python,http,parallel-processing,download,feed","A_Id":6750711,"CreationDate":"2011-07-19T16:28:00.000","Title":"Library or tool to download multiple files in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm looking for a python library or a command line tool for downloading multiple files in parallel. My current solution is to download the files sequentially which is slow. I know you can easily write a half-assed threaded solution in python, but I always run into annoying problem when using threading. It is for polling a large number of xml feeds from websites.\nMy requirements for the solution are:\n\nShould be interruptable. Ctrl+C should immediately terminate all downloads.\nThere should be no leftover processes that you have to kill manually using kill, even if the main program crashes or an exception is thrown.\nIt should work on Linux and Windows too.\nIt should retry downloads, be resilient against network errors and should timeout properly.\nIt should be smart about not hammering the same server with 100+ simultaneous downloads, but queue them in a sane way.\nIt should handle important http status codes like 301, 302 and 304. That means that for each file, it should take the Last-Modified value as input and only download if it has changed since last time. \nPreferably it should have a progress bar or it should be easy to write a progress bar for it to monitor the download progress of all files.\nPreferably it should take advantage of http keep-alive to maximize the transfer speed.\n\nPlease don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution.\nI guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. \nThen the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","AnswerCount":10,"Available Count":4,"Score":-0.0199973338,"is_accepted":false,"ViewCount":6882,"Q_Id":6750619,"Users Score":-1,"Answer":"Threading isn't \"half-assed\" unless you're a bad programmer. The best general approach to this problem is the producer \/ consumer model. You have one dedicated URL producer, and N dedicated download threads (or even processes if you use the multiprocessing model).\nAs for all of your requirements, ALL of them CAN be done with the normal python threaded model (yes, even catching Ctrl+C -- I've done it).","Q_Score":19,"Tags":"python,http,parallel-processing,download,feed","A_Id":6750741,"CreationDate":"2011-07-19T16:28:00.000","Title":"Library or tool to download multiple files in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm looking for a python library or a command line tool for downloading multiple files in parallel. My current solution is to download the files sequentially which is slow. I know you can easily write a half-assed threaded solution in python, but I always run into annoying problem when using threading. It is for polling a large number of xml feeds from websites.\nMy requirements for the solution are:\n\nShould be interruptable. Ctrl+C should immediately terminate all downloads.\nThere should be no leftover processes that you have to kill manually using kill, even if the main program crashes or an exception is thrown.\nIt should work on Linux and Windows too.\nIt should retry downloads, be resilient against network errors and should timeout properly.\nIt should be smart about not hammering the same server with 100+ simultaneous downloads, but queue them in a sane way.\nIt should handle important http status codes like 301, 302 and 304. That means that for each file, it should take the Last-Modified value as input and only download if it has changed since last time. \nPreferably it should have a progress bar or it should be easy to write a progress bar for it to monitor the download progress of all files.\nPreferably it should take advantage of http keep-alive to maximize the transfer speed.\n\nPlease don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution.\nI guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. \nThen the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","AnswerCount":10,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":6882,"Q_Id":6750619,"Users Score":0,"Answer":"I used the standard libs for that, urllib.urlretrieve to be precise. downloaded podcasts this way, via a simple thread pool, each using its own retrieve. I did about 10 simultanous connections, more should not be a problem. Continue a interrupted download, maybe not. Ctrl-C could be handled, I guess. Worked on Windows, installed a handler for progress bars. All in all 2 screens of code, 2 screens for generating the URLs to retrieve.","Q_Score":19,"Tags":"python,http,parallel-processing,download,feed","A_Id":6889198,"CreationDate":"2011-07-19T16:28:00.000","Title":"Library or tool to download multiple files in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Does anybody know how to check the status of the last executed command (exit code) in ipython?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5195,"Q_Id":6755794,"Users Score":16,"Answer":"It should be stored as _exit_code after you run the command (at least in the upcoming v0.11 release).","Q_Score":8,"Tags":"python,ipython","A_Id":6766813,"CreationDate":"2011-07-19T23:18:00.000","Title":"Check the exit status of last command in ipython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For those of you who have written fairly complex PyQt applications, what tips and tricks would you offer for speeding up your applications? I have a few examples of where my program begins to slow down as it grows larger:\n\nI have a 'dashboard' written that is destroyed and re-created when a user clicks on an item in a TreeWidget. What would be a better way to have a modular interface where clicking an item in the TreeWidget changes the dashboard, but doesn't require destroying a widget and recreating it.\nEach dashboard also loads an image from a network location. This creates some slowdown as one navigates around the application, but after it's loaded into memory, 'going back to that same dash' is faster. Is there a good method or way to run a thread on program load that maybe pre-loads the images into memory? If so, how do you implement that?\nWhen you have a large variety of dashboard items and data that gets loaded into them, do you guys normally thread the data load and load it back in which each thread completes? Is this viable when somebody is browsing around quickly? Would implementing a kill-switch for the threads such that when a user changes dashboards, the threads die work? Or would the constant creation and killing of threads cause some sort of, well, meltdown.\n\nSorry for the huge barrage of questions, but they seemed similar enough to warrant bundling them together.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3849,"Q_Id":6764329,"Users Score":8,"Answer":"I'm not sure if this is exactly the same thing you are doing, but it sounds similar to something I have in some apps, where there is some list of custom widget. And it does significantly slow down when you are creating and destroying tons of widgets.\nIf its an issue of lesser amounts of total widgets, but just being created and deleted a lot, you can just create the widgets once, and only change the data of those widgets as information needs to be updated... as opposed to creating new widgets each time the information changes. That way you can even change the data from threads without having to worry about creating widgets.\nAnother situation is where you are displaying a list with custom widgets and there are a TON of results. I notice it always slows down when you have 1000's of custom widgets in a list. A trick my co-worker came up with was to have a fake kind of list where it is using a static number of slots in the display. Say, it shows 10 slots in the view. The scrollbar doesn't really scroll down across MORE widget...what it does is scrolls the DATA through the 10 visible widgets. You can a crazy performance increase doing that. But only if it is an acceptable display style for your application.","Q_Score":6,"Tags":"python,optimization,pyqt","A_Id":6821582,"CreationDate":"2011-07-20T15:21:00.000","Title":"Optimizing your PyQt applications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For those of you who have written fairly complex PyQt applications, what tips and tricks would you offer for speeding up your applications? I have a few examples of where my program begins to slow down as it grows larger:\n\nI have a 'dashboard' written that is destroyed and re-created when a user clicks on an item in a TreeWidget. What would be a better way to have a modular interface where clicking an item in the TreeWidget changes the dashboard, but doesn't require destroying a widget and recreating it.\nEach dashboard also loads an image from a network location. This creates some slowdown as one navigates around the application, but after it's loaded into memory, 'going back to that same dash' is faster. Is there a good method or way to run a thread on program load that maybe pre-loads the images into memory? If so, how do you implement that?\nWhen you have a large variety of dashboard items and data that gets loaded into them, do you guys normally thread the data load and load it back in which each thread completes? Is this viable when somebody is browsing around quickly? Would implementing a kill-switch for the threads such that when a user changes dashboards, the threads die work? Or would the constant creation and killing of threads cause some sort of, well, meltdown.\n\nSorry for the huge barrage of questions, but they seemed similar enough to warrant bundling them together.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3849,"Q_Id":6764329,"Users Score":1,"Answer":"Are you using QNetworkAccessManager to load you images? It has cache support. Also it loads everything in background with finishing callbacks.\nI don't really understand what your dashboard is doing. Have you think about using QWebkit? Maybe your dashboard content is easy to be implemented in HTML?\nPS. I don't like threads in Python and don't think they are good idea. Deferred jobs delegated to Qt core is better.","Q_Score":6,"Tags":"python,optimization,pyqt","A_Id":6774281,"CreationDate":"2011-07-20T15:21:00.000","Title":"Optimizing your PyQt applications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i want to use python in combination with tcpdump to put the generated stream from tcpdump into a more readable way. There are some fields in the streams with interesting values.\nI found some stuff here at stackoverflow regarding python and tcpdump but in my mind the best way is to put it in an array.\nAfter this is done i want to read some fields out of the array, and than it can be cleared and used for the next network frame.\nCan somebody give me some hints, how this can be done?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":476,"Q_Id":6791916,"Users Score":0,"Answer":"You can try using Scapy sniffing function sniff, append the captured packets to a list and do your extraction process.","Q_Score":0,"Tags":"python,stream","A_Id":17312308,"CreationDate":"2011-07-22T15:00:00.000","Title":"put stream from tcpdump into an array - which python version should i use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"In Numpy (and Python in general, I suppose), how does one store a slice-index, such as (...,0,:), in order to pass it around and apply it to various arrays? It would be nice to, say, be able to pass a slice-index to and from functions.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":389,"Q_Id":6795657,"Users Score":0,"Answer":"I think you want to just do myslice = slice(1,2) to for example define a slice that will return the 2nd element (i.e. myarray[myslice] == myarray[1:2])","Q_Score":5,"Tags":"python,indexing,numpy,slice","A_Id":6795732,"CreationDate":"2011-07-22T20:20:00.000","Title":"Numpy: arr[...,0,:] works. But how do I store the data contained in the slice command (..., 0, :)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anybody know how to distinguish new errors (those that were found during latest Pylint execution) and old errors (those that were alredy found during previous executions) in the Pylint report?\nI'm using Pylint in one of my projects, and the project is pretty big. Pylint reports pretty many errors (even though I disabled lots of them in the rcfile). While I fix these errors with time, it is also important to not introduce new ones. But Pylint HTML and \"parseable\" reports don't distinguish new errors from those that were identified previously, even though I run Pylint with persistent=yes option.\nAs for now - I compare old and new reports manually. What would be really nice though, is if Pylint could highlight somehow those error messages which were found on a latest run, but were not found on a previous one. Is it possible to do so using Pylint or existing tools or something? Becuase if not - it seems I will end up writing my own comparison and report generation.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":925,"Q_Id":6802119,"Users Score":0,"Answer":"Run pylint on dev branch, get x errors\nRun pylint on master branch, get y errors\nIf y > x, which means you have new errors\nYou can do above things in CI process, before code is merged to master","Q_Score":8,"Tags":"python,pylint","A_Id":64587242,"CreationDate":"2011-07-23T17:35:00.000","Title":"Pylint - distinguish new errors from old ones","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Does anybody know how to distinguish new errors (those that were found during latest Pylint execution) and old errors (those that were alredy found during previous executions) in the Pylint report?\nI'm using Pylint in one of my projects, and the project is pretty big. Pylint reports pretty many errors (even though I disabled lots of them in the rcfile). While I fix these errors with time, it is also important to not introduce new ones. But Pylint HTML and \"parseable\" reports don't distinguish new errors from those that were identified previously, even though I run Pylint with persistent=yes option.\nAs for now - I compare old and new reports manually. What would be really nice though, is if Pylint could highlight somehow those error messages which were found on a latest run, but were not found on a previous one. Is it possible to do so using Pylint or existing tools or something? Becuase if not - it seems I will end up writing my own comparison and report generation.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":925,"Q_Id":6802119,"Users Score":4,"Answer":"Two basic approaches. Fix errors as they appear so that there will be no old ones. Or, if you have no intention of fixing certain types of lint errors, tell lint to stop reporting them.\nIf you have a lot of files it would be a good idea to get a lint report for each file separately, commit the lint reports to revision control like svn, and then use the revision control systems diff utility to separate new lint errors from older pre-existing ones. The reason for seperate reports for each .py file is to make it easier to read the diff output.\nIf you are on Linux, vim -d oldfile newfile is a nice way to read diff. If you are on Windows then just use the diff capability built into Tortoise SVN.","Q_Score":8,"Tags":"python,pylint","A_Id":6805524,"CreationDate":"2011-07-23T17:35:00.000","Title":"Pylint - distinguish new errors from old ones","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a Pyramid web application that needs to send emails such as confirmation emails after registration, newsletters and so forth. I know how to send emails using smtplib in python and I decided on an smtp service (I think sendgrid will do the trick).\nThe real problem is the scheduling and delay sending of the emails - for example, when a user registers, the email is to be sent on the form post view. But, I don't want to block the request, and therefore would like to \"schedule\" the email in a non-blocking way.\nOther than implementing this myself (probably with a DB and a worker), is there an existing solution to email queue and scheduling?\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":493,"Q_Id":6802638,"Users Score":0,"Answer":"In my app, I insert emails in DB table, and I have python script running under cron that checks this table and sends email updating record as sent.","Q_Score":0,"Tags":"python,email,queue,scheduling","A_Id":6806145,"CreationDate":"2011-07-23T19:06:00.000","Title":"Best way to do email scheduling on a python web application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Pyramid web application that needs to send emails such as confirmation emails after registration, newsletters and so forth. I know how to send emails using smtplib in python and I decided on an smtp service (I think sendgrid will do the trick).\nThe real problem is the scheduling and delay sending of the emails - for example, when a user registers, the email is to be sent on the form post view. But, I don't want to block the request, and therefore would like to \"schedule\" the email in a non-blocking way.\nOther than implementing this myself (probably with a DB and a worker), is there an existing solution to email queue and scheduling?\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":493,"Q_Id":6802638,"Users Score":0,"Answer":"The existing solution to which you refer is to run your own SMTP server on the machine, bound only to localhost to prevent any other machines from connecting to it. Since you're the only one using it, submitting a message to it should be close to instantaneous, and the server will handle queuing, retries, etc. If you are running on a UNIX\/Linux box, there's probably already such a server installed.","Q_Score":0,"Tags":"python,email,queue,scheduling","A_Id":6802910,"CreationDate":"2011-07-23T19:06:00.000","Title":"Best way to do email scheduling on a python web application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"am working on a code which I would like to retrieve the commits from a repository on github. Am not entirely sure how to do such a thing, I got git-python but most the api's are for opening a local git repository on the same file system. \nCan someone advice? \nregards,","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":10402,"Q_Id":6806266,"Users Score":1,"Answer":"I really advise using only the command line git, git-python its used for macros or complicated things, not just for pulling, pushing or cloning :)","Q_Score":2,"Tags":"python,git","A_Id":6806465,"CreationDate":"2011-07-24T10:30:00.000","Title":"git-python get commit feed from a repository","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've used Python's subprocess.call() before, but how do you get it to act like the Windows START \/WAIT myprogram?\nI've tried subprocess.call(['start', '\/wait', 'myprogram.exe']) but it can't find start and neither can I.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":6820856,"Users Score":1,"Answer":"If you want to wait for a spawned process, then use subprocess.Popen and then either wait or communicate. start is AFAIR a shell construct, not a real exec (so you'd have to use shell = True \u2014 but that still wouldn't do what you want).","Q_Score":0,"Tags":"python,winapi,subprocess","A_Id":6820974,"CreationDate":"2011-07-25T18:49:00.000","Title":"python: executing \"start \/wait someprocess\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a background in PHP, dotNet and am charmed by Python. I want to transpose functionality from PHP to Python step by step, running bits and pieces side-by-side. During this transition, which could take 2 years since the app is enormous, I am bound to IIS. I've got 15 years background of web-programming, including some C work in an ISAPI module on IIS which is the kind of work I don't want to dive into any more.\nIt seems Python just doesn't run well on IIS. I've struggled with FastCGI (not supported, just for PHP) and PyIsapie (badly documented, couldn't get it up and running). In the end I got it up and running with a HeliconZoo dll BUT:\nMy next problem is: how to debug\/develop a site? In PHP you install a debugger and whenever you have a problem in your website, you just debug it, set a breakpoint, step through code, inspect watches and such. It seems to me this is the most rudimentary type of work for a developer or troubleshooter. I've bought WingIDE which is an excellent tool and debugger but it can't hook into the Python instance in the IIS process for some reason so no debugging. I noticed Helicon starts Python with -O so I even recompiled Python to ignore this flag altogether but my debugger (WingIDE) just won't come up.\nI can set up a PHP 'hello world' website on IIS in half an hour including download time. I think I've spent about 120 hours or more getting this to work for Python to no avail. I've bought Programming Python and Learning Python which is about 3000 pages. And I've googled until I dropped.\nI think Python is a great language but I'm on the verge of aborting my attempts. Is there anyone who can give me a step-by-step instruction on how to set this up on IIS7?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":85151,"Q_Id":6823316,"Users Score":3,"Answer":"just make sure the path to the directory holding the cgi scripts doesn't have spaces or &.\ni tried lots of things for many days and nothing worked then i changed the path and it worked\nUPDATE:\nIf it has spaces, put quotes around the path, but not the %s %s\nlike this:\n\"C:\\Program Files\\Python36\\python.exe\" %s %s","Q_Score":66,"Tags":"python,iis","A_Id":25462179,"CreationDate":"2011-07-25T22:47:00.000","Title":"Python on IIS: how?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The docs I've found on NPAPI plugins explain how to write plugins to be loaded by browsers, but how hard is it to write an application that loads existing NPAPI plugins?\n(My ultimate goal here is to find a way to use SWF content inside an application written with Python and wxPython in Linux. I've accomplished this on Windows by using the comtypes module to load the ActiveX Flash player. For Linux, I'm thinking that wrapping the Gnash NPAPI plugin in some C\/C++ code and making this a Python extension seems like it would work, albeit a bit convoluted...)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":499,"Q_Id":6838281,"Users Score":0,"Answer":"Your best bet (assuming basing your hosting code on open source software isn't an issue for you licensing-wise) is probably to look at the implementation of NPAPI host in WebKit, Chromium, and\/or Gecko.\nThe Mozilla documentation for the browser side of NPAPI will help, but there are a lot of little corner cases where plugins expect certain behavior because some early browser did it, and now everyone who wants to support those plugins has to do the same thing even if it's not part of the standard; the only way to learn about those is to look at existing implementation.","Q_Score":2,"Tags":"python,linux,flash,npapi","A_Id":6839048,"CreationDate":"2011-07-27T00:44:00.000","Title":"How can I load an NPAPI plugin in my own application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not sure on how to articulate this...  \nI have a Tkinter window, and I need to hide half of this window when a button is pressed. \nHowever, I need the left-most side to be hidden, so that the window is now half the size it originally was,\nand shows the right half of the original window.  \nAll of Tkinter's resize functions span from the left side of the window. \nChanging the geometry values can only show the left side whilst hiding the right; \nI need the inverse.\nDoes anybody know how to go about doing this?  \n(I don't want the user to have to drag the window border, \nI need the button to automate it).\n\nSpecs:\n\nPython 2.7.1\nTkinter\nWindows 7","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1136,"Q_Id":6870118,"Users Score":2,"Answer":"You can use right-anchored geometry specifications by using a minus sign in the right place:\n123x467-78+9\nHowever, I don't know if this will work on Windows (the above is an X11 trick, and I don't know if it is implemented in the platform-compatibility layer or not); you might have to just calculate the new position given the projected size of the left side and use that.","Q_Score":0,"Tags":"python,resize,tkinter,tk","A_Id":6870304,"CreationDate":"2011-07-29T07:51:00.000","Title":"Resize Tkinter Window FROM THE RIGHT (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not sure on how to articulate this...  \nI have a Tkinter window, and I need to hide half of this window when a button is pressed. \nHowever, I need the left-most side to be hidden, so that the window is now half the size it originally was,\nand shows the right half of the original window.  \nAll of Tkinter's resize functions span from the left side of the window. \nChanging the geometry values can only show the left side whilst hiding the right; \nI need the inverse.\nDoes anybody know how to go about doing this?  \n(I don't want the user to have to drag the window border, \nI need the button to automate it).\n\nSpecs:\n\nPython 2.7.1\nTkinter\nWindows 7","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":6870118,"Users Score":0,"Answer":"My IT teacher had a suggestion:\nAdd a Scrollbar out of sight,\nand after resizing the root window,\nforce the scrollbar to scroll all the way to the right.  \n(So I guess I'd have to create a canvas,\npack all my widgets to the frame,\npack the frame to the canvas,\nconfigure the canvas with the scrollbar?)  \nI'm not sure if there's a function to set the current position of the scrollbar (thus xview of the window),\nbut I'd imagine there is.\nHave yet to implement this, but it looks promising.  \nThanks for the suggestions!","Q_Score":0,"Tags":"python,resize,tkinter,tk","A_Id":6954676,"CreationDate":"2011-07-29T07:51:00.000","Title":"Resize Tkinter Window FROM THE RIGHT (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse.\nPylint is being triggered OK when I edit files, and is outputting to the Eclipse console.\nBut, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors)\nNewly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module.\nI know this is possible as I've had it working previously - but how do I set this up?\nTicking or unticking \"Redirect Pylint output to console?\" doesn't seem to make any difference.","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3051,"Q_Id":6874214,"Users Score":0,"Answer":"have you tried rebuilding your project?","Q_Score":11,"Tags":"python,eclipse,pydev,pylint","A_Id":7062993,"CreationDate":"2011-07-29T13:52:00.000","Title":"How to get pylint warnings to be marked in the Pydev Eclipse editor margin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse.\nPylint is being triggered OK when I edit files, and is outputting to the Eclipse console.\nBut, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors)\nNewly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module.\nI know this is possible as I've had it working previously - but how do I set this up?\nTicking or unticking \"Redirect Pylint output to console?\" doesn't seem to make any difference.","AnswerCount":5,"Available Count":4,"Score":-0.0399786803,"is_accepted":false,"ViewCount":3051,"Q_Id":6874214,"Users Score":-1,"Answer":"Only modules reachable through PYTHONPATH are passed to pylint, so you need to set your PYTHONPATH correctly in the project options.","Q_Score":11,"Tags":"python,eclipse,pydev,pylint","A_Id":7064520,"CreationDate":"2011-07-29T13:52:00.000","Title":"How to get pylint warnings to be marked in the Pydev Eclipse editor margin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse.\nPylint is being triggered OK when I edit files, and is outputting to the Eclipse console.\nBut, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors)\nNewly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module.\nI know this is possible as I've had it working previously - but how do I set this up?\nTicking or unticking \"Redirect Pylint output to console?\" doesn't seem to make any difference.","AnswerCount":5,"Available Count":4,"Score":0.0798297691,"is_accepted":false,"ViewCount":3051,"Q_Id":6874214,"Users Score":2,"Answer":"I was having the same problem, and it turned out to be my pylint configuration file (~\/.pylintrc by default).  Be sure the output-format field is correct.  It is under the [REPORTS] section, and the line should be:\noutput-format=text\nIf you've ever used pylint with another application (I do with emacs), it might say output-format=parseable.","Q_Score":11,"Tags":"python,eclipse,pydev,pylint","A_Id":7349528,"CreationDate":"2011-07-29T13:52:00.000","Title":"How to get pylint warnings to be marked in the Pydev Eclipse editor margin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse.\nPylint is being triggered OK when I edit files, and is outputting to the Eclipse console.\nBut, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors)\nNewly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module.\nI know this is possible as I've had it working previously - but how do I set this up?\nTicking or unticking \"Redirect Pylint output to console?\" doesn't seem to make any difference.","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":3051,"Q_Id":6874214,"Users Score":3,"Answer":"I had this exact problem today, on a brand new system. I tracked down the cause, and it seems that PyDev refuses to pick up the messages from pylint 0.24.0, which was released on July 20, 2011.\nReverting to the previous version (pylint 0.23.0) seems to have solved the problem.  For me, that involved removing everything from Python's Lib\/site-packages directory that was related to pylint, and then running python setup.py install from the directory I'd extracted pylint 0.23.0 into.  (Without deleting those files in the site-packages directory first, it kept using the new version.)  But after both those steps, the messages started showing up in PyDev as expected.\nYou can check your pylint version with pylint --version from a shell prompt; if it shows 0.23.0 you're good to go.","Q_Score":11,"Tags":"python,eclipse,pydev,pylint","A_Id":7449962,"CreationDate":"2011-07-29T13:52:00.000","Title":"How to get pylint warnings to be marked in the Pydev Eclipse editor margin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to pass my database connection to the EchoHandler class, however I can't figure out how to do that or access the EchoHandler class at all.\n\n\nclass EchoHandler(SocketServer.StreamRequestHandler):\n    def handle(self):\n        print self.client_address, 'connected'\n\nif __name__ == '__main__':\n    conn = MySQLdb.connect (host = \"10.0.0.5\", user = \"user\", passwd = \"pass\", db = \"database\")\n\n    SocketServer.ForkingTCPServer.allow_reuse_address = 1\n\n    server = SocketServer.ForkingTCPServer(('10.0.0.6', 4242), EchoHandler)\n\n    print \"Server listening on localhost:4242...\"\n    try:\n        server.allow_reuse_address\n        server.serve_forever()\n    except KeyboardInterrupt:\n        print \"\\nbailing...\"","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":13253,"Q_Id":6875599,"Users Score":1,"Answer":"It seems that you can't use ForkingServer to share variables because Copy-on-Write happens when a process tries to modify a shared variable.\nChange it to ThreadingServer and you'll be able to share global variables.","Q_Score":24,"Tags":"python,python-2.7,socketserver","A_Id":68489995,"CreationDate":"2011-07-29T15:41:00.000","Title":"With python socketserver how can I pass a variable to the constructor of the handler class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to DNSSEC Sign a RRSET, however I am not able finding any references to how to do so using DNSPython. Yes it has dns.dnssec.validate_rrsig(), but I want to DNSSEC sign a rrset, how can this be done?\nI've been pooring over the RFC's however I'm obviously lacking something in order to make it work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":884,"Q_Id":6877553,"Users Score":0,"Answer":"Do you really have to do it with DNSPython? Is this a custom name server?\nThe typical way you normally do it (with bind, for example) is by pre-signing the zone file. The DNSSEC RRSIG does not have any dependency on the connection parameters so we don't really have to do on-the-fly signing. Also, things like NSEC would be easier to handle if you pre-sign.","Q_Score":3,"Tags":"python,dns,dnspython","A_Id":6890137,"CreationDate":"2011-07-29T18:40:00.000","Title":"DNSSEC Sign RRSET using DNSPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just wonder how is transaction managed in django's admin commands. Commit on save? Commit on success? I can't find related info from official documents.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1967,"Q_Id":6879815,"Users Score":-1,"Answer":"I'm not too sure, but admin forms don't reach to the commit point unless they meet clean() requirements. After that I guess everything will be committed. This behavior should be sufficient for the default forms in admin. However, for more complex forms, you can create your custom admin form and I'm pretty sure you can define whether or not you want to commit on success or on save.","Q_Score":6,"Tags":"python,django,django-admin","A_Id":6880287,"CreationDate":"2011-07-29T22:51:00.000","Title":"How is transaction managed in Django's admin commands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get a Python script which I normally run on my PC to run on my Android phone (HTC Hero). I have SL4A running on my phone and have made a few tweaks to the Python script so that this does now run. The problem that I am having is how to pass parameters to the script. I have tried creating a sh script in SL4A which called the python file with the parameters, but this didn't work. I have also tried using the app TaskBomb to call through to the python file, but again this doesn't work when parameters are supplied. When no params are supplied the file loads correctly, but when I add -h to the filename it says it can no longer find the python file I am calling.\nIs anybody able to provide assistance with how to this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2086,"Q_Id":6882218,"Users Score":1,"Answer":"I used a round about method to circumvent the problem. First the python script needs to be modified to look for a text file containing the attributes. Now whenever I need to start the script, i have to push the txt file containing the attributes and then start the script.","Q_Score":2,"Tags":"android,python,sl4a","A_Id":10452996,"CreationDate":"2011-07-30T09:17:00.000","Title":"Passing parameters to a python script using SL4A on Android","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've done a lot of development in rails, and am looking into developing projects using python & app engine.\nFrom the demo project and what I've seen so far, I've got a question\/concern about app engine projects:\nHow is data migration handled in app-engine? For example, if I change the name of an entity\/table (ex: Texts to Documents), or change a column in an existing table (ex: age to dob) - how does it handle old data when this happens?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":608,"Q_Id":6892408,"Users Score":1,"Answer":"You can't change the name of an entity. It's not permitted. \nIf you change the name of an attribute in a model (please don't call them columns), AppEngine will ignore the old data in the old field, and return None for the new field.","Q_Score":5,"Tags":"python,ruby-on-rails-3,google-app-engine,data-migration","A_Id":6892479,"CreationDate":"2011-07-31T21:22:00.000","Title":"Data Migrations and AppEngine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know similar questions to this have been asked before, but I'm looking for a more specific answer so here it goes:\nI'm a student and am looking to develop a web app. I have little experience with all mentioned and like different aspects of each. I like the Visual  Web Dev that can be used to create ASP.NET sites, a aspect that isn't there for PHP or Python..\nI'm also looking to learn and develop with the language that will be most beneficial for uni, and work in the future - the language that is used and respected most in industry. I've heard mixed views about this. Because I'd want to know the language that is most used, most in demand, and has the longest future.\nI'd also like the ability to make things fast, they all come with frameworks.. But would it be better me learning things from scratch and understanding how it works that use a framework? Which language has the most frameworks and support?\nI see that a lot of industries (the ones I've looked at) use ASP.NET. But it seems (remember no real experience) to be easier (especially as a GUI can be used) so does that make it less valuable. \nBasically - which language do you think would be best for me based on this? WHich would you recommend based on the advantages and disadvantages of each and ease of fast efficient and powerful development?\nThanks","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":3202,"Q_Id":6896942,"Users Score":1,"Answer":"python has a ui like vb, it's called pygtk (pygtk.org), i suggest you learn python, it's the easiest to learn, and you don't have to write as much as you would in .net\nphp is powerful, and you have to learn it, you just have to, but for big complicated web apps, I rather choose ruby on rails or even better django\nwhich is the best? \"the best\" is just an opinion, asp.net developers think that it's the best and i think that python is the best, it's an argument that will never end","Q_Score":2,"Tags":"php,asp.net,python,django","A_Id":6899782,"CreationDate":"2011-08-01T10:10:00.000","Title":"Python + Django vs. ASP.NET + C#\/VB vs PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I know similar questions to this have been asked before, but I'm looking for a more specific answer so here it goes:\nI'm a student and am looking to develop a web app. I have little experience with all mentioned and like different aspects of each. I like the Visual  Web Dev that can be used to create ASP.NET sites, a aspect that isn't there for PHP or Python..\nI'm also looking to learn and develop with the language that will be most beneficial for uni, and work in the future - the language that is used and respected most in industry. I've heard mixed views about this. Because I'd want to know the language that is most used, most in demand, and has the longest future.\nI'd also like the ability to make things fast, they all come with frameworks.. But would it be better me learning things from scratch and understanding how it works that use a framework? Which language has the most frameworks and support?\nI see that a lot of industries (the ones I've looked at) use ASP.NET. But it seems (remember no real experience) to be easier (especially as a GUI can be used) so does that make it less valuable. \nBasically - which language do you think would be best for me based on this? WHich would you recommend based on the advantages and disadvantages of each and ease of fast efficient and powerful development?\nThanks","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3202,"Q_Id":6896942,"Users Score":1,"Answer":"This question is really too open ended. there is no one true language, otherwise we'd all be using it. As you've seen they all have merit. You didn't mention Java which still holds a lot of clout in enterprise computing.\nThe only answer is pick one you like and get good at it. You can spends years wishing you'd picked one of the others. Also, if you get good at one & have a firm understanding of the basics, at a later date you'll find it easy (ish) to pick up another one.\nFor what it's worth. my money's on .net. But that's just me.\nSimon","Q_Score":2,"Tags":"php,asp.net,python,django","A_Id":6899152,"CreationDate":"2011-08-01T10:10:00.000","Title":"Python + Django vs. ASP.NET + C#\/VB vs PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I know similar questions to this have been asked before, but I'm looking for a more specific answer so here it goes:\nI'm a student and am looking to develop a web app. I have little experience with all mentioned and like different aspects of each. I like the Visual  Web Dev that can be used to create ASP.NET sites, a aspect that isn't there for PHP or Python..\nI'm also looking to learn and develop with the language that will be most beneficial for uni, and work in the future - the language that is used and respected most in industry. I've heard mixed views about this. Because I'd want to know the language that is most used, most in demand, and has the longest future.\nI'd also like the ability to make things fast, they all come with frameworks.. But would it be better me learning things from scratch and understanding how it works that use a framework? Which language has the most frameworks and support?\nI see that a lot of industries (the ones I've looked at) use ASP.NET. But it seems (remember no real experience) to be easier (especially as a GUI can be used) so does that make it less valuable. \nBasically - which language do you think would be best for me based on this? WHich would you recommend based on the advantages and disadvantages of each and ease of fast efficient and powerful development?\nThanks","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3202,"Q_Id":6896942,"Users Score":0,"Answer":"I would recomend looking at asp.net mvc and scaffolding. That way you can create good applications quick and effective.","Q_Score":2,"Tags":"php,asp.net,python,django","A_Id":6897150,"CreationDate":"2011-08-01T10:10:00.000","Title":"Python + Django vs. ASP.NET + C#\/VB vs PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to copy a directory to another directory recursively. I also want to ignore some files (eg. all hidden files; everything starting with \".\") and then run a function on all the other files (after copying them). This is simple to do in the shell, but I need a Python script.\nI tried using shutil.copytree, which has ignore support, but I don't know how to have it do a function on each file copied. I might also need to check some other condition when copying so I can't just run the function on all the files once they are copied over. I also tried looking at os.walk but I couldn't figure it out.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2031,"Q_Id":6904069,"Users Score":4,"Answer":"If you're on Python 2.6 or higher, you can simply use shutil.copytree and its ignore argument. Since it gets passed all the files and directories, you can call your function from there, unless you want it to be called right after the file is copied.\nIf that is the case, the easiest thing is to copy and modify the copytree code.","Q_Score":3,"Tags":"python","A_Id":6904116,"CreationDate":"2011-08-01T20:28:00.000","Title":"Copying files recursively with skipping some directories in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to insert new entities programatically as well as manually. For this I was thinking about using key_name to uniquely identify an entity.\nThe problem is that I don't know how to get the model to generate a new unique key name when I create the entity.\nOn the other hand, I cannot create the ID (which is unique across data store) manually.\nHow can I do \"create unique key name if provided value is None\"?\nThanks for your help!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":178,"Q_Id":6908827,"Users Score":1,"Answer":"I don't really understand your question. If you want an automatically-generated key name, just leave out the key when you instantiate the object - one will be automatically assigned when you call put().","Q_Score":0,"Tags":"python,google-app-engine","A_Id":6909612,"CreationDate":"2011-08-02T07:52:00.000","Title":"Fun with GAE: using key_name as PK?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For some reason i can't figure out, other than the 'stupid' errors that keep creeping up when I try to access media files (files uploaded by the user) in my Django app, why I just can't server media files!\nIn this particular case, all I want for example is to be able to serve up images to the front that have been uploaded. My up correctly serves static files via \/static\/, but when I try to serve my \/site_media\/ files hell breaks loose! What could I be doing wrong?\nSo, after realizing that Django wasn't essentially crafted to actually handle media files, I decided to resort to using Apache via the recommended mod_python option like it is recommended to do in production. But I've never done this before, and am wondering whether this is worth the trouble on the development server.\nWell, I know eventually I have to go down this path when I go production, and so will still have to learn how to do this, but what are the pros and cons for this route on the development server?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":859,"Q_Id":6909143,"Users Score":0,"Answer":"It is surely a pro since the django serves the requests faster without having to deal with the media.\nA con is that, if and when you edit the media, you need to also restart the apache, for the media to refresh.\nupdate based on your comment:\nYou can of-course easily do it. One simple way I practice this is, by using the nginx and symlinking the media folder into nginx sites-enabled and run nginx on port 80 (or any other).\nYou can set the MEDIA_URL in your settings, where you point it to the url with the appropriate port.","Q_Score":0,"Tags":"django,apache,media,mod-python","A_Id":6909236,"CreationDate":"2011-08-02T08:23:00.000","Title":"Serve Media Files Via Apache on a Django Development Server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For some reason i can't figure out, other than the 'stupid' errors that keep creeping up when I try to access media files (files uploaded by the user) in my Django app, why I just can't server media files!\nIn this particular case, all I want for example is to be able to serve up images to the front that have been uploaded. My up correctly serves static files via \/static\/, but when I try to serve my \/site_media\/ files hell breaks loose! What could I be doing wrong?\nSo, after realizing that Django wasn't essentially crafted to actually handle media files, I decided to resort to using Apache via the recommended mod_python option like it is recommended to do in production. But I've never done this before, and am wondering whether this is worth the trouble on the development server.\nWell, I know eventually I have to go down this path when I go production, and so will still have to learn how to do this, but what are the pros and cons for this route on the development server?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":859,"Q_Id":6909143,"Users Score":0,"Answer":"First, mod_python is not recommended. In fact, it's specifically recommended against. Use mod_wsgi instead.\nSecondly, we have no possible way of telling what you're doing wrong when serving static media via the dev server, because you have provided no code or details of your setup.\nFinally, there is no reason why you can't use Apache - or even better, a lightweight server such as nginx - and point it at your static directory only. Then, set STATIC_URL in your settings.py to the address served by that server. It makes no difference what port it is on while you're in development.","Q_Score":0,"Tags":"django,apache,media,mod-python","A_Id":6909511,"CreationDate":"2011-08-02T08:23:00.000","Title":"Serve Media Files Via Apache on a Django Development Server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a Hex file using python and at the end I need to add a checksum that consists of sum of all hex values so that checksum = Byte 0x000000 + Byte 0x000001 +\u2026+ Byte 0x27DAFF (not including this 4 bytes). This checksum shall then be written to buffer at position 0x27DB00-0x27DB03 as unsigned long.\nAny good ideas for how to get this done fast, I am running python2.7.\nAs info of what I am up to I start with creating a buffer using ctypes, then write lots and lots of hex stuff to buffer, then create a cStringIO from buffer and write this string object to a file_obj which happen to be a django http response (i.e. returns the hex file as downloadable file) so any smart things involving the buffer would be appreciated !!! :-)\n\/ Jens","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":7142,"Q_Id":6917330,"Users Score":4,"Answer":"Thanks !!!\nthe following two solutions worked;\nchecksum = sum(map(ord, b))\nor \nchecksum = sum(bytearray(b))\n\/ J","Q_Score":0,"Tags":"python,byte,hex,checksum,crc","A_Id":6922436,"CreationDate":"2011-08-02T19:16:00.000","Title":"How to generate checksum from hex byte using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that setup.py uses the same CFLAGS that were used to build Python. I have a single C extension of ours that is segfaulting. I need to build it without -O2 because -O2 is optimizing out some values and code so that the core files are not sufficient to pin down the problem.\nI just need to modify setup.py so that -O2 is not used.\nI've read distutils documentation, in particular distutils.ccompiler and distutils.unixccompiler and see how to add flags and libs and includes, but not how to modify the default GCC flags.\nSpecifically, this is for a legacy product on Python 2.5.1 with a bunch of backports (Fedora 8, yes, I know...). No, I cannot change the OS or Python version and I cannot, without great problems, recompile Python. I just need to build a one off of the C extension for one customer whose environment is the only one segfaulting.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":35921,"Q_Id":6928110,"Users Score":4,"Answer":"I ran into this problem when I needed to fully remove a flag (-pipe) so I could compile SciPy on a low-memory system. I found that, as a hack, I could remove unwanted flags by editing \/usr\/lib\/pythonN.N\/_sysconfigdata.py to remove every instance of that flag, where N.N is your Python version. There are a lot of duplicates, and I'm not sure which are actually used by setup.py.","Q_Score":67,"Tags":"python,gcc,setuptools,setup.py,distutils","A_Id":60766834,"CreationDate":"2011-08-03T14:28:00.000","Title":"How may I override the compiler (GCC) flags that setup.py uses by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want get the mount node of an usb mass-storage device, like \/media\/its-uuid\nin pyudev, class Device has some general attributes, but not uuid or mount node.\nhow to do it\nthanks help","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2348,"Q_Id":6928566,"Users Score":3,"Answer":"With pyudev, each device object provides a dictionary-like interface for its attributes. You can list them all with device.keys(), e.g. UUID is for block devices is dev['ID_FS_UUID'].","Q_Score":0,"Tags":"python,udev","A_Id":6930448,"CreationDate":"2011-08-03T14:59:00.000","Title":"how to get uuid of a device using udev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple mail sending application which runs in python using Django. After sending an email is there a way to see if the recipient has opened it or is it still un-opened?\nif so how can i do it?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2684,"Q_Id":6936252,"Users Score":1,"Answer":"You have no other way than generate confirm url in your message like most sites registrations do. If person would be glad to register on your website, he will certainly click confirm at his email client of any sort. Otherwise it's a spam\/scam email.\nThere is no way you can do it and know it's a live e-mail for sure...\nBesides there are 2 other ways mentioned by my colleagues... But they are based on \"unsecure\" settings in old email clients rather than sure way... IMHO.","Q_Score":1,"Tags":"python,django,email","A_Id":6937662,"CreationDate":"2011-08-04T04:37:00.000","Title":"Checking the status of a sent email in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple mail sending application which runs in python using Django. After sending an email is there a way to see if the recipient has opened it or is it still un-opened?\nif so how can i do it?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2684,"Q_Id":6936252,"Users Score":3,"Answer":"You can try setting require return receipt flag on the email you are sending. But, a lot of people (I know I do) ignore that return receipt so you will never find out in those cases.\nIf you are asking for a 100% certain method of finding out if the recipient read his\/her email, then the straight answer is: NO, you can't do that.","Q_Score":1,"Tags":"python,django,email","A_Id":6936289,"CreationDate":"2011-08-04T04:37:00.000","Title":"Checking the status of a sent email in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have one pdf file. I want to split that file into multiple pdf files\n  by some specific word from that file. how can i do that in python ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":457,"Q_Id":6941231,"Users Score":1,"Answer":"Have a look at pdftk. It is a toolbox for working with pdf files. You can integrate it into python with the subprocess module.","Q_Score":2,"Tags":"python,pdf,pypdf","A_Id":6941309,"CreationDate":"2011-08-04T12:15:00.000","Title":"how to split pdf file into multiple pdf files by specific word?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When trying to access __variables from a class, the parser assumes the 2 underscores are private relative to the current class. Notice how an unrelated function gets a \"private\" variable.\nIs this a bug?\n\n>>> def f(): pass\n...\n>>> class A:\n...     def g(self):\n...             f.__x = 1\n...             def h():\n...                     pass\n...             h.__y = 2\n...             return h\n...\n>>> z = A().g()\n>>> dir(z)\n['_A__y', '__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get_\n_', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new\n__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'func_\nclosure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals',\n 'func_name']\n>>> dir(f)\n['_A__x', '__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get_\n_', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new\n__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'func_\nclosure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals',\n 'func_name']\n\nTested on python 2.5 and 3.2","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":514,"Q_Id":6967076,"Users Score":0,"Answer":"Here\u2019s a way to declare private variables: overload the __setattr__ (and other many methods about attributes) method, in the method, you can check current executing method is in the own class. If it is true, let it pass. Otherwise, you can raise an exception, or you can use your own customize error handle logic. (Tips: use inspect.stack function)","Q_Score":1,"Tags":"python,class,private","A_Id":68909648,"CreationDate":"2011-08-06T13:22:00.000","Title":"Python private class variables that aren't class variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to access the screen of a stock version of a headless VirtualBox 4.x remotely using RDP with Python or access it using the VNC protocol?\nI want to be able to access the boot screen (F12), too, so I cannot boot a VNC server in the Guest as the Guest is not yet booted.\nNote that I already have an RFB version in pure Python, however stock VirtualBox seems not to support VNC style remote connections, OTOH I somehow was unable to find a Python RDP library, sadly.\nWhat I found so far but I do not want to use:\n\nA Java RDP client, however I do not want to switch horses, so I want to keep it Python\nVirtualBox API seems to provide Python with access to the framebuffer, but I am not completely sure.  However this then is bound to VirtualBox only, an RDP library (or letting VB talk RFB) would be more generic.\n\nNotes:\n\nSo what I need either is a way to add VNC\/RFB support to an original VirtualBox (.vbox-extpack?)\nor find some RDP library written in pure Python.\nIt must be available on at least all platforms for which VirtualBox is available.\n\nIf neither is possible, I think I will try the VirtualBox API in Python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1273,"Q_Id":6975995,"Users Score":0,"Answer":"Have you considered Jython, which ought to be able to integrate  natively with the Java library you already have?","Q_Score":2,"Tags":"python,virtualbox,rdp","A_Id":7852841,"CreationDate":"2011-08-07T21:46:00.000","Title":"How to connect Python to VirtualBox using RDP or RFB?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to disable the option to move FeinCMS contenttypes whithin a region.\nDoes anyone have any suggestions how to accomplish this?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":108,"Q_Id":6979529,"Users Score":2,"Answer":"No, that's not possible currently. \nWhat's the reasoning behind this feature request?","Q_Score":2,"Tags":"python,django,content-management-system,contenttype,feincms","A_Id":6979669,"CreationDate":"2011-08-08T08:38:00.000","Title":"Disable option to move FeinCMS contenttypes within a region","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a mostly entirely plain django project, with no adding of my own media or customization of the admin interface in any way. Running the server with python manage.py runserver results in a nicely-formatted admin interface. Running the server with gunicorn_django does not. Why is this the case, and how can I fix it? \nIt's definitely an issue of not finding the css files, but where are they stored? I never configured this, and the MEDIA_ROOT setting is ''.\nEDIT: I just want to know how django-admin serves the non-existent admin files... and how can I get gunicorn_django to do the same?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":2860,"Q_Id":6984672,"Users Score":1,"Answer":"If you use contrib.static, you have to execute a collectstatic command to get all the app-specific static files (including admin's own) into the public directory that is served by gunicorn.","Q_Score":3,"Tags":"python,django,django-admin,gunicorn","A_Id":6984814,"CreationDate":"2011-08-08T15:38:00.000","Title":"django: admin site not formatted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I managed to plot my data and would like to add a background image (map) to it.\nData is plotted by the long\/lat values and I have the long\/lat values for the image's three corners (top left, top right and bottom left) too.\nI am trying to figure out how to use 'extent' option with imshow. However, the examples I found don't explain how to assign x and y for each corner ( in my case I have the information for three corners).\nHow can I assign the location of three corners for the image when adding it to the plot?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80144,"Q_Id":6999621,"Users Score":51,"Answer":"Specify, in the coordinates of your current axis, the corners of the rectangle that you want the image to be pasted over\nExtent defines the left and right limits, and the bottom and top limits. It takes four values like so: extent=[horizontal_min,horizontal_max,vertical_min,vertical_max]. \nAssuming you have longitude along the horizontal axis, then use extent=[longitude_top_left,longitude_top_right,latitude_bottom_left,latitude_top_left]. longitude_top_left and longitude_bottom_left should be the same, latitude_top_left and latitude_top_right should be the same, and the values within these pairs are interchangeable. \nIf your first element of your image should be plotted in the lower left, then use the origin='lower' imshow option as well, otherwise the 'upper' default is what you want.","Q_Score":37,"Tags":"python,plot,matplotlib","A_Id":7000381,"CreationDate":"2011-08-09T16:34:00.000","Title":"how to use 'extent' in matplotlib.pyplot.imshow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am implementing payment plans on an multilingual eshop based on django-cms. I need internationalized support for payment plans.\n\nUser can enter abritrary number of payment plans (implies standard django models)\nEvery payment plan must have a description in every language site supports (3 at the moment). Implies basic django-cms post or plugin.\n\nPossible solutions I thought of, but did not fit..\n\nIf I go with django models, how do I handle i18n?\nIf I go with cms plugin, how would I link those descriptions to same django models in every language?\nIf I go with cms page, how do I create separate entities?\n\nWhat is the most elegant solution?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":240,"Q_Id":7017059,"Users Score":0,"Answer":"Found the solution. Django-nani.","Q_Score":1,"Tags":"python,django,internationalization,django-cms","A_Id":7448955,"CreationDate":"2011-08-10T20:06:00.000","Title":"Django-cms translatable objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm totally confused and have no idea how to do this, so please forgive me if my description\/information is bad.\nSo I want say to do a notification via django-notification or simply send an e-mail to one of my user when a post of his had ended like on ebay.  In my database I have a model which stores the datetime of when the post is going to end, but I'm not sure how to effectively check or store a signal or something which would alert the system to alert the user when the current time is > than the end datetime.\nthanks!\nSince I want to send an email\/notification the second a post ends, I don't think I can use a scheduler to check if any post had ended, I believe this would be too inefficient, because I would have to check like every second, but like I said above, I'm not sure about anything...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":7020108,"Users Score":0,"Answer":"As other have said, the best solution is django-celery (https:\/\/github.com\/ask\/django-celery) but it's a little heavyweight if you are low on resources.\nIn a similar need, I have a middleware that checks the conditions and executes the needed operations (which, in my case, are just changing a boolean in some records of the database). This works for me because until someone actually access the data there is no need to change it, and because the \"task\" is just one UPDATE query, so it's not an unbearable load.\nOtherwise you can set up a cron job every short time (1 minute? 5 minutes?) and check conditions and do consequences.","Q_Score":2,"Tags":"python,sql,django,django-models,django-signals","A_Id":7021874,"CreationDate":"2011-08-11T02:15:00.000","Title":"Django 1.3, how to signal when a post has ended like on ebay?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What do you suggest to get rid of pdb calls on production software?\nIn my case, I'm developing a django website. \nI don't know if I should:\n\nMonkey patch pdb from settings.py (dependding on DEBUG boolean). \nMake a pdb wrapper for our project which expose set_trace or print basic log if DEBUG = True\nDissalow comitting brakpoints on git hooks... (if you think it's the best idea how would you do that?).","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":133,"Q_Id":7027803,"Users Score":1,"Answer":"The best option would be to have an extensive test suite, and to run the tests before pushing to production.  Extraneous pdb breakpoints will prevent the tests from passing.\nIf you can't do that, then option 2 is the best: write a utility to break into the debugger, and make it sensitive to the state of the settings.  You still have to solve the problem of how to be sure people use the wrapper rather than a raw pdb call though.","Q_Score":3,"Tags":"python,django,git,pdb","A_Id":7027964,"CreationDate":"2011-08-11T14:37:00.000","Title":"How to ensure there are no pdb calls out of debugging configuration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What do you suggest to get rid of pdb calls on production software?\nIn my case, I'm developing a django website. \nI don't know if I should:\n\nMonkey patch pdb from settings.py (dependding on DEBUG boolean). \nMake a pdb wrapper for our project which expose set_trace or print basic log if DEBUG = True\nDissalow comitting brakpoints on git hooks... (if you think it's the best idea how would you do that?).","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":7027803,"Users Score":2,"Answer":"The third one. You have to enforce some commit rules. For example, run a serie of tests before a commit, etc. This way, developpers have a simple way to check if a pdb break remain. If someone commit a set_trace, he has to bake a cake for the rest of the team.\nThis works fine in my company :-)\nedit: you may present this method to your boss as CDD (Cake Driven Developpement)","Q_Score":3,"Tags":"python,django,git,pdb","A_Id":7028046,"CreationDate":"2011-08-11T14:37:00.000","Title":"How to ensure there are no pdb calls out of debugging configuration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do i generate random numbers but have the numbers avoid numbers already used.\nI have a TXT file with thousands of sets of numbers and i need to generate a series of random numbers while avoiding these.\nIE,  TXT - 0102030405\nmy random number needs to avoid this number.\non a side note,   how can i split up the TXT 10 digit number into 5, two digit numbers?\nthen how can i generate random numbers based off of that.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":613,"Q_Id":7033542,"Users Score":1,"Answer":"If you need to maintain the file (which I think you do, in order to add new numbers), I would suggest you to \"forget\" using a plain text file and use SQLite or any other embedded DB that is backed up in a file, as you probably don't want to load all the numbers in memory.\nThe \"feature\" (or better said, data structure) you want from SQLite is a B-Tree, so you can retrieve the numbers fast. I'm saying this, because you could also try to find a library that implements B-Trees, and then you wouldn't need SQLite.","Q_Score":1,"Tags":"python,random,numbers,generator","A_Id":7033665,"CreationDate":"2011-08-11T22:11:00.000","Title":"How do generate random numbers, while avoiding numbers already used","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm implementing a profiler in an application and I'm a little flummoxed about how to implement Python profiling such that the results can be displayed in my existing tool. The application allows for Python scripting via communication with the python interpreter.\nI was wondering if anyone has ideas on how to profile Python functions from C++\nThank you for your suggestions :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":447,"Q_Id":7033612,"Users Score":0,"Answer":"The usual technique for profiling already-existing functions that we use in Lua a lot is to overwrite the function with your own version that will start timing, call the original function, and stop timing, returning the value that the original function returned.","Q_Score":2,"Tags":"c++,python,profiling","A_Id":7033696,"CreationDate":"2011-08-11T22:19:00.000","Title":"How can I \"hook into\" Python from C++ when it executes a function? My goal is to profile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have updated my model in Datastore so now it has an additional field. Now I have entities with and without that field but I need to add this field to all entities that don't yet have it. Idea is to get entities in a function without that field and add it. So, I wonder how I can filter such entities in Datastore requests?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":7037269,"Users Score":1,"Answer":"You cannot filter for property non-existence. Every query must be satisfied by an index, and there's no \"negative index\" of entities that lack a given property.\nGenerally, you'll need to iterate over all entities, and just ignore the ones that already have the property.","Q_Score":1,"Tags":"python,google-app-engine,datastore","A_Id":7041161,"CreationDate":"2011-08-12T08:10:00.000","Title":"Check if a field is present in an entity","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I read in wikipedia that python logging module was inspired by log4j .In log4j ,there is an HTMLLayout with which one can create the log file as html.Is there any such facility in python logging? Or do anyone know how I can format the log output into an html file ?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":7716,"Q_Id":7039343,"Users Score":3,"Answer":"I would not recommend storing logs as HTML, having logs easily onward processable is a very important and useful feature, and HTML is hard to parse, and it is also verbose - and logs get large fast :-)\nHowever if you really want to you can write your own formatter that will output to HTML - I am not aware of one already in existence - I suspect for the reasons above.","Q_Score":6,"Tags":"python,html,logging,format","A_Id":7039432,"CreationDate":"2011-08-12T11:20:00.000","Title":"python logging how to create logfile as html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"OK to be short =)\nI'm noob yes. -.- but I'm convinced i don't need to learn everything.. and that a specific field of knowledge suited to my project may save me time..?\nI'm going to build a game that i have designed but not begun constructing.\nI'm going to learn everything i need to to get my project finished.\nhowever to save time...\nI'm using python\nthe game needs only to reference locations on a grid with values:\nso a green 'pine tree' square = *information *values = tree type \/ tree's hardness \/ tree's life ect... \nI am perhaps wrong in the assumption there are no objects needed? should i focus all my time on learning how to use the dictionary's function..\nwhat is the most efficient coding for a grid based tile game that simulates change per turn.\nSo that; a blue square spreads according to sets of rules and according to the adjacent tiles at the end of a turn. And these tiles have values attached...? even just the name of the best feasible technique... i can learn how to do it once i know what i need to learn...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":627,"Q_Id":7049637,"Users Score":9,"Answer":"Any Python project of any size will become unmanageable without objects.\nIs it possible to use modules as your objects instead of classes? Yes, if you really want to. (In Python, a module is what you call a single file.)\nHowever, even if you aren't creating user-defined classes, you still need to learn how to use objects.\nWhy? Because everything is an object in Python. You need to at least know how to use objects to understand how to use the built in types and functions in Python.\nIn Python, dictionaries are very important to how things are implemented internally, so your intuition that dictionaries would be an alternative is good.\nBut dictionaries are objects too, so you'd still have to learn to use objects, without getting the benefit of their ease of use for many things vs. a plain dictionary.\nMy advice? Do a Python tutorial (or three). The whole thing. Even the parts on networking, or whatever else you don't think you'll be using. You'll learn things about the language that you'll end up using later in ways you'd never anticipate.\nDo you need to learn about metaclasses? No. Multiprocessing? No. But you need to learn all of the core language features, and classes and object oriented programming are the core language feature. It's so central to nearly all modern languages that people don't even mention it any more.","Q_Score":0,"Tags":"python,oop","A_Id":7049703,"CreationDate":"2011-08-13T09:33:00.000","Title":"Do I need to learn about objects, or can I save time and just learn dictionaries?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to be able to identify an audio sample (that is provided by the user) in a audio file I've got (mp3).\nThe mp3 file is a radio stream that I've kept for testing purposes, and I have the Pre-roll of the show. I want to identify it in the file and get the timestamp where it's playing in the file.\nNote: The solution can be in any of the following programming languages: Java, Python or C++. I don't know how to analyze the video file and any reference about this subject will help.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":573,"Q_Id":7052169,"Users Score":2,"Answer":"I'd start by computing the FFT spectrogram of both the haystack and needle files (so to speak). Then you could try and (fuzzily) match the spectrograms - if you format them as images, you could even use off-the-shelf algorithms for that.\nNot sure if that's the canonical or optimal way, but I feel like it should work.","Q_Score":2,"Tags":"java,c++,python,audio,signal-processing","A_Id":7052252,"CreationDate":"2011-08-13T17:37:00.000","Title":"Identify audio sample in a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am very new to programming, and have had no formal training in it before so please bear with me if this is a vague question.\nI was just curious: how do different programs on the same computer communicate with each other? From my programming experience I believe it can be achieved by socket programming? \nThanks","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":650,"Q_Id":7053905,"Users Score":1,"Answer":"Sockets, shared memory, events \/ signals, pipes, semaphores, message queues, mailslots. Just search the Internet for either.","Q_Score":6,"Tags":"java,c++,python,communication","A_Id":7053927,"CreationDate":"2011-08-13T23:19:00.000","Title":"Communicating between applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In django, the documentation asks to use the absolute paths and not the relative paths.\nThen, how do they manage portability ?\nIf I have my template in the project folder then, even a rename of the folder will cause breakage.. !\nThen what is the reason behind this practice ?\nPlease explain ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":612,"Q_Id":7064564,"Users Score":1,"Answer":"Could you post a link to that piece of documentation, please?\nIn Django you configure, in settings.py, the search path for templates (through TEMPLATE_DIRS variable). Then, inside a view, you render a template naming its file relative to one of the path included in TEMPLATE_DIRS. That way, whenever you move you template dir you just need to modify your settings.py\nAs for static files, like CSS docs, Django does not need to know anything about them (unless you are serving static files through django itself, which is discouraged by django's documentation): you only need to tell your web server where to find them.","Q_Score":0,"Tags":"python,django","A_Id":7064785,"CreationDate":"2011-08-15T11:51:00.000","Title":"Why absolute paths to templates and css in django ? (Isn't that a bad practice ?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been working with Django for some time now and have written several apps on a setup that uses Apache 2 mod_wsgi and a PostgreSQL database on ubuntu.\nI have aa app that uses xsendfile to serve files from Apache via a Django view, and also allow users to upload files via a form as well.  All this working great, but I now want to ramp up the features (and the complexity I am sure) by allowing users to chat and to see when new files have been uploaded without refreshing their browser.\nAs I want this to be scale-able, I don't want to poll continually with AJAX as this is going to get very heavy with large numbers of users.\nI have read more posts, sites and blogs then I can count on integrating comet functionality into a Django app but there are so many different opinions out there on how to do this that I am now completely confused.\nShould I be using orbited, gevent, iosocket?\nWhere does Tornado fit into this debate?\nI want the messages also be stored on the database, so do I need any special configuration \nto prevent my application blocking when writing to the database?\nWill running a chat server with Django have any impact on my ability to serve files from Apache?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1434,"Q_Id":7065283,"Users Score":1,"Answer":"Instead of Apache + X-Sendfile you could use Nginx + X-Accel-Redirect. That way you can run a gevent\/wsgi\/django server behind Nginx with views that provide long-polling. No need for a separate websockets server.\nI've used both Apache + X-Sendfile and Nginx + X-Accel-Redirect to serve (access-protected) content on Webfaction without any problems.","Q_Score":5,"Tags":"python,django,postgresql,comet,gevent","A_Id":11276439,"CreationDate":"2011-08-15T13:08:00.000","Title":"Should I use orbited or gevent for integrating comet functionality into a django app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently attempted to upgrade our Python install on a CentOS server from 2.4.3 to 2.7, however it lists 2.4.3 as the newest stable release.  This is a problem because I have a Python program that requires at least 2.7 to run properly.  After contacting support they installed Python 2.7 in a separate directory, however I'm not sure how to access this version.  Anytime I try to run the python program it uses the 2.4.3 version.  I have looked into changing the PythonHome variable, but can't get it to work correctly.  Is there anything I can do via the command line or inside the program itself to specify which Python version I want to use?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":608,"Q_Id":7066395,"Users Score":1,"Answer":"Try specifying the full path to the python executable (i.e. \/opt\/python27\/python) rather than using a bare python command. Alternatively, place \/opt\/python27\/ on your PATH earlier than \/usr\/local\/bin (where the python command is presumably already present, you can check with which python).","Q_Score":2,"Tags":"python,centos","A_Id":7066558,"CreationDate":"2011-08-15T14:50:00.000","Title":"Using Non-Standard Python Install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently attempted to upgrade our Python install on a CentOS server from 2.4.3 to 2.7, however it lists 2.4.3 as the newest stable release.  This is a problem because I have a Python program that requires at least 2.7 to run properly.  After contacting support they installed Python 2.7 in a separate directory, however I'm not sure how to access this version.  Anytime I try to run the python program it uses the 2.4.3 version.  I have looked into changing the PythonHome variable, but can't get it to work correctly.  Is there anything I can do via the command line or inside the program itself to specify which Python version I want to use?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":608,"Q_Id":7066395,"Users Score":2,"Answer":"I'd suggest you ask your support team to build a separate RPM for Python2.7 and have it installed in a separate location and not conflicting with the OS version. I've done this before it was great to have a consistent Python released across my RHEL3, 4, and 5 systems.\nNext, I'd suggest you use the following for your sh-bang (first line) \"#!\/bin\/env python2.7\" and then ensure your PATH includes the supplemental Python install path. This way, your script stays the same as you run it on your workstation, with it's own unique path to python2.7, and the production environment as well.","Q_Score":2,"Tags":"python,centos","A_Id":7066607,"CreationDate":"2011-08-15T14:50:00.000","Title":"Using Non-Standard Python Install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"there are huge number of data, there are various groups. i want to check whether the new data fits in any group and if it does i want to put that data into that group. If datum doesn't fit to any of the group, i want to create new group. So, i want to use linked list for the purpose or is there any other way to doing so??\nP.S. i have way to check the similarity between data and group representative(lets not go that in deatil for now) but i dont know how to add the data to group (each group may be list) or create new one if required. i guess what i needis linked list implementation in python, isn't it?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":468,"Q_Id":7067726,"Users Score":7,"Answer":"This sounds like a perfect use for a dictionary.","Q_Score":0,"Tags":"python,linked-list","A_Id":7067801,"CreationDate":"2011-08-15T16:30:00.000","Title":"linked list in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to write a python program with wxPython GUI. Program must to collect some information in background (infinite loop), but GUI should be active at this time. Like, if I click on the some button, some variable or another information must change, and at the new cycle this variable should be used instead of the old.\nBut I don't know, how to make it. I think that I must use threading, but I don't understand how to use it.\nAnyone can suggest how to solve this problem?\nThanks in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4727,"Q_Id":7082529,"Users Score":0,"Answer":"Have you considered having wxPython invoke an event handler of yours periodically, and perform the background processing in this? This depends on you being able to divide your work into discrete pieces, of course. Be aware that your background processing would have to be non-blocking so control would return to wxPython in a timely manner, to allow responsive GUI processing. Not sure what's the idiomatic way to implement such background processing in wxPython, but if I recall correctly the technique in (Py)Qt was to use a timer.","Q_Score":3,"Tags":"python,loops,wxpython,infinite","A_Id":7083015,"CreationDate":"2011-08-16T17:42:00.000","Title":"Python: Infinite loop and GUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to generate a random string using this command: \nstrings \/dev\/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\\n';\nWorks fine, but when I try to do subprocess.call(cmd,shell=True) it just gets stuck on the strings \/dev\/urandom command and spams my screen with grep: writing output: Broken pipe\nWhat's causing this and how do I fix it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":250,"Q_Id":7088175,"Users Score":0,"Answer":"First of all, for what you're doing, it should be better to generate the string using python directly.\nAnyway, when using subprocess, the correct way to pipe data from a process to another is by redirecting stdout and\/or stderr to a subprocess.PIPE, and feed the new process' stdin with the previous process' stdout.","Q_Score":4,"Tags":"python,linux,pipe","A_Id":7088283,"CreationDate":"2011-08-17T05:01:00.000","Title":"Getting output of system commands that use pipes (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use VTK together with Python on a Windows system.\nIt seems that I cannot use the windows installer but \"have to compile VTK from source code using CMake and a native build system\". So far I have installed CMake.\nBut now I wonder how to proceed? It seems that I need MS Visual Studio to create the project files?!\nBut I don't have Visual Studio. So what can I do?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1416,"Q_Id":7089620,"Users Score":1,"Answer":"You can use VTK with python just installing pythonxy framework, it is just a python with many many libraries included VTK, ITK, Qt and many other, also it is very well documented, and also have many examples, all in python. I recommend it to you, I have worked a lot with it, and is very amazing.\nJust make a try. All you have to do is in the installer wizard select among the tools, VTK, and it will be installed with vtk.","Q_Score":6,"Tags":"python,compilation,cmake,vtk","A_Id":28362827,"CreationDate":"2011-08-17T08:09:00.000","Title":"VTK \/ Python \/ compile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to set PIL and by extension Imagedraw to allow float values for such commands as Arc and Ellipse? I am running into major problems and cannot do what I need to do because of the seeming requirement that angles and bounding box position specifiers must be integers, and I cannot use a different package, nor is approximating everything with short straight lines a viable alternative either.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":197,"Q_Id":7114946,"Users Score":0,"Answer":"If you want sub-pixel positioning, one possible-if-inefficient solution would be to scale everything up by a factor of, say, 10, rounding (original_floating_point_coordinates * 10) to integers, then resize the whole image back down at the end. Doesn't help with angles, I suppose.","Q_Score":1,"Tags":"python,image,generator,python-imaging-library","A_Id":7115394,"CreationDate":"2011-08-18T22:32:00.000","Title":"Using Float values in Imagedraw","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in the process of writing an application with an Urwid front-end and a MongoDB back-end in python. The ultimate goal is to be able to be able to serve the application over SSH. The application has its own authentication\/identity system. I'm not concerned about the overhead of launching a new process for each user, the expected number of concurrent users is low. Since the client does not recall any state information and instead it is all stored in the DB I'm not concerned about sessions as such except for authentication purposes.\nI was wondering if there are any methods to serving the application as is without having to roll my own socket-server code or re-code the app using Twisted. I honestly don't know how Urwid and Twisted play together. I see that Urwid has a TwistedEventLoop method which purports to use the twisted reactor but I cannot find any example code running an Urwid application over a twisted connection. Examples would be appreciated, even simple ones. I've also looked at ZeroMQ but that seems even more inscrutable than Twisted. In short I explored a number of different libraries which purport to serve applications over tcp, most of them by telnet. And nearly all of them focusing on http.\nWorst case scenario I expect that I may create an extremely locked down user as a global login and use chrooted SSH sessions. that way each user gets their own chroot\/process\/client. Yes, I know that's probably a \"Very Bad Idea(tm)\". But I had to throw it out there as a possibility.\nI appreciate any constructive feedback. Insults, chides, and arrogance will be scowled at, printed out and spat upon.\n-CH","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":643,"Q_Id":7116553,"Users Score":0,"Answer":"A cheap and posibly very dangerous hack is to put your app as the default shell for a particular user. you need to be very careful though (suggestion chroot it to hell and back) as it might be possible to break out of the app and into the server.","Q_Score":5,"Tags":"python,ssh,twisted","A_Id":8927201,"CreationDate":"2011-08-19T03:12:00.000","Title":"Howto Serve Python CLI Application Over SSH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In python, given a directory or file path like \/usr\/local, I need to get the file system where its available.  In some systems it could be \/ (root) itself and in some others it could be \/usr.\nI tried os.statvfs it doesnt help.  Do I have to run the df command with the path name and extract the file system from the output?  Is there a better solution?\nIts for linux\/unix platforms only.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":5990,"Q_Id":7119630,"Users Score":2,"Answer":"As df itself opens and parses \/etc\/mtab, you could either go this way and parse this file as well (an alternative would be \/proc\/mounts), or you indeed parse the df output.","Q_Score":3,"Tags":"python,filesystems,filepath","A_Id":7119780,"CreationDate":"2011-08-19T09:31:00.000","Title":"In Python, how can I get the file system of a given file path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In python, given a directory or file path like \/usr\/local, I need to get the file system where its available.  In some systems it could be \/ (root) itself and in some others it could be \/usr.\nI tried os.statvfs it doesnt help.  Do I have to run the df command with the path name and extract the file system from the output?  Is there a better solution?\nIts for linux\/unix platforms only.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":5990,"Q_Id":7119630,"Users Score":4,"Answer":"Use os.stat to obtain device number of the file\/directory in question (st_dev field), and then iterate through system mounts (\/etc\/mtab or \/proc\/mounts), comparing st_dev of each mount point with this number.","Q_Score":3,"Tags":"python,filesystems,filepath","A_Id":7119758,"CreationDate":"2011-08-19T09:31:00.000","Title":"In Python, how can I get the file system of a given file path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to save a file (.pdf) but I'm unsure how to do it. I need to save .pdfs and store them in such a way that they are organized in a directories much like they are stored on the site I'm scraping them off. \nFrom what I can gather I need to make a pipeline, but from what I understand pipelines save \"Items\" and \"items\" are just basic data like strings\/numbers. Is saving files a proper use of pipelines, or should I save file in spider instead?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":16042,"Q_Id":7123387,"Users Score":4,"Answer":"It's a perfect tool for the job. The way Scrapy works is that you have spiders that transform web pages into structured data(items). Pipelines are postprocessors, but they use same asynchronous infrastructure as spiders so it's perfect for fetching media files.\nIn your case, you'd first extract location of PDFs in spider, fetch them in pipeline and have another pipeline to save items.","Q_Score":17,"Tags":"python,scrapy,web-crawler,pipeline","A_Id":7135102,"CreationDate":"2011-08-19T14:51:00.000","Title":"Should I create pipeline to save files with scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the simple basic explanation of what the return statement is, how to use it in Python?\nAnd what is the difference between it and the print statement?","AnswerCount":13,"Available Count":1,"Score":0.0767717131,"is_accepted":false,"ViewCount":683021,"Q_Id":7129285,"Users Score":5,"Answer":"I think a really simple answer might be useful here:  \nreturn makes the value (a variable, often) available for use by the caller (for example, to be stored by a function that the function using return is within). Without return, your value or variable wouldn't be available for the caller to store\/re-use. \nprint prints to the screen, but does not make the value or variable available for use by the caller. \n(Fully admitting that the more thorough answers are more accurate.)","Q_Score":94,"Tags":"python,return,output","A_Id":58644500,"CreationDate":"2011-08-20T02:44:00.000","Title":"What is the purpose of the return statement? How is it different from printing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know if Google App Engine support using google.appengine.api.quota package to get bandwidth usage, not cpu usage?\nIf so, how to get with Python or Java and print in webpage?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":475,"Q_Id":7131834,"Users Score":1,"Answer":"No, but you can get a very close estimate of this by adding up the length of the request headers and body for incoming requests, and the response body and headers for responses.","Q_Score":0,"Tags":"java,python,api,google-app-engine","A_Id":7142758,"CreationDate":"2011-08-20T12:48:00.000","Title":"How to get bandwidth quota usage with Google app engine api?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get started with Google App Engine. I have python 2.6 installed in my virtual environment which I wanted to use. But Google App Engine supports python2.5. So I want to set up another python virtual environment with python 2.5.\nCan you help me how to do exactly that?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2418,"Q_Id":7138229,"Users Score":4,"Answer":"Virtualenv lets you specify a python binary to use instead of the default. On your machine, python probably maps to \/usr\/bin\/python, which will be a symlink to \/usr\/bin\/python2.6. If you've got Python 2.5 installed, it will be \/usr\/bin\/python2.5\nYou can create a virtualenv called envname with virtualenv -p \/usr\/bin\/python2.5 envname","Q_Score":2,"Tags":"python,virtualenv","A_Id":9660148,"CreationDate":"2011-08-21T12:23:00.000","Title":"Set up a python virtualenv with a specific version of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i'm trying to build a web server using apache as the http server, mod_wsgi + python as the logic handler, the server was supposed to handler long request without returning, meaning i want to keep writing stuff into this request.\nthe problem is, when the link is broken, the socket is in a CLOSE_WAIT status, apache will NOT notify my python program, which means, i have to write something to get an exception, says the link is broken, but those messages were lost and can't be restored.\ni tried to get the socket status before writing through \/proc\/net\/tcp, but it could not prevent a quick connect\/break connection.\nanybody has any ideas, please help, very much thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":393,"Q_Id":7144011,"Users Score":1,"Answer":"You cant. It is a limitation of the API defined by the WSGI specification. So, nothing to do with Apache or mod_wsgi really as you will have the same issue with any WSGI server if you follow the WSGI specification.\nIf you search through the mod_wsgi mailing list on Google Groups you will find a number of discussions about this sort of problem in the past.","Q_Score":0,"Tags":"python,apache,webserver,mod-wsgi","A_Id":7145199,"CreationDate":"2011-08-22T06:52:00.000","Title":"apache server with mod_wsgi + python as backend, how can i be able to notified my connection status?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"My question might be quite vague. I am looking for some reasonable approach to perform my task.\nI have developed a webpage where the user uploads a file used as an input file for my code developed in python.\nWhen the input  file is submitted through the webpage, it is saved in a temporary folder from where the daemon copies it to another location. What I want is to  looks for the files in the folder regularly (can write a daemon) If it finds more than one file it runs the code as separate jobs with the input files found in the directory limiting to a max of 5 processes running at the same time and when one process finishes it starts the next if there are files in the folder (in a chronological order).\nI am aware of multiprocessing in python but don't know how to implement to achieve what I want or should I go for something like XGrid to mange my jobs. The code usually takes few hours to few day to finish one job. But the jobs are independent of each other.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1157,"Q_Id":7149287,"Users Score":0,"Answer":"I use a SQL table to perform such a thing, because my users may launch dozens of tasks alltogether if I do not limit them. \nWhen a new file shows up, a daemon writes its name in the table (with allsort of other information such as size, date, time, user, ...)\nAnother daemon is then reading the table, getting the first not-executed task, doing it, and marking it as executed. When nothing is found to be done, it just waits for another minute or so.\nThis table is also the log of jobs performed and may carry results too. And you can get averages from it.","Q_Score":2,"Tags":"python,multiprocessing","A_Id":7161916,"CreationDate":"2011-08-22T14:50:00.000","Title":"multiprocessing in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've always coded in the style of if not value, however, a few guides have brought to my attention that while this style works, it seems to have 2 potential problems:\n\nIt's not completely readable; if value is None is surely more understandable.\nThis can have implications later (and cause subtle bugs), since things like [] and 0 will evaluate to False as well.\n\nI am also starting to apply this idea to other comparisons, such as:\n\nif not value vs if value is False\nif not value vs if value is []\n\nAnd so goes the list...\nThe question is, how far do you go with the principle? Where to draw the line, while keeping your code safe?\nShould I always use the if value is None style no matter what?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":40121,"Q_Id":7152441,"Users Score":7,"Answer":"My answer is simple, as it applies to most coding problems: Don't try to write something that just works. Try to express your intent as clearly as possible. If you want to check if a value is false, use if not value. If you want to check for None, write it down. It always depends on the situation and your judgement.\nYou should not try to find rules which can be applied without thinking. If you find those rules, it's a job for a computer, not for a human! ;-)","Q_Score":65,"Tags":"python,comparison,boolean,readability","A_Id":7152501,"CreationDate":"2011-08-22T19:20:00.000","Title":"Python: if not val, vs if val is None","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've always coded in the style of if not value, however, a few guides have brought to my attention that while this style works, it seems to have 2 potential problems:\n\nIt's not completely readable; if value is None is surely more understandable.\nThis can have implications later (and cause subtle bugs), since things like [] and 0 will evaluate to False as well.\n\nI am also starting to apply this idea to other comparisons, such as:\n\nif not value vs if value is False\nif not value vs if value is []\n\nAnd so goes the list...\nThe question is, how far do you go with the principle? Where to draw the line, while keeping your code safe?\nShould I always use the if value is None style no matter what?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":40121,"Q_Id":7152441,"Users Score":34,"Answer":"No. If you want to run code when the value is false but isn't None, this would fail horribly. \nUse is None if you're checking for identity with the None object. Use not value if you just want the value to be False.","Q_Score":65,"Tags":"python,comparison,boolean,readability","A_Id":7152491,"CreationDate":"2011-08-22T19:20:00.000","Title":"Python: if not val, vs if val is None","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've always coded in the style of if not value, however, a few guides have brought to my attention that while this style works, it seems to have 2 potential problems:\n\nIt's not completely readable; if value is None is surely more understandable.\nThis can have implications later (and cause subtle bugs), since things like [] and 0 will evaluate to False as well.\n\nI am also starting to apply this idea to other comparisons, such as:\n\nif not value vs if value is False\nif not value vs if value is []\n\nAnd so goes the list...\nThe question is, how far do you go with the principle? Where to draw the line, while keeping your code safe?\nShould I always use the if value is None style no matter what?","AnswerCount":5,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":40121,"Q_Id":7152441,"Users Score":5,"Answer":"Your use of the is operator is a little problematic. if value is [] will always be false, for example, because no two active lists have the same identity. It works great with None because None is a singleton (all references to None are the same object) but for other comparisons, use ==.\nHowever, if value and if not value are perfectly readable and useful.  IMHO there's no need to be more specific, unless you need to treat various types of truthy or falsy values differently, as, for example, distinguishing between 0 and None.","Q_Score":65,"Tags":"python,comparison,boolean,readability","A_Id":7153236,"CreationDate":"2011-08-22T19:20:00.000","Title":"Python: if not val, vs if val is None","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script and this python script shall call an html-file (i.e. a web page) stored locally on the computer. The html-file does some calculations (jquery,javascript and so on) and should pass the result back to the python script.\nI don't want to change the setting (python script calls html-file and result is passed back to python-script) so please don't ask why.\nCould anyone tell me how to solve this? How can I pass the result from html-file to the calling python function? That troubles me since 2 weeks.\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":367,"Q_Id":7158635,"Users Score":0,"Answer":"This would be very hard to accomplish without the use of external libraries. You'd need a HTML parser to start with, so you can actually make sense of the HTML. Then you'd need a Javascript parser\/lexer\/engine so you could do the actual calculations. I guess it would be possible to implement this in Python, but I'd recommend looking for an open source project which already implemented this. You'd then have to parse\/lex\/interpret the javascript and pass back the result to python. \nAll in all I'd say it's easier to just port the Javascript calculation to Python, but that's just me.","Q_Score":2,"Tags":"javascript,python,html,javascript-engine","A_Id":7158707,"CreationDate":"2011-08-23T09:10:00.000","Title":"How can my HTML file pass JavaScript results back to a Python script that calls it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running python 2.6 on Linux, Mac OS, and Windows, and need to determine whether the kernel is running in 32-bit or 64-bit mode.  Is there an easy way to do this?\nI've looked at platform.machine(), but this doesn't work properly on Windows.\nI've also looked at platform.architecture(), and this doesn't work when running 32-bit python on 64-bit Windows.\nNote: It looks like python 2.7 has a fix that makes platform.architecture() work correctly.  Unfortunately, I need to use python 2.6 (at least for now).\n(edit:  From talking to folks off-line, it sounds like there probably isn't a robust python-only way to make this determination without resorting to evil hacks.  I'm just curious what evil hacks folks have used in their projects that use python 2.6.  For example, on Windows it may be necessary to look at the PROCESSOR_ARCHITEW6432 environment variable and check for AMD64)","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":8553,"Q_Id":7164843,"Users Score":-1,"Answer":"we can used follow  API to detect current is 32bit or 64 bit\n\n\n\nplatform.architecture()[0]\n\n\n\n'64bit","Q_Score":12,"Tags":"python","A_Id":16995242,"CreationDate":"2011-08-23T17:08:00.000","Title":"In Python, how do you determine whether the kernel is running in 32-bit or 64-bit mode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a file that I would like to copy from a shared folder which is in a shared folder on a different system, but on the same network. How can I access the folder\/file? The usual open() method does not seem to work?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":187115,"Q_Id":7169845,"Users Score":6,"Answer":"I had the same issue as OP but none of the current answers solved my issue so to add a slightly different answer that did work for me:\nRunning Python 3.6.5 on a Windows Machine, I used the format\nr\"\\DriveName\\then\\file\\path\\txt.md\"\nso the combination of double backslashes from reading @Johnsyweb UNC link and adding the r in front as recommended solved my similar to OP's issue.","Q_Score":73,"Tags":"python,windows,networking","A_Id":51795325,"CreationDate":"2011-08-24T02:34:00.000","Title":"Using Python, how can I access a shared folder on windows network?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Why is it that I have to run python manage.py somecommand and others simply run manage.py somecommand? I'm on OSX 10.6. Is this because there is a pre-set way to enable .py files to automatically run as Python scripts, and I've somehow disabled the functionality, or is that something that you explicitly enable?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":802,"Q_Id":7182165,"Users Score":6,"Answer":"If you are using a recent version of Django, the manage.py file should be an \"executable\" file by default.\nPlease note, you cannot just type manage.py somecommand into the terminal as manage.py is not on the PATH, you will have to type .\/ before it to run it from the current directory, i.e. .\/manage.py somecommand.\nIf that does not work please be sure that the manage.py file has:\n#!\/usr\/bin\/env python\nas its first line. And make sure it is executable: chmod +x manage.py","Q_Score":2,"Tags":"python,django,command-line","A_Id":7182225,"CreationDate":"2011-08-24T20:56:00.000","Title":"Django manage.py question","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use mono develop 2.4 in ubuntu 10.10, with monodevelop-python and ironpython \nWhen I created a empty python project mono develop don't show the reference node.\nhow I can add a new reference file ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":7192763,"Users Score":0,"Answer":"The Python addin is for cpython, not IronPython, so it doesn't support assembly references.","Q_Score":0,"Tags":"ironpython,monodevelop","A_Id":7242146,"CreationDate":"2011-08-25T15:07:00.000","Title":"mono develop don\u00b4t show reference node","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My webhost where our website is runs Python 2.4 & the website uses the SQLite3 python module (which is only part of Python 2.5 & up). This means that I cant use the module SQLite3 because its not part of Python 2.4.\nIs there a way for me to upload the python SQLite3 module myself & just import\/refernce that in my script? Do you know how I would do this?\nUsually I would just install Python25 on my  webhost home directory, but this webhost wont allow me to do this.\nIs there any way I can just upload & import a specific module - coming from c++ it seems this must be possible right? Because in C++ I spend my whole life writting libraries & just importing specific parts of them & importing specific classes of a namespace & etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":7200745,"Users Score":0,"Answer":"This very much depends about how much control your webhost gives you about the Python environment. For normal shared hosting, the runtime Python environment is fixed.","Q_Score":1,"Tags":"python,mysql,sqlite,web-hosting","A_Id":7200805,"CreationDate":"2011-08-26T06:22:00.000","Title":"Importing a specific module thats not part of my current Python 2.X version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As a personal project, I have been developing my own database software in C#. Many current database systems can use SQL commands for queries. Is there anyone here that could point me in the right direction of implementing such a system in a database software written completely from scratch? For example a user familiar with SQL could enter a statement as a string into an application, that statement will be analyzed by my application and the proper query will be run. Does anyone have any experience with something like that here? This is probably a very unusual questions haha. Basically what I am asking, are there any tools available out there that can dissect SQL statements or will I have to write my own from scratch for that?\nThanks in advance for any help!\n(I may transfer some of my stuff to Python and Java, so any potential answers need not be limited to C#)\nALSO: I am not using any current SQL database or anything like that, my system is completely from scratch, I hope my question makes sense. Basically I want my application to be able to interface with programs that send SQL commands.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2117,"Q_Id":7211204,"Users Score":3,"Answer":"A full-on database engine is a pretty serious undertaking.  You're not going to sit down and have a complete engine next week, so I'd have thought you would want to write the SQL parser piecemeal: adding features to the parser as the features are supported in the engine.\nI'm guessing this is just something fun to do, rather than something you want working ASAP.  Given that, I'd have thought writing an SQL parser is one of the best bits of the project!  I've done lots of work with flat file database engines, because the response times required for queries don't allow a RDBMS.  One of the most enjoyable bits has been adding support for SQL fragments in e.g. the UI, where response time isn't quite as vital.\nThe implementation I work on is plain old C, but in fact from what I've seen, most relational databases are still written primarily in C.  And there is something satisfying about writing these things in a really low level language :)","Q_Score":1,"Tags":"c#,java,python,sql,database","A_Id":7211297,"CreationDate":"2011-08-26T22:36:00.000","Title":"C# custom database engine, how to implement SQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Python and JavaScript both allow developers to use or to omit semicolons. However, I've often seen it suggested (in books and blogs) that I should not use semicolons in Python, while I should always use them in JavaScript.\nIs there a technical difference between how the languages use semicolons or is this just a cultural difference?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":6980,"Q_Id":7219541,"Users Score":8,"Answer":"Aside from the syntactical issues, it is partly cultural.  In Python culture any extraneous characters are an anathema, and those that are not white-space or alphanumeric, doubly so.\nSo things like leading $ signs, semi-colons, and curly braces, are not liked.  What you do in your code though, is up to you, but to really understand a language it is not enough just to learn the syntax.","Q_Score":61,"Tags":"javascript,python,syntax","A_Id":7219710,"CreationDate":"2011-08-28T07:12:00.000","Title":"What is the difference between semicolons in JavaScript and in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Python and JavaScript both allow developers to use or to omit semicolons. However, I've often seen it suggested (in books and blogs) that I should not use semicolons in Python, while I should always use them in JavaScript.\nIs there a technical difference between how the languages use semicolons or is this just a cultural difference?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":6980,"Q_Id":7219541,"Users Score":8,"Answer":"JavaScript is designed to \"look like C\", so semicolons are part of the culture. Python syntax is different enough to not make programmers feel uncomfortable if the semicolons are \"missing\".","Q_Score":61,"Tags":"javascript,python,syntax","A_Id":7219723,"CreationDate":"2011-08-28T07:12:00.000","Title":"What is the difference between semicolons in JavaScript and in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Python and JavaScript both allow developers to use or to omit semicolons. However, I've often seen it suggested (in books and blogs) that I should not use semicolons in Python, while I should always use them in JavaScript.\nIs there a technical difference between how the languages use semicolons or is this just a cultural difference?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":6980,"Q_Id":7219541,"Users Score":7,"Answer":"The answer why you don't see them in Python code is: no one needs them, and the code looks cleaner without them.\nGenerally speaking, semicolons is just a tradition. Many new languages have just dropped them for good (take Python, Ruby, Scala, Go, Groovy, Io for example). Programmers don't need them, neither do compilers. If a language lets you not type an extra character you never needed, you will want to take advantage of that, won't you?\nIt's just that JavaScript's attempt to drop them wasn't very successful, and many prefer the convention to always use them, because that makes code less ambiguous.","Q_Score":61,"Tags":"javascript,python,syntax","A_Id":7219731,"CreationDate":"2011-08-28T07:12:00.000","Title":"What is the difference between semicolons in JavaScript and in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I asked a question before about how to do multiprocessing in Python (although I did not use the word multiprocessing in the former question, because I was not sure I was asking about that yet).\nNow I am wondering how to do multiprocessing when you have more then one language involved, particularly if you have a PHP script that calls a Python script.  In that case how can you have both the PHP script and the Python script multiprocess, and communicate with each other (send variables back and forth) as they multiprocess?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":335,"Q_Id":7225684,"Users Score":1,"Answer":"One way to this would be though web services.  You could have a PHP process sitting on a web server and running and calling a Python web service (using CherryPy) multiple times.  You would pass variables using a standard object notation such as JSON which can be efficiently encoded\/decoded by both PHP and Python.\nYou could also do the reverse of this with a Python service making multiple calls to a PHP service.\nIn both cases, since you're limited by a certain number of concurrent connections you don't need to worry about handling the threads yourself.","Q_Score":0,"Tags":"php,python,multiprocess","A_Id":7225770,"CreationDate":"2011-08-29T03:04:00.000","Title":"Multiprocessing between different languages such as PHP and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I use selenium webdriver with a custom firefox profile I get the firefox Add-ons pop up showing 2 extensions: Firefx WebDriver 2.5.0 and Ubuntu Firefox Modifications 0.9rc2.\nHow can I get rid of this popup? I looked in the server jar to see if I could find the extensions, no luck. Looked online for the extensions, no luck. When I run the code without using the custom profile there is no popup.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1461,"Q_Id":7233631,"Users Score":0,"Answer":"Open Firefox with this profile (with profile manager), go to Firefox preferences, turn off updates - this works for me.","Q_Score":4,"Tags":"python,firefox,selenium","A_Id":7267936,"CreationDate":"2011-08-29T17:33:00.000","Title":"Using Selenium webdriver with a custom firefox profile - how to get rid of addins popup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in Windows and Suppose I have a main python code that calls python interpreter in command line to execute another python script ,say test.py .\nSo test.py is executed as a new process.How can I find the processId for this porcess in Python ?\nUpdate:\nTo be more specific , we have os.getpid() in os module. It returns the current process id.\nIf I have a main program that runs Python interpreter to run another script , how can I get the process Id for that executing script ?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":36362,"Q_Id":7250126,"Users Score":0,"Answer":"You will receive the process ID of the newly created process when you create it. At least, you will if you used fork() (Unix), posix_spawn(), CreateProcess() (Win32) or probably any other reasonable mechanism to create it.\nIf you invoke the \"python\" binary, the python PID will be the PID of this binary that you invoke. It's not going to create another subprocess for itself (Unless your python code does that).","Q_Score":18,"Tags":"python","A_Id":7250363,"CreationDate":"2011-08-30T21:37:00.000","Title":"getting ProcessId within Python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in Windows and Suppose I have a main python code that calls python interpreter in command line to execute another python script ,say test.py .\nSo test.py is executed as a new process.How can I find the processId for this porcess in Python ?\nUpdate:\nTo be more specific , we have os.getpid() in os module. It returns the current process id.\nIf I have a main program that runs Python interpreter to run another script , how can I get the process Id for that executing script ?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":36362,"Q_Id":7250126,"Users Score":0,"Answer":"Another option is that the process you execute will set a console window title for himself.\nAnd the searching process will enumerate all windows, find the relevant window handle by name and use the handle to find PID.  It works on windows using ctypes.","Q_Score":18,"Tags":"python","A_Id":16131293,"CreationDate":"2011-08-30T21:37:00.000","Title":"getting ProcessId within Python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm on Mac OS X 10.7.1 (Lion). I just downloaded a fresh copy of Eclipse IDE for Java EE Developers, and installed the Mercurial plugin. I get the following error message:\n\nabort: couldn't find mercurial libraries in [...assorted Python directories...].\n\nI do have Python 2.6.1 and 3.2.1 installed. I also have a directory System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7, which is on the list of places it looked for the Mercurial libraries. hg -y debuginstall gives me the same message.\nWhat are these libraries named, where is Eclipse likely to have put them when I installed the plugin, and how do I tell Eclipse where they are (or where should I move them to)?\nThanks, Dave\nFull error message follows:\n\nabort: couldn't find mercurial libraries in\n  [\/usr\/platlib\/Library\/Python\/2.6\/site-packages \/usr\/local\/bin\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python27.zip\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/plat-darwin\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/plat-mac\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/plat-mac\/lib-scriptpackages\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-tk\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-old\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-dynload\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/PyObjC\n  \/Library\/Python\/2.7\/site-packages] (check your install and PYTHONPATH)","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1116,"Q_Id":7261451,"Users Score":3,"Answer":"Nobody answered me, but I figured out the answer. Maybe it will help someone.\nI finally realized that since 'hg -y debuginstall' at the command line was giving me the same error message, it wasn't an Eclipse problem at all (duh). Reinstalling a newer version of Mercurial solved the problem.","Q_Score":1,"Tags":"python,mercurial,eclipse-plugin,osx-lion","A_Id":7278773,"CreationDate":"2011-08-31T18:12:00.000","Title":"Mercurial plugin for Eclipse can't find Python--how to fix?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm on Mac OS X 10.7.1 (Lion). I just downloaded a fresh copy of Eclipse IDE for Java EE Developers, and installed the Mercurial plugin. I get the following error message:\n\nabort: couldn't find mercurial libraries in [...assorted Python directories...].\n\nI do have Python 2.6.1 and 3.2.1 installed. I also have a directory System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7, which is on the list of places it looked for the Mercurial libraries. hg -y debuginstall gives me the same message.\nWhat are these libraries named, where is Eclipse likely to have put them when I installed the plugin, and how do I tell Eclipse where they are (or where should I move them to)?\nThanks, Dave\nFull error message follows:\n\nabort: couldn't find mercurial libraries in\n  [\/usr\/platlib\/Library\/Python\/2.6\/site-packages \/usr\/local\/bin\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python27.zip\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/plat-darwin\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/plat-mac\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/plat-mac\/lib-scriptpackages\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-tk\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-old\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/lib-dynload\n  \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python\/PyObjC\n  \/Library\/Python\/2.7\/site-packages] (check your install and PYTHONPATH)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1116,"Q_Id":7261451,"Users Score":0,"Answer":"I had two installation of mercurial in mac. \nOne was installed directly and another using macport.\nRemoving the direct installation solved the problem.\n\nRemove the direct installation using \neasy_install -m mercurial \nUpdate \"Mercurial Executable\" path to \"\/opt\/local\/bin\/hg\"\nEclipse->Preference->Team->Mercurial->\nRestart eclipse","Q_Score":1,"Tags":"python,mercurial,eclipse-plugin,osx-lion","A_Id":12130976,"CreationDate":"2011-08-31T18:12:00.000","Title":"Mercurial plugin for Eclipse can't find Python--how to fix?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using eclipse + pydev. I want to refactor and change the name of my module. I clicked on my module in the package explorer, but no refactoring (other than 'rename') in the context menu. Similarly, the refactoring on the top navigation menu is greyed out.\nSo how do i change my module name and have it reflected across my project.?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1767,"Q_Id":7268426,"Users Score":1,"Answer":"Did you try rename? it seems to work in other language plugins.(make sure to right click on the module)","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":7268461,"CreationDate":"2011-09-01T09:26:00.000","Title":"eclipse+pydev how to rename module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using eclipse + pydev. I want to refactor and change the name of my module. I clicked on my module in the package explorer, but no refactoring (other than 'rename') in the context menu. Similarly, the refactoring on the top navigation menu is greyed out.\nSo how do i change my module name and have it reflected across my project.?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1767,"Q_Id":7268426,"Users Score":2,"Answer":"This feature is still not properly integrated in the pydev package explorer, so, for now, you have to find a place that uses the module you want in the code and rename that reference in the editor (you don't need to report that as a bug as that's already known and should be fixed soon).","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":7272489,"CreationDate":"2011-09-01T09:26:00.000","Title":"eclipse+pydev how to rename module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started.\nI was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance?\nNote, results are huge too, I am talking about an ERP in production developed by other people.","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3111,"Q_Id":7279761,"Users Score":7,"Answer":"Let the DB figure out how best to retrieve the information that you want, else you'll have to duplicate the functionality of the RDBMS in your code, and that will be way more complex than your SQL queries. \nPlus, you'll waste time transferring all that unneeded information from the DB to your app, so that you can filter and process it in code.\nAll this is true because you say you're dealing with large data.","Q_Score":9,"Tags":"python,sql,performance","A_Id":7279821,"CreationDate":"2011-09-02T06:05:00.000","Title":"Should I use complex SQL queries or process results in the application?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started.\nI was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance?\nNote, results are huge too, I am talking about an ERP in production developed by other people.","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3111,"Q_Id":7279761,"Users Score":3,"Answer":"I would have the business logic in the application, as much as possible. Complex business logic in queries are difficult to maintain. (when I finish understanding one I have already forgotten how it all started)Complex logic in stored procedures are ok. But with a typical python application, you would want your business logic to be in python.\nNow, the database is way better in handling data than your application code. So if your logic involves huge amount of data, you may get better performance with the logic in the database. But this will be for complex reports, bookkeeping operations and such, that operate on a large volume of data. You may want to use stored procedures, or systems that specialize in such operations (a data warehouse for reports) for these types of operations.\nNormal OLTP operations do not involve much of data. The database may be huge, but the data required for a typical transaction will be (typically) a very small part of it. Querying this in a large database may cause performance issues, but you can optimize this in several ways (indexes, full text searches, redundancy, summary tables... depends on your actual problem).\nEvery rule has exceptions, but as a general guideline, try to have your business logic in your application code. Stored procedures for complex logic. A separate data warehouse or a set of procedures for reporting.","Q_Score":9,"Tags":"python,sql,performance","A_Id":7280826,"CreationDate":"2011-09-02T06:05:00.000","Title":"Should I use complex SQL queries or process results in the application?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started.\nI was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance?\nNote, results are huge too, I am talking about an ERP in production developed by other people.","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":3111,"Q_Id":7279761,"Users Score":1,"Answer":"@Nivas is generally correct.\nThese are pretty common patterns\n\nDivision of labour - the DBAs have to return all the data the business need, but they only have a database to work with.  The developers could work with the DBAs to do it better but departmental responsbilities make it nearly impossible.  So SQL to do morethan retrieve data is used.\nlack of smaller functions.  Could the massive query be broken down into smaller stages, using working tables?  Yes, but I have known environments where a new table needs reams of approavals - a heavy Query is just written\n\nSo, in general, getting data out of the database - thats down to the database.  But if a SQL query is too long its going to be hard for the RDBMS to optimise, and it probably means the query is spanning data, business logic and even presentation in one go.\nI would suggest a saner approach is usually to seperate out the \"get me the data\" portions into stored procedures or other controllable queries that populate staging tables.  Then the business logic can be written into a scripting language sitting above and controlling the stored procedures.  And presentation is left elsewhere.  In essence solutions like cognos try to do this anyway.\nBut if you are looking at an ERP in production, the constraints and the solutions above probably already exist - are you talking to the right people?","Q_Score":9,"Tags":"python,sql,performance","A_Id":7282367,"CreationDate":"2011-09-02T06:05:00.000","Title":"Should I use complex SQL queries or process results in the application?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My python application is dying, this oracle trace file is being generated. I am using cx_Oracle, how do I go about using this trace file to resolve this crash?\nora_18225_139690296567552.trc\nkpedbg_dmp_stack()+360<-kpeDbgCrash()+192<-kpureq2()+3194<-OCIStmtPrepare2()+157<-Cursor_InternalPrepare()+298<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":653,"Q_Id":7285135,"Users Score":0,"Answer":"Do you have an Oracle support contract?  If I would file an SR and upload the trace to Oracle and have them tell you what it is complaining about.  Those code calls are deep in their codebase from the looks of it.","Q_Score":1,"Tags":"python,cx-oracle","A_Id":7530424,"CreationDate":"2011-09-02T14:43:00.000","Title":"I have an Oracle Stack trace file Python cx_Oracle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a regular application (like on Windows), when objects\/variables are created on a global level it is available to the entire program during the entire duration the program is running.\nIn a web application written in PHP for instance, all variables\/objects are destroyed at the end of the script so everything has to be written to the database.\na) So what about python running under apache\/modwsgi? How does that work in regards to the memory? \nb) How do you create objects that persist between web page requests and how do you ensure there isn't threading issues in apache\/modwsgi?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":7293290,"Users Score":0,"Answer":"All Python globals are created when the module is imported. When module is re-imported the same globals are used.\nPython web servers do not do threading, but pre-forked processes. Thus there is no threading issues with Apache.\nThe lifecycle of Python processes under Apache depends. Apache has settings how many child processes are spawned, keep in reserve and killed. This means that you can use globals in Python processes for caching (in-process cache), but the process may terminate after any request so you cannot put any persistent data in the globals. But the process does not necessarily need to terminate and in this regard Python is much more efficient than PHP (the source code is not parsed for every request - but you need to have the server in reload mode to read source code changes during the development).\nSince globals are per-process and there can be N processes, the processes share \"web server global\" state using mechanisms like memcached.\nUsually Python globals only contain\n\nSetting variables set during the process initialization\nCached data (session\/user neutral)","Q_Score":4,"Tags":"python,apache,memory-management,mod-wsgi","A_Id":7293404,"CreationDate":"2011-09-03T13:09:00.000","Title":"Memory model for apache\/modwsgi application in python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this question is incredibly easy to answer, or I sound like an idiot. I'm wondering how I would execute a script in one file, pygame event loop, blits, etc, then switch to another file, SelectWorld.py, which has it's own event loop, and blits, and etc. If I just call it's main function, does it create any slowdown because I still have the original file open, or am I fine just doing that? SelectWorld.transition() sort of thing. Thanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":790,"Q_Id":7296987,"Users Score":1,"Answer":"Here, what is wanted is to be able to share the variables between two different applications: 2 different scripts with event loops, blits, etc. So by definition, they should be on different process (if they must be running at the same time).\nThere is two major ways of doing this:\n1 - Client-Server Architecture (like a Game server would be) (the server and client can both run on the same machine)\n2 - Multiprocessing with 2 process running on the same machine with different ways of communicating and synchronize the variables. (Pipe Queue, Event, etc)\nI understand that you're trying to do a kind of variables profiling of your game? If it is used to debug your game or test it. I consider that you need a lot of code to gain a little useful information (because the game might run too fast for you to analyse the variables)\nYou have those alternatives:\n1 - import pdb, pdb.set_trace(): it will stop the process at the line where you called the function and, on the terminal, you can see the variables values.\n2 - You can use Eclipse (with pyDev): Very good debugger (line by line)\n3 - Unittest, Mock: Is something you should start to use, because it is useful, because you can easily see when you break some old code (with unittest) and\/or testing new code...\nI hope it helps you :)","Q_Score":1,"Tags":"python,transition,pygame,blit","A_Id":7300851,"CreationDate":"2011-09-04T02:02:00.000","Title":"Python\/Pygame transitioning from one file to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this question is incredibly easy to answer, or I sound like an idiot. I'm wondering how I would execute a script in one file, pygame event loop, blits, etc, then switch to another file, SelectWorld.py, which has it's own event loop, and blits, and etc. If I just call it's main function, does it create any slowdown because I still have the original file open, or am I fine just doing that? SelectWorld.transition() sort of thing. Thanks in advance.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":790,"Q_Id":7296987,"Users Score":0,"Answer":"Turns out the answer to this was painfully simple, and I asked this back when I was just learning Python. There is no speed downgrade from just calling a function from another file and letting it do all the work. Thanks for all the answers, guys.","Q_Score":1,"Tags":"python,transition,pygame,blit","A_Id":10609284,"CreationDate":"2011-09-04T02:02:00.000","Title":"Python\/Pygame transitioning from one file to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get some locations in New York using FourSquare API using the following API call:\n\nhttps:\/\/api.foursquare.com\/v2\/venues\/search?ll=40.7,-74&limit=50\n\nWhat I don't understand is that if the call imposes a limit of 50 search results (which is the maximum), how can I get more locations? When using Facebook API, the results being returned were random so I could issue multiple calls to get more results but FourSquare seems to be returning the same result set. Is there a good way to get more locations?\nEDIT:\nOk. So there was a comment saying that I could be breaking a contractual agreement and I am not sure why this would be the case. I would gladly accept a reasoning for this. My doubt is this: Let us say that hypothetically, the location I am searching for is not in the 50 results returned? In that case, shouldn't there be a pagination mechanism somewhere?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2222,"Q_Id":7303309,"Users Score":1,"Answer":"The current API limits results to 50. You should try altering your coordinates to be more precise to avoid not finding your venue.\nPagination would be nice but 50 is a lot of venues for a search.","Q_Score":1,"Tags":"javascript,python,http,foursquare","A_Id":7354603,"CreationDate":"2011-09-05T02:02:00.000","Title":"How do I get more locations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two integers in my program; let's call them \"a\" and \"b\".  I would like to add them together and get another integer as a result.  These are regular Python int objects.  I'm wondering; how do I add them together with Twisted?  Is there a special performAsynchronousAddition function somewhere?  Do I need a Deferred?  What about the reactor?  Is the reactor involved?","AnswerCount":3,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":5861,"Q_Id":7313761,"Users Score":-9,"Answer":"Good question, and Twisted (or Python) should have a way to at least spawn \"a + b\" of to several cores (on my 8 core i7). \nUnfortunately the Python GIL prevents this from happening, meaning that you will have to wait, not only for the CPU bound task, but for one core doing the job, while the seven others core are doing nothing.\nNote: Maybe a better example would be \"a() + b()\", or even \"fact(sqrt(a()**b())\" etc. but the important fact is that above operation will lock one core and the GIL pretty much prevents Python for doing anything else during that operation, which could be several ms...","Q_Score":48,"Tags":"python,asynchronous,twisted,addition,arithmetic-expressions","A_Id":20604305,"CreationDate":"2011-09-06T00:08:00.000","Title":"How do I add two integers together with Twisted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to run a bunch of long running processes on a CENTOS server.\nIf I leave the processes (python\/php scripts) to run sometimes the processes will stop running because of trivial errors eg. string encoding issues or sometimes because the process seems to get killed by the server.\nI try to use nohup and fire the jobs from the crontab\nIs there any way to keep these processes running in such a way that all the variables are saved and I can restart the script from where it stopped?\nI know I can program this into the code but would prefer a generalised utility which could just keep these things running so that the script completed even if there were trivial errors.\nPerhaps I need some sort of process-management tool?\nMany thanks for any suggestions","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":137,"Q_Id":7334587,"Users Score":3,"Answer":"is there any way to keep these processes running in such a way that all the variables are saved and i can restart the script from where it stopped?\n\nYes.  It's called creating a \"checkpoint\" or \"memento\".\n\ni know i can program this \n\nGood.  Get started.  Each problem is unique, so you have to create, save, and reload the mementos.\n\nbut would prefer a generalised utility which could just keep these things running so that the script completed even if there were trivial errors.\n\nIt doesn't generalize well.  Not all variables can be saved.  Only you know what's required to restart your process in  a meaningful way.\n\nperhaps i need some sort of process-management tool?\n\nNot really.\n\ntrivial errors eg. string encoding issues \n\nUsually, we find these by unit testing.  That saves a lot of programming to work around the error.  An ounce of prevention is worth a pound of silly work-arounds.\n\nsometimes because the process seems to get killed by the server.\n\nWhat?  You'd better find out why.  An ounce of prevention is worth a pound of silly work-arounds.","Q_Score":1,"Tags":"php,python,process,centos,process-management","A_Id":7334651,"CreationDate":"2011-09-07T13:23:00.000","Title":"running really long scripts - how to keep them running and start them again if they fail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a simple module that let's you paste input in python ? \nAsking someone to type letter by letter is kinda harsh .\nBy default a .py file is opened with python.exe if is installed and this does not allow \"rightclick+paste\" in the console .So how can i make this happen with python ? i think this would be more of a exact question .","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1567,"Q_Id":7335957,"Users Score":0,"Answer":"You can make this by open cmd.exe and type here \"C:\\Python32\\python\".\nPath is depend on the version of python. Mine is 3.2.","Q_Score":0,"Tags":"python","A_Id":7336599,"CreationDate":"2011-09-07T14:53:00.000","Title":"Python raw_input() unable to paste in windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table).\nI tried select count(*) from table, but that seems to access each row and is super slow.\nI also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table can be empty etc. It's more of a hack.\nAny ideas on how to find the table size quickly and cleanly?\n\nUsing Python 2.5's sqlite3 version 2.3.2, which uses Sqlite engine 3.4.0.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3251,"Q_Id":7346079,"Users Score":0,"Answer":"To follow up on Thilo's answer, as a data point, I have a sqlite table with 2.3 million rows. Using select count(*) from table, it took over 3 seconds to count the rows. I also tried using SELECT rowid FROM table, (thinking that rowid is a default primary indexed key) but that was no faster. Then I made an index on one of the fields in the database (just an arbitrary field, but I chose an integer field because I knew from past experience that indexes on short fields can be very fast, I think because the index is stored a copy of the value in the index itself). SELECT my_short_field FROM table brought the time down to less than a second.","Q_Score":2,"Tags":"python,sqlite","A_Id":34628302,"CreationDate":"2011-09-08T09:44:00.000","Title":"Fast number of rows in Sqlite","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table).\nI tried select count(*) from table, but that seems to access each row and is super slow.\nI also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table can be empty etc. It's more of a hack.\nAny ideas on how to find the table size quickly and cleanly?\n\nUsing Python 2.5's sqlite3 version 2.3.2, which uses Sqlite engine 3.4.0.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":3251,"Q_Id":7346079,"Users Score":1,"Answer":"Do you have any kind of index on a not-null column (for example a primary key)? If yes, the index can be scanned (which hopefully does not take that long). If not, a full table scan is the only way to count all rows.","Q_Score":2,"Tags":"python,sqlite","A_Id":7346136,"CreationDate":"2011-09-08T09:44:00.000","Title":"Fast number of rows in Sqlite","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table).\nI tried select count(*) from table, but that seems to access each row and is super slow.\nI also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table can be empty etc. It's more of a hack.\nAny ideas on how to find the table size quickly and cleanly?\n\nUsing Python 2.5's sqlite3 version 2.3.2, which uses Sqlite engine 3.4.0.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":3251,"Q_Id":7346079,"Users Score":1,"Answer":"Other way to get the rows number of a table is by using a trigger that stores the actual number of rows in other table (each insert operation will increment a counter). \nIn this way inserting a new record will be a little slower, but you can immediately get the number of rows.","Q_Score":2,"Tags":"python,sqlite","A_Id":7346821,"CreationDate":"2011-09-08T09:44:00.000","Title":"Fast number of rows in Sqlite","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know if there is any built in function in python to break the string in to 2 parts, based on the last occurrence of a separator.\nfor eg:\nconsider the string \"a b c,d,e,f\" , after the split over separator \",\", i want the output as\n\"a b c,d,e\" and \"f\". \nI know how to manipulate the string to get the desired output, but i want to know if there is any in built function in python.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62919,"Q_Id":7351744,"Users Score":122,"Answer":"Use rpartition(s). It does exactly that.\nYou can also use rsplit(s, 1).","Q_Score":103,"Tags":"python,string","A_Id":7351789,"CreationDate":"2011-09-08T16:56:00.000","Title":"split string in to 2 based on last occurrence of a separator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to ask how can I get list of urls which are opened in my webbrowser, from example in firefox. I need it in Python.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1872,"Q_Id":7358224,"Users Score":0,"Answer":"First I'd check if the browser has some kind of command line argument which could print such informations. I only checked Opera and it doesn't have one. What you could do is parse session file. I'd bet that every browser stores list of opened tabs\/windows on disk (so it could recover after crash). Opera has this information in ~\/.opera\/sessions\/autosave.win. It's pretty straight-forward text file. Find other browsers' session files in .mozzila, .google, etc.. or if you are on windows in \/user\/ directories. There might be commands to ask running instance for its working directory (as you can specify it on startup and it doesn't have to be the default one).\nThat's the way I'd go. Might be the wrong one.","Q_Score":1,"Tags":"python","A_Id":7358989,"CreationDate":"2011-09-09T07:05:00.000","Title":"Get url from webbrowser in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recommended to a friend to learn some functional programming using Python to expand his knowledge and overcome programmer's fatigue.\nI chose Python because that way there's a good chance he'll be able to use the new knowledge in practical daily work.\nI tried to find him some tutorials, and found a lot of guides - diving deep into how to use map, reduce, filter, etc., but don't provide exercises where he can learn while coding.\nWhere can I find a tutorial that uses functional python to solve problems while teaching?\nAn optimal answer for me would be homework from a functional programming course, that needs to be written in Python. Such a thing is probably rare because an academic course will usually prefer a purer functional language for such work.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":539,"Q_Id":7368119,"Users Score":0,"Answer":"It's not a literal answer to your question, but I'd recommend to your friend to practice in Javascript instead of python.  With python you can do some functional programming, but most projects don't need to do much if any.  Javascript really requires doing this, and is at least as common\/useful of a language these days.  You'll find a lot more useful educational material on closures in javascript than python.","Q_Score":7,"Tags":"python,functional-programming","A_Id":7391685,"CreationDate":"2011-09-09T22:29:00.000","Title":"What good homework style tutorials are recommended for learning functional programming in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Is there any way how to find out, if ip address comming to the server is proxy in Python?\nI tried to scan most common ports, but i don't want to ban all ips with open 80 port, because it don't have to be proxy.\nIs there any way how to do it in Python? I would prefere it before using some external\/paid services.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":328,"Q_Id":7371442,"Users Score":1,"Answer":"If it's a HTTP traffic, you can scan for headers like X-Forwarded-For. \nBut whatever you do it will always be only a heuristic.","Q_Score":2,"Tags":"python,sockets,proxy","A_Id":7378232,"CreationDate":"2011-09-10T11:39:00.000","Title":"Python - Determine if ip is proxy or not","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Psycopg2 with PostgreSQL 8.4. While reading from a huge table, I suddenly get this cryptic error at the following line of code, after this same line of code has successfully fetched a few hundred thousand rows.\nsomerows = cursorToFetchData.fetchmany(30000)\npsycopg2.DataError: invalid value \"L\u00c3\" for \"DD\"\nDETAIL:  Value must be an integer.\nMy problem is that I have no column named \"DD\", and about 300 columns in that table (I know 300 columns is a design flaw). I would appreciate a hint about the meaning of this error message, or how to figure out where the problem lies. I do not understand how Psycop2 can have any requirements about the datatype while fetching rows.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":176,"Q_Id":7375572,"Users Score":2,"Answer":"Can you paste in the data from the row that's causing the problem? At a guess I'd say it's a badly formatted date entry, but hard to say.\n(Can't comment, so has to be in a answer...)","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":7378101,"CreationDate":"2011-09-11T00:33:00.000","Title":"Cryptic Psycopg2 error message","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using Psycopg2 with PostgreSQL 8.4. While reading from a huge table, I suddenly get this cryptic error at the following line of code, after this same line of code has successfully fetched a few hundred thousand rows.\nsomerows = cursorToFetchData.fetchmany(30000)\npsycopg2.DataError: invalid value \"L\u00c3\" for \"DD\"\nDETAIL:  Value must be an integer.\nMy problem is that I have no column named \"DD\", and about 300 columns in that table (I know 300 columns is a design flaw). I would appreciate a hint about the meaning of this error message, or how to figure out where the problem lies. I do not understand how Psycop2 can have any requirements about the datatype while fetching rows.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":176,"Q_Id":7375572,"Users Score":1,"Answer":"This is not a psycopg error, it is a postgres error.\nAfter the error is raised, take a look at cur.query to see the query generated. Copy and paste it into psql and you'll see the same error. Then debug it from there.","Q_Score":0,"Tags":"python,postgresql,psycopg2","A_Id":40247155,"CreationDate":"2011-09-11T00:33:00.000","Title":"Cryptic Psycopg2 error message","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm just wondering what knowledge or techniques are needed to make a web framework like django. \nso the webframework is able to serve as a cloud computing (a website can be scaled horizontally by sending some stuffs that must be solved to other server.) when needed, and can be used to build a website fast like django if a developer want to build a just simple website.\nSorry. my English is very awkward cause I'm an Korean.\njust give me some approaches or instructions about what techniques are needed to build a web framework or what I have to do or learn. \nThanks a lot.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":12556,"Q_Id":7378398,"Users Score":1,"Answer":"I would also browse the documentation for Paste and read a bit from Ian Bicking.. He lays out the conceptual blocks so to speak, quite well and has bloggedthe lessons learned as it was developed.\nWeb2py doco also\nbut yes as UKU said: WSGI is a modern requirement.","Q_Score":14,"Tags":"python,django","A_Id":7378820,"CreationDate":"2011-09-11T13:11:00.000","Title":"how to make web framework based on Python like django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background\nI am working on a fairly computationally intensive project for a computational linguistics project, but the problem I have is quite general and hence I expect that a solution would be interesting to others as well.\nRequirements\nThe key aspect of this particular program I must write is that it must: \n\nRead through a large corpus (between 5G and 30G, and potentially larger stuff down the line)\nProcess the data on each line.\nFrom this processed data, construct a large number of vectors (dimensionality of some of these vectors is > 4,000,000). Typically it is building hundreds of thousands of such vectors.\nThese vectors must all be saved to disk in some format or other.\n\nSteps 1 and 2 are not hard to do efficiently: just use generators and have a data-analysis pipeline. The big problem is operation 3 (and by connection 4)\nParenthesis: Technical Details\nIn case the actual procedure for building vectors affects the solution:\nFor each line in the corpus, one or more vectors must have its basis weights updated. \nIf you think of them in terms of python lists, each line, when processed, updates one or more lists (creating them if needed) by incrementing the values of these lists at one or more indices by a value (which may differ based on the index). \nVectors do not depend on each other, nor does it matter which order the corpus lines are read in.\nAttempted Solutions\nThere are three extrema when it comes to how to do this:\n\nI could build all the vectors in memory. Then write them to disk.\nI could build all the vectors directly on the disk, using shelf of pickle or some such library.\nI could build the vectors in memory one at a time and writing it to disk, passing through the corpus once per vector.\n\nAll these options are fairly intractable. 1 just uses up all the system memory, and it panics and slows to a crawl. 2 is way too slow as IO operations aren't fast. 3 is possibly even slower than 2 for the same reasons.\nGoals\nA good solution would involve:\n\nBuilding as much as possible in memory.\nOnce memory is full, dump everything to disk.\nIf bits are needed from disk again, recover them back into memory to add stuff to those vectors. \nGo back to 1 until all vectors are built.\n\nThe problem is that I'm not really sure how to go about this. It seems somewhat unpythonic to worry about system attributes such as RAM, but I don't see how this sort of problem can be optimally solved without taking this into account. As a result, I don't really know how to get started on this sort of thing.\nQuestion\nDoes anyone know how to go about solving this sort of problem? I python simply not the right language for this sort of thing? Or is there a simple solution to maximise how much is done from memory (within reason) while minimising how many times data must be read from the disk, or written to it?\nMany thanks for your attention. I look forward to seeing what the bright minds of stackoverflow can throw my way.\nAdditional Details\nThe sort of machine this problem is run on usually has 20+ cores and ~70G of RAM. The problem can be parallelised (\u00e0 la MapReduce) in that separate vectors for one entity can be built from segments of the corpus and then added to obtain the vector that would have been built from the whole corpus.\nPart of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","AnswerCount":11,"Available Count":4,"Score":0.0363476168,"is_accepted":false,"ViewCount":3167,"Q_Id":7381258,"Users Score":2,"Answer":"Two ideas:\n\nUse numpy arrays to represent vectors. They are much more memory-efficient, at the cost that they will force elements of the vector to be of the same type (all ints or all doubles...).\nDo multiple passes, each with a different set of vectors. That is, choose first 1M vectors and do only the calculations involving them (you said they are independent, so I assume this is viable). Then another pass over all the data with second 1M vectors.\n\nIt seems you're on the edge of what you can do with your hardware. It would help if you could describe what hardware (mostly, RAM) is available to you for this task. If there are 100k vectors, each of them with 1M ints, this gives ~370GB. If multiple passes method is viable and you've got a machine with 16GB RAM, then it is about ~25 passes -- should be easy to parallelize if you've got a cluster.","Q_Score":17,"Tags":"python,memory,io","A_Id":7381424,"CreationDate":"2011-09-11T21:08:00.000","Title":"Minimising reading from and writing to disk in Python for a memory-heavy operation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Background\nI am working on a fairly computationally intensive project for a computational linguistics project, but the problem I have is quite general and hence I expect that a solution would be interesting to others as well.\nRequirements\nThe key aspect of this particular program I must write is that it must: \n\nRead through a large corpus (between 5G and 30G, and potentially larger stuff down the line)\nProcess the data on each line.\nFrom this processed data, construct a large number of vectors (dimensionality of some of these vectors is > 4,000,000). Typically it is building hundreds of thousands of such vectors.\nThese vectors must all be saved to disk in some format or other.\n\nSteps 1 and 2 are not hard to do efficiently: just use generators and have a data-analysis pipeline. The big problem is operation 3 (and by connection 4)\nParenthesis: Technical Details\nIn case the actual procedure for building vectors affects the solution:\nFor each line in the corpus, one or more vectors must have its basis weights updated. \nIf you think of them in terms of python lists, each line, when processed, updates one or more lists (creating them if needed) by incrementing the values of these lists at one or more indices by a value (which may differ based on the index). \nVectors do not depend on each other, nor does it matter which order the corpus lines are read in.\nAttempted Solutions\nThere are three extrema when it comes to how to do this:\n\nI could build all the vectors in memory. Then write them to disk.\nI could build all the vectors directly on the disk, using shelf of pickle or some such library.\nI could build the vectors in memory one at a time and writing it to disk, passing through the corpus once per vector.\n\nAll these options are fairly intractable. 1 just uses up all the system memory, and it panics and slows to a crawl. 2 is way too slow as IO operations aren't fast. 3 is possibly even slower than 2 for the same reasons.\nGoals\nA good solution would involve:\n\nBuilding as much as possible in memory.\nOnce memory is full, dump everything to disk.\nIf bits are needed from disk again, recover them back into memory to add stuff to those vectors. \nGo back to 1 until all vectors are built.\n\nThe problem is that I'm not really sure how to go about this. It seems somewhat unpythonic to worry about system attributes such as RAM, but I don't see how this sort of problem can be optimally solved without taking this into account. As a result, I don't really know how to get started on this sort of thing.\nQuestion\nDoes anyone know how to go about solving this sort of problem? I python simply not the right language for this sort of thing? Or is there a simple solution to maximise how much is done from memory (within reason) while minimising how many times data must be read from the disk, or written to it?\nMany thanks for your attention. I look forward to seeing what the bright minds of stackoverflow can throw my way.\nAdditional Details\nThe sort of machine this problem is run on usually has 20+ cores and ~70G of RAM. The problem can be parallelised (\u00e0 la MapReduce) in that separate vectors for one entity can be built from segments of the corpus and then added to obtain the vector that would have been built from the whole corpus.\nPart of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","AnswerCount":11,"Available Count":4,"Score":0.0181798149,"is_accepted":false,"ViewCount":3167,"Q_Id":7381258,"Users Score":1,"Answer":"Use a database. That problem seems large enough that language choice (Python, Perl, Java, etc) won't make a difference. If each dimension of the vector is a column in the table, adding some indexes is probably a good idea. In any case this is a lot of data and won't process terribly quickly.","Q_Score":17,"Tags":"python,memory,io","A_Id":7381462,"CreationDate":"2011-09-11T21:08:00.000","Title":"Minimising reading from and writing to disk in Python for a memory-heavy operation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Background\nI am working on a fairly computationally intensive project for a computational linguistics project, but the problem I have is quite general and hence I expect that a solution would be interesting to others as well.\nRequirements\nThe key aspect of this particular program I must write is that it must: \n\nRead through a large corpus (between 5G and 30G, and potentially larger stuff down the line)\nProcess the data on each line.\nFrom this processed data, construct a large number of vectors (dimensionality of some of these vectors is > 4,000,000). Typically it is building hundreds of thousands of such vectors.\nThese vectors must all be saved to disk in some format or other.\n\nSteps 1 and 2 are not hard to do efficiently: just use generators and have a data-analysis pipeline. The big problem is operation 3 (and by connection 4)\nParenthesis: Technical Details\nIn case the actual procedure for building vectors affects the solution:\nFor each line in the corpus, one or more vectors must have its basis weights updated. \nIf you think of them in terms of python lists, each line, when processed, updates one or more lists (creating them if needed) by incrementing the values of these lists at one or more indices by a value (which may differ based on the index). \nVectors do not depend on each other, nor does it matter which order the corpus lines are read in.\nAttempted Solutions\nThere are three extrema when it comes to how to do this:\n\nI could build all the vectors in memory. Then write them to disk.\nI could build all the vectors directly on the disk, using shelf of pickle or some such library.\nI could build the vectors in memory one at a time and writing it to disk, passing through the corpus once per vector.\n\nAll these options are fairly intractable. 1 just uses up all the system memory, and it panics and slows to a crawl. 2 is way too slow as IO operations aren't fast. 3 is possibly even slower than 2 for the same reasons.\nGoals\nA good solution would involve:\n\nBuilding as much as possible in memory.\nOnce memory is full, dump everything to disk.\nIf bits are needed from disk again, recover them back into memory to add stuff to those vectors. \nGo back to 1 until all vectors are built.\n\nThe problem is that I'm not really sure how to go about this. It seems somewhat unpythonic to worry about system attributes such as RAM, but I don't see how this sort of problem can be optimally solved without taking this into account. As a result, I don't really know how to get started on this sort of thing.\nQuestion\nDoes anyone know how to go about solving this sort of problem? I python simply not the right language for this sort of thing? Or is there a simple solution to maximise how much is done from memory (within reason) while minimising how many times data must be read from the disk, or written to it?\nMany thanks for your attention. I look forward to seeing what the bright minds of stackoverflow can throw my way.\nAdditional Details\nThe sort of machine this problem is run on usually has 20+ cores and ~70G of RAM. The problem can be parallelised (\u00e0 la MapReduce) in that separate vectors for one entity can be built from segments of the corpus and then added to obtain the vector that would have been built from the whole corpus.\nPart of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","AnswerCount":11,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3167,"Q_Id":7381258,"Users Score":0,"Answer":"Split the corpus evenly in size between parallel jobs (one per core) - process in parallel, ignoring any incomplete line (or if you cannot tell if it is incomplete, ignore the first and last line of that each job processes).\nThat's the map part.\nUse one job to merge the 20+ sets of vectors from each of the earlier jobs - That's the reduce step.\nYou stand to loose information from 2*N lines where N is the number of parallel processes, but you gain by not adding complicated logic to try and capture these lines for processing.","Q_Score":17,"Tags":"python,memory,io","A_Id":7433853,"CreationDate":"2011-09-11T21:08:00.000","Title":"Minimising reading from and writing to disk in Python for a memory-heavy operation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Background\nI am working on a fairly computationally intensive project for a computational linguistics project, but the problem I have is quite general and hence I expect that a solution would be interesting to others as well.\nRequirements\nThe key aspect of this particular program I must write is that it must: \n\nRead through a large corpus (between 5G and 30G, and potentially larger stuff down the line)\nProcess the data on each line.\nFrom this processed data, construct a large number of vectors (dimensionality of some of these vectors is > 4,000,000). Typically it is building hundreds of thousands of such vectors.\nThese vectors must all be saved to disk in some format or other.\n\nSteps 1 and 2 are not hard to do efficiently: just use generators and have a data-analysis pipeline. The big problem is operation 3 (and by connection 4)\nParenthesis: Technical Details\nIn case the actual procedure for building vectors affects the solution:\nFor each line in the corpus, one or more vectors must have its basis weights updated. \nIf you think of them in terms of python lists, each line, when processed, updates one or more lists (creating them if needed) by incrementing the values of these lists at one or more indices by a value (which may differ based on the index). \nVectors do not depend on each other, nor does it matter which order the corpus lines are read in.\nAttempted Solutions\nThere are three extrema when it comes to how to do this:\n\nI could build all the vectors in memory. Then write them to disk.\nI could build all the vectors directly on the disk, using shelf of pickle or some such library.\nI could build the vectors in memory one at a time and writing it to disk, passing through the corpus once per vector.\n\nAll these options are fairly intractable. 1 just uses up all the system memory, and it panics and slows to a crawl. 2 is way too slow as IO operations aren't fast. 3 is possibly even slower than 2 for the same reasons.\nGoals\nA good solution would involve:\n\nBuilding as much as possible in memory.\nOnce memory is full, dump everything to disk.\nIf bits are needed from disk again, recover them back into memory to add stuff to those vectors. \nGo back to 1 until all vectors are built.\n\nThe problem is that I'm not really sure how to go about this. It seems somewhat unpythonic to worry about system attributes such as RAM, but I don't see how this sort of problem can be optimally solved without taking this into account. As a result, I don't really know how to get started on this sort of thing.\nQuestion\nDoes anyone know how to go about solving this sort of problem? I python simply not the right language for this sort of thing? Or is there a simple solution to maximise how much is done from memory (within reason) while minimising how many times data must be read from the disk, or written to it?\nMany thanks for your attention. I look forward to seeing what the bright minds of stackoverflow can throw my way.\nAdditional Details\nThe sort of machine this problem is run on usually has 20+ cores and ~70G of RAM. The problem can be parallelised (\u00e0 la MapReduce) in that separate vectors for one entity can be built from segments of the corpus and then added to obtain the vector that would have been built from the whole corpus.\nPart of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","AnswerCount":11,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3167,"Q_Id":7381258,"Users Score":0,"Answer":"From another comment I infer that your corpus fits into the memory, and you have some cores to throw at the problem, so I would try this:\n\nFind a method to have your corpus in memory. This might be a sort of ram disk with file system, or a database. No idea, which one is best for you. \nHave a smallish shell script monitor ram usage, and spawn every second another process of the following, as long as there is x memory left (or, if you want to make things a bit more complex, y I\/O bandwith to disk):\n\niterate through the corpus and build and write some vectors\n\nin the end you can collect and combine all vectors, if needed (this would be the reduce part)","Q_Score":17,"Tags":"python,memory,io","A_Id":7381527,"CreationDate":"2011-09-11T21:08:00.000","Title":"Minimising reading from and writing to disk in Python for a memory-heavy operation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"If I want the function name I can simply include %(funcName)s in the Formatter. But how do I get the name of the class containing the logging call instead?\nI've gone through the documentation for logging, but I can't find any mentioning of it.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":30677,"Q_Id":7385037,"Users Score":0,"Answer":"I personally just tend to name my loggers after classes, as it makes it much easier to track down where a particular message came from. So you can have a root logger named \"top\", and for the module \"a\" and class \"testclass\", I name my logger \"top.a.testclass\". \nI don't see the need to otherwise retrieve the classname, since the log message should give you all the information you need. \n@ed's response above, it feels very unpythonic to me and it is not something I would be comfortable with using on production code.","Q_Score":24,"Tags":"python,class,logging","A_Id":7389220,"CreationDate":"2011-09-12T08:18:00.000","Title":"How do I get the name of the class containing a logging call in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to figure out how i can have a 3 column layout where the (smaller) left and right columns are resizable with a draggable separator on each side of the center\/main area. I've tried using splitwindow but that seems to only split in two parts.\nHope someone can give me pointers on how it can be done.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":383,"Q_Id":7389417,"Users Score":0,"Answer":"I susggest that you create three panels, side by side.  When one of the panels is resized by the user, you will have to adjust the size of the other panels to compensate - so that there are no gaps or overlaps.  You can do this by handling the resize event, probably in the parent windows of the three panels.\nAnother way, which requires you to write less code, would be to use wxGrid with one row and three columns and zero width labels for columns and rows.  You will lose the flexibility of panels, but wxGrid will look after the resizing of the column widths for you.","Q_Score":0,"Tags":"python,user-interface,wxpython,wxwidgets","A_Id":7389557,"CreationDate":"2011-09-12T14:25:00.000","Title":"WxWidget\/WxPython; 3 column resizable layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I work in a python shell and some weeks ago I have defined a variable which refers to a very important list. The shell stays always open, but I have forgotten this name. How to get a list of all global names I have ever defined?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1597,"Q_Id":7390016,"Users Score":2,"Answer":"Don't you have readline enabled? You can look through your interpreter history to find what you want. I think it's easier than digging through globals() or dir().","Q_Score":3,"Tags":"python","A_Id":7390053,"CreationDate":"2011-09-12T15:08:00.000","Title":"Python - how to get a list of all global names I have ever defined?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I work in a python shell and some weeks ago I have defined a variable which refers to a very important list. The shell stays always open, but I have forgotten this name. How to get a list of all global names I have ever defined?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1597,"Q_Id":7390016,"Users Score":2,"Answer":"You can examine globals(), which shows all the module-level variables, or locals(), which is the local scope.  In the prompt, these are the same.  Also, vars() shows all the names available to you, no matter where you are.","Q_Score":3,"Tags":"python","A_Id":7390036,"CreationDate":"2011-09-12T15:08:00.000","Title":"Python - how to get a list of all global names I have ever defined?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am basically new to this kind of work.I am programming my application in C# in VS2010.I have a crystal report that is working fine and it basically gets populated with some xml data. That XMl data is coming from other application that is written in Python on  another machine.\nThat Python script generates some data and that data is put on the memory stream. I basically have to read that memory stream and write my xml which is used to populate my crystal report. So my supervisor wants me to use remote procedure call.\nI have never done any remote procedure calling. But as I have researched and understood. I majorly have to develop a web or WCF service I guess. I don't know how should I do it. We are planning to use the http protocol.\nSo, this is how it is supposed to work. I give them the url of my service and they would call that service and my service should try to read the data they put on the memory stream. After reading the data I should use part of the data to write my xml and this xml is used to populate my crystal report.\nThe other part of the data ( other than the data used to write the xml) should be sent to a database on the SQl server. This is my complete problem definition. I need ideas and links that will help me in solving this problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":779,"Q_Id":7392676,"Users Score":0,"Answer":"As John wrote, you're quite late if it's urgent and your description is quite vague. There are 1001 RPC techniques and the choice depends on details. But taking into account that you seem just to exchange some xml data, you probably don't need a full RPC implementation. You can write a HTTP server in python with just a few lines of code. If it needs to be a bit more stable and log running, have a look at twisted. Then just use pure html and the WebClient class. Not a perfect solution, but worked out quite well for me more than once. And you said it's urgent! ;-)","Q_Score":0,"Tags":"c#,python,web-services,rpc","A_Id":7392759,"CreationDate":"2011-09-12T19:05:00.000","Title":"Remote procedure call in C#","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"most of my job is on a citrix ICA app.\ni work in a winsows enviroment.\namong other things, i have to print 300 reports from my app weekly. i am trying to automate this task. i was using a screenshot automation tool called sikuli, but it is not portable form station to station. \ni thought i might be able to inject packets and send the commands on that level. i was not able to read the packets i captured with whireshark or do anythin sensable with them.\ni have expirence with python and if i get pointed in the right direction, i am pretty sure i can pull something off. \ndoes anyone have any ideas on how to do this (i am leaning towards packet injection aat the moment, but am open to ideas).\nthanks for the help,\nsam","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":978,"Q_Id":7398343,"Users Score":0,"Answer":"after a lot of research, it cant be done. some manipulation like change window focus with the ICA COM object.","Q_Score":0,"Tags":"python,automation,citrix,packet-injection","A_Id":10010649,"CreationDate":"2011-09-13T07:34:00.000","Title":"citrix GUI automation or packet injection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a sane\/safe filename (i.e. somewhat readable, no \"strange\" characters, etc.) from some random Unicode string (which might contain just anything).\n(It doesn't matter for me whether the function is Cocoa, ObjC, Python, etc.)\n\nOf course, there might be infinite many characters which might be strange. Thus, it is not really a solution to have a blacklist and to add more and more to that list over the time.\nI could have a whitelist. However, I don't really know how to define it. [a-zA-Z0-9 .] is a start but I also want to accept unicode chars which can be displayed in a normal way.","AnswerCount":13,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48106,"Q_Id":7406102,"Users Score":0,"Answer":"Extra note for all other answers\nAdd hash of original string to the end of filename. It will prevent conflicts\nin case your conversion makes same filename from different strings.","Q_Score":64,"Tags":"python,cocoa,filenames,pyobjc","A_Id":71761675,"CreationDate":"2011-09-13T17:40:00.000","Title":"Create (sane\/safe) filename from any (unsafe) string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I seem to be able to find information on how to do this in C#, but not on how to perform the same operation in Python.\nAny advice or suggestions would be appreciated. Thank you very much.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1453,"Q_Id":7408089,"Users Score":0,"Answer":"Use open with 'rb' as flags. That would read the file in binary mode","Q_Score":0,"Tags":"python,binary","A_Id":7408259,"CreationDate":"2011-09-13T20:30:00.000","Title":"In Python, how do I convert a .exe file to a string of 1s and 0s?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"What is a good way to call a function at datetime in Python?\nThere 3 ways that I know of:\n\n\"Are we there yet?!\" (check at if date has passed at interval (time.sleep(interval)))\nThis is obviously bad. It can only be precise if interval is low, which becomes inefficient.\nSleep off the difference (time.sleep(timedelta.seconds))\nThis is better, but I don't like the idea of putting a thread to sleep for an insanely long time, e.g. 6 months if such is the date.\nHybrid between the two above; sleep off the difference if difference is bellow interval. If above, sleep for an interval to prevent long sleeps.\nI think this is the best out of all three when you think about long sleeps, but interval seems bad anyway.\n\nAre there any more ways you can think of? Is there anything in standard library that can help me call a function at datetime behind the scene?\nEDIT:\nI'm asking this because I've actually developed my own Cron implementation in Python. The only problem is that I can't decide how my code should wait for next occurrence. One of the differences between my implementation and original Cron is support for seconds. So, simply sleeping for minimum possible interval (1 second in my case) is too inefficient.\nI realize now that this question could perhaps be changed to \"how does Cron do this?\" i.e. \"how does Cron check if any date has passed? Does it run constantly or is a process run each minute?\". I believe the latter is the case, which, again, is inefficient if interval is 1 second.\nAnother difference is that my code reads crontab once and calculates the exact date (datetime object) of next occurrence from the pattern. While Cron, I assume, simply checks each minute if any pattern from crontab matches current time.\nI'll stick to the \"hybrid\" way if there's no other way to do this.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":7412941,"Users Score":0,"Answer":"It might be a good idea to use a cron job.\nyou can edit the cron table with : crontab -e\nand add a line like this (called every 20 minutes)\n*\/20 * * * * \/usr\/bin\/python \/home\/toto\/my_script.py","Q_Score":0,"Tags":"python","A_Id":7414084,"CreationDate":"2011-09-14T07:51:00.000","Title":"Calling a function at datetime in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is a good way to call a function at datetime in Python?\nThere 3 ways that I know of:\n\n\"Are we there yet?!\" (check at if date has passed at interval (time.sleep(interval)))\nThis is obviously bad. It can only be precise if interval is low, which becomes inefficient.\nSleep off the difference (time.sleep(timedelta.seconds))\nThis is better, but I don't like the idea of putting a thread to sleep for an insanely long time, e.g. 6 months if such is the date.\nHybrid between the two above; sleep off the difference if difference is bellow interval. If above, sleep for an interval to prevent long sleeps.\nI think this is the best out of all three when you think about long sleeps, but interval seems bad anyway.\n\nAre there any more ways you can think of? Is there anything in standard library that can help me call a function at datetime behind the scene?\nEDIT:\nI'm asking this because I've actually developed my own Cron implementation in Python. The only problem is that I can't decide how my code should wait for next occurrence. One of the differences between my implementation and original Cron is support for seconds. So, simply sleeping for minimum possible interval (1 second in my case) is too inefficient.\nI realize now that this question could perhaps be changed to \"how does Cron do this?\" i.e. \"how does Cron check if any date has passed? Does it run constantly or is a process run each minute?\". I believe the latter is the case, which, again, is inefficient if interval is 1 second.\nAnother difference is that my code reads crontab once and calculates the exact date (datetime object) of next occurrence from the pattern. While Cron, I assume, simply checks each minute if any pattern from crontab matches current time.\nI'll stick to the \"hybrid\" way if there's no other way to do this.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":7412941,"Users Score":0,"Answer":"I use the gobject main loop, but any library with an event loop should have this ability.","Q_Score":0,"Tags":"python","A_Id":7413538,"CreationDate":"2011-09-14T07:51:00.000","Title":"Calling a function at datetime in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is a good way to call a function at datetime in Python?\nThere 3 ways that I know of:\n\n\"Are we there yet?!\" (check at if date has passed at interval (time.sleep(interval)))\nThis is obviously bad. It can only be precise if interval is low, which becomes inefficient.\nSleep off the difference (time.sleep(timedelta.seconds))\nThis is better, but I don't like the idea of putting a thread to sleep for an insanely long time, e.g. 6 months if such is the date.\nHybrid between the two above; sleep off the difference if difference is bellow interval. If above, sleep for an interval to prevent long sleeps.\nI think this is the best out of all three when you think about long sleeps, but interval seems bad anyway.\n\nAre there any more ways you can think of? Is there anything in standard library that can help me call a function at datetime behind the scene?\nEDIT:\nI'm asking this because I've actually developed my own Cron implementation in Python. The only problem is that I can't decide how my code should wait for next occurrence. One of the differences between my implementation and original Cron is support for seconds. So, simply sleeping for minimum possible interval (1 second in my case) is too inefficient.\nI realize now that this question could perhaps be changed to \"how does Cron do this?\" i.e. \"how does Cron check if any date has passed? Does it run constantly or is a process run each minute?\". I believe the latter is the case, which, again, is inefficient if interval is 1 second.\nAnother difference is that my code reads crontab once and calculates the exact date (datetime object) of next occurrence from the pattern. While Cron, I assume, simply checks each minute if any pattern from crontab matches current time.\nI'll stick to the \"hybrid\" way if there's no other way to do this.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":199,"Q_Id":7412941,"Users Score":1,"Answer":"If this is something that might be six months out like you said, a chron job is probably more suitable than keeping a python program running the whole time.","Q_Score":0,"Tags":"python","A_Id":7413202,"CreationDate":"2011-09-14T07:51:00.000","Title":"Calling a function at datetime in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to pyramid and paster, just reading the docs for now. I use virtualenv and inside the virtualenv dir I want to start a pyramid project. The problem is that I would like for paster to not create a dir with the project name, and instead put all the scaffold files on the current dir (the venv root).\nI thought about just not using paster but I still wouldn't know how to point to my app on development.ini \"use\" option.\nI could also have my virtualenv on an entirely different place of my filesystem, but that seems weird to me (maybe virtualenvwrapper could make it easier). Any other way to do this?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":286,"Q_Id":7421082,"Users Score":3,"Answer":"It is confusing at first but your code really doesn't need to be in your virtual environment directory at all. Actually it's better not to put your code inside your environment, as you might want to use different environments with the same code, for example to test your code with different versions of Python or different versions of a library.\nvirtualenvwrapper does put all your environments in a single place. virtualenvwrapper is a convenient tool on top of virtualenv but you don't need it to put your code and your environments in different places. Maybe you should get a bit more comfortable with virtualenv itself before starting to use virtualenvwrapper.\nYou should let paster create a directory with the project name. This is the directory that you will commit in version control (eg. git, mercurial...). You don't want to commit the directory containing the virtual environment.","Q_Score":0,"Tags":"python,pyramid,paster","A_Id":7421270,"CreationDate":"2011-09-14T18:20:00.000","Title":"How do I create a project without the project folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am about to build a new python lib and I was seeking information concerning packaging in Python.\nI understand that \"setup.py\" is the script that controls everything. I wonder how to deal with it when there are external libraries in svn for instance. \nHow to download automatically a given version from the repository using \"setup.py\" ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":742,"Q_Id":7434837,"Users Score":0,"Answer":"I may not have understood the problem correctly.\nFor any additional dependencies, you mention them in setup.py as\n\ninstall_requires=['module1 >= 1.3', 'module2 >=1.8.2']\n\nWhen you use setuptools, easy_install oo pip, these external dependencies will get installed during setup, if required. These should also be available in package repositories for download.","Q_Score":0,"Tags":"python,packaging,setup.py","A_Id":7435249,"CreationDate":"2011-09-15T17:12:00.000","Title":"setup.py and source control repository","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to code my own Python 3 http library to learn more about sockets and the Http protocol. My question is, if a do a recv(bytesToRead) using my socket, how can I get only the header and then with the Content-Length information, continue recieving the page content? Isn't that the purpose of the Content-Length header?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":739,"Q_Id":7437147,"Users Score":2,"Answer":"In the past to accomplish this, I will read a portion of the socket data into memory, and then read from that buffer until a \"\\r\\n\\r\\n\" sequence is encountered (you could use a state machine to do this or simply use the string.find() function.  Once you reach that sequence you know all of the headers have been read and you can do some parsing of the headers and then read the entire content length.  You may need to be prepared to read a response that does not include a content-length header since not all responses contain it.\nIf you run out of buffer before seeing that sequence, simply read more data from the socket into your buffer and continue processing.\nI can post a C# example if you would like to look at it.","Q_Score":0,"Tags":"python,http-headers","A_Id":7437186,"CreationDate":"2011-09-15T20:36:00.000","Title":"Http protocol, Content-Length, get page content Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How does one get (finds the location of) the dynamically imported modules from a python script ?\nso, python from my understanding can dynamically (at run time) load modules.\nBe it using _import_(module_name), or using the exec \"from x import y\", either using imp.find_module(\"module_name\") and then imp.load_module(param1, param2, param3, param4) .\nKnowing that I want to get all the dependencies for a python file. This would include getting (or at least I tried to) the dynamically loaded modules, those loaded either by using hard coded string objects or those returned by a function\/method. \nFor normal import module_name and from x import y you can do either a manual scanning of the code or use module_finder.\nSo if I want to copy one python script and all its dependencies (including the custom dynamically loaded modules) how should I do that ?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":303,"Q_Id":7441726,"Users Score":1,"Answer":"Just an idea and I'm not sure that it will work:\nYou could write a  module that contains a wrapper for __builtin__.__import__. This wrapper would save a reference to the old __import__and then assign a function to __builtin__.__import__ that does the following:\n\nwhenever called, get the current stacktrace and work out the calling function. Maybe the information in the globals parameter to __import__ is enough.\nget the module of that calling functions and store the name of this module and what will get imported\nredirect the call the real __import__\n\nAfter you have done this you can call your application with python -m magic_module yourapp.py. The magic module must store the information somewhere where you can retrieve it later.","Q_Score":2,"Tags":"python,module,loadmodule","A_Id":7442171,"CreationDate":"2011-09-16T07:57:00.000","Title":"how do you statically find dynamically loaded modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am able to find the name if the input file in a mapper class using FileSplit when writing the program in Java.\nIs there a corresponding way to do this when I write a program in Python (using streaming?)\nI found the following in the hadoop streaming document on apache:\n\nSee Configured Parameters. During the execution of a streaming job,\n  the names of the \"mapred\" parameters are transformed. The dots ( . )\n  become underscores ( _ ). For example, mapred.job.id becomes\n  mapred_job_id and mapred.jar becomes mapred_jar. In your code, use the\n  parameter names with the underscores.\n\nBut I still cant understand how to make use of this inside my mapper.\nAny help is highly appreciated.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9150,"Q_Id":7449756,"Users Score":0,"Answer":"The new ENV_VARIABLE for Hadoop 2.x is MAPREDUCE_MAP_INPUT_FILE","Q_Score":7,"Tags":"python,input,streaming,hadoop,filesplitting","A_Id":24434211,"CreationDate":"2011-09-16T19:59:00.000","Title":"Get input file name in streaming hadoop program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am able to find the name if the input file in a mapper class using FileSplit when writing the program in Java.\nIs there a corresponding way to do this when I write a program in Python (using streaming?)\nI found the following in the hadoop streaming document on apache:\n\nSee Configured Parameters. During the execution of a streaming job,\n  the names of the \"mapred\" parameters are transformed. The dots ( . )\n  become underscores ( _ ). For example, mapred.job.id becomes\n  mapred_job_id and mapred.jar becomes mapred_jar. In your code, use the\n  parameter names with the underscores.\n\nBut I still cant understand how to make use of this inside my mapper.\nAny help is highly appreciated.\nThanks","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":9150,"Q_Id":7449756,"Users Score":6,"Answer":"By parsing the mapreduce_map_input_file(new) or map_input_file(deprecated) environment variable, you will get the map input file name.  \nNotice:\nThe two environment variables are case-sensitive, all letters are lower-case.","Q_Score":7,"Tags":"python,input,streaming,hadoop,filesplitting","A_Id":24906345,"CreationDate":"2011-09-16T19:59:00.000","Title":"Get input file name in streaming hadoop program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install.\nI am using a mac osx\nI see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":2129,"Q_Id":7474887,"Users Score":1,"Answer":"I was having a problem with Netbeans 7 not starting. Netbeans had first errored out with no error message. Then it wouldn't start or give me an error. I looked in the .netbeans directory in my user directory, and found and attempted to delete the 'lock' file in that directory. When I first tried to delete it, it said it was in use. So with task manager, I had to go to processes tab and find netbeans. I killed that task, then was able to delete 'lock'. Then netbeans started.","Q_Score":1,"Tags":"python,macos,netbeans","A_Id":8114362,"CreationDate":"2011-09-19T17:31:00.000","Title":"Netbeans 7 not starting up after python plugin installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install.\nI am using a mac osx\nI see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":2129,"Q_Id":7474887,"Users Score":0,"Answer":"I have the same problem afther installing the python plguin. To solve this problem i deleted the file: org-openide-awt.jar from C:\\Users\\MYUSERNAME.netbeans\\7.0\\modules\nRegards!\nMart\u00edn.\nPD: I'm using Netbeans 7.0.1 anda Windows 7 64bit.","Q_Score":1,"Tags":"python,macos,netbeans","A_Id":19486580,"CreationDate":"2011-09-19T17:31:00.000","Title":"Netbeans 7 not starting up after python plugin installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install.\nI am using a mac osx\nI see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":2129,"Q_Id":7474887,"Users Score":1,"Answer":"I had the same issue. Netbeans would die before opening at all. I could not fix it, and had to revert back to 6.9.1.","Q_Score":1,"Tags":"python,macos,netbeans","A_Id":7478399,"CreationDate":"2011-09-19T17:31:00.000","Title":"Netbeans 7 not starting up after python plugin installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install.\nI am using a mac osx\nI see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":2129,"Q_Id":7474887,"Users Score":1,"Answer":"I had the same problem, but with Windows 7. I deleted the .netbeans directory located in my home folder. That fixed my problem, hope it fixes yours.","Q_Score":1,"Tags":"python,macos,netbeans","A_Id":8088729,"CreationDate":"2011-09-19T17:31:00.000","Title":"Netbeans 7 not starting up after python plugin installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install.\nI am using a mac osx\nI see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","AnswerCount":6,"Available Count":5,"Score":-0.0333209931,"is_accepted":false,"ViewCount":2129,"Q_Id":7474887,"Users Score":-1,"Answer":"I know I'm not answering your question directly, but I too was considering installing the Python plugin in Netbeans 7 but saw that it was still in Beta.  \nI use WingIDE from wingware for Python development.  I'm a Python newbie but I'm told by the pros that Wing is the best IDE for Python.  The \"101\" version is free and works very well.  The licensed versions include more options such as version control integration and Django features.","Q_Score":1,"Tags":"python,macos,netbeans","A_Id":7475990,"CreationDate":"2011-09-19T17:31:00.000","Title":"Netbeans 7 not starting up after python plugin installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how many python interpreter would be executed for distinct python apps?\nSay I have 6 different python apps up and running, so does that mean there are 6 different python interpreters are running for each of them?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":7482493,"Users Score":1,"Answer":"Assuming CPython, yes you have 'n' different interpreters running but (at least on operating systems like Windows, UNIX, and Linux) the interpreter code itself is shared.\nThe data areas (which includes your Python code, depending on the implementation)  will be unique to each process.  Any modules written in C that produce a .dll or .so (shared object) will also share the code areas between processes, but have their own data areas.","Q_Score":1,"Tags":"python,scripting","A_Id":7483796,"CreationDate":"2011-09-20T08:53:00.000","Title":"Python Apps and Python Interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how many python interpreter would be executed for distinct python apps?\nSay I have 6 different python apps up and running, so does that mean there are 6 different python interpreters are running for each of them?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":117,"Q_Id":7482493,"Users Score":1,"Answer":"Yes, each python script is launched by a separate python interpreter process. (unless your applications are in fact a single application multi threaded of course ;) )","Q_Score":1,"Tags":"python,scripting","A_Id":7482628,"CreationDate":"2011-09-20T08:53:00.000","Title":"Python Apps and Python Interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how many python interpreter would be executed for distinct python apps?\nSay I have 6 different python apps up and running, so does that mean there are 6 different python interpreters are running for each of them?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":7482493,"Users Score":5,"Answer":"when executing a python script, you have 1 interpreter running per process executing.\n\nif your application executes in a single process, you have 1 interpreter executing for each instance of your application. \nif your application launches multiple processes, then you get additional interpreters for each process launched.\nif your application uses threads, the interpreter is shared between the multiple threads which belong to the same process.","Q_Score":1,"Tags":"python,scripting","A_Id":7482633,"CreationDate":"2011-09-20T08:53:00.000","Title":"Python Apps and Python Interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i'm checking out pyglet, but, funny enough, i can't find how to do a simple button!\nso\n\nwhat is the standard way to create a standard button?\nis there a standard way to create a Message-Box? open\/save dialogs? \nor am i missing the point of pyglet? isn't it yet-another gui toolkit\nfor creating (also) forms, windows, buttons, texts, standard widgets, etc. ?\n\ni'm using Python 2.x on a windows PC if that matters.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6713,"Q_Id":7484924,"Users Score":3,"Answer":"I didn't use Pyglet yet, but is not a GUI library, it doesn't have to have widgets like buttons, or containers etc. It's a multimedia library like Pygame, it draws stuff on screen, plays sounds, and has some helper functions.\nIf you want to draw a button on screen, you should first draw a rectangle, print some text in it, and then listen mouse clicks to know if it's clicked on this rectangle.\nSee PyQT, PyGTK, WxPython for some examples of GUI libraries.","Q_Score":3,"Tags":"python,pyglet","A_Id":7485069,"CreationDate":"2011-09-20T12:11:00.000","Title":"where is the button widget in pyglet ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a directory for a django project on my localhost\n\/MyDjangoList\/\nIn this folder I have a django application called PK\nI downloaded django-registration and unzipped the folder into the \/MyDjangoList\/\nI went into terminal and went to the django-registration folder and ran\npython setup.py install.\nIt did a bunch of things then spit out the following:\nerror: could not create '\/usr\/local\/lib\/python2.7\/dist-packages\/registration': Permission denied\nThe Install file says I can just put it into the same folder as my project, so do I even need to install this? If so, how do I properly install it?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1876,"Q_Id":7491507,"Users Score":1,"Answer":"i'd also add that there is a set of default templates somewhere that make the usage of registration vastly easier. think they were on ubernostrums google code last time i needed them.","Q_Score":3,"Tags":"python,django","A_Id":7498096,"CreationDate":"2011-09-20T20:41:00.000","Title":"How do I properly install django registration on localhost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a directory for a django project on my localhost\n\/MyDjangoList\/\nIn this folder I have a django application called PK\nI downloaded django-registration and unzipped the folder into the \/MyDjangoList\/\nI went into terminal and went to the django-registration folder and ran\npython setup.py install.\nIt did a bunch of things then spit out the following:\nerror: could not create '\/usr\/local\/lib\/python2.7\/dist-packages\/registration': Permission denied\nThe Install file says I can just put it into the same folder as my project, so do I even need to install this? If so, how do I properly install it?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1876,"Q_Id":7491507,"Users Score":1,"Answer":"Do you need more permission? As in you need to do:  sudo python setup.py install","Q_Score":3,"Tags":"python,django","A_Id":7491553,"CreationDate":"2011-09-20T20:41:00.000","Title":"How do I properly install django registration on localhost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am  making some programs which includes while loops(to illustrate some number calculatings) and when I use Tkinter for GUI, the program windows is freezing until the loop finished. I want to add a stop button and I want the windows not to freeze. How can I do these two things?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1117,"Q_Id":7491777,"Users Score":3,"Answer":"You'll have to use separate threads or processes.  Tkinter uses a single thread to process display updates, and the same thread is used to do event callbacks.  If your event handler blocks then no Tkinter code will execute until it completes.\nIf you have the Tkinter thread (the one that calls Tk.mainloop) and another thread for the rest of your application, then the event handlers running within the Tkinter thread can simply pass messages (possibly using Queue.Queue) to your application event handler.","Q_Score":1,"Tags":"python,tkinter","A_Id":7491885,"CreationDate":"2011-09-20T21:06:00.000","Title":"Tkinter is freezing while the loop is processing, how can i prevent it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I make heavy use of virtualenv to isolate my development environments from the system-wide Python installation. Typical work-flow for using a virtualenv involves running source \/path\/to\/virtualenv\/bin\/activate to set the environment variables that Python requires to execute an isolated runtime. Making sure my Python executables use the current active virtualenv is as simple as setting the shebang to #!\/usr\/bin\/env python\nLately, though, I've been writing some C code that embeds the Python runtime. What I can't seem to figure out is how to get the embedded runtime to use the current active virtualenv. Anybody got a good example to share?","AnswerCount":6,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4477,"Q_Id":7492855,"Users Score":2,"Answer":"Seems to be not an answer, but still might be useful in other contexts.\n\nHave you tried running bin\/activate_this.py from your Python virtualenv? The comment in this file of my virtualenv reads:\n\nBy using execfile(this_file, dict(__file__=this_file)) you will\n  activate this virtualenv environment.\nThis can be used when you must use an existing Python interpreter, not\n  the virtualenv bin\/python\n\nYou should achieve the desired result if you execute the runtime equivalent of the above code.","Q_Score":15,"Tags":"python,virtualenv","A_Id":9071047,"CreationDate":"2011-09-20T23:07:00.000","Title":"Getting an embedded Python runtime to use the current active virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I make heavy use of virtualenv to isolate my development environments from the system-wide Python installation. Typical work-flow for using a virtualenv involves running source \/path\/to\/virtualenv\/bin\/activate to set the environment variables that Python requires to execute an isolated runtime. Making sure my Python executables use the current active virtualenv is as simple as setting the shebang to #!\/usr\/bin\/env python\nLately, though, I've been writing some C code that embeds the Python runtime. What I can't seem to figure out is how to get the embedded runtime to use the current active virtualenv. Anybody got a good example to share?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4477,"Q_Id":7492855,"Users Score":0,"Answer":"You can the check the environment variable VIRTUAL_ENV to get the current envs location.","Q_Score":15,"Tags":"python,virtualenv","A_Id":31758278,"CreationDate":"2011-09-20T23:07:00.000","Title":"Getting an embedded Python runtime to use the current active virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here is the code:\n\n 1 #!\/usr\/bin\/env python\n  2 \n  3 import re, os, sys, jira, subprocess\n  4 \n  5 class Check_jira:\n  6 \n  7     def verify_commit_text(self, tags):\n  8         for line in tags:\n  9             if re.match('^NO-TIK',line):\n 10                 return True\n 11             elif re.match('^NO-REVIEW', line):\n 12                 return True\n 13             elif re.match(r'[a-zA-Z]+-\\d+', line):\n 14                 # Validate the JIRA ID\n 15                 m = re.search(\"([a-zA-Z]+-\\d+)\",line)\n 16                 if m:\n 17                     my_args = m.group(1)\n 18                     result = Check_jira.CheckForJiraIssueRecord(my_args)\n 19                     if result == False:\n 20                         util.warn(\"%s does not exist\"%my_args)\n 21                     else:\n 22                         return True\n 23                 return True\n 24             else:\n 25                 return False\n 26 if __name__ == '__main__':\n 27     p = Check_jira()\n 28     commit_text_verified = p.verify_commit_text(os.popen('hg tip --template \"{desc}\"'))\n 29 \n 30     if (commit_text_verified):\n 31         sys.exit(0)\n 32     else:\n 33         print >> sys.stderr, ('[obey the rules!]')\n 34         sys.exit(1);\n 35     def CheckForJiraIssueRecord(object):\n 36    \n 37         sys.stdout = os.devnull\n 38         sys.stderr = os.devnull\n 39 \n 40    \n 41         try:\n 42             com = jira.Commands()\n 43             logger = jira.setupLogging()\n 44             jira_env = {'home':os.environ['HOME']}\n 45             command_cat= \"cat\"\n 46             command_logout= \"logout\"\n 47             #my_args = [\"QA-656\"]\n 48             server = \"http:\/\/jira.myserver.com:8080\/rpc\/soap\/jirasoapservice-v2?wsdl\"\n 49         except Exception, e:\n 50             sys.exit('config error')\n 51 \n 52 class Options:\n 53     pass\n 54 options = Options()\n 55 \n 56 options.user = 'user'\n 57 options.password = 'password'\n 58 \n 59 try:\n 60 \n 61     jira.soap = jira.Client(server)\n 62     jira.start_login(options, jira_env, command_cat, com, logger)\n 63     issue = com.run(command_cat, logger, jira_env, my_args)\n 64 except Exception, e:\n 65     print sys.exit('data error')\n\nso maybe:\n1. if name == 'main': shoudl be at the bottom ? \n2. So, i have 2 classes (Check_jira) and (Options)\n3. Check_jira has 2 functions verify_commit_text() and CheckForJiraIssueRecord()\n4. I pass object as an argument to CheckForJiraIssueRecord since i am passing my_args to it , on its usage.\n5. Not sure how to call one function from another function in the same class\n6. Error i am getting is :\n\nTraceback (most recent call last):\n  File \"\/home\/qa\/hook-test\/.hg\/check_jira.py\", line 31, in \n    commit_text_verified = p.verify_commit_text(os.popen('hg tip --template \"{desc}\"'))\n  File \"\/home\/qa\/hook-test\/.hg\/check_jira.py\", line 21, in verify_commit_text\n    result = Check_jira.CheckForJiraIssueRecord(my_args)\nAttributeError: class Check_jira has no attribute 'CheckForJiraIssueRecord'\ntransaction abort!\nrollback completed\nabort: pretxncommit.jira hook exited with status 1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1839,"Q_Id":7503149,"Users Score":1,"Answer":"class Check_jira ends on line 25 and has only one method. Then you have an if block, and CheckForJiraIssueRecord is just a function defined in this block (that is, the function is defined if __name__ == '__main__'.\nJust put the if block outside after the whole class definition.","Q_Score":0,"Tags":"python","A_Id":7503299,"CreationDate":"2011-09-21T16:18:00.000","Title":"Getting error: AttributeError: class  has no attribute ''","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm developing an web based application written in PHP5, which basically is an UI on top of a database. To give users a more flexible tool I want to embed a scripting language, so they can do more complex things like fire SQL queries, do loops and store data in variables and so on. In my business domain Python is widely used for scripting, but I'm also thinking of making a simple Domain Specific Language. The script has to wrap my existing PHP classes.\nI'm seeking advise on how to approach this development task? \nUpdate: I'll try scripting in the database using PLPGSQL in PostgreSQL. This will do for now, but I can't use my PHP classes this way. Lua approach is appealing and seems what is what I want (besides its not Python).","AnswerCount":6,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":570,"Q_Id":7528360,"Users Score":3,"Answer":"How about doing the scripting on the client. That will ensure maximum security and also save server resources.\nIn other words Javascript would be your scripting platform. What you do is expose the functionality of your backend as javascript functions. Depending on how your app is currently written that might require backend work or not.\nOh and by the way you are not limited to javascript for the actual language. Google \"compile to javascript\" and first hit should be a list of languages you can use.","Q_Score":11,"Tags":"php,python,dsl,plpgsql","A_Id":7660613,"CreationDate":"2011-09-23T11:36:00.000","Title":"Embed python\/dsl for scripting in an PHP web application","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing an web based application written in PHP5, which basically is an UI on top of a database. To give users a more flexible tool I want to embed a scripting language, so they can do more complex things like fire SQL queries, do loops and store data in variables and so on. In my business domain Python is widely used for scripting, but I'm also thinking of making a simple Domain Specific Language. The script has to wrap my existing PHP classes.\nI'm seeking advise on how to approach this development task? \nUpdate: I'll try scripting in the database using PLPGSQL in PostgreSQL. This will do for now, but I can't use my PHP classes this way. Lua approach is appealing and seems what is what I want (besides its not Python).","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":570,"Q_Id":7528360,"Users Score":0,"Answer":"You could do it without Python, by ie. parsing the user input for pre-defined \"tags\" and returning the result.","Q_Score":11,"Tags":"php,python,dsl,plpgsql","A_Id":7605372,"CreationDate":"2011-09-23T11:36:00.000","Title":"Embed python\/dsl for scripting in an PHP web application","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using xmpppy libary to write a XMPP IM robot.\nI want to act on disconnects, but I don't know how to detect disconnects. This could happen if your Jabber server crashes or if you have lost your internet connection.\nI found the callback, RegisterDisconnectHandler(self, DisconnectHandler), but it didn't work for the network failure, it only works when I explicitly call the method \"disconnect\". \nHow do I detect a network failure or server crash?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":392,"Q_Id":7536732,"Users Score":0,"Answer":"Did you try waiting 30 minutes after the network failure?  Depending on your network stack's settings, it could take this long to detect.  However, if you're not periodically sending on the socket, you may never detect the outage.  This is why many XMPP stacks periodically send a single space character, using an algorithm like:\n\nSet timer to N seconds\nOn sending a stanza, reset the timer to N\nWhen the timer fires, send a space.","Q_Score":0,"Tags":"python,xmpp,bots,xmpppy","A_Id":7558640,"CreationDate":"2011-09-24T03:08:00.000","Title":"A script im robot with xmpppy of python, how to detect network failure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just got started with ZMQ. I am designing an app whose workflow is:\n\none of many clients (who have random PULL addresses) PUSH a request to a server at 5555\nthe server is forever waiting for client PUSHes. When one comes, a worker process is spawned for that particular request. Yes, worker processes can exist concurrently.\nWhen that process completes it's task, it PUSHes the result to the client.\n\nI assume that the PUSH\/PULL architecture is suited for this. Please correct me on this.\n\nBut how do I handle these scenarios?\n\nthe client_receiver.recv() will wait for an infinite time when server fails to respond.\nthe client may send request, but it will fail immediately after, hence a worker process will remain stuck at server_sender.send() forever.\n\nSo how do I setup something like a timeout in the PUSH\/PULL model?\n\nEDIT: Thanks user938949's suggestions, I got a working answer and I am sharing it for posterity.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":82000,"Q_Id":7538988,"Users Score":10,"Answer":"The send wont block if you use ZMQ_NOBLOCK, but if you try closing the socket and context, this step would block the program from exiting..\nThe reason is that the socket waits for any peer so that the outgoing messages are ensured to get queued.. To close the socket immediately and flush the outgoing messages from the buffer, use ZMQ_LINGER and set it to 0..","Q_Score":77,"Tags":"python,zeromq","A_Id":10846438,"CreationDate":"2011-09-24T12:25:00.000","Title":"zeromq: how to prevent infinite wait?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am completely new to multiprocessing. I have been reading documentation about multiprocessing module. I read about Pool, Threads, Queues etc. but I am completely lost.\nWhat I want to do with multiprocessing is that, convert my humble http downloader, to work with multiple workers. What I am doing at the moment is, download a page, parse to page to get interesting links. Continue until all interesting links are downloaded. Now, I want to implement this with multiprocessing. But I have no idea at the moment, how to organize this work flow. I had two thoughts about this. Firstly, I thought about having two queues. One queue for links that needs to be downloaded, other for links to be parsed. One worker, downloads the pages, and adds them to queue which is for items that needs to be parsed. And other process parses a page, and adds the links it finds interesting to the other queue. Problems I expect from this approach are; first of all, why download one page at a time and parse a page at a time. Moreover, how do one process know that there are items to be added to queue later, after it exhausted all items from queue.\nAnother approach I thought about using is that. Have a function, that can be called with an url as an argument. This function downloads the document and starts parsing it for the links. Every time it encounters an interesting link, it instantly creates a new thread running identical function as itself. The problem I have with this approach is, how do I keep track of all the processes spawned all around, how do I know if there is still processes to running. And also, how do I limit maximum number of processes.\nSo I am completely lost. Can anyone suggest a good strategy, and perhaps show some example codes about how to go with the idea.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2128,"Q_Id":7541397,"Users Score":2,"Answer":"What you're describing is essentially graph traversal;  Most graph traversal algorithms (That are more sophisticated than depth first), keep track of two sets of nodes, in your case, the nodes are url's.\nThe first set is called the \"closed set\", and represents all of the nodes that have already been visited and processed.  If, while you're processing a page, you find a link that happens to be in the closed set, you can ignore it, it's already been handled.\nThe second set is unsurprisingly called the \"open set\", and includes all of the edges that have been found, but not yet processed.  \nThe basic mechanism is to start by putting the root node into the open set (the closed set is initially empty, no nodes have been processed yet), and start working.  Each worker takes a single node from the open set, copies it to the closed set, processes the node, and adds any nodes it discovers back to the open set (so long as they aren't already in either the open or closed sets).  Once the open set is empty, (and no workers are still processing nodes) the graph has been completely traversed.\nActually implementing this in multiprocessing probably means that you'll have a master task that keeps track of the open and closed sets;  If a worker in a worker pool indicates that it is ready for work, the master worker takes care of moving the node from the open set to the closed set and starting up the worker.  the workers can then pass all of the nodes they find, without worrying about if they are already closed, back to the master; and the master will ignore nodes that are already closed.","Q_Score":5,"Tags":"python,multithreading,multiprocessing","A_Id":7541787,"CreationDate":"2011-09-24T19:36:00.000","Title":"Which strategy to use with multiprocessing in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an 2-port signal relay connected to my computer via a USB serial interface. Using the pyserial module I can control these relays with ease. However, this is based on the assumption that I know beforehand which COM-port (or \/dev-node) the device is assigned to. \nFor the project I'm doing that's not enough since I don't want to assume that the device always gets assigned to for example COM7 in Windows. I need to be able to identify the device programatically across the possible platforms (Win, Linux, OSX (which I imagine would be similar to the Linux approach)), using python. Perhaps by, as the title suggests, enumerate USB-devices on the system and somehow get more friendly names for them. Windows and Linux being the most important platforms to support.\nAny help would be greatly appreciated!\nEDIT:\nSeems like the pyudev-module would be a good fit for Linux-systems. Has anyone had any experience with that?","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8806,"Q_Id":7551546,"Users Score":7,"Answer":"Regarding Linux, if all you need is to enumerate devices, you can even skip pyudev dependency for your project, and simply parse the output of \/sbin\/udevadm info --export-db command (does not require root privileges). It will dump all information about present devices and classes, including USB product IDs for USB devices, which should be more then enough to identify your USB-to-serial adapters. Of course, you can also do this with pyudev.","Q_Score":11,"Tags":"python,windows,linux,macos","A_Id":7552255,"CreationDate":"2011-09-26T06:53:00.000","Title":"Getting friendly device names in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an 2-port signal relay connected to my computer via a USB serial interface. Using the pyserial module I can control these relays with ease. However, this is based on the assumption that I know beforehand which COM-port (or \/dev-node) the device is assigned to. \nFor the project I'm doing that's not enough since I don't want to assume that the device always gets assigned to for example COM7 in Windows. I need to be able to identify the device programatically across the possible platforms (Win, Linux, OSX (which I imagine would be similar to the Linux approach)), using python. Perhaps by, as the title suggests, enumerate USB-devices on the system and somehow get more friendly names for them. Windows and Linux being the most important platforms to support.\nAny help would be greatly appreciated!\nEDIT:\nSeems like the pyudev-module would be a good fit for Linux-systems. Has anyone had any experience with that?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8806,"Q_Id":7551546,"Users Score":0,"Answer":"It will be great if this is possible, but in my experience with commercial equipments using COM ports this is not the case. Most of the times you need to set manually in the software the COM port. This is a mess, specially in windows (at least XP) that tends to change the number of the com ports in certain cases. In some equipment there is an autodiscovery feature in the software that sends a small message to every COM port and waits for the right answer. This of course only works if the instrument implements some kind of identification command. Good luck.","Q_Score":11,"Tags":"python,windows,linux,macos","A_Id":7552386,"CreationDate":"2011-09-26T06:53:00.000","Title":"Getting friendly device names in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm downloading files over HTTPS, I request the files through urllib2.Request and they come back as a socket._fileobject. I'd ideally like to stream this to file to avoid loading it into memory but I'm not sure how to do this.\nMy problem is if I call .read() on the object it only returns all the data up to the first NUL character and doesn't read the whole file. How can I solve this?\nThe NUL character comes down as \\x00 if that's any help, not sure what encoding that is","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":406,"Q_Id":7581963,"Users Score":1,"Answer":"I found out the problem was that I was running the code inside PyScripter and the in-built python interpreter terminates NUL bytes in the output. So there was no problem with my code, if I run it outside PyScripter everything works fine. Now running Wing IDE and never looking back :)","Q_Score":2,"Tags":"python,nul","A_Id":7791175,"CreationDate":"2011-09-28T10:42:00.000","Title":"read() stops after NUL character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Every time I restart the shell or run a script and instance of pythonw.exe*32 is created.  When I close out of IDLE these processes don't go away in the task manager.  Any ideas on how to fix this?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2421,"Q_Id":7592008,"Users Score":1,"Answer":"Have you tried using python.exe instead of pythonw.exe?\nIm pretty sure this is the intended default behavior for the window python interperter (pythonw.exe).\nIf its a .pyw file, just right click \"Open With...\" and use python.exe","Q_Score":2,"Tags":"python,process,python-idle","A_Id":7592072,"CreationDate":"2011-09-29T03:02:00.000","Title":"pythonw.exe processes not quitting after running script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using pyramid to create a web application. I am then using pyramid-beaker to interface beaker into pyramid's session management system. \nTwo values affect the duration of a user's session.\n\nThe session cookie timeout\nThe actual session's life time on either disk\/memcache\/rdbms\/etc\n\nI currently have to cookie defaulted (via the standard beaker config) to delete when the browser closes. I have the session data set to clear out after 2 hours. This works prefectly.\nWhat I need to know is how to override the cookie's timeout and the session timeout to both be 30 days or some other arbirtrary value.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2326,"Q_Id":7603674,"Users Score":2,"Answer":"Changing the timeout isn't supported by beaker. If you are trying to make a session stick around that long, you should probably just put it into a separate cookie. A common use-case is the \"remember me\" checkbox on login. This helps you track who the user is, but generally the actual session shouldn't be sticking around that long and gets recreated.","Q_Score":3,"Tags":"python,pyramid,beaker","A_Id":7608095,"CreationDate":"2011-09-29T21:36:00.000","Title":"How do I override the default session timeout with pyramid + pyramid-beaker + beaker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Problem\nI am writing a program that reads a set of documents from a corpus (each line is a document). Each document is processed using a function processdocument, assigned a unique ID, and then written to a database. Ideally, we want to do this using several processes. The logic is as follows:\n\nThe main routine creates a new database and sets up some tables.\nThe main routine sets up a group of processes\/threads that will run a worker function.\nThe main routine starts all the processes.\nThe main routine reads the corpus, adding documents to a queue.\nEach process's worker function loops, reading a document from a queue, extracting the information from it using processdocument, and writes the information to a new entry in a table in the database. \nThe worker loops breaks once the queue is empty and an appropriate flag has been set by the main routine (once there are no more documents to add to the queue).\n\nQuestion\nI'm relatively new to sqlalchemy (and databases in general). I think the code used for setting up the database in the main routine works fine, from what I can tell. Where I'm stuck is I'm not sure exactly what to put into the worker functions for each process to write to the database without clashing with the others. \nThere's nothing particularly complicated going on: each process gets a unique value to assign to an entry from a multiprocessing.Value object, protected by a Lock. I'm just not sure whether what I should be passing to the worker function (aside from the queue), if anything. Do I pass the sqlalchemy.Engine instance I created in the main routine? The Metadata instance? Do I create a new engine for each process? Is there some other canonical way of doing this? Is there something special I need to keep in mind?\nAdditional Comments\nI'm well aware I could just not bother with the multiprocessing but and do this in a single process, but I will have to write code that has several processes reading for the database later on, so I might as well figure out how to do this now.\nThanks in advance for your help!","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":1473,"Q_Id":7603790,"Users Score":5,"Answer":"The MetaData and its collection of Table objects should be considered a fixed, immutable structure of your application, not unlike your function and class definitions.  As you know with forking a child process, all of the module-level structures of your application remain present across process boundaries, and table defs are usually in this category.\nThe Engine however refers to a pool of DBAPI connections which are usually TCP\/IP connections and sometimes filehandles.  The DBAPI connections themselves are generally not portable over a subprocess boundary, so you would want to either create a new Engine for each subprocess, or use a non-pooled Engine, which means you're using NullPool.\nYou also should not be doing any kind of association of MetaData with Engine, that is \"bound\" metadata.  This practice, while prominent on various outdated tutorials and blog posts, is really not a general purpose thing and I try to de-emphasize this way of working as much as possible.\nIf you're using the ORM, a similar dichotomy of \"program structures\/active work\" exists, where your mapped classes of course are shared between all subprocesses, but you definitely want Session objects to be local to a particular subprocess - these correspond to an actual DBAPI connection as well as plenty of other mutable state which is best kept local to an operation.","Q_Score":1,"Tags":"python,database,multithreading,sqlalchemy,multiprocessing","A_Id":7603832,"CreationDate":"2011-09-29T21:50:00.000","Title":"How to use simple sqlalchemy calls while using thread\/multiprocessing","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've got a short python script that will eventually edit an input file, run an executable on that input file and read the output from the executable. The problem is, I've compiled the executable through msys, and can only seem to run it from the msys window. I'm wondering if the easiest way to do this is to somehow use os.command in Python to run msys and pipe a command in, or run a script through msys, but I haven't found a way to do this.\nHas anyone tried this before? How would you pipe a command into msys? Or is there a smarter way to do this that I haven't thought of?\nThanks in advance!\nEDIT: Just realized that this information might help, haha . . . . I'm running Windows, msys 1.0 and Python 2.7","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2618,"Q_Id":7613525,"Users Score":1,"Answer":"Find where in the msys path libgcc_s_dw2-1.dll is. \nFind the environmental variable in MSYS that has that path in it.\nAdd that environmental variable to Windows.","Q_Score":4,"Tags":"python,msys","A_Id":7613945,"CreationDate":"2011-09-30T16:47:00.000","Title":"How can I run a program in msys through Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an HTTP server which host some large file and have python clients (GUI apps) which download it.\nI want the clients to download the file only when needed, but have an up-to-date file on each run.\nI thought each client will download the file on each run using the If-Modified-Since HTTP header with the file time of the existing file, if any. Can someone suggest how to do it in python?\nCan someone suggest an alternative, easy, way to achieve my goal?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1447,"Q_Id":7623600,"Users Score":1,"Answer":"You can add a header called ETag, (hash of your file, md5sum or sha256 etc ), to compare if two files are different instead of last-modified date","Q_Score":3,"Tags":"python,http,httpclient,urllib2,if-modified-since","A_Id":7623988,"CreationDate":"2011-10-01T23:25:00.000","Title":"Sync local file with HTTP server location (in Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have an HTTP server which host some large file and have python clients (GUI apps) which download it.\nI want the clients to download the file only when needed, but have an up-to-date file on each run.\nI thought each client will download the file on each run using the If-Modified-Since HTTP header with the file time of the existing file, if any. Can someone suggest how to do it in python?\nCan someone suggest an alternative, easy, way to achieve my goal?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1447,"Q_Id":7623600,"Users Score":0,"Answer":"I'm assuming some things right now, BUT..\nOne solution would be to have a separate HTTP file on the server (check.php) which creates a hash\/checksum of each files you're hosting. If the files differ from the local files, then the client will download the file. This means that if the content of the file on the server changes, the client will notice the change since the checksum will differ.\ndo a MD5 hash of the file contents, put it in a database or something and check against it before downloading anything.\nYour solution would work to, but it requires the server to actually include the \"modified\" date in the Header for the GET request (some server softwares does not do this).\nI'd say putting up a database that looks something like:\n[ID]   [File_name]   [File_hash] \n0001   moo.txt       asd124kJKJhj124kjh12j","Q_Score":3,"Tags":"python,http,httpclient,urllib2,if-modified-since","A_Id":7623922,"CreationDate":"2011-10-01T23:25:00.000","Title":"Sync local file with HTTP server location (in Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using pydev for python development. I am facing issue while removing indentation for a block of statement. \nIf I have to add indentation I used to press SHIFT + down arrow key until I reach the end of block of statements which I want to indent and then press the TAB key.This is how i used to add indent for a block of statements in one step.\nThe issue now I am facing is to remove indent in one step for a block of statement.For example I have a for loop and i have a block of statement with in that for loop. Now I dont want to have the for loop any more and want to remove the indent underlying the for loop  statement block. At present I am going each line and press backspace to remove that indentation. Is there any easy way to do this for the entire statement block?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2441,"Q_Id":7623795,"Users Score":7,"Answer":"I don't know Pydev, but in most editors Shift+Tab will do the trick.","Q_Score":3,"Tags":"python,pydev","A_Id":7623803,"CreationDate":"2011-10-02T00:12:00.000","Title":"Removing indent in PYDEV","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using pydev for python development. I am facing issue while removing indentation for a block of statement. \nIf I have to add indentation I used to press SHIFT + down arrow key until I reach the end of block of statements which I want to indent and then press the TAB key.This is how i used to add indent for a block of statements in one step.\nThe issue now I am facing is to remove indent in one step for a block of statement.For example I have a for loop and i have a block of statement with in that for loop. Now I dont want to have the for loop any more and want to remove the indent underlying the for loop  statement block. At present I am going each line and press backspace to remove that indentation. Is there any easy way to do this for the entire statement block?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":2441,"Q_Id":7623795,"Users Score":2,"Answer":"From pydev.org, their page:\nBlock indent (and dedent)   Tab \/ Shift-Tab\nSmart indent (and dedent)   Enter \/ Backspace","Q_Score":3,"Tags":"python,pydev","A_Id":7626593,"CreationDate":"2011-10-02T00:12:00.000","Title":"Removing indent in PYDEV","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am testing a piece of hardware which hosts an ftp server. I connect to the server in order to configure the hardware in question.\nMy test environment is written in Python 3.\nTo start the ftp server, I need to launch a special proprietary terminal application on my pc. I must use this software as far as I know and I have no help files for it. I do however know how to use it to launch the ftp server and that's all I need it for.\nWhen I start this app, I go to the menu and open a dialog where I select the com port\/speed the hardware is connected to. I then enter the command to launch the ftp server in a console like window within the application. I am then prompted for the admin code for the hardware, which I enter. When I'm finished configuring the device, I issue a command to restart the hardware's software.\nIn order for me to fully automate my tests, I need to remove the manual starting of this ftp server for each test.\nAs far as I know, I have two options:\n\nWindows GUI automation\nSave the stream of data sent on the com port when using this application.\n\nI've tried to find an GUI automater but pywinauto isn't supporting Python 3. Any other options here which I should look at?\nAny suggestions on how I can monitor the com port in question and save the traffic on it? \nThanks,\nBarry","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1707,"Q_Id":7632642,"Users Score":0,"Answer":"I was also able to solve this using WScript, but pySerial was the preferred solution.","Q_Score":2,"Tags":"python,windows,python-3.x,serial-port,automated-tests","A_Id":7712917,"CreationDate":"2011-10-03T08:27:00.000","Title":"Control rs232 windows terminal program from python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a program of mine I have a database full of street name (using GIS stuff) in unicode. The user selects any part of the world he wants to see (using openstreetmap, google maps or whatever) and my program displays every streets selected using a nice font to show their names. As you may know not every font can display non latin characters... and it gives me headaches. I wonder how to tell my program \"if this word is written in chinese, then use a chinese font\".\nEDIT: I forgot to mention that I want to use non-standard fonts. Arial, Courier and some other can display non-latin words, but I want to use other fonts (I have a specific font for chinese, another one for japanese, another one for arabic...). I just have to know what font to chose depending of the word I want to write.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":210,"Q_Id":7638787,"Users Score":0,"Answer":"Use utf-8 text and a font that has glyphs for every possible character defined, like Arial\/Verdana in Windows. That bypasses the entire detection problem. One font will handle everything.","Q_Score":1,"Tags":"python,unicode,localization,fonts","A_Id":7638836,"CreationDate":"2011-10-03T17:59:00.000","Title":"How to detect the right font to use depending on the langage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a program of mine I have a database full of street name (using GIS stuff) in unicode. The user selects any part of the world he wants to see (using openstreetmap, google maps or whatever) and my program displays every streets selected using a nice font to show their names. As you may know not every font can display non latin characters... and it gives me headaches. I wonder how to tell my program \"if this word is written in chinese, then use a chinese font\".\nEDIT: I forgot to mention that I want to use non-standard fonts. Arial, Courier and some other can display non-latin words, but I want to use other fonts (I have a specific font for chinese, another one for japanese, another one for arabic...). I just have to know what font to chose depending of the word I want to write.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":210,"Q_Id":7638787,"Users Score":0,"Answer":"You need information about the language of the text.\nAnd when you decide what fonts you want, you do a mapping from language to font.\nIf you try to do it automatically, it does not work. The fonts for Japanese, Chinese Traditional, and Chinese Simplified look differently even for the same character. They might be inteligible, but a native would be able to tell (ok, complain) that the font is wrong.\nPlus, if you do anything algorithmically, there is no way to consider the estethic part (for instance the fact that you don't like Arial :-)","Q_Score":1,"Tags":"python,unicode,localization,fonts","A_Id":7684888,"CreationDate":"2011-10-03T17:59:00.000","Title":"How to detect the right font to use depending on the langage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"[This question is intended as a means to both capture my findings and sanity check them - I'll put up my answer toute suite and see what other answers and comments appear.]\nI spent a little time trying to get my head around the different social authentication options for (python) Appengine. I was particularly confused by how the authentication mechanisms provided by Google can interact with other social authentication mechanisms. The picture is complicated by the fact that Google has nice integration with third party OpenID providers but some of the biggest social networks are not OpenID providers (eg facebook, twitter). [Note that facebook can use OpenID as a relaying party, but not as a provider].\nThe question is then the following: what are the different options for social authentication in Appengine and what are the pros and cons of each?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":552,"Q_Id":7660059,"Users Score":11,"Answer":"In my research on this question I found that there are essentially three options:\n\nUse Google's authentication mechanisms (including their federated login via OpenID)\n\nPros:\n\nYou can easily check who is logged in via the Users service provided with Appengine\nGoogle handles the security so you can be quite sure it's well tested\n\nCons:\n\nThis can only integrate with third party OpenID providers; it cannot integrate with facebook\/twitter at this time\n\n\nUse the social authentication mechanisms provided by a known framework such as tipfy, or django\n\nPros:\n\nThese can integrate with all of the major social authentication services\nThey are quite widely used so they are likely to be quite robust and pretty well tested\n\nCons:\n\nWhile they are probably well tested, they may not be maintained\nThey do come as part of a larger framework which you may have to get comfortable with before deploying your app\n\n\nRoll your own social authentication\n\nPros:\n\nYou can do mix up whatever flavours of OpenID and OAuth tickles your fancy\n\nCons:\n\nYou are most likely to introduce security holes\nUnless you've a bit of experience working with these technologies, this is likely to be the most time consuming\n\n\n\nFurther notes:\n\nIt's probable that everyone will move to OpenID eventually and then the standard Google authentication should work everywhere\nThe first option allows you to point a finger at Google if there is a problem with their authentication; the second option imposes more responsibility on you, but still allows you to say that you use a widely used solution if there is a problem and the final option puts all the responsibility on you\nMost of the issues revolve around session management - in case 1, Google does all of the session management and it is pretty invisible to the developer; in case 2, the session management is handled by the framework and in the 3rd case, you've to devise your own.","Q_Score":6,"Tags":"python,google-app-engine,oauth,openid,facebook-authentication","A_Id":7662946,"CreationDate":"2011-10-05T10:42:00.000","Title":"What are the different options for social authentication on Appengine - how do they compare?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am coding a new python package to be used by others. To demonstrate how it should be used, I am writing a demo script that executes the main parts of the new package.\nWhat is the convention for doing this, so that other will find the script easily? Should it be  a separate module (by what name)? Should it be located in the package's root directory? Out of the package? In __init__.py?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":348,"Q_Id":7671348,"Users Score":3,"Answer":"I've never seen any real convention for this, but I personally put it in a main sentinel within __init__.py so that it can be invoked via python -m somepackage.","Q_Score":5,"Tags":"python,package,main,demo,convention","A_Id":7671369,"CreationDate":"2011-10-06T07:30:00.000","Title":"Where should I place a Python package's demo script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am coding a new python package to be used by others. To demonstrate how it should be used, I am writing a demo script that executes the main parts of the new package.\nWhat is the convention for doing this, so that other will find the script easily? Should it be  a separate module (by what name)? Should it be located in the package's root directory? Out of the package? In __init__.py?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":348,"Q_Id":7671348,"Users Score":4,"Answer":"Should it be a separate module (by what name)? \n\ndemo\/some_useful_name.py\nA demo directory contains demo scripts.  Similarly, a test directory contains all your unit tests.\n\nShould it be located in the package's root directory? \n\nNo.  It's not part of the package.  It's a demo.\n\nOut of the package?\n\nYes.\n\nIn init.py?\n\nNever.\n\nA package has two lives.  (1) as uninstalled source, (2) in the lib\/site-packages as installed code.\nThe \"source\" should include README, setup.py, demo directory, test directory, and the package itself.\nThe top-level \"source\" setup.py should install just the package.  The demo and test don't get installed.  They get left behind as part of the download.","Q_Score":5,"Tags":"python,package,main,demo,convention","A_Id":7672997,"CreationDate":"2011-10-06T07:30:00.000","Title":"Where should I place a Python package's demo script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to put a bunch of widgets into an MDIChildFrame , using wxpython, but i cant find much documentation on how to do so. has anyone created a child frame with alot going on it in so i can take a look at the source code? would be really Helpful \nCheers \nKemill","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":317,"Q_Id":7690324,"Users Score":0,"Answer":"The wxPython demo has a fairly complicated window in their MDI with SashWindows demo. However, I keep seeing on the wxPython mailing list that MDI in general isn't usually recommended anyway. If I were you, I'd look at wx.lib.agw.aui. It's a pure python implementation of AUI and fixes a lot of the bugs in wx.aui. I know it's not quite the same, but at least it gets active development.","Q_Score":0,"Tags":"wxpython,widget","A_Id":7691411,"CreationDate":"2011-10-07T16:47:00.000","Title":"Using wx.MDIChildFrame Widgets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I want to change the opacity or color of a gtk.IconView select box (I want actually to make the selection more visible).\nI noticed that the gtk.IconView widget had style properties selection-box-alpha & selection-box-color but only accessible for reading.\nThe set_select_function() method of the gtk.TreeSelection class would have been useful to do what I want but it's used for a gtk.TreeView and I haven't found an equivalent for gtk.IconView\nSo, how can I do to have control over the selection and perform an action when the user select or unselect stuff ?\nEdit :\nIn fact, change the values of selection-box-alpha and selection-box-color style properties wouldn't be a solution.\nI don't really want to change the selection box opacity but the \"opacity\" of the pixbuf (by compositing with a color).\nSo, I need an equivalent method of set_select_function for a gtk.IconView widget.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":735,"Q_Id":7698217,"Users Score":1,"Answer":"You might be able to set the pixmap opacity by implementing a custom gtk.CellRenderer that draws the pixmap according to the selection state, and replacing the gtk.IconView's default cell renderer with your own.","Q_Score":0,"Tags":"python,gtk,pygtk","A_Id":7705370,"CreationDate":"2011-10-08T16:32:00.000","Title":"How to get the control over the selection in a gtk.IconView?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on an application that is supposed to connect to IMAP account, read through emails and pick out emails sent by lets say \"Mark\", then it is supposed to respond to mark\nwith an automatic response such as \"Got it mate\" and then do the same tomorrow, with the only difference that tomorrow it should not respond to the same email. \nI am not sure how to achieve this the best way, I have thought of storing the processed IDs in a table, or record last check date. But I feel these are not the best CS solutions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":7712554,"Users Score":1,"Answer":"The UID is guaranteed to be unique. Store each one locally.","Q_Score":0,"Tags":"python,imap","A_Id":7793784,"CreationDate":"2011-10-10T12:12:00.000","Title":"Best way to earmark messages in an IMAP folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm using cygwin on windows 7 to run a bash script that activates a python script, and I am getting the following error:\nmyscript.script: \/cydrive\/c\/users\/mydrive\/folder\/myscript.py: usr\/bin\/env: bad interpreter: Permission Denied.\nI'm a total newbie to programming, so I've looked around a bit, and I think this means Python is mounted on a different directory that I don't have access to. However, based on what I found, I have tried to following things:\n\nChange something (from user to exec) in the fstab: however, my fstab file is all commented out and only mentions what the defaults are. I don't know how I can change the defaults. The fstab.d folder is empty.\nchange the #! usr\/bin\/env python line in the script to the actual location of Python: did not work, same error\nadd a PYTHONPATH to the environment variables of windows: same error.\n\nI would really appreciate it if someone could help me out with a suggestion!","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":33994,"Q_Id":7716357,"Users Score":1,"Answer":"This seems to be a late answer, but may be useful for others. I got the same kinda error, when I was trying to run a shell script which used python. Please check \\usr\\bin for existence of python. If not found, install that to solve the issue. I come to such a conclusion, as the error shows \"bad interpreter\".","Q_Score":10,"Tags":"python,permissions,cygwin","A_Id":16814809,"CreationDate":"2011-10-10T17:22:00.000","Title":"usr\/bin\/env: bad interpreter Permission Denied --> how to change the fstab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using cygwin on windows 7 to run a bash script that activates a python script, and I am getting the following error:\nmyscript.script: \/cydrive\/c\/users\/mydrive\/folder\/myscript.py: usr\/bin\/env: bad interpreter: Permission Denied.\nI'm a total newbie to programming, so I've looked around a bit, and I think this means Python is mounted on a different directory that I don't have access to. However, based on what I found, I have tried to following things:\n\nChange something (from user to exec) in the fstab: however, my fstab file is all commented out and only mentions what the defaults are. I don't know how I can change the defaults. The fstab.d folder is empty.\nchange the #! usr\/bin\/env python line in the script to the actual location of Python: did not work, same error\nadd a PYTHONPATH to the environment variables of windows: same error.\n\nI would really appreciate it if someone could help me out with a suggestion!","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":33994,"Q_Id":7716357,"Users Score":0,"Answer":"You should write your command as 'python .\/example.py ',then fix it in your script.","Q_Score":10,"Tags":"python,permissions,cygwin","A_Id":26632686,"CreationDate":"2011-10-10T17:22:00.000","Title":"usr\/bin\/env: bad interpreter Permission Denied --> how to change the fstab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Hello I am having problems with audio being sent over the network. On my local system with no distance there is no problems but whenever I test on a remote system there is audio but its not the voice input i want its choppy\/laggy etc. I believe its in how I am handling the sending of the audio but I have tried now for 4 days and can not find a solution.\nI will post all relevant code and try and explain it the best I can\nthese are the constant\/global values\n\n\n    #initilaize Speex\n    speex_enc = speex.Encoder()\n    speex_enc.initialize(speex.SPEEX_MODEID_WB)\n    speex_dec = speex.Decoder()\n    speex_dec.initialize(speex.SPEEX_MODEID_WB)\n\n    #some constant values\n    chunk = 320\n    FORMAT = pyaudio.paInt16\n    CHANNELS = 1\n    RATE = 44100\n\n\nI found adjusting the sample rate value would allow for more noise\nBelow is the pyAudio code to initialize the audio device this is also global\n\n\n    #initalize PyAudio\n    p = pyaudio.PyAudio()\n    stream = p.open(format = FORMAT,\n                    channels = CHANNELS,\n                    rate = RATE,\n                    input = True,\n                    output = True,\n                    frames_per_buffer = chunk)\n\n\nThis next function is the keypress function which writes the data from the mic and sends it using the client function This is where I believe I am having problems. \nI believe how I am handling this is the problem because if I press and hold to get audio it loops and sends on each iteration. I am not sure what to do here. (Ideas!!!)\n\n\n    def keypress(event):\n        #chunklist = []\n        #RECORD_SECONDS = 5\n        if event.keysym == 'Escape':\n            root.destroy()\n        #x = event.char\n        if event.keysym == 'Control_L':   \n            #for i in range(0, 44100 \/ chunk * RECORD_SECONDS):\n            try:\n                #get data from mic\n                data = stream.read(chunk)\n            except IOError as ex:\n                if ex[1] != pyaudio.paInputOverflowed:\n                    raise\n                data = '\\x00' * chunk\n            encdata = speex_enc.encode(data)        #Encode the data.\n            #chunklist.append(encdata)\n            #send audio\n            client(chr(CMD_AUDIO), encrypt_my_audio_message(encdata))\n\n\nThe server code to handle the audio\n\n\n    ### Server function ###\n    def server():\n        PORT = 9001\n        ### Initialize socket \n        server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n        server_socket.bind((socket.gethostbyname(socket.gethostname()), PORT))\n        # socket.gethostbyname(socket.gethostname())\n        server_socket.listen(5)\n        read_list = [server_socket]\n        ### Start receive loop\n        while True:\n            readable, writable, errored = select.select(read_list, [], [])\n            for s in readable:\n                if s is server_socket:\n                    conn, addr = s.accept()\n                    read_list.append(conn)\n                    print \"Connection from \", addr\n                else:\n                    msg = conn.recv(2048)\n                    if msg:                \n                        cmd, msg = ord(msg[0]),msg[1:]\n                        ## get a text message from GUI\n                        if cmd == CMD_MSG:\n                            listb1.insert(END, decrypt_my_message(msg).strip() + \"\\n\")\n                            listb1.yview(END)\n                        ## get an audio message\n                        elif cmd == CMD_AUDIO:\n                            # make sure length is 16 --- HACK ---\n                            if len(msg) % 16 != 0:\n                                msg += '\\x00' * (16 - len(msg) % 16)\n                            #decrypt audio\n                            data = decrypt_my_message(msg)\n                            decdata = speex_dec.decode(data)\n                            #Write the data back out to the speaker\n                            stream.write(decdata, chunk)\n                    else:\n                        s.close()\n                        read_list.remove(s)\n\n\nand for completion the binding of the keyboard in Tkinter\n\n\n    root.bind_all('', keypress)\n\n\nAny ideas are greatly appreciated how I can make that keypress method work as needed or suggest a better way or maybe I am doing something wrong altogether\n*cheers\nPlease note I have tested it without the encryption methods also and same thing :-)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2438,"Q_Id":7720932,"Users Score":0,"Answer":"Did you run ping or ttcp to test network performance between the 2 hosts?\nIf you have latency spikes or if some packets are dropped your approach to sending voice stream will suffer badly. TCP will wait for missing packet, report it being lost, wait for retransmit, etc.\nYou should be using UDP over lossy links and audio compression that handles missing packets gracefully. Also in this case you have to timestamp outgoing packets.","Q_Score":2,"Tags":"python,tcp,speex,pyaudio","A_Id":13102430,"CreationDate":"2011-10-11T02:55:00.000","Title":"Python Audio over Network Problems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to write a simple telned server that will expose a IPython shell to the connected client. Does someone know how to do that ?\nThe question is really about embedding the IPython shell into the Telnet server (I can probably use Twisted for the Telnet server part )\nThx","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":830,"Q_Id":7723399,"Users Score":0,"Answer":"I think it is not possible provide full functionality of IPython, such as auto complete,.. Twisted has python shell that works well with telnet.","Q_Score":1,"Tags":"python,ipython","A_Id":7723501,"CreationDate":"2011-10-11T08:43:00.000","Title":"Writing a telnet server in Python and embedding IPython as shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I rename the python interpreter from C:\\Python27\\python.exe to C:\\Python27\\python27.exe and run it, it will not complain.\nBut if I now try to run C:\\Python27\\Scripts\\ipython.exe, it will fail to start because now the python interpreter has a different filename.\nMy question is: how do I configure IPython (ms windows) to start up a python interpreter which has a different filename than python.exe?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":550,"Q_Id":7727017,"Users Score":0,"Answer":"Found a solution:\npython27.exe c:\\Python27\\Scripts\\ipython-script.py","Q_Score":0,"Tags":"python,windows,interpreter,ipython","A_Id":7820862,"CreationDate":"2011-10-11T13:42:00.000","Title":"Running IPython after changing the filename of python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I rename the python interpreter from C:\\Python27\\python.exe to C:\\Python27\\python27.exe and run it, it will not complain.\nBut if I now try to run C:\\Python27\\Scripts\\ipython.exe, it will fail to start because now the python interpreter has a different filename.\nMy question is: how do I configure IPython (ms windows) to start up a python interpreter which has a different filename than python.exe?","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":550,"Q_Id":7727017,"Users Score":1,"Answer":"Try to find Python in windows registry and changes path to python. After that try to reinstall ipython.","Q_Score":0,"Tags":"python,windows,interpreter,ipython","A_Id":7727342,"CreationDate":"2011-10-11T13:42:00.000","Title":"Running IPython after changing the filename of python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I rename the python interpreter from C:\\Python27\\python.exe to C:\\Python27\\python27.exe and run it, it will not complain.\nBut if I now try to run C:\\Python27\\Scripts\\ipython.exe, it will fail to start because now the python interpreter has a different filename.\nMy question is: how do I configure IPython (ms windows) to start up a python interpreter which has a different filename than python.exe?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":550,"Q_Id":7727017,"Users Score":0,"Answer":"I do not know if there is a config file where you can change, but you may have to recompile Ipython and change the interpreter variables. But why do you need to rename it to python27.exe when it already is in a python27 folder?","Q_Score":0,"Tags":"python,windows,interpreter,ipython","A_Id":7727120,"CreationDate":"2011-10-11T13:42:00.000","Title":"Running IPython after changing the filename of python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I rename the python interpreter from C:\\Python27\\python.exe to C:\\Python27\\python27.exe and run it, it will not complain.\nBut if I now try to run C:\\Python27\\Scripts\\ipython.exe, it will fail to start because now the python interpreter has a different filename.\nMy question is: how do I configure IPython (ms windows) to start up a python interpreter which has a different filename than python.exe?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":550,"Q_Id":7727017,"Users Score":0,"Answer":"instead of renaming python.exe, make sure the path to the python you want to run is before the path to other pythons","Q_Score":0,"Tags":"python,windows,interpreter,ipython","A_Id":7727290,"CreationDate":"2011-10-11T13:42:00.000","Title":"Running IPython after changing the filename of python.exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This has probably been asked before but I can't seem to find the answer. I've moved from windows to Linux and started using PyDev (Aptana) recently but what I cannot seem to find is how to find all references to a function.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10065,"Q_Id":7731324,"Users Score":42,"Answer":"Ctrl+Shift+G will find all the references to a function in PyDev (F3 will go to the definition of a function).","Q_Score":35,"Tags":"python,pydev","A_Id":7742529,"CreationDate":"2011-10-11T19:20:00.000","Title":"pydev: find all references to a function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wonder how I could create a image with a transparent background and only 2 indexed colours (red and blue) to minimise the file size?\nMore specifically I have two black and white images that I want to convert, one to transparent and blue and the other to transparent and red. Then I want to merge those 2 images. I could do that with a regular RGBA image, but I really want the colour to be indexed to minimise the file size.\nIdeally with PIL, but other Python library could also work.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6876,"Q_Id":7733364,"Users Score":1,"Answer":"Once you merge the two images, you won't have two colors any more - the colors will combine based on the transparency of each one at every pixel location. Worst case, you will have 256*256=65536 colors, which can't be indexed and wouldn't compress well if you did.\nI would suggest saving as a PNG and let the lossless compression do its best.","Q_Score":5,"Tags":"python,transparency,python-imaging-library,indexed-image","A_Id":7733515,"CreationDate":"2011-10-11T22:36:00.000","Title":"Python PIL: Create indexed color image with transparent background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I generate a uniformly distributed [-1,1]^d data in Python? E.g. d is a dimension like 10.\nI know how to generate uniformly distributed data like  np.random.randn(N) but dimension thing is confused me a lot.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":13886,"Q_Id":7733969,"Users Score":2,"Answer":"You can import the random module and call random.random to get a random sample from [0, 1). You can double that and subtract 1 to get a sample from [-1, 1). \nDraw d values this way and the tuple will be a uniform draw from the cube [-1, 1)^d.","Q_Score":7,"Tags":"python,numpy,machine-learning,scipy","A_Id":7734072,"CreationDate":"2011-10-12T00:15:00.000","Title":"Uniformly distributed data in d dimensions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to have a \"control panel\" on a website, and when a button is pressed, I want it to run a command on the server (my computer).  The panel is to run different python scripts I wrote (one script for each button), and I want to run the panel on my Mac, my iPod touch, and my wii.  The best way I see for this is a website, since they all have browsers.  Is there a javascript or something to run a command on my computer whenever the button is pressed? \nEDIT: I heard AJAX might work for server-based things like this, but I have no idea how to do that.  Is there like a 'system' block or something I can use?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":7747852,"Users Score":0,"Answer":"On the client side (the browser), you can do it with the simplest approach. Just an html form. javascript would make it nicer for validation and to do ajax calls so the page doesnt have to refresh. But your main focus is handling it on the server. You could receive the form request in the language of your choice. If you are already running python, you could write a super fast cgi python script. Look at the cgi module for python. You would need to put this into the apache server on osx if thats where you will host it. \nUnfortunately, your question about exactly how to write it is beyond the scope of a simple answer. But google for how to write and html form, or look at maybe jquery to build a quick form that can make ajax calls easily. \nThen search for how to use the python cgi module and receive POST requests.","Q_Score":0,"Tags":"javascript,python,macos,unix,controls","A_Id":7747962,"CreationDate":"2011-10-12T23:43:00.000","Title":"Running command with browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to have a \"control panel\" on a website, and when a button is pressed, I want it to run a command on the server (my computer).  The panel is to run different python scripts I wrote (one script for each button), and I want to run the panel on my Mac, my iPod touch, and my wii.  The best way I see for this is a website, since they all have browsers.  Is there a javascript or something to run a command on my computer whenever the button is pressed? \nEDIT: I heard AJAX might work for server-based things like this, but I have no idea how to do that.  Is there like a 'system' block or something I can use?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":7747852,"Users Score":0,"Answer":"Here are three options:\n\nHave each button submit a form with the name of the script in a hidden field.  The server will receive the form parameters and can then branch off to run the appropriate script.\nHave each button hooked to it's own unique URL and use javascript on the button click to just set window.location to that new URL.  Your server will receive that URL and can decide which script to run based on the URL.  You could even just use a link on the web page with no javascript.\nUse Ajax to issue a unique URL to your server.  This is essentially the same (from the server's point of view) as the previous two options.  The main difference is that the web browser doesn't change what URL it's pointing to.  The ajax call just directs the server to do something and return some data which the host web page can then do whatever it wants with.","Q_Score":0,"Tags":"javascript,python,macos,unix,controls","A_Id":7747896,"CreationDate":"2011-10-12T23:43:00.000","Title":"Running command with browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It's so convenient to use shell escape from interactive environment in ipython, but is it possible to call python script containing shell escape from ipython?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":7752532,"Users Score":1,"Answer":"If you give the script a .ipy extension, ipython's special syntax (like !ls) should work when you do ipython myscript.ipy.","Q_Score":1,"Tags":"python,ipython","A_Id":7754105,"CreationDate":"2011-10-13T10:09:00.000","Title":"how can i run a script containing shell escape from ipython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is os.getuid() which \"Returns the current process\u2019s user id.\". But how do I find out any given user's id?","AnswerCount":4,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":48007,"Q_Id":7770034,"Users Score":-5,"Answer":"You could just parse \/etc\/passwd, it's stored there.","Q_Score":34,"Tags":"python,linux","A_Id":7770065,"CreationDate":"2011-10-14T15:37:00.000","Title":"in Python and linux how to get given user's id","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to write an (GUI) application that listens both to keyboard events (client side generated events) and to a network port (server side generated events). I could use some high level advice on how to do this. Some additional info:\n- I am using the wxPython module for the GUI\n- I could set the socket in non-blocking mode, but this way I have to keep polling the socket by keeping executing the recv() command. I did this earlier and I can recall that this used considerable resources\n- I could use the thread module, but since I am not familiar with it, I try to avoid this, but maybe I can't\nAdvice would be appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":803,"Q_Id":7784969,"Users Score":0,"Answer":"I am not a wx expert. Could you use wx's native event driven mechanisms? The keypress would certainly have an event. Wx has a socket class wxSocketClient() that could translate the low level socket events (data ready, closed, etc) into a wx event.","Q_Score":1,"Tags":"python,wxpython","A_Id":7785429,"CreationDate":"2011-10-16T14:40:00.000","Title":"Listening to network event and keyboard input at the same time in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've decided to try and create a game before I finish studies. Searching around the net, I decided to create the basic game logic in python (for simplicity and quicker development time), and the actual I\/O engine in c# (for better performance. specifically, I'm using Mono with the SFML library). \nAfter coming to grips with both languages and IDEs, I've gotten stuck on integrating the two, which leads me to three questions (the most important one is the second):\na. which module should encapsulate the other? should the python game logic call the c# I\/O for input and then update it for output, or should it be the other way around?\nb. whatever the answer is, how can I do it? I haven't found any specific instructions on porting or integrating scripts or binaries in either language. \nc. Will the calls between modules be significantly harmful for performance? If they will, should I just develop everything in in one language?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":814,"Q_Id":7792013,"Users Score":2,"Answer":"Have you considered IronPython? It's trivial to integrate and since it's working directly with .net the integration works very well.","Q_Score":1,"Tags":"c#,python,mono","A_Id":7792073,"CreationDate":"2011-10-17T09:48:00.000","Title":"Integrating python and c#","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've decided to try and create a game before I finish studies. Searching around the net, I decided to create the basic game logic in python (for simplicity and quicker development time), and the actual I\/O engine in c# (for better performance. specifically, I'm using Mono with the SFML library). \nAfter coming to grips with both languages and IDEs, I've gotten stuck on integrating the two, which leads me to three questions (the most important one is the second):\na. which module should encapsulate the other? should the python game logic call the c# I\/O for input and then update it for output, or should it be the other way around?\nb. whatever the answer is, how can I do it? I haven't found any specific instructions on porting or integrating scripts or binaries in either language. \nc. Will the calls between modules be significantly harmful for performance? If they will, should I just develop everything in in one language?\nThanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":814,"Q_Id":7792013,"Users Score":2,"Answer":"Sincerely, I would say C# is today gives you a lot of goods from Python. To quote Jon Skeet:\n\nDo you know what I really like about dynamic languages such as Python, Ruby, and \n  Groovy? They suck away fluff from your code, leaving just the essence of it\u2014the bits \n  that really do something. Tedious formality gives way to features such as generators, \n  lambda expressions, and list comprehensions.\n  The interesting thing is that few of the features that tend to give dynamic lan-\n  guages their lightweight feel have anything to do with being dynamic. Some do, of \n  course\u2014duck typing, and some of the magic used in Active Record, for example\u2014 \n  but statically typed languages don't have to be clumsy and heavyweight.\n\nAnd you can have dynamic typing too. That's a new project, I would use just C# here.","Q_Score":1,"Tags":"c#,python,mono","A_Id":7792064,"CreationDate":"2011-10-17T09:48:00.000","Title":"Integrating python and c#","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to download a KML file and print a particular element of it as a string in Python. \nCould anyone give me an example of how to do this? \nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2981,"Q_Id":7821977,"Users Score":0,"Answer":"You can download the KML file in python using urllib. For reading KML, you can use a parser (search for \"kml python parser\").","Q_Score":1,"Tags":"python,kml","A_Id":7822039,"CreationDate":"2011-10-19T13:24:00.000","Title":"KML to string in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm very new to Python and I'm trying to write a sort of recipe organizer to get acquainted with the language.  Basically, I am unsure how how I should be storing the recipes.\nFor now, the information I want to store is: \n\nRecipe name\nIngredient names\nIngredient quantities\nPreparation\n\nI've been thinking about how to do this with the built-in sqlite3, but I know nothing about database architecture, and haven't been able to find a good reference.\nI suppose one table would contain recipe names and primary keys.  Preparation could be in a different table with the primary key as well.  Would each ingredient\/quantity pair need its own table.  \nIn other words, there would be a table for ingredientNumberOne, and each recipe's first ingredient, with the quantity, would go in there.  Then each time recipe comes along with more ingredients than there are tables, a new table would be created. \nAm I even correct in assuming that sqlite3 is sufficient for this task?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2639,"Q_Id":7827859,"Users Score":2,"Answer":"Just a general data modeling concept:  you never want to name anything \"...NumberOne\", \"...NumberTwo\".  Data models designed in this way are very difficult to query.  You'll ultimately need to visit each of N tables for 1 to N ingredients.  Also, each table in the model would ultimately have the same fields making maintenance a nightmare.  \nRather, just have one ingredient table that references the \"recipe\" table.  \nUltimately, I just realized this doesn't exactly answer the question, but you could implement this solution in Sqlite.  I just get worried when good developers start introducing bad patterns into the data model.  This comes from a guy who's been on both sides of the coin.","Q_Score":0,"Tags":"python,database,database-design","A_Id":7827955,"CreationDate":"2011-10-19T20:42:00.000","Title":"How to store recipe information with Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using a package and it is returning me an array. When I print the shape it is (38845,). Just wondering why this ','.\nI am wondering how to interpret this.\nThanks.","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":376,"Q_Id":7843786,"Users Score":3,"Answer":"It sounds like you're using Numpy. If so, the shape (38845,) means you have a 1-dimensional array, of size 38845.","Q_Score":0,"Tags":"python","A_Id":7843795,"CreationDate":"2011-10-21T00:24:00.000","Title":"How to intepret the shape of the array in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using a package and it is returning me an array. When I print the shape it is (38845,). Just wondering why this ','.\nI am wondering how to interpret this.\nThanks.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":376,"Q_Id":7843786,"Users Score":0,"Answer":"Just wondering why this ','.\n\nBecause (38845) is the same thing as 38845, but a tuple is expected here, not an int (since in general, your array could have multiple dimensions). (38845,) is a 1-tuple.","Q_Score":0,"Tags":"python","A_Id":7843917,"CreationDate":"2011-10-21T00:24:00.000","Title":"How to intepret the shape of the array in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using a package and it is returning me an array. When I print the shape it is (38845,). Just wondering why this ','.\nI am wondering how to interpret this.\nThanks.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":376,"Q_Id":7843786,"Users Score":8,"Answer":"Python has tuples, which are like lists but of fixed size. A two-element tuple is (a, b); a three-element one is (a, b, c). However, (a) is just a in parentheses. To represent a one-element tuple, Python uses a slightly odd syntax of (a,). So there is only one dimension, and you have a bunch of elements in that one dimension.","Q_Score":0,"Tags":"python","A_Id":7843805,"CreationDate":"2011-10-21T00:24:00.000","Title":"How to intepret the shape of the array in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using GeoDjango with PostGIS. Then I am into trouble on how to get the nearest record from the given coordinates from my postgres db table.","AnswerCount":6,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5401,"Q_Id":7846355,"Users Score":2,"Answer":"I have no experience with GeoDjango, but on PostgreSQL\/PostGIS you have the st_distance(..) function. So, you can order your results by st_distance(geom_column, your_coordinates) asc and see what are the nearest rows.\nIf you have plain coordinates (no postgis geometry), you can convert your coordinates to a point with the geometryFromText function.\nIs that what you were looking for? If not, try to be more explicit.","Q_Score":13,"Tags":"python,postgresql,postgis,geodjango","A_Id":7904142,"CreationDate":"2011-10-21T07:36:00.000","Title":"How can I query the nearest record in a given coordinates(latitude and longitude of string type)?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have windows xp, I have found some python libraries that only work for windows xp and thus if you have a mac os or linux or windows 7, you can't download my program because it won't work, how to make these libraries compatible with these OS, I can't ask the creator of the libraries so I have to download the source code and modify it, and i have to make it compatible on these OS using my xp :D well  my brother's pc is windows 7, but I don't have mac OS or linux (unless i can use VM)\nEDIT\nmy application is not simple","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":133,"Q_Id":7873170,"Users Score":1,"Answer":"You're asking a very general question. Perhaps overly general.\nGenerally, unless your application is relatively simple, it's impossible to guarantee that it is going to work on Linux and Mac OS X by only having Windows available. You will have to at least test it on Linux. Mac OS X is rather similar to Linux in many aspects, so you may get off the hook there, although for more complex cases it won't suffice. \nPython is not much different from other languages in this respect - it makes writing cross platform code easier, but it won't solve all your problems.\nLuckily, installing Linux on a VM is quick and free. Personally I use VirtualBox with a Ubuntu installation on top. It takes less than an hour to set up such a system from scratch (download Vbox, download an Ubuntu image and install it).","Q_Score":1,"Tags":"python","A_Id":7873222,"CreationDate":"2011-10-24T08:50:00.000","Title":"How to make python modules compatible with different OS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have windows xp, I have found some python libraries that only work for windows xp and thus if you have a mac os or linux or windows 7, you can't download my program because it won't work, how to make these libraries compatible with these OS, I can't ask the creator of the libraries so I have to download the source code and modify it, and i have to make it compatible on these OS using my xp :D well  my brother's pc is windows 7, but I don't have mac OS or linux (unless i can use VM)\nEDIT\nmy application is not simple","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":7873170,"Users Score":0,"Answer":"Your question is quite broad:\n1) Development and testing:\nUse VMs, absolutely, they are great for testing on OS you don't natively use, and to have a clean environment for testing (eg. test even windows stuff on a clean windows VM if you can, you might find out you're missing some dependencies that you took for granted on your dev machine).\n2) Actual library porting:\nDepending on the library this may or may not be difficult. Why is this library only working on windows? does it use specific DLLs, via ctypes or swig or some other bindings. If the library is python code (not a C library), is it tied to windows python APIs?\nThere are many things to take into account, if using system specific APIs\/libs, can they be faked on other OSs (write small abstraction over them), or does it require a lot more code. You get the gist.","Q_Score":1,"Tags":"python","A_Id":7873269,"CreationDate":"2011-10-24T08:50:00.000","Title":"How to make python modules compatible with different OS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When developing a Python plug-in (in C++), how does one go about setting\nthe documentation for __new__?  In particular, given a new type\ndefined by a PyTypeObject structure in the C++, how does one document\nthe arguments which can be passed to the constructor.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":7876250,"Users Score":0,"Answer":"Constructor arguments are usually documented in the type docstring, i.e. via the tp_doc slot, so you can do help(type) (or type? in IPython) instead of help(type.__new__) or help(type.__init__).","Q_Score":1,"Tags":"python","A_Id":7876369,"CreationDate":"2011-10-24T13:20:00.000","Title":"Generating constructor documentation for class defined in C++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how yield works. I know permutation, think it just as a math simplicity.\nBut what's yield's true force? When should I use it? A simple and good example is better.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":34825,"Q_Id":7883962,"Users Score":3,"Answer":"Another use is in a network client. Use 'yield' in a generator function to round-robin through multiple sockets without the complexity of threads.\nFor example, I had a hardware test client that needed to send a R,G,B planes of an image to firmware. The data needed to be sent in lockstep: red, green, blue, red, green, blue. Rather than spawn three threads, I had a generator that read from the file, encoded the buffer. Each buffer was a 'yield buf'. End of file, function returned and I had end-of-iteration.\nMy client code looped through the three generator functions, getting buffers until end-of-iteration.","Q_Score":43,"Tags":"python,yield","A_Id":7884098,"CreationDate":"2011-10-25T02:11:00.000","Title":"Where to use yield in Python best?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a form with \"subject\", \"body\" and \"file\" fields on some page on my Django site.\nIf \"subject\" and\/or \"body\" parameters exist in GET, I pre-fill them in the form from server side.\nI want to do the same with \"file\" field - more exactly, I want if there is an \"URL\" parameter in request.GET, take the file from this URL and pre-fill the \"file\" field with it.\nI've googled and still have no idea how to implement this whether with pure Javascript or with server-side help, and from my experience, it isn't possible (or at least hard to do) in most browsers due to input type=\"file\" nature.\nIs it in fact possible to implement it in some way?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":851,"Q_Id":7929014,"Users Score":1,"Answer":"Most sites that do something like this implement it with a second form where you attach the file. Doing the upload via ajax means you do need to store the file on your server for some amount of time, and then your original form just needs a reference to that file so you know when you're done with it.\nThen you just need to know when you can delete it.","Q_Score":0,"Tags":"javascript,python,django","A_Id":7929052,"CreationDate":"2011-10-28T12:06:00.000","Title":"Pre-fill a form with attached file taken from some URL in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a form with \"subject\", \"body\" and \"file\" fields on some page on my Django site.\nIf \"subject\" and\/or \"body\" parameters exist in GET, I pre-fill them in the form from server side.\nI want to do the same with \"file\" field - more exactly, I want if there is an \"URL\" parameter in request.GET, take the file from this URL and pre-fill the \"file\" field with it.\nI've googled and still have no idea how to implement this whether with pure Javascript or with server-side help, and from my experience, it isn't possible (or at least hard to do) in most browsers due to input type=\"file\" nature.\nIs it in fact possible to implement it in some way?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":851,"Q_Id":7929014,"Users Score":1,"Answer":"You can't pre-fill a file field. But I don't think you need to use one at all, since you're getting the file from a URL, not from the user's local machine. Just use a normal text field for the URL, and get the file server-side (eg using urllib) after the form is submitted.","Q_Score":0,"Tags":"javascript,python,django","A_Id":7929043,"CreationDate":"2011-10-28T12:06:00.000","Title":"Pre-fill a form with attached file taken from some URL in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need some help in implementing Multicast Streaming server over IPv6 preferably in Python. I am able to do so with Datagram servers but since I need to send large amounts of data (images and videos) over the connection, I get an error stating , data too large to send. \nCan any one tell me how do I implement a Streaming Socket with multicast that can both send and receive data?\nAlso, if there is a better way to do than Stream Sockets, please tell. \nThank You.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":570,"Q_Id":7937928,"Users Score":3,"Answer":"You DO want to use datagrams, as with multicast there are multiple receivers and a stream socket will not work.\nYou need to send your data in small chunks (datagrams) and state in each which part of the stream it is so receivers can detect lost (and reordered) datagrams.\nInstead of inventing a new mechanism for identifying the parts you are most likely better off encapsulating your data in RTP.\nIf you are going to stream video it might be worth looking into gstreamer which can do both sending and receiving RTP and has python bindings.","Q_Score":0,"Tags":"python,sockets,streaming,ipv6,multicast","A_Id":7939658,"CreationDate":"2011-10-29T09:04:00.000","Title":"How do I create a multicast stream socket over IPv6 in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm create a blog using django.\nI'm getting an 'operational error: FATAL: role \"[database user]\" does not exist.\nBut i have not created any database yet, all i have done is filled in the database details in setting.py.\nDo i have to create a database using psycopg2? If so, how do i do it? \nIs it:\npython\n\n\n\nimport psycopg2\n      psycopg2.connect(\"dbname=[name] user=[user]\")\n\n\n\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1391,"Q_Id":7941623,"Users Score":0,"Answer":"Generally, you would create the database externally before trying to hook it up with Django.\nIs this your private server?  If so, there are command-line tools you can use to set up a PostgreSQL user and create a database.\nIf it is a shared hosting situation, you would use CPanel or whatever utility your host provides to do this.  For example, when I had shared hosting, I was issued a database user and password by the hosting administrator.  Perhaps you were too.\nOnce you have this set up, there are places in your settings.py file to put your username and password credentials, and the name of the database.","Q_Score":0,"Tags":"python,database,django,psycopg2","A_Id":7942855,"CreationDate":"2011-10-29T20:52:00.000","Title":"how do i create a database in psycopg2 and do i need to?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm create a blog using django.\nI'm getting an 'operational error: FATAL: role \"[database user]\" does not exist.\nBut i have not created any database yet, all i have done is filled in the database details in setting.py.\nDo i have to create a database using psycopg2? If so, how do i do it? \nIs it:\npython\n\n\n\nimport psycopg2\n      psycopg2.connect(\"dbname=[name] user=[user]\")\n\n\n\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1391,"Q_Id":7941623,"Users Score":0,"Answer":"before connecting to database, you need to create database, add user,  setup access for user you selected. \nReffer to installation\/configuration guides for Postgres.","Q_Score":0,"Tags":"python,database,django,psycopg2","A_Id":7941712,"CreationDate":"2011-10-29T20:52:00.000","Title":"how do i create a database in psycopg2 and do i need to?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to use feedparser to retrieve some specific information from feeds, but also retrieve the raw XML of each entry (ie.  elements for RSS and  for Atom), and I can't see how to do that. Obviously I could parse the XML by hand, but that's not very elegant, would require separate support for RSS and Atom, and I imagine it could fall out of sync with feedparser for ill-formed feeds. Is there a better way?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1115,"Q_Id":7945669,"Users Score":2,"Answer":"I'm the current developer of feedparser. Currently, one of the ways you can get that information is to monkeypatch feedparser._FeedParserMixin (or edit a local copy of feedparser.py). The methods you'll want to modify are:\n\nfeedparser._FeedParserMixin.unknown_starttag\nfeedparser._FeedParserMixin.unknown_endtag\n\nAt the top of each method you can insert a callback to a routine of your own that will capture the elements and their attributes as they're encountered by feedparser.","Q_Score":2,"Tags":"python,xml,rss,atom-feed,feedparser","A_Id":8021162,"CreationDate":"2011-10-30T15:06:00.000","Title":"Retrieving raw XML for items with feedparser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"How can I add steps to a waiting Amazon EMR job flow using boto without the job flow terminating once complete?\nI've created an interactive job flow on Amazon's Elastic Map Reduce and loaded some tables. When I pass in new steps to the job flow using Boto's emr_conn.add_jobflow_steps(...), the job flow terminates after it finishes or fails. \nI know I can start a job flow with boto using run_jobflow with the keep_alive parameter -- but I'd like to work with flows that are already running.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2242,"Q_Id":7960578,"Users Score":3,"Answer":"If it finishes correctly, it should not terminate with keep_alive=True.  That said, it would normally exit on failure, so you want to add terminate_on_failure=\"CONTINUE\" to your add_job_steps arguments.","Q_Score":2,"Tags":"python,boto,amazon-emr","A_Id":9055033,"CreationDate":"2011-10-31T22:33:00.000","Title":"Boto: how to keep EMR job flow running after completion\/failure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Qt4 Designer and I want that when I click on the \"yes\" button, some code will execute. And when I click on the \"no\", some other code will be execute. How can I do it?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":38462,"Q_Id":7964869,"Users Score":7,"Answer":"Right-click on your widget\nSelect \"Go to slot...\"\nSelect a signal and click OK\n\nYour custom slot declaration and definition for that signal will be added to *.cpp and *.h files. Its name will be generated automatically.\nupd:\nSorry, I didn't notice that the question is about Python & QtDesigner itself, I was thinking of the designer mode in QtCreator IDE. However, this still may be useful for someone who is looking for Qt\/C++ info, so I leave the answer.","Q_Score":22,"Tags":"python,qt4,qt-designer","A_Id":34307822,"CreationDate":"2011-11-01T09:59:00.000","Title":"Qt Designer: how to add custom slot and code to a button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Qt4 Designer and I want that when I click on the \"yes\" button, some code will execute. And when I click on the \"no\", some other code will be execute. How can I do it?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":38462,"Q_Id":7964869,"Users Score":45,"Answer":"Click on the Edit Signal\/Slots tool.\nCreate a connection for your button. For this, select your button in the designer by pressing on it with the left button of the mouse. Move the mouse to some place in the main window to create a connection with the main window (it is like a red line with a earth connection).\nWhen you release the mouse button, the Configure Connection dialog appears.\nIn this dialog select a signal in the left text control (the sender), for example, pressed().\nThen press edit in the right text control (the receiver). A dialog for the Signals\/Slots of MainWindow appears.\nIn the slot panel add a new slot (green cross). The text slot1() appears. Double click on it to edit the line and write instead the name of your function doit_when_yes_ispressed(). Accept.\nNow in the Configure Connection dialog you will see your function in the right text control. Select and Accept.\nIn the designer now you can see the signal and your function in the widget.","Q_Score":22,"Tags":"python,qt4,qt-designer","A_Id":7965081,"CreationDate":"2011-11-01T09:59:00.000","Title":"Qt Designer: how to add custom slot and code to a button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Other empty objects in Python evaluate as False -- how can I get iterators\/generators to do so as well?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5257,"Q_Id":7976269,"Users Score":9,"Answer":"Guido doesn't want generators and iterators to behave that way.\nObjects are true by default.  They can be false only if they define __len__ that returns zero or __nonzero__ that returns False (the latter is called __bool__ in Py3.x).\nYou can add one of those methods to a custom iterator, but it doesn't match Guido's intent.  He rejected adding __len__ to iterators where the upcoming length is known.  That is how we got __length_hint__ instead.\nSo, the only way to tell if an iterator is empty is to call next() on it and see if it raises StopIteration.  \nOn ASPN, I believe there are some recipes using this technique for lookahead wrapper.  If a value is fetched, it is saved-up the an upcoming next() call.","Q_Score":16,"Tags":"python,iterator,boolean,generator","A_Id":7976309,"CreationDate":"2011-11-02T05:40:00.000","Title":"How can I get generators\/iterators to evaluate as False when exhausted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to determine the most popular keywords for certain class of documents in my collection. Assuming that the domain is \"computer science\" (which of course, includes networking, computer architecture, etc.) what is the best way to preserve these domain-specific keywords from text? I tried using Wordnet but I am not quite how to best use it to extract this information.\nAre there any well-known list of words that I can use as a whitelist considering the fact that I am not aware of all domain-specific keywords beforehand? Or are there any good nlp\/machine learning techniques to identity domain specific keywords?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1008,"Q_Id":7986900,"Users Score":6,"Answer":"You need a huge training set of documents. Small subset of this collection (but still large set of documents) should represent given domain. Using nltk calculate words statistics taking into account morphology, filter out stopwords. The good statistics is TF*IDF which is roughly a number of occurenses of a word in the domain subset divided by number of documents containing the word in a whole collection. Keywords are words with greatest TF*IDF.","Q_Score":5,"Tags":"python,nlp,machine-learning,nltk","A_Id":7987856,"CreationDate":"2011-11-02T20:27:00.000","Title":"Preserving only domain-specific keywords?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I am using the pydev remote debugger feature for my application.\nWhen I try to stop the debugger server via the stop button it shows on the console that the server is successfully terminated but it isn't because it is still accepting new connections on its default port (5678).\nDo you know how can I stop the server in a reliable way?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":525,"Q_Id":7988856,"Users Score":0,"Answer":"This was a bug -- and it was fixed in the latest version (PyDev 2.2.4), so, please upgrade to the latest version and that should be working already.","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":7993203,"CreationDate":"2011-11-03T00:02:00.000","Title":"How can I stop the debugger server from pydev?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to write a hook for Mercurial to do the following, an am struggling to get going.:\n\nRun on central repo, and execute when changeset(s) are pushed (I think I should use the \"input\" or \"changegroup\" hook)\nSearch each commit message for a string with the format \"issue:[0-9]*\"\nIF string found, call a webservice, and provide the issue number, commit message, and a list of files that were changed\n\nSo, just for starters, how can I get the commit message for each commit from the \"input\" or \"changegroup\" hook? Any advice beyond this on how to achieve the other points would also be appeciated.\nThanks for any help.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":817,"Q_Id":8000280,"Users Score":2,"Answer":"changegroup hook is called once per push. If you want to analyse each changeset, then you want incoming hook (there's no input hook AFAIK) \u2014 it'll be called for each changeset, with ID in HG_NODE environment variable. You can get the commit message with e.g. hg log -r $HG_NODE --template '{desc}' or via the API.","Q_Score":2,"Tags":"python,mercurial,hook,mercurial-hook","A_Id":8000347,"CreationDate":"2011-11-03T18:47:00.000","Title":"How to access commit message from Mercurial Input or Changeset hook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you are in the middle of a TDD iteration, how do you know which tests fail because the existing code is genuinely incorrect and which fail because either the test itself or the features haven't been implemented yet?  Please don't say, \"you just don't care, because you have to fix both.\"  I'm ready to move past that mindset.\nMy general practice for writing tests is as follows:\n\nFirst, I architect the general structure of the test suite, in whole or in part.  That is - I go through and write only the names of tests, reminding me of the features that I intend to implement.  I typically (at least in python) simply start with each testing having only one line: self.fail().  This way, I can ride a stream of consciousness through listing every feature I think I will want to test - say, 11 tests at a time.\nSecond, I pick one test and actually write the test logic.\nThird, I run the test runner and see 11 failures - 10 that simply self.fail() and 1 that is a genuine AssertionError.\nFourth, I write the code that causes my test to pass.\nFifth, I run the test runner and see 1 pass and 10 failures.\nSixth, I go to step 2.\n\nIdeally, instead of seeing tests in terms of passes, failures, and exceptions, I'd like to have a fourth possibility: NotImplemented.\nWhat's the best practice here?","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":1102,"Q_Id":8017514,"Users Score":2,"Answer":"I use a piece of paper to create a test list (scratchpad to keep track of tests so that I don't miss out on them). I hope you're not writing all the failing tests at one go (because that can cause some amount of thrashing as new knowledge comes in with each Red-Green-Refactor cycle).\nTo mark a test as TO-DO or Not implemented, you could also mark the test with the equivalent of a [Ignore(\"PENDING\")] or [Ignore(\"TODO\")]. NUnit for example would so such tests as yellow instead of failed. So Red implies test failure, Yellow implies TODO.","Q_Score":2,"Tags":"python,tdd","A_Id":8017802,"CreationDate":"2011-11-05T01:28:00.000","Title":"TDD practice: Distinguishing between genuine failures and unimplemented features","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you are in the middle of a TDD iteration, how do you know which tests fail because the existing code is genuinely incorrect and which fail because either the test itself or the features haven't been implemented yet?  Please don't say, \"you just don't care, because you have to fix both.\"  I'm ready to move past that mindset.\nMy general practice for writing tests is as follows:\n\nFirst, I architect the general structure of the test suite, in whole or in part.  That is - I go through and write only the names of tests, reminding me of the features that I intend to implement.  I typically (at least in python) simply start with each testing having only one line: self.fail().  This way, I can ride a stream of consciousness through listing every feature I think I will want to test - say, 11 tests at a time.\nSecond, I pick one test and actually write the test logic.\nThird, I run the test runner and see 11 failures - 10 that simply self.fail() and 1 that is a genuine AssertionError.\nFourth, I write the code that causes my test to pass.\nFifth, I run the test runner and see 1 pass and 10 failures.\nSixth, I go to step 2.\n\nIdeally, instead of seeing tests in terms of passes, failures, and exceptions, I'd like to have a fourth possibility: NotImplemented.\nWhat's the best practice here?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1102,"Q_Id":8017514,"Users Score":1,"Answer":"Most projects would have a hierarchy (e.g. project->package->module->class) and if you can selectively run tests for any item on any of the levels or if your report covers these parts in detail you can see the statuses quite clearly. Most of the time, when an entire package or class fails, it's because it hasn't been implemented.\nAlso, In many test frameworks you can disable individual test cases by removing annotation\/decoration from or renaming a method\/function that performs a test. This has the disadvantage of not showing you the implementation progress, though if you decide on a fixed and specific prefix you can probably grep that info out of your test source tree quite easily.\nHaving said that, I would welcome a test framework that does make this distinction and has NOT_IMPLEMENTED in addition to the more standard test case status codes like PASS, WARNING and FAILED. I guess some might have it.","Q_Score":2,"Tags":"python,tdd","A_Id":8017731,"CreationDate":"2011-11-05T01:28:00.000","Title":"TDD practice: Distinguishing between genuine failures and unimplemented features","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you are in the middle of a TDD iteration, how do you know which tests fail because the existing code is genuinely incorrect and which fail because either the test itself or the features haven't been implemented yet?  Please don't say, \"you just don't care, because you have to fix both.\"  I'm ready to move past that mindset.\nMy general practice for writing tests is as follows:\n\nFirst, I architect the general structure of the test suite, in whole or in part.  That is - I go through and write only the names of tests, reminding me of the features that I intend to implement.  I typically (at least in python) simply start with each testing having only one line: self.fail().  This way, I can ride a stream of consciousness through listing every feature I think I will want to test - say, 11 tests at a time.\nSecond, I pick one test and actually write the test logic.\nThird, I run the test runner and see 11 failures - 10 that simply self.fail() and 1 that is a genuine AssertionError.\nFourth, I write the code that causes my test to pass.\nFifth, I run the test runner and see 1 pass and 10 failures.\nSixth, I go to step 2.\n\nIdeally, instead of seeing tests in terms of passes, failures, and exceptions, I'd like to have a fourth possibility: NotImplemented.\nWhat's the best practice here?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1102,"Q_Id":8017514,"Users Score":0,"Answer":"I also now realize that the unittest.expectedFailure decorator accomplishes functionality congruent with my needs.  I had always thought that this decorator was more for tests that require certain environmental conditions that might not exist in the production environment where the test is being run, but it actually makes sense in this scenario too.","Q_Score":2,"Tags":"python,tdd","A_Id":8021286,"CreationDate":"2011-11-05T01:28:00.000","Title":"TDD practice: Distinguishing between genuine failures and unimplemented features","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying out Mechanize to make some routine simpler. I have managed to bypass that error by using br.set_handle_robots(False). There are talks about how ethical it's to use it. What I wonder about is where this error is generated, on my side, or on server side? I mean does Mechanize throw the exception when it sees some robots.txt rule or does server decline the request when it detects that I use an automation tool?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":997,"Q_Id":8034767,"Users Score":0,"Answer":"The server blocks your activity with such response.\nIs it your site? If not, follow the rules:\n\nObey robots.txt file\nPut a delay between request, even if robots.txt doesn't require it.\nProvide some contact information (e-mail or page URL) in the User-Agent header.\n\nOtherwise be ready site owner blocking you based on User-Agent, IP or other information he thinks distinguish you from legitimate users.","Q_Score":3,"Tags":"python,mechanize","A_Id":8035293,"CreationDate":"2011-11-07T09:37:00.000","Title":"On what side is 'HTTP Error 403: request disallowed by robots.txt' generated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I store several properties of objects in hashsets. Among other things, something like \"creation date\". There are several hashsets in the db.\nSo, my question is, how can I find all objects older than a week for example? Can you suggest an algorithm what faster than O(n) (naive implementation)?\nThanks,\nOles","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":462,"Q_Id":8039566,"Users Score":2,"Answer":"My initial thought would be to store the data elsewhere, like relational database, or possibly using a zset.\nIf you had continuous data (meaning it was consistently set at N interval time periods), then you could store the hash key as the member and the date (as a int timestamp) as the value.  Then you could do a zrank for a particular date, and use zrevrange to query from the first rank to the value you get from zrank.","Q_Score":1,"Tags":"python,redis","A_Id":8039797,"CreationDate":"2011-11-07T16:37:00.000","Title":"Redis: find all objects older than","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering how to go about implementing a web application with Python. \nFor example, the html pages would link to python code that would give it increased functionality and allow it to write to a database.\nKind of like how Reddit does it.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7276,"Q_Id":8041501,"Users Score":0,"Answer":"Plain CGI is a good starting point to learn about server side scripting, but it is an outdated technology and gets difficult to maintain after certain level of complexity. I would think it is no longer used in industrial-grade web server anymore. Plus you have to setup a web server and then install some module to interpret python script (like Apache with mod_python) just to get started. \nI had some experience with Django (https:\/\/www.djangoproject.com\/) and found it fairly easy to get started with since they come with development test server. All you need to have is a Python interpreter + Django and you can get up-and-running quickly and worry about the deployment setup later. They have pretty good documentation for beginner as well.","Q_Score":0,"Tags":"python,scripting","A_Id":8077102,"CreationDate":"2011-11-07T19:30:00.000","Title":"How to develop a simple web application with server-side Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some mails in txt format, that have been forwarded multiple times. \nI want to extract the content\/the main body of the mail. This should be at the last position in the hierarchy..right? (Someone point this out if I'm wrong). \nThe email module doesn't give me a way to extract the content. if I make a message object, the object doesn't have a field for the content of the body. \nAny idea on how to do it? Any module that exists for the same or any any particular way you can think of except the most naive one of-course of starting from the back of the text file and looking till you find the  header. \nIf there is an easy or straightforward way\/module with any other language ( I doubt), please let me know that as well!\nAny help is much appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1419,"Q_Id":8041852,"Users Score":0,"Answer":"The email module doesn't give me a way to extract the content. if I make a message object, the object doesn't have a field for the content of the body.\n\nOf course it does.  Have a look at the Python documentation and examples.  In particular, look at the walk and payload methods.","Q_Score":2,"Tags":"python,parsing,email","A_Id":8041910,"CreationDate":"2011-11-07T19:59:00.000","Title":"Forwarded Email parsing in Python\/Any other language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm curious, i have the following code {% code_goes_here %}, how do I comment it out in the html file?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3772,"Q_Id":8047092,"Users Score":8,"Answer":"Django templates has {# ... #} as comments. NOTE: These comments are not multi-line.","Q_Score":4,"Tags":"python,html,django","A_Id":8047122,"CreationDate":"2011-11-08T07:17:00.000","Title":"Is there a way to comment out python code in a django html file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running and interactive ipython shell in an emacs buffer using ipython.el. I wonder if there is a way to clear the screen? Since it is not running on a terminal, the import os; os.system('CLS') trick will not work. Thanks.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2167,"Q_Id":8054953,"Users Score":6,"Answer":"C-c M-o runs the command comint-clear-buffer (found in\ninferior-python-mode-map), which is an interactive compiled Lisp\nfunction.\nIt is bound to C-c M-o.\n(comint-clear-buffer)\nClear the comint buffer.","Q_Score":7,"Tags":"emacs,ipython","A_Id":64160062,"CreationDate":"2011-11-08T17:57:00.000","Title":"how to clear ipython buffer in emacs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I've been tinkering with a few different GUI's but I haven't been able to even find a point to begin researching this question:\nHow do I make a GUI like Steam (Digital distribution app) has? More specifically, I'm interested in how they manage to make their SHIFT+TAB menu pop up in-game, without disrupting\/pausing\/effecting the game. I've been somewhat successful in making a GUI window \"stay on top\" when a game is in window mode, but Steam pops this little menu up over the top of a running, fullscreen game.\nThat's what I'm interested in learning about. Any info would be much appreciated. :)\nSorry if this isn't the correct place to post this. I wasn't sure exactly where to ask.\nPS> Preferably something I could implement in Python!!!","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1878,"Q_Id":8059845,"Users Score":-2,"Answer":"Hmm, that looks very much like they are using Adobe AIR or maybe Flash.","Q_Score":0,"Tags":"python,user-interface","A_Id":8059885,"CreationDate":"2011-11-09T03:00:00.000","Title":"Programming a GUI Like Steam?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a hard time finding a conclusive answer for how to compile a Python 2.7 .py file into a executable program for Debian. Most tutorials say \"we assume you've already written the manifest, etc.\", but I cannot find how to do those first steps.\nSo, I need a step-by-step. How do I take JUST a .py file (using Python 2.7 and PyGTK) and a few .pdf and .png files that go with it, and compile all of that into a working Debian binary?\n(Note: If the tutorial starts out with a tar.gz, or requires a setup.py or similar already written, I need instructions on how to get those files too.)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2610,"Q_Id":8072461,"Users Score":0,"Answer":"Why do you think you need to compile it? Debian, like most other Linux distributions, comes with Python installed as standard, as many of the system tools depend on it. A Python script will just run.","Q_Score":1,"Tags":"python,compilation,debian","A_Id":8072665,"CreationDate":"2011-11-09T22:10:00.000","Title":"How to compile .py into an executable for Debian","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wanted to know how to maximize a browser window using the Python bindings for Selenium 2-WebDriver.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":9312,"Q_Id":8075297,"Users Score":12,"Answer":"You can use browser.maximize_window() for that","Q_Score":2,"Tags":"python,webdriver,selenium-webdriver","A_Id":18481265,"CreationDate":"2011-11-10T05:17:00.000","Title":"How to maximize a browser window using the Python bindings for Selenium 2-WebDriver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's take a random container in Python (list, dict...), do you say a container has items or do you refer to it as members? Documentation seems to suggest that only sets have members.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":8082243,"Users Score":0,"Answer":"Python documentation extensively refers to dictionaries and lists as containing 'items'","Q_Score":1,"Tags":"python","A_Id":8082297,"CreationDate":"2011-11-10T15:48:00.000","Title":"item or member, is there a rule how to refer to a container's contents?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's take a random container in Python (list, dict...), do you say a container has items or do you refer to it as members? Documentation seems to suggest that only sets have members.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":76,"Q_Id":8082243,"Users Score":2,"Answer":"\"Items\" in Python usually are the things that can be retrieved or modified using the __getitem__() and __setitem__() functions, so lists and dictionaries have items.  Sets in contrast don't implement __getitem__() and __setitem__(), so the documentation uses one of the usual terms to refer to the members of a set (\"element\" being the other one).","Q_Score":1,"Tags":"python","A_Id":8082280,"CreationDate":"2011-11-10T15:48:00.000","Title":"item or member, is there a rule how to refer to a container's contents?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django application where users have additional data. That data is collected in a Profile model with a OneToOneField pointing to User.\nThis is fine and works perfectly for most purposes, but I have trouble customizing the admin for User. In particular:\n\nI would like to be able to show a Profile field inside list_display. I don't know how to do this without writing an additional method on User itself.\nI would like to be able to show some information about related models (e.g. some resources owned by the user) inside the User detail page. Again, I do not know how to do this without writing a custom User method.\n\n\nDo you know any solution to the above?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":521,"Q_Id":8092254,"Users Score":0,"Answer":"Turns out, one can put the methods in the UserAdmin itself instead than in the User model. This way I can access all the information I need about the user.","Q_Score":0,"Tags":"python,django,django-models,django-admin","A_Id":8092344,"CreationDate":"2011-11-11T09:52:00.000","Title":"Customizing the Django User admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I started new clear Main Window project,\nThere are 4 Objects: MainWindow, centralWidget, menubar, and statusbar.\nI need to set default layout inside the window, so probably for centralWidget.\nBut I didnt found way how to do it.\nI can get LayoutWidget with some particular size into centralWidget.\nBut I want to set layout for the whole centralWidget.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2793,"Q_Id":8095062,"Users Score":1,"Answer":"Add some widgets to the central widget first.\nThen select the central widget and use the \"Layout in a Grid\", \"Layout Vertically\", etc buttons on the toolbar to add a main layout.\nThe layouts in the \"Widget Box\" side-bar are used for adding child layouts to a main layout.","Q_Score":1,"Tags":"python,qt,pyqt","A_Id":8095328,"CreationDate":"2011-11-11T14:04:00.000","Title":"pyqt designer and layout for central widget","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I started new clear Main Window project,\nThere are 4 Objects: MainWindow, centralWidget, menubar, and statusbar.\nI need to set default layout inside the window, so probably for centralWidget.\nBut I didnt found way how to do it.\nI can get LayoutWidget with some particular size into centralWidget.\nBut I want to set layout for the whole centralWidget.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2793,"Q_Id":8095062,"Users Score":3,"Answer":"Right click anywhere within your centralWidget go to the Lay Out sub menu and select the Layout you want. This will be applied automatically to all contents of your centralWidget. \nIn order to see how it works place inside it 2 or 3 push buttons and try changing the layouts.","Q_Score":1,"Tags":"python,qt,pyqt","A_Id":8095337,"CreationDate":"2011-11-11T14:04:00.000","Title":"pyqt designer and layout for central widget","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm submitting a form and instead of redirecting to a success url I would like to just show \"Form has been submitted\" in text on the page when the form has been submitted. Does anyone know how I can do so?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3238,"Q_Id":8097644,"Users Score":0,"Answer":"Honestly, this isn't a Django-specific issue. The problem is whether you are doing a normal form submission or using AJAX.\nThe basic idea is to POST to your form submission endpoint using AJAX and the form data, and in the Django view, merely update your models and return either an empty 200 response or some data (in XML, JSON, small HTML, whatever you need). Then the AJAX call can populate a success message div on success, or display a failure message if it gets back a non-200 response.","Q_Score":1,"Tags":"python,django","A_Id":8097716,"CreationDate":"2011-11-11T17:23:00.000","Title":"How do I confirm a form has been submitted with django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails.\nNow I want to try a different idea, but I do not know very much about network programming with python. I want to setup a webpage with essentially nothing on it. The \"master\" program, the program actually collecting the data, will send a pickled string to the webpage. Then any of the \"remote\" programs will be able to read the string. I will also need the master program to delete old strings as it updates the webpage. It would be preferred to be able to store multiple string, so there is no chance of the master updating while the remote is reading.\nI do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":403,"Q_Id":8098068,"Users Score":2,"Answer":"I would suggest taking a look at setting up a simple site in google app engine. It's free and you can use python to do the site. Than it would just be a matter of creating a simple restful service that you could send a POST to with your pickled data and store it in a database. Than just create a simple web front end onto the database.","Q_Score":1,"Tags":"python,networking","A_Id":8098102,"CreationDate":"2011-11-11T18:02:00.000","Title":"Sending data through the web to a remote program using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails.\nNow I want to try a different idea, but I do not know very much about network programming with python. I want to setup a webpage with essentially nothing on it. The \"master\" program, the program actually collecting the data, will send a pickled string to the webpage. Then any of the \"remote\" programs will be able to read the string. I will also need the master program to delete old strings as it updates the webpage. It would be preferred to be able to store multiple string, so there is no chance of the master updating while the remote is reading.\nI do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":403,"Q_Id":8098068,"Users Score":0,"Answer":"Adding this as an answer so that OP will be more likely to see it...\nMake sure you consider security! If you just blindly accept pickled data, it can open you up to arbitrary code execution.","Q_Score":1,"Tags":"python,networking","A_Id":8098342,"CreationDate":"2011-11-11T18:02:00.000","Title":"Sending data through the web to a remote program using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails.\nNow I want to try a different idea, but I do not know very much about network programming with python. I want to setup a webpage with essentially nothing on it. The \"master\" program, the program actually collecting the data, will send a pickled string to the webpage. Then any of the \"remote\" programs will be able to read the string. I will also need the master program to delete old strings as it updates the webpage. It would be preferred to be able to store multiple string, so there is no chance of the master updating while the remote is reading.\nI do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":403,"Q_Id":8098068,"Users Score":0,"Answer":"I suggest you to use a good middle-ware like: Zero-C ICE, Pyro4, Twisted.\nPyro4 using pickle to serialize data.","Q_Score":1,"Tags":"python,networking","A_Id":8099975,"CreationDate":"2011-11-11T18:02:00.000","Title":"Sending data through the web to a remote program using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails.\nNow I want to try a different idea, but I do not know very much about network programming with python. I want to setup a webpage with essentially nothing on it. The \"master\" program, the program actually collecting the data, will send a pickled string to the webpage. Then any of the \"remote\" programs will be able to read the string. I will also need the master program to delete old strings as it updates the webpage. It would be preferred to be able to store multiple string, so there is no chance of the master updating while the remote is reading.\nI do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":403,"Q_Id":8098068,"Users Score":1,"Answer":"Another option in addition to what Casey already provided:\nSet up a remote MySQL database somewhere that has user access levels allowing remote connections.  Your Python program could then simply access the database and INSERT the data you're trying to store centrally (e.g. through MySQLDb package or pyodbc package).  Your users could then either read the data through a client that supports MySQL or you could write a simple front-end in Python or PHP that displays the data from the database.","Q_Score":1,"Tags":"python,networking","A_Id":8098220,"CreationDate":"2011-11-11T18:02:00.000","Title":"Sending data through the web to a remote program using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm scraping pdf files from a site using Scrapy, a Python web-scraping framework.\nThe site requires to follow the same session in order to allow you to download the pdf. \nIt works great with Scrapy's because it's all automated but when I run the script after a couple of seconds it starts to give me fake pdf files like when I try to access directly the pdf, without my session.\nWhy is that so & any idea how to overcome this problem!?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1740,"Q_Id":8108477,"Users Score":0,"Answer":"I think the site tracks your session. If it's a PHP site, pass PHPSESSID cookie to the request which downloads the PDF file.","Q_Score":0,"Tags":"python,session,cookies,scrapy","A_Id":8113814,"CreationDate":"2011-11-12T23:54:00.000","Title":"Downloading PDF files with Scrapy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm note sure about conventions for different types of line termination in different programming languages. I know that there are 2 types, 1: line feed, 2: carriage-return, line feed. My question is: how does readline in different programming languages, like python: a = fd.readline();, c\/c++: file.getline (buffer,100);, java: line = buf.readLine(); deal with line termination? If they are sensitive to these 2 different types of terminations, how do I treat them separately?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":8113895,"Users Score":1,"Answer":"You mostly don't need to worry about it.  If you come to a point when something doesn't work, come back and ask about that.\nNote however that what determines the line-ending convention is not which programming language you use, but the platform it runs on (*nix\/Windows\/Mac, all are different).","Q_Score":0,"Tags":"python,termination,linefeed","A_Id":8115701,"CreationDate":"2011-11-13T19:04:00.000","Title":"different types of line terminations(unix, windows, etc)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Scrapy script, and it's working fine. To distribute it to my friends, I need it to be executable because they don't know much about Scrapy. Would someone tell me how to turn a Scrapy script into an exe file?\nIs py2exe applicable in this regard?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1257,"Q_Id":8114839,"Users Score":1,"Answer":"Yes, use py2exe\nAsk questions about any specific problems you have.","Q_Score":0,"Tags":"python,exe,scrapy","A_Id":8114876,"CreationDate":"2011-11-13T21:23:00.000","Title":"How to make an exe file out of Python Scrapy script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want a tool which can compute source code metrics such as lines of code, number of packages, classes, functions, cyclomatic complexity number, depth of inheritance tree etc. for my Python Code.\nI have tried pylint, but it didn't offer much metrics.\npynocle seemed interesting but I dont know how to use it.\nCan anyone give me some suggestions ?\nThanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1752,"Q_Id":8136921,"Users Score":0,"Answer":"try radon, It calculate Cyclomatic Complexity, Maintainability Index and Raw metrics like LOC, SLOC and...","Q_Score":12,"Tags":"python","A_Id":52946193,"CreationDate":"2011-11-15T13:17:00.000","Title":"Software metric tool for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use PyBrain for some simple NN training. What I don't know how to do is to load the training data from a file. It is not explained in their website anywhere. I don't care about the format because I can build it now, but I need to do it in a file instead of adding row by row manually, because I will have several hundreds of rows.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9903,"Q_Id":8139822,"Users Score":21,"Answer":"Here is how I did it:\n\nds = SupervisedDataSet(6,3)\n\ntf = open('mycsvfile.csv','r')\n\nfor line in tf.readlines():\n    data = [float(x) for x in line.strip().split(',') if x != '']\n    indata =  tuple(data[:6])\n    outdata = tuple(data[6:])\n    ds.addSample(indata,outdata)\n\nn = buildNetwork(ds.indim,8,8,ds.outdim,recurrent=True)\nt = BackpropTrainer(n,learningrate=0.01,momentum=0.5,verbose=True)\nt.trainOnDataset(ds,1000)\nt.testOnData(verbose=True)\n\n\nIn this case the neural network has 6 inputs and 3 outputs. The csv file has 9 values on each line separated by a comma. The first 6 values are input values and the last three are outputs.","Q_Score":8,"Tags":"python,neural-network,pybrain","A_Id":8143012,"CreationDate":"2011-11-15T16:39:00.000","Title":"How to load training data in PyBrain?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a form where I upload a file, and I generate a report out of it. The thing is, I would also like to make the report available for download, as an archive. I would like to somehow include the CSS and the JS ( that I inherit from my layout ) inside the report, but I don't really know how to go about this.\nSo far, I am not storing the file ( the report's being generated from ) on server side, I delete it after I'm done with it.\nThe only solution I could think of so far, was: from my archive generating view, use urllib to post to the form generating the report, save the response, and just rewrite the links to the stylesheet\/JS files.\nIs there a simpler way to go about this? Is there a way to keep some files on server side as long as the client's session lives?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":8143228,"Users Score":0,"Answer":"you could always keep the files, and have a cron job that deletes files whose session has expired","Q_Score":0,"Tags":"python,django","A_Id":8143409,"CreationDate":"2011-11-15T21:14:00.000","Title":"How to use a report from a view inside another view in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm fed up with manually creating graphs in excel and consequently, I'm trying to automate the process using Python to massage the .csv data into a workable form and matplotlib to plot the result.\nUsing matplotlib and generating them is no problem but I can't work out is how to set the aspect ration \/ resolution of the output.\nSpecifically, I'm trying to generate scatter plots and stacked area graphs. Everything I've tried seems to result in one or more of the following:\n\nCramped graph areas (small plot area covered with the legend, axes etc.).\nThe wrong aspect ratio.\nLarge spaces on the sides of the chart area (I want a very wide \/ not very tall image).\n\nIf anyone has some working examples showing how to achieve this result I'd be very grateful!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1578,"Q_Id":8143439,"Users Score":0,"Answer":"For resolution, you can use the dpi (dots per inch) argument when creating a figure, or in the savefig() function. For high quality prints of graphics dpi=600 or more is recommended.","Q_Score":4,"Tags":"python,matplotlib","A_Id":8147354,"CreationDate":"2011-11-15T21:34:00.000","Title":"How do get matplotlib pyplot to generate a chart for viewing \/ output to .png at a specific resolution?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using a terminal client to interact with a mainframe computer.  The entire interface is based on the concept of screens.  An example workflow might look like:\n\nLogin Screen: enter login credentials, press enter\nMenu Screen: enter the number of the menu item you want (lets say \"6\" for memos), press enter\nMemo Screen: enter account number, press enter\nAdd Memo Screen: enter memo details, etc, press enter to save, F3 to go back\n\nI have written a python application to automate the processing of records through this terminal interface.  One of the difficulties I am having is that there are a lot of different screens and my application right now is pretty dumb about how to get from one screen to another.  It can go from the login screen, to adding memos.  But, if it finds itself on the memo screen and needs to de-activate an account, it has to logout and login again because it only knows how to get to the deactivation screen from the login screen, not from the add memos screen.\nSo, I would like to create a \"map\" in my application that links each screen to the screens that are \"next\" to it.  Then, I need an algorithm that could tell how to get from any screen A to any screen B in the shortest manner possible.\nI already have some screen objects setup and have \"related\" them to the screens next to them.  So, I am looking for some kind of algorithm that I can implement or python library that I can use that will do the work of calculating the route from one screen to another.\nEdit: I realize that I am looking for some kind of shortest-path graph algorithm.  What is currently throwing me is that I don't really have a \"distance\", I just have nodes.  So, I really don't want shortest-distance, I want least-nodes.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":137,"Q_Id":8153525,"Users Score":0,"Answer":"If you have created a topology of the screens, the A* algorithm should work fine.","Q_Score":0,"Tags":"python,graph-algorithm","A_Id":8154303,"CreationDate":"2011-11-16T14:46:00.000","Title":"Looking for algorithm to help determine shortest path from one terminal screen to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a share (on Machine-A) mounted via sshfs on Machine-B.  From Machine-C, I have this share mounted also via sshfs (double sshfs) like so:\nOn Machine-C: \/mnt\/Machine-B\/target_share\nOn Machine-B: \/mnt\/Machine-A\/target_share\nOn Machine-A: \/media\/target_share\nNow I have a Python program that runs fine in all places tested (including Machine-C on its local file system) except from Machine-C on the drive that lives on Machine-A, but is mounted on Machine-B.\nThe reason I am running the Python program from Machine-C is that it has the resources necessary to run it.  I have run it on Machine-A and Machine-B and it has maxed the memory out on each, thereby failing each time.  I have tried to mount the target_share on Machine-B with this type of command as well:\nsudo mount -t cifs -o username=<username>,password=<password> \/\/Machine-A\/target_share \/mnt\/target_share\nBut this doesn't seem to work each way I have tried it, i.e., with different credentials, with and without credentials, etc.\nTo make matters worse, one caveat is that I can only SSH into Machine-B from Machine-C.  I cannot directly access Machine-A from Machine-C, which, if I could, would probably make all this work just fine.\nThe Python program runs on Machine-C but the logic in the middle that I need to work doesn't run and gives no errors.  It basically starts, and then ends a few seconds later.\nI am relatively new to Python.  Also, not sure if this post would be better on another board.  If so, let me know or move as necessary.\nI can post the Python code as well if I need to.\nMy apologies for the complicated post.  I didn't know how else to explain it.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":509,"Q_Id":8189641,"Users Score":0,"Answer":"I found that there may be a bug in sshfs, such that if a user on a Linux system has the same user ID as another, i.e., 1002, but different usernames, this causes problems.\nThe way I worked around this was to actually avoid sshfs for this case all together and mount the drives directly to a local system.  I wanted to avoid this because I couldn't do this from a remote location, but it gets the job done.","Q_Score":0,"Tags":"python,filesystems,sshfs,mount-point","A_Id":8217136,"CreationDate":"2011-11-18T21:54:00.000","Title":"Running Python Program via sshfs-mounted Share","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm messing around with machine learning, and I've written a K Means algorithm implementation in Python. It takes a two dimensional data and organises them into clusters. Each data point also has a class value of either a 0 or a 1.\nWhat confuses me about the algorithm is how I can then use it to predict some values for another set of two dimensional data that doesn't have a 0 or a 1, but instead is unknown. For each cluster, should I average the points within it to either a 0 or a 1, and if an unknown point is closest to that cluster, then that unknown point takes on the averaged value? Or is there a smarter method?\nCheers!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":14656,"Q_Id":8193563,"Users Score":1,"Answer":"If you are considering assigning a value based on the average value within the nearest cluster, you are talking about some form of \"soft decoder\", which estimates not only the correct value of the coordinate but your level of confidence in the estimate.  The alternative would be a \"hard decoder\" where only values of 0 and 1 are legal (occur in the training data set), and the new coordinate would get the median of the values within the nearest cluster.  My guess is that you should always assign only a known-valid class value (0 or 1) to each coordinate, and averaging class values is not a valid approach.","Q_Score":9,"Tags":"python,machine-learning,data-mining,k-means,prediction","A_Id":8194069,"CreationDate":"2011-11-19T10:58:00.000","Title":"Predicting Values with k-Means Clustering Algorithm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a simple project (the language doesn't really matter\/but I prefer C++) which simply takes a window title as it's input and duplicate it's visual part, bit by bit, to a new window. just like a mirror better I'd say.\nAs far as I remember there was a win32 API for this but I can't remember, so would you please tell me how can I achieve this?\nAnd please tell me, will your answers work with DirectX\/Open-GL applications as well or not?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":8196618,"Users Score":0,"Answer":"You can get DC of first window, and get DC of second window. And after this do BitBlt or StretchBlt. It has to work... But I don't know what about DirectX\/Open-Gl... I think it has to work too. But anyway. It won't take much time to check it.","Q_Score":3,"Tags":"c++,python,c,winapi,api","A_Id":14110911,"CreationDate":"2011-11-19T19:24:00.000","Title":"How to duplicate a window's clientarea to another window?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Assuming I have a class X, how do I check which is the base class\/classes, and their base class\/classes etc?\nI'm using Eclipse with PyDev, and for Java for example you could type CTRL + T on a class' name and see the hierarchy, like:\n\njava.lang.Object\n   java.lang.Number\n       java.lang.Integer\n\nIs it possible for Python?\nIf not possible in Eclipse PyDev, where can I find this information?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4686,"Q_Id":8202949,"Users Score":8,"Answer":"Hit f4 with class name highlighted to open hierarchy view.","Q_Score":10,"Tags":"python,class,inheritance,pydev,hierarchy","A_Id":8202983,"CreationDate":"2011-11-20T16:35:00.000","Title":"How do I inspect a Python's class hierarchy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have just started to use the pywinauto module to automate GUI tasks. One of them is to launch the remote desktop exe (mstsc.exe)->Login->Invoke another tool there.\nHowever, I manged to connect to the remote server but the control gets lost after that. I did not manage to login. So, the question is how to use the pywinauto with Remote Desktop? Has any one tried this before?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1705,"Q_Id":8207755,"Users Score":1,"Answer":"After trying out various things I figured that the window which opens after pressing the \"Connect\" button on mstsc can be found by searching for the window with the title 'XYZ - Remote Desktop' where XYZ is the name of the remote server. I have tested this on the WinXP.","Q_Score":0,"Tags":"python,remote-desktop,rdp,pywinauto","A_Id":8264720,"CreationDate":"2011-11-21T05:42:00.000","Title":"pywinauto with Remote Desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on a specialization project on simulating guitar effects with Evolutionary Algorithms, and want to use Python and CSound to do this.\nThe idea is to generate effect parameters in my algorithm in Python, send them to CSound and apply the filter to the audio file, then send the new audio file back to Python to perform frequency analysis for comparison with the target audio file (this will be done in a loop till the audio file is similar enough to the target audio file, so sending\/receiving between CSound and Python will be done alot).\nShortly phrased, how do I get Python to send data to a CSound(.csd file), how do I read the data in the .csd file, and how do I send a .wav file from CSound to Python? It is also preferred that this can work dynamically on its own till the criterions for the audio file is met.\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":986,"Q_Id":8214339,"Users Score":1,"Answer":"sending parameter values from python to csound could be done using the osc protocol\nsending audio from csound to python could be done by routing jack channels between the two applications","Q_Score":5,"Tags":"python,audio,evolutionary-algorithm,csound","A_Id":8214378,"CreationDate":"2011-11-21T15:41:00.000","Title":"CSound and Python communication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on a specialization project on simulating guitar effects with Evolutionary Algorithms, and want to use Python and CSound to do this.\nThe idea is to generate effect parameters in my algorithm in Python, send them to CSound and apply the filter to the audio file, then send the new audio file back to Python to perform frequency analysis for comparison with the target audio file (this will be done in a loop till the audio file is similar enough to the target audio file, so sending\/receiving between CSound and Python will be done alot).\nShortly phrased, how do I get Python to send data to a CSound(.csd file), how do I read the data in the .csd file, and how do I send a .wav file from CSound to Python? It is also preferred that this can work dynamically on its own till the criterions for the audio file is met.\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":986,"Q_Id":8214339,"Users Score":1,"Answer":"You can use Csound's python API, so you can run Csound within python and pass values using the software bus. See csound.h. You might also want to use the csPerfThread wrapper class which can schedule messages to and from Csound when it is running. All functionality is available from python.","Q_Score":5,"Tags":"python,audio,evolutionary-algorithm,csound","A_Id":8218664,"CreationDate":"2011-11-21T15:41:00.000","Title":"CSound and Python communication","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python 3.2 on Windows 7.  When I open the Python shell, how can I know what the current directory is and how can I change it to another directory where my modules are?","AnswerCount":7,"Available Count":1,"Score":0.0855049882,"is_accepted":false,"ViewCount":539479,"Q_Id":8248397,"Users Score":3,"Answer":"If you import os you can use os.getcwd to get the current working directory, and you can use os.chdir to change your directory","Q_Score":255,"Tags":"python,windows,python-3.x,python-3.2","A_Id":8248427,"CreationDate":"2011-11-23T20:06:00.000","Title":"How to know\/change current directory in Python shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a Django application on a shared hosting service (hostmonster) and am, of course, unable to access the runserver on the default localhost ip of 127.0.0.1:8000 over Firefox. The Django Project site's documentation details how to set up remote access to the run-server, but I'm not having any success with that. Setting the runserver to 0.0.0.0:8000 leaves it inaccessible. Though I figured it wouldn't work, I tried to configure the runserver to my home ip address. That gave me a \"That IP address can't be assigned-to\" error, as I'd expected.\nSo, I tried configuring it to my hosted IP, the one through which I SSH in the first place. That set up properly, but still was unable to access the address via Firefox. When I plug in the IP address on its own, I just get a hostmonster error page. When I affix the port number, the connection times out. When I plug in the IP, port number and the \/admin to access the Django admin page I've created, I also time out.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5897,"Q_Id":8250936,"Users Score":0,"Answer":"First, a webserver typically has at least two \"interfaces\", each with one or more IPs.  The \"loopback\" interface will have the IP 127.0.0.1, and is ONLY accessible from the machine running the server.\nSo, running on 127.0.0.1:8000 means that you are telling runserver to be accessible ONLY from that server itself, on port 8000.  That's secure, but a little rough for testing.  In order to see the result in a web browser you would need to use an SSH tunnel with port forwarding.  (I'd explain how to do that, but honestly, it won't solve your real issue.  But I'll come back to that.)\nRunning on :8000 means that you are telling runserver to be accessible from the internet - which is probably what you want.  If that's not working, then it probably means they're firewalling the port.  You could contact support and ask them to open a hole, OR use an SSH tunnel, but at this point I have to ask:  What are you trying to achieve?\nYou shouldn't use runserver for production.  Use runserver on your local machine for testing, then deploy to Hostmonster.  (Apparently they support Django via FastCGI, according to their website.)  Don't use runserver on Hostmonster, it won't do what you want.","Q_Score":3,"Tags":"python,django,django-admin,timeout,shared-hosting","A_Id":8252044,"CreationDate":"2011-11-24T00:27:00.000","Title":"Accessing Django Runserver on Shared Hosting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm developing a Django application on a shared hosting service (hostmonster) and am, of course, unable to access the runserver on the default localhost ip of 127.0.0.1:8000 over Firefox. The Django Project site's documentation details how to set up remote access to the run-server, but I'm not having any success with that. Setting the runserver to 0.0.0.0:8000 leaves it inaccessible. Though I figured it wouldn't work, I tried to configure the runserver to my home ip address. That gave me a \"That IP address can't be assigned-to\" error, as I'd expected.\nSo, I tried configuring it to my hosted IP, the one through which I SSH in the first place. That set up properly, but still was unable to access the address via Firefox. When I plug in the IP address on its own, I just get a hostmonster error page. When I affix the port number, the connection times out. When I plug in the IP, port number and the \/admin to access the Django admin page I've created, I also time out.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5897,"Q_Id":8250936,"Users Score":0,"Answer":"I'm betting that port 8000 is blocked. That explains the timeouts you mention in the last couple sentences: the firewall is set to simply drop the packets and not return any connection refusal responses.\nYou're going to have to ask your hosting company if there's a way around this, but there might not be one. At the least, they'll have to open a non-root port (8000 or something else over 1023), but the OS can't tell when it's you opening the port or something else, so it'll be a potential security hole (e.g. an intruder can set up something to listen for commands on that port, just like you are).\nrunserver wasn't really designed to be run on the production box. It's designed to be run on your development machine, with a small test database or something. This lets you get most of the bugs out. Then you push your code to a beta server, configured with the real server apps (e.g. apache on port 80) and databases and such, to do the heavy testing (make sure there's a filter for what IPs can connect, at least). Then you push to production from there. Or not; there are lots of ways to do this.","Q_Score":3,"Tags":"python,django,django-admin,timeout,shared-hosting","A_Id":8252018,"CreationDate":"2011-11-24T00:27:00.000","Title":"Accessing Django Runserver on Shared Hosting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm working on a monte carol pricer and I need to improve the efficiency of the engine.\n\nMonteCarlo path are created by a third party library (in c++)\nPricing is done in IronPython (script created by the end user)\nEverything else is driven by a c# application\n\nthe pricing process is as follow:\n\nC# application request the path and collect them\nC# application push the paths to the script, who price and return the values\nC# application display the result to the end user\n\nThe number and size of the paths collected are know in advance. \nI have 2 solutions with some advantages and drawback:\n\nRequest path generation, for each path, ask the script to return the result and finaaly aggregate the results once all paths are processed\nRequest path generation, collect all of them, request the script to process all of them at once and retrun me the final price\n\nThe first solutions work fine in all scenarios but as the number of path requested increase the performance decrease (I think it's due to the multiple call to ironpython)\nThe second solution is faster but can hit an \"out of memory\" exception (I think it's not enough virtual memory addressing space) if the number of path requested is too large\nI choose the middle ground and process a bunch of path then aggregate the prices.\nWhat I want now is to increase the performance futher by knowing in advance how many path I can process withou hitting the \"out of memory\" exception\nI did the math and I know in advance the size (in memory) of path for a given request. However because I'm quiet sure it's not a memory problem but more virtual memory addressing issue\n\nSo all this text is summarize by the following 2 questions:\n\nIs it possible to know in advance how much virtual memory address my\nprocess wil need to store n instance of a class (size in memory and structure are known)?\nIs it possible to know how much virtual memory address are still available for my process\n\nbtw I'm working on the 32 bit computer\nThanks in advance for the help","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":871,"Q_Id":8257686,"Users Score":1,"Answer":"Finding out how much memory an object takes in .NET is a pretty difficult task. I've hit the same problem several times. There are some imperfect methods, but none are very precise.\nMy suggestion is to get some estimate of how much a path will take, and then pass a bunch of them leaving a good margin of safety. Even if you're processing them just 10 at a time, you've reduced the overhead 10 times already.\nYou can even make the margin configurable and then tweak it until you strike a good balance. An even more elegant solution would be to run the whole thing in another process and if it hits an OutOfMemoryException, restart the calculation with less items (and adjust the margin accordingly). However, if you have so much data that it runs out of memory, then it might be a bit slow to pass it across two processes (which will also duplicate the data).\nCould it be that the memory overflow is because of some imperfections in the path processor? Memory leaks maybe? Those are possible both in C++ and .NET.","Q_Score":3,"Tags":"c#,memory-management,ironpython","A_Id":8257843,"CreationDate":"2011-11-24T13:16:00.000","Title":"Virtual memory address management in c#","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on this project which deals with vectors in python. But I'm new to python and don't really know how to crack it. Here's the instruction:\n\"Add a constructor to the Vector class. The constructor should take a single argument. If this argument is either an int or a long or an instance of a class derived from one of these, then consider this argument to be the length of the Vector instance. In this case, construct a Vector of the specified length with each element is initialized to 0.0. If the length is negative, raise a ValueError with an appropriate message. If the argument is not considered to be the length, then if the argument is a sequence (such as a list), then initialize with vector with the length and values of the given sequence. If the argument is not used as the length of the vector and if it is not a sequence, then raise a TypeError with an appropriate message.\nNext implement the __repr__ method to return a string of python code which could be used to initialize the Vector. This string of code should consist of the name of the class followed by an open parenthesis followed by the contents of the vector represented as a list followed by a close parenthesis.\"\nI'm not sure how to do the class type checking, as well as how to initialize the vector based on the given object. Could someone please help me with this? Thanks!","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":8979,"Q_Id":8262017,"Users Score":2,"Answer":"Your instructor seems not to \"speak Python as a native language\". ;) The entire concept for the class is pretty silly; real Python programmers just use the built-in sequence types directly. But then, this sort of thing is normal for academic exercises, sadly...\n\nAdd a constructor to the Vector class.\n\nIn Python, the common \"this is how you create a new object and say what it's an instance of\" stuff is handled internally by default, and then the baby object is passed to the class' initialization method to make it into a \"proper\" instance, by setting the attributes that new instances of the class should have. We call that method __init__.\n\nThe constructor should take a single argument. If this argument is either an int or a long or an instance of a class derived from one of these\n\nThis is tested by using the builtin function isinstance. You can look it up for yourself in the documentation (or try help(isinstance) at the REPL).\n\nIn this case, construct a Vector of the specified length with each element is initialized to 0.0.\n\nIn our __init__, we generally just assign the starting values for attributes. The first parameter to __init__ is the new object we're initializing, which we usually call \"self\" so that people understand what we're doing. The rest of the arguments are whatever was passed when the caller requested an instance. In our case, we're always expecting exactly one argument. It might have different types and different meanings, so we should give it a generic name.\nWhen we detect that the generic argument is an integer type with isinstance, we \"construct\" the vector by setting the appropriate data. We just assign to some attribute of self (call it whatever makes sense), and the value will be... well, what are you going to use to represent the vector's data internally? Hopefully you've already thought about this :)\n\nIf the length is negative, raise a ValueError with an appropriate message.\n\nOh, good point... we should check that before we try to construct our storage. Some of the obvious ways to do it would basically treat a negative number the same as zero. Other ways might raise an exception that we don't get to control.\n\nIf the argument is not considered to be the length, then if the argument is a sequence (such as a list), then initialize with vector with the length and values of the given sequence.\n\n\"Sequence\" is a much fuzzier concept; lists and tuples and what-not don't have a \"sequence\" base class, so we can't easily check this with isinstance. (After all, someone could easily invent a new kind of sequence that we didn't think of). The easiest way to check if something is a sequence is to try to create an iterator for it, with the built-in iter function. This will already raise a fairly meaningful TypeError if the thing isn't iterable (try it!), so that makes the error handling easy - we just let it do its thing.\nAssuming we got an iterator, we can easily create our storage: most sequence types (and I assume you have one of them in mind already, and that one is certainly included) will accept an iterator for their __init__ method and do the obvious thing of copying the sequence data.\n\nNext implement the __repr__ method to return a string of python code which could be used to initialize the Vector. This string of code should consist of the name of the class followed by an open parenthesis followed by the contents of the vector represented as a list followed by a close parenthesis.\"\n\nHopefully this is self-explanatory. Hint: you should be able to simplify this by making use of the storage attribute's own __repr__. Also consider using string formatting to put the string together.","Q_Score":1,"Tags":"python,class,vector,initialization","A_Id":8262970,"CreationDate":"2011-11-24T20:06:00.000","Title":"Vector in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on this project which deals with vectors in python. But I'm new to python and don't really know how to crack it. Here's the instruction:\n\"Add a constructor to the Vector class. The constructor should take a single argument. If this argument is either an int or a long or an instance of a class derived from one of these, then consider this argument to be the length of the Vector instance. In this case, construct a Vector of the specified length with each element is initialized to 0.0. If the length is negative, raise a ValueError with an appropriate message. If the argument is not considered to be the length, then if the argument is a sequence (such as a list), then initialize with vector with the length and values of the given sequence. If the argument is not used as the length of the vector and if it is not a sequence, then raise a TypeError with an appropriate message.\nNext implement the __repr__ method to return a string of python code which could be used to initialize the Vector. This string of code should consist of the name of the class followed by an open parenthesis followed by the contents of the vector represented as a list followed by a close parenthesis.\"\nI'm not sure how to do the class type checking, as well as how to initialize the vector based on the given object. Could someone please help me with this? Thanks!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8979,"Q_Id":8262017,"Users Score":0,"Answer":"This may or may not be appropriate depending on the homework, but in Python programming it's not very usual to explicitly check the type of an argument and change the behaviour based on that. It's more normal to just try to use the features you expect it to have (possibly catching exceptions if necessary to fall back to other options).\nIn this particular example, a normal Python programmer implementing a Vector that needed to work this way would try using the argument as if it were an integer\/long (hint: what happens if you multiply a list by an integer?) to initialize the Vector and if that throws an exception try using it as if it were a sequence, and if that failed as well then you can throw a TypeError.\nThe reason for doing this is that it leaves your class open to working with other objects types people come up with later that aren't integers or sequences but work like them. In particular it's very difficult to comprehensively check whether something is a \"sequence\", because user-defined classes that can be used as sequences don't have to be instances of any common type you can check. The Vector class itself is quite a good candidate for using to initialize a Vector, for example!\nBut I'm not sure if this is the answer your teacher is expecting. If you haven't learned about exception handling yet, then you're almost certainly not meant to use this approach so please ignore my post. Good luck with your learning!","Q_Score":1,"Tags":"python,class,vector,initialization","A_Id":8263003,"CreationDate":"2011-11-24T20:06:00.000","Title":"Vector in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have text files with a few thousands words in them (one word in a line).\nI've written a function which take two words (strings), and checks if one\nword is an Anagram of the other (that means if the two words contains the same\nletters, even if in different order).\nNow I want to go over my huge text file and search for anagrams.  My output should be a list which contains tuples of couple of words which\nare anagrams.\nThe problem is that I have no idea how to go over the words with a for\/while loop.  Everything I've tried has failed. (I'm clear with the way of doing it, but I just don't know python well enough).\nedit#1:\nAssuming I want to go over lines 1 to 100 in the text instead of the whole text, how do I do that?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3485,"Q_Id":8269722,"Users Score":0,"Answer":"load all words (lines) into list, while words are in separate lines this can be done via readlines() (you will have to use strip() to remove line ends): \nwords = [s.strip() for s in f.readlines()]\nfor each word create anagram\nuse word list in operator for that anagram to check if anagram exists\nif exists then print","Q_Score":2,"Tags":"python,list,text-files,anagram","A_Id":8269802,"CreationDate":"2011-11-25T13:17:00.000","Title":"how do i go over lines in an open text file on Python (2.72)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working through the design of a Django inventory tracking application, and have hit a snag in the model layout. I have a list of inventoried objects (Assets), which can either exist in a Warehouse or in a Shipment. I want to store different lists of attributes for the two types of locations, e.g.:\n\nFor Warehouses, I want to store the address, manager, etc.\nFor Shipments, I want to store the carrier, tracking number, etc.\n\nSince each Warehouse and Shipment can contain multiple Assets, but each Asset can only be in one place at a time, adding a ForeignKey relationship to the Asset model seems like the way to go. However, since Warehouse and Shipment objects have different data models, I'm not certain how to best do this.\nOne obvious (and somewhat ugly) solution is to create a Location model which includes all of the Shipment and Warehouse attributes and an is_warehouse Boolean attribute, but this strikes me as a bit of a kludge.  Are there any cleaner approaches to solving this sort of problem (Or are there any non-Django Python libraries which might be better suited to the problem?)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":8274664,"Users Score":0,"Answer":"I think its perfectly reasonable to create a \"through\" table such as location, which associates an asset, a content (foreign key) and a content_type (warehouse or shipment) . And you could set a unique constraint on the asset_fk so thatt it can only exist in one location at a time","Q_Score":0,"Tags":"python,django,django-models","A_Id":8515995,"CreationDate":"2011-11-25T22:07:00.000","Title":"Django design patterns - models with ForeignKey references to multiple classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working through the design of a Django inventory tracking application, and have hit a snag in the model layout. I have a list of inventoried objects (Assets), which can either exist in a Warehouse or in a Shipment. I want to store different lists of attributes for the two types of locations, e.g.:\n\nFor Warehouses, I want to store the address, manager, etc.\nFor Shipments, I want to store the carrier, tracking number, etc.\n\nSince each Warehouse and Shipment can contain multiple Assets, but each Asset can only be in one place at a time, adding a ForeignKey relationship to the Asset model seems like the way to go. However, since Warehouse and Shipment objects have different data models, I'm not certain how to best do this.\nOne obvious (and somewhat ugly) solution is to create a Location model which includes all of the Shipment and Warehouse attributes and an is_warehouse Boolean attribute, but this strikes me as a bit of a kludge.  Are there any cleaner approaches to solving this sort of problem (Or are there any non-Django Python libraries which might be better suited to the problem?)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":235,"Q_Id":8274664,"Users Score":1,"Answer":"what about having a generic foreign key on Assets?","Q_Score":0,"Tags":"python,django,django-models","A_Id":8515865,"CreationDate":"2011-11-25T22:07:00.000","Title":"Django design patterns - models with ForeignKey references to multiple classes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I feel a bit silly for asking what I'm sure is a rather basic question, but I've been learning Python and I'm having difficulty understanding what exactly the \"g\" and \"G\" string formats actually do.\nThe documentation has this to say:\n\nFloating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise.\n\nI'm sure this is supposed to make sense, but I'm just not getting it. Can someone provide a clearer explanation for this format, and possibly provide some examples of when and how it should be used, vs. just using \"e\" or \"f\".\nThanks","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":6837,"Q_Id":8282130,"Users Score":5,"Answer":"g and G are similar to the output you would get on a calculator display if the output is very large or very small you will get a response in scientific notation. For example 0.000001 gives \"1e-06\" with g and \"1E-06\" with G. However numbers that are not too small or too large are displayed simply as decimals 1000 gives \"1000\"\ne always gives the result in exponential format 1000 gives 1.000000e+03\nf always gives the result in decimal format, however it does not do the rounding off that g and G do 1000 gives \"1000.000000\"","Q_Score":8,"Tags":"python,floating-point,number-formatting,exponent","A_Id":8282181,"CreationDate":"2011-11-26T22:30:00.000","Title":"In laymans terms, what does the Python string format \"g\" actually mean?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want my Python program to be AppleScript-able, just like an Objective C program would be. Is that possible?\n(Note, this is not about running AppleScript from Python programs, nor about calling Python programs from AppleScript via Unix program invocation. Those are straightforward. I need genuine AppleScriptability of my program's operations.)\nThere is some documentation about how to do this. Python 2.7.2 documentation describes MiniAEFrame, for example, but even a minimal reference to from MiniAEFrame import AEServer, MiniApplication dies with an ImportError and a complaint that a suitable image can't be found \/ my architecture (x86) not supported. Rut roh! It seems that MiniAEFrame might pertain to the earlier (\"Carbon\") API set. In other words, obsolete.\nThere's a very nice article about \"Using PyObjC for Developing Cocoa Applications with Python\"\n(http:\/\/developer.apple.com\/cocoa\/pyobjc.html). Except it was written in 2005; my recently-updated version of Xcode (4.1) doesn't have any of the options it describes; the Xcode project files it provides blow up in an impressive build failure; and the last PyObjC update appears to have been made 2 years ago. Apple seems to have removed all of the functions that let you build \"real\" apps in AppleScript or Python, leaving only Objective C. \nSo, what are my options? Is it still possible to build a real, AppleScriptable Mac app using Python? If so, how?\n(If it matters, what I need AppleScripted is text insertion. I need Dragon Dicate to be able to add text to my app. I'm currently using Tk as its UI framework, but would be happy to use the native Cocoa\/Xcode APIs\/tools instead, if that would help.)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":8282352,"Users Score":0,"Answer":"You can also use the py-aemreceive module from py-appscript. I use that to implement AppleScript support in my Tkinter app.","Q_Score":5,"Tags":"python,xcode,applescript","A_Id":13686960,"CreationDate":"2011-11-26T23:13:00.000","Title":"Can a program written in Python be AppleScripted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Twisted server supports more than 10,000 concurrent connections. I want to write a test case to check it using Python.\nWhat I know is just using multiprocessing + threading + greenlet. My question is how to confirm Twisted's support for more than 10,000 concurrent connections? \nSomething I know is using logger, but is logger accurate? Or has other way to calculate it?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1595,"Q_Id":8284086,"Users Score":4,"Answer":"It's easy to support more than 10,000 concurrent connections.  What can be harder is supporting so many active connections.  The kind of activity you expect to find on your connections is more likely to determine how many you can support at once.  What do you expect these connections to be doing?  Construct a test which reflects real world behavior and then see how many clients you can support with it.  The more accurately your test reflects real world behavior, the more accurate your results will be.","Q_Score":1,"Tags":"python,twisted","A_Id":8286511,"CreationDate":"2011-11-27T06:45:00.000","Title":"How to calculating and testing the number of concurrent connections?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create a GUI in Python for a client server interaction. The GUI is on the client side for which I want to create complex tables. I tried to use wxPython's grid class, but its too tough to create a complex table in that. I saw a couple of examples for simple table layouts. \n I tried to put up a snapshot of the complex table layout but the site doesn't allow me to. So, I am just drawing a format here : \n[ Blah Blah      Heading ]\n--------------------------\n[col1] | [col 2] | [col 3]\n--------------------------\n   |   |    |    |   |   |\n   |   |    |    |   |   |\n   |   |    |    |   |   | \nCan someone please help regarding how to draw the complex layout and which module to use?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":903,"Q_Id":8290781,"Users Score":0,"Answer":"Tkinter would be enough for this.\nYou can create any level of complexity on the layout even with the \"grid\" \nlayout manager, which allows you to specify \"columnspam\" and \"rowspam\" for widgets that\nwill take more than a single cell.","Q_Score":1,"Tags":"python,user-interface,tablelayout","A_Id":8295831,"CreationDate":"2011-11-28T02:03:00.000","Title":"Draw complex table layout in Python GUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using RabbitMQ with Python\/pika to distribute some batch jobs. So I think I have a very common scenario: One process fills a queue with jobs to be done. Multiple workers retrieve jobs, transform data and put the results in a second queue. Another single process retrives the results and merges them. The works very fine so far. But how do I stop my scripts in a controlled way? Is there some build in functionality to \"invalidate\" a queue, so that the works will be aware that no more jobs will be filled in?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":8295078,"Users Score":0,"Answer":"No, there is no way to find how many publishers are still publishing to a queue in AMQP.  You'll have to roll your own system.\nA way to do this would be to have a fanout exchange that every worker binds a queue to (let's call it the \"control\" exchange), and have the publisher send a special message to it when it finishes.  Workers could then check their \"control\" queue to see if the publisher is still there; if it isn't and there are no more messages available, they can safely disconnect and shutdown.","Q_Score":1,"Tags":"python,rabbitmq","A_Id":8296293,"CreationDate":"2011-11-28T11:22:00.000","Title":"\"Invalidate\" RabbitMQ queue or sending \"DONE signal\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a little program here (python 2.7) that runs on an old machine and it basically keeps getting pictures (for timelapses) by running an external binary and converts them to an efficient format to save up disk space.\nI want to minimize the disk operations, because it's already pretty old and I want it to last some more time.\nAt the moment the program writes the data from the camera on the disk, then converts it and removes the original data. However it does that for every image, 1- it writes a large file on disk, 2- reads it to convert, 3- and then deletes it... a bunch of disc operations that aren't necessary and could be done in ram, because the original file doesn't have to be stored and is only used as a basis to create another one.\nI was sure a ramdisk was the solution, then I googled on how to do that, and google returned me a bunch of links that discourage the use of ramdisk, the reasons are many: because they are not useful in modern systems (i'm running a pretty new linux kernel); they should only be used if you want to decrypt data that shouldn't hit the disk; some tests shows that ramdisk could be actually slower than hd; the operating system has a cache...\nSo I'm confused...\nIn this situation, should I use a ramdisk?\nThank you.\nPS: If you want more info: I have a proprietary high-res camera, and a proprietary binary that I run to capture a single image, I can specify where it will write the file, which is a huge TIFF file, and then the python program runs the convert program from imagemagick to convert it to JPEG and then compress it in tar.bz2, so the quality is almost the same but the filesize is 1\/50 of the TIFF.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":8298442,"Users Score":0,"Answer":"Ah, proprietary binaries that only give certain options. Yay. The simplest solution would be adding a solid state hard drive. You will still be saving to disk, but disk IO will be much higher for reading and writing. \nA better solution would be outputting the tiff to stdout, perhaps in a different format, and piping it to your python program. It would never hit the hard drive at all, but it would be more work. Of course, if the binary doesn't allow you to do this, then it's moot.","Q_Score":0,"Tags":"python,image-processing,camera,ramdisk","A_Id":8299093,"CreationDate":"2011-11-28T15:51:00.000","Title":"Should I use a ramdisk for pictures that are converted and removed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a little program here (python 2.7) that runs on an old machine and it basically keeps getting pictures (for timelapses) by running an external binary and converts them to an efficient format to save up disk space.\nI want to minimize the disk operations, because it's already pretty old and I want it to last some more time.\nAt the moment the program writes the data from the camera on the disk, then converts it and removes the original data. However it does that for every image, 1- it writes a large file on disk, 2- reads it to convert, 3- and then deletes it... a bunch of disc operations that aren't necessary and could be done in ram, because the original file doesn't have to be stored and is only used as a basis to create another one.\nI was sure a ramdisk was the solution, then I googled on how to do that, and google returned me a bunch of links that discourage the use of ramdisk, the reasons are many: because they are not useful in modern systems (i'm running a pretty new linux kernel); they should only be used if you want to decrypt data that shouldn't hit the disk; some tests shows that ramdisk could be actually slower than hd; the operating system has a cache...\nSo I'm confused...\nIn this situation, should I use a ramdisk?\nThank you.\nPS: If you want more info: I have a proprietary high-res camera, and a proprietary binary that I run to capture a single image, I can specify where it will write the file, which is a huge TIFF file, and then the python program runs the convert program from imagemagick to convert it to JPEG and then compress it in tar.bz2, so the quality is almost the same but the filesize is 1\/50 of the TIFF.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":8298442,"Users Score":0,"Answer":"If on Debian (and possibly its derivatives), use \"\/run\/shm\" directory.","Q_Score":0,"Tags":"python,image-processing,camera,ramdisk","A_Id":24181039,"CreationDate":"2011-11-28T15:51:00.000","Title":"Should I use a ramdisk for pictures that are converted and removed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background: I am writing a matching script in python that will match records of a transaction in one database to names of customers in another database. The complexity is that names are not unique and can be represented multiple different ways from transaction to transaction.\nRather than doing multiple queries on the database (which is pretty slow) would it be faster to get all of the records where the last name (which in this case we will say never changes) is \"Smith\" and then have all of those records loaded into memory as you go though each looking for matches for a specific \"John Smith\" using various data points.\nWould this be faster, is it feasible in python, and if so does anyone have any recommendations for how to do it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":8299614,"Users Score":0,"Answer":"Your strategy is reasonable though I would first look at doing as much of the work as possible in the database query using LIKE and other SQL functions.  It should be possible to make a query that matches complex criteria.","Q_Score":0,"Tags":"python,mysql","A_Id":8299759,"CreationDate":"2011-11-28T17:14:00.000","Title":"Could someone give me their two cents on this optimization strategy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background: I am writing a matching script in python that will match records of a transaction in one database to names of customers in another database. The complexity is that names are not unique and can be represented multiple different ways from transaction to transaction.\nRather than doing multiple queries on the database (which is pretty slow) would it be faster to get all of the records where the last name (which in this case we will say never changes) is \"Smith\" and then have all of those records loaded into memory as you go though each looking for matches for a specific \"John Smith\" using various data points.\nWould this be faster, is it feasible in python, and if so does anyone have any recommendations for how to do it?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":98,"Q_Id":8299614,"Users Score":2,"Answer":"Regarding: \"would this be faster:\"\nThe behind-the-scenes logistics of the SQL engine are really optimized for this sort of thing. You might need to create an SQL PROCEDURE or a fairly complex query, however.\nCaveat, if you're not particularly good at or fond of maintaining SQL, and this isn't a time-sensitive query, then you might be wasting programmer time over CPU\/IO time in getting it right.\nHowever, if this is something that runs often or is time-sensitive, you should almost certainly be building some kind of JOIN logic in SQL, passing in the appropriate values (possibly wildcards), and letting the database do the filtering in the relational data set, instead of collecting a larger number of \"wrong\" records and then filtering them out in procedural code.\nYou say the database is \"pretty slow.\" Is this because it's on a distant host, or because the tables aren't indexed for the types of searches you're doing? \u2026 If you're doing a complex query against columns that aren't indexed for it, that can be a pain; you can use various SQL tools including ANALYZE to see what might be slowing down a query. Most SQL GUI's will have some shortcuts for such things, as well.","Q_Score":0,"Tags":"python,mysql","A_Id":8299780,"CreationDate":"2011-11-28T17:14:00.000","Title":"Could someone give me their two cents on this optimization strategy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a Python implementation of Dawkins' biomorphs as described in his book, The Blind Watchmaker.\nIt works like this: A parent organism is displayed, as well as its offspring which are just mutated versions of the parent. Then the user clicks on a descendant it wants to breed, and all the offspring will \"evolve\" based on cumulative selection. \nWhat I'm unsure of is how to get started in Python. I've already created genetic algorithm and l-system programs that are supposed to be used. The l-system program evolves trees given certain parameters (which is my goal in this biomorph implementation), and the genetic algorithm program evolves the genotypes that are created in the l-system program. \n\nWhat library would be good to use (turtle, pygame, etc)?\nI am familiar with turtle, but the documentation says, \"To use multiple turtles an a screen one has to use the object-oriented interface.\" I'm not sure what that means. The reason I thought of using multiple turtles on a screen is to have the the parent and its descendants displayed on one screen, as they are in online apps. Then the user can click on the organism it wants to breed by using mouse events. Is this a good idea, or is there better way to do it?\n\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":718,"Q_Id":8299966,"Users Score":1,"Answer":"Depending on graphical requirements, I would say that for a lightweight app you could get away with PyQt or PyGame. For more demanding real-time graphical requirements you could use something like PyOgre or PyOpenGL.\nYou may need to also research graph-layout\/data-visualisation algorithms or libraries (e.g. dot) depending on your UI goals.","Q_Score":3,"Tags":"python","A_Id":8425387,"CreationDate":"2011-11-28T17:40:00.000","Title":"Biomorph Implementation in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"i'm working on a project thata i need develop one web service ( in java ) that get one simple number from a Corba python implementation... how can i proceed with this??\nim using omniOrb and already done the server.py that genetares one simple number!\nthx a lot","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":375,"Q_Id":8310262,"Users Score":4,"Answer":"You will need a Java CORBA provider - for example IONA or JacORB.  Generate the IDL files for your python service and then use whatever IDL -> stub compiler your Java ORB provides to generate the java client-side bindings.\nFrom there it should be as simple as binding to the corbaloc:\/\/ at which your python server is running and executing the remote calls from your java stubs.\nOf course, CORBA being CORBA, it is likely to require the ritual sacrifice of small mammals and, possibly, lots of candles.","Q_Score":0,"Tags":"java,python,web-services,corba","A_Id":8310341,"CreationDate":"2011-11-29T11:55:00.000","Title":"Corba python integration with web service java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use the OAuth of a website, which requires the signature method to be 'HMAC-SHA1' only.\nI am wondering how to implement this in Python?","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70277,"Q_Id":8338661,"Users Score":0,"Answer":"In Python 3.7 there is an optimized way to do this. HMAC(key, msg, digest).digest() uses an optimized C or inline implementation, which is faster for messages that fit into memory.","Q_Score":57,"Tags":"python,oauth,sha1,hmac","A_Id":62871193,"CreationDate":"2011-12-01T08:55:00.000","Title":"Implementation HMAC-SHA1 in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm analyzing the AST generated by python code for \"fun and profit\", and I would like to have something more graphical than \"ast.dump\" to actually see the AST generated.\nIn theory is already a tree, so it shouldn't be too hard to create a graph, but I don't understand how I could do it.\nast.walk seems to walk with a BFS strategy, and the visitX methods I can't really see the parent or I don't seem to find a way to create a graph...\nIt seems like the only way is to write my own DFS walk function, is does it make sense?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3299,"Q_Id":8340567,"Users Score":6,"Answer":"If you look at ast.NodeVisitor, it's a fairly trivial class. You can either subclass it or just reimplement its walking strategy to whatever you need. For instance, keeping references to the parent when nodes are visited is very simple to implement this way, just add a visit method that also accepts the parent as an argument, and pass that from your own generic_visit.\nP.S. By the way, it appears that NodeVisitor.generic_visit implements DFS, so all you have to do is add the parent node passing.","Q_Score":11,"Tags":"python,grammar,abstract-syntax-tree","A_Id":8341353,"CreationDate":"2011-12-01T11:23:00.000","Title":"Python ast to dot graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to parse a page using Python. My question is which is the fastest method of all parsing techniques, how fast is it from others?\nThe parsing techniques I know are Xpath, DOM, BeautifulSoup, and using the find method of Python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4678,"Q_Id":8342335,"Users Score":1,"Answer":"lxml was written on C. And if you use x86 it is best chose.\nIf we speak about techniques there is no big difference between Xpath and DOM - it's very quickly methods. But if you will use find or findAll in BeautifulSoup it will be slow than other. BeautifulSoup was written on Python. This lib needs a lot of memory for parse any data and, of course, it use standard search methods from python libs.","Q_Score":6,"Tags":"python,dom,xpath,html-parsing,lxml","A_Id":8342483,"CreationDate":"2011-12-01T13:45:00.000","Title":"Xpath vs DOM vs BeautifulSoup vs lxml vs other Which is the fastest approach to parse a webpage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After running for a number of hours on Linux, my Python 2.6 program that uses urllib2, httplib and threads, starts raising this error for every request:\n<class 'urllib2.URLError'> URLError(gaierror(-3, 'Temporary failure in name resolution'),)\nIf I restart the program it starts working again. My guess is some kind of resource exhaustion but I don't know how to check for it. How do I diagnose and fix the problem?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18882,"Q_Id":8356517,"Users Score":18,"Answer":"This was caused by a library's failure to close connections, leading to a large number of connections stuck in a CLOSE_WAIT state. Eventually this causes the 'Temporary failure in name resolution' error due to resource exhaustion.","Q_Score":21,"Tags":"python,urllib2,httplib","A_Id":8376268,"CreationDate":"2011-12-02T12:45:00.000","Title":"Permanent 'Temporary failure in name resolution' after running for a number of hours","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I saw a couple of tutorials and they all make use of termial\/command-prompt and I just dont know how they work. Is it necessary to know how they work before learning python or you can just earn it like you would learn some other language(lets say C)\nIt'll be great if you could recommend something. \nNOTE: I am a windows user.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":8368463,"Users Score":0,"Answer":"No.  If you know how to open the command prompt, navigate to a directory (\"cd\") and list a directory (\"dir\" on windows and \"ls\" on linux), then you can probably jump right into those python tutorials.","Q_Score":0,"Tags":"python,windows,command-prompt","A_Id":8368528,"CreationDate":"2011-12-03T14:51:00.000","Title":"Is it necessary to have the knowledge of using terminal\/command-prompt for learning python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using py2exe to make executable.\nI want to know how to pause the program until a button is pressed..  just like we do in C using system(\"pause\");\nAs the program terminates automatically in windows, I need this tool.\nIs there anything better than py2exe which does similar work ?","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":21409,"Q_Id":8370135,"Users Score":-2,"Answer":"import os\nThen in your code\nos.system(\"pause\")","Q_Score":2,"Tags":"python,py2exe","A_Id":23424057,"CreationDate":"2011-12-03T18:59:00.000","Title":"how to pause a program until a button is pressed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Pygame and Pyglet are for 2D game development.\nPysoy needs many requirements to be installed.\nI can't figure out how to install Pyogre.\nPanda3d is giving me this error and don't know how to fix it.\n\n\nimporterror no module named direct.showbase.showbase\n\nIs there any other good 3D game development library that could be installed on Windows XP with Python 2.7?  I prefer to install it using pypm or pypi to avoid possible errors that I'm currently having with Panda3d.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2006,"Q_Id":8370951,"Users Score":0,"Answer":"You can use pyopengl.\ni think you might have to install pygame...","Q_Score":0,"Tags":"python,3d","A_Id":8874392,"CreationDate":"2011-12-03T20:57:00.000","Title":"What is the best Python library for 3D game development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is there an efficient way to start tasks via Redis Pub\/Sub and return \nthe value of the task back to a Pub\/Sub channel to start another task \nbased on the result?\nDoes anybody have an idea on how to put this together? Maybe \ndecorators are a good idea to handle and prepare the return value back \nto a Pub\/Sub channel without changing the code of the task too much. \nAny help is very much appreciated!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2033,"Q_Id":8379513,"Users Score":1,"Answer":"The problem with using pub\/sub is that it's not persistant.  If you're looking to do closer to real time communication celery might not be your best choice.","Q_Score":11,"Tags":"python,redis,celery","A_Id":11473359,"CreationDate":"2011-12-04T23:39:00.000","Title":"Start Python Celery task via Redis Pub\/Sub","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just changed a program I am writing to hold my data as numpy arrays as I was having performance issues, and the difference was incredible. It originally took 30 minutes to run and now takes 2.5 seconds!\nI was wondering how it does it. I assume it is that the because it removes the need for for loops but beyond that I am stumped.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47312,"Q_Id":8385602,"Users Score":0,"Answer":"Numpy arrays are extremily similar to 'normal' arrays such as those in c. Notice that every element has to be of the same type. The speedup is great because you can take advantage of prefetching and you can instantly access any element in array by it's index.","Q_Score":84,"Tags":"python,arrays,numpy","A_Id":8385718,"CreationDate":"2011-12-05T12:53:00.000","Title":"Why are NumPy arrays so fast?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anybody know how to apply conditional formatting to a google spreadsheet document using ruby or python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":428,"Q_Id":8396511,"Users Score":1,"Answer":"This is not currently possible, Google does not let python or ruby runs in the browser. Conditional formatting is currently limited to simple rules based on cell contents. Google has recently rolled macros ability in their spreadsheets but that is limited to JavaScript and does not support conditional formatting.","Q_Score":0,"Tags":"python,ruby,google-sheets","A_Id":8778840,"CreationDate":"2011-12-06T07:20:00.000","Title":"Conditional formatting using ruby or python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The idea is to make a script that would get stored procedure and udf contents (code) every hour (for example) and add it to SVN repo. As a result we have sql versioning control system.\nDoes anyone know how to backup stored procedure code using Python (sqlAlchemy, pyodbc or smth). \nI'v done this via C# before using SQL Management Objects.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":244,"Q_Id":8412636,"Users Score":1,"Answer":"There is no easy way to access SMO from Python (because there is no generic solution for accessing .NET from Python), so I would write a command-line tool in C# and call it from Python using the subprocess module. Perhaps you could do something with ctypes but I have no idea if that's feasible.\nBut, perhaps a more important question is why you want or need to do this. Does the structure of your database really change so often? If so, presumably you have no real control over it so what benefit does source control have in that scenario? How do you deploy database changes in the first place? Usually changes go from source control into production, not the other way around, so the 'master' source of DDL (including tables, indexes etc.) is SVN, not the database. But you haven't given much information about what you really need to achieve, so perhaps there is a good reason for needing to do this in your environment.","Q_Score":0,"Tags":"c#,python,sql-server,stored-procedures,smo","A_Id":8414549,"CreationDate":"2011-12-07T09:00:00.000","Title":"backup msSQL stored proc or UDF code via Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a view in django that is going to save HTML data to a model, and I'm wondering how I might go about filtering it before saving it to the model? Are there built in functions for it? I know there are template filters, but I don't think those help me in this case.\nWhat I'll be doing is getting the content of a div via JQuery, sending that to a view via ajax, then saving it to a model.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":688,"Q_Id":8417971,"Users Score":1,"Answer":"django takes care of safely storing strings in the database. html is a worry when displaying to the user, and django provides some help there as well, escaping html unless explicitly told not to","Q_Score":0,"Tags":"python,django,django-models","A_Id":8418076,"CreationDate":"2011-12-07T15:36:00.000","Title":"Filter POST data in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a Linux system, I am writing a program in Python, who spawns child processes. I am using the \"multiprocessing\" library and I am wondering if there is a method to call sub-processes with a different user than the current one. I'd like to be able to run each subprocess with a different user (like Postfix, for example.)\nAny idea or pointers ?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2331,"Q_Id":8419558,"Users Score":2,"Answer":"You could look in os.setpgid(pid, pgrp) direction.","Q_Score":1,"Tags":"python,subprocess,multiprocessing","A_Id":8420171,"CreationDate":"2011-12-07T17:17:00.000","Title":"In Python how to call subprocesses under a different user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With Python, I need to read a file into a script similar to open(file,\"rb\"). However, the file is on a server that I can access through SSH. Any suggestions on how I can easily do this? I am trying to avoid paramiko and am using pexpect to log into the SSH server, so a method using pexpect would be ideal.\nThanks,\nEric","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1242,"Q_Id":8425089,"Users Score":0,"Answer":"If it's a short file you can get output of ssh command using subprocess.Popen\nssh root@ip_address_of_the_server 'cat \/path\/to\/your\/file'\nNote: Password less setup using keys should be configured in order for it to work.","Q_Score":1,"Tags":"python,ssh,pexpect","A_Id":8425184,"CreationDate":"2011-12-08T01:35:00.000","Title":"Python - Read in binary file over SSH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In java if I want to read a file that contains resource data for my algorithms how do I do it so the path is correctly referenced.\nClarification\nI am trying to understand how in the Python world one packages data along with code in a module.\nFor example I might be writing some code that looks at a string and tries to classify the language the text is written in. For this to work I need to have a file that contains data about language models.\nSo when my code is called I would like to load a file (or files) that is packaged along with the module. I am not clear on how I should do that in Python.\nTIA.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1032,"Q_Id":8426196,"Users Score":0,"Answer":"For Pythonistas who don't know, the behaviour of Java's Class.getResource is basically: the supplied file name is (unless it's already an absolute path) transformed into a relative path by using the class' package (since the directory path to the class file is expected to mirror the explicit \"package\" declaration for the class). The ClassLoader that was used to load the class in the first place then gets to transform this path string, by its own logic, into a URL object that could encode a file name, a location on the WWW, etc.\nPython is not Java, so we have to approximate a few things and read intent into the question.\nPython classes don't really explicitly go into packages, although you can create packages by putting them in folders with an additional __init__.py file.\nPython does not really have anything quite like the URL class in its standard library; although there is plenty of support for connecting to the Internet, you're generally expected to just use strings to represent URLs (and file names) and format them appropriately. This is arguably an unfortunate missed opportunity for polymorphism (it would not be hard to make your own wrapper, though you might miss lots of special cases and useful functionality). Anyway, in normal cases with Java, you're not expecting to get a web URL from this process.\nPython has a concept of a \"working directory\" that depends on how the Python process was launched. File paths are not necessarily relative to the directory where the \"main class\" (well, really, \"main module\", because Python doesn't make you put everything in a class) is found.\nSo what you really want, probably, is to get the absolute path on disk to the source file corresponding to the class. But that isn't really going to work out either. The problem is: given a class, you can get the name of the module it comes from, and then look up that name to get the actual module object, and then from the module object get the file name that the module was loaded from. However, that file name is relative to whatever the working directory was when the module was loaded, and that information isn't recorded. If the working directory has changed since then (with os.chdir), you're out of luck.\nPlease try to be more clear about what you're really trying to do.","Q_Score":2,"Tags":"java,python","A_Id":8426447,"CreationDate":"2011-12-08T04:32:00.000","Title":"What is the equivalent to python equivalent to using Class.getResource()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am parsing the USDA's food database and storing it in SQLite for query purposes.  Each food has associated with it the quantities of the same 162 nutrients.  It appears that the list of nutrients (name and units) has not changed in quite a while, and since this is a hobby project I don't expect to follow any sudden changes anyway.  But each food does have a unique quantity associated with each nutrient.\nSo, how does one go about storing this kind of information sanely.  My priorities are multi-programming language friendly (Python and C++ having preference), sanity for me as coder, and ease of retrieving nutrient sets to sum or plot over time.\nThe two things that I had thought of so far were 162 columns (which I'm not particularly fond of, but it does make the queries simpler), or a food table that has a link to a nutrient_list table that then links to a static table with the nutrient name and units.  The second seems more flexible i ncase my expectations are wrong, but I wouldn't even know where to begin on writing the queries for sums and time series.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":373,"Q_Id":8431451,"Users Score":4,"Answer":"Use the second (more normalized) approach.\nYou could even get away with fewer tables than you mentioned:\n\ntblNutrients\n-- NutrientID\n-- NutrientName\n-- NutrientUOM (unit of measure)\n-- Otherstuff  \ntblFood\n-- FoodId\n-- FoodName\n-- Otherstuff  \ntblFoodNutrients\n-- FoodID (FK)\n-- NutrientID (FK)\n-- UOMCount   \n\nIt will be a nightmare to maintain a 160+ field database.\nIf there is a time element involved too (can measurements change?) then you could add a date field to the nutrient and\/or the foodnutrient table depending on what could change.","Q_Score":2,"Tags":"c++,python,sql,sqlite","A_Id":8431705,"CreationDate":"2011-12-08T13:07:00.000","Title":"How to store data with large number (constant) of properties in SQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project that contains a QTreeWidget. This widget will have Parent nodes with childs nodes and or other siblings nodes. Attached to each node will be a unique ID in the form of an integer as well as a name.  \nNow..... what methods can or should I use to save all the nodes in the QTreeWidget to  disk and how to read them back in?????\nWhat I would do is traverse the tree and save each node into a sqlite DB. I already can do that in exactly the same order as it is in the tree. BUT...... QTreeWidget and its related QTreeWidgetItem objects do NOT have a uniq index that you can USE to insert other nodes around.\nWhen I rebuild the tree, childs have to be attached to their parents\/ancestor (which by then exists in the tree). To do so I keep track of the Parents and their IDs I already added to the tree, like (parent name, parentID) inside an array. Note that the parentID has nothing to do with location as a node inside the QTreeWidget\/WidgetItem. It is created by myself and stored insite the sqlite db allong with the name of the node just as some sort of tag since QTreeWidget\/QTreeWidgetItem does not supply any.\nTo determine the correct parent I\n\ntake the ParentID from the sqlite DB,\nsearch the array or the QTreeWidget for that same ID,\nselect that parent in the QTreeWidget,\nadd the sqlite db item as a child node to the parent in the\ntreeview.\n\nBut it feels clumsy this way, because of the search each time a node is added and because of a missing index inside the QTreeWidget\/WidgetItem I can use for inserting nodes around.\nI know this should be done much more elegant and less resource intensive.\nI'm not looking for exact coding examples but more for ideas and hints of the methods and properties to use from QTreeWidget and QTreeWidgetItem. \nAny ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2266,"Q_Id":8432620,"Users Score":0,"Answer":"I managed this by using the data property of the TreewidgetItem by setting a value in it. Using that value as a reference to find one or more or even all TreewidgetItem(s) makes it easy to save a complete tree.","Q_Score":2,"Tags":"python,sqlite,pyqt,qtreewidget,qtreewidgetitem","A_Id":14873799,"CreationDate":"2011-12-08T14:35:00.000","Title":"QTreeWidget and PyQt: Methods to save and read data back in from file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, in rails you can do a 'gem list' and it will show all of the gems that you have installed. \nAny clue how I can do this in python?  Also, I am using virtualenv, not sure if that helps?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":881,"Q_Id":8451426,"Users Score":3,"Answer":"Install pip and do pip freeze.\nIf you are using virtualenv, it is already installed in it.","Q_Score":3,"Tags":"python","A_Id":8451487,"CreationDate":"2011-12-09T20:37:00.000","Title":"How do I list the libraries that exist in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a beginner in python. For practice reasons I want to learn how to upload a python code to a website.\nI have a domain and web hosting service, however I'm really confused about how to integrate my code with a\nweb page on my website.\n(I have a decent bit of knowledge with Tkinter)\nCan anybody show me how to upload this simple function to my website?:\nThere are two entries on the interface for the user to enter two numbers. On pressing a button a new\nwindow(web page) with the answer displayed.\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3068,"Q_Id":8453362,"Users Score":0,"Answer":"I would recommend you look at something like Django and mod_wsgi.\nGenerally helps if you have shell access to the server.","Q_Score":0,"Tags":"python,interface,upload,web","A_Id":8453549,"CreationDate":"2011-12-10T00:25:00.000","Title":"Simple python code to website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a system python installation and a personal python installation in my home directory. My personal python comes in ahead in my $PATH and I usually run that. But the system python installation has some modules that I want to use with my personal python installation.\nSo, basically, I want to append the sys.path of the system python installation to the sys.path of the personal python installation.\nI read up on the docs and source of site module and saw that I could use the sitecustomize or usercustomize modules to do this. But where I am stuck is how do I get the sys.path of the system python to be appended to the personal python's sys.path.\nThe gensitepackages function in the site modules seems to calculate the paths to be added to sys.path but it is using the PREFIXES global variable instead of taking it as an argument, so for all I know, I can't use it. Adding system python's prefixes to PREFIXES is also not an option as by the time the customize module(s) are loaded, the PREFIXES is already used to build the path.\nAny ideas on how to go about this?\nAlso, I'm not sure if I should ask this on askubuntu\/unix&linux. Comments?\nEdit: Guess I wasn't clear on this part. I want the system python's path to be appended so that when I try to use modules that are not present in my personal python, it will automatically fallback to the system python's modules.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":717,"Q_Id":8454339,"Users Score":1,"Answer":"python is gonna check if there is a $PYTHONPATH environment variable set. Use that for the path of your other modules.\nuse export PYTHONPATH=\"path:locations\"","Q_Score":0,"Tags":"python,ubuntu,module","A_Id":8454391,"CreationDate":"2011-12-10T04:15:00.000","Title":"Append system python installation's sys.path to my personal python installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make sure that the first name and last name field are not optional for the auth User model but I'm not sure how to change it. I can't use a sub class as I have to use the authentication system.\nTwo solutions I can think of are:\n\nto put the name in the user profile but it's a little silly to have a field that I can't use correctly.\nTo validate in the form rather than in the model. I don't think this really fits with Django's philosophy...\n\nFor some reason I can't seem to find a way to do this online so any help is appreciated. I would have thought that this would be a popular question.\nCheers,\nDurand","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5078,"Q_Id":8466851,"Users Score":2,"Answer":"I would definitely go with validating on the form. You could even go as far as having more form validation in the admin if you felt like it.","Q_Score":11,"Tags":"python,django,forms,validation,authentication","A_Id":8473116,"CreationDate":"2011-12-11T19:37:00.000","Title":"Making first name, last name a required attribute rather than an optional one in Django's auth User model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Need example in scrapy on how to get a link from one page, then follow this link, get more info from the linked page, and merge back with some data from first page.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10013,"Q_Id":8467700,"Users Score":15,"Answer":"Partially fill your item on the first page, and the put it in your request's meta. When the callback for the next page is called, it can take the partially filled request, put more data into it, and then return it.","Q_Score":21,"Tags":"python,web-scraping,scrapy","A_Id":8468824,"CreationDate":"2011-12-11T21:38:00.000","Title":"How do I merge results from target page to current page in scrapy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Celery with Django to manage a task que and using one (or more) small(single core) EC2 instances to process the task.\nI have some considerations.\n\nMy task eats 100% CPU on a single core. - uses whatever CPU available but only in one core\nIf 2 tasks are in progress on the same core, each task will be slowed down by half.\nI would like to start each task ASAP and not let it be que.\n\nNow say I have 4 EC2 instances, i start celery with \"-c 5\" . i.e. 5 concurrent tasks per instance.\nIn this setup, if I have 4 new tasks, id like to ensure, each of them goes to different instance, rather than 4 going to same instance and each task fighting for CPU.\nSimilarly, if I have 8 tasks, id like each instance to get 2 tasks at a time, rather than 2 instances processing 4 tasks each.\nDoes celery already behave the way I described? If not then how can i make it behave as such?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1269,"Q_Id":8479320,"Users Score":2,"Answer":"it's actually easy: you start one celery-instance per ec2-instance. set concurrency to the number of cores per ec2-instance.\nnow the tasks don't interfere and distribute nicely among you instances.\n(the above assumes that your tasks are cpu bound)","Q_Score":0,"Tags":"python,django,celery,django-celery","A_Id":8479823,"CreationDate":"2011-12-12T18:51:00.000","Title":"How to evenly distribute tasks among nodes with Celery?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a genetic expression tree program to control a bot. I have a GP.py and a MyBot.py. I need to be able to have the MyBot.py access an object created in GP.py\nThe GP.py is starting the MyBot.py via the os.system() command\nI have hundreds of tree objects in the GP.py file and the MyBot.py needs to evaluate them.\nI can't combine the two into one .py file because a fresh instance of MyBot.py is executed thousands of times, but GP.py needs to evaluate the fitness of MyBot.py with each tree.\nI know how to import the methods and Class definitions using import GP.py, but I need the specific instance of the Tree class object\nAny ideas how to send this tree from the first instance to the second?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":771,"Q_Id":8500225,"Users Score":2,"Answer":"You could serialize the object with the pickle module (or maybe json?)\nIf you really want to stick with os.system, then you could have MyBot.py write the pickled object to a file, which GP.py could read once MyBot.py returns.\nIf you use the subprocess module instead, then you could have MyBot.py write the pickled object to stdout, and GP.py could read it over the pipe.\nIf you use the multiprocessing module, then you could spawn the MyBot process and pass data back and forth over a Queue instance.","Q_Score":1,"Tags":"python","A_Id":8500285,"CreationDate":"2011-12-14T06:17:00.000","Title":"How to pass object between python instances","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I\u2019m working on simple class something like \u201cin memory  linux-like filesystem\u201d for educational purposes. Files will be as StringIO objects. I can\u2019t make decision how to implement files-folders hierarchy type in Python. I\u2019m thinking about using list of objects with fields: type, name, parent what else? Maybe I should look for trees and graphs.\nUpdate:\nThere will be these methods: \nnew_dir(path), \ndir_list(path), \nis_file(path), \nis_dir(path), remove(path), \nread(file_descr), \nfile_descr open(file_path, mode=w|r), \nclose(file_descr), \nwrite(file_descr, str)","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":846,"Q_Id":8501756,"Users Score":0,"Answer":"You should first ask the question: What operations should my \"file system\" support?\nBased on the answer you select the data representation.\nFor example, if you choose to support only create and delete and the order of the files in  the dictionary is not important, then select a python dictionary. A dictionary will map a file name (sub path name) to either a dictionary or the file container object.","Q_Score":1,"Tags":"python,filesystems","A_Id":8501985,"CreationDate":"2011-12-14T08:59:00.000","Title":"Representing filesystem table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I\u2019m working on simple class something like \u201cin memory  linux-like filesystem\u201d for educational purposes. Files will be as StringIO objects. I can\u2019t make decision how to implement files-folders hierarchy type in Python. I\u2019m thinking about using list of objects with fields: type, name, parent what else? Maybe I should look for trees and graphs.\nUpdate:\nThere will be these methods: \nnew_dir(path), \ndir_list(path), \nis_file(path), \nis_dir(path), remove(path), \nread(file_descr), \nfile_descr open(file_path, mode=w|r), \nclose(file_descr), \nwrite(file_descr, str)","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":846,"Q_Id":8501756,"Users Score":0,"Answer":"What's the API of the filestore? Do you want to keep creation, modification and access times? Presumably the primary lookup will be by file name. Are any other retrieval operations anticipated?\nIf only lookup by name is required then one possible representation is to map the filestore root directory on to a Python dict. Each entry's key will be the filename, and the value will either be a StringIO object (hint: in Python 2 use cStringIO for better performance if it becomes an issue) or another dict. The StringIO objects represent your files, the dicts represent subdirectories.\nSo, to access any path you split it up into its constituent components (using .split(\"\/\")) and then use each to look up a successive element. Any KeyError exceptions imply \"File or directory not found,\" as would any attempts to index a StringIO object (I'm too lazy to verify the specific exception).\nIf you want to implement greater detail then you would replace the StringIO objects and dicts with instances of some \"filestore object\" class. You could call it a \"link\" (since that's what it models: A Linux hard link). The various attributes of this object can easily be manipulated to keep the file attributes up to date, and the .data attribute can be either a StringIO object or a dict as before.\nOverall I would prefer the second solution, since then it's easy to implement methods that do things like keep access times up to date by updating them as the operations are performed, but as I said much depends on the level of detail you want to provide.","Q_Score":1,"Tags":"python,filesystems","A_Id":8502479,"CreationDate":"2011-12-14T08:59:00.000","Title":"Representing filesystem table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Few days ago I found out that my webapp wrote ontop of the tornadoweb framework doesn't stop or restart via upstart. Upstart just hangs and doesn't do anything.\nI investigated the issue and found that upstart recieves wrong PID, so it can only run once my webapp daemon and can't do anything else.\nStrace shows that my daemon makes 4 (!) clone() calls instead of 2.\nWeek ago anything was good and webapp was fully and correctly managed by the upstart.\nOS is Ubuntu 10.04.03 LTS (as it was weeks ago).\nDo you have any ideas how to fix it?\nPS: I know about \"expect fork|daemon\" directive, it changes nothing ;)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":8506002,"Users Score":0,"Answer":"There are two often used solutions\nThe first one is to let your application honestly report its pid. If you could force your application to write the actual pid into the pidfile then you could get its pid from there.\nThe second one is a little more complicated. You may add specific environment variable for the script invocation. This environment variable will stay with all the forks if forks don't clear environment and than you can find all of your processes by parsing \/proc\/*\/environ files.\nThere should be easier solution for finding processes by their environment but I'm not sure.","Q_Score":1,"Tags":"python,daemon,tornado,upstart","A_Id":8516641,"CreationDate":"2011-12-14T14:22:00.000","Title":"Tornadoweb webapp cannot be managed via upstart","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Few days ago I found out that my webapp wrote ontop of the tornadoweb framework doesn't stop or restart via upstart. Upstart just hangs and doesn't do anything.\nI investigated the issue and found that upstart recieves wrong PID, so it can only run once my webapp daemon and can't do anything else.\nStrace shows that my daemon makes 4 (!) clone() calls instead of 2.\nWeek ago anything was good and webapp was fully and correctly managed by the upstart.\nOS is Ubuntu 10.04.03 LTS (as it was weeks ago).\nDo you have any ideas how to fix it?\nPS: I know about \"expect fork|daemon\" directive, it changes nothing ;)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":8506002,"Users Score":1,"Answer":"Sorry my silence, please.\nInvestigation of the issue ended with the knowledge about uuid python library which adds 2 forks to my daemon. I get rid of this lib and tornado daemon works now properly.\nAlternative answer was supervisord which can run any console tools as a daemon which can't daemonize by itself.","Q_Score":1,"Tags":"python,daemon,tornado,upstart","A_Id":10837488,"CreationDate":"2011-12-14T14:22:00.000","Title":"Tornadoweb webapp cannot be managed via upstart","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning python and now I'm having some problems with reading and analyzing txt files. I want to open in python a .txt file that contains many lines and in each line I have one fruit and it's price.\nI would like to know how to make python recognize their prices as a number (since it recognizes as a string when I use readlines()) so then I could use the numbers in some simple functions to calculate the minimum price that I have to sell the fruits to obtain profit.\nAny ideas of how to do it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4297,"Q_Id":8508167,"Users Score":0,"Answer":"I had the same problem when I first was learning Python, coming from Perl. Perl will \"do what you mean\" (or at least what it thinks you mean), and automatically convert something that looks like a number into a number when you try to use it like a number. (I'm generalizing, but you get the idea). The Python philosophy is to not have so much magic occurring, so you must do the conversion explicitly. Call either float(\"12.00\") or int(\"123\") to convert from strings.","Q_Score":0,"Tags":"python,string,text-files","A_Id":8508385,"CreationDate":"2011-12-14T16:40:00.000","Title":"using data from a txt file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two strings of equal length, how can I find all the locations where the strings are different?\nFor example, \"HELPMEPLZ\" and \"HELPNEPLX\" are different at positions 4 and 8.","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49782,"Q_Id":8545492,"Users Score":0,"Answer":"Easiest way is to split data into two char arrays and then loop through comparing the letters and return the index when the two chars do not equal each other.\nThis method will work fine as long as both strings are equal in length.","Q_Score":22,"Tags":"python","A_Id":8545533,"CreationDate":"2011-12-17T14:48:00.000","Title":"Find the position of difference between two strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to set up a complete Python IDE in Sublime Text 2.\nI want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?","AnswerCount":16,"Available Count":4,"Score":0.012499349,"is_accepted":false,"ViewCount":582824,"Q_Id":8551735,"Users Score":1,"Answer":"seems the Ctrl+Break doesn't work on me, neither the Preference - User...\nuse keys, Alt \u2192 t \u2192 c","Q_Score":315,"Tags":"python,ide,sublimetext2,sublimetext","A_Id":62906919,"CreationDate":"2011-12-18T12:36:00.000","Title":"How do I run Python code from Sublime Text 2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to set up a complete Python IDE in Sublime Text 2.\nI want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?","AnswerCount":16,"Available Count":4,"Score":0.0624187467,"is_accepted":false,"ViewCount":582824,"Q_Id":8551735,"Users Score":5,"Answer":"[ This applies to ST3 (Win), not sure about ST2 ]\nTo have the output visible in Sublime as another file (+ one for errors), do this:\n\nCreate a new build system: Tools > Build Systems > New Build System...\nUse the following configuration:\n\n\n\n    {\n        \"cmd\": [\"python.exe\", \"$file\", \"1>\", \"$file_name.__STDOUT__.txt\", \"2>\", \"$file_name.__STDERR__.txt\"],\n        \"selector\": \"source.python\",\n        \"shell\": true,\n        \"working_dir\": \"$file_dir\"\n    }\n\n\nFor your Python file select the above build system configuration file: Tools > Build Systems > {your_new_build_system_filename}\nctrl + b\nNow, next to your file, e.g. \"file.py\" you'll have \"file.__STDOUT__.py\" and  \"file.__STDERR__.py\" (for errors, if any)\nIf you split your window into 3 columns, or a grid, you'll see the result immediately, without a need to switch panels \/ windows","Q_Score":315,"Tags":"python,ide,sublimetext2,sublimetext","A_Id":40689778,"CreationDate":"2011-12-18T12:36:00.000","Title":"How do I run Python code from Sublime Text 2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to set up a complete Python IDE in Sublime Text 2.\nI want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?","AnswerCount":16,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":582824,"Q_Id":8551735,"Users Score":0,"Answer":"I had the same problem. You probably haven't saved the file yet. Make sure to save your code with .py extension and it should work.","Q_Score":315,"Tags":"python,ide,sublimetext2,sublimetext","A_Id":10363165,"CreationDate":"2011-12-18T12:36:00.000","Title":"How do I run Python code from Sublime Text 2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to set up a complete Python IDE in Sublime Text 2.\nI want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?","AnswerCount":16,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":582824,"Q_Id":8551735,"Users Score":0,"Answer":"You can access the Python console via \u201cView\/Show console\u201d or Ctrl+`.","Q_Score":315,"Tags":"python,ide,sublimetext2,sublimetext","A_Id":8552005,"CreationDate":"2011-12-18T12:36:00.000","Title":"How do I run Python code from Sublime Text 2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex\/markdown + knitr\/sweave, using seeds. \nI am now interested in developing a web-based system, that would use the various versions generated, and administer a different one for each student, online. I have looked into several sites related to forms (google docs, wufoo, formsite etc.), but none of them allow programmatic creation of questionnaires. \nI am tagging this with R since that is the language I am most familiar with, and is key to solving the first part of the problem. I know that there are several web-based frameworks for R, and was wondering whether any of them are suitable for this job.\nI am not averse to solutions in other languages like Ruby, Python etc. But the key consideration is the ability to programatically deliver online assignments. I am aware of tools like WebWork, but they require the use of Perl and the interfaces are usually quite clunky. \nFeel free to add tags to the post, if you think I have missed a framework that would be more suitable.\nEDIT. Let me make it clear by giving an example. Currently, if I want to administer an assignment online, I could simply create a Google Form, send the link to my students, and collect all responses in a spreadsheet, and automatically grade it. This works, if I just have one version of the assignment. \nMy questions is, if I want to administer a different version of the assignment for each student, and collect their responses, how can I do that?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":656,"Q_Id":8554562,"Users Score":9,"Answer":"The way you have worded your question it's not really clear why you have to mark the students' work online. Especially since you say that you generate assignments using sweave. If you use R to generate the (randomised) questions, then you really have to use R to mark them (or output the data set).\nFor my courses, I use a couple of strategies.\n\nFor the end of year exam (~500 students), each student gets a unique data set. The students log on to a simple web-site (we use blackboard since the University already has it set up). All students answer the same questions, but use their own unique data set. For example, \"What is the mean\". The answers are marked offline using an R script.\nIn my introductory R course, students upload their R functions and I run and mark them off line. I use sweave to generate a unique pdf for each student. Their pdf shows where they lost marks. For example, they didn't use the correct named arguments.\n\nCoupling a simple web-form with marking offline gives you a lot of flexibility and is fairly straightforward.","Q_Score":13,"Tags":"python,ruby-on-rails,ruby,r,r-exams","A_Id":8554862,"CreationDate":"2011-12-18T20:27:00.000","Title":"Personalizing Online Assignments for a Statistics Class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex\/markdown + knitr\/sweave, using seeds. \nI am now interested in developing a web-based system, that would use the various versions generated, and administer a different one for each student, online. I have looked into several sites related to forms (google docs, wufoo, formsite etc.), but none of them allow programmatic creation of questionnaires. \nI am tagging this with R since that is the language I am most familiar with, and is key to solving the first part of the problem. I know that there are several web-based frameworks for R, and was wondering whether any of them are suitable for this job.\nI am not averse to solutions in other languages like Ruby, Python etc. But the key consideration is the ability to programatically deliver online assignments. I am aware of tools like WebWork, but they require the use of Perl and the interfaces are usually quite clunky. \nFeel free to add tags to the post, if you think I have missed a framework that would be more suitable.\nEDIT. Let me make it clear by giving an example. Currently, if I want to administer an assignment online, I could simply create a Google Form, send the link to my students, and collect all responses in a spreadsheet, and automatically grade it. This works, if I just have one version of the assignment. \nMy questions is, if I want to administer a different version of the assignment for each student, and collect their responses, how can I do that?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":656,"Q_Id":8554562,"Users Score":2,"Answer":"I found one possible solution that might work using the RGoogleDocs package. I am posting this as an answer only because it is long. I am still interested in better approaches, and hence will keep the question open.\nHere is the gist of the idea, which is still untested.\n\nCreate multiple versions of each assignment using knitr\/Sweave.\nUpload them to GoogleDocs using uploadDoc.\nShare one document per student using setAccess which modifies access controls.\nCreate a common Google Form to capture final answers for each student.\n\nThe advantage I see is two-fold. One, since all final answers get captured on a spreadsheet, I can access them with R and grade them automatically. Two, since I have access to all  the completed assignments on Google Docs, I can skim through them and provide individual comments as required (or let some of my TAs do it).\nI will provide an update, if I manage to get this working, and maybe even create an R package if it would be useful for others.","Q_Score":13,"Tags":"python,ruby-on-rails,ruby,r,r-exams","A_Id":8564007,"CreationDate":"2011-12-18T20:27:00.000","Title":"Personalizing Online Assignments for a Statistics Class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a string #abcde#jfdkjfd, how can I get the string between two # ? And I also want that if no # pair(means no # or only one #), the function will return None.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4295,"Q_Id":8559398,"Users Score":2,"Answer":"Use (?<=#)(\\w+)(?=#) and capture the first group. You can even cycle through a string which contains several embedded strings and it will work.\nThis uses both a positive lookbehind and positive lookahead.","Q_Score":1,"Tags":"python,regex","A_Id":8559424,"CreationDate":"2011-12-19T09:37:00.000","Title":"python string parsing using regular expression","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have .ui, .py and .pyc files generated. Now, when I edit the .py file, how will it reflect changes in the .ui file? How do I connect .the ui and .py files together as QT designer allows only .ui files for running purposes?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":8571366,"Users Score":0,"Answer":"the .py file generated from pyuic is not supposed to be edited by the user, best way it is intended to use is to subclass the class in .py file into your own class and do the necessary changes in your class..","Q_Score":0,"Tags":"python,pyqt","A_Id":8571839,"CreationDate":"2011-12-20T05:57:00.000","Title":"Running .py files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a quick and dirty script which requires interaction with a database (PG).\nThe script is a pragmatic, tactical solution to an existing problem. however, I envisage that the script will evolve over time into a more \"refined\" system. Given the fact that it is currently being put together very quickly (i.e. I don't have the time to pour over huge reams of documentation), I am tempted to go the quick and dirty route, using psycopg.\nThe advantages for psycopg2 (as I currently understand it) is that:\n\nwritten in C, so faster than sqlAlchemy (written in Python)?\nNo abstraction layer over the DBAPI since works with one db and one db only (implication -> fast)\n(For now), I don't need an ORM, so I can directly execute my SQL statements without having to learn a new ORM syntax (i.e. lightweight)\n\nDisadvantages:\n\nI KNOW that I will want an ORM further down the line\npsycopg2 is (\"dated\"?) - don't know how long it will remain around for\n\nAre my perceptions of SqlAlchemy (slow\/interpreted, bloated, steep learning curve) true - IS there anyway I can use sqlAlchemy in the \"rough and ready\" way I want to use psycopg - namely:\n\nexecute SQL statements directly without having to mess about with the ORM layer, etc.\n\nAny examples of doing this available?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":40683,"Q_Id":8588126,"Users Score":108,"Answer":"SQLAlchemy is a ORM, psycopg2 is a database driver. These are completely different things:  SQLAlchemy generates SQL statements and psycopg2 sends SQL statements to the database. SQLAlchemy depends on psycopg2 or other database drivers to communicate with the database!\nAs a rather complex software layer SQLAlchemy does add some overhead but it also is a huge boost to development speed, at least once you learned the library. SQLAlchemy is a excellent library and will teach you the whole ORM concept, but if you don't want to generate SQL statements to begin with then you don't want SQLAlchemy.","Q_Score":57,"Tags":"python,postgresql,sqlalchemy,psycopg2","A_Id":8588766,"CreationDate":"2011-12-21T10:08:00.000","Title":"SQLAlchemy or psycopg2?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a quick and dirty script which requires interaction with a database (PG).\nThe script is a pragmatic, tactical solution to an existing problem. however, I envisage that the script will evolve over time into a more \"refined\" system. Given the fact that it is currently being put together very quickly (i.e. I don't have the time to pour over huge reams of documentation), I am tempted to go the quick and dirty route, using psycopg.\nThe advantages for psycopg2 (as I currently understand it) is that:\n\nwritten in C, so faster than sqlAlchemy (written in Python)?\nNo abstraction layer over the DBAPI since works with one db and one db only (implication -> fast)\n(For now), I don't need an ORM, so I can directly execute my SQL statements without having to learn a new ORM syntax (i.e. lightweight)\n\nDisadvantages:\n\nI KNOW that I will want an ORM further down the line\npsycopg2 is (\"dated\"?) - don't know how long it will remain around for\n\nAre my perceptions of SqlAlchemy (slow\/interpreted, bloated, steep learning curve) true - IS there anyway I can use sqlAlchemy in the \"rough and ready\" way I want to use psycopg - namely:\n\nexecute SQL statements directly without having to mess about with the ORM layer, etc.\n\nAny examples of doing this available?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":40683,"Q_Id":8588126,"Users Score":11,"Answer":"To talk with database any one need driver for that. If you are using client like SQL Plus for oracle, MysqlCLI for Mysql then it will direct run the query and that client come with DBServer pack. \nTo communicate from outside with any language like java, c, python, C#... We need driver to for that database. psycopg2 is driver to run query for PostgreSQL from python. \nSQLAlchemy is the ORM which is not same as database driver. It will give you flexibility so you can write your code without any database specific standard. ORM provide database independence for programmer. If you write object.save in ORM then it will check, which database is associated with that object and it will generate insert query according to the backend database.","Q_Score":57,"Tags":"python,postgresql,sqlalchemy,psycopg2","A_Id":8589254,"CreationDate":"2011-12-21T10:08:00.000","Title":"SQLAlchemy or psycopg2?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"hi every one I was wondering how to go about deploying a small time python database web application. Is buying some cheap hardware and installing a server good on it a good route to go?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":8591602,"Users Score":0,"Answer":"You can get a virtual server instance on amazon or rackspace or many others for a very small fee per month, $20 - $60.  This will give you a clean install of the OS of your choice.  No need to invest in hardware.  From there you can follow any of the many many tutorials on deploying a django app.","Q_Score":0,"Tags":"python,web","A_Id":8592171,"CreationDate":"2011-12-21T14:43:00.000","Title":"deploying a python web application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Our situation is as follows:\nWe are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking.\nAs such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google appengine.\nSomeone is behind a webbrowser,watching all these teams walk around, and sending them messages etc.\nWe are using the datastore the google appengine provides to store all the data these teams send and request, to store the messages and retrieve them etc.\nHowever we soon found out we where at our max limit of reads and writes, so we searched for a solution to be able to retrieve periodic updates(which cost the most reads and writes) without using any of the limited resources google provides. And obviously, because it's a schoolproject we don't want to pay for more reads and writes.\nStoring this information in global variables seemed an easy and quick solution, which it was... but when we started to truly test we noticed some of our data was missing and then reappearing. Which turned out to be because there where so many requests being done to the cloud that a new instance was made, and instances don't keep these global variables persistent.\nSo our question is:\nCan we somehow make sure these global variables are always the same on every running instance of google appengine.\nOR\nCan we limit the amount of instances ever running, no matter how many requests are done to '1'.\nOR\nIs there perhaps another way to store this data in a better way, without using the datastore and without using globals.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2158,"Q_Id":8616487,"Users Score":0,"Answer":"Interesting question. Some bad news first, I don't think there's a better way of storing data; no, you won't be able to stop new instances from spawning and no, you cannot make seperate instances always have the same data. \nWhat you could do is have the instances perioidically sync themselves with a master record in the datastore, by choosing the frequency of this intelligently and downloading\/uploading the information in one lump you could limit the number of read\/writes to a level that works for you. This is firmly in the kludge territory though.\nDespite finding the quota for just about everything else, I can't find the limits for free read\/write so it is possible that they're ludicrously small but the fact that you're hitting them with a mere 10 smartphones raises a red flag to me. Are you certain that the smartphones are being polled (or calling in) at a sensible frequency? It sounds like you might be hammering them unnecessarily.","Q_Score":2,"Tags":"python,google-app-engine,variables,global","A_Id":8617102,"CreationDate":"2011-12-23T13:10:00.000","Title":"How to keep global variables persistent over multiple google appengine instances?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Our situation is as follows:\nWe are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking.\nAs such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google appengine.\nSomeone is behind a webbrowser,watching all these teams walk around, and sending them messages etc.\nWe are using the datastore the google appengine provides to store all the data these teams send and request, to store the messages and retrieve them etc.\nHowever we soon found out we where at our max limit of reads and writes, so we searched for a solution to be able to retrieve periodic updates(which cost the most reads and writes) without using any of the limited resources google provides. And obviously, because it's a schoolproject we don't want to pay for more reads and writes.\nStoring this information in global variables seemed an easy and quick solution, which it was... but when we started to truly test we noticed some of our data was missing and then reappearing. Which turned out to be because there where so many requests being done to the cloud that a new instance was made, and instances don't keep these global variables persistent.\nSo our question is:\nCan we somehow make sure these global variables are always the same on every running instance of google appengine.\nOR\nCan we limit the amount of instances ever running, no matter how many requests are done to '1'.\nOR\nIs there perhaps another way to store this data in a better way, without using the datastore and without using globals.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2158,"Q_Id":8616487,"Users Score":0,"Answer":"Consider jabber protocol for communication between peers. Free limits are on quite high level for it.","Q_Score":2,"Tags":"python,google-app-engine,variables,global","A_Id":8617199,"CreationDate":"2011-12-23T13:10:00.000","Title":"How to keep global variables persistent over multiple google appengine instances?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Our situation is as follows:\nWe are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking.\nAs such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google appengine.\nSomeone is behind a webbrowser,watching all these teams walk around, and sending them messages etc.\nWe are using the datastore the google appengine provides to store all the data these teams send and request, to store the messages and retrieve them etc.\nHowever we soon found out we where at our max limit of reads and writes, so we searched for a solution to be able to retrieve periodic updates(which cost the most reads and writes) without using any of the limited resources google provides. And obviously, because it's a schoolproject we don't want to pay for more reads and writes.\nStoring this information in global variables seemed an easy and quick solution, which it was... but when we started to truly test we noticed some of our data was missing and then reappearing. Which turned out to be because there where so many requests being done to the cloud that a new instance was made, and instances don't keep these global variables persistent.\nSo our question is:\nCan we somehow make sure these global variables are always the same on every running instance of google appengine.\nOR\nCan we limit the amount of instances ever running, no matter how many requests are done to '1'.\nOR\nIs there perhaps another way to store this data in a better way, without using the datastore and without using globals.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2158,"Q_Id":8616487,"Users Score":3,"Answer":"You should be using memcache. If you use the ndb (new database) library, you can automatically cache the results of queries. Obviously this won't improve your writes much, but it should significantly improve the numbers of reads you can do.\nYou need to back it with the datastore as data can be ejected from memcache at any time. If you're willing to take the (small) chance of losing updates you could just use memcache. You could do something like store just a message ID in the datastore and have the controller periodically verify that every message ID has a corresponding entry in memcache. If one is missing the controller would need to reenter it.","Q_Score":2,"Tags":"python,google-app-engine,variables,global","A_Id":8624587,"CreationDate":"2011-12-23T13:10:00.000","Title":"How to keep global variables persistent over multiple google appengine instances?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed cocos2d today on OS X Lion, but whenever I try to import cocos in the Python interpreter, I get a bunch of import errors.\n\nFile \"\", line 1, in     File\n  \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/ \n  python2.7\/site-packages\/cocos2d-0.5.0-py2.7.egg\/cocos\/init.py\", \n  line 105, in  \n      import_all()    File \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/ \n  python2.7\/site-packages\/cocos2d-0.5.0-py2.7.egg\/cocos\/init.py\", \n  line 89, in import_all \n      import actions    File \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/ \n  python2.7\/site-packages\/cocos2d-0.5.0-py2.7.egg\/cocos\/actions\/ \n  init.py\", line 37, in  \n      from basegrid_actions import *    File \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/ \n  python2.7\/site-packages\/cocos2d-0.5.0-py2.7.egg\/cocos\/actions\/ \n  basegrid_actions.py\", line 62, in  \n      from pyglet.gl import *    File \"build\/bdist.macosx-10.6-intel\/egg\/pyglet\/gl\/init.py\", line  510,\n  in     File\n  \"build\/bdist.macosx-10.6-intel\/egg\/pyglet\/window\/init.py\",  line\n  1669, in     File\n  \"build\/bdist.macosx-10.6-intel\/egg\/pyglet\/window\/carbon\/ \n  init.py\", line 69, in     File \"build\/bdist.macosx-10.6-intel\/egg\/pyglet\/lib.py\", line 90, in \n  load_library    File\n  \"build\/bdist.macosx-10.6-intel\/egg\/pyglet\/lib.py\", line 226, in \n  load_framework    File\n  \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/ \n  python2.7\/ctypes\/init.py\", line 431, in LoadLibrary \n      return self._dlltype(name)    File \"\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/ \n  python2.7\/ctypes\/init.py\", line 353, in init \n      self._handle = _dlopen(self._name, mode)  OSError: dlopen(\/System\/Library\/Frameworks\/QuickTime.framework\/  QuickTime, 6):\n  no suitable image found.  Did find: \n          \/System\/Library\/Frameworks\/QuickTime.framework\/QuickTime: mach-o, but  wrong architecture \n          \/System\/Library\/Frameworks\/QuickTime.framework\/QuickTime: mach-o, but  wrong architecture\n\nSince I can't fix it, I'd like to remove cocos2d entirely. The problem is that I can't seem to find a guide anywhere that details how to remove it from the Python installation.\nAny help regarding either of these problems is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":559,"Q_Id":8626180,"Users Score":1,"Answer":"You could fix it.\nThe problem comes from the fact that cocos2D is built on top of Pyglet, and the stable release of pyglet does not yet support Mac OS X 64 bits architecture. You have to use the 1.2 release of pyglet or later, which by now is not released yet.\nA workaround is to remove any existing Pyglet install:\npip uninstall piglet\nThen install the latest Pyglet from the mercurial repository\npip install hg+https:\/\/pyglet.googlecode.com\/hg\/","Q_Score":0,"Tags":"python,cocos2d-python","A_Id":10575373,"CreationDate":"2011-12-24T18:25:00.000","Title":"Removing cocos2d-python from Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm stucked on the chapter 3.3 \"Math functions\" of \"Think Python\".\nIt tells me to import math (through the interpreter).\nThen print math and that I should get something like this:\n<module 'math' from '\/usr\/lib\/python2.5\/lib-dynload\/math.so'>\nInstead I get <module 'math' <built-in>>\nAnyway that's not the problem. Though I wasn't able to find a 'math.so' file in my python folder. The most similar file is named test_math.\nThe problem is that I'm supposed to write this:\n>>> ratio = signal_power \/ noise_power\n>>> decibels = 10 * math.log10(ratio)\n>>> radians = 0.7\n>>> height = math.sin(radians)\nWhen I write the first line it tells me this:\nTraceback <most recent call last>:\nFile \"<stdin>\", line 1, in <module>\nNameError: name 'signal_power' is not defined\nOn the book says \"The first example uses log10 to compute a signal-to-noise ratio in decibels (assuming that signal_power and noise_power are defined).\"\nSo I assume that the problem might be that I didn't defined 'signal_power', but I don't know how to do it and what to assign to it...\nThis is the first time that I feel that this book is not holding my hand and I'm already lost. To be honest I don't understand this whole chapter.\nBy the way, I'm using Python2.7 and Windows XP. I may copy and paste the whole chapter if anyone feels that I should do it.\nPython is my first language and I already tried to learn it using \"Learn Python the hard way\" but got stucked on chapter 16. So I decided to use \"Think Python\" and then go back to \"Learn Python the hard way\".","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":529,"Q_Id":8627414,"Users Score":3,"Answer":"You've figured it out - you have to set signal_power's value before using it. As to what you have to set it to - it's not really a Python related question, but 1 is always a safe choice :) While you are at it, don't forget to define noise_power.","Q_Score":0,"Tags":"python,function,module","A_Id":8627435,"CreationDate":"2011-12-24T23:22:00.000","Title":"Python's math module & \"Think Python\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using gearman for synchronizing data on different servers. We have 1 main server and, for example, 10 local servers. Let me describe one of possible situations. Say, gearman started working, and 5 jobs are done, data on that 5 servers is synced. When doing the next job is started, say, we lost the connection with server and it's not available right now. By the logic of gearman it retries again and again. So the remaining jobs (for servers 7, 8, 9, 10) will not be executed until the 6th is not done. The best solution would be postponing the job and putting it to the end of queue and continuing work of jobs 7-10.\nIf someone do know how to do that, please post the way.\nPS: I'm using python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":903,"Q_Id":8628940,"Users Score":0,"Answer":"Gearman jobs can run in parallel or series.  Instead of using single jobs, you should use concurrent jobs (one for each server).","Q_Score":1,"Tags":"gearman,task-management,python-gearman","A_Id":8943378,"CreationDate":"2011-12-25T09:05:00.000","Title":"How to delay\/postpone Gearman job?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am scraping a webpage using Selenium webdriver in Python\nThe webpage I am working on, has a form. I am able to fill the form and then I click on the Submit button.\nIt generates an popup window( Javascript Alert). I am not sure, how to click the popup through webdriver.\nAny idea how to do it ?\nThanks","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38288,"Q_Id":8631500,"Users Score":0,"Answer":"that depends on the javascript function that handles the form submission\nif there's no such function try to submit the form using post","Q_Score":20,"Tags":"python,selenium,webdriver,web-scraping,alert","A_Id":8631520,"CreationDate":"2011-12-25T20:50:00.000","Title":"Click the javascript popup through webdriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I downloaded tarball of python 2.7.2 to install on Suse Linux server--it comes with 2.6 and 3.1.\nUntarred it (I know--wrong lingo, sorry) to a directory.\nWhen trying to run .\/configure, which should create a valid makefile I can't get past the step one:  the script reports that it can't find a compiler on the path.\nBut, when I run the shell in the same directory and type \"make\", make runs.\nI am really unfamiliar with Linux, but this just seems so basic that I can't even begin to see what's wrong.\nI also downloaded what appears to be an RPM file for python 2.7.2 for SUSE Linux but I can't for the life of me figure out how to get \"import\" this package into Yast2 or \"Install Software.\"  These two tools seem impenetrable and hostile to packages saved in the file system rather than accessed from specific distribution web sites.\nReally, this should be just trivial but it is not.\nSuse uses Gnome and Gnome seems to have its own view of what the directory structure should be for desktop end user-y kinds of files.  That is where I put my downloaded tar file.  Might I do better if I put somewhere in usr?\nSorry to be so much more clueless than most stackoverflow participants but I am just not a Linux guy.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":8640781,"Users Score":0,"Answer":"Suse has a package manager called Yast. It would do your installation with no fuss.","Q_Score":0,"Tags":"python,linux,configure","A_Id":8658970,"CreationDate":"2011-12-27T03:07:00.000","Title":"Completely lost: Python configure script runs with errors","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two computers on a network. I'll call the computer I'm working on computer A and the remote computer B. My goal is to send a command to B, gather some information, transfer this information to computer A and use this in some meaningfull way. My current method follows:\n\nEstablish a connection to B with paramiko.\nUse paramiko to execute a remote command e.g. paramiko.exec_command('python file.py').\nWrite the information to a file with pickle, and use paramiko.ftp to transfer the file to  computer A.\nOpen this file and parse the information back into a usable form, like a class or dictionary. \n\nThis seems very ad-hoc. My question is, is there a better way to transfer data between computers using Python? I know how to transfer files, this is a different question. I want to make an object on B and use it on A.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2292,"Q_Id":8649405,"Users Score":0,"Answer":"I have been doing something similar on a larger scale (with 15 clients). I use the pexpect module to do essentially ssh commands on the remote machine (computer B). Another module to look into would be the subprocess module.","Q_Score":1,"Tags":"python,rpc","A_Id":8649530,"CreationDate":"2011-12-27T21:20:00.000","Title":"How do I transfer data between two computers ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've looked in the documentation and haven't seen (from first sight) anything about cache in Pyramid. Maybe I missed something... Or maybe there are some third party packages to help with this.\nFor example, how to cache db query (SQLAlchemy), how to cache views? Could anyone give some link to examples or documentation?\nAppreciate any help!\nEDITED:\nHow to use memcache or database type cache or filebased cache?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4486,"Q_Id":8651061,"Users Score":6,"Answer":"Your options are pyramid_beaker and dogpile.cache \npyramid_beaker was written to offer beaker caching for sessions.  it also lets you configure beaker cache regions, which can be used elsewhere.\ndogpile.cache is a replacement for beaker.  it hasn't been integrated to offer session support or environment.ini based setup yet.  however it addresses a lot of miscellaneous issues and shortcomings with beaker.\nyou can't\/shouldn't cache a SqlAlchemy query or results. weird and bad things will happen, because the SqlAlchemy objects are bound to a database session.  it's much better to convert the sqlalchemy results into another object\/dict and cache those.","Q_Score":3,"Tags":"python,sqlalchemy,pyramid","A_Id":14859955,"CreationDate":"2011-12-28T01:50:00.000","Title":"How to cache using Pyramid?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering exactly how a thermostat program would work and wanted to see if anyone had a better opinion on it. From what I know, there are a few control algorithms that could be used, some being Bang-Bang (On\/Off), Proportional Control Algorithms, and PID Control. Looking on Wikipedia, there is a great deal of explanations for all three in which I understand completely. However, when trying to implement a proportional control algorithm, I feel that I am missing the need or the use of the proportional gain (K) and the output. Since today's thermostats do not include the need to vary power or current, how do I manipulate the output so that I can trigger the controls ON\/OFF of the thermostat? Also, what is the value of the proportional gain or K?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2614,"Q_Id":8651063,"Users Score":4,"Answer":"The issue is overshooting the setpoint temperature.\nIf you simply run the device until the set point temperature is reached, you will overshoot, wasting energy (and possibly doing damage, depending on what the thermostat controls.)\nYou need to \"ease up to\" the setpoint so that you arrive at the set point just as the device is shutting down so that no more energy goes in to rise above the set point.","Q_Score":0,"Tags":"python,algorithm","A_Id":8651274,"CreationDate":"2011-12-28T01:51:00.000","Title":"Thermostat Control Algorithms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a new report with report plugin and openoffice but I don't know how to assign it in the OpenERP system.\nIs there someone who can give me exact steps for creation of new report and integration with openerp? \nThanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":6171,"Q_Id":8651668,"Users Score":1,"Answer":"First you save .odt file then connect with server and select open new report and then send it ti server with proper report name and then keep on editing your report by selecting the option modify existing report.","Q_Score":1,"Tags":"python,report,openoffice.org,openerp,openoffice-writer","A_Id":9046631,"CreationDate":"2011-12-28T03:54:00.000","Title":"OpenERP - Report Creation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a math fair project I want to make a program that will generate a Julia set fractal. To do this i need to plot complex numbers on a graph. Does anyone know how to do this? Remember I am using complex numbers, not regular coordinates. Thank You!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1786,"Q_Id":8662501,"Users Score":0,"Answer":"Julia set renderings are generally 2D color plots, with [x y] representing a complex starting point and the color usually representing an iteration count.","Q_Score":2,"Tags":"python,graph,fractals,complex-numbers","A_Id":8662563,"CreationDate":"2011-12-28T23:36:00.000","Title":"Plotting Complex Numbers in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a math fair project I want to make a program that will generate a Julia set fractal. To do this i need to plot complex numbers on a graph. Does anyone know how to do this? Remember I am using complex numbers, not regular coordinates. Thank You!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1786,"Q_Id":8662501,"Users Score":2,"Answer":"You could plot the real portion of the number along the X axis and plot the imaginary portion of the number along the Y axis. Plot the corresponding pixel with whatever color makes sense for the output of the Julia function for that point.","Q_Score":2,"Tags":"python,graph,fractals,complex-numbers","A_Id":8662525,"CreationDate":"2011-12-28T23:36:00.000","Title":"Plotting Complex Numbers in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Apologies for the longish description.\nI want to run a transform on every doc in a large-ish Mongodb collection with 10 million records approx 10G. Specifically I want to apply a geoip transform to the ip field in every doc and either append the result record to that doc or just create a whole other record linked to this one by say id (the linking is not critical, I can just create a whole separate record).  Then I want to count and group by say city - (I do know how to do the last part).\nThe major reason I believe I cant use map-reduce is I can't call out to the geoip library in my map function (or at least that's the constraint I believe exists).\nSo I the central question is how do I run through each record in the collection apply the transform - using the most efficient way to do that.  \nBatching via Limit\/skip is out of question as it does a \"table scan\" and it is going to get progressively slower.\nAny suggestions?\nPython or Js preferred just bec I have these geoip libs but code examples in other languages welcome.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":477,"Q_Id":8663432,"Users Score":1,"Answer":"Since you have to go over \"each record\", you'll do one full table scan anyway, then a simple cursor (find()) + maybe only fetching few fields (_id, ip) should do it. python driver will do the batching under the hood, so maybe you can give a hint on what's the optimal batch size (batch_size) if the default is not good enough.   \nIf you add a new field and it doesn't fit the previously allocated space, mongo will have to move it to another place, so you might be better off creating a new document.","Q_Score":3,"Tags":"python,mongodb,mapreduce","A_Id":8666791,"CreationDate":"2011-12-29T02:33:00.000","Title":"How do I transform every doc in a large Mongodb collection without map\/reduce?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Apologies for the longish description.\nI want to run a transform on every doc in a large-ish Mongodb collection with 10 million records approx 10G. Specifically I want to apply a geoip transform to the ip field in every doc and either append the result record to that doc or just create a whole other record linked to this one by say id (the linking is not critical, I can just create a whole separate record).  Then I want to count and group by say city - (I do know how to do the last part).\nThe major reason I believe I cant use map-reduce is I can't call out to the geoip library in my map function (or at least that's the constraint I believe exists).\nSo I the central question is how do I run through each record in the collection apply the transform - using the most efficient way to do that.  \nBatching via Limit\/skip is out of question as it does a \"table scan\" and it is going to get progressively slower.\nAny suggestions?\nPython or Js preferred just bec I have these geoip libs but code examples in other languages welcome.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":477,"Q_Id":8663432,"Users Score":0,"Answer":"Actually I am also attempting another approach in parallel (as plan B) which is to use mongoexport.  I use it with --csv to dump a large csv file with just the (id, ip) fields.  Then the plan is to use a python script to do a geoip lookup and then post back to mongo as a new doc on which map-reduce can now be run for count  etc.  Not sure if this is faster or the cursor is.  We'll see.","Q_Score":3,"Tags":"python,mongodb,mapreduce","A_Id":8677503,"CreationDate":"2011-12-29T02:33:00.000","Title":"How do I transform every doc in a large Mongodb collection without map\/reduce?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem with links on my website. Please forgive me if this is asked somewhere else, but I have no idea how to search for this.\nA little background on the current situation:\nI've created a python program that randomly generates planets for a sci-fi game. Each created planet is placed in a text file to be viewed at a later time. The program asks the user how many planets he\/she wants to create and makes that many text files. Then, after all the planets are created, the program zips all the files into a file 'worlds.zip'. A link is then provided to the user to download the zip file.\nThe problem:\nThe first time I run this everything works perfectly fine. When run a second time, however, and I click the link to download the zip file it gives me the exact same zip file as I got the first time. When I ftp in and download the zip file directly I get the correct zip file, despite the link still being bad.\nThings I've tried:\nWhen I refresh the page the link is still bad. When I delete all my browser history the link is still bad. I've tried a different browser and that didn't work. I've attempted to delete the file from the web server and that didn't solve the problem. Changing the html file providing the link worked once, but didn't work a second time. \nSimplified Question:\nHow can I get a link on my web page to update to the correct file?\nI've spent all day trying to fix this. I don't mind looking up information or reading articles and links, but I don't know how to search for this, so even if you guys just give me links to other sites I'll be happy (although directly answering my question will always be appreciated :)).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":8674077,"Users Score":0,"Answer":"I don't know anything about Python, but in PHP, in some fopen modes, if a file is trying to be made with the same name as an existing file, it will cancel the operation.","Q_Score":0,"Tags":"python,html,web","A_Id":8674108,"CreationDate":"2011-12-29T22:08:00.000","Title":"Website Links to Downloadable Files Don't Seem to Update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am thinking of writing a bitboard in python or lisp. But I don't know how to ensure I would get a 64 bit integer in python. I have been reading documentation and found that mpz library returns a unsigned 32 bit integer. Is this true? If not what should I do?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":58013,"Q_Id":8676682,"Users Score":31,"Answer":"Python 2 has two integer types: int, which is a signed integer whose size equals your machine's word size (but is always at least 32 bits), and long, which is unlimited in size.\nPython 3 has only one integer type, which is called int but is equivalent to a Python 2 long.","Q_Score":10,"Tags":"python,integer,bit","A_Id":8676794,"CreationDate":"2011-12-30T06:05:00.000","Title":"getting 64 bit integer in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The question is, how do you make a robot for Robocode using Python? There seem to be two options:\n\nRobocode + Jython\nRobocode for .NET + Iron Python\n\nThere's some info for the first, but it doesn't look very robust, and none for the latter. Step by step, anyone?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1489,"Q_Id":8683501,"Users Score":1,"Answer":"As long as your java-class extends robocode.Robot everything is recognized as robot.\nIt doesn't matter where you put the class.","Q_Score":3,"Tags":"python,jython,robocode","A_Id":18469631,"CreationDate":"2011-12-30T20:00:00.000","Title":"Robocode + Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a SECRET_KEY,\nhow do i decompile a user password using python?\nI assume that the encryption method is sha1.\nthanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":8688762,"Users Score":5,"Answer":"You are asking the impossible.  The passwords are salted and hashed.  The way they're validated is by performing the same process on the re-supplied password.  There's no way to 'decrypt' it.","Q_Score":0,"Tags":"python,django,sha1","A_Id":8688811,"CreationDate":"2011-12-31T14:51:00.000","Title":"how to decompile user password in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have searched tutorials and documentation for gevent, but seems that there isn't lots of it.\nI have coded Python for several years, also I can code PHP + JavaScript + jQuery.\nSo, how would I create Omeglish chat, where one random person connects and then waits for another one to connect? I have understood that Omegle uses gevent, but my site would have to hold 200 - 1000 people simultaneously.\nBesides the server side, there should be fully functional client side too and I think it should be created with jQuery\/JavaScript.\nI would need little help with the coding part. I can code Python well, but I have no idea how I would make that kind of chat system nor what would be the best Python library for it.\nThe library doesn't have to be gevent but I have heard that it's very good for stuff like this.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2300,"Q_Id":8702080,"Users Score":1,"Answer":"If I've understood you right, you just need to link the second person with someone connected before. Think it's simple.\nThe greenlet working with a person who comes first  ('the first greenlet') just register somewhere it's inbound and outbound queues. The greenlet working with the second person gets this queues, unregister them and use for chat messages exchange.\nThe next person's greenlet finds out that there is no registered in\/out queues, registers its own and waits for the fourth. An so on.\nIs it what you need?","Q_Score":1,"Tags":"python,gevent","A_Id":8712328,"CreationDate":"2012-01-02T14:39:00.000","Title":"How would I create \"Omegle\"-like random chat with gevent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Update: The requirement is \"fixed length 9 digits\" so 460 000 000 138 should be 460 000 138\nI want to generate IDs on a special form such as 460 000 000 138 where 46 is the country code and the rest is the ID and this number always(?) has the same number of digits ie four pairs of threes.\nMy input is this ID that can be expected to be lower than some largest number. When starting the project from scratch the ID could be 1 and then just autoincrement as long as IDs don't collide (I probably would want a sequential count but that is tricky in distributed environment where actions can happen at the same time. \nSo input could be for example 138. I now want to fill with zeros and the country number, in this case Sweden (46) so the output should be 460 000 000 138\nSimilarly, if input is 1138 the output should be on the same form an fill with less zeroes ie 460 000 001 138\nSo I don't know how many zeroes I need. Can you help me? The solution should be in python. I will probably use the entity ID, fill with zeroes and add the country code and can you help me find an algorithm in python for that?\nAny help is greatly appreciated","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":171,"Q_Id":8706850,"Users Score":1,"Answer":"\"always(?)\" indeed. Sweden = 46 looks like you mean the telephone not-necessarily-a-country code which is VARIABLE LENGTH ... for example CHINA = 86, HONG KONG (not a country) = 852, CANADA = USA = 1. Is your ID allowed to be variable length or not?\nIf it is allowed to be variable, you would need do str(countrycode) + str(n).zfill(10) ... this allows n to be up to 10 digits.\nOtherwise, for a fixed total length of 12 digits, you would need str(countrycode) + str(n).zfill(12 - len(str(countrycode)))","Q_Score":0,"Tags":"python,google-cloud-datastore","A_Id":8709167,"CreationDate":"2012-01-03T00:53:00.000","Title":"Generating IDs how to make IDs same length using zeroes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can i copy a .exe file through python? I tried to read the file and then write the contents to another but everytime i try to open the file it say ioerror is directory. Any input is appreciated.\nEDIT:\nok i've read through the comments and i'll edit my code and see what happens. If i still get an error i'll post my code.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2980,"Q_Id":8707663,"Users Score":0,"Answer":"Use shutil.copyfile(src, dst) or shutil.copy(src, dst). It may not work in case of files in the C:\\Program Files\\ as they are protected by administrator rights by default.","Q_Score":0,"Tags":"python,executable","A_Id":8709784,"CreationDate":"2012-01-03T03:42:00.000","Title":"how to copy an executable file with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"How can i copy a .exe file through python? I tried to read the file and then write the contents to another but everytime i try to open the file it say ioerror is directory. Any input is appreciated.\nEDIT:\nok i've read through the comments and i'll edit my code and see what happens. If i still get an error i'll post my code.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":2980,"Q_Id":8707663,"Users Score":1,"Answer":"Windows Vista and 7 will restrict your access to files installed into the Programs directories. Unless you run with UAC privileges you will never be able to open them.\nI hope I'm interpreting your error properly. In the future it is best to copy and paste the actual error message into your question.","Q_Score":0,"Tags":"python,executable","A_Id":8707865,"CreationDate":"2012-01-03T03:42:00.000","Title":"how to copy an executable file with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i need to know how share variable between two program,\nbasically the go program have to write a variable ,like a string, and the python program have to read this variable.\nPlease help me, thank you in advance.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":247,"Q_Id":8715435,"Users Score":1,"Answer":"use standard streams. use a simple printf type command to print the string to stdout.  then read it with a raw_input() in python.\nrun the two programs like so:\n.\/output | .\/read.py","Q_Score":0,"Tags":"python,variables,environment-variables,go,share","A_Id":8715483,"CreationDate":"2012-01-03T16:37:00.000","Title":"how to share variable between python and go language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i need to know how share variable between two program,\nbasically the go program have to write a variable ,like a string, and the python program have to read this variable.\nPlease help me, thank you in advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":247,"Q_Id":8715435,"Users Score":1,"Answer":"In Windows, most common way to do communication between two processes is \"Named Pipe\" (could also be tcp\/ip, web service, etc...). \nA ugly but lighter way is to write the value to a file, and read it from python.","Q_Score":0,"Tags":"python,variables,environment-variables,go,share","A_Id":8752696,"CreationDate":"2012-01-03T16:37:00.000","Title":"how to share variable between python and go language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I don't know if this has been answered before(i looked online but couldn't find one), but how can i send a file (.exe if possible) over a network to another computer that is connected to the network? I tried sockets but i could only send strings and i've tried to learn ftplib but i don't understand it at all or if ftp is even what i am looking for, so i am at a complete standstill. Any input is appreciated (even more so if someone can explain FTP, is it like socket? All the examples i've seen don't have a server program where the client can connect to.)","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":24645,"Q_Id":8721870,"Users Score":3,"Answer":"ZeroMQ helps to replace sockets. \nYou can send an entire file in one command.\nA ZMQ 'party' can be written in any major language and for a given ZMQ-powered software, it doesnt matter what the other end it written in.\nFrom their site:\n\nIt gives you sockets that carry whole messages across various\n  transports like in-process, inter-process, TCP, and multicast. You can\n  connect sockets N-to-N with patterns like fanout, pub-sub, task\n  distribution, and request-reply.","Q_Score":7,"Tags":"python,file,sockets","A_Id":8722433,"CreationDate":"2012-01-04T04:03:00.000","Title":"How to transfer a file between two connected computers in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in a red hat environment.\nI need to move a file from server A to server B when a file is available in a folder F.\nTHere's no constraint on the method used. Is it possible to trigger this event in python or any other scripts?\nIt could be run as a daemon but I'm not sure how to do that.\nAny advices?","AnswerCount":6,"Available Count":1,"Score":-0.0333209931,"is_accepted":false,"ViewCount":176,"Q_Id":8731179,"Users Score":-1,"Answer":"This is a job for cron. Cron man, man cron!","Q_Score":2,"Tags":"python,bash,redhat","A_Id":8732259,"CreationDate":"2012-01-04T17:26:00.000","Title":"How to start a script based on an event?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a two dimensional table (Matrix)\nI need to process each line in this matrix independently from the others.\nThe process of each line is time consuming.\nI'd like to use parallel computing resources in our university (Canadian Grid something)\nCan I have some advise on how to start ? I never used parallel computing before.\nThanks :)","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1155,"Q_Id":8736396,"Users Score":0,"Answer":"Like the commentators have said, find someone to talk to in your university.  The answer to your question will be specific to what software is installed on the grid.  If you have access to a grid, it's highly likely you also have access to a person whose job it is to answer your questions (and they will be pleased to help) - find this person!","Q_Score":2,"Tags":"python","A_Id":8741894,"CreationDate":"2012-01-05T01:13:00.000","Title":"Parallel computing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a folder A which contains some Python files and __init__.py.\nIf I copy the whole folder A into some other folder B and create there a file with \"import A\", it works. But now I remove the folder and move in a symbolic link to the original folder. Now it doesn't work, saying \"No module named foo\".\nDoes anyone know how to use symlink for importing?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":22941,"Q_Id":8749108,"Users Score":8,"Answer":"This kind of behavior can happen if your symbolic links are not set up right. For example, if you created them using relative file paths. In this case the symlinks would be created without error but would not point anywhere meaningful.\nIf this could be the cause of the error, use the full path to create the links and check that they are correct by lsing the link and observing the expected directory contents.","Q_Score":17,"Tags":"python,import,symlink","A_Id":41005775,"CreationDate":"2012-01-05T20:13:00.000","Title":"Python: import symbolic link of a folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to\/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":8772087,"Users Score":0,"Answer":"You can store it for as long as you want. It's just a file. However, if your data structures start becoming complicated, it can become tedious and time consuming to unpickle, update and pickle the data again. Also, it's just file access so you have to handle concurrency issues by yourself.","Q_Score":0,"Tags":"python,pickle","A_Id":8772278,"CreationDate":"2012-01-07T18:46:00.000","Title":"how long can i store data in cPickle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to\/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":8772087,"Users Score":0,"Answer":"cPickle is just a faster implementation of pickle. You can use it to convert a python object to its string equivalent and retrieve it back by unpickling. \nYou can do one of the two things with a pickled object:\n\nDo not write to a file\nIn this case, the scope of your pickled data is similar to that of\nany other variable.\nWrite to a file\nWe can write this pickled data to a file and read it whenever we\nwant and get back the python objects\/data structures. Your pickled\ndata is safe as long as your pickled file is stored on the disk.","Q_Score":0,"Tags":"python,pickle","A_Id":8772238,"CreationDate":"2012-01-07T18:46:00.000","Title":"how long can i store data in cPickle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to\/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":8772087,"Users Score":0,"Answer":"No. cPickle just writes data to files and reads it back; why would you think there would be a limit?","Q_Score":0,"Tags":"python,pickle","A_Id":8772177,"CreationDate":"2012-01-07T18:46:00.000","Title":"how long can i store data in cPickle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I was flicking through my Facebook Timeline, and started to look at some old posts I made in 2009~2010. And they're a bit stupid and I'd like to remove them or change the privacy settings on them. \nThere are too many to do it individually, so I've been looking at the Graph API. However, I have been unable to find anything about changing the privacy settings of posts, or even searching for posts made in a specific date range. \nSo here is the information that I want:\nIs it possible to change privacy settings for OLD posts via the Graph API?\nIs it possible to search the Graph API for posts in a particular date range? Preferably before 31st December 2010.\nIf it is possible, how do you do it!?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":740,"Q_Id":8779159,"Users Score":1,"Answer":"1) Nope.\n2) Yes, you can use the Graph API and HTTP Get me\/feed?until={date}","Q_Score":4,"Tags":"php,python,facebook,api,facebook-graph-api","A_Id":8781271,"CreationDate":"2012-01-08T16:29:00.000","Title":"Changing privacy of old Facebook posts using the Graph API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm searching for a single function to convert RGB tuple (255, 255, 255) or HTML hex (#FFFFFF) to X11 color (0...255 int) to manage colors in Unix terminal. I've looked over the internet but I didn't find anything like that, so I'm asking for code or link to a website that contains code or information about how I can do this in Python.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2309,"Q_Id":8790555,"Users Score":1,"Answer":"You can't convert to x11 colors automatically.\nx11 colors are basically just names mapped to arbitrary RGB values, so the only way to get from RGB to x11 is to reverse the map.\nIf you want to convert an RGB color that isn't in x11 to the closest match in x11 that would be pretty difficult.","Q_Score":2,"Tags":"python,colors,hex,x11,rgb","A_Id":8791192,"CreationDate":"2012-01-09T15:12:00.000","Title":"Convert HTML HEX Color or RGB tuple to X11 color","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm searching for a single function to convert RGB tuple (255, 255, 255) or HTML hex (#FFFFFF) to X11 color (0...255 int) to manage colors in Unix terminal. I've looked over the internet but I didn't find anything like that, so I'm asking for code or link to a website that contains code or information about how I can do this in Python.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2309,"Q_Id":8790555,"Users Score":1,"Answer":"If I understand your question properly, I don't think you can do this. The RGB tuple (and its representation as a 6-digit hex number for HTML) represents a specific color in the RGB colorspace. The single integer in the range 0 to 255 you mention for the Unix terminal isn't a specific color, but rather an index into a color table. As an example, color 15 on one terminal may be #ff0000, but #33ff33 on another. There really isn't a conversion between the two.","Q_Score":2,"Tags":"python,colors,hex,x11,rgb","A_Id":8791219,"CreationDate":"2012-01-09T15:12:00.000","Title":"Convert HTML HEX Color or RGB tuple to X11 color","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python 2.7.1.  I can't figure out how to launch the IDLE IDE.  I am told it comes already installed with python, but I can't find it using spotlight.","AnswerCount":10,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":100963,"Q_Id":8792044,"Users Score":13,"Answer":"One way to run IDLE from spotlight or an icon in the Applications folder is to build a quick Automation for it. As mentioned by other commentators, this probably isn't necessary for Python 3, as it creates a shortcut automatically, and some hand-installed versions have tools to do this automatically.  But if you want to roll your own:\n\nYou'll need to know the terminal command to open your version of IDLE.  On my Mac right now (early 2016), running python 2.7.10, it is \"idle2.7\"\nUsing spotlight, or in the Utilities folder, open \"Automator\"\nChoose an \"Application\" type document.\nMake sure \"Actions\" is selected in the gray bar, upper left.\nIn the actions column, find \"Run Shell Script\" and double-click it, or drag it to the workflow area on the right.\nEnter the terminal command in the parameters box that appears.\nSave your automation (I called mine \"IDLE\" and put it in the Applications folder, to make it easy).\nIt's now available (as soon as spotlight indexes it) via all the normal methods.  The only side-effect will be that while it's running, your menu bar will have a spinning gear over in the tray area next to the clock.  This indicates an automation workflow is running.  Once you close IDLE, it will go away.","Q_Score":46,"Tags":"python,python-idle","A_Id":34907888,"CreationDate":"2012-01-09T16:50:00.000","Title":"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python 2.7.1.  I can't figure out how to launch the IDLE IDE.  I am told it comes already installed with python, but I can't find it using spotlight.","AnswerCount":10,"Available Count":6,"Score":0.0399786803,"is_accepted":false,"ViewCount":100963,"Q_Id":8792044,"Users Score":2,"Answer":"first to launch the terminal CMD+space\nsecond to input idle3\nthe idle will be activated automatically.","Q_Score":46,"Tags":"python,python-idle","A_Id":45255372,"CreationDate":"2012-01-09T16:50:00.000","Title":"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python 2.7.1.  I can't figure out how to launch the IDLE IDE.  I am told it comes already installed with python, but I can't find it using spotlight.","AnswerCount":10,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":100963,"Q_Id":8792044,"Users Score":63,"Answer":"In the stock Mac OS X python installation, idle is found in \/usr\/bin, which is not (easily) accessible from Finder and not indexed by Spotlight. The quickest option is to open the Terminal utility and type 'idle' at the prompt. For a more Mac-like way of opening it, you'll have to create a small app or shortcut to launch \/usr\/bin\/idle for you (an exercise left to the reader).","Q_Score":46,"Tags":"python,python-idle","A_Id":8792311,"CreationDate":"2012-01-09T16:50:00.000","Title":"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python 2.7.1.  I can't figure out how to launch the IDLE IDE.  I am told it comes already installed with python, but I can't find it using spotlight.","AnswerCount":10,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":100963,"Q_Id":8792044,"Users Score":0,"Answer":"As to the earlier questions about starting IDLE: you can certainly start it from the command line. Also, if you installed Python using Homebrew, you can run 'brew linkapps' (from the command line); that will place an app for IDLE (among other things) in Launchpad (Applications folder).","Q_Score":46,"Tags":"python,python-idle","A_Id":32878774,"CreationDate":"2012-01-09T16:50:00.000","Title":"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python 2.7.1.  I can't figure out how to launch the IDLE IDE.  I am told it comes already installed with python, but I can't find it using spotlight.","AnswerCount":10,"Available Count":6,"Score":0.0199973338,"is_accepted":false,"ViewCount":100963,"Q_Id":8792044,"Users Score":1,"Answer":"After you launch idle from the command line (make sure idle shell window has focus), click File, click \"New File\". A new window opens; this is your editor.\nType your program in the editor. Click \"File\", click \"Save As...\". Save your file somewhere with any name you choose, and a \".py\" extension to the file name. \nClick \"Run\", click \"Run Module\" (or, F5). Assuming no errors, the results will appear in the Shell window. Edit your file & repeat as necessary.","Q_Score":46,"Tags":"python,python-idle","A_Id":32877359,"CreationDate":"2012-01-09T16:50:00.000","Title":"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python 2.7.1.  I can't figure out how to launch the IDLE IDE.  I am told it comes already installed with python, but I can't find it using spotlight.","AnswerCount":10,"Available Count":6,"Score":0.0199973338,"is_accepted":false,"ViewCount":100963,"Q_Id":8792044,"Users Score":1,"Answer":"The answer of Matthewm1970 works like a charm!\nAnd if you add an & to your shell command, the automation script will end immediately. There is no spinning gear. Like so:\n\n\/usr\/local\/bin\/idle3.5&\n\nNote the ampersand.\nCheers.\n-melle","Q_Score":46,"Tags":"python,python-idle","A_Id":35586250,"CreationDate":"2012-01-09T16:50:00.000","Title":"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am interested in doing some snail mail based surveys but I am looking for quick ways to digitize the surveys they send back.\nSo if I had a question and 5 boxes beneath it where you would indicate your opinion by checking the appropriate box, does anything exist where I could scan it and run it through a piece of software that spit out the responses. \nEdit clarification:\nI am inquiring about what I need to do after the paper has been digitized.  I want to write some code that looks at an image file and recognizes which box has been marked in and outputs a representation of the respondents answers. \nI would be looking at a page scanned from a desktop scanner or something similar.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2785,"Q_Id":8793702,"Users Score":2,"Answer":"I don't really see what this has to do with python, unless of course you've already digitized the results and are now looking to tally up the results. It sounds like you still need to scan the results in and as far as I know, python doesn't have any direct capabilities of doing something like that. You're going to have to get your hands on a scanner first, and only then can you use python to read through the data.","Q_Score":3,"Tags":"python,icr","A_Id":8793854,"CreationDate":"2012-01-09T19:02:00.000","Title":"any Python tools for reading Scantron-style data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possibe to copy python modules from one virtualenv to another.If so how is this done?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":31912,"Q_Id":8793877,"Users Score":1,"Answer":"seems like we can't just copy one virtualenv as another one.\neven you chnage the $VIRTUAL_ENV in the activate file, it still act as in origin virtualenv and pip will install all the packages to origin site-packages\/","Q_Score":34,"Tags":"python,django,virtualenv,pip","A_Id":43931969,"CreationDate":"2012-01-09T19:17:00.000","Title":"how to copy modules from one virtualenv to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possibe to copy python modules from one virtualenv to another.If so how is this done?","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":31912,"Q_Id":8793877,"Users Score":0,"Answer":"I was facing a problem installing 'wordcloud' on another Python venv on Windows 10. Package was installed on another project, same machine.\ncopy \"wordcloud\" and \"wordcloud-1.8.1.dist-info\" folders from Users\/<user>\/PycharmProjects\/<projectname>\/venv\/Lib\/site-packages and paste to your new project \/<projectname>\/venv\/Lib\/site-packages.","Q_Score":34,"Tags":"python,django,virtualenv,pip","A_Id":69423767,"CreationDate":"2012-01-09T19:17:00.000","Title":"how to copy modules from one virtualenv to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possibe to copy python modules from one virtualenv to another.If so how is this done?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":31912,"Q_Id":8793877,"Users Score":1,"Answer":"Usually you are able to copy the .egg-info from the lib\/site-packages folder of the virtualenv to the lib\/site-packages of the other environment.","Q_Score":34,"Tags":"python,django,virtualenv,pip","A_Id":8794087,"CreationDate":"2012-01-09T19:17:00.000","Title":"how to copy modules from one virtualenv to another","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Haskell's type system I know that at some point in the program, a variable must contain say an Int of a list of strings. For code that compiles, the type checker offers certain guarantees that for instance I'm not trying to add an Int and a String.\nAre there any tools to provide similar guarantees for Python code?\nI know about and practice TDD.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":497,"Q_Id":8796565,"Users Score":2,"Answer":"Python is dynamic and strongly typed programming language. What that means is that you can define a variable without explicitly stating its type, but when you first use that variable it becomes bound to a certain type.\nFor example,\nx = 5 is an integer, and so now you cannot concatenate it with string, e.g. x+\"hello\"","Q_Score":1,"Tags":"python,types","A_Id":8796638,"CreationDate":"2012-01-09T23:18:00.000","Title":"When coding in Python, how do I achieve guarantees of correctness similar to those I get with Haskell's type system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried googling this, couldn't find an answer, searched here, couldn't find an answer.  Has anyone looked into whether it's thread safe to write to a Serial() object (pyserial) from thread a and do blocking reads from thread b?\nI know how to use thread synchronization primitives and thread-safe data structures, and in fact my current form of this program has a thread dedicated to reading\/writing on the serial port and I use thread-safe data structures to coordinate activities in the app.\nMy app would benefit greatly if I could write to the serial port from the main thread (and never read from it), and read from the serial port using blocking reads in the second thread (and never write to it).  If someone really wants me to go into why this would benefit the app I can add my reasons.  In my mind there would be just one instance of Serial() and even while thread B sits in a blocking read on the Serial object, thread A would be safe to use write methods on the Serial object.\nAnyone know whether the Serial class can be used this way?\nEDIT: It occurs to me that the answer may be platform-dependent.  If you have any experience with a platform like this, it'd be good to know which platform you were working on.\nEDIT: There's only been one response but if anyone else has tried this, please leave a response with your experience.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":10755,"Q_Id":8796800,"Users Score":14,"Answer":"I have done this with pyserial.  Reading from one thread and writing from another should not cause problems in general, since there isn't really any kind of resource arbitration problem.  Serial ports are full duplex, so reading and writing can happen completely independently and at the same time.","Q_Score":10,"Tags":"python,serial-port,pyserial","A_Id":8808218,"CreationDate":"2012-01-09T23:46:00.000","Title":"pyserial - possible to write to serial port from thread a, do blocking reads from thread b?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried googling this, couldn't find an answer, searched here, couldn't find an answer.  Has anyone looked into whether it's thread safe to write to a Serial() object (pyserial) from thread a and do blocking reads from thread b?\nI know how to use thread synchronization primitives and thread-safe data structures, and in fact my current form of this program has a thread dedicated to reading\/writing on the serial port and I use thread-safe data structures to coordinate activities in the app.\nMy app would benefit greatly if I could write to the serial port from the main thread (and never read from it), and read from the serial port using blocking reads in the second thread (and never write to it).  If someone really wants me to go into why this would benefit the app I can add my reasons.  In my mind there would be just one instance of Serial() and even while thread B sits in a blocking read on the Serial object, thread A would be safe to use write methods on the Serial object.\nAnyone know whether the Serial class can be used this way?\nEDIT: It occurs to me that the answer may be platform-dependent.  If you have any experience with a platform like this, it'd be good to know which platform you were working on.\nEDIT: There's only been one response but if anyone else has tried this, please leave a response with your experience.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":10755,"Q_Id":8796800,"Users Score":0,"Answer":"I would recommend to modify Thread B from \"blocking read\" to \"non blocking read\/write\". Thread B would become your serial port \"Daemon\".\nThread A could run at full speed for a friendly user interface or perform any real time operation.\nThread A would write a message to Thread B instead of trying to write directly to the serial port. If the size\/frequency of the messages is low, a simple shared buffer for the message itself and a flag to indicate that a new message is present would work. If you need higher performance, you should use a stack. This is actually implemented simply using an array large enough to accumulate many message to be sent and two pointers. The write pointer is updated only by Thread A. The read pointer is updated only by Thread B.\nThread B would grab the message and sent it to the serial port. The serial port should use the timeout feature so that the read serial port function release the CPU, allowing you to poll the shared buffer and, if any new message is present, send it to the serial port. I would use a sleep at that point to limit the CPU time used by Thread B.. Then, you can make Thread B loop to the read serial port function. If the serial port timeout is not working right, like if the USB-RS232 cable get unplugged, the sleep function will make the difference between a good Python code versus the not so good one.","Q_Score":10,"Tags":"python,serial-port,pyserial","A_Id":14660364,"CreationDate":"2012-01-09T23:46:00.000","Title":"pyserial - possible to write to serial port from thread a, do blocking reads from thread b?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried googling this, couldn't find an answer, searched here, couldn't find an answer.  Has anyone looked into whether it's thread safe to write to a Serial() object (pyserial) from thread a and do blocking reads from thread b?\nI know how to use thread synchronization primitives and thread-safe data structures, and in fact my current form of this program has a thread dedicated to reading\/writing on the serial port and I use thread-safe data structures to coordinate activities in the app.\nMy app would benefit greatly if I could write to the serial port from the main thread (and never read from it), and read from the serial port using blocking reads in the second thread (and never write to it).  If someone really wants me to go into why this would benefit the app I can add my reasons.  In my mind there would be just one instance of Serial() and even while thread B sits in a blocking read on the Serial object, thread A would be safe to use write methods on the Serial object.\nAnyone know whether the Serial class can be used this way?\nEDIT: It occurs to me that the answer may be platform-dependent.  If you have any experience with a platform like this, it'd be good to know which platform you were working on.\nEDIT: There's only been one response but if anyone else has tried this, please leave a response with your experience.","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":10755,"Q_Id":8796800,"Users Score":4,"Answer":"I've used pyserial in this way on Linux (and Windows), no problems !","Q_Score":10,"Tags":"python,serial-port,pyserial","A_Id":8814172,"CreationDate":"2012-01-09T23:46:00.000","Title":"pyserial - possible to write to serial port from thread a, do blocking reads from thread b?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is probably a nice document that will help me.  Please point to it.\nIf I write a Thrift server using Python what is the best way to deploy it in a production environment?  All I can find is examples of using the Python based servers that come with the distribution.  How can I use Apache as the server platform for example?  Will it support persistent connections?\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1005,"Q_Id":8808476,"Users Score":1,"Answer":"I've read that you can deploy it behind nginx using the upstream module to point to the thrift server. You should have at least one CPU core per thrift server and one left for the system (i.e. if you're on a quad-core, you should only run 3 thrift servers, leaving one left over for the system).","Q_Score":5,"Tags":"python,thrift","A_Id":8826673,"CreationDate":"2012-01-10T18:27:00.000","Title":"how to deploy a hardened Thrift server for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"There is probably a nice document that will help me.  Please point to it.\nIf I write a Thrift server using Python what is the best way to deploy it in a production environment?  All I can find is examples of using the Python based servers that come with the distribution.  How can I use Apache as the server platform for example?  Will it support persistent connections?\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1005,"Q_Id":8808476,"Users Score":1,"Answer":"I assume that you are using the Python THttpServer? A couple of notes:\n1) There is a comment in that code that reads\n\"\"\"\nThis class is not very performant, but it is useful (for example) for\n  acting as a mock version of an Apache-based PHP Thrift endpoint.\n\"\"\"\nI wouldn't recommend that you use it in production if you care about performance. If you read through this code a bit, you'll find that it is fairly easy to re-implement it using a different HTTP server of your choosing. There are a number of good options in the Python ecosystem.\n2) Also if you read the code, you'll find that Thrift HTTP servers are regular old HTTP servers. They accept all traffic on a single path ('\/' by default) and direct the message to the appropriate method by reading routing information encoded into the message itself (using the Thrift \"processor\" construct). You should be able to set up Apache\/nginx\/whatever in the normal way and simply forward all traffic to '\/' on the host and port you are running on.","Q_Score":5,"Tags":"python,thrift","A_Id":17220313,"CreationDate":"2012-01-10T18:27:00.000","Title":"how to deploy a hardened Thrift server for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using IPython 0.10.2 and Python 2.7 right now. I start one ipcontroller and 20 ipengines on my cluster. The code structure is very simple. I just use MultiEngineClient.execute() methods and MultiEngineClient dictionary interface (e.g., mec['a'] = b) . My current application needs to run nearly two days. However, after 10 hours running, I find that ipcontroller has used 3.1 GB memory. I do use MultiEngineClient.clear_properties(). But it never releases any memory. Does anyone know how to release the memory of ipcontroller ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":345,"Q_Id":8823830,"Users Score":0,"Answer":"Unfortunately, it may not be possible to free memory effectively in the Controller in IPython 0.10, but the MultiEngineClient.clear_pending_results() method may help.\nThe controller in 0.11-0.12 can use a database (sqlite or mongodb) to store results, and has been seen to run for a long time, with gigabytes of throughput without unreasonable long-term growth.","Q_Score":0,"Tags":"ipython","A_Id":8825937,"CreationDate":"2012-01-11T17:29:00.000","Title":"Huge memory usage by ipcontroller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to have auto-fill set to 79 columns for code sections and 72 for docstrings to get automatic PEP8 compliance. There seems to be an option to do this for Lisp mode (emacs-lisp-docstring-fill-column) but not for Python.\nIs there an enhanced python-mode.el around somewhere that includes this?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2249,"Q_Id":8823924,"Users Score":4,"Answer":"I don't know how to do that, but I've never felt the need.  It is so easy to use C-x f to change the fill column.  And you can just hit M-p to reuse the last value you entered.  Just C-x f M-p --- 3 keystrokes.","Q_Score":14,"Tags":"python,emacs,docstring,pep8,autoformatting","A_Id":8827727,"CreationDate":"2012-01-11T17:36:00.000","Title":"In emacs Python mode, how do I set a different auto-fill width for docstrings and code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Two part question:\nI have a 10x10 QTableWidget with QTableWidgetItem in each cell.\nFor some reason, clicking on a cell is not sufficient to edit it, I need to double-click the cell to enter it. \n\nIs there a way to change this behavior to single click \nIs there a way to have 2nd cell in 1st row selected and ready for editing by default when window is created?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3799,"Q_Id":8826688,"Users Score":2,"Answer":"You can also use setCurrentCell.\ntable.setCurrentCell(0,1)\nQTableWidget.setCurrentCell (self, int row, int column)","Q_Score":2,"Tags":"python,pyqt,pyqt4,editing,qtablewidget","A_Id":8948046,"CreationDate":"2012-01-11T21:11:00.000","Title":"QTableWidget how to have a cell selected for editing from code and\/or with single click","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my school our teacher is holding a Rock, paper, scissors bot competition. I know how to program in Python, but I have no idea how to program a bot that would have a bigger chance of success than one that randomly selects its weapons. I think it is possible to store all previous moves and then look for patterns in order to defy attacks. Am I going in a right direction? Any ideas?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6603,"Q_Id":8827703,"Users Score":7,"Answer":"It is proven for rock-paper-scissors that a random bot will be at the median of each rank.\nTherefore, I'd create a set of bots, each calculating one heuristic and running on the background on parallel. For each turn, each bot will virtually \"draw\" and check if he had won or lost - if it would have played this turn. Each bot will keep track on how many games it would have won if it played, and how many it would have lost.\nOne of these bots will be the random attacker.\nEach time it is your turn: choose which bot won so far the most [greedy] - and use it.\nUsing this approach you are guaranteed  to be at the top median of your class! [with enough rounds of games of course]","Q_Score":10,"Tags":"python,algorithm,theory","A_Id":8827797,"CreationDate":"2012-01-11T22:33:00.000","Title":"Rock paper Scissors bot algorithm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my school our teacher is holding a Rock, paper, scissors bot competition. I know how to program in Python, but I have no idea how to program a bot that would have a bigger chance of success than one that randomly selects its weapons. I think it is possible to store all previous moves and then look for patterns in order to defy attacks. Am I going in a right direction? Any ideas?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6603,"Q_Id":8827703,"Users Score":0,"Answer":"Where might be some potential profit in trying to figure out the strategies of the other bots, for instance, if it's a forced participation, there will be some lazy student who makes up a bot that would always throw up scissors.\nI propose another strategy (I've heard about it on some similar competition, but can't track the source anymore), suppose that you could let several bots running (if not, cooperate with some of your classmates to run this strategy). \nLet's say you have 4 bots A,B,C,D \nImagine each bot play 100 times against the others. Let your B,C,D bots play for the first let's say 10 times play a strategy that would let recognise it as a bot from your team, say 'RPPSPPSSRS', let your A bot play some other strategy that would let it be recognized by the bots B,C,D. \nThen, in the next 90 round let the bots B,C,D lose ('paper') to the A and play random against the others. Let the bot A win ('scissors') from the B,C,D and play random against the others.\nThus, the bot A gets a huge advantage.","Q_Score":10,"Tags":"python,algorithm,theory","A_Id":8827880,"CreationDate":"2012-01-11T22:33:00.000","Title":"Rock paper Scissors bot algorithm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do people usually extract the shape of the lips once the mouth region is found (in my case using haar cascade)? I tried color segmentation and edge\/corner detection but they're very inaccurate for me. I need to find the two corners and the very upper and lower lip at the center. I've heard things about active appearance models but I'm having trouble understanding how to use this with python and I don't have enough context to figure out if this is even the conventional method for detecting different parts of the lips. Is that my best choice or do I have other options? If I should use it, how would I get started with it using python and simplecv?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4301,"Q_Id":8840127,"Users Score":0,"Answer":"The color segementation involves \"gradient of the difference between the pseudo-hue and luminance (obtaining hybrid contours)\". Try googling for qouted string and you will find multiple research papers on this topic.","Q_Score":5,"Tags":"python,opencv,face-detection,simplecv","A_Id":33917789,"CreationDate":"2012-01-12T18:15:00.000","Title":"OpenCV Lip Segmentation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to replace child elements from one tree to another , based on some criteria. I can do this using Comprehension ? But how do we replace element in ElementTree?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6654,"Q_Id":8845456,"Users Score":2,"Answer":"You can't replace an element from the ElementTree you can only work with Element.\nEven when you call ElementTree.find() it's just a shortcut for getroot().find().\nSo you really need to:\n\nextract the parent element\nuse comprehension (or whatever you like) on that parent element\n\nThe extraction of the parent element can be easy if your target is a root sub-element (just call getroot()) otherwise you'll have to find it.","Q_Score":6,"Tags":"python,elementtree","A_Id":8848549,"CreationDate":"2012-01-13T03:15:00.000","Title":"How can i do replace a child element(s) in ElementTree","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple need with Quality Center 10\nIf you noticed in Quality Center Client on IE 8 -> Test Plan. If you create a new Testcase with Test Type = 'VAPI-XP-TEST', it will ask you for Script Language and Script Name. I have selected Script Language to be Python. Once you have gone through this process of creating a new testcase, the testcase is pre-populated with a Default Python Script.\nI wish to know how I can modify that Base Default Python Script so that the future new testcases will have my default Python Script? Is there any way to do the same through OTA API?\nThanks,\nAmit","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2376,"Q_Id":8858306,"Users Score":0,"Answer":"Can you post the default script here ? Iam not sure why you cant edit it ? You can edit the script as you want. \nThere are 2 ways you can run the QC script one using VAPI-XP-TEST as you are doing , in that case you can use tdhelper object for updating the results.\nSecond is OTA-API which you  can use python script externally to connect to QC and execute your tests and also update run results. there is lot of documentation available on QC help for OTA-API","Q_Score":0,"Tags":"python,hp-quality-center","A_Id":13123269,"CreationDate":"2012-01-13T22:47:00.000","Title":"Quality Center VAPI-XP-TEST - Modify Default Python Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a text file containing tabular data.  What I need to do is automate the task of writing to a new text file that is comma delimited instead of space delimited, extract a few columns from existing data, reorder the columns.  \nThis is a snippet of the first 4 lines of the original data:\n\nNumber of rows: 8542\n Algorithm  |Date   |Time   |Longitude  |Latitude   |Country    \n 1  2000-01-03  215926.688  -0.262  35.813  Algeria \n 1  2000-01-03  215926.828  -0.284  35.817  Algeria\n\nHere is what I want in the end:\n\nLongitude,Latitude,Country,Date,Time\n-0.262,35.813,Algeria,2000-01-03,215926.688\n\nAny tips on how to approach this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18146,"Q_Id":8858946,"Users Score":0,"Answer":"str.split() without any arguments will split by any length of whitespace. operator.itemgetter() takes multiple arguments, and will return a tuple.","Q_Score":5,"Tags":"python","A_Id":8858983,"CreationDate":"2012-01-14T00:11:00.000","Title":"converting a space delimited file to a CSV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The documentation only talks about how to do it from ruby.","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":6640,"Q_Id":8859532,"Users Score":4,"Answer":"Get the connection string settings by running heroku config on the command line after installed the add-on to your heroku app.\nThere will be an entry with the key MONGOLAB_URI in this form:\nMONGOLAB_URI => mongodb:\/\/user:pass@xxx.mongolab.com:27707\/db\nSimply the info from the uri in python by creating a connection from the uri string.","Q_Score":3,"Tags":"python,mongodb,heroku,mlab","A_Id":8859701,"CreationDate":"2012-01-14T01:57:00.000","Title":"How can I use the mongolab add-on to Heroku from python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a netcdf file that I would like to convert to an image (joed, png, gif) using a command line tool.\nIs someone could please help me with the library name and possibly a link to how it is done.\nRegards\nDavid","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8951,"Q_Id":8864599,"Users Score":0,"Answer":"IDV is a good visualization tool for NetCDF, but, as far as I know, there is no command line interface.\nI would recommend Matlab. It has read and write functions for NetCDF as well as an extensive plotting library...probably one of the best. You can then compile the matlab code and run it from the command line.","Q_Score":6,"Tags":"python,netcdf","A_Id":9473690,"CreationDate":"2012-01-14T19:03:00.000","Title":"Convert netcdf to image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how to draw images using pygame. I know how to load them.\nI have made a blank window.\nWhen I use screen.blit(blank, (10,10)), it does not draw the image and instead leaves the screen blank.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":36330,"Q_Id":8873219,"Users Score":3,"Answer":"After using blit or any other update on your drawing surface, you have to call pygame.display.flip() to actually update what is displayed.","Q_Score":16,"Tags":"python,image,pygame","A_Id":8873270,"CreationDate":"2012-01-15T20:43:00.000","Title":"What is a good way to draw images using pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As part of a deployment procedure, I upload Python source packages (generated with setup.py sdist) to a remote server and install them in a virtualenv using pip install mypackage-1.0.tar.bz2.\nThis has worked for long time both for new installs and upgrades (specifically, upgrades without a change in the package's version number). For some reason I cannot figure out, since yesterday, it fails to upgrade the packages. No error is reported, the files are just not changed. Now I'm sure I'm doing something differently but I can't explain the change in behaviour.\nI can upgrade the package with the -U --no-deps flags, but this technique forces the deployment script to differentiate between first install and upgrades (--no-deps is required as otherwise dependencies would be downloaded each time from pypi).\nAny ideas how I can get a single pip command to do installs and upgrades?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":8878210,"Users Score":1,"Answer":"pip install package will only be executed with you don't have this package already.\nWith you want to upgrade the package you'll have to use: pip install -U package","Q_Score":0,"Tags":"python,virtualenv,pip","A_Id":10285156,"CreationDate":"2012-01-16T09:50:00.000","Title":"Python package won't upgrade","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been happily using Aptana for a PHP project. As of yesterday evening, it's been crashing repeatedly and causing no end of grief!\nI can pinpoint two events which may have caused this:\n\nYesterday evening I seem to have hit a combination of keyboard keys which has resulted in 'Python not configured' appearing at the top of the App explorer window. I can't see anyway to turn Python off.\nI have also been trying to get Git to behave, and (away from Aptana) have been making changes to TortoiseGit and installing SmartGit.\n\nAny ideas? (Specifically, can I turn off Python somehow to see if this helps?)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":308,"Q_Id":8879102,"Users Score":0,"Answer":"i suggest you to click on:\nHELP -> About Aptana\nthen: Installation Details (button on the bottom left)\nin the new window you can remove software, or revert some installation\/configuration with with the \"installation history\" section.\nHope this help you","Q_Score":0,"Tags":"python,git,aptana","A_Id":8897929,"CreationDate":"2012-01-16T11:04:00.000","Title":"Aptana has started crashing - possibly due to Python or Git","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to see if a line contains words that matches a set of regex pattern?\nIf I have [regex1, regex2, regex3], and I want to see if a line matches any of those, how would I do this?\nRight now, I am using re.findall(regex1, line), but it only matches 1 regex at a time.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":55780,"Q_Id":8888567,"Users Score":51,"Answer":"You can use the built in functions any (or all if all regexes have to match) and a Generator expression to cycle through all the regex objects.\nany (regex.match(line) for regex in [regex1, regex2, regex3])\n(or any(re.match(regex_str, line) for regex in [regex_str1, regex_str2, regex_str2]) if the regexes are not pre-compiled regex objects, of course)\nHowever, that will be inefficient compared to combining your regexes in a single expression. If this code is time- or CPU-critical, you should try instead to compose a single regular expression that encompasses all your needs, using the special | regex operator to separate the original expressions.\nA simple way to combine all the regexes is to use the string join method:\nre.match(\"|\".join([regex_str1, regex_str2, regex_str2]), line)\nA warning about combining the regexes in this way: It can result in wrong expressions if the original ones already do make use of the | operator.","Q_Score":28,"Tags":"python,regex","A_Id":8888615,"CreationDate":"2012-01-17T01:19:00.000","Title":"Match a line with multiple regex using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to see if a line contains words that matches a set of regex pattern?\nIf I have [regex1, regex2, regex3], and I want to see if a line matches any of those, how would I do this?\nRight now, I am using re.findall(regex1, line), but it only matches 1 regex at a time.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":55780,"Q_Id":8888567,"Users Score":7,"Answer":"Try this new regex: (regex1)|(regex2)|(regex3).  This will match a line with any of the 3 regexs in it.","Q_Score":28,"Tags":"python,regex","A_Id":8888619,"CreationDate":"2012-01-17T01:19:00.000","Title":"Match a line with multiple regex using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have objects from various classes that work together to perform a certain task. The task requires a lot of parameters, provided by the user (through a configuration file). The parameters are used deep inside the system.\nI have a choice of having the controller object read the configuration file, and then allocate the parameters as appropriate to the next layer of objects, and so on in each layer. But the only objects themselves know which parameters they need, so the controller object would need to learn a lot of detail about every other object.\nThe other choice is to bundle all the parameters into a collection, and pass the whole collection into every function call (equivalently, create a global object that stores them, and is accessible to everyone). This looks and feels ugly, and would cause a variety of minor technical issues (e.g., I can't allow two objects to use parameters with the same name; etc.)\nWhat to do?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":8906265,"Users Score":1,"Answer":"I have used the \"global collection\" alternative in the past.\nIf you are concerned with naming: how would you handle this in your config file?  The way I see it, your global collection is a datastructure representing the same information you have in your config file, so if you have a way of resolving or avoiding name clashes in your cfg-file, you can do the same in your global collection.","Q_Score":0,"Tags":"python,design-patterns","A_Id":8908454,"CreationDate":"2012-01-18T06:48:00.000","Title":"how to make a lot of parameters available to the entire system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Well i have a question that i feel i've been answered several times, from what i found here. However, as a newbie, i can't really understand how to perform a really basic operation.\nHere's the thing :\n\ni have an .xls and when i use xlrd to get a value i'm just using \nsh.cell(0,0) (assuming that sh is my sheet);\nif what is in the cell is a string i get something like text:u'MyName' and i only want to keep the string 'MyName';\nif what is in the cell is a number i get something like number:201.0 and i only want to keep the integer 201.\n\nIf anyone can indicate me what i should to only extract the value, formatted as i want, thank you.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27320,"Q_Id":8909342,"Users Score":0,"Answer":"The correct answer to this is to simply use the Cell.value function. This will return a number or a Unicode string depending on what the cell contains.","Q_Score":9,"Tags":"python,xlrd","A_Id":43124531,"CreationDate":"2012-01-18T11:29:00.000","Title":"Python xlrd : how to convert an extracted value?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if any of you know where I could find a simple tutorial on the web maybe to make a very simplistic gui. I have no idea how to start out in code to make one so I need your help. What I want the gui to be used for is I have written a program that I want to be to use it on other computers that already don't have python on it. I have already made an executable but I would much rather use a gui just because of the more \"polished\" look it has.","AnswerCount":10,"Available Count":2,"Score":0.0199973338,"is_accepted":false,"ViewCount":104449,"Q_Id":8912327,"Users Score":1,"Answer":"If you're more into gaming you can use PyGame for GUIs.","Q_Score":23,"Tags":"python,user-interface","A_Id":8913722,"CreationDate":"2012-01-18T15:03:00.000","Title":"How to make a gui in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if any of you know where I could find a simple tutorial on the web maybe to make a very simplistic gui. I have no idea how to start out in code to make one so I need your help. What I want the gui to be used for is I have written a program that I want to be to use it on other computers that already don't have python on it. I have already made an executable but I would much rather use a gui just because of the more \"polished\" look it has.","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104449,"Q_Id":8912327,"Users Score":0,"Answer":"While some suggestions have included tkinter and wxPython, the other part of the answer to your question is that you will also need to package it using something like py2app, pyinstaller, or py2exe (depending on the operating system). You mentioned the other machines do not have python, so this would be required in order to distribute the entire python environment with your app.\nAlso have a look at PySide or PyQt. They have a ton of tutorials everywhere and heavy documentation from Qt.","Q_Score":23,"Tags":"python,user-interface","A_Id":8912460,"CreationDate":"2012-01-18T15:03:00.000","Title":"How to make a gui in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"if .\\venv\\Scripts\\activate does not work neither and you find this error\n\\Activate.ps1 cannot be loaded because running scripts is disabled on this system\nyou can simple type set-executionpolicy remotesigned in powershell and the error must be gone.\n\npowershell should run as administrator","Q_Score":190,"Tags":"python,virtualenv","A_Id":71692901,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0235250705,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":4,"Answer":"Open your powershell as admin\nEnter \"Set-ExecutionPolicy RemoteSigned -Force\nRun \"gpedit.msc\" and go to >Administrative Templates>Windows Components>Windows Powershell\nLook for \"Activate scripts execution\" and set it on \"Activated\"\nSet execution directive to \"Allow All\"\nApply\nRefresh your env","Q_Score":190,"Tags":"python,virtualenv","A_Id":62498657,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"If you are using windows, just run .\\Scripts\\activate. Mind that the backslash plays the trick!","Q_Score":190,"Tags":"python,virtualenv","A_Id":65636990,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":-0.0058822851,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":-1,"Answer":"Some people are having trouble with vscode i assume as all the above methods dont work.\nIts simply because by default vscode uses powershell not cmd...\nclick on the little arrow beside it and select cmd and run the command.","Q_Score":190,"Tags":"python,virtualenv","A_Id":71559922,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0058822851,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":1,"Answer":"The steps for activating virtualenv using Python3 on windows are:\n\npython3 -m venv env\n.\\env\\bin\\activate","Q_Score":190,"Tags":"python,virtualenv","A_Id":71215993,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"Open your project using VS code editor .\nChange the default shell in vs code terminal to git bash.\nnow your project is open with bash console and right path, put \n\"source venv\\Scripts\\activate\" in Windows","Q_Score":190,"Tags":"python,virtualenv","A_Id":60413441,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":2,"Answer":"For windows Microsoft Tech Support it might be a problem with Execution Policy Settings. To fix it, you should try executing\nSet-ExecutionPolicy Unrestricted -Scope Process","Q_Score":190,"Tags":"python,virtualenv","A_Id":67224356,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"It's been a while without usign Django, so when I got back to my old project I run into the same issue on Windows 10\nand this worked for me:\n\nvenv\/Scripts\/activate","Q_Score":190,"Tags":"python,virtualenv","A_Id":71382806,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"Use These it worked for meenv\\Scripts\\activate","Q_Score":190,"Tags":"python,virtualenv","A_Id":71376740,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"If you are using windows OS then in Gitbash terminal use the following command $source venv\/Scripts\/activate. This will help you to enter the virtual environment.","Q_Score":190,"Tags":"python,virtualenv","A_Id":59298771,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":1.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":21,"Answer":"For activation you can go to the venv your virtualenv directory\nby cd venv.\nThen on Windows, type dir (on unix, type ls). \nYou will get 5 folders include, Lib, Scripts, tcl and 60 \nNow type .\\Scripts\\activate to activate your virtualenv venv.\n\nYour prompt will change to indicate that you are now operating within the virtual environment. It will look something like this (venv)user@host:~\/venv$.\nAnd your venv is activated now.","Q_Score":190,"Tags":"python,virtualenv","A_Id":47483536,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"Navigate to your virtualenv folder eg ..\\project1_env>\nThen type \n\nsource scripts\/activate\n\neg ..\\project1_env>source scripts\/activate","Q_Score":190,"Tags":"python,virtualenv","A_Id":61607988,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"If some beginner, like me, has followed multiple Python tutorials now possible has multiple Python versions and\/or multiple versions of pip\/virtualenv\/pipenv... \nIn that case, answers listed, while many correct, might not help. \nThe first thing I would try in your place is uninstall and reinstall Python and go from there.","Q_Score":190,"Tags":"python,virtualenv","A_Id":61962316,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":2,"Answer":"I have a hell of a time using virtualenv on windows with git bash, I usually end up specifying the python binary explicitly. \nIf my environment is in say .env I'll call python via .\/.env\/Scripts\/python.exe \u2026, or in a shebang line #!.\/.env\/Scripts\/python.exe; \nBoth assuming your working directory contains your virtualenv (.env).","Q_Score":190,"Tags":"python,virtualenv","A_Id":25353183,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0117641631,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":2,"Answer":"You can run the source command on cygwin terminal","Q_Score":190,"Tags":"python,virtualenv","A_Id":48840058,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0058822851,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":1,"Answer":"If you see the 5 folders (Include,Lib,Scripts,tcl,pip-selfcheck) after using the virtualenv yourenvname command, change directory to Scripts folder in the cmd itself and simply use \"activate\" command.","Q_Score":190,"Tags":"python,virtualenv","A_Id":53059234,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a virtualenv around my project, but when I try to activate it I cannot.\nIt might just be syntax or folder location, but I am stumped right now.\nYou can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv\/bin\/activate\nI'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 \/ windows os, virtual env 2.2.x\n\nProcessing dependencies for virtualenv\nFinished processing dependencies for virtualenv\n\nc:\\testdjangoproj\\mysite>virtualenv --no-site-packages venv\nThe --no-site-packages flag is deprecated; it is now the default behavior.\nUsing real prefix 'C:\\\\Program Files (x86)\\\\Python'\nNew python executable in venv\\Scripts\\python.exe\nFile venv\\Lib\\distutils\\distutils.cfg exists with different content; not overwri\nting\nInstalling setuptools.................done.\nInstalling pip...................done.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source venv\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>source mysite\/bin\/activate\n'source' is not recognized as an internal or external command,\noperable program or batch file.\n\nc:\\testdjangoproj\\mysite>","AnswerCount":34,"Available Count":17,"Score":0.0,"is_accepted":false,"ViewCount":352338,"Q_Id":8921188,"Users Score":0,"Answer":"If you\u2019re using Windows, use the command \"venv\\Scripts\\activate\" (without the word source) to activate the virtual environment. If you\u2019re using PowerShell, you might need to capitalize Activate.","Q_Score":190,"Tags":"python,virtualenv","A_Id":58090444,"CreationDate":"2012-01-19T04:54:00.000","Title":"Issue with virtualenv - cannot activate","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to provide individuals with their financial statement, and I am using S3. So far what I am doing is making the file public-read and creating a unique Key, using uuid.uuid4(). \nWould this be acceptable, or how else could I make this more secure? Sending authentication keys for each individual is not an option.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":260,"Q_Id":8935191,"Users Score":1,"Answer":"Even though version 4 UUIDs are supposed to incorporate random data, I wouldn't want to rely on the fact that the RNG used by Python's uuid.uuid4() being securely random. The Python docs make no mention about the quality of the randomness, so I'd be afraid that you might end up with guessable UUID's.\nI'm not a crypto expert, so I won't suggest a specific alternative, but I would suggest using something that is designed to produce crypto-quailty random data, and transform that into something that can be used as an S3 key (I'm not sure what the requirements on S3 key data might be, but I'd guess they're supposed to be something like a filename).\nTo be honest, having no security other than an unguessable name still leaves me with a bad feeling. It seems to easy to have an unintentional leak of the names, as Ian Clelland suggests in his comment.","Q_Score":1,"Tags":"python,security,amazon-s3","A_Id":8935272,"CreationDate":"2012-01-20T00:08:00.000","Title":"Sending 'secure' financial statements on S3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to implement least-squares with elementary matrix decomposition and other operations, but how can I do it in Python? (I've never tried to use matrices in Python)\n\n(clarification edit to satisfy the shoot-first-and-ask-questions-later -1'er)\nI was looking for help to find out how to use numerical programming in Python. Looks like numpy and scipy are the way to go. I was looking for how to use them, but I found a tutorial.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":8953991,"Users Score":2,"Answer":"scipy and numpy is the obvious way to go here.\nNote that numpy uses the famous (and well-optimized) BLAS libraries, so it is also very fast. Much faster than any \"pure python\" will ever be.","Q_Score":0,"Tags":"python,matrix,numerical-methods","A_Id":8954018,"CreationDate":"2012-01-21T15:03:00.000","Title":"python: least-squares estimation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I know how to implement least-squares with elementary matrix decomposition and other operations, but how can I do it in Python? (I've never tried to use matrices in Python)\n\n(clarification edit to satisfy the shoot-first-and-ask-questions-later -1'er)\nI was looking for help to find out how to use numerical programming in Python. Looks like numpy and scipy are the way to go. I was looking for how to use them, but I found a tutorial.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":819,"Q_Id":8953991,"Users Score":1,"Answer":"Have a look at SciPy.  It's got matrix operations.","Q_Score":0,"Tags":"python,matrix,numerical-methods","A_Id":8954011,"CreationDate":"2012-01-21T15:03:00.000","Title":"python: least-squares estimation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a small game in python. I am using a 2D rectangular grid. I know that for pathfinding I can use A* and the likes, I know how this works, but the problem I have is a bit different.\nLet's say we have a computer controlled human and some computer controlled zombies. When the human spots a zombie, it should get away from this as far as he can. At the moment, to test everything I just turn around 180\u00b0 and run away, until I spot another zombie and repeat.\nObviously this is not very smart (and can cause problems if there is a zombie on both sides).\nI was wondering if there was a smarter way to do this? Something like using Dijkstra to find a \"safe zone\" where I can run to? Alternatives are always welcome, I can't seem to figure it out.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":239,"Q_Id":8963987,"Users Score":1,"Answer":"You could suppose that the zombies can see everything within a particular range (radius or perhaps be more clever) and then have the human look for a spot that he thinks the zombies can't see. Pick the closest spot the zombie can't see and use the A* algorithm to find a path if one exists, else try a different one. Look out when there's nowhere to run. Alternatively you could weight all of the spots in your visibility region with a value based on how far away you would be from the zombies if you chose that spot.","Q_Score":0,"Tags":"python,dijkstra,path-finding,a-star","A_Id":8964029,"CreationDate":"2012-01-22T19:31:00.000","Title":"Get away from an object in a 2D-grid","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a small game in python. I am using a 2D rectangular grid. I know that for pathfinding I can use A* and the likes, I know how this works, but the problem I have is a bit different.\nLet's say we have a computer controlled human and some computer controlled zombies. When the human spots a zombie, it should get away from this as far as he can. At the moment, to test everything I just turn around 180\u00b0 and run away, until I spot another zombie and repeat.\nObviously this is not very smart (and can cause problems if there is a zombie on both sides).\nI was wondering if there was a smarter way to do this? Something like using Dijkstra to find a \"safe zone\" where I can run to? Alternatives are always welcome, I can't seem to figure it out.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":239,"Q_Id":8963987,"Users Score":0,"Answer":"Just off the top of my head, you'll probably be able to do some vector math and have the human run in the normal vector to the zombies.\nI don't know how well this will work (or how it will scale to the number of zombies you have), but you could do something like: \n\nFor each zombie, compute the distance to the human and the direction it is from the human.\nCreate a vector for each zombie (or some subset of the close zombies), using the direction and the inverse of the distance, since the closer the zombie is the more important it is to run away.\nFind the sum of all the vectors.\nMake the human run in the normal vector to your result. \n\nI'm not sure how resource intensive this would be, but it seems like the most logical way to prioritize where to run.","Q_Score":0,"Tags":"python,dijkstra,path-finding,a-star","A_Id":8964083,"CreationDate":"2012-01-22T19:31:00.000","Title":"Get away from an object in a 2D-grid","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understood that Python pickling is a way to 'store' a Python Object in a way that does respect Object programming - different from an output written in txt file or DB. \nDo you have more details or references on the following points:\n\nwhere are pickled objects 'stored'?\nwhy is pickling preserving object representation more than, say, storing in DB?\ncan I retrieve pickled objects from one Python shell session to another?\ndo you have significant examples when serialization is useful?\ndoes serialization with pickle imply data 'compression'? \n\nIn other words, I am looking for a doc on pickling - Python.doc explains how to implement pickle but seems not dive into details about use and necessity of serialization.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53631,"Q_Id":8968884,"Users Score":0,"Answer":"I find it to be particularly useful with large and complex custom classes. In a particular example I'm thinking of, \"Gathering\" the information (from a database) to create the class was already half the battle. Then that information stored in the class might be altered at runtime by the user.\nYou could have another group of tables in the database and write another function to go through everything stored and write it to the new database tables. Then you would need to write another function to be able to load something saved by reading all of that info back in.\nAlternatively, you could pickle the whole class as is and then store that to a single field in the database. Then when you go to load it back, it will all load back in at once as it was before. This can end up saving a lot of time and code when saving and retrieving complicated classes.","Q_Score":98,"Tags":"python,serialization,pickle","A_Id":55150034,"CreationDate":"2012-01-23T08:35:00.000","Title":"Python serialization - Why pickle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get an understanding of the best way of handling file uploads safely in a wsgi app. It seems a lot of solutions involve using FieldStorage from the cgi module to parse form data. From what I understand about FieldStorage it performs a bit of 'magic' behind the scenes by streaming data into a tempfile.\nWhat I'm not 100% clear on is how to restrict a request containing a file greater than a specified amount (say 10MB). If someone uploads a file which is several GB in size you obviously want to block the request before it chews through your server's disk space right?\nWhat is the best way to restrict file uploads in a wsgi application?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1729,"Q_Id":8970713,"Users Score":3,"Answer":"It would depend on your front-end server. If it has any configuration to block big request even before it goes into your app, use it.\nIf you want to block this with your code I see two approaches:\n\nLook ate the Content-Length HTTP Header. If it's bigger than you can handle, deny the request right away.\nDon't trust the headers and start reading the request body, until you reach your limit. Note that this is not a very clever way, but could work. =)\n\nTrusting the HTTP header could lead you to some problems. Supose some one send a request with a Content-Length: 1024 but sends a 1GB request body. If your front-end server trusts the header, it will start do read this request and would find out later that the request body is actually much bigger that it should be. This situation could still fill your server disk, even being a request that \"passes\" the \"too big check\".\nAlthough this could happen, I think trusting the Header would be a good start point.","Q_Score":5,"Tags":"python,http,wsgi,webob","A_Id":8975702,"CreationDate":"2012-01-23T11:12:00.000","Title":"How do you restrict large file uploads in wsgi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm setting up a pyramid application where access to ressources can be shared across registered users. \nI would also like to give access to non-members, using non-trivial links to files or directories.\nWhile I see how to do this for registered members, I'm not sure how to do this with anonymous users. Do I need to create an unprotected view and perform security checks myself ? \nMaybe a better way would be to append access rights to users sessions using cookies? \nCan route factories help me for this purpose? Any other way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":8971115,"Users Score":2,"Answer":"If you've figured out how to do this for authenticated users, it should be obvious how to do it for anonymous users as well. They will have the pyramid.security.Everyone principal, which you can use in your ACLs to assign various permissions.\nRoute factories will allow you to assign custom ACLs to individual routes. They simply override the default root factory on the Configurator.","Q_Score":0,"Tags":"python,session,authorization,pyramid","A_Id":8973728,"CreationDate":"2012-01-23T11:47:00.000","Title":"url-enabled access to ressources with pyramid","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running into some really weird problems with ctypes.  I'm using ctypes to interface to a C++ library that has a C interface.  The library has lots of parallel functionality.  More often than not, the parallel calls tend to end up with a segfault from the C++ layer, but I've run into them with some serial code too.  I'm wondering if there is any restriction on whether the Python interpreter and the C++ code need to be compiled with the same version of the C++ compiler?  If so, how do I find out what c++ was used to build Python?  I've tried to run strings on Python and grep for gcc and g++, nothing shows up.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":8989328,"Users Score":0,"Answer":"CPython doesn't contain C++ code and thus there is no requirement with regards to the C++ compiler used to compile a C++ library loaded into a CPython process.  However, the C layer and the C++ library must generally be compiled with the same C++ compiler.  And if the C++ library or the C layer link against libpython, they must be compiled against the same version of CPython that is later used to run the ctypes code that loads the library.","Q_Score":2,"Tags":"python,ctypes","A_Id":8989530,"CreationDate":"2012-01-24T15:22:00.000","Title":"ctypes - does python need to be compiled with same version as C library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running into some really weird problems with ctypes.  I'm using ctypes to interface to a C++ library that has a C interface.  The library has lots of parallel functionality.  More often than not, the parallel calls tend to end up with a segfault from the C++ layer, but I've run into them with some serial code too.  I'm wondering if there is any restriction on whether the Python interpreter and the C++ code need to be compiled with the same version of the C++ compiler?  If so, how do I find out what c++ was used to build Python?  I've tried to run strings on Python and grep for gcc and g++, nothing shows up.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":337,"Q_Id":8989328,"Users Score":4,"Answer":"There's no requirement at all that the native library that you call with ctypes has to be built with a matching runtime. In fact there's not even a requirement that the native library even uses a C runtime.\nFor example you can use ctypes to call code written in other languages, e.g. Delphi. Or you can use ctypes to call Windows API functions which are not linked against MSVC.\nI guess you'll have to look elsewhere to resolve your problem!","Q_Score":2,"Tags":"python,ctypes","A_Id":8989579,"CreationDate":"2012-01-24T15:22:00.000","Title":"ctypes - does python need to be compiled with same version as C library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just encounter a little bug, maybe someone can help me.\nI'm creating Thiessen Polygons. \nI define my shapefile in Input Features, and in Output Feature Class, then I have to possibilities either keep the default file or save my output where I want.\nWhen I save my output in the Default file, and then I open the attribute table of the Polygon file created, I can observe the Shape_length field and the Shape_Area field.\nBut if I save my file in another file (Output Feature Class), then I don't find the Shape_length field and the Shape_Area field in my attribute table..\nI have no idea how to change that? because I'm running a small loop using Python and I'd like to have the Area for each Polygon in the table rather than having to recalculate it for each file created !\ncheers","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":8999047,"Users Score":0,"Answer":"Saving the output in a file geodatabase (which is probably what your default output location is) will create a feature class, which by default adds the shape_length and shape_area columns.  Saving the output into a regular folder will create a shapefile, which does not create these fields by default.  If your python script requires you to place your outputs in different places and in different formats, you could check to see if your output will be into a regular folder, and thus a shapefile, and add the two fields accordingly, then calculate them.  \nThis is not a bug, it's a format thing.","Q_Score":0,"Tags":"python,arcmap","A_Id":10212782,"CreationDate":"2012-01-25T07:16:00.000","Title":"Bug output feature class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In order to download files, I'm creating a urlopen object (urllib2 class) and reading it in chunks.\nI would like to connect to the server several times and download the file in six different sessions. Doing that, the download speed should get faster. Many download managers have this feature.\nI thought about specifying the part of file i would like to download in each session, and somehow process all the sessions in the same time. I'm not sure how I can achieve this.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10489,"Q_Id":9007456,"Users Score":3,"Answer":"As we've been talking already I made such one using PycURL.\nThe one, and only one, thing I had to do was pycurl_instance.setopt(pycurl_instance.NOSIGNAL, 1) to prevent crashes.\nI did use APScheduler to fire requests in the separate threads. Thanks to your advices of changing busy waiting while True: pass to while True: time.sleep(3) in the main thread the code behaves quite nice and usage of Runner module from python-daemon package application is almost ready to be used as a typical UN*X daemon.","Q_Score":6,"Tags":"python,http,asynchronous,urllib2,urllib","A_Id":13502466,"CreationDate":"2012-01-25T17:45:00.000","Title":"Parallel fetching of files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i apologize in advance for not being very precise, as a i dont know the mathematical expression for what i want. \ni am using matplotlib to analyze a large dataset. What i have now is a distribution of x,y points. I want to find out the cases in which the x values of my function are the same, but y differs the greatest. So if i plot it, one part of the cases is at the top of my graph, the other is the botton of the graph. \nSo how do i get the points(x,y), (x,y') where f(x)=y and f(x)=y' and y-y'=max ?\ncheers","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":960,"Q_Id":9019949,"Users Score":1,"Answer":"I think what you want is a variance plot. Create a dictionary for distinct x values. Put each distinct value of y in a list associated with each x. Find the stdev (np.std) of the list associated with each x say \"s\". Plot the s vs. x.","Q_Score":2,"Tags":"python,statistics,matplotlib","A_Id":9020306,"CreationDate":"2012-01-26T14:52:00.000","Title":"Finding 'edge cases' in a dataset","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking through the Tweepy API and not quite sure how to find the event to register for when a user either send or receives a new tweet.  I looked into the Streaming API but it seems like that is only sampling the Twitter fire house and not really meant for looking at one indvidual user.  What I am trying to do is have my program update whenever something happens to the user.  Essentially what a user would see if they were in their account on the twitter homepage.  So my question is: What is the method or event I should be looking for in the Tweepy API to make this happen?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":183,"Q_Id":9027884,"Users Score":1,"Answer":"I used the .filter function then filtered for the user I was looking for.","Q_Score":0,"Tags":"python,twitter,twitter-oauth,tweepy","A_Id":9056152,"CreationDate":"2012-01-27T01:25:00.000","Title":"How to register an event for when a user has a new tweet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking through the Tweepy API and not quite sure how to find the event to register for when a user either send or receives a new tweet.  I looked into the Streaming API but it seems like that is only sampling the Twitter fire house and not really meant for looking at one indvidual user.  What I am trying to do is have my program update whenever something happens to the user.  Essentially what a user would see if they were in their account on the twitter homepage.  So my question is: What is the method or event I should be looking for in the Tweepy API to make this happen?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":183,"Q_Id":9027884,"Users Score":1,"Answer":"I don't think there is any event based pub-sub exposed by twitter. You just have to do the long polling.","Q_Score":0,"Tags":"python,twitter,twitter-oauth,tweepy","A_Id":9028060,"CreationDate":"2012-01-27T01:25:00.000","Title":"How to register an event for when a user has a new tweet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have no idea why python run every script in a new command window. \nFor example I run: python testfile.py, it is show new window and close immediately, so I can't look the traceback. \nPython 2.7 32-bit at the same machine works normally","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":390,"Q_Id":9034799,"Users Score":0,"Answer":"You can run it through IDLE, the built-in editor. It may not be much helpful if you have to provide command-line args.\nAn alternate option may be making the code wait for a keypress using raw_input(), as Insidi0us said.\nYou can also print the errors to a file.\nAnother option may be running the command prompt first, then run python command (make sure your environment variable contains the python installation directory).","Q_Score":1,"Tags":"python,cmd","A_Id":9034986,"CreationDate":"2012-01-27T14:31:00.000","Title":"Python run .py in separate windows (Windows 7, Python 2.6.6 64-bit)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have no idea why python run every script in a new command window. \nFor example I run: python testfile.py, it is show new window and close immediately, so I can't look the traceback. \nPython 2.7 32-bit at the same machine works normally","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":390,"Q_Id":9034799,"Users Score":0,"Answer":"Did you try adding raw_input() at the end of testfile.py ?","Q_Score":1,"Tags":"python,cmd","A_Id":9034871,"CreationDate":"2012-01-27T14:31:00.000","Title":"Python run .py in separate windows (Windows 7, Python 2.6.6 64-bit)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to do some stuff with siemens PLC using OPENOPC using python. I am wondering how I will get OPC server that I can communicate using PYOPC. Is there any open OPC server available or am I not understanding some of the key concepts here? Since I am a newbie, I hope to get some down-to-earth suggestions.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2203,"Q_Id":9036653,"Users Score":0,"Answer":"You can install some tryout opc servers. google opc simulation. The python OpenOPC client is what i try to use.\nMy problems was that I did not have a plc on my desk. You need a plc on your desk connected to your actual siemens s7 engineering station to have the siemens opc server show the tags in the plc.","Q_Score":0,"Tags":"python,ole,opc","A_Id":9213366,"CreationDate":"2012-01-27T16:26:00.000","Title":"OpenOPC using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a java class that calls other java classes and then prints to a screen. i am trying to build a python interface that calls my java class, runs the one method within it, and terminates. i cannot get access to my method. i have used the line \"import directory.directory2.myClass.java (and .jar and .class) i made the .jar file from both the raw code and from the .class file. none of these seem to be working. i set sys.path.append to point to the directory where the java files are. Do i need to convert my java class file to a python module? and if so how do i do that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5286,"Q_Id":9038505,"Users Score":3,"Answer":"Jython supports loading Java classes as if they were Python modules. It searches the directories in sys.path for .class files.\nFirst, make sure your Java class has already been compiled with javac.\nThen, do a sys.path.append(d), where d is the directory containing the package. So if your class says package foo.bar; at the top, and resides at mydir\/foo\/bar\/myclass.java, then you must have mydir in sys.path (NOT one of the subdirs of mydir).\nFinally, import the class via something like from foo.bar import myclass. The names between must match up between Python and Java! You'll be doing \"from [package] import [class]\".","Q_Score":2,"Tags":"java,python,jython","A_Id":9047483,"CreationDate":"2012-01-27T18:52:00.000","Title":"How to import a java class i created in jython and call a method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I get a Json object from a URL which has values in the form like above:\ntitle:'\\u05d9\\u05d7\\u05e4\\u05d9\\u05dd'\nI need to print these values as readable text however I'm not able to convert them as they are taken as literal strings and not unicode objects.\ndoing unicode(myStr) does not work\ndoing a = u'%s' % myStr does not work \nall are escaped as string so return the same sequence of characters.\nDoes any one know how I can do this conversion in python?\nMay be the right approach is to change the encoding of the response, how do I do that?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1062,"Q_Id":9040618,"Users Score":4,"Answer":"You should use the json module to load the JSON data into a Python object.  It will take care of this for you, and you'll have Unicode strings.  Then you can encode them to match your output device, and print them.","Q_Score":2,"Tags":"python,string,json,unicode","A_Id":9040643,"CreationDate":"2012-01-27T21:57:00.000","Title":"convert a String '\\u05d9\\u05d7\\u05e4\\u05d9\\u05dd' to its unicode character in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm preparing a set of reports using open source ReportLab.  The reports contain a number of charts.  Everything works well so far.\nI've been asked to take a (working) bar chart that shows two series of data and overlay a fitted curve for each series.\nI can see how I could overlay a segmented line on the bar graph by creating both a line chart and bar chart in the same ReportLab drawing.  I can't find any reference for fitted curves in ReportLab, however.\nDoes anyone have any insight into plotting a fitted curve to a series of data in ReportLab or, failing that, a suggestion about how to accomplish this task (I'm thinking that chart would need to be produced in matplotlib instead)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":447,"Q_Id":9045888,"Users Score":1,"Answer":"I would recommend using MatPlotLib.  This is exactly the sort of thing it's designed to handle and it will be much easier than trying to piece together something in ReportLab alone, especially since you'll have to do all the calculation of the line on your own and figure out the details of how to draw it in just the right place.  MatPlotLib integrates easily with ReportLab; I've used the combination several times with great results.","Q_Score":0,"Tags":"python,charts,reportlab,curve-fitting","A_Id":9046880,"CreationDate":"2012-01-28T14:16:00.000","Title":"Fitted curve on chart using ReportLab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to determine on what page(need a page number) will be each flowable after rendering to pdf. I was thinking to add a custom id attribute  to flowable, so i will know what flowable is it. But how can i determine on what page it will be placed?\nWhat is the best way to achieve this?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1281,"Q_Id":9045937,"Users Score":2,"Answer":"At what point do you need this information?  It becomes available as the document is constructed, so you can get it after rendering by overriding methods such as afterPage, afterDrawPage, and afterFlowable.  You can then get the page number from the DocTemplate class (I believe there's a class variable called something like _currentPage, but you'll need to check the ReportLab code since I don't think it's documented).","Q_Score":2,"Tags":"python,pdf,reportlab","A_Id":9046943,"CreationDate":"2012-01-28T14:21:00.000","Title":"How to know on what page number flowable was placed during rendering a pdf with reportlab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a problem using the tag {% url%} in Django on GAE, I found the problem applying internationalization in JavaScript files, writing:\n{% url django.views.i18n.javascript_catalog %}\nDjango throws the error:\n\nTemplateSyntaxError at \/ view \/ test \/\nCaught ImproperlyConfigured while rendering: Error Importing data\n  store piston.gae_store OAuth: \"No module named piston.gae_store\"\n\nAnd try other parameters: {% url prueba.views.prueba %}\nI get the same error.\nIf I remove piston throws another error on another package, and if only the URL url.py let me test the latter throws error:\n\n'str' object has no attribute 'resolve'\n\nThe final url.py:\n\nurlpatterns = patterns('',\n      url(r'^view\/', include('website.urls')), )\n\nI hope I can help or show another way to get the url of the JavaScript I want without using {% url django.views.i18n.javascript_catalog %}","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":417,"Q_Id":9048513,"Users Score":0,"Answer":"There is an earlier error that you did not yet fix:\n\nError Importing data store piston.gae_store OAuth: \"No module named piston.gae_store\"\n\nThis does not seem to be related to the lines that you change. It will probably even occur when your remove the {% url ...%} completely, right? Try to fix the existing error first.","Q_Score":1,"Tags":"python,django,google-app-engine,internationalization,django-templates","A_Id":9054738,"CreationDate":"2012-01-28T20:52:00.000","Title":"{% url %} not work in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need to add logging to a milter that I wrote a few months back.  It is occasionally rejecting some messages, but I'm not sure why.  I know how to add logging to a Python script from the HowTo, but is it necessary for me to add log output commands at every point in my script, or is there a way Python automatically handles that?\nBasically, I don't know where in the script it fails and don't want to add the overhead of 60 logging lines.  I'm looking for the simplest method of doing this.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":540,"Q_Id":9065936,"Users Score":2,"Answer":"If you have no idea where it fails you could run a debugging session with input that you know causes the error, and step through the code if that is an option.\nAnother pretty obvious option is to log all exceptions at the entrance of your script and then drill down from there, but I honestly don't think that there is a way that will find the right places to log for you - if this would be the case that program could just as well track the bug down on itself.","Q_Score":1,"Tags":"python,logging","A_Id":9065992,"CreationDate":"2012-01-30T15:04:00.000","Title":"How to automate python logging","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python has a lot of convenient data structures (lists, tuples, dicts, sets, etc) which can be used to make other 'conventional' data structures (Eg, I can use a Python list to create a stack and a collections.dequeue to make a queue, dicts to make trees and graphs, etc).\nThere are even third-party data structures that can be used for specific tasks (for instance the structures in Pandas, pytables, etc).\nSo, if I know how to use lists, dicts, sets, etc, should I be able to implement any arbitrary data structure if I know what it is supposed to accomplish?\nIn other words, what kind of data structures can the Python data structures not be used for?\nThanks","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2410,"Q_Id":9091252,"Users Score":0,"Answer":"Given that all data structures exist in memory, and memory is effectively just a list (array)... there is no data structure that couldn't be expressed in terms of the basic Python data structures (with appropriate code to interact with them).","Q_Score":2,"Tags":"python,data-structures","A_Id":9091268,"CreationDate":"2012-02-01T05:31:00.000","Title":"Data structures with Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to pickle wx.frame(python GUI) object and unpickle it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":460,"Q_Id":9095796,"Users Score":1,"Answer":"Instead of pickling the object, pickle the necessary attributes of the object required to reconstruct a new instance of the object.","Q_Score":0,"Tags":"python,wxpython,python-2.5","A_Id":9095942,"CreationDate":"2012-02-01T12:27:00.000","Title":"how to pickle wx.frame(python GUI) object and unpickle it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run the following code:\nif substr in movie.lowercase:\nI get the following error\nAttributeError: 'NavigableString' object has no attribute 'lowercase'\nmovie is from here:\nmovie = row.td.div.h4.string\nI tried to change it to (without success)\nmovie = row.td.div.h4.string.string\nor\nmovie = unicode(row.td.div.h4.string)\nDo you know how to convert NavigableString to normal unicode string with lowercase method?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7115,"Q_Id":9099523,"Users Score":0,"Answer":"There should not be any problem just using python's str() method on the navigable string object you have. From my experience with NavigableString's they are already in unicode so if you want a string on which .lower will work then you need to cast it to a python string (UTF-8) then recast it back to unicode.","Q_Score":2,"Tags":"python,string,unicode,beautifulsoup","A_Id":41417621,"CreationDate":"2012-02-01T16:34:00.000","Title":"converting NavigableString to unicode string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to know how to call subclass methods in the superclass.","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":32346,"Q_Id":9125997,"Users Score":9,"Answer":"The point behind a subclass is that it extends and alters the behaviour of the superclass. The superclass can't know how  a subclass will extend it.\nEdit: But it is well possible that the superclass knows, that the subclass will extend it. Not sure, if this is good design, though.","Q_Score":14,"Tags":"python","A_Id":9126238,"CreationDate":"2012-02-03T08:56:00.000","Title":"How to call subclass methods in a superclass in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Google's Oauth 2.0 to get the user's access_token, but I dont know how to use it with imaplib to access inbox.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":6657,"Q_Id":9134491,"Users Score":-1,"Answer":"IMAP does not support accessing inbox without password -> so imaplib doesnt","Q_Score":12,"Tags":"python,gmail,oauth-2.0,gmail-imap,imaplib","A_Id":11414012,"CreationDate":"2012-02-03T19:38:00.000","Title":"Access Gmail Imap with OAuth 2.0 Access token","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question.\nThere are two classes: A and B. A creates object of type B. So from A, it is easy to access methods of B, but how can I access methods of object A from object B? I am trying to use bidirectional signal-slot mechanism in Qt. A can easily have a slot for a signal in B, but B cannot see signals in A.\nI have a vague idea that somehow the creator class can be referenced as a 'member' while an object is being created, but I am not sure how to do code this.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":298,"Q_Id":9148782,"Users Score":0,"Answer":"There's no way to do this automatically. You'll just have to give each B a reference to A when you create it, something like b_instance.parent = a_instance.","Q_Score":0,"Tags":"python,pyqt4,python-2.7","A_Id":9148796,"CreationDate":"2012-02-05T11:17:00.000","Title":"How to reference creator object in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We are trying to develop a project in google app engine for a senior project, and its set up in such a way that only a subset of user at our college should be able to login to it.  Our college uses google domains for email, so that is currently out login requirement (a college email though google that is), but how can we limit it to not just people without that domain, but a subset or per-approved users with that domain?  Also if it matters, within the subset of users, there are four additional types of usesr, who will have access to different pages, functions and information.\nRight now we are just using the google login APIs, and we are at a loss of how to micro-manage the user pool.  Would we have to create a data store entry for each user who should be authorized to access the service and run a check at each page to ensure they have the privileges to be there?  Or does google provide some type of service to make this easier that I've missed?  Thanks folks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":9171080,"Users Score":1,"Answer":"Wouldn't it be easier to write a user model rather than access it with the Google accounts API? That way you could define user groups and access without having to rely on Google.\nThe Google Accounts API in the example is really for low-level init debugging.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":9171764,"CreationDate":"2012-02-07T04:38:00.000","Title":"Only allow a subset of users to access a google app project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written a few little things in python, and I am ramping up to build something a little more challenging. \nThe last project I made basically ingested some text files, did some regex over each file and structured the data in an useful way so I could investigate some data I have. \nI found it quite tough near the end to remember what section operated on what part of the text, especially as the code grew as I 'fixed' things along the way. \nIn my head, I imagine my code to be a series of small interconnected modules - descrete .py files that I can leave to one side knowing what they do, and how they interoperate. \nThe colleague that showed me how to def functions basically meant that I ended up with one really long piece of code that I found really hard to navigate and troubleshoot. \n(1) Is this the right way? or is there an easier way of making modules that pass variables between them, I think i would find this better, as I could visualise the flow better (mainly becuase its how I was used to working in MATLAB a few years ago I guess)\n(2) Can you use this method to plan out the various layers of functions before hand to give you a 'map' to write towards?\n(3) is there any easy to access tutorials for this kind of stuff? I often find the tutorials suddenly jump way over my head.... \nThanks.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":953,"Q_Id":9173794,"Users Score":3,"Answer":"Others have suggested studying other experienced programmers' code from open source projects, etc. and from tutorials and textbooks, which is sound advice.  Sometimes a similar example is all you need to set you on the right path.\nI also suggest to use your own frustration and experience as feedback to help yourself improve.  Whenever you find yourself thinking any of the following:\n\nIt feels like I'm writing the same code over and over again with only small changes\nI wrote this code myself, but I had to study it for a long time to re-learn how it works\nEach time I go back and add something to this code it takes me longer to get it working again\nThere's a bug in this code somewhere, but I haven't a clue where\nSurely somebody somewhere has solved this problem already\nWhy is this taking me so long to get done?\n\nThat means you have room for improvement in your technique.  A lot of the difference between an expert and beginning programmer is the ability to do the following:\n\nDon't Repeat Yourself (DRY): Instead of copy-pasting code, or writing the same code over and over with variations, write a single common routine with one or more parameters that can do all of those things.  Then call that routine in multiple places.\nKeep It Simple (KIS): Break up your code into simple well-defined behaviors\/routines that make sense on their own, organized into classes\/modules\/packages, so that each part of the overall program is easy to understand and maintain.  Write informative and concise comments, and document the calls even if you don't intend to publish them.\nDivide & Conquer Testing: Thoroughly test each individual class, function, etc. by itself (preferably with a unit-testing framework) as you develop it, rather than only testing the entire application.\nDon't Re-invent the Wheel: Use open source frameworks or other tools where possible to solve problems that are general and not specific to your application.  In all but the most trivial cases, there is a risk that you do not fully understand the problem and your home-grown solution may be lacking in an important way.\nEstimate Honestly: Study your own previous efforts to learn how long it takes you to do certain things.  Try to work faster next time, but don't assume you will.  Measure yourself and use your own experience to estimate future effort.  Set expectations and bargain with scope.","Q_Score":1,"Tags":"python,modularity","A_Id":9180449,"CreationDate":"2012-02-07T09:28:00.000","Title":"Python 'theory' - constructing a multifunction program - how to plan a basic flow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I've written a few little things in python, and I am ramping up to build something a little more challenging. \nThe last project I made basically ingested some text files, did some regex over each file and structured the data in an useful way so I could investigate some data I have. \nI found it quite tough near the end to remember what section operated on what part of the text, especially as the code grew as I 'fixed' things along the way. \nIn my head, I imagine my code to be a series of small interconnected modules - descrete .py files that I can leave to one side knowing what they do, and how they interoperate. \nThe colleague that showed me how to def functions basically meant that I ended up with one really long piece of code that I found really hard to navigate and troubleshoot. \n(1) Is this the right way? or is there an easier way of making modules that pass variables between them, I think i would find this better, as I could visualise the flow better (mainly becuase its how I was used to working in MATLAB a few years ago I guess)\n(2) Can you use this method to plan out the various layers of functions before hand to give you a 'map' to write towards?\n(3) is there any easy to access tutorials for this kind of stuff? I often find the tutorials suddenly jump way over my head.... \nThanks.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":953,"Q_Id":9173794,"Users Score":4,"Answer":"(1) It is possible to write a fine programme in a single .py file\n(2) In any style of programming, it is always (apart from special, hardware-driven cases) best to break your code up into short functions (or methods) that accomplish a discrete task. \n(3) Experienced programmers will frequent write their code one way, discover a problem, either  write more code, or different code, and consider whether any of their existing code can be broken out into a separate function. \nA sign that you need to do this is when you are sequentially assigning to variables to pass data down your function. Never copy-paste your code to another place, even with changes, unless it be to break it out as a function, and replace the original code with a call to that function.\n(4) In many cases, it can be useful to organise your code into classes and objects, even when it is not technologically necessary to do so. It can help you see that you have defined a complete set of operations (or not) necessary on some collection of data.\n(5) Programming is actually quite hard. Even among those who have a talent for it, it takes a while to be comfortable. As an illustration, when I was doing my master's degree, I and my (fairly talented) friends all felt only in our final year that we had begun to achieve a degree of facility and competence (and these are all people who had been programming since at least their teenage years). \nThe important thing is to keep learning and improving, rather than repeating the same one or two years of experience over and over.\n(6) To that end, read books and articles. Try new things. Think.","Q_Score":1,"Tags":"python,modularity","A_Id":9174984,"CreationDate":"2012-02-07T09:28:00.000","Title":"Python 'theory' - constructing a multifunction program - how to plan a basic flow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"If you have a list of numbers, how do you return only the max odd integer without using the max() function?\nI'm assuming it will have something to do with int % 2 != 0, but I'm not sure what else.\n\nI also have to return the overall max integer without using max(), but I got around that by sorting my list and using list[-1].","AnswerCount":14,"Available Count":3,"Score":-0.0142847425,"is_accepted":false,"ViewCount":4845,"Q_Id":9185443,"Users Score":-1,"Answer":"numbers = []\nwhile True:\n    try:\n        num = int(input('Enter the number: '))\n        if num == 0:\n            break\n        else:\n            numbers.append(num)\n    except:\n        print('Not a valid digit')\nodd = [i for i in numbers if i % 2 != 0]\nif odd:\n    print('The largest odd number is: ', max(odd))\nelse:\n    print('All numbers are even')","Q_Score":3,"Tags":"python,list","A_Id":53438736,"CreationDate":"2012-02-07T23:09:00.000","Title":"In Python, what's the method for returning only the max odd integer in a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you have a list of numbers, how do you return only the max odd integer without using the max() function?\nI'm assuming it will have something to do with int % 2 != 0, but I'm not sure what else.\n\nI also have to return the overall max integer without using max(), but I got around that by sorting my list and using list[-1].","AnswerCount":14,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":4845,"Q_Id":9185443,"Users Score":2,"Answer":"Have a look at 'filter' built-in function","Q_Score":3,"Tags":"python,list","A_Id":9185488,"CreationDate":"2012-02-07T23:09:00.000","Title":"In Python, what's the method for returning only the max odd integer in a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you have a list of numbers, how do you return only the max odd integer without using the max() function?\nI'm assuming it will have something to do with int % 2 != 0, but I'm not sure what else.\n\nI also have to return the overall max integer without using max(), but I got around that by sorting my list and using list[-1].","AnswerCount":14,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4845,"Q_Id":9185443,"Users Score":0,"Answer":"The easiest approach is to separate the problem into subproblems. You can safely ignore every even number, so you have to be able to identify even numbers, you have to ignore numbers that satisfy the condition of being even and on the result - a list of odd numbers - you just have to find the highest number.\nSo, find or implement...\n\n...a function that checks whether a number is even or not.\n...a function that filters a list on a condition.\n...a function that finds the highest value in a list.\n\nOnce you've done that you just have to combine the three functions.","Q_Score":3,"Tags":"python,list","A_Id":9185613,"CreationDate":"2012-02-07T23:09:00.000","Title":"In Python, what's the method for returning only the max odd integer in a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I had a cloud cluster with Python or C or something and I want to execute my function (as a client) in the cloud.  How could I possibly pass the function I wrote locally up to the server?\nI've seen this elsewhere and I not only don't know how to do it but I want to see if there are many ideas for it.\nThanks,\nAnthony Hurst","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":124,"Q_Id":9187578,"Users Score":1,"Answer":"One of the most popular systems for processing large amounts of data in a cluster is Hadoop (http:\/\/hadoop.apache.org\/)\nYou can write functions in python using the MapReduce programming pattern (google it), upload your program to the cluster, and it will process your data.\nTake a look and read up. It's a huge topic - too much for one question. If you have some specific use cases please edit your question with more info.","Q_Score":0,"Tags":"python,cloud","A_Id":9187618,"CreationDate":"2012-02-08T03:42:00.000","Title":"Cloud Computing Passing a Function to Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I had a cloud cluster with Python or C or something and I want to execute my function (as a client) in the cloud.  How could I possibly pass the function I wrote locally up to the server?\nI've seen this elsewhere and I not only don't know how to do it but I want to see if there are many ideas for it.\nThanks,\nAnthony Hurst","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":9187578,"Users Score":0,"Answer":"Well if you wrote it locally you probably wont be executing anything that require compilation in realtime (I assume your looking for efficiency and will be exchanging a whole series of computations in the cloud) which in that case you looking to send it something like a ruby file on the fly?\nBut that doesn't seem very practical since you really aren't going to get this newly written function coming from the client side sent over and scaled well across the cluster you are sending it to.\nThat being said, set something up where you can send functions perimeters in the form of xml, json, etc. Use an http connection or an https if you need it secure and build it using hadoop, mpi, et.","Q_Score":0,"Tags":"python,cloud","A_Id":9187637,"CreationDate":"2012-02-08T03:42:00.000","Title":"Cloud Computing Passing a Function to Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I had a cloud cluster with Python or C or something and I want to execute my function (as a client) in the cloud.  How could I possibly pass the function I wrote locally up to the server?\nI've seen this elsewhere and I not only don't know how to do it but I want to see if there are many ideas for it.\nThanks,\nAnthony Hurst","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":9187578,"Users Score":0,"Answer":"Code mobility is a largely unexplored field with more questions than answers. Generally you cannot move arbitrary code around at runtime. There are a few programming languages that historically supported code mobility (e.g. Kali Scheme), but it is not something that would be ready for main stream use.\nConcerning functions, here I am not quite sure what you are asking. There are functional programming languages that support what I would consider \"precursors\" to code mobility. E.g. in Erlang you can pass function signatures around and in Cloud Haskell you can send a Closure (that is a function with collocated data) within certain limitations.\nOther approaches that have reached higher significance are to craft plug-ins, that is precompiled binaries that are loaded at runtime. There might be further possibilities to pass object code around so that not everything has to be compiled and linked at runtime when it is passed from one platform to an other.\nGenerally what needs to be clear to you is that what you develop is source code. This either needs to be interpreted at runtime (means on both platforms there must be an interpreter loaded) or compiled into binaries and then started. Then there is still the question of data and state etc. that would need to be shared before code mobility will work as we envision it.","Q_Score":0,"Tags":"python,cloud","A_Id":9337324,"CreationDate":"2012-02-08T03:42:00.000","Title":"Cloud Computing Passing a Function to Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a large Django site where some of the users are going to have specific needs. So I am looking for a way to overload part of a Django app if the user meets specific conditions.\nI would prefer to be able to dynamically load a user tailored version of an app, instead of loading the standard app all together.\nThe idea is all good in theory, but i have no idea how to do this in a clean python\/django-esque way, I would also prefer if my urls would remain the same even when an user app is loaded.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":9189795,"Users Score":0,"Answer":"In short, you can't (or, at least, it would be fairly tricky and magical).\nIn longer: apart from performing the checks in the apps themselves, you might want to consider creating a router app which handles the requests, then decides which sub-app should be responsible for them.\nIf you can give some more details, it would be possible to give a more detailed answer.","Q_Score":0,"Tags":"python,django","A_Id":9189836,"CreationDate":"2012-02-08T08:23:00.000","Title":"Overloading a part of or entire Django app for a specific User","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two packages that install different packages with the same name.  They are both \"packages\" in that they have top-level setup.py files which specify package=['foo'] in the setup command.\nIf I install using distutils.core, the last to be installed overwrites the previous one (but I think wouldn't overwrite unless the .py files all had the same names?).  If I install using setuptools, the two packages get installed into different eggs.\nOne option would be to explicitly set sys.path before importing the package name; this seems \"un-pythonic\" and rather dirty.  \nAssuming I have these two identically named packages installed in different eggs from setuptools, how do I specify which is imported?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4345,"Q_Id":9197668,"Users Score":0,"Answer":"I think the best way to workaround, would be to change the name of the toplevel directory, unless other packages depend on that package.\nYou can do this by altering the setup.py or just change the name folder in site-packages directly. The egg is just meta data.\nAs far as setting sys.path, it's better to use the site module, by creating a .pth file. When instantiated, any paths located in that file will be added to the \"head\" of the python path.\nAre these two packages different and the naming is a coincidence, or are they simply branches of the same?","Q_Score":7,"Tags":"python,import","A_Id":9197871,"CreationDate":"2012-02-08T16:44:00.000","Title":"Python: Two packages with the same name; how do you specify which is loaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"major noob question:\nwhen I run python on the windows command line, it says I have 2.4.5... however, it's not in my PATH environment variable (or anywhere in my environment variables), and, Python27 IS in PATH! Anyone know how I can get Python27 up and running in windows cmd?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":9206627,"Users Score":0,"Answer":"Trying running WHERE PYTHON (or WHERE PYTHON.EXE) to figure out where the python executable is at.\nIt may be that python v2.4.5 is as part of another program.","Q_Score":1,"Tags":"python","A_Id":12851137,"CreationDate":"2012-02-09T06:56:00.000","Title":"getting python 2.4.5 out of my environment variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing my first gedit plugin, a directory browser for the sidebar.\nShow sidepanel with content of the cwd.\n\nself._side_widget = self.get_dir() #returns a Gtk.Treestore obj\nself.side_panel = self.window.get_side_panel()\nself.side_panel.add_item(self._side_widget, \"dir-browser\", \"Directory\n  Browser\", None)\nself.side_panel.activate_item(self._side_widget)\n\nWith a double click on a file, i open the document in gedit.\nWith a double click on a directory I change the directory and I want to update the content of the side panel. \nI can build the a new treestore from the current working directory with self.get_dir() but I don't know how to update self.side_panel.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":543,"Q_Id":9212350,"Users Score":1,"Answer":"Either empty the current tree store and fill it again from the new directory, or call set_model(new_treestore) on the tree view widget. It will update itself.","Q_Score":0,"Tags":"python,pygtk,gedit,pygobject","A_Id":9213736,"CreationDate":"2012-02-09T14:09:00.000","Title":"Update Gedit side panel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using pythonbrew to install 2.7.2  on my CentOS. \nIt has worked before but this time on a separate clean system I am running into an issue.\nAfter installing pythonbrew (which I had to --force since it complained in make test about distutils) I switched to 2.7.2\nWhen I run easy_install setuptools it tries to go system python (2.5). Since I am non superuser this ofcourse failed.\nWhat am I missing here?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":399,"Q_Id":9217687,"Users Score":0,"Answer":"Finally I just ditched pythonbrew and did a multi install of python.\nThereafter I used bash and profile to switch between my python environments.","Q_Score":0,"Tags":"python,pythonbrew","A_Id":9245490,"CreationDate":"2012-02-09T19:49:00.000","Title":"how to install additional python packages with pythonbrew","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just set up a simple virtual server with Debian netinst. Now I want to use the tornado webserver to host a public website. I am quite new to Linux so I don't know how to set up a secure server environment.\n\nWhich users do I need to create?\nWhich config changes do I need to do to get a secure system?\nHow should I run my tornado server (deamon, init.d, ... I don't know these methods...)?\nAre there more things I need to take care of when setting up a server from scratch?\n\nThanks for help :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":867,"Q_Id":9220302,"Users Score":0,"Answer":"You can create www user just as deploying LAMP environment\nlock the www user in website directory\nSupervisor is a good solution of running several tornado process\nYou can use nginx as front-end of your tornado server.","Q_Score":1,"Tags":"python,security,debian,tornado","A_Id":9826573,"CreationDate":"2012-02-09T23:03:00.000","Title":"Tornado Web Production Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any tutorials about how to set-up sqlalchemy for windows? I went to www.sqlalchemy.org and they don't have clear instructions about set-up for windows. When I opened the zipped package, I see distribute_setup, ez_setup and setup.py among other files but it doesn't see to install sqlalchemy.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":9330,"Q_Id":9221888,"Users Score":1,"Answer":"The Command pip install sqlalchemy will download the necessary files and run setup.py install for you.","Q_Score":1,"Tags":"python,sql,database,orm,sqlalchemy","A_Id":29831712,"CreationDate":"2012-02-10T02:21:00.000","Title":"Configuring sqlalchemy for windows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"When using wx.grid for creating table with wxpython, how can I automatically extend the number of rows and columns in the table once the user resizes the frame? \nIf I create 5*5 table(grid) to fit on my frame and user resizes the frame( say, makes it bigger), how can I implement automatic increase to the number of rows and\/or column which responds to increase in frame size?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":522,"Q_Id":9222734,"Users Score":1,"Answer":"Sadly there is no builtin way to do this that I'm aware of. You'll need to catch the frame's EVT_SIZE and then use AppendRows and AppendCols as necessary with the grid. You'll need to take into account how much the frame size has changed and only append when it gets bigger, not smaller.","Q_Score":1,"Tags":"python,user-interface,event-handling,wxpython,wxwidgets","A_Id":9230043,"CreationDate":"2012-02-10T04:34:00.000","Title":"automatic resizing of table in wx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running OSX Lion and have installed python2.7 from python.org (this distribution can run in both 64bit and 32bit mode). I have also installed the wxPython package. I can run python scripts that import wxPython from the Terminal by explicitly using the 32-bit version. I would like to run the same scripts in Eclipse, but cannot. I configure PyDev to use python.org's interpreter, but it defaults to 64-bit (I check this by printing sys.maxint). I cannot figure out how to make PyDev use the 32-bit interpreter.\nI have tried configuring the PyDev python interpreter to point to:\n\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python2.7-32\nbut it ends up using: \n\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Resources\/Python.app\/Contents\/MacOS\/Python\nHow can I configure PyDev to use the 32-bit python interpreter in Eclipse on OSX Lion?\nI appreciate any input regarding this matter. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1922,"Q_Id":9237508,"Users Score":2,"Answer":"The interpreter used in PyDev is computed from sys.executable...\nNow, a doubt: if you start a shell with \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python2.7-32 and do 'print sys.executable', which executable appears?\nNow, onto a workaround... you can try replacing the places where sys.executable appears in plugins\/org.python.pydev\/PySrc\/interpreterInfo.py to point to  '\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python2.7-32'\nThat's the script where it decides which interpreter to actually use... (still, it's strange that sys.executable would point to a different location...)","Q_Score":3,"Tags":"python,eclipse,osx-lion,32bit-64bit,pydev","A_Id":9282173,"CreationDate":"2012-02-11T03:11:00.000","Title":"How to configure PyDev to use 32-bit Python Interpreter In Eclipse, on OSX Lion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a google app using next db module (ndb) to create my models. Now the problem is i want to deploy search over the fields of these models, and i have found two modules to do that: 1. The officially shipped with google app engine (appengine\/google\/ext\/search) and 2. gae text search (http:\/\/code.google.com\/p\/gae-text-search\/). Both of these provide the Searchable Model for the old db module properties. Is there any way i can do full text search using ndb and  google app engine 1.6.2. Also i want to store those search queries to the datastore, how can i achieve that too? I am using python 2.7 for my development. Thanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2635,"Q_Id":9239575,"Users Score":1,"Answer":"The best solution is to wait until app engine's full text search is released. They are currently in trusted tester phase, so it's coming soon. If you roll your own solution now, you may end up redoing it in a few months.","Q_Score":4,"Tags":"python,google-app-engine,full-text-search,google-cloud-datastore","A_Id":9243456,"CreationDate":"2012-02-11T10:45:00.000","Title":"Full text search with google app engine using ndb models","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a bit of trouble deciding whatever to use python multiprocessing or celery or pp for my application.  \nMy app is very CPU heavy but currently uses only one cpu so, I need to spread it across all available cpus(which caused me to look at python's multiprocessing library) but I read that this library doesn't scale to other machines if required.  Right now I'm not sure if I'll need more than one server to run my code but I'm thinking of running celery locally and then scaling would only require adding new servers instead of refactoring the code(as it would if I used multiprocessing).\nMy question: is this logic correct? and is there any negative(performance) with using celery locally(if it turns out a single server with multiple cores can complete my task)? or is it more advised to use multiprocessing and grow out of it into something else later?\nThanks!\np.s. this is for a personal learning project but I would maybe one day like to work as a developer in a firm and want to learn how professionals do it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8882,"Q_Id":9245656,"Users Score":6,"Answer":"I have actually never used Celery, but I have used multiprocessing.\nCelery seems to have several ways to pass messages (tasks) around, including ways that you should be able to run workers on different machines. So a downside might be that message passing could be slower than with multiprocessing, but on the other hand you could spread the load to other machines.\nYou are right that multiprocessing can only run on one machine. But on the other hand, communication between the processes can be very fast, for example by using shared memory. Also if you need to process very large amounts of data, you could easily read and write data from and to the local disk, and just pass filenames between the processes.\nI don't know how well Celery would deal with task failures. For example, task might never finish running, or might crash, or you might want to have the ability to kill a task if it did not finish in certain time limit. I don't know how hard it would be to add support for that if it is not there.\nmultiprocessing does not come with fault tolerance out of the box, but you can build that yourself without too much trouble.","Q_Score":26,"Tags":"python,parallel-processing,multiprocessing,celery","A_Id":9246968,"CreationDate":"2012-02-12T01:32:00.000","Title":"Is Celery as efficient on a local system as python multiprocessing is?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm brand new to Eclipse (learning Python).  I'm really confused about the terminology within Eclipse.  I had previously created a \"hello world\" project and exited Eclipse.  I've restarted Eclipse, but how do I list all of the projects in the current workspace?  Is there a way to do that?  If not how do I open a project?  I tried using \"Import\" but it said the project was already in the workspace.  What ever happened to say an option to \"Open Project...\"?  This seems way overly complicated.  I guess other questions I have are:\nHow do you determine the currently set \"workspace\"?\nHow do you see what workspaces are available?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":144,"Q_Id":9245719,"Users Score":1,"Answer":"The projects for the current workspace are shown in the \"Package Explorer\" view, which displays them as in a \"Windows Explorer\" fashion. Using this view you can open\/close and manage your projects for a given workspace. If you currently don't have Package Explorer open, you can go to Window->Show View->Package Explorer. If package explorer is not an option there just select \"Other...\" and look under General.\nNote that projects are not shared across workspaces, so if you create a new workspace or switch to a different one you won't see the other one's projects.","Q_Score":2,"Tags":"python,eclipse","A_Id":9245979,"CreationDate":"2012-02-12T01:45:00.000","Title":"How do you view\/list projects within a workspace within Eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. \nNow, how do I specify for Apache\/WSGI to use Python 2.7 to run the Django project?\n[edit]\nI can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1793,"Q_Id":9252986,"Users Score":3,"Answer":"You need to build mod_wsgi against python 2.7 and load this module into apache instead of the current mod_wsgi version you are using that links against python 2.4.\nThis requires root access to the machine.","Q_Score":1,"Tags":"python,django","A_Id":9253022,"CreationDate":"2012-02-12T21:43:00.000","Title":"How do set Python path to run Django with WSGI and Apache?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. \nNow, how do I specify for Apache\/WSGI to use Python 2.7 to run the Django project?\n[edit]\nI can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1793,"Q_Id":9252986,"Users Score":0,"Answer":"\"You got peanut butter on my chocolate!\"\n\"You got chocolate in my peanut butter!\"\nTwo great tastes that go together.\nAs Thiefmaster says, you need to use the correct version of wsgi. As Alex says, you need to run in a virtualenv for the later python so that you don't mess up everything else.\nInstall all your python stuff, including your preferred Django, into your virtualenv and everything will be good.","Q_Score":1,"Tags":"python,django","A_Id":9253191,"CreationDate":"2012-02-12T21:43:00.000","Title":"How do set Python path to run Django with WSGI and Apache?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. \nNow, how do I specify for Apache\/WSGI to use Python 2.7 to run the Django project?\n[edit]\nI can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1793,"Q_Id":9252986,"Users Score":0,"Answer":"You can run Django 1.3 in Python 2.4 without problems. I think it's the best choice for CentOS, and you won't have to upgrade Python.\nI've installed django on Centos 5 with Apache+mod_wsgi and Cherokee+uwsgi (I prefer the last one)","Q_Score":1,"Tags":"python,django","A_Id":9253152,"CreationDate":"2012-02-12T21:43:00.000","Title":"How do set Python path to run Django with WSGI and Apache?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Right now, I'm learning Python and Javascript, and someone recently suggested to me that I learn tcl. Being a relative noob to programming, I have no idea what tcl is, and if it is similar to Python. As i love python, I'm wondering how similar the two are so I can see if I want to start it.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3587,"Q_Id":9268611,"Users Score":1,"Answer":"Tcl is not really very similar to Python. It has some surface similarities I guess, as it is a mostly procedural language, but its philosophy is rather different. Whereas Python takes the approach that everything is an object, Tcl's approach is sometimes described as \"everything is (or can be) a string.\" There are some interesting things to learn from Tcl deriving from this approach, but it's one of the lesser-used languages, so maybe hold off until you have a tangible reason to use it. In any case, you have two very different languages on your plate already; no need (IMHO) to add a third just yet.","Q_Score":2,"Tags":"python,tcl","A_Id":9268696,"CreationDate":"2012-02-13T21:53:00.000","Title":"Similarities between tcl and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Right now, I'm learning Python and Javascript, and someone recently suggested to me that I learn tcl. Being a relative noob to programming, I have no idea what tcl is, and if it is similar to Python. As i love python, I'm wondering how similar the two are so I can see if I want to start it.","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":3587,"Q_Id":9268611,"Users Score":5,"Answer":"While this question will obviously be closed as inconstructive in a short time, I'll leave my answer here anyway.\nJoe, you appear to be greatly confused about what should drive a person who count himself a programmer to learn another programming language: in fact, one should have a natural desire to learn different languages because only this can widen one's idea about how problems can be solved by programming (programming is about solving problems).  Knowing N similar programming languages basically gives you nothing besides an immediate ability to use those programming languages. This doesn't add anything to your mental toolbox.\nI suggest you to at least look at functional languages (everyone's excited about them these days anyway), say, Haskell. Also maybe look at LISP or a similar thing.\nTcl is also quite interesting in its concepts (almost no syntax, everything is a string, uniformity of commands etc). Python is pretty boring in this respect--it's certainly enables a programmer to do certain things quick and efficient but it does not contain anything to satisfy a prying mind.\nSo my opinion is that your premises are wrong. Hope I was able to explain why.","Q_Score":2,"Tags":"python,tcl","A_Id":9268859,"CreationDate":"2012-02-13T21:53:00.000","Title":"Similarities between tcl and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have always used a mac to write and run python scripts. However, I have a bunch of files on a PC that I need to run a script on. I have never really used a PC and don't know how to run the script. \nIf I go to the command program on the PC and type in python, nothing happens. How do I find where the python path is in order to get into the python prompt? Also, once I am in the prompt, is the importing of modules the same as in a Unix system?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2860,"Q_Id":9282100,"Users Score":1,"Answer":"Assuming Python is installed, it is usually placed in a folder prefixed with \"Python\" and the major\/minor version. E.g. C:\\Python26","Q_Score":0,"Tags":"python,windows","A_Id":9282142,"CreationDate":"2012-02-14T18:19:00.000","Title":"Run a python script in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In NLTK, if I write a NaiveBayes classifier for say movie reviews (determining if positive or negative), how can I determine the classifier \"certainty\" when classify a particular review? That is, I know how to run an 'accuracy' test on a given test set to see the general accuracy of the classifier. But is there anyway to have NLTk output its certainess? (perhaps on the basis on the most informative features...)\nThanks\nA","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":524,"Q_Id":9288221,"Users Score":1,"Answer":"I am not sure about the NLTK implementation of Naive Bayes, but the Naive Bayes algorithm outputs probabilities of class membership.  However, they are horribly calibrated.\nIf you want good measures of certainty, you should use a different classification algorithm.  Logistic regression will do a decent job at producing calibrated estimates.","Q_Score":1,"Tags":"python,classification,nltk,probability","A_Id":9300400,"CreationDate":"2012-02-15T05:16:00.000","Title":"NLTK certainty measure?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In NLTK, if I write a NaiveBayes classifier for say movie reviews (determining if positive or negative), how can I determine the classifier \"certainty\" when classify a particular review? That is, I know how to run an 'accuracy' test on a given test set to see the general accuracy of the classifier. But is there anyway to have NLTk output its certainess? (perhaps on the basis on the most informative features...)\nThanks\nA","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":524,"Q_Id":9288221,"Users Score":1,"Answer":"nltk.classify.util.log_likelihood. For this problem, you can also try measuring the results by precision, recall, F-score at the token level, that is, scores for positive and negative respectively.","Q_Score":1,"Tags":"python,classification,nltk,probability","A_Id":9300932,"CreationDate":"2012-02-15T05:16:00.000","Title":"NLTK certainty measure?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I place my project in \/usr\/bin\/\nwill my python interpreter generate bytecode?  If so where does it put them as the files do not have write permission in that folder.  Does it cache them in a temp file?\nIf not, is there a performance loss for me putting the project there?\nI have packaged this up as a .deb file that is installed from my Ubuntu ppa, so the obvious place to install the project is in \/usr\/bin\/\nbut if I don't generate byte code by putting it there what should I do?  Can I give the project write permission if it installs on another persons machine?  that would seem to be a security risk.\nThere are surely lots of python projects installed in Ubuntu ( and obviously other distros ) how do they deal with this?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":738,"Q_Id":9290018,"Users Score":1,"Answer":"Regarding the script in \/usr\/bin, if you execute your script as a user that doesn't have permissions to write in \/usr\/bin, then the .pyc files won't be created and, as far as I know, there isn't any other caching mechanism.\nThis means that your file will be byte compiled by the interpreter every time so, yes, there will be a performance loss. However, probably that loss it's not noticeable. Note that when a source file is updated, the compiled file is updated automatically without the user noticing it (at least most of the times).\nWhat I've seen is the common practice in Ubuntu is to use small scripts in \/usr\/bin without even the .py extension. Those scripts are byte compiled very fast, so you don't need to worry about that. They just import a library and call some kind of library.main.Application().run() method and that's all.\nNote that the library is installed in a different path and that all library files are byte compiled for different python versions. If that's not the case in your package, then you have to review you setup.py and your debian files since that's not the way it should be.","Q_Score":3,"Tags":"python,linux","A_Id":9290219,"CreationDate":"2012-02-15T08:27:00.000","Title":"Out of home folder .pyc files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I place my project in \/usr\/bin\/\nwill my python interpreter generate bytecode?  If so where does it put them as the files do not have write permission in that folder.  Does it cache them in a temp file?\nIf not, is there a performance loss for me putting the project there?\nI have packaged this up as a .deb file that is installed from my Ubuntu ppa, so the obvious place to install the project is in \/usr\/bin\/\nbut if I don't generate byte code by putting it there what should I do?  Can I give the project write permission if it installs on another persons machine?  that would seem to be a security risk.\nThere are surely lots of python projects installed in Ubuntu ( and obviously other distros ) how do they deal with this?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":738,"Q_Id":9290018,"Users Score":1,"Answer":".pyc\/.pyo files are not generated for scripts that are run directly. Python modules placed where Python modules are normally expected and packaged up have the .pyc\/.pyo files generated at either build time or install time, and so aren't the end user's problem.","Q_Score":3,"Tags":"python,linux","A_Id":9290322,"CreationDate":"2012-02-15T08:27:00.000","Title":"Out of home folder .pyc files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probably trivial and I'm just too far removed from trigonometry to remember how to do it correctly. Am I going to need to generate a value for the hypotenuse and then translate it into x and y displacements with sin and cos? (How do you do this correctly?)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":996,"Q_Id":9297679,"Users Score":0,"Answer":"If you have a hypotenuse in the form of a line segment, then you have two points. From two points in the form P0 = (x0, y0) P1 = (x1, y1) you can get the x and y displacements by subtracting x0 from x1 and y0 from y1.\nIf your hypotenuse is actually a vector in a polar coordinate plane, then yes, you'll have to take the sin of the angle and multiply it by the magnitude of the vector to get the y displacement and likewise with cos for the x displacement.","Q_Score":1,"Tags":"python,random,trigonometry,hypotenuse","A_Id":9297835,"CreationDate":"2012-02-15T16:57:00.000","Title":"2d random walk in python - drawing hypotenuse from distribution","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probably trivial and I'm just too far removed from trigonometry to remember how to do it correctly. Am I going to need to generate a value for the hypotenuse and then translate it into x and y displacements with sin and cos? (How do you do this correctly?)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":996,"Q_Id":9297679,"Users Score":1,"Answer":"This is best done by using polar coordinates (r, theta) for your distributions (where r is your \"hypotenuse\")), and then converting the result to (x, y), using x = r cos(theta) and y = r sin(theta).  That is, select r from whatever distribution you like, and then select a theta, usually from a flat, 0 to 360 deg, distribution, and then convert these values to x and y.\nGoing the other way around (i.e., constructing correlated (x, y) distributions that gave a direction independent hypotenuse) would be very difficult.","Q_Score":1,"Tags":"python,random,trigonometry,hypotenuse","A_Id":9298238,"CreationDate":"2012-02-15T16:57:00.000","Title":"2d random walk in python - drawing hypotenuse from distribution","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I call a __repr__() function on object x as follows:\nval = x.__repr__()\nand then I want to store val string to SQLite database. The problem is\nthat val should be unicode.\nI tried this with no success:\nval = x.__repr__().encode(\"utf-8\")\nand\nval = unicode(x.__repr__())\nDo you know how to correct this?\nI'm using Python 2.7.2","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":11366,"Q_Id":9318574,"Users Score":9,"Answer":"repr(x).decode(\"utf-8\") and unicode(repr(x), \"utf-8\") should work.","Q_Score":8,"Tags":"python,unicode,repr","A_Id":9318611,"CreationDate":"2012-02-16T20:29:00.000","Title":"How to make __repr__ to return unicode string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I call a __repr__() function on object x as follows:\nval = x.__repr__()\nand then I want to store val string to SQLite database. The problem is\nthat val should be unicode.\nI tried this with no success:\nval = x.__repr__().encode(\"utf-8\")\nand\nval = unicode(x.__repr__())\nDo you know how to correct this?\nI'm using Python 2.7.2","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":11366,"Q_Id":9318574,"Users Score":16,"Answer":"The representation of an object should not be Unicode. Define the __unicode__ method and pass the object to unicode().","Q_Score":8,"Tags":"python,unicode,repr","A_Id":9319359,"CreationDate":"2012-02-16T20:29:00.000","Title":"How to make __repr__ to return unicode string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want my users to write code and run it inside a controlled environment, like for example Lua or Perl. My site runs on Perl CGI's.\nIs there a way to run an isolated perl\/Lua\/python\/etc script without access to the filesystem and returns data via stdout to be saved in a database?\nWhat i need is a secure environment, how do i apply the restrictions? Thanks in advance.\nFYI: I want to achieve something like ideone.com or codepad.org\nI've been reading about sandboxes in Lua or inline code, but they don't allow me to limit resources and time, just operations. I think i'll have a virtual machine and run the code in there, any tips?","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":303,"Q_Id":9322042,"Users Score":3,"Answer":"One idea that comes to my mind is to create a chroot'ed env for each of your user and run the user's script in that chroot'ed env.","Q_Score":2,"Tags":"python,perl,scripting,lua,cgi","A_Id":9323660,"CreationDate":"2012-02-17T02:19:00.000","Title":"How to run a script that can only write to STDOUT and read from STDIN?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works.\nIt seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that value is 'UTF-8', as it should be. But when running the script through a browser, the encoding mysteriously gets redefined to 'ANSI_X3.4-1968', which appears to be a just a fancy name for plain ASCII.\nI now need to know how to make the cgi script run with 'utf-8' as the default encoding in all cases. My setup is Python 3.1.3 and Apache2 on Debian Linux. The system-wide locale is en_GB.utf-8.","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":7021,"Q_Id":9322410,"Users Score":1,"Answer":"Your best bet is to explicitly encode your Unicode strings into bytes using the encoding you want to use.  Relying on the implicit conversion will lead to troubles like this.\nBTW: If the error is really UnicodeDecodeError, then it isn't happening on output, it's trying to decode a byte stream into Unicode, which would happen somewhere else.","Q_Score":23,"Tags":"python,unicode,python-3.x,cgi","A_Id":9322497,"CreationDate":"2012-02-17T03:18:00.000","Title":"Set encoding in Python 3 CGI scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works.\nIt seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that value is 'UTF-8', as it should be. But when running the script through a browser, the encoding mysteriously gets redefined to 'ANSI_X3.4-1968', which appears to be a just a fancy name for plain ASCII.\nI now need to know how to make the cgi script run with 'utf-8' as the default encoding in all cases. My setup is Python 3.1.3 and Apache2 on Debian Linux. The system-wide locale is en_GB.utf-8.","AnswerCount":7,"Available Count":3,"Score":0.1137907297,"is_accepted":false,"ViewCount":7021,"Q_Id":9322410,"Users Score":4,"Answer":"You shouldn't read your IO streams as strings for CGI\/WSGI; they aren't Unicode strings, they're explicitly byte sequences.\n(Consider that Content-Length is measured in bytes and not characters; imagine trying to read a multipart\/form-data binary file upload submission crunched into UTF-8-decoded strings, or return a binary file download...)\nSo instead use sys.stdin.buffer and sys.stdout.buffer to get the raw byte streams for stdio, and read\/write binary with them. It is up to the form-reading layer to convert those bytes into Unicode string parameters where appropriate using whichever encoding your web page has.\nUnfortunately the standard library CGI and WSGI interfaces don't get this right in Python 3.1: the relevant modules were crudely converted from the Python 2 originals using 2to3 and consequently there are a number of bugs that will end up in UnicodeError.\nThe first version of Python 3 that is usable for web applications is 3.2. Using 3.0\/3.1 is pretty much a waste of time. It took a lamentably long time to get this sorted out and PEP3333 passed.","Q_Score":23,"Tags":"python,unicode,python-3.x,cgi","A_Id":9337200,"CreationDate":"2012-02-17T03:18:00.000","Title":"Set encoding in Python 3 CGI scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works.\nIt seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that value is 'UTF-8', as it should be. But when running the script through a browser, the encoding mysteriously gets redefined to 'ANSI_X3.4-1968', which appears to be a just a fancy name for plain ASCII.\nI now need to know how to make the cgi script run with 'utf-8' as the default encoding in all cases. My setup is Python 3.1.3 and Apache2 on Debian Linux. The system-wide locale is en_GB.utf-8.","AnswerCount":7,"Available Count":3,"Score":0.0855049882,"is_accepted":false,"ViewCount":7021,"Q_Id":9322410,"Users Score":3,"Answer":"Summarizing @cercatrova 's answer:\n\nAdd PassEnv LANG line to the end of your \/etc\/apache2\/apache2.conf or .htaccess.\nUncomment . \/etc\/default\/locale line in \/etc\/apache2\/envvars.\nMake sure line similar to LANG=\"en_US.UTF-8\" is present in \/etc\/default\/locale.\nsudo service apache2 restart","Q_Score":23,"Tags":"python,unicode,python-3.x,cgi","A_Id":44271683,"CreationDate":"2012-02-17T03:18:00.000","Title":"Set encoding in Python 3 CGI scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a VB6 DLL and it is registered on my PC. I have pywin32 and python2.7 installed. I ran makepy in the win32com\\client dir and chose the appropriate DLL. I am now at a loss as to how to use this DLL in my Python program...examples on the Web show win32com.client.Dispatch(X), but what do I use for X? How do I use a human readable name to access this DLL in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":9336053,"Users Score":1,"Answer":"The parameter that should be in Dispatch is a string called the ProgID (Program ID). This is of the form <projectname>.<classname> . So for instance, if your VB6 project was called BusinessLib, and it contained a Public class called Formulae, the string would be BusinessLib.Formulae.","Q_Score":0,"Tags":"python,com,vb6,activex","A_Id":9358941,"CreationDate":"2012-02-17T22:00:00.000","Title":"How to use VB6 DLL (Active X\/COM) in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite literally two weeks familiar with any programming whatsoever. I am currently enrolled in a class on Python. I have a programming assignment that requires me to write a program that simulates the game 'rock, paper, scissors'. It is supposed to be designed as a two player game that:\n 1: gets the first player's name.\n 2: gets the second player's name.\n 3: displays a 'Let's Play!' intro.\n 4: asks the first player for their entry.\n 5: asks the second player for their entry.\n 6: display the results.\n 7: ask the user if they want to play again.\nI have been able to write the simple programs up to this point, but I am really lost on this assignment; I can't seem to get anything to work at all.\nany help on how to get started would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":442,"Q_Id":9338289,"Users Score":0,"Answer":"Do pseudo code for defining all the possible outcomes, and conditional statements for saying what happens \"if\" one has one and the other has their choice.  who wins?  make function modules for each specific process that happens, which is basically just what i already said.  at least that's how i would do it in C, I am very new to programming myself.\nChris","Q_Score":0,"Tags":"python","A_Id":9338332,"CreationDate":"2012-02-18T03:35:00.000","Title":"problems with rock paper scissors in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how you guys handle functions fails. Do you raise an exception, or do you return an error message?\ne.G. I have a function that is supposed to connect to an external com-object. If the com-object has not been initiated through another program, the connection cannot be established. What would be the preferred python way of notifying the main program? Should I raise an exception with the detailed error message, or should I simple return the error message?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":10315,"Q_Id":9344163,"Users Score":4,"Answer":"Throw an exception, this is what they are there for.\nThey allow the things using your code to manage the error, passing back strings provides too much opportunity for mishandling.\nConsider the case you return a string or an iterable normally, checking for an error message could cause problems, and may not catch them all the time, it's also not very Pythonic.","Q_Score":12,"Tags":"python,pep8","A_Id":9344207,"CreationDate":"2012-02-18T18:57:00.000","Title":"Function failed: Raise Exception, or return FALSE? What's the better approach?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"This is my problem.\nI'm trying to read a text file and then convert the lines into floats. The text file has \\n and \\t in it though I don't know how to get rid of it.\nI tried using line.strip() but it didn't take it off and I got an error when I wanted to convert the stuff to floats. I then tried line.strip(\"\\n\") but that didn't work either. My program works fine when I take out the \\t and \\n from the text file, but it's part of the assignment to get it to work with them. \nI really don't know why this isn't working. Thanks for any help.","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":575477,"Q_Id":9347419,"Users Score":1,"Answer":"Often, depending on the way you read the lines, in order to get rid of \\n from myline, \nyou can take myline[:-1] \nsince \\n is the last character of myline. \nFor the '\\t' you can use replace() or strip()","Q_Score":112,"Tags":"python,strip","A_Id":9347524,"CreationDate":"2012-02-19T07:07:00.000","Title":"Python strip with \\n","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"This is my problem.\nI'm trying to read a text file and then convert the lines into floats. The text file has \\n and \\t in it though I don't know how to get rid of it.\nI tried using line.strip() but it didn't take it off and I got an error when I wanted to convert the stuff to floats. I then tried line.strip(\"\\n\") but that didn't work either. My program works fine when I take out the \\t and \\n from the text file, but it's part of the assignment to get it to work with them. \nI really don't know why this isn't working. Thanks for any help.","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":575477,"Q_Id":9347419,"Users Score":1,"Answer":"If you're trying to convert lines of floats separated by tab characters, then just float(line) will try to convert the whole line into one float, which will fail if there's more than one. Using strip to get rid of leading and trailing whitespace isn't going to help that fundamental problem.\nMaybe you need to split each line into pieces and do something with each piece?","Q_Score":112,"Tags":"python,strip","A_Id":9347611,"CreationDate":"2012-02-19T07:07:00.000","Title":"Python strip with \\n","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"How can I activate autocompletion feature for wx classes in pyDev? I cannot find anything to prompt me to change that will activate this feature from PyDev>Preference>Autocompletion. How can I get autocompletion from packages like wx and other third-party packages?\nUpdate:\nI added wx path in configuration to pyDev and it now shows autocompletion for wx. However, I cannot see the method arguments and properties. For example if I seek for wx.Button, I just get autocompletion to complete writing Button but I want to know the required arguments for wx.Button as wx.Button(,....,size,pos...) etc. This works for the other methods of built-in methods when I press Ctrl+Space but I don't know how should I configure to get that from wx and other third party packages?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":324,"Q_Id":9350183,"Users Score":0,"Answer":"Regarding missing parameters on the constructor for wx.Button, unfortunately that's currently expected. Please create a bug report for PyDev specifying that.","Q_Score":1,"Tags":"java,c++,python,eclipse,wxpython","A_Id":9363014,"CreationDate":"2012-02-19T14:46:00.000","Title":"Autocompletion in Pydev- Eclipse for wxpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've read a dozen pages but im still not getting it.\nWhere is the difference between these versions:\nu'Georges M\u00e9li\u00e8s' and u'Georges M\\xe9li\\xe8s'\nand how do convert one to the other and vice-versa?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":139,"Q_Id":9350430,"Users Score":7,"Answer":"There is no difference after those strings have been parsed by the interpreter.\nOne version simply puts the special characters, but it requires the source file to have a special encoding, such as UTF-8.\nThe second version replaces those characters with their byte representation, so it's safe to have such strings in an ASCII-encoded file.\nYou can't talk about \"converting\" between them, because they are essentially the same strings. But here is something that may be interesting.\nprint u'Georges M\\xe9li\\xe8s' gives the output Georges M\u00e9li\u00e8s and\nprint repr(u'Georges M\u00e9li\u00e8s') gives u'Georges M\\xe9li\\xe8s'","Q_Score":2,"Tags":"python,unicode","A_Id":9350510,"CreationDate":"2012-02-19T15:21:00.000","Title":"u'Georges M\u00e9li\u00e8s' vs u'Georges M\\xe9li\\xe8s'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've read a dozen pages but im still not getting it.\nWhere is the difference between these versions:\nu'Georges M\u00e9li\u00e8s' and u'Georges M\\xe9li\\xe8s'\nand how do convert one to the other and vice-versa?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":9350430,"Users Score":2,"Answer":"It's the same, and I would add:\nu'Georges M\u00e9li\u00e8s'.encode('latin1') gives 'Georges M\\xe9li\\xe8s'","Q_Score":2,"Tags":"python,unicode","A_Id":9350587,"CreationDate":"2012-02-19T15:21:00.000","Title":"u'Georges M\u00e9li\u00e8s' vs u'Georges M\\xe9li\\xe8s'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a .pkg installer for a python application (specifically Spyderlib). This is not an app but a python package and a command line executable that have to be copied to specific locations.\nHowever, the location depends on the version of OSX. I'm only targeting 10.6 and 10.7 but they come with different versions of python (2.6 and 2.7) so the install path is different.\nUsing bdist_mpkg I was able to create a Mac mpkg in 10.7 which installs correctly and can be edited with PackageMaker. Now I want to know how I can edit this package so that it detects the version of OSX and sets the install target path correctly.\nI understand that I can use shell scripts to do pre and post-installation jobs, however I haven't been able to find examples of how to do this and how a script could but used to set the install target for the files in the mpkg.\nAlternatively, it may be that this is possible to do directly from PackageMaker, but i was not able to see anything to this effect (and the documentation seems quite superficial).\nSo I would like to know how this could be done. It would also be really helpful to see some examples for other software packages.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":514,"Q_Id":9350571,"Users Score":0,"Answer":"You don't need any scripts - you can do that with Package Manager alone - the Package Manager GUI allows you to tag packages as installable (enabled) and selected based on conditions such as OS version (in Choices under Requirements)","Q_Score":0,"Tags":"python,macos,package,packagemaker,mpkg","A_Id":9356034,"CreationDate":"2012-02-19T15:40:00.000","Title":"How to create a Mac .pkg from python which supports multiple versions of OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just getting my feet wet with multiprocessing(and its totally awesome!), but I was wondering if there was any guidelines to selecting number of processes?  Is it just based on number of cores on the server? Is it somehow based on the application your running(number of loops, how much cpu it uses,etc)? etc...how do I decide how many processes to spawn? Right now, I'm just guessing and add\/removing processes but it would be great if there was some kind of guideline or best practice. \nAnother question, I know what happens if I add too few(program is slooow) but what if I add 'too many'?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5306,"Q_Id":9355472,"Users Score":2,"Answer":"It's definitely based on what the application does. If it's CPU-heavy, the number of cores is a sane starting point. If it's IO-heavy, mulitple processes won't help performance anyway. If it's mostly CPU with occasional IO (e.g. PNG optimisation), you can run a few processes more than the number of cores. \nThe only way to know for certain is to run your application with some realistic input and check the resource utilisation. If you have CPU time to spare, add more worker processes.","Q_Score":19,"Tags":"python,parallel-processing,multiprocessing","A_Id":9355626,"CreationDate":"2012-02-20T02:26:00.000","Title":"Are there any guidelines to follow when choosing number of processes with multiprocessing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to ask you guys, how to make my php (or python) socket server to start when a client make request to a specific file and to stop, when client stops. Also, is there a way to make a php or python socket server not to open any ports (maybe to use port 80, which I think is possible, thanks to the request above). I'm using a public hosting which doesn't allow me to open ports or to use terminal commands.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":9366899,"Users Score":0,"Answer":"Erm, sorry, you can't do WebSockets (at least not properly to my knowledge) without opening ports. You might be able to fake it with PHP, but the timeout would defeat it.\nI would recommend Comet AJAX\/long-polling instead.","Q_Score":0,"Tags":"php,python,sockets","A_Id":9367348,"CreationDate":"2012-02-20T19:06:00.000","Title":"html5 websockets OR flash sockets activated on load?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been developing a Django app and in the process I installed a couple of component using pip (e.g. pip install django-ajax-selects). I just realized that those components aren't installed in my app directory but somewhere which is machine specific. \nFirst, how do I keep track of all the components I installed. Second, how do I install those component in my app directory so that I can move the code from machine to machine without having to do \"pip install ...\".\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":9379307,"Users Score":7,"Answer":"Use virtualenv.\nCreate a virtualenv, activate it, install what you need, then do pip freeze > requirements.txt to create a file listing all your requirements. Then on your new machine (also inside a virtualenv) you can do pip install -r requirements.txt to reinstall all those libraries.","Q_Score":1,"Tags":"python,django","A_Id":9379383,"CreationDate":"2012-02-21T14:31:00.000","Title":"How to keep track of all the components used by my Django app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the book that I am reading on Python, it keeps using the code eval(input('blah')) \nI read the documentation, and I understand it, but I still do not see how it changes the input() function. \nWhat does it do? Can someone explain?","AnswerCount":10,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":488578,"Q_Id":9383740,"Users Score":175,"Answer":"eval() interprets a string as code. The reason why so many people have warned you about using this is because a user can use this as an option to run code on the computer. If you have eval(input()) and os imported, a person could type into input() os.system('rm -R *') which would delete all your files in your home directory. (Assuming you have a unix system). Using eval() is a security hole. If you need to convert strings to other formats, try to use things that do that, like int().","Q_Score":331,"Tags":"python,eval","A_Id":9384005,"CreationDate":"2012-02-21T19:19:00.000","Title":"What does Python's eval() do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the book that I am reading on Python, it keeps using the code eval(input('blah')) \nI read the documentation, and I understand it, but I still do not see how it changes the input() function. \nWhat does it do? Can someone explain?","AnswerCount":10,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":488578,"Q_Id":9383740,"Users Score":6,"Answer":"eval(), as the name suggests, evaluates the passed argument.\nraw_input() is now input() in python 3.x versions. So the most commonly found example for the use of eval() is its use to provide the functionality that input() provided in 2.x version of python. \nraw_input returned the user-entered data as a string, while input evaluated the value of data entered and returned it. \neval(input(\"bla bla\")) thus replicates the functionality of input() in 2.x, i.e., of evaluating the user-entered data. \nIn short: eval() evaluates the arguments passed to it and hence eval('1 + 1') returned 2.","Q_Score":331,"Tags":"python,eval","A_Id":31014206,"CreationDate":"2012-02-21T19:19:00.000","Title":"What does Python's eval() do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the book that I am reading on Python, it keeps using the code eval(input('blah')) \nI read the documentation, and I understand it, but I still do not see how it changes the input() function. \nWhat does it do? Can someone explain?","AnswerCount":10,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":488578,"Q_Id":9383740,"Users Score":28,"Answer":"In Python 2.x input(...) is equivalent to eval(raw_input(...)), in Python 3.x raw_input was renamed input, which I suspect lead to your confusion (you were probably looking at the documentation for input in Python 2.x). Additionally, eval(input(...)) would work fine in Python 3.x, but would raise a TypeError in Python 2.\nIn this case eval is used to coerce the string returned from input into an expression and interpreted. Generally this is considered bad practice.","Q_Score":331,"Tags":"python,eval","A_Id":9383771,"CreationDate":"2012-02-21T19:19:00.000","Title":"What does Python's eval() do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the book that I am reading on Python, it keeps using the code eval(input('blah')) \nI read the documentation, and I understand it, but I still do not see how it changes the input() function. \nWhat does it do? Can someone explain?","AnswerCount":10,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":488578,"Q_Id":9383740,"Users Score":6,"Answer":"Maybe a misleading example of reading a line and interpreting it.\nTry eval(input()) and type \"1+1\" - this should print 2. Eval evaluates expressions.","Q_Score":331,"Tags":"python,eval","A_Id":9383854,"CreationDate":"2012-02-21T19:19:00.000","Title":"What does Python's eval() do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently attempted to install python 3.2 along with IDLE 3 on my macbook pro. I successfully installed python 3.2 (as in, I can run it from the terminal), but when I attempted to install IDLE 3.2 I must have done something wrong because now both IDLE 2.7 and IDLE 3.2 crash immediately upon opening with the message \"Python quit unexpectedly\", no matter whether I open it through the terminal or through finder. Does anyone know how to fix this? I have installed the correct ActiveTCL package (and reinstalled) and still nothing. I have attempted to reinstall python 3.2 and IDLE 3 but I am not sure whether I did it correctly. Through a good amount of googling I found some people say that it was most likely a path issue but all of the solutions I found were using Windows so I am not sure how to apply that to my mac.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":7506,"Q_Id":9384021,"Users Score":1,"Answer":"I had the same issue. I run OSX 10.8.5, Python 3.3.3 and IDLE 3.3.3 and reinstalling Python haven't been a solution.\nI solved any problem removing the ~\/.idlerc directory. My problem showed for the first time when I tried to change some Preferences (IDLE->Preferences->General->Startup Preferences->At Startup Open Edit Window), so I suppose that's why resetting my Preferences deleting ~\/.idlerc  folder have been the solution.","Q_Score":3,"Tags":"python,macos,crash,python-idle","A_Id":21723895,"CreationDate":"2012-02-21T19:40:00.000","Title":"IDLE crash when opening on Mac OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently attempted to install python 3.2 along with IDLE 3 on my macbook pro. I successfully installed python 3.2 (as in, I can run it from the terminal), but when I attempted to install IDLE 3.2 I must have done something wrong because now both IDLE 2.7 and IDLE 3.2 crash immediately upon opening with the message \"Python quit unexpectedly\", no matter whether I open it through the terminal or through finder. Does anyone know how to fix this? I have installed the correct ActiveTCL package (and reinstalled) and still nothing. I have attempted to reinstall python 3.2 and IDLE 3 but I am not sure whether I did it correctly. Through a good amount of googling I found some people say that it was most likely a path issue but all of the solutions I found were using Windows so I am not sure how to apply that to my mac.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7506,"Q_Id":9384021,"Users Score":0,"Answer":"I had the same problem where IDLE would crash after I opened it on my MAC\nI ended up updating my computer to OS Yosemite. \nand the most updated version of python but it still would shut\n  the reason it started was because I tried to change the preferences for certain keys.\nResetting the preferences fixed it! \nI typed mc ~\/.idlerc idlerc2\n :)","Q_Score":3,"Tags":"python,macos,crash,python-idle","A_Id":26536767,"CreationDate":"2012-02-21T19:40:00.000","Title":"IDLE crash when opening on Mac OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a proof of concept for an in-memory database. I do know about stuff like redis and love things like intersecting sets but that is not enough. I want to find out how to implement a service which is like the parstream database or the drawntoscale solutions. \nAnd therefore I like to have a daemon which keeps stuff in the memory.\nI did a prototype with pyro which does what it should: generate a random bitmap index and accept an bitmap mask as input from a pyro client and return all primary keys which match the bitmap mask.\nBut iterating over the index is too slow by some magnitudes which is obvious since it is python. I would like to use an C extension which does the index scan. Therefore the bitmap index shoud be kept in memory inside the c extension.\nThe very next step would be to keep the same data in the gpu ram iterate over inside my gpu.\nHaving no experience writing c extensions and pyOpenCL my question is: can I keep data inside my C Extension and use python ( pyro daeomon or maybe even flask\/tornado ) just for receiving and returning the queries without copying the whole bitmap index all the time?\nRegards\nChristian","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":9385251,"Users Score":0,"Answer":"Yes, C extensions can have internal structures allocated, but be sure to destroy your data properly when needed. \nYou can also write your code as  a C\/C++ DLL and use the ctypes python extension to access C functions directly and pass them C variables (ints, char *, etc.).","Q_Score":0,"Tags":"python,c,database,daemon,opencl","A_Id":9497466,"CreationDate":"2012-02-21T21:12:00.000","Title":"python c extension \/ opencl daemon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In order to demonstrate the security feature of Oracle one has to call OCIServerVersion() or OCIServerRelease() when the user session has not yet been established.\nWhile having the database parameter sec_return_server_release_banner = false.\nI am using Python cx_Oracle module for this, but I am not sure how to get the server version before establishing the connection. Any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1064,"Q_Id":9389381,"Users Score":0,"Answer":"With-out establishing a connection,. No you can never asking anything. It's like going to Google Page.(Internet Architecture - wether you call it sessionless or session based)\nAs for Authentical, if no permission are set - Oracle uses a username 'nobody' as a user and thus gives every user a session.\nI am a user of Oracle APEX, and I use Python, PLSQL regurlary.\nThat's one nice question. Thanks.","Q_Score":7,"Tags":"python,cx-oracle","A_Id":21155146,"CreationDate":"2012-02-22T05:08:00.000","Title":"python cx_oracle and server information","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a bunch of functions defined in file foo.py, each of them has the name like func_xxx. I want import only those functions, not the other things in foo.py. How can I achieve that without list them all?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":9394676,"Users Score":0,"Answer":"There is no easy way to do a from foo import func_*, alas.\nYou should import them all by name explicitly to make the code more cleaner and readable.","Q_Score":1,"Tags":"python,import","A_Id":9394920,"CreationDate":"2012-02-22T12:25:00.000","Title":"Python: how to import a bunch of similar names?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anybody know how much memory is used by a numpy ndarray? (with let's say 10,000,000 float elements).","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14086,"Q_Id":9395758,"Users Score":0,"Answer":"I gauss, easily, we can compute by print(a.size \/\/ 1024 \/\/ 1024, a.dtype)\nit is similar to how much MB is uesd, however with the param dtype, float=8B, int8=1B ...","Q_Score":23,"Tags":"python,arrays,memory,numpy,floating-point","A_Id":62791902,"CreationDate":"2012-02-22T13:29:00.000","Title":"How much memory is used by a numpy ndarray?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Any ideas how to use Python with the PIL module to shrink select all?  I know this can be achieved with Gimp. I'm trying to package my app as small as possible, a GIMP install is not an option for the EU.  \nSay you have 2 images, one is 400x500, other is 200x100.  They both are white with a 100x100 textblock somewhere within each image's boundaries.  What I'm trying to do is automatically strip the whitespace around that text, load that 100x100 image textblock into a variable for further text extraction.\nIt's obviously not this simple, so just running the text extraction on the whole image won't work!  I just wanted to query about the basic process.  There is not much available on Google about this topic.  If solved, perhaps it could help someone else as well...\nThanks for reading!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4161,"Q_Id":9396312,"Users Score":1,"Answer":"The general algorithmn would be to find the color of the top left pixel, and then do a spiral scan inwards until you find a pixel not of that color. That will define one edge of your bounding box. Keep scanning until you hit one more of each edge.","Q_Score":6,"Tags":"python,python-imaging-library","A_Id":9396440,"CreationDate":"2012-02-22T14:02:00.000","Title":"Use Python \/ PIL or similar to shrink whitespace","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a server where I don't have administrative rights and I need to use the latest version of numpy. The system administrator insists that he cannot update the global numpy to the latest version, so I have to install it locally. \nI can do that without trouble, but how do I make sure that \"import numpy\" results in the newer local install to be imported, as opposed to the older global version? I can adjust my PYTHONPATH, but I will want to use some of the global imports as well so I can't exclude all the global packages.\nI'm on CentOS 6, by the way.\nThanks!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1857,"Q_Id":9419327,"Users Score":1,"Answer":"Python searches the path in order, so simply put the directory where you installed your NumPy first in the path.\nYou can check numpy.version.version to make sure you're getting the version you want.","Q_Score":1,"Tags":"python,numpy,centos","A_Id":9419462,"CreationDate":"2012-02-23T18:53:00.000","Title":"have local numpy override global","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to deploy python applications such that you don't release the source code and you don't have to be sure the customer has python installed?\nI'm thinking maybe there is some installation process that can run a python app from just the .pyc files and a shared library containing the interpreter or something like that?\nBasically I'm keen to get the development benefits of a language like Python - high productivity etc. but can't quite see how you could deploy it professionally to a customer where you don't know how there machine is set up and you definitely can't deliver the source.\nHow do professional software houses developing in python do it (or maybe the answer is that they don't) ?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":9784,"Q_Id":9421373,"Users Score":1,"Answer":"Build a web application in python. Then the world can use it via a browser with zero install.","Q_Score":14,"Tags":"python,deployment","A_Id":9421431,"CreationDate":"2012-02-23T21:11:00.000","Title":"deploying python applications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to deploy python applications such that you don't release the source code and you don't have to be sure the customer has python installed?\nI'm thinking maybe there is some installation process that can run a python app from just the .pyc files and a shared library containing the interpreter or something like that?\nBasically I'm keen to get the development benefits of a language like Python - high productivity etc. but can't quite see how you could deploy it professionally to a customer where you don't know how there machine is set up and you definitely can't deliver the source.\nHow do professional software houses developing in python do it (or maybe the answer is that they don't) ?","AnswerCount":5,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":9784,"Q_Id":9421373,"Users Score":19,"Answer":"You protect your source code legally, not technologically. Distributing py files really isn't a big deal. The only technological solution here is not to ship your program (which is really becoming more popular these days, as software is provided over the internet rather than fully installed locally more often.)\nIf you don't want the user to have to have Python installed but want to run Python programs, you'll have to bundle Python. Your resistance to doing so seems quite odd to me. Java programs have to either bundle or anticipate the JVM's presence. C programs have to either bundle or anticipate libc's presence (usually the latter), etc. There's nothing hacky about using what you need.\nProfessional Python desktop software bundles Python, either through something like py2exe\/cx_Freeze\/some in-house thing that does the same thing or through embedding Python (in which case Python comes along as a library rather than an executable). The former approach is usually a lot more powerful and robust.","Q_Score":14,"Tags":"python,deployment","A_Id":9421511,"CreationDate":"2012-02-23T21:11:00.000","Title":"deploying python applications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to deploy python applications such that you don't release the source code and you don't have to be sure the customer has python installed?\nI'm thinking maybe there is some installation process that can run a python app from just the .pyc files and a shared library containing the interpreter or something like that?\nBasically I'm keen to get the development benefits of a language like Python - high productivity etc. but can't quite see how you could deploy it professionally to a customer where you don't know how there machine is set up and you definitely can't deliver the source.\nHow do professional software houses developing in python do it (or maybe the answer is that they don't) ?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":9784,"Q_Id":9421373,"Users Score":8,"Answer":"Yes, it is possible to make installation packages. Look for py2exe, cx_freeze and others.\nNo, it is not possible to keep the source code completely safe. There are always ways to decompile.\nOriginal source code can trivially be obtained from .pyc files if someone wants to do it. Code obfuscation would make it more difficult to do something with the code.","Q_Score":14,"Tags":"python,deployment","A_Id":9421442,"CreationDate":"2012-02-23T21:11:00.000","Title":"deploying python applications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to PySide and Qt at all, and now need to create an application which has a tree view with styled items. Each item needs two lines of text (different styles), and a button. Many items are supposed to be in the view, so I chose QTreeView over QTreeWidget. Now I managed to add simple text items (non-styled) to the QTreeView and have almost no idea about how to place several widgets on one item. Could you please give me an example of how to create such design?\nI've found some samples on the Internet, that are similar to what I want, but they all are in C++, and it's not obvious how to convert delegates and other things to Python. I'm now really confused about it all...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1305,"Q_Id":9431870,"Users Score":1,"Answer":"I'd recomend you use simple QTreeWidget and insert complex widgets with setItemWidget. While Qt's widhets are alien, they are not so heavy to draw, but:\n\nYou shouldn't create delegates.\nYou shouldn't handle events (If you are going to place button in view and draw it using delegates, you had to handle all its events, such as mouseOver, focus changing, etc. It is a lot of work.","Q_Score":0,"Tags":"python,qt,customization,pyside,qtreeview","A_Id":9434264,"CreationDate":"2012-02-24T13:53:00.000","Title":"Customize QTreeView items","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"first thing is, I'm a long time lurker but the first time user, I'd like to thank you all for creating the site!\nI'm in a situation that I need to implement the client part of a proprietary protocol. The protocol uses TCP\/IP underneath and the message flow can be summarized as follows:\n\nClient connects to server\nClient expresses interest in data of a certain type\nIf server has any such data, it it sent down to the client\nClient confirms the reception to the server\nClient now needs to tell the server that it is still interested in data of the same type\nServer sends the data to the client as it is coming in\nClient needs to send application-level keep-alive requests to the server from time to time (like each minute or so)\nSome messages from the server require the client to send a reply back to the server\nClient disconnects\n\nAll of that is to happen within a single TCP session, which is to be a long-living one, sort of like WebSocket I imagine.\nAnother thing is that the client is to be deployed on a multi-threaded server and should allow for concurrent access from several threads, which means that a single thread should be able to 'subscribe' to messages of a certain type from the server and should also be able to send the messages to it.\nI'm well aware of GIL hence I guess it doesn't much make to comment on that, I'm only writing a client, I can't change any other pieces of the architecture.\nSo the thing is that I've never had to delve below the HTTP level, I've been lucky enough to always use some already existing libraries and on the other hand, I haven't done that much network programming, that would be the first time I'll be something like that myself.\nI'd like it to be an opportunity for me to learn more about all the asynchronous libraries\/tools\/toolkits like select, epoll, libev or gevent. \nThe trouble is that most of the resources on the web deal with writing servers and I'm not even sure if that I'm to deploy the client on a multi-threaded doesn't mean all of them won't do much. All of the servers people are obviously single-threaded but it's not clear if it's because multiple threads aren't needed or if it's because things like epoll don't really like multiple threads using them.\nThe server clearly treats all the clients like if they were single-threaded units so I think I will need to serialize the access to the client. The thing I can't quite get is how to make sure the server responses match threads and vice versa. If one thread receives a message but another thread needs to confirm a message it received prior to the former one's getting a chance of confirming it, then how I can be sure the messages simply don't get mixed up?\nWhat do you think about it all? Are asynchronous libraries a good choice in this case? Can you think of any code samples I could have a look at? I'm using Python but the question I think is generic enough that I can use C, C++ or Java for inspiration.\nMany, many thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":494,"Q_Id":9434494,"Users Score":0,"Answer":"Is it possible for each thread (each client) to open their own socket? In that case, it's all a non-issue: Only the client in that one thread has a handle on that socket and so it automatically gets the correct data from the server. For the server, all of these connections from the client will look like completely independent client connections (which is exactly what they are).\nIf one of the requirements is to limit the overall number of network connections then you could construct a special thread that maintains the connection to the server, and which locally receives communication requests from the various threads\/ But using the independent sockets (one per thread) is probably much simpler.\nDo you absolutely have to use application level keepalive? Because TCP can do this for you, automatically. If the keepalive is not received in time then the socket is closed, thus informing the other side that the connection has timed out. Do consider this as an option, if it's possible in your case.\nFinally, if you don't have to do the application-level keepalive you can take advantage of one of the nice aspects of multi-threaded programming: Develop each thread as if it's the only one out there and you then don't need to worry about anything asynchronous at all. For example, you can write your client to send request and then blocking-wait for resonse, do computation and either send result or check if more data from the server has arrived. The data from the server will have accumulated in the TCP receive window on your side. This also serves as a means of flow control: If your client becomes too slow and the receive window is full then the server cannot send anymore. This might block the server, so you need to see whether the server can handle this situation.","Q_Score":2,"Tags":"python,asynchronous,client,asyncsocket","A_Id":9527618,"CreationDate":"2012-02-24T16:35:00.000","Title":"Long-lived multithreaded client for a proprietary protocol (Python, select, epoll)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to interrogate all new emails (one by one) and find the contents of them so that I can use the contents for another application.  \nMy first step was interpreting the return values from a search done via the search attr of an IMAP4 object.  I'm trying to figure out what data is in a list that I have returned to me.\nHow can I examine the object tree via print?  Or, better yet, how can I get the contents of the email in a string?\nFor ex., I am returned the following via print:\nunseen email content: ['3 4'] from a variable named \"response\".\nIf I run print response.__class__.__name__, I get \"list\" returned.\nI know that there is other data in \"3\", and \"4\", I just don't know what.  \nupdate: Specifically, this is the return of a call to an IMAP4obj.search(None, '(UNSEEN)')","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":176,"Q_Id":9449927,"Users Score":1,"Answer":"You may try importing pdb and doing a pdb.pprint.pprint(response)\nIf it's a program running on your own machine, you can also do a pdb.set_trace() and play with  response.\nThe ipdb module has nicer versions, but it's not usually installed by default.","Q_Score":0,"Tags":"python","A_Id":9450016,"CreationDate":"2012-02-26T02:09:00.000","Title":"find all items in list object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on building an inverted index using Python. \nI am having some doubts regarding the performance it can provide me. \nWould Python be almost equally as fast in indexing as Java or C? \nAlso, I would like to know if any modules\/implementations exists (and what are they, some link please?) for the same and how well do they perform compared to the something developed in Java\/C?\nI read about this guy who optimized his Python twice as fast as C by using it with Psyco. \nI know for a fact that this is misleading since gcc 3.x compilers are like super fast. Basically, my point is I know Python won't be faster than C. But is it somewhat comparable? \nAnd can someone shed some light on its performance compared with Java? I have no clue about that. (In terms of inverted index implementation, if possible because it would essentially require disk write and reads.)\nI am not asking this here without googling first. I didn't get a definite answer, hence the question. \nAny help is much appreciated!","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2059,"Q_Id":9452631,"Users Score":4,"Answer":"Worry about optimization after the fact. Write the code, profile it, stress test it, identify the slow parts and offset them in Cython or C or re-write the code to make it more efficient, it might be faster if you load it onto PyPy as that has a JIT Compiler, it can help with long running processes and loops.\nRemember\n\nPremature optimization, is the root of all evil. (After threads of course)","Q_Score":2,"Tags":"python,information-retrieval,inverted-index","A_Id":9452656,"CreationDate":"2012-02-26T11:19:00.000","Title":"Inverted Index System using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a python GUI in Tkinter for a time-clock system. The micro machine is wall mounted and the employees only have access to the touchscreen menu I programmed and a barcode swipe. I know how to get the script to start on startup, but how do I prevent them from exiting out or opening other menus? Basically the sole purpose of this console is to run the time-clock GUI.\nIf it cant be done in Ubuntu, is there another flavor of linux it can be done in?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":224,"Q_Id":9484724,"Users Score":1,"Answer":"Don't start a window manager. Only start your program, e.g. from xinitrc. Make the program full-screen","Q_Score":1,"Tags":"python,user-interface,ubuntu,tkinter,restriction","A_Id":9489644,"CreationDate":"2012-02-28T15:27:00.000","Title":"How do I limit a Ubuntu machine to a Python GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just installed Scipy and Numpy on my machine and added them to the System Library option in eclipse.\nNow the program runs fine, but eclipse editor keeps giving this red mark on the side says \"Unresolved import\".\nI guess I didn't configure correctly.\nAny one know how to fix this ?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":611,"Q_Id":9500524,"Users Score":1,"Answer":"Try to recreate your project in PyDev and add these new libraries.","Q_Score":1,"Tags":"python,eclipse,scipy","A_Id":9500809,"CreationDate":"2012-02-29T14:02:00.000","Title":"Eclipse editor doesn't recognize Scipy content","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing web app on flask, python, sqlalchemy and postgresql.\nMy question is here regarding concurrency handling in this app. \nHow I wrote the app :\nI take the example of adding user in database. I post the form and a view is called. I process all the form data and then call add_user(*arg) which uses sqlalchemy code to insert user in database and returns on successful execution and I return the response from the view.\nWhat I assumed:\nOk now I assumed that my web server (which I have not decided yet) will either spawn a thread or a process if two users are trying to signup at the same time and will handle all the concurreny requirements.\n\nDo i need to write threaded code here? By threaded code I mean that before writing I acquire a lock and after write release it.\nI am pretty new to web development and multithreading\/multiprocessing programing and would like some guidance on how write web app which can handle concurrency well.\nWriting concurrency handling from start is right or this thought should come when a large number of concurrent users are using the webapp. Even If it should be done later I would like some pointers about it.\n\nBasically I have no idea about concurrency part of webapp development. If you can point to resources from where I can learn more about it would be really helpful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2325,"Q_Id":9517054,"Users Score":6,"Answer":"Flask will execute each request in a separate thread or even in separate processes. The number of threads and processes to spawn is determined by the WSGI server (for example, Apache with mod_wsgi).\nIf you use SQLAlchemy ScopedSessions, the session is perfectly thread-safe. You must not share ORM-controlled objects across threads (but in the large majority of cases, you won't let your objects live longer than a request anyway so this is usually not a concern).\nIn other words, as long as you don't intend to share state between requests other than through the database or cookies, you don't need to worry about concurrency issues. You don't need to create a lock for writing to the database.\nIf you create your own long-lived objects within your application, which you most likely don't need to do, and if those objects communicate or share state with request handling code, then you must take appropriate precautions to avoid synchronization issues (race conditions, deadlocks, use of libraries that are not thread-safe, etc.)","Q_Score":1,"Tags":"python,multithreading,postgresql,web-applications,concurrency","A_Id":9521531,"CreationDate":"2012-03-01T13:26:00.000","Title":"Concurrency handling in python based webapp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've tried \"nosetests p1.py > text.txt\" and it is not working.\nWhat is the proper way to pipe this console output?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5685,"Q_Id":9519717,"Users Score":1,"Answer":"parameter -s - Not capturing stdout","Q_Score":18,"Tags":"python,nosetests","A_Id":9519888,"CreationDate":"2012-03-01T16:11:00.000","Title":"how do i redirect the output of nosetests to a textfile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am fetching records from gae model using cursor() and with_cursor() logic as used in paging. but i am not sure how to check that there is no any other record in db that is pointed by cursor. i am fetching these records in chunks within some iterations.when i got my required results in the first iteration then in next iteration I want to check there is no any record in model but I not get any empty\/None value of cursor at this stage.please let me know how to perform this check with cursors in google app engine with python.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":550,"Q_Id":9521289,"Users Score":0,"Answer":"i am not 100% sure about that but what i used to do is compare the last cursor with the actual cursor and i think i noticed that they were the same so i came to the conclusion that it was the last cursor.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":9521520,"CreationDate":"2012-03-01T17:47:00.000","Title":"cursor and with_cursor() in GAE","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on my senior project at university and I have a question. My advisor and other workers don't know much more on the matter so I thought I would toss it out to SO and see if you could help.\nWe want to make a website that will be hosted on a server that we are configuring. That website will have buttons on it, and when visitors of that website click a certain button we want to register an event on the server. We plan on doing this with PHP.\nOnce that event is registered (this is where we get lost), we want to communicate with a serial device on a remote computer. We are confident we can set up the PHP event\/listener for the button press, but once we have that registered, how do we signal to the remote computer(connected via T1 line\/routers) to communicate with the serial device? What is this sequence of events referred to as? The hardest thing for us (when researching it) is that we are not certain what to search for!\nWe have a feeling that a python script could be running on the server, get signals from the PHP listener, and then communicate with the remote PC. The remote PC could also be running a python script that then will communicate with our serial device. Again, most of this makes sense, but we are not clear on how we communicate between Python and PHP on the web server (or if this is possible).\nIf any one could give me some advice on what to search for, or similar projects I would really appreciate it. Thanks,","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":9523147,"Users Score":0,"Answer":"You can set up a web server also on the remote computer, perhaps using the same software as on the public server, so you do not need to learn another technology. The public server can make HTTP requests and the remote server responds by communicating with the serial device.","Q_Score":3,"Tags":"php,python,web","A_Id":9523459,"CreationDate":"2012-03-01T20:02:00.000","Title":"Website to computer communications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I switch between audio tracks in a video using PyGST, but without using playbin2? I'm using this pipeline, but I have no idea about how to select a specific audio stream in the video and connecting it to the audiosink:\n\nuridecodebin name=pipe1 pipe1. ! videobalance name=balance ! textoverlay name=text ! xvimagesink name=videosink pipe1. ! volume name=volume ! autoaudiosink name=audiosink\n\nAny example would be useful. Thank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":411,"Q_Id":9525437,"Users Score":0,"Answer":"Instead of \"pipe1. ! volume name=volume ! autoaudiosink name=audiosink\" you can write pipe1.srcXX ! volume name=volume ! autoaudiosink name=audiosink\" where XX is the pad you want to connect to. You will need to listen to newly added pads with a signal handler and ideally connect them all to an input-selector. This you can then use to switch tracks.","Q_Score":0,"Tags":"python,gstreamer,python-gstreamer","A_Id":9540599,"CreationDate":"2012-03-01T22:47:00.000","Title":"PyGST and videos with multiple audio tracks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been reading about beautifulSoup, http headers, authentication, cookies and something about mechanize.\nI'm trying to scrape my favorite art websites with python. Like deviant art which I found a scraper for. Right now I'm trying to login but the basic authentication code examples I try don't work.\nSo question, How do I find out what type of authentication a site uses so that I know I'm trying to login the correct way? Including things like valid user-agents when they try to block bots.\nBear with my ignorance as I'm new to HTTP, python, and scraping.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":829,"Q_Id":9528395,"Users Score":0,"Answer":"It's very unlikely that any of the sites you are interested in use basic auth. You will need a library like mechanize that manages cookies and you will need to submit the login information to the site's login page.","Q_Score":0,"Tags":"python,http,authentication,screen-scraping,web-scraping","A_Id":9542705,"CreationDate":"2012-03-02T05:23:00.000","Title":"how to find the authentication used on a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a program that will take user input and create a\ncalendar using the input.\n\nexample: John,Conner 1\/3\/10 birthday  \n\nThis information will also be sortable by the obvious: last name,first name, date, (other).\nIt will be able to print this information as a list or a calendar.\nIt will have to have exceptions like 1\/3\/10 is put on the 2nd\n(because the 3rd is a sat and weekends aren't usable dates)\nSecurity is a must as its HIPPA information\nPossible will be only used by myself on a work computer... but i would like to think others might use it eventually\n\nI'm new to programming and have the following under my belt:\nLearn python the hard way \nHow to think like a computer scientist learn python 3\npython for informatics\nGiven what i know the programming part of this doesn't really worry me. I feel like i have done similar if not more difficult things already. with the exception being the user interface setup... err the graphical part the user see's. I don't know how to set that up at all. (i used turtle does that count?)\nLimitations:\nI'm not sure what the computers at work are running. If its a server that the computers boot into or what. They are using Internet explorer.\nSo... i have researched some points i know i need to plan ahead about such as: \n\nGUI vs web application. --- i'm learning towards web application because I like the eventually seeing something i made get used on a more widespread basis... also i hear that GUI's area a pain. With this in mind i was going to learn Django.\n\nBut as a newbie i feel I might be sailing into a storm of things i haven't envisioned. And while i understand trail by fire is a good way to learn i feel it also pays to seek advice as to limit yourself... especially when you work 9 to 5 like i do.\nSo after all my to do. Is learning Django a logical next step for my I have in mind? What else might i want to consider..? finally maybe stackoverflow isn't the right spot for these types of questions! if so, where?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":177,"Q_Id":9528748,"Users Score":2,"Answer":"The first thing to look out for is overplanning. This, along with overengineering, is even more true for your second project.\nYou have lots of ideas about how this program will behave, but don't get ahead of yourself. Remember what the problem is you want to solve, and try to keep focused on the simplest way to solve that, without tons of options or cases. For example, in its simplest form you want to programmatically add a calendar event, so create a simple html form and the simplest possible back-end to take the user input and add it to a calendar.\nDon't worry about HIPAA up front, as you're going to make lots of security mistakes anyway, it's better to focus on the functionality for now.\nAlso don't worry too much about the interface, because you're going to decide this version sucks and you need to throw it away at some point. Then (and not a moment sooner) will be the right time to think about the interface, json vs. soap vs. web app, etc. For now, just start building the thing and prove that you can provide the value you believe this will provide.","Q_Score":2,"Tags":"python,django","A_Id":9528803,"CreationDate":"2012-03-02T06:02:00.000","Title":"First project what should I look out for","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to increment an ip address by a fixed value.\nPrecisely this is what I am trying to achieve, I have an ip address say, 192.168.0.3 and I want to increment it by 1 which would result in 192.168.0.4 or even by a fixed value, x so that it will increment my ip address by that number. so, I can have a host like 192.168.0.3+x. \nI just want to know if any modules already exist for this conversion.\nI tried socket.inet_aton and then socket.inet_ntoa, but I don't know how to get that working properly. Need some help or advice on that.","AnswerCount":8,"Available Count":1,"Score":0.0748596907,"is_accepted":false,"ViewCount":22989,"Q_Id":9539006,"Users Score":3,"Answer":"Convert the last part of your IP address into a number, add 1 to it, and call ifconfig.\n\nI think the approach of incrementing the last bit will not scale well as we span across networks. \u2013OP\n\nI thought of mentioning that in my original answer, but didn't, for various reasons. These reasons are as follows:\n\nI thought it is unlikely you would need to do this, and could not guess why you'd want to.\nEven if you did need to do this, you could just parse the second-to-last number.\nThis is only valid for those bits where the netmask is 0.\nYou also have to worry about \"special\" reserved IP ranges, such as 192.168.etc.etc. Also hex doublets with 0 and possibly ff\/255 have special meaning. There are different rules in IPv6.","Q_Score":15,"Tags":"python,networking","A_Id":9539066,"CreationDate":"2012-03-02T19:12:00.000","Title":"python increment ipaddress","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know there are frameworks that exist, but I am trying to use wsgi directly to improve my own understanding.\nI have my wsgi handler, and up at the top I have declared a variable i = 0.\nIn my application(environ, start_response) function, I declare global i, then I increment i whenever a button is pressed.\nIt is my understanding that the state of this variable is preserved as long as the server is running, so all users of the web app see the same i.\nIf I declare i inside the application function, then the value of i resets to 0 any time a request is made.\nI'm wondering, how do you preserve i between a single user's requests, but not have it preserved across different users' sessions?  So, a single user can make multiple posts, and i will increment, but if another user visits the web app, they start with i=0.\nAnd I know you could store i in a database between posts, but is it possible to just keep i in memory between posts?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3538,"Q_Id":9541301,"Users Score":3,"Answer":"Web-apps are generally \u201cshared-nothing\u201d. In the context of WSGI, that means you have no idea how many times your application (and the counter with it) will be instantiated; that choice is up to the WSGI server which acts as your app's container.\nIf you want some notion of user sessions, you have to implement it explicitly, typically on top of cookies. If you want persistence, you need a component that explicitly supports it; that can be a shared database, or it can piggy-back on your cookie sessions.","Q_Score":4,"Tags":"python,apache,mod-wsgi","A_Id":9541433,"CreationDate":"2012-03-02T22:31:00.000","Title":"Global variables in Python and Apache mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to think through a script that I need to create. I am most likely going to be using php unless there would be a better language to do this with e.g. python or ror. I only know a little bit of php so this will definitely be a learning experience for me and starting fresh with a different language wouldn't be a problem if it would help in the long run. \nWhat I am wanting to do is create a website where people can sign up for WordPress hosting. Right now I have the site set up with WHMCS. If I just leave it how it is I will have manually go in and install WordPress every time a customer signs up. I would like an automated solution that creates a database and installs WordPress as soon as the customer signs up. With WHMCS I can run a script as soon as a customer signs up and so far I understand how to create a database, download WordPress, and install WordPress. The only thing is I can't figure out how to make it work with more than one customer because with each customer there will be a new database. What I need the script to do is when customer A signs up,  the script will create a database name \"customer_A\" (that name is just an example) and when, lets say my second customer signs up, the script will create a database named \"customer_B\". \nIs there a possible solution to this?\nThanks for the help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":9543171,"Users Score":0,"Answer":"I did this yesterday.\nmy process was to add a row to a master accounts table, get the auto inc id, use that along with the company name to create the db name. so in my case the db's are \nRoot_1companyname1\nRoot_2companyname2\n..\nRoot_ is optional of course.\nAsk if you have any questions.","Q_Score":0,"Tags":"php,python,wordpress","A_Id":9543194,"CreationDate":"2012-03-03T03:30:00.000","Title":"Automate database creation with incremental name?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. \nFurther, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? \nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1586,"Q_Id":9550690,"Users Score":0,"Answer":"If I'm reading your question right, you're not trying to build a web app (client- or server-side), but rather a standalone app that simply requests and downloads pages from the Web.\nYou can write a standalone app in JavaScript, but it's not common. The primary use of JavaScript is for code that's going to run in a user's Web browser. For standalone apps, Python is the better choice. And it has very good support (in the form of the urllib2 and related libraries) for tasks like Web scraping.\nOf course, if your scraping task is relatively simple, you might be better off just using wget.","Q_Score":0,"Tags":"jquery,python,screen-scraping","A_Id":9551356,"CreationDate":"2012-03-03T23:13:00.000","Title":"Scraping with JQuery or Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. \nFurther, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? \nThanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1586,"Q_Id":9550690,"Users Score":3,"Answer":"This is just my opinion but I would rank them like this\n\njavascript might be the best choice but only if you have a node\nenvironment already set up. The advantage of javascript scrapers is\nthey can interpret the js in the pages you're scraping.\nnext is a three way tie between perl python and ruby. They all have a mechanize library and do xpath and regex in a sensible way.\nDown at the bottom is php. It's lack of a cookie handling library like mechanize (curl isn't great) and it's clumsy dom and regex functions make it a poor choice for scraping.","Q_Score":0,"Tags":"jquery,python,screen-scraping","A_Id":9551757,"CreationDate":"2012-03-03T23:13:00.000","Title":"Scraping with JQuery or Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \\1?\nI tried the \\g<1> syntax that is available in substitution patterns for this purpose, but it doesn't work in my match pattern.\nI have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":549,"Q_Id":9552629,"Users Score":3,"Answer":"I noticed that I don't need the \\g<1> syntax. Instead I can use one of several techniques to separate the numeric backreference like \\2 from the digit like 9 that follows it. Here are three such techniques:\n\na non-capturing group (?:\\2)9\nan otherwise unnecessary quantification by one \\2{1}9\nusing an otherwise unnecessary character class to contain only the digit that follows the backreference \\2[9]","Q_Score":2,"Tags":"python,regex,numbers,regex-group","A_Id":9552653,"CreationDate":"2012-03-04T05:35:00.000","Title":"python re.match group: number after \\number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \\1?\nI tried the \\g<1> syntax that is available in substitution patterns for this purpose, but it doesn't work in my match pattern.\nI have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":549,"Q_Id":9552629,"Users Score":2,"Answer":"Put the digit that you want to match literally in a character class \\1[1] or a group \\1(1) of its own so that the bracket or parentheses separates the digit from the backreference.","Q_Score":2,"Tags":"python,regex,numbers,regex-group","A_Id":9552654,"CreationDate":"2012-03-04T05:35:00.000","Title":"python re.match group: number after \\number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"there's something I'm struggling to understand with SQLAlchamy from it's documentation and tutorials. \nI see how to autoload classes from a DB table, and I see how to design a class and create from it (declaratively or using the mapper()) a table that is added to the DB. \nMy question is how does one write code that both creates the table (e.g. on first run) and then reuses it?\nI don't want to have to create the database with one tool or one piece of code and have separate code to use the database.\nThanks in advance,\nPeter","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":9554204,"Users Score":0,"Answer":"I think you're perhaps over-thinking the situation. If you want to create the database afresh, you normally just call Base.metadata.create_all() or equivalent, and if you don't want to do that, you don't call it.\nYou could try calling it every time and handling the exception if it goes wrong, assuming that the database is already set up.\nOr you could try querying for a certain table and if that fails, call create_all() to put everything in place.\nEvery other part of your app should work in the same way whether you perform the db creation or not.","Q_Score":0,"Tags":"python,database,sqlalchemy","A_Id":9554925,"CreationDate":"2012-03-04T10:41:00.000","Title":"SQLAlchamy Database Construction & Reuse","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can someone please show me how to get cherrypy to work with Google App Engine, I have made applications with cherrypys built in server, but I have no idea how to make an app that works with WSGI and GAE.\nI have read the documentation for cherrypy and GAE but can't find anything. And I would prefer cherrypy to the webapp2 which is in the GAE example.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1132,"Q_Id":9556280,"Users Score":1,"Answer":"The problem was that cherrypy was not in the root of the working directory, all of which I uploaded with the app engine tool. Not 100% sure if its the correct way to use GAE but it works.","Q_Score":1,"Tags":"python,google-app-engine,cgi,wsgi,cherrypy","A_Id":15619684,"CreationDate":"2012-03-04T15:46:00.000","Title":"Setup Cherrypy with Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a multi-player game in Python with a Flask frontend, and I'm using it as an opportunity to learn more about the NoSQL way of doing things.\nRedis seems to be a good fit for some of the things I need for this app, including storage of server-side sessions and other transient data, e.g. what games are in progress, who's online, etc. There are also several good Flask\/Redis recipes that have made things very easy so far.\nHowever, there are still some things in the data model that I would prefer lived inside a traditional RDBMS, including user accounts, logs of completed games, etc.  It's not that Redis can't do these things, but I just think the RDBMS is more suited to them, and since Redis wants everything in memory, it seems to make sense to \"warehouse\" some of this data on disk.\nThe one thing I don't quite have a good strategy for is how to make these two data stores live happily together.  Using ORMs like SQLAlchemy and\/or redisco seems right out, because the ORMs are going to want to own all the data that's part of their data model, and there are inevitably times I'm going to need to have classes from one ORM know about classes from the other one (e.g. \"users are in the RDBMS, but games are in Redis, and games have users participating in them.)\nDoes anyone have any experience deploying python  web apps using a NoSQL store like Redis for some things and an RDBMS for others?  If so, do you have any strategies for making them work together?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":532,"Q_Id":9557552,"Users Score":3,"Answer":"You should have no problem using an ORM because, in the end, it just stores strings, numbers and other values. So you could have a game in progress, and keep its state in Redis, including the players' IDs from the SQL player table, because the ID is just a unique integer.","Q_Score":4,"Tags":"python,nosql,redis,rdbms,flask","A_Id":9557895,"CreationDate":"2012-03-04T18:17:00.000","Title":"Redis and RDBMS coexistence (hopefully cooperation) in Flask applications","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an apps and I am making used of django admin, but my apps does not allow deleting of data and django admin have a delete button\/link. I have already removed the delete action.\nmy question is, how can i remove the delete button\/link in admin page in django?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2890,"Q_Id":9563935,"Users Score":7,"Answer":"Do not remove or change anything in the admin.\nInstead remove user's\/group's permission to delete given model. If user does not have the permission to delete, the delete button won't appear at any page related to that model.","Q_Score":2,"Tags":"python,django,django-admin","A_Id":9564009,"CreationDate":"2012-03-05T08:59:00.000","Title":"removing buttons\/links in django admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"p4.exe is the perforce command line tool (git\/cvs\/svn like tool).\nI am trying to launch several ms-dos commands 'p4 resolve' in an python script. because I have a hundred files to resolve.\nHowever I cannot launch 'p4 resolve -m' as I want (which automatically opens my 3-way merge tool on the conflicting files). p4 doesn't accept the m as an executable parameter.\nInstead, manually, I must do 'p4 resolve', then wait for the prompt to ask me for an option, and then only type 'm' there.\nDo you know in python how I could feed the input since I cannot pass the 'm' parameter to the command line tool p4.exe.\nFor the moment I use os.system(myDosCommand)","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":9567322,"Users Score":0,"Answer":"Have you tried merely piping the input to the command?\nIn cmd.exe:\nC:\\> echo m | p4 resolve","Q_Score":0,"Tags":"python,perforce","A_Id":9567478,"CreationDate":"2012-03-05T13:19:00.000","Title":"Feed input of MS-DOS interactive executable with a string value","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a Xcode newbie and need to programmatically access Xcode projects and methods to modify from a Python module. For example, say i have a \"hello world\" program in Xcode, and i need to modify the message to \"Hello Python!\", how do i do that from within my Python module? Please note i am talking about a Python module which is external and not in the Xcode project.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":461,"Q_Id":9573193,"Users Score":-1,"Answer":"Xcode projects are bundles like app bundles.  So 'foo.xcodeproj' will be a directory, inside of which is project.pbxproj. \nThere may be other files in the directory, but they are not used for the build and direct project definition; they are user configuration and window layout and things like that for the user of the project.","Q_Score":2,"Tags":"macos,xcode4,python-3.x","A_Id":9573545,"CreationDate":"2012-03-05T20:05:00.000","Title":"How to access and modify Xcode project files from python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The import statement import the needed parts. but is the \"user\" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":9574970,"Users Score":0,"Answer":"All installed apps can contribute to the database schema. django.contrib.auth.models contributes, among others, the auth_user table behind the django.contrib.auth.models.User model, therefore you do not have to worry about recreating it unless you have a specific reason to do so.","Q_Score":0,"Tags":"python,django","A_Id":9575013,"CreationDate":"2012-03-05T22:23:00.000","Title":"Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The import statement import the needed parts. but is the \"user\" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":9574970,"Users Score":0,"Answer":"There's a number of things going on here. As you're aware, Django comes with a number of \"contrib\" packages that can be used in your app. You \"activate\" these by putting them into your INSTALLED_APPS.\nWhen you run python manage.py syncdb, Django parse the models.py files of every app in INSTALLED_APPS and creates the associated tables in your database. So, once you have added django.contrib.auth to your INSTALLED_APPS and ran syncdb, the tables for User and Group are there and ready to be used.\nNow, if you want to use these models in your other apps, you can import them, as you mention, with something like from django.contrib.auth.models import User. You can then do something like create a ForeignKey, OneToOneField or ManyToManyField on one of your models to the User model. When you do this, no tables are created (with the exception of ManyToManyField; more on that in a bit). The same table is always used for User, just as for any of your own models that you might create relationships between.\nManyToManyFields are slightly different in that an intermediary table is created (often called a \"join table\") that links both sides of the relationship together. However, this is purely for the purposes of that one particular relationship -- nothing about the actual User table is different or changed in any way.\nThe point is that one table is created for User and this same table is used to store all Users no matter what context they were created in. You can import User into any and all of your apps, create as many and as varied relationships as you like and nothing really changes as far as User is concerned.","Q_Score":0,"Tags":"python,django","A_Id":9575285,"CreationDate":"2012-03-05T22:23:00.000","Title":"Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using django-admin-tool to customized my django admin page. my problem is, how can I change the header of 'Django Administration' with django-admin-tools?\ni know how to change it using base_site.html but the problem is my custom menu that i have done in django-admin-tools is not appearing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2081,"Q_Id":9576822,"Users Score":1,"Answer":"The django-admin-tools header is controlled by the theming.css file which is by default sitting under \\admin_tools\\theming\\static\\admin_tools\\css\\theming.css, and the default header should display the \"Django\" png that comes with django-admin-tools and is placed under \\admin_tools\\theming\\static\\admin_tools\\images\\django.png.\nI guess that if the default admin tools header doesn't display then your admin tools theme is not kicking in either. This means django can't see your theming folder of admin tools. Check that your MEDIA_ROOT, STATIS_ROOT andADMIN_MEDIA_PREFIX parameters in setting.py are set correctly. Check the PYTHONPATH env param is also set to all the needed folders.\nWhen the default admin tools theme will load you can drop a new header image in the images folders as above and edit the theming.css to load it instead of the default.","Q_Score":0,"Tags":"python,django,django-admin","A_Id":9588284,"CreationDate":"2012-03-06T01:50:00.000","Title":"django-admin-tools : change header 'Django Administration'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my view i execute Site.objects.get_current().domain but the result is empty string.\nSo, how can i get the domain name to compose right url?\nHosting is dreamhost.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":9577614,"Users Score":0,"Answer":"The problem waas that it was executing the old instance of webapp (that didn't use sites module) So i have resolved with pkill python command.","Q_Score":0,"Tags":"python,django,web,dreamhost,domain-name","A_Id":9588891,"CreationDate":"2012-03-06T03:44:00.000","Title":"dreamhost+django: cannot get domain name using site framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When developing a Tornado application, I frequently want to restart the server to pick up new changes. I hit ctrl-c to stop the server, but with Tornado, this seems to be very slow. It waits for many seconds before shutting down, or doesn't shut down at all when issued a ctrl-c.\nWhat's weird, is if, after clicking ctrl-c, I make a new request to the server (by, for example, refreshing my browser that is pointing at the server), it shuts down right away.\nAnyone know how to explain this or fix it? Anyone experienced something similar?\n(Note, this is on Windows.)","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1548,"Q_Id":9578245,"Users Score":2,"Answer":"I don't know why it takes so long to exit with Ctrl+C, but it worked for me in some cases to press Ctrl+\\ (Linux terminal)","Q_Score":3,"Tags":"python,tornado","A_Id":9578432,"CreationDate":"2012-03-06T05:14:00.000","Title":"Why does Tornado take so long to die when I hit ctrl-c?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an app which amounts to a Python script, running on the user's phone, and a JS client, running in the user's browser. The Python script sends messages to App Engine as HTTP requests. The server then pushes the messages to the JS client.\nThe problem is authentication: The server can easily use Google Accounts to authenticate anything coming from the JS client as being sent by a particular user, but I do not know how to get the Python script to make HTTP requests which will also authenticate.\nAny ideas?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":425,"Q_Id":9593659,"Users Score":2,"Answer":"Can you use OAUth to authenticate with Google, then use the OAuth token to ensure the messages are legitimate?","Q_Score":0,"Tags":"python,google-app-engine,cookies,oauth","A_Id":9596143,"CreationDate":"2012-03-06T23:39:00.000","Title":"Need to send a HTTP request in Python that'll authenticate with Google Accounts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a document d1 consisting of lines of form user_id tag_id.\nThere is another document d2 consisting of tag_id tag_name\nI need to generate clusters of users with similar tagging behaviour.\nI want to try this with k-means algorithm in python.\nI am completely new to this and cant figure out how to start on this.\nCan anyone give any pointers?\nDo I need to first create different documents for each user using d1 with his tag vocabulary?\nAnd then apply k-means algorithm on these documents?\nThere are like 1 million users in d1. I am not sure I am thinking in right direction, creating 1 million files ?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2252,"Q_Id":9595494,"Users Score":4,"Answer":"Since the data you have is binary and sparse (in particular, not all users have tagged all documents, right)? So I'm not at all convinced that k-means is the proper way to do this.\nAnyway, if you want to give k-means a try, have a look at the variants such as k-medians (which won't allow \"half-tagging\") and convex\/spherical k-means (which supposedly works better with distance functions such as cosine distance, which seems a lot more appropriate here).","Q_Score":3,"Tags":"python,tags,cluster-analysis,data-mining,k-means","A_Id":9597117,"CreationDate":"2012-03-07T03:43:00.000","Title":"Clustering using k-means in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a crusade to make my application pip-installable, I'm fighting big fights with setuptools and distribute. I assume my dependencies are correct, i.e. installing with pip install myapp should probably fill the virtual environment correctly. However, I'd like to streamline development while I'm at it, so my goal is to start with an empty virtualenv and make setup.py test (and later setup.py develop, but that's a whole different fight) fill it with all defined dependencies.\nAnd now to my problem: no matter how hard I try, all I get are dependencies installed as .eggs in my project directory which is sub-optimal at the very least. I tried creating a new setuptools command which would use pip (which seems to work, even though awkwardly) but that can't seriously be the solution (subclassing and overriding that is).\nSo how do I make setup.py test fill the virtualevn instead of my working directory?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11234,"Q_Id":9607565,"Users Score":13,"Answer":"By design, you can't make the tests_requires or the setup_requires entries go into the virtual environment. The idea is to separate what is required for performing tests\/setup and what is required to actually use the package being installed. For example, I may require that the \"coverage\" module be needed for running tests on my package, but it isn't used by any of my code in the package. Therefore, if I didn't have \"coverage\" in my environment when I go and run tests, I wouldn't want \"coverage\" to get installed into the environment if my package didn't need it.","Q_Score":33,"Tags":"python,virtualenv,setuptools,distribute","A_Id":21003259,"CreationDate":"2012-03-07T19:10:00.000","Title":"How do I force `setup.py test` to install dependencies into my `virtualenv`?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a lot scripts running: scrappers, checkers, cleaners, etc. They have some things in common:\n\nthey are forever running;\nthey have no time constrain to finish their job;\nthey all access the same MYSQL DB, writting and reading.\n\nAccumulating them, it's starting to slow down the website, which runs on the same system, but depends on these scripts.\nI can use queues with Kombu to inline all writtings.\nBut do you know a way to make the same with reading ? \nE.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time.\nI have no idea how to do this.\nOf course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":9618773,"Users Score":0,"Answer":"You could create a function that each process must call in order to talk to the DB. You could re-write the scripts so that they must call that function rather than talk directly to the DB. Within that function, you could have a scope-based lock so that only one process would be talking to the DB at a time.","Q_Score":0,"Tags":"python,database,queue","A_Id":9618894,"CreationDate":"2012-03-08T13:59:00.000","Title":"How to ensure several Python processes access the data base one by one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a lot scripts running: scrappers, checkers, cleaners, etc. They have some things in common:\n\nthey are forever running;\nthey have no time constrain to finish their job;\nthey all access the same MYSQL DB, writting and reading.\n\nAccumulating them, it's starting to slow down the website, which runs on the same system, but depends on these scripts.\nI can use queues with Kombu to inline all writtings.\nBut do you know a way to make the same with reading ? \nE.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time.\nI have no idea how to do this.\nOf course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":157,"Q_Id":9618773,"Users Score":1,"Answer":"You say that your dataset is <1GB, the problem is CPU bound.\nNow start analyzing what is eating CPU cycles:\n\nWhich queries are really slow and executed often. MySQL can log those queries.\nWhat about the slow queries? Can they be accelerated by using an index?\nAre there unused indices? Drop them!\nNothing helps? Can you solve it by denormalizing\/precomputing stuff?","Q_Score":0,"Tags":"python,database,queue","A_Id":9619460,"CreationDate":"2012-03-08T13:59:00.000","Title":"How to ensure several Python processes access the data base one by one?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newer and if the question is so easy I apologize for that.\nAssume I want to dev a classical online judge system, obviously the core part is\n\nget users' code to a file\ncompile it on server\nrun it on server (with some sandbox things to prevent damage)\n\nthe program exit itself, then check the answer.\nor get the signal of program collapsing.\n\n\nI wonder if it's possible to do all the things using Node.js, how to do the sandbox things. Is there any example for compile-sandbox-run-abort-check thing?\nadditional:\nis it more convenient to dev a such system using PYTHON?\nthanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1228,"Q_Id":9636294,"Users Score":0,"Answer":"To accomplish the sandbox, it would be fairly easy to do this by simply running your code inside of a closure that reassigns all of the worrisome calls to NaN\nfor instance, if the code executes inside a closure where eval=NaN","Q_Score":4,"Tags":"javascript,python,node.js,compiler-construction","A_Id":9636911,"CreationDate":"2012-03-09T15:06:00.000","Title":"Is that possible to develop a ACM ONLINE JUDGE system using NODE.JS(or PYTHON)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written an IRC bot using Twisted and now I've gotten to the point where I want to be able to dynamically reload functionality.\nIn my main program, I do from bots.google import GoogleBot and I've looked at how to use reload to reload modules, but I still can't figure out how to do dynamic re-importing of classes.\nSo, given a Python class, how do I dynamically reload the class definition?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6092,"Q_Id":9645388,"Users Score":0,"Answer":"Better yet subprocess the plugins, then hypervise the subprocess, when the files change reload the plugins process.\nEdit: cleaned up.","Q_Score":4,"Tags":"python,reflection,twisted","A_Id":9645892,"CreationDate":"2012-03-10T09:33:00.000","Title":"Dynamically reload a class definition in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"1: i create main window in QtCreator.\nhow i use this form in my python code in eclipse.\n2: can write python and build complete python application in QtCreator ? (How).\nthanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":9657333,"Users Score":0,"Answer":"You need PyQt or PySide to use Qt in your Python script.\nTo generate python script from ui file run pyuic -x form.ui","Q_Score":0,"Tags":"python","A_Id":9657438,"CreationDate":"2012-03-11T17:51:00.000","Title":"How To Add .ui Files To Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a Java developer. I would like to know what capabilities and\/or positives I can add to a Java application, by including Python as a development language.\nI am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":124,"Q_Id":9663321,"Users Score":2,"Answer":"I know how to use python with java through jython, but backwards ... try to ask your question to jython community.","Q_Score":3,"Tags":"java,python,jython","A_Id":9663378,"CreationDate":"2012-03-12T07:44:00.000","Title":"What are the extra capabilities Python gives when used with Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a Java developer. I would like to know what capabilities and\/or positives I can add to a Java application, by including Python as a development language.\nI am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":124,"Q_Id":9663321,"Users Score":1,"Answer":"1st: jython is many times slower than java.\n2nd: as I recall integration in direction jython -> java is not very seemless.\n3rd: you get python syntax, maybe some batteries (i don't really know this). This is a plus.\n4th: you get good heavy multithreading support in python instead of green thread and GIL. That can be a plus.","Q_Score":3,"Tags":"java,python,jython","A_Id":9663439,"CreationDate":"2012-03-12T07:44:00.000","Title":"What are the extra capabilities Python gives when used with Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a Java developer. I would like to know what capabilities and\/or positives I can add to a Java application, by including Python as a development language.\nI am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":124,"Q_Id":9663321,"Users Score":8,"Answer":"In general, there are no (overall) benefits for doing this. You're simply adding in another language with its own set of runtime features, that, for the most part does the same things that you can do in Java. Unless you have specific reason to add Python integration into your Java application, it would be a very poor idea to do so.\nHowever, in some cases there are reasons why you might want to do this:\nTo add scripting capabilities to your application.\nIf you want the end users of your application (or perhaps authors of add-ons, or system administrators) to be able to script parts of your application, then Python is a reasonable choice to offer them. There are other good choices too, but Python is fairly well known, quite mature, has decent Java integration and a good set of features, so it's not a bad choice.\nTo accommodate Python developers in your team\nIf your team has Python developers who (for whatever reason) aren't willing\/able to write in Java, then you can provide facilities to support including their code in your Java application.\nIf you believe that writing in Python is more productive\nIf you\/your team believe that writing Python code is sufficiently more productive than writing Java code to justify the cost of integrating the Jython runtime into your Java application, then you might take that path. Personally, I'd question that decision in all by the most niche of use cases, but that's up to each team to decide.\nTo integrate with existing Python code\nThere may be libraries or tools that are written in Python that you want to integrate with in your application. Rather than re-writing them in Java, or trying to run them via the command-line, it might be a good idea to run them in the Jython environment in the JVM.\nUnless you have a specific reason like one of those listed above, then simply integrating Jython into your application isn't going to give you any benefits, it will simply be extra effort to write and support. If you have one of those reasons, then it might make sense, it will depend on your circumstances.","Q_Score":3,"Tags":"java,python,jython","A_Id":9663494,"CreationDate":"2012-03-12T07:44:00.000","Title":"What are the extra capabilities Python gives when used with Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need a framework which will allow me to do the following:\n\nAllow to dynamically define tasks (I'll read an external configuration file and create the tasks\/jobs; task=spawn an external command for instance)\nProvide a way of specifying dependencies on existing tasks (e.g. task A will be run after task B is finished)\nBe able to run tasks in parallel in multiple processes if the execution order allows it (i.e. no task interdependencies)\nAllow a task to depend on some external event (don't know exactly how to describe this, but some tasks finish and they will produce results after a while, like a background running job; I need to specify some of the tasks to depend on this background-job-completed event)\nUndo\/Rollback support: if one tasks fail, try to undo everything that has been executed before (I don't expect this to be implemented in any framework, but I guess it's worth to ask..)\n\nSo, obviously, this looks more or less like a build system, but I don't seem to be able to find something that will allow me to dynamically create tasks, most things I've seem already have them defined in the \"Makefile\".\nAny ideas?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4879,"Q_Id":9664809,"Users Score":1,"Answer":"Another option is to use make. \n\nWrite a Makefile manually or let a python script write it\nuse meaningful intermediate output file stages\nRun make, which should then call out the processes. The processes would be a python (build) script with parameters that tell it which files to work on and what task to do.\nparallel execution is supported with -j\nit also deletes output files if tasks fail\n\nThis circumvents some of the python parallelisation problems (GIL, serialisation).\nObviously only straightforward on *nix platforms.","Q_Score":13,"Tags":"python,build,build-process,build-automation,jobs","A_Id":28289788,"CreationDate":"2012-03-12T09:49:00.000","Title":"Python framework for task execution and dependencies handling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The below is a part of a script i'm trying to write.  The script opens my iptables log, each line in the log contains the details in the example below.\n\n#example of a single line\n#Mar  9 14:57:51 machine kernel: [23780.638839] IPTABLES Denied UDP: IN=p21p1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:00:00:00:00:00:00:00 SRC=10.100.1.4 DST=10.100.1.63 LEN=78 TOS=0x00 PREC=0x00 TTL=128 ID=10898 PROTO=UDP$\n\n# Read file in a line at a time\nfor line in iptables_log.readlines():\n    #find time based on 4 letters, 2 spaces, up to 2 numbers, 1 space, then standard 10:10:10 time format\n    time = re.findall('(^\\w{1,4}\\s\\s\\d{1,2}\\s\\d\\d:\\d\\d:\\d\\d)', line)\n    #mac lookup\n    mac = re.findall('MAC=(?:\\w\\w:\\w\\w:\\w\\w:\\w\\w\\:\\w\\w:\\w\\w:\\w\\w:\\w\\w:\\w\\w:\\w\\w:\\w\\w:\\w\\w:\\w\\w:\\w\\w)', line)\n    #source port\n    src = re.findall('SRC=(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})', line)\n    #destination port\n    dst = re.findall('DST=(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})', line)\n    #protocol\n    proto = re.findall('PROTO=(?:\\w{3,4})', line)\n    #sourceport\n    sourceport = re.findall('SPT=(?:\\w{1,5})', line)\n    #destport\n    destport = re.findall('DPT=(?:\\w{1,5})', line)\n    print time, mac, src, dst, proto, sourceport, destport\n    print '======================================================'\n\nI'm trying to get the script to print only the items i want, but when its output by the script it looks like this, which would seem to be a list.  I want it to print without the [] ''.  Looking online it seems like every variable (time, mac, src, etc) are a list themselves.  I'm not sure how to combine them.  I have seen reference to join but am not sure how to use it this example.  Can someone assist please?\n\n['Mar  9 14:57:51'] ['MAC=ff:ff:ff:ff:ff:ff:00:00:00:00:00:00:00:00'] ['SRC=10.100.1.4'] ['DST=10.100.1.63'] ['PROTO=UDP'] ['SPT=137'] ['DPT=137']","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":9665586,"Users Score":0,"Answer":"re.findall returns a list of matches.  In your case you are getting lists with only one value.  If that is always the case then @x539 answer will get the first item in the list.","Q_Score":1,"Tags":"python,list","A_Id":9666450,"CreationDate":"2012-03-12T10:42:00.000","Title":"Python - List issues (multiple lists?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just created a web chat server with Tornado over Python. The communication mechanism is to use long-polling and I\/O events.\nI want to benchmark this web chat server at large scale, meaning I want to test this chat server (Tornado based) to see how many chatters it can withstand.\nBecause I'm using cookies to identify sessions, presently I can only test with maximum 5 (IE, Firefox, Chrome, Safari, Opera) sessions per computer (cookie path has no use coz everything goes thru' the same web page), but in my office we only have limited number of computers.\nI want to test this Tornado app at the extreme, hopefully it can withstand few thousand concurrent users like Tornado is advertising, but having no clue how to do this!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":510,"Q_Id":9665913,"Users Score":1,"Answer":"I would run the server in a mode where you let the client tell which client they are. i.e. change the code so it can be run this way as required.  This is less secure, but makes testing easier. In production, don't use this option.  This will give you a realistic test from a small number of client machines.","Q_Score":2,"Tags":"python,performance,chat,tornado,long-polling","A_Id":9668433,"CreationDate":"2012-03-12T11:06:00.000","Title":"How to benchmark web chat performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This might be a simple question.but,does any one know how to disable a button after clicking it in OpenERP?\nPlease help!!!!!\nThanks for all your help....","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2267,"Q_Id":9666425,"Users Score":0,"Answer":"If we talking about web interface then you could disable it by javascript.","Q_Score":4,"Tags":"python,openerp","A_Id":9667268,"CreationDate":"2012-03-12T11:46:00.000","Title":"How to disable a button after clicking it in OpenERP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My code is broken by eclipse but works normaly if I launch it from command prompt with python and no option. I need to delete -u option when the python interpreter is launched in eclipse and pydev, how can I do that?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":9680762,"Users Score":0,"Answer":"Actually, so far you can't do that without grabbing the code and changing it yourself (i.e.: that's hardcoded).\nBut still, if you don't use the unbuffered output (i.e.: -u option), the PyDev console will end up not showing the I\/O output as it's printed (as it'll be buffered).\nSo, what is it that breaks because -u? (maybe it'd be better fixing that then changing PyDev to launch without the -u as you may end up without the output until the run is finished if you do that).","Q_Score":0,"Tags":"python,eclipse,command-line,pydev","A_Id":9687892,"CreationDate":"2012-03-13T08:48:00.000","Title":"PyDev: how remove command line switch -u","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a spreadsheet with about 1.7m lines, totalling 1 GB, and need to perform various queries on it. Being most comfortable with Python, my first approach was to hack together a bunch of dictionaries keyed in a way that would facilitate the queries I was trying to make. E.g. if I needed to be able to access everyone with a particular area code and age, I would make an areacode_age 2-dimensional dict. I ended up needing quite a few of these, which multiplied my memory footprint (to the order of ~10GB), and even though I had enough RAM to support this, the process was still quite slow.\nAt this point, it seemed like I was playing a sucker's game. \"Well this is what relational databases were made for, right?\", I thought. I imported sqlite3 and imported my data into an in-memory database. I figure databases are built for speed and this will solve my problems.\nIt turns out though, that doing a query like \"SELECT (a, b, c) FROM foo WHERE date1<=d AND date2>e AND name=f\" takes 0.05 seconds. Doing this for my 1.7m rows would take 24 hours of compute time. My hacky approach with dictionaries was about 3 orders of magnitude faster for this particular task (and, in this example, I couldn't key on date1 and date2 obviously, so I was getting every row that matched name and then filtering by date).\nSo, my question is, why is this so slow, and how can I make it fast? And what is the Pythonic approach? Possibilities I've been considering:\n\nsqlite3 is too slow, and I need something more heavyweight\nI need to somehow change my schema or my queries to be more... optimized?\nthe approaches I've tried so far are entirely wrong and I need a whole new tool of some kind\nI read somewhere that, in sqlite 3, doing repeated calls to cursor.execute is much slower than using cursor.executemany. It turns out that executemany isn't even compatible with select statements though, so I think this was a red herring.\n\nThanks.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":572,"Q_Id":9694967,"Users Score":4,"Answer":"sqlite3 is too slow, and I need something more heavyweight\n\nFirst, sqlite3 is fast, sometime faster than MySQL\nSecond, you have to use index, put a compound index in (date1, date2, name) will speed thing up significantly","Q_Score":2,"Tags":"python,database,sqlite,indexing,bigdata","A_Id":9695095,"CreationDate":"2012-03-14T02:05:00.000","Title":"Querying (pretty) big relational data in Python in a reasonable amount of time?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm in the midst of trying to get my first website up and running all of the sudden I get to the point where I need to get my file online and I have zero idea on how to do that. I thought it would be as easy as selecting your files and clicking upload but so far it has not been that easy. Currently I'm using djangoeurope.com. So if anyone has experience with that site that would help extra.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":676,"Q_Id":9696294,"Users Score":0,"Answer":"There are different tools for FTP and SSH file transfer. Which one is best for you depends on your environment (e.g. operating system) and your needs (do you want a graphical or command line interface?). But basically it's always a program you run on your machine that connects to a server to upload files. You don't do anything through a web site (except finding out which server to connect to and maybe setting up an account \/ password).","Q_Score":0,"Tags":"python,django,ftp,web-hosting","A_Id":9698149,"CreationDate":"2012-03-14T05:13:00.000","Title":"Beginner advice on how to use FTP or SSH? (django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My computer is running windows behind a proxy on a windows server (using active directory), and I can't figure out how to get through it with pip (in python3).  I have tried using --proxy, but it still just timeouts.  I have also tried setting a long timeout (60s), but that made no difference.  My proxy settings are correct, and I compared them with those that I'm using successfully in TortoiseHG to make sure.\nAre there any other tricks that anyone knows of that I can try, or is there some limitation in pip with regards to windows proxies?\nUpdate: My failed attempts involved searching pypi.  I've just tried actually installing something and it worked.  Searching still fails though.  Does this indicate a bug in pip or do they work differently?","AnswerCount":11,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":241528,"Q_Id":9698557,"Users Score":0,"Answer":"For me, the issue was being inside a conda environment. Most likely it used the pip command from the conda environment (\"where pip\" pointed to the conda environment). Setting proxy-settings via --proxy or set http_proxy did not help.\nInstead, simply opening a new CMD and doing \"pip install \" there, helped.","Q_Score":99,"Tags":"python,authentication,proxy,pip","A_Id":65307484,"CreationDate":"2012-03-14T08:54:00.000","Title":"How to use pip on windows behind an authenticating proxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a unittesting framework for servers that uses popen to basically execute \"python myserver.py\" with shell=False, run some tests, and then proceed to take the server down by killpg. \nThis myserver.py can and will use multiprocessing to spawn subprocesses of its own. The problem is, from my tests, it seems that the pgrp pid of the server processes shares the same group pid as the actual main thread running the unittests, therefore doing an os.killpg on the group pid will not only take down the server but also the process calling the popen (not what I want to do). Why does it do this? And how can I make them be on separate group pids that I can kill independently?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":9722778,"Users Score":1,"Answer":"You're asking about something pretty messy here. I suspect that none of this is what you want to do at all, and that you really want to accomplish this some simpler way. However, presuming you really want to mess with process groups...\nGenerally, a new process group is created only by the setpgrp(2) system call. Otherwise, processes created by fork(2) are always members of the current process group. That said, upon creating a new process group, the processes in that group aren't even controlled by any tty and doing what you appear to want to do properly requires understanding the whole process group model. A good reference for how all this works is Stevens, \"Advanced Programming in the Unix Environment\", which goes into it in gory detail.\nIf you really want to go down this route, you're going to have to implement popen or the equivalent yourself with all the appropriate system calls made.","Q_Score":1,"Tags":"python,unix","A_Id":10034142,"CreationDate":"2012-03-15T15:21:00.000","Title":"Popen-ing a python call that invokes a script using multiprocessing (pgrp issue)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a news on my site done with \"James Bennett - Practical Django Projects, 2nd Edition (2009)\". So I am using a date-based views, which will be deprecated in django-1.4. How can I just convert my views and urls to class-based views ? May be you have seen this, please just post a link, I can't find any working example, at least for MonthMixin.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":9724539,"Users Score":0,"Answer":"Think of CBV, more specifically \"Generic Class Based Views\" as a large tree of Python classes. Starting with the simplest class. Each one subclasses and over rides methods from one another. For example, the ArchiveIndexView is typically the view you will sub-class for the index of your site. It adds an extra context variable called latest. You must supply it with a date_field, num_latest, and a couple optionals in the view class. You can also pass these arguements in through the URLConf. However, it is more tidy and clean to have the logic in the views.py . It is quite convenient once you get the hang of it. You can create mixins of your own that essentially are as powerful as your brain. Beyond, a mixin though for something you want available on every page then perhaps a template tag or a custom context processor at worst.","Q_Score":0,"Tags":"python,django","A_Id":10783975,"CreationDate":"2012-03-15T16:59:00.000","Title":"Can you share an example of using class based view with MonthMixin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just for my knowledge, how does python, especially wxpython reacts to multiple imports? If I import wx in multiple files, how does it handle that when called the main frame? Does it slows the speed or it firstly checks whether it is already been imported or not?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":111,"Q_Id":9726483,"Users Score":3,"Answer":"Only the first import executes the file. Subsequent imports copy the reference from sys.modules.","Q_Score":2,"Tags":"python,wxpython","A_Id":9726647,"CreationDate":"2012-03-15T19:09:00.000","Title":"Multiple imports of python modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just for my knowledge, how does python, especially wxpython reacts to multiple imports? If I import wx in multiple files, how does it handle that when called the main frame? Does it slows the speed or it firstly checks whether it is already been imported or not?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":9726483,"Users Score":5,"Answer":"When Python imports a file, it keps track of it by storing it in sys.modules.  So whenever Python is importing a file it checks there first and, if it finds it there, returns that instead; if it is not there, it imports it, adds it to sys.modules, and then returns it.","Q_Score":2,"Tags":"python,wxpython","A_Id":9726645,"CreationDate":"2012-03-15T19:09:00.000","Title":"Multiple imports of python modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script say script1.py.  It will prompt the user with a serious of questions like Name, 'Y' \/ 'N' type questions.  Now i need to call this python script from another python script,say scripts2.py  such that I would define the user inputs in script2.py.  So how to pass the input sequentially???\nHelp would be appreciated.\nRegards,\nSujith","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":751,"Q_Id":9736542,"Users Score":1,"Answer":"Sounds like you have a stand-alone program that reads from stdin, and you want to automate input to it using python. Download and use the pexpect module, that's what it's for.","Q_Score":1,"Tags":"python","A_Id":9739990,"CreationDate":"2012-03-16T11:38:00.000","Title":"Python : Automate the user input data(Multiple sequential inputs)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is a theoretical question as I don't have an actual problem, but I got to wondering ... \nIf I had a huge file, say many gigs long and I wanted to change a single byte and I knew the offset of that byte, how could I do this efficiently? Is there a way to do this without rewriting the entire file and only writing the single byte?\nI'm not seeing anything in the Python file api that would let me write to a particular offset in a file.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1583,"Q_Id":9739963,"Users Score":2,"Answer":"You can seek() to a position and write a single byte. It will overwrite what's there, rather than inserting.","Q_Score":6,"Tags":"python","A_Id":9740014,"CreationDate":"2012-03-16T15:22:00.000","Title":"Python - Small Change to a Huge File","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am crawling online stores for price comparison. Mot of the stores are using dynamic URLs heavily. This is causing my crawler to spend lot of time on every online stores. Even though most of them have only 5-6k unique products, they have unique URLs >= 300k. Any idea how to get around this.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":9752891,"Users Score":0,"Answer":"If you parsing some product pages, usually these URLs have some kind of product id.\nFind the pattern to extract product id from URLs, and use it to filter already visited URLs.","Q_Score":0,"Tags":"python,url,dynamic","A_Id":9753135,"CreationDate":"2012-03-17T19:08:00.000","Title":"How to handle dynamic URLs while crawling online stores?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to basically copy whats from the clipboard and paste it in a file in utf-8 encoding, but what ever I try, the file has the '?' symbols in it and is Anscii encoding...\nBut what I found out is, if there is a file that's already in utf-8 encoding, then whatever I paste in it manually (deleting whats there already), wont have the '?' in it. \nSo if there is a way to clear content in a utf-8 file, then copy whats from the clipboard and write it to that file then that would be great.\nIf I create the file, it's always ends up being Ancii...\nNow I already know how to copy from clip board and write it to a file, its just how to clear a file which is confusing...","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12883,"Q_Id":9763675,"Users Score":5,"Answer":"Opening the file in write\/read mode (w+) will truncate the file without rewriting it if it already exists.","Q_Score":2,"Tags":"python","A_Id":9763705,"CreationDate":"2012-03-19T00:41:00.000","Title":"How to erase all text from a file using python, but not delete\/recreate the file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know if it is possible to use Coffeescript on Google App Engine?  If so how can this be done with the app engine Python or Go platforms?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1031,"Q_Id":9764895,"Users Score":2,"Answer":"Coffeescript compiles to Javascript, which can be run in a web browser.  In that case, App Engine can serve up the resulting javascript.\nI don't know of any way to compile coffeescript to python, java or go though, so you can't use it as a server side language.","Q_Score":2,"Tags":"python,google-app-engine,coffeescript,go","A_Id":9764949,"CreationDate":"2012-03-19T04:03:00.000","Title":"How to use Coffeescript on Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a pdf file. There is number of tables in that pdf.\nAccording to the table names given in the pdf, I wanted to fetch the data from that table using python.\nI have worked on html, xlm parsing but never with pdf.\nCan anyone tell me how to fetch tables from pdf using python?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":12830,"Q_Id":9782972,"Users Score":6,"Answer":"This is a very complex problem and not solvable in general.\nThe reason for this is simply that the format PDF is too flexible.  Some PDFs are only bitmaps (you would have to do your own OCR then\u2014obviously not our topic here), some are a bunch of letters literally spilled out over the pages; this means that by parsing the text information in the PDF you could get single characters placed on some coordinates.  In some cases these come in an orderly fashion (line by line, from left to right), but in some cases you will get rather random-like distributions, most commonly with  and  stuff, but also special characters, characters in a different font etc. can come way out of line.\nThe only proper approach is to place all characters according to their coordinates on a page model and then use heuristics to find out what the lines are.\nI propose to have a look at your PDFs and the tables therein you want to parse before starting.  Maybe they are alike all the time and well-parsable.\nGood luck!","Q_Score":4,"Tags":"python,pdf,pdf-scraping","A_Id":9803283,"CreationDate":"2012-03-20T07:42:00.000","Title":"Working on tables in pdf using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here is my current setup:\nGitHub repository, a branch for dev.\nmyappdev.appspot.com (not real url)\nmyapp.appspot.com  (not real url)\nApp written on GAE Python 2.7, using django-nonrel\nDevelopment is performed on a local dev server.  When I'm ready to release to dev, I increment the version, commit, and run \"manage.py upload\" to the myappdev.appspot.com\nOnce testing is satisfactory, I merge the changes from dev to main repo.  I then run \"manage.py upload\" to upload the main repo code to the myapp.appspot.com domain.\nIs this setup good?  Here are a few issues I've run into.\n1) I'm new to git, so sometimes I forget to add files, and the commit doesn't notify me.  So I deploy code to dev that works, but does not match what is in the dev branch. (This is bad practice).\n2) The datastore file in the git repo causes issues.  Merging binary files?  Is it ok to migrate this file between local machines, or will it get messed up?\n3) Should I be using \"manage.py upload\" for each release to the dev or prod environment, or is there a better way to do this?  Heroku looks like it can pull right from GitHub.  The way I'm doing it now seems like there is too much room for human error.\nAny overall suggestions on how to improve my setup?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":398,"Q_Id":9788264,"Users Score":0,"Answer":"I'm on a pretty similar setup, though I'm still runing on py2.5, django-nonrel.\n1) I usually use 'git status' or 'git gui' to see if I forgot to check in files.\n2) I personally don't check in my datastore.  Are you familiar with .gitignore?  It's a text file in which you list files for git to ignore when you run 'git status' and other functions.  I put in .gaedata as well as .pyc and backup files.\nTo manage the database I use \"python manage.py dumpdata > file\" which dumps the database to a json encoded file.  Then I can reload it using \"python manage.py loaddata\".\n3) I don't know of any deploy from git.  You can probably write a little python script to check whether git is up to date before you deploy.  Personally though, I deploy stuff to test to make sure it's working, before I check it in.","Q_Score":1,"Tags":"django,google-app-engine,github,development-environment,python-2.7","A_Id":9793302,"CreationDate":"2012-03-20T13:58:00.000","Title":"Google App Engine Development and Production Environment Setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"How soon after the reference count reaches zero is __del__ method called? Does the language promise that it's done right away, before any other use code can execute? Or can each implementation do what it likes, potentially delaying the call to __del__ arbitrarily long?\nPlease ignore the situation when the program is about to exit (I assume it means the last statement in the given block has finished, and the stack is empty). I understand that in such cases, there's no promises about __del__; it may not even be called at all. \nAlso, I'm aware that reference count may be non-zero due to cycles, etc. I am not concerned about that here (I'm asking a separate question about it).","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":743,"Q_Id":9796643,"Users Score":11,"Answer":"Python doesn't make any guarantees about when __del__ is called, or whether it is called at all. As it is, __del__ methods are unlikely to be called if the object is part of a reference cycle, because even if the cycle as a whole is cleaned up, Python has no way to decide where to break the cycle and in what order the __del__ methods (if any) should be called. Because of __del__'s rather quirky semantics (in order to call __del__ the refcount of the object is temporarily increased, and the __del__ method can prevent destruction of the object by storing the reference somewhere else) what happens in other implementations is a bit of a crapshoot. (I don't remember the exact details in current Jython, but it has changed a few times in the past.)\nThat said, in CPython, if __del__ is called, it's called as soon as the reference count drops to zero (since refcounting is the only way __del__ methods are called, and the only chance CPython has of calling __del__ is when the actual refcount is changed.)","Q_Score":4,"Tags":"python,garbage-collection,python-3.x,destructor","A_Id":9796689,"CreationDate":"2012-03-20T23:38:00.000","Title":"how soon is `__del__` called after reference count drops to zero?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We need to use in Java written software some Python subclasses of an abstract Python class. Trying to do it with Jython we had some troubles that we haven't experienced importing not-abstract Python classes. More specifically, the error that we get is this\n\nthe source attachment is not contain the source for the file PyTableCode.class\n\nDoes anybody knows how to fix this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":9807215,"Users Score":0,"Answer":"Code would really be needed, but my gut feeling is, that your system has access to the compiled .class file from Jython but not the .py source file","Q_Score":1,"Tags":"java,python,abstract-class,jython","A_Id":9993155,"CreationDate":"2012-03-21T15:01:00.000","Title":"How to import in Java Python subclasses that use abstract methods of other classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I don't know how to present the title more clearly. \nI want build a site on Google app engine (GAE), and one app on android.\nThe site on GAE should wait the signal which is from the app on android and handle the signal to do something. \nI don't know how to search the \"keyword\" on Google of waiting signal on GAE, or what method should I use. \nIs here have anyone who have some related experiment on it ?\nThank you very much.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":9808250,"Users Score":1,"Answer":"You don't seem to have understood how web applications work. They don't wait for signals - or, rather, that's all they do. Every page served by a Web service is in response to a signal, ie a request. Your web service just needs to respond to normal requests in the normal way.","Q_Score":0,"Tags":"android,python,http,google-app-engine","A_Id":9808831,"CreationDate":"2012-03-21T15:56:00.000","Title":"GAE wait response from other source","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In C#, Python and\/or VB.NET, how can I write a method of a class that can accept different sequences of arguments? As an indication, the multiple choices of arguments sequence would be accessible when pressing shift+shift+space in Visual Studio.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":290,"Q_Id":9812084,"Users Score":0,"Answer":"If the arguments are of a different type you could overload the method\nAlternatively, you can just pass in a value indicating the sequence of arguments and have logic within the method to treat it accordingly.","Q_Score":0,"Tags":"c#,python,vb.net,visual-studio","A_Id":9812140,"CreationDate":"2012-03-21T20:10:00.000","Title":"How do I define a method which can accept different sequences of arguments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have multiple Python projects that have dependencies on each other. Hierarchically, these are organized like this:\n\nP1\nP2\n...\nPn\n\nEach of these is an PyDev project within Eclipse and they co-exist just fine within that environment. We are in the process of structuring out build process to enable us to deploy these and distribute these in a more systematic fashion. Currently, we just zip up these projects and copy them over for deployment.\nI need some advice on how to go about this task using distutils. Our objective is to have a script to build a zip file (or tar file) using distutils that contains all the necessary code and necessary data\/properties from the projects P1 through Pn. We should then be able to deploy this with setup.py and having our DJango-based web layer access it.\nMy first attempt is to create a project whose sole purpose is to build the deployment artifacts. This will sit parallel to the projects P1 through Pn, called PBuild. \nDoes this seem reasonable? I'm having some issues with this approach. Does anybody have any other ideas of how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":180,"Q_Id":9826322,"Users Score":1,"Answer":"There's different philosophies on how apps should be packaged, but most Python developers adhere to a very minimalistic approach. In other words, you package up the smallest units of logic you can.\nSo, your goal here shouldn't be to cram everything together, but to package each discrete application separately. By application, here, I don't mean necessarily each Django app, although breaking out some of the apps into their own packages may be worthwhile as well.\nThis is really all about reusability. Any piece that could serve a purpose in some other scenario should get its own package. Then, you can set them up to have dependencies on whatever other packages they require.","Q_Score":0,"Tags":"python,django,deployment,distutils,project-organization","A_Id":9826658,"CreationDate":"2012-03-22T16:16:00.000","Title":"Multiple Python projects organization for deployment and\/or distribution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python web app that essentially allows 2 computers to talk with one another.  If a session ends abruptly the record is still stored in pymongo, I want to be able to run a cron job to clean up old records, but I am not clear on how to do that, can't figure how to use bash to talk to pymongo...\nWhat else could I do, call python from the cron job?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":457,"Q_Id":9861344,"Users Score":1,"Answer":"You could write a python script using pymongo (or any other mongodb client library) that does the necessary cleanup and configure cron to run it regularly.","Q_Score":1,"Tags":"python,mongodb,openshift","A_Id":9862914,"CreationDate":"2012-03-25T15:26:00.000","Title":"Openshift, python, mongodb, and cron guidance needed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Salut, community!\nBriefly.\nI wrote usual model over QAbstractTableModel and using it in usual way for QTableView. But I think I need to use some columns of this model for the few QListViews in QWizard to fill main table in the right way (for user).\nFor example: use the column2 as the QListView's model on the page1 of the wizard; column3 for page2 for its QListView etc.\nPlease, help me to understand just two things:\n\nAm I on the right way?\nIf yes then how can I make it simply and explicitly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":9864843,"Users Score":2,"Answer":"Set the QTableModel as the model for each QListView, and use QListView.setModelColumn to choose which column they each display.","Q_Score":2,"Tags":"python,qt,model,pyqt,pyqt4","A_Id":9864880,"CreationDate":"2012-03-25T23:01:00.000","Title":"QAbstractTableModel as a model for one QTableView and few QListViews","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)?\nI navigate to menu Window \u2192 Preference \u2192 General \u2192 Appearance \u2192 Colors & Fonts, but I don't find which item would affect the Python code font.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":16217,"Q_Id":9868711,"Users Score":2,"Answer":"On a Mac, I can get to the PyDev settings via:\nEclipse \u2192 Preferences \u2192 PyDev (in tree) \u2192 Editor (subtree)\nIn my case, I wanted to change hash tag comments from nearly invisible grey to a better color. It worked like a charm.","Q_Score":12,"Tags":"python,eclipse,pydev","A_Id":13807754,"CreationDate":"2012-03-26T08:16:00.000","Title":"How do I change the default font for Python code in Eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)?\nI navigate to menu Window \u2192 Preference \u2192 General \u2192 Appearance \u2192 Colors & Fonts, but I don't find which item would affect the Python code font.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":16217,"Q_Id":9868711,"Users Score":2,"Answer":"Following the guidance of gecco, I found out the item in General \u2192 Appearance \u2192 Colors & Fonts which affects Python code fonts. It's Text Font in the Basic folder.","Q_Score":12,"Tags":"python,eclipse,pydev","A_Id":9883196,"CreationDate":"2012-03-26T08:16:00.000","Title":"How do I change the default font for Python code in Eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For debug use I want to show the type of a variable in Google App Engine.\nIn traditional environment, I will use \"print type( x )\" to do it. But in GAE I just don't know why I can't use self.response.out.write( str( type( x )  )  ) to echo it in the browser. I got confused because I did transform the <type 'type'> to < type 'str' >.\nSince that doesn't work I have to use self.response.out.write( str( type( x) == type( \"123\" )  ) ) instead of directly echoing the type.\nSo what did I miss in thinking?\nI am also using logging module to echo the type which works well. But I still want to know why self.response.out.write(  ) doesn't work.\nThanks all for help!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":9872029,"Users Score":1,"Answer":"When browser renders html it thinks that <type 'str'> is a (unknown) tag, so it renders it as <type 'str'><\/type>, hence it becomes part of your page markup... You can see this with Firebug or any similar tool.","Q_Score":0,"Tags":"python,google-app-engine,types","A_Id":9885834,"CreationDate":"2012-03-26T12:22:00.000","Title":"how to show an object's type in google app engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a vector\/array of n elements. I want to choose m elements.\nThe choices must be fair \/ deterministic -- equally many from each subsection.\nWith m=10, n=20 it is easy: just take every second element.\nBut how to do it in the general case? Do I have to calculate the LCD?","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":11243,"Q_Id":9873626,"Users Score":3,"Answer":"Use a loop (int i=0; i < m; i++)\nThen to get the indexes you want, Ceil(i*m\/n).","Q_Score":12,"Tags":"python,algorithm","A_Id":9873885,"CreationDate":"2012-03-26T14:05:00.000","Title":"Choose m evenly spaced elements from a sequence of length n","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm taking over a Satchmo site and need it to charge a different shipping rate for international versus local postage.  \nAny idea what I need to do to enable this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":9886494,"Users Score":0,"Answer":"it seems like the tieredweight shipping module is what I need here.","Q_Score":0,"Tags":"python,django,shipping,satchmo","A_Id":14647712,"CreationDate":"2012-03-27T09:13:00.000","Title":"Different national and international shipping rate in Satchmo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to use PyPy 1.8 on Windows XP 32-bit. I downloaded the zip file off the website and installed it into a My Documents file. Initially, I thought it was similar to psyco in that I had to \"import psyco,\" but I found that PyPy.exe acted like the Python command line instead.\nI tried dragging my scripts into the PyPy.exe to run them, but it didn't seem to work at all. Attempting to use the \"python\" command within PyPy yielded a \"global name 'python' is not defined.\" \nSo I was hoping if someone can assist me in making PyPy run because I'm pretty much out of ideas. The documentation on the PyPy website confused me mainly and was not very helpful. \nAns: I found that I could simply right-click the script and \"Open with\" Pypy.exe to make it work. Not sure why it didn't work with the drag since I thought that was equivalent. Thanks everyone.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":24210,"Q_Id":9893317,"Users Score":0,"Answer":"install Chocolatey\nchoco install python.pypy -y","Q_Score":15,"Tags":"python,pypy","A_Id":68372961,"CreationDate":"2012-03-27T16:04:00.000","Title":"How to use PyPy on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to use PyPy 1.8 on Windows XP 32-bit. I downloaded the zip file off the website and installed it into a My Documents file. Initially, I thought it was similar to psyco in that I had to \"import psyco,\" but I found that PyPy.exe acted like the Python command line instead.\nI tried dragging my scripts into the PyPy.exe to run them, but it didn't seem to work at all. Attempting to use the \"python\" command within PyPy yielded a \"global name 'python' is not defined.\" \nSo I was hoping if someone can assist me in making PyPy run because I'm pretty much out of ideas. The documentation on the PyPy website confused me mainly and was not very helpful. \nAns: I found that I could simply right-click the script and \"Open with\" Pypy.exe to make it work. Not sure why it didn't work with the drag since I thought that was equivalent. Thanks everyone.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":24210,"Q_Id":9893317,"Users Score":9,"Answer":"Maybe I'm not following what you're trying to do, but isn't it just a question of opening a command prompt and running pypy myscriptname ?  Assuming you've got all the paths for PyPy and your script straight, anyway (e.g. your script's in PyPy's folder).","Q_Score":15,"Tags":"python,pypy","A_Id":9895099,"CreationDate":"2012-03-27T16:04:00.000","Title":"How to use PyPy on Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any way in a browser, to type python code into an input field, it will then be sent to a local server and executed and the result pushed back to the browser.\nBasically a browser hosted python notebook, where the code gets evaluated on a different machine.\nIs there any python package to do this. \nsomething like what ideone.com or picloud do, but opensource and that can install on your own server.\nOr any suggestions on how to do it, I have looked around already but have struggled to find something meaningful.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":92,"Q_Id":9899180,"Users Score":1,"Answer":"I haven't tried myself. You may want to check out ipython notebook.","Q_Score":0,"Tags":"python,python-3.x,cloud","A_Id":9899346,"CreationDate":"2012-03-27T23:32:00.000","Title":"cloud scripting through browser and evaluate python on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This isn't as much of a specific problem as something I am looking for more of a \"Pythonic\" philosophical answer to.  Namely, what's the best way to keep track of unique items and ensure duplicates don't arise?\nFor example, I am writing a script to scrape a website for links to songs on SoundCloud so I can automatically download them.  If I want to automate this program with, say, cron, what's the most efficient way to ensure that I am downloading only content I don't have already?\nOr if I downloaded images, how could I make sure that there aren't any duplicates, or have some sort of process that searches for and removes duplicates efficiently?\nKind of open ended, so contribute as little or as much as you please.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":214,"Q_Id":9899313,"Users Score":2,"Answer":"Use a dict or set.  Consider computing a checksum of each item.  This brings you toward what's known as Content Addressable Storage, which is where the checksum actually is stored as if it were the item's \"name\", and a separate index is stored which maps things like filenames or song names to the checksums or data blocks.  The problem with the CAS approach in your particular case is that it may not be possible for you to get a checksum computed on the remote side for new content--that's how programs like rsync avoid copying duplicate data.","Q_Score":1,"Tags":"python,beautifulsoup,mechanize","A_Id":9899341,"CreationDate":"2012-03-27T23:48:00.000","Title":"What is the most efficient way to keep track of unique downloaded files in a Python program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"i'm working with an application written in python using gevent.  i want it to exit immediately as a result of any exception that i haven't explicitly trapped. \nit looks like i'd have to patch the core gevent code.\nis there any way can i do this in my app, without patching gevent or greenlet?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1560,"Q_Id":9916873,"Users Score":0,"Answer":"You can use spawn_link_exception instead of spawn.","Q_Score":2,"Tags":"python,exception,gevent","A_Id":17853380,"CreationDate":"2012-03-28T22:58:00.000","Title":"how can i make gevent application exit immediately after any exception?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Does an analogue to Java's Math.rint exist in Python?\nIf not, how can I achieve the same result?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1638,"Q_Id":9921057,"Users Score":0,"Answer":"You can use the built-in function round:\n\nround(3.5) gives 4.0\nround(3.4) gives 3.0\nround(3.6) gives 4.0","Q_Score":1,"Tags":"java,python,math","A_Id":9921123,"CreationDate":"2012-03-29T07:41:00.000","Title":"Rounding numbers: Java's 'Math.rint' in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making an application in Python and using Amazon Web Services in some modules.\nI'm now hard coding my AWS access id and secret key in *.py file. Or might move them out to an configuration file in future.\nBut there's a problem, how can I protect AWS information form other people? As I know python is a language that easy to de-compile. \nIs there a way to do this? \n\nWell what I'm making is an app to help user upload\/download stuff from cloud. I'm using Amazon S3 as cloud storage. As I know Dropbox also using S3 so I'm wondering how they protects the key.\n\nAfter a day's research I found something.\nI'm now using boto (an AWS library for python). I can use a function of 'generate_url(X)' to get a url for the app to accessing the object in S3. The url will be expired in X seconds.\nSo I can build a web service for my apps to provide them the urls. The AWS keys will not be set into the app but into the web service.\nIt sounds great, but so far I only can download objects with this function, upload doesn't work. Any body knows how to use it for uploading?\n\nDoes anyone here know how to use key.generate_url() of boto to get a temporary url for uploading stuff to S3?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6307,"Q_Id":9926825,"Users Score":0,"Answer":"Don't put it in applications you plan to distribute.  It'll be visible and they can launch instances that are directly billable to you or worst..they can take down instances if you use it in production.\nI would look at your programs design and seriously question why I need to include that information in the app.  If you post more details on the design I'm sure we can help you figure out a way in which you don't need to bundle this information.","Q_Score":11,"Tags":"python,amazon-web-services","A_Id":9928772,"CreationDate":"2012-03-29T13:54:00.000","Title":"How can I protect my AWS access id and secret key in my python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is.\nI could work for hours trying to determine which Python GUI toolkit is \"best\", then learning how to do what I need, but it seems like this would have been done before.  \nIs there a relatively cook-book method to GUIify my program?  Direction to either some sort of lesson\/tutorial or an existing, documented, concise program would be excellent.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4233,"Q_Id":9927821,"Users Score":0,"Answer":"Basically you just need to figure out what widgets will hold the data you want the best. I suspect you could use a couple combo boxes to hold different sets of extensions. Or you could just use the path name strings to figure that out. Hit a button and run the conversion process, probably in another thread so the GUI remains responsive.\nI'm biased for wxPython. However, you're better off taking a look at their demos and documentation and seeing which GUI toolkit fits your brain the easiest.","Q_Score":3,"Tags":"python,user-interface,wxpython,pyqt,tkinter","A_Id":9928114,"CreationDate":"2012-03-29T14:48:00.000","Title":"Cookbook GUI interface for a command-line script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is.\nI could work for hours trying to determine which Python GUI toolkit is \"best\", then learning how to do what I need, but it seems like this would have been done before.  \nIs there a relatively cook-book method to GUIify my program?  Direction to either some sort of lesson\/tutorial or an existing, documented, concise program would be excellent.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":4233,"Q_Id":9927821,"Users Score":1,"Answer":"There are a few answers advocating wxpython. However, any toolkit will work for this project. Tkinter has the added benefit tha you and your collegues already have it installed and it is very easy to use. \nThat being said, the other toolkits are more-or-less equally easy to use but you might have to jump through a hoop or two to get them installed. If installation is not an issue it won't matter which one you pick.\nUnfortunately, telling you how to \"GUIfy\" your program is hard since we know nothing about your app. Probably all it will involve is putting up a few labels and input widgets, then creating a button that collects all the data and then runs your program with the subprocess module.","Q_Score":3,"Tags":"python,user-interface,wxpython,pyqt,tkinter","A_Id":9934956,"CreationDate":"2012-03-29T14:48:00.000","Title":"Cookbook GUI interface for a command-line script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is.\nI could work for hours trying to determine which Python GUI toolkit is \"best\", then learning how to do what I need, but it seems like this would have been done before.  \nIs there a relatively cook-book method to GUIify my program?  Direction to either some sort of lesson\/tutorial or an existing, documented, concise program would be excellent.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4233,"Q_Id":9927821,"Users Score":0,"Answer":"This depends mostly on your need. If your need is simple, you can just go with tkinter that is bundled with python itself. If you use this, you will not be relying on third party library to implement your GUI. Since you are wanting to make this available for your collegues, this might be easier to compile with py2exe or other similar stuffs to exe which might be tricky if you use third party library for GUI. However, if you want to add more functionality to your GUI, wxpython\/pyqt\/pyGTK are the GUI toolkit to look for. Personally, I favor wxpython due to its cross-platform nature but pyqt and pyGTK are also equally good as far as I have heard.","Q_Score":3,"Tags":"python,user-interface,wxpython,pyqt,tkinter","A_Id":9928262,"CreationDate":"2012-03-29T14:48:00.000","Title":"Cookbook GUI interface for a command-line script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given 3 numbers, I need to find which number lies between the two others.\nie,given 3,5,2\nI need 3 to be returned.\nI tried to implement this by going thru all three and using if else conditions to check if each is between the other two.But this seems a naive way to do this.Is there a better way?","AnswerCount":10,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55236,"Q_Id":9979602,"Users Score":23,"Answer":"Put them in a list, sort them, pick the middle one.","Q_Score":8,"Tags":"python","A_Id":9979626,"CreationDate":"2012-04-02T15:55:00.000","Title":"how to find the middle number in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) \"normal\" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be the problem?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7327,"Q_Id":9991838,"Users Score":4,"Answer":"Nothing is the problem. Python code is executed line-by-line.\nIf your code does not work when executed line-by-line, it should not work when loaded from a file (assuming in both cases a \"clean\" environment).","Q_Score":8,"Tags":"python,linux,shell,ipython,line-breaks","A_Id":9991864,"CreationDate":"2012-04-03T10:56:00.000","Title":"Linux - Linebreak in IPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) \"normal\" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be the problem?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7327,"Q_Id":9991838,"Users Score":7,"Answer":"If you want to do a line-break, you end the line with the \\ escape character, same as you do in a Python file. Shift+Enter doesn't have any special meaning in ipython, and indeed most over places in the shell. It doesn't have special meaning in Python, either.\nIt does have special meaning in some text editors and word processors, most notably LyX and LibreOffice, and of course on some websites (through a web browser).","Q_Score":8,"Tags":"python,linux,shell,ipython,line-breaks","A_Id":9992118,"CreationDate":"2012-04-03T10:56:00.000","Title":"Linux - Linebreak in IPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project which is getting more and more complex. I started off with the traditional files: models, views, and forms.py. The issue I have right now is that those files are getting bigger and bigger and I'd like to break them into manageable parts. What are the best practices around that?\nIn addition, I am wondering if it is best practice to add class method to a model in Django? For instance, I have a Vote class on which I would like to add methods to get the number of votes for a specific user, content, etc?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1093,"Q_Id":9995041,"Users Score":1,"Answer":"I certainly use class methods, and I have found that where there are similar operations to be performed on classes, it is possible (and easy) to factor the classmethods into base classes (use the self parameter of your class method to write generic code).\nProbably the best way to manage broken-up views, etc is to replace each file you want to break up with its own package, and put whatever you need to (if anything) into that package's __init__.py module.","Q_Score":4,"Tags":"python,django","A_Id":9995337,"CreationDate":"2012-04-03T14:10:00.000","Title":"How to structure complex Django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project which is getting more and more complex. I started off with the traditional files: models, views, and forms.py. The issue I have right now is that those files are getting bigger and bigger and I'd like to break them into manageable parts. What are the best practices around that?\nIn addition, I am wondering if it is best practice to add class method to a model in Django? For instance, I have a Vote class on which I would like to add methods to get the number of votes for a specific user, content, etc?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1093,"Q_Id":9995041,"Users Score":2,"Answer":"I find refactoring can really help. Are there a lot of similar views that just have different templates or querysets? Make a more generic view that accepts multiple template names, records, etc.\nAnything that requires extensive calculations gets moved to a utils.py in the same directory.\nClass methods are for actions that affect a single record; managers are for dealing with filtering records or creating a record.\nIf you're already taking the step of making separate models, views, etc. folders and breaking views and models into separate files, that suggests to me that you could separate them out into separate apps. I like that as an option much better.","Q_Score":4,"Tags":"python,django","A_Id":9997876,"CreationDate":"2012-04-03T14:10:00.000","Title":"How to structure complex Django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I acquired a python script that will either telnet to some equipment, or if the equipment is in a lab, ssh to a firewall machine and then it will telnet to the equipment, and run a command, returning the output for more processing.\nI took this script and tied it into a Django web app so that I could, from a browser, fill out a form with the target system info and have it display the results. If I start up this web app from the command line, and then access it from the browser (python manage.py app), everything works fine.\nHowever, if I set this up to run in \"production\" mode, using a virtual host with Apache, the SSH fails. I suspect that this is running under root or some web account and cannot SSH to the firewall.\nCan someone suggest how I get this to work? I don't have any privileges on the firewall machine, so I can't setup SSH to run under some web account.\nWould I need to collect username and password from the user, in the case where SSH is used, and then pass it to ssh, or are there other ways to get the telnet info and command through to the equipment?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2644,"Q_Id":10002771,"Users Score":2,"Answer":"You're close.  The problem here is probably that your web server runs as a non-privileged user (NOT root), like www or www-data or nobody (depending on your operating system).  While that user can probably run the SSH binary, when doing so as nobody, it probably doesn't have a home directory, can't find your .ssh directory, and can't find the key file (.ssh\/id_rsa  for example) that it needs to use for authentication.\nYou have a number of options.  Make your private key available to the web server software, then launch ssh with the -i option to select an identity file.  Or do this in an SSH config file that you specify with the -F option.  Or launch ssh using sudo, and give your web server software the ability to run ssh as some other (shell) user.\nI can't provide a more specific answer because you haven't provided specifics in your question.  Operating system, sample code, etc.\nHope this helps.\nOh, and you should also consider NOT doing this, and finding some other solution.  A web application, even an internal one, that has SSH access to your firewall?  Sounds like a recipe for eventual disaster to me.  :-)","Q_Score":0,"Tags":"python,django,ssh","A_Id":10003264,"CreationDate":"2012-04-03T23:09:00.000","Title":"need to ssh to remote machine from web page with python\/django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a small matrix operations library as a programming challenge to myself(and for the purpose of learning to code with Python), and I've come upon the task of calculating the determinant of 2x2, 3x3 and 4x4 matrices.\nAs far as my understanding of linear algebra goes, I need to implement the Rule of Sarrus in order to do the first 2, but I don't know how to tackle this Pythonically or for matrices of  larger size. Any hints, tips or guides would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3244,"Q_Id":10003232,"Users Score":6,"Answer":"The rule of Sarrus is only a mnemonic for solving 3x3 determinants, and won't be as helpful moving beyond that size.\nYou should investigate the Leibniz formula for calculating the determinant of an arbitrarily large square matrix. The nice thing about this formula is that the determinant of an n*n matrix is that it can be determined in terms of a combination of the determinants of some of its (n-1)*(n-1) sub-matrices, which lends itself nicely to a recursive function solution.\nIf you can understand the algorithm behind the Leibniz formula, and you have worked with recursive functions before, it will be straightforward to translate this in to code (Python, or otherwise), and then you can find the determinant of 4x4 matrices and beyond!","Q_Score":3,"Tags":"python,matrix,linear-algebra","A_Id":10003296,"CreationDate":"2012-04-04T00:08:00.000","Title":"Python determinant calculation(without the use of external libraries)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used to Python logging, it works fine.  The logging.basicConfig(...) set in one module (a some.py file), then we can use logging every where.  Obviously, logging is global.\nThe question is how logging find it's settings, when we not call the module where basicConfig(...) appeared (in some.py file )?  Is logging scan all the packages?\nEven the logging.basicConfig(...) put into an any.py and the module (any.py) never get imported, or not used anywhere, the logging setting take effect!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":727,"Q_Id":10006017,"Users Score":2,"Answer":"I think there is no magic scanning here.\n\nTry to test it this way in a separate test directory:\n\ntest\/main.py:\n    import logging\n    logging.info('test')\ntest\/any.py:\n    import logging\n    logging.basicConfig(filename='test.log', level=logging.INFO)\npython main.py\n\nResult: NO test.log file.\nNow let's update the test:\n\ntest\/main.py:\n    import logging\n    import any\n    logging.info('test')\npython main.py\n\nResult: new test.log file with INFO:root:test string inside.\nSo I guess that any.py in your case is imported somehow,\ndespite your expectations.\nYou may find the way any.py is imported easily,\njust add few lines there:\n\ntest\/any.py:\n    from traceback import print_stack\n    print_stack()\n    ...\npython main.py\n\nResult:\n\nFile \"main.py\", line 2, in \n    import any\nFile \"any.py\", line 2, in \n    print_stack()\n\nThis stack shows that any.py is imported from main.py.\nI hope you will find where it is imported from in your case.","Q_Score":2,"Tags":"python,logging","A_Id":10023080,"CreationDate":"2012-04-04T06:34:00.000","Title":"How python logging get it's configuration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I downloaded the actual py2exe package.\nBut I've no idea how to get it in my system. I mean I can follow the tutorial a 100% but I can't find anything how to install py2exe to my kubuntu 11.10.\nI also can't find a py2exe.py which I could include to my workingfolder. \nCould some please help me the project has to be finish till tomorrow? \nThanks for your help\ncheers,\nChris","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":23189,"Q_Id":10009660,"Users Score":9,"Answer":"Py2exe has to run on Windows, you can not run it in Linux. (Maybe wine can help, but I'm not sure)","Q_Score":9,"Tags":"python,installation,py2exe","A_Id":10009715,"CreationDate":"2012-04-04T10:53:00.000","Title":"How to install the py2exe modul in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a Oracle of Bacon type website that involves a breadth first search on a very large directed graph (>5 million nodes with an average of perhaps 30 outbound edges each). This is also essentially all the site will do, aside from display a few mostly text pages (how it works, contact info, etc.). I currently have a test implementation running in Python, but even using Python arrays to efficiently represent the data, it takes >1.5gb of RAM to hold the whole thing. Clearly Python is the wrong language for a low-level algorithmic problem like this, so I plan to rewrite most of it in C using the Python\/C bindings. I estimate that this'll take about 300 mb of RAM.\nBased on my current configuration, this will run through mod_wsgi in apache 2.2.14, which is set to use mpm_worker_module. Each child apache server will then load up the whole python setup (which loads the C extension) thus using 300 mb, and I only have 4gb of RAM. This'll take time to load and it seems like it'd potentially keep the number of server instances lower than it could otherwise be. If I understand correctly, data-heavy (and not client-interaction-heavy) tasks like this would typically get divorced from the server by setting up an SQL database or something of the sort that all the server processes could then query. But I don't know of a database framework that'd fit my needs.\nSo, how to proceed? Is it worth trying to set up a database divorced from the webserver, or in some other way move the application a step farther out than mod_wsgi, in order to maybe get a few more server instances running? If so, how could this be done?    \nMy first impression is that the database, and not the server, is always going to be the limiting factor. It looks like the typical Apache mpm_worker_module configuration has ServerLimit 16 anyways, so I'd probably only get a few more servers. And if I did divorce the database from the server I'd have to have some way to run multiple instances of the database as well (I already know that just one probably won't cut it for the traffic levels I want to support) and make them play nice with the server. So I've perhaps mostly answered my own question, but this is a kind of odd situation so I figured it'd be worth seeing if anyone's got a firmer handle on it. Anything I'm missing? Does this implementation make sense? Thanks in advance!\nTechnical details: it's a Django website that I'm going to serve using Apache 2.2.14 on Ubuntu 10.4.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":214,"Q_Id":10017645,"Users Score":1,"Answer":"First up, look at daemon mode of mod_wsgi and don't use embedded mode as then you can control separate to Apache child processes the number of Python WSGI application processes. Secondly, you would be better off putting the memory hungry bits in a separate backend process. You might use XML-RPC or other message queueing system to communicate with the backend processes, or even perhaps see if you can use Celery in some way.","Q_Score":2,"Tags":"python,database,django,apache,mod-wsgi","A_Id":10020054,"CreationDate":"2012-04-04T19:06:00.000","Title":"Maximizing apache server instances with large mod_wsgi application","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I'm wanting to do is create a selection tool (like what you see in most paint programs) using PyGtk.  I've seen a previous question that asked something similar, but they already seemed to know what they were doing to make the selection itself.  That user said he was using an eventbox, but I don't know how I would use that to accomplish what I am trying to do.  How would the eventbox work with a selection?\nThe algorithm for the rectangle isn't a problem at all, I just need to know what tools I should be using to actually select a part of a picture and be able to move it around.  This is my first time using PyGtk, and I'm also fairly new to python itself, so any help would be great.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":10018767,"Users Score":0,"Answer":"If you want to display an image and allow the user to select and move parts of it, you best look for a ready-made image editing widget. GTK doesn't come with one.\nTo roll your own you can use an image widget for display, but it doesn't care about the mouse, so you can place it inside an event box and connect to button and movement events. You'll have to handle all the drawing of rectangle, walking ants and floating cutout yourself in the pixbuf backing the image.\nIt might be easier to start from scratch with an empty event box and draw even the image yourself.","Q_Score":0,"Tags":"python,pygtk","A_Id":10057082,"CreationDate":"2012-04-04T20:29:00.000","Title":"How do I create a canvas selection tool?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This might be a more difficult question since I don't even know how to do it outside of Python...\nI want to write a terminal program that completely locks up my PC until a password is entered. In the locked state no one should be able to do anything outside the terminal. In it, the user may rampage and write silly commands, but he should not be able to switch windows, click outside of it, open the task manager, open the menu with Ctrl + Alt Gr + Del and so on.\nWhile searching for a way to accomplish this I've thought of two approaches that Python is also able to do:\n\nModifying the registry -> can disable task manager and some other functions, but not the app switcher neither the menu\nTask-killing explorer.exe and dwm.exe -> killing explorer.exe just removed the taskbar, killing dwm.exe seems like the right way, but as it's the window manager it automatically boots up itself again as soon as it gets killed\n\nI know this is a kind of weird question and doesn't contain any code snippet, but the front-end is no problem and as said I don't even got a working approach for the back-end.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":545,"Q_Id":10020389,"Users Score":-1,"Answer":"write a while loop\nInto the while loop write the command to taskkill dwm.exe\n\nIt's a poor solution, but the only one I know.\nRegards!","Q_Score":0,"Tags":"winapi,windows-7,python-3.x,block,pywin32","A_Id":28282261,"CreationDate":"2012-04-04T22:52:00.000","Title":"Completely locking down Windows 7 using Python 3.2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not sure if I worded the subject correctly but essentially I'm curious if someone can develop code in the Python IDLE, or a similar tool, and then through some command spit out the current code in memory. I believe I did this previously when going through a Lisp book and recall it being a very different approach than the usual re-running of static files. Any suggestions as to how to do this or something similar? Thanks\nUPDATE I ended up using a combination of the IDLE using execfile and reload commands, while editing code in a separate editor (eclipse\/pydev). I changed my \"main\" file so that nothing executes immediately when execfile is called on it. Code in the main file and modules imported are loaded into the current scope\/stack so as I'm writing new code or an error occurs I can test directly in the IDLE command line. Once I have found the problem or way forward I then update code in editor, run reload(module) for updated modules, then execfile(path) on the main file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":199,"Q_Id":10031427,"Users Score":5,"Answer":"The reason why this is sensible with LISP is that every LISP programs is just a bunch of macros and functions and the s-expressions can be formatted automatically into a nice representation. \nThis isn't the case in Python, where you have more complex syntax (significant whitespace, decorators, lots of control structures, different types of string literals, ...) and more semantic elements (classes, functions, top-level code, ...), so this approach will not work very well here. The resulting code would get really messy for even the smallest of projects and the resulting code would still require a lot of \"post-processing\", somewhat annihilating the speed of development advantage.\nInstead, you can just write the code in a good text editor and\n\nUse built-in functionality to integrate it with the REPL (EMACS and Vim have good support for this kind of stuff) or\nload it into REPL using execfile, which will give you the comfort of good text editing and the interactivity of the prompt.\nalong with the program, write a suite of unit tests. This is to be recommended for any non-trivial piece of software and automates the testing of your code, so you'll have to spend less time in an interactive prompt, manually checking if a function works correctly.\n\nYou could also grab a more fully-featured IDE that supports code evaluation and full-blown debugging (PyDev is an example here, thanks to sr2222).","Q_Score":3,"Tags":"python,python-idle","A_Id":10031501,"CreationDate":"2012-04-05T15:22:00.000","Title":"Can a python IDLE be used for iterative\/in-memory development?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I think understand the idea of duck typing, and would like to use it more often in my code. However, I am concerned about one potential problem: name collision.\nSuppose I want an object to do something. I know the appropriate method, so I simply call it and see what happens. In general, there are three possible outcomes:\n\nThe method is not found and AttributeError exception is raised. This indicates that the object isn't what I think it is. That's fine, since with duck typing I'm either catching such an exception, or I am willing to let the outer scope deal with it (or let the program terminate).\nThe method is found, it does precisely what I want, and everything is great.\nThe method is found, but it's not the method that I want; it's a same-name method from an entirely unrelated class. The execution continues, until either inconsistent state is detected later, or, in the worst case, the program silently produces incorrect output. \n\nNow, I can see how good quality names can reduce the chances of outcome #3. But projects are combined, code is reused, libraries are swapped, and it's quite possible that at some point two methods have the same name and are completely unrelated (i.e., they are not intended to substitute for each other in a polymorphism).\nOne solution I was thinking about is to add a registry of method names. Each registry record would contain:\n\nmethod name (unique; i.e., only one record per name)\nits generalized description (i.e., applicable to any instance it might be called on)\nthe set of classes which it is intended to be used in\n\nIf a method is added to a new class, the class needs to be added to the registry (by hand). At that time, the programmer would presumably notice if the method is not consistent with the meaning already attached to it, and if necessary, use another name.\nWhenever a method is called, the program would automatically verify that the name is in the registry and the class of the instance is one of the classes in the record. If not, an exception would be raised.\nI understand this is a very heavy approach, but in some cases where precision is critical, I can see it might be useful. Has it been tried (in Python or other dynamically typed languages)? Are there any tools that do something similar? Are there any other approaches worth considering?\nNote: I'm not referring to name clashes at the global level, where avoiding namespace pollution would be the right approach. I'm referring to clashes at the method names; these are not affected by namespaces.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1060,"Q_Id":10033953,"Users Score":0,"Answer":"If you are worried that the lack of static type checking will let some bugs get through, the answer isn't to bolt on type checking, it is to write tests.\nIn the presence of unit tests, a type checking system becomes largely redundant as a means of catching bugs.  While it is true that a type checking system can catch some bugs, it will only catch a small subset of potential bugs.  To catch the rest you'll need tests.  Those unit tests will necessarily catch most of the type errors that a type checking system would have caught, as well as bugs that the type checking system cannot catch.","Q_Score":4,"Tags":"python,language-agnostic,duck-typing,dynamic-typing","A_Id":10034420,"CreationDate":"2012-04-05T18:27:00.000","Title":"Duck typing: how to avoid name collisions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm learning Python and want to make a small text editor that would allow the code collapsing like when def a Function, how you can collapse that to a single line.\nI'm thinking of using Tkinter but would be open to other environments.\nI mainly want to know what widget I should use, I'd like to think that I'd be able to figure out how to do it. (Although an example is always welcome.)\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":200,"Q_Id":10045312,"Users Score":1,"Answer":"You could consider the Scintilla text editing component, with bindings for Python (and other languages.) The Scintilla text editing widget is the basis for the SciTE text editor.\nSciTE supports code folding, so it is certainly doable - it may even be a built in part of Scintilla.\nFrom the SciTE website:\n\nScintilla is a free source code editing component. It comes with\n  complete source code and a license that permits use in any free\n  project or commercial product.\nAs well as features found in standard text editing components,\n  Scintilla includes features especially useful when editing and\n  debugging source code. These include support for syntax styling, error\n  indicators, code completion and call tips. The selection margin can\n  contain markers like those used in debuggers to indicate breakpoints\n  and the current line. Styling choices are more open than with many\n  editors, allowing the use of proportional fonts, bold and italics,\n  multiple foreground and background colours and multiple fonts.\nSciTE is a SCIntilla based Text Editor. Originally built to\n  demonstrate Scintilla, it has grown to be a generally useful editor\n  with facilities for building and running programs. It is best used for\n  jobs with simple configurations - I use it for building test and\n  demonstration programs as well as SciTE and Scintilla, themselves.","Q_Score":0,"Tags":"python","A_Id":10045462,"CreationDate":"2012-04-06T15:03:00.000","Title":"Python: How to program an IDE Code collapsing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In an IPython notebook, when you look at some docs with ? or help(), a split frame is opened at the bottom of the screen where the documentation shows up.\nWhile I find this useful as a guide for continuing to play with some Python code, I would like to close this spit frame when I'm done reading the docs, so to get back the screen space.\nBut I can't find instructions anywhere, not with Google and not in the IPython notebook docs how to do this?\nAnybody knows?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":613,"Q_Id":10047020,"Users Score":8,"Answer":"Doh, one has to click on the very slim divider line. The subframe then closes...","Q_Score":5,"Tags":"ipython","A_Id":10047045,"CreationDate":"2012-04-06T17:36:00.000","Title":"How to close the doc reading part of the IPython notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In an IPython notebook, when you look at some docs with ? or help(), a split frame is opened at the bottom of the screen where the documentation shows up.\nWhile I find this useful as a guide for continuing to play with some Python code, I would like to close this spit frame when I'm done reading the docs, so to get back the screen space.\nBut I can't find instructions anywhere, not with Google and not in the IPython notebook docs how to do this?\nAnybody knows?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":613,"Q_Id":10047020,"Users Score":5,"Answer":"You have to press the q key.\nThat works for me.","Q_Score":5,"Tags":"ipython","A_Id":21760178,"CreationDate":"2012-04-06T17:36:00.000","Title":"How to close the doc reading part of the IPython notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to learn OpenGL, and I'm using PyOpenGL and GLUT.\nWhat really bugs me, is that I can't figure out how to change the\ntitle bar icon. Has anyone had any success in changing this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":248,"Q_Id":10054167,"Users Score":2,"Answer":"You don't.\nRemember: GLUT is primarily for test applications and demos. If your application is complex and platform-specific enough to need to change its icon, then you probably need to move beyond GLUT.","Q_Score":1,"Tags":"python,opengl,freeglut","A_Id":10055756,"CreationDate":"2012-04-07T11:45:00.000","Title":"How do I replace the GLUT title bar icon when using pyopengl?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was able to get attributes about an user by doing queries on LDAP using Python ldap but I don't know how to obtain his DN.\nRemark: Doing CN=sAMAccount,base_dn) is not valid because the user can be somewhere in another sub-tree.\nWhich is the proper way of getting the DN for an user for which I do have the sAMAccount?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1443,"Q_Id":10054878,"Users Score":1,"Answer":"The search result contains:\n\nA list of search result entries. Each search result entry in the list contains the distinguished name of the entry and a (partial) attribute list\n\nor\n\nA list of search result references. Each search result reference contains a sequence of URIs\n\nAfter the entries or references comes a single search result done message.\nTherefore, if any entries matched, they are returned in the list of search result entries, each of which contains the distinguished name of the entry that was matched. Your python API documentation should contain information as to how to extract the distinguished name of the entry that matched.","Q_Score":0,"Tags":"python,active-directory,ldap","A_Id":10056144,"CreationDate":"2012-04-07T13:24:00.000","Title":"How do I get the full DN, distinguishedName of an user with python ldap?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"another question for all of you-\nSo i am trying to get a program called Pysomap to work (its basically ISOMAP but for python[http:\/\/web.vscht.cz\/spiwokv\/pysomap\/]), i follow the directions best as i can, building it on Ubuntu, Windows, and Fedora (prebuilt libraries), but cant seem to get it to work. On windows (which is the preferred implementation platform), every time i go to python and import pysomap, it gives me the above error. Anybody know how to solve this?\nThanks\n-J","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":10066554,"Users Score":0,"Answer":"This source code is over 5 years old and the build script for floyd looks to assume hard-coded python2.4. \nIt seems pretty clear that your floyd module did not build. You will most likely have to go back to the build step and ensure that you are properly generating a _floyd.so. \nIf you built it correctly, then this should not fail for you:\npython -c \"import _floyd\"","Q_Score":0,"Tags":"python,windows,linux,isometric","A_Id":10067738,"CreationDate":"2012-04-08T21:11:00.000","Title":"How to get program to not throw \"Error: Can't load Floyd's algorithm library\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am developing an application designed for a secretary to use. She has a stack of hundreds of ballot forms which have a number of questions on them, and wishes to input this data into a program to show the total votes for each answer. Each question has a number of answers.\nFor example:\nQ: \"Re-elect current president of the board\"\nA: Choice between \"Yes\" or \"No\" or \"Neutral\"\nYear on year the questions can change, as well as the answers, but the current application used in the company is hard coded with the questions and answers of last year.\nMy aim is to create an app (in Django\/Python) which allows the secretary to add\/delete questions and answers as she wishes. I am relatively new to Django... I have created an app in University and know how to create basic models and implement the Twitter bootstrap for the GUI.\nBut I'm a little confused about how to enable the secretary to add custom fields in (which are obviously defined in SQL). Does anyone have any small tips on how to get started? By the way, I recognize that this could be achievable using the admin part of website and would welcome any suggestions about that.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72,"Q_Id":10066573,"Users Score":5,"Answer":"You really don't want to implement each question\/answer as a separate DB field.\nInstead, make a table of questions and a table of answers, and have a field in the answers table (in general, a ForeignKey) to indicate which question a given answer is associated with.","Q_Score":0,"Tags":"python,sql,django","A_Id":10066588,"CreationDate":"2012-04-08T21:14:00.000","Title":"Adding field to SQL table from Django Application","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to implement one web2py application which has to access java code (which has code to connect to the remote machine) but not sure whether we can do it in web2py or not.My PC has Java 1.6, Python2.7 ,web2py ,eclipse installed.\nUse case is :\nI have created one button in web2py application and upon clicking the button, it should instantiate the java object and invoke particular method of that java object which will further connect to the remote machine.\nDoubts are:\n\nCan we deploy that particular java class to web2py server so web2py application can easily access it?\nIs it possible to import that class from python code?\nHow to instantiate java object from python code?\nAnd how to invoke java method from python code?\n\nRegards,\nPiks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":632,"Q_Id":10070703,"Users Score":2,"Answer":"I would consider looking into webservices.\nIf you could expose url from java, that will route to a method\/function of java where logic is performed and it returns json object.\nWhile in web2py urllib2 you can make a request and decode that json into native python dictionary.\nThe clue is that you would have to expose all the methods of objects and pass the object back and forth as json. Do not be scared in most programming lanugages objects are just hash_arrays\/dictionaries with some special qualities. So if you can serialize and deserialize the object and expose apriopriate urls you will be fine.\nAlso there is implementation of web2py in jython. But then the entire stack will be in JVM and i may be more complex to work with.","Q_Score":1,"Tags":"python,python-2.7,web2py,web2py-modules","A_Id":10090081,"CreationDate":"2012-04-09T08:26:00.000","Title":"can we use java code in web2py application code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here is what I would like to do.\nUse web2py with MySQL.\nTo do that, I need to use source web2py rather than web2py.app\nTo use web2py, I need Python 2.5\nI am having trouble building and installing Python 2.5\nI downloaded Python-2.5.6.tgz from Python release page.\nNow, I did \n\n.\/configure\n\nand then \n\nmake\n\nThen, I get the following error.\n\ngcc -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp\n  -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I.\/Include   -DPy_BUILD_CORE -o Modules\/python.o .\/Modules\/python.c \n  cc1: error: unrecognized command line option\n  \"-Wno-long-double\" make: * [Modules\/python.o] Error 1\n\nCan anybody help me how to get rid of this error and install Python 2.5?\nHere is gcc I am using\n\ngcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build\n  2336.9.00)\n\nYour help would be greatly appreciated.\nThanks.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":483,"Q_Id":10084379,"Users Score":2,"Answer":"web2py works fine with Lion's stock Python 2.7. Unless you have a compelling reason to use 2.5, stick with 2.7.","Q_Score":1,"Tags":"python,build,osx-lion,web2py","A_Id":10090778,"CreationDate":"2012-04-10T06:56:00.000","Title":"Python 2.5.6 build error on Mac Lion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Here is what I would like to do.\nUse web2py with MySQL.\nTo do that, I need to use source web2py rather than web2py.app\nTo use web2py, I need Python 2.5\nI am having trouble building and installing Python 2.5\nI downloaded Python-2.5.6.tgz from Python release page.\nNow, I did \n\n.\/configure\n\nand then \n\nmake\n\nThen, I get the following error.\n\ngcc -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp\n  -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I.\/Include   -DPy_BUILD_CORE -o Modules\/python.o .\/Modules\/python.c \n  cc1: error: unrecognized command line option\n  \"-Wno-long-double\" make: * [Modules\/python.o] Error 1\n\nCan anybody help me how to get rid of this error and install Python 2.5?\nHere is gcc I am using\n\ngcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build\n  2336.9.00)\n\nYour help would be greatly appreciated.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":483,"Q_Id":10084379,"Users Score":0,"Answer":"I have web2py on my iMac OSX Lion using the web2py app and MySQL. I haven't run into any reason why you can't use the app with MySQL.","Q_Score":1,"Tags":"python,build,osx-lion,web2py","A_Id":10114744,"CreationDate":"2012-04-10T06:56:00.000","Title":"Python 2.5.6 build error on Mac Lion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have to write a script that does this:\nInputfile:\nName\n10\n-43\n54\nName2\n654\n43\n2\n-5467\nName3\n65\n65\nOutputfile:\nName 21\nName2 -4768\nName3 130\nI came to the conclusion that I am supposed to split the input into arrays at the names and then print the first element and the sum of the rest, but I do not know how to do it and I haven't really found anything about this on the web.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":193,"Q_Id":10090645,"Users Score":1,"Answer":"Open the files and use readline to open the files line by line. Check whether it is string or not. By looking at your file format, I assume everything in between two strings (Name1 and Name2 or else) are numbers so store those on list. Finally use sum(list) to get the output. I am not writing the code since this is \"HOMEWORK\".","Q_Score":0,"Tags":"python,sum","A_Id":10090752,"CreationDate":"2012-04-10T14:27:00.000","Title":"Summing numbers with header in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a desktop python application whose data backend is a MySQL database, but whose previous database was a network-accessed xml file(s). When it was xml-powered, I had a thread spawned at the launch of the application that would simply check the xml file for changes and whenever the date modified changed (due to any user updating it), the app would refresh itself so multiple users could use and see the changes of the app as they went about their business.\nNow that the program has matured and is venturing toward an online presence so it can be used anywhere. Xml is out the window and I'm using MySQL with SQLAlchemy as the database access method. The plot thickens, however, because the information is no longer stored in one xml file but rather it is split into multiple tables in the SQL database. This complicates the idea of some sort of 'last modified' table value or structure. Thus the question, how do you inform the users that the data has changed and the app needs to refresh? Here are some of my thoughts:\n\nEach table needs a last-modified column (this seems like the worst option ever)\nA separate table that holds some last modified column?\nSome sort of push notification through a server?\nIt should be mentioned that I have the capability of running perhaps a very small python script on the same server hosting the SQL db that perhaps the app could connect to and (through sockets?) it could pass information to and from all connected clients?\n\nSome extra information:\n\nThe information passed back and forth would be pretty low-bandwidth. Mostly text with the potential of some images (rarely over 50k).\nNumber of clients at present is very small, in the tens. But the project could be picked up by some bigger companies with client numbers possibly getting into the hundreds. Even still the bandwidth shouldn't be a problem for the foreseeable future.\n\nAnyway, somewhat new territory for me, so what would you do? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":450,"Q_Id":10091108,"Users Score":0,"Answer":"As I understand this is not a client-server application, but rather an application that has a common remote storage.\nOne idea would be to change to web services (this would solve most of your problems on the long run).\nAnother idea (if you don't want to switch to web) is to refresh periodically the data in your interface by using a timer.\nAnother way (and more complicated) would be to have a server that receives all the updates, stores them in the database and then pushes the changes to the other connected clients.\nThe first 2 ideas you mentioned will have maintenance, scalability and design uglyness issues.\nThe last 2 are a lot better in my opinion, but I still stick to web services as being the best.","Q_Score":0,"Tags":"python,mysql,notifications","A_Id":10091535,"CreationDate":"2012-04-10T14:55:00.000","Title":"Best way to inform user of an SQL Table Update?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to navigate though a website that is written mostly in Javascript. There are no hard links at all, as the page is simply modified through the script. I can do what I need to using Javascript injections one after another, but chrome starts searching for my input instead of injecting it after a certain string length. I've tried to use frames to do this in HTML, but chrome won't let me use Javascript inside the frame since the source is from a different domain. Is there a good way that I can do this? I've looked into using Java or Python, but I don't see anything that lets you work with Javascript.\nEDIT: Thanks for telling me about different software, but I don't want to use other third-party software. I would really like to know how to execute Javascript injections in a systematic manner from a HTML page. I can do it from the browser, so why can't I do it from an HTML document?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":343,"Q_Id":10098963,"Users Score":2,"Answer":"You can use a tool like Selenium to emulate a user clicking things in a web browser (I believe it actually \"drives\" a real instance of whatever browser you choose.)\nSelenium has a domain-specific language for specifying what actions you want to perform, and Python bindings for controlling it programmatically. I haven't actually used it, so I can't say much more about it, but you should go check it out.","Q_Score":2,"Tags":"java,javascript,python,html,navigation","A_Id":10099151,"CreationDate":"2012-04-11T02:09:00.000","Title":"How do I navigate a website through software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to initialize an array that has X two-dimensional elements. For example, if X = 3, I want it to be [[0,0], [0,0], [0,0]]. I know that [0]*3 gives [0, 0, 0], but how do I do this for two-dimensional elements?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1407,"Q_Id":10099619,"Users Score":0,"Answer":"Using the construct \n[[0,0]]*3 \nworks just fine and returns the following:\n[[0, 0], [0, 0], [0, 0]]","Q_Score":2,"Tags":"python,arrays","A_Id":10101163,"CreationDate":"2012-04-11T04:01:00.000","Title":"How do I initialize a one-dimensional array of two-dimensional elements in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to initialize an array that has X two-dimensional elements. For example, if X = 3, I want it to be [[0,0], [0,0], [0,0]]. I know that [0]*3 gives [0, 0, 0], but how do I do this for two-dimensional elements?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1407,"Q_Id":10099619,"Users Score":0,"Answer":"I believe that it's [[0,0],]*3","Q_Score":2,"Tags":"python,arrays","A_Id":10099628,"CreationDate":"2012-04-11T04:01:00.000","Title":"How do I initialize a one-dimensional array of two-dimensional elements in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Fandjango for a Django Facebook Canvas app.\nTo use fandjango, you need to wrap all view functions with @facebook_authorization_required, which makes sure you're authorized, then gives you the variable request.facebook.user.\nWhat I want is to make a context processor which defines a few more variables based on this, i.e., I want all my templates to be able to use fb_user as a shortcut for request.facebook.user.\nThe problem is, I don't know how to use the decorator on the context processor.\nAny ideas how I can do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":280,"Q_Id":10105610,"Users Score":3,"Answer":"There's no need to wrap the context processor. If you've wrapped the view in the first place, then the request will already be annotated with the facebook.user attribute. Since the request is passed to the context processor anyway, you have access to that attribute.\nYou should probably do a quick check - if hasattr(request, 'facebook') - within the context processor, just to make sure it's being called from a wrapped view.","Q_Score":0,"Tags":"python,django,facebook,fandjango","A_Id":10105994,"CreationDate":"2012-04-11T12:09:00.000","Title":"Apply decorator to context processor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am facing a problem with crawler processes dying unexpectedly. \nI am using scrapy 0.14, the problem existed in 0.12 as well .\nThe scrapyd log shows entries like: Process died: exitstatus=None \nThe spider logs dont show spider closed information as depicted by my database status also. \nHas anybody else faced similar situation?  How can i trace the reason for these processes vanishing,  any ideas, \nsuggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":493,"Q_Id":10130367,"Users Score":0,"Answer":"I think i had a similar situation.\nThe reason that processes were dying was that spiders were generating an exception making the process to stop.\nTo find out the exception look at the log files somewhere in .scrapy folder. For each started crawler process scrapy creates a log file with job id in its name.","Q_Score":2,"Tags":"python,scrapy,scrapyd","A_Id":10136943,"CreationDate":"2012-04-12T19:25:00.000","Title":"Crawler processes dying unexpectedly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The goal is to collect the MAC address of the connected local NIC,\nnot a list of all local NICs :) \nBy using socket and connect (to_a_website),\nI can just use getsockname() to get the IP,\nthat is being used to connect to the Internet. \nBut from the IP how can I then get the MAC address of the local NIC ? \nMain reason for the question is if there are multiple NICs.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8993,"Q_Id":10137594,"Users Score":0,"Answer":"Another roundabout way to get a systems mac id is to use the ping command to ping the system's name then performing an arp -a request against the ip address that was pinged. the downfall to doing it that way thou is you need to write the ping response into the memory of python and performing a readline operation to retrieve the ip address and then writing the corresponding arp data into memory while writing the system name, ip address, and mac id to the machine in question to either the display or to a test file.\nIm trying to do something similar as a system verification check to improve the automation of a test procedure and the script is in python for the time being.","Q_Score":1,"Tags":"python,networking,ethernet","A_Id":16929947,"CreationDate":"2012-04-13T08:30:00.000","Title":"Python - Get MAC address of only the connected local NIC","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to define a class with  a __getitem__ that takes a tuple argument using the Python C-API?\nThe sq_item member of the tp_as_sequence member of a PyTypeObject\nmust be a ssizeargfunc, so I don't see how to do it.\n(But I assume that the NumPy ndarray does it.)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":853,"Q_Id":10151806,"Users Score":5,"Answer":"Yes, use tp_as_mapping instead.\nIts mp_subscript takes a PyObject * so you can use anything as index\/key.\nTo understand how they relate, you could have a look at the source of PyObject_GetItem() which (as the doc says) is the equivalent of Python o[key] expression. You will see that it first tries tp_as_mapping and if that's not there and key is int, it tries tp_as_sequence.","Q_Score":3,"Tags":"python,python-c-api","A_Id":10152614,"CreationDate":"2012-04-14T07:16:00.000","Title":"__getitem__ method with tuple argument using Python C-API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an application I am developing on top of GAE, using Python APIs. I am using the local development server right now. The application involves parsing large block of XML data received from outside service. \nSo the question is - is there an easy way to get this XML data exported out of the GAE application - e.g., in regular app I would just write it to a temp file, but in GAE app I can not do that. So what could I do instead? I can not easily run all the code that produces the service call outside of GAE since it uses some GAE functions to create the call, but it would be much easier if I could take the XML result out and develop\/test the parser part outside and then put it back to GAE app. \nI tried to log it using logging and then extract it from the console, but when XML is getting big it doesn't work well. I know there's bulk data import\/export APIs but seems to be an overkill for extracting just this one piece of information to write it to data store and then export the whole store. So how to do it in the best way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":10152055,"Users Score":3,"Answer":"How about writing the XML data to the blobstore and then write a handler that uses send_blob to download to your local file system? \nYou can use the files API to write to the blobstore from you application.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":10152181,"CreationDate":"2012-04-14T08:01:00.000","Title":"Getting a piece of information from development GAE server to local filesystem","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a video encoding script that I would like to run as soon as a file is moved into a specific directory.\nIf I use something like inotify, how do I ensure that the file isn't encoded until it is done moving?\nI've considered doing something like:\n\nCopy (rsync) file into a temporary directory.\nOnce finished, move (simple 'mv') into the encode directory.\nHave my script monitor the encode directory.\n\nHowever, how do I get step #2 to work properly and only run once #1 is complete?\nI am using Ubuntu Server 11.10 and I'd like to use bash, but I could be persuaded to use Python if that'd simplify issues.\nI am not \"downloading\" files into this directory, per se; rather I will be using rsync the vast majority of the time.\nAdditionally, this Ubuntu Server is running on a VM.\nI have my main file storage mounted via NFS from a FreeBSD server.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1292,"Q_Id":10163877,"Users Score":1,"Answer":"One technique I use works with FTP. You issue a command to the FTP server to transfer the file to an auxiliary directory. Once the command completes, you send a second command to the server, this time telling it to rename the file from from the aux directory to the final destination directory.If you're using inotify or polling the directory, the filename won't appear until the rename has completed, thus, you're guaranteed that the file is complete.\nI'm not familar with rsync so I don't know if it has a similar rename capability.","Q_Score":6,"Tags":"python,bash,ubuntu,file-monitoring","A_Id":10176476,"CreationDate":"2012-04-15T16:35:00.000","Title":"Move file to another directory once it is done transferring","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"zc.recipe.egg allows you to install any egg and its script with buildout.\nHowever, zc.recipe.egg relies on find-links and index behavior, inherit from setuptools I guess. It would like to take an egg server \/ HTML for scanning.\nWhat if I just want to point zc.recipe.egg to a egg direct download URL how would I do that? Looks like putting it to find-links is no go.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":748,"Q_Id":10165342,"Users Score":0,"Answer":"Putting it in find-links should work. I've done that in the past. You have to make sure the link is of the correct format as any python egg.","Q_Score":0,"Tags":"python,buildout","A_Id":10168036,"CreationDate":"2012-04-15T19:34:00.000","Title":"Buildout and zc.recipe.egg - specifying egg download URL directly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to access and parse  a website at work using Python. The sites authorization is done via siteminder, so the usual urllib\/urllib2 user password does not work.\nDoes anyone have an idea how to do that?\nThanks\nNoamM","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2741,"Q_Id":10169500,"Users Score":1,"Answer":"Agree with Martin - you need to just replicate what the browser does. Siteminder will pass you a token once successfully authenticated. I have to do this as well, will post once I find a good way.","Q_Score":3,"Tags":"python,url,web,siteminder","A_Id":19700519,"CreationDate":"2012-04-16T06:19:00.000","Title":"Use Python\/urllib to access web sites with \"siteminder\" authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am inserting some data in qtablewidget after some time interval. For this i am clearing all content of qtable and then inserting data. But the table showing data from first row, I want that the table always show last row. This will feel like real updation of table. how to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":303,"Q_Id":10196716,"Users Score":0,"Answer":"After inserting the row, call QTableWidget.scrollToBottom() to show that last row.","Q_Score":0,"Tags":"python,pyqt4","A_Id":10201627,"CreationDate":"2012-04-17T18:16:00.000","Title":"Pyqt table widget updation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed a few python programs that I want to make available online. \nI am new to web services, and I am not sure what I need to do in order to create a service where somebody makes a request to an URL (for example), and the URL triggers a Python program that displays something in the user's browser, or a set of inputs are given to the program via browser, and then python does whatver it is supposed to do.\nI was playing with the google app engine, which runs fine with the tutorial, and was planning to use it becuase it looks easy, but the problem with GAE is that it does not work well (or does not work at all) with some libraries that I plan to use.\nI guess what I am trying to do is some sort of API using my WebFaction account.\nCan anybody point me in the right directions? What choices do I have in WebFaction? What are the easiest tools available?\nThank you very much for your help in advance.\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":597,"Q_Id":10199697,"Users Score":1,"Answer":"Well, your question is a little bit generic, but here are a few pointers\/tips:\n\nWebfaction allows you to install pretty much anything you want (you need to compile it \/ or ask the admins to install some CentOS package for you).\nThey provide some default Apache server with mod_wsgi, so you can run web2py, Django or any other wsgi frameworks.\nMost popular Python web frameworks have available installers in Webfaction (web2py, django...), so I would recommend you to go with one of them.\nI would also install supervisord to keep your service running after some reboot\/crash\/problem.\n\nI would be glad to help you if you have any specific question...","Q_Score":1,"Tags":"python,web-services,api","A_Id":10332534,"CreationDate":"2012-04-17T21:49:00.000","Title":"RESTful Web service or API for a Python program in WebFaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Google App Engine app that periodically processes bursts of memory-intensive long-running tasks. I'm using the taskqueue API on the Python2.7 run-time in thread-safe mode, so each of my instances is handling multiple tasks concurrently. As a result, I frequently get these errors:\n\nExceeded soft private memory limit with 137.496 MB after servicing 8 requests total\nAfter handling this request, the process that handled this request was found to be using too much memory and was terminated. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may have a memory leak in your application.\n\nAs far as I can tell, each instance is taking on 8 tasks each and eventually hitting the soft memory limit. The tasks start off using very low amounts of memory but eventually grow to about 15-20MB.\nIs there any way to restrict tell App Engine to assign no more than 5 requests to an instance? Or tell App Engine that the task is expected to use 20MB of memory over 10 minutes and to adjust accordingly?\nI'd prefer not to use the backend APIs since I want the number of instances handling tasks to automatically scale, but if that's the only way, I'd like to know how to structure that.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":228,"Q_Id":10199963,"Users Score":7,"Answer":"There's not currently any way to advise the App Engine infrastructure about this. You could have your tasks return a non-200 status code if they shouldn't run now, in which case they'll be automatically retried (possibly on another instance), but that could lead to a lot of churn. Backends are probably your best option.\nIf you set up dynamic backends, they'll only be spun up as required for task queue traffic. You can send tasks to a backend by specifying the URL of the backend as the 'target' argument.\nYou can gain even more control over task execution by using pull queues. Then, you can spin up backends as you choose (or use push queue tasks, for that matter), and have the instances pull tasks off the pull queue in whatever manner suits.","Q_Score":1,"Tags":"python,google-app-engine,memory-management,python-2.7,task-queue","A_Id":10200635,"CreationDate":"2012-04-17T22:12:00.000","Title":"Restricting the number of task requests per App Engine instance","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Note: I have very little python and PyQt experience...\nGiven a context menu already created, I'm looking for a functional example of how I would gain access to that context menu, so it can be extended for a plugin which is doing the python equivalent of a javascript greasemonkey script.  Then I'm also looking for a functional example of how I could add a submenu to that context menu.  Thanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3646,"Q_Id":10200594,"Users Score":1,"Answer":"Avaris' comments basically answered this question the best.  I can't select it, though, because it's comments, rather than an answer.  So I'm summarizing that answer here, so this Q can be answered:\n\"If you are given a context menu (QMenu to be specific) you can access it.\" - Avaris\n\"You can't do this without modifying that file [the one containing the context menu creation code]. It assumes it has given a list of QActions (see line 301) and it wouldn't be expecting QMenu. Though, if you can get to the plugin_menu reference in your plugin, that's a different story.\" - Avaris\nSo either you can access to manipulate the menu in the same file (and same place in that file) where the menu creation\/definition code is, or you can gain access to do so via that file (in the same place) exposing the menu via an API.  On the flip side, if you don't have such API access, and\/or modify that file\/function, then there's no way to do this.","Q_Score":3,"Tags":"python,plugins,pyqt,contextmenu,pyqt4","A_Id":10543269,"CreationDate":"2012-04-17T23:19:00.000","Title":"PyQt: Basic example of accessing and adding a submenu to an existing context menu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new in OpenERP, I have installed OpenERP v6. I want to know how can I insert data in database? Which files I have to modify to do the job? (files for the SQL code)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":794,"Q_Id":10208147,"Users Score":0,"Answer":"OpenERP works with PostgreSQl as the Back-end Structure.\nPostgresql is managed by pgadmin3 (Postgres GUI),you can write sql queries there and can add\/delete records from there.\nIt is not advisable to insert\/remove data directly into Database!!!!","Q_Score":2,"Tags":"python,postgresql,openerp","A_Id":10208766,"CreationDate":"2012-04-18T11:10:00.000","Title":"OpenERP: insert Data code","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new in OpenERP, I have installed OpenERP v6. I want to know how can I insert data in database? Which files I have to modify to do the job? (files for the SQL code)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":794,"Q_Id":10208147,"Users Score":0,"Answer":"The addition of columns in the .py files of the corresponding modules you want to chnage will insert coumns to the pgadmin3 also defenition of classes will create tables...when the fields are displayed in xml file and values are entered to the fields through the interface the values get stored to the table values to the database...","Q_Score":2,"Tags":"python,postgresql,openerp","A_Id":10225346,"CreationDate":"2012-04-18T11:10:00.000","Title":"OpenERP: insert Data code","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to get the number of unique visitors(say, for the last 5 minutes) that are currently looking at an article, so I can display that number, and sort the articles by most popular.\nex. Similar to how most forums display 'There are n people viewing this thread'\nHow can I achieve this on Google App Engine? I am using Python 2.7.\nPlease try to explain in a simple way because I recently started learning programming and I am working on my first project. I don't have lots of experience. Thank you!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1919,"Q_Id":10217948,"Users Score":1,"Answer":"There is no way to tell when someone stops viewing a page unless you use Javascript to inform the server when that happens. Forums etc typically assume that someone has stopped viewing a page after n minutes of inactivity, and base their figures on that.\nFor minimal resource use, I would suggest using memcache exclusively here. If the value gets evicted, the count will be incorrect, but the consequences of that are minimal, and other solutions will use a lot more resources.","Q_Score":2,"Tags":"python,google-app-engine,analytics,visitors","A_Id":10221347,"CreationDate":"2012-04-18T21:02:00.000","Title":"How to get number of visitors of a page on GAE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing some R&D on selenium+python. I wrote some test cases in python using selenium webdriver and unittest module. I want to know how can I create report of the test cases. Is there inbuilt solution available in selenium or I need to code to generate file.\nOr is there any other web testing framework with javascript support available in python which have reporting functionality.\nI am basically new to python as well as selenium. Just trying to explore.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":24481,"Q_Id":10218679,"Users Score":1,"Answer":"My experience has been that any sufficiently useful test framework will end up needing a customized logging solution.  You are going to end up wanting domain specific and context relevant information, and the pre-baked solutions never really fit the bill by virtue of being specifically designed to be generic and broadly applicable.  If you are already using Python, I'd suggest looking in to the logging module and learning how to write Handlers and Formatters.  It's actually pretty straight forward, and you will end up getting better results than trying to shoehorn the logging you need in to some selenium-centric module.","Q_Score":7,"Tags":"python,selenium","A_Id":10218792,"CreationDate":"2012-04-18T21:59:00.000","Title":"Selenium+python Reporting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"'lo,\nI am currently trying to code a simple routine for an experiment we are planning to run. The experiment starts by entering a subject number and creating a bunch of files. I got that part working. Next, we want the screen to go blank and display a message. Something like 'Please fill in questionnaire 1 and press [ENTER] when you are done.'\nMy question is, how do you recommend I present a blank screen with a message like that that waits for a certain key to be pressed?\nI have quite some programming experience but haven't worked with Python before so any hints are greatly appreciated. Thanks a lot in advance for your time!\n~~~~~~~~~~~~~~~~~~\nSome extra info that might be relevant: We are running this on Windows XP (Service Pack 2) computers. The whole point of this is that the participant does not have access to the desktop or anything on the computer basically. We want the experiment to start and display a bunch of instructions on the screen that the subject has to follow without them being able to abort etc. Hope this makes sense.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5401,"Q_Id":10220943,"Users Score":0,"Answer":"raw_input('Please fill in questionnaire 1 and press [ENTER] when you are done.') will wait for someone to hit [enter].\nClearing the screen may be OS\/environment dependent, I am not sure.","Q_Score":0,"Tags":"python,windows","A_Id":10220978,"CreationDate":"2012-04-19T02:41:00.000","Title":"Present blank screen, wait for key press -- how?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have used type() function in my program...\nI just want to know how does Python implement this? Or where could I find the source code file that implement this function?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2787,"Q_Id":10221441,"Users Score":2,"Answer":"In general\nimport multiprocessing\n multiprocessing.__path__\n multiprocessing.__file__\n__path__ yields location of the library\n__file__ yields complete path of the file.\nIf above didn't work, you need to look into python development source code.\nRegarding type source code, Raymond Hettinger's answer is correct.","Q_Score":2,"Tags":"python,function","A_Id":10221621,"CreationDate":"2012-04-19T03:55:00.000","Title":"source code of python inbuilt functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7.\nI have been using Python IDLE to edit python files.\nThe problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on \"switch to interpreter\", then it says \"Searching for program: no such file or directory, python\"\nSomeone says i need to make some change on .emacs file, but i do not know where to look for.\nAnd I am very unexperienced and just started to learn programming. I am not familiar with commonly used terminologies. I have been searching for solutions but most of the articles i find on the Internet only confuse me.\nso the questions are:\n\nhow do i run python interpreter in Emacs?\nare there different kind of python interpreter? if so, why do they have different interpreters for one language?","AnswerCount":8,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":37056,"Q_Id":10241279,"Users Score":0,"Answer":"In emacs 24.2 there is python-switch-to-python","Q_Score":32,"Tags":"python,emacs,interpreter","A_Id":15099767,"CreationDate":"2012-04-20T06:27:00.000","Title":"How do I run a python interpreter in Emacs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7.\nI have been using Python IDLE to edit python files.\nThe problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on \"switch to interpreter\", then it says \"Searching for program: no such file or directory, python\"\nSomeone says i need to make some change on .emacs file, but i do not know where to look for.\nAnd I am very unexperienced and just started to learn programming. I am not familiar with commonly used terminologies. I have been searching for solutions but most of the articles i find on the Internet only confuse me.\nso the questions are:\n\nhow do i run python interpreter in Emacs?\nare there different kind of python interpreter? if so, why do they have different interpreters for one language?","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":37056,"Q_Id":10241279,"Users Score":14,"Answer":"C-c C-z can do this. It is the key-binding for the command python-switch-to-python","Q_Score":32,"Tags":"python,emacs,interpreter","A_Id":20375113,"CreationDate":"2012-04-20T06:27:00.000","Title":"How do I run a python interpreter in Emacs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"here is the problem:\n1) suppose that I have some measure data (like 1Msample read from my electronics) and I need to process them by a processing chain.\n2) this processing chain consists of different operations, which can be swapped\/omitted\/have different parameters. A typical example would be to take this data, first pass them via a lookup table, then do exponential fit, then multiply by some calibration factors\n3) now, as I do not know what algorithm the the best, I'd like to evaluate at each stage best possible implementation (as an example, the LUTs can be produced by 5 ways and I want to see which one is the best)\n4) i'd like to daisychain those functions such, that I would construct a 'class' containing top-level algorithm and owning (i.e. pointing) to child class, containing lower-level algorithm.\nI was thinking to use double-linked-list and generate sequence like:\nmyCaptureClass.addDataTreatment(pmCalibrationFactor(opt, pmExponentialFit (opt, pmLUT (opt))))\nwhere myCaptureClass is the class responsible for datataking and it should as well (after the data being taken) trigger the top-level data processing module (pm). This processing would first go deep into the bottom-child (lut), treat data there, then middle (expofit), then top (califactors) and return the data to the capture, which would return the data to the requestor.\nNow this has several issues:\n1) everywhere on the net is said that in python one should not use double-linked-lists\n2) this seems to me highly inefficient because the data vectors are huge, hence i would prefer solution using generator function, but i'm not sure how to provide the 'plugin-like' mechanism.\ncould someone give me a hint how to solve this using 'plugin-style' and generator so I do not need to process vector of X megabytes of data and process them 'on-request' as is correct when using generator function?\nthanks a lot\ndavid\nAn addendum to the problem:\nit seems that I did not express myself exactly. Hence: the data are generated by an external HW card plugged into VME crate. They are 'fetched' in a single block transfer to the python tuple, which is stored in myCaptureClass. \nThe set of operation to be applied is in fact on a stream data, represented by this tuple. Even exponential fit is stream operation (it is a set of variable state filters applied on each sample).\nThe parameter 'opt' i've mistakenly shown was to express, that each of those data processing classes has some configuration data which come with, and modify behaviour of the method used to operate on data.\nThe goal is to introduce into myCaptureClass a daisychained class (rather than function), which - when user asks for data - us used to process 'raw' data into final form.\nIn order to 'save' memory resources i thought it might be a good idea to use generator function to provide the data.\nfrom this perspective it seems that the closest match to what i want to do is shown in code of bukzor. I'd prefer to have a class implementation instead of function, but i guess this is just a cosmetic stuff of implementing call operator in particular class, which realizes the data operation....","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":987,"Q_Id":10249121,"Users Score":0,"Answer":"Get the functional module from pypi. It has a compose function to compose two callables. With that, you can chain functions together.\nBoth that module, and functool provide a partial function, for partial-application.\nYou can use the composed functions in a generator expression just like any other.","Q_Score":3,"Tags":"python","A_Id":10249180,"CreationDate":"2012-04-20T15:31:00.000","Title":"how to implement 'daisychaining' of pluggable function in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to handle the different encodings in a Python script the more user-friendly and auto-magic way possible (there are APIs for utf8). It is a cross-platform console script.\nFor printing to stdout I use sys.stdout.encoding and it seems to do the right thing almost always when printing to the console. However when stdout is piped it becomes None.\nSo in that case I assume I am piping to a file and use locale.getpreferredencoding() but:\n\nI am not sure this is the right encoding for printing to a file, but it works quite cross-platform.\nThat doesn't work when piping to a program |. I don't know how to detect that this is the case neither if there is a standard or an expected behavior for encoding in that case.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":643,"Q_Id":10249240,"Users Score":1,"Answer":"If it is None, simply output your data as utf-8, and document it.  If it happens that there are use cases for other encodings, make that an option through the command line or other means.","Q_Score":2,"Tags":"python,character-encoding","A_Id":10250521,"CreationDate":"2012-04-20T15:38:00.000","Title":"What should I do when sys.stdout.encoding is None?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to compile PyPy on cygwin, and the compilation stops when python tries to open the file \"externmod\", which was just compiled with gcc.  The problem with gcc on cygwin is that it automatically appends a '.exe' to whatever you're compiling, so even though gcc is called as gcc -shared -Wl,--enable-auto-image-base -pthread -o \/tmp\/usession-release-1.8\/shared_cache\/externmod, the output file ends up being externmod.exe regardless.  So python tries to open \/tmp\/usession-release-1.8\/shared_cache\/externmod and can't find it--thus the compilation stops.  Anyone know how to solve this, short of recompiling gcc?  I don't  want to do that.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1101,"Q_Id":10252304,"Users Score":1,"Answer":"Windows needs the \".exe\" extension to know that it's executable. You'll need to modify the build to look for Windows and use the .exe extension.","Q_Score":2,"Tags":"python,gcc,cygwin,pypy","A_Id":10252762,"CreationDate":"2012-04-20T19:22:00.000","Title":"Compiling PyPy on cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how I would have a python web scrape dump all of it's results into excel.\nIt's not that I don't know how to webscrape, it's just I do not know how to scrape into excel.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4830,"Q_Id":10255185,"Users Score":2,"Answer":"if you don't want to introduce a full excel library, you can write an HTML table or CSV and Excel will happily import those. The downside with this is that you're limited to one worksheet and no formulaes.","Q_Score":2,"Tags":"python,excel,web-scraping","A_Id":10255232,"CreationDate":"2012-04-21T00:44:00.000","Title":"How to scrape in python into excel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to celery.I know how to install and run one server but I need to distribute the task to multiple machines.\nMy project uses celery to assign user requests passing to a web framework to different machines and then returns the result.\nI read the documentation but there it doesn't mention how to set up multiple machines.\nWhat am I missing?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":26305,"Q_Id":10260925,"Users Score":2,"Answer":"The way I deployed it is like this:\n\nclone your django project on a heroku instance (this will run the frontend)\nadd RabitMQ as an add on and configure it \nclone your django project into another heroku instance (call it like worker) where you will run the celery tasks","Q_Score":58,"Tags":"python,celery","A_Id":43633216,"CreationDate":"2012-04-21T16:36:00.000","Title":"How to set up celery workers on separate machines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to celery.I know how to install and run one server but I need to distribute the task to multiple machines.\nMy project uses celery to assign user requests passing to a web framework to different machines and then returns the result.\nI read the documentation but there it doesn't mention how to set up multiple machines.\nWhat am I missing?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":26305,"Q_Id":10260925,"Users Score":60,"Answer":"My understanding is that your app will push requests into a queueing system (e.g. rabbitMQ) and then you can start any number of workers on different machines (with access to the same code as the app which submitted the task). They will pick out tasks from the message queue and then get to work on them. Once they're done, they will update the tombstone database. \nThe upshot of this is that you don't have to do anything special to start multiple workers. Just start them on separate identical (same source tree) machines. \nThe server which has the message queue need not be the same as the one with the workers and needn't be the same as the machines which submit jobs. You just need to put the location of the message queue in your celeryconfig.py and all the workers on all the machines can pick up jobs from the queue to perform tasks.","Q_Score":58,"Tags":"python,celery","A_Id":10261277,"CreationDate":"2012-04-21T16:36:00.000","Title":"How to set up celery workers on separate machines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question may have been asked in a different way, if so please point it to me. I just couldn't find it among my search results.\nI would like to parse text for mark-ups, like those here on SO.\n\neg. * some string for bullet list \neg. *some string* for  italic text \neg. &some string& for a URL\neg. &some string&specific url& for URL different from string\n\netc.\nI can think of two ways to go about processing a string to find out special mark-up sequences:\na. I could proceed in a character-centric way, i.e. parsing the string looking for sequences 1, then 2 etc. That however seems to be inefficient as it would have to parse the string multiple times.\nb. It seems better to process the string character by character and keep a memory of special characters and their position. If the memory matches a special sequence as above, then the special characters are replaced by HTML in the string. I'm not really sure whether that's a better idea however, nor am I sure as to how one should implement it.\nWhat is the best way to go about this? How about Regular Expressions? Does it follow pattern a or b? Is there a third option?\nP.S. I am using Python. Python example most appreciated.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":102,"Q_Id":10270331,"Users Score":-1,"Answer":"Regular expressions, of course! If still haven't done so, learn it. After you are done, you will find it hard to imagine how you got along without it. The samples you show are simple with regular expressions. For example, an asterisk, then a space then a word is expressed as:\n\\*\\s\\w+\nNothing else but regular expressions.","Q_Score":1,"Tags":"python,html,regex,markdown,markup","A_Id":10270412,"CreationDate":"2012-04-22T17:35:00.000","Title":"What is the most efficient way to trace markups in a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a very basic question : how to do a line break with matplotlib in python with an \"annotate\" command. I tried \"\\\" and \"\\n\" but it does not work. And how to do this for a \"Latex\" annotation and for a normal text annotation ?\nThank you very much.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":40716,"Q_Id":10284847,"Users Score":6,"Answer":"Quick solutions\nplt.annotate(\"I am \\n\"+r\"$\\frac{1}{2}$\"+\"\\n in latex math environment\", xy=(0.5, 0.5))","Q_Score":24,"Tags":"python,latex,matplotlib","A_Id":44506534,"CreationDate":"2012-04-23T16:55:00.000","Title":"Python : Matplotlib annotate line break (with and without latex)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating message boxes in Tkinter using tkMessageBox.showwarning. \nDoes Tkinter let you insert a sort of checkbox with the message that says, for example, \"do not show again\" so when selected the message won't appear the next time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":410,"Q_Id":10295384,"Users Score":1,"Answer":"No, the standard dialogs don't support that.\nIf you want such a feature you'll have to build your own dialog out of a Toplevel window and other widgets.","Q_Score":2,"Tags":"python,checkbox,tkinter,message","A_Id":10296668,"CreationDate":"2012-04-24T09:41:00.000","Title":"\"do not show message again\" checkbox in Tkinter warning message","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking at using pywinauto in python to automate the installation of a Windows MSI installer for testing purposes.\nWhen I try to launch the MSI through the application.start I get the following error:\n\"Error returned by CreateProcess: [Error 193] \"\nIs it possible to even do this, or do I need to launch the MSI first and then connect to it, and if so, how do I achieve this?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1186,"Q_Id":10298104,"Users Score":4,"Answer":"You need to launch \"msiexec.exe\" and pass the MSI as a command line parameter for it to be installed. You cannot launch directly an MSI as you would launch an EXE file.\nExample: msiexec.exe \/i [MSI_path]","Q_Score":2,"Tags":"python,windows-installer,pywinauto","A_Id":10298383,"CreationDate":"2012-04-24T12:46:00.000","Title":"Using pywinauto to automate an MSI installer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been trying to figure out how to add multiple tuples that contain multiple values to to a single key in a dictionary. But with no success so far. I can add the values to a tuple or list, but I can't figure out how to add a tuple so that the key will now have 2 tuples containing values, as opposed to one tuple with all of them.\nFor instance say the dictionary = {'Key1':(1.000,2.003,3.0029)}\nand I want to add (2.3232,13.5232,1325.123) so that I end up with:\ndictionary = {'Key1':((1.000,2.003,3.0029),(2.3232,13.5232,1325.123))} (forgot a set of brackets!)\nIf someone knows how this can be done I'd appreciate the help as it's really starting to annoy me now.\nThanks!\nEdit: Thanks everyone! Ironic that I tried that except at the time I was trying to make the value multiple lists instead of multiple tuples; when the solution was to just enclose the tuples in a list. Ah the irony.","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":48959,"Q_Id":10301589,"Users Score":4,"Answer":"A dictionary value can't contain two tuples just by themselves. Each dictionary key maps to a single value, so the only way you can have two separate tuples associated with that key is for them to be themselves contained within a tuple or list: {'Key1':[(1.000,2.003,3.0029),(2.3232,13.5232,1325.123)]} - note the extra pair of square brackets.\nOne way of doing this would be to get the current value associated with your key, and append it to a list before setting the new list back to that key. But if there's a possibility you'll need that for any key, you should do it for all keys right at the start, otherwise you'll get into all sorts of difficulties working out what level you're at.","Q_Score":4,"Tags":"python,list,dictionary,tuples","A_Id":10301663,"CreationDate":"2012-04-24T15:58:00.000","Title":"How do you add multiple tuples(lists, whatever) to a single dictionary key without merging them?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working in a multiuser environment with the following setup:\n\nLinux 64bits environment (users can login in to different servers).\nEclipse (IBM Eclipse RSA-RTE) 32bits. So Java VM, Eclipse and PyDev is 32bits.\nPython 3 interpreter is only available for 64bits at this moment.\n\nIn the preferences for PyDev, I want to set the path to the Python interpreter like this:\n\/app\/python\/@sys\/3.2.2\/bin\/python\nIn Eclipse\/PyDev, @sys points to i386_linux26 even if the system actually is amd64_linux26. So if I do not explicitly write amd64_linux26 instead of @sys, PyDev will not be able to find the Python 3 interpreter which is only available for 64bits. The link works as expected outside Eclipse\/PyDev, e.g. in the terminal.\nAny ideas how to force Eclipse\/PyDev to use the real value of @sys?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":10315232,"Users Score":0,"Answer":"I don't really think there's anything that can be done on the PyDev side... it seems @sys is resolved based on the kind of process you're running (not your system), so, if you use a 64 bit vm (I think) it should work...\nOther than that, you may have to provide the actual path instead of using @sys...","Q_Score":2,"Tags":"python,linux,eclipse,pydev","A_Id":10343117,"CreationDate":"2012-04-25T12:05:00.000","Title":"Eclipse \/ PyDev overrides @sys, cannot find Python 64bits interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In openerp, im working on a dummy function that (for example) returns the sum of a certain field on selected records.\nfor instance, u select 3 invoices and it returns the sum of the quantity in the invoice lines. i think the function to perform the sum is correct, and even if it wasnt, i just need help in displaying the result of the function when called in a popup box. for that, i've added an action similar to \"Confirm Invoices\" found in the invoice object.  \nto make myself clearer, when the confirm invoice is pressed, its function is called and the popup previously opened is of course closed because of this line found in the function: return {'type': 'ir.actions.act_window_close'}\nhow can i tell it in my function instead (of closing) to display the result stored after executing the function?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":517,"Q_Id":10315257,"Users Score":0,"Answer":"If your purpose is to debug, the simplest solution is to add print statements in your code and then run the server in a console.","Q_Score":1,"Tags":"python,openerp","A_Id":10324086,"CreationDate":"2012-04-25T12:07:00.000","Title":"openerp echo the return result of a function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have long a text file where each line looks something like \/MM0001 (Table(12,)) or \/MM0015 (Table(11,)). I want to keep only the four-digit number next to \/MM. If it weren't for the \"table(12,)\" part I could just strip all the non-numeric characters, but I don't know how to extract the four-digit numbers only. Any advice on getting started?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":460,"Q_Id":10322938,"Users Score":3,"Answer":"If it's exactly that format, you could just print out line[3:7]","Q_Score":0,"Tags":"python","A_Id":10322992,"CreationDate":"2012-04-25T20:05:00.000","Title":"Removing selected characters from text file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have long a text file where each line looks something like \/MM0001 (Table(12,)) or \/MM0015 (Table(11,)). I want to keep only the four-digit number next to \/MM. If it weren't for the \"table(12,)\" part I could just strip all the non-numeric characters, but I don't know how to extract the four-digit numbers only. Any advice on getting started?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":460,"Q_Id":10322938,"Users Score":2,"Answer":"You could parse text line by line and then use 4th to 7th char of every line. \nln[3:7]","Q_Score":0,"Tags":"python","A_Id":10322983,"CreationDate":"2012-04-25T20:05:00.000","Title":"Removing selected characters from text file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to implement a Mario type plat-former in pyGame.  I have Collision detection working with Polygons no problem.  I am curious how I can get the player to be able to jump through the floor above him, which is a polygon floating in air.  \nWhat is the theory on how to handle that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":228,"Q_Id":10325418,"Users Score":1,"Answer":"you could make it so that when your character hits a block, they move up at the current speed until they are no longer colliding with the polygon. That way, when you hit the ground from above,you don't go downward through it, but when you hit the bottom, you do. I would recommend a while loop set to the collide function.","Q_Score":0,"Tags":"python,collision-detection,pygame","A_Id":11217539,"CreationDate":"2012-04-25T23:52:00.000","Title":"Jump Through Polygon\/Floor Collision Detection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python3 on Windows 7. I want to grab all the attributes like color intensity, color etc. Of all the pixels of the screen area that I select with mouse. The selection can be of any shape but right now rectangular and square will do.\nI want to do it in any area of the screen. \nCan you guys please guide me how to do that in Python?\nPS: If the method can work across all the platforms that would be much more appreciated.\nThanks,\nAashiq","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":10328943,"Users Score":0,"Answer":"You need to use some sort of cross-platform GUI toolkit, such as GTK or KDE, maybe Tk or wx will work as well, I don't know.\nHow you then do it depends on what toolkit you choose.","Q_Score":1,"Tags":"python-3.x,pixels","A_Id":10331335,"CreationDate":"2012-04-26T07:24:00.000","Title":"Grabbing pixel attributes in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is my first time purchasing a hosting and I opted for Webfaction.com to host my Django application. So far, i've been using Eclipse to write all my code and manage my Django application and I'm not ready to use VIM as a text editor yet. Now my question is, how can I use Eclipse to write my code and manage all my files while being connected to my webfaction account?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":10332337,"Users Score":4,"Answer":"Don't do that. Your host is for hosting. Your personal machine is for developing.\nEdit and run your code locally. When it's ready, upload it to Webfaction. Don't edit code on your server.","Q_Score":2,"Tags":"python,eclipse,pydev,webfaction","A_Id":10332409,"CreationDate":"2012-04-26T11:18:00.000","Title":"Eclipse with Webfaction and Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Django framework and kindly consider if my question is novice.\nI have created a polls application using the django framwork. I am unable to figure out how to make my stylesheet dynamic for front end. As i dont want to call it in my base_site.html or index.html files as I am also multiple views render different template files. My only aim is to how i define my app's stylesheet on one place and applicable through out my application.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":10336582,"Users Score":0,"Answer":"If i'm reading your question correctly the first part wants to make a stylesheet that is dynamic???\n\nI am unable to figure out how to make my stylesheet dynamic for front\n  end\n\nFor that you could use something like\nDjango admin follows convention of adding {% block extra_head %} (or something similar, sorry don't remember specifics)\nWhich is exactly what it sounds like a block that is in the <head> tag.  This will let you load a stylesheet from any template.  Just define that block in your base_site.html and implement it when you extend base_site.html\nBut then at the end of your question you it seems you want to define style sheet in one place and include that stylesheet for every request?  \n\nMy only aim is to how i define my app's stylesheet on one place and\n  applicable through out my application.\n\nPerhaps you could set up a directive in your settings.py 'DEFAULT_STYLESHEET and include that in your base_site.html template.  Put the css in the block extra_head.  If you need to override it just implement that block and viola!","Q_Score":0,"Tags":"python,django","A_Id":10336728,"CreationDate":"2012-04-26T15:28:00.000","Title":"Django Application Assign Stylesheet -- don't want to add it to app's index file? Can it be dynamic?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how to setup a complex python website, that is currently running in production environment, into a local machine for development?\nCurrently the site uses python combined with Django apps (registration + cms modules) in a virtual environment.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2657,"Q_Id":10341707,"Users Score":13,"Answer":"In case you are using pip for package management, you can easily recreate the virtualenv on another system:\nOn system1, run pip freeze --local > requirements.txt and copy that file to system2. Over there, create and activate the virtualenv and use pip install -r requirements.txt to install all packages that were installed in the previous virtualenv.\nYour python code can be simply copied to the new system; I'd find -name '*.pyc' -delete though since you usually do not want to move compiled code (even if it's just python bytecode) between machines.","Q_Score":5,"Tags":"python,django,virtualenv","A_Id":10341733,"CreationDate":"2012-04-26T21:30:00.000","Title":"How to migrate a python site to another machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have set up a Ldap Server somewhere. I can bind to it, can add, modify, delete entry in the database. Now when it come to authentication isnt it as simple as giving the username and password to the server, asking it to search for an entry matching the two? And furthermore, isnt it the 'userPassword' field that contains the password for a user in there?\nNow,\nI tried to set up splunk to authenticate from my Ldap server, i provided the username and password, but it failed authentication. Isnt it that 'userPassword' field that splunk checks? What should be the possible reason?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1711,"Q_Id":10349093,"Users Score":1,"Answer":"Typically you would search using the username value provided on uid or cn values within the LDAP Tree.\n-jim","Q_Score":1,"Tags":"authentication,ldap,splunk,python-ldap","A_Id":10397477,"CreationDate":"2012-04-27T10:35:00.000","Title":"how to do Ldap Server Authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have set up a Ldap Server somewhere. I can bind to it, can add, modify, delete entry in the database. Now when it come to authentication isnt it as simple as giving the username and password to the server, asking it to search for an entry matching the two? And furthermore, isnt it the 'userPassword' field that contains the password for a user in there?\nNow,\nI tried to set up splunk to authenticate from my Ldap server, i provided the username and password, but it failed authentication. Isnt it that 'userPassword' field that splunk checks? What should be the possible reason?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1711,"Q_Id":10349093,"Users Score":2,"Answer":"LDAP servers are generally not going to allow you to search on the userPassword attribute, for  obvious security reasons. (and the password attribute is likely stored in hashed form anyway, so a straight search would not work.)\nInstead, the usual way to do LDAP authentication is:\n\nprompt for username & password\nBind to LDAP with your application's account, search for username to get the full distinguished name (dn) of the user's LDAP entry\nMake a new LDAP connection, and attempt to bind using the user's dn & password\n\n(If you know how to construct the dn from the username, you can skip step 2, but it's generally a good idea to search first - that way you're less sensitive to things like changes in the OU structure of the LDAP directory)","Q_Score":1,"Tags":"authentication,ldap,splunk,python-ldap","A_Id":10349171,"CreationDate":"2012-04-27T10:35:00.000","Title":"how to do Ldap Server Authentication?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using cherrypy in python script.I think I have to register a callback method from the main application so that i can stop cherrypy main process from a worker thread,but how do i kill the main process within the that process.\nSo i want to know how to stop cherrypy from within the main process.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1787,"Q_Id":10363438,"Users Score":0,"Answer":"If your process is using CherryPy to block (via quickstart or engine.block), then you could simply call: cherrypy.engine.exit() from your page handler. That would be the cleanest option since it would properly terminate CherryPy and plugins you may have subscribed to.","Q_Score":0,"Tags":"python,cherrypy,kill-process","A_Id":10370708,"CreationDate":"2012-04-28T12:20:00.000","Title":"How to kill the cherrypy process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have started playing with Sage recently, and I've come to suspect that the standard Python int is wrapped in a customized class called Integer in Sage. If I type in type(1) in Python, I get <type 'int'>, however, if I type in the same thing in the sage prompt I get <type 'sage.rings.integer.Integer'>.\nIf I wanted to replace Python int (or list or dict) with my own custom class, how might it be done? How difficult would it be (e.g. could I do it entirely in Python)?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":123,"Q_Id":10376129,"Users Score":1,"Answer":"In the case of Sage, it's easy. Sage has complete control of its own REPL (read-evaluate-print loop), so it can parse the commands you give it and make the parts of your expression into whatever classes it wants. It is not so easy to have standard Python automatically use your integer type for integer literals, however.  Simply reassigning the built-in int() to some other type won't do it. You could probably do it with an import filter, that scans each file imported for (say) integer literals and replaces them with MyInt(42) or whatever.","Q_Score":1,"Tags":"python,sage","A_Id":10376372,"CreationDate":"2012-04-29T21:27:00.000","Title":"Creating a customized language using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using openerp 5.16 web. \nIs there any way we can hide button depending upon the logged in user. \nor how can i control the group visibility depending upon the user group.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2413,"Q_Id":10377131,"Users Score":1,"Answer":"Depending the logged in user : \nYou can use the variable 'uid' but I don't think you can do 'uid.name' or 'uid.groups_id'. So the easier method will be the second.\nDepending on the groups\nExample : We have some users who are managers and others not, create a group 'Manager' (in a xml file !!!) and add this group to managers. Now change the field in the xml like this :\n<field name=\"name\" string=\"this is the string\" groups=\"my_module.my_reference_to_the_group\"\/>\n\nThe field will only be visible for managers","Q_Score":1,"Tags":"python,openerp","A_Id":10379449,"CreationDate":"2012-04-30T00:07:00.000","Title":"button visibility in openerp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to learn threading and multiprocessing in Python. I don't know what kind of project to take up for this.\nI want to be able to deal with all the related objects like Locks, Mutexes, Conditions, Semaphores, etc.\nPlease suggest a project type that's best for me.\nP.S. Along with the project, please suggest any tools to debug \/ profile \/ load-test my app so that I can gauge how good my threaded implementations are.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1969,"Q_Id":10397695,"Users Score":6,"Answer":"a few ideas:\n\nweb crawler - have a pool of threads getting work from a dispatcher via a queue, download web pages and return the results somewhere.\nchat server -  accepting permanent connections from users and dispatching messages from one to another.\nmp3 file organizer - rebuild a music library's structure from mp3 tag data, and reorganize them in folders. you can have multiple threads working at once.\n\nI'll edit with some more ideas if I think of any.\nEDIT: Since python is limited to one CPU per process, no matter how many threads, if you want to parallelize CPU consuming stuff, threading will get you nowhere, use the multiprocessing interface instead, it's almost identical to the threading API, but dispatches stuff to sub processes that can use more CPU cores.","Q_Score":2,"Tags":"python,multithreading","A_Id":10397794,"CreationDate":"2012-05-01T12:34:00.000","Title":"What type of project will help me learn thread programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to learn threading and multiprocessing in Python. I don't know what kind of project to take up for this.\nI want to be able to deal with all the related objects like Locks, Mutexes, Conditions, Semaphores, etc.\nPlease suggest a project type that's best for me.\nP.S. Along with the project, please suggest any tools to debug \/ profile \/ load-test my app so that I can gauge how good my threaded implementations are.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1969,"Q_Id":10397695,"Users Score":0,"Answer":"I propose you attempt to program a very simple database server. Each client can connect to the server and do create, read, update, delete on a set of entities. Implementation-wise, the server should have one thread for each client all operating a global set of entities, which are protected using locks.\nFor learning how to use conditional variables, the server should also implement a notify method, which allows a client to be notified when an entity changed.\nGood luck!\nNOTE: Using threads is not the most efficient way to program a simple database server, but I think it is a good project for self-improvement.","Q_Score":2,"Tags":"python,multithreading","A_Id":10397753,"CreationDate":"2012-05-01T12:34:00.000","Title":"What type of project will help me learn thread programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to have simple program in python that can process different requests (POST, GET, MULTIPART-FORMDATA). I don't want to use a complete framework.\nI basically need to be able to get GET and POST params - probably (but not necessarily) in a way similar to PHP. To get some other SERVER variables like REQUEST_URI, QUERY, etc.\nI have installed nginx successfully, but I've failed to find a good example on how to do the rest. So a simple tutorial or any directions and ideas on how to setup nginx to run certain python process for certain virtual host would be most welcome!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7440,"Q_Id":10412063,"Users Score":0,"Answer":"All the same you must use wsgi server, as nginx does not support fully this protocol.","Q_Score":7,"Tags":"python,nginx,web,fastcgi","A_Id":10412251,"CreationDate":"2012-05-02T10:39:00.000","Title":"How to run nginx + python (without django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to have simple program in python that can process different requests (POST, GET, MULTIPART-FORMDATA). I don't want to use a complete framework.\nI basically need to be able to get GET and POST params - probably (but not necessarily) in a way similar to PHP. To get some other SERVER variables like REQUEST_URI, QUERY, etc.\nI have installed nginx successfully, but I've failed to find a good example on how to do the rest. So a simple tutorial or any directions and ideas on how to setup nginx to run certain python process for certain virtual host would be most welcome!","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7440,"Q_Id":10412063,"Users Score":4,"Answer":"You should look into using Flask -- it's an extremely lightweight interface to a WSGI server (werkzeug) which also includes a templating library, should you ever want to use one.  But you can totally ignore it if you'd like.","Q_Score":7,"Tags":"python,nginx,web,fastcgi","A_Id":10417619,"CreationDate":"2012-05-02T10:39:00.000","Title":"How to run nginx + python (without django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am testing kivy and I want to create a BoxLayout so to stack some buttons. My problem is that the children that are added to the layout follow a bottom-top logic while I want the opposite. Do you know how can I reverse the order? Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2021,"Q_Id":10421194,"Users Score":1,"Answer":"There is a tricky way to do that. \nUse a gridlayout and set cols to 1","Q_Score":3,"Tags":"python,layout,python-2.7,boxlayout,kivy","A_Id":22755884,"CreationDate":"2012-05-02T20:29:00.000","Title":"How can I change the order of the BoxLayout in kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm surprised I don't see anything but \"use celery\" when searching for how to use celery tasks with sorl-thumbnails and S3.\nThe problem: using remote storages causes massive delays when generating thumbnails (think 100s+ for a page with many thumbnails) while the thumbnail engine downloads originals from remote storage, crunches them, then uploads back to s3.\nWhere is a good place to set up the celery task within sorl, and what should I call?\nAny of your experiences \/ ideas would be greatly appreciated.\nI will start digging around Sorl internals to find a more useful place to delay this task, but there are a few more things I'm curious about if this has been solved before.\n\nWhat image is returned immediately? Sorl must be told somehow that the image returned is not the real thumbnail. The cache must be invalidated when celery finishes the task.\nHandle multiple thumbnail generation requests cleanly (only need the first one for a given cache key)\n\nFor now, I've temporarily solved this by using an nginx reverse proxy cache that can serve hits while the backend spends time generating expensive pages (resizing huge PNGs on a huge product grid) but it's a very manual process.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1459,"Q_Id":10424456,"Users Score":4,"Answer":"As I understand Sorl works correctly with the S3 storage but it's very slow.\nI believe that you know what image sizes do you need.\nYou should launch the celery task after the image was uploaded. In task you call to \nsorl.thumbnail.default.backend.get_thumbnail(file, geometry_string, **options)\nSorl will generate a thumbnail and upload it to S3. Next time you request an image from template it's already cached and served directly from Amazon's servers\n\na clean way to handle a placeholder thumbnail image while the image is being processed.\n\nFor this you will need to override the Sorl backend. Add new argument to get_thumbnail function, e.g. generate=False. When you will call this function from celery pass generate=True\nAnd in function change it's logic, so if thumb is not present and generate is True you work just like the standard backend, but if generate is false you return your placeholder image with text like \"We process your image now, come back later\" and do not call backend._create_thumbnail. You can launch a task in this case, if you think that thumbnail can be accidentally deleted.\nI hope this helps","Q_Score":11,"Tags":"python,django,amazon-s3,celery,sorl-thumbnail","A_Id":11048085,"CreationDate":"2012-05-03T02:48:00.000","Title":"Pointers on using celery with sorl-thumbnails with remote storages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have got indexes created on tables having data of the form:\nindexname='text'---->Today is a great day for running in the park.\nNow i want to perform a search on the indexes where only 'day' or 'run' is appearing in the text.\nI have implemented query like :\nq = 'text:(day or run*)'\nBut this query is not returning me any results from indexes.Is this correct way?or how can i improve my query by applying regex ?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":624,"Q_Id":10426506,"Users Score":1,"Answer":"Your use case is very basic and doesn't require regex at all with Solr.  It looks like you just may have a syntax issue.  q=text:day OR text:run should do exactly what you're looking for.","Q_Score":0,"Tags":"python,regex,solr","A_Id":10426794,"CreationDate":"2012-05-03T06:52:00.000","Title":"Apply regex on Solr query?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have got indexes created on tables having data of the form:\nindexname='text'---->Today is a great day for running in the park.\nNow i want to perform a search on the indexes where only 'day' or 'run' is appearing in the text.\nI have implemented query like :\nq = 'text:(day or run*)'\nBut this query is not returning me any results from indexes.Is this correct way?or how can i improve my query by applying regex ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":624,"Q_Id":10426506,"Users Score":0,"Answer":"Regex and wildcards are slow in search engines. You'll get better performance by pre-processing the terms in a language-sensitive way.\nYou can match \"run\" to \"running\" with a stemmer, an analysis step that reduces different forms of a word to a common stem. When the query and the index term are both stemmed, then they will match.\nYou should also look into the Extended Dismax (edismax) search handler. That will do some of the work of turning \"day run\" into a search for the individual words and the phrase, something like 'day OR run OR \"day run\"'. Then it can further expand that against multiple fields with different weights, all automatically.","Q_Score":0,"Tags":"python,regex,solr","A_Id":10434663,"CreationDate":"2012-05-03T06:52:00.000","Title":"Apply regex on Solr query?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I stupidly downloaded python 3.2.2 and since then writing 'python' in the terminal yields 'command not found'. Also, when starting the terminal I get this:\nLast login: Wed May 2 23:17:28 on ttys001\n-bash: export: `folder]:\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin:\/opt\/local\/bin:\/opt\/local\/sbin:\/usr\/local\/git\/bin:\/opt\/local\/bin:\/opt\/local\/sbin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin:\/usr\/local\/bin:\/Applications\/android-sdk-mac_86\/tools:\/Applications\/android-sdk-mac_86\/platform-tools:\/usr\/local\/git\/bin:\/usr\/X11\/bin:\/usr\/local\/ant\/bin': not a valid identifier\nWhy the Android SDK folder is there is beyond me. It's all jazzed up. Any ideas how can I remove the offending file, folder or fix his problem? I've checked the System Profiler and python 2.6.1 and 2.7.2.5 shows up.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1985,"Q_Id":10435715,"Users Score":1,"Answer":"Something got messed up in your $PATH.  Have a look in ~\/.profile, ~\/.bashrc, ~\/.bash_profile, etc., and look for a line starting with export that doesn't end cleanly.","Q_Score":4,"Tags":"python,macos,bash,shell,installation","A_Id":10435770,"CreationDate":"2012-05-03T16:40:00.000","Title":"Python installation mess on Mac OS X, cannot run python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on the deployment tool in Django and fabric. The case is putting some parameters (like hostname and username) in the initial form, then let Django app to call fabric methods to do the rest and collect the output in the web browser.\nIF there is a password prompt from OS to fabric (ie. running sudo commands etc.), I would like to popup the one-field form for the password to be put in it (for example using jQuery UI elements). The person will fill the password field for user prompted and fabric will continue to do the things. Is this situation possible to be implemented? I was thinking about some async calls to browser, but I have no idea how it can be done from the other side. Probably there is another way.\nPlease let me know if you have any suggestions. Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":626,"Q_Id":10439654,"Users Score":1,"Answer":"I can't think of a way to do a password prompt only if required... you could prompt before and cache it as required, though, and the backend would have access.\nTo pass the sudo password to the fabric command, you can use sudo -S... i.e.\necho password | sudo -S command","Q_Score":1,"Tags":"python,ajax,django,sudo,fabric","A_Id":10439756,"CreationDate":"2012-05-03T21:36:00.000","Title":"Fabric + django asynchronous prompt for sudo password","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on the deployment tool in Django and fabric. The case is putting some parameters (like hostname and username) in the initial form, then let Django app to call fabric methods to do the rest and collect the output in the web browser.\nIF there is a password prompt from OS to fabric (ie. running sudo commands etc.), I would like to popup the one-field form for the password to be put in it (for example using jQuery UI elements). The person will fill the password field for user prompted and fabric will continue to do the things. Is this situation possible to be implemented? I was thinking about some async calls to browser, but I have no idea how it can be done from the other side. Probably there is another way.\nPlease let me know if you have any suggestions. Thanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":626,"Q_Id":10439654,"Users Score":2,"Answer":"Yes, capture the password exception, than popup the form, and run the fabric script again with env.password = userpassword\nIf you want to continue where you caught the exception, keep a variable that knows what has been done yet (i.e. nlinesexecuted) and save it when you catch the exception. Use logic when you rerun the script to continue where you left of.","Q_Score":1,"Tags":"python,ajax,django,sudo,fabric","A_Id":10439758,"CreationDate":"2012-05-03T21:36:00.000","Title":"Fabric + django asynchronous prompt for sudo password","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to create a content rule for an event such that after expiry date of the event i.e end date, it should be moved to another folder. How do I specify the content rule. Please guide. Using Plone 4.1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":10447858,"Users Score":4,"Answer":"Not sure you can do this with a content rule; there is no code running at that exact time. You'd need to run an external cron job to trigger a scan for expired events.\nWhy not just use a collection to list expired events in the other location?","Q_Score":2,"Tags":"python,plone","A_Id":10448068,"CreationDate":"2012-05-04T11:23:00.000","Title":"plone how to add content rule for event which after end date should be moved to another folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say, I find some bug in a web interface. I open firebug and discover element and class, id of this element. By them I can then identify a template which contains variables, tags and so on.\nHow can I move forward and reveal in which .py files these variables are filled in?\nI know how it works in Lift framework: when you've found a template there are elements with attributes bound to snippets. So you can easily proceed to specific snippets and edit code.\nHow does it work in django? May be, I suppose wrong process... then point me to the right algorithm, please.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":66,"Q_Id":10451323,"Users Score":1,"Answer":"In well designed django, you should only have to edit the template. Good design provides clean separation. It's possible the developer may have been forced todo something unusual...but you could try to edit the template and see what happens (make backup 1st)","Q_Score":0,"Tags":"python,django","A_Id":10451563,"CreationDate":"2012-05-04T14:59:00.000","Title":"Django: How can I find methods\/functions filling in the specific template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say, I find some bug in a web interface. I open firebug and discover element and class, id of this element. By them I can then identify a template which contains variables, tags and so on.\nHow can I move forward and reveal in which .py files these variables are filled in?\nI know how it works in Lift framework: when you've found a template there are elements with attributes bound to snippets. So you can easily proceed to specific snippets and edit code.\nHow does it work in django? May be, I suppose wrong process... then point me to the right algorithm, please.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":10451323,"Users Score":1,"Answer":"Determining template variable resolution is all about Context.\n\nUse the URL to identify the view being invoked.\nLook at the view's return and note a) the template being used, and b) any values being passed in the Context used when the template is being rendered.\nLook at settings.py for the list of TEMPLATE_CONTEXT_PROCESSORS. These are routines that are called automatically and invisibly to add values to the Context being passed to the template. This is sort of a Man Behind the Curtain\u2122 process that can really trip you up if you don't know about it.\nCheck to see if there are any magic template tags being called (either in the template in question, in a template it extends, or in a template that includes the template) that might be modifying the Context. Sometimes I need use an old-school django snippet called {%expr%} that can do evaluation in the template, but I always use it as close to the point of need as possible to highlight the fact it is being used.\n\nNote that because of the way Django template variables are resolved, {{foo.something}} could be either a value or a callable method. I have serious issues with this syntax, but that's the way they wrote it.","Q_Score":0,"Tags":"python,django","A_Id":10451982,"CreationDate":"2012-05-04T14:59:00.000","Title":"Django: How can I find methods\/functions filling in the specific template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a Project Manager using wxPython it has a splitter window. On one side is a tree that shows the names of and opens the files and on the other size is a textctrl that is used to edit the file.\nOne problem I am having is that I would like it to go back 4 spaces when SHIFT and TAB are pressed, I have code working that add's 4 spaces when TAB is pressed.\nI am also have a problem that when I add a file that is in a different folder to my programs cwd the tree adds a new node and the file appears under this node and I am struggling to get the tree to save to a file. \nAlso I would like to know how to add an icon to an item in the tree from an external png file.\nI would appreciate any help that could be given with either of these problems.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1518,"Q_Id":10463702,"Users Score":1,"Answer":"I don't know use WxPython and so don't have much idea about it. But in general what you can do is whenever a key is pressed, call a callback function and you could get the time when the key was pressed. save it somewhere. And when the next key is pressed, get the time. compare both times, if there's not much significant delay (you can decide the delay), it means that both the keys were pressed simultaneously (although they were not).","Q_Score":0,"Tags":"python,tree,wxpython","A_Id":10464339,"CreationDate":"2012-05-05T16:19:00.000","Title":"Multiple key press detection wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been searching for tutorials on how to use pyinstaller and cant find that one that i can follow. I have been researching this for hours on end and cant find anything that helps me. I am using Linux and was wondering if anyone can help me out form the very begging, because there is not one part i understand about this. I also have three files that make up one program, and am also using Tkinter so i dont know if that makes it more difficult.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":731,"Q_Id":10468669,"Users Score":1,"Answer":"The following is reposted from my comment on the question, so that this question may be marked as answered (assuming OP is satisfied with this answer). It was originally posted as a comment because it does not answer the question directly.\n\nThe reason there aren't many tutorials on how to do this on Linux is\n  because there is not much point to do this on Linux, as the actual\n  Python files can be turned into a package with a set of dependencies\n  and everything. Perhaps you should try that instead; the PyInstaller\n  approach is only worth it if you have a valid reason not to use\n  packages (and such reasons do exist).","Q_Score":2,"Tags":"python,linux,ubuntu,tkinter,pyinstaller","A_Id":10468962,"CreationDate":"2012-05-06T06:31:00.000","Title":"Python PyInstaller Ubuntu Troubles","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I want to read bytes directly off a hard drive, preferably using python. How can I do this, provided it is even possible. Also, can I write directly to a hard drive, and how?\nI want to do this to make a complete clone of a hard drive, and then restoring from that backup. I'm quite certain there are easier ways to get what I want done, and this is partly simply curiosity ;)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1762,"Q_Id":10479040,"Users Score":5,"Answer":"On linux, you can open('\/dev\/sdX', 'r').\nHowever, the easier way is using the dd commandline utility (but it will only work properly if both disks are exactly the same).","Q_Score":4,"Tags":"python,hard-drive","A_Id":10479073,"CreationDate":"2012-05-07T08:37:00.000","Title":"Python - Reading directly from hard drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having weird behaviors in my Python environment on Mac OS X Lion.\nApps like Sublime Text (based on Python) don't work (I initially thought it was an app bug),\nand now, after I installed hg-git, I get the following error every time I lauch HG in term: \n*** failed to import extension hggit from \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-package\/hggit\/: [Errno 2] No such file\nor directory\nSo it probably is a Python environment set up error. Libraries and packages are there in place.\nAny idea how to fix it?\nNotes:\n\nI installed hg-git following hg-git web site directions.\nI also added the exact path to the extension in my .hgrc file as: hggit = \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-package\/hggit\/\nPython was installed using official package on Python web site.\nEchoing $PYTHONPATH in term print anything","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2128,"Q_Id":10510450,"Users Score":0,"Answer":"\"site-package\"? Did you mean \"site-packages\"?","Q_Score":2,"Tags":"python,mercurial,path,pythonpath","A_Id":10510460,"CreationDate":"2012-05-09T05:43:00.000","Title":"Python: Failed to import extension - Errno 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I use Django-social-auth to authenticate the users of a Django project. So I guess I have all the necessary information about a Twitter user to make a post on their behalf on their Twitter account. So do I really need to install a new app? or with the info at hand how would I do that? Isn't it just a matter of posting to a Twitter API with the relevant info?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":783,"Q_Id":10513759,"Users Score":2,"Answer":"You could just extract the code into your own project and that will work. But the benefits of using an open source library is that there's a good chance when Twitter or Social Network X changes it's API, the library, if popular, would get updated as opposed to you needing to make the change.","Q_Score":1,"Tags":"python,django,twitter","A_Id":10516808,"CreationDate":"2012-05-09T09:54:00.000","Title":"Django users post to twitter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a java application as server (installed on Tomcat\/Apache) and another java application as client. The client's task is to get some arguments and pass them to the server and call an adequate method on the server to be execute.\nI want to have the client in other languages like Perl, Python or TCL. So, I\u200c need to know how to establish the communication and what is the communication structure. I'm not seeking for some codes but rather to know more about how to execute some java codes via other languages. I try to google it, but I mostly found the specific question\/answer and not a tutorial or something like that. I wonder if I should search for a specific expression ? Do you know any tutorial or site whom explains such structures considering all aspects ?\nMany thanks\nBye.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":10519454,"Users Score":0,"Answer":"What you are talking about is Web Services. A corollary to this is XML and SOAP. In Java, Python, C#, C++... any language, you can create a Web Service that conforms to a standard pattern. Using NetBeans (Oracle's Java IDE) it is easy to create Java web services. Otherwise, use google to search for \"web services tutorial [your programming language]","Q_Score":3,"Tags":"java,python,perl,client","A_Id":10519519,"CreationDate":"2012-05-09T15:42:00.000","Title":"Execute java methodes via a Python or Perl client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have thousands of survey responses that have been tagged according to the content of the response. Each response can have one tag or many (up to 20), and the tags are independent of one another rather than being structured into category-subcategory or something.\nI want to be able to do analysis like the following:\n\nHow many instances of a given tag are there?\nWhich tags occur most frequently overall?\nWhere tag X is present, which other tags appear along with it most frequently?\nList of all tags with the count of each next to it\nSelect subsets of the data to do similar analysis on (by country, for example)\n\nThe people I'm working with have traditionally tackled everything in Excel (general business strategy consulting work), and that won't work in this case. Their response is to change the project framework to something that Excel can handle in a pivot table, but it would be so much better if we could use more robust tools that allow for more sophisticated relationships.\nI've been learning SQLite but am starting to fear that the kinds of things I want to do will be pretty complicated.\nI've also been learning Python (for unrelated reasons) and am kind of wondering if an ORM tool and some Python code might be the better way to go.\nAnd then there's something like Access (which I don't have but would possibly be willing to get if it's a sweet spot for this kind of thing).\nIn summary, I'd love to know how hard these kinds of analysis would be to do overall and which tools would best be suited for the job. I'm completely open to the idea that I'm thinking about some of or all of the problem in a way that's backwards and would welcome any advice on any aspect of what I've written here.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":144,"Q_Id":10522290,"Users Score":1,"Answer":"While data concerning the frequency of individual tags should be very simple to construct, data concerning the relationships between tags is very difficult and falls under the realm of data mining.  Here is what I would do, at a very high level, assuming you have a response table, a tag table, and a response_tag table.  \nCreate a summary table that lists each unique combination of response tags, along with a column that will indicate how many times this combination occurs.  The table structure should be something like combination (id, count), combination_tags(combination_id, tag_id).  Use a procedural statement (ORM or SQL Cursors) to populate the table, and then use ad-hoc queries to sample the data.  \nThis is not a simple operation, but it will get you results using a simple RDBMS, without having to use enterprise level data mining solutions.","Q_Score":2,"Tags":"python,sql,excel,ms-access","A_Id":10522435,"CreationDate":"2012-05-09T18:49:00.000","Title":"Best approach to doing analysis of sets of tags?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have thousands of survey responses that have been tagged according to the content of the response. Each response can have one tag or many (up to 20), and the tags are independent of one another rather than being structured into category-subcategory or something.\nI want to be able to do analysis like the following:\n\nHow many instances of a given tag are there?\nWhich tags occur most frequently overall?\nWhere tag X is present, which other tags appear along with it most frequently?\nList of all tags with the count of each next to it\nSelect subsets of the data to do similar analysis on (by country, for example)\n\nThe people I'm working with have traditionally tackled everything in Excel (general business strategy consulting work), and that won't work in this case. Their response is to change the project framework to something that Excel can handle in a pivot table, but it would be so much better if we could use more robust tools that allow for more sophisticated relationships.\nI've been learning SQLite but am starting to fear that the kinds of things I want to do will be pretty complicated.\nI've also been learning Python (for unrelated reasons) and am kind of wondering if an ORM tool and some Python code might be the better way to go.\nAnd then there's something like Access (which I don't have but would possibly be willing to get if it's a sweet spot for this kind of thing).\nIn summary, I'd love to know how hard these kinds of analysis would be to do overall and which tools would best be suited for the job. I'm completely open to the idea that I'm thinking about some of or all of the problem in a way that's backwards and would welcome any advice on any aspect of what I've written here.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":144,"Q_Id":10522290,"Users Score":1,"Answer":"You have a quite small dataset, so you do not need any kind of ORM really, just load all data in Python and chew a report of it.\nSQL as a language is horrible for a more complex data analysis (e.g. where you really want to crosstabulate things etc).","Q_Score":2,"Tags":"python,sql,excel,ms-access","A_Id":10522611,"CreationDate":"2012-05-09T18:49:00.000","Title":"Best approach to doing analysis of sets of tags?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have thousands of survey responses that have been tagged according to the content of the response. Each response can have one tag or many (up to 20), and the tags are independent of one another rather than being structured into category-subcategory or something.\nI want to be able to do analysis like the following:\n\nHow many instances of a given tag are there?\nWhich tags occur most frequently overall?\nWhere tag X is present, which other tags appear along with it most frequently?\nList of all tags with the count of each next to it\nSelect subsets of the data to do similar analysis on (by country, for example)\n\nThe people I'm working with have traditionally tackled everything in Excel (general business strategy consulting work), and that won't work in this case. Their response is to change the project framework to something that Excel can handle in a pivot table, but it would be so much better if we could use more robust tools that allow for more sophisticated relationships.\nI've been learning SQLite but am starting to fear that the kinds of things I want to do will be pretty complicated.\nI've also been learning Python (for unrelated reasons) and am kind of wondering if an ORM tool and some Python code might be the better way to go.\nAnd then there's something like Access (which I don't have but would possibly be willing to get if it's a sweet spot for this kind of thing).\nIn summary, I'd love to know how hard these kinds of analysis would be to do overall and which tools would best be suited for the job. I'm completely open to the idea that I'm thinking about some of or all of the problem in a way that's backwards and would welcome any advice on any aspect of what I've written here.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":10522290,"Users Score":0,"Answer":"Go with SQL!  It is very powerful for data analysis.  It will allow you to ask questions in the future about the data.  Questions that you have not yet thought of.\nAlthough SQL as a language may seem a bit cumbersome, it is much easier to use than a \"real\" programming language.  In your case, SQL interfaces to Excel, so users can get access to the data through a tool they are familiar with.\nIf you do go with SQL, a real database (SQLLite) is a better solution than MSAccess.\nI feel strongly enough in SQL as an analysis tool that I wrote a book on the subject, \"Data Analysis Using SQL and Excel\".  You might check out the Amazon comments (http:\/\/www.amazon.com\/Data-Analysis-Using-SQL-Excel\/dp\/0470099518\/ref=pd_sim_b_1) to understand how effective it can be.","Q_Score":2,"Tags":"python,sql,excel,ms-access","A_Id":10523469,"CreationDate":"2012-05-09T18:49:00.000","Title":"Best approach to doing analysis of sets of tags?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get the available bandwidth from my PC. \nSuppose I'm streaming a video at 2 Mbps and my network card is of 100 Mbps, my program should tell me that 98 Mbps is available. \nIs it easy to do in C++ or Python? And how can I find the available bandwidth using any of the suggested programming language. Any help will be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":832,"Q_Id":10532642,"Users Score":2,"Answer":"There are many, many factors that will influence the available bandwidth: your hardware (network card, router, WiFi stability, cabling), what you are doing (other downloads, machine load) and what is happening elsewhere (bandwidth to target server, ISP issues, etc.). And all of those can change at any moment in time to make things more interesting. The end result is that there is no way to useful way calculate the available bandwidth. The best you can do is to try downloading (or uploading, depending on what direction you are interested in) some testdata to the target server and see what bandwidth you can use. Keep in mind that TCP has a speeds up over time so you need to run your test for a while to get the real available bandwidth.","Q_Score":0,"Tags":"c++,python","A_Id":10532867,"CreationDate":"2012-05-10T11:02:00.000","Title":"Find available bandwidth from Python or C++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After creating a simple window\/widget layout with Page (page.sourceforge.net)\nI found that the listbox curselection() call returns the proper index when releasing Button-1.\nWhen hit, it returns the previous index (the item which we just leave).\nBecasue of some timer activities I'd like to get the clicked index at click-time, instead of release-time. Can somebody help me how could I do that? Thank you","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":875,"Q_Id":10560041,"Users Score":1,"Answer":"Bind to the event <<ListboxSelect>> instead of <1>, this event will fire after the current selection has been updated. \nIf you genuinely need for the binding to work literally on a press of the mouse button you will have to rearrange the order of the bind tags for the widget.","Q_Score":1,"Tags":"python,listbox,tkinter","A_Id":10560466,"CreationDate":"2012-05-12T00:18:00.000","Title":"Getting Tkinter listbox item when hit Button-1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I have tried UpfrontContacts, collective.contacts couldn't get to build the zope.conf. Any for the version of Plone i.e 4.1 ? Please let me know the exact steps to implement the same also. Also tried Membrane. But don't know how to use it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":10561426,"Users Score":0,"Answer":"Products.PressRoom is the answer yahooo! :)","Q_Score":0,"Tags":"python,plone","A_Id":10561638,"CreationDate":"2012-05-12T05:52:00.000","Title":"Any addons for contacts for Plone 4.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a sorting system with card ranks and their values are obtained from a separate dictionary. In a simple deck of 52 cards, we have 2 to Ace ranks, in this case I want a ranking system where 0 is 10, J is 11, Q is 12, K is 13, A is 14 and 2 is 15 where 2 is the largest valued rank. The thing is, if there is a list where I want to sort rank cards in ASCENDING order according to the numbering system, how do I do so?\nFor example, here is a list, [3,5,9,7,J,K,2,0], I want to sort the list into [3,5,7,9,0,J,K,2]. I also made a dictionary for the numbering system as {'A': 14, 'K': 13, 'J': 11, 'Q': 12, '0': 10, '2': 15}.\nTHANKS","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":10569853,"Users Score":0,"Answer":"have you already tried\n\nsorted(list_for_sorting, key=dictionary_you_wrote.__getitem__)\n\n?","Q_Score":3,"Tags":"python,list,sorting,dictionary","A_Id":10569942,"CreationDate":"2012-05-13T06:47:00.000","Title":"Sorting a list with elements containing dictionary values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing an app that writes log entries from a BackgroundThread object on a backend instance. My problem is that I don't know how to access the logs. \nThe docs say, \"A background thread's os.environ and logging entries are independent of those of the spawning thread,\" and indeed, the log entries don't show up with the backend instance's entries on the admin console. But the admin console doesn't offer an option for showing the background threads.\nappcfg request_logs doesn't seem to be the answer either.\nDoes anybody know?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":354,"Q_Id":10573217,"Users Score":3,"Answer":"There is a combobox in the top left corner of the versions\/backends of your application switch to the backend there and you will see the backend logs.","Q_Score":2,"Tags":"python,google-app-engine,backend,background-thread","A_Id":10573307,"CreationDate":"2012-05-13T16:13:00.000","Title":"Where are the logs from BackgroundThreads on App Engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a program using Python and OpenCV where I perform operations on a video stream in run time. It works fine. Now if I want to publish it on a website where someone can see this using their browser and webcam, how do I proceed?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":878,"Q_Id":10578763,"Users Score":0,"Answer":"not really sure what you want to happen but if your going to implement this kind of feature in a website I think you should use a flash application instead of python (or if possible html 5). though your using python on the development of you web app it would only run on the server side instead and the feature you want to use is on a client side so for me it's more feasible to use flash instead to capture the video then after capturing the video you upload it to your server then your python code will do the rest of the process on the server side.","Q_Score":3,"Tags":"python,webcam","A_Id":10578877,"CreationDate":"2012-05-14T07:01:00.000","Title":"Access webcam over internet using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I apologise if this question has already been asked.\nI'm really new to Python programming, and what I need to do is this:\nI have a .csv file in which each line represent a person and each column represents a variable.\nThis .csv file comes from an agent-based C++ simulation I have done.\nNow, I need to read each line of this file and for each line generate a new instance of the class Person(), passing as arguments every variable line by line.\nMy problem is this: what is the most pythonic way of generating these agents while keeping their unique ID (which is one of the attributes I want to read from the file)? Do you suggest creating a class dictionary for accessing every instance? But I still need to provide a name to every single instance, right? How can I do that dynamically? Probably the best thing would be to use the unique ID, read from the file, as the instance name, but I think that numbers can't be used as instance names, can they? I miss pointers! :(\nI am sure there is a pythonic solution I cannot see, as I still have to rewire my mind a bit to think in pythonic ways...\nThank you very much, any help would be greatly appreciated!\nAnd please remember that this is my first project in python, so go easy on me! ;)\nEDIT:\nThank you very much for your answers, but I still haven't got an answer on the main point: how to create an instance of my class Person() for every line in my csv file. I would like to do that automatically! Is it possible?\nWhy do I need this? Because I need to create networks of these people with networkx and I would like to have \"agents\" linked in a network structure, not just dictionary items.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":725,"Q_Id":10583195,"Users Score":1,"Answer":"I have a .csv file\n\nYou're in luck; CSV support is built right in, via the csv module.\n\nDo you suggest creating a class dictionary for accessing every instance?\n\nI don't know what you think you mean by \"class dictionary\". There are classes, and there are dictionaries.\n\nBut I still need to provide a name to every single instance, right? How can I do that dynamically? Probably the best thing would be to use the unique ID, read from the file, as the instance name, but I think that numbers can't be used as instance names, can they?\n\nNumbers can't be instance names, but they certainly can be dictionary keys.\nYou don't want to create \"instance names\" dynamically anyway (assuming you're thinking of having each in a separate variable or something gross like that). You want a dictionary. So just let the IDs be keys.\n\nI miss pointers! :(\n\nI really, honestly, can't imagine how you expect pointers to help here, and I have many years of experience with C++.","Q_Score":0,"Tags":"python,oop","A_Id":10583784,"CreationDate":"2012-05-14T12:19:00.000","Title":"How can I dynamically generate class instances with single attributes read from flat file in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a big key-value pair dump, that I need to lookup for my django-Python webapp.\nSo, I have following options:\n\nStore it as json dump and load it as a python dict.\nStore it in a dump.py and import the dict from it.\nUse some targeted systems for this problem: [ Are these really meant for this usecase ? ]\n\nMem-cache\nRedis\nAny other option ?\n\n\nWhich from above is the right way to go ?\nHow will you compare memcache and redis ?\nUpdate:\n\nMy dictionary is about 5 MB in size and will grow over time.\nUsing Redis\/Memcache adds an overhead of hitting a socket every-time, so would dump.py will be better since it would take time to load it to memory but after that it would only do memory lookups.\nMy dictionary needs to be updated every day, considering that dump.py will be problem, since we have to restart the django-server to reload where as I guess it would reflect on the fly in redis and memcache.\nOne uses a system like redis only when you have large amount of data and you have to lookup very frequently, in that case socket gives a overhead so, how do we achieve the advantage ?\n\nPlease share your experiences on this !","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":2666,"Q_Id":10595058,"Users Score":1,"Answer":"5Mb isn't that large. You could keep it in memory in process, and I recommend that you do, until it becomes clear from profiling and testing that that approach isn't meeting your needs. Always do the simplest thing possible.\nSocket communication doesn't of itself introduce much of an overhead. You could probably pare it back a little by using a unix domain socket. In any case, if you're not keeping your data in process, you're going to have to talk over some kind of pipe.","Q_Score":10,"Tags":"python,django,dictionary,memcached,redis","A_Id":10597896,"CreationDate":"2012-05-15T06:13:00.000","Title":"Maintain a large dictionary in memory for Django-Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a big key-value pair dump, that I need to lookup for my django-Python webapp.\nSo, I have following options:\n\nStore it as json dump and load it as a python dict.\nStore it in a dump.py and import the dict from it.\nUse some targeted systems for this problem: [ Are these really meant for this usecase ? ]\n\nMem-cache\nRedis\nAny other option ?\n\n\nWhich from above is the right way to go ?\nHow will you compare memcache and redis ?\nUpdate:\n\nMy dictionary is about 5 MB in size and will grow over time.\nUsing Redis\/Memcache adds an overhead of hitting a socket every-time, so would dump.py will be better since it would take time to load it to memory but after that it would only do memory lookups.\nMy dictionary needs to be updated every day, considering that dump.py will be problem, since we have to restart the django-server to reload where as I guess it would reflect on the fly in redis and memcache.\nOne uses a system like redis only when you have large amount of data and you have to lookup very frequently, in that case socket gives a overhead so, how do we achieve the advantage ?\n\nPlease share your experiences on this !","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":2666,"Q_Id":10595058,"Users Score":1,"Answer":"In past for a similar problem I have used the idea of a dump.py . I would think that all of the other data structures would require a layer to convert objects of one kind into   python objects . However I would still think that this would depend on data size and the amount of data you are handling . Memcache and redis should have better indexing and look up when it comes to really large data sets and things like regex based lookup . So my recommendation would be \njson -- if you are serving the data over http to some other service\npython file - if data structure is not too large and you need not any special kind of look ups\nmemcache and redis -- if the data becomes really large","Q_Score":10,"Tags":"python,django,dictionary,memcached,redis","A_Id":10595177,"CreationDate":"2012-05-15T06:13:00.000","Title":"Maintain a large dictionary in memory for Django-Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a big key-value pair dump, that I need to lookup for my django-Python webapp.\nSo, I have following options:\n\nStore it as json dump and load it as a python dict.\nStore it in a dump.py and import the dict from it.\nUse some targeted systems for this problem: [ Are these really meant for this usecase ? ]\n\nMem-cache\nRedis\nAny other option ?\n\n\nWhich from above is the right way to go ?\nHow will you compare memcache and redis ?\nUpdate:\n\nMy dictionary is about 5 MB in size and will grow over time.\nUsing Redis\/Memcache adds an overhead of hitting a socket every-time, so would dump.py will be better since it would take time to load it to memory but after that it would only do memory lookups.\nMy dictionary needs to be updated every day, considering that dump.py will be problem, since we have to restart the django-server to reload where as I guess it would reflect on the fly in redis and memcache.\nOne uses a system like redis only when you have large amount of data and you have to lookup very frequently, in that case socket gives a overhead so, how do we achieve the advantage ?\n\nPlease share your experiences on this !","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2666,"Q_Id":10595058,"Users Score":2,"Answer":"Memcached, though a great product, is trumped by Redis in my book.  It offers lots of things that memcached doesn't, like persistence.  \nIt also offers more complex data structures like hashses.  What is your particular data dump?  How big is it, and how large \/ what type of values?","Q_Score":10,"Tags":"python,django,dictionary,memcached,redis","A_Id":10595172,"CreationDate":"2012-05-15T06:13:00.000","Title":"Maintain a large dictionary in memory for Django-Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library.\nDoes Someone know how to install these components in cygwin?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":37080,"Q_Id":10597284,"Users Score":6,"Answer":"@spacediver is right on. Run cygwin's setup.exe again and when you get to the packages screen make sure you select make and python (and any other libs\/apps you may need - perhaps gcc or g++).","Q_Score":20,"Tags":"python,windows,makefile,cygwin,installation","A_Id":10607864,"CreationDate":"2012-05-15T08:55:00.000","Title":"install python and make in cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library.\nDoes Someone know how to install these components in cygwin?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":37080,"Q_Id":10597284,"Users Score":12,"Answer":"Look into cygwin native package manager, devel category. You should find make and python there.","Q_Score":20,"Tags":"python,windows,makefile,cygwin,installation","A_Id":10597334,"CreationDate":"2012-05-15T08:55:00.000","Title":"install python and make in cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library.\nDoes Someone know how to install these components in cygwin?","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":37080,"Q_Id":10597284,"Users Score":7,"Answer":"After running into this problem myself, I was overlooking all of the relevant answers saying to check the setup.exe again. This was the solution to me, there are a few specific things to check.\n\nCheck \/bin for \"make.exe\". If it's not there, you have not installed it correctly\nRun the setup.exe. Don't be afraid, as new package installs append to your installation and do not over write\nIn the setup.exe, make sure you run the install from the Internet and NOT your local folder. This was where I was running into problems. Search \"make\" and make sure you select to Install it, do not leave this as \"Default\".","Q_Score":20,"Tags":"python,windows,makefile,cygwin,installation","A_Id":19168003,"CreationDate":"2012-05-15T08:55:00.000","Title":"install python and make in cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library.\nDoes Someone know how to install these components in cygwin?","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":37080,"Q_Id":10597284,"Users Score":0,"Answer":"In my case, it was happened due to python is not well installed. So python.exe is referenced in the shell so it can't find the file because the system is different.\nPlease check cygwin python is well installed.","Q_Score":20,"Tags":"python,windows,makefile,cygwin,installation","A_Id":58692435,"CreationDate":"2012-05-15T08:55:00.000","Title":"install python and make in cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library.\nDoes Someone know how to install these components in cygwin?","AnswerCount":6,"Available Count":5,"Score":0.1651404129,"is_accepted":false,"ViewCount":37080,"Q_Id":10597284,"Users Score":5,"Answer":"Here is a command line version to install python in cygwin\nwget rawgit.com\/transcode-open\/apt-cyg\/master\/apt-cyg\ninstall apt-cyg \/bin\napt-cyg install python","Q_Score":20,"Tags":"python,windows,makefile,cygwin,installation","A_Id":43129128,"CreationDate":"2012-05-15T08:55:00.000","Title":"install python and make in cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to perform serialisation of some object graph in a modular way. That is I don't want to serialize the whole graph. The reason is that this graph is big. I can keep timestamped version of some part of the graph, and i can do some lazy access to postpone loading of the parts i don't need right now.\nI thought i could manage this with metaprogramming in Python. But it seems that metaprogramming is not strong enough in Python.\nHere's what i do for now. My graph is composed of several different objects. Some of them are instances of a special class. This class describes the root object to be pickled. This is where the modularity come in. Each time i pickle something it starts from one of those instances and i never pickle two of them at the same time. Whenever there is a reference to another instance, accessible by the root object, I replace this reference by a persistant_id, thus ensuring that i won't have two of them in the same pickling stream. The problem comes when unpickling the stream. I can found a persistant_id of an instance which is not loaded yet. When this is the case, i have to wait for the target instance to be loaded before allowing access to it. And i don't see anyway to do that :\n1\/ I tried to build an accessor which get methods return the target of the reference. Unfortunately, accessors must be placed in the class declaration, I can't assign them to the unpickled object.\n2\/ I could store somewhere the places where references have to be resolved. I don't think this is possible in Python : one can't keep reference to a place (a field, or a variable), it is only possible to keep a reference to a value.\nMy problem may not be clear. I'm still looking for a clear formulation. I tried other things like using explicit references which would be instances of some \"Reference\" class. It isn't very convenient though. \nDo you have any idea how to implement modular serialisation with pickle ? Would i have to change internal behaviour of Unpickler to be able to remember places where i need to load the remaining of the object graph ? Is there another library more suitable to achieve similar results ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":10607350,"Users Score":0,"Answer":"Metaprogramming is strong in Python; Python classes are extremely malleable. You can alter them after declaration all the way you want, though it's best done in a metaclass (decorator). More than that, instances are malleable, independently of their classes.\nA 'reference to a place' is often simply a string. E.g. a reference to object's field is its name. Assume you have multiple node references inside your node object. You could have something like {persistent_id: (object, field_name),..} as your unresolved references table, easy to look up. Similarly, in lists of nodes 'references to places' are indices.\nBTW, could you use a key-value database for graph storage? You'd be able to pull nodes by IDs without waiting.","Q_Score":1,"Tags":"python,pickle","A_Id":10608972,"CreationDate":"2012-05-15T19:16:00.000","Title":"Modular serialization with pickle (Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to perform serialisation of some object graph in a modular way. That is I don't want to serialize the whole graph. The reason is that this graph is big. I can keep timestamped version of some part of the graph, and i can do some lazy access to postpone loading of the parts i don't need right now.\nI thought i could manage this with metaprogramming in Python. But it seems that metaprogramming is not strong enough in Python.\nHere's what i do for now. My graph is composed of several different objects. Some of them are instances of a special class. This class describes the root object to be pickled. This is where the modularity come in. Each time i pickle something it starts from one of those instances and i never pickle two of them at the same time. Whenever there is a reference to another instance, accessible by the root object, I replace this reference by a persistant_id, thus ensuring that i won't have two of them in the same pickling stream. The problem comes when unpickling the stream. I can found a persistant_id of an instance which is not loaded yet. When this is the case, i have to wait for the target instance to be loaded before allowing access to it. And i don't see anyway to do that :\n1\/ I tried to build an accessor which get methods return the target of the reference. Unfortunately, accessors must be placed in the class declaration, I can't assign them to the unpickled object.\n2\/ I could store somewhere the places where references have to be resolved. I don't think this is possible in Python : one can't keep reference to a place (a field, or a variable), it is only possible to keep a reference to a value.\nMy problem may not be clear. I'm still looking for a clear formulation. I tried other things like using explicit references which would be instances of some \"Reference\" class. It isn't very convenient though. \nDo you have any idea how to implement modular serialisation with pickle ? Would i have to change internal behaviour of Unpickler to be able to remember places where i need to load the remaining of the object graph ? Is there another library more suitable to achieve similar results ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":10607350,"Users Score":0,"Answer":"Here's how I think I would go about this.\n\nHave a module level dictionary mapping persistent_id to SpecialClass objects. Every time you initialise or unpickle a SpecialClass instance, make sure that it is added to the dictionary.\nOverride SpecialClass's __getattr__ and __setattr__ method, so that specialobj.foo = anotherspecialobj merely stores a persistent_id in a dictionary on specialobj (let's call it specialobj.specialrefs). When you retrieve specialobj.foo, it finds the name in specialrefs, then finds the reference in the module-level dictionary.\nHave a module level check_graph function which would go through the known SpecialClass instances and check that all of their specialrefs were available.","Q_Score":1,"Tags":"python,pickle","A_Id":10608783,"CreationDate":"2012-05-15T19:16:00.000","Title":"Modular serialization with pickle (Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a list of elements (integers) and what I need to do is to quickly check how many elements from this list fall within a specified range. The example is below.\nrange is from 34 to 566\nl = [9,20,413,425]\nThe result is 2.\nI can of course use a simple for loop for the purpose and compare each element with the min and max value (34 < x < 566) and then use a counter if the statement is true, however I think there might be a much easier way to do this, possibly with a nice one-liner.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2870,"Q_Id":10615196,"Users Score":9,"Answer":"len([x for x in l if x > 34 and x < 566])","Q_Score":7,"Tags":"python,list,range","A_Id":10615351,"CreationDate":"2012-05-16T09:00:00.000","Title":"Check how many elements from a list fall within a specified range (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm quite new to algorithms and i was trying to understand the minimax, i read a lot of articles,but i still can't get how to implement it into a tic-tac-toe game in python.\nCan you try to explain it to me as easy as possible maybe with some pseudo-code or some python code?. \nI just need to understand how it works. i read a lot of stuff about that and i understood the basic, but i still can't get how it can return a move.\nIf you can please don't link me tutorials and samples like (http:\/\/en.literateprograms.org\/Tic_Tac_Toe_(Python)) , i know that they are good, but i simply need a idiot explanation.\nthank you for your time :)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":5575,"Q_Id":10626766,"Users Score":3,"Answer":"Minimax is a way of exploring the space of potential moves in a two player game with alternating turns.  You are trying to win, and your opponent is trying to prevent you from winning.  \nA key intuition is that if it's currently your turn, a two-move sequence that guarantees you a win isn't useful, because your opponent will not cooperate with you.  You try to make moves that maximize your chances of winning and your opponent makes moves that minimize your chances of winning.\nFor that reason, it's not very useful to explore branches from moves that you make that are bad for you, or moves your opponent makes that are good for you.","Q_Score":10,"Tags":"python,algorithm","A_Id":10627590,"CreationDate":"2012-05-16T21:10:00.000","Title":"Minimax explanation \"for dummies\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"java's System.nanoTime() seems to give a long: 1337203874231141000L\nwhile python time.time() will give something like 1337203880.462787\nhow can i convert time.time()'s value to something match up to System.nanoTime()?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3163,"Q_Id":10627055,"Users Score":0,"Answer":"Divide the output of System.nanoTime() by 10^9. This is because it is in nanoseconds, while the output of time.time() is in seconds.","Q_Score":5,"Tags":"java,python,nanotime","A_Id":10627094,"CreationDate":"2012-05-16T21:36:00.000","Title":"convert python time.time() to java.nanoTime()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am starting to depend heavily on the IPython notebook app to develop and document algorithms.  It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it:\nI would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm.  I know enough to add something like <img src=\"image.png\"> to the markdown, but that is about as far as my knowledge goes.  I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is.  (I'm working on a mac.)  So, is it possible to do what I'm trying to do without too much trouble?","AnswerCount":14,"Available Count":5,"Score":-1.0,"is_accepted":false,"ViewCount":455440,"Q_Id":10628262,"Users Score":-4,"Answer":"You can find your current working directory by 'pwd' command in jupyter notebook without quotes.","Q_Score":305,"Tags":"python,jupyter-notebook,ipython,jupyter","A_Id":58837887,"CreationDate":"2012-05-16T23:52:00.000","Title":"Inserting image into IPython notebook markdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am starting to depend heavily on the IPython notebook app to develop and document algorithms.  It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it:\nI would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm.  I know enough to add something like <img src=\"image.png\"> to the markdown, but that is about as far as my knowledge goes.  I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is.  (I'm working on a mac.)  So, is it possible to do what I'm trying to do without too much trouble?","AnswerCount":14,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":455440,"Q_Id":10628262,"Users Score":0,"Answer":"I never could get \"insert image\" into a markdown cell to work.  However, the drag and drop entered the png file saved in the same directory as my notebook.  It brought this text into the cell\n\"\"\nThe shift + enter > image is now displayed in notebook.\nFWIW","Q_Score":305,"Tags":"python,jupyter-notebook,ipython,jupyter","A_Id":67960394,"CreationDate":"2012-05-16T23:52:00.000","Title":"Inserting image into IPython notebook markdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am starting to depend heavily on the IPython notebook app to develop and document algorithms.  It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it:\nI would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm.  I know enough to add something like <img src=\"image.png\"> to the markdown, but that is about as far as my knowledge goes.  I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is.  (I'm working on a mac.)  So, is it possible to do what I'm trying to do without too much trouble?","AnswerCount":14,"Available Count":5,"Score":0.0428309231,"is_accepted":false,"ViewCount":455440,"Q_Id":10628262,"Users Score":3,"Answer":"minrk's answer is right.\nHowever, I found that the images appeared broken in Print View (on my Windows machine running the Anaconda distribution of IPython version 0.13.2 in a Chrome browser)\nThe workaround for this was to use <img src=\"..\/files\/image.png\"> instead.\nThis made the image appear correctly in both Print View and the normal iPython editing view. \nUPDATE: as of my upgrade to iPython v1.1.0 there is no more need for this workaround since the print view no longer exists. In fact, you must avoid this workaround since it prevents the nbconvert tool from finding the files.","Q_Score":305,"Tags":"python,jupyter-notebook,ipython,jupyter","A_Id":19664281,"CreationDate":"2012-05-16T23:52:00.000","Title":"Inserting image into IPython notebook markdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am starting to depend heavily on the IPython notebook app to develop and document algorithms.  It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it:\nI would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm.  I know enough to add something like <img src=\"image.png\"> to the markdown, but that is about as far as my knowledge goes.  I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is.  (I'm working on a mac.)  So, is it possible to do what I'm trying to do without too much trouble?","AnswerCount":14,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":455440,"Q_Id":10628262,"Users Score":10,"Answer":"Last version of jupyter notebook accepts copy\/paste of image natively","Q_Score":305,"Tags":"python,jupyter-notebook,ipython,jupyter","A_Id":48560308,"CreationDate":"2012-05-16T23:52:00.000","Title":"Inserting image into IPython notebook markdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am starting to depend heavily on the IPython notebook app to develop and document algorithms.  It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it:\nI would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm.  I know enough to add something like <img src=\"image.png\"> to the markdown, but that is about as far as my knowledge goes.  I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is.  (I'm working on a mac.)  So, is it possible to do what I'm trying to do without too much trouble?","AnswerCount":14,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":455440,"Q_Id":10628262,"Users Score":62,"Answer":"Getting an image into Jupyter NB is a much simpler operation than most people have alluded to here.\n\nSimply create an empty Markdown cell.\nThen drag-and-drop the image file into the empty Markdown cell.\n\nThe Markdown code that will insert the image then appears.\nFor example, a string shown highlighted in gray below will appear in the Jupyter cell:\n![Venus_flytrap_taxonomy.jpg](attachment:Venus_flytrap_taxonomy.jpg)\n\nThen execute the Markdown cell by hitting Shift-Enter.  The Jupyter server will then insert the image, and the image will then appear.\n\nI am running Jupyter notebook server is: 5.7.4 with Python 3.7.0 on Windows 7.\nThis is so simple !!\nUPDATE AS OF March 18, 2021:\nThis simple \"Drag-and-Drop-from-Windows-File-System\" method still works fine in JupyterLab.  JupyterLab inserts the proper HTML code to embed the image directly and permanently into the notebook so the image is stored in the .ipynb file.  I am running Jupyter Lab v2.2.7 on Windows 10 Python 3.7.9 still works in JupyterLab.  I am running Jupyter Lab v2.2.7 using Python 3.7.9 on Windows 10.\nThis stopped working in Jupyter Classic Notebook v6.1.5 sometime last year.  I reported an bug notice to the Jupyter Classic Notebook developers.\nIt works again in the latest version of Jupyter Classic Notebook.  I just tried it in v6.4 on 7\/15\/2021.  Thank you Jupyter NB Classic Developers !!","Q_Score":305,"Tags":"python,jupyter-notebook,ipython,jupyter","A_Id":55623116,"CreationDate":"2012-05-16T23:52:00.000","Title":"Inserting image into IPython notebook markdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Circumstances\nI have a procedure which will construct a matrix using the given list of values!\nand the list starts growing bigger like 100 thousand or million values in a list, which in turn, will result in million x million size matrix.\nin the procedure, i am doing some add\/sub\/div\/multiply operations on the matrix, either based on the row, the column or just the element.\nIssues\nsince the matrix is so big that i don`t think doing the whole manipulation in the memory would work.\nQuestions\ntherefore, my question would be: \nhow should i manipulate this huge matrix and the huge value list?\nlike, where to store it, how to read it etc, so that i could carry out my operations on the matrix and the computer won`t stuck or anything.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1461,"Q_Id":10632427,"Users Score":1,"Answer":"First and foremost, such matrix would have 10G elements. Considering that for any useful operation you would then need 30G elements, each taking 4-8 bytes, you cannot assume to do this at all on a 32-bit computer using any sort of in-memory technique. To solve this, I would use a) genuine 64-bit machine, b) memory-mapped binary files for storage, and c) ditch python.\nUpdate\nAnd as I calculated below, if you have 2 input matrices and 1 output matrix, 100000 x 100000 32 bit float\/integer elements, that is 120 GB (not quite GiB, though) of data. Assume, on a home computer you could achieve constant 100 MB\/s I\/O bandwidth, every single element of a matrix needs to be accessed for any operation including addition and subtraction, the absolute lower limit for operations would be 120 GB \/ (100 MB\/s) = 1200 seconds, or 20 minutes, for a single matrix operation. Written in C, using the operating system as efficiently as possible, memmapped IO and so forth. For million by million elements, each operation takes 100 times as many time, that is 1.5 days. And as the hard disk is saturated during that time, the computer might just be completely unusable.","Q_Score":1,"Tags":"python,list,matrix","A_Id":10632557,"CreationDate":"2012-05-17T08:47:00.000","Title":"How do I operate on a huge matrix (100000x100000) stored as nested list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Circumstances\nI have a procedure which will construct a matrix using the given list of values!\nand the list starts growing bigger like 100 thousand or million values in a list, which in turn, will result in million x million size matrix.\nin the procedure, i am doing some add\/sub\/div\/multiply operations on the matrix, either based on the row, the column or just the element.\nIssues\nsince the matrix is so big that i don`t think doing the whole manipulation in the memory would work.\nQuestions\ntherefore, my question would be: \nhow should i manipulate this huge matrix and the huge value list?\nlike, where to store it, how to read it etc, so that i could carry out my operations on the matrix and the computer won`t stuck or anything.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1461,"Q_Id":10632427,"Users Score":0,"Answer":"Your data structure is not possible with arrays, it is too large. If the matrix is for instance a binary matrix you could look at representations for its storage like hashing larger blocks of zeros together to the same bucket.","Q_Score":1,"Tags":"python,list,matrix","A_Id":10643647,"CreationDate":"2012-05-17T08:47:00.000","Title":"How do I operate on a huge matrix (100000x100000) stored as nested list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way in python to truncate the decimal part at 5 or 7 digits?\nIf not, how can i avoid a float like e**(-x) number to get too big in size?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":6061,"Q_Id":10643982,"Users Score":2,"Answer":"The \"Result too large\" doesn't refer to the number of characters in the decimal representation of the number, it means that the number that resulted from your exponential function is large enough to overflow whatever type python uses internally to store floating point values.\nYou need to either use a different type to handle your floating point calculations, or rework you code so that e**(-x) doesn't overflow or underflow.","Q_Score":1,"Tags":"python","A_Id":10644350,"CreationDate":"2012-05-17T21:46:00.000","Title":"python e**(-x) OverflowError: (34, 'Result too large')","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've built a paywalled CMS + invoicing system for a client and I need to get more stringent with my testing.\nI keep all my data in a Django ORM and have a bunch of Celery tasks that run at different intervals that makes sure that new invoices and invoice reminders get sent and cuts of access when users don't pay their invoices. \nFor example I'd like to be a able to run a test that:\n\nCreates a new user and generates an invoice for X days of access to the site\nSimulates the passing of X + 1 days, and runs all the tasks I've got set up in Celery.\nChecks that a new invoice for an other X days has been issued to the user.\n\nThe KISS approach I've come up with so far is to do all the testing on a separate machine and actually manipulate the date\/time at the OS-level. So the testing script would:\n\nSet the system date to day 1\nCreate a new user and generate the first invoice for X days of access\nAdvance then system date 1 day. Run all my celery tasks. Repeat until X + 1 days have \"passed\"\nCheck that a new invoice has been issued\n\nIt's a bit clunky but I think it might work. Any other ideas on how to get it done?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":3901,"Q_Id":10652097,"Users Score":4,"Answer":"Without the use of a special mock library, I propose to prepare the code for being in mock-up-mode (probably by a global variable).  In mock-up-mode instead of calling the normal time-function (like time.time() or whatever) you could call a mock-up time-function which returns whatever you need in your special case.\nI would vote down for changing the system time.  That does not seem like a unit test but rather like a functional test as it cannot be done in parallel to anything else on that machine.","Q_Score":20,"Tags":"python,testing,mocking,integration-testing,celery","A_Id":10653559,"CreationDate":"2012-05-18T11:48:00.000","Title":"Simulating the passing of time in unittesting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Another way to ask this:\nIf I wrote doctests in reST, can I use it for Sphinx or other automatic documentation efforts?\nBackground: I don't know how to use Sphinx and have not much experience with reST either, so I am wondering if I can use reST-written doctests somewhere else useful than with Sphinx?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":880,"Q_Id":10660246,"Users Score":0,"Answer":"Adding doctests to your documentation makes sense to ensure that code in your documentation is actually working as expected. So, you're testing your documentation. For general code-testing, using doctests can't be recommended at all.","Q_Score":0,"Tags":"python,restructuredtext,doctest","A_Id":32209186,"CreationDate":"2012-05-18T21:59:00.000","Title":"Why would I write doctests in restructured text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to generate an Eclipse plugin that just runs an existing Python script with parameters.\nWhile this sounds very simple, I don't think it's easy to implement. I can generate a Eclipse plugin. My issue is not how to use PDE. But:\n\ncan I call the existing Python script from Java, from an Eclipse plugin?\nit needs to run from the embedded console with some parameters\n\nIs this reasonably easy to do? And I don't plan to reimplement it in any way. Calling it from command-line works very well. My question is: can Eclipse perform this, too?\nBest,\nMarius","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1884,"Q_Id":10665768,"Users Score":1,"Answer":"You can already create an External Launch config from Run>External Tools>External Tools Configurations.  You are basically calling the program from eclipse.  Any output should then show up in the eclipse Console view.  External launch configs can also be turned into External Builders and attached to projects.\nIf you are looking to run your python script within your JVM then you need a implementation of python in java ... is that what you are looking for?","Q_Score":2,"Tags":"python,eclipse-plugin,eclipse-pde","A_Id":10856306,"CreationDate":"2012-05-19T13:55:00.000","Title":"Eclipse plugin that just runs a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using PyGObject but I think this is a question that could be adapted to all GTK, so if someone know how to do it using C or anything should work in python also.\nI have two treeview, Active and Inactive, I load data from a Sqlite database and I can swap and drag & drop items from one to other. \nThis is just an aestetic thing, if I click on one item on one treeview I want that a previous selected item on the other be deselected.\nIt appears that nobody had to do something similar because I didn't found anything about it on the net.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1990,"Q_Id":10681740,"Users Score":2,"Answer":"At the risk of being too basic (perhaps I misunderstand the problem), to manipulate treeview selections, you use the GtkTreeSelection object returned from GtkTreeView.get_selection.  You can attach to signals on this object, change the current selection,etc.","Q_Score":3,"Tags":"python,c,gtk,pygobject,gtktreeview","A_Id":10690046,"CreationDate":"2012-05-21T08:23:00.000","Title":"Gtk.Treeview deselect row via signals and code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am newbie in cryptography and pycrypto. \nI have modulus n and private exponent d. From what I understand after reading some docs private key consists of n and d. \nI need to sign a message and I can't figure out how to do that using pycrypto. RSA.construct() method accepts a tuple. But I have to additionally provide public exponent e to this method (which I don't have).\nSo here is my question. Do I have to compute e somehow in order to sign a message?\nIt seems I should be able to sign a message just by using n and d (that constitute private key). Am I correct? Can I do this with pycrypto?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":10098,"Q_Id":10689273,"Users Score":3,"Answer":"No, you can't compute e from d.\nRSA is symmetric in d and e: you can equally-well interchange the roles of the public and the private keys. Of course, we choose one specially to be private and reveal the other -- but theoretically they do the same thing. Naturally, since you can't deduce the private key from the public, you can't deduce the public key from the private either.\nOf course, if you have the private key that means that you generated the keypair, which means that you have the public key somewhere.","Q_Score":8,"Tags":"python,cryptography,rsa,pycrypto","A_Id":10689441,"CreationDate":"2012-05-21T16:49:00.000","Title":"I have modulus and private exponent. How to construct RSA private key and sign a message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am newbie in cryptography and pycrypto. \nI have modulus n and private exponent d. From what I understand after reading some docs private key consists of n and d. \nI need to sign a message and I can't figure out how to do that using pycrypto. RSA.construct() method accepts a tuple. But I have to additionally provide public exponent e to this method (which I don't have).\nSo here is my question. Do I have to compute e somehow in order to sign a message?\nIt seems I should be able to sign a message just by using n and d (that constitute private key). Am I correct? Can I do this with pycrypto?\nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":10098,"Q_Id":10689273,"Users Score":2,"Answer":"If you don't have the public exponent you may be able to guess it. Most of the time it's not a random prime but a static value. Try the values 65537 (hex 0x010001, the fourth number of Fermat), 3, 5, 7, 13 and 17 (in that order).\n[EDIT] Simply sign with the private key and verify with the public key to see if the public key is correct.\nNote: if it is the random prime it is as hard to find as the private exponent; which means you would be trying to break RSA - not likely for any key sizes > 512 bits.","Q_Score":8,"Tags":"python,cryptography,rsa,pycrypto","A_Id":10690482,"CreationDate":"2012-05-21T16:49:00.000","Title":"I have modulus and private exponent. How to construct RSA private key and sign a message?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've added a new queue to a python GAE app, and would like to add tasks to it, but always get an UnknownQueueError when I run my tests. On the other hand, I see the queue present in the GAE admin console (both local and remote). So the question is (1) do I miss something when I add a task to my queue? (2) if not, then how can I run custom queues in a test?\nHere is my queue.yaml\n\nqueue:\n- name: requests\n  rate: 20\/s\n  bucket_size: 100\n  retry_parameters:\n    task_age_limit: 60s\n\nand my python call is the following:\n\ntaskqueue.add(queue_name=\"requests\", url=reverse('queue_request', kwargs={\"ckey\":ckey}))\n\nany ideas?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":178,"Q_Id":10697651,"Users Score":1,"Answer":"If your are running a unitest and using init_taskqueue_stub() you need to pass the path of the queue.yaml when calling it using the root_path parameter.","Q_Score":1,"Tags":"python,google-app-engine","A_Id":10698246,"CreationDate":"2012-05-22T07:32:00.000","Title":"queues remain unknown or just don't know how to call them","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is really a newbie question, but I don't know how to search answers for this. I want to use pystache, and I am able to execute the .py file to print out some rendered output from .mustache file. but how exactly do I convert this into .html file? Specifically, how to put it on the server so that the browser would direct to the .html file like index.html?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":617,"Q_Id":10703616,"Users Score":3,"Answer":"Pystache is a template library not http server! If you want make webapp try to use ready-made webframeworks like Django or Pyramid.","Q_Score":1,"Tags":"python","A_Id":10703762,"CreationDate":"2012-05-22T14:00:00.000","Title":"Get started with pystache","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Lets say I have a few Ruby gems that I'd like to use from my Python (Django) application. I know this isn't the most straightforward question but let's assume that rewriting the Ruby gem in Python is a lot of work, how can I use it?\nShould I create an XML-RPC wrapper around it using Rails and call it? Is there something like a ruby implementation in Python within which I could run my gem code?\nAre there other methods that I may have missed? I've never tacked anything like this before I was a bit lost in this area.\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":333,"Q_Id":10735998,"Users Score":7,"Answer":"I suggest you either:\n\nExpose a ruby service using REST or XML-RPC.\n\nor \n\nShell out to a ruby script from Django.\n\nTo transfer data between Python and Ruby I suggest you use JSON, XML or plain text (depending on what kind of data you need to transfer).\nI would recommend to use option 2 (start a ruby script from the Python process), as this introduces fewer moving parts to the solution.","Q_Score":2,"Tags":"python,ruby-on-rails,ruby,django,interop","A_Id":10736225,"CreationDate":"2012-05-24T10:50:00.000","Title":"Using a Ruby gem from a Django application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Lets say I have a few Ruby gems that I'd like to use from my Python (Django) application. I know this isn't the most straightforward question but let's assume that rewriting the Ruby gem in Python is a lot of work, how can I use it?\nShould I create an XML-RPC wrapper around it using Rails and call it? Is there something like a ruby implementation in Python within which I could run my gem code?\nAre there other methods that I may have missed? I've never tacked anything like this before I was a bit lost in this area.\nThanks","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":333,"Q_Id":10735998,"Users Score":3,"Answer":"It depends a little on what you need to do. The XML-RPC suggestion has already been made. \nYou might actually be able to use them together in a JVM, assuming you can accept running Django with jython and use jruby. But that is a bit of work, which may or may not be worth the effort.\nIt would perhaps be easier if you described exactly what the Ruby gem is and what problem it is supposed to solve. You might get suggestions that could help you avoid the problem altogether.","Q_Score":2,"Tags":"python,ruby-on-rails,ruby,django,interop","A_Id":10737263,"CreationDate":"2012-05-24T10:50:00.000","Title":"Using a Ruby gem from a Django application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have this python script that outputs the Twitter Stream to my terminal console. Now here is the interesting thing:\n* On snowleopard I get all the data I want.\n* On Ubuntu (my pc) this data is limited and older data is deleted.\nBoth terminal consoles operate in Bash, so it has to be an OS thing presumably.\nMy question is: how do I turn this off? I want to leave my computer on for a week to capture around 1 or 2 gigabytes of data, for my bachelor thesis!","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":957,"Q_Id":10745363,"Users Score":2,"Answer":"I'd also avoid doing this with a terminal, but to answer the question directly:\n\nright click on the terminal window\nprofiles\nprofile preferences\nscolling\nscollback: unlimited\n\nIt's better though to redirect to a file, then access that file.  \"tail -f\" is very helpful.","Q_Score":1,"Tags":"python,linux,ubuntu,console,terminal","A_Id":10745449,"CreationDate":"2012-05-24T21:13:00.000","Title":"Ubuntu Linux: terminal limits the output when I get the full Twitter Streaming API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any eclipse plugin for python dependency management? just like what M2Eclipse does for maven project? so I can resolve all the dependencies and get ride off all the errors when I develop python using pydev.\nIf there is no such plugin, how do I resolve the dependencies, do I have to install the dependency modules locally?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":10754496,"Users Score":0,"Answer":"The only one so far I found available is PyFlakes, it does some level of dependency check and import validations.","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":10803047,"CreationDate":"2012-05-25T12:32:00.000","Title":"python eclipse dependency plugin - m2eclipse like","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have downloaded the omniORB4.1.6 pre-compiled with msvc10. I have python 2.7 and everything seems to work fine. I want to know how i can tell my omniidl to use my python 2.6 installation instead of 2.7. Can anyone help me? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":10760968,"Users Score":0,"Answer":"you can't and shouldn't.  it is compiled specifically for 2.7.  that's why \"2.7\" appears in the download file name.\nif you want to use a different python, download the source package and build it yourself.","Q_Score":0,"Tags":"python,python-2.7,omniorb","A_Id":10761033,"CreationDate":"2012-05-25T20:27:00.000","Title":"Changing python from 2.7 to 2.6 for omniidl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm following a python website for my schoolwork. It's really neat, it gives you tasks to complete and compiles the code in the browser. Anyway, I came to a challenge that I'm not really sure how to go about.\nOne of the questions was:\n\nThe same substring may occur several times inside the same string: for example \"assesses\" has the substring \"sses\" 2 times, and\n  \"trans-Panamanian banana\" has the substring \"an\" 6 times. Write a\n  program that takes two lines of input, we call the first needle and\n  the second haystack. Print the number of times that needle occurs as a\n  substring of haystack.\n\nI'm not too sure how I should start this, I know I have to compare the two strings but how? I used the count method, but it didn't recognize the second occurrence of sses in assesses.\nMy second question is one I solved but I cheated a little.\nThe question was:\n\nWrite a program that takes a single input line of the form \u00abnumber1\u00bb+\u00abnumber2\u00bb, where both of these represent positive integers,\n  and outputs the sum of the two numbers. For example on input 5+12 the\n  output should be 17.\n\nI used the eval() method and it worked, I just think that this wasn't what the grader had in mind for this.\nAny insight would be greatly appreciated.\nEDIT: Second question was solved.","AnswerCount":9,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4889,"Q_Id":10762199,"Users Score":0,"Answer":"the STRING.count method should work just fine for the first problem. If you look carefully, there actually aren't two non-overlapping 'sses' strings in assesses.\nYou either have a- sses -ses, or asse- sses. Do you see the issue? Calling \"trans-Panamanian banana\".count(\"an\") produces the correct number.\n\nI think using eval() is probably ok. Your other option is to split on the + and then iterate over the resulting list, doing type conversion and accumulation as you go. It sounds like your doing a string module, so that might be the better solution for your gpa ;).\n\n\nEDIT: F.G. beat me to posting essentially the same answer by mere seconds. Gah!","Q_Score":3,"Tags":"python","A_Id":10762273,"CreationDate":"2012-05-25T22:53:00.000","Title":"Substring Counting in Python and Adding 2 Numbers From One Line of Input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"hi i am having trouble in running python IDLE.\nonce i have installed EMACS and uninstalled it, whenever i try to run python IDLE it gives me:\nWarning: os.path.expanduser(\"~\") points to\nC:\\Program Files\\Emacs\\,\nbut the path does not exist\nthe IDLE does work, but i can't launch IDLE by simply clicking on \"open with IDLE\".\ni guess i need to change the path of os.path.expanduser to fix this error?\nbut i can't find it.\nwhere should i look for and which path does it originally point?\nthank you.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":858,"Q_Id":10764025,"Users Score":2,"Answer":"According to the doc, \n\nOn Windows, HOME and USERPROFILE will be used if set, otherwise a\n  combination of HOMEPATH and HOMEDRIVE will be used. An initial ~user\n  is handled by stripping the last directory component from the created\n  user path derived above.\n\nYou can try run 'set' in command prompt to see if these two environment variables are set or not. If yes, remove the setting.","Q_Score":1,"Tags":"python,python-idle","A_Id":10764052,"CreationDate":"2012-05-26T06:03:00.000","Title":"how do i change the value of os.path.expanduser(\"~\") in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"Node.js is a perfect match for our web project, but there are few computational tasks for which we would prefer Python. We also already have a Python code for them.\nWe are highly concerned about speed, what is the most elegant way how to call a Python \"worker\" from node.js in an asynchronous non-blocking way?","AnswerCount":7,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":116462,"Q_Id":10775351,"Users Score":7,"Answer":"If you arrange to have your Python worker in a separate process (either long-running server-type process or a spawned child on demand), your communication with it will be asynchronous on the node.js side. UNIX\/TCP sockets and stdin\/out\/err communication are inherently async in node.","Q_Score":134,"Tags":"python,node.js,ipc","A_Id":10775437,"CreationDate":"2012-05-27T16:03:00.000","Title":"Combining node.js and Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have python 2.7 by default and 2.6 but I need some modules installed on python 2.6 .But by default it is installing on 2.7.Any idea how to do it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":10780165,"Users Score":1,"Answer":"If you explicitly call your Python 2.6 Binary when installing the package it will install to that instance instead.  So instead of python setup.py install you would do \/path\/to\/python26 setup.py install.","Q_Score":1,"Tags":"python","A_Id":10780293,"CreationDate":"2012-05-28T06:22:00.000","Title":"how to install library modules on python version which is not default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using fedora and wxpython version 2.8.12 .While trying to import wx.lib.agw.persist\nI am getting an error saying \nImport Error: No module persist.\nWill the module not be there by default with wxPython, if not how do I get this module installed? please help me.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":58,"Q_Id":10780523,"Users Score":2,"Answer":"wx.lib.agw.persist is new in 2.8.12.1.","Q_Score":1,"Tags":"python,wxpython","A_Id":10780744,"CreationDate":"2012-05-28T06:53:00.000","Title":"Error importing persist module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on a telescope project and we are testing the CCD.  Whenever we take pictures things are slightly pink-tinted and we need true color to correctly image galactic objects.  I am planning on writing a small program in python or java to change the color weights but how can I access the weight of the color in a raw data file (it is rgb.bin)?\nWe are using a bayer matrix algorithm to convert monochromatic files to color files and I would imagine the problem is coming from there but I would like to fix it with a small color correcting program.\nThanks!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1116,"Q_Id":10805356,"Users Score":3,"Answer":"Typical white-balance issues are caused by differing proportions of red, green, and blue in the makeup of the light illuminating a scene, or differences in the sensitivities of the sensors to those colors. These errors are generally linear, so you correct for them by multiplying by the inverse of the error.\nSuppose you measure a point you expect to be perfectly white, and its RGB values are (248,237,236) i.e. pink. If you multiply each pixel in the image by (248\/248,248\/237,248\/236) you will end up with the correct balance.\nYou should definitely ensure that your Bayer filter is producing the proper results first, or the base assumption of linear errors will be incorrect.","Q_Score":1,"Tags":"java,python,image-processing,rgb","A_Id":10807433,"CreationDate":"2012-05-29T19:22:00.000","Title":"Change color weight of raw image file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Ruby on Rails project,  using Python + Scrapy to scrape the web, and I would like to distribute and deploy the Rails project with all Python executables and libraries installed automatically.\nThe deployment environment ships by default a Python version lower than 2.6, and I would like users not to depend on OS and installed Python executable.\nSo, basically I want to achieve a Python virtualenv inside my Rails project.\nAny ideas on how do that?\nI use Capistrano for deploying my Rails project.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":10816962,"Users Score":1,"Answer":"Are all your (DTAP) environments using the same operating system and processor architecture?\nIf not, I wouldn't recommend shipping the Python interpreter with your project. Why don't you compile a more recent version of Python on your environments and install it in some non-standard path, like \/opt\/python27\/ (or similiar).\nThen, just create a virtualenv on all environments using that interpreter.\nNext, you deploy your project from your virtualenv (without the bin, include, etc.) to the virtualenv of the target environment.\nI've never used Capistrano (Python dev myself), but I'm assuming it can just copy over directories from one environment (or VCS) to the other.","Q_Score":0,"Tags":"python,ruby-on-rails,ruby,deployment,scrapy","A_Id":10817852,"CreationDate":"2012-05-30T13:09:00.000","Title":"Setting up a Python environment in a Rails project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am encrypting a file using python-gnupg and it looks like encrypt_file onlys accepts a single key for the sign parameter.  If I have a key file with multiple keys that I want to encrypt the document with, how can I do this?  If I understand correctly I should be able to encrypt a file using multiple keys.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1486,"Q_Id":10821741,"Users Score":0,"Answer":"Having re-read your question again after reading the python-gnupg documentation, I think you're asking about signing a document with several private keys at the same time you are encrypting it.\nUnfortunately, that process is not supported by python-gnupg, because GnuPG does not support it either. You'll have to decide how exactly you want your signatures to be applied, then do them one at a time.\nYou can, for instance layer the signatures, by encrypting and signing with one key, then signing the results with another private key (and repeating for any additional keys you have beyond the second).\nAlternatively, you could create several \"detached\" signatures, each of just the base document (so no signatures would be applied to other signatures). This is a bit more complicated, as I'm not sure that there's any file format that will automatically be recognized by GnuPG to verify several detached signatures at once.","Q_Score":0,"Tags":"python,gnupg","A_Id":10824962,"CreationDate":"2012-05-30T18:00:00.000","Title":"Encrypt a file in python-gnupg using multiple keys","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to using pygame and I was wondering if someone could explain the use of alpha values?  I don't quite understand the difference between that and colorkey.\nFor my current situation I think I want to use alpha values but am not quite clear how.  \nIn my game I have two sprites with .png files loaded to each surface.  Upon collision I would like both images to disappear (go completely transparent).\nI would really appreciate it if someone could explain the basics of alpha value and how to specifically use them in pygame and if it is possible to use these alpha values to solve my problem.\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":399,"Q_Id":10823285,"Users Score":3,"Answer":"Colorkey lets you pick one color in a sprite (surface); any pixel of that color will be completely transparent. (If you remember .gif transparency, it's the same idea.)\n'alpha' is a measure of opacity - 0 for completely transparent, 255 for completely opaque - and can be applied to an entire sprite (as an alpha plane) or per pixel (slower, but gives much more control).\nTo make the sprites disappear, I would just set them to non-visible, rather than playing around with alpha values.","Q_Score":1,"Tags":"python,pygame","A_Id":10823436,"CreationDate":"2012-05-30T19:52:00.000","Title":"Pygame alpha values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to using pygame and I was wondering if someone could explain the use of alpha values?  I don't quite understand the difference between that and colorkey.\nFor my current situation I think I want to use alpha values but am not quite clear how.  \nIn my game I have two sprites with .png files loaded to each surface.  Upon collision I would like both images to disappear (go completely transparent).\nI would really appreciate it if someone could explain the basics of alpha value and how to specifically use them in pygame and if it is possible to use these alpha values to solve my problem.\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":10823285,"Users Score":0,"Answer":"Although if you want the sprites to fade until they've vanished, gradually reduce the alpha value after they've collided. When alpha reaches 0, use   del sprite   if you don't need the sprites anymore.","Q_Score":1,"Tags":"python,pygame","A_Id":51940966,"CreationDate":"2012-05-30T19:52:00.000","Title":"Pygame alpha values","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the Image.save method from PIL and I cannot find where the file is being placed.  I have done a system search yet still no luck.\nMy code looks like this:\n    print imageObj.save(fileName, \"JPEG\")\nand gives the proper None response to say that it is working.  Any idea where they go and how I can find them?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1490,"Q_Id":10824951,"Users Score":1,"Answer":"You should pick a location to save the image when setting the filename variable. \nfilename = \"\/Users\/clifgray\/Desktop\/filename.jpeg\"\nimgObj.save(filename)","Q_Score":0,"Tags":"python,image,image-processing,python-imaging-library","A_Id":10825016,"CreationDate":"2012-05-30T22:08:00.000","Title":"Where does Python Imaging LIbrary Save Objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From someone who has a django application in a non-trivial production environment, how do you handle database migrations? I know there is south, but it seems like that would miss quite a lot if anything substantial is involved. \nThe other two options (that I can think of or have used) is doing the changes on a test database and then (going offline with the app) and importing that sql export. Or, perhaps a riskier option, doing the necessary changes on the production database in real-time, and if anything goes wrong reverting to the back-up.\nHow do you usually handle your database migrations and schema changes?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":11397,"Q_Id":10826266,"Users Score":1,"Answer":"South isnt used everywhere. Like in my orgainzation we have 3 levels of code testing. One is local dev environment, one is staging dev enviroment, and third is that of a production . \nLocal Dev is on the developers hands where he can play according to his needs. Then comes staging dev which is kept identical to production, ofcourse, until a db change has to be done on the live site, where we do the db changes on staging first, and check if everything is working fine and then we manually change the production db making it identical to staging again.","Q_Score":22,"Tags":"python,mysql,django,migration,django-south","A_Id":10872504,"CreationDate":"2012-05-31T01:12:00.000","Title":"Database migrations on django production","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From someone who has a django application in a non-trivial production environment, how do you handle database migrations? I know there is south, but it seems like that would miss quite a lot if anything substantial is involved. \nThe other two options (that I can think of or have used) is doing the changes on a test database and then (going offline with the app) and importing that sql export. Or, perhaps a riskier option, doing the necessary changes on the production database in real-time, and if anything goes wrong reverting to the back-up.\nHow do you usually handle your database migrations and schema changes?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":11397,"Q_Id":10826266,"Users Score":0,"Answer":"If its not trivial, you should have pre-prod database\/ app that mimic the production one. To avoid downtime on production.","Q_Score":22,"Tags":"python,mysql,django,migration,django-south","A_Id":70559647,"CreationDate":"2012-05-31T01:12:00.000","Title":"Database migrations on django production","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to migrate data from an old Tomcat\/Jetty website to a new one which runs on Python & Django. Ideally I would like to populate the new website by directly reading the data from the old database and storing them in the new one.\nProblem is that the database I was given comes in the form of a bunch of WEB-INF\/data\/*.dbx and I didn't find any way to read them. So, I have a few questions.\n\nWhich format do the WEB-INF\/data\/*.dbx use?\nIs there a python module for directly reading from the WEB-INF\/data\/*.dbx files?\nIs there some external tool for dumpint the WEB-INF\/data\/*.dbx to an ascii format that will be parsable by python?\nIf someone has attempted a similar data migration, how does it compare against scraping the data from the old website? (assuming that all important data can be scraped)\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":126,"Q_Id":10830829,"Users Score":0,"Answer":"The \".dbx\" suffix has been used by various softwares over the years so it could be almost anything. The only way to know what you really have here is to browse the source code of the legacy java app (or the relevant doc or ask the author etc).\nwrt\/ scraping, it's probably going to be a lot of a pain for not much results, depending on the app.","Q_Score":0,"Tags":"python,tomcat,jetty,data-migration,web-inf","A_Id":10833110,"CreationDate":"2012-05-31T09:25:00.000","Title":"migrating data from tomcat .dbx files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With wxPython a password field could be created as:  \nwx.TextCtrl(frm, -1, '', style=wx.TE_PASSWORD )\nI'm wondering if there is a way to dynamically change this password field into a normal textctrl, such that user could see what the password is.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":5172,"Q_Id":10836062,"Users Score":3,"Answer":"I'm not aware of a way to dynamically change the style flags on the text control widget after creation. Some widgets allow this sort of thing on some OSes and some do not. You could just create two text controls with the second one in normal mode and hide it. Then when you want to toggle, you grab the password-protected version's value and hide it, give the value to the normal one and show it. You'll probably need to call Layout() at the end as well.","Q_Score":4,"Tags":"python,user-interface,wxpython","A_Id":10837325,"CreationDate":"2012-05-31T14:56:00.000","Title":"how to make wxpython password textctrl show chars?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"With wxPython a password field could be created as:  \nwx.TextCtrl(frm, -1, '', style=wx.TE_PASSWORD )\nI'm wondering if there is a way to dynamically change this password field into a normal textctrl, such that user could see what the password is.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":5172,"Q_Id":10836062,"Users Score":-1,"Answer":"then it would not be a password entry, but you can use style=wx.TE_MULTILINE or TE_RICH. if that is what you are asking.\nHope this helps","Q_Score":4,"Tags":"python,user-interface,wxpython","A_Id":10836512,"CreationDate":"2012-05-31T14:56:00.000","Title":"how to make wxpython password textctrl show chars?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"My simple question is how can I use pygame.MOUSEBUTTONDOWN on a sprite or item to trigger an event?\ne.g. I have item_A and want music to start when I press the object with my mouse.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18074,"Q_Id":10838959,"Users Score":0,"Answer":"You will need to poll for events in your main loop, and when you detect a MOUSEBUTTONDOWN event you will need to check if it's on the sprite you want, and if it is then start the music.","Q_Score":2,"Tags":"python,pygame,mouseevent,mouse","A_Id":10839038,"CreationDate":"2012-05-31T18:12:00.000","Title":"How to use pygame.MOUSEBUTTONDOWN?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a small gallery app and after extensive testing i submitted a 3mb image.\nBasically the gallery app relies on another app that creates an UploadedFile instance for every image, however i see that for this specific image it has created 4 instances ( rows in db ) that belong to the same 3mb image, each image has \"blob\" at the end of its name.\nMy question is, how can i handle an image as big as this and be able to refer to the whole image ? in a html tag or django templatetag like sorl-thumbnail's ?\nIm using python 2.7.2, Django 1.3.1 and MySQL 5.1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":10859714,"Users Score":0,"Answer":"It seems like the issue was the Jquery plugin that i was using to upload multiple files. The plugin was the one who split the file into chunks which were then sent individually as POST requests, and django didn't know that blob1, blob2, blob3, blob4 where the same file in chunks.","Q_Score":0,"Tags":"python,django,blob,sorl-thumbnail","A_Id":10971247,"CreationDate":"2012-06-02T04:10:00.000","Title":"Django Handle big files ( imageblob )","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I guess it's socket programming. But I have never done socket programming expect for running the tutorial examples while learning Python. I need some more ideas to implement this.\nWhat I specifically need is to run a monitoring program of a server which will poll or listen to traffic being exchange from different IPs across different popular ports. For example, how do I get data received and sent through port 80 of 192.168.1.10 and 192.168.1.1 ( which is the gateway).\nI checked out a number of ready made tools like MRTG, Bwmon, Ntop etc but since we are looking at doing some specific pattern studies, we need to do data capturing within the program.\nIdea is to monitor some popular ports and do a study of network traffic across some periods and compare them with some other data.\nWe would like to figure a way to do all this with Python....","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2642,"Q_Id":10871752,"Users Score":0,"Answer":"IPTraf is an ncurses based IP LAN monitoring tool. Has a capability to generate network statistics including TCP,UDP,ICMP and some more.\nSince you're thinking to execute it from python, you may consider to use screen (screen manager with VT100\/ANSI terminal emulation) to overcome ncurses issues and you may want to pass logging and interval parameters to IPTraf which forces iptraf to log to a file in a given interval. Little bit tricky but eventually you can have what you are looking for by basically parsing the log file.","Q_Score":1,"Tags":"python,sockets,network-traffic,traffic-measurement","A_Id":10872601,"CreationDate":"2012-06-03T15:53:00.000","Title":"Python: how to calculate data received and send between two ipaddresses and ports","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im developing an installer for a GNU\/Linux distribution in Python using Eclipse+PyDev. For some tasks on it there is needed that the program runs with root priviledges, but I run Eclipse as a common user.\nI had searched a lot of stuff on the Internet about how to run an app as root without having to run Eclipse with priviledges, but no a single clue of how to accomplish this in a \"nice way\". So I tried with the \"gksu2\" python module, with has the gksu2.sudo() functions in the same way as gksu in bash. \nI created a new module, imported gksu2 and executed the main.py module of the app, but I got a \"ImportError: No module named ui.regular_ui.wizard\". It runs ok without gksu2 in eclipse, but it doesn't if I use it. I thought it was an environment variables problem, but the sys.path is ok.\nThe same error happens if I run the app from a terminal, outside of Eclipse. What do you think?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":10874949,"Users Score":0,"Answer":"It seems like your PYTHONPATH is different outside\/inside Eclipse. Try just removing the Python interpreter and adding it again to gather new paths -- if that's not enough, do: import sys;print('\\n'.join(sorted(sys.path))) outside\/inside Eclipse to know what's different and fix your paths inside Eclipse.","Q_Score":1,"Tags":"python,eclipse,import,root","A_Id":10995927,"CreationDate":"2012-06-03T23:59:00.000","Title":"import error in eclipse, running an app as root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Background\nI have a Django application, it works and responds pretty well on low load, but on high load like 100 users\/sec, it consumes 100% CPU and then due to lack of CPU slows down.\nProblem:\n\nProfiling the application gives me time taken by functions.\nThis time increases on high load.\nTime consumed may be due to complex calculation or for waiting for CPU.\n\nSo, how to find the CPU cycles consumed by a piece of code ?\nSince reducing the CPU consumption will increase the response time.\n\nI might have written extremely efficient code and need to add more CPU power \n\nOR\n\nI might have some stupid code taking the CPU and causing the slow down ?\n\nUpdate\n\nI am using Jmeter to profile my web app, it gives me a throughput of 2 requests\/sec. [ 100 users]\nI get a average time of 36 seconds on 100 request vs 1.25 sec time on 1 request.\n\nMore Info\n\nConfiguration Nginx + Uwsgi with 4 workers\nNo database used, using a responses from a REST API\nOn 1st hit the response of REST API gets cached, therefore doesn't makes a difference.\nUsing ujson for json parsing.\n\nCurious to know:\n\nPython-Django is used by so many orgs for so many big sites, then there must be some high end Debug \/ Memory-CPU analysis tools.\nAll those I found were casual snippets of code that perform profiling.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1360,"Q_Id":10877048,"Users Score":2,"Answer":"You could try configuring your test to ramp up slowly, slow enough so that you can see the CPU gradually increase and then run the profiler before you hit high CPU. There's no point trying to profile code when the CPU is maxed out because at this point everything will be slow. In fact, you really only need a relatively light load to get useful data from a profiler.\nAlso, by gradually increasing the load you will be better able to see if there is a gradual increase in CPU (suggesting a CPU bottleneck) or if there is a sudden jump in CPU (suggesting perhaps another type of problem, one that would not necessarily be addressed by more CPU).\nTry using something like a Cosntant Throughput Timer to pace the requests, this will prevent JMeter getting carried away and over-loading the system.","Q_Score":6,"Tags":"python,django,performance,profiling,stress-testing","A_Id":10906462,"CreationDate":"2012-06-04T06:16:00.000","Title":"How do you find the CPU consumption for a piece of Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"(Warning: Potential flame-war starter. This is however not my goal, the point here is not to discuss the design choices of Python, but to know how to make the best out of it).\nIs there a program, script, method (Unix-based, ideally), to display \"virtual\" brackets around blocs of code in Python, and to keep them where they are so that the code can still be executed even if indenting is broken ?\nI realize that Python only uses indentation to define blocks of code, and that the final program may not contain brackets.\nHowever, I find it very annoying that your program can stop functioning just because of an unfortunate and undetected carriage-return.\nSo, ideally I would be looking for a plugin in a text editor (kate, gedit...) that would:\n\nDisplay virtual brackets around blocks of code in my Python program\nKeep them in place\nGenerate dynamically the \"correct\" Python code with the indentation corresponding to where the brackets belong.\n\n(no flame-war, please !)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":262,"Q_Id":10897239,"Users Score":1,"Answer":"I used an editor that does code rollups and understood Python syntax, then I looked for rollups that are in unexpected locations.  I don't remember if Kate does that.  It's not obvious that there is an issue, but it makes it easier when you are looking for an issue.","Q_Score":6,"Tags":"python,linux","A_Id":10897423,"CreationDate":"2012-06-05T12:23:00.000","Title":"Virtual brackets in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Every Monday at Work, I have the task of printing out Account analysis (portfolio analysis) and Account Positions for over 50 accounts. So i go to the page, click \"account analysis\", enter the account name, click \"format this page for printing\", Print the output (excluding company disclosures), then I go back to the account analysis page and click \"positions\" instead this time, the positions for that account comes up. Then I  click \"format this page for printing\", Print the output (excluding company disclosures).Then I repeat the process for the other 50 accounts.\nI haven't taken any programming classes in the past but I heard using python to automate a html response might help me do this faster. I was wondering if that's true, and if so, how does it work? Also, are there any other programs that could enable me automate this process and save time? \nThank you so much","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":773,"Q_Id":10899192,"Users Score":0,"Answer":"I think it will be easier for you get program like autoit.","Q_Score":2,"Tags":"javascript,python,html,automation","A_Id":10899256,"CreationDate":"2012-06-05T14:26:00.000","Title":"Automating HTTP navigation and HTML printing using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Newbie question I am finding it hard to get my head around.\nIf I wanted to use one of the many tool out their like rsync lsync or s3cmd how can you build these into a program for none computer savvy people to use.\nIe I am comfortable opening terminal and running s3cmd which Is developed in python how would I go about developing this as a dmg file for mac or exe file for windows?\nSo a user could just install the dmg or exe then they have s3cmd lsync or rsync on their computer.\nI can open up eclipse code a simple app in java and then export as a dmg or exe I cannot figure out how you do this for other languages say write a simple piece of code that I cam save as a dmg or exe and that after installed will add a folder to my desktop or something simple like that to get me started?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1925,"Q_Id":10906198,"Users Score":0,"Answer":"If you mean specifically with Python, as I gather from tagging that in your question, it won't simply run the same way as Java will, because there's no equivalent Virtual Machine.\nIf the user has a Python interpreter on their system, they they can simply run the .py file.\nIf they do not, you can bundle the interpreter and needed libraries into an executable using Py2Exe, cxFreeze, or bbFreeze.  For replacing a dmg, App2Exe does something similar.\nHowever. the three commands you listed are not python-related, and rely on functionality that is not necessarily available on Windows or Mac, so it might not be as possible.","Q_Score":0,"Tags":"python,exe,dmg","A_Id":10906453,"CreationDate":"2012-06-05T23:01:00.000","Title":"Compiling and running code as dmg or exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking to implement an item-based news recommendation system. There are several ways I want to track a user's interest in a news item; they include: rating (1-5), favorite, click-through, and time spent on news item.\nMy question: what are some good methods to use these different metrics for the recommendation system? Maybe merge and normalize them in some way?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":614,"Q_Id":10920199,"Users Score":0,"Answer":"Recommender systems in the land of research generally work on a scale of 1 - 5. It's quite nice to get such an explicit signal from a user. However I'd imagine the reality is that most users of your system would never actually give a rating, in which case you have nothing to work with. \nTherefore I'd track page views but also try and incorporate some explicit feedback mechanism (1-5, thumbs up or down etc.)\nYour algorithm will have to take this into consideration.","Q_Score":0,"Tags":"python,metrics,recommendation-engine,personalization,cosine-similarity","A_Id":10955138,"CreationDate":"2012-06-06T18:43:00.000","Title":"Recommendation system - using different metrics","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking to implement an item-based news recommendation system. There are several ways I want to track a user's interest in a news item; they include: rating (1-5), favorite, click-through, and time spent on news item.\nMy question: what are some good methods to use these different metrics for the recommendation system? Maybe merge and normalize them in some way?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":614,"Q_Id":10920199,"Users Score":0,"Answer":"For recommendation system, there are two problems:\n\nhow to quantify the user's interest in a certain item based on the numbers you collected\nhow to use the quantified interest data to recommend new items to the user\n\nI guess you are more interested in the first problem.\nTo solve the first problem, you need either linear combination or some other fancy functions to combine all the numbers. There is really no a single universal function for all systems. It heavily depends on the type of your users and your items. If you want a high quality recommandation system, you need to have some data to do machine learning to train your functions.\nFor the second problem, it's somehow the same thing, plus you need to analyze all the items to abstract some relationships between each other. You can google \"Netflix prize\" for some interesting info.","Q_Score":0,"Tags":"python,metrics,recommendation-engine,personalization,cosine-similarity","A_Id":10956591,"CreationDate":"2012-06-06T18:43:00.000","Title":"Recommendation system - using different metrics","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to PyQt and I have to work on an application which use it. For the moment, I don't have any problem, but I'm stuck on something. I have to create a \"ComboBox with its items checkable, like a CheckBox\". This ComboBox should contain many image format, like \"jpg\", \"exr\" or \"tga\", and I will have to pick up the text of the checked option and put it in a variable. The problem is that I can't find a thing about making items checkable using a ComboBox (if you know how to, It would gladly help me !)\nSince I can't do it with a ComboBox, maybe I can do it with a QList I thought, but I can't find anything either which is understandable for a beginner like me. I have read stuff about flags and \"Qt.ItemIsUserCheckable\" but I don't know how to use it in a easy way :(\nCan you help me ? Thanks !\nPyQt version : 4.4.3\nPython version : 2.6","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1527,"Q_Id":10929285,"Users Score":0,"Answer":"You can do this using the model->view framework, but it means implementing a custom model to support checkable data.\nYou create a custom model by subclassing QAbstractItemModel. This presents an API to the QComboBox for accessing the underlying data. Off the top of my head I think you'll need to implement the flags method to indicate that you support ItemIsUserCheckable for the indexes you want to be able to check. You'll also need to implement data() which reports back the data state from your underlying data, and setData() which accept input from the QComboBox and changes the underlying data.\nYou then set this as the model for the QComboBox using setModel().\nThis isn't really beginner stuff, but the model->view framework in Qt is one of it's most important and valuable features and well worth getting to grips with.","Q_Score":0,"Tags":"python,qt,checkbox,combobox,pyqt","A_Id":10930835,"CreationDate":"2012-06-07T09:39:00.000","Title":"How to simply create a list of CheckBox which has a dropdown list like a ComboBox with PyQt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a desktop application that send POST requests to a server where a django app store the results. DB server and web server are not on the same machine and it happens that sometimes the connectivity is lost for a very short time but results in a connection error on some requests:\n\nOperationalError: (2003, \"Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (110)\")\n\nOn a \"normal\" website I guess you'd not worry too much: the browser display a 500 error page and the visitor tries again later. \nIn my case loosing info posted by a request is not an option and I am wondering how to handle this? I'd try to catch on this exception, wait for the connectivity to come back (lag is not a problem) and then continue the process. But as the exception can occur about anywhere in the code I'm a bit stuck on how to proceed.\nThanks for your advice.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2536,"Q_Id":10930459,"Users Score":1,"Answer":"You could use a middleware with a process_view method and a try \/ except wrapping your call. \nOr you could decorate your views and wrap the call there.\nOr you could use class based views with a base class that has a method decorator on its dispatch method, or an overriden.dispatch.\nReally, you have plenty of solutions.\nNow, as said above, you might want to modify your Desktop application too!","Q_Score":1,"Tags":"python,mysql,django","A_Id":10935789,"CreationDate":"2012-06-07T11:00:00.000","Title":"Django: how to properly handle a database connection error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am a data scientist and database veteran but a total rookie in web development and have just finished developing my first Ruby On Rails app. This app accepts data from users submitting data to my frontend webpage and returns stats on the data submitted. Some users have been submitting way too much data - its getting slow and I think I better push the data crunching to a backed python or java app, not a database. I don't even know where to start. Any ideas on how to best architect this application? The job flow is > data being submitted from the fronted app which pushes it to the > backend for my server app to process and > send back to my Ruby on Rails page. Any good tutorials that cover this? Please help!\nWhat should I be reading up on?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":694,"Q_Id":10956683,"Users Score":0,"Answer":"Are you sure your database is well maintained and efficient (good indexes, normalised, clean etc)\nOr can you not make use of messaging queues, so you keep your rails crud app, then the jobs are just added to a queue. Python scripts on the backend (or different machine) read from the queue, process then insert back into the database or add results to a results queue or whereever you want to read them from","Q_Score":0,"Tags":"python,ruby-on-rails,server-side","A_Id":33303096,"CreationDate":"2012-06-08T22:21:00.000","Title":"Ruby on Rails frontend and server side processing in Python or Java.. HOW, What, Huh?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a function that takes as parameters 2 objects: a and b\nThe function checks (with a very long algorithm) which one of these objects is better.\nIf a is better it returns -1, if b is better it returns 1, if they tied it returns 0\nMy problem is:\nI have 21 of these objects in a list.\nI need to find out, using the function above (the function cannot be\nchanged, the only way is to compare 2 objects, it's a very complicated\nand long algorithm), which one of these 21 objects is the best.\nI tried thinking for hours how to do it efficiently without doing the same comparison too many times, how to write an algorithm that will find out which one is the best (and if two of them are tied and they both are the best, it doesn't matter which one to take, though I don't think it's even possible for a tie to happen), and I couldn't come up with anything good.\nThe function's name is handCompare(a, b)\nThe objects are found in a list called Combos, len(combos) is 21\nI need an algorithm that will find out the best item in the combos list\nThanks for reading and I hope you can help :)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":103,"Q_Id":10957467,"Users Score":1,"Answer":"The most straightforward way: Create an object of each one, with your comparison function as __cmp__ (python 2.x) or define __lt__ and __eq__ (python 3.x).  Stash each one in a list named list_.  Find the least valued one using min(list_).\nAn optimization that might help, if practical: If you can come up with a way of mapping your objects to (possibly large) integers, such that the integer for x is < the integer for y, iff the original object ox is < the original object oy, and then take a min of the integers.  This should speed things up slightly, if it's workable for your types.","Q_Score":1,"Tags":"python,list,comparison","A_Id":10957519,"CreationDate":"2012-06-09T00:34:00.000","Title":"Python, using a comparison function for finding the best object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm going to make a kind of remover that erase files never recoverable.\nI don't know the algorithm but I think it is possible to get exact file memory address and\nwrite something like 'null' at there. So I'm searching at os module and others,\nbut don't know how to do that...Is there a function or the otherway?\nOr what I have to do is just read the file binarymode and override it null?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":10960672,"Users Score":4,"Answer":"Unless you entirely control the system, I think you'd be better off abandoning this particular pursuit.  Modern filesystems or mediums (e.g. SSD wear-leveling) can result in data being retained physically on-disk even if you overwrite them in-place.\nBest practice in my book is to fill the disk with random data, then exclusively use whole-disk encryption.","Q_Score":0,"Tags":"python","A_Id":10960826,"CreationDate":"2012-06-09T11:39:00.000","Title":"How can I get the exact memory address on HDD of an file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using PyGtk's IconView, I can set the icons to be reorderable by calling gtk.IconView.set_reorderable(True).  My question is what is the best way to retrieve the new order?  That is, how should I access a property of each of the elements in the new order?  An iterator of sorts?\nI am using gtk.ListStore to store the data.\nI know this might sound trivial but I have virtually no experience in Python or PyGtk (or GTK in general) so I'd like to know the right way!  Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":135,"Q_Id":10972821,"Users Score":0,"Answer":"So, I understand now: it turns out that when items are reordered in IconView, gtk.ListStore.reorder or something similar is called.  What that means is that all I needed to do was to use gtk.ListStore.get_iter() or gtk.ListStore.get_iter_first() and all the problems are solved.\nHow trivial!  All I needed to do was eat over it it seems.","Q_Score":0,"Tags":"python,pygtk","A_Id":10973513,"CreationDate":"2012-06-10T22:25:00.000","Title":"Reordering in IconView (PyGtk)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am testing several different algorithms (for solving 16x16 sudokus)\nagainst each other, measuring their performance using the timeit module. \nHowever, it appears that only the first of the timeit.repeat() iterations is \nactually calculated, because the other iterations are gotten much faster. \nTesting a single algorithm with t.repeat(repeat=10, number=1) the following \nresults are gotten:\n[+] Results for......: solve1 (function 1\/1)\n[+] Fastest..........: 0.00003099\n[+] Slowest..........: 32.38717794\n[+] Average*.........: 0.00003335 (avg. calculated w\/o min\/max values)\nThe first out of 10 results always takes an much larger time to complete, \nwhich seems to be explainable only by the fact that iterations 2 to 10 of the \ntimeit.repeat() loop somehow use the cached results of the loop's previous \niterations. When actually using timeit.repeat() in a for loop to compare \nseveral algorithms against each other, again it appears that the solution\nto the puzzle is calculated only once:\n[+] Results for......: solve1 (function 1\/3)\n[+] Fastest..........: 0.00003099\n[+] Slowest..........: 16.33443809\n[+] Average*.........: 0.00003263 (avg. calculated w\/o min\/max values)\n[+] Results for......: solve2 (function 2\/3)\n[+] Fastest..........: 0.00365305\n[+] Slowest..........: 0.02915907\n[+] Average*.........: 0.00647599 (avg. calculated w\/o min\/max values)\n[+] Results for......: solve3 (function 3\/3)\n[+] Fastest..........: 0.00659299\n[+] Slowest..........: 0.02440906\n[+] Average*.........: 0.00717765 (avg. calculated w\/o min\/max values)\nThe really weird thing is that relative speed (in relation to each other) \nof the algorithms is consistent throughout measurements, which would indicate \nthat all algorithms are calculating their own results. Is this extreme increase in performance due to the fact that a large part of the intermediate results (gotten \nwhen computing the first solution) are still in some sort of cache, reserved by the \npython proces? \nAny help\/insights would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1635,"Q_Id":10994405,"Users Score":2,"Answer":"I think the memory allocation is the problem.\nthe python interpreter itself holds a memory pool, which starts with no (or little?) memory pooling. after the first run of your program, much memory is allocated (from the system) and free (to the pool), and then the following runs get memory from the pool, which is much faster than asking memory from system.\nbut this makes sense only if your algorithm will consume much memory.","Q_Score":1,"Tags":"python,caching,timeit","A_Id":10994548,"CreationDate":"2012-06-12T10:04:00.000","Title":"Python timeit: results cached instead of calculated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to implement a network protocol that listens on 2 separate TCP ports. One is for control messages and one is for data messages.\nI understand that I need two separate protocol classes since there are two ports involved.\nI would like to have one factory that creates both of these protocols since there is state information and data that is shared between them and they essential implement one protocol.\nIs this possible? If yes, how? \nIf not, how can I achieve something similar?\nI understand that it is unusal to divide a protocol between 2 ports but that is the given situation.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":10999627,"Users Score":0,"Answer":"Your factory's buildProtocol can return anything you want it to return.  That's up to you.\nHowever, you might find that things are a lot simpler if you just use two different factories.  That does not preclude sharing state.  Just have them share a bunch of attributes, or collect all your state together onto a single new object and have the factories share that object.","Q_Score":0,"Tags":"python,twisted","A_Id":11001717,"CreationDate":"2012-06-12T15:14:00.000","Title":"A single factory for multiple protocols?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python and have been studying its fundementals for 3 months now, learning types, functions and algorithms. Now I started practiciging web app development with GAE framework.\nGoal: have a very large dictionary, which can be accessed from all .py files throughout the web app without having it stored more than once or re-created each time when someone visits a URL of the app.\nI want to render a simple DB table to a dictionary, with hopes of speed gain as it will be in memory.\nAlso I am planing on creating an in memory DAWG - TRIE\nI don't want this dictionary to be created each time a page is called, I want it to be stored in memory once, kept there and used and accessed by all sessions and if possible modified too.\nHow can I achieve this? Like a simple in memory DB but actually a Python dictionary?\nThank you.","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":576,"Q_Id":11013911,"Users Score":-2,"Answer":"This is impossible (without an external service). DBs are made for this to store data longer than one request. What you could do is to safe the dict \"in\" the users session, but I don't recommend that. Unless you have millions of entries every DB is fast enough even sqlite.","Q_Score":3,"Tags":"python,google-app-engine,python-2.7","A_Id":11013947,"CreationDate":"2012-06-13T11:28:00.000","Title":"python: how to have a dictionary which can be accessed from all the app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Okay., We have Rails webapp which stores data in a mysql data base. The table design was not read efficient. So we resorted to creating a separate set of read only tables in mysql and made all our internal API calls use that tables for read. We used callbacks to keep the data in sync between both the set of tables. Now we have a another Python app which is going to mess with the same database - now how do we proceed maintaining the data integrity? \nActive record callbacks can't be used anymore. We know we can do it with triggers. But is there a any other elegant way to do this? How to people achieve to maintain the integrity of such derived data.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":296,"Q_Id":11013976,"Users Score":1,"Answer":"Yes, refactor the code to put a data web service in front of the database and let the Ruby and Python apps talk to the service.  Let it maintain all integrity and business rules.  \n\"Don't Repeat Yourself\" - it's a good rule.","Q_Score":2,"Tags":"python,mysql,ruby-on-rails,database,triggers","A_Id":11014025,"CreationDate":"2012-06-13T11:31:00.000","Title":"Maintaining data integrity in mysql when different applications are accessing it","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm interested in tries and DAWGs (direct acyclic word graph) and I've been reading a lot about them but I don't understand what should the output trie or DAWG file look like.\n\nShould a trie be an object of nested dictionaries? Where each letter is divided in to letters and so on?\nWould a lookup performed on such a dictionary be fast if there are 100k or 500k entries?\nHow to implement word-blocks consisting of more than one word separated with - or space?\nHow to link prefix or suffix of a word to another part in the structure? (for DAWG)\n\nI want to understand the best output structure in order to figure out how to create and use one.\nI would also appreciate what should be the output of a DAWG along with trie.\nI do not want to see graphical representations with bubbles linked to each other, I want to know the output object once a set of words are turned into tries or DAWGs.","AnswerCount":15,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":138151,"Q_Id":11015320,"Users Score":14,"Answer":"There's no \"should\"; it's up to you. Various implementations will have different performance characteristics, take various amounts of time to implement, understand, and get right. This is typical for software development as a whole, in my opinion.\nI would probably first try having a global list of all trie nodes so far created, and representing the child-pointers in each node as a list of indices into the global list. Having a dictionary just to represent the child linking feels too heavy-weight, to me.","Q_Score":148,"Tags":"python,trie,dawg","A_Id":11015381,"CreationDate":"2012-06-13T12:56:00.000","Title":"How to create a trie in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I list files and folders if I only have an IP-address?\nWith urllib and others, I am only able to display the content of the index.html file. But what if I want to see which files are in the root as well?\nI am looking for an example that shows how to implement username and password if needed. (Most of the time index.html is public, but sometimes the other files are not).","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":57862,"Q_Id":11023530,"Users Score":4,"Answer":"HTTP does not work with \"files\" and \"directories\". Pick a different protocol.","Q_Score":17,"Tags":"python,html,directory,ip-address","A_Id":11023595,"CreationDate":"2012-06-13T21:25:00.000","Title":"Python to list HTTP-files and directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I list files and folders if I only have an IP-address?\nWith urllib and others, I am only able to display the content of the index.html file. But what if I want to see which files are in the root as well?\nI am looking for an example that shows how to implement username and password if needed. (Most of the time index.html is public, but sometimes the other files are not).","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":57862,"Q_Id":11023530,"Users Score":13,"Answer":"You cannot get the directory listing directly via HTTP, as another answer says. It's the HTTP server that \"decides\" what to give you. Some will give you an HTML page displaying links to all the files inside a \"directory\", some will give you some page (index.html), and some will not even interpret the \"directory\" as one.\nFor example, you might have a link to \"http:\/\/localhost\/user-login\/\": This does not mean that there is a directory called user-login in the document root of the server. The server interprets that as a \"link\" to some page.\nNow, to achieve what you want, you either have to use something other than HTTP (an FTP server on the \"ip address\" you want to access would do the job), or set up an HTTP server on that machine that provides for each path (http:\/\/192.168.2.100\/directory) a list of files in it (in whatever format) and parse that through Python.\nIf the server provides an \"index of \/bla\/bla\" kind of page (like Apache server do, directory listings), you could parse the HTML output to find out the names of files and directories. If not (e.g. a custom index.html, or whatever the server decides to give you), then you're out of luck :(, you can't do it.","Q_Score":17,"Tags":"python,html,directory,ip-address","A_Id":11024116,"CreationDate":"2012-06-13T21:25:00.000","Title":"Python to list HTTP-files and directories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, here I'm happy that I wrote the whole code for a awesome looking GUI using wxPython in a day but it evaporated when I found that the panels are getting out of the way leaving a lot of empty space on the sides or getting congested (you know how!) on a different screen resolution. \nWhat I want to ask is that what all properties of a GUI should I adjust or care about if I want to see that the GUI's aspect ratio, frame alignment, panel alignments, sizer ratios etc. should remain intact or if there're any methods to do so, suggest me.\nThanks in advance. :)","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":284,"Q_Id":11027366,"Users Score":2,"Answer":"Sizers automatically adjust your application widgets for screen resolution, resize, etc. If they aren't doing this automatically, then there's probably something buggy in your code. Since I don't have your code to look at, try going over the wxPython tutorials on sizers very carefully. I found the book wxPython In Action very useful on this topic.","Q_Score":0,"Tags":"python,user-interface,wxpython,alignment,screen-resolution","A_Id":11036132,"CreationDate":"2012-06-14T05:49:00.000","Title":"wxPython : Adjusting the panels and sizers for different screen resolutions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We are writing an inventory system and I have some questions about sqlalchemy (postgresql) and transactions\/sessions. This is a web app using TG2, not sure this matters but to much info is never a bad. \n\nHow can make sure that when changing inventory qty's that i don't run into race conditions. If i understand it correctly if user on is going to decrement inventory on an item to say 0 and user two is also trying to decrement the inventory to 0 then if user 1s session hasn't been committed yet then user two starting inventory number is going to be the same as user one resulting in a race condition when both commit, one overwriting the other instead of having a compound effect.\nIf i wanted to use postgresql sequence for things like order\/invoice numbers how can I get\/set next values from sqlalchemy without running into race conditions?\n\nEDIT: I think i found the solution i need to use with_lockmode, using for update or for share. I am going to leave open for more answers or for others to correct me if I am mistaken.\nTIA","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2935,"Q_Id":11033892,"Users Score":3,"Answer":"If two transactions try to set the same value at the same time one of them will fail.  The one that loses will need error handling. For your particular example you will want to query for the number of parts and update the number of parts in the same transaction.\nThere is no race condition on sequence numbers. Save a record that uses a sequence number the DB will automatically assign it.\nEdit:\nNote as Limscoder points out you need to set the isolation level to Repeatable Read.","Q_Score":2,"Tags":"python,postgresql,web-applications,sqlalchemy,turbogears2","A_Id":11034199,"CreationDate":"2012-06-14T13:15:00.000","Title":"SQLAlchemy(Postgresql) - Race Conditions","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have scanned thousands of old documents and entered key data into a database. One of the fields is author name.\nWe need to search for documents by a given author but the exact name might have been entered incorrectly as on many documents the data is handwritten.\nI thought of searching for only the first few letters of the surname and then presenting a list for the user to select from. I don't know at this stage how many distinct authors there are, I suspect it will be in the hundreds rather than hundreds of thousands. There will be hundreds of thousands of documents.\nIs there a better way? Would an SQL database handle it better?\nThe software is python, and there will be a list of documents each with an author.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":11034268,"Users Score":0,"Answer":"I think you can use mongodb where you can set list field with all possible names of author. For example you have handwriten name \"black\" and you cant recognize what letter in name for example \"c\" or \"e\"  and you can set origin name as \"black\" and add to list of possible names \"blaek\"","Q_Score":0,"Tags":"python","A_Id":11034398,"CreationDate":"2012-06-14T13:34:00.000","Title":"Search unreliable author names","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've been trying to find a way to implement MVVM with PySide but haven't been able to. I think that there should be a way to create Views from ViewModels with QItemEditorFactory, and to do data binding I think I can use QDataWidgetMapper.\nDo you have any ideas on how MVVM may be implemented with Qt and PySide? Even if there are some resources in C++ I'll try to translate them to python.\nThanks.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4531,"Q_Id":11042172,"Users Score":0,"Answer":"I don't know how far do you want to take MVVM, but at a basic level it comes with Qt, and I've been using it for a long time. You have a business-specific model, say tied to a database. Then you create view-specific viewmodel as a proxy model. You can stack a few layers of those, depending on what you need. Then you show that using a view. As long as everything is set up right, it will \"just work\". Now if you want to use a model to configure a view, Qt doesn't provide anything directly for you. You'd need to write a factory class that can use viewmodel data to instantiate and set up the view for you. Everything depends on how far do you want to take it, and what architectural benefits does it give you.","Q_Score":16,"Tags":"python,qt,mvvm,pyside,architectural-patterns","A_Id":18681903,"CreationDate":"2012-06-14T22:22:00.000","Title":"MVVM pattern with PySide","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been trying to find a way to implement MVVM with PySide but haven't been able to. I think that there should be a way to create Views from ViewModels with QItemEditorFactory, and to do data binding I think I can use QDataWidgetMapper.\nDo you have any ideas on how MVVM may be implemented with Qt and PySide? Even if there are some resources in C++ I'll try to translate them to python.\nThanks.","AnswerCount":3,"Available Count":2,"Score":-0.1325487884,"is_accepted":false,"ViewCount":4531,"Q_Id":11042172,"Users Score":-2,"Answer":"An obvious answer for me is that MVVM is suitable for WPF and some other techs that welcome this pattern, and so you have to find out whether it's possible to apply this pattern on other technologies. Please, read on MVVM in wiki.","Q_Score":16,"Tags":"python,qt,mvvm,pyside,architectural-patterns","A_Id":17227321,"CreationDate":"2012-06-14T22:22:00.000","Title":"MVVM pattern with PySide","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a physics simulating program, and found after() useful.\nI once would like to create a thread for physics calculation and simulation. But when I finally noticed that function, I used it instead.\nSo, I'm curious about how Tkinter implements that function. Is it multi-threading?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":718,"Q_Id":11046836,"Users Score":5,"Answer":"It is not multithreaded. \nTkinter works by pulling objects off of a queue and processing them. Usually what is on this queue are events generated by the user (mouse movements, button clicks, etc).\nThis queue can contain other things, such as job created with after. So, to Tkinter, something submitted with after is just another event to be processed at a particular point in time.","Q_Score":1,"Tags":"python,tkinter,python-multithreading","A_Id":11049545,"CreationDate":"2012-06-15T08:03:00.000","Title":"Python: Does after() in Tkinter have a multi-threading approach?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Java I use getters\/setters when I have simple models\/pojos. I find that the code becomes self-documenting when you do it this way. Calling getName() will return a name, I don't need to care how it's mapped to some database and so on.\nProblems rise when using languages where getters and setters start feeling clunky, like in Python, and I often hear people saying that they are bad. For example some time a go I had a PHP project in which some of the data was just queried from the database and column values mapped to the objects\/dictionaries. What I found out was that code like this was annoyingly hard to read, you can't really just read the code, you read the code, then you notice that the values are fetched from the database and now you have to look through the database schema all the time to understand it. When all you could do is just look at the class definition and knowing that there won't be any undocumented magic keys there.\nSo my question is how do you guys document code without getters and setters?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":11053550,"Users Score":1,"Answer":"In my opinion, there shouldn't be any undocumented attributes in a class. PHP and other languages allow you to just stick attributes on a class from anywhere, whether they've been defined in the class or not. I think that's bad practice for the reasons you describe and more: \nIt's hard to read. \nIt makes it harder for other programmers (including your future self) to understand what's going on. \nIt prevents auto-complete functionality in IDEs from working. \nIt often makes the domain layer too dependent on the persistence layer.\nWhether you use getters and setters to access the defined attributes of a class is a little more fungible to me. I like things to be consistent, so if I have a class that has a getChildren() method to lazy load some array of objects, then I don't make the $children attribute public, and I tend to make other attributes private as well. I think that's a little more a matter of taste, but I find it annoying to access some attributes in a class directly ($object->name;) and others by getters\/setters.","Q_Score":0,"Tags":"java,php,python,setter,getter","A_Id":11053683,"CreationDate":"2012-06-15T15:18:00.000","Title":"Documentation when not using getters and setters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to use python-rest-client package into my project. I tried several times for installing python-rest-client into my linux python, it never worked. But it works well in Windows python. Would anybody tell me how to install python-rest-client in linux python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1855,"Q_Id":11081209,"Users Score":1,"Answer":"avasal, you were right. I did it by  pip install python-rest-client","Q_Score":1,"Tags":"python,json,rest","A_Id":11184777,"CreationDate":"2012-06-18T10:45:00.000","Title":"how to install python-rest-client lib in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to ask if anyone has an idea or example of how to do support vector regression in python with high dimensional output( more than one) using a python binding of libsvm? I checked the examples and they are all assuming the output to be one dimensional.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3847,"Q_Id":11083921,"Users Score":4,"Answer":"libsvm might not be the best tool for this task.\nThe problem you describe is called multivariate regression, and usually for regression problems, SVM's are not necessarily the best choice.\nYou could try something like group lasso (http:\/\/www.di.ens.fr\/~fbach\/grouplasso\/index.htm - matlab) or sparse group lasso (http:\/\/spams-devel.gforge.inria.fr\/ - seems to have a python interface), which solve the multivariate regression problem with different types of regularization.","Q_Score":3,"Tags":"python,machine-learning,svm,regression,libsvm","A_Id":11172695,"CreationDate":"2012-06-18T13:27:00.000","Title":"Support Vector Regression with High Dimensional Output using python's libsvm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just installed Python 2.7.3 on a Windows7 machine. \nHow do I get .py files to be associated with python (they are with notepad ATM) and how do I get the context menu shortcut for \"edit in IDLE\"? Somehow I didn't get that on this particular computer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":11091052,"Users Score":2,"Answer":"try making a .py file and then try to open it, and a window should appear asking you what to open it with, and then select idle in your program files.","Q_Score":1,"Tags":"python,installation,python-idle","A_Id":11091290,"CreationDate":"2012-06-18T21:07:00.000","Title":"IDLE not integrated in desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to run Tornado such that it listens to a local port (e.g. localhost:8000). I can't seem to find any documentation explaining how to do this.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":19432,"Q_Id":11094920,"Users Score":0,"Answer":"If you want to daemonize tornado - use supervisord. If you want to access tornado on address like http:\/\/mylocal.dev\/ - you should look at nginx and use it like reverse proxy. And on specific port it can be binded like in Lafada's answer.","Q_Score":9,"Tags":"python,tornado","A_Id":11096932,"CreationDate":"2012-06-19T05:33:00.000","Title":"How do you run the Tornado web server locally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to run Tornado such that it listens to a local port (e.g. localhost:8000). I can't seem to find any documentation explaining how to do this.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":19432,"Q_Id":11094920,"Users Score":1,"Answer":"Once you've defined an application (like in the other answers) in a file (for example server.py), you simply save and run that file.\npython server.py","Q_Score":9,"Tags":"python,tornado","A_Id":39968411,"CreationDate":"2012-06-19T05:33:00.000","Title":"How do you run the Tornado web server locally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I need to read in a dictionary file to filter content specified in the hdfs_input, and I have uploaded it to the cluster using the put command, but I don't know how to access it in my program.\nI tried to access it using path on the cluster like normal files, but it gives the error information: IOError: [Errno 2] No such file or directory\nBesides, is there any way to maintain only one copy of the dictionary for all the machines that runs the job ?\nSo what's the correct way of access files other than the specified input in hadoop jobs?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":11095220,"Users Score":0,"Answer":"Problem solved by adding the file needed with the -file option or file= option in conf file.","Q_Score":0,"Tags":"python,hadoop","A_Id":11098023,"CreationDate":"2012-06-19T06:00:00.000","Title":"How to read other files in hadoop jobs?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"How can we write a python (with CPython) binding to a Java library so that the developers that want to use this java library can use it by writing only python code, not worrying about any Java code?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10944,"Q_Id":11098131,"Users Score":2,"Answer":"I've used JPype in a similar instance with decent results. The main task would be to write wrappers to translate your java api into a more pythonic api, since raw JPype usage is hardly any prettier than just writing java code.","Q_Score":6,"Tags":"java,python,binding,word-wrap,cpython","A_Id":11286405,"CreationDate":"2012-06-19T09:26:00.000","Title":"how to write python wrapper of a java library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The following saves floating values of a matrix into textfiles\nnumpy.savetxt('bool',mat,fmt='%f',delimiter=',')\nHow to save a boolean matrix ? what is the fmt for saving boolean matrix ?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":3549,"Q_Id":11100066,"Users Score":3,"Answer":"Thats correct, bools are integers, so you can always go between the two. \n\n\nimport numpy as np\narr = np.array([True, True, False, False])\nnp.savetxt(\"test.txt\", arr, fmt=\"%5i\")\n\n\nThat gives a file with 1 1 0 0","Q_Score":2,"Tags":"python,numpy,save,boolean","A_Id":11101558,"CreationDate":"2012-06-19T11:33:00.000","Title":"how to save a boolean numpy array to textfile in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I change behavior of how items are selected in QGridLayout by cursor keys? I want to move selection horizontally by left\/right cursor keys and vertically by up\/down keys.\nWho is responsible for it? Layout, items container or tab order?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":706,"Q_Id":11120427,"Users Score":1,"Answer":"You can reimplement keyPressEvent() method for the main widget to catch the pressed keys. Then you can access the desired widget in your layout by calling QGridLayout::itemAtPosition (int row, int column) and then set focus to it.","Q_Score":0,"Tags":"python,qt,pyqt,grid-layout","A_Id":11120871,"CreationDate":"2012-06-20T13:15:00.000","Title":"Custom QGridLayout items selection behaviour","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As a relatively new programmer, I have several times encountered situations where it would be beneficial for me to read and assemble program data from an external source rather than have it written in the code. This is mostly the case when there are a large number of objects of the same type. In such scenarios, object definitions quickly take up a lot of space in the code and add unnecessary impediment to readability. \nAs an example, I've been working on text-based RPG, which has a large number of rooms and items of which to keep track. Even a few items and rooms leads to massive blocks of object creation code.\nI think it would be easier in this case to use some format of external data storage, reading from a file. In such a file, items and rooms would be stored by name and attributes, so that they could parsed into an object with relative ease. \nWhat formats would be best for this? I feel a full-blown database such as SQL would add unnecessary bloat to a fairly light script. On the other hand, an easy method of editing this data is important, either through an external application, or another python script. On the lighter end of things, the few I heard most often mentioned are XML, JSON, and YAML. \nFrom what I've seen, XML does not seem like the best option, as many seem to find it complex and difficult to work with effectively.   \nJSON and YAML seem like either might work, but I don't know how easy it would be to edit either externally.\nSpeed is not a primary concern in this case. While faster implementations are of course desirable, it is not a limiting factor to what I can use.\nI've looked around both here and via Google, and while I've seen quite a bit on the topic, I have not been able to find anything specifically helpful to me. Will formats like JSON or YAML be sufficient for this, or would I be better served with a full-blown database?","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4619,"Q_Id":11129844,"Users Score":0,"Answer":"I would be tempted to research a little into some GUI that could output graphviz (DOT format) with annotations, so you could create the rooms and links between them (a sort of graph). Then later, you might want another format to support heftier info.\nBut should make it easy to create maps, links between rooms (containing items or traps etc..), and you could use common libraries to produce graphics of the maps in png or something.\nJust a random idea off the top of my head - feel free to ignore!","Q_Score":5,"Tags":"python","A_Id":11130087,"CreationDate":"2012-06-20T23:59:00.000","Title":"Optimal format for simple data storage in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"As a relatively new programmer, I have several times encountered situations where it would be beneficial for me to read and assemble program data from an external source rather than have it written in the code. This is mostly the case when there are a large number of objects of the same type. In such scenarios, object definitions quickly take up a lot of space in the code and add unnecessary impediment to readability. \nAs an example, I've been working on text-based RPG, which has a large number of rooms and items of which to keep track. Even a few items and rooms leads to massive blocks of object creation code.\nI think it would be easier in this case to use some format of external data storage, reading from a file. In such a file, items and rooms would be stored by name and attributes, so that they could parsed into an object with relative ease. \nWhat formats would be best for this? I feel a full-blown database such as SQL would add unnecessary bloat to a fairly light script. On the other hand, an easy method of editing this data is important, either through an external application, or another python script. On the lighter end of things, the few I heard most often mentioned are XML, JSON, and YAML. \nFrom what I've seen, XML does not seem like the best option, as many seem to find it complex and difficult to work with effectively.   \nJSON and YAML seem like either might work, but I don't know how easy it would be to edit either externally.\nSpeed is not a primary concern in this case. While faster implementations are of course desirable, it is not a limiting factor to what I can use.\nI've looked around both here and via Google, and while I've seen quite a bit on the topic, I have not been able to find anything specifically helpful to me. Will formats like JSON or YAML be sufficient for this, or would I be better served with a full-blown database?","AnswerCount":8,"Available Count":3,"Score":0.1243530018,"is_accepted":false,"ViewCount":4619,"Q_Id":11129844,"Users Score":5,"Answer":"Though there are good answers here already, I would simply recommend JSON for your purposes for the sole reason that since you're a new programmer it will be the most straightforward to read and translate as it has the most direct mapping to native Python data types (lists [] and dictionaries {}).  Readability goes a long way and is one of the tenets of Python programming.","Q_Score":5,"Tags":"python","A_Id":11129974,"CreationDate":"2012-06-20T23:59:00.000","Title":"Optimal format for simple data storage in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"As a relatively new programmer, I have several times encountered situations where it would be beneficial for me to read and assemble program data from an external source rather than have it written in the code. This is mostly the case when there are a large number of objects of the same type. In such scenarios, object definitions quickly take up a lot of space in the code and add unnecessary impediment to readability. \nAs an example, I've been working on text-based RPG, which has a large number of rooms and items of which to keep track. Even a few items and rooms leads to massive blocks of object creation code.\nI think it would be easier in this case to use some format of external data storage, reading from a file. In such a file, items and rooms would be stored by name and attributes, so that they could parsed into an object with relative ease. \nWhat formats would be best for this? I feel a full-blown database such as SQL would add unnecessary bloat to a fairly light script. On the other hand, an easy method of editing this data is important, either through an external application, or another python script. On the lighter end of things, the few I heard most often mentioned are XML, JSON, and YAML. \nFrom what I've seen, XML does not seem like the best option, as many seem to find it complex and difficult to work with effectively.   \nJSON and YAML seem like either might work, but I don't know how easy it would be to edit either externally.\nSpeed is not a primary concern in this case. While faster implementations are of course desirable, it is not a limiting factor to what I can use.\nI've looked around both here and via Google, and while I've seen quite a bit on the topic, I have not been able to find anything specifically helpful to me. Will formats like JSON or YAML be sufficient for this, or would I be better served with a full-blown database?","AnswerCount":8,"Available Count":3,"Score":0.024994793,"is_accepted":false,"ViewCount":4619,"Q_Id":11129844,"Users Score":1,"Answer":"If you want editability, YAML is the best option of the ones you've named, because it doesn't have <> or {} required delimiters.","Q_Score":5,"Tags":"python","A_Id":11129853,"CreationDate":"2012-06-20T23:59:00.000","Title":"Optimal format for simple data storage in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Having ease of implementation a strong factor but security also an issue what would the best user authentication method for google app engine be?  My goal is to have a small very specific social network.  I know how to make my own but making it hack-proof is a little out of my league right now.  I have looked at OpenID and a few others.\nI am using Jinja2 as my template system and writing all of my web app code in python.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":637,"Q_Id":11130434,"Users Score":2,"Answer":"Your choices are Google's own authentication, OpenID, some third party solution or roll your own. Unless you really know what you are doing, do not choose option 4! Authentication is very involved, and if you make a single mistake or omission you're opening yourself up to a lot of pain. Option 3 is not great because you have to ensure the author really knows what they are doing, which either means trusting them or... really knowing what you're doing!\nSo I'd suggest you chose between Google's authentication and OpenID. Both are well trusted; Google is going to be easier to implement because there are several OpenID account providers you have to test against; but Google authentication may turn away some users who refuse to have Google accounts.","Q_Score":1,"Tags":"python,google-app-engine,jinja2,authentication","A_Id":11132393,"CreationDate":"2012-06-21T01:32:00.000","Title":"top user authentication method for google app engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a object A move with Velocity (v1, v2, v3) in 3D space.\nObject position is (px,py,pz)\nNow i want to add certain particles around object A (in radius dis) on plane which perpendicular to its Velocity direction.\nI find something call \"cross product\" but seen that no use in this case.\nAnyone can help?\nI'm new to python and don't really know how to crack it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2293,"Q_Id":11134610,"Users Score":1,"Answer":"The plane perpendicular to a vector \u27e8A, B, C\u27e9 has the general equation Ax + By + Cz + K = 0.","Q_Score":0,"Tags":"python,vector","A_Id":11134685,"CreationDate":"2012-06-21T08:50:00.000","Title":"Find perpendicular to given vector (Velocity) in 3D","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does python have immutable lists?\nSuppose I wish to have the functionality of an ordered collection of elements, but which I want to guarantee will not change, how can this be implemented? Lists are ordered but they can be mutated.","AnswerCount":7,"Available Count":1,"Score":-0.0285636566,"is_accepted":false,"ViewCount":87513,"Q_Id":11142397,"Users Score":-1,"Answer":"Instead of tuple, you can use frozenset. frozenset creates an immutable set. you can use list as member of frozenset and access every element of list inside frozenset using single for loop.","Q_Score":117,"Tags":"python,list,tuples,immutability","A_Id":35129521,"CreationDate":"2012-06-21T16:15:00.000","Title":"Does Python have an immutable list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to typeset a large document using ReportLab and Python 2.7. \nIt has a number of sections (about 6 in a 1,000 page document) and I would like each to start on odd-numbered\/right-hand page. I have no idea though whether the preceding page will be odd or even and so need the ability to optionally throw an additional blank page before a particular paragraph style (like you sometimes get in manuals where some pages are \"intentionally left blank\"). Can anyone suggest how this could be done, as the only conditional page break I can find works on the basis of the amount of text on the page not a page number.\nI also need to make sure that the blank page is included in the PDF so that double-sided printing works.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":463,"Q_Id":11142503,"Users Score":0,"Answer":"If you can keep track of page numbers, then just add a PageBreak or canvas.showPage() command at the appropriate times.","Q_Score":2,"Tags":"python,pdf-generation,reportlab","A_Id":11369181,"CreationDate":"2012-06-21T16:22:00.000","Title":"Throw blank even-numbered\/left pages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a personal module of functions, generic functions for my scientific work.\nIt's not finished so I would like to keep it in it's development folder for the time being without installing it like you install every other modules with pip, etc.\nNow, I also need to work on other non-related projects but still need the functions.\nMy question is, having those 2 projects in completely independent folders, how do I import one to use in the other?\nthanks\nEDIT: Just another quick one. If both were inside their respective folder but with the same root. Would there be a better\/easier way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":11165937,"Users Score":1,"Answer":"Put the directory containing your module (let's call it functions.py) into the PYTHONPATH environment variable.  Then you'll be able to use import functions to get your functions.\nPip also seems to have support for this:  pip install -e src\/mycheckout for exxample, but I don't quite understand the ramifications of that.","Q_Score":0,"Tags":"python,python-2.7","A_Id":11165954,"CreationDate":"2012-06-23T01:02:00.000","Title":"Importing unfinished modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the process of trying to install django, I had a series of failures. I followed many different tutorials online and ended up trying to install it several times. I think I may have installed it twice (which the website said was not a good thing), so how do I tell if I actually have multiple versions installed? I have a Mac running Lion.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":2635,"Q_Id":11166014,"Users Score":5,"Answer":"Check out virtualenv and virtualenvwrapper","Q_Score":7,"Tags":"python,django,installation,duplicates","A_Id":11166438,"CreationDate":"2012-06-23T01:15:00.000","Title":"How to tell if you have multiple Django's installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"In the process of trying to install django, I had a series of failures. I followed many different tutorials online and ended up trying to install it several times. I think I may have installed it twice (which the website said was not a good thing), so how do I tell if I actually have multiple versions installed? I have a Mac running Lion.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2635,"Q_Id":11166014,"Users Score":9,"Answer":"open terminal and type python then type import django then type django and it will tell you the path to the django you are importing. Goto that folder [it should look something like this: \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\/] and look for more than one instance of django(if there is more than one, they will be right next to each other). Delete the one(s) you don't want.","Q_Score":7,"Tags":"python,django,installation,duplicates","A_Id":11166539,"CreationDate":"2012-06-23T01:15:00.000","Title":"How to tell if you have multiple Django's installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that?\nBonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","AnswerCount":8,"Available Count":3,"Score":-0.024994793,"is_accepted":false,"ViewCount":224173,"Q_Id":11170827,"Users Score":-1,"Answer":"I had this problem and just decided to rename one of the programs from python.exe to python2.7.exe. Now I can specify on command prompt which program to run easily without introducing any scripts or changing environmental paths. \nSo i have two programs: python2.7 and python (the latter which is v.3.8 aka default).","Q_Score":95,"Tags":"python,version,virtualenv","A_Id":60839180,"CreationDate":"2012-06-23T15:46:00.000","Title":"How do I tell a Python script to use a particular version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that?\nBonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","AnswerCount":8,"Available Count":3,"Score":-0.024994793,"is_accepted":false,"ViewCount":224173,"Q_Id":11170827,"Users Score":-1,"Answer":"While working with different versions of Python on Windows,\nI am using this method to switch between versions.\nI think it is better than messing with shebangs and virtualenvs\n1) install python versions you desire \n2) go to Environment Variables > PATH\n(i assume that paths of python versions are already added to Env.Vars.>PATH)\n3) suppress the paths of all python versions you dont want to use\n(dont delete the paths, just add a suffix like \"_sup\")\n4) call python from terminal \n(so Windows will skip the wrong paths you changed, \nand will find the python.exe at the path you did not suppressed,\nand will use this version after on)\n5) switch between versions by playing with suffixes","Q_Score":95,"Tags":"python,version,virtualenv","A_Id":56130973,"CreationDate":"2012-06-23T15:46:00.000","Title":"How do I tell a Python script to use a particular version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that?\nBonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","AnswerCount":8,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":224173,"Q_Id":11170827,"Users Score":0,"Answer":"You can't do this within the Python program, because the shell decides which version to use if you a shebang line. \nIf you aren't using a shell with a shebang line and just type python myprogram.py it uses the default version unless you decide specifically which Python version when you type pythonXXX myprogram.py which version to use.\nOnce your Python program is running you have already decided which Python executable to use to get the program running.\nvirtualenv is for segregating python versions and environments, it specifically exists to eliminate conflicts.","Q_Score":95,"Tags":"python,version,virtualenv","A_Id":11170838,"CreationDate":"2012-06-23T15:46:00.000","Title":"How do I tell a Python script to use a particular version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a game in python in which I must periodically pull a random word from a list of words. When I prototyped my game I declared a word_list = ['cat','dog','rat','house'] of ten words at the top of one of my modules. I then use choice(word_list) to get a random word. However, I must must change this temporary hack into something more elegant because I need to increase the size of the word list to 5,000+ words. If I do this in my current module it will look ridiculous.\nShould I put all of these words in a flat txt file, and then read from that file as I need words? If so, how would I best do that? Put each word an a separate line and then read one random line? I'm not sure what the most efficient way is.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":290,"Q_Id":11181195,"Users Score":2,"Answer":"I would create a separated module called random_words, or something like that, hiding the list inside it and encapsulating the choice(word_list) inside an interface function.\nAs to load them from a file, well, since I would need to type them anyway, and a python file is just a text file in the end, I would type them right there, probably one per line for easy maintenance.","Q_Score":0,"Tags":"python","A_Id":11181226,"CreationDate":"2012-06-24T21:07:00.000","Title":"Where should I declare a list of 5,000+ words?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a game in python in which I must periodically pull a random word from a list of words. When I prototyped my game I declared a word_list = ['cat','dog','rat','house'] of ten words at the top of one of my modules. I then use choice(word_list) to get a random word. However, I must must change this temporary hack into something more elegant because I need to increase the size of the word list to 5,000+ words. If I do this in my current module it will look ridiculous.\nShould I put all of these words in a flat txt file, and then read from that file as I need words? If so, how would I best do that? Put each word an a separate line and then read one random line? I'm not sure what the most efficient way is.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":290,"Q_Id":11181195,"Users Score":3,"Answer":"Read the words from the file at startup (or at least the line indexes), and use as required.","Q_Score":0,"Tags":"python","A_Id":11181204,"CreationDate":"2012-06-24T21:07:00.000","Title":"Where should I declare a list of 5,000+ words?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It is pretty easy to split a rectangle\/square into smaller regions and enforce a maximum area of each sub-region.  You can just divide the region into regions with sides length sqrt(max_area) and treat the leftovers with some care.\nWith a quadrilateral however I am stumped.  Let's assume I don't know the angle of any of the corners.  Let's also assume that all four points are on the same plane.  Also, I don't need for the the small regions to be all the same size.  The only requirement I have is that the area of each individual region is less than the max area.\nIs there a particular data structure I could use to make this easier?\nIs there an algorithm I'm just not finding?\nCould I use quadtrees to do this?  I'm not incredibly versed in trees but I do know how to implement the structure.\nI have GIS work in mind when I'm doing this, but I am fairly confident that that will have no impact on the algorithm to split the quad.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1141,"Q_Id":11217855,"Users Score":1,"Answer":"You could recursively split the quad in half on the long sides until the resulting area is small enough.","Q_Score":1,"Tags":"python,math,geometry,gis","A_Id":11217921,"CreationDate":"2012-06-27T00:39:00.000","Title":"Split quadrilateral into sub-regions of a maximum area","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the last query executed.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1125,"Q_Id":11223147,"Users Score":1,"Answer":"If you're not after just parameter substitution, but full construction of the SQL, you have to do that using string operations on your end. The ? replacement always just stands for a value. Internally, the SQL string is compiled to SQLite's own bytecode (you can find out what it generates with EXPLAIN thesql) and ? replacements are done by just storing the value at the correct place in the value stack; varying the query structurally would require different bytecode, so just replacing a value wouldn't be enough.\nYes, this does mean you have to be ultra-careful. If you don't want to allow updates, try opening the DB connection in read-only mode.","Q_Score":0,"Tags":"python,sqlite","A_Id":11224222,"CreationDate":"2012-06-27T09:27:00.000","Title":"Python + Sqlite 3. How to construct queries?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the last query executed.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1125,"Q_Id":11223147,"Users Score":1,"Answer":"If you're trying to transmit changes to the database to another computer, why do they have to be expressed as SQL strings?  Why not pickle the query string and the parameters as a tuple, and have the other machine also use SQLite parameterization to query its database?","Q_Score":0,"Tags":"python,sqlite","A_Id":11224475,"CreationDate":"2012-06-27T09:27:00.000","Title":"Python + Sqlite 3. How to construct queries?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the last query executed.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1125,"Q_Id":11223147,"Users Score":0,"Answer":"I want how to get the parsed 'sql param'.\n\nIt's all open source so you have full access to the code doing the parsing \/ sanitization. Why not just reading this code and find out how it works and if there's some (possibly undocumented) implementation that you can reuse ?","Q_Score":0,"Tags":"python,sqlite","A_Id":11224003,"CreationDate":"2012-06-27T09:27:00.000","Title":"Python + Sqlite 3. How to construct queries?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have a chunk of code that declares some classes, creates data, uses django to actually save them to the database. My question is how do I actually execute it?\nI am using PyCharm and have the file open. But I have no clue how to actually execute it. I can execute line by line in Django Console, but if it's more than that it can't handle the indentation. \nThe project itself runs fine (127.0.0.1 loads my page). How can I accomplish this?\nI am sorry if this a completely obvious answer, I've been struggling with this for a bit.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1138,"Q_Id":11230979,"Users Score":1,"Answer":"If your site loads, you should put the import the models into one of your Django views.\nIn a view you can do whatever you like with the models.","Q_Score":1,"Tags":"python,django,pycharm","A_Id":11231045,"CreationDate":"2012-06-27T16:31:00.000","Title":"How to run a file that uses django models (large block of code) in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the way to do urlopen in python such that even if the underlying machine has ipv6 networking enabled, the request is sent via ipv4 instead of ipv6?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2773,"Q_Id":11231244,"Users Score":1,"Answer":"I had a look into the source code. Unfortunately, urllib.urlopen() seems to use httplib.HTTP(), which doesn't even allow setting a source address.\nurllib2.urlopen() uses httplib.HTTPConnection() which you could inherit from and create a class which by default sets a source address '0.0.0.0' instead of ''. Then you could somehow inject that new overridden class into the urllib2 stuff by creating a \"new\" HTTPHandler() (look how it's done in urllib2.py) and a new opener which you build_opener() and\/or install_opener().\nSorry for not being very exact, but I never have done such a thing and don't know exactly how that works.","Q_Score":2,"Tags":"python,ipv6,urllib,ipv4","A_Id":11231476,"CreationDate":"2012-06-27T16:48:00.000","Title":"how to do urlopen over ipv4 by default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting out some projects in words processing and I needed NumPy and NLTK.\nThat was the first time I got to know easy_install and how to compile new module of python into the system.\nI have Python 2.7 x64 plus VS 11 and VS 12. Also Cygwin (the latest one I guess).\nI could see in the file that compiles using VS that it looks for VS env with the same version as the one that compiled the python code, why?\nWhen I hardcoded 11.0 which is my version, numpy failed to build on several strange errors regarding vcvarsall (it found vcvarsall, probably misused it).\nCan't I build python binaries on Windows?\nIf not, can I cross compile on Linux for Windows? (using the same method as Google for the Android SDK)","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20743,"Q_Id":11267463,"Users Score":0,"Answer":"there are several ways to do it apparently.\n\nbuild using mingw\nbuild python 2.7 using VS 2008 express.\ni'm not sure regarding which version is good to build 3.2 but it could be VS 2010.\nyou can compile python x64 from source using your desired VS, but u'll have competability issues with other pre built packages.","Q_Score":17,"Tags":"python,visual-studio,python-2.7,compilation,windows-7-x64","A_Id":11285320,"CreationDate":"2012-06-29T18:57:00.000","Title":"Compiling Python modules on Windows x64","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently I was asked this question in an interview. I gave an answer in O(n) time but in two passes. Also he asked me how to do the same if the url list cannot fit into the memory. Any help is very much appreciated.","AnswerCount":5,"Available Count":2,"Score":-0.0399786803,"is_accepted":false,"ViewCount":1129,"Q_Id":11279779,"Users Score":-1,"Answer":"This is actually a classic interview question and the answer they were expecting was that you first sort the urls and then make a binary search.\nIf it doesn't fit in memory, you can do the same thing with a file.","Q_Score":0,"Tags":"c++,python,algorithm","A_Id":11280036,"CreationDate":"2012-07-01T05:20:00.000","Title":"Finding a unique url from a large list of URLs in O(n) time in a single pass","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently I was asked this question in an interview. I gave an answer in O(n) time but in two passes. Also he asked me how to do the same if the url list cannot fit into the memory. Any help is very much appreciated.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1129,"Q_Id":11279779,"Users Score":6,"Answer":"If it all fits in memory, then the problem is simple: Create two sets (choose your favorite data structure), both initially empty. One will contain unique URLs and the other will contain URLs that occur multiple times. Scan the URL list once. For each URL, if it exists in the unique set, remove it from the unique set and put it in the multiple set; otherwise, if it does not exist in the multiple set, add it to the unique set.\nIf the set does not fit into memory, the problem is difficult. The requirement of O(n) isn't hard to meet, but the requirement of a \"single pass\" (which seems to exclude random access, among other things) is tough; I don't think it's possible without some constraints on the data. You can use the set approach with a size limit on the sets, but this would be easily defeated by unfortunate orderings of the data and would in any event only have a certain probability (<100%) of finding a unique element if one exists.\nEDIT:\nIf you can design a set data structure that exists in mass storage (so it can be larger than would fit in memory) and can do find, insert, and deletes in O(1) (amortized) time, then you can just use that structure with the first approach to solve the second problem. Perhaps all the interviewer was looking for was to dump the URLs into a data base with a UNIQUE index for URLs and a count column.","Q_Score":0,"Tags":"c++,python,algorithm","A_Id":11279881,"CreationDate":"2012-07-01T05:20:00.000","Title":"Finding a unique url from a large list of URLs in O(n) time in a single pass","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've tried setting dlg.CenterOnParent() but that doesn't work. I assume it's because my MessageDialog is not setting the frame as the parent. In that case how would I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":176,"Q_Id":11282099,"Users Score":0,"Answer":"When you create a wx widget, the normal pattern of the create function is wx.SomeUIObject(parent, id, ...). The parent could be set when you create the dialog.","Q_Score":0,"Tags":"python,wxwidgets","A_Id":14640674,"CreationDate":"2012-07-01T12:51:00.000","Title":"How do I center a wx.MessageDialog to the frame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a django class and a field name how can you test to see whether the class has a field with the given name? \nThe field name is a string in this case.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":63,"Q_Id":11284600,"Users Score":1,"Answer":"For example:\nfield_name_exists = field_name in ModelName._meta.get_all_field_names()","Q_Score":0,"Tags":"python,django","A_Id":11284649,"CreationDate":"2012-07-01T18:29:00.000","Title":"Test for existence of field in django class","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a website that gets a lot of links to youtube and similar sites and I wanted to know if there is anyway that I can make a link automatically appear as a video. Like what happens when you post a link to a video on facebook.  You can play it right on the page.  Is there a way to do this without users actually posting the entire embed video HTML code?\nBy the way I am using google app engine with python and jinja2 templating.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4555,"Q_Id":11286809,"Users Score":0,"Answer":"Use this code when getting embed link from list value. In the template inside the iframe use below code\nsrc=\"{{results[0].video_link}}\"\n\"video_link\" is the Field name.","Q_Score":4,"Tags":"python,google-app-engine,youtube,youtube-api,jinja2","A_Id":64008461,"CreationDate":"2012-07-02T00:56:00.000","Title":"how to make youtube videos embed on your webpage when a link is posted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just set up IDE env for Python 3. I was wondering how I can run the file being currently edited in vim. I remembered that the command was \":python %\", but it did not work for Python 3.\nThank you very much.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":428,"Q_Id":11287862,"Users Score":3,"Answer":"For Python 3, just simply execute :!python3 %\n\nFurthermore, you might also want to map it to a hotkey in your settings, like what I did: \nnoremap <D-r> <esc>:w<CR>:!python3 %<CR>\nSo that you can just press Command+r to execute the current code with Python 3 anytime (it will be saved automatically.","Q_Score":0,"Tags":"python,vim,macvim","A_Id":11288495,"CreationDate":"2012-07-02T04:40:00.000","Title":"In Macvim with +python3 supported, which command should I use to execute the current file itself?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using django 1.4 and Python 2.7.\nI just have a simple requirement where I have to add a new URL to the django admin app. I know how to add URLs which are for the custom apps but am unable figure out how to add URLs which are of the admin app. Please guide me through this.\nBasically the full URL should be something like admin\/my_url.\nUPDATE\nI want a way after which I can as well reverse map the URL using admin.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":10538,"Q_Id":11288320,"Users Score":3,"Answer":"Just put your desired url mapping before the admin mapping in your root urls.py. The first match for the request will be taken, because django goes the url mappings from top to down. Just remember that you don't use an url the admin normally needs or provides because this will never match with a custom mapping in front of it. HTH!","Q_Score":7,"Tags":"django,django-admin,python-2.7,django-urls,django-1.4","A_Id":11288438,"CreationDate":"2012-07-02T05:46:00.000","Title":"New URL on django admin independent of the apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for an algorithm to compare two images (I work with python).\nI find the PIL library, numpy\/scipy and opencv. I know how to transform in greyscale, binary, make an histogram, .... that's ok but I don't know what I have to do with the two images to say \"yes they're similar \/\/ they're probably similar \/\/ they don't match\".\nDo you know the right way to go about it ?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1355,"Q_Id":11289652,"Users Score":1,"Answer":"If you want to check if they are binary equal you can count a checksum on them and compare it. If you want to check if they are similar in some other way , it will be more complicated and definitely would not fit into simple answer posted on Stack Overflow. It just depends on how you define similarity but anyway it would require good programming skills and a lot of code written.","Q_Score":0,"Tags":"python,image,compare","A_Id":11289709,"CreationDate":"2012-07-02T07:50:00.000","Title":"How to compare image with python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to now how do i split a string like\n44664212666666 into [44664212 , 666666] or\n58834888888888 into [58834, 888888888]\nwithout knowing where the first occurrence of the last recurring digit occurs.\nso passing it to a function say seperate(str) --> [non_recurring_part, end_recurring digits]","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":11295714,"Users Score":0,"Answer":"Can't you just scan from the last character to the first character and stop when the next char doesn't equal the previous. Then split at that index.","Q_Score":0,"Tags":"python,string,algorithm","A_Id":11295792,"CreationDate":"2012-07-02T14:30:00.000","Title":"Splitting a number pattern","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to figure out a way to share memory between python processes.  Basically there is are objects that exists that multiple python processes need to be able to READ (only read) and use (no mutation).  Right now this is implemented using redis + strings + cPickle, but cPickle takes up precious CPU time so I'd like to not have to use that.  Most of the python shared memory implementations I've seen on the internets seem to require files and pickles which is basically what I'm doing already and exactly what I'm trying to avoid.\nWhat I'm wondering is if there'd be a way to write a like...basically an in-memory python object database\/server and a corresponding C module to interface with the database?  \nBasically the C module would ask the server for an address to write an object to, the server would respond with an address, then the module would write the object, and notify the server that an object with a given key was written to disk at the specified location.  Then when any of the processes wanted to retrieve an object with a given key they would just ask the db for the memory location for the given key, the server would respond with the location and the module would know how to load that space in memory and transfer the python object back to the python process.\nIs that wholly unreasonable or just really damn hard to implement?  Am I chasing after something that's impossible? Any suggestions would be welcome.  Thank you internet.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":19934,"Q_Id":11302656,"Users Score":3,"Answer":"If you don't want pickling, multiprocessing.sharedctypes might fit. It's a bit low-level, though; you get single values or arrays of specified types. \nAnother way to distribute data to child processes (one way) is multiprocessing.Pipe. That can handle Python objects, and it's implemented in C, so I cannot tell you wether it uses pickling or not.","Q_Score":15,"Tags":"python,c,shared-memory","A_Id":11305191,"CreationDate":"2012-07-02T23:40:00.000","Title":"Shared memory between python processes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't believe I have to ask this, but I have spent almost three hours looking for the answer.  Anyway, I have Eric IDE 4 installed on my linux distro.  I can't seem to download any plugins to the plugins repository.  \nThe only one I really want is the Django plugin so when I start a new project in Eric, the Django option shows.  The plugin repository just shows me an empty folder for .eric4\/eric4plugins and there's no follow up as to where I can get the plugins from somewhere else.  Actually, there was a hinting at it on the Eric docs site, but what I ended up getting was the ENTIRE trunk for eric.  And the plugins that came with the trunk are just the bare bones ones that ship with it.  I didn't get the Django one and the documentation on the Eric site is seriously lacking and overly complex.\nAnyone know how I can just get the Django snap in?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":4909,"Q_Id":11319116,"Users Score":4,"Answer":"In the Plugins dropdown menu click on Plugin repository...\nMake sure that the repository URL is: http:\/\/eric-ide.python-projects.org\/plugins4\/repository.xml  and then click on update.\nThe Django plugin will show up in the list of available plugins, click on it and then click the download button. That should download the plugin for you.\nAfter that you need to actually install the plugin as well: In the Plugins dropdown menu click on Install plugins. Then select your newly downloaded Django plugin and install it.\nGood luck!","Q_Score":0,"Tags":"python,django,ide,eric-ide","A_Id":11370886,"CreationDate":"2012-07-03T21:01:00.000","Title":"How to install the Django plugin for the Eric IDE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to write out a piece of code that can reduce the LENGTH of a boolean expression to the minimum, so the code should reduce the number of elements in the expression to as little as possible. Right now I'm stuck and I need some help =[\nHere's the rule: there can be arbitrary number of elements in a boolean expression, but it only contains AND and OR operators, plus brackets. \nFor example, if I pass in a boolean expression: ABC+BCD+DE, the optimum output would be BC(A+D)+DE, which saves 2 unit spaces compared to the original one because the two BCs are combined into one. \nMy logic is that I will attempt to find the most frequently appeared element in the expression, and factor it out. Then I call the function recursively to do the same thing to the factored expression until it's completely factored. \nHowever, how can I find the most common element in the original expression? That is, in the above example, BC? It seems like I would have to try out all different combinations of elements, and find number of times each combination appears in the whole expression. But this sounds really naive. \nSecond \nCan someone give a hint on how to do this efficiently? Even some keywords I can search up on Google will do.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":8347,"Q_Id":11324804,"Users Score":1,"Answer":"Unfortunately, most of the given suggestions may not actually give @turtlesoup what he\/she is looking for.  @turtlesoup asked for a way to minimize the number of characters for a given boolean expression.  Most simplification methods don't target the number of characters as a focus for simplification.  When it comes to minimization in electronics, users typically want the fewest number of gates (or parts).  This doesn't always result in a shorter expression in terms of the \"length\" of the expression -- most times it does, but not always.  In fact, sometimes the expression can become larger, in terms of length, though it may be simpler from an electronics standpoint (requires fewer gates to build).\nboolengine.com is the best simplification tool that I know of when it comes to boolean simplification for digital circuits.  It doesn't allow hundreds of inputs, but it allows 14, which is a lot more than most simplification tools.  \nWhen working with electronics, simplification programs usually break down the expression into sum-of-product form.  So the expression '(ab)+'cd becomes 'c+'b+'a+d.  The \"simplified\" result requires more characters to print as an expression, but is easier to build from an electronics standpoint.  It only requires a single 4-input OR gate and 3 inverters (4 parts).  Whereas the original expression would require 2 AND gates, 2 inverters, and an OR gate (5 parts).\nAfter giving @turtlesoup's example to BoolEngine, it shows that BC(A+D)+DE becomes E+D+ABC.  This is a shorter expression, and will usually be.  But certainly not always.","Q_Score":7,"Tags":"python,algorithm,math,boolean","A_Id":26163606,"CreationDate":"2012-07-04T07:59:00.000","Title":"algorithm - minimizing boolean expressions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Not sure if the title is a great way to word my actual problem and I apologize if this is too general of a question but I'm having some trouble wrapping my head around how to do something. \nWhat I'm trying to do:\nThe idea is to create a MySQL database of 'outages' for the thousands of servers I'm responsible for monitoring. This would give a historical record of downtime and an easy way to retroactively tell what happened. The database will be queried by a fairly simple PHP form where one could browse these outages by date or server hostname etc. \nWhat I have so far:\nI have a python script that runs as a cron periodically to call the Pingdom API to get a list of current down alerts reported by the pingdom service. For each down alert, a row is inserted into a database containing a hostname, time stamp, pingdom check id, etc. I then have a simple php form that works fine to query for down alerts. \nThe problem:\nWhat I have now is missing some important features and isn't quite what I'm looking for. Currently, querying this database would give me a simple list of down alerts like this:\nPindom alerts for Test_Check from 2012-05-01 to 2012-06-30:\ntest_check was reported DOWN at 2012-05-24 00:11:11\ntest_check was reported DOWN at 2012-05-24 00:17:28\ntest_check was reported DOWN at 2012-05-24 00:25:24\ntest_check was reported DOWN at 2012-05-24 00:25:48\nWhat I would like instead is something like this:\ntest_check was reported down for 15 minutes (2012-05-24 00:11:11 to 2012-05-24 00:25:48)(link to comment on this outage)(link to info on this outage). \nIn this ideal end result, there would be one row containing a outage ID, hostname of the server pingdom is reporting down, the timestamp for when that box was reported down originally and the timestamp for when it was reported up again along with a 'comment' field I (and other admins) would use to add notes about this particular event after the fact. I'm not sure if I should try to do this when pulling the alerts from pingdom or if I should re-process the alerts after they're collected to populate the new table and I'm not quite sure how I would work out either of those options.\nI'm a little lost as to how I will go about combining several down alerts that occur within a short period of time into a single 'outage' that would be inserted into a separate table in the existing MySQL database where individual down alerts are currently being stored. This would allow me to comment and add specific details for future reference and would generally make this thing a lot more usable. I'm not sure if I should try to do this when pulling the alerts from pingdom or if I should re-process the alerts after they're collected to populate the new table and I'm not quite sure how I would work out either of those options.\nI've been wracking my brain trying to figure out how to do this. It seems like a simple concept but I'm a somewhat inexperienced programmer (I'm a Linux admin by profession) and I'm stumped at this point. \nI'm looking for any thoughts, advice, examples or even just a more technical explanation of what I'm trying to do here to help point me in the right direction. I hope this makes sense. Thanks in advance for any advice :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":11329588,"Users Score":0,"Answer":"The most basic solution with the setup you have now would be to:\n\nGet a list of all events, ordered by server ID and then by time of the event\nLoop through that list and record the start of a new event \/ end of an old event for your new database when:\n\nthe server ID changes\nthe time between the current event and the previous event from the same server is bigger than a certain threshold you set.\nStore the old event you were monitoring in your new database\n\n\nThe only complication I see, is that the next time you run the script, you need to make sure that you continue monitoring events that were still taking place at the time you last ran the script.","Q_Score":0,"Tags":"php,python,mysql,json,pingdom","A_Id":11329769,"CreationDate":"2012-07-04T12:56:00.000","Title":"How can I combine rows of data into a new table based on similar timestamps? (python\/MySQL\/PHP)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to learn how to use Python's multiprocessing package, but I don't understand the difference between map and imap.\nIs the difference that map returns, say, an actual array or set, while imap returns an iterator over an array or set? When would I use one over the other?\nAlso, I don't understand what the chunksize argument is. Is this the number of values that are passed to each process?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25529,"Q_Id":11338044,"Users Score":49,"Answer":"That is the difference. One reason why you might use imap instead of map is if you wanted to start processing the first few results without waiting for the rest to be calculated. map waits for every result before returning.\nAs for chunksize, it is sometimes more efficient to dole out work in larger quantities because every time the worker requests more work, there is IPC and synchronization overhead.","Q_Score":56,"Tags":"python,multiprocessing","A_Id":11338089,"CreationDate":"2012-07-05T04:59:00.000","Title":"Python Multiprocessing: What's the difference between map and imap?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to make the uploaded file contents only viewable on the browser i.e using atreal.richfile.preview for doc\/xls\/pdf files. The file should not be downloadable at any cost. How do I remove the hyperlink for the template in a particular folder for all the files in that folder? I use Plone 4.1 There is AT at_download.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":362,"Q_Id":11341112,"Users Score":3,"Answer":"Cue tune from Hotel California:  \"You can check out any time you like, but you can never leave.\" \nYou do not not really want to disable all downloading, I believe that you really just want to disable downloads from all users but Owner.  There is no practical use for putting files into something with no vehicle for EVER getting them back out...\n...so you need to solve this problem with workflow:\n\nUse a custom workflow definition that has a state for this behavior (\"Confidential\").  Ensure that \"View\" permission is not inherited from folder above in the permissions for this state, and check \"Owner\" (and possibly \"Manager\" if you see fit) as having \"View\" permission.\nSet the confidential state as the default state for files.  You can do this using Workflow policy support (\"placeful workflows\") in parts of the site if you do not wish to do this site-wide.\n\nShould you wish to make the existence of the items viewable, but the download not, you are best advised to create a custom permission and a custom type to protect downloading with a permission other than \"View\" (but you still should use workflow state as permission-to-role mapping templates).","Q_Score":1,"Tags":"python,plone","A_Id":11350843,"CreationDate":"2012-07-05T09:05:00.000","Title":"In plone how can I make an uploaded file as NOT downloadable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to make the uploaded file contents only viewable on the browser i.e using atreal.richfile.preview for doc\/xls\/pdf files. The file should not be downloadable at any cost. How do I remove the hyperlink for the template in a particular folder for all the files in that folder? I use Plone 4.1 There is AT at_download.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":362,"Q_Id":11341112,"Users Score":1,"Answer":"Script (Python) at \/mysite\/portal_skins\/archetypes\/at_download Just customize to contain nothing. Thought this will be helpful to someone who would like to keep files\/ image files in Plone confidential by sharing the folders with view permission and disable checkout and copy option for the role created","Q_Score":1,"Tags":"python,plone","A_Id":11355784,"CreationDate":"2012-07-05T09:05:00.000","Title":"In plone how can I make an uploaded file as NOT downloadable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use the ScrolledPanel in wx.lib.scrolledpanel, and i would like to check if the scrollbar of the ScrolledPanel is currently visible, so i can give my StaticText the correct wrap width. Because when the scrollbar is visible i need to remove another 10 pixels or so from the wrap width...\nAnyone any idea how this is done?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":11342620,"Users Score":0,"Answer":"I solved this by getting the width of the parent widget inside the scrolledpanel, instead of the width of the scrolledpanel itself.\nSometimes the answer is so obvious :)","Q_Score":0,"Tags":"python,wxpython,wxwidgets","A_Id":11382239,"CreationDate":"2012-07-05T10:38:00.000","Title":"Check if wx.lib.scrolledpanel.ScrolledPanel is currently scrolling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script which scans an email inbox for specific emails. That part's working well and I'm able to acquire the data I'm interested in. I'd now like to take that data and add it to a Django app which will be used to display the information.\nI can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app?\nThe Django server is running on a Linux box under Apache \/ FastCGI if that makes a difference.\n[Edit] - in response to Srikar's question When you are saying \" get that data into the Django app\" what exactly do you mean?...\nThe Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":3419,"Q_Id":11349476,"Users Score":1,"Answer":"I have done the same thing.\nFirstly, my script was already parsing the emails and storing them in a db, so I set the db up in settings.py and used python manage.py inspectdb to create a model based on that db.\nThen it's just a matter of building a view to display the information from your db.\nIf your script doesn't already use a db it would be simple to create a model with what information you want stored, and then force your script to write to the tables described by the model.","Q_Score":1,"Tags":"python,django,data-importer","A_Id":16125317,"CreationDate":"2012-07-05T17:30:00.000","Title":"How can I periodically run a Python script to import data into a Django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script which scans an email inbox for specific emails. That part's working well and I'm able to acquire the data I'm interested in. I'd now like to take that data and add it to a Django app which will be used to display the information.\nI can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app?\nThe Django server is running on a Linux box under Apache \/ FastCGI if that makes a difference.\n[Edit] - in response to Srikar's question When you are saying \" get that data into the Django app\" what exactly do you mean?...\nThe Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3419,"Q_Id":11349476,"Users Score":0,"Answer":"When you are saying \" get that data into the DJango app\" what exactly do you mean? \nI am guessing that you are using some sort of database (like mysql). Insert whatever data you have collected from your cronjob into the respective tables that your Django app is accessing. Also insert this cron data into the same tables that your users are accessing. So that way your changes are immediately reflected to the users using the app as they will be accessing the data from the same table.","Q_Score":1,"Tags":"python,django,data-importer","A_Id":11349554,"CreationDate":"2012-07-05T17:30:00.000","Title":"How can I periodically run a Python script to import data into a Django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script which scans an email inbox for specific emails. That part's working well and I'm able to acquire the data I'm interested in. I'd now like to take that data and add it to a Django app which will be used to display the information.\nI can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app?\nThe Django server is running on a Linux box under Apache \/ FastCGI if that makes a difference.\n[Edit] - in response to Srikar's question When you are saying \" get that data into the Django app\" what exactly do you mean?...\nThe Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":3419,"Q_Id":11349476,"Users Score":0,"Answer":"Best way?\nMake a view on the django side to handle receiving the data, and have your script do a HTTP POST on a URL registered to that view.\nYou could also import the model and such from inside your script, but I don't think that's a very good idea.","Q_Score":1,"Tags":"python,django,data-importer","A_Id":11349556,"CreationDate":"2012-07-05T17:30:00.000","Title":"How can I periodically run a Python script to import data into a Django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script which scans an email inbox for specific emails. That part's working well and I'm able to acquire the data I'm interested in. I'd now like to take that data and add it to a Django app which will be used to display the information.\nI can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app?\nThe Django server is running on a Linux box under Apache \/ FastCGI if that makes a difference.\n[Edit] - in response to Srikar's question When you are saying \" get that data into the Django app\" what exactly do you mean?...\nThe Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":3419,"Q_Id":11349476,"Users Score":1,"Answer":"Forget about this being a Django app for a second. It is just a load of Python code.\nWhat this means is, your Python script is absolutely free to import the database models you have in your Django app and use them as you would in a standard module in your project.\nThe only difference here, is that you may need to take care to import everything Django needs to work with those modules, whereas when a request enters through the normal web interface it would take care of that for you.\nJust import Django and the required models.py\/any other modules you need for it work from your app. It is your code, not a black box. You can import it from where ever the hell you want.\nEDIT: The link from Rohan's answer to the Django docs for custom management commands is definitely the least painful way to do what I said above.","Q_Score":1,"Tags":"python,django,data-importer","A_Id":16125548,"CreationDate":"2012-07-05T17:30:00.000","Title":"How can I periodically run a Python script to import data into a Django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So basically, at the moment, we are trying to write a basic HTML 5 page that, when you press a button, returns whether the user, on Steam, is in-game, offline, or online. We have looked at the Steam API, and to find this information, it requires the person's 64 bit ID (steamID64) and we, on the website, are only given the username. In order to find their 64 bit id, we have tried to scrape off of a website (steamidconverter.com) to get the user's 64 bit id from their username. We tried doing this through the javascript, but of course we ran into the cross domain block, not allowing us to access that data from our google App Engine website.\nI have experience in Python, so I attempted to figure out how to get the HTML from that website (in the form of steamidconverter.com\/(personsusername)) with Python. That was a success in scraping, thanks to another post on Stack Overflow.\nBUT, I have no idea how to get that data back to the javascript and get it to do the rest of the work. I am stumped and really need help. This is all on google App Engine. All it is at the moment, is a button that runs a simple javascript that attempts to use JQuery to get the contents of the page back, but fails. I don't know how to integrate the two!\nPlease Help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":614,"Q_Id":11349709,"Users Score":1,"Answer":"Since you have the steam id from the service you can then make another request to their steam community page via the id.  From there you can use beautiful soup to return a dom to grab the required information for your project.\nNow onto your question.  You can have all this happen within a request in a handler, if you are using a web framework such as Tornado, and the handler can return json in the page and you can render this json using your javascript code.\nLook into a web framework for python such as Tornado or Django to help you with return and displaying the data.","Q_Score":0,"Tags":"jquery,python,html,google-app-engine,steam-web-api","A_Id":11350089,"CreationDate":"2012-07-05T17:46:00.000","Title":"Scraper Google App Engine for Steam","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing pretty big and complex application, so I want to stick to design patterns to keep code in good quality. I have problem with one instance that needs to be available for almost all other instances.\nLets say I have instance of BusMonitor (class for logging messages) and other instances that use this instance for logging actions, in example Reactor that parses incoming frames from network protocol and depending on frame it logs different messages. \nI have one main instance that creates BusMonitor, Reactor and few more instances.\nNow I want Reactor to be able to use BusMonitor instance, how can I do that according to design patterns?\nSetting it as a variable for Reactor seems ugly for me:\nself._reactor.set_busmonitor(self._busmonitor) \nI would do that for every instance that needs access to BusMonitor.\nImporting this instance seems even worse.\nAltough I can make BusMonitor as Singleton, I mean not as Class but as Module and then import this module but I want to keep things in classes to retain consistency. \nWhat approach would be the best?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":105,"Q_Id":11361488,"Users Score":3,"Answer":"I want to keep things in classes to retain consistency\n\nWhy? Why is consistency important (other than being a hobgoblin of little minds)?\nUse classes where they make sense. Use modules where they don't. Classes in Python are really for encapsulating data and retaining state. If you're not doing those things, don't use classes. Otherwise you're fighting against the language.","Q_Score":0,"Tags":"python,design-patterns,singleton","A_Id":11362386,"CreationDate":"2012-07-06T11:39:00.000","Title":"Python app design patterns - instance must be available for most other instances","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing pretty big and complex application, so I want to stick to design patterns to keep code in good quality. I have problem with one instance that needs to be available for almost all other instances.\nLets say I have instance of BusMonitor (class for logging messages) and other instances that use this instance for logging actions, in example Reactor that parses incoming frames from network protocol and depending on frame it logs different messages. \nI have one main instance that creates BusMonitor, Reactor and few more instances.\nNow I want Reactor to be able to use BusMonitor instance, how can I do that according to design patterns?\nSetting it as a variable for Reactor seems ugly for me:\nself._reactor.set_busmonitor(self._busmonitor) \nI would do that for every instance that needs access to BusMonitor.\nImporting this instance seems even worse.\nAltough I can make BusMonitor as Singleton, I mean not as Class but as Module and then import this module but I want to keep things in classes to retain consistency. \nWhat approach would be the best?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":11361488,"Users Score":0,"Answer":"I found good way I think. I made module with class BusMonitor, and in the same module, after class definition I make instance of this class. Now I can import it from everywhere in project and I retain consistency using classes and encapsulation.","Q_Score":0,"Tags":"python,design-patterns,singleton","A_Id":11471003,"CreationDate":"2012-07-06T11:39:00.000","Title":"Python app design patterns - instance must be available for most other instances","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used the Python's C-API to call some Python code in my c code and now I want to profile my python code for bottlenecks. I came across the PyEval_SetProfile API and am not sure how to use it. Do I need to write my own profiling function?  \nI will be very thankful if you can provide an example or point me to an example.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":276,"Q_Id":11371057,"Users Score":2,"Answer":"If you only need to know the amount of time spent in the Python code, and not (for example), where in the Python code the most time is spent, then the Python profiling tools are not what you want.  I would write some simple C code that sampled the time before and after the Python interpreter invocation, and use that.  Or, C-level profiling tools to measure the Python interpreter as a C function call.\nIf you need to profile within the Python code, I wouldn't recommend writing your own profile function.  All it does is provide you with raw data, you'd still have to aggregate and analyze it.  Instead, write a Python wrapper around your Python code that invokes the cProfile module to capture data that you can then examine.","Q_Score":1,"Tags":"python,profiling","A_Id":11371096,"CreationDate":"2012-07-06T23:51:00.000","Title":"Profiling Python via C-api (How to ? )","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"While plotting using Matplotlib, I have found how to change the font size of the labels.\nBut, how can I change the size of the numbers in the scale?\nFor clarity, suppose you plot x^2 from (x0,y0) = 0,0 to (x1,y1) = (20,20).\nThe scale in the x-axis below maybe something like \n\n0   1   2  ...   20.\n\nI want to change the font size of such scale of the x-axis.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44462,"Q_Id":11379910,"Users Score":0,"Answer":"simply put, you can use the following command to set the range of the ticks and change the size of the ticks\nimport matplotlib.pyplot as plt\nset the range of ticks for x-axis and y-axis\nplt.set_yticks(range(0,24,2))\nplt.set_xticks(range(0,24,2))\nchange the size of ticks for x-axis and y-axis\nplt.yticks(fontsize=12,)\nplt.xticks(fontsize=12,)","Q_Score":14,"Tags":"python,matplotlib","A_Id":68635240,"CreationDate":"2012-07-08T01:03:00.000","Title":"How do I change the font size of the scale in matplotlib plots?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I read from output PIPE multiple times without using process.communicate() as communicate closes the PIPE after reading the output but I need to have sequential inputs and outputs.\nFor example,\n1) process.stdin.write('input_1')\n2) After that, I need to read the output PIPE (how can I accomplish that without using communicate as it closes the PIPE) and then give another input as\n3) process.stdin.write('input_2')\n4) And then read the output of step 3\nBut if I use process.communicate after giving first input then it closes the output PIPE and i am unable to give second input as the PIPE is closed.\nKindly help please.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":176,"Q_Id":11389331,"Users Score":0,"Answer":"Instead of process.communicate(), use process.stdout.read()","Q_Score":2,"Tags":"python,subprocess","A_Id":11389343,"CreationDate":"2012-07-09T05:04:00.000","Title":"Python Sub-process (Output PIPE)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I read from output PIPE multiple times without using process.communicate() as communicate closes the PIPE after reading the output but I need to have sequential inputs and outputs.\nFor example,\n1) process.stdin.write('input_1')\n2) After that, I need to read the output PIPE (how can I accomplish that without using communicate as it closes the PIPE) and then give another input as\n3) process.stdin.write('input_2')\n4) And then read the output of step 3\nBut if I use process.communicate after giving first input then it closes the output PIPE and i am unable to give second input as the PIPE is closed.\nKindly help please.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":176,"Q_Id":11389331,"Users Score":1,"Answer":"flush() stdin, then read() stdout.","Q_Score":2,"Tags":"python,subprocess","A_Id":11389339,"CreationDate":"2012-07-09T05:04:00.000","Title":"Python Sub-process (Output PIPE)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an ejabberd server at jabber.domain.com, with an xmpp component written in python (using sleekxmpp) at presence.domain.com.\nI wanted the component to get a notification each time a client changed his presence from available to unavailable and vice-versa.\nThe clients themselves don't have any contacts.\nCurrently, I have set up my clients to send their available presence stanzas to admin@presence.domain.com, and I do get their online\/offline presence notifications. But I feel this isn't the right approach.\nI was hoping the clients wouldn't be aware of the component at presence.domain.com, and they would just connect to jabber.domain.com and the component should somehow get notified by the server about the clients presence.\nIs there a way to do that?\nIs my component setup correct? or should I think about using an xmpp plugin\/module\/etc..\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1392,"Q_Id":11392302,"Users Score":0,"Answer":"It is possible for a component to subscribe to a user's presence exactly the same way a user does. Also it is possible for the user to subscribe to a component's presence. You just have to follow the usual pattern, i.e. the component\/user sends a <presence\/> of type subscribe which the user\/component can accept by sending a <presence\/> of type subscribed.\nYou can also have the user just send a presence to the component directly.\nThere is no need to write custom hooks or create proxy users.","Q_Score":1,"Tags":"python,xmpp,ejabberd","A_Id":11941846,"CreationDate":"2012-07-09T09:26:00.000","Title":"Getting ejabberd to notify an external module on client presence change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an ejabberd server at jabber.domain.com, with an xmpp component written in python (using sleekxmpp) at presence.domain.com.\nI wanted the component to get a notification each time a client changed his presence from available to unavailable and vice-versa.\nThe clients themselves don't have any contacts.\nCurrently, I have set up my clients to send their available presence stanzas to admin@presence.domain.com, and I do get their online\/offline presence notifications. But I feel this isn't the right approach.\nI was hoping the clients wouldn't be aware of the component at presence.domain.com, and they would just connect to jabber.domain.com and the component should somehow get notified by the server about the clients presence.\nIs there a way to do that?\nIs my component setup correct? or should I think about using an xmpp plugin\/module\/etc..\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1392,"Q_Id":11392302,"Users Score":5,"Answer":"It is not difficult to write a custom ejabberd module for this.   It will need to register to presence change hooks in ejabberd,  and on each presence packet route a notification towards your external component.\nThere is a pair of hooks  'set_presence_hook'  and 'unset_presence_hook' that your module can register to,  to be informed when the users starts\/end a session. \nIf you need to track other presence statuses, there is also a hook 'c2s_update_presence' that fires on any presence packets sent by your users.  \nOther possibility, without using a custom module, is using shared rosters.  Add  admin@presence.domain.com  to the shared rosters of all your users,  but in this case they will see this item reflected on their roster.","Q_Score":1,"Tags":"python,xmpp,ejabberd","A_Id":11926839,"CreationDate":"2012-07-09T09:26:00.000","Title":"Getting ejabberd to notify an external module on client presence change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a way to embed an .exe into a frame.  (MDI)\nI am not sure how this can be done.\nI am using wxpython 2.9 and there is nothing online about this (until now).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":389,"Q_Id":11404994,"Users Score":0,"Answer":"Embedding one GUI application inside another is not a simple thing.  Applications are written to provide their own main frame, for example.  You could try to position Notepad to a particular place on the screen instead.\nIf you're really talking about Notepad, then you have a different course of action.  Notepad is nothing more than a text control with some code to save and load the contents to a file.","Q_Score":0,"Tags":"python,wxpython,wxwidgets","A_Id":11411866,"CreationDate":"2012-07-10T00:11:00.000","Title":"Embed .exe in wxpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a research project in big data mining. I have written the code currently to organize the data I have into a dictionary. However, The amount of data is so huge that while forming the dictionary, my computer runs out of memory. I need to periodically write my dictionary to main memory and create multiple dictionaries this way. I then need to compare the resulting multiple dictionaries, update the keys and values accordingly and store the whole thing in one big dictionary on disk. Any idea how I can do this in python? I need an api that can quickly write a dict to disk and then compare 2 dicts and update keys. I can actually write the code to compare 2 dicts, that's not a problem but I need to do it without running out of memory..\nMy dict looks like this:\n\"orange\" : [\"It is a fruit\",\"It is very tasty\",...]","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":442,"Q_Id":11406085,"Users Score":0,"Answer":"First thought - switch to 64-bit python and increase your computer's virtual memory settings ;-)\nSecond thought - once you have a large dictionary, you can sort on key and write it to file. Once all your data has been written, you can then iterate through all the files simultaneously, comparing and writing out the final data as you go.","Q_Score":2,"Tags":"python,memory,data-mining","A_Id":11406222,"CreationDate":"2012-07-10T03:11:00.000","Title":"Integrating multiple dictionaries in python (big data)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a research project in big data mining. I have written the code currently to organize the data I have into a dictionary. However, The amount of data is so huge that while forming the dictionary, my computer runs out of memory. I need to periodically write my dictionary to main memory and create multiple dictionaries this way. I then need to compare the resulting multiple dictionaries, update the keys and values accordingly and store the whole thing in one big dictionary on disk. Any idea how I can do this in python? I need an api that can quickly write a dict to disk and then compare 2 dicts and update keys. I can actually write the code to compare 2 dicts, that's not a problem but I need to do it without running out of memory..\nMy dict looks like this:\n\"orange\" : [\"It is a fruit\",\"It is very tasty\",...]","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":442,"Q_Id":11406085,"Users Score":0,"Answer":"You should use a database such as PostgreSQL.","Q_Score":2,"Tags":"python,memory,data-mining","A_Id":11406103,"CreationDate":"2012-07-10T03:11:00.000","Title":"Integrating multiple dictionaries in python (big data)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone please tell me how to find the x-offset and y-offset default value of a Slider in a webpage using python for selenium webdriver.\nThanks in Advance !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":636,"Q_Id":11411182,"Users Score":0,"Answer":"You can use the get_attribute(name) method on a webelement to retrieve attributes.","Q_Score":0,"Tags":"python,webdriver","A_Id":11412106,"CreationDate":"2012-07-10T10:17:00.000","Title":"How to find x and y-offset for slider in python for a web-application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to programming and was wondering how I can have a python program execute and communicate with a c program. I am doing a mathematical computation in python, and was wondering if I could write up the main computation in C, that way the computation runs faster. I've been reading about \"calling c functions from python\", \"including C or C++ code directly in your Python code\", and \"using c libraries from python\". Is this the same thing? I want a python program to execute a c program and receive the results.\nWhat does it mean to \"call C library functions\" from python? Would it allow the python script to use c libraries or allow the script to execute code within a c compiler?\nthanks","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":634,"Q_Id":11420053,"Users Score":2,"Answer":"There's also numpy which can be reasonably fast when dealing with \"array operations\" (sometimes called vector operations, but I find that term confusing with SIMD terminology).  You'll probably need numpy if you decide to go the cython route, so if the algorithm isn't too complicated, you might want to see if it is good enough with numpy by itself first.\nNote that there are two different routes you can take here.  You can use subprocess which basically issues system calls to some other program that you have written.  This is slow because you need to start a new process and send the data into the process and then read the data back from the process.  In other words, the data gets replicated multiple times for each call.  The second route is calling a C function from python.  Since Cpython (the reference and most common python implementation) is written in C, you can create C extensions.  They're basically compiled libraries that adhere to a certain API.  Then Cpython can load those libraries and use the functions inside, passing pointers to the data.  In this way, the data isn't actually replicated -- You're working with the same block of memory in python that you're using in C.  The downside here is that the C API is a little complex.  That's where 3rd party extensions and existing libraries come in (numpy, cython, ctypes, etc).  They all have different ways of pushing computations int C functions without you having to worry about the C API.  Numpy removes loops so you can add, subtract, multiply arrays quickly (among MANY other things).  Cython translates python code to C which you can then compile and import -- typically to gain speed here you need to provide additional hints which allow cython to optimize the generated code, ctypes is a little fragile since you have to re-specify your C function prototype, but otherwise it's pretty easy as long as you can compile your library into a shared object ... The list could go on.\nAlso note that if you're not using numpy, you might want to check out pypy.  It claims to run your python code faster than Cpython.","Q_Score":2,"Tags":"python,c","A_Id":11420313,"CreationDate":"2012-07-10T18:59:00.000","Title":"executing c program from a python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using PyDev in eclipse with Python 2.7 on windows 7. I Installed networkx and it is properly running within Python shell but in eclipse it is showing error as it is unable to locate networkx can anyone tell me how to remove this error?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1086,"Q_Id":11421476,"Users Score":0,"Answer":"I think there are two options:\n\nRebuild your interpreter\nAdd it to your python path by appending the location of networkx to sys.path in python","Q_Score":3,"Tags":"python,eclipse,networkx","A_Id":11421571,"CreationDate":"2012-07-10T20:32:00.000","Title":"Integrate networkx in eclipse on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using PyDev in eclipse with Python 2.7 on windows 7. I Installed networkx and it is properly running within Python shell but in eclipse it is showing error as it is unable to locate networkx can anyone tell me how to remove this error?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1086,"Q_Id":11421476,"Users Score":4,"Answer":"you need to rebuild your interpreter\ngo to project > properties > pyDev-Interpreter\/Grammar\nclick the \"click here to configure\"\nremove the existing interpreter\nhit \"Auto config\" button and follow the prompts\nkind of a pain but the only way Ive found to autodiscover newly installed packages","Q_Score":3,"Tags":"python,eclipse,networkx","A_Id":11421549,"CreationDate":"2012-07-10T20:32:00.000","Title":"Integrate networkx in eclipse on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am capturing mobile snapshot(android) through monkeyrunner and with the help of some python script(i.e. for socket connection),i made it to display in an html page.but there is some time delay between the image i saw on my browser and that one on the android device.how can i synchronise these things so that the mobile screen snapshot should be visible at the sametime on the browser.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":11427168,"Users Score":1,"Answer":"It takes time for the image to get from your phone to your server to your desktop client. There's nothing you can do to change that.\nThe best you can hope to do is to benchmark your entire application, figure out where are your bottlenecks, and hope it's not the network connection itself.","Q_Score":0,"Tags":"javascript,python","A_Id":11427225,"CreationDate":"2012-07-11T06:57:00.000","Title":"how to darw the image faster in canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running an os.system(cmd) in a for-loop. Since sometimes it hangs, I am trying to use process=subprocess.pOpen(cmd) in a for-loop. But I want to know the following:\n\nIf I do sleep(60) and then check if the process is still running by using process.poll(), how do I differentiate between process actually running even after 1 minute and process that hung? \nIf I kill the process which hung, will the for-loop still continue or will it exit? \n\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":11442944,"Users Score":0,"Answer":"A common way to detect things that have stopped working is to have them emit a signal at roughly regular intervals and have another process monitor the signal.  If the monitor sees that no signal has arrived after, say, twice the interval it can take action such as killing and restarting the process.\nThis general idea can be used not only for software but also for hardware.  I have used it to restart embedded controllers by simply charging a capacitor from an a.c. coupled signal from an output bit.  A simple detector monitors the capacitor and if the voltage ever falls below a threshold it just pulls the reset line low and at the same time holds the capacitor charged for long enough for the controller to restart.\nThe principle for software is similar; one way is for the process to simply touch a file at intervals.  The monitor checks the file modification time at intervals and if it is too old kills and restarts the process.\nIn OP's case the subprocess could write a status code to a file to say how far it has got in its work.","Q_Score":2,"Tags":"python,for-loop,subprocess","A_Id":20869726,"CreationDate":"2012-07-11T23:18:00.000","Title":"python handling subprocess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running an os.system(cmd) in a for-loop. Since sometimes it hangs, I am trying to use process=subprocess.pOpen(cmd) in a for-loop. But I want to know the following:\n\nIf I do sleep(60) and then check if the process is still running by using process.poll(), how do I differentiate between process actually running even after 1 minute and process that hung? \nIf I kill the process which hung, will the for-loop still continue or will it exit? \n\nThanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":144,"Q_Id":11442944,"Users Score":4,"Answer":"I don't know of any general way to tell whether a process is hung or working.  If a process hangs due to a locking issue, then it might consume 0% CPU and you might be able to guess that it is hung and not working; but if it hangs with an infinite loop, the process might make the CPU 100% busy but not accomplish any useful work.  And you might have a process communicating on the network, talking to a really slow host with long timeouts; that would not be hung but would consume 0% CPU while waiting.\nI think that, in general, the only hope you have is to set up some sort of \"watchdog\" system, where your sub-process uses inter-process communication to periodically send a signal that means \"I'm still alive\".\nIf you can't modify the program you are running as a sub-process, then at least try to figure out why it hangs, and see if you can then figure out a way to guess that it has hung.  Maybe it normally has a balanced mix of CPU and I\/O, but when it hangs it goes in a tight infinite loop and the CPU usage goes to 100%; that would be your clue that it is time to kill it and restart.  Or, maybe it writes to a log file every 30 seconds, and you can monitor the size of the file and restart it if the file doesn't grow.  Or, maybe you can put the program in a \"verbose\" mode where it prints messages as it works (either to stdout or stderr) and you can watch those.  Or, if the program works as a daemon, maybe you can actively query it and see if it is alive; for example, if it is a database, send a simple query and see if it succeeds.\nSo I can't give you a general answer, but I have some hope that you should be able to figure out a way to detect when your specific program hangs.\nFinally, the best possible solution would be to figure out why it hangs, and fix the problem so it doesn't happen anymore.  This may not be possible, but at least keep it in mind.  You don't need to detect the program hanging if the program never hangs anymore!\nP.S. I suggest you do a Google search for \"how to monitor a process\" and see if you get any useful ideas from that.","Q_Score":2,"Tags":"python,for-loop,subprocess","A_Id":11443356,"CreationDate":"2012-07-11T23:18:00.000","Title":"python handling subprocess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django to send iOS push notifications.  To do that, I need to access a .pem certificate file currently stored on the server in my app directory along with views.py, models.py, admin.py, etc.  When I try to send a push notification from a python shell on the server, everything works fine.  But when I try to send a push notification by accessing a Django view, it doesn't send and gives me an SSLError.  I think that this is because Django can't find the .pem certificate file. \nIn short, I'm wondering how a Django view function can read in another file on the server.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":846,"Q_Id":11445143,"Users Score":1,"Answer":"Never mind, I tried it again using an absolute file path, and it worked after I restarted Django.","Q_Score":1,"Tags":"python,ios,django,apple-push-notifications","A_Id":11471280,"CreationDate":"2012-07-12T04:47:00.000","Title":"Django Access File on Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I gave my CustomTreeCtrl the TR_HAS_VARIABLE_ROW_HEIGHT style. But I am not sure where to go from there to change the height of the items inside the tree.\nI cant really find anything on the API or online.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":138,"Q_Id":11460864,"Users Score":0,"Answer":"I think all you have to do is change the font size of the item.  That's what it looks like in the wxPython demo anyway. You could ask on the wxPython users group though. The author of that widget is on there most of the time and is very helpful.","Q_Score":0,"Tags":"python,wxpython,wxwidgets","A_Id":11471540,"CreationDate":"2012-07-12T21:20:00.000","Title":"how to use CustomTreeCtrl with the TR_HAS_VARIABLE_ROW_HEIGHT style to change the items height?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make very simple application in Python which:\n\nWhen REST calls PUT\/DEL\/GET are recived than response code is 200\nWhen REST call create is recived than response code is 201\n\nI tried with sockets but I don't know how to send 201.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":11470856,"Users Score":2,"Answer":"Use an existing web framework such as Flask or Django.  Doing this by yourself with sockets is way too much work, it's not worth it.","Q_Score":2,"Tags":"python,rest,http-status-codes","A_Id":11470884,"CreationDate":"2012-07-13T12:49:00.000","Title":"Recive REST and Response http codes in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a package to depend the particular version range e.g. >= 0.5.0, < 0.7.0.  Is it possible in install_requires option, and if so how should it be?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":21786,"Q_Id":11472810,"Users Score":2,"Answer":"Another way to it is to use wildcards.\nThis does not apply to >= 0.5.0, < 0.7.0, but in case you decide that all maintenance releases should be supported (e.g. 0.5.0 to 0.5.x), you can use\n== 0.5.* \ne.g.\ndocutils == 0.3.*","Q_Score":61,"Tags":"python,setuptools","A_Id":55708951,"CreationDate":"2012-07-13T14:45:00.000","Title":"How to specify version ranges in install_requires (setuptools, distribute)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am launching IronPython 2.7.3 on Windows 7 and it is taking more than 15 seconds. Why is it so slow? And how to fix it? The computer is a Samsung NP300E5A(Celeron B800,2gb) notebook.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":345,"Q_Id":11475925,"Users Score":5,"Answer":"There are a few reason why IronPython is slow to startup.\nFirst, if you didn't use the installer (which will ngen the assemblies), the JIT compiler has to convert the IronPython assemblies from MSIL bytecode to native code, and that takes time, as it's a lot of code. So use the installer on manually ngen the assemblies.\nSecond, the actual Python code is also JIT compiled, although not right away to reduce the penalty; startup time used to be much worse when all Python code was JITted. The .NET JIT isn't fast enough for my liking.\nFinally, it's not a powerhouse of a laptop. That said, even on my SSD-equipped quad core it still takes a few seconds to get started.\nIronPython's startup time has improved a lot, to the point where it's now really hard to optimize further - profiling is hard (small sample size) and there's no obvious wins. It's \"uniformly slow code\" now, unfortunately.\nIronPython's strength right now lies in long-running processes where the JIT can get some big wins, and not in short ones where it's more of a hindrance.","Q_Score":2,"Tags":"python,ironpython","A_Id":11476423,"CreationDate":"2012-07-13T18:06:00.000","Title":"IronPython launching very slowly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been at this for a few hours... how to use python to get all enclosing files from a folder... now by enclosing I mean all the files enclosed within a folder within a folder etc.  So all the files beyond a certain point using Python.\nI have tried to use glob.glob() and listdir() to do this, but those will just only work within the first level of code.  I could get this to work if there was a way that python could differentiate between a file and a folder?  Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":11479978,"Users Score":5,"Answer":"You want os.walk(). It will give you a list of files and folders in each directory under the starting directory.","Q_Score":0,"Tags":"python","A_Id":11479983,"CreationDate":"2012-07-14T00:33:00.000","Title":"Python get list of all enclosing files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In comparison to Java (in a string), you would do something like \"First Line\\r\\nSecond Line\".\nSo how would you do that in Python, for purposes of writing multiple lines to a regular file?","AnswerCount":15,"Available Count":3,"Score":0.0532828229,"is_accepted":false,"ViewCount":2399304,"Q_Id":11497376,"Users Score":4,"Answer":"Most escape characters in string literals from Java are also valid in Python, such as \"\\r\" and \"\\n\".","Q_Score":410,"Tags":"python,line-breaks,file-writing","A_Id":11497399,"CreationDate":"2012-07-16T02:14:00.000","Title":"How do I specify new lines on Python, when writing on files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In comparison to Java (in a string), you would do something like \"First Line\\r\\nSecond Line\".\nSo how would you do that in Python, for purposes of writing multiple lines to a regular file?","AnswerCount":15,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":2399304,"Q_Id":11497376,"Users Score":6,"Answer":"The same way with '\\n', though you'd probably not need the '\\r'. Is there a reason you have it in your Java version? If you do need\/want it, you can use it in the same way in Python too.","Q_Score":410,"Tags":"python,line-breaks,file-writing","A_Id":11497389,"CreationDate":"2012-07-16T02:14:00.000","Title":"How do I specify new lines on Python, when writing on files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In comparison to Java (in a string), you would do something like \"First Line\\r\\nSecond Line\".\nSo how would you do that in Python, for purposes of writing multiple lines to a regular file?","AnswerCount":15,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":2399304,"Q_Id":11497376,"Users Score":10,"Answer":"In Python you can just use the new-line character, i.e. \\n","Q_Score":410,"Tags":"python,line-breaks,file-writing","A_Id":11497390,"CreationDate":"2012-07-16T02:14:00.000","Title":"How do I specify new lines on Python, when writing on files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm gonna write a web service which will allow upload\/download of files, managing permissions and users. It will be the interface to which a Desktop app or Mobile App will communicate. I was wondering which of the web frameworks I should use to to that?\nIt is a sort of remote storage for media files.\nI am going to host the web service on EC2 in a Linux environment. It should be fast (obviously) because It will have to handle tens of requests per second, transferring lots of data (GBs)... Communication will be done using JSon... But how to deal with binary data? If I use base64, it will grow by 33%...\nI think web2py should be ok, because it is very stable and mature project, but wanted other suggestions before choosing.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":11505231,"Users Score":2,"Answer":"I'm no doubt going to be shot down for this answer, but it needs to be said...\nYou're going to write a service that allows tens of transfers a second, with very large file sizes... Uptime is going to be essential and so is transfer speeds etc...\nIf this is for a business, and not just a personal pet project get the personal responsible for the IT budget to give \"Box\" or \"DropBox\" some pennies and use their services (I am not affiliated with either company).\nOn a business level, this gets you up and running straight off, would probably end up cheaper than you coding, designing, debugging, paying for EC2 etc...\nMore related to your question:\nFlask seems to be an up-coming and usable \"simple\" framework. That should provide all the functionality without all the bells and whistles.\nThe other I would spend time looking at would be Pyramid - which when using a very basic starter template is very simple, but you've got the machinery behind it to really get quite complex things done. (You can mix url dispatch and traversal where necessary for instance).","Q_Score":0,"Tags":"python,json,web-services,web-frameworks","A_Id":11505774,"CreationDate":"2012-07-16T13:20:00.000","Title":"Python web framework suggestion for a web service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having much trouble trying to understand just how the multiprocessing queue works on python and how to implement it. Lets say I have two python modules that access data from a shared file, let's call these two modules a writer and a reader. My plan is to have both the reader and writer put requests into two separate multiprocessing queues, and then have a third process pop these requests in a loop and execute as such.\nMy main problem is that I really don't know how to implement multiprocessing.queue correctly, you cannot really instantiate the object for each process since they will be separate queues, how do you make sure that all processes relate to a shared queue (or in this case, queues)","AnswerCount":7,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":221619,"Q_Id":11515944,"Users Score":9,"Answer":"in \"from queue import Queue\" there is no module called queue, instead multiprocessing should be used. Therefore, it should look like \"from multiprocessing import Queue\"","Q_Score":136,"Tags":"python,multithreading,multiprocessing","A_Id":48592969,"CreationDate":"2012-07-17T04:17:00.000","Title":"How to use multiprocessing queue in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know how to have a program wait for another program to finish a task. I'm not sure what I'd look for for that...\nAlso, I'm using a mac.\nI'd like to use Python or perhaps even applescript (I could just osascript python if the solution if for applescript anyway)\nBasically this program \"MPEGstreamclip\" converts videos, and it opens what appears to be 2 new windows while it's converting. One window is a conversion progress bar, and the other window is a preview of the conversion. (Not sure if these actually count as windows) \n(Also, MPEGstreamclip does not have an applescript dictionary, so as far as I know, it can't listen for certain window names existence)\nBut basically I want my program to listen for when MPEGstreamclip is done, and then run its tasks.\nIf it helps, when the conversion is done, the mpegstreamclip icon in the dock bounces once. I'm not sure what that means but I'd think you could use that to trigger something couldn't you?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":220,"Q_Id":11517743,"Users Score":1,"Answer":"I realized GUI applescript was the answer in this scenario. With it I could tell the PROCESS to get every window, and that worked. However, I'm leaving this up because I'd like to know other ways. I'm sure this GUI workaround won't work for everything.","Q_Score":0,"Tags":"python,process,applescript","A_Id":11518020,"CreationDate":"2012-07-17T07:21:00.000","Title":"Waiting for a program to finish its task","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had installed virtualenv on the system with python2.6.\nI upgraded the system python to 2.7, but the virtualenv still has affinity for python2.6.\nI tried easy_install --upgrade virtualenv, but that didn't change anything.\nDoes anyone know how to update the system installed virtualenv to use the new python2.7 on the system?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2650,"Q_Id":11528327,"Users Score":1,"Answer":"You could try pip install -U python from within the virtual environment, not sure what it would break.\nYou could also change the symlinks that point to the old Python, but not sure what side effects that would have.\nI would recommend the safest path, that is to first pip freeze > installed.txt and then recreate your virtualenv with your new Python and pip install -r installed.txt in it.","Q_Score":2,"Tags":"python,virtualenv","A_Id":11528399,"CreationDate":"2012-07-17T18:07:00.000","Title":"How to upgrade virtualenv to use a new system python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I specify the column that I want in my query using a model (it selects all columns by default)? I know how to do this with the sqlalchmey session: session.query(self.col1), but how do I do it with with models?  I can't do SomeModel.query(). Is there a way?","AnswerCount":10,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":191024,"Q_Id":11530196,"Users Score":2,"Answer":"result = ModalName.query.add_columns(ModelName.colname, ModelName.colname)","Q_Score":183,"Tags":"python,sqlalchemy,flask-sqlalchemy","A_Id":68064416,"CreationDate":"2012-07-17T20:16:00.000","Title":"Flask SQLAlchemy query, specify column names","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently writing a new test runner for Django and I'd like to know if it's possible to TDD my test runner using my own test runner. Kinda like compiler bootstrapping where a compiler compiles itself.\nAssuming it's possible, how can it be done?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":123,"Q_Id":11545759,"Users Score":10,"Answer":"Yes. One of the examples Kent Beck works through in his book \"Test Driven Development: By Example\" is a test runner.","Q_Score":2,"Tags":"python,django,testing,tdd,bootstrapping","A_Id":11546149,"CreationDate":"2012-07-18T16:11:00.000","Title":"Is it possible to TDD when writing a test runner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently writing a new test runner for Django and I'd like to know if it's possible to TDD my test runner using my own test runner. Kinda like compiler bootstrapping where a compiler compiles itself.\nAssuming it's possible, how can it be done?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":11545759,"Users Score":4,"Answer":"Bootstrapping is a cool technique, but it does have a circular-definition problem. How can you write tests with a framework that doesn't exist yet?\nBootstrapping compilers can get around this problem in several ways, but it's my understanding that usually the first implementation isn't bootstrapped. Later bootstraps would be rewrites that then use the original compiler to compile themselves. \nSo use an existing framework to write it the first time out. Then, once you have a stable release, you can re-write the tests using your own test-runner.","Q_Score":2,"Tags":"python,django,testing,tdd,bootstrapping","A_Id":11546191,"CreationDate":"2012-07-18T16:11:00.000","Title":"Is it possible to TDD when writing a test runner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a GUI that is dependent on information from MySQL table, what i want to be able to do is to display a message every time the table is updated with new data.  I am not sure how to do this or even if it is possible. I have codes that retrieve the newest MySQL update but I don't know how to have a message every time new data comes into a table. Thanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1004,"Q_Id":11567357,"Users Score":3,"Answer":"Quite simple and straightforward solution will be just to poll the latest autoincrement id from your table, and compare it with what you've seen at the previous poll. If it is greater -- you have new data. This is called 'active polling', it's simple to implement and will suffice if you do this not too often. So you have to store the last id value somewhere in your GUI. And note that this stored value will reset when you restart your GUI application -- be sure to think what to do at the start of the GUI. Probably you will need to track only insertions that occur while GUI is running -- then, at the GUI startup you need just to poll and store current id value, and then poll peroidically and react on its changes.","Q_Score":1,"Tags":"python,mysql","A_Id":11567806,"CreationDate":"2012-07-19T18:48:00.000","Title":"Scanning MySQL table for updates Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.\nBut passwords--like any other setting--seem like they should be versioned. So what is the proper way to keep passwords version controlled?\nI imagine it would involve keeping the secrets in their own \"secrets settings\" file and having that file encrypted and version controlled. But what technologies? And how to do this properly? Is there a better way entirely to go about it?\n\nI ask the question generally, but in my specific instance I would like to store secret keys and passwords for a Django\/Python site using git and github.\nAlso, an ideal solution would do something magical when I push\/pull with git--e.g., if the encrypted passwords file changes a script is run which asks for a password and decrypts it into place.\n\nEDIT: For clarity, I am asking about where to store production secrets.","AnswerCount":17,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":36273,"Q_Id":11575398,"Users Score":10,"Answer":"I suggest using configuration files for that and to not version them.\nYou can however version examples of the files.\nI don't see any problem of sharing development settings. By definition it should contain no valuable data.","Q_Score":140,"Tags":"python,django,git,version-control","A_Id":11575518,"CreationDate":"2012-07-20T08:11:00.000","Title":"How can I save my secret keys and password securely in my version control system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.\nBut passwords--like any other setting--seem like they should be versioned. So what is the proper way to keep passwords version controlled?\nI imagine it would involve keeping the secrets in their own \"secrets settings\" file and having that file encrypted and version controlled. But what technologies? And how to do this properly? Is there a better way entirely to go about it?\n\nI ask the question generally, but in my specific instance I would like to store secret keys and passwords for a Django\/Python site using git and github.\nAlso, an ideal solution would do something magical when I push\/pull with git--e.g., if the encrypted passwords file changes a script is run which asks for a password and decrypts it into place.\n\nEDIT: For clarity, I am asking about where to store production secrets.","AnswerCount":17,"Available Count":6,"Score":0.0470241165,"is_accepted":false,"ViewCount":36273,"Q_Id":11575398,"Users Score":4,"Answer":"EDIT: I assume you want to keep track of your previous passwords versions - say, for a script that would prevent password reusing etc.\nI think GnuPG is the best way to go - it's already used in one git-related project (git-annex) to encrypt repository contents stored on cloud services. GnuPG (gnu pgp) provides a very strong key-based encryption.\n\nYou keep a key on your local machine.\nYou add 'mypassword' to ignored files.\nOn pre-commit hook you encrypt the mypassword file into the mypassword.gpg file tracked by git and add it to the commit.\nOn post-merge hook you just decrypt mypassword.gpg into mypassword.\n\nNow if your 'mypassword' file did not change then encrypting it will result with same ciphertext and it won't be added to the index (no redundancy). Slightest modification of mypassword results in radically different ciphertext and mypassword.gpg in staging area differs a lot from the one in repository, thus will be added to the commit. Even if the attacker gets a hold of your gpg key he still needs to bruteforce the password. If the attacker gets an access to remote repository with ciphertext he can compare a bunch of ciphertexts, but their number won't be sufficient to give him any non-negligible advantage.\nLater on you can use .gitattributes to provide an on-the-fly decryption for quit git diff of your password.\nAlso you can have separate keys for different types of passwords etc.","Q_Score":140,"Tags":"python,django,git,version-control","A_Id":11576543,"CreationDate":"2012-07-20T08:11:00.000","Title":"How can I save my secret keys and password securely in my version control system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.\nBut passwords--like any other setting--seem like they should be versioned. So what is the proper way to keep passwords version controlled?\nI imagine it would involve keeping the secrets in their own \"secrets settings\" file and having that file encrypted and version controlled. But what technologies? And how to do this properly? Is there a better way entirely to go about it?\n\nI ask the question generally, but in my specific instance I would like to store secret keys and passwords for a Django\/Python site using git and github.\nAlso, an ideal solution would do something magical when I push\/pull with git--e.g., if the encrypted passwords file changes a script is run which asks for a password and decrypts it into place.\n\nEDIT: For clarity, I am asking about where to store production secrets.","AnswerCount":17,"Available Count":6,"Score":0.0235250705,"is_accepted":false,"ViewCount":36273,"Q_Id":11575398,"Users Score":2,"Answer":"Encrypt the passwords file, using for example GPG. Add the keys on your local machine and on your server. Decrypt the file and put it outside your repo folders.\nI use a passwords.conf, located in my homefolder. On every deploy this file gets updated.","Q_Score":140,"Tags":"python,django,git,version-control","A_Id":11666554,"CreationDate":"2012-07-20T08:11:00.000","Title":"How can I save my secret keys and password securely in my version control system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.\nBut passwords--like any other setting--seem like they should be versioned. So what is the proper way to keep passwords version controlled?\nI imagine it would involve keeping the secrets in their own \"secrets settings\" file and having that file encrypted and version controlled. But what technologies? And how to do this properly? Is there a better way entirely to go about it?\n\nI ask the question generally, but in my specific instance I would like to store secret keys and passwords for a Django\/Python site using git and github.\nAlso, an ideal solution would do something magical when I push\/pull with git--e.g., if the encrypted passwords file changes a script is run which asks for a password and decrypts it into place.\n\nEDIT: For clarity, I am asking about where to store production secrets.","AnswerCount":17,"Available Count":6,"Score":0.0352794699,"is_accepted":false,"ViewCount":36273,"Q_Id":11575398,"Users Score":3,"Answer":"Provide a way to override the config\nThis is the best way to manage a set of sane defaults for the config you checkin without requiring the config be complete, or contain things like hostnames and credentials.  There are a few ways to override default configs.\nEnvironment variables (as others have already mentioned) are one way of doing it.\nThe best way is to look for an external config file that overrides the default config values.  This allows you to manage the external configs via a configuration management system like Chef, Puppet or Cfengine.  Configuration management is the standard answer for the management of configs separate from the codebase so you don't have to do a release to update the config on a single host or a group of hosts.\nFYI: Encrypting creds is not always a best practice, especially in a place with limited resources.  It may be the case that encrypting creds will gain you no additional risk mitigation and simply add an unnecessary layer of complexity.  Make sure you do the proper analysis before making a decision.","Q_Score":140,"Tags":"python,django,git,version-control","A_Id":11689937,"CreationDate":"2012-07-20T08:11:00.000","Title":"How can I save my secret keys and password securely in my version control system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.\nBut passwords--like any other setting--seem like they should be versioned. So what is the proper way to keep passwords version controlled?\nI imagine it would involve keeping the secrets in their own \"secrets settings\" file and having that file encrypted and version controlled. But what technologies? And how to do this properly? Is there a better way entirely to go about it?\n\nI ask the question generally, but in my specific instance I would like to store secret keys and passwords for a Django\/Python site using git and github.\nAlso, an ideal solution would do something magical when I push\/pull with git--e.g., if the encrypted passwords file changes a script is run which asks for a password and decrypts it into place.\n\nEDIT: For clarity, I am asking about where to store production secrets.","AnswerCount":17,"Available Count":6,"Score":0.0235250705,"is_accepted":false,"ViewCount":36273,"Q_Id":11575398,"Users Score":2,"Answer":"This is what I do:\n\nKeep all secrets as env vars in $HOME\/.secrets (go-r perms) that $HOME\/.bashrc sources (this way if you open .bashrc in front of someone, they won't see the secrets)\nConfiguration files are stored in VCS as templates, such as config.properties stored as config.properties.tmpl\nThe template files contain a placeholder for the secret, such as:\nmy.password=##MY_PASSWORD##\nOn application deployment, script is ran that transforms the template file into the target file, replacing placeholders with values of environment variables, such as changing ##MY_PASSWORD## to the value of $MY_PASSWORD.","Q_Score":140,"Tags":"python,django,git,version-control","A_Id":49701069,"CreationDate":"2012-07-20T08:11:00.000","Title":"How can I save my secret keys and password securely in my version control system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I keep important settings like the hostnames and ports of development and production servers in my version control system. But I know that it's bad practice to keep secrets (like private keys and database passwords) in a VCS repository.\nBut passwords--like any other setting--seem like they should be versioned. So what is the proper way to keep passwords version controlled?\nI imagine it would involve keeping the secrets in their own \"secrets settings\" file and having that file encrypted and version controlled. But what technologies? And how to do this properly? Is there a better way entirely to go about it?\n\nI ask the question generally, but in my specific instance I would like to store secret keys and passwords for a Django\/Python site using git and github.\nAlso, an ideal solution would do something magical when I push\/pull with git--e.g., if the encrypted passwords file changes a script is run which asks for a password and decrypts it into place.\n\nEDIT: For clarity, I am asking about where to store production secrets.","AnswerCount":17,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":36273,"Q_Id":11575398,"Users Score":0,"Answer":"You could use EncFS if your system provides that. Thus you could keep your encrypted data as a subfolder of your repository, while providing your application a decrypted view to the data mounted aside. As the encryption is transparent, no special operations are needed on pull or push. \nIt would however need to mount the EncFS folders, which could be done by your application based on an password stored elsewhere outside the versioned folders (eg. environment variables).","Q_Score":140,"Tags":"python,django,git,version-control","A_Id":11713674,"CreationDate":"2012-07-20T08:11:00.000","Title":"How can I save my secret keys and password securely in my version control system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Database A resides on server server1, while database B resides on server server2.\nBoth servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).\nIn such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B?\nIf so, how do I go about it, programatically,","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":11585494,"Users Score":0,"Answer":"Without doing something like replicating database A onto the same server as database B and then doing the JOIN, this would not be possible.","Q_Score":0,"Tags":"mysql,python-2.7","A_Id":11585571,"CreationDate":"2012-07-20T19:04:00.000","Title":"MySQL Joins Between Databases On Different Servers Using Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Database A resides on server server1, while database B resides on server server2.\nBoth servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).\nIn such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B?\nIf so, how do I go about it, programatically,","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":11585494,"Users Score":0,"Answer":"I don't know python, so I'm going to assume that when you do a query it comes back to python as an array of rows.\nYou could query table A and after applying whatever filters you can, return that result to the application. Same to table B. Create a 3rd Array, loop through A, and if there is a joining row in B, add that joined row to the 3rd array. In the end the 3rd array would have the equivalent of a join of the two tables. It's not going to be very efficient, but might work okay for small recordsets.","Q_Score":0,"Tags":"mysql,python-2.7","A_Id":11585697,"CreationDate":"2012-07-20T19:04:00.000","Title":"MySQL Joins Between Databases On Different Servers Using Python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python and sqlite3 to handle a website. I need all timezones to be in localtime, and I need daylight savings to be accounted for. The ideal method to do this would be to use sqlite to set a global datetime('now') to be +10 hours.\nIf I can work out how to change sqlite's 'now' with a command, then I was going to use a cronjob to adjust it (I would happily go with an easier method if anyone has one, but cronjob isn't too hard)","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3357,"Q_Id":11590082,"Users Score":2,"Answer":"you can try this code, I am in Taiwan , so I add 8 hours:\nDateTime('now','+8 hours')","Q_Score":1,"Tags":"python,sqlite,timezone,dst","A_Id":21014456,"CreationDate":"2012-07-21T06:48:00.000","Title":"sqlite timezone now","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am testing a Log-parser that does a infinite loop (on purpose) with a cool down of 3 seconds every recurrence.\nEventually I will link all the data to a GUI front-end so I can call a stop to the loop when the user is ready with parsing.\nThe (small) problem now is, when testing the output in the Terminal (in OSX) when I do CTRL + Z to cancel the process my activity monitor keeps showing the process as active (probably because of the loop?).\nSo the question: How can I call (without extra non-native libraries, if possible) to stop the whole process when calling a CTRL + Z in Terminal? When I quit the Terminal, all python processes get killed, but I would like to know how to do it while the Terminal is still running :).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6153,"Q_Id":11592433,"Users Score":6,"Answer":"CTRL + Z sends to background, CTRL + C is to kill. However I am talking Linux here and Mac might be something different.","Q_Score":1,"Tags":"python,terminal,osx-lion,infinite-loop","A_Id":11592469,"CreationDate":"2012-07-21T13:05:00.000","Title":"keyboard interrupt doesn't stop my interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am making a music player in python\/wxpython. I have a listbox with all the songs, and the music player plays the selected song. I am now trying to make a \"next button\" to select the next item in the listbox and play it. How would I go about doing that? Is there something like GetNextString() or something along those lines?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":11594044,"Users Score":0,"Answer":"Not to my knowledge. Just keep track of the currently selected item's placement in the list and update it by incrementing or decrementing it.","Q_Score":0,"Tags":"python,wxpython","A_Id":11613711,"CreationDate":"2012-07-21T16:47:00.000","Title":"how to select next item of wxlistbox in wxpython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a model that has been already built and i need to add some validation managment. (accessing to two fields and checking data, nothing too dramatic)\nI was wondering about the exact difference between models and forms at a validation point of view and if i would be able to just make a clean method raising errors as in a formview in a model view ?\n\nfor extra knowledge, why are thoses two things separated ?\n\nAnd finnaly, what would you do ? There are already some methods written for the model and i don't know yet if i would rewrite it to morph it into a form and simply add the clean() method + i don't exactly know how they work. \nOh, and everything is in the admin interface, havn't yet worked a lot on it since i started django not so long ago.\nThanks in advance,","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1664,"Q_Id":11609943,"Users Score":0,"Answer":"Generally models represent business entities which may be stored in some persistent storage (usually relational DB). Forms are used to render HTML forms which may retreive data from users.\nDjango supports creating forms on the basis of models (using ModelForm class). Forms may be used to fetch data which should be saved in persistent storage, but that's not only the case - one may use forms just to get data to be searched in persistent storage or passed to external service, feed some application counters, test web browser engines, render some text on the basis of data entered by user (e.g. \"Hello USERNAME\"), login user etc.\nCalling save() on model instance should guarantee that data will be saved in persistent storage if and only data is valid - that will provide consistent mechanism of validation of data before saving to persistent storage, regardless whether business entity is to be saved after user clicks \"Save me\" button on web page or in django interactive shell user will execute save() method of model instance.","Q_Score":2,"Tags":"python,django,forms,model","A_Id":11610267,"CreationDate":"2012-07-23T09:37:00.000","Title":"Difference between Model and Form validation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a web service that requires user input python code to be executed on my server (we have checks for code injection).  I have to import a rather large module so I would like to make sure that I am not starting up python and importing the module from scratch each time something runs (it takes about 4-6s).  \nTo do this I was planning to create a python (3.2) deamon that imports the user input code as a module, executes it and then delete\/garbage collect that module.  I need to make sure that that module is completely gone from RAM since this process will continue until the server is restarted.  I have read a bunch of things that say this is a very difficult thing to do in python.\nWhat is the best way to do this?  Would it be better to use exec to define a function with the user input code (for variable scoping) and then execute that function and somehow remove the function?   Or is there a better way to do this process that I have missed?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":477,"Q_Id":11611351,"Users Score":0,"Answer":"You could perhaps consider to create a pool of python daemon processes?\nTheir purpose would be to serve one request and to die afterwards.\nYou would have to write a pool-manager that ensures that there are always X daemon processes waiting for an incoming request. (X being the number of waiting daemon processes: depending on the required workload). The pool-manager would have to observe the pool of daemon processes and start new instances every time a process was finished.","Q_Score":0,"Tags":"python,module,daemon","A_Id":11614012,"CreationDate":"2012-07-23T11:10:00.000","Title":"User Input Python Script Executing Daemon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a python script which I have made dropable using a registry-key, but it does not seem to work. The cmd.exe window just flashes by, can I somehow make the window stay up, or save the output?\nEDIT: the problem was that it gave the whole path not only the filename.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":5043,"Q_Id":11627846,"Users Score":1,"Answer":"Either right-click your script and remove Program->Close on exit checkbox in its properties, or use cmd \/k as part of its calling line.\nThink twice before introducing artificial delays or need to press key - this will make your script mostly unusable in any unattended\/pipe calls.","Q_Score":6,"Tags":"python,registry,cmd","A_Id":11628345,"CreationDate":"2012-07-24T09:23:00.000","Title":"Keep cmd.exe open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script which I have made dropable using a registry-key, but it does not seem to work. The cmd.exe window just flashes by, can I somehow make the window stay up, or save the output?\nEDIT: the problem was that it gave the whole path not only the filename.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":5043,"Q_Id":11627846,"Users Score":1,"Answer":"Another possible option is to create a basic TKinter GUI with a textarea and a close button. Then run that with subprocess or equiv. and have that take the stdout from your python script executed with pythonw.exe so that no CMD prompt appears to start with.\nThis keeps it purely using Python stdlib's and also means you could use the GUI for setting options or entering parameters...\nJust an idea.","Q_Score":6,"Tags":"python,registry,cmd","A_Id":11628145,"CreationDate":"2012-07-24T09:23:00.000","Title":"Keep cmd.exe open","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to have a string containing 4 pound signs..how can I accomplish this in Python without commenting the string out due to the pound signs?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":17557,"Q_Id":11638579,"Users Score":1,"Answer":"If some IDE interprets '####' as a half-baked string plus a comment, change the IDE!","Q_Score":2,"Tags":"python","A_Id":12689109,"CreationDate":"2012-07-24T20:10:00.000","Title":"Using POUND SIGN as a string in PYTHON?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I debug a Python extension written in C? I found some links that said we need to get the Python debug built, but how do we do that if we don't have root access? I have Python 2.7 installed.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":262,"Q_Id":11647810,"Users Score":1,"Answer":"You can compile a debug-enabled version python in your home folder without having root access and develop the C extension against that version.","Q_Score":1,"Tags":"python,debugging","A_Id":11648687,"CreationDate":"2012-07-25T10:33:00.000","Title":"How do I debug a Python extension written in C?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running Windows 7 currently, and I remember when using Linux at the school computers I was able to type \"gedit &\" into the terminal for example to open up the gedit text editor. I was wondering whether there is a similar process to open IDLE, and for that matter a Python program\/script by typing it into the \"terminal-equivalent.\" I'm a complete newbie, so I may be off-base a bit...anyways, so there is this terminal-like program called python.exe, and it seems like it should be able to open Python-related software (like IDLE), and I was wondering 1) what python.exe is for, 2) whether it can be treated like a Linux terminal, and 3) how to do stuff in it. I've tried various commands and I get a syntax error for virtually everything. Much appreciated!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2121,"Q_Id":11661053,"Users Score":0,"Answer":"python.exe is Python, the python interpreter specifically.","Q_Score":0,"Tags":"python,python-idle","A_Id":11661081,"CreationDate":"2012-07-26T01:22:00.000","Title":"How to start Python IDLE from python.exe window if possible, and if not, what is python.exe even used for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm at the start of creating a chess engine. When I created a function that checks if a move is legal, first I had to make the move and then check if the move had put my king in check and then unmake it. \nAfter giving some thought on how to make a function that unmakes a move, I decided it's much simpler to just copy the board and make the hypothetical move on the copied board, so it doesn't change the original board structure at all.\nBut I'm worried this might be a bad idea because when I get to the AI part, as I have to copy the board completely, and it might slow down my engine. Is it so? Could you please share your thoughts about this, since I don't know much about algorithm complexity and that kind of stuff.\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":1935,"Q_Id":11668748,"Users Score":5,"Answer":"Generally the unmake approach is used more as it avoids unnecessary copying of the board.  This is especially true if you want to keep your pieces in two different forms in your Position class; as a traditional 8x8 array and as a set of 64-bit unsigned integers (bitboards).\nYou need to create a class to store your UnmakeMoveInfo which holds:\n\nThe from\/to of the move.\nThe previous position hash.\nThe 'halfmove clock'.\nThe en-passant mask.\nThe captured piece.\nThe previous position flags (check, ep_move, castling rights).\n\nSo that you have all the info required to unmake the move.","Q_Score":4,"Tags":"python,chess","A_Id":11668833,"CreationDate":"2012-07-26T11:55:00.000","Title":"Unmake move vs copy board in chess programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to show continuous real time updates in browser like facebook ticker, meetup.com home page does? In python, PHP, node.js and what would be the performance impact at the server side ?\nAlso how could we achieve the same update thing if the page is cached by an CDN like akamai?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5085,"Q_Id":11688397,"Users Score":0,"Answer":"You could use a poll, long-poll or if you want a push system. Easiest would be a poll. However, all solutions require client side coding.\nPerformance impact depends on your solution. Easiest to implement would be a poll. A poll with short frequency does effectively a request every, say 100ms ot simulate real time. A long-poll would be of less impact, but it would keep open a lot of request during a more or less time.","Q_Score":8,"Tags":"php,python,node.js,asynchronous,real-time","A_Id":11688432,"CreationDate":"2012-07-27T13:08:00.000","Title":"How to show continuous real time updates like facebook ticker, meetup.com home page does?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an application written in Python 2.7 that reads user's file from the hard-drive using os.walk.\nThe application requires a UTF-8 system locale (we check the env variables before it starts) because we handle files with Unicode characters (audio files with the artist name in it for example), and want to make sure we can save these files with the correct file name to the filesystem.\nSome of our users have UTF-8 locales (therefore a UTF-8 fs), but still somehow manage to have ISO-8859-1 files stored on their drive. This causes problems when our code tries to os.walk() these directories as Python throws an exception when trying to decode this sequence of ISO-8859-1 bytes using UTF-8.\nSo my question is, how do I get python to ignore this file and move on to the next one instead of aborting the entire os.walk(). Should I just roll my own os.walk() function?\nEdit: Until now we've been telling our users to use the convmv linux command to correct their filenames, however many users have various different types of encodings (8859-1, 8859-2, etc.), and using convmv requires the user to make an educated guess on what files have what encoding before they run convmv on each one individually.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1707,"Q_Id":11689223,"Users Score":0,"Answer":"Use character encoding detection,  chardet modules for python work well for determining actual encoding with some confidence.  \"as appropriate\" -- You either know the encoding or you have to guess at it.  If with chardet you guess wrong, at least you tried.","Q_Score":0,"Tags":"python,unicode,utf-8,filesystems,iso-8859-1","A_Id":11835980,"CreationDate":"2012-07-27T13:53:00.000","Title":"Python, UTF-8 filesystem, iso-8859-1 files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been trying for weeks to get Microsoft Visual Studio 2010 to create a DLL for me with SWIG. If you have already gone through this process, would you be so kind as to give a thoughtful step-by-step process explanation? I've looked everywhere online and have spent many many hours trying to do this; but all of the tutorials that I have found are outdated or badly explained.\nI have succeeded in going through this process with cygwin; but as some of you know, a cygwin DLL is not very practical.\nAs a result, I have .i, .cpp, and .h files that I know can create a DLL together. I just need to know how to do this with Visual Studio C++ 2010. The language that I am targeting is Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":14880,"Q_Id":11693047,"Users Score":55,"Answer":"Step-by-step instructions.  This assumes you have the source and are building a single DLL extension that links the source directly into it.  I didn't go back through it after creating a working project, so I may have missed something.  Comment on this post if you get stuck on a step.  If you have an existing DLL and want to create a Python extension DLL that wraps it, this steps are slightly different.  If you need help with that comment on this post and I will extend it.\nEdit 8\/19\/2012: If starting with a C example, don't use -c++ in step 13 and use .c instead of .cxx for the wrap file extension in steps 14 and 19.\n\nStart Visual Studio 2010\nFile, New, Project from Existing Code...\nSelect \"Visual C++\" project type and click Next.\nEnter project file location where the .cpp\/.h\/.i files are.\nFor Project Name, choose the name used in %module statement in your .i file (case matters).\nSelect project type \"Dynamically linked library (DLL) project\" and click Next.\nAdd to Include search paths the path to the Python.h file, usually something like \"C:\\Python27\\include\" and click Next.\nClick Finish.\nRight-click the Project in Solution Explorer, Add, Existing Item..., and select your .i file.\nRight-click the .i file, Properties, and select Configuration \"All Configurations\".\nChange Item Type to \"Custom Build Tool\" and click Apply.\nSelect \"Custom Build Tool\" in Properties (it will appear after Apply above).\nEnter Command Line of \"swig -c++ -python -outdir $(Outdir) %(Identity)\" (this assumes SWIG is in your path and redirects the generated .py file to the Debug or Release directory as needed).\nIn Outputs enter \"%(Filename)_wrap.cxx;$(Outdir)%(Filename).py\".\nClick OK.\nRight-click the .i file, and select Compile.\nRight-click the project, Add, New Filter, name it \"Generated Files\".\nRight-click \"Generated Files\", click Properties, and set \"SCC Files\" to \"False\" (if you use source-control, this prevents VS2010 trying to check in the generated files in this filter).\nRight-click \"Generated Files\", Add, Exiting Item and select the _wrap.cxx file that was generated by the compile.\nRight-click the project, Properties.\nSelect Configuration \"All Configurations\".\nSelect Configuration Properties, Linker, General, Additional Library Directories and add the path to the python libraries, typically \"C:\\Python27\\libs\".\nSelect Configuration Properties, General and set TargetName to \"_$(ProjectName)\".\nSet Target Extension to \".pyd\".\nBuild the \"Release\" version of the project.  You can't build the Debug version unless you build a debug version of Python itself.\nOpen a console, go to the Release directory of the project, run python, import your module, and call a function!","Q_Score":22,"Tags":"c++,python,visual-studio-2010,swig","A_Id":11732619,"CreationDate":"2012-07-27T17:50:00.000","Title":"How to create a DLL with SWIG from Visual Studio 2010","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have successfully outsourced an expensive routine in my PyQT4 GUI to a worker QThread to prevent the GUI from going unresponsive. However, I would like the GUI to wait until the worker thread is finished processing to continue executing its own code.\nThe solution that immediately comes to my mind is to have the thread emit a signal when complete (as I understand, QThreads already do this), and then look for this signal in the main window before the rest of the code is executed. Is this hacked?\nI know QThread provides the wait() function described here , but the usage is unclear to me. I think I want to call this on the main thread, but I'm not sure how to call that in my app...?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":330,"Q_Id":11695649,"Users Score":1,"Answer":"This is a really bad plan.  Split up the 'before thread action' and 'after thread action'.  The 'after thread action' should be a slot fired by a QueuedConnection that the thread can signal.  \nDo not wait in GUI event handlers!","Q_Score":1,"Tags":"python,pyqt4,qthread,python-multithreading","A_Id":11695734,"CreationDate":"2012-07-27T21:06:00.000","Title":"How do I tell my main GUI to wait on a worker thread?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have successfully outsourced an expensive routine in my PyQT4 GUI to a worker QThread to prevent the GUI from going unresponsive. However, I would like the GUI to wait until the worker thread is finished processing to continue executing its own code.\nThe solution that immediately comes to my mind is to have the thread emit a signal when complete (as I understand, QThreads already do this), and then look for this signal in the main window before the rest of the code is executed. Is this hacked?\nI know QThread provides the wait() function described here , but the usage is unclear to me. I think I want to call this on the main thread, but I'm not sure how to call that in my app...?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":330,"Q_Id":11695649,"Users Score":0,"Answer":"If the GUI thread called the wait() function on the worker thread object, it would not return from it until the worker thread returns from its main function. This is not what you want to do.\nThe solution you describe using signal and slots seems to make plenty of sense to me. Or you could just use a boolean.","Q_Score":1,"Tags":"python,pyqt4,qthread,python-multithreading","A_Id":11695743,"CreationDate":"2012-07-27T21:06:00.000","Title":"How do I tell my main GUI to wait on a worker thread?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with urllib and urllib2 in python and am using them to retrieve images from urls.\nUsing something similar to :\n\ntry:\n    buffer=urllib2.url_open(urllib2.Request(url))\n    f.write(buffer)\n    f.close\nexcept (Errors that could occur):    #Network Errors(?)\n    print \"Failed to retrieve \"+url\n    pass\n\nNow what happens often is that the image does not load\/is broken when using the site via a normal web browser this is presumably because of high server load or because the image does not exist or could not be retrieved by the server.\nWhatever the reason may be, the image does not load and a similar situation can also\/is likely to occur when using the script. Since I do not know what error it might it throw up how do I handle it?\nI think mentioning all possible errors in the urllib2,urllib library in the except statement might be overkill so I need a better way.\n(I also might need to\/have to handle broken Wi-Fi, unreachable server and the like at times so more errors)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1816,"Q_Id":11697289,"Users Score":5,"Answer":"There are only two exceptions you'll see, HTTPError (HTTP status codes) and URLError (everything that can go wrong), so it's not like it's overkill handling both of them. You can even just catch URLError if you don't care about status codes, since HTTPError is a subclass of it.","Q_Score":5,"Tags":"python,try-catch,urllib2,urllib","A_Id":11697336,"CreationDate":"2012-07-28T00:47:00.000","Title":"Python: trying to raise multi-purpose exception for multiple error types","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm currently using urllib2 and BeautifulSoup to open and parse html data. However I've ran into a problem with a site that uses javascript to load the images after the page has been rendered (I'm trying to find the image source for a certain image on the page).\nI'm thinking Twill could be a solution, and am trying to open the page and use a regular expression with 'find' to return the html string I'm looking for. I'm having some trouble getting this to work though, and can't seem to find any documentation or examples on how to use regular expressions with Twill. \nAny help or advice on how to do this or solve this problem in general would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":225,"Q_Id":11705835,"Users Score":0,"Answer":"I'd rather user CSS selectors or \"real\" regexps on page source. Twill is AFAIK not being worked on. Have you tried BS or PyQuery with CSS selectors?","Q_Score":3,"Tags":"python,regex,beautifulsoup,twill","A_Id":11712834,"CreationDate":"2012-07-29T00:57:00.000","Title":"Using Regular Expression with Twill","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am pretty new to Django so I am creating a project to learn more about how it works. Right now I have a model that contains a URL field. I want to automatically generate a thumbnail from this url field by taking an appropriate image from the webite like facebook or reddit does. I'm guessing that I should store this image in an image field. What would be a good way to select an ideal image from the website and how can I accomplish this?\nEDIT- I'm trying to take actual images from the website rather than a picture of the website","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1630,"Q_Id":11713284,"Users Score":1,"Answer":"You'll first need to parse the html content for img src urls with something like lxml or BeautifulSoup. Then, you can feed one of those img src urls into sorl-thumbnail or easy-thumbnails as Edmon suggests.","Q_Score":2,"Tags":"python,django,image","A_Id":11748617,"CreationDate":"2012-07-29T21:53:00.000","Title":"Need to create thumbnail from user submitted url like reddit\/facebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can each node of selenium grid run different python script\/test?\n- how to setup?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":382,"Q_Id":11716677,"Users Score":0,"Answer":"Yes, use different browser configurations in the hub, and use two or more programs to contact the grid with different browsers","Q_Score":0,"Tags":"python,testing,selenium","A_Id":11718057,"CreationDate":"2012-07-30T06:58:00.000","Title":"Can each node of selenium grid run different script\/test? - how to setup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using pywinauto for gui automation for quite a long time already. Now I have to move to x64 OS. There seems to be no official version for 64 bit OS. There are clones which claim they support 64, but in practice they don't.\nOn installation there are several assertions about wrong win structures size. If commented out, the lib manages to install, but some API doesn't work. E.g. win32functions.GetMenuItemInfo() returns Error 87: wrong parameter. This API depends on struct MENUITEMINFOW (which size initially didn't pass the assertion).\nDoes anybody know how to handle this situation?\nIs there a pure pywinauto version to work without additional patches?\nAnd finally, if no answer, is there a powerful Python lib you may suggest for gui automation? With a support of 64 bit?\nThanks in advance.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2889,"Q_Id":11719619,"Users Score":1,"Answer":"Azurin, you always can use python32bit + pywinauto on your x64 OS. If you realy need python64 you also can use py2exe to compile a test in .exe and use it everywhere, even on OSes where python is not installed. :)","Q_Score":3,"Tags":"python,user-interface,64-bit,pywinauto","A_Id":12949711,"CreationDate":"2012-07-30T10:26:00.000","Title":"Looking for a way to use Pywinauto on Win x64","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using pywinauto for gui automation for quite a long time already. Now I have to move to x64 OS. There seems to be no official version for 64 bit OS. There are clones which claim they support 64, but in practice they don't.\nOn installation there are several assertions about wrong win structures size. If commented out, the lib manages to install, but some API doesn't work. E.g. win32functions.GetMenuItemInfo() returns Error 87: wrong parameter. This API depends on struct MENUITEMINFOW (which size initially didn't pass the assertion).\nDoes anybody know how to handle this situation?\nIs there a pure pywinauto version to work without additional patches?\nAnd finally, if no answer, is there a powerful Python lib you may suggest for gui automation? With a support of 64 bit?\nThanks in advance.","AnswerCount":4,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2889,"Q_Id":11719619,"Users Score":-2,"Answer":"win32structure.py\n\nensure HANDLE is c_void_p\nredefine other handles like HBITMAP to HANDLE\nensure pointers are pointers and not long","Q_Score":3,"Tags":"python,user-interface,64-bit,pywinauto","A_Id":22605499,"CreationDate":"2012-07-30T10:26:00.000","Title":"Looking for a way to use Pywinauto on Win x64","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a group chat application to learn how to use sockets, threads (maybe), and asycore module(maybe).\nWhat my thought was have a client-server architecture so that when a client connects to the server the server sends the client a list of other connects (other client 'user name', ip addres) and then a person can connect to one or more people at a time and the server would set up a P2P connection between the client(s).  I have the socket part working, but the server can only handle one client connection at a time.\nWhat would be the best, most common, practical way to go about handling multiple connections? \nDo I create a new process\/thread whenever I new connection comes into the server and then connect the different client connections together, or use the asycore module which from what I understand makes the server send the same data to multiple sockets(connection) and I just have to regulate where the data goes.  \nAny help\/thoughts\/advice would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1547,"Q_Id":11725192,"Users Score":1,"Answer":"For a group chat application, the general approach will be:\nServer side (accept process):\n\nCreate the socket, bind it to a well known port (and on appropriate interface) and listen\nWhile (app_running)\n\nClient_socket = accept (using serverSocket)\nSpawn a new thread and pass this socket to the thread. That thread handles the client that just connected.\nContinue, so that server can continue to accept more connections.\n\n\nServer-side client mgmt Thread:\n\nwhile app_running:\n\nread the incoming message, and store to a queue or something.\ncontinue\n\n\nServer side (group chat processing):\n\nFor all connected clients:\n\ncheck their queues. If any message present, send that to ALL the connected clients (including the client that sent this message -- serves as ACK sort of)\n\n\nClient side:\n\ncreate a socket\nconnect to server via IP-address, and port\ndo send\/receive.\n\nThere can be lots of improvement on the above. Like the server could poll the sockets or use \"select\" operation on a group of sockets. That would make it efficient in the sense that having a separate thread for each connected client will be an overdose when there are many. (Think ~1MB per thread for stack).\nPS: I haven't really used asyncore module. But I am just guessing that you would notice some performance improvement when you have lots of connected clients and very less processing.","Q_Score":2,"Tags":"python,multithreading,sockets,asynchronous","A_Id":11725633,"CreationDate":"2012-07-30T16:03:00.000","Title":"Group chat application in python using threads or asycore","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program using a thread. When my program is closed, my thread is still running and that's normal. I would like to know how my thread can detect that the main program is terminated; by itself ONLY. How would I do that?\nMy thread is in an infinite loop and process many object in a Queue. I can't define my thread as a daemon, else I can lose some data at the end of the main program. I don't want that my main program set a boolean value when it closed.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2406,"Q_Id":11725340,"Users Score":5,"Answer":"If you can get a handle to the main thread, you can call is_alive() on it.\nAlternatively, you can call threading.enumerate() to get a list of all currently living threads, and check to see if the main thread is in there.  \nOr if even that is impossible, then you might be able to check to see if the child thread is the only remaining non-daemon thread.","Q_Score":6,"Tags":"python,multithreading,orphan","A_Id":11725777,"CreationDate":"2012-07-30T16:11:00.000","Title":"python: How to detect when my thread become orphan?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a program using a thread. When my program is closed, my thread is still running and that's normal. I would like to know how my thread can detect that the main program is terminated; by itself ONLY. How would I do that?\nMy thread is in an infinite loop and process many object in a Queue. I can't define my thread as a daemon, else I can lose some data at the end of the main program. I don't want that my main program set a boolean value when it closed.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2406,"Q_Id":11725340,"Users Score":0,"Answer":"Would it work if your manager tracked how many open threads there were, then the children killed themselves when starved of input?  So the parent would start pushing data on to the queue, and the workers would consume data from the queue.  If a worker found nothing on the queue for a certain timeout period, it would kill itself.  The main thread would then track how many workers were operating and periodically start new workers if the number of active workers were under a given threshold.","Q_Score":6,"Tags":"python,multithreading,orphan","A_Id":11725681,"CreationDate":"2012-07-30T16:11:00.000","Title":"python: How to detect when my thread become orphan?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm just beginning to learn programming (on C++ and Python), and by beginning I mean total beginning (\"hello world\" beginning...). Not wanting to use multiple IDE's, I would like to be able to code and build\u2013simple\u2013programs with my text editor, Sublime Text 2. Could someone indicate me, with a step-by-step tutorial, how to implement C++ and Python compiling and executing capabilities in Sublime Text.\nI've searched Sublime Text build systems on the site, but the answers are very specific and can't help a rookie like me (but they'll probably help me later).\nThanks","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":79860,"Q_Id":11729368,"Users Score":2,"Answer":"windows(install minigw, python2.7 and added to the system path)\ncpp:  \n\nbuild: ctrl+b\nrun: ctrl+shift+b\n\npython:  \n\nbuild and run: ctrl+b\n\nyou may try to learn the the .sublime-build files in your Tools -> Build system -> New build system","Q_Score":25,"Tags":"c++,python,build,sublimetext2","A_Id":14229213,"CreationDate":"2012-07-30T20:51:00.000","Title":"Build systems in Sublime Text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"(Cards numbered 2-10 should be valued from 2-10, respectively. J,Q, and K should be 10, and A should be either 1 or 11, depending on the value of the hand).\nHow do I assign the deck these values? Also, the game needs to be 3 rounds. The way I did it is only one round. How do I make the game go three times, while keeping track of the players wins\/losses?\nCould someone please explain how I can do this a simple way?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":938,"Q_Id":11730723,"Users Score":0,"Answer":"You should probably calculate the total dynamically. Also, you need some kind of way to store the money of each individual player. Right now, there is no way of knowing the distribution of money since you only have one total.","Q_Score":1,"Tags":"python","A_Id":11730883,"CreationDate":"2012-07-30T22:36:00.000","Title":"Trouble giving values to deck of cards","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a python cgi script I have many selects in a form (100 or so), and each select has 5 or 6 options to choose from.  I don't want to have a separate submit button, so I am using onchange=\"submit();\" to submit the form as soon as an option is selected from one of the many selects.  When I read the form data with  form.keys() the name of every select on the form is listed instead of just the one that was changed.  This requires me to compare the value selected in each select with the starting value to find out which one changed and this of course is very slow.  How can I just get the new value of the one select that was changed?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":130,"Q_Id":11755474,"Users Score":1,"Answer":"If every select should be the only value that's needed, then every select is basically a form on its own.\nYou could either remove all other selects when you activate a single select (which is prone to errors), or simply put every select in its own form instead of using one giant form. Otherwise all data is going to be send.","Q_Score":0,"Tags":"javascript,python,html,forms,cgi","A_Id":11755603,"CreationDate":"2012-08-01T08:34:00.000","Title":"many selects (dropdowns) on html form, how to get just the value of the select that was changed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have 2 sites: A and B. A relies on some tables from B so it has an entry in its DATABASES settings pointing to B together with some entries under its DATABASE_ROUTERS settings to route certain model access to B's database.\nNow I'm trying to write a test on A but just running manage.py test immediately fails because some of A's models relies on some models covered by the tables coming from B, and B's complete database tables hasn't been created yet.\nSo my question is, how do I tweak my TEST_RUNNER to first run syncdb on B against B's test db so then when I run manage.py test on A it can find the tables from B that it relies on?\nI hope that makes sense.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1276,"Q_Id":11756115,"Users Score":0,"Answer":"I finally get the tests running, here's what I did:\n\ndisabled DATABASE_ROUTERS settings when running tests\nmaintain B alias in DATABASES settings but the name is the same as A\nappend B's INSTALLED_APPS that aren't present to A's INSTALLED_APPS","Q_Score":0,"Tags":"python,django","A_Id":11758203,"CreationDate":"2012-08-01T09:13:00.000","Title":"Django: writing test for multiple database site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a python web service.\nIt calls another web service to change the picture of a profile.\nIt connects to another web service.\nThis web service can only accept pictures that are 4 MB or smaller.\nI will put the checking in the first web service.\nIt uses PIL to check if the base64 string is a valid image.\nHowever, how do I check if the base64 string will create a 4 MB or smaller image?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12113,"Q_Id":11761889,"Users Score":19,"Answer":"Multiply the length of the data by 3\/4, since encoding turns 6 bytes into 8. If the result is within a few bytes of 4MB then you'll need to count the number of = at the end.","Q_Score":12,"Tags":"python,image","A_Id":11761906,"CreationDate":"2012-08-01T14:53:00.000","Title":"Get Image File Size From Base64 String","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Django-imagekit, which I'm using to process user uploaded images on a social media website, uses an unacceptably high level of memory.  I'm looking for ideas on how to get around this problem.\nWe are using django-imagekit to copy user uploaded images it into three predefined sizes, and saves the four copies (3 processed plus 1 original) into our AmazonS3 bucket.  \nThis operation is quickly causing us to go over our memory limit on our Heroku dynos.  On the django-imagekit github page, I've seen a few suggestions for hacking the library to use less memory.  \nI see three options: \n\nTry to hack django-imagekit, and deal with the ensuing update problems from using a modified third party library\nUse a different imaging processing library\nDo something different entirely -- resize the images on in the browser perhaps? Or use a third party service? Or...?\n\nI'm looking for advice on which of these routes to take.  In particular, if you are familiar with django-imagekit, or if you know of \/ are using a different image processing library in a Django app, I'd love to hear your thoughts.\nThanks a lot!\nClay","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":353,"Q_Id":11762290,"Users Score":3,"Answer":"Try to change image size with PIL from console and see if memory usage is ok. Image resize is a simple task, I don't believe you should use side applications. Besides, split your task into 3 tasks(3 images?).","Q_Score":3,"Tags":"python,django,image-processing,heroku,django-imagekit","A_Id":11834793,"CreationDate":"2012-08-01T15:15:00.000","Title":"Memory usage in django-imagekit is unacceptable -- ideas on fixes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm trying to basically set up a webpage where a user chooses an id, the webpage then sends the id information to python, where python uses the id to query a database, and then returns the result to the webpage for display.\nI'm not quite sure how to do this. I know how to use an ajax call to call the data generated by python, but I'm unsure of how to communicate the initial id information to the django app. Is it possible to say, query a url like .\/app\/id (IE \/app\/8), and then use the url information to give python the info? How would I go about editing urls.py and views.py to do that?\nThanks,","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":10912,"Q_Id":11762629,"Users Score":1,"Answer":"Yes, it is possible. If you pass the id as a parameter to the view you will use inside your app, like: \ndef example_view (request,id) \nand in urls.py, you can use something like this: \nurl(r'^example_view\/(?P<id>\\d+)\/', 'App.views.example_view'). \nThe id in the url \/example_view_template\/8 will get access to the result using the id which is related to the number 8. Like the 8th record of a specific table in your database, for example.","Q_Score":13,"Tags":"javascript,python,ajax,django","A_Id":11762988,"CreationDate":"2012-08-01T15:32:00.000","Title":"Pass information from javascript to django app and back","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"My question I suppose is rather simple. Basically, I have a profile. It has many variables being passed in. For instance, name, username, profile picture, and many others that are updated by their own respective pages. So one page would be used to update the profile picture, and that form would submit data from the form to the handler, and put() it to the database. What i'm trying to do here, is put all of the forms used to edit the profile on one single page at the same time.\nWould I need one huge handler to deal with that page? When I hit 'save' at the bottom of the page, how do I avoid overwriting data that hasn't been modified? Currently, say I have 5 profile variables, they map to 5 handlers, and 5 separate pages that contain their own respective form.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":146,"Q_Id":11764579,"Users Score":0,"Answer":"I've used django on most of my webapps, but the concept should be the same; I use ajax to send the data to the backend whenever the user hits submit (and the form returns false) so the user can keep editing it.  With ajax, you can send the data to different handlers on the backend.  Also, using jQuery, you can set flags to see if fields have been changed, to avoid sending the ajax message in the first place.  Ajax requests behave almost exactly like standard HTTP requests, but I believe the header indicates AJAX.\nIf you're looking at strictly backend, then you will need to do multiple \"if\" statements on the backend and check one field at a time to see if it has been changed. On the backend you should still be able to call other handlers (passing them the same request).","Q_Score":0,"Tags":"python,google-app-engine,profile","A_Id":11764721,"CreationDate":"2012-08-01T17:37:00.000","Title":"Submitting Multiple Forms At The Same Time (Edit Profile Page)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use Ajaxterm and I remember that when I used it for the first time about a year ago, there was something about logging in as root. \nCan anyone tell me how to enable root login or point me to a guide? Many different google searches have returned no results. \nP.S. My question is NOT whether or not I should login as root, but how to login as root.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":11764777,"Users Score":1,"Answer":"Once you have logged in as a non-root user you can just su to the root user","Q_Score":0,"Tags":"javascript,python,ajax,bash,terminal","A_Id":11764917,"CreationDate":"2012-08-01T17:51:00.000","Title":"Login as root in Ajaxterm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Python and Django and have over the past few weeks managed to set up my first deployment - a very basic site with user authentication and a few pages, which I hope to fill with content in the next couple of weeks. \nI have managed to find the answer to probably 40+ questions I have encountered so far by searching Google \/ StackOverflow \/ Django docs etc., but now I have one I can't seem to find a good answer to (perhaps because I don't know how best to search for it): when I develop on my local machine I need my settings.py file to point to the remote database ('HOST': 'www.mysite.com',) but when I deploy to a shared hosting service provider they require the use of localhost ('HOST': '', in settings.py). \nSince I host my code on GitHub and want to mirror it to the server, is there a way to resolve this so I don't have to make a manual edit to settings.py each time after uploading changes to the server?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":11765123,"Users Score":1,"Answer":"You can have two copies of your settings.py file, one for production and one for development. Whatever you need to be the default, name it as settings.py\nJust set DJANGO_SETTINGS_MODULE to the python path for the file that you would like to use.\nSo, if your settings files are myproject\/settings.py, myproject\/settings_dev.py; you can then do:\n$ DJANGO_SETTINGS_MODULE=settings_dev python manage.py shell\nFrom the myproject directory.","Q_Score":1,"Tags":"python,django","A_Id":11765289,"CreationDate":"2012-08-01T18:14:00.000","Title":"How to use a different database host in development vs deployment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using rpy2 and I have this issue that's bugging me: I know how to convert a Python array or list to a FloatVector that R (thanks to rpy2) can handle within Python, but I don't know if the opposite can be done, say, I have a FloatVector or Matrix that R can handle and convert it back to a Python array or list...can this be done?\nThanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":5269,"Q_Id":11769471,"Users Score":3,"Answer":"In the latest version of rpy2, you can simply do this in a direct way:\n\nimport numpy as np\narray=np.array(vector_R)","Q_Score":9,"Tags":"python,rpy2","A_Id":52399670,"CreationDate":"2012-08-02T00:30:00.000","Title":"rpy2: Convert FloatVector or Matrix back to a Python array or list?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, what issue im running into is how do i know what element of my page made a post request? I have multiple elements that can make the post request on the page, but how do i get the values from the element that created the request? It seems like this would be fairly trivial,but i have come up with nothing, and when doing quite a few google searches i have come up with nothing again.\nIs there any way to do this using Bottle?\nI had an idea to an a route for an sql page (with authentication of course) for providing the action for the form and use the template to render the id in the action, but i was thinking there had to be a better way to do this without routing another page.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":11770312,"Users Score":0,"Answer":"You could add a hidden input field to each form on the page with a specific value. On the server side, check the value of this field to detect which form the post request came from.","Q_Score":0,"Tags":"python,html,post,bottle","A_Id":11770627,"CreationDate":"2012-08-02T02:36:00.000","Title":"Distinguishing post request's from possible poster elements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The HTTP file and its contents are already downloaded and are present in memory. I just have to pass on the content to a decoder in gstreamer and play the content. However, I am not able to find the connecting link between the two.\nAfter reading the documentation, I understood that gstreamer uses httpsoupsrc for downloading and parsing of http files. But, in my case, I have my own parser as well as file downloader to do the same.  It takes the url and returns the data in parts to be used by the decoder.  I am not sure howto bypass httpsoupsrc and use my parser instead also how to link it to the decoder.\nPlease let me know if anyone knows how things can be done.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":11786318,"Users Score":1,"Answer":"You can use appsrc. You can pass chunks of your data to app source as needed.","Q_Score":0,"Tags":"gstreamer,python-gstreamer","A_Id":11802443,"CreationDate":"2012-08-02T21:49:00.000","Title":"How to hook custom file parser to Gstreamer Decoder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to work out how to approach building a \"machine\" to send and receive messages to WebSphere MQ, via Twisted.  I want it to be as generic as possible, so I can reuse it for many different situations that interface with MQ.\nI've used Twisted before, but many years ago now and I'm trying to resurrect the knowledge I once had...\nThe specific problem I'm having is how to implement the MQ IO using Twisted.  There's a pymqi Python library that interfaces with MQ, and it provides all the interfaces I need.  The MQ calls I need to implement are:\n\ninitiate a connection to a specific MQ server\/port\/channel\/queue-manager\/queue combination\ntake content and post it as a message to the desired queue\npoll a queue and return the content of the next message in the queue\nsend a request to a queue manager to find the number of messages currently in a queue\n\nAll of these involve blocking calls to MQ.\nAs I'm intending to reuse the Twisted\/MQ interface many times across a range of projects, should I be looking to implement the MQ IO as a Twisted protocol, as a Twisted transport, or just call the pymqi methods via deferToThread() calls?  I realise this is a very broad question with possibly no definitive answer; I'm really after advice from those who may have encountered similar challenges before (i.e. working with queueing interfaces that will always block) and found a way that works well.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":245,"Q_Id":11792531,"Users Score":1,"Answer":"If you're going to use this functionality a lot, then having a native Twisted implementation is probably worth the effort.  A wrapper based on deferToThread will be less work, but it will also be harder to test and debug, perform less well, and have problems on certain platforms where Python threads don't work extremely well (eg FreeBSD).\nThe approach to take for a native Twisted implementation is probably to implement a protocol that can speak to MQ servers and give it a rich API for interacting with channels, queues, queue managers, etc, and then build a layer on top of that which abstracts the actual network connection away from the application (as I believe mqi\/pymqi largely do).","Q_Score":0,"Tags":"python,ibm-mq,twisted,pymqi","A_Id":11794331,"CreationDate":"2012-08-03T08:58:00.000","Title":"Using WebSphere MQ with Twisted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I try to use omnicomplete in a .py file vim says that I need to compile vim with +python support. I already have a bunch of plugins downloaded in my vimfiles with pathogen so how do I recompile vim 7.3 with +python support without losing my settings? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1308,"Q_Id":11793895,"Users Score":1,"Answer":"Your settings won't be lost if you recompile vim: recompilation will simply create a new vim executable. If you are using a common Linux distribution, though, you might not need to compile anything: Archlinux, for example, bundles \"vim compiled with +python\" in the gvim package. Your distro might do something similar.","Q_Score":0,"Tags":"python,vim,omnicomplete","A_Id":11794082,"CreationDate":"2012-08-03T10:27:00.000","Title":"recompile vim with +python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new here and I'm Italian (forgive me if my English is not so good).\nI am a computer science student and I am working on a concurrent program project in Python.\nWe should use monitors, a class with its methods and data (such as condition variables). An instance (object) of this class monitor should be shared accross all processes we have (created by os.fork o by multiprocessing module) but we don't know how to do. It is simpler with threads because they already share memory but we MUST use processes. Is there any way to make this object (monitor) shareable accross all processes?\nHoping I'm not saying nonsenses...thanks a lot to everyone for tour attention.\nWaiting answers.\nLorenzo","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":619,"Q_Id":11809438,"Users Score":0,"Answer":"shared memory between processes is usually a poor idea; when calling os.fork(), the operating system marks all of the memory used by parent and inherited by the child as copy on write; if either process attempts to modify the page, it is instead copied to a new location that is not shared between the two processes.\nThis means that your usual threading primitives (locks, condition variables, et-cetera) are not useable for communicating across process boundaries.\nThere are two ways to resolve this;  The preferred way is to use a pipe, and serialize communication on both ends.  Brian Cain's answer, using multiprocessing.Queue, works in this exact way.  Because pipes do not have any shared state, and use a robust ipc mechanism provided by the kernel, it's unlikely that you will end up with processes in an inconsistent state.\nThe other option is to allocate some memory in a special way so that the os will allow you to use shared memory.  the most natural way to do that is with mmap.  cPython won't use shared memory for native python object's though, so you would still need to sort out how you will use this shared region.  A reasonable library for this is numpy, which can map the untyped binary memory region into useful arrays of some sort.  Shared memory is much harder to work with in terms of managing concurrency, though; since there's no simple way for one process to know how another processes is accessing the shared region.  The only time this approach makes much sense is when a small number of processes need to share a large volume of data, since shared memory can avoid copying the data through pipes.","Q_Score":2,"Tags":"python,concurrency,process,monitor,sharing","A_Id":11809544,"CreationDate":"2012-08-04T14:39:00.000","Title":"Monitor concurrency (sharing object across processes) in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a graph G, a node n and a length L, I'd like to collect all (non-cyclic) paths of length L that depart from n.\nDo you have any idea on how to approach this?\nBy now, I my graph is a networkx.Graph instance, but I do not really care if e.g. igraph is recommended.\nThanks a lot!","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6172,"Q_Id":11809856,"Users Score":6,"Answer":"A very simple way to approach (and solve entirely) this problem is to use the adjacency matrix A of the graph. The (i,j) th element of A^L is the number of paths between nodes i and j of length L. So if you sum these over all j keeping i fixed at n, you get all paths emanating from node n of length L.\nThis will also unfortunately count the cyclic paths. These, happily, can be found from the element A^L(n,n), so just subtract that.\nSo your final answer is: \u03a3j{A^L(n,j)} - A^L(n,n).\nWord of caution: say you're looking for paths of length 5 from node 1: this calculation will also count the path with small cycles inside like 1-2-3-2-4, whose length is 5 or 4 depending on how you choose to see it, so be careful about that.","Q_Score":3,"Tags":"python,graph,networkx,igraph","A_Id":11810286,"CreationDate":"2012-08-04T15:38:00.000","Title":"All paths of length L from node n using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a way to output a VERY simple pdf file from Python. Basically it will consist of two columns of words, one in Russian (so utf-8 characters) and the other in English.\nI've been googling for about an hour, and the packages I've found are either massive overkill (and still don't provide useful examples) such as ReportLab, or seem to assume that the only thing anyone would ever do with pdfs is concatenate several of them together (PyPdf, pdfrw).\nMaybe I'm just missing something obvious, but all the ones I've seen seem to launch into some massive discussion about taking 17 pdf files and converting them into a 60 foot wide poster with 23 panes (slight exaggeration maybe), and leave me wondering how to get the \"Hello World\" program working. Any help would be appreciated.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14227,"Q_Id":11813555,"Users Score":0,"Answer":"A simpler approach would be to use the csv package to write the two columns to a .csv file, then read it into a spreadsheet & print to pdf.    Not 100% python but maybe 90% less work ...","Q_Score":23,"Tags":"python,pdf","A_Id":44475810,"CreationDate":"2012-08-05T02:36:00.000","Title":"How do I create a simple pdf file in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"python file object how to remove byte from current seed postion to end\nf = open(filename, \"a+\")\ntruncate_pos = f.tell()\nf.truncate(truncate_pos)\nseems not work,how could i do?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":138,"Q_Id":11822111,"Users Score":2,"Answer":"Opening a file in a+ positions the pointer at the end of the file; truncation from there results in no change to the file.","Q_Score":0,"Tags":"python,file","A_Id":11822131,"CreationDate":"2012-08-06T03:10:00.000","Title":"python file object how to remove byte from current seed postion to end","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to write a Web app in Python, which is to consist of two parts:\n\nA Django-based user interface, which allows each user to set up certain tasks\nWorker processes (one per user), which, when started by the user, perform the tasks in the background without freezing the UI.\n\nSince any object I create in a view is not persistent, I have no way of keeping tracks of worker processes. I'm not even sure how to approach this task. Any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":685,"Q_Id":11823586,"Users Score":0,"Answer":"You can try celery as it's django friendly. \nBut if to be honest i'm not fond of it (bugs :)\nWe are going to switch to Gearman.\nWriting your own job producers and consumers (workers) are a kind of a fun!","Q_Score":1,"Tags":"python,django,multiprocessing","A_Id":11823901,"CreationDate":"2012-08-06T06:42:00.000","Title":"Python multiprocessing and Django - I'm confused","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I don't know how to run the activate.bat in a Python Tools for Visual Studio Project. I have a directory environment in my project with my virtualenv. But, I don't know how I can run .\/env\/Scripts\/activate.bat before the project run my main python script.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30422,"Q_Id":11824589,"Users Score":4,"Answer":"I found that if : \n\nmain.py is set as Startup File,\nin the Properties of the project -> Debug tab -> Interpreter Path field, I put the path C:...\\env\\Scripts\\python.exe (i.e. the python executable of the virtualenv)\n\nIt works !","Q_Score":6,"Tags":"python,visual-studio-2010,ptvs","A_Id":11826101,"CreationDate":"2012-08-06T08:06:00.000","Title":"How to run a python script with Python Tools for Visual Studio in a virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to rename a build in buildbot without losing all of the logs?\nFor instance I have several windows slaves which all might build: \"Windows 2008+ DEBUG\" but I want to rename this build to: \"Windows 2008R2+ DEBUG\".\nHow do I set compare_attr (if that's even what I need to do) so that all of the logs\/etc... are included from the previous builds in the new one.\nCan I manually rename the directories and expect everything to work? Experimentation has told me that will not work but maybe I can write a command to change certain things?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":812,"Q_Id":11837330,"Users Score":2,"Answer":"If you don't care about the name of the directory, just the name of the builder, you can set the builddir attribute of the builder to be whatever it currently is, then name you builder however you want.\nThe data stored in the builder directory is in pickles. Looking at the code, I think the only data could cause issues is the builder name. If you done care about non-build events, you could probably just delete the builder file from each directory. Otherwise, rewriting the pickle with the update builder name should work.","Q_Score":22,"Tags":"python,buildbot","A_Id":12306901,"CreationDate":"2012-08-06T23:24:00.000","Title":"rename a build in buildbot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry, for the vague question, don't know actually how to ask this nor the rightful terminologies for it.\nHow to run a python script\/bytecode\/.pyc (any compiled python code) without going through the terminal.  Basically on Nautilus:  \"on double click of the python script, it'll run\" or \"on select then [Enter], it'll run!\".  That's my goal at least.\nWhen i check the \"Allow executing of file as a program\" then press [enter] on the file.  It gives me this message:\n\nCould not display \"\/home\/ghelo\/Music\/arrange.pyc\".\n  There is no application installed for Python bytecode files.\n  Do you want to search for an application to open this file?\n\nUsing Ubuntu 12.04, by the way and has to be python 2, one of the packages doesn't work on python 3.  If there's a difference between how to do it on the two version, include it, if it's not to much t ask, thank you.\nI know it doesn't matter, but it's a script auto renaming & arranging my music files. Guide me accordingly, stupid idiot here. :)","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":15947,"Q_Id":11848650,"Users Score":4,"Answer":"You should make the .py files executable and click on them. The .pyc files cannot be run directly.","Q_Score":6,"Tags":"python,ubuntu,compilation,nautilus","A_Id":11848690,"CreationDate":"2012-08-07T14:55:00.000","Title":"How to run Python script with one icon click?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry, for the vague question, don't know actually how to ask this nor the rightful terminologies for it.\nHow to run a python script\/bytecode\/.pyc (any compiled python code) without going through the terminal.  Basically on Nautilus:  \"on double click of the python script, it'll run\" or \"on select then [Enter], it'll run!\".  That's my goal at least.\nWhen i check the \"Allow executing of file as a program\" then press [enter] on the file.  It gives me this message:\n\nCould not display \"\/home\/ghelo\/Music\/arrange.pyc\".\n  There is no application installed for Python bytecode files.\n  Do you want to search for an application to open this file?\n\nUsing Ubuntu 12.04, by the way and has to be python 2, one of the packages doesn't work on python 3.  If there's a difference between how to do it on the two version, include it, if it's not to much t ask, thank you.\nI know it doesn't matter, but it's a script auto renaming & arranging my music files. Guide me accordingly, stupid idiot here. :)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":15947,"Q_Id":11848650,"Users Score":1,"Answer":"Adding \" #!\/usr\/bin\/env python \" at the top of the .py file works!  Hmm, although don't appreciate the pop-up, but nevermind. :P\nFrom PHPUG:\n\nYou do not invoke the pyc file. It's the .py file that's invoked. Python is an interpreted language.\nA simpler way to make a python exectuable (explained):\n1) Add #!\/usr\/bin\/env python at the top of your python executable file (eg. main.py) (it uses the default python - eg. if using arch, that's py3 instead of py2. You can explicitly tell it to run python2\/python3 by replacing python with it's version: ex. python2.7)\n2) Write the code. If the script is directly invoked, __name__ variable becomes equal to the string '__main__' thus the idiom: if __name__ == '__main__':. You can add all the logic that relates to your script being directly invoked in this if-block. This keeps your executable importable.\n3) Make it executable 'chmod +x main.py'\n4) Call the script: .\/main.py args args","Q_Score":6,"Tags":"python,ubuntu,compilation,nautilus","A_Id":12015527,"CreationDate":"2012-08-07T14:55:00.000","Title":"How to run Python script with one icon click?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python and programming in general.  I was wondering if there is a way to validate that you are getting a video feed and not just a black screen from an incoming call.  I have automated a script in Python that makes a call and answers the call, but some of the issues we are testing is how often we get black screen instead of the video call.  I have been reading up on OpenCV and played around with it some, but am not getting anywhere near the results I am looking for.  Is there another way in python to detect video?  If so I would greatly appreciate being pointed in the right direction.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1107,"Q_Id":11854528,"Users Score":0,"Answer":"I do something similar with C++ in OpenCV. There are a couple of ways to go about this.\nI use TCP\/IP protocols - make sure I don't have packet loss.\nNext, To test quality, I send and receive a Video file (that I recorded from the camera) instead of stream \"new\" video from the camera. Now, I can check the quality by checking the bytes received in every frame.\nThis may not be optimal, but it is a starting point.","Q_Score":0,"Tags":"python,opencv","A_Id":25125143,"CreationDate":"2012-08-07T21:41:00.000","Title":"Checking the quality of an Incoming Video with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a pure python TIFF G4 decompress for use with tifffile.py. I know there are ways to add libtiff to a custom PIL, but I never could get that working very well in a mixed virtualenv.  I want to manipulate the image in PIL. I am looking for pointers in hooking my decompressor to stock PIL for TiffImagePlugin.py.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":973,"Q_Id":11868963,"Users Score":0,"Answer":"It appears that TiffImagePlugin does not easily allow me to hook in additional decompressors.  Replacing TiffImageFile._decoder with a dictionary of decoders might work, but you would have to examine and test each release of PIL to ensure it hasn't broken.  This level of maintenance is just as bad as a custom PIL.  I appreciate the design of tifffile.py for using a dictionary of decoders.  It made it very easy.\nFinal solution?  I couldn't hook my code into PIL.  I had to use PIL.Image.fromarray() to using my decompressed images.","Q_Score":1,"Tags":"python,python-imaging-library,tiff","A_Id":11877012,"CreationDate":"2012-08-08T16:27:00.000","Title":"Using TIFF G4 image in PIL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a application in python from Windows. When I run it in the console, it stops, shows an error, and closes. I can't see the error becase its too fast, and I can't read it. I'm editing the code with IDLE (the program that came with python when I instaled it), and when I run it with the python shell, there are no errors. I would run it from IDLE, but when I use the console, it has more features.\nI don't know why this is happening. I need your help.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7808,"Q_Id":11876545,"Users Score":1,"Answer":"Run your program from a Windows command prompt. That will not automatically close when the program finishes.\nIf you run your program by double-clicking on the .py file icon, then Windows will close the window when your program finishes (whether it was successful or not).","Q_Score":1,"Tags":"windows,python-2.7","A_Id":11876572,"CreationDate":"2012-08-09T03:52:00.000","Title":"how to make my console in python not to close?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So as I near the production phase of my web project, I've been wondering how exactly to deploy a pyramid app. In the docs, it says to use ..\/bin\/python setup.py develop to put the app in development mode. Is there another mode that is designed for production. Or do I just use ..\/bin\/python setup.py install.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2476,"Q_Id":11894210,"Users Score":3,"Answer":"Well the big difference between python setup.py develop and python setup.py install. Is that install will install the package in your site-packages directory. While develop will install an egg-link that point to the directory for development. \nSo yeah you can technically use both method. But depending on how you did your project, installing in site-package might be a bad idea. \nWhy? FileUpload or anything your app might generate like dynamic files etc... If your app doesn't use config files to find where to save your files. Installing your app and running your app may try to write file in your site-packages directory.\nIn other words, you have to make sure that all files and directories that may be generated, etc can be located using config files.\nThen if all dynamic directories are pointed out in the configs, then installing is good...\nAll you'll have to do is create a folder with a production.ini file and run pserve production.ini. \nCode can be saved anywhere on your comp that way and you can also use uWSGI or any other WSGI server you like. \nI think installing the code isn't a bad thing, and having data appart from the application is a good thing.\nIt has some advantage for deployment I guess.","Q_Score":3,"Tags":"python,pyramid,production","A_Id":11898284,"CreationDate":"2012-08-10T01:18:00.000","Title":"Preparing a pyramid app for production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating an app in several different python web frameworks to see which has the better balance of being comfortable for me to program in and performance. Is there a way of reporting the memory usage of a particular app that is being run in virtualenv?\nIf not, how can I find the average, maximum and minimum memory usage of my web framework apps?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1578,"Q_Id":11894333,"Users Score":1,"Answer":"It depends on how you're going to run the application in your environment. There are many different ways to run Python web apps. Recently popular methods seem to be Gunicorn and uWSGI. So you'd be best off running the application as you would in your environment and you could simply use a process monitor to see how much memory and CPU is being used by the process running your applicaiton.","Q_Score":1,"Tags":"python,memory,virtualenv,web-frameworks","A_Id":12218779,"CreationDate":"2012-08-10T01:37:00.000","Title":"Testing memory usage of python frameworks in Virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a Python script that will constantly scrape data, but it will take quite a long time. Is there a safe way to stop a long running python script? The loop will run for more than 10 minutes and I need a way to stop it if I want, after it's already running.\nIf I execute it from a cron job, then I'm assuming it'll just run until it's finished, so how do I stop it?\nAlso, if I run it from a browser and just call the file. I'm assuming stopping the page from loading would halt it, correct?\n\nHere's the scenario: I have one python script that is gather info from pages and put it into a queue. Then I want to have another python script that is in an infinite loop that just checks for new items in the queue. Lets say I want the infinite loop to begin at 8am and end at 8pm. How do I accomplish this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10068,"Q_Id":11898451,"Users Score":0,"Answer":"I guess one way to work around the issue is having a script for one loop run, that would:\n\ncheck no other instance of the script is running\nlook into the queue and process everything found there\n\nNow, then you can run this script from cron every minute between 8 a.m. and 8 p.m. The only downside is that new items may some time to get processed.","Q_Score":3,"Tags":"python,loops,cron,infinite-loop","A_Id":11898609,"CreationDate":"2012-08-10T09:03:00.000","Title":"Stop python script in infinite loop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an array of pixels which I wish to save to an image file. Python appears to have a few libraries which can do this for me, so I'm going to use one of them, passing in my pixel array and using functions I didn't write to write the image headers and data to disk. \nHow do I do unit testing for this situation? \nI can:\n\nTest that the pixel array I'm passing to the external library is what I expect it to be. \nTest that the external library functions I call give me the expected return values. \nManually verify that the image looks like I'm expecting (by opening the image and eyeballing it). \n\nI can't:\n\nTest that the image file is correct. To do that I'd have to either generate an image to compare to (but how do I generate that 'trustworthy' image?), or write a unit-testable image-writing module (so I wouldn't need to bother with the external library at all). \n\nIs this enough to provide coverage for my code? Is testing the interface between my code and the external library sufficient, leaving me to trust that the output of the external library (the image file) is correct through manual eyeballing? \nHow do you write unit tests to ensure that the external libraries you use do what you expect them to?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":641,"Q_Id":11903310,"Users Score":3,"Answer":"Bit old on Python.\nBut this is how I would approach it.\nGrab the image doing a manual test. Compute a check sum (MD5 perhaps). Then the automated tests need to compare it by computing the MD5 (in this example) with the one done on the manual test.\nHope this helps.","Q_Score":1,"Tags":"python,unit-testing,tdd","A_Id":11903386,"CreationDate":"2012-08-10T14:02:00.000","Title":"Unittest binary file output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a TSV file that consists of integers along with some false data that could be anything such as floats or characters etc. \nThe idea is to read the contents of the file and find out which ones are bad (containing data other than integers) \nEach line can be read using the readline method once the file has been opened for reading. Off course, the readline() method returns each line read as a string and not it's constituent data types. My understanding is, that I could use the pickle module somehow to ensure that i retain the original data type by representing it as it's serialized version carrying out dump and load methods. \nThe question is, how do I do this?\nBy reading each line and pickling it, would not help since readline by default reads it as a string. Thereby upon pickling, it's really just pickling a string into a serialized python object representation and unpickling would only return it as a string. Thus the actual data in the line, such as integers or chars are being represented as strings irrespective. \nSo I assume the question is, how do I pickle things the right way OR how do I process each line of a file ensuring that it's data types are being maintained?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":374,"Q_Id":11926023,"Users Score":0,"Answer":"The TSV file has already lost all the type information.\nIf the pickle module had been used to write out the file, you would have been able to easily unpickle it, however it looks like you just get to read the damaged file, so pickle is no use to you here\nThe best you can do is attempt to convert each field to int and handle the exception if it fails","Q_Score":0,"Tags":"python","A_Id":11926214,"CreationDate":"2012-08-12T21:28:00.000","Title":"Read a file of mixed items and retain their data types","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to OpenERP and python and I need some help saving an amount into a particular account.\nI have created a field in the invoice form that calculates a specific amount based on some code and displays that amount in the field. What I want to do is to associate an account with this field, so when the invoice is validated and\/or payed, this amount is saved into an account and later on I can see it in the journal entries and\/or chart of account. Any idea how to do that ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":226,"Q_Id":11929073,"Users Score":1,"Answer":"You can override \"pay_and_reconcile\" function to write in account field, this function is called at time of Pay.\naction_date_assign()\naction_move_create()\naction_number()\nthis 3 function are called at time of validating invoice. \nYou can override any one from this or you can add your own function . in workflow for the \"open\" activity.","Q_Score":1,"Tags":"python,openerp,accounting","A_Id":11929906,"CreationDate":"2012-08-13T06:20:00.000","Title":"OpenERP : Saving field value (amount) into an account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building custom CRM web based system and have integrated synchronization of contacts and reminders with Google apps and need do the same with Apple iCloud. Is there any way how to do it? I haven't find any official API for this purpose, CRM is written in PHP, but I'm able to use python for this purpose as well.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":1657,"Q_Id":11970079,"Users Score":1,"Answer":"To the best of my knowledge, there is no way to interface with iCloud directly; it can only be done through an iOS or Mac OS app, and by calling the correct iCloud Objective-C APIs with UI\/NSDocument classes. Since you are not using Cocoa, let alone Objective-C, you will most likely not be able to do this. I may be wrong of course, as I haven't conducted an in-depth search into this.","Q_Score":4,"Tags":"php,python,api,sync,icloud","A_Id":11973429,"CreationDate":"2012-08-15T13:23:00.000","Title":"Website sync of contacts and reminders with iCloud","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building custom CRM web based system and have integrated synchronization of contacts and reminders with Google apps and need do the same with Apple iCloud. Is there any way how to do it? I haven't find any official API for this purpose, CRM is written in PHP, but I'm able to use python for this purpose as well.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1657,"Q_Id":11970079,"Users Score":0,"Answer":"I would recommend that you sync using the google contacts api.  Then, you can tell iPhone people to use that instead of iCloud.","Q_Score":4,"Tags":"php,python,api,sync,icloud","A_Id":12255882,"CreationDate":"2012-08-15T13:23:00.000","Title":"Website sync of contacts and reminders with iCloud","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am thinking of writing a python program that runs in the background and can inspect user's GUI events.\nMy requirements is very simple:\n1) When user right click the mouse, it can show an option; and when this option is chosen, my program should know this event.\n2) When user select a file and click some predefined key combination, my program should know this event.\nWhat should I do? Is this a GUI program? I am also thinking that, this program maybe a daemon on the machine and can inspect the user's GUI event, but I am not sure how can I do this.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":367,"Q_Id":11970246,"Users Score":2,"Answer":"If you're talking about doing this stuff inside of a wxPython program, then it's all pretty simple. There's a PopupMenu widget for the first one and an AcceratorTable for the second one. If you're wanting to catch mouse and keyboard events outside of a wxPython program, then you have to go very low-level and hook into the OS itself, which means that there really isn't any good way to do it cross-platform. You'll probably want to look at ctypes and similar libraries for that sort of thing.","Q_Score":0,"Tags":"python,wxpython","A_Id":11975689,"CreationDate":"2012-08-15T13:35:00.000","Title":"Background python program inspect GUI events","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't run my PyCharm IDE using port 80.\nI need to use PayPal that requires me to use port 80.\nBut using Mac OS X 10.8 I can't have it working because of permission issues.\nI've already tried running PyCharm with SUDO command.\nDoes anyone know how to run Pycharm using port 80, or any other solution?\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":8103,"Q_Id":11988636,"Users Score":2,"Answer":"To give PyCharm permissions, one has to run as Administor (Windows) or using sudo if on OSX\/Linux: sudo \/Applications\/PyCharm.app\/Contents\/MacOS\/pycharm.  Note that this truly runs PyCharm as a new user, so you'll have to register the app again and set up your customizations again if you have any (ie theme, server profiles etc)","Q_Score":8,"Tags":"python,django,pycharm","A_Id":38212424,"CreationDate":"2012-08-16T13:49:00.000","Title":"How to run PyCharm using port 80","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't run my PyCharm IDE using port 80.\nI need to use PayPal that requires me to use port 80.\nBut using Mac OS X 10.8 I can't have it working because of permission issues.\nI've already tried running PyCharm with SUDO command.\nDoes anyone know how to run Pycharm using port 80, or any other solution?\nThanks.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":8103,"Q_Id":11988636,"Users Score":1,"Answer":"For the ones who are looking for the answer of this question, please check your Pycharm Run\/Debug Configurations. Run->Edit Configurations ->Port","Q_Score":8,"Tags":"python,django,pycharm","A_Id":22296578,"CreationDate":"2012-08-16T13:49:00.000","Title":"How to run PyCharm using port 80","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am fairly new to databases and have just figured out how to use MongoDB in python2.7 on Ubuntu 12.04. An application I'm writing uses multiple python modules (imported into a main module) that connect to the database. Basically, each module starts by opening a connection to the DB, a connection which is then used for various operations.\nHowever, when the program exits, the main module is the only one that 'knows' about the exiting, and closes its connection to MongoDB. The other modules do not know this and have no chance of closing their connections. Since I have little experience with databases, I wonder if there are any problems leaving connections open when exiting.\nShould I:\n\nLeave it like this?\nInstead open the connection before and close it after each operation?\nChange my application structure completely?\nSolve this in a different way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1207,"Q_Id":11989408,"Users Score":3,"Answer":"You can use one pymongo connection across different modules. You can open it in a separate module and import it to other modules on demand. After program finished working, you are able to close it. This will be the best option.\nAbout other questions:\n\nYou can leave like this (all connections will be closed when script finishes execution), but leaving something unclosed is a bad form.\nYou can open\/close connection for each operation (but establishing connection is a time-expensive operation.\nThat what I'd advice you (see this answer's first paragraph)\nI think this point can be merged with 3.","Q_Score":3,"Tags":"python,mongodb,pymongo","A_Id":11989459,"CreationDate":"2012-08-16T14:29:00.000","Title":"When to disconnect from mongodb","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python to set up a computationally intense simulation, then running it in a custom built C-extension and finally processing the results in python. During the simulation, I want to store a fixed-length number of floats (C doubles converted to PyFloatObjects) representing my variables at every time step, but I don't know how many time steps there will be in advance. Once the simulation is done, I need to pass back the results to python in a form where the data logged for each individual variable is available as a list-like object (for example a (wrapper around a) continuous array, piece-wise continuous array or column in a matrix with a fixed stride).\nAt the moment I'm creating a dictionary mapping the name of each variable to a list containing PyFloatObject objects. This format is perfect for working with in the post-processing stage but I have a feeling the creation stage could be a lot faster.\nTime is quite crucial since the simulation is a computationally heavy task already. I expect that a combination of A. buying lots of memory and B. setting up your experiment wisely will allow the entire log to fit in the RAM. However, with my current dict-of-lists solution keeping every variable's log in a continuous section of memory would require a lot of copying and overhead.\nMy question is: What is a clever, low-level way of quickly logging gigabytes of doubles in memory with minimal space\/time overhead, that still translates to a neat python data structure?\n\nClarification: when I say \"logging\", I mean storing until after the simulation. Once that's done a post-processing phase begins and in most cases I'll only store the resulting graphs. So I don't actually need to store the numbers on disk.\n\nUpdate: In the end, I changed my approach a little and added the log (as a dict mapping variable names to sequence types) to the function parameters. This allows you to pass in objects such as lists or array.arrays or anything that has an append method. This adds a little time overhead because I'm using the PyObject_CallMethodObjArgs function to call the Append method instead of PyList_Append or similar. Using arrays allows you to reduce the memory load, which appears to be the best I can do short of writing my own expanding storage type. Thanks everyone!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":186,"Q_Id":11994515,"Users Score":2,"Answer":"You might want to consider doing this in Cython, instead of as a C extension module.  Cython is smart, and lets you do things in a pretty pythonic way, even though it at the same time lets you use C datatypes and python datatypes.\nHave you checked out the array module?  It allows you to store lots of scalar, homogeneous types in a single collection.\nIf you're truly \"logging\" these, and not just returning them to CPython, you might try opening a file and fprintf'ing them.\nBTW, realloc might be your friend here, whether you go with a C extension module or Cython.","Q_Score":2,"Tags":"python,numpy,scipy","A_Id":11995122,"CreationDate":"2012-08-16T19:54:00.000","Title":"Logging an unknown number of floats in a python C extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python to set up a computationally intense simulation, then running it in a custom built C-extension and finally processing the results in python. During the simulation, I want to store a fixed-length number of floats (C doubles converted to PyFloatObjects) representing my variables at every time step, but I don't know how many time steps there will be in advance. Once the simulation is done, I need to pass back the results to python in a form where the data logged for each individual variable is available as a list-like object (for example a (wrapper around a) continuous array, piece-wise continuous array or column in a matrix with a fixed stride).\nAt the moment I'm creating a dictionary mapping the name of each variable to a list containing PyFloatObject objects. This format is perfect for working with in the post-processing stage but I have a feeling the creation stage could be a lot faster.\nTime is quite crucial since the simulation is a computationally heavy task already. I expect that a combination of A. buying lots of memory and B. setting up your experiment wisely will allow the entire log to fit in the RAM. However, with my current dict-of-lists solution keeping every variable's log in a continuous section of memory would require a lot of copying and overhead.\nMy question is: What is a clever, low-level way of quickly logging gigabytes of doubles in memory with minimal space\/time overhead, that still translates to a neat python data structure?\n\nClarification: when I say \"logging\", I mean storing until after the simulation. Once that's done a post-processing phase begins and in most cases I'll only store the resulting graphs. So I don't actually need to store the numbers on disk.\n\nUpdate: In the end, I changed my approach a little and added the log (as a dict mapping variable names to sequence types) to the function parameters. This allows you to pass in objects such as lists or array.arrays or anything that has an append method. This adds a little time overhead because I'm using the PyObject_CallMethodObjArgs function to call the Append method instead of PyList_Append or similar. Using arrays allows you to reduce the memory load, which appears to be the best I can do short of writing my own expanding storage type. Thanks everyone!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":186,"Q_Id":11994515,"Users Score":1,"Answer":"This is going to be more a huge dump of ideas rather than a consistent answer, because it sounds like that's what you're looking for. If not, I apologize.\nThe main thing you're trying to avoid here is storing billions of PyFloatObjects in memory. There are a few ways around that, but they all revolve on storing billions of plain C doubles instead, and finding some way to expose them to Python as if they were sequences of PyFloatObjects.\nTo make Python (or someone else's module) do the work, you can use a numpy array, a standard library array, a simple hand-made wrapper on top of the struct module, or ctypes. (It's a bit odd to use ctypes to deal with an extension module, but there's nothing stopping you from doing it.) If you're using struct or ctypes, you can even go beyond the limits of your memory by creating a huge file and mmapping in windows into it as needed.\nTo make your C module do the work, instead of actually returning a list, return a custom object that meets the sequence protocol, so when someone calls, say, foo.getitem(i) you convert _array[i] to a PyFloatObject on the fly.\nAnother advantage of mmap is that, if you're creating the arrays iteratively, you can create them by just streaming to a file, and then use them by mmapping the resulting file back as a block of memory.\nOtherwise, you need to handle the allocations. If you're using the standard array, it takes care of auto-expanding as needed, but otherwise, you're doing it yourself. The code to do a realloc and copy if necessary isn't that difficult, and there's lots of sample code online, but you do have to write it. Or you may want to consider building a strided container that you can expose to Python as if it were contiguous even though it isn't. (You can do this directly via the complex buffer protocol, but personally I've always found that harder than writing my own sequence implementation.) If you can use C++, vector is an auto-expanding array, and deque is a strided container (and if you've got the SGI STL rope, it may be an even better strided container for the kind of thing you're doing).\nAs the other answer pointed out, Cython can help for some of this. Not so much for the \"exposing lots of floats to Python\" part; you can just move pieces of the Python part into Cython, where they'll get compiled into C. If you're lucky, all of the code that needs to deal with the lots of floats will work within the subset of Python that Cython implements, and the only things you'll need to expose to actual interpreted code are higher-level drivers (if even that).","Q_Score":2,"Tags":"python,numpy,scipy","A_Id":11995857,"CreationDate":"2012-08-16T19:54:00.000","Title":"Logging an unknown number of floats in a python C extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am amateur Programmer looking to develop a game. I've decided to use Python and pygame. (I know, there are better options out there, but I really don't know C++ or java that well.) The issue I'm having is that I really have no idea how to create a decent AI. I'm talking about the sort of AI that has monsters move this way at this point, use a bow and arrow at that point, and use a long-range magic attack at another point (yes, its a top-down 2-d fantasy game). I really don't understand how it makes those decisions and how you program it to make those decisions. I've looked around everywhere, and either the resource gets so technical that I can't understand it at all, or it gives me no information whatsoever. I'm hoping someone here can give me some clear suggestions, or at least point me to some decent resources. Right now my bots just sort of wander randomly around the screen...","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":3243,"Q_Id":11996987,"Users Score":2,"Answer":"basically its \n\nDefault Behavior:Random Walk\nif player is within X distance: Melee Attack\nif player is within Y distance: Charge Player\nif player is within Z distance: Cast spell \nif player is outside range and MOB has agro move toward player\n\nthats the extent of most AI... at least game AI\nits too cpu intensive to do things like neural networks and machine learning for game mobs\nyou may want to look at fuzzy logic AI ... thats largely what i described up there but it can be more than one simultaneuosly","Q_Score":0,"Tags":"python,artificial-intelligence,pygame,game-engine,game-physics","A_Id":11997071,"CreationDate":"2012-08-16T23:43:00.000","Title":"How to develop an AI script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating.\nI cannot find any documentation that describes whether sklearn supports complex numbers as targets to classifiers. In theory the distance metric should work just fine, so it should work for at least some regression algorithms.\nCan anyone suggest how I can get a regression algorithm to operate with complex numbers as targets?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":2406,"Q_Id":11999147,"Users Score":2,"Answer":"So far I discovered that most classifiers, like linear regressors, will automatically convert complex numbers to just the real part.\nkNN and RadiusNN regressors, however, work well - since they do a weighted average of the neighbor labels and so handle complex numbers gracefully.\nUsing a multi-target classifier is another option, however I do not want to decouple the x and y directions since that may lead to unstable solutions as Colonel Panic mentions, when both results come out close to 0.\nI will try other classifiers with complex targets and update the results here.","Q_Score":7,"Tags":"python,numpy,scipy,scikit-learn","A_Id":12011024,"CreationDate":"2012-08-17T02:48:00.000","Title":"Is it possible to use complex numbers as target labels in scikit learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating.\nI cannot find any documentation that describes whether sklearn supports complex numbers as targets to classifiers. In theory the distance metric should work just fine, so it should work for at least some regression algorithms.\nCan anyone suggest how I can get a regression algorithm to operate with complex numbers as targets?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":2406,"Q_Id":11999147,"Users Score":1,"Answer":"Good question. How about transforming angles into a pair of labels, viz. x and y co-ordinates. These are continuous functions of angle (cos and sin). You can combine the results from separate x and y classifiers for an angle? $\\theta = \\sign(x) \\arctan(y\/x)$. However that result will be unstable if both classifiers return numbers near zero.","Q_Score":7,"Tags":"python,numpy,scipy,scikit-learn","A_Id":12003586,"CreationDate":"2012-08-17T02:48:00.000","Title":"Is it possible to use complex numbers as target labels in scikit learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating.\nI cannot find any documentation that describes whether sklearn supports complex numbers as targets to classifiers. In theory the distance metric should work just fine, so it should work for at least some regression algorithms.\nCan anyone suggest how I can get a regression algorithm to operate with complex numbers as targets?","AnswerCount":3,"Available Count":3,"Score":0.2605204458,"is_accepted":false,"ViewCount":2406,"Q_Id":11999147,"Users Score":4,"Answer":"Several regressors support multidimensional regression targets. Just view the complex numbers as 2d points.","Q_Score":7,"Tags":"python,numpy,scipy,scikit-learn","A_Id":12004759,"CreationDate":"2012-08-17T02:48:00.000","Title":"Is it possible to use complex numbers as target labels in scikit learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"Recently, I use Eclipse to edit my python code. But lacking indentation guides, I feel not very well. So how to add the auto indentation guides for Eclipse? Is there certain plugin?\nWhat's more, I have tried the EditBox. But, you know, that is not very natural under some themes...............","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":12501,"Q_Id":12000219,"Users Score":1,"Answer":"As for me, all I do with Eclipse for working with Python:\n\nInstall pydev\nSet tabs to be replaced by spaces\nSet tab length to 4\n\nyou can make tabs and spaces visual by displaying non-printable symbols.\nHopefully, this is what you meant.","Q_Score":10,"Tags":"python,eclipse-plugin,pydev","A_Id":12003951,"CreationDate":"2012-08-17T05:25:00.000","Title":"Does Eclipse have indentation guides?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading.\nTo do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest session opened correctly.\nI did bit of research on internet and found that it's because of Global Interpretor Lock in python. I would like to know how to overcome this GIL...Any idea would be much appreciated","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":229,"Q_Id":12005515,"Users Score":3,"Answer":"Instead of using threads, use different processes and use some sort of IPC to communicate between each process.","Q_Score":0,"Tags":"python","A_Id":12005547,"CreationDate":"2012-08-17T12:09:00.000","Title":"python how to overcome global interpretor lock","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading.\nTo do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest session opened correctly.\nI did bit of research on internet and found that it's because of Global Interpretor Lock in python. I would like to know how to overcome this GIL...Any idea would be much appreciated","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":229,"Q_Id":12005515,"Users Score":2,"Answer":"I don't think you'll have RuntimeErrors because of the GIL. Can you paste the traceback? If you have some critical parts of the code that are not re entrant, you'll have to isolate them using some concurrency primitives. \nThe main issue with the GIL is that it will forcibly serialise computation. The result is reduced throughput and scaling.","Q_Score":0,"Tags":"python","A_Id":12005614,"CreationDate":"2012-08-17T12:09:00.000","Title":"python how to overcome global interpretor lock","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to send and receive messages between two Python programs using sockets. I can do this using the private IPs when the computers are connected to the same router, but how do I do it when there are 2 NATs separating them?\nThanks (my first SO question)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":668,"Q_Id":12014203,"Users Score":0,"Answer":"Redis, could work but not the exact same functionality.","Q_Score":6,"Tags":"python,sockets,nat","A_Id":12020661,"CreationDate":"2012-08-17T23:03:00.000","Title":"How do I communicate between 2 Python programs using sockets that are on separate NATs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking to make a 2d side scrolling game in Python, however I'm not sure what library to use. I know of PyGame (Hasn't been updated in 3 years), Pyglet, and PyOpenGL. My problem is I can't find any actually shipped games that were made with Python, let alone these libraries - so I don't know how well they perform in real world situations, or even if any of them are suitable for use in an actual game and not a competition.\nCan anyone please shed some light on these libraries? Is PyGame still used effectively? Is Pyglet worth while? Have either of them been used to make a game? Are there any other libraries I'm forgetting?\nHonestly I'm not even sure I want to use Python, it seems too slow, unproven (For games written solely in Python), etc.... I have not found any game that was made primarily in Python, for sure, that has been sold. If I don't end up going with Python, what would a second\/better choice be? Java? LUA?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6320,"Q_Id":12016443,"Users Score":1,"Answer":"Pygame should suffice for what you want to do. Pygame is stable and if you look around the websites you will find games which have been coded in pygame. What type of game are you looking to implement?","Q_Score":1,"Tags":"python,pygame,game-engine,pyglet","A_Id":12016497,"CreationDate":"2012-08-18T06:32:00.000","Title":"Making a 2d game in Python - which library should be used?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to find a link by its text but it's written in non-English characters (Hebrew to be precise, if that matters). The \"find_element_by_link_text('link_text')\" method would have otherwise suited my needs, but here it fails. Any idea how I can do that? Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":258,"Q_Id":12023402,"Users Score":0,"Answer":"In the future you need to pastebin a representative snippet of your code, and certainly a traceback. I'm going to assume that when you say \"the code does not compile\" that you mean that you get an exception telling you you haven't declared an encoding.\nYou need a line at the top of your file that looks like # -*- coding: utf-8 -*- or whatever encoding the literals you've put in your file are in.","Q_Score":1,"Tags":"python,selenium,hyperlink","A_Id":12023574,"CreationDate":"2012-08-19T00:55:00.000","Title":"Selenium in Python: how to click non-English link?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could any one shed some light on how to migrate my MongoDB to PostgreSQL? What tools do I need, what about handling primary keys and foreign key relationships, etc?\nI had MongoDB set up with Django, but would like to convert it back to PostgreSQL.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1475,"Q_Id":12034390,"Users Score":1,"Answer":"Whether the migration is easy or hard depends on a very large number of things  including how many different versions of data structures you have to accommodate.  In general you will find it a lot easier if you approach this in stages:\n\nEnsure that all the Mongo data is consistent in structure with your RDBMS model and that the data structure versions are all the same.\nMove your data.  Expect that problems will be found and you will have to go back to step 1.\n\nThe primary problems you can expect are data validation problems because you are moving from a less structured data platform to a more structured one.\nDepending on what you are doing regarding MapReduce you may have some work there as well.","Q_Score":2,"Tags":"python,django,mongodb,database-migration,django-postgresql","A_Id":15858338,"CreationDate":"2012-08-20T08:25:00.000","Title":"From MongoDB to PostgreSQL - Django","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question might sound weird, but how do I make a job fail? \nI have a python script that compiles few files using scons, and which is running as a jenkins job. The script tests if the compiler can build x64 or x86 binaries, I want the job to fail if it fails to do one of these. \nFor instance: if I'm running my script on a 64-bit system and it fails to compile a 64-bit. Is there something I can do in the script that might cause to fail?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15709,"Q_Id":12036620,"Users Score":0,"Answer":"I came across this as a noob and found the accepted answer is missing something if you're running python scripts through a Windows batch shell in Jenkins.\nIn this case, Jenkins will only fail if the very last command in the shell fails. So your python command may fail but if there is another line after it which changes directory or something then Jenkins will believe the shell was successful.\nThe solution is to check the error level after the python line:\n\nif %ERRORLEVEL% NEQ 0 (exit)\n\nThis will cause the shell to exit immediately if the python line fails, causing Jenkins to be marked as a fail because the last line on the shell failed.","Q_Score":8,"Tags":"python,jenkins","A_Id":70767921,"CreationDate":"2012-08-20T11:11:00.000","Title":"Making a job fail in jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two programs: the first only write to sqlite db, and the second only read. May I be sure that there are never be some errors? Or how to avoid from it (in python)?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":383,"Q_Id":12046760,"Users Score":1,"Answer":"generally, it is safe if there is only one program writing the sqlite db at one time.\n(If not, it will raise exception like \"database is locked.\" while two write operations want to write at the same time.)\nBy the way, it is no way to guarantee the program will never have errors. using Try ... catch to handle exception will make the program much safer.","Q_Score":3,"Tags":"python,concurrency,sqlite","A_Id":12047988,"CreationDate":"2012-08-20T23:51:00.000","Title":"sqlite3: safe multitask read & write - how to?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, given a date, how do I find the preceding weekday? (Weekdays are Mon to Fri. I don't care about holidays)","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":20747,"Q_Id":12053633,"Users Score":1,"Answer":"in datetime module you can do something like this: a = date.today() - timedelta(days=1)\nand then a.weekday(). Where monday is 0 and sunday is 6.","Q_Score":21,"Tags":"python,date,weekday","A_Id":12053730,"CreationDate":"2012-08-21T11:14:00.000","Title":"Previous weekday in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is the problem I'm trying to solve,\nI want to write an application that will read outbound http request packets on the same machine's network card. This would then be able to extract the GET url from it.On basis of this information, I want to be able to stop the packet, or redirect it , or let it pass. \nHowever I want my application to be running in promiscuous mode (like wireshark does), and yet be able to eat up (stop) the outbound packet.\nI have searched around a bit on this..\nlibpcap \/ pcap.h allows to me read packets at the network card, however I haven't yet been able to figure out a way to stop these packets or inject new ones into the network.\nCertain stuff like twisted or scapy in python, allows me set up a server that is listening on some local port, I can then configure my browser to connect to it, using proxy configurations. This app can then do the stuff.. but my main purpose of being promiscuous is defeated here..\nAny help on how I could achieve this would be greatly appreciated ..","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1109,"Q_Id":12072506,"Users Score":0,"Answer":"Using pcap you cannot stop the packets, if you are under windows you must go down to the driver level... but you can stop only packets that your machine send.\nA solution is act as a pipe to the destination machine: You need two network interfaces (without address possibly), when you get a packet that you does not found interesting on the source network card you simply send it on the destination network card. If the packet is interesting you does not send it, so you act as a filter. I have done it for multimedia performance test (adding jitter, noise, etc.. to video streaming)","Q_Score":0,"Tags":"python,c,networking","A_Id":12075452,"CreationDate":"2012-08-22T11:53:00.000","Title":"Stop packets at the network card","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need python script that can sniff and decode SIP messages in order to check their correctness.\nAs a base for this script I use python-libpcap library for packets sniffing. I can catch UDP packet and extract SIP payload from it, but I don't know how to decode it. Does python has any libraries for packets decoding? I've found only dpkt, but as I understood it can't decode SIP. \nIf there are no such libraries how can I do this stuff by hands?\nThank you in advance!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5300,"Q_Id":12094148,"Users Score":4,"Answer":"Finally I did this with help of pyshark from the sharktools (http:\/\/www.mit.edu\/~armenb\/sharktools\/). In order to sniff IP packages I used scapy instead of libpcap.","Q_Score":3,"Tags":"python,sip,decode,pcap","A_Id":12708904,"CreationDate":"2012-08-23T14:38:00.000","Title":"Decode SIP messages with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a newbie to Google App Engine and Python.\nI want to create an entry in a SessionSupplemental table (Kind) anytime a new user accesses the site (regardless of what page they access initially).\nHow can I do this?\nI can imagine that there is a list of standard event triggers in GAE; where would I find these documented?  I can also imagine that there are a lot of system\/application attributes; where can I find these documented and how to use them?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":412,"Q_Id":12098358,"Users Score":0,"Answer":"I am trying to be pretty general here as I don't know whether you are using the default users service or not and I don't know how you are uniquely linking your SessionSupplemental entities to users or whether you even have a way to identify users at this point. I am also assuming you are using some version of webapp as that is the standard request handling library on App Engine. Let me know a bit more and I can update the answer to be more specific.\n\nSubclass the default RequestHandler in webapp with a new class (such as MyRequestHandler).\nIn your subclass override the initialize() method.\nIn your new initialize() method get the current user from your session system (or the users service or whatever you are using). Test to see if a SessionSupplemental entity already exists for this user and if not create a new one.\nFor all your other request handlers you now want to subclass MyRequestHandler (instead of the default RequestHandler).\nWhenever a request happens webapp will automatically call the initialize() method.\nThis is going to cost you a read for every request and also a write for every request by a new user. If you use the ndb library (instead of db) then a lot of the requests will just hit memcache instead of the datastore.\n\nNow if you are just starting creating a new AppEngine app I would recommend using the Python27 runtime and webapp2 and trying to leverage as much of the webapp2 Auth module as you can so you don't have to write so much session stuff yourself. Also, ndb can be much nicer than the default db library.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":12116756,"CreationDate":"2012-08-23T19:01:00.000","Title":"How can I trigger a function anytime there is a new session in a GAE\/Python Application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am using the Python C API and trying to create a function that will allocate new instances of PyTypeObjects to use in several C++ classes. The idea is that each class would have a pointer to a PyTypeObject that would get instantiated with this factory. The pointers must be static. \nHowever, I'm having issues with this approach.\n\nIn the class that contains the pointer to the PyTypeObject, I get the \"undefined reference\" linker error when I try to set that static variable equal to the result of the factory function (which is in another class but is static). I suppose this makes sense because the function wouldn't happen until runtime but I don't know another way to do this.\nI don't know how to set the PyTypeObject fields dynamically because the first field is always a macro: PyObject_VAR_HEAD. \n\nHope this makes sense. Basically, I'm trying to make it so several classes don't have to redefine PyTypeObject statically, but can instead instantiate their PyTypeObject variables from a factory function.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":12098554,"Users Score":0,"Answer":"Try this: create a 'template' PyTypeObject, and use struct copying (or memcpy) to clone the basic template. Then you can fill it in with the requisite field definitions after that. This solves (2), since you only have to declare the full PyTypeObject once.\nFor your first point, you just set the static variable from your module init instead of doing it in the static variable declaration. So, it won't be set until your module actually initializes.\nIf you plan on doing this often, it may be worth looking at Boost::Python, which simplifies the process of generating CPython wrappers from C++ classes.","Q_Score":0,"Tags":"python,c,api","A_Id":12098669,"CreationDate":"2012-08-23T19:17:00.000","Title":"Static factory for PyTypeObject","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I installed python 3.2 and later installed python 2.7. Somehow the IDLE, which I open it by right-click on python file -> Edit with IDLE, are using python 2.7 instead of python 3.2.\nIt seems that python 2.7 was set as default with IDLE. Even if I changed the PATH environment variable in windows advance setting back to python 3.2, the default python shell is still 2.7. I am sure that there was no more python 2.7 in the path.\nLater I have to uninstall python 2.7 and reinstall python 3.2.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1564,"Q_Id":12102061,"Users Score":1,"Answer":"The IDLE context menu plug-in is registered when you install Python and points to the version of IDLE supplied with the Python installed. (IDLE itself has significant code changes between Python 2 and 3 because it's written in Python and the language changed a lot.) To change it, simply re-install the version of Python you wish the IDLE context menu to invoke.","Q_Score":5,"Tags":"python,windows-7","A_Id":12102132,"CreationDate":"2012-08-24T01:15:00.000","Title":"how to set python IDLE's default python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've seen a lot of stuff about running code in subprocesses or threads, and using the multiprocessing and threading modules it's been really easy. However, doing this in a GUI adds an extra layer of complication.\nFrom what I understand, the GUI classes don't like it if you try and manipulate them from multiple threads (or processes). The workaround is to send the data from whatever thread you created it in to the thread responsible for the graphics and then render it there.\nUnfortunately, for the scenario I have in mind this is not an option: The gui I've created allows users to write their own plotting code which is then executed. This means I have no control over how they plot exactly, nor do I want to have it. (Update: these plots are displayed in separate windows and don't need to be embedded anywhere in the main GUI. What I want is for them to exist separated from the main GUI, without sharing any of the underlying stack of graphics libraries.)\nSo what I'm wondering now is \nIs there some clean(ish) way of executing a string of python code in a whole new interpreter instance with its own ties to the windowing system?\n\nIn response to the comments:\nThe current application is set up as follows: A simple python script loads a wxPython gui (a wx.App). Using this gui users can set up a simulation, part of which involves creating a script in plain python that runs the simulation and post-processes the results (which usually involves making plots and displaying them). At the moment I'm doing this by simply calling exec() on the script code. This works fine, but the gui freezes while the simulation is running. I've experimented with running the embedded script in a subprocess, which also works fine, right up until you try to display the created graphs (usually using matplotlib's show()). At this point some library deep down in the stack of wxPython, wx, gtk etc starts complaining because you cannot manipulate it from multiple threads.\nThe set-up I would like to have is roughly the same, but instead of the embedded script sharing a GUI with the main application, I would like it to show graphics in an environment of its own.\nAnd just to clarify:\nThis is not a question about \"how do I do multithreading\/multiprocessing\" or even \"how do I do multithreading\/multiprocessing within a single wxpython gui\". The question is how I can start a script from a gui that loads an entirely new gui. How do I get the window manager to see this script as an entirely separate application?\nThe easiest way would be to generate it in a temporary folder somewhere and then make a non-blocking call to the python interpreter, but this makes communication more difficult and it'd be quite hard to know when I could delete the temp files again. I was hoping there was a cleaner, dynamical way of doing this.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":973,"Q_Id":12105855,"Users Score":1,"Answer":"I don't no much about wx, I work with jython(python implemented in java and you can use java) and swing. Swing has its own worker thread, and if you do gui updates you wrap your code into a runnable and invoke it with swing.invokelater.\nYou could see if wx has something like that, if you however are only allowed to manipulate the gui from the thread in which you created it try something similar. create a proxy object for your gui, which forwards all your calls to your thread which forwards them to the gui.\nBut proxying like this gets messy. how about you let them define classes, with an 'updateGui' function, that they should hand back to you over a queue and that you will execute in your gui thread.","Q_Score":0,"Tags":"python,wxpython","A_Id":12106760,"CreationDate":"2012-08-24T08:38:00.000","Title":"Executing a python script in a subprocess - with graphics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use\n\npython 2.7 \npyodbc module\ngoogle app engine 1.7.1\n\nI can use pydobc with python but the Google App Engine can't load the module. I get a no module named pydobc error.\nHow can I fix this error or how can use MS-SQL database with my local Google App Engine.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2793,"Q_Id":12108816,"Users Score":0,"Answer":"You could, at least in theory, replicate your data from the MS-SQL to the Google Cloud SQL database. It is possible create triggers in the MS-SQL database so that every transaction is reflected on your App Engine application via a REST API you will have to build.","Q_Score":3,"Tags":"python,sql-server,google-app-engine","A_Id":12116542,"CreationDate":"2012-08-24T11:45:00.000","Title":"How can use Google App Engine with MS-SQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In one model I've got update() method which updating few fields and creates one object of some other model. The problem is that data I use to update is fetched from another host (unique for each object) and it could take a moment (host may be offline, and timeout is set to 3sec). And now, I need to update couple of hundred objects, 3-4 times per hour - of course updating every one in a row is not an option, because it could take all day.\nMy first thought was split it up for 50-100 threads so each one could update its own part of objects. 99% of update function time is waiting for server respond (there is few bytes of data only, so pings are the problem), I think the CPU won't be a problem, I'm more worried about:\n\nDjango ORM. Can it handle it? Getting all objects, splitting it up, and updating from >50 threads?\nIs it a good idea to solve this? If it is - how to do it and don't screw a database? Or maybe I shouldn't care about so little records?\nIf it isn't a good way, how to do it right?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5194,"Q_Id":12111983,"Users Score":7,"Answer":"You can perform actions from different thread manually (eg with Queue and executors pool), but you should note, that Django's ORM manages database connections in thread-local variables. So each new thread = new connection to database (which will be not good idea for 50-100 threads for one request - too many connections). On the other hand, you should check database \"bandwith\".","Q_Score":7,"Tags":"python,mysql,django,multithreading","A_Id":12115563,"CreationDate":"2012-08-24T15:05:00.000","Title":"Django databases and threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a simple python script that runs as soon as a certain user on my linux system logs in. It ask's for a password... however the problem is they just exit out of the terminal or minimize it and continue using the computer. So basically it is a password authentication script. So what I am curious about is how to make the python script stay up and not let them exit or do anything else until they entered the correct password. Is there some module I need to import or some command that can pause the system functions until my python script is done?\nThanks\nI am doing it just out of interest and I know a lot could go wrong but I think it would be a fun thing to do. It can even protect 1 specific system process. I am just curious how to pause the system and make the user do the python script before anything else.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":223,"Q_Id":12133857,"Users Score":2,"Answer":"You want the equivalent of a \"modal\" window, but this is not (directly) possible in a multiuser, multitasking environment.\nThe next best thing is to prevent the user from accessing the system. For example, if you create an invisible window as large as the display, that will intercept any mouse events, and whatever is \"behind\" will be unaccessible.\nAt that point you have the problem of preventing the user from using the keyboard to terminate the application, or to switch to another application, or to another virtual console (this last is maybe the most difficult). So you need to access and lock the keyboard, not only the \"standard\" keyboard but the low-level keys as well.\nAnd to do this, your application needs to have administrative rights, and yet run in the user environment. Which starts to look like a recipe for disaster, unless you really know what you are doing.\nWhat you want to do should be done through a Pluggable Authentication Module (PAM) that will integrate with your display manager. Maybe, you can find some PAM module that will \"outsource\" or \"callback\" some external program, i.e., your Python script.","Q_Score":0,"Tags":"python,linux,passwords","A_Id":12134029,"CreationDate":"2012-08-26T20:57:00.000","Title":"pause system functionality until my python script is done","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a simple python script that runs as soon as a certain user on my linux system logs in. It ask's for a password... however the problem is they just exit out of the terminal or minimize it and continue using the computer. So basically it is a password authentication script. So what I am curious about is how to make the python script stay up and not let them exit or do anything else until they entered the correct password. Is there some module I need to import or some command that can pause the system functions until my python script is done?\nThanks\nI am doing it just out of interest and I know a lot could go wrong but I think it would be a fun thing to do. It can even protect 1 specific system process. I am just curious how to pause the system and make the user do the python script before anything else.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":223,"Q_Id":12133857,"Users Score":3,"Answer":"There will always be a way for the user to get past your script.\nLet's assume for a moment that you actually manage to block the X-server, without blocking input to your program (so the user can still enter the password). The user could just alt-f1 out of the X-server to a console and kill \"your weird app\". If you manage to block that too he could ssh to the box and kill your app.\nThere is most certainly no generic way to do something like this; this is what the login commands for the console and the session managers (like gdm) for the graphical display are for: they require a user to enter his password before giving him some form of interactive session. After that, why would you want yet another password to do the same thing? the system is designed to not let users use it without a password (or another form of authentication), but there is no API to let programs block the system whenever they feel like it.","Q_Score":0,"Tags":"python,linux,passwords","A_Id":12134000,"CreationDate":"2012-08-26T20:57:00.000","Title":"pause system functionality until my python script is done","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"is snmp really required to manage devices ?\ni'd like to script something with python to manage devices (mainly  servers), such as disk usage, process list etc.\ni'm learning how to do and many article speak about snmp protocole.\nI can't use, for example, psutil, or subprocess or os modules, and send information via udp ?\nThanks a lot","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":197,"Q_Id":12147224,"Users Score":1,"Answer":"The SNMP is a standard monitoring (and configuration) tool used widely in managing network devices (but not only). I don't understand your question fully - is it a problem that you cannot use SNMP because device does not support it (what does it support then?) To script anything you have to know what interface is exposed to you (if not a MIB files then what?). Did you read about NETCONF?","Q_Score":0,"Tags":"python,monitoring,snmp","A_Id":12147545,"CreationDate":"2012-08-27T18:11:00.000","Title":"is snmp required","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"is snmp really required to manage devices ?\ni'd like to script something with python to manage devices (mainly  servers), such as disk usage, process list etc.\ni'm learning how to do and many article speak about snmp protocole.\nI can't use, for example, psutil, or subprocess or os modules, and send information via udp ?\nThanks a lot","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":197,"Q_Id":12147224,"Users Score":1,"Answer":"No, it's not required, but your question is sort of like asking if you're required to use http to serve web pages.  Technically you don't need it, but if you don't use it you're giving up interoperability with a lot of existing client software.","Q_Score":0,"Tags":"python,monitoring,snmp","A_Id":12148746,"CreationDate":"2012-08-27T18:11:00.000","Title":"is snmp required","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a php application that executes Python scripts via exec() and cgi.  \nI have a number of pages that do this and while I know WSGI is the better way to go long-term, I'm wondering if for a small\/medium amount of traffic this arrangement is acceptable.  \nI ask because a few posts mentioned that Apache has to spawn a new process for each instance of the Python interpreter which increases overhead, but I don't know how significant it is for a smaller project.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":266,"Q_Id":12150405,"Users Score":0,"Answer":"In case of CGI, server starts a copy of PHP interpreter every time it gets a request. PHP in turn starts Python process, which is killed after exec(). There is a huge overhead on starting two processes and doing all imports on every request.\nIn case of FastCGI or WSGI, server keeps couple processes warmed up (min and max amount of running processes is configurable), so at price of some memory you get rid of starting new process every time. However, you still have to start\/stop Python process on every exec() call. If you can use a Python app without exec(), eg port PHP part to Python, it would boost performance a lot.\nBut as you mentioned this is a small project so the only important criteria is if your current server can sustain current load.","Q_Score":4,"Tags":"php,python,exec","A_Id":12151910,"CreationDate":"2012-08-27T22:18:00.000","Title":"PHP Exec() and Python script scaleability","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using ZODB which, as I understand it, uses pickle to store class instances. I'm doing a bit of refactoring where I want to split my models.py file into several files. However, if I do this, I don't think pickle will be able to find the class definitions, and thus won't be able to load the objects that I already have stored in the database. What's the best way to handle this problem?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":745,"Q_Id":12163918,"Users Score":1,"Answer":"Unfortunately, there is no easy solution. You can convert your old-style objects with the refactored ones (I mean classes which are in another file\/module) by the following schema\n\nadd the refactored classes to your code without removing the old-ones\nwalk through your DB starting from the root and replacing all old objects with new equivalents\ncompress your database (that's important)\nnow you can remove your old classes from the sources","Q_Score":7,"Tags":"python,refactoring,pickle,zodb","A_Id":12164152,"CreationDate":"2012-08-28T16:50:00.000","Title":"pickle\/zodb: how to handle moving .py files with class definitions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using ZODB which, as I understand it, uses pickle to store class instances. I'm doing a bit of refactoring where I want to split my models.py file into several files. However, if I do this, I don't think pickle will be able to find the class definitions, and thus won't be able to load the objects that I already have stored in the database. What's the best way to handle this problem?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":745,"Q_Id":12163918,"Users Score":3,"Answer":"As long as you want to make the pickle loadable without performing a migration to the new class model structure: you can use alias imports of the refactored classes inside the location of the old model.py.","Q_Score":7,"Tags":"python,refactoring,pickle,zodb","A_Id":12164218,"CreationDate":"2012-08-28T16:50:00.000","Title":"pickle\/zodb: how to handle moving .py files with class definitions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got this:\ntu = (\"func1\", \"func2\", \"func3\")\nAnd with the operation I am looking for I would get this for the first string:\nmoduleA.func1()\nI know how to concatenate strings, but is there a way to join into a callable string?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":186,"Q_Id":12167452,"Users Score":5,"Answer":"getattr(moduleA, 'func1')() == moduleA.func1()","Q_Score":1,"Tags":"python,string,function","A_Id":12167479,"CreationDate":"2012-08-28T21:00:00.000","Title":"Join two strings into a callable string 'moduleA' + 'func1' into moduleA.func1()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got this:\ntu = (\"func1\", \"func2\", \"func3\")\nAnd with the operation I am looking for I would get this for the first string:\nmoduleA.func1()\nI know how to concatenate strings, but is there a way to join into a callable string?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":186,"Q_Id":12167452,"Users Score":0,"Answer":"If you mean get a function or method on a class or module, all entities (including classes, modules, functions, and methods) are objects, so you can do a func = getattr(thing 'func1') to get the function, then func() to call it.","Q_Score":1,"Tags":"python,string,function","A_Id":12167492,"CreationDate":"2012-08-28T21:00:00.000","Title":"Join two strings into a callable string 'moduleA' + 'func1' into moduleA.func1()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use matplotlib from my Sublime Text 2 directly via the build command.\nDoes anybody know how I accomplish that? I'm really confused about the whole multiple python installations\/environments. Google didn't help.\nMy python is installed via homebrew and in my terminal (which uses brew python), I have no problem importing matplotlib from there. But Sublime Text shows me an import Error (No module named matplotlib.pyplot).\nI have installed Matplotlib via EPD free. The main matplotlib .dmg installer refused to install it on my disk, because no system version 2.7 was found. I have given up to understand the whole thing. I just want it to work.\nAnd, I have to say, for every bit of joy python brings with it, the whole thing with installations and versions and path, environments is a real hassle. \nBeneath a help for this specific problem I would appreciate any helpful link to understand and this environment mess.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3245,"Q_Id":12173541,"Users Score":5,"Answer":"I had the same problem and the following fix worked for me:\n1 - Open Sublime Text 2 -> Preferences -> Browse Packages\n2 - Go to the Python folder, select file Python.sublime-build\n3 - Replace the existing cmd line for this one:\n\n\"cmd\": [\"\/Library\/Frameworks\/Python.framework\/Versions\/Current\/bin\/python\", \"$file\"],\n\nThen click CMD+B and your script with matplotlib stuff will work.","Q_Score":3,"Tags":"python,matplotlib,sublimetext2,sublimetext","A_Id":12610165,"CreationDate":"2012-08-29T08:16:00.000","Title":"MatPlotLib with Sublime Text 2 on OSX","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. \nAs far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions?\ntl;dr: when should I use them, why should I use them, and how should I use them?","AnswerCount":12,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":721840,"Q_Id":12179271,"Users Score":0,"Answer":"A slightly different way to think about it that might be useful for someone... A class method is used in a superclass to define how that method should behave when it's called by different child classes. A static method is used when we want to return the same thing regardless of the child class that we are calling.","Q_Score":1809,"Tags":"python,oop,static-methods,class-method","A_Id":41840490,"CreationDate":"2012-08-29T13:37:00.000","Title":"Meaning of @classmethod and @staticmethod for beginner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. \nAs far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions?\ntl;dr: when should I use them, why should I use them, and how should I use them?","AnswerCount":12,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":721840,"Q_Id":12179271,"Users Score":279,"Answer":"@classmethod means: when this method is called, we pass the class as the first argument instead of the instance of that class (as we normally do with methods). This means you can use the class and its properties inside that method rather than a particular instance.\n@staticmethod means:  when this method is called, we don't pass an instance of the class to it (as we normally do with methods). This means you can put a function inside a class but you can't access the instance of that class (this is useful when your method does not use the instance).","Q_Score":1809,"Tags":"python,oop,static-methods,class-method","A_Id":12179325,"CreationDate":"2012-08-29T13:37:00.000","Title":"Meaning of @classmethod and @staticmethod for beginner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. \nAs far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions?\ntl;dr: when should I use them, why should I use them, and how should I use them?","AnswerCount":12,"Available Count":3,"Score":0.0166651236,"is_accepted":false,"ViewCount":721840,"Q_Id":12179271,"Users Score":1,"Answer":"I'm a beginner on this site, I have read all above answers, and got the information what I want. However, I don't have the right to upvote.  So I want to get my start on StackOverflow with the answer as I understand it.\n\n@staticmethod doesn't need self or cls as the first parameter of the method\n@staticmethod and @classmethod wrapped function could be called by instance or class variable\n@staticmethod decorated function impact some kind 'immutable property' that subclass inheritance can't overwrite its base class function which is wrapped by a @staticmethod decorator. \n@classmethod need cls (Class name, you could change the variable name if you want, but it's not advised) as the first parameter of function\n@classmethod always used by subclass manner, subclass inheritance may change the effect of base class function, i.e. @classmethod wrapped base class function could be overwritten by different subclasses.","Q_Score":1809,"Tags":"python,oop,static-methods,class-method","A_Id":45264634,"CreationDate":"2012-08-29T13:37:00.000","Title":"Meaning of @classmethod and @staticmethod for beginner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am noticing an issue in my Tkinter application when I create a new Toplevel popup (actually a subclass of tkSimpleDialog.Dialog) and try to navigate through its widgets with the Tab key.  It works as expected, except whatever I had selected in a Listbox in my application's main window becomes unselected, as if the widget in the popup took the focus from it. Does anyone know why this is happening and how to prevent it? My Tkinter knowledge doesn't cover how interactions between windows affect the focus...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":236,"Q_Id":12184739,"Users Score":2,"Answer":"Solution: When creating the entry widgets in the popup, set their exportselection property to 0. Then selecting them won't affect any other selections.","Q_Score":1,"Tags":"python,tkinter","A_Id":12184877,"CreationDate":"2012-08-29T18:56:00.000","Title":"Widgets in a Tkinter popup taking Tab focus from widgets in another window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a website using Django 1.4 and I use django-registration for the signup process. It turns out that Unicode characters are not allowed as usernames, whenever a user enters e.g. a Chinese character as part of username the registration fails with:\n\nThis value may contain only letters, numbers and @\/.\/+\/-\/_ characters.\n\nIs it possible to change it so Unicode characters are allowed in usernames? If yes, how can I do it? Also, can it cause any problem?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2967,"Q_Id":12185218,"Users Score":5,"Answer":"It is really not a problem - because this character restriction is in UserCreationForm (or RegistrationForm in django-registration) only as I remember, and you can easily make your own since field in database is just normal TextField.\nBut those restriction is there not without a reason. One of the possible problems I can think of now is creating links - usernames are often used for that and it may cause a problem. There is also bigger possibility of fake accounts with usernames looking the same but being in fact different characters, etc.","Q_Score":6,"Tags":"python,django,unicode,internationalization,django-registration","A_Id":12185565,"CreationDate":"2012-08-29T19:32:00.000","Title":"Unicode characters in Django usernames","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a device that is connected to my Mac via bluetooth. I would like to use R (or maybe Python, but R is preferred) to read the data real-time and process it. Does anyone know how I can do the data streaming using R on a Mac?\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":377,"Q_Id":12187795,"Users Score":0,"Answer":"there is a strong probability that you can enumerate the bluetooth as serial port for the bluetooth and use pyserial module to communicate pretty easily...\nbut if this device does not enumerate serially you will have a very large headache trying to do this... \nsee if there are any com ports that are available if there are its almost definitely enumerating as a serial connection","Q_Score":0,"Tags":"python,macos,r,bluetooth","A_Id":12187989,"CreationDate":"2012-08-29T23:16:00.000","Title":"How can I stream data, on my Mac, from a bluetooth source using R?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a task that retries often, and I would like a way for it to cleanup if it is revoked while it is in the retry state. It seems like there are a few options for doing this, and I'm wondering what the most acceptable\/cleanest would be. Here's what I've thought of so far:\n\nCustom Camera that picks up revoked tasks and calls on_revoked\nCustom Event Consumer that knows to process on_revoked on tasks that get revoked\nUsing AbortableTasks and using abort instead of revoke (I'd really like to avoid this)\n\nAre there any other options that I am missing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":355,"Q_Id":12200972,"Users Score":0,"Answer":"Use AbortableTask as a template and create a RevokableTask class to your specification.","Q_Score":0,"Tags":"python,celery","A_Id":18464160,"CreationDate":"2012-08-30T16:00:00.000","Title":"how to implement an on_revoked event in celery","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i'll try to be the most specific possible. I have a Django project and i want to be able to draw a inner map of a certain place. By that, i mean a graphical representation of important objects like the tables positions, bathrooms etc. I'm trying to avoid Flash as an option. Is there an existing API that i can use? Or how can i get this thing working?\nI don't mean to draw soemthing in 3d, just a simple view from above, like a blueprint.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":211,"Q_Id":12203149,"Users Score":2,"Answer":"Assuming you mean drawing plans interactively in the browser, rather than maps in the sense of Google Maps, you need something like HTML5 canvas or SVG, and a library like fabric.js (for canvas) or Raphael (for SVG). Your JS code will then handle the mechanics of drawing lines from mouse input, producing a picture in the browser. You can then extract that picture using JS and pass it back to the server for saving as a PNG or whatever. \nIf you're targeting modern browsers, canvas is definitely the way to go - it's a much nicer API, has better libraries (IMO) and is easier to extract PNGs from. SVG isn't too bad, but getting PNGs out is tricky - it relies either on hacks (converting the SVG to canvas in JS, rendering it in an invisible element, then converting that to PNG!) or sending the whole SVG to the server to be rendered there. \nI've recently implemented something requiring very similar mechanics, although for a very different purpose, so if you have any more detailed questions feel free to ask.","Q_Score":0,"Tags":"python,django,flash,api,graphics","A_Id":12203505,"CreationDate":"2012-08-30T18:23:00.000","Title":"Draw an inner map of a certain place (like a house blueprint) in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a collection that is potentially going to be very large. Now I know MongoDB doesn't really have a problem with this, but I don't really know how to go about designing a schema that  can handle a very large dataset comfortably. So I'm going to give an outline of the problem.\nWe are collecting large amounts of data for our customers. Basically, when we gather this data it is represented as a 3-tuple, lets say (a, b, c), where b and c are members of sets B and C respectively. In this particular case we know that the B and C sets will not grow very much over time. For our current customers we are talking about ~200,000 members. However, the A set is the one that keeps growing over time. Currently we are at about ~2,000,000 members per customer, but this is going to grow (possibly rapidly.) Also, there are 1->n relations between b->a and c->a.\nThe workload on this data set is basically split up into 3 use cases. The collections will be periodically updated, where A will get the most writes, and B and C will get some, but not many. The second use case is random access into B, then aggregating over some number of documents in C that pertain to b \\in B. And the last usecase is basically streaming a large subset from A and B to generate some new data.\nThe problem that we are facing is that the indexes are getting quite big. Currently we have a test setup with about 8 small customers, the total dataset is about 15GB in size at the moment, and indexes are running at about 3GB to 4GB. The problem here is that we don't really have any hot zones in our dataset. It's basically going to get an evenly distributed load amongst all documents.\nBasically we've come up with 2 options to do this. The one that I described above, where all data for all customers is piled into one collection. This means we'd have to create an index om some field that links the documents in that collection to a particular customer.\nThe other options is to throw all b's and c's together (these sets are relatively small) but divide up the C collection, one per customer. I can imangine this last solution being a bit harder to manage, but since we rarely access data for multiple customers at the same time, it would prevent memory problems. MongoDB would be able to load the customers index into memory and just run from there.\nWhat are your thoughts on this?\nP.S.: I hope this wasn't too vague, if anything is unclear I'll go into some more details.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":239,"Q_Id":12210307,"Users Score":1,"Answer":"It sounds like the larger set (A if I followed along correctly), could reasonably be put into its own database.  I say database rather than collection, because now that 2.2 is released you would want to minimize lock contention between the busier database and the others, and to do that a separate database would be best (2.2 introduced database level locking).  That is looking at this from a single replica set model, of course.\nAlso the index sizes sound a bit out of proportion to your data size - are you sure they are all necessary?  Pruning unneeded indexes, combining and using compound indexes may well significantly reduce the pain you are hitting in terms of index growth (it would potentially make updates and inserts more efficient too).  This really does need specifics and probably belongs in another question, or possibly a thread in the mongodb-user group so multiple eyes can take a look and make suggestions.\nIf we look at it with the possibility of sharding thrown in, then the truly important piece is to pick a shard key that allows you to make sure locality is preserved on the shards for the pieces you will frequently need to access together.  That would lend itself more toward a single sharded collection (preserving locality across multiple related sharded collections is going to be very tricky unless you manually split and balance the chunks in some way).  Sharding gives you the ability to scale out horizontally as your indexes hit the single instance limit etc. but it is going to make the shard key decision very important.\nAgain, specifics for picking that shard key are beyond the scope of this more general discussion, similar to the potential index review I mentioned above.","Q_Score":2,"Tags":"python,mongodb","A_Id":12216914,"CreationDate":"2012-08-31T06:56:00.000","Title":"Split large collection into smaller ones?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating an application with wxpython for writing tests in schools, and it needs to be able to block the windows key, alt-tab and so on to prevent cheating. Is this possible and if it is, how do you do it?\nI know that you can't block ctrl + alt + del, but is it possible to detect when it is pressed?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":876,"Q_Id":12210976,"Users Score":0,"Answer":"The simple answer is No, unless this is a touchscreen application with no access to the computer hardware. That would probably work. Otherwise you'll have to look into how to lockdown your PC with Microsoft Policies etc. Or you might be able to do it with a locked down Linux install. Regardless, it's not really something you can manage with wxPython. It's something you have to manage at the OS level.","Q_Score":1,"Tags":"python,windows,wxpython","A_Id":12216343,"CreationDate":"2012-08-31T07:46:00.000","Title":"Block windows key wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using epy\/ropemacs for my python project. \"C-c g\" (rope-goto-definition) works fine if the target is my source file. But it doesnt jump to third party source files. What I want to be able to do is jump to relevant third party source files. \nThis might be just a matter of letting rope know what the path the libraries are. I dont know how to do it though. Any pointers will be helpful","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":12212473,"Users Score":0,"Answer":"Ok found the solution. Edit .ropeproject\/config.py and add these lines to to set_prefs function\ndef set_prefs(prefs):\n\u00a0\u00a0\u00a0\u00a0...\n\u00a0\u00a0\u00a0\u00a0prefs.add('python_path', '<path to your external library>')\nExample:\n\u00a0\u00a0\u00a0\u00a0prefs.add('python_path', '\/usr\/local\/google_appengine')","Q_Score":0,"Tags":"python,emacs,rope","A_Id":12436344,"CreationDate":"2012-08-31T09:24:00.000","Title":"Jumping to Python library sources with epy\/emacs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on C++ programming with perforce (a version control tool) on VMS.\nI need to handle tens or even hundreds of C++ files (managed by perforce) on VMS. \nI am familiar with Linux, python but not DCL (a script language) on VMS. \nI need to find a way to make programming\/debug\/code-review as easy as possible. \nI prefer using python and kscope (a kde based file search\/code-review GUI tool that can generate call graph) or similar tools on VMS. \nI do not have sys-adm authorization, so I prefer some code-review GUI tools that can be installed without the  authorization. \nWould you please give me some suggestions about how to do code-review\/debug\/programing\/compile\/test by python on VMS meanwhile using kscope or similar large-scale files management tools for code-review ? \nAny help will really be appreciated. \nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":281,"Q_Id":12218088,"Users Score":0,"Answer":"Indeed, it's not clear from your question what sort of programming you want to do on VMS: C++ or python??\nAssuming your first goal is to get familiar with the code-base, i.e. you want the ease of cross-ref'ing the sources:\n\nIf you have Perforce server running on VMS, then you may try to connect to it directly with Linux Perforce client. And do \"review\" locally on Linux.\nIf you've no Linux client, I'd try fetching the latest revisions off and importing raw files it into an external repository (svn, git, fossil etc.). Then again using Linux client and tools.\n\nIf your ultimate goal is to do all development off VMS, then it may not really be viable -- the code may use VMS specific includes, system\/RMS calls, data structs. And sync'ing the changes back and forth to VMS will get messy.\nFrom my experience, once you're familiar with the code-base, it's a lot more effective to make the code-changes directly on VMS using whatever editor is available (EDIT\/TPU, EDT, LSE, emacs or vim ports etc.).\nAs for debugging - VMS native debugger supports X-GUI as well as command-line. Check your build system for debug build, or use \/NOOPT \/DEBUG compile and \/DEBUG link qualifiers.\nBTW, have a look into DECset, if installed on your VMS system.","Q_Score":1,"Tags":"c++,python,linux,perforce,vms","A_Id":13205270,"CreationDate":"2012-08-31T15:08:00.000","Title":"How to do code-review\/debug\/coding\/test\/version-control for C++ on perforce and VMS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on C++ programming with perforce (a version control tool) on VMS.\nI need to handle tens or even hundreds of C++ files (managed by perforce) on VMS. \nI am familiar with Linux, python but not DCL (a script language) on VMS. \nI need to find a way to make programming\/debug\/code-review as easy as possible. \nI prefer using python and kscope (a kde based file search\/code-review GUI tool that can generate call graph) or similar tools on VMS. \nI do not have sys-adm authorization, so I prefer some code-review GUI tools that can be installed without the  authorization. \nWould you please give me some suggestions about how to do code-review\/debug\/programing\/compile\/test by python on VMS meanwhile using kscope or similar large-scale files management tools for code-review ? \nAny help will really be appreciated. \nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":281,"Q_Id":12218088,"Users Score":1,"Answer":"Your question is pretty broad so it's tough to give a specific answer.  \nIt sounds like you have big goals in mind which is good, but since you are on VMS, you won't have a whole lot of tools at your disposal.  It's unlikely that kscope works on VMS.  Correct  me if I'm wrong.  I believe a semi-recent version of python is functional there.\nI would recommend starting off with the basics.  Get a basic build system working that let's you build in release and debug.  Consider starting with either MMS (an HP provided make like tool) or GNU make.  You should also spend some time making sure that your VMS based Perforce client is working too.  There are some quirks that may or may not have been fixed by the nice folks at Perforce.\nIf you have more specific issues in setting up GNU make (on VMS) or dealing with the Perforce client on VMS, do ask, but I'd recommend creating separate questions for those.","Q_Score":1,"Tags":"c++,python,linux,perforce,vms","A_Id":12220702,"CreationDate":"2012-08-31T15:08:00.000","Title":"How to do code-review\/debug\/coding\/test\/version-control for C++ on perforce and VMS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having the same problem on Windows and Linux. I launch any of various python 2.6 shells and run nose.py() to run my test suite. It works fine. However, the second time I run it, and every time thereafter I get exactly the same output, no matter how I change code or test files. My guess is that it's holding onto file references somehow, but even deleting the *.pyc files, I can never get the output of nose.run() to change until I restart the shell, or open another one, whereupon the problem starts again on the second run. I've tried both del nose and reload(nose) to no avail.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":12225244,"Users Score":0,"Answer":"Solved* it with some outside help. I wouldn't consider this the proper solution, but by searching through sys.modules for all of my test_modules (which point to *.pyc files) and deling them, nose finally recognizes changes again. I'll have to delete them before each nose.run() call. These must be in-memory versions of the pyc files, as simply deleting them out in the shell wasn't doing it. Good enough for now.\nEdit:\n*Apparently I didn't entirely solve it. It does seem to work for a bit, and then all of a sudden it won't anymore, and I have to restart my shell. Now I'm even more confused.","Q_Score":0,"Tags":"python,unit-testing,nose","A_Id":12226647,"CreationDate":"2012-09-01T05:42:00.000","Title":"nose.run() seems to hold test files open after the first run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm at lost as to why I have deleted some versions of my apps in appspot.com, but event after clearing out the cache on both local browsers and appspot.com under pagespeed service.\nOld versions are still accessible. How long before deleted versions are gone?\nAlso, I have upload changes, but it does not show up at all.\nSo how long before changes show up?\nIf there is a way to force these to happen I would greatly appreciate it.\nThank you in advance of your assistance in this matter.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":12229881,"Users Score":0,"Answer":"If you go to the App Engine Admin page, you should be able to see all the instances you have running.  Kill all the instances for the old versions and it should stop serving.","Q_Score":1,"Tags":"google-app-engine,version-control,python-2.7","A_Id":12230416,"CreationDate":"2012-09-01T17:30:00.000","Title":"deleted version are still being serverd in appspot.com","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm at lost as to why I have deleted some versions of my apps in appspot.com, but event after clearing out the cache on both local browsers and appspot.com under pagespeed service.\nOld versions are still accessible. How long before deleted versions are gone?\nAlso, I have upload changes, but it does not show up at all.\nSo how long before changes show up?\nIf there is a way to force these to happen I would greatly appreciate it.\nThank you in advance of your assistance in this matter.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":155,"Q_Id":12229881,"Users Score":1,"Answer":"Google's GSLB proxy will cache your static files for hours, even if you have disable your appspot application and then re-enable it.\nMy solution is to append version number at every css, js, jpg url.","Q_Score":1,"Tags":"google-app-engine,version-control,python-2.7","A_Id":18547441,"CreationDate":"2012-09-01T17:30:00.000","Title":"deleted version are still being serverd in appspot.com","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a Python newbie but I'm interested in going into the depths of the language. I learned recently how to make simple GUI apps with wxPython and I loved it, I've read around that is the best cross-platform GUI kit around - yet, there are better \"native\" GUI kits (pyGTK, IronPython (if I'm not mistaken), pyObjc, etc.), but they are individual.\nIs there a way I can \"mix\" those GUI libraries into a single app? How can I provide the best GUI experience in a cross-platform app?\nAny help or suggestions are greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":294,"Q_Id":12234623,"Users Score":0,"Answer":"The grate benefit from wxPython is its use of native widgets where possible, so on GTK platform it'll use GTK, on windows it will use win32, and on mac it will use cocoa\/carbon.\nIf you don't write a cross-platform app, then you should better use the specific API to this platform, e.g. pyGTK (Gnome etc.), PyWin32T (Windows) or whatever native toolkit on your platform, as it is normally more updated to the latest API than wxPython.","Q_Score":0,"Tags":"python,user-interface,wxpython,cross-platform","A_Id":12235213,"CreationDate":"2012-09-02T08:57:00.000","Title":"Multiple GUI Kits in a single Python app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a string and I need match that string with an sequence and determine the number of times the matched sequence is found in that sequence\nBut it has following conditions\nSequence can contain only ACGT valid chars so seq could be ACGTGTCTG \nthe string could be ACGnkG\nwhere n could be replaced by A or G\n   k could be replaced by C or T\nhow can we find if the string matches the sequence by substituting valid values for n and k\nIs there any regular expression ?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":118,"Q_Id":12273201,"Users Score":2,"Answer":"re.findall(pattern, string) will return a list with all matches for pattern in string. len(...) will return the number of items in a list.","Q_Score":0,"Tags":"python,regex","A_Id":12273291,"CreationDate":"2012-09-05T00:55:00.000","Title":"string matching with substitution using PYTHON","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can I clear a complete csv file with python. Most forum entries that cover the issue of deleting row\/columns basically say, write the stuff you want to keep into a new file. I need to completely clear a file - how can I do that?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":41353,"Q_Id":12277864,"Users Score":1,"Answer":"The Python csv module is only for reading and writing whole CSV files but not for manipulating them. If you need to filter data from file then you have to read it, create a new csv file and write the filtered rows back to new file.","Q_Score":8,"Tags":"python,csv","A_Id":12277912,"CreationDate":"2012-09-05T09:02:00.000","Title":"python clear csv file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE: \nthis works\nname_element.send_keys(\"John Doe\")\nbut this doesnt\nname_element.send_keys(username)\nDoes anyone know how I can accomplish this? Pretty big Python noob, but used Google extensively to try and find out.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":9992,"Q_Id":12289700,"Users Score":0,"Answer":"I think username might be a variable in the python library you are using. Try calling it something else like Username1 and see if it works??","Q_Score":7,"Tags":"python,selenium","A_Id":60626053,"CreationDate":"2012-09-05T21:00:00.000","Title":"Passing variables through Selenium send.keys instead of strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE: \nthis works\nname_element.send_keys(\"John Doe\")\nbut this doesnt\nname_element.send_keys(username)\nDoes anyone know how I can accomplish this? Pretty big Python noob, but used Google extensively to try and find out.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":9992,"Q_Id":12289700,"Users Score":1,"Answer":"Try this.  \n\nusername = r'John Doe'\n\nname_element.send_keys(username)\n\nI was able to pass the string without casting it just fine in my test.","Q_Score":7,"Tags":"python,selenium","A_Id":47662083,"CreationDate":"2012-09-05T21:00:00.000","Title":"Passing variables through Selenium send.keys instead of strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create a portable python install on a usb but also install the scrapy framework on it, so I can work on and run my spiders on any computer.\nHas anyone else done this? Is it even possible?\nIf so how do you add scrapy onto the portable python usb and then run the spiders?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":658,"Q_Id":12290694,"Users Score":0,"Answer":"you can easily download scrapy executable, extract it with python, copy scrapy folder and content to c:\\Portable Python 2.7.5.1\\App\\Lib\\site-packages\\ and you'll have scrapy in your portable python.\nI just had my similar problem with SciKit this way.","Q_Score":1,"Tags":"python,scrapy,portable-python","A_Id":20853931,"CreationDate":"2012-09-05T22:29:00.000","Title":"How do you add the scrapy framework to portable python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to export a website(.html page) to a XML file. The website contains a table with some data which i require for using in my web project. The table in the website is formed using some javascript, so i cannot get the data by getting the page source. Please tell me how I can export the table in the website to a XML file using php\/python\/javascript\/perl.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2036,"Q_Id":12295834,"Users Score":4,"Answer":"You could try to reverse engineer the javascript code. Maybe it's making an ajax request to a service, that delivers the data as json. Use your browsers developer tools\/network tab to see what's going on.","Q_Score":1,"Tags":"php,javascript,python,xml,perl","A_Id":12295930,"CreationDate":"2012-09-06T08:20:00.000","Title":"Export a website to an XML Page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I intend to draw a chart with data in an xlsx file.\nIn order to keep the style, I HAVE TO draw it within excel.\nI found a package named win32com, which can give a support to manipulate excel file with python on win32 platform, but I don't know where is the doc.....\nAnother similar question is how to change the style of cells, such as font, back-color ?\nSo maybe all I wanna know is the doc, you know how to fish is more useful than fishes.... and an example is better.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2868,"Q_Id":12296563,"Users Score":1,"Answer":"Documentation for win32com is next to non-existent as far I know. However, I use the following method to understand the commands.\n\nMS-Excel\nIn Excel, record a macro of whatever action you intend to, say plotting a chart. Then go to the Macro menu and use View Macro to get the underlying commands. More often than not, the commands used would guide you to the corresponding commands in python that you need to use.\n\nPythonwin\nYou can use pythonwin to browse the underlying win32com defined objects (in your case Microsoft Excel Objects). In pythonwin (which can be found at \\Lib\\site-packages\\pythonwin\\ in your python installation), go to Tools -> COM Makepy Utility, select your required Library (in this case, Microsoft Excel 14.0 Object Library) and press Ok. Then when the process is complete, go to Tools -> COM Browser and open the required library under Registered Libraries. Note the ID no. as this would correspond to the source file. You can browse the various components of the library in the COM Browser.\n\nSource\nGo to \\Lib\\site-packages\\win32com\\ in your python installation folder. Run makepy.py and choose the required library. After this, the source file of the library can be found at \\Lib\\site-packages\\win32com\\gen_py . It is one of those files with the wacky name. The name corresponds to that found in Pythonwin. Open the file, and search for the commands you saw in the Excel Macro. (#2 and #3 maybe redundant, I am not sure)","Q_Score":0,"Tags":"python,excel,win32com","A_Id":13086152,"CreationDate":"2012-09-06T09:03:00.000","Title":"How to draw a chart with excel using python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"how can I debug python code in to the eclipse.if it will be done then we face less effort and fast do our work.can any one tell me???","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3051,"Q_Id":12298811,"Users Score":2,"Answer":"To debug your Openerp+python code in eclipse, start eclipse in debug perspective and follow the given steps:\n1: Stop your openERP running server by pressing \"ctr+c\".\n2: In eclipse go to Menu \"Run\/Debug Configurations\". In configuration window under \"Python Run\", create new debug configuration(Double click on 'Python Run').\n3: After creating new debug configuration follow the given steps:\n3.1: In \"Main\" tab under \"Project\", select the \"server\" project or folder (in which Openerp Server resides) from your workspace.\n3.2: Write location of 'openerp-server' under \"Main Module\".\n\nEx: ${workspace_loc:server\/openerp-server}.\n\n3.3: In \"Arguments\" tab under \"Program Arguments\", click on button \"Variables\" and new window will appear.\n3.4: Then create new \"Variable\" by clicking on \"Edit Variables\" button and new window will appear.\n3.5: Press on \"New\" button and give your addons path as value.\n\nEx: --addons ..\/addons,..\/your_module_path\n\n3.6: Press Ok in all the opened windows and then \"Apply\".\n4: Now into \"PyDev Package Explorer\" view go to 6.1\/server and right click on \"openerp-server\" file, Select 'Debug As --> Python Run'.\n5: Now in \"Console\" you can see your server has been started.\n6: Now open your .py file which you want to debug and set a break-point.\n7: Now start your module's form from 'gtk' or 'web-client' and execution will stop when execution will reach to break-point.\n8: Now enjoy by debugging your code by pressing \"F5, F6, F7\" and you can see value of your variables.","Q_Score":2,"Tags":"python,openerp","A_Id":12298831,"CreationDate":"2012-09-06T11:12:00.000","Title":"how can i debug openerp code in to the eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7661,"Q_Id":12318437,"Users Score":9,"Answer":"If you're looking to learn new things, and aren't looking to make a \"must work today\" type project, try Python3. It will be easier to move forward into the future with Python3, as it will become the standard over time.\nIf you're making something quick and dirty, you'll typically get better library support with Python 2.7.\nFinally, if anything you are using includes full unicode support, don't sell yourself short -- go with Python3. The simplification of unicode alone is worth it.","Q_Score":9,"Tags":"python,python-3.x,python-2.x","A_Id":12318539,"CreationDate":"2012-09-07T12:46:00.000","Title":"Confused about the choice between Python 2 vs Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":7661,"Q_Id":12318437,"Users Score":1,"Answer":"Nowadays, quite a number of libraries support Python 3. There is not a single list of these, so you'll have to check the frameworks you'd like to use for Python 3 compatibility. Some support Python 3 only in some beta stage, but that doesn't mean those are bad.\nI would start off nowadays with Python 3, and see where you get. Only if you know you need to support whatever you are developing on other platforms that you don't control, it may be better to start with Python 2.","Q_Score":9,"Tags":"python,python-3.x,python-2.x","A_Id":12318536,"CreationDate":"2012-09-07T12:46:00.000","Title":"Confused about the choice between Python 2 vs Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to pass somehow user password for rsync_project() function (that is wrapper for regular rsync command) from Fabric library.\nI've found the option --password-file=FILE of rsync command that requires password stored in FILE. This could somehow work but I am looking for better solution as I have (temporarily) passwords stored as plain-text in database.\nPlease provide me any suggestions how should I work with it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1763,"Q_Id":12335114,"Users Score":2,"Answer":"If rsync using ssh as a remote shell transport is an option and you can setup public key authentication for the users, that would provide you a secure way of doing the rsync without requiring passwords to be entered.","Q_Score":1,"Tags":"python,rsync,fabric","A_Id":12335299,"CreationDate":"2012-09-08T22:53:00.000","Title":"Putting password for fabric rsync_project() function","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have couple of apps on internet and want to serve static files for those apps using another Django App. I simply can't afford to use Amazon Web Services for my pet-projects.\nSo, I want to setup an Admin interface where I can manage static files easily. The following are the actions I am thinking to include in admin.\n\nUpload, delete static files\nGrouping static files (creating new folders, adding new\/ existing files to it); I am not sure If it is possible.\nchecking my models\n\nThus, I would like to know how secure is Django-Admin interface!\nHow secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of \"cracking\".. is django admin can be cracked easily?)","AnswerCount":2,"Available Count":2,"Score":-0.1973753202,"is_accepted":false,"ViewCount":2419,"Q_Id":12337318,"Users Score":-2,"Answer":"How secure is a Google Login ;) ? You can't tell as you can't look behind the scenes (Update: Of Google Login of course.). I would guess that Django's admin code is pretty safe, as it's used in lots of production systems. Still, beside the code, it also matters how you set it up. In the end, it depends on the level of security you need.","Q_Score":0,"Tags":"python,django,web-applications,django-admin","A_Id":12337353,"CreationDate":"2012-09-09T07:36:00.000","Title":"How secure is Django Admin interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have couple of apps on internet and want to serve static files for those apps using another Django App. I simply can't afford to use Amazon Web Services for my pet-projects.\nSo, I want to setup an Admin interface where I can manage static files easily. The following are the actions I am thinking to include in admin.\n\nUpload, delete static files\nGrouping static files (creating new folders, adding new\/ existing files to it); I am not sure If it is possible.\nchecking my models\n\nThus, I would like to know how secure is Django-Admin interface!\nHow secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of \"cracking\".. is django admin can be cracked easily?)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2419,"Q_Id":12337318,"Users Score":0,"Answer":"Besides serving static files through django is considered a bad idea, the django admin itself is pretty safe. You can take additional measure by securing it via .htaccess and force https access on it. You could also restrict access to a certain IP. If the admin is exposed to the whole internet you should at least be careful when choosing credentials. Since I don't know how secure Google and Yahoo really are, I can't compare to them.","Q_Score":0,"Tags":"python,django,web-applications,django-admin","A_Id":12337841,"CreationDate":"2012-09-09T07:36:00.000","Title":"How secure is Django Admin interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When installing mod_wsgi I get stuck after doing .\/config\nApparently I am missing the apxs2 \nHere is the result:\nchecking for apxs2... no\nchecking for apxs... \/usr\/sbin\/apxs\nchecking Apache version... 2.2.22\nchecking for python... \/usr\/bin\/python\nconfigure: creating .\/config.status\nconfig.status: creating Makefile\nWhat I am not sure of now is how I get apxs2 working and installed. Any solution anyone? This is so that I can later on install Django and finally get a Python\/Django environment up and running on my VPS.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":314,"Q_Id":12341610,"Users Score":0,"Answer":"You have Apache 2.2 core package installed, but possibly have the devel package for Apache 1.3 instead of that for 2.2 installed. This isn't certain though, as for some Apache distributions, such as when compiled from source code, 'apxs' is still called 'apxs'. It is only certain Linux distros that have changed the name of 'apxs' in Apache 2.2 distros to be 'apxs2'. This is why the mod_wsgi configure script checks for 'apxs2' as well as 'apxs'.\nSo, do the actual make and see if that fails before assuming you have the wrong apxs.","Q_Score":0,"Tags":"python,python-2.7,mod-wsgi","A_Id":12444455,"CreationDate":"2012-09-09T18:12:00.000","Title":"Error when installing mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When installing mod_wsgi I get stuck after doing .\/config\nApparently I am missing the apxs2 \nHere is the result:\nchecking for apxs2... no\nchecking for apxs... \/usr\/sbin\/apxs\nchecking Apache version... 2.2.22\nchecking for python... \/usr\/bin\/python\nconfigure: creating .\/config.status\nconfig.status: creating Makefile\nWhat I am not sure of now is how I get apxs2 working and installed. Any solution anyone? This is so that I can later on install Django and finally get a Python\/Django environment up and running on my VPS.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":314,"Q_Id":12341610,"Users Score":2,"Answer":"checking for apxs... \/usr\/sbin\/apxs\n   ...\n  config.status: creating Makefile\n\nIt succeeded. Go on to the next step.","Q_Score":0,"Tags":"python,python-2.7,mod-wsgi","A_Id":12341622,"CreationDate":"2012-09-09T18:12:00.000","Title":"Error when installing mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hello friends and colleagues\nI am trying to make a function mute \/ un mute microphone and  also speakers  for my program softphone  on pyt4  and using library PJSIP\nI found this in the code pjsip\npjsip:\n\n    def conf_set_tx_level(self, slot, level):\n        \"\"\"Adjust the signal level to be transmitted from the bridge to \n        the specified port by making it louder or quieter.\n\n        Keyword arguments:\n        slot        -- integer to identify the conference slot number.\n        level       -- Signal level adjustment. Value 1.0 means no level\n                       adjustment, while value 0 means to mute the port.\n        \"\"\"\n        lck = self.auto_lock()\n        err = _pjsua.conf_set_tx_level(slot, level)\n        self._err_check(\"conf_set_tx_level()\", self, err)\n\n    def conf_set_rx_level(self, slot, level):\n        \"\"\"Adjust the signal level to be received from the specified port\n        (to the bridge) by making it louder or quieter.\n\n        Keyword arguments:\n        slot        -- integer to identify the conference slot number.\n        level       -- Signal level adjustment. Value 1.0 means no level\n                       adjustment, while value 0 means to mute the port.\n        \"\"\"\n        lck = self.auto_lock()\n        err = _pjsua.conf_set_rx_level(slot, level)\n        self._err_check(\"conf_set_rx_level()\", self, err)\n\nwell I understand I need to send a parameter 0, but how to do?\nAnd to return back work the sound device and microphone.\nMaybe it \"\"\"\"\"pjsua_conf_adjust_tx_level(slot_number, 0 )\"\"\"\"\"","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1239,"Q_Id":12342807,"Users Score":1,"Answer":"himself answer :-)\nin my case it was so\n\n        # call window\n\n        ################ \n        self.MuteMic = False\n        self.MuteSpeaker = False\n        ################\n\n\n        #btn signals\n        self.connect(self.MuteUnmuteMicButton, QtCore.SIGNAL(\"clicked()\"), self.MuteUnmuteMic)\n        self.connect(self.MuteUnmuteSpeakerButton, QtCore.SIGNAL(\"clicked()\"), self.MuteUnmuteSpeaker)\n\n\n\n\n    def MuteUnmuteMic(self):\n        try:\n            if self.MuteMic:\n                self.MuteMic = False\n                self.parent().unmute_mic()\n            else:\n                self.MuteMic = True\n                self.parent().mute_mic()\n\n        except:\n                debug (\"\u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430 (call Window).\")\n\n    def MuteUnmuteSpeaker(self):\n        try:\n            if self.MuteSpeaker:\n                self.MuteSpeaker = False\n                self.parent().unmute_speaker()\n            else:\n                self.MuteSpeaker = True\n                self.parent().mute_speaker()\n\n        except:\n                debug (\"\u043e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430 (call Window).\")\n\n# other code\n\n\n----------\n\n\n# ----------------------core of the my app \n# ---import PJUA lib----\n\n        def mute_mic(self):\n            #this that you need in my case my app connected to pjua \"self.lib\"\n            self.lib.conf_set_rx_level(0,0)\n\n            debug (\"\u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430\")\n        def unmute_mic(self):\n            self.lib.conf_set_rx_level(0,1)\n\n        debug (\"\u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430\")\n        def mute_speaker(self):         \n            self.lib.conf_set_tx_level(0,0)\n\n            debug (\"\u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u043e\u0432\")\n        def unmute_speaker(self):\n            self.lib.conf_set_tx_level(0,1)\n\n        debug (\"\u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u043e\u0432\")","Q_Score":0,"Tags":"python,pyqt4,pjsip","A_Id":12426092,"CreationDate":"2012-09-09T20:44:00.000","Title":"pyqt4, function Mute \/ Un mute microphone and also speakers [PJSIP]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going to be storing a significant amount of information inside Django's session cookie.  I want this data to persist for the entire time the user is on the website. When he leaves, the data should be deleted, but the session MUST persist. I do not want to user to need to log in every time he returns to the website.\nI found ways to purge the entire session cookie every time a user leaves the website, but ideally I would like to only delete select pieces of the cookie which I explicitly set.  Does anyone know how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1943,"Q_Id":12342820,"Users Score":2,"Answer":"You're confusing things a bit.\nThe only thing stored inside \"Django's session cookie\" is an ID. That ID refers to the data which is stored inside the session backend: this is usually a database table, but could be a file or cache location depending on your Django configuration.\nNow the only time that data is updated is when it is modified by Django. You can't expire data automatically, except by either the cookie itself expiring (in which case the entire set of data persists in the session store, but is no longer associated with the client) or by running a process on the server that modifies sessions programmatically.\nThere's no way of telling from the server end when a user leaves a website or closes his browser. So the only way of managing this would be to run a cron job on your server that gets sessions that were last modified (say) two hours ago, and iterate through them deleting the data you want to remove.","Q_Score":1,"Tags":"python,django,session,cookies","A_Id":12343112,"CreationDate":"2012-09-09T20:45:00.000","Title":"Delete pieces of Session on browser close","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have that issue with python interpreter - it's closing immediately after script execution. I'm trying to learn pygtk; I wrote \"hello world\" after tutorial and all I can see is a quick flash of two windows, one interpreter's and one gtk's. I tried to run the script from command.com instead of by double-click - didn't help much.\nIn older Windows I'd simply check the checkbox on apropriate tab, but how do I do it on this frelling eye candy?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1943,"Q_Id":12344187,"Users Score":0,"Answer":"I suggest that you run your code in some sort of editor (pretty much any will do: Eclipse, Geany, Spyder, IDLE, etc.). The reason for this is that when the program is executed, you are most likely getting a fatal error in your code somewhere. Python IDEs have a tendency to keep the windows used to execute the code open even if there is an error, so you can see the error callback for reference. That will tell you where you are getting the error, and will allow you to fix the code accordingly. of course, you could always just tack on input() or time.sleep() to the end and hope that helps, but that's up to you. I recommend using an IDE like one I mentioned above.","Q_Score":0,"Tags":"python,windows-7","A_Id":12344713,"CreationDate":"2012-09-10T00:44:00.000","Title":"How to stop python interpreter from closing on Windows 7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in visual  studio all you had to do was type the first parenthesis and it showed you the parameters required.\nIt's not doing that in python \/ wingware, what is the best \/ easiest way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":468,"Q_Id":12344481,"Users Score":0,"Answer":"Python is a \"dynamically-typed\" programming language, that meaning that the odds are against the IDE in providing code-intelligence. \nThat said, Wing-IDE is the very best for Python, and there are a few things you can do: first be sure to have open the \"Source Assistant\" panel, i.e., press F2 and locate it to your right. Second, be sure to inform the IDE of what Python interpreter are you using, as well as any particular Python path that your project might be using; all of that you can do in Project\/Project Properties. Finally, you still might need to give hints sometimes to the IDE about your instances with \"assert isinstance(x,SomeType)\". \nAdmittedly, is not as straightforward as using Visual Studio, but the good reasons to use Python and its very capable ecosystem, or the easy integration with C\/C++ more than compensate.","Q_Score":0,"Tags":"python","A_Id":12344677,"CreationDate":"2012-09-10T01:42:00.000","Title":"how do i know what parameters a python function takes with wingware IDE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not able to do this\n\nptags.py *.py\n\nor\n\npython *.py\n\ni'm getting an error saying \"Cannot open file named *.py\"\nbut i'm able to open all the python files in vim using this command\n\nvim *.py\n\npython 2.7 in windows 7 command prompt","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1629,"Q_Id":12348291,"Users Score":1,"Answer":"You cannot using standard Windows cmd shell. You can use something like bash from Cygwin, maybe PowerShell.\nIf you want to open *.py from application like vim but in Python, then you can use glob module.","Q_Score":0,"Tags":"python,windows-7,command-line,tags,command-line-arguments","A_Id":12348372,"CreationDate":"2012-09-10T08:56:00.000","Title":"how do i pass multiple files as arguments in command line for python using regular expressions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a Python program which performs a set of operations and prints the response on STDOUT. Now I am writing a GUI which will call that already existing code and I want to print the same contents in the GUI instead of STDOUT. I will be using the Text widget for this purpose. I do not want to modify my existing code which does the task (This code is used by some other programs as well).\nCan someone please point me to how I can use this existing task definition and use its STDOUT result and insert it into a text widget? In the main GUI program I want to call this task definition and print its results to STDOUT. Is there a way to use this information?","AnswerCount":5,"Available Count":1,"Score":-0.0798297691,"is_accepted":false,"ViewCount":23774,"Q_Id":12351786,"Users Score":-2,"Answer":"The function which normally prints to stdout should instead put the text into text widget.","Q_Score":18,"Tags":"python,tkinter","A_Id":12351926,"CreationDate":"2012-09-10T12:30:00.000","Title":"How to redirect print statements to Tkinter text widget","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking to expand my recommender system to include other features (dimensions). So far, I'm tracking how a user rates some document, and using that to do the recommendations. I'm interested in adding more features, such as user location, age, gender, and so on.\nSo far, a few mysql tables have been enough to handle this, but i fear it will quickly become messy as i add more features.\nMy question: how can i best represent and persist this kind of multi dimensional data?\nPython specific tips would be helpful.\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":12355416,"Users Score":0,"Answer":"An SQL database should work fine in your case. In fact, you can store all the training examples in just one database, each row representing a particular training set and each column representing a feature. You can add features by adding collumns as and when required. In a relational database, you might come across access errors when querying for your data for various inconsistency reasons. Try using a NoSQL database. I personally user MongoDB and Pymongo on python to store the training examples as dicts in JSON format. (Easier for web apps this way).","Q_Score":1,"Tags":"python,numpy,scipy,data-mining","A_Id":12369285,"CreationDate":"2012-09-10T16:05:00.000","Title":"Multi feature recommender system representation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking to expand my recommender system to include other features (dimensions). So far, I'm tracking how a user rates some document, and using that to do the recommendations. I'm interested in adding more features, such as user location, age, gender, and so on.\nSo far, a few mysql tables have been enough to handle this, but i fear it will quickly become messy as i add more features.\nMy question: how can i best represent and persist this kind of multi dimensional data?\nPython specific tips would be helpful.\nThank you","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":12355416,"Users Score":0,"Answer":"I recommend using tensors, which is multidimensional arrays. You can use any data table or simply text files to store a tensor. Each line or row is a record \/ transaction with different features all listed.","Q_Score":1,"Tags":"python,numpy,scipy,data-mining","A_Id":24491488,"CreationDate":"2012-09-10T16:05:00.000","Title":"Multi feature recommender system representation","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to download emails using imaplib with Python. I have tested the script using my own email account, but I am having trouble doing it for my corporate gmail (I don't know how the corporate gmail works, but I go to gmail.companyname.com to sign in). When I try running the script with imaplib.IMAP4_SSL(\"imap.gmail.companyname.com\", 993), I get an error gaierror name or service not known. Does anybody know how to connect to a my company gmail with imaplib?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":321,"Q_Id":12375113,"Users Score":2,"Answer":"IMAP server is still imap.gmail.com -- try with that?","Q_Score":1,"Tags":"python,gmail,gmail-imap,imaplib","A_Id":12375120,"CreationDate":"2012-09-11T17:43:00.000","Title":"IMAP in Corporate Gmail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to know why doesn't python2.7 drop blocking operations when ctrl+c is pressed, I am unable to kill my threaded application, there are several socket waits, semaphore waits and so on. In python3 ctrl+c dropped every blocking operation and garbage-collected everything, released all the sockets and whatsoever ... Is there (I am convinced there is, I just yet don't know how) a way to acomplish this? Signal handle? Thanks guys","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":12382229,"Users Score":0,"Answer":"I guess you are launching the threads and then the main thread is waiting to join them on termination.\nYou should catch the exception generated by Ctrl-C in the main thread, in order to signal the spawned threads to terminate (changing a flag in each thread, for instance). In this manner, all the children thread will terminate and the main thread will complete the join call, reaching the bottom of your main.","Q_Score":0,"Tags":"python,multithreading,python-2.7,exit,kill","A_Id":12390276,"CreationDate":"2012-09-12T06:19:00.000","Title":"Terminate python application waiting on semaphore","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a small Django application with a view that I want to restrict to certain users. Anyone from a specific network should be able to see that view without any further authentication, based on IP address alone. Anyone else from outside this IP range should be asked for a password and authenticated against the default Django user management.\nI assume I have to write a custom authentication backend for that, but the documentation confuses me as the authenticate() function seems to expect a username\/password combination or a token. It is not clear to me how to authenticate using IP addresses here.\nWhat would be the proper way to implement IP address-based authentication in Django? I'd prefer to use as much existing library functions as possible for security-related code instead of writing all of it myself.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":16527,"Q_Id":12383540,"Users Score":3,"Answer":"There's no need to write an authentication backend for the use case you have written. Writing an IP based dispatcher in the middleware layer will likely be sufficient\nIf your app's url(s) is\/are matched, process_request should check for an authenticated django user and match that user to a whitelist.","Q_Score":18,"Tags":"python,django,authentication","A_Id":12383605,"CreationDate":"2012-09-12T07:53:00.000","Title":"Authenticate by IP address in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I set in Tornado a secure cookie that expires when the browser is closed?\nIf I use set_cookie I can do this without passing extra arguments (I just set the cookie), but how if I have to use set_secure_cookie? \nI tried almost everything:\n\npassing nothing: expiration is set to its default value, that is 1 month  \npassing an integer value: the value is considered as day, i.e. 1 means 1 day  \npassing a float value: it works, for example setting 0.1 it means almost one hour and a half","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4626,"Q_Id":12383697,"Users Score":11,"Answer":"It seems to me that you are really on the right track. You try lower and lower values, and the cookie has a lower and lower expiration time.\nPass expires_days=None to make it a session cookie (which expires when the browser is closed).","Q_Score":7,"Tags":"python,cookies,tornado","A_Id":12385159,"CreationDate":"2012-09-12T08:04:00.000","Title":"Tornado secure cookie expiration (aka secure session cookie)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, I have object user stored in database (Redis)\nIt has several fields: \n\nString nick\nString password\nString email\nList posts\nList comments\nSet followers\nand so on...\n\nIn Python programm I have class (User) with same fields for this object. Instances of this class maps to object in database. The question is how to get data from DB for best performance:\n\nLoad values for each field on instance creating and initialize fields with it.\nLoad field value each time on field value requesting.\nAs second one but after value load replace field property by loaded value.\n\np.s. redis runs in localhost","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":96,"Q_Id":12394528,"Users Score":2,"Answer":"The method entirely depends on the requirements.\nIf there is only one client reading and modifying the properties, this is a rather simple problem. When modifying data, just change the instance attributes in your current Python program and -- at the same time -- keep the DB in sync while keeping your program responsive. To that end, you should outsource blocking calls to another thread or make use of greenlets. If there is only one client, there definitely is no need to fetch a property from the DB on each value lookup.\nIf there are multiple clients reading the data and only one client modifying the data, you have to think about which level of synchronization you need. If you need 100 % synchronization, you will have to fetch data from the DB on each value lookup.\nIf there are multiple clients changing the data in the database you better look into a rock-solid industry standard solution rather than writing your own DB cache\/mapper.\nYour distinction between (2) and (3) does not really make sense. If you fetch data on every lookup, there is no need to 'store' data. You see, if there can be multiple clients involved these things quickly become quite complex and it's really hard to get it right.","Q_Score":0,"Tags":"python,database,python-3.x,redis","A_Id":12394712,"CreationDate":"2012-09-12T18:54:00.000","Title":"Which one data load method is the best for perfomance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to python, and I find that to see the import search paths, you have to import the sys module and than access the list of paths using sys.path, if this list is not available until I explicitly import the sys module, so how the interpreter figure out where this module resides.\nthanks for any explanation.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1511,"Q_Id":12414570,"Users Score":3,"Answer":"The module search path always exists, even before you import the sys module. The sys module just makes it available for you.\nIt reflects the contents of the system variable $PYTHONPATH, or a system default, if you have not set that environment variable.","Q_Score":1,"Tags":"python,search-path","A_Id":12414602,"CreationDate":"2012-09-13T20:49:00.000","Title":"how the python interpreter find the modules path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to deploy a heavily JS based project to a embedded device. Its disk size is no more than 16Mb. The problem is the size of my minified js file all-classes.js is about 3Mb.  If I compress it using gzip I get a 560k file which saves about 2.4M. Now I want to store all-classes.js as all-classes.js.gz so I can save space and it can be uncompressed by browser very well. All I have to do is handle the headers. \nNow the question is how do I include the .gz file so browser understands and decompresses? Well i am aware that a .gz file contains file structure information while browser accepts only raw gzipped data. In that I would like to store the raw gzipped data. It'd some sort of caching!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":332,"Q_Id":12418822,"Users Score":0,"Answer":"What you need to do, when the \"all-classes.js\" file is requested, is to return the content of \"all-classes.js.gzip\" with the additional \"Content-Encoding: gzip\" HTTP header.\nBut it's only possible if the request contained the \"Accept-Encoding: gzip\" HTTP header in the first place...","Q_Score":3,"Tags":"javascript,python,extjs,embedded","A_Id":12436279,"CreationDate":"2012-09-14T05:50:00.000","Title":"Use compressed JavaScript file (not run time compression)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a difference in python programming while using just python and while using pypy compiler? I wanted to try using pypy so that my program execution time becomes faster. Does all the syntax that work in python works in pypy too? If there is no difference, can you tell me how can i install pypy on debian lunux and some usage examples on pypy? Google does not contain much info on pypy other than its description.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7679,"Q_Id":12431847,"Users Score":2,"Answer":"pypy is a compliant alternative implementation of the python language. This means that there are few (intentional) differences. One of the few differences is pypy does not use reference counting. This means, for instance, you have to manually close your files, they will not be automatically closed when your file variable goes out of scope as in CPython.","Q_Score":8,"Tags":"python,python-3.x,python-2.7,pypy","A_Id":12432095,"CreationDate":"2012-09-14T20:55:00.000","Title":"Usage of pypy compiler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For my database project, I am using SQL Alchemy. I have a unit test that adds the object to the table, finds it, updates it, and deletes it. After it goes through that, I assumed I would call the session.rollback method in order to revert the database changes. It does not work because my sequences are not reverted. My plan for the project is to have one database, I do not want to create a test database.\nI could not find in the documentation on SQL Alchemy on how to properly rollback the database changes. Does anyone know how to rollback the database transaction?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3017,"Q_Id":12440044,"Users Score":-3,"Answer":"Postgres does not rollback advances in a sequence even if the sequence is used in a transaction which is rolled back.  (To see why, consider what should happen if, before one transaction is rolled back, another using the same sequence is committed.)\nBut in any case, an in-memory database (SQLite makes this easy) is the best choice for unit tests.","Q_Score":4,"Tags":"python,unit-testing,sqlalchemy,rollback","A_Id":12443800,"CreationDate":"2012-09-15T18:39:00.000","Title":"How to rollback the database in SQL Alchemy?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have decided to develop a Auto Text Summarization Tool using Python\/Django. \nCan someone please recommend books or articles on how to get started? \nIs there any open source algorithm or made project in the Auto Text Summarization so that I can gain the idea? \nAlso, would you like to suggest me the new challenging FYP for me in Django\/Python?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1797,"Q_Id":12444496,"Users Score":0,"Answer":"About papers, I would like to add to the previous answer next ones:\n\n\"Text Data Management and Analysis\" by ChengXiang Zhai and Sean Massung, chapter 16.\n\"Texts in Computer Science: Fundamentals of Predictive Text Mining\" by Sholom M. Weiss, \nNitin Indurkhya and Tong Zhang (second edition), chapter 9.","Q_Score":2,"Tags":"python,django,nlp,summarization","A_Id":55256456,"CreationDate":"2012-09-16T04:55:00.000","Title":"Auto Text Summarization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have decided to develop a Auto Text Summarization Tool using Python\/Django. \nCan someone please recommend books or articles on how to get started? \nIs there any open source algorithm or made project in the Auto Text Summarization so that I can gain the idea? \nAlso, would you like to suggest me the new challenging FYP for me in Django\/Python?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1797,"Q_Id":12444496,"Users Score":2,"Answer":"First off for Paper, I recommend:\n1- Recent automatic text summarization techniques: a survey by M.Gambhir and V.Gupta\n2- A Survey of Text Summarization Techniques, A.Nenkova  \nAs for tools for Python, I suggest taking a look at these tools:\n\nThe Conqueror: NLTK  \nThe Prince: TextBlob\nThe Mercenary: Stanford CoreNLP\nThe Usurper: spaCy\nThe Admiral: gensim\nFirst off learn about different kinds of summarizations and what suits you best. Also, remember to make sure you have a proper preprocessing tool for the language you are targeting as this is very important for the quality of your summarizer.","Q_Score":2,"Tags":"python,django,nlp,summarization","A_Id":43989780,"CreationDate":"2012-09-16T04:55:00.000","Title":"Auto Text Summarization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have seen the documentation of pyspeech and dragonfly, but don't know how to input an audio file to be converted into text. I have tried it with microphone via speaking to it and the speech is converted into text, but If I want to input a previously recorded audio file. Can anyone help with an example?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1965,"Q_Id":12455069,"Users Score":0,"Answer":"Both PySpeech and Dragonfly are relatively thin wrappers over SAPI.  Unfortunately, both of them use the shared recognizer, which doesn't support input selection.  While I'm familiar with SAPI, I'm not that familiar with Python, so I haven't been able to assist anyone with moving PySpeech\/Dragonfly over to an in-process recognizer.","Q_Score":3,"Tags":"python,speech-recognition","A_Id":18925412,"CreationDate":"2012-09-17T07:49:00.000","Title":"How to input and process audio files to convert to text via pyspeech or dragonfly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have data that needs to stay in the exact sequence it is entered in (genome sequencing) and I want to search approximately one billion nodes of around 18 members each to locate patterns.\nObviously speed is an issue with this large of a data set, and I actually don't have any data that I can currently use as a discrete key, since the basis of the search is to locate and isolate (but not remove) duplicates.\nI'm looking for an algorithm that can go through the data in a relatively short amount of time to locate these patterns and similarities, and I can work out the regex expressions for comparison, but I'm not sure how to get a faster search than O(n).\nAny help would be appreciated.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":386,"Q_Id":12470094,"Users Score":0,"Answer":"probably what you want is called \"de novo assembly\"\nan approach would be to calculate N-mers, and use these in an index\nnmers will become more important if you need partial matches \/ mismatches\nif billion := 1E9, python might be too weak\nalso note that 18 bases* 2 bits := 36 bits of information to enumerate them. That is tentavely close to 32 bits and could fit into 64 bits. hashing \/ bitfiddling might be an option","Q_Score":1,"Tags":"python,sql,dna-sequence,genome","A_Id":12474645,"CreationDate":"2012-09-18T03:43:00.000","Title":"Fast algorithm comparing unsorted data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a game I am working on I would like to implement a scrolling starfield. All the game so far is being drawn from OpenGL primitives and I would like to continue this and gl_points seems appropriate.\nI am using pyglet (python) and know I could achieve this storing the positions of a whole bunch or points updating them and moving them manually but I was hoping there was a neater alternative.\nEDIT:\nIn answer to Ian Mallett\nI guess what I am trying to ask is if I generate a bunch of points, is there some way I can blit these onto some kind of surface or buffer and scroll this in the background.\nAlso as for what kind of star-field all I am trying to generate at this stage all I am trying for a simple single layer for a top down game, pretty much how you would have in asteroids","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1710,"Q_Id":12470417,"Users Score":1,"Answer":"Can you clarify what sort of starfield?  2D scrolling (for a side or top scrolling game, maybe with different layers) or 3D (like really flying through a starfield in an impossibly fast spaceship)?\nIn the former, a texture (or layers of textures blended additively) is probably the cleanest and fastest approach.  [EDIT: Textures are by far the best approach, but if you really don't want to use textures, you can do the following, which is the next best thing:\n\nMake a static VBO or display list of points that is maybe six times as large as it needs to be in the direction of scroll (e.g. if you're running 800x600 screen and you're scrolling horizontally, generate points on a 4800x600 grid).\nDraw these points twice, offset by the width and the scrolling variable.  E.g., let x be your scrolling variable (it starts at 0, then is incremented until it reaches 4800 (the width of your points), and then wraps back around and restarts at 0).  Each frame, draw your points with a glTranslatef(x,0,0).  Then draw them again with a glTranslatef(x+4800,0,0).\nIn this way your points will scroll past seemingly continuously.  The constant (I chose six, above) doesn't really matter to the algorithm.  Larger values will have fewer repeats but slower performance.\nYou can also try doing all of the above several times with different scrolling constants to give the illusion of depth (with multiple layers).\n\n]\nIn the latter, there are a bunch of clever algorithms I can think of, but I'd suggest just using the raw points (point sprites if you're feeling fancy); GPUs can handle this if you put them in a static VBO or display list.  If your points are small, you can probably throw a few thousand up at a time without any noticeable performance hit.","Q_Score":2,"Tags":"python,opengl,pyglet","A_Id":12471143,"CreationDate":"2012-09-18T04:33:00.000","Title":"Scrolling starfield with gl_points in pyglet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"can anyone tell me that how can i install osqa on windows 7 with xampp localhost ? i don't know xampp support python.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":12472432,"Users Score":1,"Answer":"If you're flexible about xampp, try bitnami native installer:\nhttp:\/\/bitnami.org\/stack\/osqa\nIt took me about 10min for the installer to run, then I had running on Win7 localhost.","Q_Score":0,"Tags":"python,xampp,osqa","A_Id":13022630,"CreationDate":"2012-09-18T07:38:00.000","Title":"install OSQA using xampp on windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using django to create a web based app. This app will be used as a service by multiple clients. \nIt has several models \/ tables that represent a hierarchical relationship. Users are given access based on this hierarchical relationship - ex County -> Schools -> Divisions -> Classrooms. \nSo a user having access to a division has access to all classrooms within it etc\nMy question is how do I make this permissions system configurable across clients. The application should a new client to define arbitrary levels - ex country -> state -> city -> schools -> class. \nAny ideas on what are good approaches ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":167,"Q_Id":12479206,"Users Score":1,"Answer":"What about storing the new levels in a prefix tree? you could use each level as a node of a branch of the tree. \nWhen a new user wants do define a new level, the prefix tree will be updated starting from the level where the user belongs. If your problem is just about giving visibility to the user of the sub-branch of the level where he belongs, this should work.\nA similar approach, maybe less intuitive, is to give to each level a number (or alpha-numeric value), so that in the end a user associated to the level \"state\" in your example, has a level code of 23 (let's say: \"ex-country\": 2 and \"state\": 3), so that he can add sub-levels starting with the prefix 23.","Q_Score":0,"Tags":"python,django","A_Id":12480077,"CreationDate":"2012-09-18T14:35:00.000","Title":"creating a configurable permissions system in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like some thoughts on how to write a regular expression which validates a pattern\nex. .??2 \none of more characters followed by two question marks followed by one or more numbers and if only if there is another repeating pattern then the seperator will be a semi colon.\nmore examples\n--??9;.??50;,??3 - in this example I have the pattern repeating and that is why the semi colon\nor\n*??5 - a * followed by two qnestions marks followed by a number and no semi colon as there are no repeating groups\nThis is what i currently have\n.+\\?\\?\\d+(;|)+","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3006,"Q_Id":12487415,"Users Score":1,"Answer":"The basic pattern is .+?\\?\\?\\d+. We have made the first .+ non-greedy so it won't try to match the whole string right away. Use a repeated group to capture the subsequent patterns: r'(.+?\\?\\?\\d+)(;.+?\\?\\?\\d+)*'","Q_Score":1,"Tags":"python,regex","A_Id":12487430,"CreationDate":"2012-09-19T01:33:00.000","Title":"python regular expression repeating pattern match","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to write for myself a simple map generator and I do not know how to bite. field will have to draw lots hexagonal.\nWhen I generate random tile I must watch for neighbor. Then I have to take into account the already two neighbors, etc. Recursion? I determined that the field may be the water, the earth, the mountains - but in one field may be the transition from water to land with one of the sides.\nAn array will consist of a number specifying the type of tile. \nI want to do it in python - for learning.\nSome advice please.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":296,"Q_Id":12492337,"Users Score":0,"Answer":"There is probably no need to use recursion. Since you do this as a learning exercise, I will only provide you with an outline of how to progress.\nThe hexagonal grid will need a coordinate system, for the rows and columns.\nCreate a function neighbours that, given the coordinates x,y of a tile returns all the neighbours of that tile.\nLoop through the all the tiles using your coordinate system. For each tile, retrieve its neighbours. If a neighbour does not have a type you can ignore it, otherwise, determine the character of a tile based on the character of its neighbours.","Q_Score":0,"Tags":"python","A_Id":12492718,"CreationDate":"2012-09-19T09:50:00.000","Title":"How to write own map generator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to write for myself a simple map generator and I do not know how to bite. field will have to draw lots hexagonal.\nWhen I generate random tile I must watch for neighbor. Then I have to take into account the already two neighbors, etc. Recursion? I determined that the field may be the water, the earth, the mountains - but in one field may be the transition from water to land with one of the sides.\nAn array will consist of a number specifying the type of tile. \nI want to do it in python - for learning.\nSome advice please.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":296,"Q_Id":12492337,"Users Score":0,"Answer":"I think the most important thing is to denote your hexagons on the map in a way which makes checking neighbours easy...\nOne sensible choice could be to use 2D tuples, so that the hexagon (1,1)'s 6 neighbours are (1,0),(2,0),(2,2),(1,2),(0,2) and (1,1) - starting from north\/up and going clockwise.\nTo populate the map you could then just iterate over all squares picking a random choice from the set of allowable tiles (based on it's current neighbours).","Q_Score":0,"Tags":"python","A_Id":12492724,"CreationDate":"2012-09-19T09:50:00.000","Title":"How to write own map generator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django 1.4.\nThere are two servers (app server and file server).\nThe app server provide a web service using django, wsgi, and apache.\nUser can upload files via the web service.\nI'd like to upload directly these files to the file server.\n\"directly\" means that the files aren't uploaded via the app server.\nI'd like to make the file server simple as possible. The file server just serve files.\nIdeally, transfer costs between the app server and the file server are zero.\n\nCould somebody tell me how to do this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1077,"Q_Id":12500623,"Users Score":1,"Answer":"You can't actually do both of these at once:\n\nI'd like to upload directly these files to the file server.\nI'd like to make the file server simple as possible. The file server just serve files.\n\nUnder your requirements, the file server needs to both Serves Files and Accepts Uploads of files.\nThere are a few ways to get the files onto the FileServer\n\nthe easiest way, is just to upload to the AppServer and then have that upload to another server.  this is what most AmazonS3 implementations are like.\nif the two machines are on the same LAN , you can mount a volume of the FileServer onto the AppServer using NFS or something similar.  Users upload to the AppServer, but the data is saved to a partition that is really on the FileServer.  \nYou could have a file upload script work on the FileServer.  However, you'd need to do a few complex things:\n\nhave a mechanism to authenticate the ability to upload the file.  you couldn't just use an authtkt, you'd need to have something that allows one-and-only-one file upload along with some sort of identifier and privilege token.  i'd probably opt for an encrypted payload that is timestamped and has the upload permission credentials + an id for the file.\nhave a callback on successful upload from the FileServer to the AppServer, letting it know that the id in the payload has been successfully received.","Q_Score":2,"Tags":"python,django,file-upload,django-file-upload","A_Id":12623702,"CreationDate":"2012-09-19T18:22:00.000","Title":"Django: How to upload directly files submitted by a user to another server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two dictionaries as follows:\nD1={'a':1,'b':2,'c':3}\nand \nD2={'b':2,'c':3,'d':1}\nI want to merge these two dictionaries and the result should be as follows:\nD3={'a':1,'b':2,'c':3,'b':2,'c':3,'d':1}\nhow can I achieve this in python?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":3838,"Q_Id":12511801,"Users Score":2,"Answer":"What are you asking is not possible, since you cannot have two different keys with the same value in a Python dictionary.\nThe closest answer to your question is:\nD3 = dict( D1.items() + D2.items() )\nNote: if you have different values for the same key, the ones from D2 will be the ones in D3. \nExample:\nD1 = { 'a':1, 'b'=2 }\nD2 = { 'c':3, 'b':3}\nThen, D3 will be:\nD3= { 'a':1, 'b':3, 'c':3 }","Q_Score":19,"Tags":"python","A_Id":12511861,"CreationDate":"2012-09-20T11:37:00.000","Title":"Merging of two dictionaries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a python3 program that generates a text file that is post-procesed with asciidoc for the final report in html and pdf.\nThe python program generates thousands files with graphics to be included in the final report. The filenames for the files are generated with tempfile.NamedTemporaryFile\nThe problem it that the character set used by tempfile is defined as:\ncharacters = \"abcdefghijklmnopqrstuvwxyz0123456789_\"\nthen I end with some files with names like \"_6456_\" and asciidoc interprets the \"_\" as formatting and inserts some html that breaks the report.\nI need to either find a way to \"escape\" the filenames in asciidoc or control the characters in the temporary file.\nMy current solution is to rename the temporary file after I close it to replace the \"_\" with some other character (not in the list of characters used by tempfile to avoid a collision) but i have the feeling that there is a better way to do it.\nI will appreciate any ideas. I'm not very proficient with python yet, i think overloading _RandomNameSequence in tempfile will work, but i'm not sure how to do it.\nregards.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":491,"Q_Id":12522844,"Users Score":0,"Answer":"Maybe you could create a temporary directory using tempfile.tempdir and generate the filenames manually such as file1, file2, ..., filen . This way you easily avoid \"_\" characters and you can just delete the temporary directory after you are finished with that.","Q_Score":3,"Tags":"python-3.x","A_Id":12522892,"CreationDate":"2012-09-21T00:38:00.000","Title":"change character set for tempfile.NamedTemporaryFile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing an application to simulate train sounds. I got very short (0.2s) audio samples for every speed of the train and I need to be able to loop up to 20 of them (one for every train) without gaps at the same time.\nGapless changing of audio samples (train speed) is also a Must-Have.\nI've been searching for possible python-audio-solutions, including\n\nPyAudio\nPyMedia\npyaudiere\n\nbut I'm not sure which one suits best my use-case, so I do really appreciate any propositions and experiences!\nPS: I did already try out gstreamer but since the 1.0 release is not there yet and I cant figure out how to get gapless playback to work with pygi, i thought there might be a better choice. I also tried pygame, but it seems like it's limited to 8 audio channels??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1335,"Q_Id":12532631,"Users Score":0,"Answer":"I am using PyAudio for a lot of things and are quite happy with it. If it can do this, I do not know, but I think it can. \nOne solution is to feed sound buffer manually and control \/ set the needed latency. I have done this and it works quite well. If you have the latency high enough it will work. \nAn other solution, similar to this, is to manage the latency your self. You can queue up and or mix your small sound files manually to e.g. sizes of 0.5 -1 sec. This will greatly reduce the requirement to the \"realtimeness\" and alow you to do some pretty cool transitions between \"speeds\" \nI do not know what sort of latency you can cope with, but if we are talking about train speeds, I guess they do not change instantaneous - hence latency of 500ms to several seconds is most likely acceptable.","Q_Score":4,"Tags":"python,audio,loops,playback","A_Id":31437197,"CreationDate":"2012-09-21T14:34:00.000","Title":"Python Audio library for fast, gapless looping of many short audio tracks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a Python beginner and my main language is C++. You know in C++, it is very common to separate the definition and implementation of a class. (How) Does Python do that? If not, how to I get a clean profile of the interfaces of a class?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3065,"Q_Id":12542111,"Users Score":1,"Answer":"For some reason, many Python programmers combine the class and its implementation in the same file; I like to separate them, unless it is absolutely necessary to do so. \n\u00a0\u00a0\u00a0 That's easy. Just create the implementation file, import the module in which the class is defined, and you can call it directly. \n\u00a0\u00a0\u00a0 So, if the class - ShowMeTheMoney - is defined inside class1_file.py, and the file structure is: \n\n  \n\/project\n    \/classes\n           \/__init__.py\n           \/class1_file.py\n           \/class2_file.py\n    \/class1_imp_.py   \n  \n\n(BTW, the file and class names must be different; the program will fail if the class and the file names are the same.) \n\u00a0\u00a0\u00a0 You can implement it in the class1_imp_.py using:\n\n \n   # class1_imp_.py\n   import classes.class1_file as any_name\n\n   class1_obj = any_name.ShowMeTheMoney()\n   #continue the remaining processes\n\n\n \n\nHope this helps.","Q_Score":7,"Tags":"python","A_Id":12543014,"CreationDate":"2012-09-22T08:22:00.000","Title":"Separating class definition and implementation in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am thinking to design my own web app to serve static files. I just don't want to use Amazon services..\nSo, can anyone tell me how to start the project? I am thinking to develop in Python - Django on Openshift (Redhat's). \nThis is how ideas are going through in my mind:\n\nA dashboard helps me to add\/ delete\/ manage static files\nTo setup API kind of thing (end point: JSON objects) so that I can use this project to serve my web apps!\nAs openshift uses Apache!, I am thinking to dynamically edit htaccess and serve the files.. but not sure whether it would be possible or not\n\nOr, I can use django's urls.py to serve the files but I don't think djano is actually made for.\nAny ideas and suggestion?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":402,"Q_Id":12545418,"Users Score":3,"Answer":"How about this:\n\nUse nginx to serve static files\nKeep the files in some kind of predefined directory structure, build a django app as the dashbord with the filesystem as the backend. That is, moving, adding or deleting files from the dashboard changed them the filesystem and nginx doesn't have to be aware of this dashboard.\nDo not use dynamic routing. Just layout and maintain the proper directory structure using the databoard.\n\nOptionally, keep the directory structure and file metadata in some database server for faster searches and manipulation.\nThis should result in a very low overhead static file server.","Q_Score":0,"Tags":"python,django,apache,webserver,openshift","A_Id":12546511,"CreationDate":"2012-09-22T16:07:00.000","Title":"A web application to serve static files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am provided with text files containing data that I need to load into a postgres database.\nThe files are structured in records (one per line) with fields separated by a tilde (~). Unfortunately it happens that every now and then a field content will include a tilde.\nAs the files are not tidy CSV, and the tilde's not escaped, this results in records containing too many fields, which cause the database to throw an exception and stop loading.\nI know what the record should look like (text, integer, float fields).\nDoes anyone have suggestions on how to fix the overlong records? I code in per but I am happy with suggestions in python, javascript, plain english.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":111,"Q_Id":12553197,"Users Score":0,"Answer":"If you know what each field is supposed to be, perhaps you could write a regular expression which would match that field type only (ignoring tildes) and capture the match, then replace the original string in the file?","Q_Score":1,"Tags":"python,perl,language-agnostic","A_Id":12553211,"CreationDate":"2012-09-23T14:36:00.000","Title":"Messed up records - separator inside field content","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Suppose I have both Python 2 and Python 3 installed. \nIn WingIDE 101, how do I choose whether I am using Python 2 or Python 3? \nFor example, I was currently working with python 3 and now I need to use the image module which is only supported in python 2. How do I change it? \nThanks.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":609,"Q_Id":12569076,"Users Score":5,"Answer":"there is a python icon on the interface .click and change","Q_Score":2,"Tags":"python","A_Id":14501078,"CreationDate":"2012-09-24T16:24:00.000","Title":"WingIDE -- Python 2 and Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running a website on google app engine written in python with jinja2.  I have gotten memcached to work for most of my content from the database and I am fuzzy on how I can increase the efficiency of images served from the blobstore.  I don't think it will be much different on GAE than any other framework but I wanted to mention it just in case.\nAnyway are there any recommended methods for caching images or preventing them from eating up my read and write quotas?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":717,"Q_Id":12573915,"Users Score":1,"Answer":"Blobstore is fine.\nJust make sure you set the HTTP cache headers in your url handler.  This allows your files to be either cached by the browser (in which case you pay nothing) or App Engine's Edge Cache, where you'll pay for bandwidth but not blobstore accesses.\nBe very careful with edge caching though.  If you set an overly long expiry, users will never see an updated version.  Often the solution to this is to change the url when you change the version.","Q_Score":0,"Tags":"python,google-app-engine,caching,distributed-caching,image-caching","A_Id":12585067,"CreationDate":"2012-09-24T22:40:00.000","Title":"Options for Image Caching","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If a function takes as an input the name of a text file, I can refactor it to instead take a file object (I call it \"stream\"; is there a better word?). The advantages are obvious - a function that takes a stream as an argument is:\n\nmuch easier to write a unit test for, since I don't need to create a temporary file just for the test\nmore flexible, since I can use it in situations where I somehow already have the contents of the file in a variable\n\nAre there any disadvantages to streams? Or should I always refactor a function from a file name argument to a stream argument (assuming, of course, the file is text-only)?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3700,"Q_Id":12576724,"Users Score":4,"Answer":"There are numerous functions in the python standard library which accept both -- strings which are filenames or open file objects (I assume that's what you're referring to as a \"stream\").  It's really not hard to create a decorator that you can use to make your functions accept either one.  \nOne serious drawback to using \"streams\" is that you pass it to your function and then your function reads from it -- effectively changing it's state.  Depending on your program, recovering that state could be messy if it's necessary.  (e.g. you might need to litter you code with f.tell() and then f.seek().)","Q_Score":14,"Tags":"python,unit-testing,python-3.x,arguments,software-design","A_Id":12576771,"CreationDate":"2012-09-25T05:34:00.000","Title":"file name vs file object as a function argument","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Any web server might have to handle a lot of requests at the same time. As python interpreter actually has GIL constraint, how concurrency is implemented?\nDo they use multiple processes and use IPC for state sharing?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2640,"Q_Id":12603678,"Users Score":2,"Answer":"You usually have many workers(i.e. gunicorn), each being dispatched with independent requests. Everything else(concurrency related) is handled by the database so it is abstracted from you.\nYou don't need IPC, you just need a \"single source of truth\", which will be the RDBMS, a cache server(redis, memcached), etc.","Q_Score":16,"Tags":"python,django,concurrency,webserver","A_Id":12604317,"CreationDate":"2012-09-26T14:11:00.000","Title":"How does a python web server overcomes GIL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Any web server might have to handle a lot of requests at the same time. As python interpreter actually has GIL constraint, how concurrency is implemented?\nDo they use multiple processes and use IPC for state sharing?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2640,"Q_Id":12603678,"Users Score":1,"Answer":"As normal. Web serving is mostly I\/O-bound, and the GIL is released during I\/O operations. So either threading is used without any special accommodations, or an event loop (such as Twisted) is used.","Q_Score":16,"Tags":"python,django,concurrency,webserver","A_Id":12603848,"CreationDate":"2012-09-26T14:11:00.000","Title":"How does a python web server overcomes GIL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's what I need to do:\nI need to copy files over the network. The files to be copied is in the one machine and I need to send it to the remote machines. It should be automated and it should be made using python. I am quite familiar with os.popen and subprocess.Popen of python. I could use this to copy the files, BUT, the problem is once I have run the one-liner command (like the one shown below)\n\nscp  xxx@localhost:file1.txt yyy@]192.168.104.XXX:file2.txt\n\nit will definitely ask for something like\n\nAre you sure you want to connect (yes\/no)?\nPassword :\n\nAnd if im not mistaken., once I have sent this command (assuming that I code this in python)\n\nconn.modules.os.popen(\"scp  xxx@localhost:file1.txt yyy@]192.168.104.XXX:file2.txt\")\n\nand followed by this command\n\nconn.modules.os.popen(\"yes\")\n\nThe output (and I'm quite sure that it would give me errors) would be the different comparing it to the output if I manually type it in in the terminal.\nDo you know how to code this in python? Or could you tell me something (a command etc.) that would solve my problem\nNote: I am using RPyC to connect to other remote machines and all machines are running on CentOS","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1825,"Q_Id":12613552,"Users Score":0,"Answer":"per my experience, use sftp the first time will prompt user to accept host public key, such as \nThe authenticity of host 'xxxx' can't be established.\n RSA key  fingerprint is xxxx. Are you sure you want to continue connecting\n (yes\/no)?\n\nonce you input yes, the public key will be saved in ~\/.ssh\/known_hosts, and next time you will not get such prompt\/alert.\nTo avoid this prompt\/alert in batch script, you can use turn strict host check off use \n\nscp -Bqpo StrictHostKeyChecking=no \n\nbut you are vulnerable to  man-in-the-middle attack.\nyou can also choose to connect to target server manually and save host public key before deploy your batch script.","Q_Score":0,"Tags":"python,shell,terminal,centos","A_Id":12613729,"CreationDate":"2012-09-27T03:14:00.000","Title":"How to automate the sending of files over the network using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I recently removed Macports and all its packages and installed Python, Gphoto and some other bits using Homebrew. However python is crashing when looking for libraries as it is looking for them in a MacPorts path. My PATH is correct and the python config show the right path \/usr\/local\/Cellar etc. \nCan someone tell me how to set Python to use the libraries installed via Homebrew, I suppose change the path effectively?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":12623155,"Users Score":3,"Answer":"I wouldn't use the Macports packages in Homebrew. I'd reinstall them all.  A lot of Python packages are compiled , or at least have compiled elements.  You're asking for a lot of potential troubles mixing them up.","Q_Score":1,"Tags":"python,macports,homebrew","A_Id":12623496,"CreationDate":"2012-09-27T13:59:00.000","Title":"Python libraries after removing MacPorts and installing homebrew","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Telit module which runs [Python 1.5.2+] (http:\/\/www.roundsolutions.com\/techdocs\/python\/Easy_Script_Python_r13.pdf)!. There are certain restrictions in the number of variable, module and method names I can use (< 500), the size of each variable (16k) and amount of RAM (~ 1MB). Refer pg 113&114 for details. I would like to know how to get the number of symbols being generated, size in RAM of each variable, memory usage (stack and heap usage). \nI need something similar to a map file that gets generated with gcc after the linking process which shows me each constant \/ variable, symbol, its address and size allocated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":403,"Q_Id":12627401,"Users Score":0,"Answer":"This post makes me recall my pain once with Telit GM862-GPS modules. My code was exactly at the point that the number of variables, strings, etc added up to the limit. Of course, I didn't know this fact by then. I added one innocent line and my program did not work any more.  I drove me really crazy for two days until I look at the datasheet to find this fact.\nWhat you are looking for might not have a good answer because the Python interpreter is not a full fledged version. What I did was to use the same local variable names as many as possible. Also I deleted doc strings for functions (those count too) and replace with #comments.\nIn the end, I want to say that this module is good for small applications. The python interpreter does not support threads or interrupts so your program must be a super loop. When your application gets bigger, each iteration will take longer. Eventually, you might want to switch to a faster platform.","Q_Score":2,"Tags":"python,symbols,decompiling","A_Id":15160831,"CreationDate":"2012-09-27T17:59:00.000","Title":"Counting number of symbols in Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I spent the last 3 hours trying to find out if it possible to disable or to build Python without the interactive mode or how can I get the size of the python executable smaller for linux.  \nAs you can guess it's for an embedded device and after the cross compilation Python is approximately 1MB big and that is too much for me. \nNow the questions:\nAre there possibilities to shrink the Python executable? Maybe to disable the interactive mode (starting Python programms on the command line). \nI looked for the configure options and tried some of them but it doesn't produce any change  for my executable. \nI compile it with optimized options from gcc and it's already stripped.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":8769,"Q_Id":12631577,"Users Score":3,"Answer":"There may be ways you can cram it down a little more just by configuring, but not much more.\nAlso, the actual interactive-mode code is pretty trivial, so I doubt you're going to save much there.\nI'm sure there are more substantial features you're not using that you could hack out of the interpreter to get the size down. For example, you can probably throw out a big chunk of the parser and compiler and just deal with nothing but bytecode. The problem is that the only way to do that is to hack the interpreter source. (And it's not the most beautiful code in the world, so you're going to have to dedicate a good amount of time to learning your way around.) And you'll have to know what features you can actually hack out.\nThe only other real alternative would be to write a smaller interpreter for a Python-like language\u2014e.g., by picking up the tinypy project. But from your comments, it doesn't sound as if \"Python-like\" is sufficient for you unless it's very close.\nWell, I suppose there's one more alternative: Hack up a different, nicer Python implementation than CPython. The problem is that Jython and IronPython aren't native code (although maybe you can use a JVM->native compiler, or possibly cram enough of Jython into a J2ME JVM?), and PyPy really isn't ready for prime time on embedded systems. (Can you wait a couple years?) So, you're probably stuck with CPython.","Q_Score":17,"Tags":"python,embedded","A_Id":12632227,"CreationDate":"2012-09-27T23:32:00.000","Title":"Optimizing the size of embedded Python interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a django project and i'm using dynatree to build treeview. \nI have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to \"unselect\" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":908,"Q_Id":12636812,"Users Score":0,"Answer":"There is a difference between 'selected' and 'active'.\nSelection is typically done using checkboxes, while only one node can be activated (typically by a mouse click).\nA 2nd click on an active node will not fire an 'onActivate' event, but you can implement the 'onClick' handler to catch this and call node.deactivate()","Q_Score":1,"Tags":"python,django,dynatree","A_Id":12659689,"CreationDate":"2012-09-28T09:00:00.000","Title":"Moving nodes from one tree to another with Dynatree","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a django project and i'm using dynatree to build treeview. \nI have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to \"unselect\" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":908,"Q_Id":12636812,"Users Score":1,"Answer":"I have a dynamTree on a DIV dvAllLetterTemplates (which contains a master List) and a DIV dvUserLetterTemplates to which items are to be copied.\n\n\/\/Select the Parent Node of the Destination Tree\nvar catNode = $(\"#dvUserLetterTemplates\").dynatree(\"getTree\").selectKey(catKey, false);\nif (catNode != null) {\n\/\/Select the source node from the Source Tree\n    var tmplNode = $(\"#dvAllLetterTemplates\").dynatree(\"getTree\").selectKey(arrKeys[i], false);\n    if (tmplNode != null) {\n        \/\/Make a copy of the source node\n        var ndCopy = tmplNode.toDict(false, null);\n        \/\/Add it to the parent node\n        catNode.addChild(ndCopy);\n        \/\/Remove the source node from the source tree (to prevent duplicate copies\n        tmplNode.remove();\n        \/\/Refresh both trees\n        $(\"#dvUserLetterTemplates\").dynatree(\"getTree\").redraw();\n        $(\"#dvAllLetterTemplates\").dynatree(\"getTree\").redraw();\n     }\n}","Q_Score":1,"Tags":"python,django,dynatree","A_Id":19162943,"CreationDate":"2012-09-28T09:00:00.000","Title":"Moving nodes from one tree to another with Dynatree","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently working on a django project and i'm using dynatree to build treeview. \nI have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to \"unselect\" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":908,"Q_Id":12636812,"Users Score":2,"Answer":"I've solved my problem using the copy\/paste concept of context menu. \nAnd for the second problem, I used global variable to store the original parent node so when user unselect the item, it will move back to its original parent.","Q_Score":1,"Tags":"python,django,dynatree","A_Id":15516606,"CreationDate":"2012-09-28T09:00:00.000","Title":"Moving nodes from one tree to another with Dynatree","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have never deployed a Django site before. I am currently looking to set it up in my deluxe GoDaddy account. Does anyone have any documentation on how to go about installing python and django on GoDaddy?","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":61875,"Q_Id":12658427,"Users Score":3,"Answer":"I am not familiar with GoDaddy's setup specifically, but in general, you cannot install Django on shared hosting unless it is supported specifically (a la Dreamhost).  So unless GoDaddy specifically mentions Django (or possibly mod_wsgi or something) in their documentation, which is unlikely, you can assume it is not supported.\nTheoretically you can install Python and run Django from anywhere you have shell access and sufficient permissions, but you won't be able to actually serve your Django site as part of your shared hosting (i.e., on port 80 and responding to your selected hostname) because you don't have access to the webserver configuration.\nYou will need either a VPS (GoDaddy offers them but it's not their core business; Linode and Rackspace are other options), or a shared host that specifically supports Django (e.g. Dreamhost), or an application host (Heroku or Google App Engine).  I recommend Heroku personally, especially if you are not confident in setting up and maintaining your own webserver.","Q_Score":32,"Tags":"python,django,installation","A_Id":12659723,"CreationDate":"2012-09-30T03:39:00.000","Title":"Installing a django site on GoDaddy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am designing a Copy\/Paste Application for Windows os using Python.Now I want to a Register my application with hotkey for \"Ctrl+V\" So that when any one press \"Ctrl+V\" Paste is done through my application and not through windows default Copy\/Paste application.But I don't know how to get the list of files path which are to be copied and also the path of Target window where paste is to be done.So I want to know what actually happens when someone presses Ctrl+C key in windows explorer","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":12659719,"Users Score":4,"Answer":"When someone presses the Ctrl+C key in Explorer, Explorer calls OleSetClipboard() with an IDataObject containing various formats, which may include CF_FILES, CFSTR_FILECONTENTS and CFSTR_SHELLIDLIST.","Q_Score":1,"Tags":"python,windows,winapi,python-2.7,pywin32","A_Id":12659846,"CreationDate":"2012-09-30T08:08:00.000","Title":"Windows:What actually happens when Ctrl+C is pressed in windows explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a Pyramid view that's misbehaving in an interesting way. What the view does is grab a pretty complex object hierarchy from a file (using pickle), does a little processing, then renders an html form. Nice and simple.\nSetup:\nI'm running Ubuntu 12.04 64bit, Python3.2, Pyramid 1.3.3, SQLAlchemy 0.7.8 and using the standard waitress server. \nSymptoms\nI was having some efficiency issues so used system monitor to try to see what was up and found that while pyramid is doing its processing and suchlike for the view I described my ram usage rose steadily. As the html form was displayed in my browser the ram usage leveled off but didn't fall. Reloading the view caused the ram usage to grow steadily from where it left off. If I keep doing this all my ram is used up and everything grinds to a halt.\nIf I kill the server then the ram usage drops back down immediately. \nQuestion\nWhat's going on? It's obvious that memory isn't being released between view renderings, but why is this happening? And how can I make it stop? I even tried calling del on stuff before returning from the view and nothing changed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":12660516,"Users Score":2,"Answer":"Pyramid's debug toolbar keeps objects alive. Deactivating it fixes most memory leak problems. The leak that was the cause of my searching for errors in Pyramid doesn't seem to be a problem with Pyramid at all","Q_Score":3,"Tags":"pyramid,pickle,python-3.2","A_Id":12673353,"CreationDate":"2012-09-30T10:24:00.000","Title":"Pyramid app not releasing memory between views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to debug Celery task from the Eclipse debugger.\nI'm using Eclipse, PyDev and Django. \nFirst, I open my project in Eclipse and put a breakpoint at the beginning of the task function. \nThen, I'm starting the Celery workers from Eclipse by Right Clicking on manage.py from the PyDev Package Explorer and choosing \"Debug As->Python Run\" and specifying \"celeryd -l info\" as the argument. This starts MainThread, Mediator and three more threads visible from the Eclipse debugger.  \nAfter that I return back to the PyDev view and start the main application by  Right Click on the project and choosing Run As\/PyDev:Django\nMy issues is that once the task is submitted by the mytask.delay()  it doesn't stop on the breakpoint. I put some traces withing the tasks code so I can see that it was executed in one of the worker threads. \nSo, how to make the Eclipse debugger to stop on the breakpoint placed withing the task when it executed in the Celery workers thread?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":23443,"Q_Id":12698212,"Users Score":1,"Answer":"I create a management command to test task.. find it easier than running it from shell..","Q_Score":29,"Tags":"python,eclipse,celery","A_Id":19998790,"CreationDate":"2012-10-02T20:57:00.000","Title":"How to debug Celery\/Django tasks running locally in Eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do you find all the combinations of a 40 letter string?\nI have to find how many combinations 20 D and 20 R can make.\nas in one combination could be...\nDDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRR\nthats 1 combination, now how do I figure out the rest?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":217,"Q_Id":12699132,"Users Score":1,"Answer":"There are a lot of permutations. It usually isn't a good idea to generate them all just to count them. You should look for a mathematical formula to solve this, or perhaps use dynamic programming to compute the result.","Q_Score":1,"Tags":"python","A_Id":12699266,"CreationDate":"2012-10-02T22:11:00.000","Title":"Finding the different combinations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning how to use open(file, 'r') and was wondering:\nIf I say open(file1, 'r')and then later try to access that same file using open() again, will it work? Because I never did close() on it. And does it close immediately after opening, because it's not assigned to any variable?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":472,"Q_Id":12703241,"Users Score":1,"Answer":"i don't know if i understood you well, but using open() you create object representing file stream. until you keep reference to this object, the file stream is opened. but if you call open() again for the same file, you'll make another object representing file stream. target of stream will be the sames but object's will be different.\ni don't know how if garbage collector works in python the same as in java, but if it does, all the objects that are not pointed by any reference will be deleted from memory. not \"immediately\" but when garbage collector will run, and this is unpredictable. it may be now, and it may be in next few seconds.","Q_Score":1,"Tags":"python,file","A_Id":12703403,"CreationDate":"2012-10-03T06:48:00.000","Title":"Open(file) - Does it stay open?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing up an IRC bot from scratch in Python and it's coming along fine.\nOne thing I can't seem to track down is how to get the bot to send a message to a user that is private (only viewable to them) but within a channel and not a separate PM\/conversation.\nI know that it must be there somewhere but I can't find it in the docs.\nI don't need the full function, just the command keyword to invoke the action from the server (eg PRIVMSG).\nThanks folks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2449,"Q_Id":12707239,"Users Score":2,"Answer":"Are you looking for \/notice ? (see irchelp.org\/irchelp\/misc\/ccosmos.html#Heading227)","Q_Score":0,"Tags":"python,protocols,irc","A_Id":12721513,"CreationDate":"2012-10-03T11:08:00.000","Title":"IRC msg to send to server to send a \"whisper\" message to a user in channel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an app that embeds python scripting.\nI'm adding calls to python from C, and my problem is that i need to suspend the script execution let the app run, and restore the execution from where it was suspended.\nThe idea is that python would call, say \"WaitForData\" function, so at that point the script must suspend (pause) the calls bail out so the app event loop would continue. When the necessary data is present, i would like to restore the execution of the script, it is like the python call returns at that point.\ni'm running single threaded python.\nany ideas how can i do this, or something similar, where i'll have the app event loop run before python call exits?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":12711511,"Users Score":1,"Answer":"Well, the only way I could come up with is to run the Python engine on a separate thread. Then the main thread is blocked when the python thread is running.\nWhen I need to suspend, I block the Python thread, and let the main thread run. When necessary, the OnIdle of the main thread, i block it and let the python continue.\nit seems to be working fine.","Q_Score":1,"Tags":"python,embed","A_Id":12862310,"CreationDate":"2012-10-03T15:14:00.000","Title":"suspend embedded python script execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python and would be grateful if anyone can point me the right direction or better still some examples. \nI am trying to write a program to convert image (jpeg or any image file) into gcode or x\/y coordinate. Instead of scanning x and y direction, I need to follow the contour of objects in the image. For example, a doughnut with outer circle and inner circle, or a face with face outline and inner contour of organs.\nI know there is something called marching square, but not sure how to do it in python? \nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3955,"Q_Id":12737993,"Users Score":0,"Answer":"I would suggest the following procedure:\n1) Convert your image to a binary image (nxn numpy array): 1(object pixels) and 0 (background pixels)\n3) Since you want to follow a contour, you can see this problem as: finding the all the object pixels belonging to the same object. This can be solved by the Connected Components Labeling Object.\n4) Once you have your objects identified, you can run the Marching squares algorithm over each object. MS consist in divide your image in n squares and then evaluating the value of all the vertex for a given square. MS will find the the border by analyzing each square and finding those in which the value of at least one of the vertex of a given square is 0 whereas the other vertex of such square are 1 --> The border\/contour is contained in such square.","Q_Score":3,"Tags":"python,image-processing","A_Id":57430322,"CreationDate":"2012-10-05T00:39:00.000","Title":"Follow image contour using marching square in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've writing a RSA implementation in Python and have now successfully encrypted it however when it prints out the cipher, every time it comes out '0x1L.' I believe this is a long number, however I do not know how to show the full number. If my code is required, I will post in the comments section( It is quite long). \nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":399,"Q_Id":12761517,"Users Score":0,"Answer":"Python's representation of your result as 0x1L indicates the number's type and value - however, it doesn't truncate the number at all. While it is stored as a long internally, its value is still just 1 in this case.","Q_Score":0,"Tags":"python,rsa,hex","A_Id":12761645,"CreationDate":"2012-10-06T16:24:00.000","Title":"Full Hexadecimal Representation in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to come up with a topic-based recommender system to suggest relevant text documents to users.\nI trained a latent semantic indexing model, using gensim, on the wikipedia corpus. This lets me easily transform documents into the LSI topic distributions. My idea now is to represent users the same way. However, of course, users have a history of viewed articles, as well as ratings of articles.\nSo my question is: how to represent the users?\nAn idea I had is the following: represent a user as the aggregation of all the documents viewed. But how to take into account the rating?\nAny ideas?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":602,"Q_Id":12763608,"Users Score":0,"Answer":"\"represent a user as the aggregation of all the documents viewed\" : that might work indeed, given that you are in linear spaces. You can easily add all the documents vectors in one big vector.\nIf you want to add the ratings, you could simply put a coefficient in the sum.\nSay you group all documents rated 2 in a vector D2, rated 3 in D3 etc... you then simply define a user vector as U=c2*D2+c3*D3+...\nYou can play with various forms for c2, c3, but the easiest approach would be to simply multiply by the rating, and divide by the max rating for normalisation reasons. \nIf your max rating is 5, you could define for instance c2=2\/5, c3=3\/5 ...","Q_Score":2,"Tags":"python,machine-learning,recommendation-engine,latent-semantic-indexing,topic-modeling","A_Id":14583682,"CreationDate":"2012-10-06T20:31:00.000","Title":"User profiling for topic-based recommender system","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to come up with a topic-based recommender system to suggest relevant text documents to users.\nI trained a latent semantic indexing model, using gensim, on the wikipedia corpus. This lets me easily transform documents into the LSI topic distributions. My idea now is to represent users the same way. However, of course, users have a history of viewed articles, as well as ratings of articles.\nSo my question is: how to represent the users?\nAn idea I had is the following: represent a user as the aggregation of all the documents viewed. But how to take into account the rating?\nAny ideas?\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":602,"Q_Id":12763608,"Users Score":1,"Answer":"I don't think that's working with lsa. \nBut you maybe could do some sort of k-NN classification, where each user's coordinates are the documents viewed. Each object (=user) sends out radiation (intensity is inversely proportional to the square of the distance). The intensity is calculated from the ratings on the single documents.\nThen you can place a object (user) in in this hyperdimensional space, and see what other users give the most 'light'.\nBut: Can't Apache Lucene do that whole stuff for you?","Q_Score":2,"Tags":"python,machine-learning,recommendation-engine,latent-semantic-indexing,topic-modeling","A_Id":12764041,"CreationDate":"2012-10-06T20:31:00.000","Title":"User profiling for topic-based recommender system","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know how Django's order_by works if the given order_by field's values are same for a set of records. Consider I have a score field in DB and I'm filtering the queryset using order_by('score'). How will records having the same values for score arrange themselves? \nEvery time, they're ordered randomly within the subset of records having equal score and this breaks the pagination at client side. Is there a way to override this and return the records in a consistent order?\nI'm Using Django 1.4 and PostgreSQL.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16934,"Q_Id":12775844,"Users Score":14,"Answer":"order_by can have multiple params, I think order_by('score', '-create_time') will always return the same queryset.","Q_Score":8,"Tags":"python,django,postgresql,sql-order-by","A_Id":12775949,"CreationDate":"2012-10-08T05:34:00.000","Title":"Django - How does order_by work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how do you make a particular file hidden? Or how do you set the file attribute as 'hidden' without using external API's\/modules such as WIN32API, etc.\nSurely there is something in the standard libraries? As the os module does allow to set the \"read\" and 'write' attributes, it is very strange that there is no mention in the os docs of 'hidden'...","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3767,"Q_Id":12789138,"Users Score":2,"Answer":"Not all operating systems have the concept of \"hidden\" for files, and most (even with all the different versions of Windows 7 etc. there are still more forms of *nix out there than Windows) indicate it by having the first character of the filename be a period (.). On the OSes that do support it you must use some external API or tool in order to set it on the file.","Q_Score":2,"Tags":"python,attributes","A_Id":12789190,"CreationDate":"2012-10-08T20:40:00.000","Title":"Hidden file attributes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I heard a lot of people talking about Django on various forums. But I am having a very basic question : What is meant by Framework and why Django is used.\nAfter listening a lot about Django, I ran few chapters for Django (from Djangobook.com). After running these chapters,  I am wondering how Django can be used to create a very simple website. (Website should have few pages like Home, Favorites, About, Contact linked to each other and will be providing static content). \nCan Django be used for creation of such website? I searched a lot on internet but couldn't find any relevant examples, I only encountered with the examples for creation of blog, forum sites etc. If Django can be used for creation of this website, what should be the approach.\nCan someone please explain this basic term \"Framework\" and its significance?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66634,"Q_Id":12797999,"Users Score":48,"Answer":"No. It's not for making websites. Your sample just sounds like you want plain old HTML.\nDjango is for creating web applications. That is, software, normally backed by a database, that includes some kind of interactivity, that operates through a browser.  A Framework provides a structure and common methods for making this kind of software.","Q_Score":64,"Tags":"python,django","A_Id":12798019,"CreationDate":"2012-10-09T10:26:00.000","Title":"For what purpose Django is used for?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using GtkMenuToolButton and it has a button and a menu. When you click on the arrow the menu is opened. I'd like to make the button open that same menu as well. Simply emitting \"show-menu\" in the \"clicked\" callback did not work. Please help how to make this work.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":213,"Q_Id":12818397,"Users Score":1,"Answer":"I have currently ended up doing this:\n\nInstead of GtkMenuToolButton I have GtkToolItem with custom content\nIn custom content I have GtkMenuButton\nInside that one, I delete the default GtkArrow and replace it with 1x2 GtkGrid which has a Label + GtkArrow\n\nAs a whole it does what I want =)","Q_Score":1,"Tags":"python,gtk","A_Id":12827853,"CreationDate":"2012-10-10T11:35:00.000","Title":"How to make GtkMenuToolButton open the same menu when 'clicked' signal is emitted?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've read a paper that uses ngram counts as feature for a classifier, and I was wondering what this exactly means.\nExample text: \"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam\"\nI can create unigrams, bigrams, trigrams, etc. out of this text, where I have to define on which \"level\" to create these unigrams. The \"level\" can be character, syllable, word, ...\nSo creating unigrams out of the sentence above would simply create a list of all words? \nCreating bigrams would result in word pairs bringing together words that follow each other? \nSo if the paper talks about ngram counts, it simply creates unigrams, bigrams, trigrams, etc. out of the text, and counts how often which ngram occurs? \nIs there an existing method in python's nltk package? Or do I have to implement a version of my own?","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":21407,"Q_Id":12821201,"Users Score":-1,"Answer":"I don't think there is a specific method in nltk to help with this. This isn't tough though. If you have a sentence of n words (assuming you're using word level), get all ngrams of length 1-n, iterate through each of those ngrams and make them keys in an associative array, with the value being the count. Shouldn't be more than 30 lines of code, you could build your own package for this and import it where needed.","Q_Score":14,"Tags":"python,nlp,nltk","A_Id":12821336,"CreationDate":"2012-10-10T14:01:00.000","Title":"What are ngram counts and how to implement using nltk?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand what __new__ does (and how it's different from __init__) so I'm not interested in definitions, I'm interested in when and how to use __new__.\nThe documentation says:\n\nIn general, you shouldn't need to override __new__ unless you're subclassing an immutable type like str, int, unicode or tuple\n\nBut I can't think of other cases to use __new__ or how to use it correctly (for example when subclassing an immutable type or why it's needed in this case).\nSo, when, why and how do you need to use __new__? \nI'm interested in the use cases, not what it does (I know what it does).","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1383,"Q_Id":12835176,"Users Score":2,"Answer":"A potential use case could be a \"factory class\" which returns instances of various classes depending on the implementation.","Q_Score":12,"Tags":"python","A_Id":12835628,"CreationDate":"2012-10-11T08:20:00.000","Title":"What are the use cases for Python's __new__?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am uploading videos to YouTube by using YouTube Data API (Python client library). Is it possible to set monetizing for that video from API rather than going to my account on the YouTube website and manually setting monetization for that uploaded video? If yes, then how can I do it from API? I am unable to find it in the API documentation, and Googling doesn't help either.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1037,"Q_Id":12840696,"Users Score":2,"Answer":"That's not something that's supported as part of the public YouTube Data API.","Q_Score":7,"Tags":"python,youtube-api","A_Id":12842420,"CreationDate":"2012-10-11T13:29:00.000","Title":"Enable Monetization on YouTube video using YouTube API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am having some issues making 'bigger than simple scripts and stuff' applications in Python. I have a class called WinMain, a class called Engine, one called State and another called Element. It's laid out like this:\nWinMain is the main class of the program, it has a mainLoop function and various other things. \nEngine is an object that contains data like images and rendering code. \nState is an object held by Engine that has its update method called each time Engine's step function is called. \nElements are objects held by State that are things like gui buttons and pictures to render. \nSince my rendering functions are in Engine, how will I get my Elements (held by state) to render things? I suppose I could give each Element the instance of Engine, but that seems to be kind of hacky, because I'd have to do stuff like this: \npicture = Element(engine, (0, 0), 'gui_image') (not good) \nI'd rather do picture = Element((0, 0), 'gui_image') and still some how let the Element render things using Engine.\nThis seems to be a major structural problem I have with most projects I start, and I can't seem to find a way around it (other than passing a honkload of variables through the arguments of classes and functions). How might I do this?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":467,"Q_Id":12848684,"Users Score":4,"Answer":"Engine is an object that contains data like images and rendering code\n\nThis sounds like a God class: they're common in GUI code, and the problem you're having is a common effect of that. \nWhat is the conceptual relationship between different stuff in Engine? Does it need to be tightly coupled, or could the Engine just coordinate between the State, a Renderer and some other stuff?\nHowever that bit breaks down, passing the Engine (or Renderer, or whatever) down through the state machine is the only way to avoid a global (or singleton) with your current architecture.\n\nThe usual way to break this dependency is to use something like an MVC (Model\/View\/Controller) pattern. Specifically, it sounds like the Engine is already roughly a Controller, and the State and Elements have the Model part covered. However, the Engine, State and Elements are also handling the rendering\/presentation part: this introduces the coupling.\nIf you can find a way to publish the State changes to some observer (deliberately leaving that vague, because we don't want the State logic to depend too much on the details of the observer), you can make a Renderer listen to State (model) updates and draw them. Now, the observer can be anything you want, so it's easy to mock, and it's also decoupled from the Engine.","Q_Score":3,"Tags":"python,oop,structure","A_Id":12849650,"CreationDate":"2012-10-11T21:19:00.000","Title":"Python structural issue: Giving an 'engine' class to everything","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have looked around for a while now and am still unable to find an answer to a method of doing this. I have made a few scripts to solve equations and now am looking for a way to write a script that will allow input of steps into an equation,number and name of variables etc. My idea is to make a script that will take all of these inputs and then write another script that will ask for the numbers in an equation and solve the equation. Any ideas of how to write the first script so that it can create a second?\nAlso I forgot to mention that I want the newer script to be saved for later use\/execution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":12851527,"Users Score":2,"Answer":"Instead of writing a script that creates another script, a better way to solve the problem would be to write functions. \nFor example, the first function would read the names of variables, etc. and return these data as a dictionary. \nNext, you would pass this dictionary into the second function, which, depending on the information stored in the dictionary, would read the remaining inputs and return another dictionary with the inputs. \nThen, you could use the data from the returned dictionary to solve the equation.","Q_Score":0,"Tags":"python,math,installation,createfile","A_Id":12851575,"CreationDate":"2012-10-12T02:49:00.000","Title":"Python Script to Make Another Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that can run for long time in the background, and am trying to find a way of getting a status update from it. Basically we're considering to send it a SIGUSR1 signal, and then have it report back a status update.\nCatching the signal in Python is not the issue, lots of information about that.\nBut how to get back information to the process initiating the signal? It seems that there is no way to figure out the pid of the initiating process by the receiving process, which could provide a way to send information back. A single reply message is enough here (in the tune of 'busy uploading; at 55% now; will finish at such a time'); a continuing update would be fantastic but not necessary.\nWhat I've come up with is to write this data to a temporary file with predetermined name - has the issue of leaving stale files behind, and need some kind of clean-up routine then. But that sounds like a hack. Is there anything better available?\nThe way the running process is signalled doesn't matter, it doesn't have to be kill -SIGUSR1 pid. Any way to communicate with it would do. As long as the communication can be initiated from a new process that's started after the main process runs, possibly running under as different user.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":882,"Q_Id":12862344,"Users Score":0,"Answer":"Signals are not designed to be general inter-process communication mechanisms that allow for passing data. They can't do much more than provide a notification. What the target process does in response can be fairly general (generating output to a particular file that the sender then knows to go look at, for example), but passing data directly back to the sender would require a different mechanism like a pipe, shared memory, message queue, etc. Also note that, in general, a process receiving a signal can't really determine who sent the signal, so it wouldn't know where to send a response anyway.","Q_Score":2,"Tags":"python,signals,ipc","A_Id":12863718,"CreationDate":"2012-10-12T15:27:00.000","Title":"Have python process talk back on SIGUSR1 call","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am attempting to teach myself python and have hit a rough spot once it has come to recursion. I have done the classic recursive functions (factorial, fibonacci numbers...) but I am going back over old code and trying to convert most of my iterative functions to recursive functions for practice.\nThis is the wall that I have hit:\nI made a dungeon crawler a while back and I am trying to replace a for loop I used to reveal the squares near my sprite. So when the sprite is placed, he\/she sees the tile he\/she is on as well as the adjacent and diagonal squares (9 in total including the one the avatar is on).The other tiles making up the room are hidden. This I deemed view radius 1. For view radius 2, I wanted the char to see radius 1 squares plus all the tiles adjacent to those tiles. At the time I could not figure out how to do it with a for loop so I just implemented a simpler scheme.\nI feel this visibility function could be written recursively but I am having a hard time coming up with a base case and what my recursive step would be. My for loop just took avatar pos and iterated over a range to avatar pos + radius and I did that for the x,y coordinates.\nAs far as translating this over to a recursive function I am really confused. I have done many searches trying to get a lead but only come up with complicated subjects such as: FOV using recursive shadowcasting which is way beyond me.\nAny help would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":241,"Q_Id":12867465,"Users Score":1,"Answer":"I find it helps a LOT to express recursions in words. What the algorithm says is basically \"what's visible at radius N is what's visible from radius N-1\". Like, uh, the edge gets bigger.","Q_Score":0,"Tags":"python,recursion","A_Id":12869565,"CreationDate":"2012-10-12T21:38:00.000","Title":"Recursive Function To Help Clear Tiles (Field Of View)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed the Enthought Python distribution on my computer, but I don't have any idea how to use it. I have PyLab and IDLE but I want to run .py files by typing the following command:\n\npython fileName.py\n\nI don't know where to write this command: IDLE, PyLab or Python.exe or Windows command prompt. When I do this in IDLE it says:\n\nSyntaxError: invalid syntax\n\nPlease help me to figure this out.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":41336,"Q_Id":12873542,"Users Score":3,"Answer":"Indeed, the command to run a Python file should be run in the command prompt. Python should be in your path variable for it to work flexible.\nWhen the python folder is added to path you can call python everywhere in the command prompt, otherwise just in your python install folder.\nThe following is from the python website:\n\nWindows has a built-in dialog for changing environment variables\n  (following guide applies to XP classical view): Right-click the icon\n  for your machine (usually located on your Desktop and called \u201cMy\n  Computer\u201d) and choose Properties there. Then, open the Advanced tab\n  and click the Environment Variables button.\nIn short, your path is:\nMy Computer \u2023 Properties \u2023 Advanced \u2023 Environment Variables In this\n  dialog, you can add or modify User and System variables. To change\n  System variables, you need non-restricted access to your machine (i.e.\n  Administrator rights).\nAnother way of adding variables to your environment is using the set\n  command in a command prompt:\nset PYTHONPATH=%PYTHONPATH%;C:\\My_python_lib\n\nIf you do it via My Computer, then look for the line named path in Enviroment Variables. Give that the value of your Python installation folder.","Q_Score":4,"Tags":"python,python-idle","A_Id":12873584,"CreationDate":"2012-10-13T13:26:00.000","Title":"How to run a Python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed the Enthought Python distribution on my computer, but I don't have any idea how to use it. I have PyLab and IDLE but I want to run .py files by typing the following command:\n\npython fileName.py\n\nI don't know where to write this command: IDLE, PyLab or Python.exe or Windows command prompt. When I do this in IDLE it says:\n\nSyntaxError: invalid syntax\n\nPlease help me to figure this out.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":41336,"Q_Id":12873542,"Users Score":3,"Answer":"Open a command prompt: Press \u229e Win  and R at the same time, then type in cmd and press \u21b5 Enter\nNavigate to the folder where you have the \".py\" file (use cd .. to go one folder back or cd folderName to enter folderName) \nThen type in python filename.py","Q_Score":4,"Tags":"python,python-idle","A_Id":12873556,"CreationDate":"2012-10-13T13:26:00.000","Title":"How to run a Python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a remote method created via Python web2py. How do I test and invoke the method from Java?\nI was able to test if the method implements @service.xmlrpc but how do i test if the method implements @service.run?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2053,"Q_Id":12890137,"Users Score":1,"Answer":"I'd be astonished if you could do it at all. Java RMI requires Java peers.","Q_Score":0,"Tags":"java,python,rmi,rpc,web2py","A_Id":12890526,"CreationDate":"2012-10-15T06:06:00.000","Title":"Using Java RMI to invoke Python method","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to access with Selenium (through) Python, a URL that demands authentication.\nWhen visit the URL, manually a new authentication window pops up, on which I need to fill in a username and password. Only after clicking on \u201cOK\u201d this window disappears and I return to the original site.\nAs I want to visit this URL on an interval base to download information and want to automatize this process in python.\nIn my current effort I use Selenium, but none of the examples that I found seem to do what I need. Thinks I tried but do not work are:\n\ndriver.get(\"https:\/\/username:password@somewebsite.com\/\")\nselenium.FireEvent(\"OK\", \"click\")\ndriver.find_element_by_id(\"UserName\")\n\nI do not know the actual element id\u2019s\nWhat I did manage is to load my Firefox profile that stores the authentication information, but I still need to confirm the authentication by clicking \u201cok\u201d.\nIs there any way to prevent this screen to pop up? \nIf not how to access this button on the authentication form, from which I cannot obtain id-information?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3449,"Q_Id":12893264,"Users Score":1,"Answer":"Using driver.get(\"https:\/\/username:password@somewebsite.com\/\") should directly log you in, without the popup being displayed,\nWhat about this did not work for you?\nEDIT\n\nI am not sure this will work but after\ndriver.get(\"https:\/\/username:password@somewebsite.com\/\") \nTry accepting alert.\nFor the alert - @driver.switch_to.alert.accept in Ruby or driver.switchTo().alert().accept(); in Java","Q_Score":2,"Tags":"python,firefox,authentication,selenium,form-submit","A_Id":12893410,"CreationDate":"2012-10-15T09:57:00.000","Title":"How to Submit Https authentication with Selenium in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a python script to copy python(say ABC.py) files from one directory to another \ndirectory with the same folder name(say ABC) as script name excluding .py.\nIn the local system it works fine and copying the files from one directory to others by\ncreating the same name folder.\nBut actually I want copy these files from my local system (windows XP) to the remote\nsystem(Linux) located in other country on which I execute my script. But I am getting\nthe error as \"Destination Path not found\" means I am not able to connect to remote\nthat's why.\nI use SSH Secure client.\nI use an IP Address and Port number to connect to the remote server.\nThen it asks for user id and password.\nBut I am not able to connect to the remote server by my python script.\n\nCan Any one help me out how can I do this??","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":9452,"Q_Id":12909334,"Users Score":-1,"Answer":"I used the same script, but my host failed to respond. My host is in different network.\nWinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond","Q_Score":2,"Tags":"python","A_Id":66757126,"CreationDate":"2012-10-16T07:14:00.000","Title":"How to Transfer Files from Client to Server Computer by using python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm working on a suite of tests using selenium webdriver (written in Python).  The page being tested contains a form that changes its displayed fields based upon what value is selected in one of its select boxes.  This select box has about 250 options.  I have a test (running via nose, though that's probably irrelevant) that iterates through all the options in the select box, verifying that the form has the correct fields displayed for each selected option.\nThe problem is that for each option, it calls through selenium:\n\nclick for the option to choose\nfind_element and is_displayed for 7 fields\nfind_elements for the items in the select box\nget_attribute and text for each option in the select box\n\nSo that comes out to (roughly) 250 * (7 * 2 + 1 + 2 * 250), or 128,750 distinct requests to the webdriver server the test is running on, all within about 10 or 15 minutes.  This is leading to client port exhaustion on the machine running the test in some instances.  This is all running through a test framework that abstracts away things like how the select box is parsed, when new page objects are created, and a few other things, so optimizations in the test code either mean hacking that all to hell or throwing away the framework for this test and doing everything manually (which, for maintainability of our test code, is a bad idea).\nSome ideas I've had for solutions are:\n\nTrying to somehow pool or reuse the connection to the webdriver server\nSomehow tweaking the configuration of urllib2 or httplib at runtime so that the connections opened by selenium timeout or are killed more quickly\nSystem independent (or at least implementable for all systems with an OS switch or some such) mechanism for actively tracking and closing the ports being opened by selenium\n\nAs I mentioned above, I can't do much to tweak the way the page is parsed or handled, but I do have control over subclassing\/tweaking WebDriver or RemoteConnection any way I please.  Does anyone have any suggestions on how to approach any of the above ideas, or any ideas that I haven't come up with?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2907,"Q_Id":12936533,"Users Score":2,"Answer":"In as much as a small amount of plastic explosive solves the problem of forgetting your house keys, I implemented a solution.  I created a class that tracks a list of resources and the time they were added to it, blocks when a limit is reached, and removes entries when their timestamp passes beyond a timeout value.  I then created an instance of this class setup with a limit of 32768 resources and a timeout of 240 seconds, and had my test framework add an entry to the list every time webdriver.execute() is called or a few other actions (db queries, REST calls) are performed.  It's not particularly elegant and it's quite arbitrary, but at least so far it seems to be keeping my tests from triggering port exhaustion while not noticeably slowing tests that weren't causing port exhaustion before.","Q_Score":2,"Tags":"python,selenium,webdriver,urllib2,tcp-ip","A_Id":12940958,"CreationDate":"2012-10-17T14:23:00.000","Title":"tcp\/ip port exhaustion with selenium webdriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i currently have this in my routing:\n(r\"\/admin\", AdminController.Index ),\n(r\"\/admin\/\", AdminController.Index ),\nhow do i merge them with just one line and have admin and admin\/ go to AdminController.Index?\ni know this could be achieved via regex, but it doesnt seem to work","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1761,"Q_Id":12949634,"Users Score":0,"Answer":"What about this: r'\/admin\/?' or r'\/admin\/{0,1}? Pay attention that I'm only talking about regex, don't know if this would work in Django.","Q_Score":1,"Tags":"python,regex,routing,tornado","A_Id":12950281,"CreationDate":"2012-10-18T07:48:00.000","Title":"Regex routing in Python using Tornado framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I like to use Python's SimpleHTTPServer for local development of all kinds of web applications which require loading resources via Ajax calls etc.\nWhen I use query strings in my URLs, the server always redirects to the same URL with a slash appended.\nFor example \/folder\/?id=1 redirects to \/folder\/?id=1\/ using a HTTP 301 response.\nI simply start the server using python -m SimpleHTTPServer.\nAny idea how I could get rid of the redirecting behaviour? This is Python 2.7.2.","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":6427,"Q_Id":12953542,"Users Score":5,"Answer":"The right way to do this, to ensure that the query parameters remain as they should, is to make sure you do a request to the filename directly instead of letting SimpleHTTPServer redirect to your index.html\nFor example http:\/\/localhost:8000\/?param1=1 does a redirect (301) and changes the url to http:\/\/localhost:8000\/?param=1\/ which messes with the query parameter.\nHowever http:\/\/localhost:8000\/index.html?param1=1 (making the index file explicit) loads correctly.\nSo just not letting SimpleHTTPServer do a url redirection solves the problem.","Q_Score":13,"Tags":"python,simplehttpserver,webdev.webserver","A_Id":25786569,"CreationDate":"2012-10-18T11:26:00.000","Title":"Why does SimpleHTTPServer redirect to ?querystring\/ when I request ?querystring?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to bring up a python window (could be idle or cmd based) with some packages already imported by double clicking a python script. Is this possible? If so, how do I do it?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":115,"Q_Id":12977441,"Users Score":5,"Answer":"You can use the -i interpreter option. python -c \"import os\" -i will import the os module and go to the interpreter read\/eval loop.\nYou can also put some statements (imports, definitions, etc) on a file and load it with python -i <file.py>","Q_Score":1,"Tags":"python,python-3.x","A_Id":12977721,"CreationDate":"2012-10-19T15:22:00.000","Title":"How can I bring up a python shell with packages already imported with a python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Django, if the view uses a sleep() function while answering a request, does this block the handling of the whole queue of requests?\nIf so, how to delay an http answer without this blocking behavior? Can we do that out-of-the-box and avoid using a job queue like Celeri?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1668,"Q_Id":13017421,"Users Score":2,"Answer":"I would image that calling sleep() should block the execution of all Django code in most cases. However it might depend on the deployment architecture (e.g. gevent, gunicorn, etc). For instance if you are using a server which fires Django threads for each request, then no it will not block all the code.\nIn most cases however using something like Celeri would like to be a much better solution because (1) don't reinvent the wheel and (2) it has been tested.","Q_Score":5,"Tags":"python,django","A_Id":13017620,"CreationDate":"2012-10-22T18:24:00.000","Title":"Is sleep() blocking the handling of requests in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having a problem with webapp2 and wtforms. More specifically I have defined two methods in two different handlers, called:\n\ncreate, which is a GET method listening to a specific route\nsave, which is a POST method listening to another route\n\nIn the save method I validate my form and if fails, I want to redirect to the create method via the redirect_to method, where I can render the template with the form. Is this possible with any way? I found an example on how this can be done if the same handler with get and post methods, but is this possible in methods of different handlers? \nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":348,"Q_Id":13049515,"Users Score":1,"Answer":"I think this will work if the routes are part of the same app.\nBut why not using a single handler with get and put and a method _create, which can be called (self._create instead of a redirect) by get and put to render the template with the form. It is faster than a browser redirect and you can pass arguments in an easy way.","Q_Score":1,"Tags":"python,google-app-engine,webapp2,wtforms","A_Id":13051668,"CreationDate":"2012-10-24T12:45:00.000","Title":"Webapp2 + WTForms issue: How to pass values and errors back to user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background \"wraps\" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started).\nI have no trouble getting the ship and objects to wrap, but the background doesn't show up until the viewport itself passes an edge of the gameworld. Is it possible to make the background surface \"wrap\" around?\nI'm sorry if I'm not being very articulate. It seems like a simple problem and tons of games do it, but I haven't had any luck finding an answer. I have some idea about how to do it by tiling the background, but it would be nice if I could just tell the surface to wrap.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1379,"Q_Id":13059891,"Users Score":0,"Answer":"I don't think so, I have an idea though. I'm guessing your background wraps horizontally and always to the right, then you could attach part of the beginning to the end of the background.\nExample, if you have a 10,000px background and your viewport is 1000px, attach the first 1000px to the end of the background, so you'll have a 11,000px background. Then when the vieport reaches the end of the background, you just move it to the 0px position and continue moving right.","Q_Score":2,"Tags":"python,scroll,pygame,geometry-surface","A_Id":13068085,"CreationDate":"2012-10-25T00:26:00.000","Title":"Wrapping a pygame surface around a viewport","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background \"wraps\" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started).\nI have no trouble getting the ship and objects to wrap, but the background doesn't show up until the viewport itself passes an edge of the gameworld. Is it possible to make the background surface \"wrap\" around?\nI'm sorry if I'm not being very articulate. It seems like a simple problem and tons of games do it, but I haven't had any luck finding an answer. I have some idea about how to do it by tiling the background, but it would be nice if I could just tell the surface to wrap.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1379,"Q_Id":13059891,"Users Score":0,"Answer":"I was monkeying around with something similar to what you described that may be of use. I decided to try using a single map class which contained all of my Tiles, and I wanted only part of it loaded into memory at once so I broke it up into Sectors (32x32 tiles). I limited it to only having 3x3 Sectors loaded at once. As my map scrolled to an edge, it would unload the Sectors on the other side and load in new ones.\nMy Map class would have a Rect of all loaded Sectors, and my camera would have a Rect of where it was located. Each tick I would use those two Rects to find what part of the Map I should blit, and if I should load in new Sectors. Once you start to change what Sectors are loaded, you have to shift \nEach sector had the following attributes:\n 1. Its Coordinate, with (0, 0) being the topleft most possible Sector in the world.\n 2. Its Relative Sector Coordinate, with (0, 0) being the topleft most loaded sector, and (2,2) the bottom right most if 3x3 were loaded.\n 3. A Rect that held the area of the Sector\n 4. A bool to indicate of the Sector was fully loaded\nEach game tick would check if the bool to see if Sector was fully loaded, and if not, call next on a generator that would blit X tiles onto the Map surface. I\n\nThe entire Surface \nEach update would unload, load, or update and existing Sector\nWhen an existing Sector was updated, it would shift \n\nIt would unload Sectors on update, and then create the new ones required. After being created, each Sector would start a generator that would blit X amount of tiles per update","Q_Score":2,"Tags":"python,scroll,pygame,geometry-surface","A_Id":13096965,"CreationDate":"2012-10-25T00:26:00.000","Title":"Wrapping a pygame surface around a viewport","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm coding a game where the viewport follows the player's ship in a finite game world, and I am trying to make it so that the background \"wraps\" around in all directions (you could think of it as a 2D surface wrapped around a sphere - no matter what direction you travel in, you will end up back where you started).\nI have no trouble getting the ship and objects to wrap, but the background doesn't show up until the viewport itself passes an edge of the gameworld. Is it possible to make the background surface \"wrap\" around?\nI'm sorry if I'm not being very articulate. It seems like a simple problem and tons of games do it, but I haven't had any luck finding an answer. I have some idea about how to do it by tiling the background, but it would be nice if I could just tell the surface to wrap.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1379,"Q_Id":13059891,"Users Score":0,"Answer":"Thanks everyone for the suggestions. I ended up doing something a little different from the answers provided. Essentially, I made subsurfaces of the main surface and used them as buffers, displaying them as appropriate whenever the viewport included coordinates outside the world. Because the scrolling is omnidirectional, I needed to use 8 buffers, one for each side and all four corners. My solution may not be the most elegant, but it seems to work well, with no noticeable performance drop.","Q_Score":2,"Tags":"python,scroll,pygame,geometry-surface","A_Id":13131429,"CreationDate":"2012-10-25T00:26:00.000","Title":"Wrapping a pygame surface around a viewport","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know nothing on this subject, but I need suggestions about the best tools or method for creating a setup program that installs python, some custom python modules, some other python modules such as PIL, and some EXE dependencies, all living on a network repository, on windows machines. In the repository are installers for python (msi file), PIL (exe file), the custom python modules (pyc files), and two windows executables (and exe file and a zip file). Any advice welcome.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2621,"Q_Id":13060146,"Users Score":3,"Answer":"You can do this with any of the installer applications out there. Each of the dependent installers has a silent install option, so your installer just needs to invoke the installers for each of the dependencies in the right order. I won't recommend any windows installer application in particular because I don't like any of them, but they will all do what you want. \nThe other option you have is to use py2exe which can bundle everything into a single exe file that runs in its own python environment. The plus side to this is you don't have to worry about installing Python in the users environment and have the user potentially uninstall python and then have your app stop working because everything is in a standalone environment.\nOther ways that I have seen this done is with a custom exe written in whatever compiled Windows Language you prefer that does all this for you, but this takes a lot of work.\nYou could also get the advantage of the py2exe route with a little work on an installer you write with either an installer app or a standalone exe that handles the install, by manually placing the python.exe, dll and related code in the proper directories relative to your application code. You may have to mess with your PYTHONPATH environment setting when your app starts to get everything working, but this way you don't have to worry about installing Python and whether the user already has Python installed or if they uninstall it because then you have the Python version you need bundled with your app.\nOne thing to note is that if you are worried about size the Python installer itself is about 10 MB before any dependencies, but a lot of that is not relevant to an end user using your app, There is no Python Runtime Environment installer like there is a Java runtime Environment installer that just install what you need to run Python, you always get the development tools.\nHope this helps a little.","Q_Score":1,"Tags":"python,windows,installation,windows-installer","A_Id":13060316,"CreationDate":"2012-10-25T01:00:00.000","Title":"how to write installer (installing python, python modules and other dependencies) for windows boxes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have huge tables of data that I need to manipulate (sort, calculate new quantities, select specific rows according to some conditions and so on...). So far I have been using a spreadsheet software to do the job but this is really time consuming and I am trying to find a  more efficient way to do the job. \nI use python but I could not figure out how to use it for such things. I am wondering if anybody can suggest something to use. SQL?!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":97,"Q_Id":13060427,"Users Score":1,"Answer":"This is a very general question, but there are multiple things that you can do to possibly make your life easier.\n1.CSV   These are very useful if you are storing data that is ordered in columns, and if you are looking for easy to read text files.\n2.Sqlite3   Sqlite3 is a database system that does not require a server to use (it uses a file instead), and is interacted with just like any other database system. However, for very large scale projects that are handling massive amounts of data, it is not recommended.\n3.MySql    MySql is a database system that requires a server to interact with, but can be tweaked for very large scale projects, as well as small scale projects.\nThere are many other different types of systems though, so I suggest you search around and find that perfect fit. However, if you want to mess around with Sqlite3 or CSV, both Sqlite3 and CSV modules are supplied in the standard library with python 2.7 and 3.x I believe.","Q_Score":0,"Tags":"python,sql,sorting,select","A_Id":13060535,"CreationDate":"2012-10-25T01:40:00.000","Title":"sorting and selecting data","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a multitenant app with a zipped package for each tenant\/client which contains the templates and handlers for the public site for each of them. right now i have under 50 tenants and its fine to keep the imported apps in memory after the first request to that specific clients domain.\nthis approach works well but i have to redeploy the app with the new clients zipped package every time i make changes and\/or a new client gets added.\nnow im working to make it possible to upload those packages via web upload and store them into the blobstore. \nmy concerns now are:\n\ngetting the packages from the blobstore is of course slower than importing a zipped package in the filesystem.\nbut this is not the biggest issue.  \nhow do i load\/import a module that is not in the filesystem and has no path?\nif every clients package is around 1mb its not a problem as long as the client base is low but what if it raises \nto 1k or even more? obviously there i dont have enough memory to store a few GB of data in memory. \nwhat is the best way to deal with this? \nif i use the instance memory to store the previously tenant package in memory how would \ninvalidate the data in memory if there would be a newly uploaded package?\n\ni would appreciate some thougts about how to deal this kind of situation.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":57,"Q_Id":13090476,"Users Score":1,"Answer":"i agree with nick. there should be no python code in the tenant specific zip. to solve the memory issue i would cache most of the pages in the datastore. to serve them you don't need to have all tenants loaded in your instances. you might also wanna look in pre generating html views on save rather then on request.","Q_Score":1,"Tags":"google-app-engine,memory-management,python-2.7,multi-tenant","A_Id":13126025,"CreationDate":"2012-10-26T16:06:00.000","Title":"zipped packages and in memory storage strategies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am just getting started with pymunk, and I have a problem that I wasn't able to find a solution to in the documentation.\nI have a character body that changes shape during a specific animation.  I know how to attach shapes to a physics body, but how do I change them?  Specifically, I need to change the box to a smaller one temporarily.\nIs that possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":898,"Q_Id":13127381,"Users Score":1,"Answer":"There are a couple of unsafe methods to modify a shape. Right now (v3.0) pymunk only supports updates of the Circle shape and the Segment shapes. However, I just committed a method to update the Poly shape as well, available in latest trunk of pymunk. \nIf you dont want to run latest trunk I suggest you instead just replace the shape instead of modifying it. The end result will be the same anyway.\n(The reason why modification of shapes is discouraged is that its very hard to do a good simulation, the resize happen magically in one instant. For example, how should a collision between of a small object that after a resize would lie inside a large object be resolved?)","Q_Score":1,"Tags":"python,chipmunk,pymunk","A_Id":13130409,"CreationDate":"2012-10-29T18:16:00.000","Title":"Changing the shape of a pymunk\/Chipmunk physics body","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a Python program that uses the os.system() function to create a new process (application) based on user input... However, this only works when the user inputs \"notepad.exe\". It does not work, for instance, when a user inputs \"firefox.exe\". I know this is a path issue because the error says that the file does not exist. I assume then that Windows has some default path setup for notepad that does allow notepad to run when I ask it to? So this leads to my question: is there any way to programmatically find the path to any application a user inputs, assuming it does in fact exist? I find it hard to believe the only way to open a file is by defining the entire path at some point. Or maybe there's a way that Windows does this for me that I do not know how to access? Any help would be great, thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":598,"Q_Id":13131699,"Users Score":1,"Answer":"I think you can add the location of the files in the PATH environment variable. Follow the steps: Go to My Computer->Right click->Properties->Advanced System Settings->Click Environmental Variables. Now click PATH and then click EDIT. In the variable value field, go to the end and append ';' (without quotes) and then add the absolute path of the .exe file which you want to run via your program.","Q_Score":1,"Tags":"python,windows,path,os.system","A_Id":13140093,"CreationDate":"2012-10-30T00:41:00.000","Title":"Python - get file path programmatically?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Do you guys know how to change the default encoding of an openerp file?\nI've tried adding # -*- coding: utf-8 -*- but it doesn't work (is there a setup that ignore this command? just a wild guess). When I try to execute sys.getdefaultencoding() still its in ASCII. \nRegards","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":803,"Q_Id":13134353,"Users Score":4,"Answer":"The comment # -*- coding: utf-8 -*- tells the python parser the encoding of the source file. It affects how the bytecode compiler converts unicode literals in the source code. It has no effect on the runtime environment. \nYou should explicitly define the encoding when converting strings to unicode. If you are getting UnicodeDecodeError, post your problem scenario and I'll try to help.","Q_Score":0,"Tags":"python,encoding,openerp","A_Id":13135341,"CreationDate":"2012-10-30T07:19:00.000","Title":"Setting default encoding Openerp\/Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am parsing a large file (>9GB) and am using iterparse of lxml in Python to parse the file while clearing as I go forward. I was wondering, is there a way to parse backwards while clearing? I could see I how would implement this independently of lxml, but it would be nice to use this package.\nThank you in advance!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1552,"Q_Id":13140185,"Users Score":0,"Answer":"iterparse() is strictly forward-only, I'm afraid. If you want to read a tree in reverse, you'll have to read it forward,  while writing it to some intermediate store (be it in memory or on disc) in some form that's easier for you to parse backwards, and then read that. I'm not aware of any stream parsers that allow XML to be parsed back-to-front.\nOff the top of my head, you could use two files, one containing the data and the other an index of offsets to the records in the data file. That would make reading backwards relatively easy once it's been written.","Q_Score":1,"Tags":"python,lxml","A_Id":13355413,"CreationDate":"2012-10-30T13:34:00.000","Title":"lxml, parsing in reverse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have received tens of thousands of user reviews on the app.\nI know the meaning of many of the comments are the same.\nI can not read all these comments.\nTherefore, I would like to use a python program to analyze all comments,\nIdentify the most frequently the most important feedback information.\nI would like to ask, how can I do that?\nI can download an app all comments, also a preliminary understanding of the Google Prediction API.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":13141796,"Users Score":0,"Answer":"You can use the Google Prediction API to characterize your comments as important or unimportant. What you'd want to do is manually classify a subset of your comments. Then you upload the manually classified model to Google Cloud Storage and, using the Prediction API, train your model. This step is asynchronous and can take some time. Once the trained model is ready, you can use it to programmatically classify the remaining (and any future) comments.\nNote that the more comments you classify manually (i.e. the larger your training set), the more accurate your programmatic classifications will be. Also, you can extend this idea as follows: instead of a binary classification (important\/unimportant), you could use grades of importance, e.g. on a 1-5 scale. Of course, that entails more manual labor in constructing your model so the best strategy will be a function of your needs and how much time you can spend building the model.","Q_Score":1,"Tags":"python,app-store,semantics,feedback,google-prediction","A_Id":13392517,"CreationDate":"2012-10-30T15:01:00.000","Title":"How to automatic classification of app user reviews?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just updated to SDK 1.7.3 running on Linux. At the same time I switched to the SQLite datastore stub, suggested by the depreciation message.\nAfter this, edits to source files are not always detected, and I have to stop and restart the SDK after updating, probably one time in ten. Is anyone else seeing this? Any ideas on how to prevent it?\nUPDATE: Changes to python source files are not being detected. I haven't made any modifications to yaml files, and I believe that jinja2 template file modifications are being detected properly.\nUPDATE: I added some logging to the dev appserver and found that the file I'm editing is not being monitored. Continuing to trace what is happening.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":294,"Q_Id":13148512,"Users Score":3,"Answer":"A similiar issue happens with appcfg.py in SDK 1.73, where it skips uploading some files sometimes.  It looks like this only happens if appcfg.py is run under python 2.7.\nThe workaround is to simply run appcfg.py under python 2.5. Then the upload works reliably.\nThe code uploaded can still be 2.7 specific - it is only necessary to revert 2.5 in the step of running the uploader function in appcfg.py.","Q_Score":3,"Tags":"python,google-app-engine","A_Id":13638216,"CreationDate":"2012-10-30T22:29:00.000","Title":"Appengine SDK 1.7.3 not detecting updated files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Sphinx to create documentation for my Python project in Windows. I need to generate PDF documentation. I found many explanation how to do this in Linux, but no good explanation how to do this in Windows. As far as i understand I need to create Latex format with Sphinx, and than use Texworks to convert Latex to PDF. Can someone provide step by step explanation how can I do this, assuming I created documentation in Latex format and installed Texworks?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":8815,"Q_Id":13155509,"Users Score":-1,"Answer":"As you have figured out: use Sphinx to generate LaTeX source, and then run it through a LaTex compiler to produce your PDF.\nInstead of troubling yourself with installing LaTeX (which can be daunting) and getting an editor set up, I suggest that you use one of the on-line LaTeX services. You then only have to create a project in ShareLaTeX or Overleaf, for example (which are in the process of merging), upload the contents of the Sphinx build\\latex directory, compile on-line, and download the finished PDF.\nThis works reasonably well, but since the output targets are very different (HTML vs a formal document), you may have to fiddle with the reST to get things the way you like it.","Q_Score":16,"Tags":"windows,pdf,python-sphinx","A_Id":52086907,"CreationDate":"2012-10-31T10:07:00.000","Title":"How to create PDF documentation with Sphinx in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am using the modules xlwd, xlwt and xlutil to do some Excel manipulations in Python. I am not able to figure out how to copy the value of cell (X,Y) to cell (A,B) in the same sheet of an Excel file in Python. Could someone let me know how to do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":472,"Q_Id":13156730,"Users Score":0,"Answer":"Work on 2 cells among tens of thousands...quite meager.\nNormally,one should present an iteration over rows x columns.","Q_Score":1,"Tags":"python,excel,xlrd,xlwt","A_Id":13998563,"CreationDate":"2012-10-31T11:21:00.000","Title":"Copying value of cell (X,Y) to cell (A,B) in same sheet of an Excel file using Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking into emacs as an alternative to Eclipse. One of my favorite features in Eclipse is being able to mouse over almost any python object and get a listing of its source, then clicking on it to go directly to its code in another file.\nI know this must be possible in emacs, I'm just wondering if it's already implemented in a script somewhere and, if so, how to get it up and running on emacs.\nLooks like my version is Version 24.2.\nAlso, since I'll be doing Django development, it would be great if there's a plugin that understands Django template syntax.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":314,"Q_Id":13160217,"Users Score":2,"Answer":"I also switched from Eclipse to Emacs and I must say that after adjusting to more text-focused ways of exploring code, I don't miss this feature at all.\nIn Emacs, you can just open a shell prompt (M-x shell). Then run IPython from within the Emacs shell and you're all set. I typically split my screen in half horizontally and make the bottom window thinner, so that it's like the Eclipse console used to be.\nI added a feature in my .emacs that lets me \"bring to focus\" the bottom window and swap it into the top window. So when I am coding, if I come across something where I want to see the source code, I just type C-x c to swap the IPython shell into the top window, and then I type %psource < code thing > and it will display the source.\nThis covers 95%+ of the use cases I ever had for quickly getting the source in Eclipse. I also don't care about the need to type C-x b or C-x C-f to open the code files. In fact, after about 2 or 3 hours of programming, I find that almost every buffer I could possibly need will already be open, and I just type C-x b < start of file name > and then tab-complete it.\nSince I have become more proficient at typing and not needing to move attention away to the mouse, I think this is now actually faster than the \"quick\" mouse-over plus F3 tactic in Eclipse. And to boot, having IPython open at the bottom is way better than the non-interactive Eclipse console. And you can use things like M-p and M-n to get the forward-backward behavior of IPython in terms of going back through commands.\nThe one thing I miss is tab completion in IPython. And for this, I think there are some add-ons that will do it but I haven't invested the time yet to install them.\nLet me know if you want to see any of the elisp code for the options I mentioned above.","Q_Score":5,"Tags":"python,django,emacs,ide","A_Id":13160450,"CreationDate":"2012-10-31T14:28:00.000","Title":"Link to python modules in emacs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to move multiple large folders (> 10 Gb , > 100 sub folders, > 2000 files ) between network drives. I have tried using shutil.copytree command in python which works fine except that it fails to copy a small percentage (< 1 % of files ) for different reasons. \nI believe robocopy is the best option for me as i can create a logfile documenting the transfer process. However as i need to copy > 1000 folders manual work is out of question.\nSo my question is essentially how can i call robocopy (i.e. command line ) from within a python script making sure that logfile is written in an external file. \nI am working on a Windows 7 environment and Linux\/Unix is out of question due to organizational restrictions. If someone has any other suggestions to bulk copy so many folders with a lot of flexibility they are welcome.","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":16661,"Q_Id":13161659,"Users Score":4,"Answer":"Like halfs13 said use subprocess but you might need to format it like so\nfrom subprocess import call\n call([\"robocopy\",'fromdir', 'todir',\"\/S\"])\n\nOr else it may read the source as everything","Q_Score":1,"Tags":"python,windows-7,command-line,copy,robocopy","A_Id":26222233,"CreationDate":"2012-10-31T15:41:00.000","Title":"How can i call robocopy within a python script to bulk copy multiple folders?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Not sure how to phrase this question properly, but this is what I intend to achieve using the hypothetical scenario outlined below - \nA user's email to me has just the SUBJECT and BODY, the subject being the topic of email, and the body being a description of the topic in just one paragraph of max 1000 words. Now I would like to analyse this paragraph (in the BODY) using some computer language (python, maybe), and then come up with a list of most important words from the paragraph with respect to the topic mentioned in the SUBJECT field.\nFor example, if the topic of email is say iPhone, and the body is something like \"the iPhone redefines user-interface design with super resolution and graphics. it is fully touch enabled and allows users to swipe the screen\"\nSo the result I am looking for is a sort of list with the key terms from the paragraph as related to iPhone. Example - (user-interface, design, resolution, graphics, touch, swipe, screen). \nSo basically I am looking at picking the most relevant words from the paragraph. I am not sure on what I can use or how to use to achieve this result. Searching on google, I read a little about Natural Language Processing and python and classification etc. I just need a general approach on how to go about this - using what technology\/language, which area I have to read on etc..\nThanks!\n\nEDIT:::\n\nI have been reading up in the meantime. To be precise, I am looking at HOW TO do this, using WHAT TOOL:\nGenerate related tags from a body of text using NLP which are based on synonyms, morphological similarity, spelling errors and contextual analysis.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1918,"Q_Id":13162409,"Users Score":1,"Answer":"I am not an expert but it seems like you really need to define a notion of \"key term\", \"relevance\", etc, and then put a ranking algorithm on top of that. This sounds like doing NLP, and as far as I know there is a python package called NLTK that might be useful in this field. Hope it helps!","Q_Score":2,"Tags":"python,nlp,classification,tagging,folksonomy","A_Id":13162597,"CreationDate":"2012-10-31T16:21:00.000","Title":"picking the most relevant words from a paragraph","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My friend has an application written in C that comes with a GUI made using GTK under Linux. Now we want to rewrite the GUI in python (wxpython or PyQT).\nI don't have experience with Python and don't know how to make Python communicate with C. I'd like to know if this is possible and if yes, how should I go about implementing it?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4672,"Q_Id":13173029,"Users Score":0,"Answer":"If you have an option between C or C#(Sharp) then go with C# and use visual studio, you can build the GUI by dragging and dropping components easy. If you want to do something in python look up wxPython. Java has a built in GUI builder known as swing. You'll need some tutorials, but unless this program doesn't need to be portable just go with C# and build it in 10 minutes .\nAlso, you can write your code in C and export it as a python module which you can load from python. It`s not very complicated to set up some C functions and have a python GUI which calls them. To achieve this you can use SWIG, Pyrex, BOOST.","Q_Score":6,"Tags":"python,c,wxpython,pyqt","A_Id":13175997,"CreationDate":"2012-11-01T07:52:00.000","Title":"Can C programs have Python GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Yesterday I started an important Python project and since then I've been searching for documentation on how to organize the code to have a \"high-quality\" project. There is a lot of articles and official documentation about how to organize packages and modules but, as I'm very new to this language, I think that is not my case.\nThe project is a client-server platform to distribute files in a local network (ok, is a lot more than this but its the basic idea). The thing is that is not going to be a module and I think that is not a package. At least not as described in the Python documentation:\n\nPackages are a way of structuring Python\u2019s module namespace by using\n  \u201cdotted module names\u201d\n\nI searched too in Git to see what popular project do to organize its code but most of them are modules and the rest... I don't even know how to run them.\nSo the question is, what is my code (module, package, ...) and which is the best way to organize it? Do you know any good article about this?\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":415,"Q_Id":13176027,"Users Score":2,"Answer":"Yes, your project will be a package.\nA module is a collection of related code. Most non-trivial projects will be a collection of modules in a package (potentially with sub-packages).","Q_Score":2,"Tags":"python,client-server,code-organization,project-organization","A_Id":13176078,"CreationDate":"2012-11-01T11:24:00.000","Title":"Python project organization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I have a HTML page which has four buttons Start, Stop, Pause and Resume in it. The functionality of the buttons are:\n\nStart Button: Starts the backend Simulator. (The Simulator takes around 3 minutes for execution.)\nStop Button: Stops the Simulator.\nPause Button: Pauses the Simulator.\nResume Button: Resumes the Simulator from the paused stage.\n\nEach of the button when clicked goes on to calling a separate view function. The problem I'm facing is that when I click the start button, it starts up the Simulator through a function call in the Python view. But as I mentioned that the simulator takes around 3 minutes for completing it's execution. So, for the 3 minutes my UI is totally unresponsive. I cannot  press Stop, Pause or Resume button untill the current view of Django is rendered.\nSo what is the best way to approach this problem ? Shall I spawn a non-blocking process for the Simulator and If so how can I get to know after the view has rendered that the new spawned process has completed it's execution.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":457,"Q_Id":13177087,"Users Score":0,"Answer":"Easiest I think will be use ajax to start he simulator. Response for start request can be updated on the same page.\nHowever, you will still have to think about how to pause,resume and stop the simulator started by earlier requests. i.e how to manage and manipulate state of the simulator.\nMay be you want to update that in DB.","Q_Score":1,"Tags":"python,django,django-views,subprocess","A_Id":13177553,"CreationDate":"2012-11-01T12:28:00.000","Title":"Getting Responsive Django View","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Say I have some Python list, my_list which contains N elements. Single elements may be indexed by using my_list[i_1], where i_1 is the index of the desired element. However, Python lists may also be indexed my_list[i_1:i_2] where a \"slice\" of the list from i_1 to i_2 is desired. What is the Big-O (worst-case) notation to slice a list of size N?\nPersonally, if I were coding the \"slicer\" I would iterate from i_1 to i_2, generate a new list and return it, implying O(N), is this how Python does it?\nThank you,","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":47961,"Q_Id":13203601,"Users Score":10,"Answer":"For a list of size N, and a slice of size M, the iteration is actually only O(M), not O(N). Since M is often << N, this makes a big difference.\nIn fact, if you think about your explanation, you can see why. You're only iterating from i_1 to i_2, not from 0 to i_1, then I_1 to i_2.","Q_Score":61,"Tags":"python,list,big-o","A_Id":13203622,"CreationDate":"2012-11-02T21:59:00.000","Title":"Big-O of list slicing","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a group of .png files where most of the image is transparent (alpha channel), but there is image in the middle (non-transparent pixels) that I need to extract.\nWhat I need to do is crop the image down to just the non-transparent pixels, but I need to know how many pixels were cropped off the left and bottom so when it comes time to render the cropped images, it's position can be adjusted back to were it was in the larger image.\nIs there a way to do the cropping and get the x,y offset using ImageMagick?  I know how to crop the .png file, but the location of the non-transparent image within the larger image is lost and I need this information.\nIt seems I can do this using PIL and python, but getting PIL installed on a Mac is proving to be a hair pulling experience.  I've spent hours trying to get rid of the jpeg_resync_to_restart errors and it seems everyone has a different solution that worked for them, but none of them work for me... so I've given up on PIL.\nImageMagick is already installed and working.\nIs there another set of tools I can call from a bash or python script that will do what I need?\nThis isn't just a one-time operation I need to preform, so I need a script that can be run over and over when the source .png files change.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":13206304,"Users Score":0,"Answer":"You mentioned that you were having problems installing PIL on a Mac. Have you considered using Macports?","Q_Score":0,"Tags":"python,image,imagemagick","A_Id":13206430,"CreationDate":"2012-11-03T05:31:00.000","Title":"Cropping away transparent pixels but preserving the offset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm looking to write a script in Python 2.x that will scan physical drive (physical and not logical) for specific strings of text that will range in size (chat artifacts). I have my headers and footers for the strings and so I am just wondering how is best to scan through the drive? My concern is that if I split it into, say 250MB chunks and read this data into RAM before parsing through it for the header and footer, it may be the header is there but the footer is in the next chunk of 250MB.\nSo in essence, I want to scan PhysicalDevice0 for strings starting with \"ABC\" for example and ending in \"XYZ\" and copy all content from within. I'm unsure whether to scan the data as ascii or Hex too.\nAs drives get bigger, I'm looking to do this in the quickest manner possible.\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":197,"Q_Id":13212673,"Users Score":1,"Answer":"Your problem can be formulated as \"how do I search in a very long file with no line structure.\" It's no different from what you'd do if you were reading line-oriented text one line at a time: Imagine you're reading a text file block by block, but have a line-oriented regexp to search with; you'd search up to the last complete line in the block you've read, then hold on to the final incomplete line and read another block to extend it with. So, you don't start afresh with each new block read. Think of it as a sliding window; you only advance it to discard the parts you were able to search completely.\nDo the same here: write your code so that the strings you're matching never hit the edge of the buffer. E.g., if the header you're searching for is 100 bytes long: read a block of text; check if the complete pattern appears in the block; advance your reading window to 100 bytes before the end of the current block, and add a new block's worth of text after it. Now you can search for the header without the risk of missing it. Once you find it, you're extracting text until you see the stop pattern (the footer). It doesn't matter if it's in the same block or five blocks later: your code should know that it's in extracting mode until the stop pattern is seen.","Q_Score":1,"Tags":"python,computer-forensics","A_Id":13214640,"CreationDate":"2012-11-03T19:28:00.000","Title":"Extracting strings from a physical drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a variable text whose value is like below,I need strip of trailing digits,is there a python built-in function to do it..if not,please suggest how can this be done in python\ne.g. -text=A8980BQDFZDD1701209.3 => -A8980BQDFZDD","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10613,"Q_Id":13215104,"Users Score":-2,"Answer":"You can use rstrip. Check the python docs.","Q_Score":2,"Tags":"python","A_Id":13215122,"CreationDate":"2012-11-04T01:04:00.000","Title":"How to strip trailing digits from a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to determine whether a function argument is a string, or some other iterable. Specifically, this is used in building URL parameters, in an attempt to emulate PHP's &param[]=val syntax for arrays - so duck typing doesn't really help here, I can iterate through a string and produce things like &param[]=v&param[]=a&param[]=l, but this is clearly not what we want. If the parameter value is a string (or a bytes? I still don't know what the point of a bytes actually is), it should produce &param=val, but if the parameter value is (for example) a list, each element should receive its own &param[]=val. I've seen a lot of explanations about how to do this in 2.* involving isinstance(foo, basestring), but basestring doesn't exist in 3.*, and I've also read that isinstance(foo, str) will miss more complex strings (I think unicode?). So, what is the best way to do this without causing some types to be lost to unnecessary errors?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":97,"Q_Id":13215873,"Users Score":3,"Answer":"You've been seeing things that somewhat conflict based on Python 2 vs 3. In Python 3, isinstance(foo, str) is almost certainly what you want. bytes is for raw binary data, which you probably can't include in an argument string like that.\nThe python 2 str type stored raw binary data, usually a string in some specific encoding like utf8 or latin-1 or something; the unicode type stored a more \"abstract\" representation of the characters that could then be encoded into whatever specific encoding. basestring was a common ancestor for both of them so you could easily say \"any kind of string\".\nIn python 3, str is the more \"abstract\" type, and bytes is for raw binary data (like a string in a specific encoding, or whatever raw binary data you want to handle). You shouldn't use bytes for anything that would otherwise be a string, so there's not a real reason to check if it's either str or bytes. If you absolutely need to, though, you can do something like isinstance(foo, (str, bytes)).","Q_Score":0,"Tags":"python,python-3.x,python-3.3","A_Id":13215904,"CreationDate":"2012-11-04T03:43:00.000","Title":"Separate strings from other iterables in python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Hello fellow python users, I bring forth a question that I have been wondering for a while. I love python, and have made many programs with it.  Now what I want to do is (or know how to do) make a python program, but run it in a window with buttons that you click on instead of typing in numbers to elect things.  I would like to just know weather or not I can do this, and if I can, please tell me where to go to learn how. Ok, it's not for the iPhone, sorry that I wasn't clear on that, and I didn't realize that iPhone was one of the tags.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":13222607,"Users Score":0,"Answer":"You can do this, the library is called tkinter.","Q_Score":0,"Tags":"python,user-interface,window","A_Id":13222646,"CreationDate":"2012-11-04T20:33:00.000","Title":"Can you run python as a windowed program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hello fellow python users, I bring forth a question that I have been wondering for a while. I love python, and have made many programs with it.  Now what I want to do is (or know how to do) make a python program, but run it in a window with buttons that you click on instead of typing in numbers to elect things.  I would like to just know weather or not I can do this, and if I can, please tell me where to go to learn how. Ok, it's not for the iPhone, sorry that I wasn't clear on that, and I didn't realize that iPhone was one of the tags.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":13222607,"Users Score":0,"Answer":"There are many GUI libraries to choose from, but I like Tkinter because it's easy and there's nothing to install (it comes with Python).\nBut some people prefer wxPython or others, such as PyQT. You'll have to decide which you like, or just go with Tkinter if you don't want to go through the trouble of installing libraries just to try them out.","Q_Score":0,"Tags":"python,user-interface,window","A_Id":13222783,"CreationDate":"2012-11-04T20:33:00.000","Title":"Can you run python as a windowed program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently building a web service using python \/ flask and would like to build my data layer on top of neo4j, since my core data structure is inherently a graph.\nI'm a bit confused by the different technologies offered by neo4j for that case. Especially : \n\ni originally planned on using the REST Api through py2neo , but the lack of transaction is a bit of a problem.\nThe \"embedded database\" neo4j doesn't seem to suit my case very well. I guess it's useful when you're working with batch and one-time analytics, and don't need to store the database on a different server from the web server.\nI've stumbled upon the neo4django project, but i'm not sure this one offers transaction support (since there are no native client to neo4j for python), and if it would be a problem to use it outside django itself. In fact, after having looked at the project's documentation, i feel like it has exactly the same limitations, aka no transaction (but then, how can you build a real-world service when you can corrupt your model upon a single connection timeout ?). I don't even understand what is the use for that project.\n\nCould anyone could recommend anything ? I feel completely stuck.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1075,"Q_Id":13233107,"Users Score":5,"Answer":"None of the REST API clients will be able to explicitly support (proper) transactions since that functionality is not available through the Neo4j REST API interface. There are a few alternatives such as Cypher queries and batched execution which all operate within a single atomic transaction on the server side; however, my general approach for client applications is to try to build code which can gracefully handle partially complete data, removing the need for explicit transaction control.\nOften, this approach will make heavy use of unique indexing and this is one reason that I have provided a large number of \"get_or_create\" type methods within py2neo. Cypher itself is incredibly powerful and also provides uniqueness capabilities, in particular through the CREATE UNIQUE clause. Using these, you can make your writes idempotent and you can err on the side of \"doing it more than once\" safe in the knowledge that you won't end up with duplicate data.\nAgreed, this approach doesn't give you transactions per se but in most cases it can give you an equivalent end result. It's certainly worth challenging yourself as to where in your application transactions are truly necessary.\nHope this helps\nNigel","Q_Score":2,"Tags":"python,flask,neo4j,py2neo","A_Id":13234558,"CreationDate":"2012-11-05T13:27:00.000","Title":"using neo4J (server) from python with transaction","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Newbie here trying to use python to do some database analysis.  I keep getting the error:\n\"error: cannot locate an Oracle software installation\"  When installing CX_oracle (via easy_install).\nThe problem is I do not have oracle on my local machine, I'm trying to use python to connect to the main oracle server. I have have setup another program to do this(visualdb) and I had a .jar file I used as the driver but I'm not sure how to use it in this case.\nAny suggestions?","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":25818,"Q_Id":13234196,"Users Score":1,"Answer":"Tip for Ubuntu users\nAfter configuring .bashrc environment variables, like it was explained in other answers,  don't forget to reload your terminal window, typing $SHELL.","Q_Score":12,"Tags":"python,oracle,cx-oracle","A_Id":58120873,"CreationDate":"2012-11-05T14:32:00.000","Title":"\"error: cannot locate an Oracle software installation\" When trying to install cx_Oracle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Newbie here trying to use python to do some database analysis.  I keep getting the error:\n\"error: cannot locate an Oracle software installation\"  When installing CX_oracle (via easy_install).\nThe problem is I do not have oracle on my local machine, I'm trying to use python to connect to the main oracle server. I have have setup another program to do this(visualdb) and I had a .jar file I used as the driver but I'm not sure how to use it in this case.\nAny suggestions?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":25818,"Q_Id":13234196,"Users Score":2,"Answer":"I got this message when I was trying to install the 32 bit version while having the 64bit Oracle client installed.\nWhat worked for me: reinstalled python with 64 bit (had 32 for some reason), installed cx_Oracle (64bit version) with the Windows installer and it worked perfectly.","Q_Score":12,"Tags":"python,oracle,cx-oracle","A_Id":28741244,"CreationDate":"2012-11-05T14:32:00.000","Title":"\"error: cannot locate an Oracle software installation\" When trying to install cx_Oracle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Newbie here trying to use python to do some database analysis.  I keep getting the error:\n\"error: cannot locate an Oracle software installation\"  When installing CX_oracle (via easy_install).\nThe problem is I do not have oracle on my local machine, I'm trying to use python to connect to the main oracle server. I have have setup another program to do this(visualdb) and I had a .jar file I used as the driver but I'm not sure how to use it in this case.\nAny suggestions?","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":25818,"Q_Id":13234196,"Users Score":2,"Answer":"I installed cx_Oracle, but I also had to install an Oracle client to use it (the cx_Oracle module is just a common and pythonic way to interface with the Oracle client in Python).\nSo you have to set the variable ORACLE_HOME to your Oracle client folder (on Unix: via a shell, for instance; on Windows: create a new variable if it does not exist in the Environment variables of the Configuration Panel). Your folder $ORACLE_HOME\/network\/admin (%ORACLE_HOME%\\network\\admin on Windows) is the place where you would place your tnsnames.ora file.","Q_Score":12,"Tags":"python,oracle,cx-oracle","A_Id":13234377,"CreationDate":"2012-11-05T14:32:00.000","Title":"\"error: cannot locate an Oracle software installation\" When trying to install cx_Oracle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Hi!I made a chess engine in python which i then compiled to .exe using py2exe. The problem is that it doesn't look very neat when i have all the strange files gathered together in the same folder (dist). I'd like to make a new folder inside the dist folder that contains all the helper files, so all my dist folder contains is the folder holding the helper files and the main launch application. However, i can't simply copy the helper files to a new folder, as the computer doesn't find them then and raises an error.\nHow can it be solved? Also, i'm using inno setup to make an installation, but i can't figure out how to find a solution there, either.\nThank you very much!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1098,"Q_Id":13236405,"Users Score":1,"Answer":"There is a feature in the configuration of py2exe that allows you to bundle all the Python files in a single library.zip file. That would considerably reduce the amount of files in the root directory, but there will still remain some files, regardless of all that.\nThese files are generally DLL files, at least from what I saw with GUI applications. You cannot remove these, because they are required to launch the application. A workaround to this problem is to create a batch file that will run the actual program which can be in child directory. The point is that these files should either be in the same directory as the executable, or the current working directory, or a path in the PATH environment variable. At least it's the case of most of these. Another approach might be a batch file which will modify the PATH variable or cd to another directory and run the file afterwards\nI never tried to do it, so it might break some things for you. Anyway, IMO the best approach is to create an installer and add shortcuts and you won't have to bother with the user messing with these files.","Q_Score":1,"Tags":"python,py2exe","A_Id":13237078,"CreationDate":"2012-11-05T16:38:00.000","Title":"How to put files in folders using py2exe.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project which requires counting the number of tweets that meet the parameters of a query. I'm working in Python, using Twython as my interface to Twitter.\nA few questions though, how do you record which tweets have already been accounted for? Would you simply make a note of the last tweet ID and ignore it plus all previous? --What is the easiest implementation of this?\nAs another optimizations question, I want to make sure that the amount of tweets missed by the counter is minimal, is there any way to make sure of this?\nThanks so much.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":13261858,"Users Score":0,"Answer":"considering the case of similar tweets and retweets, I would recommend making a semantic note of the whole tweet, extracting the text part of each tweet and doing a dictionary lookup.\nbut tweet id is more simpler with significant loss, usage as noted above.","Q_Score":1,"Tags":"python,twitter,twython","A_Id":16578360,"CreationDate":"2012-11-07T01:07:00.000","Title":"How to count tweets from query without double counting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed ipython, but I don't know how to use it. Where could I find ipython shell?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":5087,"Q_Id":13297219,"Users Score":4,"Answer":"To use ipython, just go to the command line, and run the command ipython.","Q_Score":5,"Tags":"python,ipython","A_Id":13297236,"CreationDate":"2012-11-08T20:26:00.000","Title":"Where to use ipython and where is ipthon shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a python script to do some experiment with the Mandelbrot set. I used a simple function to find Mandelbrot set points. I was wondering how much efficiency I can achieve by calling a simple C function to do this part of my code? Please consider that this function should call many times from Python.\nWhat is the effect of run time? And maybe other factors that should I aware?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":117,"Q_Id":13311732,"Users Score":1,"Answer":"You'll want the python calls to your C function to be as little as possible. If you can call the C function once from python and get it to do most\/all of the work, that would be better.","Q_Score":0,"Tags":"python,c,performance","A_Id":13311964,"CreationDate":"2012-11-09T16:12:00.000","Title":"Efficiency of calling C function from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been using the appengine python experimental searchAPI. It works great. With release 1.7.3 I updated all of the deprecated methods. However, I am now getting this warning:\nDeprecationWarning: consistency is deprecated. GLOBALLY_CONSIST\nHowever, I'm not sure how to address it in my code. Can anyone point me in the right direction?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":13313118,"Users Score":0,"Answer":"This depends on whether or not you have any globally consistent indexes. If you do, then you should migrate all of your data from those indexes to new, per-document-consistent (which is the default) indexes. To do this:\n\nLoop through the documents you have stored in the global index and reindexing them in the new index.\nChange references from the global index to the new per-document index.\nEnsure everything works, then delete the documents from your global index (not necessary to complete the migration, but still a good idea).\n\nYou then should remove any mention of consistency from your code; the default is per-document consistent, and eventually we will remove the ability to specify a consistency at all.  \nIf you don't have any data in a globally consistent index, you're probably getting the warning because you're specifying a consistency. If you stop specifying the consistency it should go away.  \nNote that there is a known issue with the Python API that causes a lot of erroneous deprecation warnings about consistency, so you could be seeing that as well. That issue will be fixed in the next release.","Q_Score":0,"Tags":"python,google-app-engine,full-text-search,gae-search","A_Id":13315587,"CreationDate":"2012-11-09T17:37:00.000","Title":"Appengine Search API - Globally Consistent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Scrapyd is service where we can eggify deploy our projects. However I am facing a problem. I have a Project named MyScrapers whose spider classes uses an import statement as follows:\nfrom mylibs.common.my_base_spider import MyBaseSpider\nThe path to my_base_spider is \/home\/myprojectset\/mylibs\/common\/my_base_spider\nWhile setting environment variable PYTHONPATH=$HOME\/myprojectset\/, I am able to run MyScrapers using scrapy command: scrapy crawl MyScrapers.\nBut when I use scrapyd for deploying MyScrapers by following command: scrapy deploy scrapyd2 -p MyScrapers, I get the following error:\nServer response (200):\n{\"status\": \"error\", \"message\": \"ImportError: No module named mylibs.common.my_base_spider\"}\nPlease tell how to make  deployed project to use these libs?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":973,"Q_Id":13318291,"Users Score":0,"Answer":"I found the answer by adding mylibs to site-packages of python by using setup.py inside mylib folder. That way I could import everything inside mylib in my projects. Actually mylibs were way outside from the location where setup.py of my deploy-able project is present. setup.py looks for packages on same level and inside the folders where it is located.","Q_Score":3,"Tags":"python,scrapyd","A_Id":13344717,"CreationDate":"2012-11-10T01:19:00.000","Title":"Scrapyd: How to specify libs and common folders that deployed projects can use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to use subprocess.check_output() with ps -A | grep 'process_name'.\nI tried various solutions but so far nothing worked. Can someone guide me how to do it?","AnswerCount":9,"Available Count":1,"Score":0.0886555158,"is_accepted":false,"ViewCount":305963,"Q_Id":13332268,"Users Score":4,"Answer":"Also, try to use 'pgrep' command instead of 'ps -A | grep 'process_name'","Q_Score":326,"Tags":"python,linux,subprocess,pipe","A_Id":13359172,"CreationDate":"2012-11-11T14:55:00.000","Title":"How to use `subprocess` command with pipes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed OpenERP 6.1 on windows using the AllInOne package. I did NOT install Python separately. Apparently OpenERP folders already contain the required python executables.\nNow when I try to install certain addons, I usually come across requirements to install certain python modules. E.g. to install Jasper_Server, I need to install http2, pypdf and python-dime. \nAs there is no separate Python installation, there is no C:\\Python or anything like that. Where and how do I install these python packages so that I am able to install the addon?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3249,"Q_Id":13346698,"Users Score":1,"Answer":"Good question..\nOpenerp on windows uses a dll for python (python26.dll in \/Server\/server of the openerp folder in program files). It looks like all the extra libraries are in the same folder, so you should be able to download the extra libraries to that folder and restart the service. (I usually stop the service and run it manually from the command line - its easier to see if there are any errors etc while debugging) \nLet us know if you get it working!","Q_Score":6,"Tags":"python,openerp","A_Id":13358175,"CreationDate":"2012-11-12T15:38:00.000","Title":"Installing Python modules for OpenERP 6.1 in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm filtering the twitter streaming API by tracking for several keywords. \nIf for example I only want to query and return from my database tweet information that was filtered by tracking for the keyword = 'BBC' how could this be done?\nDo the tweet information collected have a key:value relating to that keyword by which it was filtered?\nI'm using python, tweepy and MongoDB.\nWould an option be to search for the keyword in the returned json 'text' field? Thus generate a query where it searches for that keyword = 'BBC' in the text field of the returned json data?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":374,"Q_Id":13352796,"Users Score":0,"Answer":"Unfortunately, the Twitter API doesn't provide a way to do this. You can try searching through receive tweets for the keywords you specified, but it might not match exactly.","Q_Score":1,"Tags":"python,mongodb,twitter,tweepy","A_Id":22388827,"CreationDate":"2012-11-12T22:42:00.000","Title":"Querying twitter streaming api keywords from a database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can the range function take either: a single argument, range(stop), or range(start, stop), or range(start, stop, step).  Does it use a variadic argument like *arg to gather the arguments, and then use a series of if statements to assign the correct values depending on the number of arguments supplied? In essence, does range() specify that if there is one argument, then it set as the stop argument, or if there are two then they are start, and stop, or if there are three then it sets those as stop, start, and step respectively?  I'd like to know how one would do this if one were to write range in pure CPython.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5994,"Q_Id":13366293,"Users Score":8,"Answer":"Range takes, 1, 2, or 3 arguments. This could be implemented with def range(*args), and explicit code to raise an exception when it gets 0 or more than 3 arguments.\nIt couldn't be implemented with default arguments because you can't have a non-default after a default, e.g. def range(start=0, stop, step=1). This is essentially because python has to figure out what each call means, so if you were to call with two arguments, python would need some rule to figure out which default argument you were overriding. Instead of having such a rule, it's simply not allowed.\nIf you did want to use default arguments you could do something like: def range(start=0, stop=object(), step=1) and have an explicit check on the type of stop.","Q_Score":18,"Tags":"python,function,arguments,range","A_Id":13366356,"CreationDate":"2012-11-13T18:12:00.000","Title":"How can the built-in range function take a single argument or three?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any way to do this?\nBasically I have a file that I want a user to be able to edit via a GUI I built(all of which I can do easily). Part of this is a calculation in a function. That or being able to edit a .py file from another file would be fine as well, but it is hard to find anything on that because every search returns details about IDLE and such.\nI also have no problem with just having the calculation only in the text file and being able to read that from the text file and then parse it to add the variables in, but not even sure how to do that easily either, with the calculations varying like so:\n(abs(x) - abs(y) * dict['t']) * 18\n((abs(y) * dict['t']) - abs(x)) * 20\netc for about 10 different variations","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":13373014,"Users Score":1,"Answer":"yup, its not at all secure, but eval is the way to go: \n\nIn [1]: a= 10\nIn [2]: b= 20\nIn [3]: eval('a + 10*b')\nOut[3]: 210","Q_Score":0,"Tags":"python","A_Id":13373099,"CreationDate":"2012-11-14T04:24:00.000","Title":"Importing a function from a .txt file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This might be a bit foolish but I'm trying to use ctypes to call a function that receives a complex vector as a paramter. But in ctypes there isn't a class c_complex. \nDoes anybody know how to solve this?\nedit: I'm refering to python's ctypes, in case there are others....","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":2911,"Q_Id":13373291,"Users Score":-1,"Answer":"If c_complex is a C struct and you have the definition of in documentation or a header file you could utilize ctypes to compose a compatible type.  It is also possible, although less likely, that c_complex is a typdef for a type that ctypes already supports.\nMore information would be needed to provide a better answer...","Q_Score":4,"Tags":"python,ctypes,complex-numbers","A_Id":13373641,"CreationDate":"2012-11-14T04:59:00.000","Title":"Complex number in ctypes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to find all the days of the month where a certain activity occurs. The days when the activity occurs will be sequential. The sequence of days can range from one to the entire month, and the sequence will occur exactly one time per month. \nTo test whether or not the activity occurs on any given day is not an expensive calculation, but I thought I would use this problem learn something new. Which algorithm minimizes the number of days I have to test?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":418,"Q_Id":13385085,"Users Score":2,"Answer":"I think the linear probe suggested by @isbadawi is the best way to find the beginning of the subsequence.  This is because the subsequence could be very short and could be anywhere within the larger sequence.\nHowever, once the beginning of the subsequence is found, we can use a binary search to find the end of it.  That will require fewer tests than doing a second linear probe, so it's a better solution for you.\nAs others have pointed out, there is not much practical reason for doing this.  This is true for two reasons: your large sequence is quite short (only about 31 elements), and you still need to do at least one linear probe anyway, so the big-O runtime will be still be linear in the length of the large sequence, even though we have reduced part of the algorithm from linear to logarithmic.","Q_Score":3,"Tags":"python,algorithm","A_Id":13386318,"CreationDate":"2012-11-14T18:34:00.000","Title":"In python, how can I efficiently find a consecutive sequence that is a subset of a larger consecutive sequence?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using cx_Freeze to compile Python programs into executables and it works just fine, but the problem is that it doesn't compile the program into one EXE, it converts them into a .exe file AND a whole bunch of .dll files including python32.dll that are necessary for the program to run.\nDoes anyone know how I can package all of these files into one .exe file? I would rather it be a plain EXE file and not just a file that copies the DLLs into a temporary directory in order to launch the program.\nEDIT: This is in reference to Python 3","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2963,"Q_Id":13389724,"Users Score":0,"Answer":"Have you tried innosetup? It can create installer files from the output of cxfreeze. There might be an option somewhere to bundle everything into one file.","Q_Score":3,"Tags":"python,compilation,exe,cx-freeze","A_Id":13967222,"CreationDate":"2012-11-15T00:22:00.000","Title":"Convert an EXE and its dependencies into one stand-alone EXE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let me explain what I'm trying to achieve. In the past while working on Java platform, I used to write Java codes(say, to push or pull data from MySQL database etc.) then create a war file which essentially bundles all the class files, supporting files etc and put it under a servlet container like Tomcat and this becomes a web service and can be invoked from any platform. \nIn my current scenario, I've majority of work being done in Java, however the Natural Language Processing(NLP)\/Machine Learning(ML) part is being done in Python using the NLTK, Scipy, Numpy etc libraries. I'm trying to use the services of this Python engine in existing Java code. Integrating the Python code to Java through something like Jython is not that straight-forward(as Jython does not support calling any python module which has C based extensions, as far as I know), So I thought the next option would be to make it a web service, similar to what I had done with Java web services in the past. Now comes the actual crux of the question, how do I run the ML engine as a web service and call the same from any platform, in my current scenario this happens to be Java. I tried looking in the web, for various options to achieve this and found things like CherryPy, Werkzeug etc but not able to find the right approach or any sample code or anything that shows how to invoke a NLTK-Python script and serve the result through web, and eventually replicating the functionality Java web service provides. In the Python-NLTK code, the ML engine does a data-training on a large corpus(this takes 3-4 minutes) and we don't want the Python code to go through this step every time a method is invoked. If I make it a web service, the data-training will happen only once, when the service starts and then the service is ready to be invoked and use the already trained engine. \nNow coming back to the problem, I'm pretty new to this web service things in Python and would appreciate any pointers on how to achieve this .Also, any pointers on achieving the goal of calling NLTK based python scripts from Java, without using web services approach and which can deployed on production servers to give good performance would also be helpful and appreciable. Thanks in advance.\nJust for a note, I'm currently running all my code on a Linux machine with Python 2.6, JDK 1.6 installed on it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1090,"Q_Id":13394969,"Users Score":0,"Answer":"NLTK based system tends to be slow at response per request, but good throughput can be achieved given enough RAM.","Q_Score":4,"Tags":"python,machine-learning,cherrypy","A_Id":13399425,"CreationDate":"2012-11-15T09:51:00.000","Title":"How to expose an NLTK based ML(machine learning) Python Script as a Web Service?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to have an import in __init__() method (because i need to run that import only when i instance the class).\nBut i cannot see that import outside __init__(), is the scope limited to__init__? how to do?","AnswerCount":4,"Available Count":1,"Score":0.2449186624,"is_accepted":false,"ViewCount":7587,"Q_Id":13395116,"Users Score":5,"Answer":"You can just import it again other places that you need it -- it will be cached after the first time so this is relatively inexpensive.\nAlternatively you could modify the current global namespaces with something like globals()['name'] = local_imported_module_name.\nEDIT: For the record, although using the globals() function will certainly work, I think a \"cleaner\" solution would be to declare the module's name global and then import it, as several other answers have mentioned.","Q_Score":9,"Tags":"python,python-import","A_Id":13395225,"CreationDate":"2012-11-15T10:01:00.000","Title":"Python import in __init__()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to pass a variable from one page to another using google app engine, I know how to pass it using GET put putting it in the URL.  But I would like to keep the URL clean, and I might need to pass a larger amount of data, so how can pass info using post.\nTo illustrate, I have a page with a series of links, each goes to \/viewTaskGroup.html, and I want to pass the name of the group I want to view based on which link they click (so I can search and get it back and display it), but I'd rather not use GET if possible.\nI didn't think any code is required, but if you need any I'm happy to provide any needed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":297,"Q_Id":13427477,"Users Score":1,"Answer":"Links inherently generate GET requests. If you want to generate a POST request, you'd need to either:\n\nUse a form with method=\"POST\" and submit it, or\nUse AJAX to load the new page.","Q_Score":1,"Tags":"python,google-app-engine,http-post,http-get","A_Id":13427499,"CreationDate":"2012-11-17T03:45:00.000","Title":"Pass data in google app engine using POST","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I add a check to avoid flushing a file f with f.flush() when some function has already done f.close()?\nI can't seem to figure out how to do so :\/","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":421,"Q_Id":13428313,"Users Score":3,"Answer":"Just examine closed attribute of file object.","Q_Score":2,"Tags":"python","A_Id":13428441,"CreationDate":"2012-11-17T06:31:00.000","Title":"Python Flushing and Already Closed File","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a dictionary file containing only words without apostrophes. I cant seem to find one! Does anyone know how where I can find one, if not how could I eliminate those words from the file using Python?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1178,"Q_Id":13432635,"Users Score":1,"Answer":"On Linux:\nA nice method using grep to filter out any words containing apostrophes in the words file and save to mywords.txt in your home directory.\ngrep \"^[^']*$\" \/usr\/share\/dict\/words > ~\/mywords.txt\nNo need to install, download or write any code! \n\nOn OS X:\nEven easier as \/usr\/share\/dict\/words contains no words with apostrophes in already.","Q_Score":0,"Tags":"python,list,dictionary","A_Id":13432674,"CreationDate":"2012-11-17T16:54:00.000","Title":"List of Dictionary words without apostrophes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am trying to scrape something that is behind a login system. I tried using CasperJS, but am having issues with the form, so maybe that is not the way to go; I checked the source code of the site and the form name is \"theform\" but I can never login must be doing something wrong. Does any have any tutorials on how to do this correctly using CasperJS, I've looked at the API and google and nothing really works. \nOr does someone have any recommendations on how to do web scraping easily. I have to be able to check a simple conditional state and click a few buttons, that is all.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":684,"Q_Id":13434664,"Users Score":0,"Answer":"Because you mentioned CasperJS I can assume that web site generate some data by using JavaScript. My suggestion would be check WebKit. It is a browser \"engine\", that will let you do what ever you want with web-site.\nYou can use PyQt4 framework, which is very good, and has a good documentation.","Q_Score":2,"Tags":"python,web-scraping,casperjs","A_Id":13437094,"CreationDate":"2012-11-17T20:52:00.000","Title":"Web scraping - web login issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My score was to get the most frequent color in a image, so I implemented a k-means algorithm.\nThe algorithm works good, but the result is not the one I was waiting for.\nSo now I'm trying to do some improvements, the first I thought was to implement k-means++, so I get a beter position for the inicial clusters centers.\nFirst I select a random point, but how can I select the others. I mean how I define the minimal distance between them.\nAny help for this? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1239,"Q_Id":13436032,"Users Score":0,"Answer":"You can use a vector quantisation.  You can make a list of each pixel and each adjacent pixel in x+1 and y+1 direction and pick the difference and plot it along a diagonale. Then you can calculate a voronoi diagram and get the mean color and compute a feature vector. It's a bit more effectice then to use a simple grid based mean color.","Q_Score":0,"Tags":"python,colors,cluster-computing,k-means","A_Id":13436279,"CreationDate":"2012-11-17T23:55:00.000","Title":"K-Means plus plus implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My website users can upload image files, which then need to be found whenever they are to be displayed on a page (using src = \"\"). Currently, I put all images into one directory. What if there are many files - is it slow to find the right file? Are they indexed? Should I create subdirectories instead? \nI use Python\/Django. Everything is on webfaction.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":13440079,"Users Score":0,"Answer":"The access time for an individual file are not affected by the quantity of files in the same directory. \nrunning ls -l on a directory with more files in it will take longer of course. Same as viewing that directory in the file browser. Of course it might be easier to work with these images if you store them in a subdirectory defined by the user's name. But that just depends on what you are going to doing with them. There is no technical reason to do so. \nThink about it like this. The full path to the image file (\/srv\/site\/images\/my_pony.jpg) is the actual address of the file. Your web server process looks there, and returns any data it finds or a 404 if there is nothing. What it doesn't do is list all the files in \/srv\/site\/images and look through that list to see if it contains an item called my_pony.jpg.","Q_Score":0,"Tags":"python,operating-system","A_Id":13440101,"CreationDate":"2012-11-18T12:28:00.000","Title":"Python\/Django: how to get files fastest (based on path and name)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in the process of migrating an application from Master\/Slave to HRD. I would like to hear some comments from who already went through the migration.\n\nI tried a simple example to just post a new entity without ancestor and redirecting to a page to list all entities from that model. I tried it several times and it was always consistent. Them I put 500 indexed properties and again, always consistent...\nI was also worried about some claims of a limit of one 1 put() per entity group per second. I put() 30 entities with same ancestor (same HTTP request but put() one by one) and it was basically no difference from puting 30 entities without ancestor. (I am using NDB, could it be doing some kind of optimization?)\n\nI tested this with an empty app without any traffic and I am wondering how much a real traffic would affect the \"eventual consistency\".\nI am aware I can test \"eventual consistency\" on local development. My question is: \nDo I really need to restructure my app to handle eventual consistency? \nOr it would be acceptable to leave it the way it is because the eventual consistency is actually consistent in practice for 99%?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":560,"Q_Id":13448366,"Users Score":1,"Answer":"If you have a small app then your data probably live on the same part of the same disk and you have one instance. You probably won't notice eventual consistency. As your app grows, you notice it more. Usually it takes milliseconds to reach consistency, but I've seen cases where it takes an hour or more.\nGenerally, queries is where you notice it most. One way to reduce the impact is to query by keys only and then use ndb.get_multi() to load the entities. Fetching entities by keys ensures that you get the latest version of that entity. It doesn't guarantee that the keys list is strongly consistent, though. So you might get entities that don't match the query conditions, so loop through the entities and skip the ones that don't match. \nFrom what I've noticed, the pain of eventual consistency grows gradually as your app grows. At some point you do need to take it seriously and update the critical areas of your code to handle it.","Q_Score":8,"Tags":"python,google-app-engine,app-engine-ndb","A_Id":21716718,"CreationDate":"2012-11-19T05:49:00.000","Title":"In practice, how eventual is the \"eventual consistency\" in HRD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in the process of migrating an application from Master\/Slave to HRD. I would like to hear some comments from who already went through the migration.\n\nI tried a simple example to just post a new entity without ancestor and redirecting to a page to list all entities from that model. I tried it several times and it was always consistent. Them I put 500 indexed properties and again, always consistent...\nI was also worried about some claims of a limit of one 1 put() per entity group per second. I put() 30 entities with same ancestor (same HTTP request but put() one by one) and it was basically no difference from puting 30 entities without ancestor. (I am using NDB, could it be doing some kind of optimization?)\n\nI tested this with an empty app without any traffic and I am wondering how much a real traffic would affect the \"eventual consistency\".\nI am aware I can test \"eventual consistency\" on local development. My question is: \nDo I really need to restructure my app to handle eventual consistency? \nOr it would be acceptable to leave it the way it is because the eventual consistency is actually consistent in practice for 99%?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":13448366,"Users Score":0,"Answer":"The replication speed is going to be primarily server-workload-dependent. Typically on an unloaded system the replication delay is going to be milliseconds. \nBut the idea of \"eventually consistent\" is that you need to write your app so that you don't rely on that; any replication delay needs to be allowable within the constraints of your application.","Q_Score":8,"Tags":"python,google-app-engine,app-engine-ndb","A_Id":13457830,"CreationDate":"2012-11-19T05:49:00.000","Title":"In practice, how eventual is the \"eventual consistency\" in HRD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in the process of migrating an application from Master\/Slave to HRD. I would like to hear some comments from who already went through the migration.\n\nI tried a simple example to just post a new entity without ancestor and redirecting to a page to list all entities from that model. I tried it several times and it was always consistent. Them I put 500 indexed properties and again, always consistent...\nI was also worried about some claims of a limit of one 1 put() per entity group per second. I put() 30 entities with same ancestor (same HTTP request but put() one by one) and it was basically no difference from puting 30 entities without ancestor. (I am using NDB, could it be doing some kind of optimization?)\n\nI tested this with an empty app without any traffic and I am wondering how much a real traffic would affect the \"eventual consistency\".\nI am aware I can test \"eventual consistency\" on local development. My question is: \nDo I really need to restructure my app to handle eventual consistency? \nOr it would be acceptable to leave it the way it is because the eventual consistency is actually consistent in practice for 99%?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":13448366,"Users Score":0,"Answer":"What's the worst case if you get inconsistent results?\n\nDoes a user see some unimportant info that's out of date?  That's probably ok.\nWill you miscalculate something important, like the price of something?  Or the number of items in stock in a store?  In that case, you would want to avoid that chance occurence.\n\nFrom observation only, it seems like eventually consistent results show up more as your dataset gets larger, I suspect as your data is split across more tablets.\nAlso, if you're reading your entities back with get() requests by key\/id, it'll always be consistent.  Make sure you're doing a query to get eventually consistent results.","Q_Score":8,"Tags":"python,google-app-engine,app-engine-ndb","A_Id":13457661,"CreationDate":"2012-11-19T05:49:00.000","Title":"In practice, how eventual is the \"eventual consistency\" in HRD?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Pygame, how can I get graphical input(e.g. clicking exit button) and also get input from the a terminal window simultaneously? \nTo give you context, my game has a GUI but gets its game commands from a \"input()\" command. How can I look for input from the command line while also handling graphics?\nI'm not sure if this is possible, but if not, what other options do I have for getting text input from the user?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":906,"Q_Id":13450878,"Users Score":1,"Answer":"You can't do that, unless you use the input command in a different thread, but then you have to deal with syncronization (which might be what you want or don't want to do).\nThe way I'd implement this is to create a kind of in-game console. When a special key (e.g. '\\') is pressed you make the console appear, and when your application is in that state you interpreter key pressing not as in-game commands but... well, as text. You can print them in the console (using fonts). When a key (e.g \"return\") is pressed you can make the console disappear and the keys take back their primary functionality.\nI did this for my pet-project and it works as a charm. Plus, since you are developing in python you can accept python instructions and use exec to execute them and edit your game \"on fhe fly\"","Q_Score":2,"Tags":"python,input,pygame","A_Id":13451666,"CreationDate":"2012-11-19T09:28:00.000","Title":"Pygame: Graphical Input + Text Input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to use Firefox portable for my tests in python. In plain webdriver it works, but i was wondering how to do it in remote webdriver.\nAll i could find is how to pass firefox profile, but how to specify to webdriver which binary to use?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":620,"Q_Id":13460288,"Users Score":0,"Answer":"Very hacky, but you could modify the Webdriver Firefox plugin to point to your binary.","Q_Score":3,"Tags":"python,selenium,webdriver","A_Id":13460962,"CreationDate":"2012-11-19T18:57:00.000","Title":"How to specify browser binary in selenium remote webdriver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning python from learnpythonthehardway. in the windows I had no issues with going through a lots of exercises because the setup was easier but I want to learn linux as well and ubuntu seemed to me the nicest choice. \nnow I am having trouble with setting up. I can get access to the terminal and then usr\/lib\/python.2.7 but I don't know if to save the script in this directory? if I try to make a directory inside this through mkdir I can't as permission is denied. I also tried to do chmod but didn't know how or if to do it. \nany help regarding how to save my script in what libary? how to do that? and how to run it in terminal as: user@user$ python sampleexcercise.py\nusing ubuntu 12.04 lts\nskill = newbie\nthanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":409,"Q_Id":13464456,"Users Score":2,"Answer":"As an absolute beginner, don't worry right now about where to install libraries.  Simple example scripts that you're trying out for learning purposes don't belong being installed in any lib directory such as under \/usr\/lib\/python.'\nOn Linux you want to do most work in your home directory, so just cd ~ to make sure you're there and create files there with an editor of your choice.  You might want to organize your files hierarchically too.  For example create a directory called src\/ using the mkdir command in your home directory.  And and then mdkir src\/lpthw, for example, as a place to store all your samples from \"Learn Python the Hard Way\".  Then simply fun python <path\/to\/py\/file> to execute the script.  Or you can cd ~\/src\/lpthw and run your scripts by filename only.","Q_Score":0,"Tags":"python,installation,ubuntu-12.04","A_Id":13464518,"CreationDate":"2012-11-19T23:46:00.000","Title":"python library access in ubuntu 12.04","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to make a webapp that asks people multiple choice questions, and times how long they take to answer. \nI'd like those who want to, to be able to make accounts, and to store the data for how well they've done and how their performance is increasing.\nI've never written any sort of web app before, although I'm a good programmer and understand how http works. \nI'm assuming (without evidence) that it's better to use a 'framework' than to hack something together from scratch, and I'd appreciate advice on which framework people think would be most appropriate.\nI hope that it will prove popular, but would rather get something working than spend time at the start worrying about scaling. Is this sane?\nAnd I'd like to be able to develop and test this on my own machine, and then deploy it to a virtual server or some other hosting solution. \nI'd prefer to use a language like Clojure or Lisp or Haskell, but if the advantages of using, say, Python or Ruby would outweigh the fact that I'd enjoy it more in a more maths-y language, then I like both of those too.\nI probably draw the line at perl, but if perl or even something like Java or C have compelling advantages then I'm quite happy with them too. They just don't seem appropriate for this sort of thing.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":947,"Q_Id":13473489,"Users Score":1,"Answer":"When the server-side creates the form, encode an hidden field with the timestamp of the request, so when the users POSTs his form, you can see the time difference.\nHow to implement that is up to you, which server you have available, and several other factors.","Q_Score":1,"Tags":"python,web-applications,haskell,clojure,lisp","A_Id":13476327,"CreationDate":"2012-11-20T12:44:00.000","Title":"How do I make a web server to make timed multiple choice tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a title (\"cadeau check 50 \u20ac\") in a form value that I want to write to a background image with arial.ttf. My text is correct but for the euro sign. I have 2 [] in place. I don't know where the problem is coming from. Is this an encoding problem in PIL, or have I a problem with the font?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":785,"Q_Id":13476383,"Users Score":0,"Answer":"Maybe use Unicode strings?? Like u'cadeau check 50 \u20ac' ... Now, does also your font have the corresponding glyphs?","Q_Score":2,"Tags":"python,python-imaging-library,python-unicode","A_Id":13476705,"CreationDate":"2012-11-20T15:23:00.000","Title":"PIL: how to draw \u20ac on an image with draw.text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From main.py, I want to import a file from the backend folder\nWebAppName\/main.py\nWebAppName\/backend\/handlers.py\nHow do I specify this as an import statement\nI am aware that importing from the same folder is just import handlers\nBut this is a child directory, so how do I do this?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":134,"Q_Id":13478965,"Users Score":2,"Answer":"You need to have an __init__.py file in the backend folder for Python to consider it a package. Then you can do import backend.handlers or from backend.handlers import foo","Q_Score":0,"Tags":"python","A_Id":13479006,"CreationDate":"2012-11-20T17:44:00.000","Title":"How do I import from a child directory \/ subfolder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the applescript which will displays menu list and allow user to select menu items etc. \nIt runs fine by itself. And now I try to run it in python. I get the No user interaction allowed. (-1713) error. \nI looked online. I tried the following: \n\nadd on run function in the same applescript,  so what i did is just add the main into the run\non run \n tell application \u201cAppleScript Runner\u201d\n  main()\n end tell\nend run\ni tried to run the above in python \nimport os\ndef main():\n  os.system ('osascript -e \"tell application \"ApplesScript Runner\" do script \/Users\/eee\/applescript\/iTune.scpt end tell\"')\nif name == 'main':\n   main() \nNeither way works. Can anyone tell me how to do this correctly?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5247,"Q_Id":13484482,"Users Score":0,"Answer":"My issue was an app with LSBackgroundOnly = YES set attempting to run an AppleScript that displays UI, such as display dialog ...\n\nError Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\"\nAppleScript.scpt: execution error: No user interaction allowed. (-1713)\n\nUsing tell application \"Finder\" ... or etc. works, as shown in the other answer.\nOr, remove the LSBackgroundOnly key to enable UI AppleScripts without telling a different Application.\nLSUIElement presents a similar mode - no dock icon, no menu bar, etc. - but DOES allow UI AppleScripts to be launched.","Q_Score":5,"Tags":"python,applescript","A_Id":53218057,"CreationDate":"2012-11-21T00:23:00.000","Title":"\"No user interaction allowed\" When running AppleScript in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a processes from several servers that send data to my local port 2222 via udp every second.\nI want to read this data and write it to shared memory so there can be other processes to read the data from shared memory and do things to it.\nI've been reading about mmap and it seems I have to use a file... which I can't seem to understand why.\nI have an a.py that reads the data from the socket, but how can I write it to an shm?\nOnce once it's written, I need to write b.py, c.py, d.py, etc., to read the very same shm and do things to it.\nAny help or snippet of codes would greatly help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2659,"Q_Id":13487181,"Users Score":0,"Answer":"First, note that what you're trying to build will require more than just shared memory: it's all well if a.py writes to shared memory, but how will b.py know when the memory is ready and can be read from?  All in all, it is often simpler to solve this problem by connecting the multiple processes not via shared memory, but through some other mechanism.\n(The reason for why mmap usually needs a file name is that it needs a name to connect the several processes.  Indeed, if a.py and b.py both call mmap(), how would the system know that these two processes are asking for memory to be shared between them, and not some unrelated z.py?  Because they both mmaped the same file.  There are also Linux-specific extensions to give a name that doesn't correspond to a file name, but it's more a hack IMHO.)\nMaybe the most basic alternative mechanism is pipes: they are usually connected with the help of the shell when the programs are started.  That's how the following works (on Linux\/Unix): python a.py | python b.py.  Any output that a.py sends goes to the pipe, whose other end is the input for b.py.  You'd write a.py so that it listens to the UDP socket and writes the data to stdout, and b.py so that it reads from stdin to process the data received.  If the data needs to go to several processes, you can use e.g. named pipes, which have a nice (but Bash-specific) syntax: python a.py >(python b.py) >(python c.py) will start a.py with two arguments, which are names of pseudo-files that can be opened and written to.  Whatever is written to the first pseudo-file goes as input for b.py, and similarly what is written to the second pseudo-file goes as input for c.py.","Q_Score":2,"Tags":"python,sockets,shared-memory","A_Id":13500968,"CreationDate":"2012-11-21T05:51:00.000","Title":"how to write to shared memory in python from stream?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a processes from several servers that send data to my local port 2222 via udp every second.\nI want to read this data and write it to shared memory so there can be other processes to read the data from shared memory and do things to it.\nI've been reading about mmap and it seems I have to use a file... which I can't seem to understand why.\nI have an a.py that reads the data from the socket, but how can I write it to an shm?\nOnce once it's written, I need to write b.py, c.py, d.py, etc., to read the very same shm and do things to it.\nAny help or snippet of codes would greatly help.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2659,"Q_Id":13487181,"Users Score":0,"Answer":"mmap doesn't take a file name but rather a file descriptor. It performs the so-called memory mapping, i.e. it associates pages in the virtual memory space of the process with portions of the file-like object, represented by the file descriptor. This is a very powerful operation since it allows you:\n\nto access the content of a file simply as an array in memory;\nto access the memory of special I\/O hardware, e.g. the buffers of a sound card or the framebuffer of a graphics adapter (this is possible since file desciptors in Unix are abstractions and they can also refer to device nodes instead of regular files);\nto share memory between processes by performing shared maps of the same object.\n\nThe old pre-POSIX way to use shared memory on Unix was to use the System V IPC shared memory. First a shared memory segment had to be created with shmget(2) and then attached to the process with shmat(2). SysV shared memory segments (as well as other IPC objects) have no names but rather numeric IDs, so the special hash function ftok(3) is provided, which converts the combination of a pathname string and a project ID integer into a numeric key ID, but collisions are possible.\nThe modern POSIX way to use shared memory is to open a file-like memory object with shm_open(2), resize it to the desired size with ftruncate(2) and then to mmap(2) it. Memory-mapping in this case acts like the shmat(2) call from the SysV IPC API and truncation is necessary since shm_open(2) creates objects with an initial size of zero.\n(these are part of the C API; what Python modules provide is more or less thin wrappers around those calls and often have nearly the same signature)\nIt is also possible to get shared memory by memory mapping the same regular file in all processes that need to share memory. As a matter of fact, Linux implements the POSIX shared memory operations by creating files on a special tmpfs file system. The tmpfs driver implements very lightweight memory mapping by directly mapping the pages that hold the file content into the address space of the process that executes mmap(2). Since tmpfs behaves as a normal filesystem, you can examine its content using ls, cat and other shell tools. You can even create shared memory objects this way or modify the content of the existent ones. The difference between a file in tmpfs and a regular filesystem file is that the latter is persisted to storage media (hard disk, network storage, flash drive, etc.) and occasionally changes are flushed to this storage media while the former lives entirely in RAM. Solaris also provides similar RAM-based filesystem, also called tmpfs.\nIn modern operating systems memory mapping is used extensively. Executable files are memory-mapped in order to supply the content of those pages, that hold the executable code and the static data. Also shared libraries are memory-mapped. This saves physical memory since these mappings are shared, e.g. the same physical memory that holds the content of an executable file or a shared library is mapped in the virtual memory space of each process.","Q_Score":2,"Tags":"python,sockets,shared-memory","A_Id":13513533,"CreationDate":"2012-11-21T05:51:00.000","Title":"how to write to shared memory in python from stream?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some functions calling for user input, sometimes string, int or whatever. so i noticed that if ENTER is pressed with NO INPUT i get an error. SO i did some research and i think i found that EVAL function may be what I'm looking for, but then again i read about its dangers.\nSO here are my questions:\n\nHow can i check\/force user input? EX: repeating the input string or maybe even warning user that he didn't enter anything?\nhow do i check for the correct type of input (int, float, string, etc) against whatever the user types without having my scripts returning errors?\n\nI appreciate your feedback,\nCheers","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1011,"Q_Id":13503553,"Users Score":0,"Answer":"To answer your second part of the question you can use the isinstance() function in python to check if a variable is of a certain type.","Q_Score":1,"Tags":"types,input,python-3.x,eval","A_Id":13521828,"CreationDate":"2012-11-21T23:10:00.000","Title":"\"Force\" User Input and Checking for correct Input Type","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have Python 2.7.3 installed alongside Python 3.2.3 on an Ubuntu system.\nI've installed urllib3 using pip and can import it from the python shell. When I open the python3 shell, I get a can't find module error when trying to import urllib3. help('modules') from within the shell also doesn't list urllib3.\nAny ideas on how to get python3 to recognize urllib3?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4054,"Q_Id":13517991,"Users Score":3,"Answer":"You need to install it for each version of Python you have - if pip installs it for Python 2.7, it won't be accessible from 3.2.\nThere doesn't seem to be a pip-3.2 script, but you can try easy_install3 urllib3.","Q_Score":1,"Tags":"python-3.x,urllib3","A_Id":13520455,"CreationDate":"2012-11-22T18:02:00.000","Title":"Python3 can't find urllib3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm making a game using Python with PyGame module. I am trying to make an introduction screen for my game using a video that I made since it was easier to make a video than coding the animation for the intro screen.\nThe Pygame movie module does not work as stated on their site so I cannot use that. I tried using Pymedia but I have no idea how to even get a video running since their documentation weren't that helpful.\nDo you guys know any sample code that uses Pymedia to play a video? Or any code at all that loads a video using python. Or if there's any other video module out there that is simple, please let me know. I'm totally stumped.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1309,"Q_Id":13522975,"Users Score":2,"Answer":"I found a solution.\nThe latest version of Pygame is still able to play MPEG-1 files. The problem was that there are different encoding of MPEG-1.\nThe ones I found that works so far is Any Video Converter and Zamzar.com online converter. The downside to Zamzar is that it outputs really small version of the original video.\nvideo.online-convert.com does not work","Q_Score":0,"Tags":"python-2.7,pygame","A_Id":13537741,"CreationDate":"2012-11-23T04:10:00.000","Title":"Playing Video Files in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can someone give me a brief idea on how to transfer large files over the internet?\nI tried with sockets, but it does not work. I am not sure what the size of receiving sockets should be. I tried with 1024 bytes. I send the data from one end and keep receiving it at the other end.\nIs there any other way apart from sockets, I can use in Python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1410,"Q_Id":13523789,"Users Score":1,"Answer":"I encountered the same problem, and i solved it by chopping the file up and then sending the parts separately (load the file, send file[0:512], then send file[512:1024] and so on. Before sending the file i sent the length of the file to the receiver so the it would know when its done.\nI know this probably isn't the best way to do this, but i hope it will help you.","Q_Score":0,"Tags":"python,python-3.x","A_Id":13533315,"CreationDate":"2012-11-23T05:55:00.000","Title":"Transfer a Big File Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use python apt library and I would like that the commit() function doesn't produce any output.\nI've searched on the web and saw that the fork function can do the trick but I don't know how to do that or if there exists another way. I don't use any GUI, I work via the terminal.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":13542698,"Users Score":0,"Answer":"The use to fork is just a possibility I think. I've already try to redirect the sys.stdout even the sys.stderr : No Joy, it won't work.","Q_Score":3,"Tags":"python,apt","A_Id":13552981,"CreationDate":"2012-11-24T15:38:00.000","Title":"How to silence the commit function from the python apt library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I read few Boost.Python tutorials and I know how to call C++ function from Python. But what I want to do is create C++ application which will be running in the background all the time and Python script that will be able to call C++ function from that instance of C++ application. The C++ application will be a game server and it has to run all the time. I know I could use sockets\/shared memory etc. for this kind of communication but is it possible to make it with Boost.Python?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":426,"Q_Id":13553174,"Users Score":2,"Answer":"Boost python is useful for exposing C++ objects to python. \nSince you're talking about interacting with an already running application from python, and the lifetime of the script is shorter than the lifetime of the game server, I don't think boost python is what you're looking for, but rather some form of interprocess communication.\nWhilst you could create your IPC mechanism in C++, and then expose it to python using boost python, I doubt this is what you want to do.","Q_Score":1,"Tags":"c++,python,boost,boost-python","A_Id":13558179,"CreationDate":"2012-11-25T16:51:00.000","Title":"Boost.Python - communication with running C++ program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create an application that is capable of loading plugins. The twist is that I want to be able to create plugins in both C\/C++ and Python.\nSo I've started thinking about this and have a few questions that I'm hoping people can help me with.\nMy first question is whether I need to use C\/C++ for the \"core\" of the application (the part that actually does the loading of the plugins)? This is my feeling at least, I would think that implementing the core in Python would result in a nasty performance hit, but it would probably simplify loading the plugins dynamically.\nSecond question is how would I go about defining the plugin interface for C\/C++ on one hand and Python on the other? The plugin interface would be rather simple, just a single method that accepts a list of image as a parameter and returns a list of images as a return value. I will probably use the OpenCV image type within the plugins which exists for both C\/C++ and Python.\nFinally, I would like the application to dynamically discover plugins. So if you place either a .py file or a shared library file (.so\/.dll) in this directory, the application would be able to produce a list of available plugins at runtime.\nI found something in the Boost library called Boost.Extension (http:\/\/boost-extension.redshoelace.com\/docs\/boost\/extension\/index.html) but unfortunately it doesn't seem to be a part of the official Boost library and it also seems to be a bit stale now. On top of that, I don't know how well it would work with Python, that is, how easy it would be to create Python plugins that fit into this mechanism.\nAs a side note, I imagine the application split into two \"parts\". One part is a stripped down core (loading and invoking plugin instances from a \"recipe\"). The other part is the core plus a GUI that I plan on writing in Python (using PySide). This GUI will enable the user to define the aforementioned \"recipes\". This GUI part would require the core to be able to provide a list of available plugins.\nSorry for the long winded \"question\". I guess I'm hoping for more of a discussion and of course if anybody knows of something similar that would help me I would very much appreciate a pointer. I would also appreciate any concise and to the point reading material about something similar (such as integrating C\/C++ and Python etc).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":648,"Q_Id":13555278,"Users Score":1,"Answer":"Write your application in Python, then you can have a folder for your plugins. \nYour application searches for them by checking the directory\/traversing the plugin tree.\nThen import them via \"import\" or use ctypes for a .so\/.dll, or even easier: you can use boost::python for creating a .so\/.dll that you can 'import' like a normal python module.\nDon't use C++ and try to do scripting in Python - that really sucks, you will regret it. ;)","Q_Score":0,"Tags":"c++,python,c,plugins,shared-libraries","A_Id":13555348,"CreationDate":"2012-11-25T20:40:00.000","Title":"Application that can load both C\/C++ and Python plugins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a shared hosting environment on Bluehost. I am running a custom installation of python(+ django) with a few installed modules. All has been working, until yesterday a change was made on the server(I assume) which gave me this django error:\n\n... File \"\/****\/****\/.local\/lib\/python\/django\/utils\/importlib.py\", line 35, in import_module\n    __import__(name)\n\nFile \"\/****\/****\/.local\/lib\/python\/django\/db\/backends\/mysql\/base.py\", line 14, in \n    raise ImproperlyConfigured(\"Error loading MySQLdb module: %s\" % e)\n\nImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory\n\nOf course, Bluehost support is not too helpful. They advised that 1) I use the default python install, because that has MySQLdb installed already. Or that 2) I somehow import the MySQLdb package installed on the default python, from my python(dont know if this can even be done). I am concerned that if I use the default install I wont have permission to install my other packages.\nDoes anybody have any ideas how to get back to a working state, with as little infrastructure changes as possible?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2446,"Q_Id":13573359,"Users Score":2,"Answer":"I think you upgraded your OS installation which in turn upgraded libmysqlclient and broke native extension. What you can do is reinstall libmysqlclient16 again (how to do it depends your particular OS) and that should fix your issue.\nOther approach would be to uninstall MySQLdb module and reinstall it again, forcing python to compile it against a newer library.","Q_Score":2,"Tags":"python,linux,mysql-python,bluehost","A_Id":13573647,"CreationDate":"2012-11-26T21:20:00.000","Title":"Python module issue","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a shared hosting environment on Bluehost. I am running a custom installation of python(+ django) with a few installed modules. All has been working, until yesterday a change was made on the server(I assume) which gave me this django error:\n\n... File \"\/****\/****\/.local\/lib\/python\/django\/utils\/importlib.py\", line 35, in import_module\n    __import__(name)\n\nFile \"\/****\/****\/.local\/lib\/python\/django\/db\/backends\/mysql\/base.py\", line 14, in \n    raise ImproperlyConfigured(\"Error loading MySQLdb module: %s\" % e)\n\nImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory\n\nOf course, Bluehost support is not too helpful. They advised that 1) I use the default python install, because that has MySQLdb installed already. Or that 2) I somehow import the MySQLdb package installed on the default python, from my python(dont know if this can even be done). I am concerned that if I use the default install I wont have permission to install my other packages.\nDoes anybody have any ideas how to get back to a working state, with as little infrastructure changes as possible?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2446,"Q_Id":13573359,"Users Score":0,"Answer":"You were right. Bluehost upgraded MySQL. Here is what I did:\n1) remove the \"build\" directory in the \"MySQL-python-1.2.3\" directory\n2) remove the egg\n3) build the module again \"python setup.py build\"\n4) install the module again \"python setup.py install --prefix=$HOME\/.local\"\nMorale of the story for me is to remove the old stuff when reinstalling module","Q_Score":2,"Tags":"python,linux,mysql-python,bluehost","A_Id":13591200,"CreationDate":"2012-11-26T21:20:00.000","Title":"Python module issue","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Hi I am using Serial port communication to one of my device using python codes. It is sending a set of Hex code, Receives a set of data. process it.\nThis data has to be stored in to a database.\nI have another script that has MYSQLdb library pushing it in to the database.\nIf I do that in sequentially in one script i lose a lot in sampling rate. I can sample up to 32 data sets per second if I dont connect to a database and insert it in to the table.\nIf I use Multiprocessing and try to run it my sampling rate goes to 0.75, because the parent process is waiting for the child to join. so how can i handle this situation. \nIs it possible to run them independently by using a queue to fill data?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2531,"Q_Id":13585238,"Users Score":1,"Answer":"use a pipe.\nCeate two processes using the subprocess module, the first reads from the serial port and writes the set of hex codes to stdout. This is piped to the second process which reads from stdin and updates the database.","Q_Score":2,"Tags":"python,multiprocessing","A_Id":13585552,"CreationDate":"2012-11-27T13:25:00.000","Title":"Subprocess in Reading Serial Port Read","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My command prompt is currently running Python 3.2 by default how do I set it up to run Python 2.7 by default, I have changed the PATH variable to point towards Python 2.7, but that did not work.\n\nUPDATE:\nIt still does not work. :(\nStill running python3 - to be specific it runs python3 when I am trying to install flask - which is what I want to do.\nMore generally, when I simply type python into the command line, it does nothing.\nI get a 'python' is not recognized as an internal or external command, operable program, or batch file error.\nNo idea what to do.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":8222,"Q_Id":13593922,"Users Score":1,"Answer":"Changing your PATH environment variable should do the trick.  Some troubleshooting tips:\n\nMake sure you didn't just change the local, but rather the system variable to reflect the new location\nMake sure you restarted your CL window (aka close \"cmd\" or command prompt and reopen it).  This will refresh the system variables you just updated.\nMake sure you remove all references to C:\\Python32\\ or whatever the old path was (again, check local and system PATH - they are both found on the same environmental variables window).  \nCheck to see if Python3.2 is installed where you think it is... (just rename the directory to something like OLD_Python3.2 and go to your CLI and enter \"python\" - does it start up?  If it does is it 2.7? or 3.2?  If not, you did something wrong with your PATH variable.\nAll else fails - reboot and try again (you might have some persistent environment variable - which I don't see how that can be - but hey, we are brainstorming here! - and a reboot would give you a fresh start. \n\nIf that doesn't work then I'd think you are doing something else wrong (aka user error).  CMD has to know where to look for python before it can execute.  It knows this from your PATH variable... now granted, I work almost exclusively in 2.6\/2.7, so if they did something to the registry (which I doubt) then I wouldn't know about that.\nGood luck!","Q_Score":2,"Tags":"python,windows,command-prompt","A_Id":13594149,"CreationDate":"2012-11-27T22:00:00.000","Title":"Command Prompt: Set up for Python 2.7 by default","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I hope this doesn't cross into superuser territory.\nSo I have an embedded linux, where system processes are naturally quite stripped. I'm not quite sure which system process monitors to physical layer and starts a dhcp client when network cable is plugged in, but i made one myself. \n\u00a8\nThe problem is, that if i have a python script, using http connections, running before i have an IP address, it will never get a connection. Even after i have a valid IP, the python still has \n\"Temporary error in name resolution\"\nSo how can I get the python to realize the new connection available, without restarting the script? \nAlternatively , am I missing some normal procedure Linux runs normally at network cable connect.\nThe dhcp client I am using is udhcpc and python version is 2.6. Using httplib for connections.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":772,"Q_Id":13606584,"Users Score":0,"Answer":"After alot more research, the glibc problem jedwards suggested, seemed to be the problem. I did not find a solution, but made workaround for my usecase. \nConsidering I only use one URL, I added my own \"resolv.file\" . \nA small daemon gets the IP address of the URL when PHY reports cable connected. This IP is saved to \"my own resolv.conf\". From this file the python script retrieves the IP to use for posts.\nNot really a good solution, but a solution.","Q_Score":1,"Tags":"python,networking,httplib","A_Id":13643155,"CreationDate":"2012-11-28T13:47:00.000","Title":"Python not getting IP if cable connected after script has started","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am quite new to web development and am working on this social networking site. \nNow I want to add functionality to show if a person is online. \nNow one of the ways I figure out doing this is by keeping online status bit in the database.\nMy question is how to do it dynamically. Say the page is loaded and a user (say connection) comes online. How do I dynamically change status of that connection on that page. \nI wanted to know if there are any tools(libraries) available for this type of tracking. My site is in python using django framework. I think something can be done using javascript\/ jquery . I want to know if I am going in the right direction or is there anything  else I should look into?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":13609985,"Users Score":0,"Answer":"As Sanjay says, prefer using memory solutions (online statuses have a quite brief use) like the Django cache (Redis or Memcache).\nIf you want a simple way of updating the online status of an user on an already loaded web page, use any lib like jQuery, AJAX-poll an URL giving the status of an user, and then update the tiny bit of your page showing your wanted status.\nDon't poll this page too often, once every 15 seconds seems reasonable.","Q_Score":1,"Tags":"javascript,python,html,django,web-applications","A_Id":13610314,"CreationDate":"2012-11-28T16:38:00.000","Title":"Tracking online status?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite new to web development and am working on this social networking site. \nNow I want to add functionality to show if a person is online. \nNow one of the ways I figure out doing this is by keeping online status bit in the database.\nMy question is how to do it dynamically. Say the page is loaded and a user (say connection) comes online. How do I dynamically change status of that connection on that page. \nI wanted to know if there are any tools(libraries) available for this type of tracking. My site is in python using django framework. I think something can be done using javascript\/ jquery . I want to know if I am going in the right direction or is there anything  else I should look into?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":302,"Q_Id":13609985,"Users Score":1,"Answer":"Create a new model with a last_activity DateTimeField and a OneToOneField to User. Alternatively, if you are subclassing User, using a custom User in django 1.5, or using a user profile, just add the field to that model.\nWrite a custom middleware that automatically updates the last_activity field for each user on every request.\nWrite an is_online method in one of your models that uses a timedelta to determine a user's inactivity period to return a boolean for whether they are online. For example, if their last_activity was more than 15 minutes ago, return False.\nWrite a view that is polled through jQuery ajax to return a particular user's online status.","Q_Score":1,"Tags":"javascript,python,html,django,web-applications","A_Id":13610508,"CreationDate":"2012-11-28T16:38:00.000","Title":"Tracking online status?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having a little bit of trouble creating a haar classifier. I need to build up a classifier to detect cars. At the moment I made a program in python that reads in an image, I draw a rectangle around the area the object is in, Once the rectangle is drawn, it outputs the image name, the top left and bottom right coordinates of the rectangle. I am unsure of where to go from here and how to actually build up the classifier. Can anyone offer me any help?\nEDIT*\nI am looking for help on how to use the opencv_traincascade. I have looked at the documentation but I can't quite figure out how to use it to create the xml file to be used in the detection program.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1867,"Q_Id":13611126,"Users Score":1,"Answer":"This looks like you need to determine what features you would like to train your classifier on first, as using the haar classifier it benefits from those extra features. From there you will need to train the classifier, this requires you to get a lot of images that have cars and those that do not have cars in them and then run it over this and having it tweak the average it is shooting for in order to classify to the best it can with your selected features.\nTo get a better classifier you will have to figure out the order of your features and the optimal order you put them together to further dive into the object and determine if it is in fact what you are looking for. Again this will require a lot of examples for your particular features and your problem as a whole.","Q_Score":1,"Tags":"python,opencv,machine-learning,computer-vision,object-detection","A_Id":13612350,"CreationDate":"2012-11-28T17:38:00.000","Title":"Creating a haar classifier using opencv_traincascade","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"When I enter my virtual environment (source django_venv\/bin\/activate), how do I make that environment transfer to apps run outside the terminal, such as Eclipse or even Idle?  Even if I run Idle from the virtualenv terminal window command line (by typing idle), none of my pip installed frameworks are available within Idle, such as SQLAlchemy (which is found just fine when running a python script from within the virtual environment).","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2074,"Q_Id":13619088,"Users Score":2,"Answer":"Tell Eclipse or Idle that the python interpreter is django_venv\/bin\/python instead of \/usr\/bin\/python","Q_Score":3,"Tags":"python,virtualenv","A_Id":13619252,"CreationDate":"2012-11-29T04:55:00.000","Title":"Virtualenv and python - how to work outside the terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm making a room reservation system in Web2Py over Google App Engine. \nWhen a user is booking a Room the system must be sure that this room is really available and no one else have reserved it just a moment before. \nTo be sure I make a query to see if the room is available, then I make the reservation. The problem is how can I do this transaction in a kind of \"Mutual exclusion\" to be sure that this room is really for this user?\nThank you!! :)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":192,"Q_Id":13622895,"Users Score":1,"Answer":"Mutual exclusion is already built into DBMS so we just have to use that. Lets take an example.\nFirst, your table in the model should be defined in such a way that your room number should be unique (use UNIQUE constraint).\nWhen User1 and User2 both query for a room, they should get a response saying the room is vacant. When both the users send the \"BOOK\" request for that room at the same time, the booking function should directly insert the \"BOOK\" request of both users into the db. But only one will actually be executed (because of the UNIQUE constraint) and the other will produce a DAL exception. Catch the exception and respond to the user whose \"BOOK\" request was unsuccesful, saying You just missed this room by an instant :-)\nHope this helped.","Q_Score":0,"Tags":"python,google-app-engine,web2py","A_Id":13892159,"CreationDate":"2012-11-29T09:45:00.000","Title":"Transactions in Web2Py over Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a crawler that automates the login and crawling for a website, but since the login was changed it is not working anymore. \nI am wondering, can I feed the browser cookie (aka, I manually log-in) to my HTTP request? Is there anything particularly wrong in principle that wouldn't make this work? How do I find the browser cookies relevant for the website? \nIf it works, how do I get the \"raw\" cookie strings I can stick into my HTTP request?\nI am quite new to this area, so forgive my ignorant questions. I can use either PYthon or Java","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":925,"Q_Id":13628190,"Users Score":0,"Answer":"When you send the login information (and usually in response to many other requests) the server will set some cookies to the client, you must keep track of them and send them back to the server for each subsequent request.\nA full implementation would also keep track of the time they are supposed to be stored.","Q_Score":0,"Tags":"java,python,cookies,http-headers,httpwebrequest","A_Id":13628291,"CreationDate":"2012-11-29T14:42:00.000","Title":"How to use browser cookies programmatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that using \ngetpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python  to find the username and then implement it in the following script itself.\nScript: os.path.join('..','Documents and Settings','USERNAME','Desktop'))\n(Python Version 2.7 being used)","AnswerCount":10,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":107727,"Q_Id":13654122,"Users Score":2,"Answer":"you can try the following as well:\n\nimport os\nprint (os.environ['USERPROFILE'])\n\nThe advantage of this is that you directly get an output like:\nC:\\\\Users\\\\user_name","Q_Score":39,"Tags":"python","A_Id":62995730,"CreationDate":"2012-11-30T22:29:00.000","Title":"How to make Python get the username in windows and then implement it in a script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that using \ngetpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python  to find the username and then implement it in the following script itself.\nScript: os.path.join('..','Documents and Settings','USERNAME','Desktop'))\n(Python Version 2.7 being used)","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":107727,"Q_Id":13654122,"Users Score":46,"Answer":"os.getlogin() did not exist for me.  I had success with os.getenv('username') however.","Q_Score":39,"Tags":"python","A_Id":29154027,"CreationDate":"2012-11-30T22:29:00.000","Title":"How to make Python get the username in windows and then implement it in a script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that using \ngetpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python  to find the username and then implement it in the following script itself.\nScript: os.path.join('..','Documents and Settings','USERNAME','Desktop'))\n(Python Version 2.7 being used)","AnswerCount":10,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":107727,"Q_Id":13654122,"Users Score":72,"Answer":"os.getlogin() return the user that is executing the, so it can be:\npath = os.path.join('..','Documents and Settings',os.getlogin(),'Desktop')\nor, using getpass.getuser()\npath = os.path.join('..','Documents and Settings',getpass.getuser(),'Desktop')\nIf I understand what you asked.","Q_Score":39,"Tags":"python","A_Id":13654236,"CreationDate":"2012-11-30T22:29:00.000","Title":"How to make Python get the username in windows and then implement it in a script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a document based application in wxPython, by which I mean that the user can have open multiple documents at once in multiple windows or tabs. There are multiple kinds of documents, and the documents can all be in different \"states\", meaning that there should be different menu options available in the main menu.\nI know how to disable and enable menu items using the wx.EVT_UPDATE_UI event, but I can't figure out how to pull off a main menu that changes structure and content drastically based on which document that currently has focus. One of my main issues is that the main menu is created in the top level window, and it has to invoke methods in grand children and great grand children that haven't even been created yet.\n\nContrived example; when a document of type \"JPEG\" is open, the main menu should look like:\nFile      Edit      Compression     Help\nAnd when the user switches focus (CTRL+Tab) to a document of type \"PDF\", the main menu should change to:\nFile      Edit      PDF     Publish     Help\nAnd the \"Edit\" menu should contain some different options from when the \"JPEG\" document was in focus.\n\nCurrent I'm just creating the menu in a function called create_main_menu in the top level window, and the document panels have no control over it. What would be necessary to pull off the kind of main menu scheme I describe above, specifically in wxPython?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2119,"Q_Id":13655152,"Users Score":0,"Answer":"Probably the only way to do it with the standard wx.Menu is to destroy and recreate the entire menubar. You might be able to Hide it though. Either way, I think it would be easiest to just put together a set of methods that creates each menubar on demand. Then you can destroy one and create the other.\nYou might also take a look at FlatMenu since it is pure Python and easier to hack.","Q_Score":1,"Tags":"python,wxpython","A_Id":13687868,"CreationDate":"2012-12-01T00:34:00.000","Title":"How do I manage a dynamic, changing main menu in wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a website that allows players to queue to find similarly skilled players for a multiplayer video game. Simple web backends only modify a database and create a response using a template, but in addition to that, my backend has to:\n\nCommunicate with players in real-time (via gevent-socketio) while they queue or play\nRun calculations in the background to find balanced games, slowly compromising game quality as waiting time grows (and inform players via SocketIO when a game has been found)\nMonitor in progress games via a UDP socket (and if a player disconnects, ask the queue for a substitute) and eventually update the database with the results\n\nI know how I would do these things individually, but I'm wondering how I should separate these components and let them communicate. I imagine that my web framework (Flask) shouldn't be very involved at all in these other things.\nSince I already must use gevent, I'm currently planning to start separate greenlets for each of these tasks. This will work for all my tasks (with the possible exception of the calculations) because they will usually be waiting for something to happen. However, this won't scale at all because I can't run more Flask instances. Everything would be dependent on the greenlets running in just a single thread.\nSo is this the best way? Is there another way to handle separating these tasks (especially with languages I might use in the future that don't have coroutines)? I've heard of RabbitMQ\/ZeroMQ and Celery and other such tools, but I wasn't sure how and whether to use them to solve this problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":183,"Q_Id":13656736,"Users Score":1,"Answer":"My first thought is that you could use a service oriented architecture to separate these tasks.  Each of these services could run a Flask app on a separate port (or machine (or pool of machines)) and communicate to each other using simple HTTP.  The breakdown might go something like this:\n\nGameService: Handles incoming connections from players and communicates with them through socketio.\nGameFinderService: Accepts POST requests from GameService to start looking for games for player X.  Accepts GET requests from GameService to get the next best game for playerX.  You could use Redis as a backing store for this short-lived queue of games per connected player that gets updated each time GameStatusService (below) notifies us of a change.\nGameStatusService: Monitors in-progress games via UDP and when a notable event occurs e.g. new game created, player disconnects, etc it notifies GameFinderService of the change.  GameFinderService would then update its queues appropriately for each connected player.\n\nRedis is really nice because it serves as a data structure store that allows you to maintain both short and long lived data structures such as queues without too much overhead.","Q_Score":2,"Tags":"python,architecture,rabbitmq,web-frameworks,gevent","A_Id":13775086,"CreationDate":"2012-12-01T05:34:00.000","Title":"When a web backend does more than simply reply to requests, how should my application be structured?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm developing a Python-application that \"talks\" to the user, and performs tasks based on what the user says(e.g. User:\"Do I have any new facebook-messages?\", answer:\"Yes, you have 2 new messages. Would you like to see them?\"). Functionality like integration with facebook or twitter is provided by plugins. Based on predefined parsing rules, my application calls the plugin with the parsed arguments, and uses it's response. The application needs to be able to answer multiple query's from different users at the same time(or practically the same time).\nCurrently, I need to call a function, \"Respond\", with the user input as argument. This has some disadvantages, however:\ni)The application can only \"speak when it is spoken to\". It can't decide to query facebook for new messages, and tell the user whether it does, without being told to do that.\nii)Having a conversation with multiple users at a time is very hard, because the application can only do one thing at a time: if Alice asks the application to check her Facebook for new messages, Bob can't communicate with the application.\niii)I can't develop(and use) plugins that take a lot of time to complete, e.g. download a movie, because the application isn't able to do anything whilesame the previous task isn't completed.\nMultithreading seems like the obvious way to go, here, but I'm worried that creating and using 500 threads at a time dramatically impacts performance, so using one thread per query(a query is a statement from the user) doesn' seem like the right option.\nWhat would be the right way to do this? I've read a bit about Twisted, and the \"reactor\" approach seems quite elegant. However, I'm not sure how to implement something like that in my application.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":190,"Q_Id":13662400,"Users Score":0,"Answer":"i didn't really understand what sort of application its going to be, but i tried to anwser your questions\n\ncreate a thread that query's, and then sleeps for a while\ncreate a thread for each user, and close it when the user is gone\ncreate a thread that download's and stops\n\nafter all, there ain't going to be 500 threads.","Q_Score":0,"Tags":"python,multithreading,asynchronous","A_Id":13663583,"CreationDate":"2012-12-01T18:30:00.000","Title":"Multithreading or how to avoid blocking in a Python-application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a tic tac toe A.I. Given each board state, my A.I. will return 1 exact place to move. (Even if moves are equally correct, it chooses same one every time, it does not pick a random one)\nI also made a function that loops though all possible plays made with the A.I.\nSo it's a recursive function that lets the A.I. make a move for a given board, then lets the other play make all possible moves and calls the recursive function in it self with a new board for each possible move.\nI do this for when the A.I goes first, and when the other one goes first... and add these together. I end up with 418 possible wins and 115 possible ties, and 0 possible loses.\nBut now my problem is, how do I maximize the amount of wins? I need to compare this statistic to something, but I can't figure out what to compare it to.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1040,"Q_Id":13664861,"Users Score":0,"Answer":"You could actually brute force the game, and prove that every time there is a winning strategy, your A.I. picks the correct move. Then, you could prove that for every position, your A.I. picks the move which maximizes the chances of having a winning strategy, assuming the other player is playing randomly. There are not that many possibilities, so you should be able to eliminate all of them.\nYou could also significantly diminish the space of possibilities by assuming the other player is actually slightly intelligent, e.g. always tries to block a move which results in immediate victory.","Q_Score":2,"Tags":"python,recursion,artificial-intelligence,greedy","A_Id":13665044,"CreationDate":"2012-12-01T23:34:00.000","Title":"How can I test if my Tic Tac Toe A.I. is perfect?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a tic tac toe A.I. Given each board state, my A.I. will return 1 exact place to move. (Even if moves are equally correct, it chooses same one every time, it does not pick a random one)\nI also made a function that loops though all possible plays made with the A.I.\nSo it's a recursive function that lets the A.I. make a move for a given board, then lets the other play make all possible moves and calls the recursive function in it self with a new board for each possible move.\nI do this for when the A.I goes first, and when the other one goes first... and add these together. I end up with 418 possible wins and 115 possible ties, and 0 possible loses.\nBut now my problem is, how do I maximize the amount of wins? I need to compare this statistic to something, but I can't figure out what to compare it to.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1040,"Q_Id":13664861,"Users Score":0,"Answer":"One issue with akaRem's answer is that an optimal player shouldn't look like the overall distribution. For example, a player that I just wrote wins about 90% of the time against someone playing randomly and ties 10% of the time. You should only expect akaRem's statistics to match if you have two players against each other playing randomly. Two optimal players would always result in a tie.","Q_Score":2,"Tags":"python,recursion,artificial-intelligence,greedy","A_Id":18435798,"CreationDate":"2012-12-01T23:34:00.000","Title":"How can I test if my Tic Tac Toe A.I. is perfect?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a python newbie - I want to use the pymongo library to access mongoDb using some convenient IDE, and after looking through the web i decided to use WING. \nCan some one point how to add the pymongo library to the WING ide (or to any other IDE for that matter)? i want to get the auto-completion for commands.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":666,"Q_Id":13667690,"Users Score":0,"Answer":"If you are in windows platform just install the pymongo.exe file and it will install in python directory. Then you will be able to access it in any IDE such PyCharm by typing:  \nimport pymongo","Q_Score":0,"Tags":"python,ide,pymongo","A_Id":32381638,"CreationDate":"2012-12-02T08:33:00.000","Title":"Adding PyMongo to Python IDE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm familiar with LAMP systems and have been programming mostly in PHP for the past 4 years. I'm learning Python and playing around with Nginx a little bit.\nWe're working on a project website which will handle a lot of http handle requests, stream videos(mostly from a provider like youtube or vimeo). My colleague has experience with OpenBSD and has insisted that we use it as an alternative to linux.\n\nThe reason that we want to use OpenBSD is that it's well known for\nit's security.\nThe reason we chose Python is that it's fast.\nThe reason we want to use Nginx is that it's known to be able to\nhandle more http request when compared to Apache.\nThe reason we want to use NoSQL is that MySQL is known to have\nproblems in scalability when the databases grows.\n\nWe want the web pages to load as fast as possible (caching and cdn's will be used) using the minimum amount of hardware possible. That's why we want to use ONPN (OpenBSD,Nginx,Python,Nosql) instead of the traditional LAMP (Linux,Apache,Mysql,PHP).\nWe're not a very big company so we're using opensource technologies. Any suggestion is appreciated on how to use these software as a platform and giving hardware suggestions is also appreciated. Any criticism is also welcomed.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1447,"Q_Id":13675440,"Users Score":4,"Answer":"My advice - if you don't know how to use these technologies - don't do it. Few servers will cost you less than the time spent mastering technologies you don't know. If you want to try them out - do it. One by one, not everything at once. There is no magic solution on how to use them.","Q_Score":1,"Tags":"python,nginx,nosql,openbsd","A_Id":13675611,"CreationDate":"2012-12-03T00:05:00.000","Title":"How to utilize OpenBSD, Nginx, Python and NoSQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm familiar with LAMP systems and have been programming mostly in PHP for the past 4 years. I'm learning Python and playing around with Nginx a little bit.\nWe're working on a project website which will handle a lot of http handle requests, stream videos(mostly from a provider like youtube or vimeo). My colleague has experience with OpenBSD and has insisted that we use it as an alternative to linux.\n\nThe reason that we want to use OpenBSD is that it's well known for\nit's security.\nThe reason we chose Python is that it's fast.\nThe reason we want to use Nginx is that it's known to be able to\nhandle more http request when compared to Apache.\nThe reason we want to use NoSQL is that MySQL is known to have\nproblems in scalability when the databases grows.\n\nWe want the web pages to load as fast as possible (caching and cdn's will be used) using the minimum amount of hardware possible. That's why we want to use ONPN (OpenBSD,Nginx,Python,Nosql) instead of the traditional LAMP (Linux,Apache,Mysql,PHP).\nWe're not a very big company so we're using opensource technologies. Any suggestion is appreciated on how to use these software as a platform and giving hardware suggestions is also appreciated. Any criticism is also welcomed.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1447,"Q_Id":13675440,"Users Score":1,"Answer":"I agree with wdev, the time it takes to learn this is not worth the money you will save. First of all, MySQL databases are not hard to scale. WordPress utilizes MySQL databases, and some of the world's largest websites use MySQL (google for a list). I can also say the same of linux and PHP. \nIf you design your site using best practices (CSS sprites) Apache versus Nginx will not make a considerable difference in load times if you utilize a CDN and best practices (caching, gzip, etc).\nI strongly urge you to reconsider your decisions. They seem very ill-advised.","Q_Score":1,"Tags":"python,nginx,nosql,openbsd","A_Id":13676002,"CreationDate":"2012-12-03T00:05:00.000","Title":"How to utilize OpenBSD, Nginx, Python and NoSQL","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I cannot get my code to run on my win8 laptop. I am working with a combination of:\n\nStackless Python 2.7.2\nQt 4.8.4\nPySide 1.1.2\nEclipse\/Pydev and WingIDE\n\nThis works well on my Win7 PC, but now i have bought a demo laptop with windows 8. As far as I know all is installed the same way as on my PC.\nWhen i run my program (same code) now, i get  a warning:\n\"Qt: Untested Windows version 6.2 detected!\"\nOk, so that could be the source of my problem, but also i get errors:\n\nsome times the program just quits after the warning above (i think only eclipse)\nsometimes i get an APPCRASH (i think only eclipse)\nsometimes i get the exception: TypeError: Error when calling the metaclass bases: mro() returned base with unsuitable layout ('')\nsometimes i get the exception: TypeError: Error when calling the metaclass bases: multiple bases have instance lay-out conflict\n\nEspecially the last two don't seem like a windows problem, but i don't see any other difference with my PC win7 install. Does anyone have any idea what is going on or how to fix this? Did i miss a step in the installation or is it some incompatibility maybe?\nCheers, Lars\nDoes anyone have some input on this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2146,"Q_Id":13702106,"Users Score":1,"Answer":"I had the same problem with Pyside 1.1.2 and Qt 4.8.4. The solution for me was to set the compatibility mode of the Python executable to Windows 7 via right click on the executable -> Properties -> Compatiblity -> Run this program in compatibility mode for: Windows 7\nHope that helps.","Q_Score":2,"Tags":"python,qt,windows-8,pyside,stackless","A_Id":16126325,"CreationDate":"2012-12-04T11:42:00.000","Title":"windows 8 incompatibility?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I cannot get my code to run on my win8 laptop. I am working with a combination of:\n\nStackless Python 2.7.2\nQt 4.8.4\nPySide 1.1.2\nEclipse\/Pydev and WingIDE\n\nThis works well on my Win7 PC, but now i have bought a demo laptop with windows 8. As far as I know all is installed the same way as on my PC.\nWhen i run my program (same code) now, i get  a warning:\n\"Qt: Untested Windows version 6.2 detected!\"\nOk, so that could be the source of my problem, but also i get errors:\n\nsome times the program just quits after the warning above (i think only eclipse)\nsometimes i get an APPCRASH (i think only eclipse)\nsometimes i get the exception: TypeError: Error when calling the metaclass bases: mro() returned base with unsuitable layout ('')\nsometimes i get the exception: TypeError: Error when calling the metaclass bases: multiple bases have instance lay-out conflict\n\nEspecially the last two don't seem like a windows problem, but i don't see any other difference with my PC win7 install. Does anyone have any idea what is going on or how to fix this? Did i miss a step in the installation or is it some incompatibility maybe?\nCheers, Lars\nDoes anyone have some input on this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2146,"Q_Id":13702106,"Users Score":0,"Answer":"try using Hyper-V however Hyper-V is not installed by default in Windows 8. You need to go \"Turn Windows features on or off.\"","Q_Score":2,"Tags":"python,qt,windows-8,pyside,stackless","A_Id":13881726,"CreationDate":"2012-12-04T11:42:00.000","Title":"windows 8 incompatibility?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I try to save a python script as a shortcut that I want to run. It opens it but then closes right away.\nI know why it is doing this, it is opening my windows command line in python3.2 the script is in python 2.7\nI need both version on my PC, my question is how to I change the cmd default.\nI have tried to \"open with\" shortcut on the icon and it just continues to default to 3.2.\nHelp please","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":538,"Q_Id":13711765,"Users Score":0,"Answer":"Install both pythons, and change the path in Windows, by default both Pythons will be PATH=c:\\python\\python 2.7 and PATH=c:\\python\\python 3.2 Or something like that. What and since windows stops as soon as it finds the first python, what you could do is have one called PATH=c:\\python27\\ and another PATH=c:\\python32\\ this way you can run both of them.","Q_Score":1,"Tags":"python","A_Id":13711840,"CreationDate":"2012-12-04T20:56:00.000","Title":"changing python windows command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've always have trouble with dynamic language like Python.\nSeveral troubles:\n\nTypo error, I can use pylint to reduce some of these errors. But there's still some errors that pylint can not figure out.\nObject type error, I often forgot what type of the parameter is, int? str? some object? Also, forgot the type of some object in my code.\n\nUnit test might help me sometimes, but I'm not always have enough time to do UT. When I need a script to do a small job, the line of code are 100 - 200 lines, not big, but I don't have time to do the unit test, because I need to use the script as soon as possible. So, many errors appear.\nSo, any idea on how to reduce the number of these troubles?","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":166,"Q_Id":13722760,"Users Score":4,"Answer":"Unit testing is the best way to handle this. If you think the testing is taking too much time, ask yourself how much time you are loosing on defects - identifying, diagnosing and rectifying - after you have released the code.\nIn effect, you are testing in production, and there's plenty of evidence to show that defects found later in the development cycle can be orders of magnitude more expensive to fix.","Q_Score":0,"Tags":"python","A_Id":13722800,"CreationDate":"2012-12-05T11:57:00.000","Title":"How to reduce errors in dynamic language such as python, and improve my code quality\uff1f","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use Z3 from its python interface, but I would prefer not to do a system-wide install (i.e. sudo make install). I tried doing a local install with a --prefix, but the Makefile is hard-coded to install into the system's python directory. \nBest case, I would like run z3 directly from the build directly, in the same way I use the z3 binary (build\/z3). Does anyone know how to, or have script, to run the z3py directly from the build directory, without doing an install?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":540,"Q_Id":13728325,"Users Score":1,"Answer":"Yes, you can do it by including the build directory in your LD_LIBRARY_PATH and PYTHONPATH environment variables.","Q_Score":2,"Tags":"python,z3","A_Id":13730652,"CreationDate":"2012-12-05T16:54:00.000","Title":"Can I use Z3Py withouth doing a system-wide install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just starting out with Python. And I need help understanding how to do the main loop of my program.\nI have a source file with two columns of data, temperature & time. This file gets updated every 60 seconds by a bash script.\nI successfully wrote these three separate programs;\n1. A program that can read the last 1440 lines of the source data and plot out a day graph.\n2. A program that can read the last 10080 lines of the source data and plot out a week graph.\n3. A program that can read the source data and just display the last recorded temperature.\n4. Check the size of the source file and delete data over X days old.\nI want to put it all together so that a user can toggle between the 3 different display types. I understand that this would work in a main loop, with just have the input checked in the loop, and call a function based on what is returned.\nBut I don't know how to handle the file size check. I don't want it checked every time the loops cycles.  I would like it to be run once a day.\nthanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":70,"Q_Id":13736310,"Users Score":1,"Answer":"The simplest solution is to add a variable outside of the loop which stores the last time the data size was checked.  Every time through your loop you can compare the current time vs the last time every time through the loop and check if more than X time has elapsed.","Q_Score":0,"Tags":"python,loops","A_Id":13736441,"CreationDate":"2012-12-06T03:07:00.000","Title":"Understanding an element of the main loop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Summary: is there a race condition in Django sessions, and how do I prevent it?\nI have an interesting problem with Django sessions which I think involves a race condition due to simultaneous requests by the same user.\nIt has occured in a script for uploading several files at the same time, being tested on localhost. I think this makes simultaneous requests from the same user quite likely (low response times due to localhost, long requests due to file uploads). It's still possible for normal requests outside localhost though, just less likely.\nI am sending several (file post) requests that I think do this:\n\nDjango automatically retrieves the user's session*\nUnrelated code that takes some time\nGet request.session['files'] (a dictionary)\nAppend data about the current file to the dictionary\nStore the dictionary in request.session['files'] again\nCheck that it has indeed been stored\nMore unrelated code that takes time\nDjango automatically stores the user's session\n\nHere the check at 6. will indicate that the information has indeed been stored in the session. However, future requests indicate that sometimes it has, sometimes it has not.\nWhat I think is happening is that two of these requests (A and B) happen simultaneously. Request A retrieves request.session['files'] first, then B does the same, changes it and stores it. When A finally finishes, it overwrites the session changes by B.\nTwo questions:\n\nIs this indeed what is happening? Is the django development server multithreaded? On Google I'm finding pages about making it multithreaded, suggesting that by default it is not? Otherwise, what could be the problem?\nIf this race condition is the problem, what would be the best way to solve it? It's an inconvenience but not a security concern, so I'd already be happy if the chance can be decreased significantly.\n\nRetrieving the session data right before the changes and saving it right after should decrease the chance significantly I think. However I have not found a way to do this for the request.session, only working around it using django.contrib.sessions.backends.db.SessionStore. However I figure that if I change it that way, Django will just overwrite it with request.session at the end of the request. \nSo I need a request.session.reload() and request.session.commit(), basically.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1895,"Q_Id":13748166,"Users Score":7,"Answer":"Yes, it is possible for a request to start before another has finished. You can check this by printing something at the start and end of a view and launch a bunch of request at the same time.\nIndeed the session is loaded before the view and saved after the view. You can reload the session using request.session = engine.SessionStore(session_key) and save it using request.session.save().\n\nReloading the session however does discard any data added to the session before that (in the view or before it). Saving before reloading would destroy the point of loading late. A better way would be to save the files to the database as a new model.\nThe essence of the answer is in the discussion of Thomas' answer, which was incomplete so I've posted the complete answer.","Q_Score":8,"Tags":"python,django,multithreading,session,race-condition","A_Id":13924932,"CreationDate":"2012-12-06T16:33:00.000","Title":"Django session race condition?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I am trying to create a realtime plot of data that is being recorded to a SQL server.  The format is as follows:\nDatabase: testDB\nTable: sensors\nFirst record contains 3 records.  The first column is an auto incremented ID starting at 1.  The second column is the time in epoch format.  The third column is my sensor data.  It is in the following format:\n23432.32 112343.3 53454.322 34563.32 76653.44 000.000 333.2123\nI am completely lost on how to complete this project.  I have read many pages showing examples dont really understand them.  They provide source code, but I am not sure where that code goes.  I installed httpd on my server and that is where I stand.  Does anyone know of a good how-to from beginning to end that I could follow?  Or could someone post a good step by step for me to follow?\nThanks for your help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":428,"Q_Id":13772857,"Users Score":0,"Answer":"Install a httpd server\nInstall php\nWrite a php script to fetch the data from the database and render it\nas a webpage.\n\nThis is fairly elaborate request, with relatively little details given.  More information will allow us to give better answers.","Q_Score":0,"Tags":"python,mysql,flot","A_Id":13774224,"CreationDate":"2012-12-07T23:52:00.000","Title":"Plotting data using Flot and MySQL","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a directory with thousands of files and each of them has to be processed (by a python script) and subsequently deleted. \nI would like to write a bash script that reads a file in the folder, processes it, deletes it and moves onto another file - the order is not important. There will be n running instances of this bash script (e.g. 10), all operating on the same directory. They quit when there are no more files left in the directory. \nI think this creates a race condition. Could you give me an advice (or a code snippet) how to make sure that no two bash scripts operate on the same file? \nOr do you think I should rather implement multithreading in Python (instead of running n different bash scripts)?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1245,"Q_Id":13776973,"Users Score":1,"Answer":"The only sure way that no two scripts will act on the same file at the same time is to employ some kind of file locking mechanism. A simple way to do this could be to rename the file before beginning work, by appending some known string to the file name. The work is then done and the file deleted. Each script tests the file name before doing anything, and moves on if it is 'special'.\nA more complex approach would be to maintain a temporary file containing the names of files that are 'in process'. This file would obviously need to be removed once everything is finished.","Q_Score":1,"Tags":"python,bash,shell,race-condition","A_Id":13777096,"CreationDate":"2012-12-08T11:20:00.000","Title":"Multiple processes reading&deleting files in the same directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Newb quesion about Django app design:\nIm building reporting engine for my web-site. And I have a big (and getting bigger with time) amounts of data, and some algorithm which must be applied to it. Calculations promise to be heavy on resources, and it would be stupid if they are performed by requests of users. So, I think to put them into background process, which would be executed continuously and from time to time return results, which could be feed to Django views-routine for producing html output by demand.\nAnd my question is - what proper design approach for building such system? Any thoughts?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2371,"Q_Id":13780732,"Users Score":0,"Answer":"Why don't you have a url or python script that triggers whatever sort of calculation you need to have done everytime it's run and then fetch that url or run that script via a cronjob on the server? From what your question was it doesn't seem like you need a whole lot more than that.","Q_Score":4,"Tags":"python,django,background-process,backend","A_Id":13783426,"CreationDate":"2012-12-08T18:52:00.000","Title":"Django - how to set up asynchronous longtime background data processing task?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have this list called sumErrors that's 16000 rows and 1 column, and this list is already presorted into 5 different clusters. And what I'm doing is slicing the list for each cluster and finding the index of the minimum value in each slice.\nHowever, I can only find the first minimum index using argmin(). I don't think I can just delete the value, because otherwise it would shift the slices over and the indices is what I have to recover the original ID. Does anyone know how to get argmin() to spit out indices for the lowest three?\nOr perhaps a more optimal method? Maybe I should just assign ID numbers, but I feel like there maybe a more elegant method.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":11034,"Q_Id":13783071,"Users Score":4,"Answer":"numpy.argpartition(cluster, 3) would be much more effective.","Q_Score":14,"Tags":"python,list,numpy,min","A_Id":37094880,"CreationDate":"2012-12-08T23:33:00.000","Title":"Finding the indices of the top three values via argmin() or min() in python\/numpy without mutation of list?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to find out how to write Python code which sets up a process to run on startup, in this case level two.\nI have done some reading, yet it has left me unclear as to which method is most reliable on different systems. I originally thought I would just edit \/etc\/inittab with pythons fileIO, but then I found out that my computers inittab was empty.\nWhat should I do? Which method of setting something to startup on boot is most reliable? Does anyone have any code snippets lying around?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":13784459,"Users Score":0,"Answer":"I may as well answer my own question with my findings.\nOn Debian,Ubuntu,CentOS systems there is a file named \/etc\/rc.local. If you use pythons' FileIO to edit that file, you can put a command that will be run at the end of all the multi-user boot levels. This facility is still present on systems that use upstart.\nOn BSD I have no idea. If you know how to make something go on startup please comment to improve this answer.\nArchlinux and Fedora use systemd to start daemons - see the Arch wiki page for systemd. Basically you need to create a systemd service and symlink it. (Thanks Emil Ivanov)","Q_Score":0,"Tags":"python,linux,startup,runlevel","A_Id":13876262,"CreationDate":"2012-12-09T03:52:00.000","Title":"Programmatically setting a process to execute at startup (runlevel 2)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to make a simple script to push a movie to a Smart TV.\nI have already install miniupnp or ushare, but I don't want to go in a folder by the TV Smart Apps, i want to push the movie to the TV, to win time and in future why not make the same directly from a NAS.\nCan anyone have an idea how to do this ? This application SofaPlay make it great but only from my mac.\nThanks you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3338,"Q_Id":13798520,"Users Score":3,"Answer":"You will still need a DLNA server to host your videos on. Via UPnP you only hand the URL to the TV, not the video directly. Once you have it hosted on a DLNA server, you can find out the URL to a video by playing it in Windows Media Player (which has DLNA-support) or by using UPnP Inspector (which I recommend anyways, if you are going to be working with UPnP). You can then push this URL to the TV, which will download and play the video, if its format is supported.\nI do not know my way around python, but you since UPnP is HTTP based, you will need to send an HTTP request with appropriate UPnP-headers (see wikipedia or test it yourself with UPnP Inspector) and the proper XML-formatted body for the function you are trying to use.\nThe UPnP-function I worked with to push a link to the TV is \"SetAVTransportURI\", but it might differ from your TV. Use UPnP Inspector to find the correct one, including its parameters.\nIn summary: Get a DLNA-Server to host you videos on. Find out the links to those videos using UPnP Inspector or other DLNA-clients. Find out the UPnP-function that sends a URL to your TV (again, I recomment UPnP Inspector, you can explore and call all functions with it). Implement a call to that function in your script.","Q_Score":2,"Tags":"python,bash,upnp,server-push,samsung-smart-tv","A_Id":13798803,"CreationDate":"2012-12-10T09:53:00.000","Title":"uPnP pushing video to Smart TV\/Samsung TV on OSX\/Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed PyCuda without any difficulty but am having trouble linking it to my eclipse environment. Does anyone know how I can link pycuda and eclipse IDE? Thanks in Adanced","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":13803315,"Users Score":0,"Answer":"You can use NetBeans 6.5 IDE its provide python support.","Q_Score":0,"Tags":"python,eclipse","A_Id":13866443,"CreationDate":"2012-12-10T14:51:00.000","Title":"PyCuda and Eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing some scripts for our sales people to query an index with elastic search through python. (Eventually the script will update lead info in our Salesforce DB.)\nI have been using the urllib2 module, with simplejson, to pull results. The problem is that this seems to be a not-so-good approach, evidenced by scripts which are taking longer and longer to run.\nQuestions:\n\nDoes anyone have any opinions (opinions, on the internet???) about Elastic Search clients for Python? Specifically, I've found pyes and pyelasticsearch, via elasticsearch.org---how do these two stack up?\nHow good or bad is my current approach of dynamically building the query and running it via self.raw_results = simplejson.load(urllib2.urlopen(self.query))?\n\nAny advice is greatly appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":748,"Q_Id":13823554,"Users Score":0,"Answer":"It sounds like you have an issue unrelated to the client.  If you can pare down what's being sent to ES and represent it in a simple curl command it will make what's actually running slowly more apparent.  I suspect we just need to tweak your query to make sure it's optimal for your context.","Q_Score":4,"Tags":"python,elasticsearch","A_Id":14884970,"CreationDate":"2012-12-11T15:52:00.000","Title":"Elastic search client for Python: advice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing some scripts for our sales people to query an index with elastic search through python. (Eventually the script will update lead info in our Salesforce DB.)\nI have been using the urllib2 module, with simplejson, to pull results. The problem is that this seems to be a not-so-good approach, evidenced by scripts which are taking longer and longer to run.\nQuestions:\n\nDoes anyone have any opinions (opinions, on the internet???) about Elastic Search clients for Python? Specifically, I've found pyes and pyelasticsearch, via elasticsearch.org---how do these two stack up?\nHow good or bad is my current approach of dynamically building the query and running it via self.raw_results = simplejson.load(urllib2.urlopen(self.query))?\n\nAny advice is greatly appreciated!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":748,"Q_Id":13823554,"Users Score":2,"Answer":"We use pyes. And its pretty neat. You can there go with the thrift protocol which is faster then the rest service.","Q_Score":4,"Tags":"python,elasticsearch","A_Id":14870170,"CreationDate":"2012-12-11T15:52:00.000","Title":"Elastic search client for Python: advice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a small program that helps you keep track of what page you're on in your books. I'm not a fan of bookmarks, so I thought \"What if I could create a program that would take user input, and then display the number or string of text that they wrote, which in this case would be the page number they're on, and allow them to change it whenever they need to?\" It would only take a few lines of code, but the problem is, how can I get it to display the same number the next time I open the program? The variables would reset, would they not? Is there a way to permanently change a variable in this way?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5917,"Q_Id":13830334,"Users Score":1,"Answer":"You need to store it on disk. Unless you want to be really fancy, you can just use something like CSV, JSON, or YAML to make structured data easier.\nAlso check out the python pickle module.","Q_Score":6,"Tags":"python,variables","A_Id":13830530,"CreationDate":"2012-12-11T23:36:00.000","Title":"Change variable permanently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible for the user to input a specific directory on their computer, and for Python to write the all of the file\/folder names to a text document? And if so, how?\nThe reason I ask is because, if you haven't seen my previous posts, I'm learning Python, and I want to write a little program that tracks how many files are added to a specific folder on a daily basis. This program isn't like a project of mine or anything, but I'm writing it to help me further learn Python. The more I write, the more I seem to learn.\nI don't need any other help than the original question so far, but help will be appreciated!\nThank you!\nEDIT: If there's a way to do this with \"pickle\", that'd be great! Thanks again!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":7504,"Q_Id":13832095,"Users Score":1,"Answer":"While the approach of @Makato is certainly right, for your 'diff' like application you want to capture the inode 'stat()' information of the files in your directory and pickle that python object from day-to-day looking for updates; this is one way to do it - overkill maybe - but more suitable than save\/parse-load from text-files IMO.","Q_Score":2,"Tags":"python","A_Id":13832200,"CreationDate":"2012-12-12T02:59:00.000","Title":"PYTHON - Search a directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When tracing(using sys.settrace) python .egg execution by Python 2.7 interpreter frame.f_code.co_filename    instead of <path-to-egg>\/<path-inside-egg> eqauls to something like build\/bdist.linux-x86_64\/egg\/<path-inside-egg>\nIs it a bug? And how to reveal real path to egg?\nIn Python 2.6 and Python 3 everything works as expected.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":13846155,"Users Score":1,"Answer":"No, that is not a bug. Eggs, when being created, have their bytecode compiled in a build\/bdist.<platform>\/egg\/ path, and you see that reflected in the co_filename variable. The bdist stands for binary distribution.","Q_Score":0,"Tags":"python,egg,python-internals","A_Id":13846221,"CreationDate":"2012-12-12T18:22:00.000","Title":"Strange co_filename for file from .egg during tracing in Python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to build a visual debugger, which helps programming students to see how expression evaluation takes place (how subexpressions get evaluated and \"replaced\" by their values, something like expression evaluation visualizer in Excel).\nLooks like you can't step through this process with Python's pdb, as its finest step granularity is line of code. Is it somehow possible to step through Python bytecode? Any other ideas how to achieve this goal?\nEDIT: I need a lightweight solution that can be built on top of CPython standard library.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1143,"Q_Id":13858776,"Users Score":1,"Answer":"Using pdb, any function call can be stepped into. For any other statement, pdb can print the values of the relevant names in the line. What additional functionality are you looking for that isn't covered? \nIf you're trying to 'step into' things like a list comprehension, that won't work from a pure Python perspective because it's a single opcode. At some point for every expression you'll need to tell your students 'and this is where Python goes into the C implementation and evaluates this...'.","Q_Score":7,"Tags":"python,debugging,pdb","A_Id":13961662,"CreationDate":"2012-12-13T11:22:00.000","Title":"How to step through Python expression evaluation process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to parse html code in python and tried beautiful soup and pyquery already. The problem is that those parsers modify original code e.g insert some tag or etc. Is there any parser out there that do not change the code?\n\nI tried HTMLParser but no success! :(\nIt doesn't modify the code and just tells me where tags are placed. But it fails in parsing web pages like mail.live.com\nAny idea how to parse a web page just like a browser?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":273,"Q_Id":13859124,"Users Score":0,"Answer":"No, to this moment there is no such HTML parser and every parser has it's own limitations.","Q_Score":1,"Tags":"python,html,parsing","A_Id":18350504,"CreationDate":"2012-12-13T11:44:00.000","Title":"python html parser which doesn't modify actual markup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I have two functions drawn from two different APIs, function A and B.\nBy default, function A outputs audio data to a wav file.\nBy default, function B takes audio input from a wav file and process it. \nIs it possible to stream the data from function A to B? If so, how do I do this? I work on lubuntu if that is relevant.\nThis is function A I'm thinking about from the PJSUA python API:\ncreate_recorder(self, filename)\nCreate WAV file recorder.\nKeyword arguments\nfilename    -- WAV file name\nReturn:\n    WAV recorder ID\nAnd this is function B from the Pocketsphinx Python API\ndecode_raw(...)\nDecode raw audio from a file.\nParameters:\nfh (file) - Filehandle to read audio from.\nuttid (str) - Identifier to give to this utterance.\nmaxsamps (int) - Maximum number of samples to read. If not specified or -1, the rest of the file will be read.\nupdate:\nWhen I try to pass the filename of a socket or named pipe, it outputs this error message, seems that the C function that the python bindings use doesn't like anything but .wav files... Why would that be?\npjsua_aud.c .pjsua_recorder_create() error: unable to determine file format for \/tmp\/t_fifo. Exception: Object: LIb, operation=create(recorder), error=Option\/operation is not supported (PJ_ENOTSUP)\nI need to use a value returned by create_recorder(), it is an int that is used to get the wav recorder id (which is not passed on directly to decode_raw() but rather passed on to some other function.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1006,"Q_Id":13884439,"Users Score":2,"Answer":"The answer is highly platform dependent and more details are required. Different Operating Systems have different ways of handling Interprocess Communication, or IPC.\nIf you're using a UNIXlike environment, there are a rich set of IPC primitives to work with. Pipes, SYS V Message Queues, shared memory, sockets, etc. In your case I think it would make sense to use a pipe or a socket, depending on whether the A and B are running in the same process or not.\nUpdate:\nIn your case, I would use python's subprocess and or os module and a pipe. The idea here is to create calling contexts to the two APIs in processes which share a parent process, which has also created a unidirectional named pipe and passed it to its children. Then, data written to the named pipe in create_recorder will immediately be available for read()ing in the named pipe.","Q_Score":1,"Tags":"python,audio","A_Id":13884538,"CreationDate":"2012-12-14T18:37:00.000","Title":"Redirecting audio output from one function to another function in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Pretty simple, I'd like to run an external command\/program from within a Python script, once it is finished I would also want to know how much CPU time it consumed.\nHard mode: running multiple commands in parallel won't cause inaccuracies in the CPU consumed result.","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":2139,"Q_Id":13889066,"Users Score":3,"Answer":"You can do timings within Python, but if you want to know the overall CPU consumption of your program, that is kind of silly to do. The best thing to do is to just use the GNU time program. It even comes standard in most operating systems.","Q_Score":7,"Tags":"python","A_Id":13889088,"CreationDate":"2012-12-15T03:39:00.000","Title":"Run an external command and get the amount of CPU it consumed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"am trying to find a way to detect if a given URL has an RSS feed or not. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":812,"Q_Id":13892113,"Users Score":6,"Answer":"Each RSS have some format.\n\nSee what Content-Type the server returns for the given URL. However, this may not be specific and a server may not necessarily return the correct header.\nTry to parse the content of the URL as RSS and see if it is successful - this is likely the only definitive proof that a given URL is a RSS feed.","Q_Score":0,"Tags":"python,rss","A_Id":13892148,"CreationDate":"2012-12-15T12:20:00.000","Title":"given a URL in python, how can i check if URL has RSS feed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried to install Web2py with pip. The installation is completed successfully. But after that I don't know how to start the server. I know there are three apps which are 'w2p_clone', 'w2p_apps' and 'w2p_run'. I don't know how to use these three apps. And also I did not set up my virtual env for Web2py, however even I do not have virtual env I can start Web2py sever from src code (like python web2py.py)\nI just want to know how to use pip intall for Web2py.\nThank you very much.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2902,"Q_Id":13899823,"Users Score":2,"Answer":"I think I can give my answer to my own question: we don't need to install web2py, just download it and python it.","Q_Score":5,"Tags":"python,pip,web2py","A_Id":14100013,"CreationDate":"2012-12-16T08:46:00.000","Title":"pip install web2py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to store python (or C++) data in RAM for latter use and how can this be achieved?\nBackground:\nI have written a program that finds which lines in the input table match the given regular expression. I can find all the lines in roughly one second or less. However the problem is that i process the input table into a python object every time i start this program. This process takes about 30minutes.\nThis program will eventually run on a machine with over 128GB of RAM. The python object takes about 2GB of RAM. The input table changes rarely and therefore the python object (that i'm currently recalculating every time) actually changes rarely. Is there a way that i can create this python object once, store it in RAM 24\/7 (recreate if input table changes or server restarts) and then use it every time when needed?\nNOTE: The python object will not be modified after creation. However i need to be able to recreate this object if needed.\nEDIT: Only solution i can think of is just to keep the program running 24\/7 (as a daemon??) and then issuing commands to it as needed.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2201,"Q_Id":13906679,"Users Score":0,"Answer":"Your problem description is kind of vague and can be read in several different ways.\nOne way in which I read this is that you have some kind of ASCII representation of a data structure on disk. You read this representation into memory, and then grep through it one or more times looking for things that match a given regular expression.\nSpeeding this up depends a LOT on the data structure in question.\nIf you are simply doing line splitting, then maybe you should just read the whole thing into a byte array using a single read instruction. Then you can alter how you grep to use a byte-array grep that doesn't span multiple lines. If you fiddle the expression to always match a whole line by putting ^.*? at the beginning and .*?$ at the end (the ? forces a minimal instead of maximal munch) then you can check the size of the matched expression to find out how many bytes forward to go.\nAlternately, you could try using the mmap module to achieve something similar without having to read anything and incur the copy overhead.\nIf there is a lot of processing going on to create your data structure and you can't think of a way to use the data in the file in a very raw way as a simple byte array, then you're left with various other solutions depending, though of these it sounds like creating a daemon is the best option.\nSince your basic operation seems to be 'tell me which tables entries match a regexp', you could use the xmlrpc.server and xmlrpc.client libraries to simply wrap up a call that takes the regular expression as a string and returns the result in whatever form is natural. The library will take care of all the work of wrapping up things that look like function calls into messages over a socket or whatever.\nNow, your idea of actually keeping it in memory is a bit of a red-herring. I don't think it takes 30 minutes to read 2G of information from disk these days. It likely takes at most 5, and likely less than 1. So you might want to look at how you're building the data structure to see if you could optimize that instead.\nWhat pickle and\/or marshal will buy you is highly optimized code for building the data structure out of a serialized form. This will cause the data structure creation to possibly be constrained by disk read speeds instead. That means the real problem you're addressing is not reading it off disk each time, but building the data structure in your own address space.\nAnd holding it in memory and using a daemon isn't a guarantee that it will stay in memory. It just guarantees that it stays built up as the data structure you want within the address space of a Python process. The os may decide to swap that memory to disk at any time.\nAgain, this means that focusing on the time to read it from disk is likely not the right focus. Instead, focus on how to efficiently re-create (or preserve) the data structure in the address space of a Python process.\nAnyway, that's my long-winded ramble on the topic. Given the vagueness of your question, there is no definite answer, so I just gave a smorgasbord of possible techniques and some guiding ideas.","Q_Score":2,"Tags":"c++,python,memory,ram","A_Id":13928292,"CreationDate":"2012-12-16T23:50:00.000","Title":"Storing large python object in RAM for later use","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to store python (or C++) data in RAM for latter use and how can this be achieved?\nBackground:\nI have written a program that finds which lines in the input table match the given regular expression. I can find all the lines in roughly one second or less. However the problem is that i process the input table into a python object every time i start this program. This process takes about 30minutes.\nThis program will eventually run on a machine with over 128GB of RAM. The python object takes about 2GB of RAM. The input table changes rarely and therefore the python object (that i'm currently recalculating every time) actually changes rarely. Is there a way that i can create this python object once, store it in RAM 24\/7 (recreate if input table changes or server restarts) and then use it every time when needed?\nNOTE: The python object will not be modified after creation. However i need to be able to recreate this object if needed.\nEDIT: Only solution i can think of is just to keep the program running 24\/7 (as a daemon??) and then issuing commands to it as needed.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2201,"Q_Id":13906679,"Users Score":2,"Answer":"We regularly load and store much larger chunks of memory than 2 Gb in no time (seconds). We can get 350 Mb\/s from our 3 year old SAN.\nThe bottlenecks \/overheads seem to involve mainly python object management. I find that using marshal is much faster than cPickle. Allied with the use of data structures which involve minimal python object handles, this is more than fast enough.\nFor data structures, you can either use array.array or numpy. array.array is slightly more portable (no extra libraries involved) but numpy is much more convenient in many ways.\nFor example, instead of having 10 million integer (python objects), you would create a single array.array('i') with 10 million elements. \nThe best part to using marshal is that it is a very simple format you can write to and read from easily using c\/c++ code.","Q_Score":2,"Tags":"c++,python,memory,ram","A_Id":13924546,"CreationDate":"2012-12-16T23:50:00.000","Title":"Storing large python object in RAM for later use","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to store python (or C++) data in RAM for latter use and how can this be achieved?\nBackground:\nI have written a program that finds which lines in the input table match the given regular expression. I can find all the lines in roughly one second or less. However the problem is that i process the input table into a python object every time i start this program. This process takes about 30minutes.\nThis program will eventually run on a machine with over 128GB of RAM. The python object takes about 2GB of RAM. The input table changes rarely and therefore the python object (that i'm currently recalculating every time) actually changes rarely. Is there a way that i can create this python object once, store it in RAM 24\/7 (recreate if input table changes or server restarts) and then use it every time when needed?\nNOTE: The python object will not be modified after creation. However i need to be able to recreate this object if needed.\nEDIT: Only solution i can think of is just to keep the program running 24\/7 (as a daemon??) and then issuing commands to it as needed.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":2201,"Q_Id":13906679,"Users Score":2,"Answer":"You could try pickling your object and saving it to a file, so that each time the program runs it just has to deserialise the object instead of recalculating it. Hopefully the server's disk cache will keep the file hot if necessary.","Q_Score":2,"Tags":"c++,python,memory,ram","A_Id":13906794,"CreationDate":"2012-12-16T23:50:00.000","Title":"Storing large python object in RAM for later use","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I developed an application which parses a lot of data, but if I commit the data after parsing all the data, it will consume too much memory. However, I cannot commit it each time, because it costs too much hard disk I\/O. \nTherefore, my question is how can I know how many uncommitted items are in the session?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1666,"Q_Id":13910576,"Users Score":0,"Answer":"This is a classic case of buffering. Try a reasonably large chunk and reduce it if there's too much disk I\/O (or you don't like it causing long pauses, etc) or increase it if your profile shows too much CPU time in I\/O calls.\nTo implement, use an array, each \"write\" you append an item to the array. Have a separate \"flush\" function that writes the whole thing. Each append you check, and if it has reached maximum size, write them all, and clear the array. At the end, call the flush function to write partially filled array.","Q_Score":0,"Tags":"python,sqlalchemy","A_Id":13910851,"CreationDate":"2012-12-17T08:23:00.000","Title":"Find out how many uncommitted items are in the session","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to get the content of DataWindow from PBL (PowerBuilder Library) file and edit it in place. The idea is to read the pbl file, and access individual DataWindows to modify source code. Somehow, I have managed to do the first part with PblReader .NET library using IronPython. It allows me to read PBL files, and access DataWindow source code. However it doesn't support modifications. I would like to know if anyone have an idea for editing PBL files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3599,"Q_Id":13920682,"Users Score":1,"Answer":"A PowerBuilder application can load a DataWindow from a PBL (doesn't have to be in the library path), modify it, and save it back to the PBL. I've written a couple of tools that do that. PowerBuilder will allow you to modify the DataWindow according to its object model using the modify method. I don't know why anyone would want to reinvent all of this. I recall seeing Python bindings for PB somewhere. You could get the DW syntax from PB, call out to Python, then save it back in PB. But you'd have to do all the parsing in Python, whereas PB already understands the DW. Finally I'm surprised Terry didn't plug PBL Peeper. You could use PBL Peeper to export the DataWindows, massage them to your hearts's content in Python. then import them back into PB.","Q_Score":1,"Tags":"python,.net,powerbuilder","A_Id":13943263,"CreationDate":"2012-12-17T19:19:00.000","Title":"idea\/solution how to edit PBL (PowerBuilder Library) files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to make a copy of netcdf file using Python. \nThere are very nice examples of how to read or write netcdf-file, but perhaps there is also a good way how to make the input and then output of the variables to another file.\nA good-simple method would be nice, in order to get the dimensions and dimension variables to the output file with the lowest cost.","AnswerCount":5,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3485,"Q_Id":13936563,"Users Score":5,"Answer":"If you want to only use the netCDF-4 API to copy any netCDF-4 file, even those with variables that use arbitrary user-defined types, that's a difficult problem.  The netCDF4 module at netcdf4-python.googlecode.com currently lacks support for compound types that have variable-length members or variable-length types of a compound base type, for example.  \nThe nccopy utility that is available with the netCDF-4 C distribution shows it is possible to copy an arbitrary netCDF-4 file using only the C netCDF-4 API, but that's because the C API fully supports the netCDF-4 data model.  If you limit your goal to copying netCDF-4 files that only use flat types supported by the googlecode module, the algorithm used in nccopy.c should work fine and should be well-suited to a more elegant implementation in Python.\nA less ambitious project that would be even easier is a Python program that would copy any netCDF \"classic format\" file, because the classic model supported by netCDF-3 has no user-defined types or recursive types.  This program would even work for netCDF-4 classic model files that also use performance features such as compression and chunking.","Q_Score":5,"Tags":"python,netcdf","A_Id":16386862,"CreationDate":"2012-12-18T15:47:00.000","Title":"copy netcdf file using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wonder how to update fast numbers on a website.\nI have a machine that generates a lot of output, and I need to show it on line. However my problem is the update frequency is high, and therefore I am not sure how to handle it.\nIt would be nice to show the last N numbers, say ten. The numbers are updated at 30Hz. That might be too much for the human eye, but the human eye is only for control here.\nI wonder how to do this. A page reload would keep the browser continuously loading a page, and for a web page something more then just these numbers would need to be shown.\nI might generate a raw web engine that writes the number to a page over a specific IP address and port number, but even then I wonder whether this page reloading would be too slow, giving a strange experience to the users.\nHow should I deal with such an extreme update rate of data on a website? Usually websites are not like that.\nIn the tags for this question I named the languages that I understand. In the end I will probably write in C#.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":114,"Q_Id":13938903,"Users Score":2,"Answer":"a) WebSockets in conjuction with ajax to update only parts of the site would work, disadvantage: the clients infrastructure (proxies) must support those (which is currently not the case 99% of time).\nb) With existing infrastructure the approach is Long Polling. You make an XmlHttpRequest using javascript. In case no data is present, the request is blocked on server side for say 5 to 10 seconds. In case data is avaiable, you immediately answer the request. The client then immediately sends a new request. I managed to get >500 updates per second using java client connecting via proxy, http to a webserver (real time stock data displayed).\nYou need to bundle several updates with each request in order to get enough throughput.","Q_Score":2,"Tags":"c#,python,asp.net,web-services,perl","A_Id":13939065,"CreationDate":"2012-12-18T18:07:00.000","Title":"Rapid number updates on a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Iam trying to stream audio in my TideSDK application, but it seems to be quite difficult. The HTML5 audio does not work for me, neither does video tags. The player simply keeps loading. I've tested and confirmed that my code worked in many other browsers.\nMy next attemp was VLC via Python bindings. But without any confirmation I do believe you need to have VLC installed for the vlc.py file to work? \nBasically, what I want to do is play audio in a sophisticated way (probably through Python) and wrap it in my TideSDK application. I want it to work out of the box - nothing for my end users to install.\nIam by the way pretty new the the whole python thing, but I learn fast so I'd love to see some examples on how to get started! \nPerhaps a quite quirky way to do it would be by using flash, but I'd love not to. \nFor those of you who are not familiar with TideSDK, its a way to build desktop applications with HTML, CSS, Python, Ruby and PHP.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":401,"Q_Id":13940449,"Users Score":2,"Answer":"The current version has very old webkit so because of that the HTML5 support is lacking. Audio and video tags are currently not supported in windows because underlying webkit implementation (wincairo) does not support it. Wa are working on the first part to use the latest webkit. once completed we are also planning to work on the audio\/video support on windows.","Q_Score":0,"Tags":"python,html,tidesdk","A_Id":13948150,"CreationDate":"2012-12-18T19:52:00.000","Title":"Streaming audio in Python with TideSDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have been trying to figure our how to use BeautifulSoup and did a quick search and found lxml can parse the xpath of an html page. I would LOVE if I could do that but the tutorial isnt that intuitive.\nI know how to use Firebug to grab the xpath and was curious if anyone has use lxml and can explain how I can use it to parse specific xpath's, and print them.. say 5 per line..or if it's even possible?!\nSelenium is using Chrome and loads the page properly, just need help moving forward.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1853,"Q_Id":13965403,"Users Score":0,"Answer":"I prefer to use lxml. Because the efficiency of lxml is more higher than selenium for large elements extraction. You can use selenium to get source of webpages and parse the source with lxml's xpath instead of the native find_elements_with_xpath in selenium.","Q_Score":1,"Tags":"python,parsing,selenium,lxml,xpath","A_Id":40276743,"CreationDate":"2012-12-20T04:37:00.000","Title":"Can I parse xpath using python, selenium and lxml?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"By default, the built-in views in PyQt can auto-refresh itself when its model has been updated. I wrote my own chart view, but I don't know how to do it, I have to manually update it for many times. \nWhich signal should I use?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5032,"Q_Id":13999970,"Users Score":0,"Answer":"You need to connect your view to the dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) signal of the model:\n\nThis signal is emitted whenever the data in an existing item changes.\nIf the items are of the same parent, the affected ones are those\n  between topLeft and bottomRight inclusive. If the items do not have\n  the same parent, the behavior is undefined.\nWhen reimplementing the setData() function, this signal must be\n  emitted explicitly.","Q_Score":3,"Tags":"python,qt,user-interface,qt4,pyqt","A_Id":14000161,"CreationDate":"2012-12-22T04:07:00.000","Title":"PyQt - Automatically refresh a custom view when the model is updated?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a string of variable length and I know the index position is 25. As it's variable in his length (>= 25), I need a way to locate the negative index of that same position for easier data manipulation. \nDo you have any idea how this can be done?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":67,"Q_Id":14000083,"Users Score":1,"Answer":"Lets use a 'list' with following values:\n'1', '2', '3','4', '5', '6'\nSteps to get the negative index of any value:\nStep1. Get the 'normal_index' of the value. For example the normal index of value '4' is 3.\nStep2. Get the 'count' of the 'list'. In our example the 'list_count' is 5.\nStep3. Get Negative index of the requested value. negative_index = (normal_index - list_count) - 1. Which is -3.","Q_Score":2,"Tags":"list,python-2.7,indexing","A_Id":14000721,"CreationDate":"2012-12-22T04:34:00.000","Title":"How do you find the negative index of a position if you know the index?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a small application which saves file paths to a database (using django). I assumed file paths are utf-8 encoded, but I ran into the following file name: C:\\FXG\u2122.nfo which is apparently not encoded in utf-8.\nWhen I do filepath.decode('utf-8') I get the following error:\n\nUnicodeDecodeError: 'utf8' codec can't decode byte 0x99 in position 30: invalid start byte\n\n(I trimmed the file name, so the position is wrong here).\nHow do I know how the file paths are encoded in a way that this will work for every file name?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1880,"Q_Id":14003386,"Users Score":1,"Answer":"Use sys.getfilesystemencoding().\nThat should allow you to convert all paths that look ok.\nHowever, there can always be illegally-encoded files or folders, you have to think how to deal with those in the framework of your application.\nSome apps may ignore such files, others keep name as a binary blob.","Q_Score":0,"Tags":"python,windows","A_Id":14003444,"CreationDate":"2012-12-22T13:51:00.000","Title":"File path encoding in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've written a curses program in python. It runs fine. However, when I use nodelay(), the program exits straight away after starting in the terminal, with nothing shown at all (just a new prompt).\nEDIT\nThis code will reproduce the bug: \n\nsc = curses.initscr()\n\nsc.nodelay(1) # But removing this line allows the program to run properly\n\nfor angry in range(20):\n        sc.addstr(angry, 1, \"hi\")\n\n\nHere's my full code\n\nimport curses, time, sys, random\n\ndef paint(x, y, i):\n        #...\ndef string(s, y):\n        #...\n\ndef feed():\n        #...\n\nsc = curses.initscr()\ncurses.start_color()\ncurses.curs_set(0)\nsc.nodelay(1) #########################################\n\n # vars + colors inited\n\nfor angry in range(20):\n        try:\n                dir = chr(sc.getch())\n\n                sc.clear()\n\n                feed()\n\n                #lots of ifs\n\n                body.append([x, y])\n                body.pop(0)\n\n                for point in body:\n                        paint(*point, i=2)\n\n                sc.move(height-1, 1)\n                sc.refresh()\n                time.sleep(wait)\n\n        except Exception as e:\n                print sys.exc_info()[0], e\n\nsc.getch()\ncurses.beep()\n\ncurses.endwin()\n\nWhy is this happenning, and how can I use nodelay() safely?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":5827,"Q_Id":14004835,"Users Score":1,"Answer":"While I didn't use curses in python, I am currently working with it in C99, compiled using clang on Mac OS Catalina. It seems that nodelay()` does not work unless you slow down the program step at least to 1\/10 of a second, eg. usleep(100000). I suppose that buffering\/buffer reading is not fast enough, and getch() or wgetch(win*) simply doesn't manage to get the keyboard input, which somehow causes it to fail (no message whatsoever, even a \"Segmentation fault\").\nFor this reason, it's better to use halfdelay(1), which equals nodelay(win*, true) combined with usleep(100000).\nI know this is a very old thread (2012), but the problem is still present in 2022, so I decided to reply.","Q_Score":7,"Tags":"python,ncurses,curses","A_Id":72080593,"CreationDate":"2012-12-22T17:13:00.000","Title":"nodelay() causes python curses program to exit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written a curses program in python. It runs fine. However, when I use nodelay(), the program exits straight away after starting in the terminal, with nothing shown at all (just a new prompt).\nEDIT\nThis code will reproduce the bug: \n\nsc = curses.initscr()\n\nsc.nodelay(1) # But removing this line allows the program to run properly\n\nfor angry in range(20):\n        sc.addstr(angry, 1, \"hi\")\n\n\nHere's my full code\n\nimport curses, time, sys, random\n\ndef paint(x, y, i):\n        #...\ndef string(s, y):\n        #...\n\ndef feed():\n        #...\n\nsc = curses.initscr()\ncurses.start_color()\ncurses.curs_set(0)\nsc.nodelay(1) #########################################\n\n # vars + colors inited\n\nfor angry in range(20):\n        try:\n                dir = chr(sc.getch())\n\n                sc.clear()\n\n                feed()\n\n                #lots of ifs\n\n                body.append([x, y])\n                body.pop(0)\n\n                for point in body:\n                        paint(*point, i=2)\n\n                sc.move(height-1, 1)\n                sc.refresh()\n                time.sleep(wait)\n\n        except Exception as e:\n                print sys.exc_info()[0], e\n\nsc.getch()\ncurses.beep()\n\ncurses.endwin()\n\nWhy is this happenning, and how can I use nodelay() safely?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5827,"Q_Id":14004835,"Users Score":0,"Answer":"I see no difference when running your small test program with or without the sc.nodelay() line. \nNeither case prints anything on the screen...","Q_Score":7,"Tags":"python,ncurses,curses","A_Id":14006585,"CreationDate":"2012-12-22T17:13:00.000","Title":"nodelay() causes python curses program to exit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, a friend and I are currently writing a panel (in python\/django) for managing gameservers.\nEach client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'.\nThe passwords would be generated randomly and presented to the user in the panel, however, we obviously don't want them to be stored in plaintext or reversible encryption, so we are unsure what to do if a a client forgets their password.\nResetting the password is something we would try to avoid as some clients may reset the password while the gameserver is still trying to use it, which could cause corruption and crashes.\nWhat would be a secure (but without sacrificing ease of use for the clients) way to go about this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":408,"Q_Id":14008232,"Users Score":1,"Answer":"Your question embodies a contradiction in terms. Either you don't want reversibility or you do. You will have to choose.\nThe usual technique is to hash the passwords and to provide a way for the user to reset his own password on sufficient alternative proof of identity. You should never display a password to anybody, for legal non-repudiability reasons. If you don't know what that means, ask a lawyer.","Q_Score":2,"Tags":"python,mysql,django,security,encryption","A_Id":14008320,"CreationDate":"2012-12-23T02:46:00.000","Title":"Storing MySQL Passwords","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, a friend and I are currently writing a panel (in python\/django) for managing gameservers.\nEach client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'.\nThe passwords would be generated randomly and presented to the user in the panel, however, we obviously don't want them to be stored in plaintext or reversible encryption, so we are unsure what to do if a a client forgets their password.\nResetting the password is something we would try to avoid as some clients may reset the password while the gameserver is still trying to use it, which could cause corruption and crashes.\nWhat would be a secure (but without sacrificing ease of use for the clients) way to go about this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":408,"Q_Id":14008232,"Users Score":4,"Answer":"Though this is not the answer you were looking for, you only have three possibilities\n\nstore the passwords plaintext (ugh!)\nstore with a reversible encryption, e.g. RSA (http:\/\/stackoverflow.com\/questions\/4484246\/encrypt-and-decrypt-text-with-rsa-in-php)\ndo not store it; clients can only reset password, not view it\n\nThe second choice is a secure way, as RSA is also used for TLS encryption within the HTTPS protocol used by your bank of choice ;)","Q_Score":2,"Tags":"python,mysql,django,security,encryption","A_Id":14008264,"CreationDate":"2012-12-23T02:46:00.000","Title":"Storing MySQL Passwords","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a development & production server and some large video files. The large files need to be renamed. I don't know how to automatically change the file names in the production environment when I change their name in the development environment. I think using git is very inefficient for large files.\nOn the development environment I copied only the first 5 seconds of the videos. I'll be using Django with South to synchronize the database and git to synchronize the code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":14013214,"Users Score":0,"Answer":"If the names on the development and production server are the same, then record the rename commands in a shell-script.\nYou can run that on both the development and the production server...","Q_Score":0,"Tags":"python,django,linux,deployment","A_Id":14013487,"CreationDate":"2012-12-23T17:49:00.000","Title":"synchronizing file names across servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How is Deep copy being done in python for lists? \nI am a little confused for copying of lists.  Is it using shallow copy or deep copy?\nAlso, what is the syntax for sublists? is it g=a[:]?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1094,"Q_Id":14028164,"Users Score":3,"Answer":"The new list is a copy of references. g[0] and a[0] both reference the same object. Thus this is a shallow copy. You can see the copy module's deepcopy method for recursively copying containers, but this isn't a common operation in my experience.\nStylistically, I prefer the more explicit g = list(a) to create a copy of a list, but creating a full slice has the same effect.","Q_Score":1,"Tags":"python,list,shallow-copy,deep-copy","A_Id":14028181,"CreationDate":"2012-12-25T06:09:00.000","Title":"python lists copying is it deep copy or Shallow copy and how is it done?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":91,"Q_Id":14029177,"Users Score":0,"Answer":"In C language terms, a Python list is like a PyObject *mylist[100], except it's dynamically allocated.  It's a contiguous chunk of memory storing references to Python objects.","Q_Score":0,"Tags":"python,list","A_Id":14030552,"CreationDate":"2012-12-25T08:57:00.000","Title":"How dynamic arrays store different datatypes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":91,"Q_Id":14029177,"Users Score":1,"Answer":"Arrays in Python are done via the array module. They do not store different datatypes, they store arrays of specific numerical values.\nI think you mean the list type. It doesn't contain values, it just contains references to objects, which can be any type of object at all.\nNone of these reserves any space for any elements at all (well, they do, but that's internal implementation details). It adds the space for the elements needed when it they are added to the list\/array.\nThe list type is indeed less efficient than the array type, which is why the array type exists.","Q_Score":0,"Tags":"python,list","A_Id":14029213,"CreationDate":"2012-12-25T08:57:00.000","Title":"How dynamic arrays store different datatypes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":91,"Q_Id":14029177,"Users Score":1,"Answer":"Python reserves only enough space in a list for a reference to the various objects; it is up to the objects' allocators to reserve enough space for them when they are instantiated.","Q_Score":0,"Tags":"python,list","A_Id":14029199,"CreationDate":"2012-12-25T08:57:00.000","Title":"How dynamic arrays store different datatypes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a bit confused regarding data structure in python; (),[], and {}. I am trying to sort a simple list, probably since I cannot identify the type of data I am failing to sort it.\nMy list is simple: ['Stem', 'constitute', 'Sedge', 'Eflux', 'Whim', 'Intrigue'] \nMy question is what type of data this is, and how to sort the words alphabetically?","AnswerCount":6,"Available Count":1,"Score":0.1651404129,"is_accepted":false,"ViewCount":435587,"Q_Id":14032521,"Users Score":5,"Answer":"ListName.sort() will sort it alphabetically. You can add reverse=False\/True in the brackets to reverse the order of items: ListName.sort(reverse=False)","Q_Score":207,"Tags":"python,list,sorting,alphabetical","A_Id":26274529,"CreationDate":"2012-12-25T17:04:00.000","Title":"Python data structure sort list alphabetically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to store cookies persistently in an application that uses QWebKit. I understand that I have to create a subclass of QNetworkCookieJar and attach it to a QNetworkAccessManager. But how do I attach this QNetworkAccessManager to my QWebView or get the QNetworkAccessManager used by it?\nI use Python 3 and PyQt if that is important.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1268,"Q_Id":14034401,"Users Score":4,"Answer":"You can get\/set the cookie jar through QWebView.page().networkAccessManager().cookieJar()\/setCookieJar().\nThe Browser demo included with Qt (in C++) shows how to read and write cookies to disk.","Q_Score":3,"Tags":"python,qt,cookies,qwebkit","A_Id":14039648,"CreationDate":"2012-12-25T22:21:00.000","Title":"Permanent cookies with QWebKit -- where to get the QNetworkAccessManager?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Its weird because, when I run a normal python script on the server, it runs but when I run it via uWSGI, it cant import certain modules.\nthere is a bash script that starts uwsgi, and passes a path via --pythonpath option.\nIs this an additional path or all the paths have to be given here ?\nIf yes, how do I separate multiple paths given by this option.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1207,"Q_Id":14036549,"Users Score":0,"Answer":"you can specify multiple --pythonpath options, but PYTHONPATH should be honoured (just be sure it is correctly set by your init script, you can try setting it from the command line and running uwsgi in the same shell session)","Q_Score":1,"Tags":"python,uwsgi,pythonpath","A_Id":14039533,"CreationDate":"2012-12-26T06:00:00.000","Title":"Does uwsgi server read the paths in the environment variable PYTHONPATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that I can grab a blob by BlobKey, but how do I get the blobkey associated with a given filename?\nIn short, I want to implement \"get file by filename\" \nI can't seem to find any built-in functionality for this.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":259,"Q_Id":14043045,"Users Score":1,"Answer":"Every blob you upload, creates a new version of that blob (with that filename) in the blobstore. Ofcourse you can delete the old version(s) of the blob, if you uploaded a new version. But to make sure you have the latest version of a blob (of a filename) you have to store the filename in the datastore and make a reference to the latest version. This reference holds the blob_key.","Q_Score":0,"Tags":"python,google-app-engine,google-cloud-datastore","A_Id":14043190,"CreationDate":"2012-12-26T16:05:00.000","Title":"Downloading a Blob by Filename in Google App Engine (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a habit to declare new variables with self. in front to make it available to all methods. This is because sometimes I thought I don't need the variable in other methods. But halfway through I realized that I need it to be accessible in other methods. Then I have to add self. in front of all that variable.\nSo my question is, besides needing to type 5 characters more each time I use a variable, are there any other disadvantages? Or, how do you overcome my problem?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":184,"Q_Id":14049028,"Users Score":3,"Answer":"It's not really allright. self makes your variable available to global object-scope. That way you need to make sure that names of your variables are unique throughout complete object, rather than in localized scopes, amongst other side-effects that might or might not be unwanted.\nIn your particular case it might be not an issue, but it's a very bad practice in general.\nKnow your scoping and use it wisely. :)","Q_Score":3,"Tags":"python,self","A_Id":14049063,"CreationDate":"2012-12-27T03:31:00.000","Title":"Is declaring [almost] everything with self. alright (Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a habit to declare new variables with self. in front to make it available to all methods. This is because sometimes I thought I don't need the variable in other methods. But halfway through I realized that I need it to be accessible in other methods. Then I have to add self. in front of all that variable.\nSo my question is, besides needing to type 5 characters more each time I use a variable, are there any other disadvantages? Or, how do you overcome my problem?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":14049028,"Users Score":14,"Answer":"Set a property on self only when the value is part of the overall object state.  If it's only part of the method state, then it should be method-local, and should not be a property of self.","Q_Score":3,"Tags":"python,self","A_Id":14049045,"CreationDate":"2012-12-27T03:31:00.000","Title":"Is declaring [almost] everything with self. alright (Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"$ .\/pypy -O\nPython 2.7.2 (a3e1b12d1d01, Dec 04 2012, 13:33:26)\n[PyPy 1.9.1-dev0 with GCC 4.6.3] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\nAnd now for something completely different: `` amd64 and ppc are only\navailable in enterprise version''\n>>>> assert 1==2\nTraceback (most recent call last):\n  File \"\", line 1, in \nAssertionError\n>>>> \nBut when i execute\n$ python -O\nPython 2.7.3 (default, Aug  1 2012, 05:14:39) \n[GCC 4.6.3] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> assert 1==2\n>>>","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":342,"Q_Id":14051324,"Users Score":0,"Answer":"For anyone coming here in the future, Oct 3 2021 pypy3 does accept the -O flag and turn off assertion statements","Q_Score":5,"Tags":"python,pypy","A_Id":69422294,"CreationDate":"2012-12-27T07:57:00.000","Title":"how to disable pypy assert statement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"$ .\/pypy -O\nPython 2.7.2 (a3e1b12d1d01, Dec 04 2012, 13:33:26)\n[PyPy 1.9.1-dev0 with GCC 4.6.3] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\nAnd now for something completely different: `` amd64 and ppc are only\navailable in enterprise version''\n>>>> assert 1==2\nTraceback (most recent call last):\n  File \"\", line 1, in \nAssertionError\n>>>> \nBut when i execute\n$ python -O\nPython 2.7.3 (default, Aug  1 2012, 05:14:39) \n[GCC 4.6.3] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> assert 1==2\n>>>","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":342,"Q_Id":14051324,"Users Score":5,"Answer":"PyPy does silently ignore -O. The reasoning behind it is that we believe -O that changes semantics is seriously broken, but well, I guess it's illegal. Feel free to post a bug (that's also where such reports belong, on bugs.pypy.org)","Q_Score":5,"Tags":"python,pypy","A_Id":14051708,"CreationDate":"2012-12-27T07:57:00.000","Title":"how to disable pypy assert statement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a bunch of files that I need to print via PDF printer and after it is printed I need to perform additional tasks, but only when it is finally completed. \nSo to do this from my python script i call command \"lpr path\/to\/file.doc -P PDF\"\nBut this command immediately returns 0 and I have no way to track when printing process is finished, was it successful or not etc... \nThere is an option to send email when printing is done, but to wait for email after I start printing looks very hacky to me. \nDo you have some ideas how to get this done?\nEdit 1\nThere are a plenty of ways to check if printer is printing something at current moment. Therefore at the moment after I start printing something I run lpq command every 0.5 second to find out if it is still printing. But this looks to m e not the best way to do it. I want to be able get alerted or something when actual printing process is finished. Was it successful or not etc...","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2252,"Q_Id":14051766,"Users Score":1,"Answer":"You can check the state of the printer using the lpstat command (man lpstat). To wait for a process to finish, get the PID of the process and pass it wait command as argument","Q_Score":4,"Tags":"python,linux,command-line","A_Id":14052830,"CreationDate":"2012-12-27T08:42:00.000","Title":"How to check if pdf printing is finished on linux command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Simple question. It is possible to make configobj to not put a space before and after the '=' in a configuration entry ?\nI'm using configobj to read and write a file that is later processed by a bash script, so putting an antry like:\nVARIABLE = \"value\" \nbreaks the bash script, it needs to always be:\nVARIABLE=\"value\"\nOr if someone has another suggestion about how to read and write a file with this kind of entries (and restrictions) is fine too.\nThanks","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":1931,"Q_Id":14074805,"Users Score":1,"Answer":"Configobj is for reading and writing ini-style config files. You are apparently trying to use it to write bash scripts. That's not something that is likely to work.\nJust write the bash-script like you want it to be, perhaps using a template or something instead.\nTo make ConfigParses not write the spaces around the = probably requires that you subclass it. I would guess that you have to modify the write method, but only reading the code can help there. :-)","Q_Score":2,"Tags":"python,configobj","A_Id":14075363,"CreationDate":"2012-12-28T19:40:00.000","Title":"Make python configobj to not put a space before and after the '='","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to differentiate between 32-bit and 64-bit integers in Python. In C it's very easy as we can declare variables using int_64 and int_32. But in Python how do we differentiate between 32-bit integers and 64-bit integers?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5901,"Q_Id":14079587,"Users Score":7,"Answer":"There's no need.  The interpreter handles allocation behind the scenes, effectively promoting from one type to another as needed without you doing anything explicit.","Q_Score":3,"Tags":"python,integer","A_Id":14079631,"CreationDate":"2012-12-29T07:13:00.000","Title":"How to determine whether the number is 32-bit or 64-bit integer in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was working with GUI automation for visual studio C# desktop application.\nThere I have DataGridView and inside the grid I have combo box and check boxes.\nI tried to automate these using pywinauto, I can get only grid layout control only\nand internal things I cant able to get the controls\n(I tried with print _control_identifiers() , Swapy, AutoIT Window Info and winspy also..)\nanyone plz tell me how to automate visual studio C#  DataGridView  and its sub controls using pywinauto for desktop application??","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1878,"Q_Id":14101063,"Users Score":3,"Answer":"The short answer is that there's no good way to automate sub-controls of a DataGridView using PyWinAuto.\nIf you want to read data out of a DataGridView (e.g. read the text contents of a cell, or determine whether a checkbox is checked), you are completely out of luck.  If you want to control a DataGridView, there are two approaches that you can try:\n\nclicking at various coordinate offsets.  \nsending keypresses to it to mimic keyboard navigation.  \n\nThese may work if your DataGridView has a small amount of data in it, but once the DataGridView starts needing scrollbars you're out of luck.  Furthermore, clicking at offsets is sensitive to the sizes of the rows and columns, and if the columns can be resized then this approach will never be reliable.","Q_Score":0,"Tags":"c#,python,ui-automation,pywinauto","A_Id":14104632,"CreationDate":"2012-12-31T11:36:00.000","Title":"C# GUI automation using PyWinAuto","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just written a python script to do some batch file operations. I was wondering how i could keep it in some common path like rest of the command line utilities like cd, ls, grep etc.\nWhat i expect is something like this to be done from any directory -\n$ script.py arg1 arg2","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":14113906,"Users Score":0,"Answer":"Add the directory it is stored in to your PATH variable? From your prompt, I'm guessing you're using an sh-like shell and from your tags, I'm further assuming OS X. Go into your .bashrc and make the necessary changes.","Q_Score":0,"Tags":"python,macos,command-line","A_Id":14113933,"CreationDate":"2013-01-01T20:23:00.000","Title":"How to execute a python command line utility from the terminal in any directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just written a python script to do some batch file operations. I was wondering how i could keep it in some common path like rest of the command line utilities like cd, ls, grep etc.\nWhat i expect is something like this to be done from any directory -\n$ script.py arg1 arg2","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":14113906,"Users Score":1,"Answer":"Just put the script directory into the PATH environment variable, or alternatively put the script in a location that is already in the PATH. On Unix systems, you usually use \/home\/<nick>\/bin for your own scripts and add that to the PATH.","Q_Score":0,"Tags":"python,macos,command-line","A_Id":14113928,"CreationDate":"2013-01-01T20:23:00.000","Title":"How to execute a python command line utility from the terminal in any directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to build use my Raspberry Pi as a media station. It should be able to play songs via commands over the network. These commands should be handled by a server written in Python. Therefor, I need a way to control audio playback via Python.\nI decided to use a command line music player for linux since those should offer the most flexibility for audio file formats. Also, Python libraries like PyAudio and PyMedia don't seem to work for me.\nI don't really have great expectations about the music player. It must be possible to play and pause sound files in as much codecs as possible and turn the volume up and down. Also it has to be a headless player since I am not running any desktop environment. There are a lot of players like that out there, it seems. mpg123 for example, works well for all I need.\nThe problem I have now is that all of these players seem to have a user interface written in ncurses and I have no idea how to access this with the Python subprocess module. So, I either need a music player which comes with Python bindings or one which can be controlled with the command line via the subprocess module. At least these are the solutions I thought about by now.\nDoes anyone know about a command line audio player for linux that would solve my problem? Or is there any other way?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2048,"Q_Id":14120045,"Users Score":3,"Answer":"mpd should be perfect for you. It is a daemon and can be controlled by various clients, ranging from GUI-less command-line clients like mpc to GUI command-line clients like ncmpc and ncmpcpp up to several full-featured desktop clients.\nmpd + mpc should do the job for you as mpc can be easily controlled via the command line and is also able to provide various status information about the currently played song and other things.\nIt seems like there is already a python client library available for mpd - python-mpd.","Q_Score":3,"Tags":"python,linux,audio","A_Id":14120125,"CreationDate":"2013-01-02T10:02:00.000","Title":"Python-controllable command line audio player for Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter (\"J\" for example) so that when I take a picture with the letter \"J\" on it, the software will compare the image to the model and detect the letter \"J\".\nHow would I create the model?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":14130010,"Users Score":0,"Answer":"If I were going to do this, I would use normalized floats. \nThe letter A would be:\n[(0.0,0.0),(0.5,1.0),(1.0,0.0),(0.1,0.5)(0.9,0.5)]\nUpdate (further explanation)\nSo my thought is that you should be able to uniquely identify a letter with an array of normalized points.   Points would be at important features of the letter such as start, end, and midpoints of a line.  Curves would be sliced up into multiple smaller line segments, which would also be represented by points.\nTo use this model, the source image would be analyzed.  You would then analyze the image for text.  You could use edge detection and other methods to find text.  You'd also have to analyze for any transforms on the text.  After you figure out the transform of the text, you would split the text into characters, then analyze the character for the points of important features.  Then you would write an algorithm to normalize the points, and determine which model represents the found points most accurately.","Q_Score":2,"Tags":"java,python,image,image-recognition","A_Id":14130289,"CreationDate":"2013-01-02T22:09:00.000","Title":"Creating an Image model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter (\"J\" for example) so that when I take a picture with the letter \"J\" on it, the software will compare the image to the model and detect the letter \"J\".\nHow would I create the model?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":14130010,"Users Score":0,"Answer":"You can use OpenCv library for java , this library contain Template Matching Model already implemented \nbut the better thing for image recognition is using learning machine or neural network","Q_Score":2,"Tags":"java,python,image,image-recognition","A_Id":14130097,"CreationDate":"2013-01-02T22:09:00.000","Title":"Creating an Image model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter (\"J\" for example) so that when I take a picture with the letter \"J\" on it, the software will compare the image to the model and detect the letter \"J\".\nHow would I create the model?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":203,"Q_Id":14130010,"Users Score":2,"Answer":"It seems you want to do OCR (Optical Character Recognition).\nIf this is only part of a larger project, try OpenCV. Even if you are making a commercial product, it has a permissive BSD license.\nIf you have set out to make a library of your own, read some of the papers available through any good search engine. There are many tutorials for machine learning and neural nets, which could produce the image models you want.","Q_Score":2,"Tags":"java,python,image,image-recognition","A_Id":14130216,"CreationDate":"2013-01-02T22:09:00.000","Title":"Creating an Image model","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"EDIT\nOne option I contemplated but don't know enough about is to e.g. for windows write a batch script to:\n\nSearch for a Python installation, download one and install if not present\nThen install the bundled package using distutils to also handle dependencies. \n\nIt seems like this could be a relatively elegant and simple solution, but I'm not sure how to proceed - any ideas?\nOriginal Question\nIn brief\nWhat approach would you recommend for the following scenario?\n\nLinux development environment for creation of technical applications\nDeployment now also to be on Windows and Mac\nExisting code-base in Python\nwine won't install windows version of Python\nNo windows install CDs available to create virtual windows\/mac machines\nPorting to java incurs large overhead because of existing code-base\nClients are not technical users, i.e. providing standard Python packages not sufficient - really requires installable self-contained products\n\nBackground\nI am writing technical and scientific apps under Linux but will need some of them to be deployable on Windows\/MacOs machines too. \nIn the past I have used Python a lot, but I am finding that for non-technical users who aren't happy installing python packages, creating a simple executable (by using e.g. py2exe) is difficult as I can't get the windows version of Python to install using wine. \nWhile java would seem a good choice, if possible I wanted to avoid having to port my existing code from Python, especially as Python also allows writing portable code. \nI realize I'm trying to cover a lot of bases here, so any suggestions regarding the most appropriate solutions (even if not perfect) will be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1886,"Q_Id":14139377,"Users Score":0,"Answer":"I would recommend using py2exe for the windows side, and then BuildApplet for the mac side. This will allow you to make a simple app you double click for your less savvy users.","Q_Score":5,"Tags":"python,batch-file,cross-platform,py2exe,scientific-computing","A_Id":14139446,"CreationDate":"2013-01-03T12:54:00.000","Title":"Cross-platform deployment and easy installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"EDIT\nOne option I contemplated but don't know enough about is to e.g. for windows write a batch script to:\n\nSearch for a Python installation, download one and install if not present\nThen install the bundled package using distutils to also handle dependencies. \n\nIt seems like this could be a relatively elegant and simple solution, but I'm not sure how to proceed - any ideas?\nOriginal Question\nIn brief\nWhat approach would you recommend for the following scenario?\n\nLinux development environment for creation of technical applications\nDeployment now also to be on Windows and Mac\nExisting code-base in Python\nwine won't install windows version of Python\nNo windows install CDs available to create virtual windows\/mac machines\nPorting to java incurs large overhead because of existing code-base\nClients are not technical users, i.e. providing standard Python packages not sufficient - really requires installable self-contained products\n\nBackground\nI am writing technical and scientific apps under Linux but will need some of them to be deployable on Windows\/MacOs machines too. \nIn the past I have used Python a lot, but I am finding that for non-technical users who aren't happy installing python packages, creating a simple executable (by using e.g. py2exe) is difficult as I can't get the windows version of Python to install using wine. \nWhile java would seem a good choice, if possible I wanted to avoid having to port my existing code from Python, especially as Python also allows writing portable code. \nI realize I'm trying to cover a lot of bases here, so any suggestions regarding the most appropriate solutions (even if not perfect) will be appreciated.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":1886,"Q_Id":14139377,"Users Score":2,"Answer":"py2exe works pretty well, I guess you just have to setup a Windows box (or VM) to be able to build packages with it.","Q_Score":5,"Tags":"python,batch-file,cross-platform,py2exe,scientific-computing","A_Id":14139409,"CreationDate":"2013-01-03T12:54:00.000","Title":"Cross-platform deployment and easy installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have thousands of servers(linux), some only has python 2.x and some only has python 3.x, i want to write one script check.py can run on all servers just as $.\/check.py without use $python check.py or $python3 check.py, is there any way to do this?\nmy question is how the script check.py find the Interpreter no matter the Interpreter is python2.x and python3.x","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5143,"Q_Id":14152548,"Users Score":0,"Answer":"In the general case, no; many Python 2 scripts will not run on Python 3, and vice versa. They are two different languages.\nHaving said that, if you are careful, you can write a script which will run correctly under both. Some authors take extra care to make sure their scripts will be compatible across both versions, commonly using additional tools like the six library (the name is a pun; you can get to \"six\" by multiplying \"two by three\" or \"three by two\").\nHowever, it is now 2020, and Python 2 is officially dead. Many maintainers who previously strove to maintain Python 2 compatibility while it was still supported will now be relieved and often outright happy to pull the plug on it going forward.","Q_Score":7,"Tags":"python,python-3.x","A_Id":64151445,"CreationDate":"2013-01-04T06:55:00.000","Title":"can one python script run both with python 2.x and python 3.x","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have thousands of servers(linux), some only has python 2.x and some only has python 3.x, i want to write one script check.py can run on all servers just as $.\/check.py without use $python check.py or $python3 check.py, is there any way to do this?\nmy question is how the script check.py find the Interpreter no matter the Interpreter is python2.x and python3.x","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5143,"Q_Id":14152548,"Users Score":0,"Answer":"Considering that Python 3.x is not entirely backwards compatible with Python 2.x, you would have to ensure that the script was compatible with both versions.  This can be done with some help from the 2to3 tool, but may ultimately mean running two distinct Python scripts.","Q_Score":7,"Tags":"python,python-3.x","A_Id":14152613,"CreationDate":"2013-01-04T06:55:00.000","Title":"can one python script run both with python 2.x and python 3.x","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using hosted exchange Microsoft Office 365 email and I have a Python script that sends email with smtplib. It is working very well. But there is one issue, how can I get the emails to show up in my Outlook Sent Items?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1550,"Q_Id":14153954,"Users Score":2,"Answer":"You can send a copy of that email to yourself, with some header that tag the email was sent by yourself, then get another script (using IMAP library maybe) to move the email to the Outlook Sent folder","Q_Score":4,"Tags":"python,outlook,smtplib","A_Id":14154176,"CreationDate":"2013-01-04T08:57:00.000","Title":"How can I see emails sent with Python's smtplib in my Outlook Sent Items folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set local\/globals variables in PyRun_InteractiveLoop call.\nCant figure out how to do it, since, unlike exec counterparts, loop doesn't accept global\/local args.\nWhat am I missing?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":14162140,"Users Score":0,"Answer":"If what you want is a C API version of exec, maybe try PyRun_File and its ilk?  Not sure exactly what you're trying to accomplish though.","Q_Score":1,"Tags":"python","A_Id":14162418,"CreationDate":"2013-01-04T17:45:00.000","Title":"PyRun_InteractiveLoop globals\/locals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a bucket with publicly accessible contents, how can I get a listing of all those publicly accessible contents? I know boto can do this, but boto requires AWS credentials. Also, boto doesn't work in Python3, which is what I'm working with.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1214,"Q_Id":14177436,"Users Score":0,"Answer":"Using AWS CLI,\naws s3 ls s3:\/\/*bucketname* --region *bucket-region* --no-sign-request","Q_Score":3,"Tags":"python-3.x,amazon-web-services,amazon-s3","A_Id":70791596,"CreationDate":"2013-01-05T23:11:00.000","Title":"Get publicly accessible contents of S3 bucket without AWS credentials","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a bucket with publicly accessible contents, how can I get a listing of all those publicly accessible contents? I know boto can do this, but boto requires AWS credentials. Also, boto doesn't work in Python3, which is what I'm working with.","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":1214,"Q_Id":14177436,"Users Score":4,"Answer":"If the bucket's permissions allow Everyone to list it, you can just do a simple HTTP GET request to http:\/\/s3.amazonaws.com\/bucketname with no credentials. The response will be XML with everything in it, whether those objects are accessible by Everyone or not. I don't know if boto has an option to make this request without credentials. If not, you'll have to use lower-level HTTP and XML libraries.\nIf the bucket itself does not allow Everyone to list it, there is no way to get a list of its contents, even if some of the objects in it are publicly accessible.","Q_Score":3,"Tags":"python-3.x,amazon-web-services,amazon-s3","A_Id":14199730,"CreationDate":"2013-01-05T23:11:00.000","Title":"Get publicly accessible contents of S3 bucket without AWS credentials","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building project with Django, I can make two setting files for Django: production_setting.py and development_setting.py, however, I need some configure file for my project and I'm using ConfigParser to parse that files. e.g.\n\n[Section]\nname = \"development\"\nversion = \"1.0\"\n\nhow to split this configure file to production and development?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":14191034,"Users Score":1,"Answer":"What we usually do in our Django projects is create versions of all configuration files for each platform (dev, prod, etc...) and use symlinks to select the correct one. Now that Windows supports links properly, this solution fits everybody.\nIf you insist on another configuration file, try making it a Python file that just imports the proper configuration file, so instead of name=\"development\" you'll have something like execfile('development_settings.py')","Q_Score":0,"Tags":"python,django","A_Id":14191085,"CreationDate":"2013-01-07T06:34:00.000","Title":"python project setting for production and developement","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I call foreign c library in my program using ctypes, I don't know how to assign a POINTER(c_char) variant to a string.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":14191462,"Users Score":0,"Answer":"The question is vague, but I guess you should use c_char_p instead of POINTER(c_char).","Q_Score":0,"Tags":"python,python-2.7","A_Id":14193534,"CreationDate":"2013-01-07T07:12:00.000","Title":"How can I assign a variant of POINTER(c_char) type to a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on an educative multiseat project where we need to connect 36 keyboards and 36 USB sound cards to a single computer. We're running Ubuntu Linux 12.04 with the 3.6.3-030603-generic kernel.\nSo far we've managed to get the input from the 36 keyboards, and recognized the 36 sound cards without getting a kernel panic (which happened before updating the kernel). We know the 36 sound cards have been recognized because $ lsusb | grep \"Audio\" -c outputs 36.\nHowever, $ aplay -l lists 32 playback devices in total (including the \"internal\" sound card). Also, $ alsamixer -c 32 says \"invalid card index: 32\" (works just from 0 through 31 ; 32 in total too).\nSo my question is, how can I access the other sound cards if they're not even listed with these commands? I'm writing an application in python and there are some libraries to choose from, but I'm afraid they'll also be limited to 32 devices in total because of this. Any guidance will be useful.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1112,"Q_Id":14201551,"Users Score":3,"Answer":"The sound card limit is defined as the symbol SNDRV_CARDS in include\/sound\/core.h.\nWhen I increased this seven years ago, I did not go beyond 32 because the card index is used as a bit index for the variable snd_cards_lock in sound\/core\/init.c, and I did not want to change more than necessary.\nIf you make snd_cards_lock a 64-bit variable, change all accesses to use a 64-bit type, and adjust any other side effect that I might have forgotten about, you should be able to get the kernel to have more ALSA cards.\nThis limit also exists in the alsa-lib package; you will have to change at least the check in snd_ctl_hw_open in src\/control\/control_hw.c.","Q_Score":6,"Tags":"python,linux,alsa,udev,soundcard","A_Id":14203491,"CreationDate":"2013-01-07T18:08:00.000","Title":"Need more than 32 USB sound cards on my system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am totally new to Python, and I have to use some modules in my code, like numpy and scipy, but I have no permission on my hosting to install new modules using easy-install or pip ( and of course I don't know how to install new modules in a directory where I have permission [ I have SSH access ] ).\nI have downloaded numpy and used from numpy import * but it doesn't work. I also tried the same thing with scipy : from scipy import *, but it also don't work.\nHow to load \/ use new modules in Python without installing them [ numpy, scipy .. ] ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1476,"Q_Id":14242764,"Users Score":0,"Answer":"Use the --user option to easy_install or setup.py to indicate where the installation is to take place. It should point to a directory where you have write access.\nOnce the module has been built and installed, you then need to set the environmental variable PYTHONPATH to point to that location. When you next run the python command, you should be able to import the module.","Q_Score":1,"Tags":"python,numpy,scipy,python-module","A_Id":14242912,"CreationDate":"2013-01-09T17:18:00.000","Title":"use \/ load new python module without installation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I haven't seen an example of this but I wanted to know if any knows how to implement a colorbar with an adjustable slider using wxpython.  Basically the slider should change the levels of the colorbar and as such adjust the colormap.\nIf anyone has an idea of how to do and possible some example code it would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":386,"Q_Id":14244195,"Users Score":1,"Answer":"I think you're looking for one of the following widgets:\nColourDialog, ColourSelect, PyColourChooser or CubeColourDialog\nThey all let you choose colors in different ways and they have a slider to help adjust the colours too.\nYou can see each of them in action in the wxPython demo (downloadable from the wxPython web page)","Q_Score":0,"Tags":"python,slider,wxpython,color-mapping","A_Id":14260324,"CreationDate":"2013-01-09T18:41:00.000","Title":"colorbar with a slider using wxpython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: \"Registered online\", \"Accepts email notifications\" etc) and continuous data (ex: \"Age\", \"Length of membership\" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":29596,"Q_Id":14254203,"Users Score":15,"Answer":"The simple answer: multiply result!! it's the same.\nNaive Bayes based on applying Bayes\u2019 theorem with the \u201cnaive\u201d assumption of independence between every pair of features - meaning you calculate the Bayes probability dependent on a specific feature without holding the others - which means that the algorithm multiply each probability from one feature with the probability from the second feature (and we totally ignore the denominator - since it is just a normalizer).\nso the right answer is:\n\ncalculate the probability from the categorical variables.\ncalculate the probability from the continuous variables.\nmultiply 1. and 2.","Q_Score":76,"Tags":"python,machine-learning,data-mining,classification,scikit-learn","A_Id":34036255,"CreationDate":"2013-01-10T09:08:00.000","Title":"Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: \"Registered online\", \"Accepts email notifications\" etc) and continuous data (ex: \"Age\", \"Length of membership\" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":29596,"Q_Id":14254203,"Users Score":0,"Answer":"You will need the following steps:\n\nCalculate the probability from the categorical variables (using predict_proba method from BernoulliNB)\nCalculate the probability from the continuous variables (using predict_proba method from GaussianNB)\nMultiply 1. and 2. AND\nDivide by the prior (either from BernoulliNB or from GaussianNB since they are the same) AND THEN\nDivide 4. by the sum (over the classes) of 4. This is the normalisation step.\n\nIt should be easy enough to see how you can add your own prior instead of using those learned from the data.","Q_Score":76,"Tags":"python,machine-learning,data-mining,classification,scikit-learn","A_Id":69929209,"CreationDate":"2013-01-10T09:08:00.000","Title":"Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: \"Registered online\", \"Accepts email notifications\" etc) and continuous data (ex: \"Age\", \"Length of membership\" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":29596,"Q_Id":14254203,"Users Score":74,"Answer":"You have at least two options:\n\nTransform all your data into a categorical representation by computing percentiles for each continuous variables and then binning the continuous variables using the percentiles as bin boundaries. For instance for the height of a person create the following bins: \"very small\", \"small\", \"regular\", \"big\", \"very big\" ensuring that each bin contains approximately 20% of the population of your training set. We don't have any utility to perform this automatically in scikit-learn but it should not be too complicated to do it yourself. Then fit a unique multinomial NB on those categorical representation of your data.\nIndependently fit a gaussian NB model on the continuous part of the data and a multinomial NB model on the categorical part. Then transform all the dataset by taking the class assignment probabilities (with predict_proba method) as new features: np.hstack((multinomial_probas, gaussian_probas)) and then refit a new model (e.g. a new gaussian NB) on the new features.","Q_Score":76,"Tags":"python,machine-learning,data-mining,classification,scikit-learn","A_Id":14255284,"CreationDate":"2013-01-10T09:08:00.000","Title":"Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a twisted ReconnectingClientFactory and i can successfully connect to given ip and port couple with this factory. And it works well.\n\nreactor.connectTCP(ip, port, myHandsomeReconnectingClientFactory)\n\nIn this situation, when the server is gone, myHandsomeReconnectingClientFactory tries to connect same ip and port (as expected).\nMy goal is, when the server which serves on given ip and port couple is gone, connecting to a backup server (which have different ip and port).\nAny ideas\/comments on how to achieve this goal will be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1504,"Q_Id":14255289,"Users Score":2,"Answer":"ReconnectingClientFactory doesn't have this capability.  You can build your own factory which implements this kind of reconnection logic, mostly by hooking into the clientConnectionFailed factory method.  When this is called and the reason seems to you like that justifies switching servers (eg, twisted.internet.error.ConnectionRefused), pick the next address on your list and use the appropriate reactor.connectXYZ method to try connecting to it.\nYou could also try constructing this as an endpoint (which is the newer high-level connection setup API that is preferred by some), but handling reconnection with endpoints is not yet a well documented topic.","Q_Score":4,"Tags":"python,python-2.7,twisted,failover","A_Id":14266178,"CreationDate":"2013-01-10T10:08:00.000","Title":"Twisted: ReconnectingClientFactory connection to different servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?\nAn example being pylint - where I'd want the virtual env version and not the system one to run.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3302,"Q_Id":14278009,"Users Score":0,"Answer":"In Tool Settings, set Program: to $PyInterpreterDirectory$\/pylint","Q_Score":9,"Tags":"python,virtualenv,pycharm,pylint","A_Id":71898652,"CreationDate":"2013-01-11T12:14:00.000","Title":"Pycharm External tools relative to Virtual Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?\nAn example being pylint - where I'd want the virtual env version and not the system one to run.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3302,"Q_Id":14278009,"Users Score":0,"Answer":"just found your post while looking for documentation about the \"variables\" that could bew used when setting parameters for external tools.\nNo documentation but you can see a list of all the available stuff after pressing thE \"INSERT MACRO\" button in the Edit Tool dialog. \nI don't see any reference to the interpreter path there but I usually use the virtualenv as my project path. If you are doing that too you could infer the python interpreter path from there.","Q_Score":9,"Tags":"python,virtualenv,pycharm,pylint","A_Id":14508728,"CreationDate":"2013-01-11T12:14:00.000","Title":"Pycharm External tools relative to Virtual Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?\nAn example being pylint - where I'd want the virtual env version and not the system one to run.","AnswerCount":4,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":3302,"Q_Id":14278009,"Users Score":16,"Answer":"Not sure about older versions, but in PyCharm 5 one can use $PyInterpreterDirectory$ macro. It's exactly that we want","Q_Score":9,"Tags":"python,virtualenv,pycharm,pylint","A_Id":33673270,"CreationDate":"2013-01-11T12:14:00.000","Title":"Pycharm External tools relative to Virtual Environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having the idea of writing a program using Python which shall find a lyric of a song whose name I provided. I think the whole process should boil down to couple of things below. These are what I want the program to do when I run it:\n\nprompt me to enter a name of a song\ncopy that name\nopen a web browser (google chrome for example)\npaste that name in the address bar and find information about the song\nopen a page that contains the lyrics\ncopy that lyrics\nrun a text editor (like Microsoft Word for instance)\npaste the lyrics\nsave the new text file with the name of the song\n\nI am not asking for code, of course. I just want to know the concepts or ideas about how to use python to interact with other programs\nTo be more specific, I think I want to know, fox example, just how we point out where is the address bar in Google Chrome and tell python to paste the name there. Or how we tell python how to copy the lyrics as well as paste it into the Microsof Word's sheet then save it.\nI've been reading (I'm still reading) several books on Python: Byte of python, Learn python the hard way, Python for dummies, Beginning Game Development with Python and Pygame. However, I found out that it seems like I only (or almost only) learn to creat programs that work on itself (I can't tell my program to do things I want with other programs that are already installed on my computer)\nI know that my question somehow sounds rather silly, but I really want to know how it works, the way we tell Python to regconize that this part of the Google chrome browser is the address bar and that it should paste the name of the song in it. The whole idea of making python interact with another program is really really vague to me and I just \nextremely want to grasp that.\nThank you everyone, whoever spend their time reading my so-long question.\nttriet204","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":89546,"Q_Id":14288177,"Users Score":1,"Answer":"You should look into a package called selenium for interacting with web browsers","Q_Score":27,"Tags":"python,automation,interop,concept","A_Id":14288210,"CreationDate":"2013-01-11T23:13:00.000","Title":"Interact with other programs using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm a Python guy building a Linux-based web service for a client who wants me to interface with a small C++ library that they're currently using with a bunch of Windows based VB applications.\nThey have assured me that the library is fairly simple (as far as they go I guess), and that they just need to know how best to compile and deliver it to me so that I can use it in Python under Linux.\nI've read a bit about the ctypes library and other options (SWIG, etc), but for some reason I haven't really been able to wrap my head around the concept and still don't know how to tell them what I need.\nI'm pretty sure having them re-write it with Python.h, etc is out, so I'm hoping there's a way I can simply have them compile it on Linux as a .so and just import it into Python. Is such a thing possible? How does one accomplish this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":201,"Q_Id":14289656,"Users Score":0,"Answer":"Due to complexities of the C++ ABI (such as name mangling), it's generally difficult and platform-specific to load a C++ library directly from Python using ctypes.\nI'd recommend you either create a simple C API which can be easily wrapped with ctypes, or use SWIG to generate wrapper types and a proper extension module for Python.","Q_Score":0,"Tags":"c++,python","A_Id":14289688,"CreationDate":"2013-01-12T02:41:00.000","Title":"How does one get a C++ library loaded into Python as a shared object file (.so)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anybody tell me how I can return the dimensions of a video (pixel height\/width) using Qt (or any other Python route to that information).  I have googled the hell out of it and cannot find a straight answer.\nI assumed it would either be mediaobject.metadata() or os.stat() but neither appear to return the required info.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":305,"Q_Id":14323390,"Users Score":0,"Answer":"OK - for others out there looking for the same info, I found Hachoir-metadata and Hachoir-parser (https:\/\/bitbucket.org\/haypo\/hachoir\/wiki\/Home).\nThey provide the correct info but there is a serious lack of docs for it and not that many examples that I can find.  Therefore, while I have parsed a video file and returned the metadata for it, I'm now struggling to 'get' that information in a usable format.  However, I will not be defeated!","Q_Score":0,"Tags":"python,qt,video,pyside,phonon","A_Id":14509771,"CreationDate":"2013-01-14T17:21:00.000","Title":"qt phonon - returning video dimensions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For e.g. if we have an array in python arr = [1,3,4]. We can delete element in the array by just using arr.remove(element) ot arr.pop() and list will mutate and it's length will change and that element won't be there. Is there a way to do this is C ot C++?. If yes the how to do that?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2120,"Q_Id":14355747,"Users Score":0,"Answer":"As I understand, you don't want or able to use standard library (BTW, why?).\nYou can look into the code of the vector template in one of STL implementations and see, how it's implemented.\nThe basic algorithm is simple. If you're deleting something from the middle of the array, you must shrink it after. If you're inserting into the middle - you must expand it before. Sometimes it involves memory reallocation and moving you array, by memcpy for example.\nOr you can implement double-linked list as mentioned. But it won't behave like array.","Q_Score":0,"Tags":"c++,python,c,list","A_Id":14355997,"CreationDate":"2013-01-16T10:05:00.000","Title":"Python list and c\/c++ arrays","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For e.g. if we have an array in python arr = [1,3,4]. We can delete element in the array by just using arr.remove(element) ot arr.pop() and list will mutate and it's length will change and that element won't be there. Is there a way to do this is C ot C++?. If yes the how to do that?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2120,"Q_Id":14355747,"Users Score":0,"Answer":"In C++ either you can use std::list or std::vector based on your mileage\nIf you need to implement in C, you need to write your double-link list implementation or if you wan't to emulate std::vector, you can do so by using memcpy and array indexing","Q_Score":0,"Tags":"c++,python,c,list","A_Id":14355936,"CreationDate":"2013-01-16T10:05:00.000","Title":"Python list and c\/c++ arrays","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For e.g. if we have an array in python arr = [1,3,4]. We can delete element in the array by just using arr.remove(element) ot arr.pop() and list will mutate and it's length will change and that element won't be there. Is there a way to do this is C ot C++?. If yes the how to do that?","AnswerCount":4,"Available Count":3,"Score":0.2449186624,"is_accepted":false,"ViewCount":2120,"Q_Id":14355747,"Users Score":5,"Answer":"I guess you're looking for std::vector (or other containers in the standard library).","Q_Score":0,"Tags":"c++,python,c,list","A_Id":14355769,"CreationDate":"2013-01-16T10:05:00.000","Title":"Python list and c\/c++ arrays","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My Question is a bit complex and iam new to OpenERP.\nI have an external database and an OpenERP. the external one isn't PostgreSQL. \nMY job is that I need to synchronize the partners in the two databases. \nExternal one being the more important. This means that if the external one's data change so does the OpenERp's, but if OpenERP's data changes nothing changes onthe external one.\n\nI can access to the external database, and using XML RCP I have acces\nto OpenERP's as well. \nI can import data from the external database simply with XML RCP but \nthe problem is the sync.\nI can't just INSERT the modified partner and delete the old one\nbecause i have no way to identify the old one.\nI need to UPDATE it. But then i need an id that says which is which. \nand external ID.\nTo my knowledge OpenERP can handle external IDs.\n\nHow does this work? and how can i add an external ID to my res.partner using this?\nI was told that I cant create a new module for this alone I need to use the internal ID works.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4853,"Q_Id":14356218,"Users Score":0,"Answer":"Add an integer field in res partner table for storing external id on both database. When data is retrived from the external server and adding to your openerp database, store the external id in the record of res partner in local server and also save the id of the newly created partner record in the external server's partner record. So next time when the external partner record is updated, we can search the external id in our local server and update that record. \nPlease check the openerp module base_synchronization and read the codes, which will be helpful for you.","Q_Score":6,"Tags":"python,xml-rpc,openerp","A_Id":14356856,"CreationDate":"2013-01-16T10:27:00.000","Title":"Adding external Ids to Partners in OpenERP withouth a new module","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a web-app that's very heavily database driven. I'm nearing the initial release and so I've locked down the features for this version, but there are going to be lots of other features implemented after release. These features will inevitably require some modification to the database models, so I'm concerned about the complexity of migrating the database on each release. What I'd like to know is how much should I concern myself with locking down a solid database design now so that I can release quickly, against trying to anticipate certain features now so that I can build it into the database before release? I'm also anticipating finding flaws with my current model and would probably then want to make changes to it, but if I release the app and then data starts coming in, migrating the data would be a difficult task I imagine. Are there conventional methods to tackle this type of problem? A point in the right direction would be very useful.\nFor a bit of background I'm developing an asset management system for a CG production pipeline. So lots of pieces of data with lots of connections between them. It's web-based, written entirely in Python and it uses SQLAlchemy with a SQLite engine.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":14364214,"Users Score":2,"Answer":"Some thoughts for managing databases for a production application:\n\nMake backups nightly. This is crucial because if you try to do an update (to the data or the schema), and you mess up, you'll need to be able to revert to something more stable.\nCreate environments. You should have something like a local copy of the database for development, a staging database for other people to see and test before going live and of course a production database that your live system points to.\nMake sure all three environments are in sync before you start development locally.  This way you can track changes over time.\nStart writing scripts and version them for releases.  Make sure you store these in a source control system (SVN, Git, etc.)  You just want a historical record of what has changed and also a small set of scripts that need to be run with a given release.  Just helps you stay organized.\nDo your changes to your local database and test it.  Make sure you have scripts that do two things, 1) Scripts that modify the data, or the schema, 2) Scripts that undo what you've done in case things go wrong.  Test these over and over locally.  Run the scripts, test and then rollback.  Are things still ok?\nRun the scripts on staging and see if everything is still ok.  Just another chance to prove your work is good and that if needed you can undo your changes.\nOnce staging is good and you feel confident, run your scripts on the production database.  Remember you have scripts to change data (update, delete statements) and scripts to change schema (add fields, rename fields, add tables).\n\nIn general take your time and be very deliberate in your actions.  The more disciplined you are the more confident you'll be.  Updating the database can be scary, so don't rush things, write out your plan of action, and test, test, test!","Q_Score":1,"Tags":"python,database,migration,sqlalchemy","A_Id":14364804,"CreationDate":"2013-01-16T17:29:00.000","Title":"How to approach updating an database-driven application after release?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I want to query and display all the images that the user just uploaded through a form on the previous page (multiple images are uploaded at once, each is made into a separate object in the db).\nWhat's the best way to do this?\nSince the view for uploading the images is different from the view for displaying the images, how does the second view know which images were part of that upload? I thought about creating and saving the image objects in the first view, gathering the pks, and passing them to the second view, but I understand that it is bad practice. So how should I make sure the second view knows which primary keys to query for?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":14367670,"Users Score":0,"Answer":"What other fields are there in the model db?\nYou could add an upload_id, which is set automatically after uploading, send it to the next view, and query for that in the db.","Q_Score":0,"Tags":"python,django,django-models,django-forms,django-views","A_Id":14367745,"CreationDate":"2013-01-16T20:55:00.000","Title":"Django: How to query objects immediately after they have been saved from a separate view?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed pytest 2.3.4 under Debian Linux.  By default it runs under Python 2.7, but sometimes I'd like to run it under Python 3.x, which is also installed.  I can't seem to find any instructions on how to do that.\nThe PyPI Trove classifiers show Python :: 3 so presumably it must be possible.  Aside from py.test somedir\/sometest.py, I can use python -m pytest ..., or even python2.7 -m pytest ..., but if I try python3 -m pytest ... I get\n\/usr\/bin\/python3: No module named pytest","AnswerCount":6,"Available Count":3,"Score":0.1651404129,"is_accepted":false,"ViewCount":65185,"Q_Id":14371156,"Users Score":5,"Answer":"Install it with pip3:\npip3 install -U pytest","Q_Score":61,"Tags":"python,python-3.x,pytest","A_Id":59968198,"CreationDate":"2013-01-17T02:11:00.000","Title":"Pytest and Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've installed pytest 2.3.4 under Debian Linux.  By default it runs under Python 2.7, but sometimes I'd like to run it under Python 3.x, which is also installed.  I can't seem to find any instructions on how to do that.\nThe PyPI Trove classifiers show Python :: 3 so presumably it must be possible.  Aside from py.test somedir\/sometest.py, I can use python -m pytest ..., or even python2.7 -m pytest ..., but if I try python3 -m pytest ... I get\n\/usr\/bin\/python3: No module named pytest","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":65185,"Q_Id":14371156,"Users Score":27,"Answer":"python3 doesn't have the module py.test installed.  If you can, install the python3-pytest package.\nIf you can't do that try this:\n\nInstall virtualenv\nCreate a virtualenv for python3\n\nvirtualenv --python=python3 env_name\n\nActivate the virtualenv\n\nsource .\/env_name\/bin\/activate\n\nInstall py.test\n\npip install py.test\n\nNow using this virtualenv try to run your tests","Q_Score":61,"Tags":"python,python-3.x,pytest","A_Id":14371623,"CreationDate":"2013-01-17T02:11:00.000","Title":"Pytest and Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've installed pytest 2.3.4 under Debian Linux.  By default it runs under Python 2.7, but sometimes I'd like to run it under Python 3.x, which is also installed.  I can't seem to find any instructions on how to do that.\nThe PyPI Trove classifiers show Python :: 3 so presumably it must be possible.  Aside from py.test somedir\/sometest.py, I can use python -m pytest ..., or even python2.7 -m pytest ..., but if I try python3 -m pytest ... I get\n\/usr\/bin\/python3: No module named pytest","AnswerCount":6,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":65185,"Q_Id":14371156,"Users Score":69,"Answer":"I found a workaround:\n\nInstalled python3-pip using aptitude, which created \/usr\/bin\/pip-3.2.  \nNext pip-3.2 install pytest which re-installed pytest, but under a python3.2 path.\nThen I was able to use python3 -m pytest somedir\/sometest.py.\n\nNot as convenient as running py.test directly, but workable.","Q_Score":61,"Tags":"python,python-3.x,pytest","A_Id":14371849,"CreationDate":"2013-01-17T02:11:00.000","Title":"Pytest and Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a C++ application from Windows that I wish to port across to run on a Red Hat Linux system.  This application embeds a slightly modified version of Python 2.7.3 (I added the Py_SetPath command as it is essential for my use case) so I definitely need to compile the Python source.\nMy problem is that despite looking, I can't actually find any guidance on how to get Python to emit the right files for me to link against and how to then get g++ to link my C++ code against it in such a way that I don't need to have an installed copy of Python on every system I distribute this to.\nSo my questions are:\n\nhow do I compile Python so that it can be embedded into the C++ app on Linux?\nwhat am I linking against for the C++ app to work?\n\nSorry for these basic questions, but having convinced my employer to let me try and move our systems over to Linux, I'm keen to make it go off as smoothly as possible and I'm worried avbout not making too much progress!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":667,"Q_Id":14375397,"Users Score":1,"Answer":"You want to link to the python static library, which should get created by default and will be called libpython2.7.a\nIf I recall correctly, as long as you don't build Python with --enable-shared it  doesn't install the dynamic library, so you'll only get the static lib and so simply linking your C++ application with -lpython2.7 -L\/path\/where\/you\/installed\/python\/lib should link to the static library.","Q_Score":0,"Tags":"c++,python,gcc,g++,redhat","A_Id":14390969,"CreationDate":"2013-01-17T09:02:00.000","Title":"Compile Python 2.7.3 on Linux for Embedding into a C++ app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question and I tried to solve diff way with Jinja2. I have a number that is saved in database. When I print the original number is for ex: 907333-5000. I want that number to be printed in this format: (907) 333-5000 but I don't know exactly how to do with Jinja2. Thank you","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6415,"Q_Id":14377002,"Users Score":2,"Answer":"Or you can create a filter for phonenumbers like {{ phone_number|phone }}","Q_Score":0,"Tags":"python,substring,jinja2","A_Id":14386224,"CreationDate":"2013-01-17T10:30:00.000","Title":"Jinja2 substring integer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Created a gae project with the googleappengine launch and have been building it with textmate.\nNow, I'd like to import it to the Eclipse PyDev GAE project. Tried to import it, but it doesn't work.\nAnyone know how to do that? \nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":712,"Q_Id":14383025,"Users Score":0,"Answer":"If you want to use Eclipse's Import feature, go with General -> File system.","Q_Score":1,"Tags":"python,google-app-engine,pydev","A_Id":14387118,"CreationDate":"2013-01-17T15:58:00.000","Title":"Pydev: How to import a gae project to eclipse Pydev gae project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Created a gae project with the googleappengine launch and have been building it with textmate.\nNow, I'd like to import it to the Eclipse PyDev GAE project. Tried to import it, but it doesn't work.\nAnyone know how to do that? \nThanks in advance.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":712,"Q_Id":14383025,"Users Score":2,"Answer":"You could try not using the eclipse import feature. Within Eclipse, create a new PyDev GAE project, and then you can copy in your existing files.","Q_Score":1,"Tags":"python,google-app-engine,pydev","A_Id":14383720,"CreationDate":"2013-01-17T15:58:00.000","Title":"Pydev: How to import a gae project to eclipse Pydev gae project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The Situation\nAlright, so we have our app in appengine with full text search activated. We had an index set on a document with a field named 'date'. This field is a DateField and now we changed the model of the document so the field 'date' is now a NumericField. \nThe problem is, on the production server, even if I cleared all the document from the index, the server responds with this type of error: Failed to parse search request \"\"; SortSpec numeric default value does not match expression type 'TEXT' in 'date'\nThe Solution\nThe problem is, \"I think\", the fact that the model on the server doesn't fit the model of the search query. So basically, one way to do it, would be to delete the whole index, but I don't know how to do it on the production server.\nThe dev server works flawlessly","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2747,"Q_Id":14388251,"Users Score":7,"Answer":"If you empty out your index and call index.delete_schema() (index.deleteSchema() in Java) it will clear the mappings that we have from field name to type, and you can index your new documents as expected. Thanks!","Q_Score":5,"Tags":"python,google-app-engine,full-text-search","A_Id":14390379,"CreationDate":"2013-01-17T21:14:00.000","Title":"How to delete or reset a search index in Appengine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Displaying lines of LaTeX in IPython Notebook has been answered previously, but how do you, for example, label the axis of a plot with a LaTeX string when plotting in IPython Notebook?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":10151,"Q_Id":14389892,"Users Score":2,"Answer":"I ran into the problem posted in the comments: ! LaTeX Error: File 'type1cm.sty' not found.\nThe issue was that my default tex command was not pointing to my up-to-date MacTex distribution, but rather to an old distribution of tex which I had installed using macports a few years back and which wasn't being updated since I had switched to using MacTex. \nI diagnosed this by typing which tex on the command line and getting \/opt\/local\/bin\/tex which is not the default install location for MacTex. \nThe solution was that I had to edit my $PATH variable so that the right version of tex would get called by matplotlib. \nI added export PATH=\"\/usr\/local\/texlive\/2019\/bin\/x86_64-darwin:$PATH\" on the last line of my ~\/.bash_profile.\nNow when I write echo $PATH on the command line I get:\n\/usr\/local\/texlive\/2019\/bin\/x86_64-darwin:blah:blah:blah...\nDon't forget to restart both your terminal and your jupyter server afterwards for the changes to take effect.","Q_Score":1,"Tags":"python,matplotlib,latex,ipython,ipython-notebook","A_Id":57860793,"CreationDate":"2013-01-17T23:15:00.000","Title":"IPython Notebook: Plotting with LaTeX?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to be able to do the reverse of:\n\nfoo = long(binarystring.encode('hex'), 16)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":14396178,"Users Score":0,"Answer":"use binascii.hexlify() - that should do it","Q_Score":0,"Tags":"python,binary,hex","A_Id":14396302,"CreationDate":"2013-01-18T09:46:00.000","Title":"In Python how do you reverse this call: long(\"1234\", 16)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am working on a console based python(python3 actually) program where I use input(\">\")to get the command from user.\nNow I want to implement the \"last command\" function in my program - when users press the up arrow on the keyboard they can see their last command.\nAfter some research I found I can use curses lib to implement this but there are two problems.\n\nCurses are not available on Windows.\nThe other parts of my program use print() to do the output. I don't want to rewrite them with curses.\n\nSo are there any others ways to implement the \"last command\" function? Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":195,"Q_Id":14398980,"Users Score":1,"Answer":"What you can do, is to apply some sort of shell history functionality: every command issued by the user would be placed in a list, and then you'd implement a special call (command of your console), let's say 'history' that would print out the list for the user in order as it was being filled in, with increasing number to next to every command. Then, another call (again a special command of your console), let's say '!!' (but really coult be anything, like 'repeat') and a number of the command you want to repeat would fetch the command from the list and execute it without retyping: typing '!! 34' would execute again the command number 34 that can be 'something -a very -b long -c with -d very -e large -f number -g of -h arguments -666'.\nI am aware its not exactly the same thing that you wanted, but it is very easy to implement quickly, and provides the command repetition functionality you're after, and should be decent replacement until you figure out how to do it the way you want ;)","Q_Score":0,"Tags":"python,windows","A_Id":14399306,"CreationDate":"2013-01-18T12:28:00.000","Title":"How to implement \"last command\" function in a console based python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I try installing mysql-python using below command,\nmacbook-user$ sudo pip install MYSQL-python\nI get these messages:\n\n\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/include\/python2.7\/pyconfig.h:891:1: warning: this is the location of the previous definition\n\/usr\/bin\/lipo: \/tmp\/_mysql-LtlmLe.o and \/tmp\/_mysql-thwkfu.o have the same architectures (i386) and can't be in the same fat output file\nclang: error: lipo command failed with exit code 1 (use -v to see invocation)\nerror: command 'clang' failed with exit status 1\n\nDoes anyone know how to solve this problem? Help me please!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":506,"Q_Id":14399223,"Users Score":0,"Answer":"At first glance it looks like damaged pip package. Have you tried easy_install instead with the same package?","Q_Score":1,"Tags":"python,mysql,django,pip,mysql-python","A_Id":14399388,"CreationDate":"2013-01-18T12:41:00.000","Title":"clang error when installing MYSQL-python on Lion-mountain (Mac OS X 10.8)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need to login to a website. Navigate to a report page. After entering the required information and clicking on the \"Go\" button(This is a multipart\/form-data that I am submitting), there's a pop up window asking me to save the file. I want to do it automatically by python.\nI search the internet for a couple of days, but can't find a way in python. By using urllib2, I can process up to submitting multipart form, but how can I get the name and location of the file and download it?\nPlease Note: There is no Href associated with the \"Go\" button. After submitting the form, a file-save dialog popup asking me where to save the file.\nthanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":346,"Q_Id":14400767,"Users Score":0,"Answer":"There are python bindings to Selenium, that are helping in scripting simulated browser behavior allowing to do really complex stuff with it - take a look at it, should be enough for what you need.","Q_Score":0,"Tags":"python,download,popupwindow","A_Id":14401005,"CreationDate":"2013-01-18T14:15:00.000","Title":"Using python to download a file after clicking the submit button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using the IDLE command prompt with Python 3.3 and when I enter a multi-line command, I see a blank line rather than the multi-line prompt that has three dots.  I know that this is a little thing, but does anyone know how to enable the multi-line prompt?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2005,"Q_Id":14409454,"Users Score":1,"Answer":"As others have noted, IDLE will not display the three dots that you are looking for; however, if you must have them, you could always run python from the terminal by typing 'python' into the terminal and pressing ENTER. To exit python from the terminal you could type either 'exit()' or 'quit()' followed by ENTER.","Q_Score":1,"Tags":"python,python-3.x,python-idle","A_Id":14410812,"CreationDate":"2013-01-18T23:44:00.000","Title":"Python IDLE Multi-line Prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been doing a little bit of research and haven't found anything that is quite going to work. I want to have python know what the current song playing in iTunes is so I can serially send it to my Arduino.\nI have seen Appscript but it is no longer supported and from what I have read full of a few bugs now that it hasn't been updated.\nI am using Mac OS X 10.8.2 & iTunes 10.0.1\nAnyone got any ideas on how to make this work. Any information is greatly appreciated.\nFYI: My project is a little 1.8' colour display screen that I am going to have serval pieces of information on RAM HDD CPU Song etc.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2056,"Q_Id":14410771,"Users Score":0,"Answer":"You can set up a simple Automator workflow to retrieve the current iTunes song. Try these two actions for starters:\n\niTunes: Get the Current Song \nUtilities: Run Shell Script\n\nChange the shell script to cat > ~\/itunes_track.txt and you should have a text file containing the path of the current track. Once you get your data out of Automator you should be all set :)","Q_Score":0,"Tags":"python,applescript,itunes","A_Id":14410871,"CreationDate":"2013-01-19T03:21:00.000","Title":"Python getting Itunes song","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any method to let me know  the values of an object's attributes?\nFor example, info = urllib2.urlopen('http:\/\/www.python.org\/')\nI wanna know all the attributes' values of info. Maybe I don't know what are the attributes the info has. And str() or list() can not give me the answer.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":306,"Q_Id":14423868,"Users Score":2,"Answer":"You can use vars(info) or info.__dict__. It will return the object's namespace as a dictionary in the attribute_name:value format.","Q_Score":0,"Tags":"python","A_Id":14423880,"CreationDate":"2013-01-20T11:10:00.000","Title":"how to reveal an object's attributes in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im a newbie to Wxpython programming and I have a general on how to make my application more program.\nAssume, I have a tree with the list of employees being listed in the tree.  When I click a employee the information is retrieved in the db and the information is diplayed on the right side of the panel.\nNow, when I edit information of one of the employee and save it again the data the current row in the table needs to be end dated and the new row will be created in the db and also refreshing the tree.\nSo, Basically if something is saved the tree should be refreshed automatically.  How do I accomplish this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":14430915,"Users Score":0,"Answer":"I don't believe the default TreeCtrl has database interaction builtin. You would have to add that. If you want it to check for updates periodically, you could use a wx.Timer. If you'll be updating the database with your wxPython GUI, then there shouldn't be a problem as you'll have to update the display anyway.\nYou might also want to look at the DVC_DataViewModel in the wxPython demo. I think it may make this sort of thing easier as it has the concept of data objects, which I think implies that you could create a database object to feed your GUI.","Q_Score":0,"Tags":"wxpython","A_Id":14460784,"CreationDate":"2013-01-21T00:23:00.000","Title":"Wxpython dynamic programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running an app in django with gunicorn. I am trying to use selenium to test my app but have run into a problem.\nI need to create a test server like is done with djangos LiveServerTestCase that will work with gunicorn.\nDoes anyone have any ideas of how i could do this?\nnote: could also someone confirm me that LiveServerTestCase is executed as a thread not a process","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1308,"Q_Id":14431639,"Users Score":1,"Answer":"Off top of my head, you can try to override LiveServerTestCase.setUpClass and wind up gunicorn instead of LiveServerThread","Q_Score":11,"Tags":"python,django,selenium,gunicorn","A_Id":20411022,"CreationDate":"2013-01-21T02:18:00.000","Title":"How to set up a django test server when using gunicorn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running an app in django with gunicorn. I am trying to use selenium to test my app but have run into a problem.\nI need to create a test server like is done with djangos LiveServerTestCase that will work with gunicorn.\nDoes anyone have any ideas of how i could do this?\nnote: could also someone confirm me that LiveServerTestCase is executed as a thread not a process","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1308,"Q_Id":14431639,"Users Score":2,"Answer":"I've read the code. Looking at LiveServerTestCase for inspiration makes sense but trying to cook up something by extending or somehow calling LiveServerTestCase is asking for trouble and increased maintenance costs.\nA robust way to run which looks like what LiveServerTestCase does is to create from unittest.TestCase a test case class with custom setUpClass and tearDownClass methods.  The setUpClass method:\n\nSets up an instance of the Django application with settings appropriate for testing: a database in a location that won't interfere with anything else, logs recorded to the appropriate place and, if emails are sent during normal operations, with emails settings that won't make your sysadmins want to strangle you, etc.\n[In effect, this is a deployment procedure. Since we want to eventually deploy our application, the process above is one which we should develop anyway.]\nLoad whatever fixtures are necessary into the database.\nStarts a Gunicorn instance run this instance of the Django application, using the usual OS commands for this.\n\nThe tearDownClass:\n\nShuts down the Gunicorn instance, again using normal OS commands.\nDeletes the database that was created for testing, deletes whatever log files may have been created, etc.\n\nAnd between the setup and teardown our tests contact the application on the port assigned to Gunicorn and they load more fixtures if needed, etc.\nWhy not try to use a modified LiveServerTestCase?\n\nLiveServerTestCase includes the entire test setup in one process: the tests, the WSGI server and the Django application. Gunicorn is not designed for operating like this. For one thing, it uses a master process and worker processes.\nIf LiveServerTestCase is modified to somehow start the Django app in an external process, then a good deal of the benefits of this class go out the window. LiveServerTestCase relies on the fact that it can just modifies settings or database connections in its process space and that these modifications will carry over to the Django app, because it lives in the same process. If the app is in a different process, these tricks can't work. Once LiveServerTestCase is modified to take care of this, the end result is close to what I've outlined above.\n\nAdditional: Could someone get Gunicorn and Django to run in the same process?\nI'm sure someone could glue them together, but consider the following. This would certainly mean changing the core code of Gunicorn since Gunicorn is designed to use master and worker processes. Then, this person who created the glue would be responsible for keeping this glue up to date when Gunicorn or Django's internals change in such a way that makes the glue break. At the end of the day doing this requires more work than using the method outlined at the start of this answer.","Q_Score":11,"Tags":"python,django,selenium,gunicorn","A_Id":20448450,"CreationDate":"2013-01-21T02:18:00.000","Title":"How to set up a django test server when using gunicorn?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to write a python helper API to wrap existing python library.\nI have never written anything like this or may be written but not realized it. Can someone tell me what exactly it is and how to do it ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":14441086,"Users Score":0,"Answer":"The process is mostly like this:\n1) You write a new library (the wrapper)\n2) This library depends on the existing library (the one you are going to wrap)\n3) The wrapper will call the underlying library, offering a different API than the orignal library\nUsually you want to do this because the orignal library has not developer friendly APIs in the first place.\nHowver you do not say why you are supposed to undergo such task. Whoever gave you the task should also be able to give you the rationale for the work. The person giving you the task can exactly tell you what is wantd and how do it. Because there is no details in your question it is impossible to give better answer.","Q_Score":0,"Tags":"python,api","A_Id":14441199,"CreationDate":"2013-01-21T14:47:00.000","Title":"Understanding what is API wrapper around existing library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a source code editor, and I want to disable any of the pre-defined keystrokes, e.g Ctrl-V for paste, how can I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":383,"Q_Id":14441670,"Users Score":2,"Answer":"I have found the way to do this: Return boolean True from the method which handles the key-press-event. Any value that doesn't evaluate to true passes control back to Gtk.\nIn the particular way I implement this editor, the key-press-event signal of the toplevel vindow is connected to the method __key_event_handler, which basically filters all the keystrokes, modified with either Ctrl or Alt keys and returns True after processing the input, or just passes the control back to Gtk otherwise. This way, I can manage all the modified keystrokes, which are meant to be editor commands, and not need to handle insertion of normal characters.","Q_Score":2,"Tags":"python,python-3.x,gtk,gtk3,pygobject","A_Id":14460308,"CreationDate":"2013-01-21T15:17:00.000","Title":"How to disable all default keystrokes on Gtk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have populated a combobox with an QSqlQueryModel. It's all working fine as it is, but I would like to add an extra item to the combobox that could say \"ALL_RECORDS\". This way I could use the combobox as a filtering device. \nI obviously don't want to add this extra item in the database, how can I add it to the combobox after it's been populated by a model?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":243,"Q_Id":14455871,"Users Score":1,"Answer":"You could use a proxy model that takes gets it's data from two models, one for your default values, the other for your database, and use it to populate your QComboBox.","Q_Score":1,"Tags":"python,qt,pyqt,pyqt4,pyside","A_Id":14540595,"CreationDate":"2013-01-22T10:02:00.000","Title":"Adding an item to an already populated combobox","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know what is the biggest number you can make from multiplying digits entered by the user like this:\n5*6*7*2 OR 567*2 OR 67*25 ...etc\nso 5\/6\/7\/2 should be entered by the user as variables, but how do I tell python to form a number from two variables (putting the two digits next to each other and treating the outcome as a number by itself).","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":221,"Q_Id":14459821,"Users Score":1,"Answer":"Any solution that has you trying all permutations of digits will be horribly inefficient, running in O(n!).  Just 14 digits (and the multiply operator) would give around 1 trillion combinations!\nAn O(n lg n) solution would be:\n\nSort the digits from high to low.\nConcatenate them into one string.\nPrint the string.\n\n\nIf you must multiply at least one digit, then\n\nSort.\nTake the highest digit and multiply by the concatenation of the remaining digits.\nPrint the result.\n\n\nIf you must multiply at least one digit, then you might need to try all permutations (see @Mike's answer).","Q_Score":0,"Tags":"python,numbers,digits","A_Id":14460639,"CreationDate":"2013-01-22T13:34:00.000","Title":"A number out of digits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am Google Apps administrator and using xoauth.py and IMAP to download users mails without users password. But this process gets stopped after 1 hour. I searched many blogs and I came to know this token expires after 1 hour. Can anyone tell me how to extend that expiration time to Never, or how to refresh this token?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":326,"Q_Id":14478392,"Users Score":0,"Answer":"try: .. catch:.. logic can be used to handle such exceptions.\nAs Google has retired OAuth1.0, its recommended to use OAuth2.0 instead of OAUth1.","Q_Score":1,"Tags":"python,google-app-engine,oauth,imap,two-legged","A_Id":14495175,"CreationDate":"2013-01-23T11:16:00.000","Title":"xoauth.py IMAP token expires after 1 hour","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to change the indentation in all my existing(!) Python files from 2-space to 4-space shift width. Any suggestions how to do this in Vim?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":207,"Q_Id":14478615,"Users Score":2,"Answer":"It's not the best solution for your problem but for one file you can reindent the whole file (if you configured the indentation rules to match your taste):\nShift+V Shift+G =","Q_Score":2,"Tags":"python,vim","A_Id":14479445,"CreationDate":"2013-01-23T11:28:00.000","Title":"How to a posteriori double the indentation levels on all lines of a file in Vim?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Celery, the only way to conclusively reload modules is to restart all of your celery processes.  I know how to remotely shutdown workers (broadcast('shutdown', destination = [<workers>])), but not how to bring them back up.  \nI have a piece of Python code that works to create a daemon process with a new worker in it, but when I try to run it inside Celery as a celery task, I get AssertionError: daemonic processes are not allowed to have children, which I'm guessing is related to the way that the worker pool is set up.  \n\nIs there a way to override this error in Celery somehow?  \nIf not, is there another way to get Celery to start up another worker to replace itself with?  Maybe wrap this whole thing in a bash script (though the point of doing this in Python was to avoid using Python to call bash to call Python).  \nIf not, is there another way to convince Celery to reload the newest version of the code?  the --autoreload flag and broadcast('pool_restart') both do nothing.  \n\nExample Behavior:\n\nCreate:\n@task\ndef add(x,y):\n    return x+y\nLoad up celery, run add.delay(4,4), get back 8.  \nChange add to:\n@task\ndef add(x,y):\n    return x*y\nDo magic (currently \"Restart Celery\")\nRun add.delay(4,4) again\n\nYou should get back 16.  And I always get back 8, unless I shut down celery and reload it, which I can't do remotely without having a way to bring up worker processes from a remote machine, preferably using a script.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2089,"Q_Id":14486696,"Users Score":2,"Answer":"Run the Celery daemons under a supervisor, such as supervisord.  When the celeryd process dies, the supervisor will spin it back up.","Q_Score":2,"Tags":"python,daemon,celery","A_Id":14514760,"CreationDate":"2013-01-23T18:25:00.000","Title":"Using a celery task to create a new process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm writing a program and I need to inform the user about some changes with a popup message, but not a popup window. Something like the rectangle informing about new message in Kadu - no window, just a bitmap drawn directly on the screen for a few seconds. \nI wonder if there is a simple way to do that with win32 package or Tkinter, and handle the event when the user clicks on the rectangle. \nActually the message would be constant, so the bitmap might be loaded from a file, but I still don't know how to start.\nAny ideas, please?\nRegards, mopsiok","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1969,"Q_Id":14490753,"Users Score":0,"Answer":"I am using wxPython and looking for a way to have a popup message. Now I am using a popupmenu in which I append each item of the menu with one line of the message.","Q_Score":0,"Tags":"python,popup,screen,draw","A_Id":15838631,"CreationDate":"2013-01-23T22:42:00.000","Title":"Python - popup message drawn on the screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed an application for a friend. Aplication is not that complex, involves only two .py files, main.py and main_web.py, main being the application code, and _web being the web interface for it. As the web was done later, it's kept in this format, I know it can be done with one app but not to complicate it too much, I kept it that way. Two two communicate with some files, and web part uses Flask so there's \"templates\" directory too.\nNow, I want to make a package or somehow make this easier for distribution, on a OSX system. I see that there is a nice py2app thingy, but I am running Windows and I can't really use it since it won't work on Win. I also don't know will py2app make problems since some configs are in text files in the directory, and they change during the runtime.\nSo, I am wondering, is there any other way to make a package of this, some sort of setup like program, or maybe some script or something? Some simple \"way\" of doing this would be to just copy the files in the directory in the \"Documents\", and add some shortcuts to the desktop to run those two apps, and that would be it, no need for anything else. DMG would be fine, but not mandatory.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1071,"Q_Id":14500185,"Users Score":0,"Answer":"I believe what you are looking for is to add: #!\/usr\/bin\/python to the first line of your code will allow your friend to just double click on the file and it should open. Just as a warning osx does not tell us what version and as such what version of python and what standard libraries are going to be present.\nAlso, just make sure that if they have played around with their settings to much and they double click on python it does not work they will have to choose to open the file in \"terminal.app\" in the Utilities Applications folder (\/Applications\/Utilities\/terminal.app)\nThe other idea is borrow a mac and compile it with the py2app program that you already mentioned. Otherwise there is no generic binary file that you will be able to compile in windows and have run on mac.","Q_Score":1,"Tags":"python,macos,installation,py2app,dmg","A_Id":14504112,"CreationDate":"2013-01-24T11:24:00.000","Title":"Make a Python app package\/install for Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to crawl a website having multiple pages and when a page number is clicked it is dynamically loaded.How to screen scrape it?\ni.e as the url is not present as href or a how to crawl to other pages?\nWould be greatful if someone helped me on this.\nPS:URL remains the same when different page is clicked.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":4658,"Q_Id":14503078,"Users Score":1,"Answer":"if you are using google chrome, you can check the url which is dynamically being called in \nnetwork->headers  of the developer tools\nso based on that you can identify whether it is a GET or POST request.\nIf it is a GET request you can find the parameters straight away from the url.\nIf it is a POST request you can find the parameters from form data in network->headers\nof the developer tools.","Q_Score":3,"Tags":"python,web-crawler","A_Id":14503228,"CreationDate":"2013-01-24T13:58:00.000","Title":"How to crawl a web site where page navigation involves dynamic loading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The Flask documentation says :\n\nthat you can register blueprints multiple times though not every blueprint might respond properly to that. In fact it depends on how the blueprint is implemented if it can be mounted more than once.\n\nBut I can't seem to find out what must be done to mount a blueprint safely more than once.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":636,"Q_Id":14503387,"Users Score":2,"Answer":"It's hard to answer a question like this, because it is so general. \nFirst, your Blueprint needs to be implemented in a way that makes no assumptions about the state of the app object it will be registered with. Second, you'll want to use a configurable url scheme to prevent route conflicts.\nThere are far more nuanced components of this, but without seeing your specific code and problem it's about as specific as I feel I can get.","Q_Score":3,"Tags":"python,flask","A_Id":14527032,"CreationDate":"2013-01-24T14:15:00.000","Title":"Implementing a Flask blueprint so that it can be safely mounted more than once?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a binary string say '01110000', and I want to return the number of leading zeros in front without writing a forloop. Does anyone have any idea on how to do that? Preferably a way that also returns 0 if the string immediately starts with a '1'","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10560,"Q_Id":14509986,"Users Score":0,"Answer":"I'm using has_leading_zero = re.match(r'0\\d+', str(data)) as a solution that accepts any number and treats 0 as a valid number without a leading zero","Q_Score":9,"Tags":"python","A_Id":60312770,"CreationDate":"2013-01-24T20:19:00.000","Title":"Python trick in finding leading zeros in string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on an app that syncs one specific folder in a users Google Drive. I need to find when any of the files\/folders in that specific folder have changed. The actual syncing process is easy, but I don't want to do a full sync every few seconds.\nI am condisering one of these methods:\n1) Moniter the changes feed and look for any file changes\nThis method is easy but it will  cause a sync if ANY file in the drive changes.\n2) Frequently request all files in the whole drive eg. service.files().list().execute() and look for changes within the specific tree. This is a brute force approach. It will be too slow if the user has 1000's of files in their drive.\n3) Start at the specific folder, and move down the folder tree looking for changes.\nThis method will be fast if there are only a few directories in the specific tree, but it will still lead to numerous API requests.\nAre there any better ways to find whether a specific folder and its contents have changed?\nAre there any optimisations I could apply to method 1,2 or 3.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":547,"Q_Id":14511669,"Users Score":1,"Answer":"As you have correctly stated, you will need to keep (or work out) the file hierarchy for a changed file to know whether a file has changed within a folder tree.\nThere is no way of knowing directly from the changes feed whether a deeply nested file within a folder has been changed. Sorry.","Q_Score":3,"Tags":"python,google-drive-api","A_Id":14556472,"CreationDate":"2013-01-24T22:06:00.000","Title":"How can I find if the contents in a Google Drive folder have changed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on an app that syncs one specific folder in a users Google Drive. I need to find when any of the files\/folders in that specific folder have changed. The actual syncing process is easy, but I don't want to do a full sync every few seconds.\nI am condisering one of these methods:\n1) Moniter the changes feed and look for any file changes\nThis method is easy but it will  cause a sync if ANY file in the drive changes.\n2) Frequently request all files in the whole drive eg. service.files().list().execute() and look for changes within the specific tree. This is a brute force approach. It will be too slow if the user has 1000's of files in their drive.\n3) Start at the specific folder, and move down the folder tree looking for changes.\nThis method will be fast if there are only a few directories in the specific tree, but it will still lead to numerous API requests.\nAre there any better ways to find whether a specific folder and its contents have changed?\nAre there any optimisations I could apply to method 1,2 or 3.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":547,"Q_Id":14511669,"Users Score":0,"Answer":"There are a couple of tricks that might help.\nFirstly, if your app is using drive.file scope, then it will only see its own files. Depending on your specific situation, this may equate to your folder hierarchy.\nSecondly, files can have multiple parents. So when creating a file in folder-top\/folder-1\/folder-1a\/folder-1ai. you could declare both folder-1ai and folder-top as parents. Then you simply need to check for folder-top.","Q_Score":3,"Tags":"python,google-drive-api","A_Id":20685131,"CreationDate":"2013-01-24T22:06:00.000","Title":"How can I find if the contents in a Google Drive folder have changed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set my AWS id and secret in boto.cfg for the AWS python library \"boto\". I've installed it on my mac with pip install and I don't see it in \/etc \nHow do I locate and access it or do I have to create it? And if so how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":14512022,"Users Score":2,"Answer":"The installer does not create a config file for you.  You have to manually create one.  You can create a system-wide config file in \/etc\/boto.cfg or a personal config file in ~\/.boto.  Or you can create one somewhere else and point the BOTO_CONFIG environment variable at it.","Q_Score":0,"Tags":"python,amazon-web-services,boto","A_Id":14512942,"CreationDate":"2013-01-24T22:30:00.000","Title":"how to access and edit python library config file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to initialize some variables (from the database) when Django starts. \nI am able to get the data from the database but the problem is how should I call the initialize method . And this should be only called once.\nTried looking in other Pages, but couldn't find an answer to it.\nThe code currently looks something like this ::\n\ndef get_latest_dbx(request, ....):\n#get the data from database\n\ndef get_latest_x(request):\nget_latest_dbx(request,x,...)\n\ndef startup(request):\nget_latest_x(request)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8360,"Q_Id":14516737,"Users Score":1,"Answer":"there are some cheats for this. The general solution is trying to include the initial code in some special places, so that when the server starts up, it will run those files and also run the code. \nHave you ever tried to put print 'haha' in the settings.py files :) ?\nNote: be aware that settings.py runs twice during start-up","Q_Score":6,"Tags":"python,django,django-views,django-database","A_Id":14516949,"CreationDate":"2013-01-25T06:45:00.000","Title":"Django : Call a method only once when the django starts up","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to download a zip file via ftp, but then extract the files inside without ever actually saving the zip.  Any idea how I do this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7256,"Q_Id":14527010,"Users Score":0,"Answer":"The zipfile module can be used to extract things from a zip file; the ftplib would be used to access the zipfile.  Unfortunately, ftplib doesn't provide a file-like object for zipfile to use to access the contents of the file.  I suppose you could read the zip & store it in memory, for example in a string, which could then be wrapped up in a file-like object (StringIO), although you're still getting the whole zip, just not saving it to disk.\nIf you don't need to save the individual files, but just access (i.e. read) them, zipfile will allow you to do this.","Q_Score":1,"Tags":"python,ftp,zip","A_Id":14527258,"CreationDate":"2013-01-25T17:18:00.000","Title":"Download zip file via FTP and extract files in memory in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So far I have been using python to generate permutations of matrices for finding magic squares.  So what I have been doing so far (for 3x3 matrices) is that I find all the possible permutations of the set {1,2,3,4,5,6,7,8,9} using itertools.permutations, store them as a list and do my calculations and print my results.\nNow I want to find out magic squares of order 4.  Since finding all permutations means 16! possibilities, I want to increase efficiency by placing likely elements in the corner, for example 1, 16 on diagonal one corners and 4, 13 on diagonal two corners.\nSo how would I find permutations of set {1,2....16} where some elements are not moved is my question","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2502,"Q_Id":14535650,"Users Score":1,"Answer":"Just pull the placed numbers out of the permutation set. Then insert them into their proper position in the generated permutations.\nFor your example you'd take out 1, 16, 4, 13. Permute on (2, 3, 5, 6, 7,  8, 9, 10, 11, 12, 14, 15), for each permutation, insert 1, 16, 4, 13 where you have pre-selected to place them.","Q_Score":0,"Tags":"python,math,matrix,permutation,itertools","A_Id":14535721,"CreationDate":"2013-01-26T09:36:00.000","Title":"How would I go about finding all possible permutations of a 4x4 matrix with static corner elements?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Need a way to indicate\/enforce that certain methods can only be done on the root Node of my tree data structure.  I'm working in Python 2.x\nI have a class, Node, which I use in conjunction with another class, Edge, to build a tree data structure (edges are letters and nodes are words, in this case).\nSome methods in Node are needed for every instance of the Node, like get_word, which runs backwards through the tree to determine the word being represented by that Node.  But other Node operations, like load_word_into_tree, seem more like a class methods -- they operate on the entire tree.  Furthermore, the way I have structured the that call, it requires the root node and the root node only as its input.  If it is called on any other node, it'll totally mess up the tree.\nI see two options:\n\nMake load_word_into_tree an instance method, but raise an error if it is called on any Node that isn't the root.  I'm leaning towards this, but something just seems not right about it.  In my mind, instance methods are methods that every instance should need, and to have this method tacked on to every Node when it can only ever be used for the root seems like a waste.\nMake load_word_into_tree a class method, but pass it the root node as an arg.  This gets around the problem of a 'wasteful' instance method, but also seems like a misuse of concept of a class method, since it takes a single node as its input.  Furthermore, I'm not sure what use I'd have for the required cls variable available to every class method.  \n\nAny help on where and how to implement this function would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":487,"Q_Id":14553762,"Users Score":2,"Answer":"Make a Tree subclass of Node and add the tree-only methods on that class instead.\nThen make your root an instance of Tree, the rest of your graph uses Node instances.","Q_Score":2,"Tags":"python,oop,tree,class-method,instance-method","A_Id":14553768,"CreationDate":"2013-01-28T00:05:00.000","Title":"Root node operations in tree data structures","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I hope someone can help us.\nWe are using a dSpace 1103 out of Simulink\/Matlab and ControlDesk.\nWhat I would like to know is, is it possible to use python in ControlDesk to transfer data into the dSpace from network? I mean, write an UDP Listener in python and use that script to update variables inside the Simulink\/Matlab model?\nOr is there any other good chance to transfer data from a program into ControlDesk such that the changes are send to dSpace?\nAnother question is, how long does it normally take if I change a variable in ControlDesk that the change is done inside dSpace (1-2 ms)??\nIs this completely stochastic or more or less a constant value?\nThanks a lot.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3445,"Q_Id":14586171,"Users Score":1,"Answer":"Yes, it is quite possible. You should take a look at \"Real-Time Testing\" document which you can find in your dSPACE installation directory.","Q_Score":1,"Tags":"python,matlab,simulink","A_Id":14650472,"CreationDate":"2013-01-29T15:18:00.000","Title":"Python and ControlDesk interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do the following:\nIf the bash\/python script is launched from a terminal, it shall do something such as printing an error message text. If the script is launched from GUI session like double-clicking from a file browser, it shall do something else, e.g. display a GUI message box.","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":788,"Q_Id":14592390,"Users Score":4,"Answer":"It can check the value of $DISPLAY to see whether or not it's running under X11, and $(tty) to see whether it's running on an interactive terminal. if [[ $DISPLAY ]] && ! tty; then chances are good you'd want to display a GUI popup.","Q_Score":4,"Tags":"python,linux,bash,user-interface,command-line-interface","A_Id":14592451,"CreationDate":"2013-01-29T21:12:00.000","Title":"How can Linux program, e.g. bash or python script, know how it was started: from command line or interactive GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So I'm trying to run a search query through the Twitter API in Python. I can get it to return up to 100 results using the \"count\" parameter. Unfortunately, version 1.1 doesn't seem to have the \"page\" parameter that was present in 1.0. Is there some sort of alternative for 1.1? Or, if not, does anyone have any suggestions for alternative ways to get a decent amount of tweets returned for a subject.\nThanks.\nUpdate with solution:\nThanks to the Ersin below.\nI queried as a normally would for a page, and when it's return I would check for the id of the oldest tweet. I'd then use this as the max_id in the next URL.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":297,"Q_Id":14592874,"Users Score":2,"Answer":"I think you should use \"since_id\" parameter in your url. since_id provides u getting pages that older than since_id. So, for the next page you should set the since_id parameter as the last id of your current page.","Q_Score":0,"Tags":"python,twitter","A_Id":14593070,"CreationDate":"2013-01-29T21:44:00.000","Title":"Returning more than one page in Python Twitter search","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a fairly light script that I want to run periodically in the background every 5 hours or so. The script runs through a few different websites, scans them for new material, and either grabs .mp3 files from them or likes songs on youtube based on their content. There are a few things I want to achieve with this program that I am unsure of how to attain:\n\nHave the program run every 5 hours -- I'm not to familiar with system-level timing operations. \nHave the program efficiently run in the background -- I want these 'updates' to occur without the user knowing. \nHave the program activate on startup -- I know how I would set this up as a user, but I'm not sure how to add such a configuration to the python file, if that's even possible. Keep in mind that this is going to be a simple .py script -- I'm not compiling it into an executable. \n\nThe program is designed mainly with OSX and other Unix based systems in mind. Any advice on achieving some of these goals?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2035,"Q_Id":14614196,"Users Score":2,"Answer":"Have the program run every 5 hours -- I'm not to familiar with\n  system-level timing operations.\n\nfor nix cron is the default solution to accomplish this\n\nHave the program efficiently run in the background -- I want these\n  'updates' to occur without the user knowing.\n\nUsing cron the program will be run in the background on your server.  The user shouldn't be adversly affected by it.  If the user loads a page viewing mp3s you have scraped.  Then in the midst of your script running\/saving data to the database the user hits refresh, the new mp3's might show up, i don't know if this is what you had in mind  by \"without the user knowing\"\n\nHave the program activate on startup -- I know how I would set this up\n  as a user, but I'm not sure how to add such a configuration to the\n  python file, if that's even possible. Keep in mind that this is going\n  to be a simple .py script -- I'm not compiling it into an executable.\n\nI'm pretty sure cron entries will persist at reboot, (i'm not 100%), make sure that cron daemon is started on boot","Q_Score":2,"Tags":"python,unix,cron","A_Id":14614330,"CreationDate":"2013-01-30T21:32:00.000","Title":"How to run a python background process periodically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been tasked to dig through census data for things at the block level.\nAfter learning how to navigate AND find what i'm looking for I hit a snag.\ntabblock polygons (block level polygon) have an id consisting of a 15 length string,\nex: '471570001022022'\nbut the format from the census data is labelled:\n'Block 2022, Block Group 2, Census Tract 1, Shelby County, Tennessee'\nthe block id is formatted:\nstate-county-tract-group-block, with some leading zeros to make 15 characters.\nsscccttttggbbbb\nDoes anyone know a quick way to get this into a usable format?\nI thought i would ask before i spend my time trying to cook up a python script.\nThanks,\ngm","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":88,"Q_Id":14633329,"Users Score":1,"Answer":"well, i got it.\nex = 'Block 2022, Block Group 2, Census Tract 1, Shelby County, Tennessee'\nnew_id = '47157' + ex[40:len(ex)-26].zfill(4) + '0' + ex[24] + ex[6:10]\nstate and county values are constant; block groups only go to one digit (afaik).","Q_Score":2,"Tags":"python,gis,census","A_Id":14633770,"CreationDate":"2013-01-31T19:11:00.000","Title":"Reformat census title","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a data set which I do multiple mappings on. \nAssuming that I have 3 key-values pair for the reduce function, how do I modify the output such that I have 3 blobfiles - one for each of the key value pair?\nDo let me know if I can clarify further.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":14635693,"Users Score":2,"Answer":"I don't think such functionality exists (yet?) in the  GAE Mapreduce library.\nDepending on the size of your dataset, and the type of output required, you can small-time-investment hack your way around it by co-opting the reducer as another output writer. For example, if one of the reducer outputs should go straight back to the datastore, and another output should go to a file, you could open a file yourself and write the outputs to it. Alternatively, you could serialize and explicitly store the intermediate map results to a temporary datastore using operation.db.Put, and perform separate Map or Reduce jobs on that datastore. Of course, that will end up being more expensive than the first workaround.\nIn your specific key-value example, I'd suggest writing to a Google Cloud Storage File, and postprocessing it to split it into three files as required. That'll also give you more control over final file names.","Q_Score":0,"Tags":"python,google-app-engine,mapreduce","A_Id":20688782,"CreationDate":"2013-01-31T21:42:00.000","Title":"GAE MapReduce, How to write Multiple Outputs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Yesterday, I edited the bin\/activate script of my virtualenv so that it sets the PYTHONPATH environment variable to include a development version of some external package. I had to do this because the setup.py of the package uses distutils and does not support the develop command \u00e0 la setuptools. Setting PYTHONPATH works fine as far as using the Python interpreter in the terminal is concerned.\nHowever, just now I opened the project settings in PyCharm and discovered that PyCharm is unaware of the external package in question - PyCharm lists neither the external package nor its path. Naturally, that's because PyCharm does not (and cannot reliably) parse or source the bin\/activate script. I could manually add the path in the PyCharm project settings, but that means I have to repeat myself (once in bin\/activate, and again in the PyCharm project settings). That's not DRY and that's bad.\nCreating, in site-packages, a symlink that points to the external package is almost perfect. This way, at least the source editor of PyCharm can find the package and so does the Python interpreter in the terminal. However, somehow PyCharm still does not list the package in the project settings and I'm not sure if it's ok to leave it like that.\nSo how can I add the external package to my virtualenv\/project in such a way that\u2026\n\nI don't have to repeat myself; and\u2026\nboth the Python interpreter and PyCharm would be aware of it?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2662,"Q_Id":14647317,"Users Score":2,"Answer":"Even when a package is not using setuptools pip monkeypatches setup.py to force it to use setuptools.\nMaybe you can remove that PYTHONPATH hack and pip install -e \/path\/to\/package.","Q_Score":6,"Tags":"python,python-2.7,virtualenv,pycharm,pythonpath","A_Id":14661799,"CreationDate":"2013-02-01T13:26:00.000","Title":"PYTHONPATH vs symbolic link","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a package with Python 2.7.3 and gcc 4.7.2. Build is scons based and it terminates complaining that it can't find 'C library for python2.7'?\nWhat is this C library and how do I build it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":14660277,"Users Score":0,"Answer":"Often, packages are split into those parts for use and those parts that are required for development. You probably have those parts for use installed (interpreter, modules), but the libraries for development of modules are missing. Look for a python-dev package.","Q_Score":1,"Tags":"python","A_Id":14660409,"CreationDate":"2013-02-02T08:58:00.000","Title":"How to build a C library for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to make a program in which the user inputs a word and I need to do something to each individual letter in that word. They cannot enter it one letter at a time just one word. \nI.E. someone enters \"test\" how can I make my program know that it is a four letter word and how to break it up, like make my program make four variables each variable set to a different letter. It should also be able to work with bigger and smaller words.\nCould I use a for statement? Something like For letter ste that letter to a variable, but what is it was like a 20 character letter how would the program get all the variable names and such?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3180,"Q_Id":14667218,"Users Score":0,"Answer":"You don't want to assign each letter to a separate variable. Then you'd be writing the rest of your program without even being able to know how many variables you have defined! That's an even worse problem than dealing with the whole string at once.\nWhat you instead want to do is have just one variable holding the string, but you can refer to individual characters in it with indexing. Say the string is in s, then s[0] is the first character, s[1] is the second character, etc. And you can find out how far up the numbers go by checking len(s) - 1 (because the indexes start at 0, a length 1 string has maximum index 0, a length 2 string has maximum index 1, etc).\nThat's much more manageable than figuring out how to generate len(s) variable names, assign them all to a piece of the string, and then know which variables you need to reference.\nStrings are immutable though, so you can't assign to s[1] to change the 2nd character. If you need to do that you can instead create a list with e.g. l = list(s). Then l[1] is the second character, and you can assign l[1] = something to change the element in the list. Then when you're done you can get a new string out with s_new = ''.join(l) (join builds a string by joining together a sequence of strings passed as its argument, using the string it was invoked on to the left as a separator between each of the elements in the sequence; in this case we're joining a list of single-character strings using the empty string as a separator, so we just get all the single-character strings joined into a single string).","Q_Score":0,"Tags":"python,string","A_Id":14667497,"CreationDate":"2013-02-02T22:31:00.000","Title":"Python, breaking up Strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a python program where I will be appending numbers into a list, but I don't want the numbers in the list to repeat. So how do I check if a number is already in the list before I do list.append()?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":180790,"Q_Id":14667578,"Users Score":1,"Answer":"You could probably use a set object instead. Just add numbers to the set. They inherently do not replicate.","Q_Score":37,"Tags":"python,list,data-structures,set,append","A_Id":14667595,"CreationDate":"2013-02-02T23:15:00.000","Title":"check if a number already exist in a list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that creates a few text files, which are then uploaded to my current web host. This is done every 5 minutes. The text files are used in a software program which fetches the latest version every 5 min. Right now I have it running on my web host, but I'd like to move to GAE to improve reliability. (Also because my current web host does not allow for just plain file hosting, per their TOS.)\nIs google app engine right for me? I have some experience with python, but none related to web technologies. I went through the basic hello world tutorial and it seems pretty straightforward for a website, but I don't know how I would implement my project. I also worry about any caching which could cause the latest files not to propagate fast enough across google's servers.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":14669819,"Users Score":0,"Answer":"Yes and no.\nAppengine is great in terms of reliability, server speed, features, etc.  However, it has two main drawbacks: You are in a sandboxed environment (no filesystem access, must use datastore), and you are paying by instance hour.  Normally, if you're just hosting a small server accessed once in a while, you can get free hosting; if you are running a cron job all day every day, you must use at least one instance at all times, thus costing you money.\nYour concerns about speed and propagation on google's servers is moot; they have a global time server pulsating through their datacenters ensuring your operations are atomic; if you request data with consistency=STRONG, so long as your get begins after the put, you will see the updated data.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":14670069,"CreationDate":"2013-02-03T05:38:00.000","Title":"Is google app engine right for me (hosting a few rapidly updating text files created w\/ python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In python I want to simulate a joystick that when used, to give values between -63 and +63 let's say. When the value it's positive, I want to press the \"w\" key and \"s\" key when negative.\nI am not having problems receiving the values, but to transform these analog values into digital key presses. Does anyone has any idea how to do it (code can be in any language, I just need an general idea).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":14672039,"Users Score":1,"Answer":"Use PostMessage with the WM_CHAR command (if you're using Windows - you didn't say).","Q_Score":0,"Tags":"python,keypress,joystick,analog-digital-converter","A_Id":14709657,"CreationDate":"2013-02-03T11:36:00.000","Title":"Transforming analog keypresses to digital","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make upvote and downvote buttons for comments but I want all the form inputs that django.contrib.comments.forms.CommentSecurityForm gives me to make sure the form is secure. Is that necessary? And if so, how do I make a form class that with upvote and downvote buttons? Custom checkbox styles?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":829,"Q_Id":14677548,"Users Score":0,"Answer":"I would suggest, you use separate view login for up and down voting.\nSomething like this \/upvote\/{{comment.pk|urlize}}\nand then write a view that works with this url. With PK find the comment that the user is trying to up\/down vote, then write the necessary condition to check if the user is authorized to perform that kind of action, and then finally execute that action.\nI hope this helps","Q_Score":3,"Tags":"python,django,django-forms","A_Id":14678289,"CreationDate":"2013-02-03T21:34:00.000","Title":"Upvote and Downvote buttons with Django forms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed the python script for checking out a source code from repository and build it using visual studio.When i run the script,a GUI opens(developed using wxPython) which shows a button,clicking on which does the checkout and build.I would want to show a progress bar showing the process running when i click on the button and a success message after the script finishes it's work.Please help me out.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":400,"Q_Id":14681697,"Users Score":0,"Answer":"You probably won't be able to get an accurate progress unless your build scripts are generating some progress information in the output that you can parse and represent in your GUI.  Either way you will probably want to use wx.ProgressDialog or use a wx.Gauge in your main panel or something like that.  Both wx.ProgressDialog and wx.Gauge can be used in a mode that shows actual values (a percentage complete) or an 'indeterminate' mode that represents that something is happening but there isn't any way to tell how far in the process it is.","Q_Score":0,"Tags":"python-2.7,wxpython","A_Id":14692494,"CreationDate":"2013-02-04T06:52:00.000","Title":"Show progress bar when running a script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have developed a custom field that extends ImageField and this custom field, dynamically creates 2more normal fields. Now, I need to write tests for this custom fields ? \nWhat tests are needed for this customfield ? Can you name them so that I will code those test cases. I am not asking technically how to write a test, I donno but I wil learn . But, what I want to know is, what are the things I need to test here.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":14687281,"Users Score":0,"Answer":"Try to test every case of how your custom field could be used. In example try to send by it different kind of datas (string, integers, blank, different image formats etc.) and check if it works according to your expectations.","Q_Score":0,"Tags":"python,django,django-testing","A_Id":14689563,"CreationDate":"2013-02-04T12:58:00.000","Title":"What tests do I need to write for the customfield that I have developed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have seen a similar question on this site but not answered correctly for my requirements. I am reasonably familiar with py2exe.\nI'd like to create a program (in python and py2exe) that I can distribute to my customers which would enable them to add their own data (not code, just numbers) and redistribute as a new\/amended exe for further distribution (as a single file, so my code + data). I understand this can be done with more than one file.\nIs this conceptually possible without my customers installing python? I guess I'm asking how to perform the 'bundlefiles' option?\nMany thanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":167,"Q_Id":14692822,"Users Score":1,"Answer":"I think it is possible. I'm not sure how py2exe works, but I know how pyinstaller does and since both does the same it should work similiar. \nNamely, one-file flag doesn't really create one file. It looks like that for end user, but when user run app, it unpacks itself and files are stored somewhere physically. You could try to edit some source file (ie numbers.py, or data.py) and pack it again with changed data. \nI know it's not the best explanation, you have to think further on your own. I'm just showing you the possible way.","Q_Score":3,"Tags":"python,py2exe","A_Id":14693751,"CreationDate":"2013-02-04T18:11:00.000","Title":"compile py2exe from executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting to use Google App Engine and being a newcomer to much of the stuff going on here, I broke my webpage (all I see is \"server error\" in my web browser). I'd like to be able to see a console of some sort which is telling me what's going wrong (python syntax? file not found? something else?). Searching around a bit didn't lead me to a quick solution to this, so I came here. Any advice? Ideally, there would be some sort of tutorial\/guide that would show how to do this.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":104,"Q_Id":14720476,"Users Score":1,"Answer":"I assume you are using Linux, Ubuntu\/Mint If not that would be a good start\nDebug as much as you can locally using dev_appserver.py - this will display errors on start up (in the console)\nAdd your own debug logs when needed\nRun code snippets in the interactive console - this is really useful to test snippets of code:\n\nif you are on GAE >= 1.7.6 http:\/\/localhost:8000\/console\nif you are on GAE < 1.7.6 http:\/\/localhost:8080\/_ah\/admin\/interactive\/interactive","Q_Score":1,"Tags":"python,google-app-engine","A_Id":14723922,"CreationDate":"2013-02-06T02:11:00.000","Title":"How to monitor google app engine from command line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on bio project.\nI have .pdb (protein data bank) file which contains information about the molecule.  \nI want to find out the following of a molecule in the .pdb file:\n\nMolecular Mass.  \nH bond donor.  \nH bond acceptor.  \nLogP.  \nRefractivity.  \n\nIs there any module in python which can deal with .pdb file in finding this?\nIf not then can anyone please let me know how can I do the same?  \nI found some modules like sequtils and protienparam but they don't do such things.\nI have researched first and then posted, so, please don't down-vote.\nPlease comment, if you still down-vote as to why you did so.\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1814,"Q_Id":14723707,"Users Score":1,"Answer":"A pdb file can contain pretty much anything.\nA lot of projects allows you to parse them. Some specific to biology and pdb files, other less specific but that will allow you to do more (setup calculations, measure distances, angles, etc.).\nI think you got downvoted because these projects are numerous: you are not the only one wanting to do that so the chances that something perfectly fitting your needs exists are really high.\nThat said, if you just want to parse pdb files for this specific need, just do it yourself:\n\nOpen the files with a text editor.\nIdentify where the relevant data are (keywords, etc.).\nMake a Python function that opens the file and look for the keywords.\nExtract the figures from the file.\nDone.\n\nThis can be done with a short script written in less than 10 minutes (other reason why downvoting).","Q_Score":2,"Tags":"python,bioinformatics,biopython,chemistry","A_Id":14726014,"CreationDate":"2013-02-06T07:25:00.000","Title":"python with .pdb files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there anyway of making Python methods have access to the class fields\/methods without using the self parameter?\nIt's really annoying having to write self. self. self. self. The code gets so ugly to the point I'm thinking of not using classes anymore purely for code aesthetics. I don't care about the risks or best practices. I just want not to see self anymore. \nP.S. I know about the renaming possibility but it's not the point.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1285,"Q_Id":14727517,"Users Score":2,"Answer":"No, there isn't. You could though use another word instead of self, although the convention is to use \"self\".","Q_Score":5,"Tags":"python,self","A_Id":14727642,"CreationDate":"2013-02-06T11:06:00.000","Title":"Any ideas about how to get rid of self?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there anyway of making Python methods have access to the class fields\/methods without using the self parameter?\nIt's really annoying having to write self. self. self. self. The code gets so ugly to the point I'm thinking of not using classes anymore purely for code aesthetics. I don't care about the risks or best practices. I just want not to see self anymore. \nP.S. I know about the renaming possibility but it's not the point.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1285,"Q_Id":14727517,"Users Score":3,"Answer":"The only possible solution (except for making your own no-self Python version (using sources))\nTry another language.","Q_Score":5,"Tags":"python,self","A_Id":14727662,"CreationDate":"2013-02-06T11:06:00.000","Title":"Any ideas about how to get rid of self?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to hear your opinion about the effective implementation of one-to-many relationship with Python NDB. (e.g. Person(one)-to-Tasks(many))\nIn my understanding, there are three ways to implement it.\n\nUse 'parent' argument\nUse 'repeated' Structured property\nUse 'repeated' Key property\n\nI choose a way based on the logic below usually, but does it make sense to you? \nIf you have better logic, please teach me.\n\nUse 'parent' argument\n\nTransactional operation is required between these entities\nBidirectional reference is required between these entities\nStrongly intend 'Parent-Child' relationship\n\nUse 'repeated' Structured property\n\nDon't need to use 'many' entity individually (Always, used with 'one' entity)\n'many' entity is only referred by 'one' entity\nNumber of 'repeated' is less than 100\n\nUse 'repeated' Key property\n\nNeed to use 'many' entity individually\n'many' entity can be referred by other entities\nNumber of 'repeated' is more than 100\n\n\nNo.2 increases the size of entity, but we can save the datastore operations. (We need to use projection query to reduce CPU time for the deserialization though). Therefore, I use this way as much as I can.\nI really appreciate your opinion.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1389,"Q_Id":14739044,"Users Score":6,"Answer":"One thing that most GAE users will come to realize (sooner or later) is that the datastore does not encourage design according to the formal normalization principles that would be considered a good idea in relational databases. Instead it often seems to encourage design that is unintuitive and anathema to established norms. Although relational database design principles have their place, they just don't work here.  \nI think the basis for the datastore design instead falls into two questions:\n\nHow am I going to read this data and how do I read it with the minimum number of read operations?\nIs storing it that way going to lead to an explosion in the number of write and indexing operations?\n\nIf you answer these two questions with as much foresight and actual tests as you can, I think you're doing pretty well. You could formalize other rules and specific cases, but these questions will work most of the time.","Q_Score":11,"Tags":"python,google-app-engine,app-engine-ndb","A_Id":14749034,"CreationDate":"2013-02-06T21:22:00.000","Title":"Effective implementation of one-to-many relationship with Python NDB","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to hear your opinion about the effective implementation of one-to-many relationship with Python NDB. (e.g. Person(one)-to-Tasks(many))\nIn my understanding, there are three ways to implement it.\n\nUse 'parent' argument\nUse 'repeated' Structured property\nUse 'repeated' Key property\n\nI choose a way based on the logic below usually, but does it make sense to you? \nIf you have better logic, please teach me.\n\nUse 'parent' argument\n\nTransactional operation is required between these entities\nBidirectional reference is required between these entities\nStrongly intend 'Parent-Child' relationship\n\nUse 'repeated' Structured property\n\nDon't need to use 'many' entity individually (Always, used with 'one' entity)\n'many' entity is only referred by 'one' entity\nNumber of 'repeated' is less than 100\n\nUse 'repeated' Key property\n\nNeed to use 'many' entity individually\n'many' entity can be referred by other entities\nNumber of 'repeated' is more than 100\n\n\nNo.2 increases the size of entity, but we can save the datastore operations. (We need to use projection query to reduce CPU time for the deserialization though). Therefore, I use this way as much as I can.\nI really appreciate your opinion.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":1389,"Q_Id":14739044,"Users Score":7,"Answer":"A key thing you are missing: How are you reading the data?\nIf you are displaying all the tasks for a given person on a request, 2 makes sense: you can query the person and show all his tasks.\nHowever, if you need to query say a list of all tasks say due at a certain time, querying for repeated structured properties is terrible.  You will want individual entities for your Tasks.\nThere's a fourth option, which is to use a KeyProperty in your Task that points to your Person.  When you need a list of Tasks for a person you can issue a query.\nIf you need to search for individual Tasks, then you probably want to go with #4.  You can use it in combination with #3 as well.\nAlso, the number of repeated properties has nothing to do with 100.  It has everything to do with the size of your Person and Task entities, and how much will fit into 1MB.  This is potentially dangerous, because if your Task entity can potentially be large, you might run out of space in your Person entity faster than you expect.","Q_Score":11,"Tags":"python,google-app-engine,app-engine-ndb","A_Id":14740062,"CreationDate":"2013-02-06T21:22:00.000","Title":"Effective implementation of one-to-many relationship with Python NDB","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is probably a very easy question, but all the sources I have found on interpolation in Matlab are trying to correlate two values, all I wanted to benefit from is if I have data which is collected over an 8 hour period, but the time between data points is varying, how do I adjust it such that the time periods are equal and the data remains consistent?\nOr to rephrase from the approach I have been trying: I have GPS lat,lon and Unix time for these points; what I want to do is take the lat and lon at time 1 and time 3 and for the case where I don't know time 2, simply fill it with data from time 1 - is there a functional way to do this? (I know in something like Python Pandas you can use fill) but I'm unsure of how to do this in Matlab.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":705,"Q_Id":14742893,"Users Score":2,"Answer":"What you can do is use interp1 function. This function will fit in deifferent way the numbers for a new X series.\nFor example if you have \nx=[1 3 5 6 10 12] \ny=[15 20 17 33 56 89]\nThis means if you want to fill in for x1=[1 2 3 4 5 6 7 ... 12], you will type \ny1=interp1(x,y,x1)","Q_Score":2,"Tags":"python,matlab,pandas,gps","A_Id":14754539,"CreationDate":"2013-02-07T03:13:00.000","Title":"Interpolation Function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to print the actual following string: \\n , but everything I tried just reads it in takes it as a new line operator.. how do I just print the following: \\n ?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":213,"Q_Id":14780533,"Users Score":3,"Answer":"You have to escape \\n somehow\nEither just the sequence \nprint  \"\\\\n\"\nor mark whole string as raw\nprint r\"\\n\"","Q_Score":0,"Tags":"python","A_Id":14780579,"CreationDate":"2013-02-08T20:09:00.000","Title":"How to print the string \"\\n\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS\nkeys, etc.. values into settings files has problem:\n\nSecrets often should be just that: secret! Keeping them in version control means\nthat everyone with repository access has access to them.\n\nMy question is how to keep all keys as secret?","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":26432,"Q_Id":14786072,"Users Score":2,"Answer":"Here's one way to do it that is compatible with deployment on Heroku:\n\nCreate a gitignored file named .env containing:\nexport DJANGO_SECRET_KEY = 'replace-this-with-the-secret-key'\nThen edit settings.py to remove the actual SECRET_KEY and add this instead:\nSECRET_KEY = os.environ['DJANGO_SECRET_KEY']\nThen when you want to run the development server locally, use:\nsource .env\npython manage.py runserver\nWhen you finally deploy to Heroku, go to your app Settings tab and add DJANGO_SECRET_KEY to the Config Vars.","Q_Score":29,"Tags":"python,django,settings","A_Id":53798521,"CreationDate":"2013-02-09T07:49:00.000","Title":"Keep Secret Keys Out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS\nkeys, etc.. values into settings files has problem:\n\nSecrets often should be just that: secret! Keeping them in version control means\nthat everyone with repository access has access to them.\n\nMy question is how to keep all keys as secret?","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":26432,"Q_Id":14786072,"Users Score":6,"Answer":"Store your local_settings.py data in a file encrypted with GPG - preferably as strictly key=value lines which you parse and assign to a dict (the other attractive approach would be to have it as executable python, but executable code in config files makes me shiver).\nThere's a python gpg module so that's not a problem. Get your keys from your keyring, and use the GPG keyring management tools so you don't have to keep typing in your keychain password. Make sure you are reading the data straight from the encrypted file, and not just creating a decrypted temporary file which you read in. That's a recipe for fail.\nThat's just an outline, you'll have to build it yourself.\nThis way the secret data remains solely in the process memory space, and not in a file or in environment variables.","Q_Score":29,"Tags":"python,django,settings","A_Id":14786575,"CreationDate":"2013-02-09T07:49:00.000","Title":"Keep Secret Keys Out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS\nkeys, etc.. values into settings files has problem:\n\nSecrets often should be just that: secret! Keeping them in version control means\nthat everyone with repository access has access to them.\n\nMy question is how to keep all keys as secret?","AnswerCount":7,"Available Count":4,"Score":0.1418931938,"is_accepted":false,"ViewCount":26432,"Q_Id":14786072,"Users Score":5,"Answer":"Ideally, local_settings.py should not be checked in for production\/deployed server. You can keep backup copy somewhere else, but not in source control.\nlocal_settings.py can be checked in with development configuration just for convenience, so that each developer need to change it.\nDoes that solve your problem?","Q_Score":29,"Tags":"python,django,settings","A_Id":14786114,"CreationDate":"2013-02-09T07:49:00.000","Title":"Keep Secret Keys Out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS\nkeys, etc.. values into settings files has problem:\n\nSecrets often should be just that: secret! Keeping them in version control means\nthat everyone with repository access has access to them.\n\nMy question is how to keep all keys as secret?","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":26432,"Q_Id":14786072,"Users Score":0,"Answer":"You may need to use os.environ.get(\"SOME_SECRET_KEY\")","Q_Score":29,"Tags":"python,django,settings","A_Id":46735039,"CreationDate":"2013-02-09T07:49:00.000","Title":"Keep Secret Keys Out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some points in space where each point has an id. I also have a subset of these points in another group that have different id values.\nHow can I create a new type of id for both groups of points so that the points that have the same coordinates end up using the same id values?\nI assume I need to generate hash codes using their coordinates which should give me the same id value for points that have the same coordinates, right?\nI am confused how I could use it because the set of hashcodes is much smaller than float[3]. So not sure if I am on the right track.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":14804291,"Users Score":0,"Answer":"Hash codes aren't meant to be unique for unequal objects - there typically will be some collisions.  They definitely can't be used to test for equality.\nHash codes are used to place objects (hopefully) evenly across a data structure.  If you want to test for equality, test whether the coordinates are equal.","Q_Score":0,"Tags":"c#,python,.net,sorting,hash","A_Id":14804387,"CreationDate":"2013-02-11T00:27:00.000","Title":"How to match arbitrary data using hash codes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am making a download manager. And I want to make the download manager check the md5 hash of an url after downloading the file. The hash is found on the page. It needs to compute the md5 of the file ( this is done), search for a match on the html page and then compare the WHOLE contents of the html page for a match.\nmy question is how do i make python return the whole contents of the html and find a match for my \"md5 string\"?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":168,"Q_Id":14815856,"Users Score":1,"Answer":"import urllib and use urllib.urlopen for getting the contents of an html. import re to search for the hash code using regex. You could also use find method on the string instead of regex.\nIf you encounter problems, then you can ask more specific questions. Your question is too general.","Q_Score":0,"Tags":"python,html,compare,match","A_Id":14815973,"CreationDate":"2013-02-11T15:59:00.000","Title":"Matching contents of an html file with keyword python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple cgi script in python collecting a value from form fields  submitted through post. After collecting this, iam dumping these values to a single text file. \nNow, when multiple users submit at the same time, how do we go about it?\nIn C\\C++ we use semaphore\\mutex\\rwlocks etc? Do we have anything similar in python. Also, opening and closing the file multiple times doesnt seem to be a good idea for every user request.\nWe have our code base for our product in C\\C++. I was asked to write a simple cgi script for some reporting purpose and was googling with python and cgi.\nPlease let me know.\nThanks!\nSanthosh","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":300,"Q_Id":14817290,"Users Score":0,"Answer":"The simple (and slow way) is to acquire a lock on the file (in C you'd use flock), write on it and close it. If you think this can be a bottleneck then use a database or something like that.","Q_Score":0,"Tags":"python,cgi","A_Id":14817753,"CreationDate":"2013-02-11T17:17:00.000","Title":"multiple users doing form submission with python CGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple cgi script in python collecting a value from form fields  submitted through post. After collecting this, iam dumping these values to a single text file. \nNow, when multiple users submit at the same time, how do we go about it?\nIn C\\C++ we use semaphore\\mutex\\rwlocks etc? Do we have anything similar in python. Also, opening and closing the file multiple times doesnt seem to be a good idea for every user request.\nWe have our code base for our product in C\\C++. I was asked to write a simple cgi script for some reporting purpose and was googling with python and cgi.\nPlease let me know.\nThanks!\nSanthosh","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":300,"Q_Id":14817290,"Users Score":0,"Answer":"If you're concerned about multiple users, and considering complex solutions like mutexes or semaphores, you should ask yourself why you're planning on using an unsuitable solution like CGI and text files in the first place. Any complexity you're saving by doing this will be more than outweighed by whatever you put in place to allow multiple users.\nThe right way to do this is to write a simple WSGI app - maybe using something like Flask - which writes to a database, rather than a text file.","Q_Score":0,"Tags":"python,cgi","A_Id":14817362,"CreationDate":"2013-02-11T17:17:00.000","Title":"multiple users doing form submission with python CGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wonder if is possible to create a bash replacement but in python. I have done REPLs before, know about subprocess and that kind of stuff, but wonder how use my python-like-bash replacement in the OSX terminal as if were a native shell environment (with limitations). \nOr simply run ipython as is... \nP.D. The majority of the google answer are related to create shell scripts. I'm interested in create a shell..","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1426,"Q_Id":14824538,"Users Score":0,"Answer":"Yes, of course. You can simply make an executable Python script, call it \/usr\/bin\/pysh, add this filename to \/etc\/shells and then set it as your user's default login shell with chsh.","Q_Score":2,"Tags":"python,bash,shell,replace","A_Id":14824582,"CreationDate":"2013-02-12T02:33:00.000","Title":"Is possible to create a shell like bash in python, ie: Bash replacement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Use Amazon SWF to communicate messages between servers?\n\nOn server A I want to run a script A \nWhen that is finished I want to send a message to server B to run a script B \nIf it completes successfully I want it to clear the job from the workflow queue\n\nI\u2019m having a really hard time working out how I can use Boto and SWF in combination to do this. I am not after some complete code but what I am after is if anyone can explain a little more about what is involved. \n\nHow do I actually tell server B to check for the completion of script\nA? \nHow do I make sure server A wont pick up the completion of script\nA and try and run script B (since server B should run this)? \nHow do I actually notify SWF of script A completion? Is thee a flag, or a\nmessage, or what?\n\nI\u2019m pretty confused about all of this. What design should I use?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3687,"Q_Id":14829562,"Users Score":1,"Answer":"You can use SNS,\n  When script A is completed it should trigger SNS, and that will trigger a notification to Server B","Q_Score":9,"Tags":"python,linux,amazon-web-services,boto,amazon-swf","A_Id":14829925,"CreationDate":"2013-02-12T09:44:00.000","Title":"Using Amazon SWF To communicate between servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Use Amazon SWF to communicate messages between servers?\n\nOn server A I want to run a script A \nWhen that is finished I want to send a message to server B to run a script B \nIf it completes successfully I want it to clear the job from the workflow queue\n\nI\u2019m having a really hard time working out how I can use Boto and SWF in combination to do this. I am not after some complete code but what I am after is if anyone can explain a little more about what is involved. \n\nHow do I actually tell server B to check for the completion of script\nA? \nHow do I make sure server A wont pick up the completion of script\nA and try and run script B (since server B should run this)? \nHow do I actually notify SWF of script A completion? Is thee a flag, or a\nmessage, or what?\n\nI\u2019m pretty confused about all of this. What design should I use?","AnswerCount":4,"Available Count":2,"Score":0.2449186624,"is_accepted":false,"ViewCount":3687,"Q_Id":14829562,"Users Score":5,"Answer":"I don't have any example code to share, but you can definitely use SWF to coordinate the execution of scripts across two servers.  The main idea with this is to create three pieces of code that talk to SWF:\n\nA component that knows which script to execute first and what to do once that first script is done executing.  This is called the \"decider\" in SWF terms.\nTwo components that each understand how to execute the specific script you want to run on each machine.  These are called \"activity workers\" in SWF terms.\n\nThe first component, the decider, calls two SWF APIs: PollForDecisionTask and RespondDecisionTaskCompleted.  The poll request will give the decider component the current history of an executing workflow, basically the \"where am i\" state information for your script runner.  You write code that looks at these events and figure out which script should execute.  These \"commands\" to execute a script would be in the form of a scheduling of an activity task, which is returned as part of the call to RespondDecisionTaskCompleted.\nThe second components you write, the activity workers, each call two SWF APIs: PollForActivityTask and RespondActivityTaskCompleted.  The poll request will give the activity worker an indication that it should execute the script it knows about, what SWF calls an activity task.  The information returned from the poll request to SWF can include single execution-specific data that was sent to SWF as part of the scheduling of the activity task.  Each of your servers would be independently polling SWF for activity tasks to indicate the execution of the local script on that host.  Once the worker is done executing the script, it calls back to SWF through the RespondActivityTaskCompleted API.\nThe callback from your activity worker to SWF results in a new history being handed out to the decider component that I already mentioned.  It will look at the history, see that the first script is done, and schedule the second one to execute.  Once it sees that the second one is done, it can \"close\" the workflow using another type of decision.\nYou kick off the whole process of executing the scripts on each host by calling the StartWorkflowExecution API.  This creates the record of the overall process in SWF and kicks out the first history to the decider process to schedule the execution of the first script on the first host.\nHopefully this gives a bit more context on how to accomplish this type of workflow using SWF.  If you haven't already, I would take a look at the dev guide on the SWF page for additional info.","Q_Score":9,"Tags":"python,linux,amazon-web-services,boto,amazon-swf","A_Id":14881688,"CreationDate":"2013-02-12T09:44:00.000","Title":"Using Amazon SWF To communicate between servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create my own pipe line in Elastic Transcoder. I am using the boto standard function create_pipeline(name, input_bucket, output_bucket, role, notifications).\nCan you please tell me the notifications (structure) how it should look? \nSo far I have something like this:\ncreate_pipeline('test','test_start', 'test_end',\n                     'arn:aws:iam::789823056103:role\/Elastic_Transcoder_Default_Role',  ... )\nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":268,"Q_Id":14835315,"Users Score":1,"Answer":"It should be a dictionary with the 4 keys in the dictionary (I'm going to push a change that updates the structure type with the dict type). So if you don't want notifications, you just specify empty values for the keys:\n{'Progressing': '', 'Completed': '', 'Warning': '', 'Error': ''}","Q_Score":1,"Tags":"python,amazon-web-services,boto","A_Id":14849632,"CreationDate":"2013-02-12T14:54:00.000","Title":"Understanding the boto documentation for Elastic Transcoder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the Shopify Python API in an django app to interact with my Shopify Store. \nI have a collection - called - best sellers.\nI am looking to create a batch update to this collection - that is add\/remove products to this collection. However, they python API docs does not seem to say much about how to do so. How do I fetch a collection by name? How do I add a product to it?\nThank you for your help.\n\nThis is what I found\n\n\n\nx=shopify.CustomCollection.find(handle=\"best-sellers\")\ny=shopify.Collect() #creates a new collect\np = shopify.Product.find(118751076) # gets me the product\n\n\n\nSo the questions is how do I add the product \"p\" above to the Custom Collection \"x\" ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4023,"Q_Id":14845942,"Users Score":0,"Answer":"The documentation is again not promising but one thing to bear in mind is that there should in actual fact be an existing collection already created\nFind it by using this code\ncollection_id = shopify.CustomCollection.find(handle=<your_handle>)[0].id\nthen consequently add the collection_id, product_id to a Collect object and save, remember to first save your product (or have an existing one which you can find) and then only save your collection, or else the collection won't know what product its posting to (via the api), like so\nnew_product = shopify.Product()\nnew_product.save()\nadd_collection = shopify.Collect('product_id': new_product.id, 'collection_id': collection_id})\nadd_collection.save()\nAlso important to note that there is a 1 to 1 relationship between Product and Collect","Q_Score":1,"Tags":"python,django,api,shopify","A_Id":56934353,"CreationDate":"2013-02-13T03:30:00.000","Title":"Shopify Python API: How do I add a product to a collection?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm solving a classification problem with sklearn's logistic regression in python.\nMy problem is a general\/generic one.  I have a dataset with two classes\/result (positive\/negative or 1\/0), but the set is highly unbalanced.  There are ~5% positives and ~95% negatives.\nI know there are a number of ways to deal with an unbalanced problem like this, but have not found a good explanation of how to implement properly using the sklearn package.\nWhat I've done thus far is to build a balanced training set by selecting entries with a positive outcome and an equal number of randomly selected negative entries.  I can then train the model to this set, but I'm stuck with how to modify the model to then work on the original unbalanced population\/set.\nWhat are the specific steps to do this?  I've poured over the sklearn documentation and examples and haven't found a good explanation.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":18285,"Q_Id":14863125,"Users Score":22,"Answer":"Have you tried to pass to your class_weight=\"auto\" classifier? Not all classifiers in sklearn support this, but some do. Check the docstrings.\nAlso you can rebalance your dataset by randomly dropping negative examples and \/ or over-sampling positive examples (+ potentially adding some slight gaussian feature noise).","Q_Score":22,"Tags":"python,scikit-learn,classification","A_Id":14864547,"CreationDate":"2013-02-13T21:06:00.000","Title":"sklearn logistic regression with unbalanced classes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am toying around with BeautifulSoup and I like it so far. \nThe problem is the site I am trying to scrap has a lazyloader... And it only scraps one part of the site. \nCan I have a hint as to how to proceed? Must I look at how the lazyloader is implemented and parametrize anything else?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1587,"Q_Id":14868003,"Users Score":1,"Answer":"It turns out that the problem itself wasn't BeautifulSoup, but the dynamics of the page itself. For this specific scenario that is. \nThe page returns part of the page, so headers need to be analysed and sent to the server accordingly. This isn't a BeautifulSoup problem itself. \nTherefore, it is important to take a look at how the data is loaded on a specific site. It's not always a \"Load a whole page, process the whole page\" paradigm. In some cases, you need to load part of the page and send a specific parameter to the server in order to keep loading the rest of the page.","Q_Score":3,"Tags":"python,python-2.7,lazy-loading,beautifulsoup","A_Id":16251642,"CreationDate":"2013-02-14T04:49:00.000","Title":"Crawling a page using LazyLoader with Python BeautifulSoup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Fedora virtual machine.  It comes with Python pre-installed.  I've read that it's not a good idea to uninstall it.  I want to install a different version of Python, Enthought Python.  Should I try to uninstall the existing Python installation and how would I do that?  Should I instead install Enthought Python to a new directory?  Will that be a problem with the existing Python installation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":14869861,"Users Score":3,"Answer":"Do not try to uninstall the pre-installed Python.\nInstall other Python interpreters side by side (in different directories).\nYou may come across an option to choose the default Python interpreter for your system. Don't change that from the pre-installed one, as that may break some important scripts used by the system. Customize the default Python interpreter for your user only, not for the entire system. (I don't have a Fedora at hand so don't know how that works exactly.)\nAlso have a look at virtualenv for having multiple isolated Python environments with their independent collection of Python modules, and pythonbrew for installing multiple Python interpreters.","Q_Score":0,"Tags":"python,linux","A_Id":14869972,"CreationDate":"2013-02-14T07:33:00.000","Title":"Installing a new distribution of Python on Fedora","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was thinking of doing a little project that involves recognizing simple two-dimensional objects using some kind of machine learning. I think it's better that I have each network devoted to recognizing only one type of object. So here are my two questions:\n\nWhat kind of network should I use? The two I can think of that could work are simple feed-forward networks and Hopfield networks. Since I also want to know how much the input looks like the target, Hopfield nets are probably not suitable.\nIf I use something that requires supervised learning and I only want one output unit that indicates how much the input looks like the target, what counter-examples should I show it during the training process? Just giving it positive examples I'm pretty sure won't work (the network will just learn to always say 'yes').\n\nThe images are going to be low resolution and black and white.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2529,"Q_Id":14875450,"Users Score":4,"Answer":"First, a note regarding the classification method to use. \nIf you intend to use the image pixels themselves as features, neural network might be a fitting classification method. In that case, I think it might be a better idea to train the same network to distinguish between the various objects, rather than using a separate network for each, because it would allow the network to focus on the most discriminative features. \nHowever, if you intend to extract synthetic features from the image and base the classification on them, I would suggest considering other classification methods, e.g. SVM.\nThe reason is that neural networks generally have many parameters to set (e.g. network size and architecture), making the process of building a classifier longer and more complicated.\nSpecifically regarding your NN-related questions, I would suggest using a feedforward network, which is relatively easy to build and train, with a softmax output layer, which allows assigning probabilities to the various classes. \nIn case you're using a single network for classification, the question regarding negative examples is irrelevant; for each class, other classes would be its negative examples. If you decide to use different networks, you can use the same counter-examples (i.e. other classes), but as a rule of thumb, I'd suggest showing no more than 2-10 negative examples per positive example.\nEDIT: \nbased on the comments below, it seems the problem is to decide how fitting is a given image (drawing) to a given concept, e.g. how similar to a tree is the the user-supplied tree drawing. \nIn this case, I'd suggest a radically different approach: extract visual features from each drawing, and perform knn classification, based on all past user-supplied drawings and their classifications (possibly, plus a predefined set generated by you). You can score the similarity either by the nominal distance to same-class examples, or by the class distribution of the closest matches. \nI know that this is not neccessarily what you're asking, but this seems to me an easier and more direct approach, especially given the fact that the number of examples and classes is expected to constantly grow.","Q_Score":0,"Tags":"python,language-agnostic,machine-learning,object-recognition,pybrain","A_Id":14877671,"CreationDate":"2013-02-14T13:01:00.000","Title":"How to Train Single-Object Recognition?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a data intensive project where I have been using PHP for fetching data and encrypting it using phpseclib. A chunk of the data has been encrypted in AES with the ECB mode -- however the key length is only 10. I am able to decrypt the data successfully.\nHowever, I need to use Python in the later stages of the project and consequently need to decrypt my data using it. I tried employing PyCrypto but it tells me the key length must be 16, 24 or 32 bytes long, which is not the case. According to the phpseclib documentation the \"keys are null-padded to the closest valid size\", but I'm not sure how to implement that in Python. Simply extending the length of the string with 6 spaces is not working.\nWhat should I do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":975,"Q_Id":14891492,"Users Score":3,"Answer":"I strongly recommend you adjust your PHP code to use (at least) a sixteen byte key, otherwise your crypto system is considerably weaker than it might otherwise be.\nI would also recommend you switch to CBC-mode, as ECB-mode may reveal patterns in your input data. Ensure you use a random IV each time you encrypt and store this with the ciphertext.\nFinally, to address your original question:\n\nAccording to the phpseclib documentation the \"keys are null-padded to the closest valid size\", but I'm not sure how to implement that in Python. Simply extending the length of the string with 6 spaces is not working.\n\nThe space character 0x20 is not the same as the null character 0x00.","Q_Score":1,"Tags":"php,python,aes,pycrypto,phpseclib","A_Id":14892493,"CreationDate":"2013-02-15T09:22:00.000","Title":"Key length issue: AES encryption on phpseclib and decryption on PyCrypto","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a matrix of the form, say e^(Ax) where A is a square matrix. How can I integrate it from a given value a to another value bso that the output is a corresponding array?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1283,"Q_Id":14899139,"Users Score":2,"Answer":"Provided A has the right properties, you could transform it to the diagonal form A0 by calculating its eigenvectors and eigenvalues. In the diagonal form, the solution is sol = [exp(A0*b) - exp(A0*a)] * inv(A0), where A0 is the diagonal matrix with the eigenvalues and inv(A0) just contains the inverse of the eigenvalues in its diagonal. Finally, you transform back the solution by multiplying it with the transpose of the eigenvalues from the left and the eigenvalues from the right: transpose(eigvecs) * sol * eigvecs.","Q_Score":1,"Tags":"python,matrix,numpy,integration,exponential","A_Id":14900251,"CreationDate":"2013-02-15T16:35:00.000","Title":"how to find the integral of a matrix exponential in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Yep, I want it to work like in Flask framework - there I could set parameters like this:\nstatic_folder=os.getcwd()+\"\/static\/\", static_url_path=\"\"\nand all the files that lies in .\/static\/files\/blabla.bla would be accessible by mysite.com\/files\/blabla.bla address. I really don't want to add static after mysite.com.\nBut if I set STATIC_URL = '\/' in Django then I could get my static files by this address, but suddenly I could not fetch my pages that described in urls.py.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":294,"Q_Id":14902023,"Users Score":1,"Answer":"I believe this is not supported out of the box. Off the top of my head, one way to do it would be with a special 404 handler that, having failed to match against any of the defined URLs, treats the request as a request for a static resource. This would be reasonably easy to do in the development environment but significantly more difficult when nginx, Apache, and\/or gunicorn get involved.\nIn other words, don't do this. Nest your statics (or put them on a different sub domain) but don't mix the URL hierarchy in this way.","Q_Score":2,"Tags":"python,django","A_Id":14902498,"CreationDate":"2013-02-15T19:34:00.000","Title":"Django: how to make STATIC_URL empty?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How is it possible to get a compiled .exe program written in Python to kill itself after a period of time after it is launched?\nIf I have some code and I compile it into an .exe, then launch it and it stays in a 'running' or 'waiting' state, how can I get it to terminate after a few mins regardless of what the program is doing?\nThe reason why is that the exe that is launched envokes a URL using PAMIE and automates some clicks. What I have noticed is that if the browser is closed the process remains in memory and does not clean itself up. I wanted to find a way to auto-clean up the process after say 5 mins which is more then enough time. I've tried using psutils to detect the process but that does not work in my case. Any suggestions is greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1455,"Q_Id":14915048,"Users Score":0,"Answer":"Create a thread when your process starts.\nMake that thread sleep for the required duration.\nWhen that sleep is over, kill the process.","Q_Score":0,"Tags":"python,process,terminate","A_Id":14915445,"CreationDate":"2013-02-16T21:00:00.000","Title":"Python built exe process to kill itself after a period of time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to access the arguments with which a parent task A was called, from its child task Z? Put differently, when Task Z gets called in a chain, can it somehow access an argument V that was invoked when Task A was fired, but that was not passed through any intermediary nodes between tasks A and Z? And if so, how?\nUsing Celery 3.0 with RabbitMQ for results backend.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":960,"Q_Id":14923583,"Users Score":0,"Answer":"I think you can, at least in chord. When you bind=True your task, you can access self.request. In self.request.chord You can find a detailed dict. In its kwargs or options['chord'] you will find what you're looking for, but it's not an elegant solution. Also, if the parent has been replaced, you will only be able to see the final state.","Q_Score":2,"Tags":"python,celery","A_Id":71510516,"CreationDate":"2013-02-17T16:59:00.000","Title":"Access Arguments to Parent Task from Subtask in Celery","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have trouble to see django\/contrib\/admin\/templates folder. It seems like it is hidden in \/usr\/lib\/python2.7\/dist-packages\/ folder, ctrl+h wont help ( appearencely all django files are hidden).\n\"locate django\/contrib\/admin\/templates\" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu 12.10\nThanks in advance","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":15440,"Q_Id":14931793,"Users Score":0,"Answer":"Should be here: \/usr\/lib\/python2.7\/site-packages\/django\/contrib\/admin\/templates","Q_Score":14,"Tags":"python,django,ubuntu,django-templates","A_Id":14931827,"CreationDate":"2013-02-18T08:04:00.000","Title":"find django\/contrib\/admin\/templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have trouble to see django\/contrib\/admin\/templates folder. It seems like it is hidden in \/usr\/lib\/python2.7\/dist-packages\/ folder, ctrl+h wont help ( appearencely all django files are hidden).\n\"locate django\/contrib\/admin\/templates\" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu 12.10\nThanks in advance","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":15440,"Q_Id":14931793,"Users Score":0,"Answer":"Since, everyone is posting my comment's suggestion, might as well post it myself. Try looking at:\n\/usr\/lib\/python2.6\/site-packages\/django\/","Q_Score":14,"Tags":"python,django,ubuntu,django-templates","A_Id":14931847,"CreationDate":"2013-02-18T08:04:00.000","Title":"find django\/contrib\/admin\/templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have trouble to see django\/contrib\/admin\/templates folder. It seems like it is hidden in \/usr\/lib\/python2.7\/dist-packages\/ folder, ctrl+h wont help ( appearencely all django files are hidden).\n\"locate django\/contrib\/admin\/templates\" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu 12.10\nThanks in advance","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":15440,"Q_Id":14931793,"Users Score":0,"Answer":"If you are using Python3, Django is located at your venv. In my case templates are located at <project_root>\/venv\/lib\/python3.5\/site-packages\/django\/contrib\/admin\/templates\/.","Q_Score":14,"Tags":"python,django,ubuntu,django-templates","A_Id":53451127,"CreationDate":"2013-02-18T08:04:00.000","Title":"find django\/contrib\/admin\/templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Aptana Studio 3 keeps adding .pydevproject file, how can I disable Python or whatever it's doing this","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":459,"Q_Id":14940443,"Users Score":0,"Answer":"I accidentally somehow set the project as PyDev project. To disable, right click on the project > PyDev > Remove PyDev Project Config","Q_Score":3,"Tags":"python,aptana,aptana3","A_Id":56855673,"CreationDate":"2013-02-18T16:06:00.000","Title":"Aptana Studio 3 keeps adding .pydevproject file, how can I disable Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If we have a json format data file which stores all of our database data content, such as table name, row, and column, etc content, how can we use DB-API object to insert\/update\/delete data from json file into database, such as sqlite, mysql, etc.  Or please share if you have better idea to handle it. People said it is good to save database data information into json format, which will be much convenient to work with database in python. \nThanks so much! Please give advise!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":454,"Q_Id":14942462,"Users Score":1,"Answer":"There's no magic way, you'll have to write a Python program to load your JSON data in a database. SQLAlchemy is a good tool to make it easier.","Q_Score":0,"Tags":"python,database,json,sqlalchemy,python-db-api","A_Id":14951638,"CreationDate":"2013-02-18T17:57:00.000","Title":"how will Python DB-API read json format data into an existing database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am playing around with local deployment of GAE python SDK. The code that I am trying to run contains many external libraries which are not part of GAE import whitelist. I want to disable the import restrictions and let GAE app import any locally installed module. \nAfter walking through the code, I figured out that they use custom import hooks for restricting imports. However, I have not been able to figure out how to disable the overridden import hook.\nLet me know if you have any idea how this can be accomplished.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":14947860,"Users Score":0,"Answer":"Easiest thing is to modify google\/appengine\/tools\/dev_appserver_import_hook.py and add the module you want to the whitelist.\nThis will allow you to import whatever you want.\nNow there's a good reason that the imports are restricted in the development server.  The restricted imports match what's available on the production environment.  So if you add libraries to the whitelist, your code may run on your local development server, but it will not run on the production environment.\nAnd no, you can't import restricted modules on production.","Q_Score":1,"Tags":"python,google-app-engine","A_Id":14950038,"CreationDate":"2013-02-19T00:35:00.000","Title":"How to disable Google App Engine python SDK import hook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If there are lets say 4 buttons, all with the same Click event, how can I find out which button was pressed?\nif the event looks like this def Button_Click(self, sender, e): I'm sure I can compare sender to my buttons somehow. But how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":901,"Q_Id":14959093,"Users Score":1,"Answer":"Well, I've never used IronPython so I don't know how much help this will be, but what I usually do when trying to figure out these things in regular python is to print type(sender) , print sender and print dir(sender) to console(or output to a file if you don't have a console available).\nThis should help you figure out what exactly is the \"sender\" parameter. In the simplest case it could be the button itself so a simple == will work to know which button it was. Or it could have a method\/property that gets you the button object. In which case, dir(sender) might contain an obvious one, or if not, google the class name gotten from type(sender) and see if you can find any docs.","Q_Score":0,"Tags":"python,.net,ironpython","A_Id":14959257,"CreationDate":"2013-02-19T13:47:00.000","Title":"event handling iron python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am debugging my Python scripts with ipdb. Somehow I have the problem, that after entering a command, for instance n, s, c, b etc. I have to press Ctrl+D two times in order for ipdb to process the command and proceed.\nAny idea what causes this and how I can turn it off?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":463,"Q_Id":14960161,"Users Score":1,"Answer":"This is the thing: Ctrl+D does not kill programs, it cuts waiting halfway through. When you press Ctrl+D, you interrupt the process' read() call that's waiting for input.\nCtrl+D\nMost programs will abort when they read 0 bytes as input. If you Ctrl+D before entering anything, you'll be sending 0 bytes down the input pipe, and possibly induce a shutdown of a the program, which may think there is nothing left to be done. This is not forced.\nHowever, if you press some keys, then Ctrl+D, the read() call you interrupted will return that text, and the underlying program decides to wait for another round.\nThat's why, when you Ctrl+D again without entering any new text, you get the behavior you expect.\nYour case\nThis is what's probably happening:\n\nYou type some character, they get buffered.\nYou Ctrl+D. The text reaches iPdb, but it does not detect a newline, and thus it waits for more.\nYou Ctrl+D again. This time 0 bytes reach iPdb, which assumes nothing more is coming and processes the text with or without newlines.","Q_Score":2,"Tags":"python,debugging,pdb","A_Id":14960605,"CreationDate":"2013-02-19T14:42:00.000","Title":"ipdb requires Ctrl+D for processing command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I come from a C# background where the language has some built in \"protect the developer\" features.  I understand that Python takes the \"we're all adults here\" approach and puts responsibility on the developer to code thoughtfully and carefully.\nThat said, Python suggests conventions like a leading underscore for private instance variables.  My question is, is there a particular convention for marking a class as abstract other than just specifying it in the docstrings?  I haven't seen anything in particular in the python style guide that mentions naming conventions for abstract classes.\nI can think of 3 options so far but I'm not sure if they're good ideas:\n\nSpecify it in the docstring above the class (might be overlooked)\nUse a leading underscore in the class name (not sure if this is universally understood)\nCreate a def __init__(self): method on the abstract class that raises an error (not sure if this negatively impacts inheritance, like if you want to call a base constructor)\n\nIs one of these a good option or is there a better one?  I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","AnswerCount":6,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":12928,"Q_Id":14972631,"Users Score":3,"Answer":"Create your 'abstract' class and raise NotImplementedError() in the abstract methods.\nIt won't stop people using the class and, in true duck-typing fashion, it will let you know if you neglect to implement the abstract method.","Q_Score":20,"Tags":"python,naming-conventions,abstract-class","A_Id":14973303,"CreationDate":"2013-02-20T05:03:00.000","Title":"Python abstract classes - how to discourage instantiation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I come from a C# background where the language has some built in \"protect the developer\" features.  I understand that Python takes the \"we're all adults here\" approach and puts responsibility on the developer to code thoughtfully and carefully.\nThat said, Python suggests conventions like a leading underscore for private instance variables.  My question is, is there a particular convention for marking a class as abstract other than just specifying it in the docstrings?  I haven't seen anything in particular in the python style guide that mentions naming conventions for abstract classes.\nI can think of 3 options so far but I'm not sure if they're good ideas:\n\nSpecify it in the docstring above the class (might be overlooked)\nUse a leading underscore in the class name (not sure if this is universally understood)\nCreate a def __init__(self): method on the abstract class that raises an error (not sure if this negatively impacts inheritance, like if you want to call a base constructor)\n\nIs one of these a good option or is there a better one?  I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","AnswerCount":6,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":12928,"Q_Id":14972631,"Users Score":3,"Answer":"I just name my abstract classes with the prefix 'Abstract'. E.g. AbstractDevice, AbstractPacket, etc.\nIt's about as easy and to the point as it comes. If others choose to go ahead and instantiate and\/or use a class that starts with the word 'Abstract', then they either know what they're doing or there was no hope for them anyway.\nNaming it thus, also serves as a reminder to myself not to go nuts with deep abstraction hierarchies, because putting 'Abstract' on the front of a whole lot of classes feels stupid too.","Q_Score":20,"Tags":"python,naming-conventions,abstract-class","A_Id":14973549,"CreationDate":"2013-02-20T05:03:00.000","Title":"Python abstract classes - how to discourage instantiation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I come from a C# background where the language has some built in \"protect the developer\" features.  I understand that Python takes the \"we're all adults here\" approach and puts responsibility on the developer to code thoughtfully and carefully.\nThat said, Python suggests conventions like a leading underscore for private instance variables.  My question is, is there a particular convention for marking a class as abstract other than just specifying it in the docstrings?  I haven't seen anything in particular in the python style guide that mentions naming conventions for abstract classes.\nI can think of 3 options so far but I'm not sure if they're good ideas:\n\nSpecify it in the docstring above the class (might be overlooked)\nUse a leading underscore in the class name (not sure if this is universally understood)\nCreate a def __init__(self): method on the abstract class that raises an error (not sure if this negatively impacts inheritance, like if you want to call a base constructor)\n\nIs one of these a good option or is there a better one?  I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","AnswerCount":6,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":12928,"Q_Id":14972631,"Users Score":0,"Answer":"To enforce things is possible, but rather unpythonic. When I came to Python after many years of C++ programming I also tried to do the same, I suppose, most of people try doing so if they have an experience in more classical languages. Metaclasses would do the job, but anyway Python checks very few things at compilation time. Your check will still be performed at runtime. So, is the inability to create a certain class really that useful if discovered only at runtime? In C++ (and in C# as well) you can not even compile you code creating an abstract class, and that is the whole point -- to discover the problem as early as possible. If you have abstract methods, raising a NotImplementedError exception seems to be quite enough. NB: raising, not returning an error code! In Python errors usually should not be silent unless thay are silented explicitly. Documenting. Naming a class in a way that says it's abstract. That's all.\nQuality of Python code is ensured mostly with methods that are quite different from those used in languages with advanced compile-time type checking. Personally I consider that the most serious difference between dynamically typed lngauges and the others. Unit tests, coverage analysis etc. As a result, the design of code is quite different: everything is done not to enforce things, but to make testing them as easy as possible.","Q_Score":20,"Tags":"python,naming-conventions,abstract-class","A_Id":14974080,"CreationDate":"2013-02-20T05:03:00.000","Title":"Python abstract classes - how to discourage instantiation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I know the Python coding standard has a limit of 78 characters per line. I am working in Notepad++ and\nhow do I set it so it wraps after 78 characters?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9109,"Q_Id":14994955,"Users Score":0,"Answer":"To apply the WordWrap, just goo to view in the Menu bar and check the WordWrap option.","Q_Score":3,"Tags":"python,notepad++","A_Id":63126890,"CreationDate":"2013-02-21T05:08:00.000","Title":"Wrapping in Notepad++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to access a usb device through python but I'm unsure how to find the path to it.\nThe example I'm going from is:\npipe = open('\/dev\/input\/js0','r')\nIn which case this is either a mac or linux path. I don't know how to find the path for windows.\nCould someone steer me in the proper direction? I've sifted through the forums but couldn't quite find my answer.\nThanks,\n-- Mark","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1609,"Q_Id":15012694,"Users Score":0,"Answer":"\"Everything is a file\" is one of the core ideas of Unix.  Windows does not share this philosophy and, as far as I know, doesn't provide an equivalent interface.  You're going to have to find a different way.\nThe first way would to be to continue handling everything at a low level & have your code use a different code path under Windows.  The only real reason to do this is if your goal is to learn about USB programming at a low level.\nThe other way is to find a library that's already abstracted out the differences between platforms.  PySDL immediately comes to mind (followed by PyGame, which is a higher level wrapper around that) but, as that's a gaming\/multimedia library, it might be overkill for what you're doing.  Google tells me that PyUSB exists and appears to just focus on handing USB devices.  PySDL\/PyGame have been around a while & are probably more mature so, unless you've got a particular aversion to them, I'd probably stick with them.","Q_Score":0,"Tags":"python,usb","A_Id":15013500,"CreationDate":"2013-02-21T21:37:00.000","Title":"opening a usb device in python -- what is the path in winXP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to access a usb device through python but I'm unsure how to find the path to it.\nThe example I'm going from is:\npipe = open('\/dev\/input\/js0','r')\nIn which case this is either a mac or linux path. I don't know how to find the path for windows.\nCould someone steer me in the proper direction? I've sifted through the forums but couldn't quite find my answer.\nThanks,\n-- Mark","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1609,"Q_Id":15012694,"Users Score":0,"Answer":"The default USB path on windows is D:\\. So, if we have a text document named mydoc.txt, which is in the folder myData the appropriate path is D:\\myData\\mydoc.txt","Q_Score":0,"Tags":"python,usb","A_Id":15012889,"CreationDate":"2013-02-21T21:37:00.000","Title":"opening a usb device in python -- what is the path in winXP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"when user logs in to his desktop windows os authenticates him against Active Directory Server.\nso Whenever he accesses a web page  he should not be thrown a login page for entering his userid or password.Instead, his userid and domain  need to be captured from his desktop and passed to the web server.(let him enter password after that)\nIs this possible in python to get username and domain of of client?\nwin32api.GetUserName() gives the username of the server side.\nThanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2471,"Q_Id":15024894,"Users Score":0,"Answer":"What you want to do is called Single sign on (SSO) and it's much easier to implement on actual web server than Django.\nSo, you should check how to do SSO on Apache\/Nginx\/whateverYouAreUsing, then the web server will forward the authenticated username to your django app.","Q_Score":3,"Tags":"django,python-2.7","A_Id":32207711,"CreationDate":"2013-02-22T13:01:00.000","Title":"how to get username and domain of windows logged in client using python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written an irc bot that runs some commands when told so, the commands are predefined python functions that will be called on the server where the bot is running.\nI have to call those functions without knowing exactly what they'll do\n(more I\/O or something computationally expensive, nothing harmful since I review them when I accept them), but I need to get their return value in order to give a reply back to the irc channel.\nWhat module do you recommend for running several of these callbacks in parallel and why?\nThe threading or multiprocessing modules, something else?\nI heard about twisted, but I don't know how it will fit in my current implementation since I know nothing about it and the bot is fully functional from the point of view of the protocol.\nAlso requiring the commands to do things asynchronously is not an option since I want the bot to be easily extensible.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":221,"Q_Id":15031315,"Users Score":2,"Answer":"There is no definitive answer to your question: it really depends what the functions do, how often they are called and what level of parallelism you need.\nThe threading and multiprocessing modules work in radically different ways.\nthreading implements native threads within the Python interpreter: fairly inexpensive to create but limited in parallelism due to Python's Global Interpreter Lock (GIL). Threads share the same address space, so may interfere with each other (e.g. if a thread causes the interpreter to crash, all threads, including your app, die), but inter-thread communication is cheap and fast as a result.\nmultiprocessing implements parallelism using distinct processes: the setup is far more expensive than threads (required creation of a new process), but each process runs its own copy of the interpreter (hence no GIL related locking issues) and run in different address spaces (isolating your main app). The child processes communicate with the parent over IPC channels and required Python objects to be pickled\/unpickled - so again, more expensive than threads.\nYou need to figure out what trade-off is best suited to your purpose.","Q_Score":0,"Tags":"python,multithreading,parallel-processing,multiprocessing","A_Id":15031533,"CreationDate":"2013-02-22T18:59:00.000","Title":"What module to use for calling user-defined functions in parallel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a postgre database with a timestamp column and I have a REST service in Python that executes a query in the database and returns data to a JavaScript front-end to plot a graph using flot.\nNow the problem I have is that flot can automatically handle the date using JavaScript's TIMESTAMP, but I don't know how to convert the Postgre timestamps to JavaScript TIMESTAMP (YES a timestamp, not a date stop editing if you don't know the answer) in Python. I don't know if this is the best approach (maybe the conversion can be done in JavaScript?). Is there a way to do this?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":4296,"Q_Id":15031856,"Users Score":3,"Answer":"You can't send a Python or Javascript \"datetime\" object over JSON. JSON only accepts more basic data types like Strings, Ints, and Floats.\nThe way I usually do it is send it as text, using Python's datetime.isoformat() then parse it on the Javascript side.","Q_Score":8,"Tags":"javascript,python,postgresql,flot","A_Id":15032100,"CreationDate":"2013-02-22T19:33:00.000","Title":"Converting postgresql timestamp to JavaScript timestamp in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"What I'm trying to do is to combine two approaches, two frameworks into one solid scope, process ...\n\nI have a bunch of tests in python with self-written TestRunner over proboscis library which gave me a good way to write my own Test Result implementation (in which I'm using jinja). This framework is now a solid thing. These tests are for tesing UI (using Selenium) on ASP.NET site.\nOn another hand I have to write tests for business logic. Apparently it would be right to use NUnit or TestDriven.NET for C#.\n\nCould you please give me a tip, hint, advice of how I should integrate these two approaches in one final solution? May be the answer would be just to set up a CI server, donno...\nPlease note, the reason I'm using Python for ASP.Net portal is in its flexibility and opportunity to build any custom Test Runner, Test Loader, Test Discovery and so on...\nP.S. Using IronPython is not an option for me.\nP.P.S. For the sake of clarity: proboscis is the python library which allows to set test order and dependency of a choosen test. And these two options are the requirements!\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":923,"Q_Id":15036815,"Users Score":1,"Answer":"I don't know if you can fit them in one runner or process. I'm also not that familiar with Python. It seems to me that the Python written tests are more on a high level though. Acceptance tests or integration tests or whatever you want to call them. And the NUnit ones are unit test level. Therefore I would suggest that you first run the unit tests and if they pass the Python ones. You should be able to integrate that in a build script. And as you already suggested, if you can run that on a CI server, that would be my preferred approach in your situation.","Q_Score":5,"Tags":"c#,python,asp.net,unit-testing","A_Id":16286713,"CreationDate":"2013-02-23T03:43:00.000","Title":"Integrating tests written in Python and tests in C# in one solid solution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"is there a way to check if a chat is a group chat? Or at least to find out how many users there are in a group.\nLike by checking for the user number, if it is 2, then it is obviously 1-1 (Single), but if it as anything else, it would be a group chat.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1405,"Q_Id":15049661,"Users Score":0,"Answer":"The Type property of the chat object will be either chatTypeDialog or chatTypeMultiChat with the latter being a group chat. You can safely ignore the other legacy enumeration values.","Q_Score":0,"Tags":"python,skype,skype4py","A_Id":15052112,"CreationDate":"2013-02-24T07:33:00.000","Title":"Skype4Py Check If Group Chat","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am configuring access control for a web application based on the Pyramid framework. I am setting up permissions for my view callables using the @view_config decorator. I have two permissions, namely 'read' and 'write'. Now, I want certain views to require both permissions. I was unable to figure out how to do this with view_config - am I missing something, or is there maybe another way to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1193,"Q_Id":15055029,"Users Score":5,"Answer":"Make a readwrite permission. Each view gets one and only one permission but each principal can be mapped to many permissions.","Q_Score":10,"Tags":"python,web-applications,permissions,security,pyramid","A_Id":15057901,"CreationDate":"2013-02-24T18:27:00.000","Title":"Multiple permissions in view_config decorator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using PyEphem to calculate the location of the Sun in the sky at various times.\nI have an Observer point (happens to be at Stonehenge) and can use PyEphem to calculate sunrise, sunset, and the altitude angle and azimuth (degrees from N) for the Sun at any hour of the day. Brilliant, no problem.\nHowever, what I really need is to be able to calculate the altitude angle of the Sun from an known azimuth.   So I would set the same observer point (long\/lat\/elev\/date (just yy\/mm\/dd, not time)) and an azimuth for the Sun.  And from this input, calculate the altitude of the Sun and the time it is at that azimuth. \nI had hoped I would be able to just set Sun.date and Sun.az and work backwards from those values, but alas.  Any thoughts on how to approach this (and if it even is approachable) with PyEphem?\nThe only other option I'm seeing available is to \"sneak up\" on the azimuth by iterating over a sequence of times until I get within a margin of error of the azimuth I desire, but that is just gross.\nthanks in advance, Dave","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1610,"Q_Id":15056269,"Users Score":0,"Answer":"Without knowing the details of the internal calculations that PyEphem is doing I don't know how easy or difficult it would be to invert those calculations to give the result you want. \nWith regards to the \"sneaking up on it\" option however, you could pick two starting times (eg sunrise and noon) where the azimuth is known to be either side (one greater and one less than) the desired value. Then just use a simple \"halving the interval\" approach to quickly find an approximate solution.","Q_Score":3,"Tags":"python,pyephem,azimuth,altitude","A_Id":15056730,"CreationDate":"2013-02-24T20:27:00.000","Title":"PyEphem: can I calculate Sun's altitude from azimuth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am writing a simple script which should do big amount of checks. Every check is independent so I decided to put it into multiple threads. However I don't know how fast will be machine on which the script will be set. I've already found quite nice util to check basic parameters of the target machine but I am wondering if there's any way to determine what is the max sensible amount of threads (I mean the moment when new thread starts slowing the process instead of speeding it)?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":2550,"Q_Id":15057301,"Users Score":2,"Answer":"Threads for the purpose of speed in python is not a terribly good idea, particularly for cpu bound operations. The GIL sees off any potential performance improvements from multiple CPU's (the # of which is the theoretical limit of your speed increase from threading - though in practice YMMV).\nFor truly independent \"checks\" you are far better off looking at multiprocessing.","Q_Score":3,"Tags":"python,multithreading,python-multithreading","A_Id":15057672,"CreationDate":"2013-02-24T22:15:00.000","Title":"How can I determine sensible thread number in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to grab a sources HTML but not PHP is it possible with the built in functions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":15057651,"Users Score":0,"Answer":"PHP scripts are run server-side and produce a HTML document (among other things). You will never see the PHP source of a HTML document when requesting a website, hence there is no way for Python to grab it either. This isn't even Python-related.","Q_Score":0,"Tags":"python,python-3.3","A_Id":15057740,"CreationDate":"2013-02-24T22:52:00.000","Title":"Python grabbing pages source with PHP in it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django to develop a classifier service, and user can build a model using api like http:\/\/localhost\/api\/buildmodel, however, because building a model takes a long time, maybe 2 hours, and I'm using web page to show the result of building a model. How to design my Django program to return immediately and do something to show the result after building finish? maybe I can use ajax but I want to implement it in Python, like using a async method and calling a callback function after building, any suggestions will be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":15059534,"Users Score":0,"Answer":"One way to do it is to create a row in a persistent database (or a redis key\/value pair) for the task which says if it is running or finished. Have the code set the value to be running when the task starts and done when the task completes. Then have an AJAX call do a GET lookup on a URL that sends the status for the task via a web service. You can put that in a setInterval() to periodically poll the database to see if it is done. You could send an email on completion or just have a landing page \/ dashboard that shows the status of the tasks being run.","Q_Score":1,"Tags":"python,django","A_Id":15059615,"CreationDate":"2013-02-25T03:16:00.000","Title":"how to do with a request which needs to take a long time to run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In CherryPy how do you pass an argument like file path (i.e. \/abc\/def\/ghi) through a URL? I want to do something like http:\/\/.....\/filepath=\"abc\/def\/ghi\". Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":15072062,"Users Score":0,"Answer":"Well, ...\/a\/b\/x=y is the wrong way to send a value regardless of whether it is a file name or not. The correct way would be ...\/a\/b?x=y \nor ...\/a\/b\/?x=y which would make x a standard query parameter  and cherrypy would treat it as such. Thereafter whether there were slashes in the value of x or not would be moot. They would get through to your code just fine.","Q_Score":1,"Tags":"python,url,cherrypy","A_Id":52942169,"CreationDate":"2013-02-25T16:51:00.000","Title":"Passing file path argument to a CherryPy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a simple game, whereby I want my characters quite customizable. I want my characters to be able to be fully edited in colours, for example, if a player wants their character to have cyan skin, they just put into the sliders, or what I choose to use, \"0,255,255\", or purple \"255,0,255\", or something random \"25,125, 156\", and have their character be that colour. I haven't even started creating the game, but I've got the basis down and I know exactly what I must do for pretty much every EXCEPT this.\nI done a search in Google, and it turns out, I need numerical python for this? Well this is a whole new package, and in order for the average player to play, I must change it to EXE form... (or have python, pygame and numerical python installed onto their PC, which will be a problem if they have a later version...). Now, it's already getting complex with just pygame, but with numerical python as well, is there even a tutorial on how to do this?\nAny suggestions? Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2070,"Q_Id":15076133,"Users Score":0,"Answer":"I assume by image you mean pygame.Surface.  You have several options:\n\npygame.Surface.set_at(...)\nUse a palettized surface.  Then change the palette.  Based on your use case, this is actually probably what I'd suggest.\nUse the pygame.PixelArray PyGame module.  I don't think it requires NumPy.\nJust use NumPy.  It's really not that huge of a requirement; lots of projects require it and it's simple to set up.  You get access to the powerful pygame.surfarray module","Q_Score":0,"Tags":"python,image,colors,pygame,numerical","A_Id":28798012,"CreationDate":"2013-02-25T20:44:00.000","Title":"PYGAME - Edit colours of an image (makes white red at 255,0,0) without numerical python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python program that had some kind of error that prevents it from saving my data. The program is still running, but I cannot save anything. Unfortunately, I really need to save this data and there seems to be no other way to access it.\nDoes the DMP file created for the process through the task manager contain the data my program collected, and if so, how do I access it?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":15093780,"Users Score":1,"Answer":"Does it contain some or all of the current execution state of your program?  Yes.  Is it in a form that you could easily extract the information in the user-level format you are probably looking for from it?  Probably not.  It will dump the state of the entire Python interpreter, including the data as represented in memory for the specific Python program that is running.  To reconstruct that data, I'm pretty sure you'd need to run the Python interpreter itself in debug mode, then try to reconstruct your data from whatever your C debugger can piece together.  If this sounds very difficult or impossible to you, then you probably have some understanding of what it entails.","Q_Score":0,"Tags":"python,windows,python-2.7,save","A_Id":15094305,"CreationDate":"2013-02-26T16:06:00.000","Title":"Can you read variable data of an already running Python Script from its DMP file in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. \nSo how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. \nCan someone give me a practical way to do this?\nIt'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? \nThanks.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":218,"Q_Id":15101770,"Users Score":0,"Answer":"The whole point of a web application is that the GUI is written in HTML, CSS, and JavaScript, not Python. However, it talks to a web service, which can be written in Python.\nFor a well-written desktop app, the transition should be pretty easy. If you've already got a clean separation between the GUI part and the engine part of your code, the engine part will only need minor changes (and maybe stick it behind, e.g., a WSGI server). You will have to rewrite the GUI part for the web, but in a complex app, that should be the easy part.\nHowever, many desktop GUI apps don't have such a clean separation. For example, if you have button handlers that directly do stuff to your model, there's really no way to make that work without duplicating the model on both sides (the Python web service and the JS client app) and synchronizing the two, which is a lot of work and leads to a bad experience. In that case, you have to decide between rewriting most of your app from scratch, or refactoring it to the point where you can web-service-ify it.\nIf you do choose to go the refactoring route, I'd consider adding a second local interface (maybe using the cmd module to build a CLI, or tkinter for an alternate GUI), because that's much easier to do. Once the same backend code can support your PyQt GUI and your cmd GUI, adding a web interface is much easier.","Q_Score":0,"Tags":"javascript,python,google-chrome,web-applications,tsv","A_Id":15101984,"CreationDate":"2013-02-26T23:55:00.000","Title":"How to setup a web app which can handle local data without uploading the data? Use python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. \nSo how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. \nCan someone give me a practical way to do this?\nIt'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? \nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":218,"Q_Id":15101770,"Users Score":1,"Answer":"No, you cannot run Python code in a web browser.[1]  You'd have to port the core of your application to JavaScript to do it all locally.\nJust do the upload.  20MB isn't all that much data, and if it's stored on the server then they can all look at each others' results, too.\n\n[1] There are some tools that try to transpile Python to JavaScript: pyjs compiles directly, and Emscripten is an entire LLVM interpreter in JS that can run CPython itself.  I wouldn't really recommend relying on these.","Q_Score":0,"Tags":"javascript,python,google-chrome,web-applications,tsv","A_Id":15101809,"CreationDate":"2013-02-26T23:55:00.000","Title":"How to setup a web app which can handle local data without uploading the data? Use python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. \nSo how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. \nCan someone give me a practical way to do this?\nIt'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? \nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":218,"Q_Id":15101770,"Users Score":0,"Answer":"If I get your point correctly, you want\n\nWeb connection, so your python program updated on server, client get it before using it.\nData store on local to avoid upload big file.\n\nYou can write a python program to check a server location to get your latest program if needed. You need a url \/ server file for program version \/ created date\/time information to determine if you need to update or not.\nAfter get latest python program, then start this python program to run locally.\nWith this said, What you need is to update your program to add below features:\n\nAccess your server, to get latest version information\nCheck against current version to see if you need to download latest program\nDownload latest version and use that to run locally.\n\nDoes this solve your problem?","Q_Score":0,"Tags":"javascript,python,google-chrome,web-applications,tsv","A_Id":32979390,"CreationDate":"2013-02-26T23:55:00.000","Title":"How to setup a web app which can handle local data without uploading the data? Use python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards.\nWould it be bad to store the processing info as:\nCard_79x123_53_53.png\nUpon getting the filename from a file dialog, I would split the underscores to get the following info:\n\nObjectType : matched to list\n(w,h)\nNumber of objects expected (in case there's tailing empty space)\nExtra info (in this case the location of the face-down texture relative to N above)\nand the dimensions of the image provide the rest, of course.\n\nANY error in processing would of course be raised and the attempt to load textures would be rejected.\nIs there a reason why this is a bad idea or should I keep toying with it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":15104090,"Users Score":0,"Answer":"Is there a reason why this is a bad idea or should I keep toying with it?\n\nThis is essentially like encoding file type by file extension. The only bad thing about encoding file metadata in the filename is it's quite limited in space. You can encode much richer metadata if you used proper PNG metadata field or in a separate file. Encoding metadata in the file name is hard to extend with new fields in new version, with optional fields, etc.\nFor example, you might find out that you want miscellaneous sprite sheet where each frame has different size, and so you need to encode the position, size, class name, and serial number for each individual frame.\nIt's fine as long as you don't expect to want to encode many other metadata in the future.","Q_Score":0,"Tags":"python,png","A_Id":15104289,"CreationDate":"2013-02-27T04:13:00.000","Title":"Is it a bad idea to use a PNG image's filename to store the info on how to process it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards.\nWould it be bad to store the processing info as:\nCard_79x123_53_53.png\nUpon getting the filename from a file dialog, I would split the underscores to get the following info:\n\nObjectType : matched to list\n(w,h)\nNumber of objects expected (in case there's tailing empty space)\nExtra info (in this case the location of the face-down texture relative to N above)\nand the dimensions of the image provide the rest, of course.\n\nANY error in processing would of course be raised and the attempt to load textures would be rejected.\nIs there a reason why this is a bad idea or should I keep toying with it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":15104090,"Users Score":0,"Answer":"Probably it would be better to ask user about how to process image explicitly either by adding extra controls into file dialog, or by showing another dialog after file dialog is submitted.  In this case information taken from file name could be used as hints to preliminary fill these extra controls with values, but user will have a chance to correct what is wrong and fill what is missing.","Q_Score":0,"Tags":"python,png","A_Id":15104140,"CreationDate":"2013-02-27T04:13:00.000","Title":"Is it a bad idea to use a PNG image's filename to store the info on how to process it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"It seems the socket connection through paramiko (v1.10.0) is not stable. \nI have two computers. The python code is on the PC one. The connection sometime is successful and sometime is not (Same code). When the PC paramiko code fails (socket.error, 10060), I use my Mac via terminal ssh login the server and everything is fine.\nI use set_missing_host_key_policy in the code. But the Mac has the key I guess. I typed yes when login at the first time.\nIf the unstable connection is caused by the hotkey, how do I get the host key? From the server or somewhere in my local folder (win7)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3123,"Q_Id":15105183,"Users Score":1,"Answer":"Try switching off Windows firewall. It's a network error, it should not be because of SSH key problems.\nError Code 10060: Connection timeout\nBackground: The gateway could not receive a timely response from the website you are trying to access. This might indicate that the network is congested, or that the website is experiencing technical difficulties.","Q_Score":0,"Tags":"python,sockets,ssh,paramiko","A_Id":15105597,"CreationDate":"2013-02-27T05:56:00.000","Title":"python paramiko module socket.error, errno 10060","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python script that normally runs out of cron.  Sometimes, I want to run it myself in a (Unix) shell, and if so, have it write its output to the terminal instead of writing to a log file.\nWhat is the pythonic way of determining if a script is running out of cron or in an interactive shell (I mean bash, ksh, etc. not the python shell)?\nI could check for the existence of the TERM environment variable perhaps?  That makes sense but seems deceptively simple...\nCould os.isatty somehow be used?\nI'm using Python 2.6 if it makes a difference.  Thanks!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":206,"Q_Id":15121468,"Users Score":2,"Answer":"If you really need to check this, Pavel Anossov's answer is the way to do it, and it's pretty much the same as your initial guess.\nBut do you really need to check this? Why not just write a Python script that writes to stdout and\/or stderr, and your cron job can just redirect to log files?\nOr, even better, use the logging module and let it write to syslog or whatever else is appropriate and also write to the terminal if there is one?","Q_Score":2,"Tags":"python,python-2.6","A_Id":15121639,"CreationDate":"2013-02-27T20:13:00.000","Title":"How to check if I'm running in a shell (have a terminal) in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am with Python 2.7, pyScss 1.15 and Compass 0.12.2, but Compass dosn't work, could someone give an advise how to make it work?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":15134201,"Users Score":0,"Answer":"You don't need compass with pyScss. Just run \"python pyScss -mscss\" to watch your workingdir for changes and compile the .scss (or .sass) to .css.","Q_Score":0,"Tags":"python-2.7,sass,compass-sass","A_Id":15987894,"CreationDate":"2013-02-28T11:20:00.000","Title":"Compass not working with pyScss 1.1.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1791,"Q_Id":15171378,"Users Score":1,"Answer":"What methods are you using to draw the images? It's hard to answer this question without that.\nIf you aren't already doing this, you could use a class to hold data about your image, such as position and geometry.","Q_Score":0,"Tags":"python,image,drag-and-drop,pygame","A_Id":15173810,"CreationDate":"2013-03-02T06:07:00.000","Title":"How to get image position in Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1791,"Q_Id":15171378,"Users Score":1,"Answer":"If you derive your classes from pygame.sprite.Sprite , you can get the position by guy.rect. Depending on if you want center, or toplef, or the full rect:\nguy.rect.topleft or guy.rect.center or guy.rect","Q_Score":0,"Tags":"python,image,drag-and-drop,pygame","A_Id":15177879,"CreationDate":"2013-03-02T06:07:00.000","Title":"How to get image position in Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First question posted to Stack Overflow but have spent many hours reading answers here :).\nI'm creating a Heroku Python app and am using responsive design media queries in my css.  I deploy my app to Heroku and visit myherokuapp.herokuapp.com. Website looks fine on laptop browser...responsive design elements working as well.  Visiting the same url on my iPhone, however, seems to show a page where one of my css files (the media queries) is loading but the other (the main css file) is not.  \nDoes Heroku cache css files?  I read somewhere that you have to host static files elsewhere if you have a Django app, but not sure if that's applicable to me.  I'm also using the Flask function <link rel=\"stylesheet\" href=\"{{ url_for('static', filename='css\/style.css') }}\">.  Does that have anything to do with it?\nEdit: Does anyone know how to run the equivalent of the Firefox\/Google Inspector on mobile?  That would really help me figure out what files are there and what aren't.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":381,"Q_Id":15172826,"Users Score":0,"Answer":"Bug found.  It was a very, very obscure rendering issue with the text-indent css attribute that only seemed to affect the iPhone 5.\nAdditionally, if you ever need to debug Google Chrome for iPhone, clearing the cache won't do anything if you don't delete the app from the multitasking menu too (the bar that comes up when you double tap the home button).  That literally took me half an hour to figure out.","Q_Score":0,"Tags":"python,css,heroku,responsive-design,flask","A_Id":15181474,"CreationDate":"2013-03-02T09:21:00.000","Title":"Heroku Python App - CSS Not Loading On IPhone Only","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie to boost and one of its libraries which I can't understand it is Boost.Python. Can anyone explain me in details how does this interoperability achieved?In the documentation there only a few words about metaprogramming.\nP.S. I tried to look code but because of my lack of C++ knowledge I didn't understand principles.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":301,"Q_Id":15180611,"Users Score":5,"Answer":"There are two ways to interoperate:\n1) from a \"Python process\", call functions written in C++.\nPython already has a system to load dlls, they're called \"extension modules\". Boost.Python can compile your source to produce one. Basically you write a little wrapper to declare a function callable from Python, and the \"metaprogramming\" is there to do stuff like detecting what types the C++ function takes and returns, so that it can emit the right code to convert those from\/to the equivalent Python types.\n2) from a \"C++ process\", launch and control the Python interpreter.\nPython provides a C API to do this, and Boost.Python knows how to use it.","Q_Score":3,"Tags":"c++,boost,boost-python","A_Id":15180650,"CreationDate":"2013-03-02T23:24:00.000","Title":"How does boost::python work?Any ideas about the realisation details?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to find the presence of an element by finding the length of the jquery.\nHow can we capture the length of a webelement in a variable, so that I can check the value of the variable to make decision.\nOr is there any other way to accomplish the same result. I am using python, selenium webdriver and JQuery. Thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":467,"Q_Id":15187345,"Users Score":0,"Answer":"We can Use this Funda\nIf driver.findElements(By.id(id)).size() > 0 Then\n  Element Present;\nElse\n  Element Not Present\nSame Applies for Value.\nPlease Let me know is my Funda OK or NOT.","Q_Score":0,"Tags":"jquery,python,selenium-webdriver","A_Id":22935427,"CreationDate":"2013-03-03T15:42:00.000","Title":"When using python and selenium how to find the presence of an element based on id and value","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"If you try to run virtualenv with the environmental variable PYTHONDONTWRITEBYTECODE=true set, it gives this error:\nThe PYTHONDONTWRITEBYTECODE environment variable is not compatible with setuptools. Either use --distribute or unset PYTHONDONTWRITEBYTECODE.\nWhy does setuptools require the ability to write bytecode?\nI don't particularly like having .pyc files around, so I like to prevent it from being written. \n(I'm not asking how to get around this; that's trivial: just add PYTHONDONTWRITEBYTECODE=\"\" at the beginning of any command that requires the flag to be unset, or unset it globally)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":366,"Q_Id":15207938,"Users Score":1,"Answer":"Use a recent version of virtualenv and you will not see this error.","Q_Score":5,"Tags":"python,virtualenv,setuptools","A_Id":33958217,"CreationDate":"2013-03-04T18:00:00.000","Title":"Why does setuptools need to write bytecode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've looked around for an answer to this, but i don't know how to phrase it in a way that google will understand.\nI'm trying to learn Python, and i've installed it on my machine. However, when i just type \"python\" in cmd.exe, the python app is not found\/launched.\nI have to manually go to the directory in which python.exe is found in order to run my python commands. Is this normal? Online tutorials seem to indicate that I should be able to run the app from anywhere :s\nI'm on Win7, and trying to run Python from the Django stack by BitNami.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":15210454,"Users Score":1,"Answer":"http:\/\/stackoverflow.com\/questions\/7054424\/python-not-recognised-as-a-command\nAdd python to your environment path. You should then be able to use it anywhere.","Q_Score":1,"Tags":"python,console","A_Id":15210530,"CreationDate":"2013-03-04T20:25:00.000","Title":"How to start app without navigating to its directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose a python program is running. Say the object of an Class in that program can give you some stats. So if i have to develop a web UI to display the stats, how do i get the instance of that class which is running[as an separate desktop app] and display the stats in web, which I would be using web2py or django.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":160,"Q_Id":15221155,"Users Score":1,"Answer":"You can't (easily) \"get an instance of a running program\" from outside. You can certainly instrument your program so that it communicates its statistics somehow, eg via a socket, or as an even lower-tech solution you could get it to store the relevant data periodically in a file on disk or in a database, which your web app could read.","Q_Score":0,"Tags":"python,multithreading,instance","A_Id":15221754,"CreationDate":"2013-03-05T10:13:00.000","Title":"Get instance of an running Python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. \nWhat's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","AnswerCount":23,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":1701097,"Q_Id":15221473,"Users Score":8,"Answer":"for windows,\n\ngo to command prompt\nand use this command\npython -m pip install -\u2013upgrade pip\nDont forget to restart the editor,to avoid any error\nyou can check the version of the pip by\npip --version\nif you want to install any particular version of pip , for example version 18.1 then use this command,\npython -m pip install pip==18.1","Q_Score":771,"Tags":"python,upgrade,virtualenv,pip,package-managers","A_Id":65086049,"CreationDate":"2013-03-05T10:29:00.000","Title":"How do I update\/upgrade pip itself from inside my virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. \nWhat's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","AnswerCount":23,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1701097,"Q_Id":15221473,"Users Score":0,"Answer":"While updating pip in virtual env use full path in python command\nEnvirnments folder struture\n\nmyenv\\scripts\\python\n\nh:\\folderName\\myenv\\scripts\\python -m pip install --upgrade pip","Q_Score":771,"Tags":"python,upgrade,virtualenv,pip,package-managers","A_Id":72138923,"CreationDate":"2013-03-05T10:29:00.000","Title":"How do I update\/upgrade pip itself from inside my virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. \nWhat's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","AnswerCount":23,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1701097,"Q_Id":15221473,"Users Score":0,"Answer":"I had installed Python in C:\\Python\\Python36 so I went to the Windows command prompt and typed \"cd C:\\Python\\Python36 to get to the right directory. Then entered the \"python -m install --upgrade pip\" all good!","Q_Score":771,"Tags":"python,upgrade,virtualenv,pip,package-managers","A_Id":49479521,"CreationDate":"2013-03-05T10:29:00.000","Title":"How do I update\/upgrade pip itself from inside my virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm planning to build a Django app to generate and later server static pages (probably stored on S3). When users visit a url like mysite.com\/static-pages\/12345 the static file in my S3 bucket named 12345.html should be served. That static file might be the static html page of a blog page my site has generated for the user, for example.\nThis is different from including static resources like CSS\/Javascript files on a page that is rendered as a Django template since I already know how to use Django templates and SQL databases - what's unfamiliar to me is that my \"data\" is now a file on S3 rather than an entry in a database AND that I don't actually need to use a template.\nHow exactly can I retrieve the requested data (i.e. a static page) and return it to the user? I'd like to minimize performance penalties within reason, although of course it would be fastest if users directly requested their static pages from S3 (I don't want them to do this)\". \nA few additional questions:\nI've read elsewhere about a django flatpages app which stores html pages in a database, but it seems like static html pages are best stored on a filesystem like S3, no?\nIs there a way to have the request come in to my Django application and have S3 serve the file directly while making it appear to have come from my application (i.e. the browser url still says mysite.com\/static-pages\/12345, but the page did not go through my Django server)?\nThanks very much!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":795,"Q_Id":15237706,"Users Score":0,"Answer":"You can just create index.html inside \/static-pages\/12345\/ folder and it will be served.","Q_Score":2,"Tags":"python,django,amazon-s3","A_Id":15782517,"CreationDate":"2013-03-06T02:07:00.000","Title":"Serve Static Pages from S3 using Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have several thousand tests that I want to run in parallel. The tests are all compiled binaries that give a return code of 0 or non-zero (on failure). Some unknown subsets of them try to use the same resources (files, ports, etc). Each test assumes that it is running independently and just reports a failure if a resources isn't available.\nI'm using Python to launch each test using the subprocess module, and that works great serially. I looked into Nose for parallelizing, but I need to autogenerate the tests (to wrap each of the 1000+ binaries into Python class that uses subprocess) and Nose's multiprocessing module doesn't support parallelizing autogenerated tests.\nI ultimately settled on PyTest because it can run autogenerated tests on remote hosts over SSH with the xdist plugin.\nHowever, as far as I can tell, it doesn't look like xdist supports any kind of control of how the tests get distributed. I want to give it a pool of N machines, and have one test run per machine.\nIs what I want possible with PyTest\/xdist? If not, is there a tool out there that can do what I'm looking for?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1185,"Q_Id":15260422,"Users Score":0,"Answer":"I am not sure if this would help. But if you know ahead of time how you want to divide up your tests, instead of having pytest distribute your tests, you could use your continuous integration server to call a different run of pytest for each different machine. Using -k or -m to select a subset of tests, or simply specifying different test dir paths, you could control which tests are run together.","Q_Score":3,"Tags":"python,testing,nose,pytest","A_Id":25073350,"CreationDate":"2013-03-06T23:45:00.000","Title":"Controlling the distribution of tests with py.test xdist","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem in kettle connecting python. In kettle, I only find the js script module.\nDoes kettle support python directly? I mean, can I call a python script in kettle without using js or others?\nBy the way, I want to move data from Oracle to Mongo regularly. I choose to use python to implement the transformation. So without external files, does it have some easy methods to keep the synchronization between a relational db and a no-rdb?\nThanks a lot.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6043,"Q_Id":15263196,"Users Score":2,"Answer":"It doesnt support it directly from what I've seen.\nHowever there is a mongodb input step. And a lot of work has been done on it recently ( and still ongoing.  \nSo given there is a mongodb input step, if you're using an ETL tool already then why would you want to make it execute a python script to do the job??","Q_Score":3,"Tags":"python,kettle","A_Id":15274794,"CreationDate":"2013-03-07T04:39:00.000","Title":"how to call python script in kettle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates?\nAssuming I've just created a brand new project with Django 1.4, what all do I need to do to be able to render images? Where should I put the media and static folders?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":528,"Q_Id":15282318,"Users Score":0,"Answer":"The created project should have a static folder. Put all resources (images, ...) in there.\nThen, in your HTML template, you can reference STATIC_ROOT and add the resource path (relative to the static folder)","Q_Score":1,"Tags":"python,django,python-2.7","A_Id":15282357,"CreationDate":"2013-03-07T21:41:00.000","Title":"Django Static Setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates?\nAssuming I've just created a brand new project with Django 1.4, what all do I need to do to be able to render images? Where should I put the media and static folders?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":528,"Q_Id":15282318,"Users Score":2,"Answer":"Put your static files into <app>\/static or add an absolute path to STATICFILES_DIRS\nConfigure your web server (you should not serve static files with Django) to serve files in STATIC_ROOT\nPoint STATIC_URL to the base URL the web server serves\nRun .\/manage.py collectstatic\nBe sure to use RequestContext in your render calls and {{ STATIC_URL }} to prefix paths\nCoffee and pat yourself on the back \n\nA little bit more about running a web server in front of Django. Django is practically an application server. It has not been designed to be any good in serving static files. That is why it actively refuses to do that when DEBUG=False. Also, the Django development server should not be used for production. This means that there should be something in front of Django at all times. It may be a WSGI server such as gunicorn or a 'real' web server such as nginx or Apache.\nIf you are running a reverse proxy (such as nginx or Apache) you can bind \/static to a path in the filesystem and the rest of the traffic to pass through to Django. That means your STATIC_URL can be a relative path. Otherwise you will need to use an absolute URL.","Q_Score":1,"Tags":"python,django,python-2.7","A_Id":15283333,"CreationDate":"2013-03-07T21:41:00.000","Title":"Django Static Setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm doing the sentiment analysis for the Arabic language , I want to creat my own corpus , to do that , I collect 300 status from facebook and I classify them into positive and negative , now I want to do the tokenization of these status , in order to obain a list of words , and hen generate unigrams and bigrams, trigrams and use the cross fold validation , I'm using for the moment the nltk python, is this software able to do this task fr the arabic language or the rapis Minner will be better to work with , what do you think and I'm wondering how to generate the bigrams, trigrams and use the cross fold validation , is there any idea ??","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1057,"Q_Id":15282336,"Users Score":0,"Answer":"Well, I think that rapidminer is very interesting and can handle this task. It contains several operators dealing with text mining. Also, it allows the creation of new operators with high fluency.","Q_Score":2,"Tags":"python,nlp,nltk,sentiment-analysis,rapidminer","A_Id":15319789,"CreationDate":"2013-03-07T21:42:00.000","Title":"creating arabic corpus","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python 2.7 and Jenkins.\nI am writing some code in Python that will perform a checkin and wait\/poll for Jenkins job to be complete. I would like some thoughts on around how I achieve it.\n\nPython function to create a check-in in Perforce-> This can be easily done as P4 has CLI\nPython code to detect when a build got triggered -> I have the changelist and the job number. How do I poll the Jenkins API for the build log to check if it has the appropriate changelists? The output of this step is a build url which is carrying out the job\nHow do I wait till the Jenkins job is complete?\n\nCan I use snippets from the Jenkins Rest API or from Python Jenkins module?","AnswerCount":8,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15591,"Q_Id":15297322,"Users Score":4,"Answer":"You can query the last build timestamp to determine if the build finished. Compare it to what it was just before you triggered the build, and see when it changes. To get the timestamp, add \/lastBuild\/buildTimestamp to your job URL\nAs a matter of fact, in your Jenkins, add \/lastBuild\/api\/ to any Job, and you will see a lot of API information. It even has Python API, but I not familiar with that so can't help you further\nHowever, if you were using XML, you can add lastBuild\/api\/xml?depth=0 and inside the XML, you can see the <changeSet> object with list of revisions\/commit messages that triggered the build","Q_Score":10,"Tags":"python-2.7,jenkins","A_Id":15340482,"CreationDate":"2013-03-08T15:21:00.000","Title":"Wait until a Jenkins build is complete","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks \"python\" and the other uses \"python3\". so I ran brew install python3. \nI really only care about using python 3 so I would like the default command to be \"python\" instead of having to type \"python3\" every time. Is there a way to do this?  I tried brew switch python 3.3 but I get a \"python is not found in the Cellar\" error.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":11485,"Q_Id":15304785,"Users Score":8,"Answer":"You definitely do not want to do this! You may only care about Python 3, but many people write code that expects python to symlink to Python 2. Changing this can seriously mess your system up.","Q_Score":13,"Tags":"python,symlink,homebrew","A_Id":15304867,"CreationDate":"2013-03-08T23:01:00.000","Title":"In homebrew how do I change the python3 symlink to only \"python\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks \"python\" and the other uses \"python3\". so I ran brew install python3. \nI really only care about using python 3 so I would like the default command to be \"python\" instead of having to type \"python3\" every time. Is there a way to do this?  I tried brew switch python 3.3 but I get a \"python is not found in the Cellar\" error.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":11485,"Q_Id":15304785,"Users Score":1,"Answer":"As mentioned this is not the best idea. However, the simplest thing to do when necessary is run python3 in terminal. If you need to run something for python3 then run python3","Q_Score":13,"Tags":"python,symlink,homebrew","A_Id":42743923,"CreationDate":"2013-03-08T23:01:00.000","Title":"In homebrew how do I change the python3 symlink to only \"python\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this:\nErrno 2: No such file or directory\nErrno 122: Disk quota exceeded\n...","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":10342,"Q_Id":15304934,"Users Score":6,"Answer":"I fear those come straight from the standard C library, so you'll have to look it up in your system documentation. (GLibC, Microsoft, UNIX\u2026)","Q_Score":11,"Tags":"python,exception","A_Id":15304996,"CreationDate":"2013-03-08T23:15:00.000","Title":"How to get the list of error numbers (Errno) for an Exception type in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this:\nErrno 2: No such file or directory\nErrno 122: Disk quota exceeded\n...","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":10342,"Q_Id":15304934,"Users Score":4,"Answer":"look for errno.h on your system.","Q_Score":11,"Tags":"python,exception","A_Id":15305006,"CreationDate":"2013-03-08T23:15:00.000","Title":"How to get the list of error numbers (Errno) for an Exception type in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So I have algorithms (easily searchable on the net) for prime factorization and divisor acquisition but I don't know how to scale it to finding those divisors within a range. For example all divisors of 100 between 23 and 49 (arbitrary). But also something efficient so I can scale this to big numbers in larger ranges. At first I was thinking of using an array that's the size of the range and then use all the primes <= the upper bound to sieve all the elements in that array to return an eventual list of divisors, but for large ranges this would be too memory intensive.\nIs there a simple way to just directly generate the divisors?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1052,"Q_Id":15329256,"Users Score":0,"Answer":"As Malvolio was (indirectly) going about, I personal wouldn't find a use for prime factorization if you want to find factors in a range, I would start at int t = (int)(sqrt(n)) and then decremnt until1. t is a factor2. Complete util t or t\/n range has been REACHED(a flag) and then (both) has left the range\nOr if your range is relatively small, check versus those values themselves.","Q_Score":1,"Tags":"c++,python,algorithm,primes,prime-factoring","A_Id":15329656,"CreationDate":"2013-03-11T00:01:00.000","Title":"How can I efficiently get all divisors of X within a range if I have X's prime factorization?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently exploring using python to develop my server-side implementation. I've decided to use SQLAlchemy for database stuff.\nWhat I'm not currently to sure about is how it should be set up so that more than one developer can work on the project. For the code it is not a problem but how do I handle the database modifications? How do the users sync databases and how should potential data be set up? Should\/can each developer use their own sqlite db for development?\nFor production postgresql will be used but the developers must be able to work offline.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":15345864,"Users Score":0,"Answer":"Make sure you have a python programs or programs to fill databases with test data from scratch. It allows each developer to work from different starting points, but also test with the same environment.","Q_Score":0,"Tags":"python,database,development-environment","A_Id":15346132,"CreationDate":"2013-03-11T18:28:00.000","Title":"Multi developer environment python and sqlalchemy","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to make a simple p2p vpn app, after a lot of searches I found a tun\/tap module for python called PYTUN that is used to make a tunnel. How can I use this module to create a tunnel between 2 remote peers?\nAll the attached doc only show how to make the tunnel interface on your local computer and config it, but it does not mention how to connect it to the remote peer.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2900,"Q_Id":15346908,"Users Score":0,"Answer":"pytun is not sufficient for this.  It serves to connect your Python application to a system network interface.  In effect, you become responsible for implementing that system network interface.\nIf you want traffic that is routed over that network interface to traverse an actual network, then it is the job of your Python program to do the actual network operations that move the data from host A to host B.\nThis is probably a lot of work to do well.  I suggest you use an existing VPN tool instead.","Q_Score":2,"Tags":"python,networking","A_Id":17349828,"CreationDate":"2013-03-11T19:27:00.000","Title":"how to use the tun\/tap python module (pytun) to create a p2p tunnel?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running windows 7 32 bit and i am using sublime text 2 I want to know how can I change the default python in ST2 to the python 3.3 I down loaded. Any help would be great thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1111,"Q_Id":15353057,"Users Score":0,"Answer":"You need to change the Sublime build system for Python. Copy the Python.sublime-build file from the Packages\/Python folder to the Packages\/User folder. In the file in the User folder, change the cmd option from python to c:\/python33\/python (where your Python 3.3 executable is located).","Q_Score":0,"Tags":"sublimetext2,python-3.3","A_Id":15373407,"CreationDate":"2013-03-12T03:59:00.000","Title":"python 3.3 on sublime text 2 windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do \"import os\" followed by \"os.chdir(\"\")\" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it.\nIn particular, I've looked into my OS (Ubuntu)'s desktop entry '\/usr\/share\/applications\/idle-python3.2.desktop', which doesn't contain a conf file, but points to '\/usr\/lib\/python3.2\/idlelib\/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed.\nIt seems that the path is hard-coded in PyShell.py, though I could be wrong with my  limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":37378,"Q_Id":15367688,"Users Score":0,"Answer":"Here's a way to reset IDLE's default working directory for MacOS if you launch Idle as an application by double-clicking it.  You need a different solution if you launch Idle from a command line in Terminal.  This solution is a permanent fix.  You don't have to rechange the directory everytime you launch IDLE.  I wish it were easier.\nThe idea is to edit a resource file inside of the IDLE package in Applications.  \n\nStart by finding the the file.  In Finder, go to IDLE in Applications (in the Python folder) as if you wanted to open it.  Right click and select \"show package contents\".  Open Contents, then open Resources.  In Resources, you'll see a file called idlemain.py.  This file executes when you launch idle and sets, among other things, the working directory. We're going to edit that. \nBut before you can edit it, you need to give yourself permission to write to it.  To do that, right click on the idlemain.py and select get info.  Scroll to the bottom of the getinfo window and you'll see the Sharing & Permissions section.  On the bottom right there's a lock icom.  Click the lock and follow the prompts to unlock it.  Once it's unlocked, look to the left for the + (under the list of users with permissions).  Click it.  That will bring up a window with a list of users you can add.  Select yourself (probably the name of your computer or your user account) and click Select.  You'll see yourself added to the list of names with permissions.  Click where is says \"Read only\" next to your name and change it to \"Read & Write\".  Be careful not to change anything else.   When you're done, click the lock again to lock the changes.\nNow go back to idlemain.py and open it with any text editor (you could use Idle, TextEdit, or anything.  Right under the import statement at the top is the code to change the default working directory.  Read the comment if you like, then replace the single line of code under the comment with \nos.chdir('path of your desired working directory')\n\nMine looks like this:\nos.chdir('\/Users\/MyName\/Documents\/Python')\n\nSave your changes (which should work because you gave yourself permission).  Next time you start Idle, you should be in your desired working directory.  You can check with the following commands:\nimport os\nos.getcwd()","Q_Score":11,"Tags":"python,python-idle","A_Id":49071459,"CreationDate":"2013-03-12T17:11:00.000","Title":"Default working directory for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do \"import os\" followed by \"os.chdir(\"\")\" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it.\nIn particular, I've looked into my OS (Ubuntu)'s desktop entry '\/usr\/share\/applications\/idle-python3.2.desktop', which doesn't contain a conf file, but points to '\/usr\/lib\/python3.2\/idlelib\/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed.\nIt seems that the path is hard-coded in PyShell.py, though I could be wrong with my  limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","AnswerCount":9,"Available Count":3,"Score":-0.022218565,"is_accepted":false,"ViewCount":37378,"Q_Id":15367688,"Users Score":-1,"Answer":"This ought to be the number one answer.  I have been playing around this for an hour or more and nothing worked.  Paul explains this perfectly.  It's just like the PATH statement in Windows.  I successfully imported a module by appending my personal \"PythonModules\" path\/dir on my Mac (starting at \"\/users\/etc\") using a simple \nimport xxxx command in Idle.","Q_Score":11,"Tags":"python,python-idle","A_Id":54316970,"CreationDate":"2013-03-12T17:11:00.000","Title":"Default working directory for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do \"import os\" followed by \"os.chdir(\"\")\" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it.\nIn particular, I've looked into my OS (Ubuntu)'s desktop entry '\/usr\/share\/applications\/idle-python3.2.desktop', which doesn't contain a conf file, but points to '\/usr\/lib\/python3.2\/idlelib\/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed.\nIt seems that the path is hard-coded in PyShell.py, though I could be wrong with my  limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","AnswerCount":9,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":37378,"Q_Id":15367688,"Users Score":0,"Answer":"It can change depending on where you installed Python. Open up IDLE, import os, then call os.getcwd() and that should tell you exactly where your IDLE is working on.","Q_Score":11,"Tags":"python,python-idle","A_Id":15367752,"CreationDate":"2013-03-12T17:11:00.000","Title":"Default working directory for Python IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt.  The numpy array contains only floats.  I then read the file in one row at a time in a separate C++ program.\nWhat I would like to do is find a way to accomplish this same task, changing my code as little as possible such that I can decrease the size of the file I am passing between the two programs.  \nI found that I can use numpy.savetxt to save to a compressed .gz file instead of a text file.  This lowers the file size from ~2MB to ~100kB.  \nIs there a better way to do this?  Could I, perhaps, write the numpy array in binary to the file to save space?  If so, how would I do this so that I can still read it into the C++ program?\nThank you for the help.  I appreciate any guidance I can get.\nEDIT:\nThere are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":7265,"Q_Id":15369985,"Users Score":0,"Answer":"If you don't mind installing additional packages (for both python and c++), you can use [BSON][1] (Binary JSON).","Q_Score":6,"Tags":"python,numpy,scipy","A_Id":15370151,"CreationDate":"2013-03-12T19:07:00.000","Title":"python - saving numpy array to a file (smallest size possible)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt.  The numpy array contains only floats.  I then read the file in one row at a time in a separate C++ program.\nWhat I would like to do is find a way to accomplish this same task, changing my code as little as possible such that I can decrease the size of the file I am passing between the two programs.  \nI found that I can use numpy.savetxt to save to a compressed .gz file instead of a text file.  This lowers the file size from ~2MB to ~100kB.  \nIs there a better way to do this?  Could I, perhaps, write the numpy array in binary to the file to save space?  If so, how would I do this so that I can still read it into the C++ program?\nThank you for the help.  I appreciate any guidance I can get.\nEDIT:\nThere are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":7265,"Q_Id":15369985,"Users Score":1,"Answer":"numpy.ndarray.tofile and numpy.fromfile are useful for direct binary output\/input from python.  std::ostream::write std::istream::read are useful for binary output\/input in c++.\nYou should be careful about endianess if the data are transferred from one machine to another.","Q_Score":6,"Tags":"python,numpy,scipy","A_Id":15370191,"CreationDate":"2013-03-12T19:07:00.000","Title":"python - saving numpy array to a file (smallest size possible)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt.  The numpy array contains only floats.  I then read the file in one row at a time in a separate C++ program.\nWhat I would like to do is find a way to accomplish this same task, changing my code as little as possible such that I can decrease the size of the file I am passing between the two programs.  \nI found that I can use numpy.savetxt to save to a compressed .gz file instead of a text file.  This lowers the file size from ~2MB to ~100kB.  \nIs there a better way to do this?  Could I, perhaps, write the numpy array in binary to the file to save space?  If so, how would I do this so that I can still read it into the C++ program?\nThank you for the help.  I appreciate any guidance I can get.\nEDIT:\nThere are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":7265,"Q_Id":15369985,"Users Score":1,"Answer":"Use the an hdf5 file, they are really simple to use through h5py and you can use set compression a flag. Note that hdf5 has also a c++ interface.","Q_Score":6,"Tags":"python,numpy,scipy","A_Id":19226920,"CreationDate":"2013-03-12T19:07:00.000","Title":"python - saving numpy array to a file (smallest size possible)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can i add different base templates for different languages of same page in django cms?\nI am trying to set a page and show it in different languages. And for all the languages, i need to use a different base template.\nI am completely new django cms. Please help.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":404,"Q_Id":15372361,"Users Score":3,"Answer":"You need to create different page trees per language.\nEvery page has only one template. Use {% trans %} and {% blocktrans %} for translating string in it. Or {% if request.LANGUAGE == \"en\" %}.\nIf the templates really differ that much: don't add other languages to pages... but create different page trees with only one language.","Q_Score":0,"Tags":"python,django,content-management-system,django-cms","A_Id":15381624,"CreationDate":"2013-03-12T21:20:00.000","Title":"how to add different base templates for different languages of same page in django cms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to co-ordinate telling Server B to start a process from Server A, and then when its complete, run an import script on Server A. I'm having a hard time working out how I should be using SQS correctly in this scenario.\nServer A: Main Dedicated Server\nServer B: Cloud Process Server\n\nServer A sends message to SQS via SNS to say \"Start Process\"\nServer B constantly polls SQS for \"Start Process\" message\nServer B finds \"Start Process\" message on SQS\nServer B runs \"process.sh\" file\nServer B completes running \"process.sh\" file\nServer B removes \"Start Process\" from SQS\nServer B sends message to SQS via SNS to say \"Start Import\"\nServer A polls constantly polls SQS for \"Start Import\" message\nServer A finds \"Start Import\" message on SQS\nServer A runs import.sh\nServer A completes running \"import.sh\"\nServer A removes \"Start Import\" from SQS\n\nIs this how SQS should be used or am I missing the point completely?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1359,"Q_Id":15381092,"Users Score":1,"Answer":"What you laid out will work in theory, but I am moved away from putting messages directly into queues, and instead put those messages in to SNS topics, and then subscribe the queues to the topics to get them there - gives you more flexibility to change things down the road without every touching the code or the servers that are in production.\nFor the what you are doing now, the SNS piece is unnecessary, but using will allow you to change functionality without touching you existing servers down the road.\nFor example: needs change and you want to add a process C that also kicks off every time the 'Start Process' runs on Sever B. Right thru the AWS SNS console you could direct a second copy of the message to another Queue that previously did not exist, and setup a server C that polls from that Queue (a fan out pattern).\nAlso, what I often like to do during initial rollout is add notifications to SNS so I know whats going on, i.e. every time the 'start process' event occurs, I subscribe my cell phone (or email address) to the topic so I get notified - I can monitor in real time what is (or isn't) happening. Once a period of time has gone by after a production deployment, I can go into AWS console and simply unsubscribe my email\/cell from the process - without every touching any servers or code.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-sqs,amazon-sns","A_Id":15879297,"CreationDate":"2013-03-13T09:15:00.000","Title":"How should Amazon SQS be used? Import \/ Process Scenario","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to co-ordinate telling Server B to start a process from Server A, and then when its complete, run an import script on Server A. I'm having a hard time working out how I should be using SQS correctly in this scenario.\nServer A: Main Dedicated Server\nServer B: Cloud Process Server\n\nServer A sends message to SQS via SNS to say \"Start Process\"\nServer B constantly polls SQS for \"Start Process\" message\nServer B finds \"Start Process\" message on SQS\nServer B runs \"process.sh\" file\nServer B completes running \"process.sh\" file\nServer B removes \"Start Process\" from SQS\nServer B sends message to SQS via SNS to say \"Start Import\"\nServer A polls constantly polls SQS for \"Start Import\" message\nServer A finds \"Start Import\" message on SQS\nServer A runs import.sh\nServer A completes running \"import.sh\"\nServer A removes \"Start Import\" from SQS\n\nIs this how SQS should be used or am I missing the point completely?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1359,"Q_Id":15381092,"Users Score":1,"Answer":"Well... SQS doesn't not support message routing, in order to assign message to server A or B that why one of the available solutions: create SNS topics \"server a\" and \"server b\". These topics should put messages to SQS, which your application will pull. Also it possible to implement web hook - the subscriber on SNS events which will analyze message and do callback to your application.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-sqs,amazon-sns","A_Id":15397063,"CreationDate":"2013-03-13T09:15:00.000","Title":"How should Amazon SQS be used? Import \/ Process Scenario","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to co-ordinate telling Server B to start a process from Server A, and then when its complete, run an import script on Server A. I'm having a hard time working out how I should be using SQS correctly in this scenario.\nServer A: Main Dedicated Server\nServer B: Cloud Process Server\n\nServer A sends message to SQS via SNS to say \"Start Process\"\nServer B constantly polls SQS for \"Start Process\" message\nServer B finds \"Start Process\" message on SQS\nServer B runs \"process.sh\" file\nServer B completes running \"process.sh\" file\nServer B removes \"Start Process\" from SQS\nServer B sends message to SQS via SNS to say \"Start Import\"\nServer A polls constantly polls SQS for \"Start Import\" message\nServer A finds \"Start Import\" message on SQS\nServer A runs import.sh\nServer A completes running \"import.sh\"\nServer A removes \"Start Import\" from SQS\n\nIs this how SQS should be used or am I missing the point completely?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":1359,"Q_Id":15381092,"Users Score":3,"Answer":"I'm almost sorry that Amazon offers SQS as a service. It is not a \"simple queue\", and probably not the best choice in your case. Specifically: \n\nit has abysmal performance in low volume messaging (some messages will take 90 seconds to arrive) \nmessage order is not preserved\nit is fond of delivering messages more than once\nthey charge you for polling\n\nThe good news is it scales well. But guess what, you don't have a scale problem, so dealing with the quirky behavior of SQS is just going to cause you pain for no good reason. I highly recommend you check out RabbitMQ, it is going to behave exactly like you want a simple queue to behave.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-sqs,amazon-sns","A_Id":15391518,"CreationDate":"2013-03-13T09:15:00.000","Title":"How should Amazon SQS be used? Import \/ Process Scenario","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two Python files that I want to prevent anyone from executing unless it's from the server itself. The files implement a function that increases an amount of money to a user. What I need is to make this file not public to the web, so that if someone tries to call this file, the file would refuse this request, unless the call is from the server. \nDoes anyone know how I can do this? My first idea was to check for the IP address but a lot of people can spoof their IP.\nExample\nLet's say I have this file: function.py, a function in this file will accept a new amount of money and increase the appropriate balance in the database. \nWhen someone tries to post data to this file, and this person is outside the server (lets say from 244.23.23.0) the file will be in-accessible. Whereas, calling the function from the server itself will be accepted. \nSo files can access other files on the server, but external users cannot, with the result that no one can execute this file unless it's called from the server.\nThis is really important to me, because it's related to real money. Also, the money will come from PayPal IPN. And actually, if there was a way to prevent access unless it was coming from PayPal, that would be an amazing way to secure the app.\nOK, as far as what I have tried: \n\nPut the database in a cloud SQL using Google [https:\/\/developers.google.com\/cloud-sql\/]\nTry to check the IP of the incoming request, in the file\n\nThanks for any and all help.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":538,"Q_Id":15381202,"Users Score":0,"Answer":".htaccess, chmod or you could use a key defined by yourself... You have several possibilies.\nEdit: Anyway, if the file only contains a function. Nobody can use it from an external http request, unless you actually call it in this file: function();","Q_Score":0,"Tags":"php,python,security","A_Id":15381241,"CreationDate":"2013-03-13T09:20:00.000","Title":"Restrict execution of Python files only to server (prevent access from browser)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a python script(using python clang bindings) that parses C headers and extracts info about functions: name, return types, argument types.\nI have no problem with extracting function name, but I can't find a way to convert a clang.cindex.Type to C type string. (e.g. clang.cindex.TypeKind.UINT to unsigned int)\nCurrently, as a temporary solution, i have a dictionary clang.cindex.TypeKind -> C type string and code to process pointers and const qualifiers, but I didn't found a way to extract structure names.\nIs there a generic way to get C definition of clang.cindex.Type? If there isn't, how can I get C type string for clang.cindex.TypeKind.RECORD and clang.cindex.TypeKind.FUNCTIONPROTO types?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1599,"Q_Id":15388961,"Users Score":2,"Answer":"For RECORD, the function get_declaration() points to the declaration of the type (a union, enum, struct, or typedef); getting the spelling of the node returns its name. (Obviously, take care between differentiating the TYPEDEF_DECL vs. the underlying declaration kind.)\nFor FUNCTIONPROTO, you have to use a combination of get_result() and get_arguments().","Q_Score":4,"Tags":"python,clang,llvm-clang","A_Id":18359608,"CreationDate":"2013-03-13T15:04:00.000","Title":"Extract type string with Clang bindings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wonder how the Windows \"Open file with...\" feature works. Or rather, how would do if I write a program in python, compile a executable with py2exe and then want to be able to open certain files in that program by right-clicking and choose it in \"Open with\".\nIs the file simply passed as an argument, like \"CMD>C:\/myapp.exe file\"?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":262,"Q_Id":15393202,"Users Score":1,"Answer":"Yep, the path to the file gets passed in as an argument and can be accessed via sys.argv[1].","Q_Score":0,"Tags":"python,python-2.7,py2exe","A_Id":15393682,"CreationDate":"2013-03-13T18:10:00.000","Title":"Windows \"open with\" python py2exe application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know if there are any documented performance differences between a Python interpreter that I can install from an rpm (or using yum) and a Python interpreter compiled from sources (with a priori well set flags for compilations). \nI am using a Redhat 6.3 machine as Django\/Apache\/Mod_WSGI production server. I have already properly compiled everything in different setups and in different orders. However, I usually keep the build-dev dependencies on such machine. For some various ego-related (and more or less practical) reasons, I would like to use Python-2.7.3. By default, Redhat comes with Python-2.6.6. I think I could go with it but it would hurt me somehow (I would have to drop and find a replacement for a few libraries and my ego).\nHowever, besides my ego and dependencies, I would like to know what would be the impact in terms of performance for a Django server.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":139,"Q_Id":15397024,"Users Score":4,"Answer":"If you compile with the exact same flags that were used to compile the RPM version, you will get a binary that's exactly as fast. And you can get those flags by looking at the RPM's spec file.\nHowever, you can sometimes do better than the pre-built version. For example, you can let the compiler optimize for your specific CPU, instead of for \"general 386 compatible\" (or whatever the RPM was optimized for). Of course if you don't know what you're doing (or are doing it on purpose), it's always possible to build something slower than the pre-built version, too.\nMeanwhile, 2.7.3 is faster in a few areas than 2.6.6. Most of them usually won't affect you, but if they do, they'll probably be a big win.\nFinally, for the vast majority of Python code, the speed of the Python interpreter itself isn't relevant to your overall performance or scalability. (And when it is, you probably want to try PyPy, Jython, or IronPython to replace CPython.) This is especially true for a WSGI service. If you're not doing anything slow, Apache will probably be the bottleneck. If you are doing anything slow, it's probably something I\/O bound and well outside of Python's control (like reading files).\nUltimately, the only way you can know how much gain you get is by trying it both ways and performance testing. But if you just want a rule of thumb, I'd say expect a 0% gain, and be pleasantly surprised if you get lucky.","Q_Score":1,"Tags":"python,django,performance,apache,redhat","A_Id":15397078,"CreationDate":"2013-03-13T21:40:00.000","Title":"Performance differences between python from package and python compiled from source","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm using django and I'm trying to set up django-roa but when i'm trying to start my webserver I have this error cannot import name LOOKUP_SEP \nIf I remove django_roa from my INSTALLEDS_APP it's okay but I want django-roa working and I don't know how resolve this problem.\nAnd I don't know what kind of detail I can tell to find a solution.\nThanks","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2388,"Q_Id":15408255,"Users Score":0,"Answer":"django_roa is not yet compatible with django 1.5. I'm afraid it only works with django 1.3.","Q_Score":5,"Tags":"python,django","A_Id":15408439,"CreationDate":"2013-03-14T11:41:00.000","Title":"cannot import name LOOKUP_SEP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using django and I'm trying to set up django-roa but when i'm trying to start my webserver I have this error cannot import name LOOKUP_SEP \nIf I remove django_roa from my INSTALLEDS_APP it's okay but I want django-roa working and I don't know how resolve this problem.\nAnd I don't know what kind of detail I can tell to find a solution.\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2388,"Q_Id":15408255,"Users Score":0,"Answer":"I downgraded from 1.5.2 to 1.4.0 and my app started working again.  Via pip:\npip install django==1.4\nHope that helps.","Q_Score":5,"Tags":"python,django","A_Id":18352809,"CreationDate":"2013-03-14T11:41:00.000","Title":"cannot import name LOOKUP_SEP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been reading up on SimpleDB and one downfall (for me) is the 1kb max per attribute limit. I do a lot of RSS feed processing and I was hoping to store feed data in SimpleDB (articles) and from what I've read the best way to do this is to shard the article across several attributes. The typical article is < 30kb of plain text.\nI'm currently storing article data in DynamoDB (gzip compressed) without any issues, but the cost is fairly high. Was hoping to migrate to SimpleDB for cheaper storage with still fast retrievals. I do archive a json copy of all rss articles on S3 as well (many years of mysql headaches make me wary of db's).\nDoes anyone know to shard a string into < 1kb pieces? I'm assuming an identifier would need to be appended to each chunk for order of reassembly.\nAny thoughts would be much appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":255,"Q_Id":15442919,"Users Score":0,"Answer":"I opted to go with storing large text documents in Amazon S3 (retrieval seems to be quick), I'll be implementing an EC2 instance for caching the documents with S3 as a failover.","Q_Score":0,"Tags":"python,amazon-simpledb","A_Id":15460747,"CreationDate":"2013-03-15T22:13:00.000","Title":"python - simpledb - how to shard\/chunk a big string into several <1kb values?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I know how to download Excel files from Google Drive in .csv format. However, since .csv files do not support multiple sheets, I have developed a system in a for loop to add the '&grid=tab_number' to the file download url so that I can download each sheet as its own .csv file. The problem I have run into is finding out how many sheets are in the excel workbook on the Google Drive so I know how many times to set the for loop for.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":15456709,"Users Score":0,"Answer":"Ended up just downloading with xlrd and using that. Thanks for the link Rob.","Q_Score":0,"Tags":"python,excel,google-drive-api","A_Id":15505507,"CreationDate":"2013-03-17T01:39:00.000","Title":"Complicated Excel Issue with Google API and Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have a lot of python scripts that I have written for my work but no one in my lab knows how to use Python so I wanted to be able to generate a simple Mac App where you can 'Browse' for a file on your computer and type in the name of the file that you want to save . . . everything else will be processed by the application for the python script I have generated.  \nDoes anyone know if this is possible? I watched some tutorials on people generating applications in Xcode with Objective C but I don't want to have to learn a new language to reconstruct my Python scripts.\nThank you","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3884,"Q_Id":15469799,"Users Score":0,"Answer":"Open Automator\nChoose \"Application\"\nDrag a \"Run Shell Script\" onto the workflow panel\nChoose \"\/usr\/bin\/python\" as the shell. Paste in your script, and select Pass Input: \"to stdin\"\nOr, choose bash as the shell, and simply have the automator script run your Python script with Pass Input \"as arguments\" selected on the top right. You'll then use the contents of $@ as your arguments.\nSave the application. \nDone. You have a .app onto which files can be dragged.","Q_Score":3,"Tags":"python,xcode,interface","A_Id":15469982,"CreationDate":"2013-03-18T04:31:00.000","Title":"Is it possible to create Python-based Application in Xcode or equivalent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given that the code has been written indepdently of platform, how do I build a package for MAC OS when I am on Windows and the package has been successfully built there? I can use python setup.py bdist_msi on windows, but not python setup.py bdist_dmg, since I am not on MAC. What to do about that?\nPython 3.3, tkinter, cxFreeze, Windows 8.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":15485567,"Users Score":0,"Answer":"I am pretty sure OSX build tools (XCode et. al.) exist only on Apple platforms and there is no business rationale why Apple would have ported them to Windows.\nSo the probable answer is \"buy Mac\".","Q_Score":0,"Tags":"python","A_Id":15486937,"CreationDate":"2013-03-18T19:47:00.000","Title":"Build package for OSX when on Windows (Python 3.3, tkinter)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing maintenance for a python code. Python is installed in \/usr\/bin, the code installed in \/aaa, a python 2.5 installed under \/aaa\/python2.5. Each time I run Python, it use \/usr\/bin one. How to make it run \/aaa\/python2.5? \nAlso when I run Python -v; import bbb; bbb.__file__; it will automatically show it use bbb module under \/usr\/ccc\/(don't know why), instead of use bbb module under \/aaa\/python2.5\/lib\nHow to let it run python2.5 and use `\/aaa\/python2.5\/lib' module? The reason I asking this is if we maintain a code, but other people is still using it, we need to install the code under a new directory and modify it, run it and debug it.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1363,"Q_Id":15487848,"Users Score":1,"Answer":"Do \/aaa\/python2.5 python_code.py. If you use Python 2.5 more often, consider changing the $PATH variable to make Python 2.5 the default.","Q_Score":2,"Tags":"python,linux","A_Id":15487877,"CreationDate":"2013-03-18T22:06:00.000","Title":"How to run python in different directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to I get Emacs to use rst-mode inside of docstrings in Python files?  I vaguely remember that different modes within certain regions of a file is possible, but I don't remember how it's done.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1425,"Q_Id":15493342,"Users Score":0,"Answer":"As far as for edit-purposes, narrowing to docstring and activating rst-mode should be the way to go.\npython-mode el provides py--docstring-p, which might be easily adapted for python.el\nThan binding the whole thing to some idle-timer, would do the narrowing\/switching.\nRemains some expression which toggles-off rst-mode and widens.","Q_Score":13,"Tags":"python,emacs,restructuredtext","A_Id":28541254,"CreationDate":"2013-03-19T06:59:00.000","Title":"Have Emacs edit Python docstrings using rst-mode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"AppEngine 1.7.6 has promoted Django 1.4.2 to GA.\nI wonder how and if people this are using The reason for my question is that Django-nonrel seems to be stuck on Django 1.3 and there are no signs of an updated realease.\nWhat I would like to use from Djano are controllers, views and especially form validations.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":154,"Q_Id":15517766,"Users Score":0,"Answer":"The django library built into GAE is straight up normal django that has an SQL ORM.  So you can use this with Cloud SQL but not the HRD.\ndjango-nonrel is up to 1.4.5 according to the messages on the newsgroup.  The documentation, unfortunately, is sorely behind.","Q_Score":0,"Tags":"python,django,google-app-engine,python-2.7,django-nonrel","A_Id":15525796,"CreationDate":"2013-03-20T07:33:00.000","Title":"AppEngine 1.7.6 and Django 1.4.2 release","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone tell me how to count the number of times a word appears in a dictionary.  Iv already read a file into the terminal into a list.  would I need to put the list into a dictionary or start put reading the file into the terminal into a dictionary and not a list? the file is a log file if that matters...","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1257,"Q_Id":15524030,"Users Score":4,"Answer":"You should look into collections.Counter. Your question is a bit unclear.","Q_Score":0,"Tags":"python,list,logging,dictionary,system","A_Id":15524068,"CreationDate":"2013-03-20T12:50:00.000","Title":"Counting words in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"so I am working on a shared computer. It is a workhorse for computations across the department. The problem we have run into is controlling versions of imported modules. Take for example Biopython. Some people have requirements of an older version of biopython - 1.58. And yet others have requirements for the latest biopython - 1.61. How would I have both versions of the module installed side by side, and how does one specifically access a particular version. I ask because sometimes these apis change and break old scripts for other people (or they expect certain functionality that is no longer there).\nI understand that one could locally (i.e. per user) install the module and specifically direct python to that module. Is there another way to handle this? Or would everyone have to create an export PYTHONPATH before using?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":361,"Q_Id":15529417,"Users Score":2,"Answer":"I'm not sure if it's possible to change the active installed versions of a given module.  Given my understanding of how imports and site-packages work, I'm leaning towards no.\nHave you considered using virtualenv though ?\nWith virtualenv, you could create multiple shared environments -- one for biopython 1.58 , another for 1.61 , another for whatever other special situations you need.  They don't need to be locked down to a particular user, so while it would take more space than what you desired, it could take less space than everyone having their own python environment.","Q_Score":4,"Tags":"python,module,version","A_Id":15529520,"CreationDate":"2013-03-20T16:35:00.000","Title":"How do I access different python module versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for ideas, on how to display sensor data in a webpage, hosted by a Synology Diskstation, where the data comes from sensors connected to a Raspberry pi. This is going to be implemented in Python.\nI have put together the sensors, and have these connected to the Raspberry. I have also the Python code, so I can read the sensors.  I have a webpage up and running on the Diskstation using Python. But how do I get the data from the  rasp to the Diskstation. The reading is just done, when the webpage is displayed.\nGuess some kind of WebServices on the Rasp ? I have looked at Pyro4, but doesn't look like it can be installed at the Diskstation. And I would prefer not to install a whole WebServer Framework on the rasp.\nDo you have a suggestion ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":699,"Q_Id":15534297,"Users Score":1,"Answer":"I'm not experiment on this topic but what I would do is setup a database in between (on the Synology rather than on the Raspberry Pi). Let's call your Synology server, and Raspberry Pi a sensor client.\nI would host a database on the server, and push the from the sensor client. The data would be pushed either using an API through webservices or a more low level if you need it faster (some code needed on server side for this) or, since the client computer is under your control, it could directly push in the database.\nYour concrete choice between database, webservice or other API depends on:\n\nHow much data have to be pushed?\nHow fast data have to pushed?\nHow much do you trust your network?\nHow much do you trust your sensor client?\n\nI've never used it but I suggest you use SQLAlchemy for connecting to the database (from both side). \nIf in some use case the remote server can be down, the sensor client would store sensor data in some local file and push them when the server come back online.","Q_Score":2,"Tags":"python,service,web","A_Id":15534482,"CreationDate":"2013-03-20T20:42:00.000","Title":"Move data from Raspberry pi to a synology diskstation to present in a webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am searching for month now and growing quite frustrated.\nI just love python. \nSo after doing a lot of console based stuff I wanted to do some graphical UIs as well.\nI am aware of most of the frameworks (wxpython, glade, tk etc).\nBut: I do not want to write the code for the GUI itself per hand! Declaring every element from hand, thinking about grids and doing a trail and error to find out just how many pixels you have to move an object to get it in the right place. Well, lets say that just sounds like 1990's to me, and it is no fun at all.\nSo to put it plain and simple, what I am looking for is a solution that allows me to design a GUI graphically (WYSIWYG) and have an event based linking to python code.\nAlmost all major languages have that: For C\/C++ their are certainly the most IDEs\/tools that can do that. For Java there is Netbeans with Wwing (example of what i want; it would be ideal if that UI designer in Netbeans could spit out jython code, but no: python is supported but not UIdesign). Even Mono\/Visual Basic etc. has tools like that.\nSo why the hell is their nothing for python?\nP.S. And please, no comments like \"If you are are real programmer you do it by hand to get cleaner code\". If I want something very specific I edit it by hand, but designing a standard UI by hand is a waste of time.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5155,"Q_Id":15591618,"Users Score":0,"Answer":"See Glade, particularly in use with the libglade Python bindings.","Q_Score":0,"Tags":"python,wysiwyg","A_Id":15591769,"CreationDate":"2013-03-23T20:19:00.000","Title":"Is there really no event based wysiwyg Gui builder for python\/jython etc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a huge csv file which contains millions of records and I want to load it into Netezza DB using python script I have tried simple insert query but it is very very slow. \nCan point me some example python script or some idea how can I do the same?\nThank you","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4583,"Q_Id":15592980,"Users Score":0,"Answer":"You need to get the nzcli installed on the machine that you want to run nzload from - your sysadmin should be able to put it on your unix\/linux application server. There's a detailed process to setting it all up, caching the passwords, etc - the sysadmin should be able to do that to.\nOnce it is set up, you can create NZ control files to point to your data files and execute a load. The Netezza Data Loading guide has detailed instructions on how to do all of this (it can be obtained through IBM).\nYou can do it through aginity as well if you have the CREATE EXTERNAL TABLE privledge - you can do a INSERT INTO FROM EXTERNAL ... REMOTESOURCE ODBC to load the file from an ODBC connection.","Q_Score":2,"Tags":"python,netezza","A_Id":15643468,"CreationDate":"2013-03-23T22:45:00.000","Title":"How to use NZ Loader (Netezza Loader) through Python Script?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a huge csv file which contains millions of records and I want to load it into Netezza DB using python script I have tried simple insert query but it is very very slow. \nCan point me some example python script or some idea how can I do the same?\nThank you","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":4583,"Q_Id":15592980,"Users Score":1,"Answer":"you can use nz_load4  to load the data,This is the support utility \/nz\/support\/contrib\/bin\nthe syntax is same like nzload,by default nz_load4 will load the data using 4 thread and you can go upto 32 thread by using -tread option\nfor more details use nz_load4 -h \nThis will create the log files based on the number of thread,like if","Q_Score":2,"Tags":"python,netezza","A_Id":17522337,"CreationDate":"2013-03-23T22:45:00.000","Title":"How to use NZ Loader (Netezza Loader) through Python Script?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python scripts to execute simple but long measurements. I as wondering if (and how) it's possible to edit a running script. \nAn example:\nLet's assume I made an error in the last lines of a running script.These lines have not yet been executed. Now I'd like to fix it without restarting the script. What should I do?\nEdit:\nOne Idea I had was loading each line of the script in a list. Then pop the first one. Feed it to an interpreter instance. Wait for it to complete and pop the next one. This way I could modify the list.\nI guess I can't be the first one thinking about it. Someone must have implemented something like this before and I don't wan't to reinvent the weel. I one of you knows about a project please let me know.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":15609211,"Users Score":0,"Answer":"I am afraid there's no easy way to arbitrarily modify a running Python script.\nOne approach is to test the script on a small amount of data first. This way you'll reduce the likelihood of discovering bugs when running on the actual, large, dataset.\nAnother possibility is to make the script periodically save its state to disk, so that it can be restarted from where it left off, rather than from the beginning.","Q_Score":1,"Tags":"python","A_Id":15609275,"CreationDate":"2013-03-25T06:49:00.000","Title":"Modifying a running script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore the day parameter, I can't only pass two arguments to date() and since only integers can be used I don't think there's any kind of wildcard I can use for the day. How would I go about doing this?\nTo clarify, I'm trying to find a post using the year in which it was posted, the month, and it's title, but not the day. Thanks in advance for any help!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":483,"Q_Id":15625662,"Users Score":1,"Answer":"What you're looking for is probably coverd by post_date__year=year and post_date__month=month in django.\nNevertheless all this seems a little bit werid for get parameters. Do you have any constraint at database level that forbids you from putting there two posts with the same title in the same month of given year?","Q_Score":1,"Tags":"python,django,date,datetime","A_Id":15625871,"CreationDate":"2013-03-25T22:01:00.000","Title":"Matching Month and Year In Python with datetime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore the day parameter, I can't only pass two arguments to date() and since only integers can be used I don't think there's any kind of wildcard I can use for the day. How would I go about doing this?\nTo clarify, I'm trying to find a post using the year in which it was posted, the month, and it's title, but not the day. Thanks in advance for any help!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":483,"Q_Id":15625662,"Users Score":1,"Answer":"you could use post_date__year and post_date__month","Q_Score":1,"Tags":"python,django,date,datetime","A_Id":15625840,"CreationDate":"2013-03-25T22:01:00.000","Title":"Matching Month and Year In Python with datetime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running App Engine with Python 2.7 on OS X. Once I stop the development server all data in the data store is lost. Same thing happens when I try to deploy my app. What might cause this behaviour and how to fix it?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":322,"Q_Id":15635888,"Users Score":2,"Answer":"This is answered, but to explain a little further - the local datastore, by default writes to the temporary file system on your computer. By default, the temporary file is emptied any time you restart the computer, hence your datastore is emptied. If you don't restart your computer, your datastore should remain.","Q_Score":0,"Tags":"python,google-app-engine,google-cloud-datastore","A_Id":15641028,"CreationDate":"2013-03-26T11:27:00.000","Title":"GAE: Data is lost after dev server restart","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm curious. I've been programming in Python for years. When I run a command that blocks on I\/O (whether it's a hard-disk read or a network request), or blocks while waiting on a lock to be released, how is that implemented? How does the thread know when to reacquire the GIL and start running again?\nI wonder whether this is implemented by constantly checking (\"Is the output here now? Is it here now? What about now?\") which I imagine is wasteful, or alternatively in a more elegant way.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":15645296,"Users Score":0,"Answer":"There is no need to repeatedly check for either I\/O completion or for lock release.\nAn I\/O completion, signaled by a hardware interrupt to a driver, or a lock release as signaled by a software interrupt from another thread, will make threads waiting on those operations ready 'immediately', and quite possibly running, and quite possibly preempting another thread when being made running.  Essentially, after either a software or hardware interrupt, the OS can decide to interrupt-return to a different thread than the one interrupted.\nThe high I\/O performance of this mechanism, eliminating any polling or checking, is 99% of the reason for putting up with the pain of premptive multitaskers.","Q_Score":1,"Tags":"python,multithreading,io","A_Id":15647380,"CreationDate":"2013-03-26T19:02:00.000","Title":"How is waiting for I\/O or waiting for a lock to be released implemented?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a small piece of software, that is able to control (start, stop, restart and so on - with gnu screen) every possible gameserver (which have a command line) and includes a tiny standalone webserver with a complete webinterface (you can access the gnu screen from there, like if you're attached to it) on linux.\nAlmost everything is working and needs some code cleanup now.\nIt's written in python, the standalone webserver uses cherrypy as a framework.\nThe problem is, that the gnu screen output on the webinterface is done via a logfile, which can cause high I\/O when enabled (ok, it depends on what is running).\nIs there a way to pipe the output directly to the standalone webserver (it has to be fast)? Maybe something with sockets, but i dont know how to handle them yet.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1489,"Q_Id":15654714,"Users Score":0,"Answer":"You can use syslog or even better you can configure it to send all logs to a database!","Q_Score":2,"Tags":"python,linux,cherrypy,gnu-screen","A_Id":25355763,"CreationDate":"2013-03-27T08:43:00.000","Title":"A way to \"pipe\" gnu screen output to a running python process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a small piece of software, that is able to control (start, stop, restart and so on - with gnu screen) every possible gameserver (which have a command line) and includes a tiny standalone webserver with a complete webinterface (you can access the gnu screen from there, like if you're attached to it) on linux.\nAlmost everything is working and needs some code cleanup now.\nIt's written in python, the standalone webserver uses cherrypy as a framework.\nThe problem is, that the gnu screen output on the webinterface is done via a logfile, which can cause high I\/O when enabled (ok, it depends on what is running).\nIs there a way to pipe the output directly to the standalone webserver (it has to be fast)? Maybe something with sockets, but i dont know how to handle them yet.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1489,"Q_Id":15654714,"Users Score":1,"Answer":"Writing to a pipe would work but it's dangerous since your command (the one writing the pipe) will block when you're not fast enough reading the data from the pipe.\nA better solution would be create a local \"log server\" which publishes stdin on a socket. Now you can pipe the output of your command to the log server which reads from stdin and sends copy of the input to anyone connected to it's socket.\nWhen no one is connected, then the output is just ignored.\nWriting such a \"log server\" is trivial (about 1h in Python, I'd guess).\nAn additional advantage would be that you could keep part of the log file in memory (say the last 100 lines). When your command crashes, then you could still get the last output from your log server.\nFor this to work, you must not terminate the log server when stdin returns EOF. The drawback is that you need to clean up stale log servers yourself. When you use sockets, you can send it a \"kill\" command from your web app.","Q_Score":2,"Tags":"python,linux,cherrypy,gnu-screen","A_Id":15661154,"CreationDate":"2013-03-27T08:43:00.000","Title":"A way to \"pipe\" gnu screen output to a running python process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a ton of scripts I need to execute, each on a separate machine. I'm trying to use Jenkins to do this. I have a Python script that can execute a single test and handles time limits and collection of test results, and a handful of Jenkins jobs that run this Python script with different args. When I run this script from the command line, it works fine. But when I run the script via Jenkins (with the exact same arguments) the test times out. The script handles killing the test, so control is returned all the way back to Jenkins and everything is cleaned up. How can I debug this? The Python script is using subprocess.popen to launch the test.\nAs a side note, I'm open to suggestions for how to do this better, with or without Jenkins and my Python script. I just need to run a bunch of scripts on different machines and collect their output.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1510,"Q_Id":15693565,"Users Score":1,"Answer":"To debug this:\n\nAdd set -x towards the top of your shell script.\nSet a PS4 which prints the line number of each line when it's invoked: PS4='+ $BASH_SOURCE:$FUNCNAME:$LINENO:'\nLook in particular for any places where your scripts assume environment variables which aren't set when Hudson is running.\n\nIf your Python scripts redirect stderr (where logs from set -x are directed) and don't pass it through to Hudson (and so don't log it), you can redirect it to a file from within the script: exec 2>>logfile\nThere are a number of tools other than Jenkins for kicking off jobs across a number of machines, by the way; MCollective (which works well if you already use Puppet), knife ssh (which you'll already have if you use Chef -- which, in my not-so-humble opinion, you should!), Rundeck (which has a snazzy web UI, but shouldn't be used by anyone until this security bug is fixed), Fabric (which is a very good choice if you don't have mcollective or knife already), and many more.","Q_Score":1,"Tags":"python,testing,jenkins,distributed","A_Id":15693722,"CreationDate":"2013-03-28T22:53:00.000","Title":"Shell scripts have different behavior when launched by Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to do somehow the contrary to what a template is used for: I want to write templates and programmatically derive a representation of the different tags and placeholders present in the template, to ultimately generate a form.\nTo put it another way, when you usually have the data and populate the template with it, I want to have the template and ask the user the right data to fill it.\nExample (with pseudo-syntax): Hello {{ name_of_entity only-in ['World', 'Universe', 'Stackoverflow'] }}!\nWith that I could programatically derive that I should generate a form with a select tag named 'name_of_entity' and having 3 options ('World', 'Universe', 'Stackoverflow').\nI looked into Jinja2, and it seems I can reach my goal using it and extending it (even if it's made to do things the other way). But I am still unsure how I should do in some cases, eg.:\n\nif I want to represent that {{ weekday }} has values only in ['Mo', 'Tu', ...]\nif I want to represent in the template that the {{ amount }} variable is accepting only integers...\n\nIs Jinja a good base to reach these goals? If yes, how would you recommend to do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":15694341,"Users Score":1,"Answer":"I think Jinja makes sense for building this, in particular because it contains a full-on lexer and parser. You can leverage those to derive your own versions of this that do what you need.","Q_Score":2,"Tags":"python,forms,parsing,templates,jinja2","A_Id":15704671,"CreationDate":"2013-03-29T00:09:00.000","Title":"Template to forms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I know how to add nodes before and after the head and tail, but I dont know how to add a node to an empty doubly linked list. How would I go about doing this? Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":313,"Q_Id":15703520,"Users Score":1,"Answer":"When inserting into an empty list, make both head and tail refer to the new node. Also, make sure that the node's next and previous references are consistent with what the rest of the code is expecting.","Q_Score":1,"Tags":"python","A_Id":15703555,"CreationDate":"2013-03-29T12:45:00.000","Title":"Adding to empty doubly linked list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've managed to make a single working executable file (for Windows) from a PyQt based Python app using PyInstaller, but is it also possible for Linux?\nOn linux machine (LUbuntu), when I run the .py script, I've got errors about missing PyQt bindings and I can't even download them by apt-get because of inability to connect the servers. It would be much more convenient to somehow pack the missing libraries to my program's files in order to make it more portable, but how can I do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1029,"Q_Id":15714976,"Users Score":0,"Answer":"If you package your application in the Linux distribution's package format, it can contain dependency information. That is the canonical solution to this problem. \nOtherwise you'd have to include all nested dependencies to make sure that it'll work.","Q_Score":0,"Tags":"python,linux,pyqt,portability,python-bindings","A_Id":15716571,"CreationDate":"2013-03-30T04:29:00.000","Title":"How to convert a Python PyQt based program to a portable package in Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am currently developing a tool in Python using Django, in which I have to import an existing User database. Obviously, password for these existing users have not the same encryption than the default password encryption used by Django.\nI want to override the encryption for the password method to keep my passwords unmodified. I don't find how to override existing method in the documentation, just found how to add information about user (I don't find how to remove information - like first name or last name - about user either, so if someone knows, tell me please).\nThank you for your help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2355,"Q_Id":15730976,"Users Score":0,"Answer":"Reconsider your decision about keeping your old password hashes.\nEXCEPT if you already used some very modern and strong scheme for them (like pbkdf2, bcrypt. shaXXX_crypt) - and NOT just some (salted or not) sha1-hash.\nI know it is tempting to just stay compatible and support the old crap, but these old (salted or unsalted, doesn't matter much for brute-forcing) sha1-hashes can be broken nowadays at a rate of > 1*10^9 guesses per second.\nalso, old password minimum length requirements might need a reconsideration due to same reasons.\nthe default django password hash scheme is a very secure one, btw, you should really use it.","Q_Score":2,"Tags":"python,django,encryption,passwords","A_Id":15960639,"CreationDate":"2013-03-31T15:25:00.000","Title":"Django Override password encryption","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a large local file.  I want to upload a gzipped version of that file into S3 using the boto library.  The file is too large to gzip it efficiently on disk prior to uploading, so it should be gzipped in a streamed way during the upload.\nThe boto library knows a function set_contents_from_file() which expects a file-like object it will read from.\nThe gzip library knows the class GzipFile which can get an object via the parameter named fileobj; it will write to this object when compressing.\nI'd like to combine these two functions, but the one API wants to read by itself, the other API wants to write by itself; neither knows a passive operation (like being written to or being read from).\nDoes anybody have an idea on how to combine these in a working fashion?\nEDIT: I accepted one answer (see below) because it hinted me on where to go, but if you have the same problem, you might find my own answer (also below) more helpful, because I implemented a solution using multipart uploads in it.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15998,"Q_Id":15754610,"Users Score":6,"Answer":"There really isn't a way to do this because S3 doesn't support true streaming input (i.e. chunked transfer encoding).  You must know the Content-Length prior to upload and the only way to know that is to have performed the gzip operation first.","Q_Score":17,"Tags":"python,amazon-s3,gzip,boto","A_Id":15763863,"CreationDate":"2013-04-02T01:22:00.000","Title":"How to gzip while uploading into s3 using boto","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to start creating my own filetype in Python ? I have a design in mind but how to pack my data into a file with a specific format ?\nFor example I would like my fileformat to be a mix of an archive ( like other format such as zip, apk, jar, etc etc, they are basically all archives ) with some room for packed files, plus a section of the file containing settings and serialized data that will not be accessed by an archive-manager application.\nMy requirement for this is about doing all this with the default modules for Cpython, without external modules.\nI know that this can be long to explain and do, but I can't see how to start this in Python 3.x with Cpython.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4824,"Q_Id":15757213,"Users Score":0,"Answer":"This may not be appropriate for your question but I think this may help you. \nI have a similar problem faced... but end up with some thing like creating a zip file and then renamed the zip file format to my custom file format... But it can be opened with the winRar.","Q_Score":6,"Tags":"python-3.x,format,file-format","A_Id":54352007,"CreationDate":"2013-04-02T06:03:00.000","Title":"Custom filetype in Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Whenever I try to import hashlib in Python 2.7 I get a segmentation fault. I've installed openssl version 1.0.0, pyOpenssl version .10, and recompiled python with the ssl lines uncommented in Modules\/Setup, pointing to the correct path for the libraries and include files for openssl.\nI've run ldd on all the libraries I can find that might use libssl or libcrypto, and they're all pointing to the same versions of the files.\ngdb returns:\n0x0000003d1d0f670 in EVP_PKEY_CTX_dup () from \/usr\/lib64\/libcrypto.so.1.0.0\nAny ideas what might be going on, and how to repair it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1235,"Q_Id":15765699,"Users Score":2,"Answer":"hashlib uses libcrypto for hash algorithms if it can find libcrypto while building python. \nI suspect somehow it's ending up using a different libcrypto at runtime vs. build time.","Q_Score":1,"Tags":"linux,python-2.7,segmentation-fault,hashlib","A_Id":15769594,"CreationDate":"2013-04-02T13:41:00.000","Title":"Python 2.7 \"import hashlib\" segmentation fault","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Sqlalchemy in a multitenant Flask application and need to create tables on the fly when a new tenant is added. I've been using Table.create to create individual tables within a new Postgres schema (along with search_path modifications) and this works quite well.\nThe limitation I've found is that the Table.create method blocks if there is anything pending in the current transaction. I have to commit the transaction right before the .create call or it will block. It doesn't appear to be blocked in Sqlalchemy because you can't Ctrl-C it. You have to kill the process. So, I'm assuming it's something further down in Postgres.\nI've read in other answers that CREATE TABLE is transactional and can be rolled back, so I'm presuming this should be working. I've tried starting a new transaction with the current engine and using that for the table create (vs. the current Flask one) but that hasn't helped either.\nDoes anybody know how to get this to work without an early commit (and risking partial dangling data)?\nThis is Python 2.7, Postgres 9.1 and Sqlalchemy 0.8.0b2.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1872,"Q_Id":15774899,"Users Score":3,"Answer":"(Copy from comment)\nAssuming sess is the session, you can do sess.execute(CreateTable(tenantX_tableY)) instead.\nEDIT: CreateTable is only one of the things being done when calling table.create(). Use table.create(sess.connection()) instead.","Q_Score":0,"Tags":"python,postgresql,sqlalchemy,ddl,flask-sqlalchemy","A_Id":15775816,"CreationDate":"2013-04-02T21:38:00.000","Title":"How do you create a table with Sqlalchemy within a transaction in Postgres?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing my first steps with Cython, and I am wondering how to improve performance even more.\nUntil now I got to half the usual (python only) execution time, but I think there must be more!\nI know cython -a and I already typed my variables. But there is still a lot in yellow in my function. Is this because cython does not recognise numpy or is there something else I am missing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":553,"Q_Id":15775295,"Users Score":2,"Answer":"I believe you can benefit by using math functions from libc as you are calling np.sqrt and np.floor on scalars. This has not only the Python call overhead but there are different code paths in the numpy ufuncs for scalars and arrays. So that involves at least a type switch.","Q_Score":3,"Tags":"python,performance,cython","A_Id":15905349,"CreationDate":"2013-04-02T22:07:00.000","Title":"How to improve Cython performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I maintain an in-house Python package which is used by some not-really-technical people in the company.  Being that their needs (or rather, their wants) change on an almost-daily basis, I have to update the library pretty often, and I create new installers for them too often for their liking.\nThe lib provides a high-level access to a custom in-house database.   At this point, I know that I could send the lib version along with the query request, and show the user a message with the result that they need to install an update.  \nHowever, being that these people seem to think that taking a few seconds to click on an .exe file and clicking through the \"next\" buttons on the installer takes too long, I'm being asked to see if there's a way to automatically update the library when they do the \"import X\" call. \nI have never come across this kind of request, and I'm thinking that if this was possible that most popular libraries would offer this option.  But I've been wrong before, and often.  Has anyone successfully done this before?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":566,"Q_Id":15788591,"Users Score":1,"Answer":"Have the \"import X\" call run a code in a wrapper library.  The code the time of import would check the database for a new version of the library and download if it has changed.  Then it can in turn import the downloaded library or import the existing library.  There may be issues with this on frozen code so you might have to explicitly eval the new module.\nEdit:\nThis does not necessarily need to be done in another module.  It could just be a function call.","Q_Score":6,"Tags":"python,installation,automatic-updates","A_Id":15850839,"CreationDate":"2013-04-03T13:23:00.000","Title":"Is it possible to upgrade a Python package on the fly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can i borrow someone's brain for this issue. \nI have got data and their relevant timestamps. \nI am interested in grouping them by 5min frequency however i can only start the grouping on 00:00 format. I mean 13:23:27 (hours) would need to be group with 13:25:00 data and then it will be 13:30:00, 13:35:00 etc\nDo you know how i can distinguish this rounding?\nAt the moment i am able to group by 5min but it starts from the first timestamp which could be 13:18:47 so the next one is  giving me is 13:24:00 which is wrong as per my definition i would like to see 13:20:00\nHope that make sense...","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":116,"Q_Id":15794368,"Users Score":2,"Answer":"Convert to seconds, divide by 300 and use the integer portion as your grouping.","Q_Score":0,"Tags":"python,datetime,object","A_Id":15794489,"CreationDate":"2013-04-03T17:45:00.000","Title":"Date grouping python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a python app that connects to perforce on a daily basis. The app gets the contents of an excel file on perfoce, parses it, and copies some data to a database. The file is rather big, so I would like to keep track of which revision of the file the app last read on the database, this way i can check to see if the revision number is higher and avoid reading the file if it has not changed.\nI could make do with getting the revision number, or the changelist number when the file was last checked in \/ changed. Or if you have any other suggestion on how to accomplish my goal of avoiding doing an unnecessary read of the file.\nI'm using python 2.7 and the perforce-python API","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1797,"Q_Id":15795038,"Users Score":2,"Answer":"Several options come to mind.\n\nThe simplest approach would be to always let your program use the same client and let it sync the file. You could let your program call p4 sync and see if you get a new version or not. Let it continue if you get a new version. This approach has the advantage that you don't need to remember any states\/version from the previous run of your program.\nIf you don't like using a fixed client you could let your program always check the current head revision of the file in question: \np4 fstat \/\/depot\/path\/yourfile |grep headRev | sed 's\/.*headRev \\(.*\\)\/\\1\/'\nYou could store that version for the next run of your program in some temp file and compare versions each time.\nIf you run your program at fixed times (e.g. via cron) you could check the last modification time (either with p4 filelog or with p4 fstat) and if the time is between the time of the last run and the current time then you need to process the file. This option is a bit intricate since you need to parse those different time formats.","Q_Score":0,"Tags":"python,python-2.7,perforce","A_Id":15806216,"CreationDate":"2013-04-03T18:23:00.000","Title":"How to get head revision number of a file, or the changelist number when it was checked in \/ changed","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been developing a wx.python application.  at some point  i need to create a fullscreen, no taskbar, etc. wx.Frame  which has exactly  the size of the screen and display in it a bimap which has exactly the dimensions of the screen, so one pixel of the bitmap equals exactly  one pixel of the screen.\neverything has been working fine (on dvi\/vga\/hdmi  monitors) up to the time when i pluged in displayport monitor. \nthe monitor is detected by wxwidgets to be lower  resolution than it actually  is, so the bitmap goes off the screen. EDID still  detects valid resolution so it is for sure  wxwidgets related issue.\n when i use wx.DisplaySize - it returns lower resolution than is actually  set. i also tried to create the bitmap according to the wx.DisplaySize()  output  but then, as expected, when i try to light up one pixel, its neighbours are changed too. (some sort of scalling occurs).\nsimilar issue  occurs when i plug a projector. \nhave  any of you had simmilar symptomes?  how to deal with it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":15817272,"Users Score":0,"Answer":"So i found the solution of the problem.\n It is because when I was plugging the different monitor - for some reason the DPI was changing. Adjusting the settings in the windows display control panel did the thing.","Q_Score":0,"Tags":"wxpython,wxwidgets","A_Id":16090332,"CreationDate":"2013-04-04T16:59:00.000","Title":"weird scalling on displayport monitors in wx.python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been developing a wx.python application.  at some point  i need to create a fullscreen, no taskbar, etc. wx.Frame  which has exactly  the size of the screen and display in it a bimap which has exactly the dimensions of the screen, so one pixel of the bitmap equals exactly  one pixel of the screen.\neverything has been working fine (on dvi\/vga\/hdmi  monitors) up to the time when i pluged in displayport monitor. \nthe monitor is detected by wxwidgets to be lower  resolution than it actually  is, so the bitmap goes off the screen. EDID still  detects valid resolution so it is for sure  wxwidgets related issue.\n when i use wx.DisplaySize - it returns lower resolution than is actually  set. i also tried to create the bitmap according to the wx.DisplaySize()  output  but then, as expected, when i try to light up one pixel, its neighbours are changed too. (some sort of scalling occurs).\nsimilar issue  occurs when i plug a projector. \nhave  any of you had simmilar symptomes?  how to deal with it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":110,"Q_Id":15817272,"Users Score":1,"Answer":"Correct EDID values does not necessarily mean that the system is running it in that display mode.  Have you checked the system's display properties or screen resolution properties to ensure that the system is driving the display at its full resolution?  Your symptoms sound to me like it is running at a lower resolution and the display is stretching it to fill the full screen.","Q_Score":0,"Tags":"wxpython,wxwidgets","A_Id":15822502,"CreationDate":"2013-04-04T16:59:00.000","Title":"weird scalling on displayport monitors in wx.python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a list of words like this ['add', 'adds', 'adding', 'added', 'addition'], I want to stem all of them to the same word 'add'. That means stemming all different verb and noun forms of a word (but not its adjective and adverb forms) into one.  \nI couldn't find any stemmer that does that. The closest one I found is PorterStemmer, but it stems the above list to ['add', 'add', 'ad', 'ad', 'addit']\nI'm not very experienced with stemming techniques. So, I want to ask if there's any available stemmer that does what I explains above? If not, do you have any suggestion on how to achieve that?\nMany thanks,","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1664,"Q_Id":15819339,"Users Score":0,"Answer":"The idea of stemming is to reduce different forms of the same word to a single \"base\" form. That is not what you are asking for, so probably no existing stemmer is (at least not by purpose) fullfilling your needs. So the obvious solution for your problem is: If you have your own custom rules, you have to implement them.\nYou don't tell much about your requirement. Depending on your needs, you have to start from scratch. If porter stemmter comes close to your needs, but not in some special cases, you could hand code some overrides and use an existing stemmer for the other cases.","Q_Score":2,"Tags":"python,nltk,stemming,porter-stemmer","A_Id":15819519,"CreationDate":"2013-04-04T18:50:00.000","Title":"What other alternative are there to stemming?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":63312,"Q_Id":15821121,"Users Score":0,"Answer":"Old question I know but maybe the OP's question was not answered? If you want Idle's File Open\/Save\/Save As menu items to interact with a particular folder, you need to set the CWD before starting Idle. So, assuming you have a folder on Windows \"C:\\Users<username>\\Documents\\python\\my_project\", then at a cmd prompt type cd C:\\Users\\<username>\\Documents\\python\\my_project and then start Idle","Q_Score":33,"Tags":"python,python-idle","A_Id":69122871,"CreationDate":"2013-04-04T20:30:00.000","Title":"What's the working directory when using IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it?","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":63312,"Q_Id":15821121,"Users Score":5,"Answer":"This will depend on OS and how IDLE is executed.\nTo change the (default) CWD in Windows, right click on the Short-cut Icon, go to \"Properties\" and change \"Start In\".","Q_Score":33,"Tags":"python,python-idle","A_Id":15821197,"CreationDate":"2013-04-04T20:30:00.000","Title":"What's the working directory when using IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a beginner in Python and Django.\nI have installed django-oscar. Then I Configured it and started the server, it works.\nNow, I don't understand how to add a product?\nAt the dashboard there is a button Create new product. But in order to add new product it asks to select product class and I can not find any product class in the given dropdown options.\nProvide me a demo example of how to add product in django-oscar.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":6316,"Q_Id":15855468,"Users Score":-1,"Answer":"You have to add atleast one product class \/admin\/catalogue\/productclass\/","Q_Score":5,"Tags":"python,django,e-commerce,django-oscar","A_Id":22601474,"CreationDate":"2013-04-06T20:06:00.000","Title":"Django Oscar. How to add product?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey guys how do I get a variable name from HTML back into my python. So I have this variable {{file}} in my html which I need to pass back into the python file in order the function to work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":15860676,"Users Score":0,"Answer":"You can send variables to the server using methods POST or GET.\nPerhaps you can get the right answer if you elaborate more or showing us some of your code.","Q_Score":0,"Tags":"python,html,django","A_Id":15902133,"CreationDate":"2013-04-07T09:04:00.000","Title":"How do I get a variable name from HTML back into my python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having trouble importing a resource file. I'm using pyqt4 with monkey studio and I am trying to import a png image. When I run the program I get an import error like \n\nImportError: No module named icon_rc\n\nI know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. It would be very helpful to have an answer that fully explains how to compile the resource file so I can import it.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":49757,"Q_Id":15864762,"Users Score":0,"Answer":"you could try with pyside as well like:\n--- pyside-rcc -o input.qrc output.py","Q_Score":15,"Tags":"python,pyqt,pyqt4,resource-files","A_Id":47707774,"CreationDate":"2013-04-07T16:30:00.000","Title":"PYQT4 - How do I compile and import a qrc file into my program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm having trouble importing a resource file. I'm using pyqt4 with monkey studio and I am trying to import a png image. When I run the program I get an import error like \n\nImportError: No module named icon_rc\n\nI know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. It would be very helpful to have an answer that fully explains how to compile the resource file so I can import it.","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":49757,"Q_Id":15864762,"Users Score":5,"Answer":"In Pyqt5 this command can be used Pyrcc5 input_file.qrc -o Out_file.py\nWe need to convert that qrc file into python file and then it can be imported to your code","Q_Score":15,"Tags":"python,pyqt,pyqt4,resource-files","A_Id":44592514,"CreationDate":"2013-04-07T16:30:00.000","Title":"PYQT4 - How do I compile and import a qrc file into my program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to set up some scheduled tasks for a Django app with celery, hosted on heroku.  Aside from not know how everything should be configured, what is the best way to approach this?\nLet's say users can opt to receive a daily email at a time of their choosing.\nShould I have a scheduled job that run every, say 5 minutes.  Looks up every user who wants to be emailed at that time and then fire off the emails?\nOR\nSchedule a task for each user, when they set their preference.  (Not sure how I would actually implement this yet)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":15870130,"Users Score":1,"Answer":"It depends on how much accuracy you need. Do you want users to select the time down to the minute? second? or will allowing them to select the hour they wish to be emailed be enough.\nIf on the hour is accurate enough, then use a task that polls for users to mail every hour.\nIf your users need the mail to go out accurate to the second, then set a task for each user timed to complete on that second.\nEverything in between comes down to personal choice. What are you more comfortable doing, and even more importantly: what produces the simplest code with the fewest failure modes?","Q_Score":0,"Tags":"python,django,heroku,celery,django-celery","A_Id":15870589,"CreationDate":"2013-04-08T01:58:00.000","Title":"How to queue up scheduled actions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I was wondering how I fill a wxChoice with content at runtime.\nWhen creating the GUI I do not have the information of the content since it depends on the users what directory to choose.\nWhat am I doing? The user will have to select a directory from a wx.DirDialog. The event handler refers to a function that will search for files of certain type and the results will be returned as a list of strings.\nThe list of strings should be used to fill\/update the wx.Choice widget but I do not how to do this at runtime.\nDoes anybody has a solution for this problem?\nCheers Thomas","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":477,"Q_Id":15873307,"Users Score":1,"Answer":"I personally think that SetItems(listOfItems) is the quickest way of doing it and it works for several other widget types as well, such as ComboBox. The answer that Thomas mentions forces the developer to clear the widget and then Append individual items OR use AppendItems to add a list of items. Either way, that's a 2-step process compared with just using SetItems()","Q_Score":0,"Tags":"python,wxpython","A_Id":15888610,"CreationDate":"2013-04-08T07:14:00.000","Title":"Fill wx.Choice at runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have a \"Person\" model.\nHow can I display the number of persons in my system in a template?\nIn standard code, I would do: Person.objects.count().\nBut how to do this in a template?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1519,"Q_Id":15879911,"Users Score":1,"Answer":"You save the output of Person.objects.count() in a variable and pass it on to your template from the corresponding view.","Q_Score":2,"Tags":"python,django,templates","A_Id":15879987,"CreationDate":"2013-04-08T13:08:00.000","Title":"Access Model.objects methods from Django templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This has probably been asked before, but I don't know how to look up the answer, because I'm not sure what's a good way to phrase the question.\nThe topic is function arguments that can semantically be expressed in many different ways. For example, to give a file to a function, you could either give the file directly, or you could give a string, which is the path to the file. To specify a number, you might allow an integer as an argument, or maybe you might allow a string (the numeral), or you might even allow a string such as \"one\". Another example might be a function that takes a list (of numbers, say), but as a convenience, it will convert a number into a list containing one element: that number.\nIs there a more or less standard approach in Python to allowing this sort of flexibility? It certainly complicates the code for a program if you're not certain what types the arguments are, so my guess would be to try factor out the convenience functions into just one place, instead of scattered everywhere, but I don't really know how best to do that kind of factoring.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1455,"Q_Id":15883110,"Users Score":0,"Answer":"No, there is not more or less a \"standard\" approach to this.","Q_Score":0,"Tags":"python,arguments","A_Id":15883448,"CreationDate":"2013-04-08T15:28:00.000","Title":"Flexible Arguments in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0181798149,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":1,"Answer":"I had exactly the same issue :\"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" \nI found the answer  from this stackoverflow site. I created a file named string.py and that classhed with the normal python files. I removed the string.py and everything works now. Thanks folks.","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":17015420,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0544914242,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":3,"Answer":"Adding to existing answers - it is actually possible to have firewall block IDLE when not running with -n flag. I haven't used IDLE for a few months and decided to try if it works properly with newly installed python3.3 (on Linux Mint 13 x86). In between I made iptables setup much more aggressive and apparently it blocked idle-python3.3 from connecting to the Python RPC server. Sometimes it is just what the message says.","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":17843247,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0181798149,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":1,"Answer":"I had the same error message. Error not seen after I added all the *.exe filea to be found in the Python install directory to the Windows firewall exception list.","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":20869245,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0906594778,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":5,"Answer":"Look for files on your main python folder that you may create in names like \"threading.py\", \"tkinter.py\" and other names that overlapps with your Lib folder and move\/delete them","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":21956824,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0181798149,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":1,"Answer":"I finally got it to work when I disabled ALL firewalls and antivirus, because some antivirus ALSO have firewall control. Ex. avast","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":22885631,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0181798149,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":1,"Answer":"Using Windows 7 64 installation of Python 2.7.10 Shell I solved the above problem by opening the program as an administrator.","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":31248725,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":0,"Answer":"i have the Same issue on os win7 64Bit and Python 3.1 and find a workaround because i have a Project with many .py files and just one gave this error. - Workaround is to copy a working file and copy the contents from not working file to working file. (i used Another editor as idle. The Problem with that workaround is... of you rename the file it doenst work. attention just rename the not working file doesnt work for me. just that copy paste. \u2013 john","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":37479563,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":0,"Answer":"I came across this problem too. There are two things you can do\n\nYou may already have a process running call pythonw.exe which prevents IDLE from being starting. End that task and try running IDLE again\nUse pythonwin or python command line","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":42023097,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":0.0181798149,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":1,"Answer":"Remove copy.py in your folder if you happen to have one","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":27731044,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":14,"Answer":"I had this same problem today. I found another stack overflow post where someone had a tkinter.py file in the same directory as python, and they fixed it by removing that tkinter.py file.  When I looked in my python directory, I realized I had created a script called random.py and put it there.  I suspect that it conflicted with the normal random module in python.  When I removed this file, python started working again.  \nSo I would suggest you look in your main python directory and see if there are any .py files that you could move to different places.","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":16003884,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Resolved April 15, 2013. \nIn windows 7 (64bit) windows explorer when I right clicked a Python file and selected \"edit with IDLE\" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the \"IDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" error message.  All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. \nEven the \"Send to\" method worked but it was unacceptably clunky.  I've spend four days (so far) researching this and trying various things including reinstalling Python many times. \nAnd NO it's not the FireWall blocking it.  I've tried totally turning Firewall off and it had no effect.\nHere's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from \"edit with IDLE\" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained.\nThen I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to \"edit with IDLE\" and spent a day trying everything including editing in Regedit.  No luck there either. I reinstalled Python 3.3.1 still no \"edit with IDLE\" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message  \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\"\nI am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone.  Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't.  \nAnyway, thanks for listening.  Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps).  anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","AnswerCount":11,"Available Count":11,"Score":1.0,"is_accepted":false,"ViewCount":72468,"Q_Id":15888186,"Users Score":10,"Answer":"I'm running Windows 7 64-bit.  I saw the same errors today.  I tracked down the cause for me, hopefully it'll help you.  I had IDLE open in the background for days.  Today I tried to run a script in IDLE, and got the \"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.\" errors.  So I closed all IDLE windows, and tried to restart IDLE.  That then caused the same errors to pop up, and now IDLE wouldn't open successfully.\nThe cause was an extra pythonw.exe process running in the background.  If I open up an instance of IDLE, then open a second, the second has issues connecting, and closes.  But it does not close the instances of pythonw.exe that it opened, one is left running in the background.  That extra instance then prevents future attempts to open IDLE.\nOpening up Task Manager and killing all pythonw.exe processes fixed IDLE, and now it functions properly on my machine (1 instance open at a time though!).","Q_Score":10,"Tags":"python-2.7,python-3.x,python-idle","A_Id":24211913,"CreationDate":"2013-04-08T20:19:00.000","Title":"Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I searched a lot for built web service like Google Talk, using Google Application Engine and Python.\nFor that first step is to check the status of online user on the Gmail. I found many code of it on python using XMPP library but it work only on python not using Google Application Engine.\nThere is also suggestion of using XMPP python API but for sending message we have to provide JID like app-id@appspot.com and message send.We can not send message from one email Id to another Email Id directly.\nNow I want to perform Oauth authentication in python for gtalk at domain level can anyone tell me how to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":15898775,"Users Score":0,"Answer":"I think you are confused. Python runs ON appengine. Also theres a working java xmpp example provided.","Q_Score":0,"Tags":"google-app-engine,python-2.7,google-talk","A_Id":15903171,"CreationDate":"2013-04-09T09:51:00.000","Title":"Gtalk Service On Google App Engine Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I searched a lot for built web service like Google Talk, using Google Application Engine and Python.\nFor that first step is to check the status of online user on the Gmail. I found many code of it on python using XMPP library but it work only on python not using Google Application Engine.\nThere is also suggestion of using XMPP python API but for sending message we have to provide JID like app-id@appspot.com and message send.We can not send message from one email Id to another Email Id directly.\nNow I want to perform Oauth authentication in python for gtalk at domain level can anyone tell me how to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":323,"Q_Id":15898775,"Users Score":0,"Answer":"You can only send messages from your app.  There are two options:  your_app_id@appspot.com or anything@your_app_id.appspotchat.com.\nIf you wanted to behave like an arbitrary xmpp client, you'll have to use a third party xmpp library running over HTTP and handle the authentication with the user's XMPP server.","Q_Score":0,"Tags":"google-app-engine,python-2.7,google-talk","A_Id":15904726,"CreationDate":"2013-04-09T09:51:00.000","Title":"Gtalk Service On Google App Engine Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that we can install different version of Python on a same box - but there are packages that are not supported common to both.\nSo if I have two version of Python(2.x and 3.x) installed how can I automatically have packages deployed correctly for each version of Python using pip?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":15900399,"Users Score":0,"Answer":"At least on Arch Linux, and presumably on other distros, there are two separate packages for pip, which if both installed give you two different commands: pip and pip3. Running pip ... will always install to the Python 2 site-packages, and pip3 ... to the Python 3 site-packages. This works both for system-wide packages (running as root) or for installing them into your home directory.","Q_Score":1,"Tags":"python","A_Id":15900584,"CreationDate":"2013-04-09T11:16:00.000","Title":"Python site packages: How can I maintain for both 2.x and 3.x version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using pyplot.bar but I'm plotting so many points that the color of the bars is always black.  This is because the borders of the bars are black and there are so many of them that they are all squished together so that all you see is the borders (black).  Is there a way to remove the bar borders so that I can see the intended color?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":72444,"Q_Id":15904042,"Users Score":135,"Answer":"Set the edgecolor to \"none\": bar(..., edgecolor = \"none\")","Q_Score":75,"Tags":"python,graph,matplotlib,border","A_Id":15904277,"CreationDate":"2013-04-09T14:02:00.000","Title":"matplotlib bar graph black - how do I remove bar borders","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say i store a password in plain text in a variable called passWd as a string.\nHow does python release this variable once i discard of it (for instance, with del passWd or passWd= 'new random data')?\nIs the string stored as a byte-array meaning it can be overwritten in the memoryplace that it originally existed or is it a fixed set in a memory area which can't be modified and there for when assining a new value a new memory area is created and the old area is discareded but not overwritten by null?\nI'm questioning how Python implements the safety of memory areas and would like to know more about it, mainly because i'm curious :)\nFrom what i've gathered so far, using del (or __del__) causes the interpreter to not release memory areas of that variable automaticly which can cause issues, and also i'm not sure that del is so thurrow on deleting the values. But that's just from what i've gathered and not something in black or white :)\nThe main reason for me asking, is I'm intending to write a hand-over application that gets a string, does some I\/O, passes it along to another subsystem (bootloader for raspberry pi for instance) and the interface is written in Python (how odd that must sound in some peoples ears..) and i'm not worried that the data is compromised during the I\/O calculations but that a memory dump might be occuring in between the two subsystem handovers. or if the system is frozen (say a hiberation) say 20min after the system is booted and i removed the variable as fast as i could, but somehow it's still in the memory despite me doing a del passWd :)\n(Ps. I've asked on Superuser, they refered me here aand i'm sorry for poor grammar!)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":553,"Q_Id":15904973,"Users Score":2,"Answer":"Unless you use custom coded input methods to get the password, it will be in many more places then just your immutable string. So don't worry too much.\nThe OS should take care that any data from your process is cleared before the memory is allocated to another process. This may of course fail if the page is copied to disk (swapped out or hibernated).\nSecure password entry is not easy. Maybe you can find a special library or module that handles this.","Q_Score":5,"Tags":"python,security,memory-management","A_Id":15905534,"CreationDate":"2013-04-09T14:40:00.000","Title":"Python - Releasing\/replacing a string variable, how does it get handled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say i store a password in plain text in a variable called passWd as a string.\nHow does python release this variable once i discard of it (for instance, with del passWd or passWd= 'new random data')?\nIs the string stored as a byte-array meaning it can be overwritten in the memoryplace that it originally existed or is it a fixed set in a memory area which can't be modified and there for when assining a new value a new memory area is created and the old area is discareded but not overwritten by null?\nI'm questioning how Python implements the safety of memory areas and would like to know more about it, mainly because i'm curious :)\nFrom what i've gathered so far, using del (or __del__) causes the interpreter to not release memory areas of that variable automaticly which can cause issues, and also i'm not sure that del is so thurrow on deleting the values. But that's just from what i've gathered and not something in black or white :)\nThe main reason for me asking, is I'm intending to write a hand-over application that gets a string, does some I\/O, passes it along to another subsystem (bootloader for raspberry pi for instance) and the interface is written in Python (how odd that must sound in some peoples ears..) and i'm not worried that the data is compromised during the I\/O calculations but that a memory dump might be occuring in between the two subsystem handovers. or if the system is frozen (say a hiberation) say 20min after the system is booted and i removed the variable as fast as i could, but somehow it's still in the memory despite me doing a del passWd :)\n(Ps. I've asked on Superuser, they refered me here aand i'm sorry for poor grammar!)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":553,"Q_Id":15904973,"Users Score":0,"Answer":"I finally whent with two solutions.\nld_preload to replace the functionality of the string handling of Python on a lower level.\nOne other option which is a bit easier was to develop my own C library that has more functionality then what Python offers through the standard string handling.\nMainly the C code has a shread() function that writes over the memory area where the string \"was\" stored and some other error checks.\nHowever, @Ber gave me a good enough answer to start developing my own solution since (as he pointed out) there is no secure method in Python and python stores strings in way to many places and relies on the OS (which, on it's own isn't a bad thing except when you don't trust the OS you are installing your realtively secure application on).","Q_Score":5,"Tags":"python,security,memory-management","A_Id":16334037,"CreationDate":"2013-04-09T14:40:00.000","Title":"Python - Releasing\/replacing a string variable, how does it get handled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me.\nI'm able to make Tweets, but I haven't had the bot retweet anyone yet. I'm afraid of tweeting a user's tweet multiple times. I plan to have my bot just run based on Windows Scheduled Tasks, so when the script is run (for example) the 3rd time, how do I get it so the script\/bot doesn't retweet a tweet again? \nTo clarify my question:\nSay that someone tweeted at 5:59pm \"#computer\". Now my twitter bot is supposed to retweet anything containing #computer. Say that when the bot runs at 6:03pm it finds that tweet and retweets it. But then when the bot runs again at 6:09pm it retweets that same tweet again. How do I make sure that it doesn't retweet duplicates?\nShould I create a separate text file and add in the IDs of the tweets and read through them every time the bot runs? I haven't been able to find any answers regarding this and don't know an efficient way of checking.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2022,"Q_Id":15958980,"Users Score":0,"Answer":"Twitter is set such that you can't retweet the same thing more than once. So if your bot gets such a tweet, it will be redirected to an Error 403 page by the API. You can test this policy by reducing the time between each run by the script to about a minute; this will generate the Error 403 link as the current feed of tweets remains unchanged.","Q_Score":0,"Tags":"python,twitter","A_Id":30488072,"CreationDate":"2013-04-11T21:14:00.000","Title":"How do I make sure a twitter bot doesn't retweet the same tweet multiple times?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me.\nI'm able to make Tweets, but I haven't had the bot retweet anyone yet. I'm afraid of tweeting a user's tweet multiple times. I plan to have my bot just run based on Windows Scheduled Tasks, so when the script is run (for example) the 3rd time, how do I get it so the script\/bot doesn't retweet a tweet again? \nTo clarify my question:\nSay that someone tweeted at 5:59pm \"#computer\". Now my twitter bot is supposed to retweet anything containing #computer. Say that when the bot runs at 6:03pm it finds that tweet and retweets it. But then when the bot runs again at 6:09pm it retweets that same tweet again. How do I make sure that it doesn't retweet duplicates?\nShould I create a separate text file and add in the IDs of the tweets and read through them every time the bot runs? I haven't been able to find any answers regarding this and don't know an efficient way of checking.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2022,"Q_Id":15958980,"Users Score":0,"Answer":"You should store somewhere the timestamp of the latest tweet processed, that way you won't go throught the same tweets twice, hence not retweeting a tweet twice.\nThis should also make tweet processing faster (because you only process each tweet once).","Q_Score":0,"Tags":"python,twitter","A_Id":15959518,"CreationDate":"2013-04-11T21:14:00.000","Title":"How do I make sure a twitter bot doesn't retweet the same tweet multiple times?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently been working on a pet project in python using flask. It is a simple pastebin with server-side syntax highlighting support with pygments. Because this is a costly task, I delegated the syntax highlighting to a celery task queue and in the request handler I'm waiting for it to finish. Needless to say this does no more than alleviate CPU usage to another worker, because waiting for a result still locks the connection to the webserver.\nDespite my instincts telling me to avoid premature optimization like the plague, I still couldn't help myself from looking into async.\nAsync\nIf have been following python web development lately, you surely have seen that async is everywhere. What async does is bringing back cooperative-multitasking, meaning each \"thread\" decides when and where to yield to another. This non-preemptive process is more efficient than OS-threads, but still has it's drawbacks.  At the moment there seem to be 2 major approaches:\n\nevent\/callback style multitasking\ncoroutines\n\nThe first one provides concurrency through loosely-coupled components executed in an event loop. Although this is safer with respect to race conditions and provides for more consistency, it is considerably less intuitive and harder to code than preemptive multitasking. \nThe other one is a more traditional solution, closer to threaded programming style, the programmer only having to manually switch context. Although more prone to race-conditions and deadlocks, it provides an easy drop-in solution.\nMost async work at the moment is done on what is known as IO-bound tasks, tasks that block to wait for input or output. This is usually accomplished through the use of polling and timeout based functions that can be called and if they return negatively, context can be switched. \nDespite the name, this could be applied to CPU-bound tasks too, which can be delegated to another worker(thread, process, etc) and then non-blockingly waited for to yield. Ideally, these tasks would be written in an async-friendly manner, but realistically this would imply separating code into small enough chunks not to block, preferably without scattering context switches after every line of code. This is especially inconvenient for existing synchronous libraries. \n\nDue to the convenience, I settled on using gevent for async work and was wondering how is to be dealt with CPU-bound tasks in an async environment(using futures, celery, etc?). \nHow to use async execution models(gevent in this case) with traditional web frameworks such as flask? What are some commonly agreed-upon solutions to these problems in python(futures, task queues)?\nEDIT: To be more specific - How to use gevent with flask and how to deal with CPU-bound tasks in this context?\nEDIT2: Considering how Python has the GIL which prevents optimal execution of threaded code, this leaves only the multiprocessing option, in my case at least. This means either using concurrent.futures or some other external service dealing with processing(can open the doors for even something language agnostic). What would, in this case, be some popular or often-used solutions with gevent(i.e. celery)? - best practices","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6728,"Q_Id":15969213,"Users Score":2,"Answer":"How about simply using ThreadPool and Queue? You can then process your stuff in a seperate thread in a synchronous manner and you won't have to worry about blocking at all. Well, Python is not suited for CPU bound tasks in the first place, so you should also think of spawning subprocesses.","Q_Score":16,"Tags":"python,asynchronous,flask,gevent","A_Id":15970840,"CreationDate":"2013-04-12T10:38:00.000","Title":"Python async and CPU-bound tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Hi i am getting an error\n\"IOError: decoder jpeg not available\" \nwhen trying to implement some functions from the PIL.\nWhat i would like to do is remove PIL, install the jpeg decoder then re-install the PIL, but im lost as to how to uninstall the PIL?\nAny help would be greatly appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":429,"Q_Id":15972941,"Users Score":0,"Answer":"You can do this to re-install PIL\npip install -I PIL","Q_Score":0,"Tags":"jpeg,python-imaging-library,uninstallation,raspberry-pi","A_Id":16268144,"CreationDate":"2013-04-12T13:42:00.000","Title":"Remove PIL from raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Running Enthought Canopy appears to de-activate the normal .profile PATH information (OS X) for python programs run within the Canopy environment. I need to make locations searchable for user files.  \nHow to do this is not explained in the user manual.  There are several possible places to enter such information (eg the two 'activate' files) but adding extra PATH information in them has no effect.\nSo how is it done?\nDN","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6880,"Q_Id":15982612,"Users Score":0,"Answer":"The problem described also occurs in a Win 7 Canopy installation.\nI tried to place files to be imported in several of the locations provided in sys.path().\n['',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\User\\Scripts\\python27.zip',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\DLLs',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\plat-win',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\lib-tk',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\User',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\User\\lib\\site-packages',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\PIL',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\win32',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\win32\\lib',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\Pythonwin',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\site-packages',\n 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\site-packages\\IPython\\extensions']\nThe only solution I found was to use:\nsys.path.append()","Q_Score":3,"Tags":"python,path,enthought","A_Id":15995409,"CreationDate":"2013-04-12T23:50:00.000","Title":"Enthought Canopy: how do I add to the PATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Running Enthought Canopy appears to de-activate the normal .profile PATH information (OS X) for python programs run within the Canopy environment. I need to make locations searchable for user files.  \nHow to do this is not explained in the user manual.  There are several possible places to enter such information (eg the two 'activate' files) but adding extra PATH information in them has no effect.\nSo how is it done?\nDN","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":6880,"Q_Id":15982612,"Users Score":1,"Answer":"On Mac OSX 10.6.8 this worked\n% launchctl setenv PYTHONPATH \/my\/directory:\/my\/other\/directory\nthen launch Canopy and you should see \/my\/directory and \/my\/other\/directory on sys.path","Q_Score":3,"Tags":"python,path,enthought","A_Id":16281145,"CreationDate":"2013-04-12T23:50:00.000","Title":"Enthought Canopy: how do I add to the PATH?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a GAE webapp using Python 2.7, webapp2, and Jinja. In development, I run the app under PyCharm 2.7.1 on a Max OSX 10.7.5 (Lion). I'm currently using Chrome 26.0.1410.43 as my browser.\nI don't know for sure that this is a PyCharm issue, but that's my best guess. Here's a description:\nWhen I use the \"Debug\" control to start the app, webpages refresh automatically as I navigate from one page to another. That is, if I start at page A, navigate to page B, take some action that changes what A should look like, and navigate back to A, the change appears.\nHowever, when I use the \"Run\" control to start the app, with no other changes, webpages do not automatically refresh. In that same scenario, when I navigate back to A, the old version of that webpage appears. I need to click my browser's Refresh control to see the updated page.\nPlease tell me how to stop the browser from displaying cached pages in Run mode. I haven't tried publishing this to our GAE website yet, and hopefully it won't happen there, but I need Run mode for performance on the video tutorial I'm creating.\nThanks for any suggestions!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":550,"Q_Id":15990889,"Users Score":0,"Answer":"It turns out that this wasn't a refresh or caching issue but a timing issue. Under some circumstances, GAE uses an update algorithm that incurs a delay before transactions are applied. In Run mode, the new page was being requested before the update was completed; in Debug mode, enough time passed for the update to be completed.\nOne solution would have been to change the datastore architecture to eliminate reading an obsolete version of the data, but that caused other, more serious problems.\nAnother solution was to include a split-second delay, after an update  but before displaying the updated record. Not ideal, since it's impossible to know how long that delay has to be, but for now this has been satisfactory.","Q_Score":1,"Tags":"python,google-app-engine,google-chrome,pycharm,webapp2","A_Id":30849574,"CreationDate":"2013-04-13T17:43:00.000","Title":"In PyCharm, webpages refresh in debug mode, not in run mode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've a client (currently in C#, a python version in progress) which gets computer data such as CPU %, disk space etc. and sends it to a server. I don't know how to manage if my client looses connection with the server. I have to continue collecting information but where to stock them? Just a buffer? Is using a log file a better solution?\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":16001064,"Users Score":0,"Answer":"I'd create a log file on the HDD and put in the last recorded data and time. Then just read it out when needed again.","Q_Score":0,"Tags":"c#,python,buffer","A_Id":16002014,"CreationDate":"2013-04-14T15:58:00.000","Title":"How to store datas while connection is lost?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How are the lists implemented in python? I mean how is it possible to append an element in constant time and also get an item in constant time? Can anyone please tell how to do it in C?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":937,"Q_Id":16009440,"Users Score":0,"Answer":"A simple implementation is to use a preallocated buffer and a counter for the number of elements.\nWhen the buffer is filled up and you want to append element, then you allocate a bigger buffer (e.g. twice as big) and copy the old one's data into the new one.\nThus the append operation is not strictly O(1), but it's amortized O(1), namely on average it's O(1).","Q_Score":0,"Tags":"python,c","A_Id":16009488,"CreationDate":"2013-04-15T07:03:00.000","Title":"Python list implementation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When Python wants to import a module it is first going to look in sys.modules. But since the key-value pairs of dictionaries are not in a fixed order, how can you ever know for certain which of two identically named modules in sys.modules will be imported first?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":92,"Q_Id":16013843,"Users Score":7,"Answer":"Since it is a mapping, there can be no identically named modules in sys.modules.\nThat is the point. If use the statement import foo and sys.modules['foo'] exists, that module is returned. No file access is needed, no top-level code for that module needs to be run.\nIf foo is not present, then the sys.path determines where foo is going to be found first. That value is a list, so it has order, and the search for the foo module is conducted according to that ordering.","Q_Score":1,"Tags":"python,python-import","A_Id":16013905,"CreationDate":"2013-04-15T11:19:00.000","Title":"Why was sys.modules chosen to be a dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to implement one logic which is written in python, this code will do some searching stuffs, and I have a website done in PHP. can any one tell me whether I can include python script in PHP? if yes , how can I do that ?\n\nCriteria : \n  Input to the python script will come from php or html [either text or file]. and output of python is directly displayed to the page or through php or store it in mysql and show it through PHP.[Please suggest me the best one in this].","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":69,"Q_Id":16016645,"Users Score":1,"Answer":"If you have access to exec, you can run the python interpreter. However, that's:\n\nOverkill\nNot necessarily wise\nA major waste of resources\n\nIf your logic is simple, why don't you write it in PHP? Furthermore, if your logic is not simple...why don't you make an API of some sort to access it and favour communication rather than code deduplication?","Q_Score":0,"Tags":"php,python-2.7","A_Id":16016728,"CreationDate":"2013-04-15T13:38:00.000","Title":"Can Python Script be included in PHP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In our company we decided to use openERP \nWe now working to customize openERP with our work ... we can use it successfully in warehouse dept. and sallies  dept. \nMy question is how to make openERP  calculate monthly Net Salary \nwith deduct if the Employee absence or leave the work or if we decided to add bonus  \nand if we can  programming new model and add it How this difficult to work and what about expected time  required to do \nOR how we can access to fields related with attendance and building our own program to calculate    Net Salary ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1340,"Q_Id":16018995,"Users Score":1,"Answer":"Install hr_payroll module. Flow is as below:\nEmployee --> Contracts --> Salary Structure --> Salary Rules\nIn Contract, You can set Working Schedule for that employee with Wage. You need to configure Salary Structure with Salary Rules as per your need. Salary rules for Bonus, expenses, etc.\nIn that Salary structure, You need to add that rules. Now, go to the Employee Payslip menu, select that employee, Related information will be automatically come over there. Click on Compute sheet button. You will get Salary details in Salary Computation tab as per your Salary rules that you added in your Salary Structure.\nFor now, there is no link between attendance and payroll in OpenERP that you need to customize. It depends on requirements that how much time it will take for that! Hope this will help you.","Q_Score":1,"Tags":"python,postgresql,openerp,erp","A_Id":16029533,"CreationDate":"2013-04-15T15:25:00.000","Title":"Can we calculate Net Salary with openERp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been trying all sorts of sourceforge projects that try to port GNU functionality to Windows, with the goal to create a very GNU aware Ipython profile providing the best terminal environment I know how (on Windows that is).\nHow close is QtConsole to having the ability of running something like Curses through the IpyQt frontend? \n(The key here, is that I want the DPI aware rich text of QtConsole. Would knock the socks off most of the Windows terminal alternatives.)\nIs that possibility even in sight, or is that a match that will likely not happen? I have never emulated a VT100 in my spare time, how much does QtConsole look like one?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":125,"Q_Id":16026129,"Users Score":1,"Answer":"No, it's not really in sight. The Qt console has some support for control characters, so it can do things like coloured text, but it's definitely not enough to support curses, and we're not really interested in going down that route.\nThe code is all in the open if you want to try to make it into a full terminal emulator. But I rather hope there are better starting points for terminal emulators in Windows.","Q_Score":0,"Tags":"ipython,qtconsole","A_Id":16066204,"CreationDate":"2013-04-15T23:09:00.000","Title":"Ipython and Curses on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an error no such table: mytable, even though it is defined in models\/tables.py. I use sqlite. Interesting enough, if I go to admin panel -> my app -> database administration then I see a link mytable, however when I click on it then I get no such table: mytable.\nI don't know how to debug such error? \nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1115,"Q_Id":16026776,"Users Score":3,"Answer":"web2py keeps the structure it thinks the table has in a separate file. If someone has manually dropped the table, web2py will still think it exists, but of course you get an error when you try to actually use the table\nLook for the *.mytable.table file in the databases directory","Q_Score":2,"Tags":"python,web2py","A_Id":16026857,"CreationDate":"2013-04-16T00:21:00.000","Title":"web2py. no such table error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is there some way to read the PID of a process started with QProcess.start(...)? QProcess::pid() returns sip.voidptr and there's not much I can do with it (or I don't know how).\nI want to have the PID to have the possibility to make the window active later on.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":859,"Q_Id":16034823,"Users Score":0,"Answer":"pid() function is provided to keep old source code working.\nUse processId() instead.\nReturns the native process identifier for the running process, if available. If no process is currently running, 0 is returned.\nNote: Unlike processId(), pid() returns an integer on Unix and a pointer on Windows.","Q_Score":3,"Tags":"python,qt4,pyqt,qprocess","A_Id":69134278,"CreationDate":"2013-04-16T10:34:00.000","Title":"get PID of QProcess with python on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My question is about web application architecture.\nI have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get access to my database and procces that file. I know how to use django ORM itself without URLs and other parts of django. \nMy question: If I need to create workers on another server, which use different django models from my website i need to copy all of the models into every worker?\nFor example, one worker proccess file and it need models \"Report\" and \"User\". Other worker do other actions and need \"User\" and \"Link\" models. Everytime i change model in my main website i need to change same models in my workers, also different workers can have same duplicate models. I think it's not good from architecture point.\nAny suggestions on how to organize my website and workers?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":16055489,"Users Score":0,"Answer":"There are few interesting options.\nAs example, you can add additional reupload workers step for deploy process. It'll guarantee\n consistence between deployed application and workers.\nUsing own (rest) api is great idea, i like it even more than sharing models between different beings","Q_Score":0,"Tags":"python,django,ironmq","A_Id":16065078,"CreationDate":"2013-04-17T08:44:00.000","Title":"File upload and store, then proccessing with remote worker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My question is about web application architecture.\nI have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get access to my database and procces that file. I know how to use django ORM itself without URLs and other parts of django. \nMy question: If I need to create workers on another server, which use different django models from my website i need to copy all of the models into every worker?\nFor example, one worker proccess file and it need models \"Report\" and \"User\". Other worker do other actions and need \"User\" and \"Link\" models. Everytime i change model in my main website i need to change same models in my workers, also different workers can have same duplicate models. I think it's not good from architecture point.\nAny suggestions on how to organize my website and workers?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":16055489,"Users Score":0,"Answer":"Why do you really need the exact same models in your workers? You can design the worker to have a different model to perform it's own actions on your data. Just design API's for your data and access it separately from your main site.\nIf it really necessary, Django app can be shared across multiple projects. So you can just put some generic code in a separate app (like your shared models) and put them in sourcecontrol. After an update in your main website, you can easily update the workers also.","Q_Score":0,"Tags":"python,django,ironmq","A_Id":16055809,"CreationDate":"2013-04-17T08:44:00.000","Title":"File upload and store, then proccessing with remote worker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install?\nIs it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file that has libraries as prerequist without requiring the user to build and install the libraries?","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":1400,"Q_Id":16059476,"Users Score":4,"Answer":"They are cross platform, but not cross-version and not cross-implementation. In other words, different CPython versions could have trouble with one and the same .pyc file.\nAnd if you look at other implementations such as PyPy, IronPython, Jython etc., you won't have any luck with .pyc files at all.\nBesides, .pyc files correspond to one .py file. What you (probably) have in mind are libraries which include a part written in C. They must be compiled to platform-dependent files (.pyd, .dll, .so, etc.) in order to work. As not many developers have all supported platforms available, they provide it as source and leave it to the user's system to compile it.","Q_Score":6,"Tags":"python,pyc","A_Id":16059584,"CreationDate":"2013-04-17T12:02:00.000","Title":"Why are python libraries not supplied as pyc?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install?\nIs it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file that has libraries as prerequist without requiring the user to build and install the libraries?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1400,"Q_Id":16059476,"Users Score":0,"Answer":"The process of creating a .pyc file from a .py file is done transparently by the interpreter. The reason some installers generate them at install time is purely to avoid them having to be generated the first time the script is run - usually for speed reasons, but also so that the .pyc can end up in a system-wide (non-user-writable) directory. Unlike compiled languages, or even Python modules written in C, it is not a technical requirement that these files exist in the first place - if it was, you wouldn't be able to put your own scripts directly into python and have them run without a compile step. \nAny library that strictly requires a build step before it is installed certainly has a component that compiles to native code - which certainly isn't cross-platform. For any pure-python library, it is always sufficient to put the module's source directory tree somewhere in your PYTHONPATH, having copied it directly from the archive you downloaded it in.","Q_Score":6,"Tags":"python,pyc","A_Id":16059746,"CreationDate":"2013-04-17T12:02:00.000","Title":"Why are python libraries not supplied as pyc?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand how to save a redis database using bgsave.  However, once my database server restarts, how do I tell if a saved database is present and how do I load it into my application.  I can tolerate a few minutes of lost data, so I don't need to worry about an AOF, but I cannot tolerate the loss of, say, an hour's worth of data.  So doing a bgsave once an hour would work for me.  I just don't see how to reload the data back into the database.\nIf it makes a difference, I am working in Python.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1375,"Q_Id":16068644,"Users Score":1,"Answer":"You can stop redis and replace dump.rdb in \/var\/lib\/redis (or whatever file is in the dbfilename variable in your redis.conf). Then start redis again.","Q_Score":2,"Tags":"python,redis,persistence,reload","A_Id":16069631,"CreationDate":"2013-04-17T19:33:00.000","Title":"How to load a redis database after","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.\nANy ideas on how to get just the dollar sign?\nThanks","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":38570,"Q_Id":16089089,"Users Score":91,"Answer":"Put two backslashes in front of dollar signs. For example:\nSome prices: \\\\$3.10, \\\\$4.25, \\\\$8.50.\n(running Jupyter notebook server 5.7.0)","Q_Score":52,"Tags":"python,markdown,ipython,mathjax","A_Id":53228544,"CreationDate":"2013-04-18T17:04:00.000","Title":"Escaping dollar sign in ipython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.\nANy ideas on how to get just the dollar sign?\nThanks","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":38570,"Q_Id":16089089,"Users Score":7,"Answer":"If you use <span>$<\/span>, MathJax won't process it as a delimiter.  You should be able to enter that in Markdown.  For example, I've used that here:  $ This is not math $.","Q_Score":52,"Tags":"python,markdown,ipython,mathjax","A_Id":16095493,"CreationDate":"2013-04-18T17:04:00.000","Title":"Escaping dollar sign in ipython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.\nANy ideas on how to get just the dollar sign?\nThanks","AnswerCount":7,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":38570,"Q_Id":16089089,"Users Score":11,"Answer":"You can escape $ with math mode by using a backslash. Try $\\$$","Q_Score":52,"Tags":"python,markdown,ipython,mathjax","A_Id":29808632,"CreationDate":"2013-04-18T17:04:00.000","Title":"Escaping dollar sign in ipython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown.\nANy ideas on how to get just the dollar sign?\nThanks","AnswerCount":7,"Available Count":4,"Score":0.0855049882,"is_accepted":false,"ViewCount":38570,"Q_Id":16089089,"Users Score":3,"Answer":"I'm aware that this topic is old, but it's still somehow the first google result and its answers are incomplete.\nYou can also surround the $ with `backticks`, the same way that you would display code in Jupyter.\nSo $ becomes `$`, and should display without error","Q_Score":52,"Tags":"python,markdown,ipython,mathjax","A_Id":38617452,"CreationDate":"2013-04-18T17:04:00.000","Title":"Escaping dollar sign in ipython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to create a 'find' procedure myself, which is capable of finding a sub-string in a string and it also should be able to read a string backward and give position of match- just like the original find function in python. \nI am unable to figure out what logic should I use- also I don't know how the original find functions?\nI just started to use python and am fairly new to programming as well.\nAny guidance shall be highly appreciated!","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":1649,"Q_Id":16092153,"Users Score":1,"Answer":"There is a simple solution to this problem, however there are also much faster solutions which you may want to look at after you've implemented the simple version. What you want to be doing is checking each position in the string you're search over and seeing if the string you're searching for starts there. This is inefficient but works well enough for most purposes, if you're feeling comfortable with that then you may want to look at Boyer-Moore string searching, which is a much more complex solution but more efficient. It exploits the fact that you can determine that if a string doesn't start at a certain point you may not need to check some of the other positions.","Q_Score":3,"Tags":"python","A_Id":16092297,"CreationDate":"2013-04-18T20:09:00.000","Title":"How does find procedure work in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have zero experience with website development but am working on a group project and am wondering whether it would be possible to create an interaction between a simple html\/css website and my python function. \nRequired functionality:\nI have to take in a simple string input from a text box in the website, pass it into my python function which gives me a single list of strings as output. This list of strings is then passed back to the website. I would just like a basic tutorial website to achieve this. Please do not give me a link to the CGI python website as I have already read it and would like a more basic and descriptive view as to how this is done. I would really appreciate your help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3480,"Q_Id":16120717,"Users Score":1,"Answer":"First you will need to understand HTTP.  It is a text based protocol.\nI assume by \"web site\" you mean User-Agent, like FireFox.\nNow, your talking about an input box, well this will mean that you've already handled an HTTP request for your content.  In most web applications this would have been several requests (one for the dynamically generated application HTML, and more for the static css and js files).\nCGI is the most basic way to programmatically inspect already parsed HTTP requests and create HTTP responses from objects you've set.\nNow your application is simple enough where you can probably do all the HTTP parsing yourself to gain a basic understanding of what's going on, but you will still need to understand how to develop a server that can listen on a socket.\nTo avoid all that just find a Python application server that has already implemented all of the above and much more.  There are many python application servers to choose from. Use one with a small learning curve for something as simple as above.  Some are labeled as \"micro-frameworks\" in this genre.","Q_Score":0,"Tags":"python,html,web-applications,cgi","A_Id":16121984,"CreationDate":"2013-04-20T13:06:00.000","Title":"How to Combine Html + CSS code with python function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hy, still a python beginner, I am looking for help pointing me in the right direction:\nI am trying to build sort of a database of api answers from bitstamp listing the transactions on bitstamp.\nThe api-call gives all transactions in a time frame, output is json.\nAfter processing the api output with json.loads() output can be\n\nno transaction: []\none transaction: {'key':'value',....}\nmany transactions:  {'key':'value',....} {'key':'value',....} {'key':'value',....}\n\nAs I understand this:\n\nok: if x=='[]':return\nok: for key in x: print(x[key])\nseems to be a tuple. dont know how to deal with, I would like to make as many dictionarys out of the transactions-tuple as there are. So sort of\nfor every tuple make dict[x] with tuple in it.\n\nI know some mysql, in the end I want to have a table with one transaction per line, sorted chronologically, so i can build a chart of the transaction prices or some sort of 2-dimensional array, that i can acces by array[x][y].\nI dont aks for a complete solution, just a short idea how it could\/should be done, so I can start my way through the tutorials :)\np.s.: reason for json.load is, that the native output is like [{key:value, ..} {key:value,...}]","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":16122228,"Users Score":0,"Answer":"Suppose all transactions contain the same structure, it is perfectly fine to use a for item in json_tuple to deal with the transactions.\nIt all really depends on what you want to do with the data set.","Q_Score":0,"Tags":"python,json,api","A_Id":16122376,"CreationDate":"2013-04-20T15:50:00.000","Title":"Json output with none, one or many dictionaries in a tubple - best way to manipulate? (Bitstamp transaction list)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a form on my site that allows the user to add names to an object. The user can hit a plus button to add another name or a minus button to remove a name. I need to be able to easily pull all POST variables that start with a name.\nFor example. A user adds two names so we have two text boxes names 'name0' and 'name1'. Is there a way that I can pull those two values without know how many I may have?\nOne reason I want to do this without knowing is because they could do any number of add and remove functions on the list of names. So I could end up with this:\n'name2', 'name10', 'name11'\nfor the names that come in. I don't want to have to know the exact values. I just want to pull all POST variables that start with 'name'. \nIs this possible?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1678,"Q_Id":16125352,"Users Score":0,"Answer":"yeah, like Daniel said, so I add the next\nposted =    [{k.replace('person__',''):v} for k, v in request.POST.items() if k.startswith('person__')]\nthen I can use a model form with posted data","Q_Score":0,"Tags":"python,django","A_Id":32982612,"CreationDate":"2013-04-20T21:25:00.000","Title":"Getting POST values from a Django request when they start with the same string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im trying to write an IronPython app that uses a COM object interface. I manage to import it using clr.AddReference, and manage also to call some of the functions, create objects, etc.\nHowever at a certain point when trying to call a function I get :\n\nStandardError: Error while invoking GetK300RZ.\n\n(GetK300RZ being the function name.)\nWhy is this happening to me? What does this error mean exactly? could this be related to the 'embed interop types' option?\nI would greatly appriciate any insight as to how to get around this problem...\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":16131781,"Users Score":0,"Answer":"This is just for anyone who ever runs into this question with a similar problem - the problem was that the parameters of the functions were of type out and ref in C#. The function could not be invoked because there was no corresponding function signature. I had to use clr.Reference[] to explicitly create references for the function parameters.\nI guess when using an external COM objects one should stop thinking python and start thinking .net or C#...","Q_Score":0,"Tags":".net,com,interop,ironpython","A_Id":16272641,"CreationDate":"2013-04-21T13:44:00.000","Title":"IronPython - error while invoking","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is there a way to see if a user is currently logged in and active on a site?\nFor example, I know you can check the authentication token of the user and see if he is still 'actively logged in', but this doesn't tell me much, since the user could technically be logged in for two weeks, though only actively on the site for one minute of that duration. last_login would be equally unhelpful.\nWhat would be a good method in django to check to see if the user is currently active? I have done this in Google Analytics, but was wondering how I could do an entirely-django approach.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":799,"Q_Id":16139169,"Users Score":0,"Answer":"There are several ways to determine user activity:\n1) Use javascript to send periodic requests to server. \n+: You will be able to determine user activity despite he actively working on site or just keep open window.\n-: Too many requests.\n2) Use django middleware\n-: Can`t determine user activity if he keeps only open window\n3) Use asynchronous framework to keep long-lived connection. For example tornado.\nIt is cleanest way but the most labor-intensive.","Q_Score":0,"Tags":"python,django","A_Id":16141722,"CreationDate":"2013-04-22T03:54:00.000","Title":"How to determine if user is currently active on site in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"issue\nI am writing an application in python. It takes care of contacts and other information about a person. I want to prompt the user for a master key every time that he\/she wants to perform a major operation. I have everything figured out. The whole application is ready and works well. But I store the master key in a file. This file is easily readable in the plain text form. And my friends who tried using this said that the software is useless if I don't apply a strong encryption algorithm as users would simply trust the application with the details that can be easily stolen.\ngoal\nTo store the master key in a form that can be deciphered (or read) only by my program. \nother things\n\nthere is an option for the user to change the master key.\nThe master key will be read and deciphered only once. At the start of the program. It will be stored in a variable then and and used from this variable. \nIt is a GUI application. And I am using python Tkinter. \n\ndetails\nPlease note that the data is stored using another encryption that is not un breakable but enough for this kind of information. \nI have not used any database to store the information. \nThe only data to be encrypted is a master key. It is an alphanumeric string of length anywhere from 7 to 80 characters. \nspecs\n\n1. Python 2.7\n2. Tkinter 8.5\n3. Linux Mint 14","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":859,"Q_Id":16142113,"Users Score":2,"Answer":"You don't need, or even want, complex encryption for passwords--and what you are describing is a password, not a key (it just grants access, it doesn't encrypt the data). Current best practice is to store passwords salted and hashed.  That is, when the user creates a new account and enters a password, you build a string from the password plus user name plus a \"salt\" (which is just a small string that's the same for everyone on your site--this is to thwart rainbow table attacks). Then you run that string through a good hash algorithm--something like SHA1 is fine (even MD5 is more than adequate, despite reports to the contrary). You certainly don't need anything like AES.  Anyway, now that you have a hash, you store the hash in the database, and not the password. Even a strong cipher like AES is useless if don't do the rest right.\nNext time the user logs in, you do the same: add his password to user name and salt, hash that, and compare the hash to what's stored. There's no way, even in principle, for you to know what his password was, so no way for an attacker to find it even if they get your database and know your algorithm and salt.","Q_Score":1,"Tags":"python,encryption,tkinter","A_Id":16146593,"CreationDate":"2013-04-22T08:00:00.000","Title":"Encryption -- how to do it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python script that runs in a loop regularly making adjustments to my lighting system.  When I shut down my computer, I'd like my script to detect that, and turn off the lights altogether.\nHow do I detect my computer beginning to shut down in Python?\nOr, assuming Windows sends Python a \"time to shut down\" notice, how do I intercept that to kill my lights and exit the loop?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7003,"Q_Id":16145516,"Users Score":11,"Answer":"This is the wrong way to go about performing action at system shutdown time. The job of the shutdown process is to stop running processes and then switch off power; if you try to detect this happening from within your program and react by getting some last action in, it's a race between the OS and your program who gets to go first. More likely than not your program will have been stopped before it managed to perform the necessary action.\nInstead, you should hook into the normal protocol for doing things at shutdown. This will tell the shutdown utility to send an explicit signal to your program and wait for it to be acknowledged, which gives you enough time (within reason) to do what you have to do. How exactly to register to be notified varies with the OS, so this is more of an OS-specific question rather than a Python question.","Q_Score":6,"Tags":"python,windows","A_Id":16145517,"CreationDate":"2013-04-22T07:12:00.000","Title":"Detecting computer\/program shutdown in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\\python27 to my PATH and when I type \"python\" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like \"python --version\" it launches the new command prompt window and then closes before I can read it. Does anyone know how to get python to run in powershell?\nNote: this used to work before I started to install pip, easy_install and virtualenv this morning.\nThanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7079,"Q_Id":16148872,"Users Score":6,"Answer":"I just solved this issue after nearly pulling my hair out. Thought I would share. In windows system > advanced system settings > environment variables there are two places to change the PATH, user variables and system variables. I added \";c:\\python27\" as the value for PATH in both. It now works","Q_Score":0,"Tags":"python,powershell,python-2.7","A_Id":16150017,"CreationDate":"2013-04-22T13:51:00.000","Title":"Python will not run in windows powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\\python27 to my PATH and when I type \"python\" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like \"python --version\" it launches the new command prompt window and then closes before I can read it. Does anyone know how to get python to run in powershell?\nNote: this used to work before I started to install pip, easy_install and virtualenv this morning.\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7079,"Q_Id":16148872,"Users Score":0,"Answer":"I'm not expert in PS, but when I need to use python in interactive mode in windows powershell, I use something like this (version of python is 2.7.3, I didn't change env variables):\nPS C:\\Python27> .\/python\nPython 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.","Q_Score":0,"Tags":"python,powershell,python-2.7","A_Id":16149638,"CreationDate":"2013-04-22T13:51:00.000","Title":"Python will not run in windows powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a bot in Python that I've made to simulate a player playing a flash web game. The thing is, I've used an approach that requires specific screen coordinates to work, and there is a pop-up I need to click to advance to the next state that seems to appear in random positions every time it shows up.\nDo you know how to \"detect\" where the popup is?.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":253,"Q_Id":16151665,"Users Score":1,"Answer":"I'd try saving the button you have to click as a pic, then scan your entire screen and use PIL to match the pic you saved to the button you have to press; from there you should be able to retrieve the coordinates.","Q_Score":0,"Tags":"python,flash,bots","A_Id":16154217,"CreationDate":"2013-04-22T16:08:00.000","Title":"How to make this bot work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in Symbian 2nd Version, there's a software called Sisboom which works with python, with Sisboom it was possible to get the installer file of already installed software, now i've Symbian 3rd Version, and i got the same software, and i'm unbale to do the same, please help...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":16152515,"Users Score":0,"Answer":"With Symbian there is something called platform security, and from it there is something called data caging which is preventing access to the executable folders and some other ones as well, thus there are not really possibilities on 3rd party supplying such an application, and therefor I would suppose there would not be application with this kind of functionality available.","Q_Score":0,"Tags":"python-3.x,symbian3,s60-3rd-edition","A_Id":22061960,"CreationDate":"2013-04-22T16:53:00.000","Title":"how to pack already installed software in symbain 3rd version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We heavily use virtualenv and pip in our build system to isolate our Python deliveries. Everything is fully automated and was working fine until now.\nA couple of days ago, an issue appeared: an indirect dependency was moved to a private bitbucket repository, and pip started to prompt for a login\/password. Which was dramatic for continuous integration tools... And at some point, the very same dependency was removed from pypi, so we could no longer install our environment.\nIn a couple of words, pip started to prompt for a user\/password, which was quickly a pain (all automated tools were hanging forever...). And since today, it simply fails.\nI was wondering how to have something more reliable. As I guess anyone can remove a package from pypi, it is not safe to fully rely on it, right ? I was using a cache and thought that would be enough, but apparently it always try to connect to the internet to check the package existence.\nWhat is recommanded here ? Should I download everything manually, and only refer to local path via the variable \"dependency_links\" in my setup.py ? Or is there something smarter ?\nThanks !\nEmmanuel","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":92,"Q_Id":16163085,"Users Score":1,"Answer":"In reality, there is a more severe danger: pip downloads packages via plain HTTP, end even if you force it to use HTTPS, it can not check id the certificate is valid (since Python stdlib does not have the functionality either). That is someone in the middle can mask the expected package with something that you will readily install (sometimes with sudo). That's why in production environment it is anyway a good idea to install only separately downloaded and already checked packages.","Q_Score":3,"Tags":"python,virtualenv,pip","A_Id":16164433,"CreationDate":"2013-04-23T07:09:00.000","Title":"How to protect yourself from package disappearance on pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a numerical matrix of 2500*2500. To calculate the MIC (maximal information coefficient) for each pair of vectors, I am using minepy.MINE,  but this is taking forever, can I make it faster?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":425,"Q_Id":16171519,"Users Score":1,"Answer":"first, use the latest version of minepy. Second, you can use a smaller value of \"alpha\" parameter, say 0.5 or 0.45. In this way, you will reduce the computational time in despite of characteristic matrix accuracy.\nDavide","Q_Score":0,"Tags":"python,python-2.7","A_Id":16401807,"CreationDate":"2013-04-23T14:07:00.000","Title":"how to make minepy.MINE run faster?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am drawing a histogram using matplotlib in python, and would like to draw a line representing the average of the dataset, overlaid on the histogram as a dotted line (or maybe some other color would do too). Any ideas on how to draw a line overlaid on the histogram?\nI am using the plot() command, but not sure how to draw a vertical line (i.e. what value should I give for the y-axis?\nthanks!","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":127120,"Q_Id":16180946,"Users Score":2,"Answer":"I would look at the largest value in your data set (i.e. the histogram bin values) multiply that value by a number greater than 1 (say 1.5) and use that to define the y axis value. This way it will appear above your histogram regardless of the values within the histogram.","Q_Score":90,"Tags":"python,matplotlib,axis","A_Id":16180974,"CreationDate":"2013-04-23T23:35:00.000","Title":"Drawing average line in histogram (matplotlib)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing an app in GAE. Application provides different view depending upon whether logged-in user is admin or normal user. I want to use 'Google Apps domain' as Authentication Type. So that all user of my domain can login into the application and use it.\nHere, application can't differentiate a logged-in as admin or normal user. Somehow I should make an user as admin and as soon as that user logs in, application should use admin view for that user. Is there any way to tell application that a particular user is admin? \nIf we have our own USER table, we can mark any user as admin. Whenever a user logs into the app, app can consult USER table to check if user is admin or not? But in my scenario, it is not possible.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":145,"Q_Id":16191318,"Users Score":1,"Answer":"Why is what you describe not possible? The object representing the logged-in user is an instance of google.appengine.api.users.User. That object has a user_id property. You can use that ID as a field in your own user model, to which you can add a field determining whether or not they are an admin.","Q_Score":0,"Tags":"python,google-app-engine,google-cloud-datastore","A_Id":16191993,"CreationDate":"2013-04-24T11:53:00.000","Title":"Differentiating logged-in users as admin and normal user in Google App Engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've got a mac on which I installed python using macports. I like it this way because I could manually install numpy, scipy etc. without needing to mess with pre-built packages like enthought. I now wanted to install web.py, but after trying to install it through both easy_install and pip, I can't import it on the interactive python command line.\nWhen installing it, it also says: Installed \/Library\/Python\/2.6\/site-packages\/web.py-0.37-py2.6.egg while it says the following when I type 'python': Python 2.7.3 (default, Oct 22 2012, 06:12:28) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin\nWhen I type 'which python' I get: \/opt\/local\/bin\/python\nSo my question is: how to make easy_install and\/or pip install modules in the python installation which I enter when I simply type 'python' on the command line?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3596,"Q_Id":16198789,"Users Score":2,"Answer":"If you are using macports for python then you should install pip and easy_install via macports as well. You seem to have a non macports pipon your path.\ninstalling py27-pip will give you a pip-2.7 executable script on your path, similarly for easy_install.\nThe macports version have the python version in their name so as to allow multiple versions of python to be installed. If you want just pip then create a bash alias or link the pip-2.7 script to pip in a directory on yourpath.","Q_Score":0,"Tags":"python,macos,pip,macports","A_Id":16550756,"CreationDate":"2013-04-24T17:45:00.000","Title":"How to make pip install python modules in my current python2.7 installation on mac (instead of 2.6)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"UPDATE:\nThe error codes here is not such a return value of a function. Actually I am not discussing using exception or error codes for error handling. I am trying to figure out, using what pattern to  organize errors. \nWhat I am really doing is like error codes showing on Windows blue screen. Back to the very old time, when your Windows crash you can get an error code on blue screen, using that code you can figure out what's going on by looking up MS's document.\nIn my system, there are many plugins contributed by different people that may not know each other. If I allow them to define their error codes. It's mostly like error code of two plugins may conflict.\n================================================================================================\nI want to design an extendable error codes system that allows plugins to define their own error codes.\nThe basic idea is:\n\nsystem has a range of reserved error codes\nplugin can select a range that not used by system, then creates its error codes in that range. However, the problem is plugins don't know each other(because plugins may be written by different people and installed into system by user's preference). so their error codes range may conflict.\n\nIs there any good practice for this requirement? I google a lot but to my surprise, there are very few  articles talking about designing error codes in production software. Most posts are focus on exception vs error code.\nAnd, is there any good pattern for showing error in product that user could figure out what's going on?\nMy basic idea is to show user an error which has error code, descriptions, details. And user could click the error code then I would show him the proper solution","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":838,"Q_Id":16222064,"Users Score":0,"Answer":"For every exception your app throws you insert it into a db, your error code is the id for that record, that's what the user sees. Obviously same exception gets the same id. The plugin information you need is stored in the DB","Q_Score":1,"Tags":"java,python,design-patterns,error-handling,software-design","A_Id":16224608,"CreationDate":"2013-04-25T18:28:00.000","Title":"How to design extendable error codes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need a field that can contain a number and text on it, like for example \"6 months\", i've used the datetime field, but it only takes a formatted date on it, and if use integer or float it takes a number, and char takes only a character, so how can i have an integer and a char on the same field?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":422,"Q_Id":16223006,"Users Score":4,"Answer":"What you want currently not possible in openerp. But you can use one trick, you should use two fields one is integer for giving interval and other in char fields for giving months, days etc. You can get this example on Scheduler , ir.cron object of opener.","Q_Score":0,"Tags":"python,module,field,openerp","A_Id":16229121,"CreationDate":"2013-04-25T19:18:00.000","Title":"DateTime field OpenErp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am just starting out with nltk, and I am following the book. Chapter six is about text classification, and i am a bit confused about something. In the examples (the names, and movie reviews) the classifier is trained to select between two well-defined labels (male-female, and pos-neg). But how to train if you have only one label. \nSay I have a bunch of movie plot outlines, and I am only interested in fishing out movies from the sci-fi genre. Can I train a classifier to only recognize sci-fi plots, en say f.i. if classification confidence is > 80%, then put it in the sci-fi group, otherwise, just ignore it.\nHope somebody can clarify, thank you,","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":441,"Q_Id":16230984,"Users Score":0,"Answer":"I see two questions \n\nHow to train the system?\nCan the system consist of \"sci-fi\" and \"others\"?\n\nThe answer to 2 is yes. Having a 80% confidence threshold idea also makes sense, as long as you see with your data, features and algorithm that 80% is a good threshold. (If not, you may want to consider lowering it if not all sci-fi movies are being classified as sci-fi, or lowering it, if too many non-sci-fi movies are being categorized as sci-fi.)\nThe answer to 1 depends on the data you have, the features you can extract, etc. Jared's approach seems reasonable. Like Jared, I'd also to emphasize the importance of enough and representative data.","Q_Score":0,"Tags":"python,machine-learning,nlp,classification,nltk","A_Id":16231323,"CreationDate":"2013-04-26T07:29:00.000","Title":"train nltk classifier for just one label","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am just starting out with nltk, and I am following the book. Chapter six is about text classification, and i am a bit confused about something. In the examples (the names, and movie reviews) the classifier is trained to select between two well-defined labels (male-female, and pos-neg). But how to train if you have only one label. \nSay I have a bunch of movie plot outlines, and I am only interested in fishing out movies from the sci-fi genre. Can I train a classifier to only recognize sci-fi plots, en say f.i. if classification confidence is > 80%, then put it in the sci-fi group, otherwise, just ignore it.\nHope somebody can clarify, thank you,","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":16230984,"Users Score":0,"Answer":"You can simply train a binary classifier to distinguish between sci-fi and not sci-fi\nSo train on the movie plots that are labeled as sci-fi and also on a selection of all other genres. It might be a good idea to have a representative sample of the same size for the other genres such that not all are of the romantic comedy genre, for instance.","Q_Score":0,"Tags":"python,machine-learning,nlp,classification,nltk","A_Id":16231216,"CreationDate":"2013-04-26T07:29:00.000","Title":"train nltk classifier for just one label","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program that displays many tkinter PhotoImages at once (relevant: I'm not using PIL). It currently has several screens, and when the play gets to the edge it loads a new tilemap, creating a bunch more photoimages in the currentTiles array after clearing the old contents. I'm fairly certain there are no other references to these photoimages in the rest of the program.\nThe weird thing is that when I print the contents of the last item in the array after the loadLevel function is called, it says things such as \"pyimage3761\", and it increments each time I load a new screen. Is this due to tkinter keeping track of how many have been created so far, or is it because the old tiles are still in memory? I can't for the life of me figure out where there could be another reference, so I'm just wondering if there are any other possibilities before I spend hours looking for errors.\nThanks!!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":238,"Q_Id":16241755,"Users Score":2,"Answer":"Every created image is assigned a unique name (unless you specify the name of the image when creating). This unique name is generated  by using a counter, which increases monotonically.","Q_Score":1,"Tags":"python,tkinter","A_Id":16241833,"CreationDate":"2013-04-26T17:09:00.000","Title":"Tkinter PhotoImage: References in Memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am quite new to heroku and I reached a bump in my dev...\nI am trying to write a server\/client kind of application...on the server side I will have a DB(I installed postgresql for python) and I was hoping I could reach the server, for now, via a python client(for test purposes) and send data\/queries and perform basic tasks on the DB.\nI am using python with Heroku, I manage to install the DB and it seems to be working(i.e i can query, insert, delete, etc...)\nnow all i want is to write a server(in python) that would be my app and would listen on a port and receive messages and then perform whatever tasks it is asked to do...I tought about using sockets for this and have managed to write a basic server\/client locally...however when I deploy the app on heroku i cannot connect to the server and my code is basically worthless\ncan somebody plz advise on the basic framework for this sort of requirements...surely I am not the first guy to want to write a client\/server app...if you could point to a tutorial\/doc i would be much obliged.\nThx","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":569,"Q_Id":16244924,"Users Score":3,"Answer":"Heroku is for developing Web (HTTP, HTTPS) applications. You can't deploy code that uses socket to Heroku.\nIf you want to run your app on Heroku, the easier way is to use a web framework (Flask, CherryPy, Django...). They usually also come with useful libraries and abstractions for you to talk to your database.","Q_Score":0,"Tags":"python,heroku","A_Id":16245012,"CreationDate":"2013-04-26T20:44:00.000","Title":"how to write a client\/server app in heroku","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Something that I just thought about:\nSay I'm writing view code for my Django site, and I make a mistake and create an infinite loop.\nWhenever someone would try to access the view, the worker assigned to the request (be it a Gevent worker or a Python thread) would stay in a loop indefinitely.\nIf I understand correctly, the server would send a timeout error to the client after 30 seconds. But what will happen with the Python worker? Will it keep on working indefinitely? That sounds dangerous!\nImagine I've got a server in which I've allocated 10 workers. I let it run and at some point, a client tries to access the view with the infinite loop. A worker will be assigned to it, and will be effectively dead until the next server restart. The dangerous thing is that at first I wouldn't notice it, because the site would just be imperceptibly slower, having 9 workers instead of 10. But then it might happen again and again throughout a long span of time, maybe months. The site would just get progressively slower, until eventually it would be really slow with just one worker.\nA server restart would solve the problem, but I'd hate to have my site's functionality depend on server restarts.\nIs this a real problem that happens? Is there a way to avoid it?\nUpdate: I'd also really appreciate a way to take a stacktrace of the thread\/worker that's stuck in an infinite loop, so I could have that emailed to me so I'll be aware of the problem. (I don't know how to do this because there is no exception being raised.)\nUpdate to people saying things to the effect of \"Avoid writing code that has infinite loops\": In case it wasn't obvious, I do not spend my free time intentionally putting infinite loops into my code. When these things happen, they are mistakes, and mistakes can be minimized but never completely avoided. I want to know that even when I make a mistake, there'll be a safety net that will notify me and allow me to fix the problem.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2964,"Q_Id":16252538,"Users Score":0,"Answer":"Yes, your analysis is correct. The worker thread\/process will keep running. Moreover, if there is no wait\/sleep in the loop, it will hog the CPU. Other threads\/process will get very little cpu, resulting your entire site on slow response.\nAlso, I don't think server will send any timeout error to client explicitly. If the TCP timeout is set, TCP connection will be closed.\nClient may also have some timeout setting to get response, which may come into picture.\nAvoiding such code is best way to avoid such code. You can also have some monitoring tool on server to look for CPU\/memory usage and notify for abnormal activity so that you can take action.","Q_Score":7,"Tags":"python,django,web,infinite-loop","A_Id":16252661,"CreationDate":"2013-04-27T13:11:00.000","Title":"What happens when you have an infinite loop in Django view code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using the Python library HSAudioTag, and I'm trying to read the track number in my files, however, without fail, the file returns 0 as the track number, even if it's much higher. Does anybody have any idea how to fix this?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":16288787,"Users Score":0,"Answer":"The solution was to go into the code, and change the following lines to: Line 118: self.track = u'' Lines 149-152: self.track = int(self._fields.get(TRACK, u'')) + 1","Q_Score":0,"Tags":"python","A_Id":21212477,"CreationDate":"2013-04-29T21:45:00.000","Title":"Python HSAudioTag for WMA files always returns 0?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say a source A is sending me an unknown number of messages using UDP. How can I intercept all those messages? This is the complete scenario:\n\nSend 7 messages\nWait for their ACKs\nProcess ACKs\nSend another batch\nRepeat...\n\nProblems: (1) I don't know how many messages arrive, some may get lost and some are repeated, and (2) I might be be doing something else later, so I cannot wait forever.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":16293597,"Users Score":0,"Answer":"You could have a message loop continuously listening and processing received packets and putting them on a queue then read them at your leisure...\nHowever you would need to implement you own ACKs taking into account the possibilities of lost and duplicates (if your application is concerned about them).. Which begs the question - why not use TCP?","Q_Score":0,"Tags":"python,python-2.7,network-programming,udp,sliding-window","A_Id":16399916,"CreationDate":"2013-04-30T06:29:00.000","Title":"Receive an unknown number of UDP messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a requirements.txt file with a list of packages that are required for my virtual environment. Is it possible to find out whether all the packages mentioned in the file are present. If some packages are missing, how to find out which are the missing packages?","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":41835,"Q_Id":16294819,"Users Score":20,"Answer":"You can run pip freeze to see what you have installed and compare it to your requirements.txt file.\nIf you want to install missing modules you can run pip install -r requirements.txt and that will install any missing modules and tell you at the end which ones were missing and installed.","Q_Score":41,"Tags":"python,pip,requirements.txt","A_Id":16294888,"CreationDate":"2013-04-30T07:48:00.000","Title":"Check if my Python has all required packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a small python program which will be used locally by a small group of people (<15 people).But for accountability, i want to have a simple username+password check at the start of the program ( doesn't need to be super secure).For your information, I am just a beginner and this is my first time trying it.When i search around, i found that python has passlib for encryption. But even after looking though it i am still not sure how to implement my encryption.So, there are a few things that i want to know. \n\nHow do i store the passwords of users locally? The only way i know at the moment is to create a text file and read\/write from it but that will ruin the whole purpose of encryption as people can just open the text file and read it from there.\nWhat does hash & salt means in encryption and how does it work? (a brief and simple explanation will do.)\nWhat is the recommended way to implement username and password check?\n\nI am sorry for the stupid questions. But i will greatly appreciate if you could answers my question.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":6052,"Q_Id":16334482,"Users Score":-1,"Answer":"You could use htpasswd which is installed with apache or can be downloaded seperately. Use subprocess.check_output to run it and you can create Python functions to add users, remove them, verify they have given the correct password etc. Pass the -B option to enable salting and you will know that it's secure (unlike if you implement salts yourself).","Q_Score":6,"Tags":"python,encryption,passwords","A_Id":16334819,"CreationDate":"2013-05-02T09:23:00.000","Title":"Password Protection Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following situation.\nI keep track of a user's longitude and latitude using ios.\nI send the longitude and latitude coordinates to a django server.\nHow can I use these longitude and latitude coordinates to determine what objects are near? \nBasically how can I use these coordinates to determine the list of other users near a user?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":16359847,"Users Score":0,"Answer":"You keep track of all users, and you show all users whose coordinates are of a similar value.\nYes, that's a generic answer, but it is a very generic question.\nI would not be surprised if there are modules for Django doing this already.","Q_Score":0,"Tags":"python,django","A_Id":16360039,"CreationDate":"2013-05-03T13:17:00.000","Title":"Getting near objects. Django + Badoo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is part of a project I am working on for work.\nI want to automate a Sharepoint site, specifically to pull data out of a database that I and my coworkers only have front-end access to.\nI FINALLY managed to get mechanize (in python) to accomplish this using Python-NTLM, and by patching part of it's source code to fix a reoccurring error.\nNow, I am at what I would hope is my final roadblock: Part of the form I need to submit seems to be output of a JavaScript function :| and lo and behold... Mechanize does not support javascript. I don't want to emulate the javascript functionality myself in python because I would ideally like a reusable solution...\nSo, does anyone know how I could evaluate the javascript on the local html I download from sharepoint? I just want to run the javascript somehow (to complete the loading of the page), but without a browser.\nI have already looked into selenium, but it's pretty slow for the amount of work I need to get done... I am currently looking into PyV8 to try and evaluate the javascript myself... but surely there must be an app or library (or anything) that can do this??","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1441,"Q_Id":16375251,"Users Score":2,"Answer":"Well, in the end I came down to the following possible solutions:\n\nRun Chrome headless and collect the html output (thanks to koenp for the link!)\nRun PhantomJS, a headless browser with a javascript api\nRun HTMLUnit; same thing but for Java\nUse Ghost.py, a python-based headless browser (that I haven't seen suggested anyyyywhere for some reason!)\nWrite a DOM-based javascript interpreter based on Pyv8 (Google v8 javascript engine) and add this to my current \"half-solution\" with mechanize.\n\nFor now, I have decided to use either use Ghost.py or my own modification of the PySide\/PyQT Webkit (how ghost works) to evaluate the javascript, as apparently they can run quite fast if you optimize them to not download images and disable the GUI.\nHopefully others will find this list useful!","Q_Score":1,"Tags":"javascript,python,html,screen-scraping,eval","A_Id":16385053,"CreationDate":"2013-05-04T14:16:00.000","Title":"Evaluate javascript on a local html file (without browser)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I try to write a simple 2d game using python 3.x and pygame 1.9.2. I want to simulate changing of days\/nights. I have got in-game time(like real, but faster) and I'd like to make my screen darker at exact time but have no ideas how to do it. Could you advice me how to reduce the brightness of my screen or other ways how to show changing of days and nights?\nExcuse for my language if I make mistakes. English isn't native for me)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":755,"Q_Id":16375396,"Users Score":0,"Answer":"Setting gamma or screen brightness is not the best way to go. \nWhen your game gets more complicated, it's easier if you use the technique ecline6 suggested:\nchanging your background image.\nBut since it is a loaded image i suppose, you can use this trick:\nLet's say you have a background surface. Every 10s you will fire an event that will change the backround by blitting an low alpha-black surface on top of it. That way your background will get darker.\nYou can do the same with white, to make it more brighter too.","Q_Score":0,"Tags":"python,pygame","A_Id":16377757,"CreationDate":"2013-05-04T14:33:00.000","Title":"Changing days and nights with pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to run Pydev with Pymongo on an Python3.3 Interpreter.\nMy problem is, I am not able to get it working :-\/\nFirst of all I installed Eclipse with Pydev.\nAfterwards I tried installing pip to download my Pymongo-Module.\nProblem is: it always installs pip for the default 2.7 Version.\nI read that you shouldn't change the default system Interpreter (running on Lubuntu 13.04 32-Bit) so I tried to install a second Python3.3 and run it in an virtual environement, but I can't find any detailed Information on how to use everything on my specific problem.\nMaybe there is someone out there, that uses a similar configuration and can help me out to get everything running (in a simple way) ?\nThanks in advance,\nEric","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1303,"Q_Id":16379321,"Users Score":1,"Answer":"You can install packages for a specific version of Python, all you need to do is specify the version of Python you want use from the command-line; e.g. Python2.7 or Python3.\nExamples\nPython3 pip your_package\nPython3 easy_install your_package.","Q_Score":0,"Tags":"python,ubuntu,pydev,pymongo","A_Id":16379374,"CreationDate":"2013-05-04T21:52:00.000","Title":"Using Python3 with Pymongo in Eclipse Pydev on Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to delete the first three rows of a dataframe in pandas.\nI know df.ix[:-1] would remove the last row, but I can't figure out how to remove first n rows.","AnswerCount":8,"Available Count":2,"Score":0.1243530018,"is_accepted":false,"ViewCount":412922,"Q_Id":16396903,"Users Score":5,"Answer":"inp0= pd.read_csv(\"bank_marketing_updated_v1.csv\",skiprows=2)\nor if you want to do in existing dataframe\nsimply do following command","Q_Score":249,"Tags":"python,pandas","A_Id":61941548,"CreationDate":"2013-05-06T10:35:00.000","Title":"Delete the first three rows of a dataframe in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to delete the first three rows of a dataframe in pandas.\nI know df.ix[:-1] would remove the last row, but I can't figure out how to remove first n rows.","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":412922,"Q_Id":16396903,"Users Score":9,"Answer":"A simple way is to use tail(-n) to remove the first n rows\ndf=df.tail(-3)","Q_Score":249,"Tags":"python,pandas","A_Id":52984033,"CreationDate":"2013-05-06T10:35:00.000","Title":"Delete the first three rows of a dataframe in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Of course I tried to copy the files in the .gnome2\/gedit\/plugins and in the .local\/share\/gedit\/plugins directories.\nBut it doesn't work at all. How do I install the plugin?\nI'm on Fedora 18. Lxde desktop manager.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1116,"Q_Id":16397384,"Users Score":0,"Answer":"If you have gedit3, have you checked that this is a plugin for gedit3, not gedit2?\nTake a look at *.plugin file. It should say IAge=3.","Q_Score":2,"Tags":"python,plugins,autocomplete,installation,gedit","A_Id":45171475,"CreationDate":"2013-05-06T11:03:00.000","Title":"Gedit plugin for python autocomplete: how to install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can I make a loop in Google App Engine that fetches information from a site?\nI have made a small code that already gets the information I want from the site, but I don't know how to make this code run every lets say, 20 minutes.\nIs there a way to do this?\nP.S.: I have looked at TaskQueue, but I'm not sure if it is meant for things like this.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":81,"Q_Id":16406080,"Users Score":1,"Answer":"Take a look at the GAE cron functionality.","Q_Score":0,"Tags":"python,google-app-engine,loops","A_Id":16406284,"CreationDate":"2013-05-06T19:46:00.000","Title":"Google App Engine urlfetch loop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been trying to get my python code to post. I have tried using the Postman Plugin to test the post method and I would get a 405 method error. I am planning to have the user post the information and have it displayed.\nCurrently if I press submit I would get a error loading page, changing the form to get results in the submit button working and returning to the previous page. If I change the handler to post the screen would instantly display '405 Method Not Allowed'. I've looked through the Google App Engine logs and there are no errors. Can someone help me with what I done wrong and advise me on how to the post method functioning?\nThanks for the time.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":299,"Q_Id":16411136,"Users Score":2,"Answer":"You're getting '405 method not allowed' because the POST is going to the same url that served up the page, but the handler for that path (MainPage) does not have a post method.\nThat's the same diagnosis that you were given when you asked this question two hours earlier under a different user id.\nStepping back further to address the \"what have I done wrong\" question: It seems to me that you've gotten quite far along before discovering that what you have doesn't work. So far along that the example is cluttered with irrelevant code that's unrelated to the failure. That makes it harder for you for figure this out for yourself, and it makes it more difficult for people here to help you.\nIn this situation, you help yourself (and help others help you) by seeing how much code you can eliminate while still demonstrating the failure.","Q_Score":0,"Tags":"python,html,google-app-engine","A_Id":16411935,"CreationDate":"2013-05-07T04:19:00.000","Title":"Unable to get Python to POST on html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"basically, I want to have a login box, and the option to remember the password next time you log in. I know there are encryption modules out there, but they require a password to work in the first place. is there a way to get the password the user used to log into the computer, and use that to encrypt the password for my application?\nso in a nutshell, how do I store a password securely for later use.\nI'm using python 3, and my program needs to be crossplatform.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1629,"Q_Id":16426150,"Users Score":1,"Answer":"You cannot get the password the user used to log in to the computer.\nAnd, if you could, you would not want to store it.\nIn fact, the OS doesn't even have the user's password. The OS has a hash of it, and when the user logs in, it hashes what the user types and checks that it matches.\n\nAlso, if you ask the user to log in with their system password, any savvy user is going to immediately mistrust your app and refuse to use it. Make them create a password, and then login with that, not their system password. And don't save the password, save a hash, just like the OS does.\nIf you want to verify that they've been authenticated by the OS\u2026\u00a0well, you already know that, or they couldn't have logged in to run your app. (If you're building a network server that allows remote login based on local accounts, that's a different story, but it's not relevant to your use case, and complicated, so I won't get into it here.)\n\nIf you want to allow someone to \"stay logged in\", you don't do that by saving their password. Instead, you create some kind of hard-to-fake \"session key\" when they log in, and store that somewhere. They don't have to log in again until you destroy the session key (which you do when they log out).\n\nThe one exception to \"never store passwords\" is when you need to act as a \"proxy\" for the user to some other application that needs their password. A well-designed application will provide a way for you to proxy the login properly, but many applications are not well-designed. Web browsers have to do this all the time, which is why most web browsers have a \"remember my password at this site\" checkbox.\nIn this case, you do want to store passwords, ideally encrypted by the OS on your behalf (e.g., using OS X's Keychain APIs), or, if not, encrypted by you code using some key that's generated from the user's \"master password\" (which you don't store).\n\nUnfortunately, there is no real shortcut to learning how to design for security\u2014or, rather, there are all kinds of shortcuts, and taking any one of them means your entire system ends up insecure and all the work you put into trying to secure it ends up useless.\nThe easy solution is to use complete off-the-shelf solutions.\nIf you want to design things yourself, you need at least a basic grounding in all of the issues. Start with one of Bruce Scheneier's \"pop\" books, Secrets and Lies or Beyond Fear. Then read his Practical Cryptography on designing cryptosystems, and Applied Cryptography on evaluating crypto algorithms. Then, once you realize how much you don't know and how important it is, learn everything you need for your problem, and then you can think about solving it.","Q_Score":1,"Tags":"python,encryption,python-3.x,cryptography","A_Id":16426218,"CreationDate":"2013-05-07T18:34:00.000","Title":"remember password functionality in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"basically, I want to have a login box, and the option to remember the password next time you log in. I know there are encryption modules out there, but they require a password to work in the first place. is there a way to get the password the user used to log into the computer, and use that to encrypt the password for my application?\nso in a nutshell, how do I store a password securely for later use.\nI'm using python 3, and my program needs to be crossplatform.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1629,"Q_Id":16426150,"Users Score":1,"Answer":"There is no way out. If the application does not ask the user for a password, then it is not securely storing passwords, it's only doing... \"things\". In that case, don't give the user a false sense of security, use cleartext.\nA notable exception is the GNOME login keyring (and equivalent on other platforms) not asking for a password, but it uses a trick: it encrypts data with your login password and decrypts them with the same when you enter it at startup.\nIf you are developing a web application with a local client, consider using OAuth instead of passwords.","Q_Score":1,"Tags":"python,encryption,python-3.x,cryptography","A_Id":16426284,"CreationDate":"2013-05-07T18:34:00.000","Title":"remember password functionality in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to pylucene and I am trying to build a custom analyzer which tokenizes text on the basis of underscores only, i.e. it should retain the whitespaces.\nExample: \"Hi_this is_awesome\" should be tokenized into [\"hi\", \"this is\", \"awesome\"] tokens.\nFrom various code examples I understood that I need to override the incrementToken method for a CustomTokenizer and write a CustomAnalyzer for which the TokenStream needs to use the CustomTokenizer followed by a LowerCaseFilter to achieve the same.\nI am facing problems in implementing the incrementToken method and connecting the dots (how the tokenizer maybe used as usually the Analyzers depend on TokenFilter which depend on TokenStreams) as there is very little documentation available on pylucene.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":682,"Q_Id":16432969,"Users Score":3,"Answer":"Got it working eventually by creating a new tokenzier which considered every char other than an underscore as part of the token generated (basically underscore becomes the separator)\n\nclass UnderscoreSeparatorTokenizer(PythonCharTokenizer):\n  def __init__(self, input):\n    PythonCharTokenizer.__init__(self, input)\n\n  def isTokenChar(self, c):\n    return c != \"_\"\n\nclass UnderscoreSeparatorAnalyzer(PythonAnalyzer):\n  def __init__(self, version):\n    PythonAnalyzer.__init__(self, version)\n\n  def tokenStream(self, fieldName, reader):\n    tokenizer = UnderscoreSeparatorTokenizer(reader)\n    tokenStream = LowerCaseFilter(tokenizer)\n    return tokenStream","Q_Score":1,"Tags":"python,lucene,pylucene","A_Id":16469866,"CreationDate":"2013-05-08T04:58:00.000","Title":"Custom Tokenizer for pylucene which tokenizes text based only on underscores (retains spaces)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How could we generate all possible permutations of  n (given) distinct items taken r at a time where any item can be repeated any number of times?\nCombinatorics tell me that there will be n^r of them, just wondering how to generate them with C++\/python?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5032,"Q_Id":16446374,"Users Score":1,"Answer":"Treat your permutation as a r-digit number in a n-based numerical system. Start with 000...0 and increase the 'number' by one: 0000, 0001, 0002, 000(r-1), 0010, 0011, ...\nThe code is quite simple.","Q_Score":0,"Tags":"c++,python,algorithm,permutation","A_Id":16446441,"CreationDate":"2013-05-08T17:06:00.000","Title":"Generating all permutations with repetition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am not sure if this question belongs here as it may be a little to broad. If so, I apologize. Anyway, I am planning to start a project in python and I am trying to figure out how best to implement it, or if it is even possible in any practical way. The system will consist of several \"nodes\" that are essentially python scripts that translate other protocols for talking to different kinds of hardware related to i\/o, relays to control stuff, inputs to measure things, rfid-readers etc, to a common protocol for my system. I am no programming or network expert, but this part I can handle, I have a module from an old alarm system that uses rs-485 that I can sucessfully control and read. I want to get the nodes talking to eachother over the network so I can distribute them to different locations (on the same subnet for now). The obvious way would be to use a server that they all connect to so they can be polled and get orders to flip outputs or do something else. This should not be too hard using twisted or something like it. \nThe problem with this is that if this server for some reason stops working, everything else does too. I guess what I would like is some kind of serverless communication, that has no single point of failure besides the network itself. Message brokers all seem to require some kind of server, and I can not really find anything else that seems suitable for this. All nodes must know the status of all other nodes as I will need to be able to make functions based on the status of things connected to other nodes, such as, do not open this door if that door is already open. Maybe this could be done by multicast or broadcast, but that seems a bit insecure and just not right. One way I thought of could be to somehow appoint one of the nodes to accept connections from the other nodes and act as a message router and arrange for some kind of backup so that if this node crashes or goes away, another predetermined node takes over and the other nodes connect to it instead. This seems complicated and I am not sure this is any better than just using a message broker.\nAs I said, I am not sure this is an appropriate question here but if anyone could give me a hint to how this could be done or if there is something that does something similar to this that I can study. If I am beeing stupid, please let me know that too :)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":438,"Q_Id":16452913,"Users Score":1,"Answer":"There are messaging systems that don't require a central message broker. You might start by looking at ZeroMQ.","Q_Score":3,"Tags":"python,networking","A_Id":16453432,"CreationDate":"2013-05-09T01:29:00.000","Title":"Serverless communication between network nodes in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use the gaussian function in python to generate some numbers between a specific range giving the mean and variance \nso lets say I have a range between 0 and 10 \nand I want my mean to be 3 and variance to be 4\nmean = 3, variance = 4\nhow can I do that ?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":36597,"Q_Id":16471763,"Users Score":1,"Answer":"If you have a small range of integers, you can create a list with a gaussian distribution of the numbers within that range and then make a random choice from it.","Q_Score":10,"Tags":"python,gaussian","A_Id":16471982,"CreationDate":"2013-05-09T21:51:00.000","Title":"Generating numbers with Gaussian function in a range using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been experiencing a really weird bug recently:\nOften when I zoom too much on a QGraphicsItem (using scale on the view containing it) that has a QGraphicsDropShadowEffect on it, my app closes with a segmentation fault (core dumped) error.\nWhat's weird is that:\n\nI use Python (with the PySide binding)\nIf I remove the QGraphicsDropShadowEffect, the bug disappears\n\nI also had to remove the QGraphicsDropShadowEffect on a relatively big item because it got the app so slow to the point it became irresponsive when I zoomed a bit too much.\nDo anyone know how I could fix this ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":16487059,"Users Score":0,"Answer":"This may or may not help but when I encountered this the only thing that helped was reinstalling\/updating pyside. I thought the fixed that bug a while back however.","Q_Score":2,"Tags":"python,qt,user-interface,pyside","A_Id":16492340,"CreationDate":"2013-05-10T16:43:00.000","Title":"Qt : Segfault when zooming on QGraphicsDropShadowEffect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently got an exception on my server about \"Too many open files\". I checked lsof, and sure enough, there are a bunch of PDF files that remain open (all in the same directory). This particular file is managed through a Django FileField. I've tried to track down any places in my project that explicitly open the file by name, and there's only one place I can find, and from what I can tell the file is being closed correctly there. There may be other places where the file is remaining open, but I have no idea how to find out what piece of code is actually keeping the file open. I've tried simply grepping for calls to open() and file(), but no luck.\nIs there any way to systematically track down what line of code is responsible for leaving the file open? \nEDIT: I understand how to properly open\/close a file. My question is whether or not there is a way to track down an existing line of code that leaves is leaving a file open.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":16487863,"Users Score":0,"Answer":"Are you depending on the garbage collector to close your files? I.E. the handle goes out of scope and even though you've \"closed\" the file, it won't go away until GC runs. If the object chain never goes out of scope, GC cannot collect it. Also, if GC does not get an opportunity to run, they won't be collected either.\nI ran into the same issue with a long running process, and \"solved\" it by redesigning my system, such that all file access happened inside of a child object. That object got removed from the reference chain after it was done being used, or some error occurred. This allowed the GC to collect the handles.","Q_Score":1,"Tags":"python,django","A_Id":16488072,"CreationDate":"2013-05-10T17:34:00.000","Title":"How can I find out which line of code is leaving a file open?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"When using RandomForestRegressor from Sklearn, how do you get the residuals of the regression? I would like to plot out these residuals to check the linearity.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2682,"Q_Id":16502445,"Users Score":5,"Answer":"There is no function for that, as we like to keep the interface very simple.\nYou can just do\ny - rf.predict(X)","Q_Score":4,"Tags":"python,python-2.7,numpy,scipy,scikit-learn","A_Id":16524872,"CreationDate":"2013-05-11T22:51:00.000","Title":"Residuals of Random Forest Regression (Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using PyDev perspective. I get a bad indentation warning in python files. \nI just copy code from somewhere else, I cannot make sure how much space others use... so how to automatically format that or how to erase that warning? It looks bad.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":582,"Q_Id":16511231,"Users Score":0,"Answer":"There is no 'automatic' way for that... But usually in this situation you can just do a find\/replace from 2 spaces to 3 spaces (or whatever was the format you had to the expected format).\nSometimes rectangular editing is helpful there too (hint: use alt+shift+A to enter\/leave rectangular editing mode).","Q_Score":2,"Tags":"python,pydev","A_Id":16513405,"CreationDate":"2013-05-12T19:31:00.000","Title":"Pydev indentation warning in Eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've seen multiple tutorials in python, played around a bit with python file write(), tell(), seek() functions and also os.write(), lseek() functions. \nBut I still don't get how can I do the following:\nWhat I have:\nIn  a file I know the start_offset and end_offset bytes. And I need to replace the bytes from start_offset to end_offset with  a different set of bytes. How do I do this??\nftell() returns me the start_offset and similarly regex + ftell() returns me the end offset\nI have the bytes that will overwrite the original ones in the file. \nBut write() only takes  a string to write. Also how do I overwrite from start_pos to end_pos??\nappreciate any pointers\/suggestions","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":561,"Q_Id":16528178,"Users Score":3,"Answer":"You write the exact number of characters == bytes, after .seek()-ing back to your start_offset position. These then overwrite the data that was there before.\nYou can split that up into multiple writes, even writes of one character (byte) at a time if needed.","Q_Score":0,"Tags":"python,file-io","A_Id":16528237,"CreationDate":"2013-05-13T17:55:00.000","Title":"python overwrite bytes from offset1 to offset2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I use ipython on top of a pypy interpreter rather than a cpython interpreter?  ipython website just says it works, but is scant on the details of how to do it.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6903,"Q_Id":16536683,"Users Score":2,"Answer":"The \"straight forward\" way is:\n\nInstall pypy3\npypy3 -m pip install ipython\npypy3 -m IPython","Q_Score":27,"Tags":"python,ipython,pypy","A_Id":67074248,"CreationDate":"2013-05-14T06:42:00.000","Title":"How to run ipython with pypy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to know how to preform an action every hour in python. My Raspberry Pi should send me information about the temp and so on every hour. Is this possible? \nI am new to python and linux, so a detailed explanation would be nice.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7805,"Q_Id":16543715,"Users Score":0,"Answer":"The easiest way would be to set up a cron job to call a python script every hour.","Q_Score":1,"Tags":"python,raspberry-pi,schedule","A_Id":16543818,"CreationDate":"2013-05-14T12:52:00.000","Title":"How to schedule an action in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to check if a certain tweet is a reply to the tweet that I sent. Here is how I think I can do it:\nStep1: Post a tweet and store id of posted tweet\nStep2: Listen to my handle and collect all the tweets that have my handle in it\nStep3: Use tweet.in_reply_to_status_id to see if tweet is reply to the stored id\nIn this logic, I am not sure how to get the status id of the tweet that I am posting in step 1. Is there a way I can get it? If not, is there another way in which I can solve this problem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1649,"Q_Id":16574746,"Users Score":0,"Answer":"What one could do, is get the last nth tweet from a user, and then get the tweet.id of the relevant tweet. This can be done doing:\nlatestTweets = api.user_timeline(screen_name = 'user', count = n, include_rts = False)\nI, however, doubt that it is the most efficient way.","Q_Score":1,"Tags":"python,twitter,tweepy","A_Id":16589445,"CreationDate":"2013-05-15T20:51:00.000","Title":"How to get id of the tweet posted in tweepy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to take a set of tagged images as input and remove noisy tags from each image. I have written a python code which takes a text file as input, each line of which corresponds to tags of an image, and removes the noisy tags from each line. I have used the structure and similarity measures in Wordnet to do so.\nBut i dunno how to take a set of images as input. Could someone please tell me how to do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":16582065,"Users Score":0,"Answer":"Well, I suppose you take a bunch of path to images as strings, you can get them as command line arguments or reading them from stdin. Then you just have to open them or do whatever you want with it.\nIs that answering your question?","Q_Score":0,"Tags":"python,image-processing,wordnet","A_Id":16582205,"CreationDate":"2013-05-16T08:05:00.000","Title":"Using set of images as an input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to invoke a python code for screen scraping (using Beautiful Soup) from my jsp servlet. Or it would also work if it can be directly invoked from the HTML.\nLooked through few threads but couldn't get any solution.\nWhat I want is to give the python program some arguments and want it to do some screen scrapping and return the result to jsp somehow.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1132,"Q_Id":16597149,"Users Score":0,"Answer":"I assume you are talking about web scraping which is pulling information from other websites.\nYou are not going to be able to do something like this in somebody's browser because it violates Javascript's same origin policy, AND there is no way a browser is going to let you download and execute a script on a client's computer.\nYou could just write a python script to do this for you and execute it yourself on your machine however.\nJust be sure you are not violating web site's terms of service.\nEDIT:\nIn that case I would recommend running the script on the command line, and then using the output of the program in the servlet to generate the responses you want.","Q_Score":0,"Tags":"python,html,jsp,beautifulsoup","A_Id":16597278,"CreationDate":"2013-05-16T20:45:00.000","Title":"how to invoke python script in jsp\/servlet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to implement something like this:\nIf someone send email with file in attachment to system@mail.com, this file is added automatically to database.\nPlease general algorithm how to do or suggest existing app","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":99,"Q_Id":16597739,"Users Score":1,"Answer":"Are you trying to read from a mailbox and write the information into the database?  If so, then you want to:\n1) Open a connection to the mail server using poplib or imaplib from the standard library\n2) Retrieve messages from the server (again with poplib or imaplib)\n3) Parse the messages with the email package from the standard library.\nFrom there, you can populate whatever stuff you want in your database, either using the Django ORM or not.","Q_Score":1,"Tags":"python,django,email,django-email","A_Id":16599805,"CreationDate":"2013-05-16T21:23:00.000","Title":"Upload files via email in Django. General algorithm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do something like \nselect * from table where name like '%name%'\nis there anyway to do this in Hbase ? and if there is a way so how to do that\nps. I use HappyBase to communicate with Hbase","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":364,"Q_Id":16606906,"Users Score":1,"Answer":"HBase provides a scanner interface that allows you to enumerate over a range of keys in an HTable. HappyBase has support for scans and this is documented pretty well in their API.\nSo this would solve your question if you were asking for a \"like 'name%'\" type of query which searches for anything that begins with the prefix 'name'. I am assuming name is the row key in your table, otherwise you would need a secondary index which relates the name field to the row key value of the table or go with the sub-awesome approach of scanning the entire table and doing the matching in Python yourself, depending on your usecase...\nEdit: HappyBase also supports passing a 'filter' string assuming you are using a recent HBase version. You could use the SubStringComparator or RegexStringComparator to fit your needs.","Q_Score":0,"Tags":"python,hbase,thrift","A_Id":16608107,"CreationDate":"2013-05-17T10:33:00.000","Title":"Hbase wildcard support","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've collected many nice wall papers over years. \nI know python and c++ (a little MFC eperience).\nI want to make a programme that can change my wallpapers.\nI want to operate like this:\n     there is a little icon (half transparent), if i click it, it change my wallpapers to the next picture in my wallpaper collection folder.\nI found many infos of changing wallpaper by programme by google.\nBut can't find out the win7 API for adding a button on desktop.\nPlease some one tell me how to set a icon-button on the desktop, or it's just there's no such API?\nEDIT:\n    I just find that there are ways to make a window unmovable. So, I think now I need to find ways to make windows out of an icon. Then it'll looks like a button on desktop. And, there are ways to make windows taking some response when it's clicked(once), right?\nClosure:\n    Captain's method may be a better way for people with good understanding of windows. \n    I know python, but few knowledge of MFC or similar framework with deep relations with the OS itself. This desktop button creation is very hard to implement for me. \n    Modifying christian's script and a windows shortcut would be a not-good-looking compromise. I'll do it this way.","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":672,"Q_Id":16644007,"Users Score":-1,"Answer":"There is an easiest way.\nInstall VBest Icon groups. ( it is a desktop icon stack )\nThen select any stack and add a single button. ( drag and drop any application will get its link and icon in the stack )\nSelect the stack and in its settings, set transparency equals 0 ( slide to left)\nThat is it. Now you have a single button with link.","Q_Score":0,"Tags":"c++,python,windows,api","A_Id":66233621,"CreationDate":"2013-05-20T06:45:00.000","Title":"create an button on desktop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've recently discovered IronPython in C# and only tutorials I found were how to use python script in C#, but I've noticed, that IronPython has classes and methods you can use directly in C# like :  PythonIterTools.product some_pr = new PythonIterTools.product(); and others, can anyone explain how does this work?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":16646135,"Users Score":1,"Answer":"Parts of IronPython's standard library are implemented in C#, mainly because the equivalents in CPython are written in C. You can access those parts directly from a C# (or any other static .NET  language) directly, but they're not intended to be used that way and may not be easy to use.","Q_Score":0,"Tags":"c#,ironpython","A_Id":16652356,"CreationDate":"2013-05-20T09:11:00.000","Title":"Using IronPython in C#","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I\u2019m writing a cherrypy application that needs to redirect to a particular page and I use HTTPRedirect(\u2018mynewurl\u2019, status=303) to achieve this.  This works inasmuch as the browser (Safari) redirects to \u2018mynewurl\u2019 without asking the user.  However, when I attempt to unit test using nosetests with assertInBody(), I get a different result; assertInBody reports that \u2018This resource can be found at mynewurl\u2019 rather than the actual contents of \u2018mynewurl\u2019.  My question is how can I get nosetests to behave in the same way as a Safari, that is, redirecting to a page without displaying an \u2018ask\u2019 message?\nThanks\nKevin","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":190,"Q_Id":16652406,"Users Score":0,"Answer":"With python unit tests, you are basically testing the server. And the correct response from server is the redirect exception and not the redirected page itself. I would recommend you testing this behaviour in two steps:\n\ntest if the first page\/url throws correctly initialized (code, url) HTTPRedirect exception\ntest contents of the second page (on which is being redirected)\n\nBut of course, if you insist, you can resolve the redirect in Try\/Except by yourself by inspecting the exception attributes and calling testing method on target url again.","Q_Score":0,"Tags":"python,cherrypy,nose,nosetests","A_Id":16652717,"CreationDate":"2013-05-20T15:01:00.000","Title":"Unit testing Cherrypy HTTPRedirect.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working in python on a GAE app. Beautiful soup, which the app uses, works fine on my dev server locally. When I try and upload it to google's servers however, I get the following error: \"Error parsing yaml file: the library \"bs4\" is not supported\".\nI am not sure how to fix this. Does anyone have any idea?\nThank you.\nFile Structure:\napp.yaml\nmain.py\nstatic(DIR)\ntemplates(DIR)\nbs4(DIR)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1031,"Q_Id":16737386,"Users Score":0,"Answer":"It seems uploading the whole directory where the bs4 module resides in to the GAE app folder would work.","Q_Score":0,"Tags":"python,google-app-engine,beautifulsoup","A_Id":16737623,"CreationDate":"2013-05-24T14:29:00.000","Title":"Beautiful Soup \"not supported\" Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm currently developing a small application in Python with the use of GTK+ (and Glade). Everything has been fairly simple to integrate so far, until I came up with the idea to add tabs instead of pop-ups. Note: Still using Python 2.7+\nIs there any easy way to implement already existing pages inside a new tab(notebook) like structure? I'm having difficulties to find how to add content per separate tab created in glade. \nPerhabs a more 'clear' question: What Notebook function will be required to call a specific V\/HBox with every different tab? The current structure looks like (minus Menu \/ statusbar):\n[ mainWindow ] --> (1) mainOverview (gtkVbox) --> (2A) mainContent (gtkHbox) ... other non-related content\nThe structure I was hoping for would look like:\n[ mainWindow ] --> (1) mainOverview --> (2) noteBook --> (3) Tab1 --> (4) mainContent (gtkHbox) -- (3) Tab2 --> (4) secondaryContent (gtkHbox)\nThe application itself works fine (multithreaded, fully functioning) without the tabs, the mainContent(gtkHbox) contains a file\/recursive directory analyzer, a few checkboxes and a general overview. I was hoping for an easy way to display this main window (the gtkHbox) ONLY when having Tab1 selected.\nHaving difficulties to find good reference pages that display a proper way to call content pages per notebook tab. Any reference-pages or useful links are very much appreciated! Thanks so far! My apologies if this is a rather newbish question, I'm not new to Python coding, but interfaces on the other hand... ;)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1912,"Q_Id":16744702,"Users Score":1,"Answer":"Not an answer, but it looks like \"another.anon.coward\" already answered this in a comment...\n\nIf you double click on the tab, then that page is selected for adding content in glade. You can go ahead and add content for that page. As for switching you can use set_current_page to switch to page whose content you want to display. Register for \"switch-page\" signal to find out which page has been switched to.","Q_Score":6,"Tags":"python,gtk,glade","A_Id":22049793,"CreationDate":"2013-05-24T22:57:00.000","Title":"Python GTK (Glade) Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under: \n\/usr\/local\/lib\/python2.7\/site-packages\/ \nI think this is true because there is a IPython directory and ipython egg. \nHowever, when I type ipython in the terminal I get: \n-bash: ipython: command not found\nI do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add? \nCurrently, my .bashrc reads: \nPATH=$PATH:\/usr\/local\/bin\/\nThanks!","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":34234,"Q_Id":16745923,"Users Score":0,"Answer":"For me the only thing that helped was:\npython -m pip install --upgrade pip\nUpgrading pip did the work and all the installations started working properly!\nGive it a try.","Q_Score":22,"Tags":"macos,bash,command-line,terminal,ipython","A_Id":65625644,"CreationDate":"2013-05-25T02:45:00.000","Title":"IPython command not found Terminal OSX. Pip installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under: \n\/usr\/local\/lib\/python2.7\/site-packages\/ \nI think this is true because there is a IPython directory and ipython egg. \nHowever, when I type ipython in the terminal I get: \n-bash: ipython: command not found\nI do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add? \nCurrently, my .bashrc reads: \nPATH=$PATH:\/usr\/local\/bin\/\nThanks!","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":34234,"Q_Id":16745923,"Users Score":25,"Answer":"I had this issue too, the following worked for me and seems like a clean simple solution:\npip uninstall ipython\npip install ipython\nI'm running mavericks and latest pip","Q_Score":22,"Tags":"macos,bash,command-line,terminal,ipython","A_Id":22583681,"CreationDate":"2013-05-25T02:45:00.000","Title":"IPython command not found Terminal OSX. Pip installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under: \n\/usr\/local\/lib\/python2.7\/site-packages\/ \nI think this is true because there is a IPython directory and ipython egg. \nHowever, when I type ipython in the terminal I get: \n-bash: ipython: command not found\nI do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add? \nCurrently, my .bashrc reads: \nPATH=$PATH:\/usr\/local\/bin\/\nThanks!","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":34234,"Q_Id":16745923,"Users Score":0,"Answer":"After trying to a number of solutions like above with out joy, when I restarted my terminal, Ipython command launched. Don't forgot to restart your terminal after all the fiddling!\nP.S. I think the brew install Ipython did it ... but can't be sure.","Q_Score":22,"Tags":"macos,bash,command-line,terminal,ipython","A_Id":59742054,"CreationDate":"2013-05-25T02:45:00.000","Title":"IPython command not found Terminal OSX. Pip installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under: \n\/usr\/local\/lib\/python2.7\/site-packages\/ \nI think this is true because there is a IPython directory and ipython egg. \nHowever, when I type ipython in the terminal I get: \n-bash: ipython: command not found\nI do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add? \nCurrently, my .bashrc reads: \nPATH=$PATH:\/usr\/local\/bin\/\nThanks!","AnswerCount":7,"Available Count":4,"Score":0.057080742,"is_accepted":false,"ViewCount":34234,"Q_Id":16745923,"Users Score":2,"Answer":"I use pip3 install ipython is OK.\nmaybe ipython rely on python3","Q_Score":22,"Tags":"macos,bash,command-line,terminal,ipython","A_Id":59297333,"CreationDate":"2013-05-25T02:45:00.000","Title":"IPython command not found Terminal OSX. Pip installed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a dummy in web apps. I have a doubt regaring the functioning of apache web server. My question is mainly centered on \"how apache handles each incoming request\"\nQ: When apache is running in the mod_python\/mod_php mode, then does a \"fork\" happen for each incoming reuest? \n\nIf it forks in mod_php\/mod_python way, then where is the advantage over CGI mode, except for the fact that the forked process in mod_php way already contains an interpretor instance.\nIf it doesn't fork  each time, how does it actually handle each incoming request in the mod_php\/mod_python way. Does it use threads?\n\nPS: Where does FastCGI stands in the above comparison?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":459,"Q_Id":16747301,"Users Score":0,"Answer":"With a modern version of Apache, unless you configure it in prefork mode, it should run threaded (and not fork). mod_python is threadsafe, and doesn't require that each instance of it is forked into its own space.","Q_Score":4,"Tags":"apache,webserver,cgi,mod-python,mod-php","A_Id":21819195,"CreationDate":"2013-05-25T07:06:00.000","Title":"Does Apache really \"fork\" in mod_php\/python way for request handling?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a website with Django 1.5.1 and I have two doubts regarding concurrence. Now I'm runing on the development server.\n\nWhen multiple users access the website at the same time, by default, does Django run each request in a different execution thread? Or must it be configured in the webserver e.g. Apache?\nWill I experience issues if more than a user is modifying the same object concurrently? If so, how do you solve this problem? Using locks?\n\nThanks for your help!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1239,"Q_Id":16771391,"Users Score":4,"Answer":"Its webserver specific. If you configure it to run in different process, request will be handled in new process. If you configure to have threads it will be in threads.\nYes. Imagine case when, user1 is viewing\/editing a object A (retrieved from DB). user2 deletes that object. And then user1 tries to save it. You need to handle such cases explicitly in your code. \n\nMost likely the issues will be related to DB. So you can use transactions to help in some cases. \nIn some other cases, you can define strategy. E.g the case mentioned above, when user1 tries to save the object, and its not there in db you can just create one.","Q_Score":3,"Tags":"python,django,concurrency","A_Id":16771514,"CreationDate":"2013-05-27T10:42:00.000","Title":"Concurrency doubts in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a game in Python and was wondering how to give it its own icon.  I am using a windows computer and have no extra things installed with Python.  Oh also I am using version 3.3  Is this even possible.\nP.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":40170,"Q_Id":16782047,"Users Score":0,"Answer":"You can't. In Windows, custom icons can only be assigned to certain types of files (executables and shortcuts, mostly), and Python scripts are not one of those types.","Q_Score":7,"Tags":"python","A_Id":16782089,"CreationDate":"2013-05-28T00:04:00.000","Title":"How To Add An Icon Of My Own To A Python Program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a game in Python and was wondering how to give it its own icon.  I am using a windows computer and have no extra things installed with Python.  Oh also I am using version 3.3  Is this even possible.\nP.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh","AnswerCount":7,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":40170,"Q_Id":16782047,"Users Score":2,"Answer":"If you are trying to change the icon of the shortcut for your program,\n\nthen you need to get to the file where ever it is right-click it and go to create a shortcut\n\nthen drag that shortcut to your desktop\n\nthen right-click that shortcut and click properties\n\nthen click on \"Change Icon\"\n\nthen go to where your desire .ico image is saved and set that as the icon\n\n\nif you do this and you open your program in the corner will be the .ico you selected and on your desktop, it will show the icon instead of the python image.\nthat is how you change the shortcut icon but there is no way to change the actual window icon in the corner unless you're using something like Tk or Pygame.","Q_Score":7,"Tags":"python","A_Id":16782121,"CreationDate":"2013-05-28T00:04:00.000","Title":"How To Add An Icon Of My Own To A Python Program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need a field which adds a counter to a specific item i add in the product section of a custom module. \nLike an automatic number generated by the system, for let's say Internal Reference, so every time i save a new product this field will create a number for it in this field, like IN0001, IN0002, IN0003, etc...\nI've looked into the internet, searching for some example on how to achieve this in OpenErp but no luck.\nIs there any module or already made function in OpenErp which has this behavior?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":171,"Q_Id":16784271,"Users Score":1,"Answer":"there is a model called 'ir.sequence'. You can create a sequence type and sequence  for your model and then just by calling the code of the sequence you will be able to generate new sequences","Q_Score":0,"Tags":"python,orm,module,openerp","A_Id":16789456,"CreationDate":"2013-05-28T05:09:00.000","Title":"Counter in OpenErp - Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a simple pyparsing construct for extracting parts of a log message. It looks like this\nlog_line = timestamp + task_info + Suppress(LineEnd())\nThis construct parses a log file generated in Linux very well but doesn't parse a similar file generated in windows. I am pretty sure it is because of the new line representation difference. I was wondering if LineEnd() takes care of that? If it doesn't how do I take care of it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":147,"Q_Id":16820895,"Users Score":1,"Answer":"Try Suppress(\"\\r\\n\") instead of Suppress(LineEnd())","Q_Score":1,"Tags":"python,pyparsing","A_Id":16822978,"CreationDate":"2013-05-29T18:03:00.000","Title":"pyparsing not working on windows text file but works on linux text file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Today I upgraded to Xubuntu 13.04 which comes with Python 3.3. Before that, I was working with Pyton 3.2, which was working perfectly fine.\nWhen running my script under Python 3.3, I get an\n\nImportError: No module named 'pylab'\n\nin import pylab.\nRunning in Python 3.2, which I reinstalled, throws\n\nImportError: cannot import name multiarray\n\nin import numpy.\nScipy, numpy and matplotlib are, recording to apt, on the newest version.\nI don't have much knowledge about this stuff. Do you have any recommendations on how to get my script to work again, preferably on Python 3.2?\nThanks in advance,\nKatrin\nEdit:\nWe solved the problem: Apparently, there where a lot of fragments \/ pieces of the packages in different paths, as I installed from apt, pip as well as manually. After deleting all packages and installing them only via pip, everything works fine. Thank you very much for the help!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":312,"Q_Id":16820903,"Users Score":1,"Answer":"I suspect you need to install python3-matplotlib, python3-numpy, etc.  python-matlab is the python2 version.","Q_Score":1,"Tags":"python,matplotlib,python-3.3","A_Id":16823062,"CreationDate":"2013-05-29T18:04:00.000","Title":"Pylab after upgrading","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. \nSo far I see my only option is as follows...\nCopy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad!\nSo, how do other handle this? What options do I have?\nCan my models be shared somehow?","AnswerCount":4,"Available Count":3,"Score":0.1488850336,"is_accepted":false,"ViewCount":134,"Q_Id":16846391,"Users Score":3,"Answer":"For this to be meaningful, you likely need to connect to the same database\nWhy would you need two codebases? You have two copies of a single codebase.","Q_Score":2,"Tags":"python,django,web-applications","A_Id":16846436,"CreationDate":"2013-05-30T21:45:00.000","Title":"Does a Django site with a Tastypie interface need two codebases?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. \nSo far I see my only option is as follows...\nCopy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad!\nSo, how do other handle this? What options do I have?\nCan my models be shared somehow?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":134,"Q_Id":16846391,"Users Score":1,"Answer":"Why don't you run the api on the same server on a different port? that will save you a lot of problems to start with. Sharing database connections cross servers will likely require you to think about security, a lot.\nAlso if you are reusing the same apps in different projects you might want to package and version your apps for comfort. Think about the real problem you are trying to solve and always keep that in mind. There are plenty of solutions for every problem, finding the right one makes a difference.","Q_Score":2,"Tags":"python,django,web-applications","A_Id":16846450,"CreationDate":"2013-05-30T21:45:00.000","Title":"Does a Django site with a Tastypie interface need two codebases?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. \nSo far I see my only option is as follows...\nCopy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad!\nSo, how do other handle this? What options do I have?\nCan my models be shared somehow?","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":16846391,"Users Score":2,"Answer":"I wouldn't recommend splitting your project like this. \nEvery time you edit a model you have to edit it on both immediately or risk things getting out of sync. This will get very very painful, instead;\nIs the server the bottleneck? Split site and api machines (but using the same models.py) and share the connection to the DB somewhere. \nIs the DB the bottleneck? Scale up the DB to a faster machine \/ cluster and use the same site for  to supply web and api. \nEither way, One codebase, One set of models, One DB!","Q_Score":2,"Tags":"python,django,web-applications","A_Id":16855093,"CreationDate":"2013-05-30T21:45:00.000","Title":"Does a Django site with a Tastypie interface need two codebases?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that.\nCan anyone help?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":653,"Q_Id":16846967,"Users Score":1,"Answer":"Well, you could have the Android Application save the image to a folder and have the Python file import that image.","Q_Score":1,"Tags":"android,python,sockets,tcp","A_Id":16847185,"CreationDate":"2013-05-30T22:37:00.000","Title":"Connect Android to Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that.\nCan anyone help?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":653,"Q_Id":16846967,"Users Score":-1,"Answer":"You can upload a image to server using any of the database, use python code on server side and you will get the result.","Q_Score":1,"Tags":"android,python,sockets,tcp","A_Id":36057987,"CreationDate":"2013-05-30T22:37:00.000","Title":"Connect Android to Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently involved in a project where we performed some computer vision object recognition and classification using python. It is necessary to use photos taken from an Android phone (photos should be automatically sent from android to python). I actually don't know how should I connect both applications (android and python) together. I thought of using TCP Server, but I am new to socket programming and don't know how and where to start.\nAny one can help?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":780,"Q_Id":16867749,"Users Score":0,"Answer":"poof's answer is a good overview, but here are some notes on the various options:\nOption 1: Have your Android get the picture and do a HTTP POST to a Python application running a framework such as Django.  It should be 1 line of code on Android, and only a few lines of code on Python (around your existing code).\nThe upside is that the low-level \"Glue\" is written for you, and it scales easily. The downside is that HTTP has some overhead.\nOption 2: Have your Android talk a custom TCP protocol to a custom TCP application.\nThis is more work, so you should avoid it unless you need it. It will be more efficient and have lower latency, especially if you're sending multiple pictures. The response can also be much smaller without HTTP headers.\nIn either option, you don't have to send a JPEG, you could send any custom format you want (there is a trade-off between compression on Android and size of file).\n\nI thought of using TCP Server, but I am new to socket programming and don't know how and where to start.\n\nStart where everyone else started - by reading a lot and playing a lot. You can find plenty of introductions to Socket programming in Python on the web. Go thru the tutorials, and start modifying them to see how they work.  Read up on TCP\/IP itself -- there are a lot of dark corners (Nagel, fragmentation, slow start) that can affect how you write the app when you get to a low level.","Q_Score":0,"Tags":"android,python,sockets,tcp","A_Id":16868676,"CreationDate":"2013-06-01T00:15:00.000","Title":"Tcp\/IP socket programming in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to represent instances of Python \"Long integer\" in MySQL. I wonder what the most appropriate SQL data type I should use.\nThe Python documentation (v2.7) says (for numbers.Integral):\n\nLong integers\n\nThese represent numbers in an unlimited range, subject to available (virtual) memory only. For the purpose of shift and mask operations, a binary representation is assumed, and negative numbers are represented in a variant of 2\u2019s complement which gives the illusion of an infinite string of sign bits extending to the left.\n\n\nMy read of the MySQL documentation suggests that BIGINT is limited to 64 bits. The DECIMAL type seems to be limited to 65 digits. I can, of course, use BLOB.\nThe application needs to support very large amounts of data, but I don't know yet how big these long integers might get, nor how many of them I'm likely to see.\nI'd like to preserve the spirit of the Python long integer definition, which suggests BLOB. I'd also like to avoid re-inventing the wheel, and so I am appealing to the stackoverflow hive-mind.\nSuggestions?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":1333,"Q_Id":16867823,"Users Score":3,"Answer":"Yes if you really need unlimited precision then you'll have to use a blob because even strigns are limited. \nBut really I can almost guarantee that you'll be fine with a NUMERIC\/DECIMAL data type. 65 digits means that you can represent numbers in the range (-10^65, 10^65). How large is this? To give you some idea: The number of atoms in the whole universe is estimated to be about 10^80. If you only need positive numbers you can further increase the range by a factor of 2 by subtracting 10^65 -1 beforehand.","Q_Score":2,"Tags":"python,mysql,mysql-python","A_Id":16867914,"CreationDate":"2013-06-01T00:26:00.000","Title":"What are the options for storing Python long integers in MySQL?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to python and pycharm and I'd like to run a module from the pycharm console in the same way as you can from IDLE, if it's possible.\nThe idea is to create simple functions and test them \"live\" using the console.\n...how do you do that in pycharm?","AnswerCount":9,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":69594,"Q_Id":16874046,"Users Score":17,"Answer":"For anyone still having this problem: Go to the Run\/Debug menu, choose Edit Configuration, check the box 'Show command line' this will enable you to enter parameters in the console at the >>> prompt and test your function. \nEdit: To make this change apply to all your .py files (as this check box only applies to the current file you're working on) go to: Edit configuration, in the pop up you will see a menu tree on the left, select Defaults, then Python, then check the 'Show command line' box, this will make it the default setting whenever you open a .py file, (this feature should really be on by default!)","Q_Score":25,"Tags":"python,console,pycharm","A_Id":29418064,"CreationDate":"2013-06-01T15:04:00.000","Title":"Running a module from the pycharm console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to python and pycharm and I'd like to run a module from the pycharm console in the same way as you can from IDLE, if it's possible.\nThe idea is to create simple functions and test them \"live\" using the console.\n...how do you do that in pycharm?","AnswerCount":9,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":69594,"Q_Id":16874046,"Users Score":3,"Answer":"Select the script lines that you want to execute and press Shift+Alt+E","Q_Score":25,"Tags":"python,console,pycharm","A_Id":27771551,"CreationDate":"2013-06-01T15:04:00.000","Title":"Running a module from the pycharm console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to use gridsearch CV with multiple jobs via the n_jobs argument and I can see using htop that they're all launched and running but they all get stuck\/assigned on the same core using 25% each (I'm using a 4 core machine). I'm on Ubuntu 12.10 and I'm running the latest master pulled from github. Anyone know how to fix this?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":16877448,"Users Score":2,"Answer":"Found it, there's a note on the svm page that if you enable verbose settings multiprocessing may break. Disabling verbose fixed it","Q_Score":1,"Tags":"python,scikit-learn","A_Id":16877799,"CreationDate":"2013-06-01T21:29:00.000","Title":"Scikit-Learn n_jobs Multiprocessing Locked To One Core","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Anyone knows what this error is and how to fix it?\nI've already tried to \nchmod -R 777 \/usr\/local\/python2.6\/dist-packages\/joblib but with no luck.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":776,"Q_Id":16893882,"Users Score":0,"Answer":"You need to change the permissions for the directory the process wants to write to. Find out what directory joblib wants to put things in and change its permissions or use a different directory with the needed permissions for this. In order to be able to give the permissions and to allow Python to write to the filesystem, it must be mounted in a way that allows writing.","Q_Score":0,"Tags":"python,python-module","A_Id":16894057,"CreationDate":"2013-06-03T09:43:00.000","Title":"\/usr\/local\/lib\/python2.6\/dist-packages\/joblib\/parallel.py:40: UserWarning: [Errno 30] Read-only file system. joblib will operate in serial mode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm writing a single view Javascript application with a Django backend that only needs to return the initial index.html and all other templates come from a CDN. My problem is that this first index.html file is parsing out some of my \"{{}}\" handlebars which I wanted to leave for the JS library to interpret.\nI DO NOT want to use 'verbatim' or 'raw' or any additional tags because I don't want any django specific stuff in my static template files.\nA possible alternative answer to this would be desmonstrating how to to make your inital index HTML response also come from the CDN but I didn't think that was possible.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":2717,"Q_Id":16900215,"Users Score":4,"Answer":"If you don't want to render a template, simply don't render it. Django won't render anything unless you specifically call template.render or one of the shortcuts.\nIf you just want to return an HTML file, you could just open it as a normal file, read it, then return the content as the response.\nAlternatively, as suggested in the comment, you can serve it as a static file.","Q_Score":2,"Tags":"python,django,javascriptmvc","A_Id":16900507,"CreationDate":"2013-06-03T15:20:00.000","Title":"Django return .html file directly without parsing for template tags at all","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python is a relatively new language for me and I already see some of the trouble areas of maintaining a scripting language based project. I am just wondering how the larger community , with a scenario when one has to maintain a fairly large code base written by people who are not around anymore, deals with the following situations:\n\nReturn type of a function\/method. Assuming past developers didn't document the code very well, this is turning out to be really annoying as I am basically reading code line by line to figure out what a method\/function is suppose to return.\nCode refactoring: I figured a lot of code need to be moved around, edited\/deleted and etc. But lot of times simple errors, which would otherwise be compile time error in other compiled languages e.g. -  wrong number of arguments, wrong type of arguments, method not present and etc, only show up when you run the code and the code reaches the problematic area. Therefore, whether a re-factored code will work at all or not can only be known once you run the code thoroughly. I am using PyLint with PyDev but still I find it very lacking in this respect.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":16915118,"Users Score":0,"Answer":"Others have already mentioned documentation and unit-testing as being the main tools here. I want to add a third: the Python shell. One of the huge advantages of a non-compiled language like Python is that you can easily fire up the shell, import your module, and run the code there to see what it does and what it returns.\nLinked to this is the Python debugger: just put import pdb;pdb.set_trace() at any point in your code, and when you run it you will be dropped into the interactive debugger where you can inspect the current values of the variables. In fact, the pdb shell is an actual Python shell as well, so you can even change things there.","Q_Score":0,"Tags":"python,scripting","A_Id":16915630,"CreationDate":"2013-06-04T10:09:00.000","Title":"checking\/verifying python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Python is a relatively new language for me and I already see some of the trouble areas of maintaining a scripting language based project. I am just wondering how the larger community , with a scenario when one has to maintain a fairly large code base written by people who are not around anymore, deals with the following situations:\n\nReturn type of a function\/method. Assuming past developers didn't document the code very well, this is turning out to be really annoying as I am basically reading code line by line to figure out what a method\/function is suppose to return.\nCode refactoring: I figured a lot of code need to be moved around, edited\/deleted and etc. But lot of times simple errors, which would otherwise be compile time error in other compiled languages e.g. -  wrong number of arguments, wrong type of arguments, method not present and etc, only show up when you run the code and the code reaches the problematic area. Therefore, whether a re-factored code will work at all or not can only be known once you run the code thoroughly. I am using PyLint with PyDev but still I find it very lacking in this respect.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":16915118,"Users Score":0,"Answer":"You are right, that's an issue with dynamically typed interpreted languages.\nThere are to important things that can help:\n\nGood documentation\nExtensive unit-testing.\n\nThey apply to other languages as well of course, but here they are especially important.","Q_Score":0,"Tags":"python,scripting","A_Id":16915300,"CreationDate":"2013-06-04T10:09:00.000","Title":"checking\/verifying python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"GDB 7.2 python doesn't have gdb.Type.iteritems method. Anyway I can access the members of the anonymous structure (which is within another structure of course) from gdb 7.2 ? The assumption is that I dont know know the name of the members of the anonymous structure or else I could have done gdb.parse_and_eval on them.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":267,"Q_Id":16951821,"Users Score":1,"Answer":"I think you can use Type.fields to iterate over the fields.\nThen, you can look at the field offset and you can compute a pointer to the anonymous field, along the lines of (type *) (((char *) obj) + offset).\nThis isn't ideal.  There is a bug open to implement something better.","Q_Score":1,"Tags":"python,gdb","A_Id":16952566,"CreationDate":"2013-06-06T00:09:00.000","Title":"GDB 7.2 + python: how to get members of anonymous structure?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made an object controlled with arrow keys. When I move it to the edge of the pygame screen, the object moves off the screen. I was wondering how to keep the object on the screen. Any suggestions?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":364,"Q_Id":16952059,"Users Score":1,"Answer":"On each handle of the input, check if the object's target x position plus its width exceeds the width of the canvas or if it is less than 0. Deny the movement if so. \nRepeat for the y coordinate and the height.","Q_Score":0,"Tags":"python,pygame","A_Id":16952066,"CreationDate":"2013-06-06T00:47:00.000","Title":"In pygame how to make an object controlled with arrow keys not move of the edge of the screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a >100,000 urls (different domains) in a list that I want to download and save in a database for further processing and tinkering.\nWould it be wise to use scrapy instead of python's multiprocessing \/ multithreading? If yes, how do I write a standalone script to do the same?\nAlso, feel free to suggest other awesome approaches that come to your mind.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1273,"Q_Id":16957276,"Users Score":0,"Answer":"Scrapy is still an option.\n\nSpeed\/performance\/efficiency\n\nScrapy is written with Twisted, a popular event-driven networking\n  framework for Python. Thus, it\u2019s implemented using a non-blocking (aka\n  asynchronous) code for concurrency.\n\nDatabase pipelining\nYou mentioned that you want your data to be pipelined into the database - as you may know Scrapy has Item Pipelines feature:\n\nAfter an item has been scraped by a spider, it is sent to the Item\n  Pipeline which process it through several components that are executed\n  sequentially.\n\nSo, each page can be written to the database immediately after it has been downloaded.\nCode organization\nScrapy offers you a nice and clear project structure, there you have settings, spiders, items, pipelines etc separated logically. Even that makes your code clearer and easier to support and understand.\nTime to code\nScrapy does a lot of work for you behind the scenes. This makes you focus on the actual code and logic itself and not to think about the \"metal\" part: creating processes, threads etc.\n\nBut, at the same time, Scrapy might be an overhead. Remember that Scrapy was designed (and great at) to crawl, scrape the data from the web page. If you want just to download a bunch of pages without looking into them - then yes, grequests is a good alternative.","Q_Score":5,"Tags":"python,multithreading,multiprocessing,scrapy,web-crawler","A_Id":16961651,"CreationDate":"2013-06-06T08:32:00.000","Title":"What is the best way to download  number of pages from a list of urls?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"If I want to craw a circle, I use the regualr draw.circle but the problem is that I don't want it filled so I draw a smaller circle inside of it, it makes a circle with thickness.\nEverything is good right? no. The background image inside that circle disappeared because the circles are filled.\nNow my question is: There is a function that draws a circle (and other shapes[?]) that gets thick and not filling the whole inside of the shape?\nEDIT: If you can give me the signature so I know how to use it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9645,"Q_Id":16994243,"Users Score":5,"Answer":"The command is pygame.draw.circle(Surface, color, pos, radius, width=0).  The last argument of width can be changed to not fill the circle in.  If it is zero, the circle is solid and if it is anything else it is with an edge thickness of whatever the parameter is.","Q_Score":1,"Tags":"python,pygame,draw","A_Id":17000916,"CreationDate":"2013-06-07T23:13:00.000","Title":"pygame not filled shapes (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running a Python code that reads a list of URLs and opens each one of them individually with urlopen. Some URLs are repeated in the list. An example of the list would be something like:\n\nwww.example.com\/page1 \nwww.example.com\/page1\nwww.example.com\/page2\nwww.example.com\/page2\nwww.example.com\/page2\nwww.example.com\/page3\nwww.example.com\/page4\nwww.example.com\/page4\n[...]\n\nI would like to know if there's a way to implement a counter that would tell me how many times a unique URL was opened previously by the code. I want to get a counter that would return me what is showed in bold for each of the URLs in the list.\n\nwww.example.com\/page1 : 0 \nwww.example.com\/page1 : 1 \nwww.example.com\/page2 : 0 \nwww.example.com\/page2 : 1 \nwww.example.com\/page2 : 2 \nwww.example.com\/page3 : 0\nwww.example.com\/page4 : 0 \nwww.example.com\/page4 : 1 \n\nThanks!","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":1310,"Q_Id":16995007,"Users Score":-2,"Answer":"i think you can't do it that way.\nDelete duplicates in list.","Q_Score":0,"Tags":"python,counter,urlopen","A_Id":16995022,"CreationDate":"2013-06-08T01:09:00.000","Title":"How to count the number of time a unique URL is open in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been writing a Python web app (in Flask) for a while now, and I don't believe I fully grasp how database access should work across multiple request\/response cycles. Prior to Python my web programming experience was in PHP (several years worth) and I'm afraid that my PHP experience is misleading some of my Python work.\nIn PHP, each new request creates a brand new DB connection, because nothing is shared across requests. The more requests you have, the more connections you need to support. However, in a Python web app, where there is shared state across requests, DB connections can persist.\nSo I need to manage those connections, and ensure that I close them. Also, I need to have some kind of connection pool, because if I have just one connection shared across all requests, then requests could block waiting on DB access, if I don't have enough connections available.\nIs this a correct understanding? Or have I identified the differences well? In a Python web app, do I need to have a DB connection pool that shares its connections across many requests? And the number of connections in the pool will depend on my application's request load?\nI'm using Psycopg2.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":351,"Q_Id":17012349,"Users Score":4,"Answer":"Have you looked in to SQLAlchemy at all?  It takes care of a lot of the dirty details - it maintains a pool of connections, and reuses\/closes them as necessary.","Q_Score":4,"Tags":"python,psycopg2","A_Id":17012369,"CreationDate":"2013-06-09T17:36:00.000","Title":"Database access strategy for a Python web app","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating my own python module that has some functions I want to use. I wanna know how to do these things:\n\nHow do I proceed with my python module called module.py, so I import only the functions I want, when calling 'import module.function'? (so I don't have to import the entire module)\nDoes I always have to create a class for my functions, even if I would never use more than ONE object of that class? (if not, how to create a function that has all the self variables inside, so them don't mess up with global variables from the entire code?) (but without use def fun(self, var1, var2...) because I don't want to call fun(\"\", var1, var2...) \nIs it better to 'install' my module or use it like a external file?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":382,"Q_Id":17013738,"Users Score":1,"Answer":"You don't necessarily have to create a class in python, but the use of classes would help you wrap up functions and variables into an object.","Q_Score":2,"Tags":"python,python-3.x","A_Id":17013917,"CreationDate":"2013-06-09T20:13:00.000","Title":"Creating my own python module - questions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to implement this in django: In a video site, for every video a user want to watch he\/she must pay a fee before watching the video. If it's possible, what's the best way to implement this. And after every successful payment, how can the user be redirected back to the particular video he paid for?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":17021318,"Users Score":3,"Answer":"You can do everything web with Django just like with any other webframework\/weblibrary.\nProbably the easiest way would be to have a user-profile, and as soon as the payment has been working out you add this video to the users \"allowed\" list. This makes it quite easy to show the users available videos.\nThe redirection thing after payment really depends on your provider, paypal and others allow you to embed their payment process into your application, and have powerful APIs to check for \"incoming\" payments.","Q_Score":0,"Tags":"python,django","A_Id":17021455,"CreationDate":"2013-06-10T10:03:00.000","Title":"Pay Per Request in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Is it possible to implement this in django: In a video site, for every video a user want to watch he\/she must pay a fee before watching the video. If it's possible, what's the best way to implement this. And after every successful payment, how can the user be redirected back to the particular video he paid for?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":17021318,"Users Score":0,"Answer":"I believe this is possible. \nWhat you can do is have a check on your video page for a certain receipt that you can add as an entry in the UserProfile model that you'll have for your django website. \nNow this receipt will only be generated when your user goes through the complete payment path which you can handle by scripts.\nAnd as for redirection, you can have the payment processing service redirect to your receipt token generating django view that handles the addition of the user to your whitelist for that video.","Q_Score":0,"Tags":"python,django","A_Id":17021565,"CreationDate":"2013-06-10T10:03:00.000","Title":"Pay Per Request in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using python 2.6, ipython 0.12.1, tornado 3.02, pyzmq 13.1 , I am getting this error when I start ipython notebook. \n\"Websocket connection cannot be made\" \nIn the ipython console window I get torado.application error , in line 183 in create_shell_stream\nshell_stream = self.create_connected_stream(ip.....,zmq.XREQ)\nerror is \"module\" object has no attribute 'XREQ'\nDo you know what's wrong? and how can I fix this error?\nI installed ipython, tornado and pyzmq seperate and not from easy_install or pip.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":494,"Q_Id":17030589,"Users Score":1,"Answer":"For those who end up on this page, here's the solution. This is happening because your OS package manager (in my case 12.04) is lagging pypi in python packages - but not in core libraries (like zeromq).\nTo solve this, my recommended solution is to install python-pandas using your package manager, but also install systemwide \"pip\". and then run \"sudo pip install --upgrade ipython,pandas\"\nthis should get everything back in sync.","Q_Score":1,"Tags":"ipython-notebook","A_Id":17628850,"CreationDate":"2013-06-10T18:41:00.000","Title":"Ipython - Notebook error: Tornado.application : \"Module\" object has no attribute 'XREQ'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm developing on GAE-Python 2.7 using Eclipse+PyDev as IDE. Since GAE SDK 1.7.6 (March 2013), where Google \"broke\" support for breakpoints*, I've been using the old dev server to continue debugging the application I'm working on. \nHowever, Google will drop support of the old dev server as of July 2013 and, since I do not expect a prompt solution for this on PyDev (I've seen no activity so far about this), I would like to look for an alternative IDE to still being able to do debugging. \nI know that one of the possible options is to go for PyCharm (initial license of 89\u20ac+VAT and 59\u20ac+VAT each year to continue receiving upgrades), but I would like to know how other people is (will be) addressing this problem and what are the current alternatives to PyCharm\n*I would like to clarify the sentence \"Google broke support for breakpoints\": In SDK 1.7.6+, Google started using stdin\/stdout in the new dev server for doing IPC and this leaves no chances to even do debugging with pdb. Google claims that they have created the hooks for tool vendors to support debugging (as PyCharm did) but, in my opinion, they \"broke\" debugging by forcing people to move away from the IDE they were initially recommending due to an architectural decision (I'm not an expert, but they could have used the native IPC mechanisms included in Python instead of using stdin\/stdout). \nEDIT:\nI forgot to mention that I'm running Eclipse+Pydev for MacOSX, so please, also mention your OS compatibility in your alternatives\/solutions.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":927,"Q_Id":17040209,"Users Score":0,"Answer":"The latest version of PyDev (2.8.1) supports GAE debugging. However, \"Edit and Continue Debugging or Interactive Debugging\" feature seems to have stopped working.","Q_Score":2,"Tags":"python,google-app-engine,debugging,ide,breakpoints","A_Id":18138699,"CreationDate":"2013-06-11T09:01:00.000","Title":"Alternative IDE supporting debugging for Google App Engine in Python (Eclipse + PyDev no debug support on SDK 1.7.6+)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Inside emacs I am running interpreters for several different languages (python, R, lisp, ...). When I run the interpreters through the terminal in most cases I can use the up arrow to see the last command or line of code that I entered. I no longer have this functionality when I am running the interpreters in emacs. How can I achieve this functionality?\n\nHow can I access the command history from the interpreter inside emacs?\nCan I do this generally for language X?\n\nAt the moment I need to use python, so if anyone knows how to do this specifically with the python interpreter in emacs please let me know!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1865,"Q_Id":17046929,"Users Score":0,"Answer":"AFAIS the keys are the same as in M-x shell. See menu In\/Out for available keys\/commands.","Q_Score":12,"Tags":"python,emacs,command,interpreter","A_Id":17047535,"CreationDate":"2013-06-11T14:41:00.000","Title":"Command history in interpreters in emacs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following situation: I am working on several projects which make use of library modules that I have written. The library modules contain several classes and functions. In each project, some subset of the code of the libraries is used.\nHowever, when I publish a project for other users, I only want to give away the code that is used by that project rather than the whole modules. This means I would like, for a given project, to remove unused library functions from the library code (i.e. create a new reduced library). Is there any tool that can do this automatically?\nEDIT\nSome clarifications\/replies:\n\nRegarding the \"you should not do this in general\" replies: The bottom line is that in practice, before I publish a project, I manually go through the library modules and remove unused code. As we are all programmers, we know that there is no reason to do something manually when you could easily explain to a computer how to do it. So practically, writing such a program is possible and should even not be too difficult (yes, it may not be super general). My question was if someone know whether such a tool exists, before I start thinking about implementing it by myself. Also, any thoughts about implementing this are welcome.\nI do not want to simply hide all my code. If I would have wanted to do that I would have probably not used Python. In fact, I want to publish the source code, but only the code which is relevant to the project in question.\nRegarding the \"you are legally protected\" comments: In my specific case, the legal\/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use\/develop the code, you don't want dozens of irrelevant functions to be included.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":755,"Q_Id":17087758,"Users Score":-1,"Answer":"If your purpose is to not give away code, then just distribute the python-compiled library, rather than the source code for it. No need to manually weed code calls, just distribute the pyc versions of your files. If you're afraid that people will take your code and not give you credit, don't give them code if there is an alternative.\nThat said, we have licenses for a reason. You put the minimal header and your attribution at the top of every file, and you distribute a LICENSE file with your software that clearly indicates what people are, and are not, allowed to do with your source code. If they violate that, and you catch them, you now have legal recourse. IF you don't trust people to uphold that license: that's the whole reason it's there. If your code is so unique that it needs to be licensed for fear of others passing it off as their own, it will be easy to find infractions. If, however, you treat all your code like this, a small reality check: you are not that good. Almost nothing you write will be original enough that others haven't already also written it, trying to cling to it is not going to benefit you, or anyone else.\nBest code protection? Stick it online for everyone to see, so that you can point everyone else to it and go \"see? that's my code. And this jerk is using it in their own product without giving me credit\". Worse code protection, but still protection: don't distribute code, distribute the compiled libraries. (Worst code protect: distributing gimped code because you're afraid of the world for the wrong reasons)","Q_Score":13,"Tags":"python","A_Id":17089367,"CreationDate":"2013-06-13T13:02:00.000","Title":"Is there a tool that removes functions that are not used in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following situation: I am working on several projects which make use of library modules that I have written. The library modules contain several classes and functions. In each project, some subset of the code of the libraries is used.\nHowever, when I publish a project for other users, I only want to give away the code that is used by that project rather than the whole modules. This means I would like, for a given project, to remove unused library functions from the library code (i.e. create a new reduced library). Is there any tool that can do this automatically?\nEDIT\nSome clarifications\/replies:\n\nRegarding the \"you should not do this in general\" replies: The bottom line is that in practice, before I publish a project, I manually go through the library modules and remove unused code. As we are all programmers, we know that there is no reason to do something manually when you could easily explain to a computer how to do it. So practically, writing such a program is possible and should even not be too difficult (yes, it may not be super general). My question was if someone know whether such a tool exists, before I start thinking about implementing it by myself. Also, any thoughts about implementing this are welcome.\nI do not want to simply hide all my code. If I would have wanted to do that I would have probably not used Python. In fact, I want to publish the source code, but only the code which is relevant to the project in question.\nRegarding the \"you are legally protected\" comments: In my specific case, the legal\/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use\/develop the code, you don't want dozens of irrelevant functions to be included.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":755,"Q_Id":17087758,"Users Score":1,"Answer":"I agree with @zmo - one way to avoid future problems like this is to plan ahead and make your code as modular as possible. I would have suggested putting the classes and functions in much smaller files. This would mean that for every project you make, you would have to hand-select which of these smaller files to include. I'm not sure if that's feasible with the size of your projects right now. But for future projects it's a practice you may consider.","Q_Score":13,"Tags":"python","A_Id":17096348,"CreationDate":"2013-06-13T13:02:00.000","Title":"Is there a tool that removes functions that are not used in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to get the raw query string or a list of query string parameters in Flask?\nI know how to get query string parameters with request.args.get('key'), but I would like to be able to take in variable query strings and process them myself. Is this possible?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":4634,"Q_Id":17093372,"Users Score":5,"Answer":"request.query_string also seems to work.","Q_Score":6,"Tags":"python,flask,query-string","A_Id":21792010,"CreationDate":"2013-06-13T17:27:00.000","Title":"Get raw query string in flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have multiple minecraft servers running on the machine. servers are started with bat files that have according titles. My question is that, how can i shut down a certain minecraft server with python? Or how to kill a titled cmd.exe process with python?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1744,"Q_Id":17113591,"Users Score":0,"Answer":"I would look at the tools in the os module, it would also help if i had more information about what operating system you are using.","Q_Score":0,"Tags":"python,cmd,shutdown,minecraft","A_Id":17114583,"CreationDate":"2013-06-14T16:55:00.000","Title":"How to shut down a minecraft server with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have multiple minecraft servers running on the machine. servers are started with bat files that have according titles. My question is that, how can i shut down a certain minecraft server with python? Or how to kill a titled cmd.exe process with python?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1744,"Q_Id":17113591,"Users Score":0,"Answer":"I ended up using autohotkey. launched autohotkey with python and made separate  .ahk files for every server.","Q_Score":0,"Tags":"python,cmd,shutdown,minecraft","A_Id":17331529,"CreationDate":"2013-06-14T16:55:00.000","Title":"How to shut down a minecraft server with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been researching RBMs for a couple months, using Python along the way, and have read all your papers. I am having a problem, and I thought, what the hey? Why not go to the source? I thought I would at least take the chance you may have time to reply.\nMy question is regarding the Log-Likelihood in a Restricted Boltzmann Machine. I have read that finding the exact log-likelihood in all but very small models is intractable, hence the introduction of contrastive divergence, PCD, pseudo log-likelihood etc. My question is, how do you find the exact log-likelihood in even a small model? \nI have come across several definitions of this formula, and all seem to be different. In Tielemen\u2019s 2008 paper \u201cTraining Restricted Boltzmann Machines using Approximations To the Likelihood Gradient\u201d, he performs a log-likelihood version of the test to compare to the other types of approximations, but does not say the formula he used. The closest thing I can find is the probabilities using the energy function over the partition function, but I have not been able to code this, as I don\u2019t completely understand the syntax.\nIn Bengio et al \u201cRepresentation Learning: A Review and New Perspectives\u201d, the equation for the log-likelihood is:\n sum_t=1 to T (log P(X^T, theta)) \nwhich is equal to sum_t=1 to T(log * sum_h in {0,1}^d_h(P(x^(t), h; theta))\n where T is training examples. This is (14) on page 11. \nThe only problem is that none of the other variables are defined. I assume x is the training data instance, but what is the superscript (t)? I also assume theta are the latent variables h, W, v\u2026 But how do you translate this into code?\nI guess what I\u2019m asking is can you give me a code (Python, pseudo-code, or any language) algorithm for finding the log-likelihood of a given model so I can understand what the variables stand for? That way, in simple cases, I can find the exact log-likelihood and then compare them to my approximations to see how well my approximations really are.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1642,"Q_Id":17113613,"Users Score":0,"Answer":"Assume you have v visible units, and h hidden units, and v < h.  The key idea is that once you've fixed all the values for each visible unit, the hidden units are independent. \nSo you loop through all 2^v subsets of visible unit activations.  Then computing the likelihood for the RBM with this particular activated visible subset is tractable, because the hidden units are independent[1].  So then loop through each hidden unit, and add up the probability of it being on and off conditioned on your subset of visible units.  Then multiply out all of those summed on\/off hidden probabilities to get the probability that particular subset of visible units.  Add up all subsets and you are done.\nThe problem is that this is exponential in v.  If v > h, just \"transpose\" your RBM, pretending the hidden are visible and vice versa.\n[1] The hidden units can't influence each other, because you influence would have to go through the visible units (no h to h connections), but you've fixed the visible units.","Q_Score":0,"Tags":"python,machine-learning,artificial-intelligence,neural-network","A_Id":17117416,"CreationDate":"2013-06-14T16:55:00.000","Title":"Finding log-likelihood in a restricted boltzmann machine","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. \ni read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. \nI have samsung tab 2 10.1 with android 4.0.4.\nappreciate any help, thanks","AnswerCount":9,"Available Count":6,"Score":0.022218565,"is_accepted":false,"ViewCount":33438,"Q_Id":17116718,"Users Score":1,"Answer":"If both are connected to the same network, all you need to do is provide the IP address of your server (in your network) in your Android app.","Q_Score":31,"Tags":"android,python,django,web,localhost","A_Id":17116746,"CreationDate":"2013-06-14T20:24:00.000","Title":"how to access my 127.0.0.1:8000 from android tablet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. \ni read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. \nI have samsung tab 2 10.1 with android 4.0.4.\nappreciate any help, thanks","AnswerCount":9,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":33438,"Q_Id":17116718,"Users Score":0,"Answer":"Try this\npython manage.py runserver \nthen connect both tablet and system to same wifi and browse in the address\neg: python manage.py runserver 192.168.0.100:8000\nIn tablet type that url in adress bar","Q_Score":31,"Tags":"android,python,django,web,localhost","A_Id":61816349,"CreationDate":"2013-06-14T20:24:00.000","Title":"how to access my 127.0.0.1:8000 from android tablet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. \ni read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. \nI have samsung tab 2 10.1 with android 4.0.4.\nappreciate any help, thanks","AnswerCount":9,"Available Count":6,"Score":0.022218565,"is_accepted":false,"ViewCount":33438,"Q_Id":17116718,"Users Score":1,"Answer":"need to know the ip address of your machine .. \nMake sure both of your machines (tablet and computer) connected to same network\n192.168.0.22 - say your machine address\ndo this :\n192.168.0.22:8000   -- from your tablet\nthis is it !!!","Q_Score":31,"Tags":"android,python,django,web,localhost","A_Id":17116796,"CreationDate":"2013-06-14T20:24:00.000","Title":"how to access my 127.0.0.1:8000 from android tablet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. \ni read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. \nI have samsung tab 2 10.1 with android 4.0.4.\nappreciate any help, thanks","AnswerCount":9,"Available Count":6,"Score":1.2,"is_accepted":true,"ViewCount":33438,"Q_Id":17116718,"Users Score":16,"Answer":"You can find out what the ip address of your PC is with the ipconfig command in a Windows command prompt.  Since you mentioned them being connected over WiFi look for the IP address of the wireless adapter.\nSince the tablet is also in this same WiFi network, you can just type that address into your tablet's browser, with the :8000 appended to it and it should pull up the page.","Q_Score":31,"Tags":"android,python,django,web,localhost","A_Id":17116791,"CreationDate":"2013-06-14T20:24:00.000","Title":"how to access my 127.0.0.1:8000 from android tablet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. \ni read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. \nI have samsung tab 2 10.1 with android 4.0.4.\nappreciate any help, thanks","AnswerCount":9,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":33438,"Q_Id":17116718,"Users Score":6,"Answer":"127.0.0.1 is a loopback address that means, roughly, \"this device\"; your PC and your android tablet are separate devices, so each of them has its own 127.0.0.1.  In other words, if you try to go to 127.0.0.1 on your Android tab, it's trying to connect to a webserver on the Android device, which is not what you want.\nHowever, you should be able to connect over the wifi.  On your windows box, open a command prompt and execute ipconfig.  Somewhere in the output should be your windows box's address, probably 192.168.1.100 or something similar.  You tablet should be able to see the Django server at that address.","Q_Score":31,"Tags":"android,python,django,web,localhost","A_Id":17116785,"CreationDate":"2013-06-14T20:24:00.000","Title":"how to access my 127.0.0.1:8000 from android tablet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. \ni read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. \nI have samsung tab 2 10.1 with android 4.0.4.\nappreciate any help, thanks","AnswerCount":9,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":33438,"Q_Id":17116718,"Users Score":23,"Answer":"Though this thread was active quite a long time ago. This is what worked for me on windows 10. Posting it in details. Might be helpful for the newbies like me.\n\nAdd ALLOWED_HOSTS = ['*'] in django settings.py file\n\nrun django server with python manage.py 0.0.0.0:YOUR_PORT. I used 9595 as my port.\n\nMake firewall to allow access on that port:\n\nNavigate to control panel -> system and Security -> Windows Defender Firewall\n\nOpen Advanced Settings, select Inbound Rules then right click on it and then select New Rule\n\nSelect Port, hit next, input the port you used (in my case 9595), hit next, select allow the connections\n\nhit next again then give it a name and hit next for the last time.\n\n\n\nNow find the ip address of your PC.\n\nOpen Command Promt as adminstrator and run ipconfig command.\nYou may find more than one ip addresses. As I'm connected through wifi I took the one under Wireless LAN adapter WiFi. In my case it was 192.168.0.100\nNote that this ip may change when you reconnect to the network. So you need to check it again then.\n\n\nNow from another device (pc, mobile, tablet etc.) connected to the same network go to ip_address:YOUR_PORT (in my case 192.168.0.100:9595)\nHopefully you'll be good to go !","Q_Score":31,"Tags":"android,python,django,web,localhost","A_Id":48594665,"CreationDate":"2013-06-14T20:24:00.000","Title":"how to access my 127.0.0.1:8000 from android tablet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a text adventure. How could I to add static text to this. \nWhat i mean is some text that always stays on the left side of the window. Even if all the other text is scrolling down. Also how could i make this text red.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2751,"Q_Id":17122268,"Users Score":0,"Answer":"You create static text by putting it in a separate window. Create a window large enough for all the text, and then create a smaller window for the dynamic text. Text is colored by passing the various COLOR_* constants as the text attribute.","Q_Score":2,"Tags":"python,text,curses","A_Id":17122309,"CreationDate":"2013-06-15T09:46:00.000","Title":"(python) How to create static text in curses","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This application I am working on (GUI based), has well over a dozen modules. On running the application and using it, there is this particular action(clicking a label) upon which I get tons of empty prints in the stdout and because of which I suspect the application's performance is suffering. Now the problem is I am unable to find out exactly which print statement is causing this to happen.\nWhat I have tried as yet:\n\nmulti-buffer searches\ncommented the print statements which I know will be executed and left out the one which I am almost 100% sure will never be executed. period.\n\nWhat I haven't tried:\n\npdb(time consuming)\n\nAny ease hack(not too ugly) to corner out this print statement?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":17122479,"Users Score":0,"Answer":"Wherever you call your printing routine, add a small unique header to printout (module name+line number) to identify the place print was initiated from.","Q_Score":1,"Tags":"python,printing","A_Id":17122495,"CreationDate":"2013-06-15T10:10:00.000","Title":"how to find out exactly from where print is being executed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This application I am working on (GUI based), has well over a dozen modules. On running the application and using it, there is this particular action(clicking a label) upon which I get tons of empty prints in the stdout and because of which I suspect the application's performance is suffering. Now the problem is I am unable to find out exactly which print statement is causing this to happen.\nWhat I have tried as yet:\n\nmulti-buffer searches\ncommented the print statements which I know will be executed and left out the one which I am almost 100% sure will never be executed. period.\n\nWhat I haven't tried:\n\npdb(time consuming)\n\nAny ease hack(not too ugly) to corner out this print statement?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":17122479,"Users Score":6,"Answer":"Replace sys.stdout with a file-like that will spew out a traceback when its write() method is called.","Q_Score":1,"Tags":"python,printing","A_Id":17122501,"CreationDate":"2013-06-15T10:10:00.000","Title":"how to find out exactly from where print is being executed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python and XMLBuilder, a module I downloaded off the internet (pypi). It returns an object, that works like a string (I can do print(x)) but when I use file.write(x) it crashes and throws an error in the XMLBuilder module. \nI am just wondering how I can convert the object it returns into a string? \nI have confirmed that I am writing to the file correctly.\nI have already tried for example x = y although, as I thought, it just creates a pointer, and also x=x+\" \" put I still get an error. It also returns an string like object with \"\\n\".\nAny help on the matter would be greatly appreciated.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":17136085,"Users Score":0,"Answer":"I'm not quite sure what your question is, but print automatically calls str on all of it's arguments ...  So if you want the same output as print to be put into your file, then myfile.write(str(whatever)) will put the same text in myfile that print (x) would have put into the file (minus a trailing newline that print puts in there).","Q_Score":1,"Tags":"python,string,types,type-conversion","A_Id":17136094,"CreationDate":"2013-06-16T17:51:00.000","Title":"Converting a string-like object into a string in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I really would like to start getting into Objective C coding, specifically so I can write applications for iOS.\nMy coding background is that I have written C# .NET GUI Windows apps and PHP web scripts for years; I've also become a very good Python coder in the past year. I have written hundreds of useful command-line Python scripts, and also a few GUI apps using wxPython successfully. I also wrote VB6 GUI apps way back in the day, and of course, I cut my teeth on QuickBASIC in DOS. ;-)\nI understand OOP concepts: I understand classes, methods, properties and the like. I use OOP a lot in Python, and obviously use it extensively in C#.\nI haven't actually taken the time to really get good at C or C++, however I am able to write simple \"test\" programs to accomplish small tasks. The problem is that I understand the syntax just fine, but the APIs can be very different depending on platform, and accomplishing the same thing in C on Linux at the command line is totally different than accomplishing it in Windows in a GUI.\nI've looked over a few books out there for iOS coding but they seem to assume little to no programming knowledge and quickly bore me, and I can't easily find the information I really need buried among all of the \"here's what an object is\" or \"this is called a class and a method\" stuff...\nI also tried the Stanford lectures on iTunes U, but I found myself struggling with the MVC concepts and the idea of setting up different files for \"implementation\" and \"header\" and all of that...\nIs there any resources that you guys can think of that would be good for me to get started with iOS? \nIt's also worth noting I have dabbled with PyObjC a little on Mac and therefore do understand a LITTLE about the NS foundation classes and such, and I've also looked at Apple's reference documentation and I'm sure that once I get the basics down I could put good use to it, but I still don't know how to actually get a functional iOS app that does something useful going.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":166,"Q_Id":17138389,"Users Score":1,"Answer":"I learned to write iOs apps from the CS 193P iPhone Application Development course on iTunes U. It's fantastic and I highly recommend it if you are sure iOs is what you want to do.","Q_Score":0,"Tags":"python,.net,ios","A_Id":17138453,"CreationDate":"2013-06-16T22:38:00.000","Title":"Best intro to iOS for Python\/PHP\/C# Coder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I really would like to start getting into Objective C coding, specifically so I can write applications for iOS.\nMy coding background is that I have written C# .NET GUI Windows apps and PHP web scripts for years; I've also become a very good Python coder in the past year. I have written hundreds of useful command-line Python scripts, and also a few GUI apps using wxPython successfully. I also wrote VB6 GUI apps way back in the day, and of course, I cut my teeth on QuickBASIC in DOS. ;-)\nI understand OOP concepts: I understand classes, methods, properties and the like. I use OOP a lot in Python, and obviously use it extensively in C#.\nI haven't actually taken the time to really get good at C or C++, however I am able to write simple \"test\" programs to accomplish small tasks. The problem is that I understand the syntax just fine, but the APIs can be very different depending on platform, and accomplishing the same thing in C on Linux at the command line is totally different than accomplishing it in Windows in a GUI.\nI've looked over a few books out there for iOS coding but they seem to assume little to no programming knowledge and quickly bore me, and I can't easily find the information I really need buried among all of the \"here's what an object is\" or \"this is called a class and a method\" stuff...\nI also tried the Stanford lectures on iTunes U, but I found myself struggling with the MVC concepts and the idea of setting up different files for \"implementation\" and \"header\" and all of that...\nIs there any resources that you guys can think of that would be good for me to get started with iOS? \nIt's also worth noting I have dabbled with PyObjC a little on Mac and therefore do understand a LITTLE about the NS foundation classes and such, and I've also looked at Apple's reference documentation and I'm sure that once I get the basics down I could put good use to it, but I still don't know how to actually get a functional iOS app that does something useful going.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":166,"Q_Id":17138389,"Users Score":1,"Answer":"I have gotten more from Erica Sadun's books than any of the others, personally.  iOS apps use a lot of animation and graphics, by necessity, and her code examples are clean and concise.  They aren't beginner's books but you sound as though you're not a beginning coder.  They hit on a lot of topics it is hard to find much on.  \nIf you're willing to work through the sample programs, I found iPad iOS 6 Development Essentials to be comprehensive (Neil Smith).  However, it tends to focus on the visual IDE of xCode which I think is lousy and chose not to use at all; if you plan to use it, then that would be a good resource imo.  Also, I got a book that covered Objective C only (Aaron Hillegass) which I thought was good.  The iOS book from the same author was not good for me, because it depended on you working prior chapter examples to proceed to later chapters, which for me was a waste of time, so I bailed out of it quickly.  I also got Pro Core Data (Privat and Warner) which I found to be of limited (actually, little) value for the same reason as the Hillegass iOS book -- the examples are too big and not to the point.\nAnd, of course, Google.","Q_Score":0,"Tags":"python,.net,ios","A_Id":17140686,"CreationDate":"2013-06-16T22:38:00.000","Title":"Best intro to iOS for Python\/PHP\/C# Coder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to export dataframe to .xls file using to_excel() method. But while execution it was throwing an error: \"UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 892: ordinal not in range(128)\". Just few moments back it was working fine. \nThe code I used is: \n             :csv2.to_excel(\"C:\\\\Users\\\\shruthi.sundaresan\\\\Desktop\\\\csat1.xls\",sheet_name='SAC_STORE_DATA',index=False).\ncsv2 is the dataframe. Why does this kind of error happens and how to avoid this is in the future?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":474,"Q_Id":17140080,"Users Score":0,"Answer":"The problem you are facing is that your excel has a character that cannot be decoded to unicode. It was probably working before but maybe you edited this xls file somehow in Excel\/Libre. You just need to find this character and either get rid of it or replace it with the one that is acceptable.","Q_Score":0,"Tags":"python-2.7,pandas,xls","A_Id":17141432,"CreationDate":"2013-06-17T03:36:00.000","Title":"Unable to export pandas dataframe into excel file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this?","AnswerCount":12,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":387046,"Q_Id":17141979,"Users Score":3,"Answer":"Just make round(x-0.5) this will always return the next rounded down Integer value of your Float. You can also easily round up by do round(x+0.5)","Q_Score":144,"Tags":"python,floating-point,integer,rounding","A_Id":53398021,"CreationDate":"2013-06-17T07:00:00.000","Title":"Round a floating-point number down to the nearest integer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this?","AnswerCount":12,"Available Count":3,"Score":0.0166651236,"is_accepted":false,"ViewCount":387046,"Q_Id":17141979,"Users Score":1,"Answer":"Don't know if you solved this, but I just stumble upon this question. If you want to get rid of decimal points, you could use int(x) and it will eliminate all decimal digits. Theres no need to use round(x).","Q_Score":144,"Tags":"python,floating-point,integer,rounding","A_Id":27183740,"CreationDate":"2013-06-17T07:00:00.000","Title":"Round a floating-point number down to the nearest integer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this?","AnswerCount":12,"Available Count":3,"Score":-1.0,"is_accepted":false,"ViewCount":387046,"Q_Id":17141979,"Users Score":-6,"Answer":"I used this code where you subtract 0.5 from the number and when you round it, it is the original number rounded down.\n\nround(a-0.5)","Q_Score":144,"Tags":"python,floating-point,integer,rounding","A_Id":52981095,"CreationDate":"2013-06-17T07:00:00.000","Title":"Round a floating-point number down to the nearest integer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the user registration form made in django.\nI want to know the city from which the user is registering.\nIs there any way that i get the IP address of the user and then somehow get the city for that IP. using some API or something","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":17159576,"Users Score":0,"Answer":"Not in any reliable way, or at least not in Django. The problem is that user IPs are usually dynamic, hence the address is changing every couple of days. Also some ISPs soon will start to use a single IP for big blocks of users (forgot what this is called) since they are running out of IPv4 IP addresses... In other words, all users from that ISP within a whole state or even country will have a single IP address.\nSo using the IP is not reliable. You could probably figure out the country or region of the user with reasonable accuracy however my recommendation is not to use the IP for anything except logging and permission purposes (e.g. blocking a spam IP).\nIf you want user locations, you can however use HTML5 location API which will have a much better shot of getting more accurate location since it can utilize other methods such us using a GPS sensor in a phone.","Q_Score":0,"Tags":"python,django,ip","A_Id":17159679,"CreationDate":"2013-06-18T02:12:00.000","Title":"Is there any simple way to store the user location while registering in database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing an app that converts different images to JPG. It operates over a complex directory structure. There, a directory may include other directories, image files (JPG, GIF, PNG, TIFF), PDF files, RAR\/ZIP archives, which in turn may include anything of the above. The app finds everything that can be converted to an image and places the resulting JPGs into a separate folder.\nHow do i write integration tests to test the conversion of images? Specifically, how should i fake the complex directory structure with all the files?\nCurrently i just store a sample directory structure, which i manually assembled out of various image, PDF and archive files, in a tests\/ directory. In a setUp method i put this sample directory in place of the actual data and run the code. I had an idea to generate all these sample files myself (generate JPGs via Imagemagick, for example), but it proved hard.\nHow integration testing on images is usually done?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":271,"Q_Id":17171843,"Users Score":1,"Answer":"Do you write your own library to convert images of you just use existing library? In the latter case you simply do not test it. Author has already tested it somehow. You just need to create an abstraction layer between your code and the image library you use. Then you can simply check if your code calls the library with desired parameters.\nIf you really insist on testing pictures then you need to make the transformation deterministic (and compare actual result with expected result) or you need to make comparison a bit less strict (from ignoring date fields to OCR recognizing the image).\nTesting files is way easier (you do not need probability based OCR).Check if your program placed all files in expected location.","Q_Score":1,"Tags":"python,image,unit-testing,language-agnostic,integration-testing","A_Id":21843350,"CreationDate":"2013-06-18T14:42:00.000","Title":"Integration testing and images","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, if the program did not provide an API, and I need it to do something from Python script, is this possible to do so? Let's give an example:\nI would like to copy the Product ID from the Internet Explorer's product ID everyday and new a text file named in this format: ddmmyyyy, and store on desktop. It is stupid, so, I would like to handle it to the machine to do it. (Yes, it is useless, but just say, it is an example.)\nCreating a text file, with a string is easy to implement, but the REAL question is, how can I get the product ID from the program that don't have API provided. \nSo, the IE didn't provide the API for developer to access the Product ID, and I think the value can be shown on the screen or registry. Assume that I don't know the register location or they simply didn't store it in the registry, what I can get this  product ID is manually, click, and check. For this process, is this possible to make it automatic? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":17183100,"Users Score":0,"Answer":"If the Info ur looking for is showed by IE you can obtain it by using xpath. If you want to make it automatic you could use selenium which works with webs as well. \nIf the program doesnt provide an api then its not possible to interact with the program unless you get the output from a browser or you may use programs like Sikuli and obtain the info for example by image processing","Q_Score":0,"Tags":"python,automation","A_Id":17183172,"CreationDate":"2013-06-19T04:51:00.000","Title":"Is this possible to write a program to inter-act with existing software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I Have add some wrong task to a celery with redis broker\nbut now I want to remove the incorrect task and I can't find any way to do this\nIs there some commands or some api to do this ?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":22805,"Q_Id":17184244,"Users Score":0,"Answer":"try to remove the .state file and if you are using a beat worker (celery worker -B) then remove the schedule file as well","Q_Score":15,"Tags":"python,celery,celery-task,celeryd","A_Id":61655803,"CreationDate":"2013-06-19T06:25:00.000","Title":"how to remove task from celery with redis broker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I Have add some wrong task to a celery with redis broker\nbut now I want to remove the incorrect task and I can't find any way to do this\nIs there some commands or some api to do this ?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":22805,"Q_Id":17184244,"Users Score":3,"Answer":"The simplest way is to use the celery control revoke [id1 [id2 [... [idN]]]] (do not forget to pass the -A project.application flag too). Where id1 to idN are task IDs. However, it is not guaranteed to succeed every time you run it, for valid reasons...\nSure Celery has API for it. Here is an example how to do it from a script: res = app.control.revoke(task_id, terminate=True)\nIn the example above app is an instance of the Celery application.\nIn some rare ocasions the control command above will not work, in which case you have to instruct Celery worker to kill the worker process: res = app.control.revoke(task_id, terminate=True, signal='SIGKILL')","Q_Score":15,"Tags":"python,celery,celery-task,celeryd","A_Id":61655939,"CreationDate":"2013-06-19T06:25:00.000","Title":"how to remove task from celery with redis broker?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i need to find out contact angle between 2 edges in an image using open cv and python so can anybody suggest me how to find it? if not code please let me know algorithm for the same.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":531,"Q_Id":17209762,"Users Score":0,"Answer":"Simplify edge A and B into a line equation (using only the few last pixels)\nGet the line equations of the two lines (form y = mx + b)\nGet the angle orientations of the two lines \u03b8=atan|1\/m|\nSubtract the two angles from each other\n\nMake sure to do the special case of infinite slope, and also do some simple math to get Final_Angle = (0;pi)","Q_Score":1,"Tags":"opencv,python-2.7","A_Id":17212232,"CreationDate":"2013-06-20T09:13:00.000","Title":"to measure Contact Angle between 2 edges in an image","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to put the items, scraped by my spider, in a mysql db via a mysql pipeline. Everything is working but i see some odd behaviour. I see that the filling of the database is not in the same order as the website itself. There is like a random order. Probably of the dictionary like list of the items scraped i guess.\nMy questions are:\n\nhow can i get the same order as the items of the website itself.\nhow can i reverse this order of question 1.\n\nSo items on website:\n\nA\nB\nC\nD\nE\n\nadding order in my sql:\n\nE\nD\nC\nB\nA","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":17213515,"Users Score":0,"Answer":"Items in a database are have not a special order if you don't impose it. So you should add a timestamp to your table in the database, keep it up-to-date (mysql has a special flag to mark a field as auto-now) and use ORDER BY in your queries.","Q_Score":2,"Tags":"python,scrapy","A_Id":17213740,"CreationDate":"2013-06-20T12:20:00.000","Title":"Scrapy reversed item ordening for preparing in db","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to put the items, scraped by my spider, in a mysql db via a mysql pipeline. Everything is working but i see some odd behaviour. I see that the filling of the database is not in the same order as the website itself. There is like a random order. Probably of the dictionary like list of the items scraped i guess.\nMy questions are:\n\nhow can i get the same order as the items of the website itself.\nhow can i reverse this order of question 1.\n\nSo items on website:\n\nA\nB\nC\nD\nE\n\nadding order in my sql:\n\nE\nD\nC\nB\nA","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":201,"Q_Id":17213515,"Users Score":1,"Answer":"It's hard to say without the actual code, but in theory..\nScrapy is completely async, you cannot know the order of items that will be parsed and processed through the pipeline.\nBut, you can control the behavior by \"marking\" each item with priority key. Add a field priority to your Item class, in the parse_item method of your spider set the priority based on the position on a web page, then in your pipeline you can either write this priority field to the database (in order to have an ability to sort later), or gather all items in a class-wide list, and in close_spider method sort the list and bulk insert it into the database.\nHope that helps.","Q_Score":2,"Tags":"python,scrapy","A_Id":17221923,"CreationDate":"2013-06-20T12:20:00.000","Title":"Scrapy reversed item ordening for preparing in db","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I hope this hasn't already been answered but I haven't found this anywhere.\nMy problem is quite simple : I'm trying to compute an oblic profile of an image using scipy.\nOne great way to do it is to : \n\nlocate the segment along which I want my profile by giving the beginning and the end of my segment, \nextract the minimal image containing the segment, \ncompute the angle from which my image should be rotated to get the desired profile along a nice raw, \nextract said raw.\n\nThat's the theory.\nI'm stuck right now on (4), because my profile should fall in raw number array.shape[0]\/2, but rotate  seems to add sometimes lines of zeros below the data and columns on the left. The correct raw number can thus be shifted...\nHas anyone any idea how to get the right raw number, for example using the correspondence matrix used by scipy ?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":17218051,"Users Score":0,"Answer":"After some time of debugging, I realized that depending on the angle - typically under and over n*45 degrees - scipy adds a row and a column to the output image. \na simple test of the angle adding one to the indices solved my problem.\nI hope this can help the future reader of this topic.","Q_Score":1,"Tags":"python,indexing,scipy,rotatetransform,correspondence","A_Id":18653827,"CreationDate":"2013-06-20T15:44:00.000","Title":"finding corresponding pixels before and after scipy.ndimage.interpolate.rotate","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to run the command python abc.py in the windows command prompt when the button on html page is clicked.The python file is located at  C:\/abc.py> I would like to know how to code the html page to do this process.Thank you  for the help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6859,"Q_Id":17218183,"Users Score":0,"Answer":"I believe the correct answer is you cannot.  Feel free to let me know otherwise if you find out a way to do it.","Q_Score":1,"Tags":"html,windows,python-2.7,command,command-prompt","A_Id":17218531,"CreationDate":"2013-06-20T15:49:00.000","Title":"Running the Command on Windows Command prompt using HTML button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Do you know how to get the index or column of a DataFrame as a NumPy array or python list?","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":558431,"Q_Id":17241004,"Users Score":75,"Answer":"You can use df.index to access the index object and then get the values in a list using df.index.tolist(). Similarly, you can use df['col'].tolist() for Series.","Q_Score":289,"Tags":"python,pandas","A_Id":17241104,"CreationDate":"2013-06-21T17:25:00.000","Title":"How do I convert a pandas Series or index to a Numpy array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"im using a program called CodeRunner to program Python code. I want to install wxpython but how do I figure out what version python im using? when i do python -v in Terminal it says im on 2.7, but is that the same version that CodeRunner is using? Is there a way for me to find out?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1192,"Q_Id":17243749,"Users Score":0,"Answer":"CodeRunner should work fine with Python 2.7, but you'll have to make sure that a compatible version of wxPython is installed in your site-packages.\nTo verify that wxPython works correctly, you should start up a python instance in your terminal and run some test code (i.e., import the library and run some of the functions). If this works correctly, then CodeRunner should be able to run that code accordingly (because it uses the same process to run your apps).","Q_Score":1,"Tags":"python,wxpython,coderunner","A_Id":17243806,"CreationDate":"2013-06-21T20:24:00.000","Title":"Python programming with CodeRunner","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Script-1 can be run from a shell and will ask the user for 3 prompts, A, B, and C in that order. A or B will appear to the user, and C will always will appear. In other words, when Script-1 is run, the user will be prompted by question A or B. Once answered, the question C will always be prompted last.\nI want to write Script-2, which will use logic to answer prompts A, B, and C automatically in Python. Pexpect seems perfect for this, however, how would one use pexpect when there are two different prompts- A or B- that could be presented to it?\nThank you.","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":704,"Q_Id":17263517,"Users Score":-2,"Answer":"pexpect allows you to specify a list of prompts to match against, so it caters explicitly to your use case.  Consult the docstring of pexpect.expect().","Q_Score":0,"Tags":"python,python-2.7,pexpect","A_Id":17265035,"CreationDate":"2013-06-23T17:45:00.000","Title":"Pexpect Multiple, Different Prompts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"PEP8 has naming conventions for e.g. functions (lowercase), classes (CamelCase) and constants (uppercase).\nIt seems to me that distinguishing between numpy arrays and built-ins such as lists is probably more important as the same operators such as \"+\" actually mean something totally different.\nDoes anyone have any naming conventions to help with this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":415,"Q_Id":17270293,"Users Score":1,"Answer":"numpy arrays and lists should occupy similar syntactic roles in your code and as such I wouldn't try to distinguish between them by naming conventions. Since everything in python is an object the usual naming conventions are there not to help distinguish type so much as usage. Data, whether represented in a list or a numpy.ndarray has the same usage.\nI agree that it's awkward that eg. + means different things for lists and arrays. I implicitly deal with this by never putting anything like numerical data in a list but rather always in an array. That way I know if I want to concatenate blocks of data I should be using numpy.hstack. That said, there are definitely cases where I want to build up a list through concatenation and turn it into a numpy array when I'm done. In those cases the code block is usually short enough that it's clear what's going on. Some comments in the code never hurt.","Q_Score":2,"Tags":"python,numpy,naming-conventions","A_Id":17270654,"CreationDate":"2013-06-24T07:39:00.000","Title":"how do you distinguish numpy arrays from Python's built-in objects","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"PEP8 has naming conventions for e.g. functions (lowercase), classes (CamelCase) and constants (uppercase).\nIt seems to me that distinguishing between numpy arrays and built-ins such as lists is probably more important as the same operators such as \"+\" actually mean something totally different.\nDoes anyone have any naming conventions to help with this?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":415,"Q_Id":17270293,"Users Score":2,"Answer":"You may use a prefix np_ for numpy arrays, thus distinguishing them from other variables.","Q_Score":2,"Tags":"python,numpy,naming-conventions","A_Id":17270547,"CreationDate":"2013-06-24T07:39:00.000","Title":"how do you distinguish numpy arrays from Python's built-in objects","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to display the waveform of a sound file in a Tkinter window (Python)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":17303998,"Users Score":0,"Answer":"Depending on the sound file format, if it is a .wav then you can probably just read it in to a numpy array then plot it, otherwise you are going to have to parse the file format first.","Q_Score":0,"Tags":"python,python-2.7,audio,tkinter","A_Id":17304375,"CreationDate":"2013-06-25T17:41:00.000","Title":"Plot wavewform in Tkinter (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Problem: I have QTableWidget cells populated with text (10 columns). I found out that no matter how much rows I have (10 or 100000) scrolling over rows with heigth ~ over 3000 is very slow and not smooth enough (I've used table.verticalHeader().sectionSize(i) to find out heigth of every row).\nWhat I've tried to do: So I've tried to set height of those rows using table.setRowHeight(i,3000), but still when I scroll over those rows I get delay of 1-5 secunds. Also in that case I need to manualy resize height of row in order to see all text in that row (because it was cuted), and that is slow too.\nQuestions: I need to do table.resizeRowsToContent() for all smaller rows, so I think solution would be to set limit for height of every row in table. There is setMinimumSectionSize() method but I can't find any for max size, so how can I do it? Is it possible to have scrollbars inside every cell where height is >3000 so I can scroll through text inside that cell? Maybe that will speed up scrolling throug table?\nAny help would be appreciated","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":913,"Q_Id":17324670,"Users Score":1,"Answer":"This is how I've solved it:\nWhile populating table cells with text, if my text have over 1000 lines (text.count(\"\\n\")) I put it in QTextEdit() and then set it with setCellWidget. Reason I didn't put them all in QTextEdit()s is that Windows can show limited number of GUI elements (<20000) and, as I said, I have 10 columns x up to 100000 rows","Q_Score":1,"Tags":"python,scroll,qtablewidget","A_Id":21234521,"CreationDate":"2013-06-26T15:45:00.000","Title":"Qtablewidget does not scroll smoothly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can you change the font settings for the input boxes and message text in EasyGUI? I know you have to edit a file somewhere, but that's about it. Exactly how to do it and what to edit would be appreciated.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":6064,"Q_Id":17325299,"Users Score":3,"Answer":"In addition to what @Benjooster answered previously:\nApparently sometimes the font settings are not in easygui.py, but rather in\nPython27\\Lib\\site-packages\\easygui\\boxes\\state.py","Q_Score":4,"Tags":"python-3.x,easygui","A_Id":32529223,"CreationDate":"2013-06-26T16:14:00.000","Title":"Python EasyGUI module: how to change the font","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I have created a custom openerp module having several fields . I also have a field for attaching image file . But now I need to have a field that should have the ability to attach multiple image fields. How Can I be able to do this?\nHopes for suggestion","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1243,"Q_Id":17341034,"Users Score":0,"Answer":"Add a many2many field relating to ir.attachments.Check sent by email button in invoice. It opens a wizard which we can add many attachments and also email body\nfor example, add a many2many field relating to ir.attachement and in xml line of the field, specify widget=\"many2many_binary\"\nI dont know whether it is possible to show images as many2many","Q_Score":0,"Tags":"python,eclipse,openerp","A_Id":17343886,"CreationDate":"2013-06-27T10:44:00.000","Title":"how to add field for multiple image attachment in openerp module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have a password protected XLS file which i've forgotten the password for...I'm aware it's a date within a certain range so i'm trying to write a brute forcer to try various dates of the year. However, I can't find how to use python\/java to enter the password for the file. It's protected such that I can't open the xls file unless I have it and it has some very important information on there (so important I kept the password in a safe place that I now can't find lol).\nI'm using fedora. Are there any possible suggestions? Thankyou.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":17344335,"Users Score":0,"Answer":"If you search there are a number of applications that you can download that will unblock the workbook.","Q_Score":0,"Tags":"java,python,excel,passwords,xls","A_Id":17344366,"CreationDate":"2013-06-27T13:20:00.000","Title":"How to enter password in XLS files with python?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Python 32bit on W7. I then \"installed\" Eclipse 32bit.\nI successfully added PyDev to Eclipse. I then go to PyDev->Interpreter-Python, and click on \"new\", browse to C:\\Python27\\python.exe, click ok, and get the following error:\nError getting info on interpreter.\nCommon reasons include\n-Using an unsupported version\n-Specifying and invalid interpreter\nReasons:\nSee error log for details.\nLog:\norg.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 23; The reference to entity \"g\" must end with the ';' delimiter.\nAny ideas how to fix this?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":288,"Q_Id":17351154,"Users Score":1,"Answer":"i had this problem too, it turns out i had used \"&\" in the path of my eclipse folder.  i renamed the folder using just normal characters, and pydev installed fine.\ni believe the path statement for the location of the eclipse folder has to be strict unicode without any other characters","Q_Score":0,"Tags":"python,eclipse,pydev","A_Id":20921210,"CreationDate":"2013-06-27T18:58:00.000","Title":"Failing to define the Python interpeter for PyDev in Eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to make a project in dynamic django scraper. I have tested it on linux and it runs properly. When I try to run the command: syndb i get this error\n\/*****************************************************************************************************************************\/\npython : WindowsError: [Error 3] The system cannot find the path specified: 'C:\\Python27\\l\nib\\site-packages\\django_dynamic_scraper-0.3.0-py2.7.egg\\dynamic_scraper\\migrations\/.'\nAt line:1 char:1\n+ python manage.py syncdb\n+ ~~~~~~~~~~~~~~~~~~~~~~~\n    + CategoryInfo          : NotSpecified: (WindowsError: [...migrations\/.':String) [],\n   RemoteException\n    + FullyQualifiedErrorId : NativeCommandError\n\/*****************************************************************************************************************************\/\nThe admin server runs properly with the command python manage.py runserver \nKindly guide me how i can remove this error","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":194,"Q_Id":17364120,"Users Score":0,"Answer":"Step # 1\ndownload django-dynamic-scraper-0.3.0-py2.7.tar.gz file\nStep # 2\nUnzip it and change the name of the folder to:\ndjango-dynamic-scraper-0.3.0-py2.7.egg\nStep # 3\npaste the folder into C:\\Python27\\Lib\\site-packages","Q_Score":0,"Tags":"python,django,web-scraping,scraper,scraperwiki","A_Id":17374282,"CreationDate":"2013-06-28T11:53:00.000","Title":"Django Dynamic Scraper Project does not run on windows even though it works on Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Can someone please help and tell me how to get the celery task debug details to a log file? I have a requirement to have the details of celery task logged into a .log file.\nCan you please make some suggestions on how this can be done without impacting the performance of the task?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":63725,"Q_Id":17366579,"Users Score":10,"Answer":"If you want to log everything, you can use the following command\n\n-f celery.logs\n\nYou can also specify different log levels as well. For suppose if you want log warning and errors add like following.\n\n--loglevel=warning -f celery.logs","Q_Score":28,"Tags":"python,celery","A_Id":46843345,"CreationDate":"2013-06-28T14:05:00.000","Title":"Celery Logs into file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My project requires being run on several different physical machines, which have shared file system among them. One problem arising out of this is how to synchronize write to a common single file. With threads, that can be easily achieved with locks, however my program consists of processes distributed on different machines, which I have no idea how to synchronize. In theory, any way to check whether a file is being opened right now or any lock-like solutions will do, but I just cannot crack out this by myself. A python way would be particularly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1617,"Q_Id":17376033,"Users Score":0,"Answer":"Just a thought...\nCouldn't you put a 'lock' file in the same directory as the file your trying to write to?  In your distributed processes check for this lock file.  If it exists sleep for x amount and try again.  Likewise, when the process that currently has the file open finishes the process deletes the lock file?\nSo if you have in the simple case 2 processes called A and B:\nProcess A checks for lock file and if it doesn't exist it creates the lock file and does what it needs to with the file.  After it's done it deletes this lock file.\nIf process A detects the lock file then that means process B has the file, so sleep and try again later....rinse repeat.","Q_Score":4,"Tags":"python-2.7,locking,shared-file","A_Id":17376105,"CreationDate":"2013-06-29T02:14:00.000","Title":"is there a way to synchronize write to a file among different processes (not threads)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my python\/django based web application I want to export some (not all!) data from the app's SQLite database to a new SQLite database file and, in a web request, return that second SQLite file as a downloadable file. \nIn other words: The user visits some view and, internally, a new SQLite DB file is created, populated with data and then returned. \nNow, although I know about the :memory: magic for creating an SQLite DB in memory, I don't know how to return that in-memory database as a downloadable file in the web request. Could you give me some hints on how I could reach that? I would like to avoid writing stuff to the disc during the request.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":169,"Q_Id":17382053,"Users Score":1,"Answer":"I'm not sure you can get at the contents of a :memory: database to treat it as a file; a quick look through the SQLite documentation suggests that its API doesn't expose the :memory: database to you as a binary string, or a memory-mapped file, or any other way you could access it as a series of bytes. The only way to access a :memory: database is through the SQLite API.\nWhat I would do in your shoes is to set up your server to have a directory mounted with ramfs, then create an SQLite3 database as a \"file\" in that directory. When you're done populating the database, return that \"file\", then delete it. This will be the simplest solution by far: you'll avoid having to write anything to disk and you'll gain the same speed benefits as using a :memory: database, but your code will be much easier to write.","Q_Score":0,"Tags":"python,django,sqlite","A_Id":17382483,"CreationDate":"2013-06-29T16:01:00.000","Title":"Python: Create and return an SQLite DB as a web request result","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to be able to customize auto-completion in canopy, so it behaves like sublime. \nIs it possible? And if so, where do i find the APIs?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":792,"Q_Id":17396218,"Users Score":0,"Answer":"Canopy currently doesn't expose the API to customize auto-completion. \nBut, what exactly do you mean by making it behave like sublime?","Q_Score":1,"Tags":"python,autocomplete,enthought","A_Id":17397527,"CreationDate":"2013-07-01T00:51:00.000","Title":"Canopy: Changing the way auto-completion works","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From what I know, CPython programs are compiled into intermediate bytecode, which is executed by the virtual machine. Then how does one identify without knowing beforehand that CPython is written in C. Isn't there some common DNA for both which can be matched to identify this?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":686,"Q_Id":17400805,"Users Score":13,"Answer":"Python isn't written in C. Arguably, Python is written in an esoteric English dialect using BNF.\nHowever, all the following statements are true:\n\nPython is a language, consisting of a language specification and a bunch of standard modules\nPython source code is compiled to a bytecode representation\nthis bytecode could in principle be executed directly by a suitably-designed processor but I'm not aware of one actually existing\nin the absence of a processor that natively understands the bytecode, some other program must be used to translate the bytecode to something a hardware processor can understand\none real implementation of this runtime facility is CPython\nCPython is itself written in C, but ...\n\nC is a language, consisting of a language specification and a bunch of standard libraries\nC source code is compiled to some bytecode format (typically something platform-specific)\nthis platform specific format is typically the native instruction set of some processor (in which case it may be called \"object code\" or \"machine code\")\nthis native bytecode doesn't retain any magical C-ness: it is just instructions. It doesn't make any difference to the processor which language the bytecode was compiled from\nso the CPython executable which translates your Python bytecode is a sequence of \ninstructions executing directly on your processor\nso you have: Python bytecode being interpreted by machine code being interpreted by the hardware processor\n\nJython is another implementation of the same Python runtime facility\nJython is written in Java, but ...\n\nJava is a language, consisting of a spec, standard libraries etc. etc.\nJava source code is compiled to a different bytecode\nJava bytecode is also executable either on suitable hardware, or by some runtime facility\nThe Java runtime environment which provides this facility may also be written in C\nso you have: Python bytecode being interpreted by Java bytecode being interpreted by machine code being interpreted by the hardware processor\n\n\nYou can add more layers indefinitely: consider that your \"hardware processor\" may really be a software emulation, or that hardware processors may have a front-end that decodes their \"native\" instruction set into another internal bytecode.\nAll of these layers are defined by what they do (executing or interpreting instructions according to some specification), not how they implement it.\nOh, and I skipped over the compilation step. The C compiler is typically written in C (and getting any language to the stage where it can compile itself is traditionally significant), but it could just as well be written in Python or Java. Again, the compiler is defined by what it does (transforms some source language to some output such as a bytecode, according to the language spec), rather than how it is implemented.","Q_Score":4,"Tags":"python,cpython","A_Id":17401698,"CreationDate":"2013-07-01T09:08:00.000","Title":"What does it mean when people say CPython is written in C?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The standard python version of ubuntu 13.04 is python 2.7.\nI know that I can call a python script of version 3.3 by calling python3.3 or python3 in terminal instead of only \"python\", which starts the version 2.7...\ne.g. python3 myscript.py\nBut now I have a version 3.3. script in the system start routine and can only tell the path to the file. The system recognizes it as a python script (in the shebang with #!\/usr\/bin\/python3)\nBut how to open it with the correct version? It is tried to be opened with the standard python install so it wont work nor even show up.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1070,"Q_Id":17412982,"Users Score":0,"Answer":"The shebang line #!\/usr\/bin\/python3 should work if sh, bash, etc. is trying to launch your script.\nIt it is being run from another script as python myscript.py you'll have to find that script and get it to launch the script using python3 myscripy.py","Q_Score":0,"Tags":"python,ubuntu","A_Id":17413212,"CreationDate":"2013-07-01T20:21:00.000","Title":"starting a python 3.3. script at ubuntu startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"On a windows OS, how can I get python to detect if anything is plugged in to a specific USB location on the computer. For example \"Port_#0002.Hub_#0003\"\nI've tried pyUSB which worked fine for detecting a specific device, but I couldn't seem to figure out how to just check a specific port\/hub location for any kind of device.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1021,"Q_Id":17414855,"Users Score":0,"Answer":"What about polling? Create a Python app that enumerates a list of attached USB devices every couple of seconds or so. \nKeep a list\/dictionary of your initially detected devices, and compare to that to determine what was attached\/detached since your last polling iteration.\nThis isn't the best approach, and enumerating all the devices takes a short while, so not too sure this would be the most CPU efficient method.","Q_Score":0,"Tags":"python,windows,usb,pyusb","A_Id":17516390,"CreationDate":"2013-07-01T22:44:00.000","Title":"How can I get Python to watch a USB port for any device?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python 2.7 and Mysql. I am using multi-threading and giving connections to different threads by using PooledDB . I give db connections to different threads by\npool.dedicated_connection().Now if a thread takes a connection from pool and dies due to some reason with closing it(ie. without returning it to the pool).What happens to this connection.\nIf it lives forever how to return it to the pool??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":178,"Q_Id":17423384,"Users Score":2,"Answer":"No, it does not.  You have to tell the server on the other side that the connection is closed, because it can't tell the difference between \"going away\" and \"I haven't sent my next query yet\" without an explicit signal from you.\nThe connection can time out, of course, but it won't be closed or cleaned up without instructions from you.","Q_Score":0,"Tags":"python,mysql,multithreading,python-2.7","A_Id":17423440,"CreationDate":"2013-07-02T10:37:00.000","Title":"Does database connection return to pool if a thread holding it dies?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I have created a button oin my custom openerp module. I wanted to add func to this button to create a field. I have added the function but how to add functionality for creating fields . please help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":17446703,"Users Score":0,"Answer":"You can create field on function, you have to create field in object 'ir.model.fields'\nif you are create simple field like float. char, boolean then you have to give value Field Name, Label, Model, for which object you want to create field , if many2one or many2many field then you have to give Object Relation field to.\nHope this help","Q_Score":1,"Tags":"python,eclipse,openerp","A_Id":17447105,"CreationDate":"2013-07-03T11:26:00.000","Title":"How to create field through func in openerp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using magic %paste in ipython, it executes pasted code, rather than just pasting. How can i get it to just paste the copied code so that it can be edited?","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":3184,"Q_Id":17451874,"Users Score":6,"Answer":"You have two options:\n\nTo edit it by hand, run %cpaste. Then you can paste it in with standard terminal options (try Ctrl-Shift-V), and edit it. Enter -- on a line to finish.\nTo change it as text in your code, run %paste foo. It will store the clipboard contents in foo.","Q_Score":7,"Tags":"ipython,paste,ipython-magic","A_Id":17475225,"CreationDate":"2013-07-03T15:18:00.000","Title":"When using magic %paste in ipython, how can i get it to just paste the copied code, rather than paste and execute, so that it can be edited","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using magic %paste in ipython, it executes pasted code, rather than just pasting. How can i get it to just paste the copied code so that it can be edited?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3184,"Q_Id":17451874,"Users Score":3,"Answer":"There is a solution for this issue in ipython, if you are not concerned with indentation,\nJust run  %autoindent to Automatic indentation OFF.","Q_Score":7,"Tags":"ipython,paste,ipython-magic","A_Id":30046297,"CreationDate":"2013-07-03T15:18:00.000","Title":"When using magic %paste in ipython, how can i get it to just paste the copied code, rather than paste and execute, so that it can be edited","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a traffic study and I have the following problem:\nI have a CSV file that contains time-stamps and license plate numbers of cars for a location and another CSV file that contains the same thing. I am trying to find matching license plates between the two files and then find the time difference between the two. I know how to match strings but is there a way I can find matches that are close maybe to detect user input error of the license plate number?\nEssentially the data looks like the following:\n\nA = [['09:02:56','ASD456'],...]\nB = [...,['09:03:45','ASD456'],...]\n\nAnd I want to find the time difference between the two sightings but say if the data was entered slightly incorrect and the license plate for B says 'ASF456' that it will catch that","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":1137,"Q_Id":17456233,"Users Score":1,"Answer":"What you're asking is about a fuzzy search, from what it sounds like.  Instead of checking string equality, you can check if the two string being compared have a levenshtein distance of 1 or less.  Levenshtein distance is basically a fancy way of saying how many insertions, deletions or changes will it take to get from word A to B.  This should account for small typos.\nHope this is what you were looking for.","Q_Score":0,"Tags":"python,comparison","A_Id":17456347,"CreationDate":"2013-07-03T19:09:00.000","Title":"Python Matching License Plates","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using Libsvm in a 5x2 cross validation to classify a very huge amount of data, that is, I have 47k samples for training and 47k samples for testing in 10 different configurations.\nI usually use the Libsvm's script easy.py to classify the data, but it's taking so long, I've been waiting for results for more than 3 hours and nothing, and I still have to repeat this procedure more 9 times!\ndoes anybody know how to use the libsvm faster with a very huge amount of data? does the C++ Libsvm functions work faster than the python functions?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3432,"Q_Id":17457460,"Users Score":0,"Answer":"easy.py is a script for training and evaluating a classifier. it does a metatraining for the SVM parameters with grid.py. in grid.py is a parameter \"nr_local_worker\" which is defining the mumber of threads. you might wish to increase it (check processor load).","Q_Score":3,"Tags":"python,c++,svm,libsvm","A_Id":18509671,"CreationDate":"2013-07-03T20:24:00.000","Title":"Large training and testing data in libsvm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Simple question, but I've tried a few things and nothing seems to work.\nI want to overlay some statistics onto a 3d VTK scene, using 2D vtkTextActors. This works fine, but the text is at times difficult to see, depending on what appears behind it in the 3D scene.\nFor this reason, I'd like to add a 2d, semi-transparent \"box\" behind my text actors to provide a darker background.\nWhich VTK object is appropriate for this? I've tried so far:\n\nvtkLegendBoxActor: Not what I want, but I can use this with no text to display a semi-transparent box on screen. I cannot size it directly and I get warnings about not initialising some of the content.\nvtkImageData: Tried manually creating image data and adding it to the scene; I believe it was placed within the 3d scene and not used as an overlay. If that's not the case then I couldn't get it to show at all.\nvtkCornerAnnotation: Scales with window size, is fixed to a corner and the background opacity cannot be set AFAIK.\nvtkTextActor: Cannot set a background color or opacity\n\nCan anyone tell me how they might achieve what I'm after in VTK?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1042,"Q_Id":17461600,"Users Score":0,"Answer":"just use vtktexture, vtkimagedata & add your own image as texture background to the vtkrenderer by reducing the opacity like a watermark. thats it","Q_Score":1,"Tags":"python,vtk","A_Id":25908567,"CreationDate":"2013-07-04T03:53:00.000","Title":"Semi-transparent 2d VTK text background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed OpenERP V 7 on my local machine. I made \u200b\u200bmodification in the CSS. I also remove some menu, change the labels of some windows and change the position of some menus (one after the other in the order decided by the customer).\nThe work required is over and runs well on the premises. Now I'm looking for a way to move my work on the server while keeping the changes. Knowing that I worked directly through the interface of OpenERP.\nSomeone has an idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2217,"Q_Id":17469330,"Users Score":1,"Answer":"This is not a generally accepted way of doing customization in openerp. Ususally, you should make a custom module that implements your customization when installed on the OpenERP server installation.\nAre you using Windows or Linux? The concept here is to move all of the server addons files to the upsite server, including a dump of the database which can be restored on the upsite server.\nHere's how. \nFirst click the Manage databases at the login screen,\nDo a backup database and save the generated dump file.\nInstall openerp o nthe upsite server (*major versions must match).\nCopy the server addons folder, and upload to the upsite server's addon directory.\nRestart openerp service.\nThen restore the dump file from your backup location.\nThis is basically how you can mirror a \"customized\" openerp installation across servers.\nHope this helps.","Q_Score":0,"Tags":"python,xml,postgresql,openerp","A_Id":17473961,"CreationDate":"2013-07-04T11:38:00.000","Title":"after working in local server, how to move OpenERP on a remote server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to validate the user's input of SSID and WPA Passphrase for a WPA connection. My program is a Python program running on an embedded Linux platform. I can validate an Access Point with SSID exists by parsing the output of a iwlist scan subprocess. Validating the Passphrase, however, is less straight forward. So far, the only solution I've come up with is to parse the output of \n\nwpa_supplicant -Dwext -iwlan0 -c\/tmp\/wpa_supplicant.conf\n\nlooking for \n\n\"pre-shared key may be incorrect\"\n\nor the kernel message \n\n\"OnDeAuth Reason code(15)\"\n\n(which means WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT according to the wpa_supplicant source). \nInterpreting a handshake timeout as an invalid Passphrase seems plain wrong. Besides that, that approach requires waiting for some output from a subprocess and assumes the absence of error messages means the Passphrase is valid. \nGoogling around this just returns me a lot of questions and advice on how to hack a WPA connection! There's no wpa_cli or iwevent in the yum repository for my target platform and I'm unsure how to go about getting a third-party python package running on my target. \nQuestion: What's the simplest way of validating the Wifi WPA Passphrase?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1144,"Q_Id":17484086,"Users Score":0,"Answer":"Well, a not-so-straightforward (yet the only possible) way to go about fulfilling your needs would be initiating a four-way handshake with the AP.\nSince you're coding in Python, Scapy would be your best option for crafting EAPOL message packets.\nYou'll have to know the structure of the EAPOL packets though, and fully implement it in your code.\nYou'll also have to recode, in Python, the functions for key generation, most (if not all) of which are PRFs **(Pseudo Random Functions); alternatively, you could import ready-compiled .DLL's to do the encoding for you.\nHowever, it would be enough to manage only the first 3 messages from the four-way handshake:\nIf, after several connection attempts, the AP doesn't send the 3rd key message, then the MIC (Message Integrity Check) from the STA didn't match the one generated by the AP, and the password is thus invalid.\nOtherwise, it is.\nNote: wpa_supplicant follows the same procedure for authentication and connection, however it continues on for obtaining extra information like IP address and what not... That's why I said it's the only possible way.","Q_Score":1,"Tags":"linux,python-2.7,wifi,wpa","A_Id":17960144,"CreationDate":"2013-07-05T08:09:00.000","Title":"How to programatically validate WPA passphrase on Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"It would be convenient when distributing applications to combine all of the eggs into a single zip file so that all you need to distribute is a single zip file and an executable (some custom binary that simply starts, loads the zip file's main function and kicks python off or similar). \nI've seen some talk of doing this online, but no examples of how to actually do it.\nI'm aware that you can (if it is zip safe) convert eggs into zip files.\nWhat I'm not sure about is:\nCan you somehow combine all your eggs into a single zip file? If so, how?\nHow would you load and run code from a specific egg?\nHow would you ensure that the code in that egg could access all the dependencies (ie. other eggs in the zip file)?\nPeople ask this sort of stuff a lot and get answers like; use py2exe. Yes, I get it, that's one solution. It's not the question I'm asking here though...","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":43916,"Q_Id":17486578,"Users Score":1,"Answer":"Yes, one zip-file\/egg can provide multiple modules, so you can combine them into one file. I'm however highly skeptical to that being a good idea. You still need to install that zip-file, and it may still clash with other already installed versions, etc.\nSo the first question to ask is what the aim is. Why do you want just one file? Is it for ease of install, or ease of distribution, or what?\nHaving just one file will not really make the install easier, there are other, better ways. You can let the install download and install the dependencies automatically, that's easy to do.\nAnd having them in one zip-file still means you need to expand that zip-file and run setup.py, which isn't very userfriendly.\nSo having just one file doesn't really solve many problems, so the question is which problem you are trying to solve.","Q_Score":44,"Tags":"python,setup.py,pypi","A_Id":17486777,"CreationDate":"2013-07-05T10:23:00.000","Title":"How can you bundle all your python code into a single zip file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create a python server that can accept multiple job requests.  Then from those it requests, it processes each Job one at a time but the server can still accept new Jobs while processing a task. \nDoes anyone have an suggestions on how to do this?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":455,"Q_Id":17487208,"Users Score":1,"Answer":"Sure.  Create a multiprocessing.Pool which will by default spawn one process per core.  Then use the original process to run an HTTP service or something else that accepts jobs via some protocol.  The main process then listens for new requests and submits them to the pool for async processing.","Q_Score":1,"Tags":"python,queue","A_Id":17487423,"CreationDate":"2013-07-05T10:54:00.000","Title":"Python Server, Job Queue, Launch Multiprocessing Job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that many large-scale applications such as video games are created using multiple langages. For example, it's likely the game\/physics engines are written in C++ while gameplay tasks, GUI are written in something like Python or Lua. \nI understand why this division of roles is done; use lower-level languages for tasks that require extreme optimization, tweaking, efficiency and speed, while using higher-level languages to speed up production time, reduce nasty bugs ect.\nRecently, I've decided to undertake a larger personal project and would like to divy-up parts of the project similar to above. At this point in time, I'm really confused about how this interoperability between languages (especially compiled vs interpreted) works. \nI'm quite familiar with the details of going from ANSCII code test to loading an executable, when written in something like C\/C++. I'm very curious at how something like a video game, built from many different languages, works. This is a large\/broad question, but specifically I'm interested in:\n\nHow does the code-level logic work? I.e. how can I call Python code from a C++ program? Especially since they don't support the same built-in types?\nWhat does the program image look like? From what I can tell, a video game is running in a single process, so what does the runtime image look like when running a C\/C++ program that calls a Python function?\nIf calling code from an interpreted language from a compiled program, what are the sequence of events that occur? I.e If I'm inside my compiled executable, and for some reason have a call to an interpreted language inside a loop, do I have to wait for the interpreter every iteration?\n\nI'm actually finding a hard time finding information on what happening at the machine-level, so any help would be appreciated. Although I'm curious in general about interoperation of software, I'm specifically interested in C++ and Python interaction.\nThank you very much for any insight, even if it's just pointing me to where I can find more information.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1114,"Q_Id":17507004,"Users Score":3,"Answer":"In the specific case of python, you have basically three options (and this generally applies across the board):\n\nHost python in C++: From the perspective of the C++ programme, the python interpreter is a C library. On the python side, you may or may not need to use something like ctypes to expose the C(++) api.\nPython uses C++ code as DLLs\/SOs - C++ code likely knows nothing of python, python definitely has to use a foreign function interface.\nInterprocess communication - basically, two separate processes run, and they talk over a socket. These days you'd likely use some kind of web services architecture to accomplish this.","Q_Score":8,"Tags":"c++,python,game-engine,language-interoperability","A_Id":17507117,"CreationDate":"2013-07-06T20:49:00.000","Title":"How interoperability works","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I wonder how I can create a PyObject in C++ and then return it to Python.\nSadly the documentation is not very explicit about it.\nThere is no PyObject_Create so I wonder whether allocating sizeof(PyObject) via PyObject_Malloc and initializing the struct is sufficient.\nFor now I only need an object with functions attached.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":360,"Q_Id":17511310,"Users Score":1,"Answer":"Do you really want a (1) PyObject, as in what Python calls object, or (2) an object of some subtype? That you \"need an object with functions attached\" seems to indicate you want either methods or attributes. That needs (2) in any case. I'm no expert on the C API, but generally you'd define your own PyTypeObject, then create an instance of that via PyObject_New (refcount and type field are initialized, other fields you might add are not).","Q_Score":1,"Tags":"python,python-3.x,pyobject","A_Id":17511486,"CreationDate":"2013-07-07T10:26:00.000","Title":"Create a PyObject with attached functions and return to Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am aiming to change the a part of the Tkinter screen when a button is clicked.  Do I have to destroy the screen then redraw it (to create the illusion that only a part is being changed?) Or can I keep the button there and somehow only change one part (like the graphics.) Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":881,"Q_Id":17517961,"Users Score":0,"Answer":"No, you do not have to destroy the screen and redraw it. You can easily insert widgets into the current window when a button is clicked. There's nothing special about being run from a button click -- the code is the same as your initialization code.","Q_Score":0,"Tags":"python,tkinter","A_Id":17518474,"CreationDate":"2013-07-08T01:16:00.000","Title":"Changing Tkinter Screen when button is clicked?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As a biology undergrad i'm often writing python software in order to do some data analysis. The general structure is always :\nThere is some data to load, perform analysis on (statistics, clustering...) and then visualize the results. \nSometimes for a same experiment, the data can come in different formats, you can have different ways to analyses them and different visualization possible which might or not depend of the analysis performed. \nI'm struggling to find a generic \"pythonic\" and object oriented way to make it clear and easily extensible. It should be easy to add new type of action or to do slight variations of existing ones, so I'm quite convinced that I should do that with oop.\nI've already done a Data object with methods to load the experimental data. I plan to create inherited class if I have multiple data source in order to override the load function.\nAfter that... I'm not sure. Should I do a Analysis abstract class with child class for each type of analysis (and use their attributes to store the results) and do the same for Visualization with a general Experiment object holding the Data instance and the multiple Analysis and Visualization instances ? Or should the visualizations be functions that take an Analysis and\/or Data object(s) as parameter(s) in order to construct the plots ? Is there a more efficient way ? Am I missing something ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2039,"Q_Id":17522492,"Users Score":5,"Answer":"Your general idea would work, here are some more details that will hopefully help you to proceed:\n\nCreate an abstract Data class, with some generic methods like load, save, print etc.\nCreate concrete subclasses for each specific form of data you are interested in. This might be task-specific (e.g. data for natural language processing) or form-specific (data given as a matrix, where each row corresponds to a different observation)\nAs you said, create an abstract Analysis class. \nCreate concrete subclasses for each form of analysis. Each concrete subclass should override a method process which accepts a specific form of Data and returns a new instance of Data with the results (if you think the form of the results would be different of that of the input data, use a different class Result)\nCreate a Visualization class hierarchy. Each concrete subclass should override a method visualize which accepts a  specific instance of Data (or Result if you use a different class) and returns some graph of some form.\n\nI do have a warning: Python is abstract, powerful and high-level enough that you don't generally need to create your own OO design -- it is always possible to do what you want with mininal code using numpy, scipy, and matplotlib, so before start doing the extra coding be sure you need it :)","Q_Score":8,"Tags":"python,oop,scientific-computing","A_Id":17598977,"CreationDate":"2013-07-08T08:53:00.000","Title":"Object-oriented scientific data processing, how to cleverly fit data, analysis and visualization in objects?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm really new to coding, programming, Python, and just computers in general, so I need some help with Canopy. I've been having pretty consistent troubles installing any packages to Canopy; some stuff is in the internal package manager,but whenever it isn't, it's really confusing. I guess I'll list a specific installation. \nI'm trying to install \"pywcs\" (link provided below) to my Win7 64-bit machine. I have Cygwin if that helps at all. I do not know how to go about this; the stuff I found online is pretty confusing, and Cygwin easy_install (filename) never seems to work. Any step-by-step solutions?","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":14628,"Q_Id":17533094,"Users Score":3,"Answer":"sometimes installing packages can be hard for enthought canopy . You could install all python packages using pip install mrjob command on the its own canopy command prompt\n\nGo to tools tab on the canopy editor ,\nLeft click on the canopy command prompt ,\nFinally pip install <package name>   and hit Enter key","Q_Score":4,"Tags":"python,installation,package,enthought,canopy","A_Id":45376116,"CreationDate":"2013-07-08T18:02:00.000","Title":"Installing a package to Canopy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a scrollable wx.textcontrol widget that updates during the course of the program. Whenever the text is updated,the scrollbar resets to the top of the screen. I don't want that to happen, but I can't figure out how to stop it. Does any of you know?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":70,"Q_Id":17535252,"Users Score":2,"Answer":"Just keep track of the line that you are on\/or has been updated and call EnsureVisible on the text control.  (Also ensure you are using Append rather than Set to add new text).\nCorrection, (now I have access to the help files), I was getting mixed up with MakeCellVisible from Grid controls:\nYourTextCtrl.ShowPositon(YourTextCtrl.GetLastPosition()) should do the job nicely.\nEven better if you call SetInsertionPointEnd() on your text control before the text is inserted, (by using WriteText), then your problem goes away.","Q_Score":0,"Tags":"python,wxpython","A_Id":17535320,"CreationDate":"2013-07-08T20:18:00.000","Title":"Scroll bar problems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"TFIDFVectorizer takes so much memory ,vectorizing 470 MB of 100k documents takes over 6 GB , if we go 21 million documents it will not fit 60 GB of RAM we have.\nSo we go for HashingVectorizer but still need  to know how to distribute the hashing vectorizer.Fit and partial fit does nothing so how to work with Huge Corpus?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4523,"Q_Id":17536394,"Users Score":1,"Answer":"One way to overcome the inability of HashingVectorizer to account for IDF is to index your data into elasticsearch or lucene and retrieve termvectors from there using which you can calculate Tf-IDF.","Q_Score":3,"Tags":"python,numpy,machine-learning,scipy,scikit-learn","A_Id":28424354,"CreationDate":"2013-07-08T21:36:00.000","Title":"How can i reduce memory usage of Scikit-Learn Vectorizers?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a frame with buttons and plotting options and wanted to include a table as well in that frame. Is there any example or suggestion on how to do it?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":17539441,"Users Score":0,"Answer":"You would use a wx.grid.Grid in most cases. You could use a wx.ListCtrl or an ObjectListView widget too. The idea is to put the widgets inside of sizers. So you could have a top level BoxSizer in vertical orientation that contains another sizer or sizers. In this case, I would create a sizer to hold the buttons and nest that sizer in the top level sizer. Then add the table (i.e. grid) to the top level sizer and you're done.","Q_Score":0,"Tags":"python-2.7,wxpython","A_Id":17550349,"CreationDate":"2013-07-09T03:31:00.000","Title":"How to insert a table inside a frame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a frame with buttons and plotting options and wanted to include a table as well in that frame. Is there any example or suggestion on how to do it?\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":88,"Q_Id":17539441,"Users Score":0,"Answer":"The wxpython demo is full of examples of all differant controls.","Q_Score":0,"Tags":"python-2.7,wxpython","A_Id":17547609,"CreationDate":"2013-07-09T03:31:00.000","Title":"How to insert a table inside a frame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to build Python 3.3.2 from scratch on my SLE 11 (OpenSUSE).\nDuring the compilation of Python I got the message that the modules _bz2, _sqlite and _ssl have not been compiled.\nI looked for solutions with various search engines. It is often said that you have to install the -dev packages with your package management system, but I have no root access.\nI downloaded the source packages of the missing libs, but I have no idea how to tell Python to use these libs. Can somebody help me?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":17546628,"Users Score":0,"Answer":"I don't use that distro, but Linux Mint (it's based on Ubuntu).\nIn my case before the compilation of Python 3.3.2 I've installed the necessary -dev libraries:\n $ sudo apt-get install libssl-dev\n $ sudo apt-get install libbz2-dev\n ...\nThen I've compiled and installed Python and those imports work fine.\nHope you find it useful\nLe\u00f3n","Q_Score":1,"Tags":"python-3.x,sqlite,ssl,compilation,non-admin","A_Id":17979292,"CreationDate":"2013-07-09T11:05:00.000","Title":"How to build python 3.3.2 with _bz2, _sqlite and _ssl from source","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry for the sort of general question, but I'm having a hard time figuring out how to start this. I'm trying to incorporate some natural language toolkit code in Python with a mobile app I'm developing in Unity. It's a very small amount of code, but it's critical for the functioning of the app. \nDo I need to have the python code running on some kind of server? How would I go about doing this? I'm very new to python and mobile development. \nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":17549279,"Users Score":0,"Answer":"Traditional\/classic Python is implemented in C. This makes it easy to integrate into any environment that has support for compiled C.\nI'm unfamiliar with Unity, but here are some general guidelines on how you would do it with standard iOS and Android.  On iOS, you would just add all of the Python C source files (minus the ones that have a 'main' function) to your project in Xcode. On Android, you would add all of the C source files (again, minus the ones that have a 'main' function) to your project in the JNI part of your project and would use ndk-build to build a native shared library that would be part of your app.\nAre you limited to Python? If not, you might want to have a look at Lua as it's much smaller (fewer C source files) and might be quicker to get going.","Q_Score":0,"Tags":"python,mobile,unity3d,nltk","A_Id":17551204,"CreationDate":"2013-07-09T13:20:00.000","Title":"How can I incorporate Python code in a mobile app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the best way to a text based output in a Qt widget? what I mean by this is... like in win RAR or some windows installers where there is a drop down arrow showing more details and it shows live text output of files modified and things of that nature. how would I go about doing that in a Qt app?  \nI was thinking maybe a none editable multiple line text box... but I'm not sure, because I don't wan't it to be editable. \nany help on this would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":590,"Q_Id":17555111,"Users Score":1,"Answer":"QLabel\nQTextDocument\nQTextEdit\nAlmost all of the options above, can be configured to be \"Read-only\" or even unclickable by making them disabled.\nQTextStream is also a really useful class.\nHope that helps.","Q_Score":0,"Tags":"python,qt,pyside","A_Id":17557946,"CreationDate":"2013-07-09T18:01:00.000","Title":"how to make a Qt text output widget?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I just deployed my first ever web app and I am curious if there is an easy way to track every time someone visits my website, well I am sure there is but how?","AnswerCount":4,"Available Count":1,"Score":0.2449186624,"is_accepted":false,"ViewCount":11232,"Q_Id":17559967,"Users Score":5,"Answer":"PythonAnywhere Dev here. You also have your access log. You can click through this from your web app tab. It shows you the raw data about your visitors. I would personally also use something like Google Analytics. However you don't need to do anything to be able to just see your raw visitor data. It's already there.","Q_Score":9,"Tags":"python,flask,pythonanywhere","A_Id":17579664,"CreationDate":"2013-07-09T23:24:00.000","Title":"how do I track how many users visit my website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to find words that have consecutive letter pairs using regex.\nI know for just one consecutive pair like zoo (oo), puzzle (zz), arrange (rr), it can be achieved by '(\\w){2}'. But how about\n\ntwo consecutive pairs:   committee (ttee) \nthree consecutive pairs:   bookkeeper (ookkee) \n\nedit:\n\n'(\\w){2}' is actually wrong, it finds any two letters instead of a double letter pair.\nMy intention is to find the words that have letter pairs, not the pairs.\nBy 'consecutive', I mean there is no other letter between letter pairs.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":12433,"Q_Id":17560658,"Users Score":1,"Answer":"For detecting 2-or-more consecutive letters the regex becomes: (\\w)\\1+","Q_Score":6,"Tags":"python,regex","A_Id":24908840,"CreationDate":"2013-07-10T00:43:00.000","Title":"python: how to find consecutive pairs of letters by regex?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Install QPython from Google Play store\nOpen QPython, slide right and click \"Console\"\nTry some code, starting with import androidhelper\nu0_a98@android:\/ $ python\nPython 2.7.2 (default, Jun 3 2013, 20:01:13)\n[GCC 4.4.3] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\nimport androidhelper\n      Traceback (most recent call last):\n        File \"\", line 1, in \n        File \"\/storage\/sdcard0\/com.hipipal.qpyplus\/lib\/site-packages\/androidhelper.py\", line 43, in \n          import sl4a\n      ImportError: No module named sl4a\n\n\n\n\nI'm running Cyanogenmod 10.0.0, Android 4.1.2.  Any idea how to import androidhelper successfully?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3999,"Q_Id":17569671,"Users Score":0,"Answer":"Install the latest from the Google Play store.  I'm not getting this error using QPython (classic, not QPython3).","Q_Score":2,"Tags":"system,qpython","A_Id":31173913,"CreationDate":"2013-07-07T17:45:00.000","Title":"Why does qpython say \"No module named sl4a\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a fairly simple Python program as outlined below:\nIt has 2 threads plus the main thread. One of the threads collects some data and puts it on a Queue. \nThe second thread takes stuff off the queue and logs it. Right now it's just printing out the stuff from the queue, but I'm working on adding it to a local MySQL database.\nThis is a process that needs to run for a long time (at least a few months). \nHow should I deal with the database connection? Create it in main, then pass it to the logging thread, or create it directly in the logging thread? And how do I handle unexpected situations with the DB connection (interrupted, MySQL server crashes, etc) in a robust manner?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":17578630,"Users Score":0,"Answer":"How should I deal with the database connection? Create it in main,\n  then pass it to the logging thread, or create it directly in the\n  logging thread?\n\nI would perhaps configure your logging component with the class that creates the connection and let your logging component request it. This is called dependency injection, and makes life easier in terms of testing e.g. you can mock this out later. \nIf the logging component created the connections itself, then testing the logging component in a standalone fashion would be difficult. By injecting a component that handles these, you can make a mock that returns dummies upon request, or one that provides connection pooling (and so on).\nHow you handle database issues robustly depends upon what you want to happen. Firstly make your database interactions transactional (and consequently atomic). Now, do you want your logger component to bring your system to a halt whilst it retries a write. Do you want it to buffer writes up and try out-of-band (i.e. on another thread) ? Is it mission critical to write this or can you afford to lose data (e.g. abandon a bad write). I've not provided any specific answers here, since there are so many options depending upon your requirements. The above details a few possible options.","Q_Score":1,"Tags":"python,mysql,database,multithreading","A_Id":17578684,"CreationDate":"2013-07-10T18:49:00.000","Title":"Architechture of multi-threaded program using database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have wrote a list in to a file, how can i get it back as old array list. \nlist looks like this\n\n['82294', 'ABDUL', 'NAVAS', 'B', 'M', 'MSCS', 'CUKE', '30',\n      'Kasargod', 'CU', 'Kerala', 'Online', 'PG-QS-12', '15', 'June,',\n      '2013', '12.00', 'Noon', '-', '02.00', 'PM\\n', '29']\n['82262', 'ABDUL', 'SHAFWAN', 'T', 'H', 'MSCS', 'CUKE', '30',\n          'Kasargod', 'CU', 'Kerala', 'Online', 'PG-QS-12', '15', 'June,',\n          '2013', '12.00', 'Noon', '-', '02.00', 'PM\\n', '29']\n\nwhen i read the file, it does consider as a string list,\nfor eg:\nconsider first list:\nvar[0][0] should be 82294 not '\ni am a python noob,","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":17578668,"Users Score":1,"Answer":"You can read the file line by line.  For each line you can then eval it, or use json.loads to unpack it.","Q_Score":0,"Tags":"python,python-2.7","A_Id":17578834,"CreationDate":"2013-07-10T18:51:00.000","Title":"Get array list from file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in deep trouble at the moment. After every letter I type on my python \ncommand prompt in Linux, I get an error message:\nsys:1: GtkWarning: Attempting to store changes into `\/u\/rnayar\/.recently-used.xbel', but failed: Failed to create file '\/u\/rnayar\/.recently-used.xbel.L6ETZW': Too many open files\nHence I can type nothing on python, and the prompt is stuck.\nI tried to open 185 fits files, containing some data, and feed in some of that data into an\narray. I cannot abandon the command window, because I already have significant amounts of information stored on it.\nDoes anybody know how I can stop the error message and get it working as usual?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":17584635,"Users Score":0,"Answer":"Try opening and storing information from one file at a time?  We dont have enough information to understand what is wrong with your code.  We really dont have much more than \"I tried to open 185 fits files\"  and \"too many open files\"","Q_Score":0,"Tags":"python,cmd,warnings,indefinite","A_Id":17585244,"CreationDate":"2013-07-11T03:35:00.000","Title":"infinite error message python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on smartcard based application with smartcard reader, here whenever I flash the card i should get the card UID, based on that I need to retrieve the details from database.\nFor this need how do i start, whether i need to create service on windows which always run background or is there a way to detect an event on OS or any scheduler program.\nI am able to get UID and related but i need to run the program externally.\nPlease suggest me on this issue, Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":422,"Q_Id":17585932,"Users Score":0,"Answer":"If you are using a USB or serial connection  to connect your card reader to pc, .you can use datareceived event of Serial port class.","Q_Score":2,"Tags":"python,windows,python-2.7,smartcard,rfid","A_Id":25094663,"CreationDate":"2013-07-11T05:49:00.000","Title":"How to detect the event when smart card scanned","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running a temporary Django app on a host that has lots of IP addresses. When using manage.py runserver 0.0.0.0:5000, how can the code see which of the many IP addresses of the machine was the one actually hit by the request, if this is even possible?\nOr to put it another way:\nMy host has IP addresses 10.0.0.1 and 10.0.0.2. When runserver is listening on 0.0.0.0, how can my application know whether the user hit http:\/\/10.0.0.1\/app\/path\/etc or http:\/\/10.0.0.2\/app\/path\/etc?\nI understand that if I was doing it with Apache I could use the Apache environment variables like SERVER_ADDR, but I'm not using Apache.\nAny thoughts?\nEDIT\nMore information:\nI'm testing a load balancer using a small Django app. This app is listening on a number of different IPs and I need to know which IP address is hit for a request coming through the load balancer, so I can ensure it is balancing properly.\nI cannot use request.get_host() or the request.META options, as they return what the user typed to hit the load balancer.\nFor example: the user hits http:\/\/10.10.10.10\/foo and that will forward the request to either http:\/\/10.0.0.1\/foo or http:\/\/10.0.0.2\/foo - but request.get_host() will return 10.10.10.10, not the actual IPs the server is listening on.\nThanks,\nBen","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10672,"Q_Id":17595066,"Users Score":0,"Answer":"If your goal is to ensure the load balancer is working correctly, I suppose it's not an absolute requirement to do this in the application code. You can use a network packet analyzer that can listen on a specific interface (say, tcpdump -i <interface>) and look at the output.","Q_Score":6,"Tags":"python,django,manage.py","A_Id":17599320,"CreationDate":"2013-07-11T13:44:00.000","Title":"Django runserver bound to 0.0.0.0, how can I get which IP took the request?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"To do a work i want to identify the type of file. But the files are without extension.The files may be txt,jpeg,mp3,pdf etc. Using c or c++ or python how can i check whether it is a jpeg or pdf or mp3 file?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":250,"Q_Id":17597842,"Users Score":1,"Answer":"Some files, such as .exe, .jpg, .mp3, contain a header (first few bytes of the file).  You can inspect the header and infer the file type from that.  \nOf course, some files, such as raw text, depending on their encoding, may have no header at all.","Q_Score":1,"Tags":"c++,python,c","A_Id":17597883,"CreationDate":"2013-07-11T15:44:00.000","Title":"how to identify the type of files having no extension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in the midst of writing a web app in CherryPy.  I have set it up so that it uses OpenID auth, and can successfully get user's ID\/email address.\nI would like to have it set so that whenever a page loads, it checks to see if the user is logged in, and if so displays some information about their login.\nAs I see it, the basic workflow should be like this:\n\nIs there a userid stored in the current session?  If so, we're golden.\nIf not, does the user have cookies with a userid and login token? If so, process them, invalidate the current token and assign a new one, and add the user information to the session.  Once again, we're good.\nIf neither condition holds, display a \"Login\" link directing to my OpenID form.\n\nObviously, I could just include code (or a decorator) in every public page that would handle this.  But that seems very... irritating.\nI could also set up a default index method in each class, which would do this and then use a (page-by-page) helper method to display the rest of the content.  But this seems like a nightmare when it comes to the occasional exposed method other than index.\nSo, my hope is this: is there a way in CherryPy to set some code to be run whenever a request is received?  If so, I could use this to have it set up so that the current session always includes all the information I need.\nAlternatively, is it safe to create a wrapper around the cherrypy.expose decorator, so that every exposed page also runs this code?\nOr, failing either of those: I'm also open to suggestions of a different workflow.  I haven't written this kind of system before, and am always open to advice.\n\nEdit: I have included an answer below on how to accomplish what I want.  However, if anybody has any workflow change suggestions, I would love the advice!  Thanks all.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":313,"Q_Id":17606646,"Users Score":2,"Answer":"Nevermind, folks.  Turns out that this isn't so bad to do; it is simply a matter of doing the following:\n\nWrite a function that does what I want.\nMake the function in to a custom CherryPy Tool, set to the before_handler hook.\nEnable that tool globally in my config.","Q_Score":1,"Tags":"python,web,cherrypy","A_Id":17606832,"CreationDate":"2013-07-12T02:35:00.000","Title":"Checking login status at every page load in CherryPy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Was wondering if anyone knew how if it was possible to enable programmatic billing for Amazon AWS through the API?  I have not found anything on this and I even went broader and looked for billing preferences or account settings through API and still had not luck.  I assume the API does not have this functionality but I figured I would ask.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":356,"Q_Id":17627389,"Users Score":0,"Answer":"Currently, there is no API for doing this.  You have to log into your billing preference page and set it up there.  I agree that an API would be a great feature to add.","Q_Score":0,"Tags":"python,amazon-web-services,boto","A_Id":17630560,"CreationDate":"2013-07-13T05:51:00.000","Title":"Enable programmatic billing for Amazon AWS through API (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a project I'm creating (in python 3.3) and I'm trying to figure out if there is a efficient (or prettier way) to do the following.\nI have a function that extracts binary\/hex strings like the following (groups of bits are split for example purposes only)\n\n0000 1111 0002 0001\n0000 1111 0003 0001 \n0000 1111 0002 0002\n0000 1110 0002 0001\n\nNow, what I want to do is to be able to pass these into a function and then fire them into a method depending on the values in the second group of bits, and the forth group of bits (that are opcodes)\neg; a hash function that will check to see if (* 1111 * 0001) matches and then return a function related to these bits.\nI had the idea of using a dictionary of hash tables, however I'm not fully sure how one would make a key a mask. \nWhile I could make a dictionary with the key 11110001 and the value the function I want to return, and then just concatting and passing in [4:8][12:16] would work, I was wondering if there was a way to make a hash function for a key. (if that makes sense) without going into a class and overriding the hash function and then passing that in.\nPerhaps some form of data structure that stores regex keys and performs it on any valid input? - Whilst I could create one I'm wondering if there is some form of in-built function I'm missing (just so I don't reinvent the wheel)\nHopefully this makes sense!\nThanks for the help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":17637243,"Users Score":0,"Answer":"Presumably you are actually using the bit values from the examples so why not just derive a dictionary from dictionary that has a new method getmasked which masks the value before looking it up...","Q_Score":0,"Tags":"python,python-3.x","A_Id":17637322,"CreationDate":"2013-07-14T06:52:00.000","Title":"Using a hash function as a key in a dictonary in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to take image frames from a webcam server using selenium python module.\nThe frames webcam is show on the selenium browser ( using http:\/\/ .....html webpage) .\nThe source code of the page show me it's done using some java script.\nI try to use:\ncapture_network_traffic() and captureNetworkTraffic\nNot working , also I don't think is a good way to do that.\nAlso I don't want to use capture_screenshot functions , this take all canvas of the browser.\nAny idea ?\nThank you. Regards.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":439,"Q_Id":17641441,"Users Score":0,"Answer":"First, what you'll need to do is navigate to the webpage with Selenium.\nThen, analyse the web page source HTML which the Javascript will have rendered by you navigating to the page, to get the image URL. You can do this with Selenium or with an HTML parser.\nThen you can easily download the image using wget or some other URL grabber.\nYou might not even need Selenium to accomplish this if when you get the page, the image is already there. If that is the case you can just use the URL grabber to get the page directly.\nLet me know if you want more details or if you have any questions.","Q_Score":0,"Tags":"python-2.7,selenium,selenium-webdriver","A_Id":17718816,"CreationDate":"2013-07-14T16:47:00.000","Title":"get image frames webcam from server with selenium python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently, I've been attempting to figure out how I can find out what an unlabeled POST is, and send to it using Python.\nThe issue of the matter is I'm attempting to make a chat bot entirely in Python in order to increase my knowledge of the language.  For said bot, I'm attempting to use a chat-box that runs entirely on jQuery.  The issue with this is it has no knowledgeable POST or GET statements associated with the chat-box submissions.\nHow can I figure out what the POST and GET statements being sent when a message is submitted, and somehow use that to my advantage to send custom POST or GET statements for a chat-bot?\nAny help is appreciated, thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":17646259,"Users Score":0,"Answer":"You need a server in order to be able to receive any GET and POST requests, one of the easier ways to get that is to set up a Django project, ready in minutes and then add custom views to handle the request you want properly.","Q_Score":0,"Tags":"python,post,get,chat","A_Id":17646320,"CreationDate":"2013-07-15T03:16:00.000","Title":"Python Send to and figure out POST","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning about Python socket, http request\/reponse handling these days, I'm still very novice to server programming, I have a question regarding to the fundamental idea behind chatting website.\nIn chatting website, like Omegle or Facebook's chat, how do 2 guys talk to each other? Do sockets on their own computers directly connect to each other, OR... guy A send a message to the web server, and server send this message to guy B, and vice versa?\nBecause in the first scenario, both users can retrieve each other's IP, and in the second scenario, since you are connecting to a server, you can not.. right?\nThanks a lot to clear this confusion for me, I'm very new and I really appreciate any help from you guys!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":187,"Q_Id":17646806,"Users Score":0,"Answer":"Most chats will use a push notification system.  It will keep track of people within a chat, and as it receives a new message to the chat, it will push it to all the people currently in it.  This protects the users from seeing each other.","Q_Score":1,"Tags":"python,node.js,websocket,chat","A_Id":17646861,"CreationDate":"2013-07-15T04:31:00.000","Title":"the idea behind chat website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning about Python socket, http request\/reponse handling these days, I'm still very novice to server programming, I have a question regarding to the fundamental idea behind chatting website.\nIn chatting website, like Omegle or Facebook's chat, how do 2 guys talk to each other? Do sockets on their own computers directly connect to each other, OR... guy A send a message to the web server, and server send this message to guy B, and vice versa?\nBecause in the first scenario, both users can retrieve each other's IP, and in the second scenario, since you are connecting to a server, you can not.. right?\nThanks a lot to clear this confusion for me, I'm very new and I really appreciate any help from you guys!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":187,"Q_Id":17646806,"Users Score":0,"Answer":"Usually they both connect to the server.\nThere are a few reasons to do it this way. For example, imagine you want your users to see the last 10 messages of a conversation. Who's going to store this info? One client? Both? What happens if they use more than one PC\/device? What happens if one of them is offline? Well, you will have to send the messages to the server, this way the server will have the conversation history stored, always available.\nAnother reason, imagine that one user is offline. If the user is offline you can't do anything to contact him. You can't connect. So you will have to send messages to the server, and the server will notify the user once online.\nSo you are probably going to need a connection to the server (storing common info, providing offline messages, keeping track of active users...). \n\nThere is also another reason, if you want two users to connect directly, you need one of them to start a server listening on a (public IP):port, and let the other connect against that ip:port. Well, this is a problem. If you use the clients->server model you don't have to worry about that, because you can open a port in the server easily, for all, without routers and NAT in between.","Q_Score":1,"Tags":"python,node.js,websocket,chat","A_Id":17649514,"CreationDate":"2013-07-15T04:31:00.000","Title":"the idea behind chat website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating simple search engine, so I have one input text field on the top of the page and buttom \"search\" next to it. That is all in one form, and \"produce\" for instance\/q=search%20query.\nIn sidebar I have panel with another form with filters, lets say from, to. I want to have a possibility of creating link like \/q=search%20query&from=20&to=50. I wonder how button from first form should gather information from second form.\nI read somewhere that there is something like formsets, however I didn't find information that they can be used to something like that.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":17662714,"Users Score":0,"Answer":"I just come up with an idea, that I can create in first form additional hidden fields, which can be synchronized with fields from second form by JavaScript. This will create small redundancy, however seems to be very easy to implement.\nIs it a good idea?","Q_Score":3,"Tags":"python,django,django-forms,formset","A_Id":17663244,"CreationDate":"2013-07-15T19:54:00.000","Title":"Gathering information from few forms in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"A string \"forum\/123\/topic\/4567\".\nHow can I edit a regular expression to get '123' and '4567' separately?\nI have tried lots of methods on the Internet, but nothing works.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":17664636,"Users Score":0,"Answer":"If you want just the numbers use r'0-9+'. That will give you separated sequences of integers from the input string.","Q_Score":0,"Tags":"python,regex","A_Id":17664727,"CreationDate":"2013-07-15T21:56:00.000","Title":"how to get a part from a string with regular expression in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I've released a small library on pypi, more as an exercise (to \"see how it's done\") than anything else.\nI've uploaded the documentation on readthedocs, and I have a test suite in my git repo.\nSince I figure anyone who might be interested in running the test will probably just clone the repo, and the doc is already available online, I decided not to include the doc and test directories in the released package, and I was just wondering if that was the \"right\" thing to do.\nI know answers to this question will be rather subjective, but I felt it was a good place to ask in order to get a sense of what the community considers to be the best practice.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":384,"Q_Id":17665330,"Users Score":5,"Answer":"It is not required but recommended to include documentation as well as unit tests into the package.\nRegarding documentation:\nOld-fashioned or better to say old-school source releases of open source software contain documentation, this is a (de facto?) standard (have a look at GNU software, for example). Documentation is part of the code and should be part of the release, simply because once you download the source release you are independent. Ever been in the situation where you've been on a train somewhere, where you needed to have a quick look into the documentation of module X but didn't have internet access? And then you relievedly realized that the docs are already there, locally.\nAnother important point in this regard is that the documentation that you bundle together with the code for sure applies to the code version. Code and docs are in sync.\nOne more thing especially regarding Python: you can write your docs using Sphinx and then build beautiful HTML output based on the documentation source in the process of installing the package. I have seen various Python packages doing exactly this.\nRegarding tests:\nImagine the tests are bundled in the source release and are easy to be run by the user (you should document how to do this). Then, if the user observes a problem with your code which is not so easy to track down, he can simply run the unit tests in his environment and see if at least those are passing. If not, you've probably made a wrong assumption when specifying the behavior of your code, which is good to know about. What I want to say is: it can be very good for you as a developer if you make it very simple for the user to execute unit tests.","Q_Score":8,"Tags":"python,packaging","A_Id":17722381,"CreationDate":"2013-07-15T23:01:00.000","Title":"Releasing a python package - should you include doc and tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible, on a linux box, to import dstat and use it as an api to collect OS metrics and then compute stats on them? \nI have downloaded the source and tried to collect some metrics, but the program seems to be optimized for command line usage. \nAny suggestions as to how to get my desired functionality either using Dstat or any another library?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":468,"Q_Id":17667871,"Users Score":2,"Answer":"The Dstat source-code includes a few sample programs using Dstat as a library.","Q_Score":2,"Tags":"python,linux,operating-system,profiling","A_Id":17770525,"CreationDate":"2013-07-16T04:11:00.000","Title":"DSTAT as a Python API ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been writing command line applications (mainly in Python) for quite a while now, and I've also been doing a bit of GUI programming using (Py)Qt. In the GUI program's I've written, the programs logic and the GUI were often quite integrated. I am now wondering however, how I could write a GUI front end, for the pure command line programs which I've written. Or in other words; how do I write a command line program so that a GUI could be developed completely separate from it?\nAlthough I am most interested in Python implementations I think the answer could be pretty general.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":504,"Q_Id":17676081,"Users Score":0,"Answer":"A simple, probably na\u00efve way could be to structure your CLI program such that its main function accepts your command line arguments, so that you could import it and call it with the options set in the GUI.\nI've never tried it, my guess is that it could work with simple \"pure\" CLI programs (ie, you run it, it does its jobs, and only then prints its output), but could get unwieldy with interactive program needing to prompt the user or with a lot of output.","Q_Score":2,"Tags":"python,user-interface,frontend","A_Id":17677079,"CreationDate":"2013-07-16T12:05:00.000","Title":"How to write a command line program which can be accessed by a separate frontend?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get Python to send the EOF signal (Ctrl+D) via Popen(). Unfortunately, I can't find any kind of reference for Popen() signals on *nix-like systems. Does anyone here know how to send an EOF signal like this? Also, is there any reference of acceptable signals to be sent?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3348,"Q_Id":17678620,"Users Score":5,"Answer":"EOF isn't really a signal that you can raise, it's a per-channel exceptional condition. (Pressing Ctrl+D to signal end of interactive input is actually a function of the terminal driver. When you press this key combination at the beginning of a new line, the terminal driver tells the OS kernel that there's no further input available on the input stream.)\nGenerally, the correct way to signal EOF on a pipe is to close the write channel. Assuming that you created the Popen object with stdin=PIPE, it looks like you should be able to do this.","Q_Score":2,"Tags":"python-2.7,posix,popen,eof","A_Id":17712430,"CreationDate":"2013-07-16T14:00:00.000","Title":"Trying to send an EOF signal (Ctrl+D) signal using Python via Popen()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create an application that will do the following:\n\nAccept request via messaging system ( Done )\nProcess request and determine what script and what type of instance is required for the job ( Done )\nLaunch an EC2 instance \nUpload custom script's (probably from github or may be S3 bucket)\nLaunch a script with a given argument.\n\nThe question is what is the most efficient way to do steps 3,4,5? Don't understand me wrong, right now I'm doing the same thing with script that does all of this \n\nlaunch instance, \nuse user_data to download necessary dependencies\nthan SSH into instance and launch a script\n\nMy question is really: is that the only option how to handle this type of work? or may be there is an easy way to do this?\nI was looking at OpsWork, and I'm not sure if this is the right thing for me. I know I can do steps 3 and 4 with it, but how about the rest? :\n\nLaunch a script with a given argument\nTriger an OpsWork to launch an instance when request is came in\n\nBy the way I'm using Python, boto to communicate with AWS services.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":218,"Q_Id":17686939,"Users Score":1,"Answer":"You can use knife-bootstrap. This can be one way to do it. You can use AWS SDK to do most of it\n\nLaunch an instance\nAdd a public IP (if its not in VPC)\nWait for instance to come back online \nuse knife bootstrap to supply script, setup chef-client, update system\nThen use chef cookbook to setup your machine","Q_Score":0,"Tags":"python,amazon,chef-infra,boto,aws-opsworks","A_Id":17691484,"CreationDate":"2013-07-16T21:04:00.000","Title":"Do I need to SSH into EC2 instance in order to start custom script with arguments, or there are some service that I don't know","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program completed that does the following:\n1)Reads formatted data (a sequence of numbers and associated labels) from serial port in real time.\n2)Does minor manipulations to data.\n3)plots data in real time in a gui I wrote using pyqt.\n4)Updates data stats in the gui.\n5)Allows post analysis of the data after collection is stopped.\nThere are two dialogs (separate classes) that are called from within the main window in order to select certain preferences in plotting and statistics.\nMy question is the following:  Right now my data is read in and declared as several global variables that are appended to as data comes in 20x per second or so - a 2d list of values for the numerical values and 1d lists for the various associated text values.  Would it be better to create a class in which to store data and its various attributes, and then to use instances of this data class to make everything else happen - like the plotting of the data and the statistics associated with it?\nI have a hunch that the answer is yes, but I need a bit of guidance on how to make this happen if it is the best way forward.  For instance, would every single datum be a new instance of the data class?  Would I then pass them one by one or as a list of instances to the other classes and to methods?  How should the passing most elegantly be done?\nIf I'm not being specific enough, please let me know what other information would help me get a good answer.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":184,"Q_Id":17709153,"Users Score":2,"Answer":"A reasonably good rule of thumb is that if what you are doing needs more than 20 lines of code it is worth considering using an object oriented design rather than global variables, and if you get to 100 lines you should already be using classes.  The purists will probably say never use globals but IMHO for a simple linear script it is probably overkill.\nBe warned that you will probably get a lot of answers expressing horror that you are not already.\nThere are some really good, (and some of them free), books that introduce you to object oriented programming in python a quick google should provide the help you need.\nAdded Comments to the answer to preserve them:\nSo at 741 lines, I'll take that as a yes to OOP:) So specifically on the data class. Is it correct to create a new instance of the data class 20x per second as data strings come in, or is it more appropriate to append to some data list of an existing instance of the class? Or is there no clear preference either way? \u2013 TimoB\nI would append\/extend your existing instance. \u2013 seth\nI think I see the light now. I can instantiate the data class when the \"start data\" button is pressed, and append to that instance in the subsequent thread that does the serial reading. THANKS! \u2013 TimoB","Q_Score":1,"Tags":"python,user-interface,pyqt","A_Id":17709406,"CreationDate":"2013-07-17T20:01:00.000","Title":"python program structure and use of global variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"Exactly what the title says.  If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0.  Is there any way to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":10714,"Q_Id":17709751,"Users Score":0,"Answer":"I don't think there is any way to do this. datetime.datetime.min says 1 is the min value for year.","Q_Score":2,"Tags":"python,datetime","A_Id":17709832,"CreationDate":"2013-07-17T20:37:00.000","Title":"how make a datetime object in year 0 with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Exactly what the title says.  If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0.  Is there any way to do this?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":10714,"Q_Id":17709751,"Users Score":4,"Answer":"from the docs\n\nThe datetime module exports the following constants:\ndatetime.MINYEAR The smallest year number allowed in a date or\n  datetime object. MINYEAR is 1.\ndatetime.MAXYEAR The largest year number allowed in a date or datetime\n  object. MAXYEAR is 9999.","Q_Score":2,"Tags":"python,datetime","A_Id":17709791,"CreationDate":"2013-07-17T20:37:00.000","Title":"how make a datetime object in year 0 with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to have a class written in C++ that acts as a remote procedure call server.\nI have a large (over a gigabyte) file that I parse, reading in parameters to instantiate objects which I then store in a std::map.  I would like the RPC server to listen for calls from a client, take the parameters passed from the client, look up an appropriate value in the map, do a calculation, and return the calculated value back to the client, and I want it to serve concurrent requests -- so I'd like to have multiple threads listening.  BTW, after the map is populated, it does not change.  The requests will only read from it.\nI'd like to write the client in Python.  Could the server just be an HTTP server that listens for POST requests, and the client can use urllib to send them?\nI'm new to C++ so I have no idea how to write the server.  Can anyone point me to some examples?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":674,"Q_Id":17710943,"Users Score":0,"Answer":"Maybe factors can affect the selection.\nOne solution is to use fastcgi.\nClient sends HTTP request to HTTP server that has fastCGI enabled.\nHTP server dispatch the request to your RPC server via the fastcgi mechanism.\nRPC server process and generates response, and sends back to http server.\nhttp server sends the response back to your client.","Q_Score":0,"Tags":"c++,python,map,concurrency,rpc","A_Id":17711039,"CreationDate":"2013-07-17T21:53:00.000","Title":"Concurrent Remote Procedure Calls to C++ Object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way I can import a list from a different Python file?  For example if I have a list:\nlist1  = ['horses', 'sheep', 'cows', 'chickens', 'dog']\nCan I import this list into other files? I know to import other functions you do\nfrom FileName import DefName\nThis is a user defined list and I don't want to have the user input the same list a million times. \nJust a few maybes as to how this could be done:\nfrom FileName import ListName or put all the lists into a function and then import the definition name\nThanks for the help","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":17712632,"Users Score":0,"Answer":"One option is to dump that list into a temp file, and read it from your other python script.\nAnother option (if one python script calls the other), is to pass the list as an argument (e.g. using sys.argv[1] and *args, etc).","Q_Score":0,"Tags":"python-2.7","A_Id":17712665,"CreationDate":"2013-07-18T00:38:00.000","Title":"Import a list from a different file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way I can import a list from a different Python file?  For example if I have a list:\nlist1  = ['horses', 'sheep', 'cows', 'chickens', 'dog']\nCan I import this list into other files? I know to import other functions you do\nfrom FileName import DefName\nThis is a user defined list and I don't want to have the user input the same list a million times. \nJust a few maybes as to how this could be done:\nfrom FileName import ListName or put all the lists into a function and then import the definition name\nThanks for the help","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":17712632,"Users Score":0,"Answer":"I'll just export the lists in a file. Therefore every piece of code can read it.","Q_Score":0,"Tags":"python-2.7","A_Id":18006639,"CreationDate":"2013-07-18T00:38:00.000","Title":"Import a list from a different file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like my python script to use all the free RAM available but no more (for efficiency reasons).  I can control this by reading in only a limited amount of data but I need to know how much RAM is free at run-time to get this right.  It will be run on a variety of Linux systems. Is it possible to determine the free RAM at run-time?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":20527,"Q_Id":17718449,"Users Score":7,"Answer":"You could just read out \/proc\/meminfo. Be aware that the \"free memory\" is usually quite low, as the OS heavily uses free, unused memory for caching.\nAlso, it's best if you don't try to outsmart your OS's memory management. That usually just ends in tears (or slower programs). Better just take the RAM you need. If you want to use as much as you can on a machine with a previously unknown amount of memory, I'd probably check how much RAM is installed (MemTotal in \/proc\/meminfo), leave a certain amount for the OS and as safety margin (say 1 GB) and use the rest.","Q_Score":18,"Tags":"python,memory-management","A_Id":17718746,"CreationDate":"2013-07-18T08:33:00.000","Title":"Determine free RAM in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to understand if it is possible to create reports with X number of columns. X will come from the amenities a hotel have for example. So it will change depending on the hotel selected from a wizard before generating the report.\nLets say Hotel XYZ has 5 amenities I need a report with 5 columns where I will show the payments each guest made for each amenity. Then Hotel YYY will have 10 amenities and I need to do the same but for all 10 amenities.\nWill it be possible to code a report (I am currently using the OpenOffice plugin but anything that work would be fine) flexible enough to do this with OpenERP?\nI am not asking how to do it, I just want to understand the possibilities and limitations.\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":582,"Q_Id":17730406,"Users Score":0,"Answer":"I hope you can use webkit reporting. Any other openerp reporting tools have its limitations for creating dynamic columns.","Q_Score":1,"Tags":"python,report,openerp","A_Id":17739668,"CreationDate":"2013-07-18T17:38:00.000","Title":"Is it possible to generate reports with dynamic columns in OpenERP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Ipython Notebook.  I can cut and paste from other apps into my notebooks, but how do I copy\/paste code out of notebook into a different app?\nI'm accessing a Linux VNC session via Chicken.  I can cut\/paste with wild abandon between OSX\/Linux using both command X\/C\/V and\/or middle mouse button.  I can also copy code into IPython notebook.  I'm stopped dead in my tracks trying to get code out of IpyNotebook.\nUsing Notebook's 'Edit\/Copy Cell' doesn't work, neither does 'Ctrl-m c'.\nI'm running IPython 0.13.1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":12168,"Q_Id":17731701,"Users Score":6,"Answer":"You have to select and copy code using normal Ctrl-C Ctrl-V. 'Edit\/Copy Cell' is a specific action in javascript that does a little more and that browser security policy prevent us to bind with clipboard.","Q_Score":6,"Tags":"ipython-notebook","A_Id":17732561,"CreationDate":"2013-07-18T18:55:00.000","Title":"Possible to copy\/paste from IPython Notebook to other apps?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing code with python that might run wild and do unexpected things. These might include trying to save very large arrays to disk and trying to allocate huge amounts of memory for arrays (more than is physically available on the system).\nI want to run the code in a constrained environment in Mac OSX 10.7.5 with the following rules:\n\nThe program can write files to one specific directory and no others (i.e. it cannot modify files outside this directory but it's ok to read files from outside)\nThe directory has a maximum \"capacity\" so the program cannot save gigabytes worth of data\nProgram can allocate only a finite amount of memory\n\nDoes anyone have any ideas on how to set up such a controlled environment?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":139,"Q_Id":17755621,"Users Score":0,"Answer":"import os\nstats = os.stat('possibly_big_file.txt')\nif (stats.st_size > TOOBIG):\n    print \"Oh no.....\"","Q_Score":0,"Tags":"python,macos,memory,permissions","A_Id":17755743,"CreationDate":"2013-07-19T21:15:00.000","Title":"Can I limit write access of a program to a certain directory in osx? Also set maximum size of the directory and memory allocated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a flask based app, and it's now running with virtualenv on my dev machine. Now I want to deploy it to my virtual host. Sadly, this virtual host is running flask 0.6, and I want flask 0.10. I don't have enough privilege to upgrade it. \nCan I just upload my whole virtual environment, and to use my own version of flask, and how? \nMy idea is change the PYTHONPATH, how to get rid of the old version and add the new into it?\nAny help will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":17758039,"Users Score":0,"Answer":"Uploading your virtualenv probably won't work.  There is a good chance that something in the virtualenv is dependent on the exact file paths and versions that won't match from your machine to the virtual host.\nYou can upload the virtualenv tool, make a new virtualenv, and then install the version of flask you want inside that virtualenv.","Q_Score":0,"Tags":"python,module,virtualenv","A_Id":17758271,"CreationDate":"2013-07-20T02:21:00.000","Title":"how to deploy apps developed in virtual env","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a large Django application made up of a large number of different views (some of which  contain forms). As with most large applications, we use a base layout template that contains the common layout elements across the applications (mainly a header and a footer), which the templates for all of our views extend.\nWhat we are looking to do is create a universal search box in our application, accessible on every page, which allows users to perform searches across the entire application, and want to place the search box inside the header, which involves placing a form inside our base layout template. This means that every view in our application will need to be able to handle the submission of this search form. Once this search form is submitted, we will need to redirect the user to another view containing the search results.\nHowever, we are struggling to come up with a pattern to handle this. Does anyone know of functionality built into Django that will help us to build this? Failing that, can anyone suggest a good strategy for modifying our application so that we can handle  this use-case without having to modify a large number of existing views (which we don't have the resources to do at the moment)?\nPlease note that the focus of this question is intended to be the best way to handle the submission of a form which appears in every view, and not strategies for implementing a universal search algorithm (which we have already figured out).\nIdeas Explored So Far\n\nOur first idea was to create a base View class that implements handling the universal search form submission, and have each of our views extend this. However, this is not possible because we already have views that inherit from a number of different Django view classes (TemplateView, ListView, FormView and DeleteView being some examples), and to be able to build our own common view class would mean either writing our own version of these Django view classes to inherit from our own view base class, or re-writing a large number of our views so they don't use the Django view classes.\nOur next idea was to implement a mixin that would handle the universal search form submission, in an attempt to add this functionality to all our views in a way that allows us to continue using the different Django view classes. However, this brought to light two new problems: (a) how could we do this without modifying each of our views to become a form view, and (b) how can we do this in a way that allows the form handling logic to play nicely when mixed in to existing FormViews?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":624,"Q_Id":17761974,"Users Score":0,"Answer":"It seems like you just need to create another SearchView which takes the query and displays the results.  I am not sure if the results have to be displayed differently depending on which page the search has been performed from but it does not seem like.  \nThe form would not have anything to do with the other views.  You could just hard code it in the base template.","Q_Score":0,"Tags":"python,django,search,inheritance,django-forms","A_Id":17762184,"CreationDate":"2013-07-20T11:51:00.000","Title":"Implementing Universal Search in a Django Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I would like to know from you guys how you have set up your Mac terminal for python programming. I havent done anything big so far (have used ide's until now) with python in terminal but I think that you can do all kinds of fancy things (automatic fill up functions, colors, ...). Any suggestions??\nThanks you guys!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":17767579,"Users Score":1,"Answer":"Assuming that Python is already on your computer:\nGo to \/Applications folder\nThen open Utilities\nDouble Click Terminal to open it and get a command line\ntype 'python' in the command prompt\nYour all set!","Q_Score":0,"Tags":"python,ide,development-environment","A_Id":17768272,"CreationDate":"2013-07-20T23:09:00.000","Title":"How to setup the Mac terminal for Programming with Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have data which is of the gaussian form when plotted as histogram. I want to plot a gaussian curve on top of the histogram to see how good the data is. I am using pyplot from matplotlib. Also I do NOT want to normalize the histogram. I can do the normed fit, but I am looking for an Un-normalized fit. Does anyone here know how to do it?\nThanks!\nAbhinav Kumar","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":12313,"Q_Id":17779316,"Users Score":3,"Answer":"Another way of doing this is to find the normalized fit and multiply the normal distribution with (bin_width*total length of data)\nthis will un-normalize your normal distribution","Q_Score":6,"Tags":"python,matplotlib,histogram,gaussian","A_Id":20057520,"CreationDate":"2013-07-22T03:04:00.000","Title":"Un-normalized Gaussian curve on histogram","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I have created an openerp module using Python (eclipse) . I want to add a feature in my form so that admin will be able to create his own fields whenever and whatever he wants . I needed some guidance of how this will be done . As I am new to openerp , any help will be good to me . Thanks\nHopes for advice","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":17780235,"Users Score":0,"Answer":"I can't think of any easy way of doing this.  When OpenERP connects to a database it sets up a registry containing all models and all the fields and as part of this, loads the fields into the database, performs database refactoring etc.  The idea is that it is simple to inherit existing models and add your fields that way but it does require coding.\nI have done something similar where:\n\nI predefined some fields on your model (field1, intfield1, charfield1 etc.).\nProvide a model\/form so the admin can say use intfield1 and give it a label of 'My Value'\nOverride fields_view_get on your model and change the XML to include your field with the correct label.\n\nBut this is tricky to get right.  You will want to spend some time learning the elementtree module to do the XML manipulation in the fields_view_get.","Q_Score":0,"Tags":"python,eclipse,openerp","A_Id":17897177,"CreationDate":"2013-07-22T05:02:00.000","Title":"how to make dynamic field creation capability in openerp module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using the ODRPACK library in Python to fit some 1d data. It works quite well, but I have one question: is there any possibility to make constraints on the fitting parameters? For example if I have a model y = a * x + b and for physical reasons parameter a can by only in range (-1, 1). I've found that such constraints can be done in original Fortran implementation of the ODRPACK95 library, but I can't find how to do that in Python.\nOf course, I can implement my functions such that they will return very big values, if the fitting parameters are out of bounds and chi squared will be big too, but I wonder if there is a right way to do that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":780,"Q_Id":17783481,"Users Score":3,"Answer":"I'm afraid that the older FORTRAN-77 version of ODRPACK wrapped by scipy.odr does not incorporate constraints. ODRPACK95 is a later extension of the original ODRPACK library that predates the scipy.odr wrappers, and it is unclear that we could legally include it in scipy. There is no explicit licensing information for ODRPACK95, only the general ACM TOMS non-commercial license.","Q_Score":3,"Tags":"python,scipy,curve-fitting","A_Id":17786438,"CreationDate":"2013-07-22T09:01:00.000","Title":"Constraints on fitting parameters with Python and ODRPACK","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im using python tornado as web server and I have a backend server and a frontend server. I want to create browser-frontend-backend  connection. Can anyone help me how to do this? I know how to create websocket connection between frontend and browser but I have no idea how to connect my frontend server to backend server to stream realtime data parsed by my backend server.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1390,"Q_Id":17824526,"Users Score":0,"Answer":"WebSocket was designed for low-latency bidirectional browser<->service communication. It's placed on top of TCP\/IP and brings along some overhead. It was designed to solve all the problems that you simply do not have when it's about front-end<->back-end communication, because there we're talking about a defined environment which is under your control. Hence, I would recommend going back to the basics and do simple TCP\/IP communication between your front-end and back-end.","Q_Score":0,"Tags":"python-2.7,websocket,tornado","A_Id":17835810,"CreationDate":"2013-07-24T03:07:00.000","Title":"Websocket connection between two servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed a python desktop application and application itself having setup page to change some configurations in the application and it is saved as a configuration file.\nNow I need do to give web interface to change those configurations by using web browser remotely. But I need to change the same configuration file.\nI can\u2019t access any file outside the web root, So My first question is how can I edit that file which is located outside the web root.\nmore info : for web application I use LAMP stack and desktop application is python based.\nsomeone suggest me to use CGI, Second question : Is that possible, if it is possible how I can I do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":126,"Q_Id":17832954,"Users Score":1,"Answer":"Probably by bind mounts (assuming Linux), so that the file is in it's original location as well as in the web root.\nOr by priviledge separation. The web root sends a query to some worker job, that has access to all the needed files.","Q_Score":0,"Tags":"php,python,cgi","A_Id":17833204,"CreationDate":"2013-07-24T11:40:00.000","Title":"Edit a file outside the web root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am afraid that my question may be duplicate, but I could not find good answers for my question in stackoverflow.\nI use PyDev under Eclipse. And I often run my programs by opening a Python Console (Ctrl+Alt+Enter on the editor) for quick-and-easy debugging. The thing is I do not know how to stop the running program on the way. Ctrl+C, Ctrl+Z, or Ctrl+Break did not work. If I click [terminate] icon, the whole Console disappears, in which I do not want.\nIs there any ways to stop the running program and go back to command line?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2429,"Q_Id":17867473,"Users Score":1,"Answer":"Ctrl+Alt+F9 should terminate all launches, which will do the job for you.","Q_Score":3,"Tags":"python,eclipse,pydev","A_Id":17868662,"CreationDate":"2013-07-25T19:50:00.000","Title":"How to stop a running program on PyDev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to move a (stereoscopic) video on a computer screen automatically. Think of the video as the ball in a Pong game. The problem is that it should be a stereoscopic 3D video. So the video size itself is kind of small. I did this kind of movements with pictures or drawing object, but I don't know how to do it with video material!\nDoes somebody know how I can do this? I already searched for video tools in python like pygame or pyglet. I have an external player Bino 3d which can open the desired video. But how can I make it move around the screen?\nOr is there a tool in other programming languages like c\/c++ or Matlab which can help?\nBy the way, the program will be on a Linux OS.\nI'll be grateful for any help or hints!\nAnna","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":17881838,"Users Score":0,"Answer":"I'd try to use a decent video client (mplayer, vlc).  They can present the video in lots of ways, hopefully your stereoscopic issue can be solved by them.\nThen I would let the client present a single window (not fullscreen) which I then would move around using window manager controls.\nIf you must not have window decorations around the video or if the output shall be a specific window, I think mplayer at least can be told to use an existing window to perform the output in.  Maybe that's an approach then.","Q_Score":2,"Tags":"python,video,3d,move","A_Id":17882938,"CreationDate":"2013-07-26T12:53:00.000","Title":"move a stereoscopic video on the screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any way to access current scope (class name or function name) inside a snippet? I am trying to write a snippet for super(CurrentClassName, self).get(*args, **kwargs) but seems like I can't really replace CurrentClassName with actual class name. Does anyone know how to do that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":351,"Q_Id":17884487,"Users Score":1,"Answer":"Sorry snippets are primarily meant for reusability; you can do precisely as you say above but cannot insert specific things - you would have to write your own plugin in order to add this functionality as it would require things like a specific way of selecting things to modify and replace which would be specific to it.","Q_Score":0,"Tags":"python,sublimetext2","A_Id":17885345,"CreationDate":"2013-07-26T14:47:00.000","Title":"Sublime text 2 snippets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a task where I need to have a few pieces of information specific to the environment.\nI setup the ~\/.fabricrc file but when I run the task via command line, the data is not in the env variable\nI don't really want to add the -c config to simplify the deployment.\nin the task, I'm calling \n\nenv.cb_account\n\nand I have in ~\/.fabricrc \n\ncb_account=foobar\n\nit throws AttributeError\nHas anybody else run into this problem?\nI found the information when I view env outside of my function\/task. So now the question is how do I get that information into my task? I already have 6 parameters so I don't think it would be wise to add more especially when those parameters wouldn't change.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":675,"Q_Id":17888244,"Users Score":0,"Answer":"Overrode the \"env\" variable via parameter in the function. Dumb mistake.","Q_Score":0,"Tags":"python,fabric","A_Id":17929568,"CreationDate":"2013-07-26T18:15:00.000","Title":"Python Fabric config file (~\/.fabricrc) is not used","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What i mean is, how is the syntax defined, i.e. how can i make my own constructs like these?\nI realise in a lot of languages, things like this will be built into the compiler \/ spec, and so it's dealt with by the compiler (at least that how i understand it to work).\nBut with python, everything i've come across so far has been accessible to the programmer, and so you more or less have the freedom to do whatever you want.\nHow would i go about writing my own version of for or while? Is it even possible?\nI don't have any actual application for this, so the answer to any WHY?! questions is just \"because why not?\" or \"curiosity\".","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":140,"Q_Id":17901514,"Users Score":1,"Answer":"while, print, for etc. are keywords. That means they are parsed by the python parser whilst reading the code, stripped any redundant characters and result in tokens. Afterwards a lexer takes those tokens as input and builds a program tree which is then excuted by the interpreter. Said so, those constructs are used only as syntactic sugar for underlying lexical machinery and as such are not visible from inside the code.","Q_Score":2,"Tags":"python,loops,for-loop,syntax,while-loop","A_Id":17901607,"CreationDate":"2013-07-27T19:15:00.000","Title":"How do the for \/ while \/ print *things* work in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script running. I want to call *.jsl script in my running python script and want to make use of it's output in python. May I know how can I do that?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4983,"Q_Id":17931476,"Users Score":0,"Answer":"Make sure jmp.exe is available in your system environment so that if you type \"jmp.exe\" in the command line, it would launch jmp. Then have your *.jsl ready.\nuse python procees to run this command \"jmp.exe *.jsl\" and that would open jmp and run the *.jsl script and then you can import whatever you generate from jmp back in to python.","Q_Score":4,"Tags":"python-3.x,sas-jmp,jsl","A_Id":34890487,"CreationDate":"2013-07-29T18:27:00.000","Title":"How to call a *.jsl script from python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently running into an issue in integrating ElasticSearch and MongoDB. Essentially I need to convert a number of Mongo Documents into searchable documents matching my ElasticSearch query. That part is luckily trivial and taken care of. My problem though is that I need this to be fast. Faster than network time, I would really like to be able to index around 100 docs\/second, which simply isn't possible with network calls to Mongo.\nI was able to speed this up a lot by using ElasticSearch's bulk indexing, but that's only half of the problem. Is there any way to either bundle reads or cache a collection (a manageable part of a collection, as this collection is larger than I would like to keep in memory) to help speed this up? I was unable to really find any documentation about this, so if you can point me towards relevant documentation I consider that a perfectly acceptable answer. \nI would prefer a solution that uses Pymongo, but I would be more than happy to use something that directly talks to MongoDB over requests or something similar. Any thoughts on how to alleviate this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":195,"Q_Id":17955275,"Users Score":0,"Answer":"pymongo is thread safe, so you can run multiple queries in parallel. (I assume that you can somehow partition your document space.)\nFeed the results to a local Queue if processing the result needs to happen in a single thread.","Q_Score":1,"Tags":"python,performance,mongodb,pymongo","A_Id":24357799,"CreationDate":"2013-07-30T19:04:00.000","Title":"Bundling reads or caching collections with Pymongo","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a three colour FITS image using the $aplpy.make_rgb_image$ function. I use three separate FITS images in RGB to do so  and am able to save a colour image in png, jpeg.... formats, but I would prefer to save its as a FITS file. \nWhen I try that I get the following error. \nIOError: FITS save handler not installed\nI've tried to find a solution in the web for a few days but was unable to get any good results. \nWould anyone know how to get such a handler installed, or perhaps any other approach I could use to get this done?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1054,"Q_Id":17960013,"Users Score":1,"Answer":"I don't think there is enough information for me to answer your question completely; for example, I don't know what call you are making to perform the \"image\" \"save\", but I can guess:\nFITS does not store RGB data like you wish it to. FITS can store multi-band data as individual monochromatic data layers in a multi-extension data \"cube\". Software, including ds9 and aplpy, can read that FITS data cube and author RGB images in RGB formats (png, jpg...).  The error you see comes from PIL, which has no backend to author FITS files (I think, but the validity of that point doesn't matter). \nSo I think that you should use aplpy.make_rgb_cube to save a 3 HDU FITS cube based your 3 input FITS files, then import that FITS cube back into aplpy and use aplpy.make_rgb_image to output RGB compatible formats. This way you have the saved FITS cube in near native astronomy formats, and a means to create RGB formats from a variety of tools that can import that cube.","Q_Score":0,"Tags":"python,rgb,fits,pyfits","A_Id":17984159,"CreationDate":"2013-07-31T01:14:00.000","Title":"Making a 3 Colour FITS file using aplpy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm deploying my first Django app on a BlueHost shared server. It is a simple site powered by Django-CMS, and portions of it are working, however there are some deal-breaking quirks. \nA main recurring one reads TypeError, a float is required. The exception location each time is ...\/python\/lib\/python2.7\/site-packages\/django\/core\/urlresolvers.py in _reverse_with_prefix, line 391. For example, I run into it when trying to load a page which includes {% cms_toolbar %} in the template, pressing \"save and continue editing\" when creating a page, or trying to delete a page through the admin interface.\nI don't know if this is related, but nothing happens when I select a plugin from the \"Available Plugins\" drop-down while editing a page and press \"Add Plugin\".\nHas anyone had any experience with this error, or have any ideas how to fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":17960261,"Users Score":0,"Answer":"As I wondered, the problem was that I was accessing the site using my temporary link from BlueHost, which the function throwing the error could not handle.\nWhen my clients finally pointed their domain name at the server this problem and a few others (CSS inconsistencies in the Django admin, trouble with .htaccess) disappeared. Everything is up now and working fine.","Q_Score":0,"Tags":"python,django,deployment,django-cms,bluehost","A_Id":18367549,"CreationDate":"2013-07-31T01:42:00.000","Title":"Django-CMS Type Error \"a float is required\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i have 2 treewidgets placed in a frame in mainwindow. how can i have 2 different set of context menu options for the 2 treewidgets? i need individual set of right click options for the treewidgets.Thanks in advance..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1433,"Q_Id":17961363,"Users Score":0,"Answer":"Every QWidget has a contextMenuPolicy property which defines what to do when context menu is requested. A simpliest way to do what you need is like this:\n\nCreate QAction objects that call methods you want.\nAdd these actions to your tree widgets using widget.addAction()\nCall widget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)\n\nThat's it. Context menu for the widget will contain actions you added.","Q_Score":1,"Tags":"python,pyqt,qtreewidget","A_Id":17962727,"CreationDate":"2013-07-31T04:00:00.000","Title":"PyQT treewidgets with different context menu options","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been in this problem for long time and i want to know how its done in real \/ big companies project.\nSuppose i have the project to build a website. now i divide the project into sub tasks and do it.\nBut u know that suppose i have task1 in hand like export the page to pdf. Now i spend 3 days to do that , came accross various problems , many stack overflow questions and in the end i solve it.\nNow 4 months after someone told me that there is some error in the code.\nNow by that i comepletely forgot about(60%) how i did it and why i do this way. I document the code but i can't write the whole story of that in the code.\nThen i have to spend much time on code to find what was the problem so that i added this line etc.\nI want to know that is there any way that i can log steps in completeing the project.\nSo that i can see how i end up with code , what erros i got , what questions i asked on So and etc.\nHow people do it in real time. Which software to use.\nI know in our project management softaware called JIRA we have tasks  but that does not cover what steps i took to solve that tasks.\nwhat is the besy way so that when i look backt at my 2 year old project , i know how i solve particular task","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":278,"Q_Id":17984890,"Users Score":0,"Answer":"Every time you revisit code, make a list of the information you are not finding. Then the next time you create code, make sure that information is present. It can be in comments, Wiki, bugs or even text notes in a separate file. Make the notes useful for other people, so private notebooks aren't a good idea except for personal notes.","Q_Score":3,"Tags":"python,coding-style,project-management,jira,issue-tracking","A_Id":18004681,"CreationDate":"2013-08-01T03:42:00.000","Title":"What is the best way to track \/ record the current programming project u work on","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I'm fairly familiar with the python multiprocessing module, but I'm unsure of how to implement this setup. My project has this basic flow:\nrequest serial device -> gather response -> parse response -> assert response -> repeat\nIt is right now a sequential operation that loops over this until it has gather the desired number of asserted responses. I was hoping to speed this task up by having a 'master process' do the first two operations, and then pass off the parsing and assertion task into a queue of worker processes. However, this is only beneficial if the master process is ALWAYS running. I'm guaranteed to be working on a multi-core machine. \nIs there any way to have a process in the multiprocessing module always have focus \/ make run so I can achieve this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":743,"Q_Id":17998464,"Users Score":1,"Answer":"Here's one way to implement your workflow:\n\nHave two multiprocessing.Queue objects: tasks_queue and\nresults_queue. The tasks_queue will hold device outputs, and results_queue will hold results of the assertions.\nHave a pool of workers, where each worker pulls device output from\ntasks_queue, parses it, asserts, and puts the result of assertion on the results_queue. \nHave another process continuously polling device and put device\noutput on the tasks_queue.\nHave one last process continuously polling results_queue, and\nending the overall program when the desired number of resuts (successful\nassertions) is reached.\n\nTotal number of processes (multiprocessing.Process objects) is 2 + k, where k is the number of workers in the pool.","Q_Score":1,"Tags":"python,multiprocessing,master","A_Id":18034766,"CreationDate":"2013-08-01T15:35:00.000","Title":"Python Multiprocessing Management","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Will the sources in PYTHONPATH always be searched in the very same order as they are listed? Or may the order of them change somewhere?\nThe specific case I'm wondering about is the view of PYTHONPATH before Python is started and if that differs to how Python actually uses it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":752,"Q_Id":18009550,"Users Score":0,"Answer":"PYTHONPATH passed to sys.path there any module can modify it before importing another modules.","Q_Score":0,"Tags":"python,pythonpath","A_Id":18010177,"CreationDate":"2013-08-02T05:45:00.000","Title":"Will the first source in PYTHONPATH always be searched first?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I normally use python 2.7.3 traditionally installed in \/usr\/local\/bin, but I needed to rebuild python 2.6.6 (which I did without using virtualenv) in another directory ~\/usr\/local\/ and rebuild numpy, scipy, all libraries I needed different versions from what I had for python 2.7.3 there...\nBut all the other packages that I want exactly as they were (meaning same version) in my default installation, I don't know how to just use them in the python 2.6.6 without having to download tarballs, build and installing them using --prefix=\/home\/myself\/usr\/local\/bin.\nIs there a fast or simpler way of \"re-using\" those packages in my \"local\" python 2.6.6?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":18022429,"Users Score":0,"Answer":"Reinstall them. It may seem like a no-brainer to reuse modules (in a lot of cases, you can), but in the case of modules that have compiled code - for long term systems administration this can be an utter nightmare.\nConsider supporting multiple versions of Python for multiple versions \/ architectures of Linux. Some modules will reference libraries in \/usr\/local\/lib, but those libraries can be the wrong arch or wrong version. \nYou're better off making a requirements.txt file and using pip to install them from source.","Q_Score":1,"Tags":"python,build,python-module,python-install","A_Id":18048958,"CreationDate":"2013-08-02T17:04:00.000","Title":"Allowing python use modules from other python installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a regex like this '^(a|ab|1|2)+$' and want to get all sequence for this...\nfor example for re.search(reg, 'ab1') I want to get ('ab','1')\nEquivalent result I can get with '^(a|ab|1|2)(a|ab|1|2)$' pattern, \nbut I don't know how many blocks been matched with (pattern)+\nIs this possible, and if yes - how?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1138,"Q_Id":18045565,"Users Score":2,"Answer":"I think you don't need regexpes for this problem,\nyou need some recursial graph search function","Q_Score":5,"Tags":"python,regex","A_Id":18072336,"CreationDate":"2013-08-04T17:26:00.000","Title":"Python regexp: get all group's sequence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a tornado application that will serve data via websocket.\nI have a separate blocking thread which is reading input from another application and pushing an object into a Queue and another thread which has a blocking listener to that Queue.\nWhat I would like is for the reader thread to somehow send a message to tornado whenever it sees a new item in the Queue and then tornado can relay that via websocket to listening clients.\nThe only way I can think to do this is to have a websocket client in the reader thread and push the information to tornado via websocket. However it seems that I should be able to do this without using websocket and somehow have tornado listen for non websocket async events and then call a callback.\nBut I can't find anything describing how to do this.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":625,"Q_Id":18048357,"Users Score":1,"Answer":"If I'm understanding your question correctly, all you need to do is call IOLoop.add_callback from the thread that is reading from the queue.  This will run your callback in the IOLoop's thread so you can write your message out on the client websocket connections.","Q_Score":1,"Tags":"python,tornado","A_Id":19019586,"CreationDate":"2013-08-04T22:45:00.000","Title":"How to add custom events to tornado","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sometimes I am not sure when do I have to use one or another. I usually parse all sort of things with Python, but I would like to focus this question on HTML parsing.\nPersonally I find DOM manipulation really useful when having to parse more than two regular elements (i.e. title and body of a list of news, for example).\nHowever, I found myself in situations where it is not clear for me to build a regex or try to get the desired value simply manipulating strings. A particular fictional example: I have to get the total number of photos of an album, and the only way to get this is parsing the number of photos using this way:\n\n(1 of 190)\n\nSo I have to get the '190' from the whole HTML document. I could write a regex for that, although regex for parsing HTML is not exactly the best, or that is what I always understood. On the other hand, using DOM seems overwhelming for me as it is just a simple element. String manipulation seems to be the best way, but I am not really sure if I should proceed like that in such a similar case.\nCan you tell me how would you parse these kind of single elements from a HTML document using Python (or any other language)?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":525,"Q_Id":18048512,"Users Score":2,"Answer":"People shy away from doing regexes to search HTML because it isn't the right tool for the job when parsing tags. But everything should be considered on a case-by-case basis. You aren't searching for tags, you are searching for a well-defined string in a document. It seems to me the simplest solution is just a regex or some sort of XPath expression -- simple parsing requires simple tools.","Q_Score":0,"Tags":"python,html,regex,parsing,html-parsing","A_Id":18048532,"CreationDate":"2013-08-04T23:09:00.000","Title":"Should I use regex or just DOM\/string manipulation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I am working on an openerp module . I want to make a field dynamically . I want to take a name of a field from user and then create a field to it . How this can be done ? Can I do it with fields.function to return name, char type ? Plz help","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":939,"Q_Id":18050770,"Users Score":2,"Answer":"Do you mean you want a dynamic field on the form\/tree view or in the model?\nIf it is in the view then you override fields_view_get, call super and then process the returned XML for the form type you want adding in the field or manipulating the XML.  ElementTree is your friend here.\nIf you are talking about having a dynamic database field, I don't think you can and OpenERP creates a registry for each database when that database is first accessed and this process performs database refactoring at that time.  The registry contains the singleton model instances you get with self.pool.get...\nTo achieve this you will need to create some kind of generic field like field1 and then in fields_view_get change the string attribute to give it a dynamic label.\nActually, a plan C occurs to me.  You could create a properties type of table, use a functional field to read the value for the current user and override fields_view_get to do the form.","Q_Score":0,"Tags":"python,eclipse,openerp","A_Id":18071459,"CreationDate":"2013-08-05T04:50:00.000","Title":"how to set name of a field dynamically in openerp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I am working on an openerp module . I want to make a field dynamically . I want to take a name of a field from user and then create a field to it . How this can be done ? Can I do it with fields.function to return name, char type ? Plz help","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":939,"Q_Id":18050770,"Users Score":0,"Answer":"You can create Fields Dynamically by the help of class self.pool.get('ir.model.fields')\nUse Create Function.","Q_Score":0,"Tags":"python,eclipse,openerp","A_Id":18071982,"CreationDate":"2013-08-05T04:50:00.000","Title":"how to set name of a field dynamically in openerp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building an authentication server in python and was wondering about how I could secure a connection totally between two peers totally? I cannot see how in any way a malicious user wouldn't be able to copy packets and simply analyze them if he understands what comes in which order.\nAdmitting a client server schema. Client asks for an Account. Even though SRP, packets can be copied and sent later on to allow login.\nThen now, if I add public - private key encryption, how do I send the public key to each other without passing them in an un-encrypted channel?\nSorry if my questions remains noobish or looks like I haven't minded about the question but I really have a hard time figuring out how I can build up an authentication process without having several security holes.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1317,"Q_Id":18065256,"Users Score":2,"Answer":"What you are asking about is part of what's commonly called \"key management.\"  If you google the term, you'll find lots of interesting reading.  You may well discover that there are other parts of key management that your solution needs to address, like revocation and rotation.\nIn the particular part of key management that you're looking at, you need to figure out how to have two nodes trust each other.  This means that you have to identify a separate thing that you trust on which to base the nodes' trust.  There are two common approaches:\n\nTrusting a third party.  This is the model that we use for most websites we visit.  When our computers  are created, the trusted third party creates the device to already know about and trust certain entities, like Verisign.  When we contact a web site over HTTPS, the browser automatically checks if Verisign (or another trusted third party certificate authority) agrees that this is the website that it claims to be.  The magic of Public Key Cryptography and how this works is a whole separate topic, which I recommend you investigate (just google for it :) ).\nSeparate, secure channel.  In this model, we use a separate channel, like an administrator who transfers the secret from one node to the other.  The admin can do this in any manner s\/he wishes, such as encrypted data carried carried via USB stick over sneakernet, or the data can be transferred across a separate SFTP server that s\/he has already bootstrapped and can verify that it's secure (such as with his\/her own internal certificate authority).  Some variations of this are sharing a PGP key on a business card (if you trust that the person giving you the business card is the person with whom you want to communicate), or calling the key-owner over the phone and verbally confirming that the hash of the data you received is the same as the hash of the data they sent.\n\nThere are on-line key exchange protocols - you can look them up, probably even on Wikipedia, using the phrase \"key exchange\", but you need to be careful that they actually guarantee the things you need to determine - like how does the protocol authenticate the other side of the communication channel.  For example, Diffie Hellman guarantees that you have exchanged a key without ever exchanging the actual contents of the key, but you don't know with whom you are communicating - it's an anonymous key exchange model.\nYou also mention that you're worried about message replay.  Modern secure communication protocols like SSH and TLS protect against this.  Any good protocol will have received analysis about its security properties, which are often well described on Wikipedia.\nOh, and you should not create your own protocol.  There are many tomes about how to write secure protocols, analyses of existing protocols and there security properties (or lack thereof).  Unless you're planning to become an expert in the topic (which will take many years and thousands of pages of reading), you should take the path of least resistance and just use a well known, well exercised, well respected protocol that does the work you need.","Q_Score":0,"Tags":"python,security","A_Id":18065965,"CreationDate":"2013-08-05T18:34:00.000","Title":"How could i totally secure a connection between two nodes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Basically, I need to write a Python script that can download all of the attachment files in an e-mail, and then organize them based on their name. I am new to using Python to interact with other applications, so I was wondering if you had any pointers regarding this, mainly how to create a link to Lotus Notes (API)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1295,"Q_Id":18066856,"Users Score":0,"Answer":"You can do this in LotusScript as an export of data. This could be an agent that walks down a view in Notes, selects a document, document attachments could be put into a directory. Then with those objects in the directory(ies) you can run any script you like like a shell script or whatever. \nWith LotusScript you can grab out meta data or other meaningful text for your directory name. Detach the objects you want from richtext then move to the next document. The view that you travel down will effect the type of documents that you are working with.","Q_Score":0,"Tags":"python,api,lotus-notes,email-attachments","A_Id":18662488,"CreationDate":"2013-08-05T20:12:00.000","Title":"Using Python To Access E-mail (Lotus Notes)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I apologize in advance for how long this explanation is, I don't know how to make it more concise because I imagine almost all of this is relevant. Sorry!\nI'm designing a game server in Python with Twisted (probably not relevant, as this is an architecture question).\nThe general idea is that players connect and are placed into a lobby. They can then queue for a match (for instance, deathmatch or team deathmatch), and, when a match is found, they are placed into that game. When the game ends they are placed back into the lobby.\nBecause I'm aware of how complex distributed systems can be, I tried to simplify it as much as possible. The idea I came up with was to abstract all the information about a player into an object. All game logic is implemented in a GameHandler. When a player connects, they're assigned to a Lobby(GameHandler) instance. When they join a match, they are reassigned to a, say, Deathmatch(GameHandler) instance (which are held in a map of server: gamehandler).\nAt that point, when the player is added to a match, the server they're actually connected to serves as a reverse proxy (I didn't write the client and it can't be modified, there can't be any connection re-negotiation) and sends the info about the player to the match server. Then, using the instance map, all traffic from that player is routed without being looked at to the game instance they're in, and vice versa with an ID system. I don't think this is a problem because the servers should all be able to forward data on a gigabit LAN.\nWhen a game is over, it just notifies all the Lobby servers (reverse proxies) that forwarded players, and they're returned back to the Lobby instance.\nThat should mean that I can scale out with resources by adding backend servers, scale out with network links by adding more reverse proxy lobby-only servers, and I can also scale up on any of the individual nodes. There is also no technical limitation that forces backend servers to be backend, every single server could have a Lobby instance, but games could be distributed across the network.\nNow, so far so good (In theory, I haven't started implementing the distribution yet because I want to work out the main points beforehand), but that leaves one major question:\nHow do I control metainformation that all nodes need to know?\nFor instance:\n\nHow many players are online for the server list to display before a client connects?\nIs matchmaking implemented (I'm planning on using Microsoft's TrueSkill algorithm, if that matters) in some P2P manner or should I delegate an entire server just for that (or even for metainformation)?\nWhat about a party system where players join a queue together? Which server keeps track of the players in the group?\nHow do I manage configuration, like banned players? Every forward server would need to know about them.\nIf the lobby instance the player connected to happens to be full, how do I find another lobby instance that isn't full so I can route their connection there? This goes back to the first point, I need to have a way for nodes to easily query the network state\n\nI could implement a P2P solution, or a primary server to handle this sort of thing. My major concern would be that adding a primary control server would add a single point of failure (which I would like to avoid), but the P2P solution would seem to be an order of magnitude more complex, and potentially slow things down significantly or use a fair amount of resources caching data on all the nodes.\nSo the question is: Is my design decent, and what do you think the pros and cons of those two solutions to the metainformation problem are? Is there a better third solution? What do you think is best?\nThank you in advance, your help is very much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":246,"Q_Id":18068855,"Users Score":1,"Answer":"There are many solutions to implement a shared database.  It depends on your technology stack, network architecture, programming language(s), etc.  This is too broad of a question to be answered in a few paragraphs.  Pick one approach and go with it, but make your code modular enough to replace your approach with another if necessary.\nUpdate: Based on your comment that you are using Twisted, I will ask you a question.  If you had a cluster of Twisted servers that are all sharing network state (your \"distributed nodes\"), how would you request your \"complex operations\" from those servers and how would you get back the results?  If you can answer this in enough detail, you will have determined the requirements of your nodes.  And then you can determine how they share and update the network state.  At that point, you can ask a much more specific question (like \"how do I replicate memcache across my nodes?\").","Q_Score":2,"Tags":"python,architecture,twisted,scalability,distributed","A_Id":18069861,"CreationDate":"2013-08-05T22:27:00.000","Title":"How do I manage metainformation in a horizontally scaled game server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I remove line breakers  i.e. '\\n' from a unicode text read from text file using python? Also, how do I test if values of a list is linebreaker or not in unicode string?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":129,"Q_Id":18069628,"Users Score":0,"Answer":"Unicode strings have the same methods as standard strings, you can remove '\\n' with line.replace(r'\\n','') and check if it exists with '\\n' in unc","Q_Score":0,"Tags":"python,unicode,decode,encode","A_Id":18069703,"CreationDate":"2013-08-05T23:48:00.000","Title":"how to avoid linebreakers from unicode string read from text file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them.  My idea is to somehow remove all of the buttons from the sizer, make a new list of the buttons that I want the sizer to contain, and then use the sizer's AddMany method.\nIf I can't remove the buttons from the sizer without destroying them, then is there a way to use the sizer's Show method to hide some of the times, but then have the sizer adjust to fill in the gaps?  When I hide them, all I can get them to do right now is just to have them disappear and leave a gap.  I need the next item to be adjusted to the gap's place.\nAlso is there a way to sort the grid sizer's item list?\nThanks for any help you can offer.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":698,"Q_Id":18079351,"Users Score":0,"Answer":"You should be able to call the Layout method on the parent of the sizer, this will make it recalculate the shown items.","Q_Score":0,"Tags":"python,user-interface,wxpython,wxwidgets","A_Id":18079725,"CreationDate":"2013-08-06T11:48:00.000","Title":"How to either sort a wxsizer or remove items without destroying them?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them.  My idea is to somehow remove all of the buttons from the sizer, make a new list of the buttons that I want the sizer to contain, and then use the sizer's AddMany method.\nIf I can't remove the buttons from the sizer without destroying them, then is there a way to use the sizer's Show method to hide some of the times, but then have the sizer adjust to fill in the gaps?  When I hide them, all I can get them to do right now is just to have them disappear and leave a gap.  I need the next item to be adjusted to the gap's place.\nAlso is there a way to sort the grid sizer's item list?\nThanks for any help you can offer.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":698,"Q_Id":18079351,"Users Score":0,"Answer":"So I found out that the detach method is what I'm looking for! I would still be interested to know of a way to sort a sizer's item list though, without detaching all of the items and then re attaching a sublist.","Q_Score":0,"Tags":"python,user-interface,wxpython,wxwidgets","A_Id":18079420,"CreationDate":"2013-08-06T11:48:00.000","Title":"How to either sort a wxsizer or remove items without destroying them?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them.  My idea is to somehow remove all of the buttons from the sizer, make a new list of the buttons that I want the sizer to contain, and then use the sizer's AddMany method.\nIf I can't remove the buttons from the sizer without destroying them, then is there a way to use the sizer's Show method to hide some of the times, but then have the sizer adjust to fill in the gaps?  When I hide them, all I can get them to do right now is just to have them disappear and leave a gap.  I need the next item to be adjusted to the gap's place.\nAlso is there a way to sort the grid sizer's item list?\nThanks for any help you can offer.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":698,"Q_Id":18079351,"Users Score":0,"Answer":"You can't sort the sizer items in place. It would be possible to write your own function for doing this, of course, but it would use wxSizer::Detach() and Insert() under the hood anyhow.","Q_Score":0,"Tags":"python,user-interface,wxpython,wxwidgets","A_Id":18086362,"CreationDate":"2013-08-06T11:48:00.000","Title":"How to either sort a wxsizer or remove items without destroying them?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have read somewhere that you can store python objects (more specifically dictionaries) as binaries in MongoDB by using BSON. However right now I cannot find any any documentation related to this.\nWould anyone know how exactly this can be done?","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":23835,"Q_Id":18089598,"Users Score":5,"Answer":"Assuming you are not specifically interested in mongoDB, you are probably not looking for BSON. BSON is just a different serialization format compared to JSON, designed for more speed and space efficiency. On the other hand, pickle does more of a direct encoding of python objects.\nHowever, do your speed tests before you adopt pickle to ensure it is better for your use case.","Q_Score":18,"Tags":"python,mongodb,pymongo,bson","A_Id":18089722,"CreationDate":"2013-08-06T20:14:00.000","Title":"Is there a way to store python objects directly in mongoDB without serializing them","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a small application written in python using TwistedWeb. It is a chat server.\nEverything is configured right now as for localhost.\nAll I want is to run this python script on a server(shared server provided by Fatcow.com).\nI mean that the script will be working all the time and some clients will connect\/disconnect to it. Fatcow gives me python 2.5 without any custom libraries. Is there a way and a tutorial how to make it work with TwistedWeb?\nThanks in advice.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":817,"Q_Id":18090039,"Users Score":0,"Answer":"I have contacted Fatcow.com support. They do not support SSH connections and do not support Python 2.7 with Twisted library, especially python socket application as server. So it is dead end.\nQuestion resolved.","Q_Score":0,"Tags":"python,sockets,webserver,twisted.web","A_Id":18104107,"CreationDate":"2013-08-06T20:40:00.000","Title":"How to install twistedweb python library on a web server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I use the mechanize library with Django?\nI read online that I could put it in a directory (e.g. \/lib\/) and include as needed.\nThe problem is, the the source I had found didn't show how to use it from configuration to initial use. Unfortunately, I also looked high and low elsewhere on google with nothing to find. I also checked a book I have on django without any info..\nCan anyone help me out? \nI'm on a local install of django with python 2.7.\nThank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":277,"Q_Id":18093487,"Users Score":0,"Answer":"As per comments, the answer is:\npip install mechanize\nthen just open a python interpreter and import mechanize to confirm.\nThat should be it, you can start using mechanize in your Django project.","Q_Score":1,"Tags":"django,mechanize,mechanize-python","A_Id":27438161,"CreationDate":"2013-08-07T02:10:00.000","Title":"Use of Mechanize Library with Python 2.7 and Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any special reason? I know that that's how the language has been written, but can't we change it? \nAnd what are the challenges we'd face if the index start with 1?","AnswerCount":5,"Available Count":3,"Score":0.0399786803,"is_accepted":false,"ViewCount":278,"Q_Id":18109671,"Users Score":1,"Answer":"One thing is that, you can reference and navigate the arrays using pointers. Infact the the array operations decay to pointer arithmetic at the back end. \nSuppose you want to reach a nth element of an array then you can simply do (a + n) where a is the base address of an array(1-dimension), but if the subscript starts at 1 then to reach the nth element you would have to do (a + n -1) all the time. \nThis is because just by taking the name of an array you the the address of the starting element of it, which is the simplest way!","Q_Score":0,"Tags":"java,c++,python,c,coding-style","A_Id":18109807,"CreationDate":"2013-08-07T17:16:00.000","Title":"Why doesn't the index\/list of an array begin with 1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any special reason? I know that that's how the language has been written, but can't we change it? \nAnd what are the challenges we'd face if the index start with 1?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":278,"Q_Id":18109671,"Users Score":3,"Answer":"The basic reason behind it is that the computer remembers the address at wich the first part of any variable\/object is stored. So the index represents the \"distance\" in between that and what you're looking for, so the first one is 0 away, the second 1...","Q_Score":0,"Tags":"java,c++,python,c,coding-style","A_Id":18109758,"CreationDate":"2013-08-07T17:16:00.000","Title":"Why doesn't the index\/list of an array begin with 1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any special reason? I know that that's how the language has been written, but can't we change it? \nAnd what are the challenges we'd face if the index start with 1?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":278,"Q_Id":18109671,"Users Score":3,"Answer":"In C and C++, array indexing is syntactic sugar for dereferencing an offset pointer.  That is,\narray[i] is equivalent to *(array + i).  It makes sense for pointers to point to the beginning of their block of memory, and this implies that the first element of the array needs to be *array, which is just array[0].","Q_Score":0,"Tags":"java,c++,python,c,coding-style","A_Id":18109818,"CreationDate":"2013-08-07T17:16:00.000","Title":"Why doesn't the index\/list of an array begin with 1?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have several S3 buckets containing a total of 40 TB of data across 761 million objects.  I undertook a project to copy these objects to EBS storage.  To my knowledge, all buckets were created in us-east-1.  I know for certain that all of the EC2 instances used for the export to EBS were within us-east-1.\nThe problem is that the AWS bill for last month included a pretty hefty charge for inter-regional data transfer.  I'd like to know how this is possible?\nThe transfer used a pretty simple Python script with Boto to connect to S3 and download the contents of each object.  I suspect that the fact that the bucket names were composed of uppercase letters might have been a contributing factor (I had to specify OrdinaryCallingFormat()), but I don't know this for sure.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":878,"Q_Id":18113426,"Users Score":0,"Answer":"The problem ended up being an internal billing error at AWS and was not related to either S3 or Boto.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,boto","A_Id":18366790,"CreationDate":"2013-08-07T20:42:00.000","Title":"Boto randomly connecting to different regions for S3 transfers","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning how to use the threading and the multiprocessing modules in Python to run certain operations in parallel and speed up my code.\nI am finding this hard (maybe because I don't have any theoretical background about it) to understand what the difference is between a threading.Thread() object and a multiprocessing.Process() one.\nAlso, it is not entirely clear to me how to instantiate a queue of jobs and having only 4 (for example) of them running in parallel, while the other wait for resources to free before being executed.\nI find the examples in the documentation clear, but not very exhaustive; as soon as I try to complicate things a bit, I receive a lot of weird errors (like a method that can't be pickled, and so on).\nSo, when should I use the threading and multiprocessing modules?\nCan you link me to some resources that explain the concepts behind these two modules and how to use them properly for complex tasks?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":75191,"Q_Id":18114285,"Users Score":45,"Answer":"Multiple threads can exist in a single process.\nThe threads that belong to the same process share the same memory area (can read from and write to the very same variables, and can interfere with one another).\nOn the contrary, different processes live in different memory areas, and each of them has its own variables. In order to communicate, processes have to use other channels (files, pipes or sockets).\nIf you want to parallelize a computation, you're probably going to need multithreading, because you probably want the threads to cooperate on the same memory.\nSpeaking about performance, threads are faster to create and manage than processes (because the OS doesn't need to allocate a whole new virtual memory area), and inter-thread communication is usually faster than inter-process communication. But threads are harder to program. Threads can interfere with one another, and can write to each other's memory, but the way this happens is not always obvious (due to several factors, mainly instruction reordering and memory caching), and so you are going to need synchronization primitives to control access to your variables.","Q_Score":188,"Tags":"python,multithreading,parallel-processing,process,multiprocessing","A_Id":18114475,"CreationDate":"2013-08-07T21:37:00.000","Title":"What are the differences between the threading and multiprocessing modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I have small Python3 application for manipulating some specific XML files. For gui I am using PySide and for parsing files -lxml. \nI had some troubles with freezing it with cx_freeze but finally succeed. Now - some parts of application simply don't work... no error message & no log created. \nFor example on Enter press signal in LineEdit - new dialog should be shown... but nothing happens. \nI have same version in standard python files and those are running correctly.  How do I debug the frozen application?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1843,"Q_Id":18119631,"Users Score":0,"Answer":"Take a look at the pyside documentation and see if there is a redirect output to a window option - it is entirely possible that something is causing an error that is being printed out to nowhere.","Q_Score":4,"Tags":"python,pyside,cx-freeze","A_Id":18120660,"CreationDate":"2013-08-08T06:50:00.000","Title":"cx_freeze - how debug app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a slight variant on the \"find k nearest neighbours\" algorithm which involves rejecting those that don't satisfy a certain condition and I can't think of how to do it efficiently. \nWhat I'm after is to find the k nearest neighbours that are in the current line of sight. Unfortunately scipy.spatial.cKDTree doesn't provide an option for searching with a filter to conditionally reject points.\nThe best algorithm I can come up with is to query for n nearest neighbours and if there aren't k that are in the line of sight then query it again for 2n nearest neighbours and repeat. Unfortunately this would mean recomputing the n nearest neighbours repeatedly in the worst cases. The performance hit gets worse the more times I have to repeat this query. On the other hand setting n too high is potentially wasteful if most of the points returned aren't needed.\nThe line of sight changes frequently so I can't recompute the cKDTree each time either. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":631,"Q_Id":18144810,"Users Score":0,"Answer":"If you are looking for the neighbours in a line of sight, couldn't use an method like \n\ncKDTree.query_ball_point(self, x, r, p, eps)\n\nwhich allows you to query the KDTree for neighbours that are inside a radius of size r around the x array points.\nUnless I misunderstood your question, it seems that the line of sight is known and is equivalent to this r value.","Q_Score":4,"Tags":"python,constraints,nearest-neighbor,kdtree","A_Id":18339341,"CreationDate":"2013-08-09T10:36:00.000","Title":"nearest k neighbours that satisfy conditions (python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I create my requirements.txt I always want it to get the most recent package, without me having to know  a version number, how can I do this?\nFor example I want this to get the latest version of Django:\nrequirements.txt\n\nDjango>=\nSouth==0.7.6","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":107,"Q_Id":18146661,"Users Score":3,"Answer":"Well, this is a bit of a bad idea. The idea of having a requirements.txt is that you can perfectly replicate what you have on the machine you develop on, i.e exactly the environment it works on.\nYou can do what you want by just not specifying a version number in requirements.txt, but you are better off manually upgrading each module\/package and confirming it works before using it in production.","Q_Score":1,"Tags":"python,django","A_Id":18146782,"CreationDate":"2013-08-09T12:26:00.000","Title":"Django\/Python requirements.txt get always recent package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"when connecting to mysql database in Django ,I get the error.\n\nI'm sure mysql server is running.\n\/var\/run\/mysqld\/mysqld.sock doesn't exist.\nWhen I run $ find \/ -name *.sock -type s, I only get \/tmp\/mysql.sock and some other irrelevant output.\nI added socket = \/tmp\/mysql.sock to \/etc\/my.cnf. And then restared mysql, exited django shell, and connected to mysql database. I still got the same error.\n\nI searched a lot, but I still don't know how to do.\nAny help is greate. Thanks in advance.\nWell, I just tried some ways. And it works.\nI did as follows.\n\nAdd socket = \/tmp\/mysql.sock .Restart the mysql server.\nln -s \/tmp\/mysql.sock \/var\/lib\/mysqld\/mysqld.sock\n\nI met an another problem today. I can't login to mysql.\nI'm newbie to mysql. So I guess mysql server and client use the same socket to communicate.\nI add socket = \/var\/mysqld\/mysqld.sock to [mysqld] [client] block in my.cnf  and it wokrs.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101165,"Q_Id":18150858,"Users Score":0,"Answer":"I faced this problem when connecting MySQL with Django when using Docker.\nTry 'PORT':'0.0.0.0'.\nDo not use 'PORT': 'db'. This will not work if you tried to run your app outside Docker.","Q_Score":26,"Tags":"python,mysql,django,mysql.sock","A_Id":66405102,"CreationDate":"2013-08-09T15:55:00.000","Title":"OperationalError: (2002, \"Can't connect to local MySQL server through socket '\/var\/run\/mysqld\/mysqld.sock' (2)\")","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"when connecting to mysql database in Django ,I get the error.\n\nI'm sure mysql server is running.\n\/var\/run\/mysqld\/mysqld.sock doesn't exist.\nWhen I run $ find \/ -name *.sock -type s, I only get \/tmp\/mysql.sock and some other irrelevant output.\nI added socket = \/tmp\/mysql.sock to \/etc\/my.cnf. And then restared mysql, exited django shell, and connected to mysql database. I still got the same error.\n\nI searched a lot, but I still don't know how to do.\nAny help is greate. Thanks in advance.\nWell, I just tried some ways. And it works.\nI did as follows.\n\nAdd socket = \/tmp\/mysql.sock .Restart the mysql server.\nln -s \/tmp\/mysql.sock \/var\/lib\/mysqld\/mysqld.sock\n\nI met an another problem today. I can't login to mysql.\nI'm newbie to mysql. So I guess mysql server and client use the same socket to communicate.\nI add socket = \/var\/mysqld\/mysqld.sock to [mysqld] [client] block in my.cnf  and it wokrs.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101165,"Q_Id":18150858,"Users Score":0,"Answer":"in flask, you may use that\napp=Flask(__name__)\napp.config[\"MYSQL_HOST\"]=\"127.0.0.1 \napp.config[\"MYSQL_USER\"]=\"root\"...","Q_Score":26,"Tags":"python,mysql,django,mysql.sock","A_Id":56762083,"CreationDate":"2013-08-09T15:55:00.000","Title":"OperationalError: (2002, \"Can't connect to local MySQL server through socket '\/var\/run\/mysqld\/mysqld.sock' (2)\")","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"when connecting to mysql database in Django ,I get the error.\n\nI'm sure mysql server is running.\n\/var\/run\/mysqld\/mysqld.sock doesn't exist.\nWhen I run $ find \/ -name *.sock -type s, I only get \/tmp\/mysql.sock and some other irrelevant output.\nI added socket = \/tmp\/mysql.sock to \/etc\/my.cnf. And then restared mysql, exited django shell, and connected to mysql database. I still got the same error.\n\nI searched a lot, but I still don't know how to do.\nAny help is greate. Thanks in advance.\nWell, I just tried some ways. And it works.\nI did as follows.\n\nAdd socket = \/tmp\/mysql.sock .Restart the mysql server.\nln -s \/tmp\/mysql.sock \/var\/lib\/mysqld\/mysqld.sock\n\nI met an another problem today. I can't login to mysql.\nI'm newbie to mysql. So I guess mysql server and client use the same socket to communicate.\nI add socket = \/var\/mysqld\/mysqld.sock to [mysqld] [client] block in my.cnf  and it wokrs.","AnswerCount":5,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":101165,"Q_Id":18150858,"Users Score":0,"Answer":"You need to change your HOST from 'localhost' to '127.0.0.1' and check your django app :)","Q_Score":26,"Tags":"python,mysql,django,mysql.sock","A_Id":72389079,"CreationDate":"2013-08-09T15:55:00.000","Title":"OperationalError: (2002, \"Can't connect to local MySQL server through socket '\/var\/run\/mysqld\/mysqld.sock' (2)\")","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Any basic information would be greatly appreciated.\nI am almost completed with my project, all I have to do now is run my code to get my data. However, it takes a very long time, and it has been suggested that I make my code (python) available to multiprocess. However, I am clueless on how to do this and have had a lot of trouble running how. I use a Mac OS X 10.8.2. I know that I need a semaphore.\nI have looked up the multiprocessing module and the Thread module, although I could not understand most of this. Do the Process() or Manager() functions have anything to do with this?\nLastly, I have 16 processors available for this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3162,"Q_Id":18168329,"Users Score":4,"Answer":"You need to use the multiprocessing module. \nBoth modules enable concurrency, but only multiprocessing enables true parallelism. Due to Python's Global Interpreter Lock, multiple threads cannot execute simultaneously.\nKeeping all 16 of your processors busy comes at the cost of a certain increased difficulty in programming since separate processes do not execute in a shared memory space, so if a spawned process needs to share data with its parent process you will need to serialize it.","Q_Score":0,"Tags":"python,macos,multiprocessing","A_Id":18168461,"CreationDate":"2013-08-11T03:02:00.000","Title":"Multiprocessing in python on Mac OS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a 200k lines list of number ranges like start_position,stop position.\nThe list includes all kinds of overlaps in addition to nonoverlapping ones.\nthe list looks like this\n\n[3,5] \n[10,30]\n[15,25]\n[5,15]\n[25,35]\n...\n\nI need to find the ranges that a given number fall in. And will repeat it for 100k numbers.\nFor example if 18 is the given number with the list above then the function should return\n[10,30]\n[15,25]\nI am doing it in a overly complicated way using bisect, can anybody give a clue on how to do it in a faster way.\nThanks","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3636,"Q_Id":18179680,"Users Score":0,"Answer":"How about,\n\nsort by first column O(n log n)\nbinary search to find indices that are out of range O(log n)\nthrow out values out of range\nsort by second column O(n log n)\nbinary search to find indices that are out of range O(log n)\nthrow out values out of range\nyou are left with the values in range\n\nThis should be O(n log n)\nYou can sort rows and cols with np.sort and a binary search should only be a few lines of code.\nIf you have lots of queries, you can save the first sorted copy for subsequent calls but not the second.  Depending on the number of queries, it may turn out to be better to do a linear search than to sort then search.","Q_Score":6,"Tags":"python,algorithm","A_Id":18180322,"CreationDate":"2013-08-12T04:47:00.000","Title":"finding a set of ranges that a number fall in","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a series of local gif files. I was wondering how I would be able to open this series of local gifs using the webbrowser module. I am, by the way, running on Mac OS X Snow Leapord. Whenever I try to use the webbrowser.open('file:gif_name') snippet, my computer throws the error 0:30: execution error: Bad name for file. some object (-37). Any help would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":231,"Q_Id":18222808,"Users Score":1,"Answer":"Use this line: webbrowser.open('file:\/\/'+os.getcwd()+'\/gif_name.gif') and change the default app to view pictures to Chrome.","Q_Score":0,"Tags":"python,browser,gif","A_Id":18229495,"CreationDate":"2013-08-14T03:39:00.000","Title":"Opening Series of Gifs in Chrome Using webbrowser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I just installed ArcGIS v10.2 64bit background processing which installs Python 2.7.3 64bit and NumPy 1.6.1.  I installed SciPy 0.12.0 64bit to the same Python installation.\nWhen I opened my Python interpreter I was able to successfully import arcpy, numpy, and scipy.  However, when I tried to import scipy.ndimage I got an error that said  numpy.core.multiarray failed to import.  Everything I have found online related to this error references issues between scipy and numpy and suggest upgrading to numpy 1.6.1.  I'm already at numpy 1.6.1.\nAny ideas how to deal with this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6801,"Q_Id":18282568,"Users Score":3,"Answer":"So it seems that the cause of the error was incompatibility between scipy 0.12.0 and the much older numpy 1.6.1.\nThere are two ways to fix this - either to upgrade numpy (to ~1.7.1) or to downgrade scipy (to ~0.10.1).\nIf ArcGIS 10.2 specifically requires Numpy 1.6.1, the easiest option is to downgrade scipy.","Q_Score":7,"Tags":"python,numpy,scipy","A_Id":18321537,"CreationDate":"2013-08-16T21:44:00.000","Title":"SciPy 0.12.0 and Numpy 1.6.1 - numpy.core.multiarray failed to import","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have Python 2.7 installed in \"C:\\Python27\". Now I run 1st demo of Python4delphi with D7, which somehow uses my Py2.7 install folder. If I rename Python folder, demo can't run (without error message). I didn't change properties of a demo form.\nWhat part\/file does py4delphi use from my Python folder?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":822,"Q_Id":18300841,"Users Score":3,"Answer":"python4delphi is a loose wrapper around the Python API and as such relies on a functioning Python installation. Typically on Windows this comprises at least the following:\n\nThe main Python directory. On your system this is C:\\Python27.\nThe Python DLL which is python27.dll and lives in your system directory.\nRegistry settings that indicate where your Python directory is installed.\n\nWhen you rename the Python directory, the registry settings refer to a location that no longer exists. And so the failure you observe is entirely to be expected.\n\nPerhaps you are trying to work out how to deploy your application in a self-contained way without requiring an external dependency on a Python installation. If so, then I suggest you look in to one of the portable Python distributions. You may need to adapt python4delphi a little to find the Python DLL which will be located under your application's directory. But that should be all that's needed. Take care of the licensing issues too if you do distribute Python with your application.","Q_Score":1,"Tags":"delphi,python4delphi","A_Id":18300977,"CreationDate":"2013-08-18T15:43:00.000","Title":"What part of installed Python does python4delphi use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Can someone tell me whether Celery executes a task in a thread or in a separate child process? The documentation doesn't seem to explain it (read it like 3 times). If it is a thread, how does it get pass the GIL (particularly whom and how an event is notified)? \nHow would you compare celery's async with Twisted's reactor model? Is celery using reactor model after all?\nThanks,","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3889,"Q_Id":18307366,"Users Score":4,"Answer":"Can someone tell me whether Celery executes a task in a thread or in a\n  separate child process?\n\nNeither, the task will be executed in a separate process possibly on a different machine. It is not a child process of the thread where you call 'delay'. The -C and -P options control how the worker process manages it's own threading. The worker processes get tasks through a message service which is also completely independent.\n\nHow would you compare celery's async with Twisted's reactor model? Is\n  celery using reactor model after all?\n\nTwisted is an event queue. It is asynchronous but it's not designed for parallel processing.","Q_Score":7,"Tags":"python,celery","A_Id":18319581,"CreationDate":"2013-08-19T06:09:00.000","Title":"Is celery's apply_async thread or process?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to open a csv file, select 1000 random rows and save those rows to a new file. I'm stuck and can't see how to do it. Can anyone help?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":11279,"Q_Id":18314913,"Users Score":-1,"Answer":"The basic procedure is this:\n1. Open the input file\nThis can be accomplished with the basic builtin open function.\n2.  Open the output file\nYou'll probably use the same method that you chose in step #1, but you'll need to open the file in write mode.\n3. Read the input file to a variable\nIt's often preferable to read the file one line at a time, and operate on that one line before reading the next, but if memory is not a concern, you can also read the entire thing into a variable all at once.\n4.  Choose selected lines\nThere will be any number of ways to do this, depending on how you did step #3, and your requirements.  You could use filter, or a list comprehension, or a for loop with an if statement, etc.  The best way depends on the particular constraints of your goal.\n5.  Write the selected lines\nTake the selected lines you've chosen in step #4 and write them to the file.\n6.  Close the files\nIt's generally good practice to close the files you've opened to prevent resource leaks.","Q_Score":0,"Tags":"python,random-sample","A_Id":18315125,"CreationDate":"2013-08-19T13:23:00.000","Title":"Selecting random rows with python and writing to a new file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As of now, I have a Django REST API and everything is hunky dory for the web app, wherein I have implemented User Auth in the backend. The \"login_required\" condition serves well for the web app, which is cookie based.\nI have an Android app now that needs to access the same API. I am able to sign in the user. What I need to know is how to authenticate every user when they make GET\/POST request to my views?\nMy research shows a couple of solutions:\n1) Cookie-backed sessions\n2) Send username and password with every GET\/POST request(might not be secure)\nAny ideas?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9898,"Q_Id":18330916,"Users Score":0,"Answer":"You may want to use the Django Sessions middleware, which will set a cookie with a django session_id. On the following requests, the sessions middleware will set an attribute on your request object called user and you can then test if user is authenticated by request.user.is_authenticated()  ( or login_required decorator) . Also, you can set the session timeout to whatever you like in the settings.\nThis middleware is enabled in default django settings.","Q_Score":4,"Tags":"java,android,python,django,authentication","A_Id":18334430,"CreationDate":"2013-08-20T08:57:00.000","Title":"How to authenticate android user POST request with Django REST API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've a c++ code on my mac that uses non-standard lybraries (in my case, OpenCV libs) and need to compile this so it can be called from other computers (at least from other mac computers). Runned from python. So I've 3 fundamental questions:\n\nHow to compile my project so it can be used from python? I've read\nthat I should create a *.so file but how to do so?\nShould it work like a lib, so python calls some specific functions,\nchosen in python level?\nOr should it contain a main function that is executed from\ncommand line?\n\nAny ideas on how to do so? PS: I'm using the eclipse IDE to compile my c++ project.\nCheers,","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":3206,"Q_Id":18342535,"Users Score":1,"Answer":"How to compile my project so it can be used from python? I've read\n  that I should create a *.so file but how to do so?\n\nThat depends on your compiler. By example with g++:\ng++ -shared -o myLib.so myObject.o\n\nShould it work like a lib, so python calls some specific functions,\n  chosen in python level?\n\nYes it is, in my opinion. It seems do be the \"obvious\" way, since it's great for the modularity and the evolution of the C++ code.","Q_Score":2,"Tags":"c++,python,c,opencv,compilation","A_Id":18342743,"CreationDate":"2013-08-20T18:33:00.000","Title":"Calling c++ function, from Python script, on a Mac OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a python program that lets you track how much certain people owe you. It should ask you your name and the people's names the first time it is run. Afterwards it should say something along the lines of \"Welcome back (name)\" and be able to retrieve the people's names and how much they owe you, as well as allowing the user to edit names\/owed money etc. \nHowever, this wasn't mentioned in any of the tutorials I did. I have no idea how to even start. Is there a library or something for this? I tried using text files but it didn't work. What is the best way to solve this problem?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":18369296,"Users Score":0,"Answer":"Your program should:\n\nCheck if a file (with a fixed filename) exists (or has any contents).\nIf it does not exist, then obtain data from the user and save it in the file.\nIf it does exist, read it.  Display it to the user.  Ask the user an input of \"quit\" (to exit) or a person name.  If a person name, ask the user for the change in balance (positive number= a new loan; negative number= payback).\n\nBefore you start, it's better you define a data model for the application, i.e. what data you need to store, and how you will store it.  Would you use lists?  Dictionaries?  Sets?  Would you create objects?  You also need to consider how to store this information in a file.  You can do this by yourself or use the pickle module or similar.  If you are just learning the language, I would recommend to do it yourself.","Q_Score":0,"Tags":"python,python-2.7","A_Id":18369413,"CreationDate":"2013-08-21T23:30:00.000","Title":"Python saving data and retrieving it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to use a default template for my files, such as first heading : description of file, author, shebang line and so on. But PyDev and eclipse don't do it for me.\nWhen i want to create a new file in my project, how i have them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":379,"Q_Id":18369347,"Users Score":2,"Answer":"You can define the templates used in PyDev (both for code-completion and for new modules) in window > preferences > pydev > editor > templates.\nAnything with the context 'new module' there will be shown to you when you create a new module (and you can have many templates, such as one for unittests, empty modules, class modules, etc).\nNote that the templates are only presented when you create a module with Alt+Shift+N > pydev module (or file > new > pydev module), not when you create a regular 'file' (even if it ends with .py)","Q_Score":1,"Tags":"python,eclipse,ide,pydev","A_Id":18384978,"CreationDate":"2013-08-21T23:35:00.000","Title":"how to define reserved template for python file for eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how I can get content of a certain element by a dynamic id\/name in embeded python codes in web2py view page?\nBasically I want something like:\n{{for task in tasks:}}\n...\n{{=TEXTAREA(task['remark'], _name='remark'+str(task['id']), _id='remark'+str(task['id']), _rows=2)}}\n{{=A('OK', _class='button', _href=URL('update_remark', vars=dict(task_id=task['id'], new_remark=['remark'+str(task['id'])])))}}\nWhat I want the ['remark'+str(task['id'])] do is to get the content automatically but obviously it won't work, I'm wondering how I can achieve this? Is there any API that can help?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":18386023,"Users Score":0,"Answer":"I used a Form to achieve this. Working quite well.","Q_Score":0,"Tags":"javascript,python,web2py","A_Id":18414025,"CreationDate":"2013-08-22T16:24:00.000","Title":"How to get content of element in embeded python codes in web2py view","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have built a csv reader with. It iterats through a file and gives results based on search terms.   I am reading 3 gig files.  When I let it iterate through the file it works fine.  But if I even touch the wxpython window after processing has begun the app stops responding then crashes.  My best guess is I have to somehow monitor\/throttle cpu usage.  I have no idea how to do this or if I am on the right path.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":90,"Q_Id":18390874,"Users Score":1,"Answer":"During a heavy operation a wx frame is \"stuck\" waiting on the process to finish. You're best solution is to create a worker thread and let it do the heavy job for you.","Q_Score":0,"Tags":"python,csv,wxpython","A_Id":18390934,"CreationDate":"2013-08-22T21:08:00.000","Title":"wxpython csv reader crashing while processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been trying to make a password creator to create a password for a assessment and one of the things that's needed is if the password doesn't have at least 2 numbers in it will print a error asking for a password with at least two numbers. I do not know how to do this and I was just wondering if you could give me a little hint on how I could do this in code. \nThanks in advance","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":18393975,"Users Score":0,"Answer":"If the problem is indeed to create a new password, I explain how to do it, but no code:\nUse the random.SystemRandom() if you want secure passwords.\nFirst create N characters from the set of allowed characters, where N is the length of your password. Then check if there are at least 2 digits. If there are less than 2 digits characters then remove 1 or 2 non-digit characters and add random digits, so that there are at least those 2 digits. Finally use the shuffle() to permute your password. That way your password has maximum entropy possible.","Q_Score":0,"Tags":"python","A_Id":18394654,"CreationDate":"2013-08-23T03:00:00.000","Title":"I'm trying to make a password creator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to use the GCS client library with my app engine app and I ran into this - \n\"In order to use the client library in your app, put the \/src\/cloudstorage directory in your sys.path so Python can find it.\"\nFirst, does this mean I need to move the directory into my sys.path OR does it need to add the ~\/src\/cloudstorage\/ to my PATH environment variable?\nSecond, when I print sys.version and sys.path from the App Engine Interactive Console, I see a Python Version of 2.7.2, but when I print from my Terminal (on a Mac), I get the Python I want to use and installed via Homebrew - 2.7.5. The sys.path in the Console shows all App Engine paths and the default Python installation - \/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\nOn my terminal - \/usr\/local\/Cellar\/python\/2.7.5\/Frameworks\/Python.framework\/Versions\/2.7\/\nI need help understanding how to change this.\n** UPDATE **\nOkay, I figured out part of this answer. \"In order to use the client library in your app, put the \/src\/cloudstorage directory in your sys.path so Python can find it.\" means moving the actual directory to the App Engine project directory.\nThe second piece still remains - why is my Mac PATH environment variable not used in APP Engine. How can I change the default version of Python used by the App Engine (from 2.7.2 to 2.7.5)? This is not related to changing the version in the YAML file.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1807,"Q_Id":18407249,"Users Score":1,"Answer":"In GAE change the python path via Preferences settings, set Python Path to match your python 27 path.","Q_Score":2,"Tags":"python,google-app-engine,path,google-cloud-storage,sys.path","A_Id":18955756,"CreationDate":"2013-08-23T16:05:00.000","Title":"Google App Engine, Change which python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently wondering how to list the constants in win32com in python, \nfor example using excel win32com.client.Dispatch('Excel.Application')\nIs there a way to display all constants using win32com.client.Constants ?\nOr does someone know where i could find win32com's documentation ? Because all the links I found are dead ...","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7331,"Q_Id":18435891,"Users Score":1,"Answer":"To find out what Com applications you can use... See http:\/\/timgolden.me.uk\/pywin32-docs\/html\/com\/win32com\/HTML\/QuickStartClientCom.html\nBasically you can't know for sure. Sorry.\nEach computer will have a different list based on the software installed, the webpage I linked suggests using pyWins ComBrowser, however I haven't ever found it that useful.\nMy normal approach is \n'I want to interface with application X in Python... lets google \"python com X\" and see what comes up'\nor\n'I want to interface with application X in Python.. lets look through the documentation of AppX for references to COM'\nAfterall you'll want to have some form of documentation to that programmes COM interface in order to be able to do anything meaningful with the program (other than opening it).","Q_Score":3,"Tags":"python,com,constants,win32com","A_Id":18492848,"CreationDate":"2013-08-26T02:45:00.000","Title":"Python win32com constants","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"My English just as my programming, are not good, apologize.\nI'm using SciTE to run python code. I added a while statement to the outside of a block of code. Then, in order to indent the next block of code, I selected it and pressed tab.\nAfter some more coding, I now want to delete the while statement and dedent (unindent) the block of code that's in the while-loop. How can I dedent a block of code?\nHope people can understand my poor description, man.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":298,"Q_Id":18436903,"Users Score":1,"Answer":"Highlight the block of code and press shift+tab","Q_Score":0,"Tags":"python,scite","A_Id":18437018,"CreationDate":"2013-08-26T04:58:00.000","Title":"in SciTE, how to make the whole block of code have less margin in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With this global variable defined in the script upper focus\n\nt0 = time.time()   ## is global\n\nand this function\n\ndef timestamp(t0):\n  ... return (\"[\" + str(time.time()-t0)+ \"] \") ## time stamping from initial start\n\nI'm trying to timestamp every print() of my script with\n\nprint(timestamp(t0) + \"\"...whatever...\"\")\n\nThis works, but when i'm enterring multithreading by\n\nfor thread_id in range(win32-safe_os):\n        ... p = Process(target=fonction, args=((thread_id),\"test\"))\n        ... p.start()\n        ... thread_list.append(p)\n\nin order to\n\ndef fonction(thread_id,filetodo):\n     ... print(timestamp(t0)+\"Load core \"+str(thread_id))\n     ... print(timestamp(t0)+str(filetodo)+\" on core \"+str(thread_id))\n     ... print(timestamp(t0)+\"Free core \"+str(thread_id))\n\ni get this stdout :\n[2.70299983025] 297 jpg \/ 36087 files \n[2.75] Enterring multithreading [2.75] Win32 finds : 2 core(s) [0.0] Load core 0 [0.0] test on core 0 [0.0] Free core 0 [0.0] Load core 1 [0.0] test on core 1 [0.0] Free core 1\nI can see that my call to timestamp() and t0 is working, but not in p.start(). I'm wondering how(, and why) i need to correct ?\nPS : I tried with time.clock, but in win32 it refers to the beginning of a THREAD (not a script)\/","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":18446580,"Users Score":2,"Answer":"Each process has a separate instance of the global variable. If you want each process to see the same value, you'll need to pass that value as an argument to each process.","Q_Score":0,"Tags":"python,multithreading,performance,win32-process","A_Id":18446899,"CreationDate":"2013-08-26T14:30:00.000","Title":"Understanding why multithreading could not read a global variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am planning my all day activities in Google calendar LIke\n\nOffcie time\nsleeping\nplaying\nGym\n\nI am happy with Google but issue is that i don't get reporting so that i can see how much time is spent in each category.\nI know python and django so i was thinking is it possible that i still log all events in Google calendar and then i have daily cron jobs which will fetch events from Google calendar and then put in mysql database.\nThe main issue is i want to define separate categories for different things. Like WORK, SLEEP, SHOPPING etc.\nBut how can i do that from event name only. DO i need to enter some words in events whicg i can grab and make them as category. ANy ideas on that","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3005,"Q_Id":18455213,"Users Score":0,"Answer":"I'm probably going to write a Python script for this soon. \nI had written a reporting app before in C#, but it's badly written and I think Google has changed their API again so it's not working anymore. \nThe way I did it was to use tags. I wanted my total work hours per client. I would enter them into Google Calendar as: \n    @clientname description of work\nWhere clientname can be the first few letters only and the software matches it to a full name from a list of clients. My software would then allow you to chose a time-period and one or more clients and would output them into a neat looking Word file. \nPS: to by honest the suggestion of using gtimereport.com seems very bad to me. You're basically uploading all of your calendars to strangers. That's why I'm going to write a script for this.","Q_Score":3,"Tags":"python,django,reporting,google-calendar-api","A_Id":52007377,"CreationDate":"2013-08-27T00:42:00.000","Title":"Can i generate reporting using google calendar","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a text file which is 10k lines long and I need to build a function to extract 10 random lines each time from this file. I already found how to generate random numbers in Python with numpy and also how to open a file but I don't know how to mix it all together. Please help.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":3957,"Q_Id":18455589,"Users Score":1,"Answer":"It is possible to do the job with one pass and without loading the entire file into memory as well. Though the code itself is going to be much more complicated and mostly unneeded unless the file is HUGE. \nThe trick is the following:\nSuppose we only need one random line, then first save first line into a variable, then for ith line, replace the currently with probability 1\/i. Return the saved line when reaching end of file. \nFor 10 random lines, then have an list of 10 element and do the process 10 times for each line in the file.","Q_Score":4,"Tags":"python,numpy","A_Id":18456597,"CreationDate":"2013-08-27T01:35:00.000","Title":"Retrieve 10 random lines from a file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed package control, and I use it frequently, the problem is that I added a new repository and it is wrong, and when I try to install other package, sublime throw exception, somebody know how can I remove a repository in sublime text.\nNote: I have the problem in a OSX.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1741,"Q_Id":18456708,"Users Score":1,"Answer":"You can also access the Package Control settings from the Menu bar under:\nPreferences -> Package Settings -> Package Control -> Settings - User.\nFrom there you can edit or remove the bad URL.","Q_Score":2,"Tags":"python,repository,sublimetext2","A_Id":18722089,"CreationDate":"2013-08-27T04:01:00.000","Title":"sublime text remove repository","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a vector of pointers to objects in c++ and want to expose it to python with a list. So far I gave a reference of a python list to c++. I figured pointers are not suitable for python so I read about how to make a pointer to a reference by (*obj) it. But when I call: myList.append((*obj)); python just crashes. Can someone tell me how to put objects I only have pointers of into a python list correctly so I can manipulate that list later?\nGreetings\nChris","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":18462319,"Users Score":0,"Answer":"Okay so the Problem appears when the type is not declared for boost::python. !","Q_Score":0,"Tags":"c++,python,list,boost,reference","A_Id":18467078,"CreationDate":"2013-08-27T09:56:00.000","Title":"appending object references to python list with boost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I writing Dbus service implementing some protocol. My service sends to client message with unexpected data (library i used has some bugs, that i want to overwrite).\nHow to inspect, trace client calls? I want to determine what client wants and locate buggy method.\nOr how to trace all calls in service? I has much of logger.debug() inserted.\nService is python, client is c.\nHow to specify path or service to monitor in dbus-monitor with sender and reciever?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1405,"Q_Id":18463836,"Users Score":2,"Answer":"dbus-monitor \"sender=org.freedesktop.Telepathy.Connection.******\"","Q_Score":5,"Tags":"python,c,dbus","A_Id":18476891,"CreationDate":"2013-08-27T11:14:00.000","Title":"How debug or trace DBus?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this is dumb but every piece of documentation i read doesn't ever seem to answer this question in a direct way. How do i properly use virtualenv so that I have a virtualenv i can call with workon? \nWhen i do tutorials like \"Effective Django\" they use the virtualenv command on an empty folder, then activate it. That works, until tomorrow when I want to work on the app again at which point the virtualenv is gone. What do i do at this point, I've used mkvirtualenv before and that creates a \"permanent\" virtualenv i can call with \"workon\" but I don't understand how i would use mkvirtualenv on an existing project or if this is a good idea or not, as it stands i have a project I virtualenv yesterday that has a bin folder in it and I am not sure if I need to source it again or what. Ideally i want to just workon project and get to work.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":329,"Q_Id":18475116,"Users Score":2,"Answer":"When i do tutorials like \"Effective Django\" they use the virtualenv command on an empty folder, then activate it. That works, until tomorrow when I want to work on the app again at which point the virtualenv is gone. \n\nI strongly doubt that this is the case, unless something is deleting your directories overnight. If that is the case, stop putting your code where it is being deleted.\nAssuming that is not the case, the solution is for you to go back to the directory you created as a virtualenv, and reactivate it.","Q_Score":0,"Tags":"python,django,virtualenv,virtualenvwrapper","A_Id":18475165,"CreationDate":"2013-08-27T20:43:00.000","Title":"virtualenv\/virtualenvwrapper confusion - how to properly use","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to make a wx.lib.filebrowsebutton.FileBrowseButton button match both txt and csv files, but it doesn't seem to support glob pattern as described, *.{txt,csv} ends up matching nothing on windows and it literally tries to look for files with extension of {txt,csv}.\nSo how do I make it work for both txt and csv files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":157,"Q_Id":18489613,"Users Score":3,"Answer":"The documentation is not very clear. You should be using a semi-colon inside parenthesis, like so:  \"TXT and CSV files (*.txt; *.csv)|*.txt; *.csv\"\nYou can also add a second line like so: \"TXT and CSV files (*.txt; *.csv)|*.txt; *.csv|PNG files (*.png)|*.png\"","Q_Score":3,"Tags":"python,wxpython,glob,filebrowse","A_Id":18489942,"CreationDate":"2013-08-28T13:40:00.000","Title":"Is there a way to add multiple filemasks in wx.lib.filebrowsebutton.FileBrowseButton?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a default installation of Elasticsearch which I am trying to query from a third party server. However, it seems that by default this is blocked. \nIs anyone please able to tell me how I can configure Elasticsearch so that I can query it from a different server?","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":15468,"Q_Id":18499338,"Users Score":1,"Answer":"There is no restriction by default, ElasticSearch expose a standard HTTP API on the port 9200.\nFrom your third party server, are you able to: curl http:\/\/es_hostname:9200\/?","Q_Score":5,"Tags":"python,security,lucene,debian,elasticsearch","A_Id":18514779,"CreationDate":"2013-08-28T22:29:00.000","Title":"Allowing remote access to Elasticsearch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a default installation of Elasticsearch which I am trying to query from a third party server. However, it seems that by default this is blocked. \nIs anyone please able to tell me how I can configure Elasticsearch so that I can query it from a different server?","AnswerCount":5,"Available Count":2,"Score":0.1194272985,"is_accepted":false,"ViewCount":15468,"Q_Id":18499338,"Users Score":3,"Answer":"In config\/elasticsearch.yml, put network.host: 0.0.0.0.\nAnd also add Inbound Rule in firewall for your ElasticSearch port(9200 ByDefault).\nIt worked in ElasticSearch version 2.3.0","Q_Score":5,"Tags":"python,security,lucene,debian,elasticsearch","A_Id":37047491,"CreationDate":"2013-08-28T22:29:00.000","Title":"Allowing remote access to Elasticsearch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im wanting to use imshow() to create an image of a 2D histogram. However on several of the examples ive seen the 'extent' is defined. What does 'extent' actually do and how do you choose what values are appropriate?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":18511206,"Users Score":2,"Answer":"Extent defines the images max and min of the horizontal and vertical values. It takes four values like so: extent=[horizontal_min,horizontal_max,vertical_min,vertical_max].","Q_Score":1,"Tags":"python,matplotlib,histogram2d","A_Id":18511409,"CreationDate":"2013-08-29T12:36:00.000","Title":"What does extent do within imshow()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing my first Flask application (with sqlite as a database). It takes a single name from user as a query, and displays information about this name as a response.\nAll working well, but I want to implement typeahead.js to make better user experience. Typeahead.js sends requests to server as user types, and suggests possible names in dropdown. Right now I'm searching the database with select * from table_name where name like 'QUERY%'. But this of course is not so fast as I would like it to be - it works, but with noticable input lag (less or around a second I suppose).\nIn order to speed up things I looked at some memory caching options (like Redis or memcached), but they are key-value store, therefore I think do not fit my needs. I think possible option would be to make list of names ([\"Jane\", \"John\", \"Jack\"], around 200k names total), load it into ram and do searches there. But how do I load something in memory in Flask?\nAnyway, my question is: What is the best way to make such search (by first few letters) faster (in Python\/Flask)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1008,"Q_Id":18540987,"Users Score":0,"Answer":"You are looking for \"partial matches\". I would load all possible names into an array, and sort them. Then I would separately create a (26x26) lookup array that shows the index of the first element in the list of names that corresponds to a combination of the first two letters; you might also have a dict (rather than an exhaustive list) of all possible three letter combinations, which would speed up your search (because it limits it to a much smaller slice of the array).\nIn other words - you would not really be searching at all (for the two and three letter combo's); you would be returning a slice of the array. Once you have a match of more than three, you probably can search the slice (not worth creating tables beyond three characters).","Q_Score":0,"Tags":"python,sqlite,search,flask,typeahead","A_Id":18541075,"CreationDate":"2013-08-30T20:28:00.000","Title":"Fastest text search in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to match both formats like: user:pass@112.213.123.12:3847 and 111.23.123.78:2938, how do you do that(match valid proxy only)? \nAnd by the way, is there such module(validate proxy formats) in python already?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3078,"Q_Id":18546053,"Users Score":0,"Answer":"The solution I'm currently using to accept http \/ https only, username:password optionally and host as an IP or domain name is the following:\n\n^(?:https?:\\\/\\\/)(?:(\\w+)(?::(\\w*))@)?([a-zA-Z0-9][a-zA-Z0-9-_]{0,61}[a-zA-Z0-9]{0,1}\\.([a-zA-Z]{1,6}|[a-zA-Z0-9-]{1,30}\\.[a-zA-Z]{2,3})|((?:\\d{1,3})(?:\\.\\d{1,3}){3}))(?::(\\d{1,5}))$\n\nI hope it helps","Q_Score":0,"Tags":"python,regex","A_Id":61012316,"CreationDate":"2013-08-31T08:14:00.000","Title":"How to perfectly match a proxy with regex?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to write a code which recognizes a text line by line and reverses each line in the output, I dont know how to enter a text with multiple lines (as \"input()\" function will take the input after the first \"Enter\" but I still want to enter more lines? \nsecond I don't know how to count the input line by line? whould \"split(\/n) be an option?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":105,"Q_Id":18546103,"Users Score":-1,"Answer":"Entering multiple lines: use three quotation marks thusly:\n\"\"\"hello\nthis is multiple\nlines\"\"\"\ncount lines... len(text.split()) or len(text.split('\\n')) etc","Q_Score":1,"Tags":"python,python-3.x","A_Id":18546144,"CreationDate":"2013-08-31T08:21:00.000","Title":"How to show EOF in Python? \/ how to identify lines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program thats like a desktop enviroment with educational games and I was wondering how to put the menubar on the bottom of the window.\nThanks In Advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":269,"Q_Id":18546876,"Users Score":0,"Answer":"You can't, if you're talking about the native menubar you get when you set the menu attribute of the root window.\nYou can create your own menubar that behaves a little bit like a menubar by using a frame and one or more menubuttons, and place that at the bottom.","Q_Score":0,"Tags":"python,tkinter","A_Id":18548116,"CreationDate":"2013-08-31T10:02:00.000","Title":"tkinter - Change menubar location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok so what I'd like to do is have a game written in python and for all the multiplayer to be handled socket.io just because these are two things I'm fairly familiar with and I wanna keep possibilities for a web version or web app for the game open\nSo what I'm wondering is, how exactly do I do this and would it be better to embed a javascript parser on the client side or contact node.js from python directly","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":347,"Q_Id":18555139,"Users Score":0,"Answer":"Assuming your Python objects are simple enough (not instances of classes, say), just send a JSON representation (json.dumps()) of them to the socket.io side. I am assuming you can parse JSON on the client side if needed.","Q_Score":0,"Tags":"python,node.js,socket.io","A_Id":18555399,"CreationDate":"2013-09-01T04:10:00.000","Title":"Sending python objects to node.js via socket.io","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have an excel file whose extension is .xls but his type is Tab Space separated Text.\nWhen I try to open the file by MS Excel it tells me that the extension is fake. And So I have to confirm that I trust the file and so I can read it then.\nBut my real problem is that when I try to read my file by the xlrd library it gives me this message :\nxlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;\nAnd so to resolve this problem, I go to Save as in MS Excel and I change the type manually to .xls.\nBut my boss insist that I have to do this by code. I have 3 choices : Shell script under Linux, .bat file under Windows or Python.\nSo, how can I change the type of the excel file from Tab space separated Text to xls file by Shell script (command line), .bat or Python?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":399,"Q_Id":18570143,"Users Score":1,"Answer":"mv file.{xls,csv}\nIt's a csv file, stop treating it as an excel file and things will work a lot better. :)  There are nice csv manipulation tools available in most languages. Do you really need the excel library?","Q_Score":0,"Tags":"python,linux,excel,shell,xlrd","A_Id":18574653,"CreationDate":"2013-09-02T09:46:00.000","Title":"How to change automatically the type of the excel file from Tab space separated Text to xls file?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm brand new to coding.  I managed to figure out how to use github and I have been forking projects over to my machine in an attempt to play around with them and learn python.  My problem is every single project I fork over, when I run any of the .py files in Coderunner it pops up with errors and doesn't run correctly.  \nIs this because coderunner is not capable of running these programs?  Or do I have to run the programs through terminal to get them functioning correctly?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":605,"Q_Id":18581973,"Users Score":1,"Answer":"Coderunner is more useful in testing single python files instead of larger projects, however it can run such projects.  A larger project should have a setup.py or a main.py which should be run.  Also, what errors are you getting?","Q_Score":1,"Tags":"python,coderunner","A_Id":21959976,"CreationDate":"2013-09-02T23:19:00.000","Title":"Unable to run any Python program using code runner","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was asked to split a big project into some reusable libraries (packages). So the idea was to do this:\n\ncompany-django-shared\ncompany-django-shared-dev\ncompany-python-shared\ncompany-python-shared-dev\n\nThese are installable with setuptools and namespaces:\n\ncompany\ncompany.packagename\ncompany.packagename.tests\ncompany.util\netc...\n\nAll this works fine. I can start a shell and do any of the import i need. The problem arrives when I now want to use this in a django project. My settings are in:\n\ncompany.foo.settings\n\nAt this point, since setuptools installed some packages, when I try to\n$ .\/manage.py shell\nI get the error::\nImportError: Could not import settings 'company.foo.settings' (Is it on sys.path?): No module named foo.settings\nI really can't figure out how to use namespace within django apps. If I fire up a shell and do:\nimport company\ncompany.__path__\nThe installed paths are found, but not the current directory. What am I missing?\nEDIT\nI would like to point out that the problem is Python cannot find any package under company because setuptools-installed packages define company as a namespace.\nEDIT 2\nDjango is just unhappy with namespaces. It seems there are no viable solutions.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1119,"Q_Id":18596971,"Users Score":0,"Answer":"The only way I found for now is the following:\n\nDo not use the namespace_packages parameter in setuptools.setup()\n\nInstead, explicitly define \"namespace\" packages with this in the __init__.py file:\n__import__('pkg_resources').declare_namespace(__name__)\nI have not done a lot of testings as to if this will work if I don't install my libraries in the same order, but at least, I am able to import my django settings (and everything else).\nEDIT\nThis ended up not being a viable solutions because if librairies are uninstalled and reinstalled, they will delete more than they should, so ending up loosing modules.\nI ended up using namespace_packages in setuptools.setup() and use a different first level \"namespace\" for the running django project.\nEDIT 2\nScrap all this, this namespace thing seems to be a good idea, but ended up just being a nightmare with django. So i reverted everything back to non-namespace code. I'm not happy that I have to do this, but that's the price to work with django.","Q_Score":2,"Tags":"python,django,namespaces,setuptools","A_Id":18644769,"CreationDate":"2013-09-03T16:16:00.000","Title":"ImportError: Could not import settings 'company.foo.settings' (Is it on sys.path?): No module named foo.settings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to know how to disable the window Maximise button in pyqt4. I am at present using QWidget.setFixedSize (self, QSize) to prevent user window resizing, however the maximise button is still enabled and when pressed causes the application to move to the top left corner of the screen. I am basically wanting to replicate the behaviour of the Windows calculator application, where the maximise icon is greyed out. Does anyone know how to achieve this with PyQt4?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":20169,"Q_Id":18600081,"Users Score":1,"Answer":"you could set the maximumSize and minimumSize with the same values, it'll get to dissapear maximise button","Q_Score":12,"Tags":"python,resize,window,pyqt,pyqt4","A_Id":29042473,"CreationDate":"2013-09-03T19:32:00.000","Title":"how to disable the window maximize icon using PyQt4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python so be gentle.\nI have been trying to write a program that counts or measures events in real time. At the moment I am using the sleep command but this pause event doesn't take into account the time the program takes to run. I have read up on the datetime module and can sort of see how this could be used, but I am a bit stuck in implementing this.\nIn short, I want a program that counts from 0 to 100 in real time seconds and milliseconds.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":299,"Q_Id":18600435,"Users Score":3,"Answer":"Your best bet (besides Googling for help before posting a question on SO) might be to do something like this:\n\nNote the time when the program starts. start = datetime.datetime.now()\nDo your calculations\nsleep until 100 seconds after start. (start + datetime.timedelta(seconds=100))\n\nNote that this won't be perfect, since there is a little overhead involved with the steps between accessing the \"current time\" and going to \"sleep\" (e.g. subtracting \"current time\" from \"wake-up time\"). However, if your sleep precision only needs to be in seconds, you should be okay.\n\nRepeat as needed.\n\nIf, after trying it out, you need additional help with the actual implementation of these steps, feel free to come back and post another question on that topic.","Q_Score":0,"Tags":"python","A_Id":18600585,"CreationDate":"2013-09-03T19:55:00.000","Title":"Real time timer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in the process of making a text based game with Python, and I have the general idea down. But I am going to make the game in depth to the point where, it will take longer than one sitting to finish it. So I want to be able to make the game to where, on exit, it will save a list of variables (player health, gold, room place, etc) to a file. Then if the player wants to load the file, they go to the load menu, and it will load the file.\nI am currently using version 2.7.5 of Python, and am on Windows.","AnswerCount":8,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":36232,"Q_Id":18606097,"Users Score":4,"Answer":"First, don't overthink this. You don't need to use anything complicated. As a preliminary step, research basic file input\/output in python. \nSecond, I'm assuming you have a player class in your game? Or possibly an overall class which keeps track of game state. Well have that class store default values for your variables like health, gold etc. Then have a method which can modify this class like def load_stats(player): or def load_stats(game): something. and have it read in from a save file which can have any format you like and modify the variables of your player\/game state. \nFirst test loading of game files and make sure you can get it so that your player class gets modified.\nThen all you have to do is add a save game feature that lets you output these variables back to a file in your directory system somewhere. \nTry doing this and let me know if you need any help afterwards.","Q_Score":5,"Tags":"python,save","A_Id":18606314,"CreationDate":"2013-09-04T05:35:00.000","Title":"Python text game: how to make a save feature?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to vim and I want to use it for scripting Python3. anyone knows how to customize vim for editing Python 3 scripts? (mainly for indentations, coloring and tab suggestions... ) \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1096,"Q_Id":18624934,"Users Score":1,"Answer":"You should put customized settings in to ~\/.vim\/ftplugin\/python.vim This will be sourced when vim sees a file with a filetype python.\nTo make sure the settings only affect the current buffer use setlocal.\nTo make sure that mappings only affect the current buffer use noremap <buffer>\nJust make sure to have filetype plugin indent on in ~\/.vimrc","Q_Score":0,"Tags":"vim,python-3.x","A_Id":18626135,"CreationDate":"2013-09-04T22:35:00.000","Title":"How to Customize vim for scripting in Python 3 ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python how would I write the string '\"['BOS']\"'.\nI tried entering \"\\\"['BOS']\\\"\" but this gives the output '\"[\\'BOS\\']\"' with added backslashes in front of the '.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":3846,"Q_Id":18645394,"Users Score":1,"Answer":"Enclose the entire string with \"\"\" or ''' (you would use ''' if the outermost quotation marks were \") in cases like these to make things simpler.\n\"\"\"'\"['BOS']\"'\"\"\"","Q_Score":0,"Tags":"python,string","A_Id":18645414,"CreationDate":"2013-09-05T20:30:00.000","Title":"Multiple Quotes in String","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using TastyPie and Django to build out my backend for an application that will have browser and mobile (native iOS) clients.\nI have been through the TastyPie and Django docs, can authenticate successfully either using the TastyPie resources I set up, or using Djangos built in views. I see a lot of examples on including the CSRF token on the page and grabbing it with your JavaScript, and that works, but I don't understand now to actually determine whether a user is logged in on initial page load (from JavaScript). \nExample:\nIf I want to serve static HTML from a separate, fast web server, and cache my application JavaScript, and only interact with Django through TastyPie views, how do I determine if the user is logged in (and know to render a login form or the app views using JavaScript), and after logout, is there any session information I need to remove from the client browser?\nIf I were to serve up HTML through Django's template engine, I could render the login form through there appropriately, but that seems not ideal if I want to truly decouple my JavaScript app from Django (and behave like a mobile client).\nEdit: I am using Backbone.js, but I don't think that should matter.\nUPDATE:\nI think I figured it out reading through Django's CSRF documentation again.\nIf your view is not rendering a template containing the csrf_token template tag, Django might not set the CSRF token cookie. This is common in cases where forms are dynamically added to the page. To address this case, Django provides a view decorator which forces setting of the cookie: ensure_csrf_cookie().\nIf I do not want to render Django templates, this reads like I can still use the cookie and pull that into my Backbone or jQuery AJAX methods. I'm not sure if TastyPie ensures the cookie will be sent or how to tie into it.\nIf I use AJAX to logout, will the cookie automatically be removed or does it become invalid? Are these CSRF tokens unique to each user session? I'll have to test some things tomorrow with it. Is it possible to use Django decorators on TastyPie views?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":275,"Q_Id":18650551,"Users Score":1,"Answer":"A mobile client doesn't care if the Javascript comes from Django or any other web server.  So go ahead and put all your JavaScript and static HTML on another server.\nIf you want your mobile app to see if the user is logged in, it should make an AJAX call to your Django backend (where the request is authenticated).  The data returned should indicate if the session is active (user is logged in).\nAnother AJAX call can perform the Django logout function.","Q_Score":1,"Tags":"javascript,python,django,client-server,tastypie","A_Id":18650699,"CreationDate":"2013-09-06T05:30:00.000","Title":"How to properly decouple Django from an AJAX application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to pre-pend a simple author and copyright clause the beginning of newly created ipython notebooks.  Is this possible? If so how can it be done?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1779,"Q_Id":18706059,"Users Score":1,"Answer":"We want to support this in metadata at notebook top level, but nobody has taken time to write a proposal for metadata structure, how to edit it, and how to show it.\nThis would be usefull for view on nbviewer, but also for conversion to LaTeX, and other format. It might just be slightly more complicated that at first thought, as you probably want the Authors to be more that just first name\/last name (like a full embeded vcard for example).\nIf you want to work on that you are welcomed, otherwise in the meantime I suggest adding a simple markdown cell at top with those info. \nThis should be easy to do on a buch on notebook at once as they are easy parsable json.","Q_Score":3,"Tags":"ipython-notebook","A_Id":18712352,"CreationDate":"2013-09-09T20:01:00.000","Title":"How can I automatically add author and copyright info to newly created ipython notebooks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi want to add text box and label in plone site\nbut, that plone site does not display text box \nhow can i create text box in plone site \nthanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":18711815,"Users Score":5,"Answer":"You can create a static text portlet in that context you need it: folder, page.","Q_Score":0,"Tags":"python,html,plone","A_Id":18714130,"CreationDate":"2013-09-10T06:12:00.000","Title":"How to create text box in plone site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how to text-to-speech Chinese using the python package 'pyttsx'. It seems to need some other modules like neospeech.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2532,"Q_Id":18715563,"Users Score":2,"Answer":"Yes, neospeech is a language library. By installing it, you can just set the voice of pyttsx and tts Chinese as well.","Q_Score":2,"Tags":"python,text-to-speech","A_Id":21506735,"CreationDate":"2013-09-10T09:44:00.000","Title":"How to TTS Chinese using pyttsx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a beginner of openerp 7. i just want to know the details regarding how to generate report in openerp 7 in xls format. \nThe formats supported in OpenERP report types are : pdf, odt, raw, sxw, etc..\nIs there any direct feature that is available in OpenERP 7 regarding printing the report in EXCEL format(XLS)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2902,"Q_Id":18716623,"Users Score":0,"Answer":"In python library are available to export data in pdf and excel\nFor excel you can use:\n           1)xlwt\n           2)Elementtree\nFor pdf genration :\n           1)Pypdf\n           2)Reportlab \n      are available","Q_Score":1,"Tags":"python,openerp","A_Id":18716823,"CreationDate":"2013-09-10T10:34:00.000","Title":"How to print report in EXCEL format (XLS)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using the NB convert with default options (\"article\") I am not getting a footer with page numbers?\nI know nothing about LaTex but a brief look at the tpl files seems to indicate that I should get footers (maybe with page numbers?) The \"book\" option give nice footers, but is not a great format for other reasons...\nI looked at the generated tex file and don't see anything for footers,, I did find that I can replace \"unknown author\" with my name.. :-)\nAny guidence on how to modify either the generated tex file or something else?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1224,"Q_Id":18728883,"Users Score":3,"Answer":"You can set the author using\nipython nbconvert --to latex --SphinxTransformer.author='John Doe' file.ipynb","Q_Score":3,"Tags":"python,latex,ipython-notebook","A_Id":19784607,"CreationDate":"2013-09-10T21:15:00.000","Title":"IPython Notebook NB convert formatting Footers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using \"subprocess\" to execute a .exe file from a Python script. I need to do this in a loop, ie start the .exe, run it for a minute, kill it, do it all over again.\nI am using subprocess.check_call to execute it with arguments, but I don't know how to stop it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1986,"Q_Id":18742845,"Users Score":0,"Answer":"subprocess.check_call is used to check the returned value - use subprocess.Popen this returns a process ID, (pid), which can be used after your time limit with pid.terminate() to end the process, (kill it).","Q_Score":0,"Tags":"python","A_Id":18743249,"CreationDate":"2013-09-11T13:39:00.000","Title":"In Python, how do I execute a .exe file, and stop it after n seconds?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok, I ask this question on behalf of someone else but I would also like to know if and how it is possible.\nLet's say you have a given line of code producing the string \n\nTime left: 4\n\nIs there any way how I can then after this string has been printed edit the value of the \"4\" and change it to a \"3\" and then reprint the new string on the same line so Time left: 4 is replaced with Time left: 3 without causing a new line to be printed.\nI hope you understand the question I did my best to explain it.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":131,"Q_Id":18745757,"Users Score":2,"Answer":"One method is printing the backspace escape character (\\b), which will will move the text cursor one character back; however, it is your responsibility to print something afterward to replace the text.\nFor example, if the current text in the terminal is Time left: 4 and you print \"\\b\", the user will see nothing has changed.  However, if you print \"\\b5\", it will replace it with 5.","Q_Score":0,"Tags":"python,python-3.x","A_Id":18745877,"CreationDate":"2013-09-11T15:46:00.000","Title":"How to alter a string after it has been printed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I went thought and installed pip and then added a bunch of libraries that I like to use and then, only after installing everything, did I realize that everything went into the 2.7.2 sit-packages directory, so the Python2.7.5 version doesn't see anything. \nNow, If I type python --version in the terminal, the correct version is started. However, pip is still \"tied\" to the default version of Python. \nHow do I go about telling OSX to look at the new version of Python for everything?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":257,"Q_Id":18748060,"Users Score":1,"Answer":"Honestly, one way around this is to make sure that virtualenv works with the right version, and just use pip inside the virtualenv.","Q_Score":1,"Tags":"python,macos,pip","A_Id":18748089,"CreationDate":"2013-09-11T17:54:00.000","Title":"noob, but I installed python 2.7.5 on my mac, how to I \"target\" that one rather than the built in 2.7.2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic \"template\" I downloaded from a website was old and used Python 2.5.\nSo, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard).\nI have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong.\nI know that I downloaded Python 2.7 (as the download path is C:\/Python27\/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":198,"Q_Id":18754202,"Users Score":2,"Answer":"I'm not sure if this is your formatting when you loaded your code here, but where you define app in main.py should not be part of the contacts class. If it is, your reference to main.app in your app.yaml won't work and your page won't load.","Q_Score":0,"Tags":"python,google-app-engine,python-2.7,server-error","A_Id":18774464,"CreationDate":"2013-09-12T02:08:00.000","Title":"Upgrading to Python 2.7 Google App Engine 500 server error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic \"template\" I downloaded from a website was old and used Python 2.5.\nSo, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard).\nI have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong.\nI know that I downloaded Python 2.7 (as the download path is C:\/Python27\/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":198,"Q_Id":18754202,"Users Score":0,"Answer":"Thank you everyone for your respective answers and comments, but I recently stumbled upon GAE boilerplate and decided to use that and everything's fine. I kept having very odd problems with GAE beforehand, but the boilerplate is simple and seems to be working fine so far. Anyways, thanks again. (Note: I would delete the question but two people have already answered and received rep from +1s, and they are in fact helpful answers, so I'll leave it be).","Q_Score":0,"Tags":"python,google-app-engine,python-2.7,server-error","A_Id":18778368,"CreationDate":"2013-09-12T02:08:00.000","Title":"Upgrading to Python 2.7 Google App Engine 500 server error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic \"template\" I downloaded from a website was old and used Python 2.5.\nSo, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard).\nI have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong.\nI know that I downloaded Python 2.7 (as the download path is C:\/Python27\/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":198,"Q_Id":18754202,"Users Score":2,"Answer":"I'm submitting as an answer because I'm relatively new to SO and don't have enough rep to comment, so sorry about that... But line 7 of your new main.py uses webapp instead of webapp2, so that may be causing some troubles, but likely isn't the reason that it's not working. Could you also provide the contact.html template?","Q_Score":0,"Tags":"python,google-app-engine,python-2.7,server-error","A_Id":18754606,"CreationDate":"2013-09-12T02:08:00.000","Title":"Upgrading to Python 2.7 Google App Engine 500 server error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a Django admin control panel and in each list of objects there are lots and lots of list filters. I want to be able to clear all the filters with a click of a button, but can't find where this ability is, if it already exists in Django.\nRoutes I'm considering (but cannot figure out):\n\nMake the last item in the breadcrumb link to the full list\nMake a direct hyperlink as a filter list option\nFind some way to access all the query options and remove them or simply return a blank one (queryset.all() isn't working; I'm probably barking up the wrong tree.)\nThat kind of thing should already exist! Find out how to use it.\n\nDoes anybody know how to accomplish this? I've been trying to figure it out all day.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1347,"Q_Id":18755024,"Users Score":0,"Answer":"If you have at least one entry in search_fields and therefore are showing a search box on your admin changelist page, if you have any filters or search terms in effect you should see information to the right of it showing the number of rows that match your current filter and search criteria.  It'll be worded as something like \"5 results (50 total)\".  The \"50 total\" text will be a link to an unfiltered version of the list, showing the whole set.  Possibly paginated, but all filters will be cleared.\nThis doesn't appear to be automatically exposed without the search box.  The filter settings are simple arguments in the URL querystring, so it should be easy to add a link similar to the one in the search box that just drops the querystring, but you'd have to learn a little about the admin templates to do so.  Setting a search_fields entry is probably simpler, if you have anything reasonable to search over.","Q_Score":3,"Tags":"python,django,list","A_Id":18755121,"CreationDate":"2013-09-12T03:49:00.000","Title":"Django Clear All Admin List Filters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how Python deals with ConfigParser line endings in the different OSes? Because it follows the Windows INI format. But what about Linux?\n(As you know, Windows text line endings are typically CRLF, and Unix's are CR.)\nI want users of my app to take their config files (.INI files) easily from Windows to Linux and I'd like to know if that's going to be problematic.\nIf it does use different line endings for Unix and Windows, what do you recommend?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1432,"Q_Id":18755831,"Users Score":2,"Answer":"You're fine, ConfigParser will still work.\nThe reason is that is uses fp.readline, which reads up to and including the next LF (\\n). The value is then stripped of whitespace, which removes the CR (\\r).\nI'd say just use LF (\\n) as your line separator - it will work on both systems, but using both won't cause any harm either.\nEdit: In fact, if you generate a file using ConfigParser.RawConfigParser it will use \\n as the line separator.","Q_Score":1,"Tags":"python,newline,configparser","A_Id":18756706,"CreationDate":"2013-09-12T05:13:00.000","Title":"Python's ConfigParser: Cross platform line endings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a python script which adds a user using the command os.system('useradd user'). This code works fine when run like a python script like this sudo python script.py. However, once I convert it to executable with pyinstaller with the command python pyinstaller.py --onefile script.py, and run the executable like this sudo .\/script, I get an error useradd: error while loading shared libraries: libselinux.so.1: failed to map segment from shared object: Permission denied. Any idea what is the issue and how to fix?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":550,"Q_Id":18761985,"Users Score":0,"Answer":"Looks like os.system('sudo useradd user') solved the issue.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":18767999,"CreationDate":"2013-09-12T10:39:00.000","Title":"After converting python script to executable with pyinstaller I get: error while loading shared libraries... Permission denied","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using PyScripter as IDE for Python.\nPython version 3.3.2 64 bit version.\nPython interpreter in scripter is very small for visualisation.\nCan anybody please help me how to increase the font of python interpreter in PyScripter?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":776,"Q_Id":18773414,"Users Score":4,"Answer":"In PyScripter 2.5.3 right mouse click on interpreter window and to choose in a pop-up menu 'interpreter editor option'.","Q_Score":3,"Tags":"python-3.x,pyscripter","A_Id":18924536,"CreationDate":"2013-09-12T20:05:00.000","Title":"About font of python interpreter in PyScripter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to make a very simple image that will illustrate a cash flow diagram based on user input. Basically, I just need to make an axis and some arrows facing up and down and proportional to the value of the cash flow. I would like to know how to do this with matplot.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":875,"Q_Id":18778266,"Users Score":0,"Answer":"If you simply need arrows pointing up and down, use Unicode arrows like \"\u2191\" and \"\u2193\". This would be really simple if rendering in a browser.","Q_Score":0,"Tags":"python,image,matplotlib","A_Id":18778542,"CreationDate":"2013-09-13T04:21:00.000","Title":"Cash flow diagram in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need simple cache structure (in python, but it doesn't really matter), with some specific requirements:\n\nUp to several millions of small objects (100 bytes on average)\nSpeed is the key (both put and get), I'd expect operation times at about few microseconds\nOnly one thread accessing this - so it can be all just in memory (do not need persistence)\nKeys are MD5 hashes (if it matters)\nThere's an expiration time, global for the cache - every key should be removed from the cache after expiration time, counting from the time of first put\n\nNow, the point is how to implement expiration - as everything other can be done using simple dictionary. The simplest solution - to iterate all data regularly and remove expired keys - could lock whole cache for too long. It could be improved by iterating parts of the data with every cleanup process - but still it will take some time (or won't clean it fast enough). Also removing keys one by one looks like the waste of CPU - as they could be removed in batches (don't have to be removed just after expiration - we can afford some extra RAM for keeping expired keys a little bit longer).\nChecking keys during the retrieve is not enough (although it should be done nevertheless, to not return expired keys) - as many keys can be never retrieved and then they will stay forever (or just too long). \nMost answers for that problem suggest using memcached, but I think this will be waste of CPU, especially as I keep objects which can be put to the dictionary by the reference, but using memcached they would have to be (de)serialized.\nI have some idea how to implement this: split data into time slices, having actually several dictionaries - for example, if expire time is 60 seconds, then we have (at most) 4 dictonaries and every 20 seconds we add new one - where new keys are put, and remove the 4th one - where we'll have keys added over 60 seconds ago. This makes cleaning very fast at the cost of retrieve time, where you need to lookup in 4 dictionaries instead of one (and RAM usage increased by 33%).\nSo finally the question - which is: is there any better solution? Or maybe I'm wrong and some of mentioned solutions (removing keys one by one) would be better and faster? I don't want to reinvent the wheel, but didn't find any good solution in the net.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1205,"Q_Id":18780590,"Users Score":1,"Answer":"Only experiments will tell you which is better.\nHere's another simple idea to consider: link all the keys in a linked list in order of arrival. Each time you retrieve a key, iterate from the beginning of the list and remove all expired items, from both the list and the dictionary.","Q_Score":3,"Tags":"python,performance,algorithm,caching","A_Id":18780954,"CreationDate":"2013-09-13T07:24:00.000","Title":"Optimal algorithm for cache with expire","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need simple cache structure (in python, but it doesn't really matter), with some specific requirements:\n\nUp to several millions of small objects (100 bytes on average)\nSpeed is the key (both put and get), I'd expect operation times at about few microseconds\nOnly one thread accessing this - so it can be all just in memory (do not need persistence)\nKeys are MD5 hashes (if it matters)\nThere's an expiration time, global for the cache - every key should be removed from the cache after expiration time, counting from the time of first put\n\nNow, the point is how to implement expiration - as everything other can be done using simple dictionary. The simplest solution - to iterate all data regularly and remove expired keys - could lock whole cache for too long. It could be improved by iterating parts of the data with every cleanup process - but still it will take some time (or won't clean it fast enough). Also removing keys one by one looks like the waste of CPU - as they could be removed in batches (don't have to be removed just after expiration - we can afford some extra RAM for keeping expired keys a little bit longer).\nChecking keys during the retrieve is not enough (although it should be done nevertheless, to not return expired keys) - as many keys can be never retrieved and then they will stay forever (or just too long). \nMost answers for that problem suggest using memcached, but I think this will be waste of CPU, especially as I keep objects which can be put to the dictionary by the reference, but using memcached they would have to be (de)serialized.\nI have some idea how to implement this: split data into time slices, having actually several dictionaries - for example, if expire time is 60 seconds, then we have (at most) 4 dictonaries and every 20 seconds we add new one - where new keys are put, and remove the 4th one - where we'll have keys added over 60 seconds ago. This makes cleaning very fast at the cost of retrieve time, where you need to lookup in 4 dictionaries instead of one (and RAM usage increased by 33%).\nSo finally the question - which is: is there any better solution? Or maybe I'm wrong and some of mentioned solutions (removing keys one by one) would be better and faster? I don't want to reinvent the wheel, but didn't find any good solution in the net.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1205,"Q_Id":18780590,"Users Score":0,"Answer":"One implementation of a hashtable is to store a list of (key, value) for each hash value. You can extend this to storing a list of (key, insertion time, value) for each hash value. On both get and set, you can throw away expired items as you scan for the key you're interested in.\nYes, it may leave expired items in the hashtable for arbitrarily long, but only O(N) items on average, where N is the size of your hash table.\nGood properties of this approach are that there's no concurrent cleanup going on, and the overhead is more or less constant.\nYou'll have to code this in C rather than Python if you care about speed.","Q_Score":3,"Tags":"python,performance,algorithm,caching","A_Id":18781248,"CreationDate":"2013-09-13T07:24:00.000","Title":"Optimal algorithm for cache with expire","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using pip and trying to install a python module called pyodbc which has some dependencies on non-python libraries like unixodbc-dev, unixodbc-bin, unixodbc. I cannot install these dependencies system wide at the moment, as I am only playing, so I have installed them in a non-standard location. How do I tell pip where to look for these dependencies ? More exactly, how do I pass information through pip of include dirs (gcc -I) and library dirs (gcc -L -l) to be used when building the pyodbc extension ?","AnswerCount":7,"Available Count":1,"Score":-0.0855049882,"is_accepted":false,"ViewCount":69488,"Q_Id":18783390,"Users Score":-3,"Answer":"Just in case it's of help to somebody, I still could not find a way to do it through pip, so ended up simply downloading the package and doing through its 'setup.py'. Also switched to what seems an easier to install API called 'pymssql'.","Q_Score":88,"Tags":"python,shared-libraries,pip,include-path,pyodbc","A_Id":18847849,"CreationDate":"2013-09-13T09:56:00.000","Title":"python pip specify a library directory and an include directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing an API which returns json according to queries. For example: localhost\/api\/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b.\nWhen the user query localhost\/api\/query?a=3&b=4, x will be calculate again and this is a waste of time since x won't change for any query. The question is how can I do this pre-calculation of x for all queries (In the real app, x is not a value but a complex object returned by wrapped C++ code).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":161,"Q_Id":18790301,"Users Score":1,"Answer":"You could add a model (with a db table) that stores values for a, b and x.  Then for each query, you could look for an instance with a and b and return the associated x.","Q_Score":0,"Tags":"python,django","A_Id":18794763,"CreationDate":"2013-09-13T15:43:00.000","Title":"How to avoid repeated pre-calculation in django view","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing an API which returns json according to queries. For example: localhost\/api\/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b.\nWhen the user query localhost\/api\/query?a=3&b=4, x will be calculate again and this is a waste of time since x won't change for any query. The question is how can I do this pre-calculation of x for all queries (In the real app, x is not a value but a complex object returned by wrapped C++ code).","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":161,"Q_Id":18790301,"Users Score":2,"Answer":"If you are using some sort of cache (memcached, redis) you can store it there. You can try to serialize the object with pickle, msgpack etc. That you can retrieve and deserialze it.","Q_Score":0,"Tags":"python,django","A_Id":18790769,"CreationDate":"2013-09-13T15:43:00.000","Title":"How to avoid repeated pre-calculation in django view","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After trying to find some help on the internet related to flash testing through selenium, all I find is FlexUISelenium package available for Selenium RC. I DO NOT find any such package available for Selenium Webdriver. \nI am working with python and selenium webdriver and I do not see any packages available to automate flash applications. Is there any such package available at all for webdriver? If not, how do I start automating a flash application in webdriver?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2568,"Q_Id":18799033,"Users Score":0,"Answer":"Use flashselenium or sikuli for flash object testing.","Q_Score":0,"Tags":"python,flash,selenium,webdriver","A_Id":18804048,"CreationDate":"2013-09-14T06:29:00.000","Title":"How to perform flash object testing in selenium webdriver with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can somebody pls help me on how to write the code to check if few given letters are part of the string entered. the output must be true if the letters are present or false.\nFor example: Return True if and only if the name is valid (that is, it contains no characters other than 'B' 'A' 'N') if the word entered is BANANA.\nPls help me with the code.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":18799714,"Users Score":0,"Answer":"To check if something, you use a conditional clause (if\/elif\/else)\nTo check what letters are used in a string, you can use a set. For example, if the input is BANANA, you can do set(\"BANANA\") to create a set of unique values ({\"B\", \"A\", \"N\"})\nTo check if certain letters are in the set, you can use the all() function. all(letter in the_set for letter in ['B', 'A', 'N']. Or, you can just compare one set to another (eg {'A', 'B', 'C'} == set('abbcacabacacba')\nFinally, if the above conditional is True, then return True \n\nNow have a go at writing some code. If you're having trouble, feel free to create another question supplying what you have tried and what errors occur\/what the problem is.","Q_Score":1,"Tags":"python,python-idle","A_Id":18799741,"CreationDate":"2013-09-14T08:11:00.000","Title":"How to if few letters are part of the string entered?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"All I know how to do is type \"python foo.py\" in dos; the program runs but then exits python back to dos.  Is there a way to run foo.py from within python? Or to stay in python after running?  I want to do this to help debug, so that I may look at variables used in foo.py\n(Thanks from a newbie)","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":83,"Q_Id":18805720,"Users Score":1,"Answer":"To stay in Python afterwards you could just type 'python' on the command prompt, then run your code from inside python. That way you'll be able to manipulate the objects (lists, dictionaries, etc) as you wish.","Q_Score":2,"Tags":"python","A_Id":18805746,"CreationDate":"2013-09-14T19:42:00.000","Title":"How do I run a scipt from within Python on windows\/dos?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a postgres DB in which most of the tables have a column 'valid_time' indicating when the data in that row is intended to represent and an 'analysis_time' column, indicating when the estimate was made (this might be the same or a later time than the valid time in the case of a measurement or an earlier time in the case of a forecast). Typically there are multiple analysis times for each valid time, corresponding to different measurements (if you wait a bit, more data is available for a given time, so the analysis is better but the measurment is less prompt) and forecasts with different lead times.\nI am using SQLalchemy to access this DB in Python.\nWhat I would like to do is be able to pull out all rows with the most recent N unique datetimes of a specified column. For instance I might want the 3 most recent unique valid times, but this will typically be more than 3 rows, because there will be multiple analysis times for each of those 3 valid times.\nI am new to relational databases. In a sense there are two parts to this question; how can this be achieved in bare SQL and then how to translate that to the SQLalchemy ORM?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":144,"Q_Id":18818634,"Users Score":1,"Answer":"I'm not sure about the SQLalchemy part, but as far as the SQL queries I would do it in two steps:\n\nGet the times.  For example, something like.\nSELECT DISTINCT valid_time FROM MyTable LIMIT 3 ORDER BY valid_time DESC;\nGet the rows with those times, using the previous step as a subquery:\nSELECT * FROM MyTable WHERE valid_time IN (SELECT DISTINCT valid_time FROM MyTable LIMIT 3 ORDER BY valid_time DESC);","Q_Score":0,"Tags":"python,sql,postgresql,sqlalchemy","A_Id":18818835,"CreationDate":"2013-09-15T23:45:00.000","Title":"Selecting the rows with the N most recent unique values of a datetime","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a backend in Django and I need to log in to another server backend with a simple POST method. So I would need to create a session object or something like that to handle that login.\nAny Ideas on how to do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":18827905,"Users Score":0,"Answer":"If you're not looking for single sign-on, then likely you want to either do the work in the view, and if you need the session to persist, store it in the (local django) session object; or outsource it to something like celery, and again, keep anything you need to keep track of in the session object.","Q_Score":0,"Tags":"python,django","A_Id":18838114,"CreationDate":"2013-09-16T12:20:00.000","Title":"create a session to another site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to be able to read messages from a specific user in skype using skype4py then send an automated response based upon the message back to the skype chat window. That way a user could message me and get an automated response saying that I'm currently busy or whatever. I really just need to know how to read and send skype chat using skype4py in python. Thanks for your time.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2426,"Q_Id":18836983,"Users Score":0,"Answer":"I do not want to give you all the answer so that you can improve your coding skills but I will give you some clues:\n1)Use boolean values for being activated and deactivated\n2)Set a command that activates and deactivates\n3) set a value that if reaceived or sent chat and true\/false then reply.\nGave you a lot of clues! Good look!.","Q_Score":2,"Tags":"python,skype4py","A_Id":20256552,"CreationDate":"2013-09-16T20:44:00.000","Title":"Using python and skype4py to receive and send chat","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my application, I'm using python.logging for logging.\nNow I want to control the loglevel interactively, so i created a combobox hat lets the user select \"ERROR\", \"WARN\", \"INFO\",...\nWhat I don't really like is that currently the values in the combobox are hardcoded.\nInstead,Ii would like to have a list of all \"named\" loglevels (e.g. both the system defaults, but also those added via logging.addLevelName; but not the fake generated loglevels like \"Level 42\")\nThe best I have come up with so far is to use the logging._levelNames dictionary.\nBut then this seems to be a private member, and I somehow have a bad feeling accessing it directly.\nSo my question is: what's the proper way to list all currently defined \"named\" loglevels in Python.","AnswerCount":7,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5759,"Q_Id":18846024,"Users Score":6,"Answer":"As you are only reading values, logging._levelNames looks an appropriate solution to me. Keep going with logging.addLevelName for setting new values though.","Q_Score":10,"Tags":"python,logging","A_Id":18846310,"CreationDate":"2013-09-17T09:25:00.000","Title":"get list of named loglevels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm a freelance editor and tutor as well as a fiction writer and artist looking to transition to the latter on a full-time basis. Naturally, part of that transition involves constructing a website; a dynamic site to which new content in various forms can be added with ease. Now, I've always intended to learn how to program, and I simply haven't the money to hire someone else to do it. So, having had a good experience with my brief dabblings in Python, I decided I'd go with Django for building my site.\nI set up a Fedora Virtualbox for a development environment (as I didn't want to jump through hoops to make Windows work) and went to town on some Django tutorials. Everything went swimmingly until life intervened and I didn't touch the project for three weeks. I'm in a position to return to it now, but I've realized two things in the process. First, I'm having to do a fair bit of retracing of my steps just to find where certain files are, and second, I don't know how I'd go about deploying the site after I'm done building it. My intention is to get the cheapest Linode and host off that until some theoretical point in the future where I required more.\nI suspect that re: the file organization issue, that's just something I'll become more familiar with over time, though if there are any tricks I should be aware of to simplify the structure of my overall Django development space, I'm eager to know them. However, what about deployment? How viable is it to, with sufficient knowledge, automate the process of pushing the whole file structure of a site with Git? And how can I do that in such a way that it doesn't tamper with the settings of my development environment?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":18863293,"Users Score":0,"Answer":"As a Django developer i can assure you that it grows on you and becomes easier to understand the development environment.\n\nYou should remember that settings.py is probably going to be where your thoughts will be for quite a while in the start; the good part is that its only once, after you got it up and running you'll only touch settings.py to add new modules or change some configuration but its unlikely.\nI believe there are hosts that integrate with git so that should not be a problem since you will probably just git clone your project's url into the host (and not forget to enable\/configure wsgi)\nTo leave the settings.py out of the mess, you will tell git not to track the file with: git rm file; and then when you add your files for commit you do it with git add -u so it refers only to your tracked files.\n\nI'm not sure if i was clear enough. (probably not) But, i hope i could help you in some way.","Q_Score":1,"Tags":"python,django,git,web-deployment","A_Id":18863822,"CreationDate":"2013-09-18T03:18:00.000","Title":"Simplifying development process for Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a minor issue using py.test for my unit tests.\nI use py.test to run my tests and output a junitxml report of the tests.\nThis xml report is imported in jenkins and generates nice statistics.\nWhen I use a test class which derives from unittest.TestCase, \nI skip expected failures using:\n\n@unittest.skip(\"Bug 1234 : This does not work\")\n\nThis message also shows up in jenkins when selecting this test.\nWhen I don't use a unittest.TestCase class, e.g. to use py.test parametrize functionality,\nI skip expected failures using:\n\n@pytest.mark.xfail(reason=\"Bug 1234 : This does not work\", run=False)\n\nBut then this reason is not actually displayed in jenkins, instead it will say:\n\nSkip Message\nexpected test failure\n\nHow can I fix this?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1231,"Q_Id":18867280,"Users Score":2,"Answer":"I solved it using this line as the first line of the test:\n\npytest.skip(\"Bug 1234: This does not work\")\n\nI'd rather have used one of the pytest decorators, but this'll do.","Q_Score":1,"Tags":"python,unit-testing,jenkins,pytest","A_Id":18894932,"CreationDate":"2013-09-18T08:25:00.000","Title":"Py.test skip messages don't show in jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some very large IPython (1.0) notebooks, which I find very unhandy to work with. I want to split the large notebook into several smaller ones, each covering a specific part of my analysis. However, the notebooks need to share data and (unpickleable) objects.\nNow, I want these notebooks to connect to the same kernel. How do I do this? How can I change the kernel to which a notebook is connected? (And any ideas how to automate this step?)\nI don't want to use the parallel computing mechanism (which would be a trivial solution), because it would add much code overhead in my case.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1689,"Q_Id":18882510,"Users Score":1,"Answer":"When I have a long noetbook, I create functions from my code, and hide it into python modules, which I then import in the notebook.\nSo that I can have huge chunk of code hidden on the background, and my notebook smaller for handier manipulation.","Q_Score":6,"Tags":"ipython,ipython-notebook","A_Id":35315482,"CreationDate":"2013-09-18T21:17:00.000","Title":"How to share Ipython notebook kernels?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In wakari, how do I download a CSV file and create a new CSV file with each of the rows in the original file repeated N number of times in the new CSV file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":18886383,"Users Score":0,"Answer":"cat dataset.csv dataset.csv dataset.csv dataset.csv > bigdata.csv","Q_Score":0,"Tags":"python","A_Id":18897337,"CreationDate":"2013-09-19T04:49:00.000","Title":"Repeat rows in files in wakari","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"to provide some context: Issues in an application are logged in an excel sheet and one of the columns in that sheet contains the email communication between the user (who had raised the issue) and the resolve team member. There are bunch of other columns containing other useful information. My job is to find useful insights from this data for Business.\n\nFind out what type of issue was that? e.g. was that a training issue for the user or access issue etc. This would mean that I analyze the mail text and figure out by some means the type of issue.\nHow many email conversations have happened for one issue?\nIs it a repeat issue?\nThere are other simple statistical problems e.g. How many issues per week etc...\n\nI read that NLP with Python can be solution to my problems. I also looked at Rapidminer for the same.\nNow my Question is \na. \"Am I on the right track?, Is NLP(Natural Language Processing) the solution to these problems?\"\nb. If yes, then how to start.. I have started reading book on NLP with Python, but that is huge, any specific areas that I should concentrate on and can start my analysis?\nc. How is Rapidminer tool? Can it answer all of these questions? The data volume is not too huge (may be 100000 rows)... looks like it is quite easy to build a process in rapidminer, hence started on it...\nAppreciate any suggestions!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":637,"Q_Id":18910200,"Users Score":0,"Answer":"Try xlrd Python Module to read and process excel sheets.\nI think an appropriate implementation using this module is an easy way to solve your problem.","Q_Score":0,"Tags":"python,nlp","A_Id":18910584,"CreationDate":"2013-09-20T06:26:00.000","Title":"Analyze Text to find patterns and useful information","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I Need to put an expiration date in a template, it show the current date and the expiration date will be 8 days from current date.\nCan someone tell me how can I do it? Is possible do it with Django or do I have to do it whit maybe Jquery or JavaScript?\nAnd I need to send it to my database too, not just display it in the template.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1338,"Q_Id":18934509,"Users Score":2,"Answer":"I would do it in django.  Have two DateFields in your model, both that could be blank and null.  On the first time someone views your page (with both dates unset), create a view for the template request that sets the one of the DateFields to today = datetime.date.today() and the other to today + datetime.timedelta(8) to be 8 days after the current date.  Save your updated model and then display that model in the template.","Q_Score":0,"Tags":"python,django,date","A_Id":18934550,"CreationDate":"2013-09-21T15:43:00.000","Title":"Sum 7 days after current date in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know python has inbuilt string support. But what I would like to know is how it handles the end of string construct. C has '\\0' character to signify end of string. How does python do it? It would be great if someone could tell me how it works in the cpython source code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1206,"Q_Id":18938619,"Users Score":1,"Answer":"AFAIK, CPython keeps track of the length and start of the string. As of CPython 3.3 it also keeps track of how many bytes per character in order to compress strings that can fit into subsets of the Unicode spectrum, such as Latin-1 strings.","Q_Score":1,"Tags":"python,string,eof","A_Id":18938639,"CreationDate":"2013-09-21T23:09:00.000","Title":"How does python find the end of string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do you include html docs generated by other tools such as nose, coverage, and pylint reports into Sphinx documentation. Should they go into the _static directory? and if so, how do you link to them?\nI am trying to build a concise package of all of the code development tool documentation into a .pdf or html.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":310,"Q_Id":18968569,"Users Score":0,"Answer":"I have a similar problem and I could solve it by doing the following. Note this is just for the HTML output.\n\nCreate an index.rst field with just the following:\n\n======================\nJavadoc of the API XXX\n======================\nAs I am using the extension \"sphinx.ext.autosectionlabel\", this becomes a \"level 1\" section.\n\nModify the Make file so, once the HTML is generated, it replaces the index.html of the section \"Javadoc of the API XXX\" with the Javadoc of my API.\n\nAfter this change, on the toctree I have a link to \"Javadoc of the API XXX\" and when you click it, you see the Javadoc.\nI know is not the proper way of doing it, but it is the only that I have come up with after many Google searches.","Q_Score":4,"Tags":"python,html,code-coverage,python-sphinx,nose","A_Id":43797423,"CreationDate":"2013-09-23T20:49:00.000","Title":"Integrate other html documentation into sphinx docs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I have a python application that I want to install and if I run python setup.py install --user, everything gets put into ~\/.local as expected (on linux), and inside of that the stuff in ~\/.local\/lib\/python2.7\/site-packages\/\ngets seen by the PYTHONPATH as expected; however, my executables that are created by setup.py (using either entry_points via setuptools or scripts via distutils) are correctly put into ~\/.local\/bin, but are not seen by the PATH at the command line. \nThus, I have to add $HOME\/.local\/bin to my PATH (via my .zshrc) to get these executables seen by my environment.  I'm assuming this is the expected behaviour, but my question is, is there some way to get my executables \"registered\" with my PATH when I run the installation with the --user flag during the setup? \nI believe this should work, as I see that ipython does something like this, where if it's installed with the --user flag (into ~\/.local), then you don't have to add to your path ~\/.local\/bin to get the local install of ipython seen at the command line. I just can't figure out how ipython does it. Many thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2255,"Q_Id":18972662,"Users Score":1,"Answer":"Instead of using --user, why not use a virtualenv?  they are much more flexible, and put its bin directory on the path when activated.\nOtherwise, manually putting ~\/.local\/bin on your PATH, as you did, is what you need to do.","Q_Score":1,"Tags":"python,installation,setup.py","A_Id":18973151,"CreationDate":"2013-09-24T03:49:00.000","Title":"confusion with results of `python setup.py install --user`","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"One of my desktop apps I need to know where the iPhoto Library is installed, programmatically. I do not want to pick it from predicted location (\/Users\/me\/Pictures\/iPhoto) since power user may have installed it somewhere else.\nI'm developing app using Python and I guess Applescript might have way to figure out iPhoto location but I don't know how.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":18973574,"Users Score":0,"Answer":"Simply invoke the system command which iPhoto (assuming that you can run iPhoto from a shell) and parse the output.","Q_Score":0,"Tags":"python,applescript,iphoto","A_Id":18975788,"CreationDate":"2013-09-24T05:27:00.000","Title":"Need to know iPhoto Library location programmatically using Applescript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My simple Python app uses PyQt4 for its GUI and clicking a QPushButton causes the app to send a message via serial. GUI elements also update frequently.\nQuestion: I did not know how to implement multithreading. Will not having multithreaded process cause the app to be less responsive and less consistent in sending the serial communication especially when a GUI element will be updated at the same time the serial message is being sent?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":105,"Q_Id":18981428,"Users Score":1,"Answer":"That depends. Your PC is idle 99.9995% of the time while you type; so it has a lot of CPU power to spend on background tasks. Most people don't notice this since the virus scanner typically eats 5-20% of the performance. But typing or clicking a button barely registers in the CPU load.\nOTOH, if you run a long task in the UI thread, then the UI locks up until the task is finished. So from a user perspective, the UI will be blocking while for the serial port, the world will be OK. Overall, this will be faster but it will feel sluggish.\nMultithreading is generally slower than doing everything in a single thread due to synchronization or locking. But a single thread doesn't scale. Eventually, you hit a brick wall (performance wise) and no trick will make that single thread execute faster.","Q_Score":1,"Tags":"python,multithreading,python-2.7,pyqt,pyqt4","A_Id":18983482,"CreationDate":"2013-09-24T12:18:00.000","Title":"Is Multi-threading required for PyQt4 and Writing to Serial","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to teach some students basic Python programming without having to teach them how to use the terminal.  Recently, I was teaching a 2 hour intro session, and not only did teaching terminal stuff take a long time, but it also intimidated a lot of the students.  I would like a solution where students wouldn't have to leave graphical user interfaces that they were comfortable with.  \nI also want the solution to let them execute a particular Python file (eg, not just using the interactive Python interpreter) and see the output from printing things.\nThanks!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":289,"Q_Id":19012700,"Users Score":0,"Answer":"When I'm not near my own PC, I use ideone.com. I like that it is a universal IDE, which for me means both C++ and Python.","Q_Score":1,"Tags":"python","A_Id":19013035,"CreationDate":"2013-09-25T18:40:00.000","Title":"How to Run Python without a Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to teach some students basic Python programming without having to teach them how to use the terminal.  Recently, I was teaching a 2 hour intro session, and not only did teaching terminal stuff take a long time, but it also intimidated a lot of the students.  I would like a solution where students wouldn't have to leave graphical user interfaces that they were comfortable with.  \nI also want the solution to let them execute a particular Python file (eg, not just using the interactive Python interpreter) and see the output from printing things.\nThanks!","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":19012700,"Users Score":8,"Answer":"Surely that's what IDLE is for? It's not much good as an IDE, but it does work well for exactly what you describe - opening modules and executing them, and running commands in an interactive shell.","Q_Score":1,"Tags":"python","A_Id":19012735,"CreationDate":"2013-09-25T18:40:00.000","Title":"How to Run Python without a Terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a Django project that was created by another developer on a different machine. I see that in the root of the application, there is a .virtualenv directory. Is it possible to simply setup this project locally on my Windows machine using the project settings and Python version (the app uses 2.7), so that I can run it like a local Django application so debugging is feasible? \nI have access to the development web server and have copied the full source of the app down to my Win7 machine but cannot seem to get things setup correctly to run the app locally so I can debug. \nI currently have Python 2.7, 2.7.5 and 3.3.2 installed on my local dev machine. I would call myself pretty new to Django and Virtualenv. \nIf anyone has any guidance on how I can get my environment straitened out so I can run the app with debugging, I would be very thankful. \nThank you in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":19031616,"Users Score":0,"Answer":"I once faced the same problem and it took me so much time to configure another environment that I eventually had to create a VM with the same version of OS and libraries. I then made a raw copy of the project and it worked fine.","Q_Score":0,"Tags":"python,django,windows,virtualenv","A_Id":19032797,"CreationDate":"2013-09-26T14:54:00.000","Title":"Importing and debugging a Python Django project made in a different environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a hashed password using the Hash::make() function of laravel when a user is created.  I eventually need to take that hashed password, and pass it to a python script to perform a login and download of site resources.  I know the hash is a one-way action, but I'd like to keep the password hashed to be security conscious if at all possible.\nAny suggestions on how to accomplish this task while keeping security intact would be helpful!\nThanks,\nJustin","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":331,"Q_Id":19036197,"Users Score":1,"Answer":"you cant the best you can do is encrypt it with a reversible encryption ... but then you need to store the key somewhere ... eventually you will have some plain text somewhere (or encoded at best) that will allow decryption ... you could store the hash and do a query against a db that maps hashes to pw's but you still have the password in plaintext somewhere ... you cannot login with just a hash anywhere ... (because the hash ends up getting hashed and then no longer matches the expected hash)\nan option may be to use rainbow tables to find something that results in an identical hash and use that instead ... but if they are adding salts or anything you are once again out of luck","Q_Score":1,"Tags":"php,python,hash,laravel,laravel-4","A_Id":19036400,"CreationDate":"2013-09-26T18:44:00.000","Title":"Laravel 4 passwords and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In matplotlib, how do I specify the line width and color of a legend frame?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":13797,"Q_Id":19058485,"Users Score":20,"Answer":"For the width: legend.get_frame().set_linewidth(w)\nFor the color: legend.get_frame().set_edgecolor(\"red\")","Q_Score":19,"Tags":"python,matplotlib","A_Id":28295797,"CreationDate":"2013-09-27T19:18:00.000","Title":"Specifying the line width of the legend frame, in matplotlib","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to setup a program which reads in some parameters from a widget\/gui, calculates some stuff based on database values and the input, and finally sends some ascii files via ftp to remote servers. \nIn general, I would suggest a python program to do the tasks. Write a Qt widget as a gui (interactively changing views, putting numbers into tables, setting up check boxes, switching between various layers - never done something as complex in python, but some experience in IDL with event handling etc), set up data classes that have unctions, both to create the ascii files with the given convention, and to send the files via ftp to some remote server.\nHowever, since my company is a bunch of Windows users, each sitting at their personal desktop, installing python and all necessary libraries on each individual machine would be a pain in the ass.\nIn addition, in a future version the program is supposed to become smart and do some optimization 24\/7. Therefore, it makes sense to put it to a server. As I personally rather use Linux, the server is already set up using Ubuntu server. \nThe idea is now to run my application on the server. But how can the users access and control the program?\nThe easiest way for everybody to access something like a common control panel would be a browser I guess. I have to make sure only one person at a time is sending signals to the same units at a time, but that should be doable via flags in the database. \nAfter some google-ing, next to QtWebKit, django seems to the first choice for such a task. But...\nCan I run a full fledged python program underneath my web application? Is django the right tool to do so?\nAs mentioned previously, in the (intermediate) future ( ~1 year), we might have to implement some computational expensive tasks. Is it then also possible to utilize C as it is within normal python?\nAnother question I have is on the development. In order to become productive, we have to advance in small steps. Can I first create regular python classes, which later on can be imported to my web application? (Same question applies for widgets \/ QT?)\nFinally: Is there a better way to go? Any standards, any references?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":367,"Q_Id":19071286,"Users Score":0,"Answer":"Django is a good candidate for the website, however:\n\nIt is not a good idea to run heavy functionality from a website. it should happen in a separate process.\nAll functions should be asynchronous, I.E. You should never wait for something to complete. \n\nI would personally recommend writing a separate process with a message queue and the website would only ask that process for statuses and always display a result immediatly to the user\n\nYou can use ajax so that the browser will always have the latest result.\n\nZeroMQ or Celery are useful for implementing the functionality.\nYou can implement functionality in C pretty easily. I recomment however that you write that functionality as pure c with a SWIG wrapper rather that writing it as an extension module for python. That way the functionality will be portable and not dependent on the python website.","Q_Score":0,"Tags":"python,django,web-services,qt","A_Id":19071331,"CreationDate":"2013-09-28T20:21:00.000","Title":"Python program on server - control via browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've written a large program in Python that calls numerous custom modules' main methods one after another. The parent script creates some common resources, like logging instances, database cursors, and file references which I then pass around to the individual modules. The problem is that I now need to call some of these modules by means of subprocess.check_output, and I don't know how I can share the aforementioned resources across these modules. Is this possible?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":19073579,"Users Score":1,"Answer":"The question exactly as you ask it has no general answer.  There might be custom ways; e.g. on Linux a lot of things are actually file descriptors, and there are ways to pass them to subprocesses, but it's not nicely Pythonic: you have to give them as numbers on the command line of the subprocess, and then the subprocess rebuilds a file object around the file descriptor (see file.fileno() and os.fdopen() for regular files; I'm not sure there are ways to do it in Python for other things than regular files...).\nIn your problem, if everything is in Python, why do you need to make subprocesses instead of doing it all in a single process?\nIf you really need to, then one general way is to use os.fork() instead of the subprocess module: you'd fork the process (which creates two copies of it); in the parent copy you wait for the child copy to terminate; and in the child copy you proceed to run the particular submodule.  The advantage is that at the end the child process terminates, which cleans up what it did --- while at the same time starting with its own copy of almost everything that the parent had (file descriptors, database cursors, etc.)","Q_Score":2,"Tags":"python,subprocess","A_Id":19075566,"CreationDate":"2013-09-29T01:43:00.000","Title":"Possible to share resources (logging, database, file etc.) across Python subproccesses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I searched and tried following stuff but could not found any solution, please let me know if this is possible:\nI am trying to develop a python module as wrapper where I call another 3rd party module with its .main() and provide the required parameter which I need to get from command line in my module. I need few parameter for my module too. \nI am using argparse to parse command line for calling module and my module. The calling parameter list is huge (more than 40) which are optional but may require anytime who will use my module. Currently I have declared few important parameters in my module to parse but I need to expand with all the parameter.\nI thought of providing all the parameter in my module without declaring in add_argument. I tried with parse_known_args which also require declaration of all parameter is required. \nIs there any way where I can pass on all parameter to calling module without declaring in my module? If its possible please let me know how it can be done.\nThanks in advance,","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2494,"Q_Id":19085887,"Users Score":0,"Answer":"Provided that you are calling third-party modules, a possible solution is to\nchange sys.argv and sys.argc at runtime to reflect the correct parameters for\nthe module you're calling, once you're done with your own parameters.","Q_Score":2,"Tags":"python,module,wrapper,argparse","A_Id":19086137,"CreationDate":"2013-09-30T03:07:00.000","Title":"Call another module with passing its command line parameter from my module using argparse in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a complete beginner to Flask and I'm starting to play around with making web apps. \nI have a hard figuring out how to enforce unique user names. I'm thinking about how to do this in SQL, maybe with something like user_name text unique on conflict fail, but then how to I catch the error back in Python?\nAlternatively, is there a way to manage this that's built in to Flask?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1118,"Q_Id":19086885,"Users Score":0,"Answer":"You can use SQLAlchemy.It's a plug-in","Q_Score":1,"Tags":"python,sql,web-applications,flask","A_Id":19087185,"CreationDate":"2013-09-30T05:17:00.000","Title":"How do I enforce unique user names in Flask?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I thought writing a file gives real-time output, since it is so when I use C\/C++ to write files. But when I run python program it seems the output file is always 0 byte until the whole program finished running. Even for the nohup python xxx.py &, the print stuff in the file nohup.out isn't realtime, and can only be seen after execution.\nI'm now running really big program and want to see the progress in the file, how can I achieve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2279,"Q_Id":19104798,"Users Score":6,"Answer":"There are two points at which your file can buffer - Python's internal buffers and the buffers on the operating system. This is a performance boost that avoids system calls and disk writes while the buffer is filling up.\nCalling file.flush() will push the internal buffer to the operating system. You can additionally call fsync to request the operating system to save to disk.\nUsually you can leave the operating system to do what it knows best, so calling flush is usually enough for most applications. The same is partially true for Python's internal buffer - it knows best in terms of performance, but you may require more frequent writes and be willing to pay the additional cost. The only way to know the exact cost is to measure it both ways.","Q_Score":3,"Tags":"python,file,output","A_Id":19105021,"CreationDate":"2013-09-30T22:12:00.000","Title":"Why I do not see realtime output in the output file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am relatively new to programming, and I am using Wing101 version: 5.0.0-b8 (rev 29847). \nThe Python Shell within Wing101, is version 2.7.2, how do I configure it to open python 3.3.2.\nI have downloaded Python 3.3.2 and I need the custom Python Executable. I previously tried \"\/usr\/bin\/python\" as my custom python executable, but it doesn't work.\nI am on a Mac 10.8.3","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10844,"Q_Id":19120229,"Users Score":1,"Answer":"The location of the python.exe for Python 3.3 can vary depending on how you installed it.  Probably the best bet is to search w\/ Spotlight for python.exe, press \"Show All\" in the drop down menu, change to \"File Name\" instead of \"Contents\" search and then click on results to see the full path at the bottom of the search results window.  You'll get at least 2-3 results and the full path should make clear which is the correct one.  Then enter that into Python Executable in the Configure Python dialog, accessed from the Source menu in Wing 101.  You'll need to restart the Python Shell in Wing 101 from its Options menu before it switches to the new Python version.","Q_Score":2,"Tags":"python,wing-ide","A_Id":19120750,"CreationDate":"2013-10-01T15:30:00.000","Title":"Wing101 - Configure python 3.3.2 from 2.7.2 on a mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using appium and using Sudoku app for Android on a Windows 7 machine using Python. If someone can help me find out what the app activity is to opening this and how they were able to figure that out","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":19128188,"Users Score":0,"Answer":"A simple VM emulate an Android device. Not dificult.","Q_Score":0,"Tags":"android,python,appium","A_Id":19128261,"CreationDate":"2013-10-02T00:31:00.000","Title":"What is the android activity for opening sudoku and how do I find how to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using appium and using Sudoku app for Android on a Windows 7 machine using Python. If someone can help me find out what the app activity is to opening this and how they were able to figure that out","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":19128188,"Users Score":0,"Answer":"You just need to run adb shell command in command prompt. After that , Open the Suduko app in your device(make sure your device is connected to your laptop\/pc) and go back to the command prompt and run the below command :\ndumpsys window windows | grep -E 'mCurrentFocus'\nThe Above command will give you the package name & activity name of the currently focused app.","Q_Score":0,"Tags":"android,python,appium","A_Id":51240166,"CreationDate":"2013-10-02T00:31:00.000","Title":"What is the android activity for opening sudoku and how do I find how to?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating my own Django CMS blog plugin. I'm using a placeholder to hold the full content of the blog entry and I'm trying to figure out how to automatically create an excerpt from this placeholder.\nIf it were simply a text field I know I could use \"|truncatechars:15\" in the template, but I don't know how to do this for a placeholder.\nIs there something I can use in the template or in the 'views.py' in order to truncate the placeholder?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":321,"Q_Id":19130630,"Users Score":2,"Answer":"As you've seen, you can't truncate a placeholder, as a placeholder's job is simply to render content plugins that are added to it.\nYour only viable option is to truncate the field in the render template of the plugin, or to add a separate field on your model that can store the truncated text. Such a field could be populated automatically using a post_save signal handler.","Q_Score":0,"Tags":"python,django,django-templates,django-cms","A_Id":19136318,"CreationDate":"2013-10-02T05:40:00.000","Title":"Truncate Django CMS Placeholder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question is for a school project so don't give my exact answer  XD\nBut please tell me how I would start it. I have been trying it for a couple of hours but I just can't get it. Here is the question:\nCreate a function in python that accepts names in standard form and prints them in the form: \nE.g. INPUT                               to           OUTPUT\nSanta Claus                               to           Claus, S.\nMichael J. Fox                            to           Fox, M. J.\nMadonna                                   to           Madonna\nWilliam Henry Richard Charles Windsor     to           Windsor, W. H. R. C.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":19191509,"Users Score":0,"Answer":"You will need an algorithm, which separates your input string by whitespaces. Then you would take the last of those separated strings and add it to your output string. You will have to add a comma, if more names are following. After that, take the other strings, starting with the first one, and check if they are already in the form \"[A-Z].\". If not, transform them to that form. Otherwise just add them to your output. Thats it. I could be more precise, but you asked not to be :)","Q_Score":0,"Tags":"python,function,project,output","A_Id":19191612,"CreationDate":"2013-10-04T22:04:00.000","Title":"I need help on creating a name changing program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question is for a school project so don't give my exact answer  XD\nBut please tell me how I would start it. I have been trying it for a couple of hours but I just can't get it. Here is the question:\nCreate a function in python that accepts names in standard form and prints them in the form: \nE.g. INPUT                               to           OUTPUT\nSanta Claus                               to           Claus, S.\nMichael J. Fox                            to           Fox, M. J.\nMadonna                                   to           Madonna\nWilliam Henry Richard Charles Windsor     to           Windsor, W. H. R. C.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":19191509,"Users Score":0,"Answer":"Ok, then use String.Split() To change String into List , then use len() to count the elements. Use loop for and create new string .","Q_Score":0,"Tags":"python,function,project,output","A_Id":19191615,"CreationDate":"2013-10-04T22:04:00.000","Title":"I need help on creating a name changing program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently trying to add an 'associate google account' button to my django 1.4.8 project. I've never worked with python-social-auth before, and I'm a bit confused about only associating accounts --as opposed to authenticating against--, and how to use credentials for accessing Google Drive services.\nThanks!\nA.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":325,"Q_Id":19203395,"Users Score":0,"Answer":"If your user is already logged in with a username a password you simply need to allow them to follow the same steps they would when signing up with a social account and that social account will be automatically associated with their django account","Q_Score":1,"Tags":"python,django","A_Id":19231096,"CreationDate":"2013-10-05T22:29:00.000","Title":"Python social auth account association only","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In PyCharm, after I run a script it automatically kills it:\n\nC:\\Users\\Sean.virtualenvs\\Stanley\\Scripts\\python.exe C:\/Users\/Sean\/PycharmProjects\/Stanley\/Stanley.py\nProcess finished with exit code 0\n\nHow can I interact with the script after it starts? For lack of a better way to phrase it, how can I get the\n\n>>>\n\nprompt after the script runs once through?\n\nPyCharm Community Edition 3.0\nWindows 7\nPython 2.7","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":17624,"Q_Id":19207019,"Users Score":29,"Answer":"UPDATE\nStarting with version 4.0 there's an option Show command line afterwards (renamed in later versions to Run with Python console) when editing run\/debug configuration in Run|Edit Configurations.... \n\nFrom output of python --help:\n\n-i     : inspect interactively after running script; forces a prompt even\n           if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\nTo set interpreter option in PyCharm go to Run|Edit Configuration","Q_Score":26,"Tags":"python,windows,pycharm","A_Id":19213327,"CreationDate":"2013-10-06T08:44:00.000","Title":"Interacting with program after execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In PyCharm, after I run a script it automatically kills it:\n\nC:\\Users\\Sean.virtualenvs\\Stanley\\Scripts\\python.exe C:\/Users\/Sean\/PycharmProjects\/Stanley\/Stanley.py\nProcess finished with exit code 0\n\nHow can I interact with the script after it starts? For lack of a better way to phrase it, how can I get the\n\n>>>\n\nprompt after the script runs once through?\n\nPyCharm Community Edition 3.0\nWindows 7\nPython 2.7","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":17624,"Q_Id":19207019,"Users Score":37,"Answer":"in Pycharm, Run\/Debug menu choose Edit Configuration, check the box before 'Show command line afterwards'","Q_Score":26,"Tags":"python,windows,pycharm","A_Id":27978591,"CreationDate":"2013-10-06T08:44:00.000","Title":"Interacting with program after execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In PyCharm, after I run a script it automatically kills it:\n\nC:\\Users\\Sean.virtualenvs\\Stanley\\Scripts\\python.exe C:\/Users\/Sean\/PycharmProjects\/Stanley\/Stanley.py\nProcess finished with exit code 0\n\nHow can I interact with the script after it starts? For lack of a better way to phrase it, how can I get the\n\n>>>\n\nprompt after the script runs once through?\n\nPyCharm Community Edition 3.0\nWindows 7\nPython 2.7","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":17624,"Q_Id":19207019,"Users Score":8,"Answer":"Click Run -> Edit Configurations...,\nThen check the box Run with Python console.","Q_Score":26,"Tags":"python,windows,pycharm","A_Id":50508341,"CreationDate":"2013-10-06T08:44:00.000","Title":"Interacting with program after execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the pythonOCC examples CADViewerMDI.py the CAD format step, stp, iges, igs, and brep are suported.\nDo pythonOCC support the format \".3dm\" and if, how do I load it.\nSupoptimal sulution:\nChange the format in rhino to one of the other formats.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":182,"Q_Id":19220726,"Users Score":2,"Answer":"It looks like pythonOCC do not currently support .3dm files you can either output from Rhino in another format, (sub-optimal in your post), or find\/write\/sponsor the writing of a .3dm importer for pythonOCC.","Q_Score":0,"Tags":"python,cad,opencascade","A_Id":19221047,"CreationDate":"2013-10-07T09:03:00.000","Title":"pythonocc loading .3md format","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I compiled a module.pyx file to module.so under Mac OS X, and now I can use it with:\nfrom module import method1\nHowever, the same .so file won't work on Linux, I have to compile a new module.so under Linux.\nSo the problem is, how can I write a cross platform(Mac and Linux) module with Cython?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":1310,"Q_Id":19223411,"Users Score":5,"Answer":"You can't. You'll have to compile a different library for each platform you need to support.","Q_Score":2,"Tags":"python,linux,macos,cython","A_Id":19223474,"CreationDate":"2013-10-07T11:16:00.000","Title":"How to load Cython compiled .so file on both Mac OS X and Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What are some methods to make relative urls absolute in scraped content so that the scraped html appears like the original and css are not broken?\nI found out <base> tag may help. But how can I find out what the original base of the URL is?\nI don't care about interactions with the links, but do want them to appear correct.\nAssume a site 'example.com\/blog\/new\/i.html' i scrape that has 2 resources\n\n< link src=\"\/style\/style.css\" > \n< link src=\"newstyle.css\" >. \n\nNow if i set base as 'example.com\/blog\/new\/i.html' wont the first one break","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":19231985,"Users Score":0,"Answer":"Keep track of the url of each page you scraped. One way would be to save it with the full URL as a filename. Then, you can resolve relative urls as per the HTML spec.","Q_Score":1,"Tags":"javascript,python,html","A_Id":19233083,"CreationDate":"2013-10-07T18:29:00.000","Title":"How best to handle relative urls in scraped content?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed Nginx + uWSGI + Django on a VDS with 3 CPU cores. uWSGI is configured for 6 processes and 5 threads per process. Now I want to tell uWSGI to use processes for load balancing until all processes are busy, and then to use threads if needed. It seems uWSGI prefer threads, and I have not found any config option to change this behaviour. First process takes over 100% CPU time, second one takes about 20%, and another processes are mostly not used.\nOur site receives 40 r\/s. Actually even having 3 processes without threads is anough to handle all requests usually. But request processing hangs from time to time for various reasons like locked shared resources, etc. In such cases we have -1 process. Users don't like to wait and click the link again and again. As a result all processes hangs and all users have to wait.\nI'd add even more threads to make the server more robust. But the problem is probably python GIL. Threads wan't use all CPU cores. So multiple processes work much better for load balancing. But threads may help a lot in case of locked shared resources and i\/o wait delays. A process may do much work while one of it's thread is locked.\nI don't want to decrease time limits until there is no another solution. It is possible to solve this problem with threads in theory, and I don't want to show error messages to user or to make him waiting on every request until there is no another choice.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":9291,"Q_Id":19233132,"Users Score":11,"Answer":"So, the solution is:\n\nUpgrade uWSGI to recent stable version (as roberto suggested).\nUse --thunder-lock option. \n\nNow I'm running with 50 threads per process and all requests are distributed between processes equally.","Q_Score":14,"Tags":"python,multithreading,process,load-balancing,uwsgi","A_Id":19326373,"CreationDate":"2013-10-07T19:37:00.000","Title":"How to tell uWSGI to prefer processes to threads for load balancing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've installed Nginx + uWSGI + Django on a VDS with 3 CPU cores. uWSGI is configured for 6 processes and 5 threads per process. Now I want to tell uWSGI to use processes for load balancing until all processes are busy, and then to use threads if needed. It seems uWSGI prefer threads, and I have not found any config option to change this behaviour. First process takes over 100% CPU time, second one takes about 20%, and another processes are mostly not used.\nOur site receives 40 r\/s. Actually even having 3 processes without threads is anough to handle all requests usually. But request processing hangs from time to time for various reasons like locked shared resources, etc. In such cases we have -1 process. Users don't like to wait and click the link again and again. As a result all processes hangs and all users have to wait.\nI'd add even more threads to make the server more robust. But the problem is probably python GIL. Threads wan't use all CPU cores. So multiple processes work much better for load balancing. But threads may help a lot in case of locked shared resources and i\/o wait delays. A process may do much work while one of it's thread is locked.\nI don't want to decrease time limits until there is no another solution. It is possible to solve this problem with threads in theory, and I don't want to show error messages to user or to make him waiting on every request until there is no another choice.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":9291,"Q_Id":19233132,"Users Score":9,"Answer":"Every process is effectively a thread, as threads are execution contexts of the same process.\nFor such a reason there is nothing like \"a process executes it instead of a thread\". Even without threads your process has 1 execution context (a thread). What i would investigate is why you get (perceived) poor performances when using multiple threads per process. Are you sure you are using a stable (with solid threading support) uWSGI release ? (1.4.x or 1.9.x)\nHave you thought about dynamically spawning more processes when the server is overloaded ? Check the uWSGI cheaper modes, there are various algorithm available. Maybe one will fit your situation.\nThe GIL is not a problem for you, as from what you describe the problem is the lack of threads for managing new requests (even if from your numbers it looks you may have a too much heavy lock contention on something else)","Q_Score":14,"Tags":"python,multithreading,process,load-balancing,uwsgi","A_Id":19238645,"CreationDate":"2013-10-07T19:37:00.000","Title":"How to tell uWSGI to prefer processes to threads for load balancing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I know in a linked list there are a head node and a tail node. Well, for my data structures assignment, we are suppose to create a linked matrix with references to a north, south, east, and west node. I am at a loss of how to implement this. A persistent problem that bothers me is the head node and tail node. The user inputs the number of rows and the number of columns. Should I have multiple head nodes then at the beginning of each row and multiple tail nodes at the end of each row? If so, should I store the multiple head\/tail nodes in a list? \nThank you.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1333,"Q_Id":19234950,"Users Score":0,"Answer":"There's more than one way to interpret this, but one option is:\nHave a single \"head\" node at the top-left corner and a \"tail\" node at the bottom-right. There will then be row-head, row-tail, column-head, and column-tail nodes, but these are all accessible from the overall head and tail, so you don't need to keep track of them, and they're already part of the linked matrix, so they don't need to be part of a separate linked list.\n(Of course a function that builds up an RxC matrix of zeroes will probably have local variables representing the current row's head\/tail, but that's not a problem.)","Q_Score":0,"Tags":"python,list,matrix,linked-list","A_Id":19235077,"CreationDate":"2013-10-07T21:17:00.000","Title":"Linked Matrix Implementation in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know in a linked list there are a head node and a tail node. Well, for my data structures assignment, we are suppose to create a linked matrix with references to a north, south, east, and west node. I am at a loss of how to implement this. A persistent problem that bothers me is the head node and tail node. The user inputs the number of rows and the number of columns. Should I have multiple head nodes then at the beginning of each row and multiple tail nodes at the end of each row? If so, should I store the multiple head\/tail nodes in a list? \nThank you.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1333,"Q_Id":19234950,"Users Score":0,"Answer":"It really depends on what options you want\/need to efficiently support.\nFor instance, a singly linked list with only a head pointer can be a stack (insert and remove at the head).  If you add a tail pointer you can insert at either end, but only remove at the head (stack or queue).  A doubly linked list can support insertion or deletion at either end (deque).  If you try to implement an operation that your data structure is not designed for you incur an O(N) penalty.\nSo I would start with a single pointer to the (0,0) element and then start working on the operations your instructor asks for.  You may find you need additional pointers, you may not.  My guess would be that you will be fine with a single head pointer.","Q_Score":0,"Tags":"python,list,matrix,linked-list","A_Id":19237061,"CreationDate":"2013-10-07T21:17:00.000","Title":"Linked Matrix Implementation in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been using Python to script Win32 iTunes, and it's been rocky but doable.  However, I wanted to move beyond just media (songs, etc.) to analyze what apps were on my devices.  Can anyone recommend how to use the iTunes Win32 COM interface to, say, get a list of apps that are currently on the phone?\nI thought the app list might be exposed as a playlist, with each app as an IITFileOrCDTrack, but that doesn't seem to be the case.  When I look at my phone as a source, it just lists media playlists (books, movies, etc.)\nOr, if you can suggest a different way to do this from Python, open to suggestions.  I assumed I'd have to use iTunes as my phone is not jailbroken and I don't know any other way to see what's on the phone, but if there is another way, cool.  I don't need to add or remove, just want to see what's there.\nThanks for any ideas...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":19238296,"Users Score":0,"Answer":"Apple does not offer any APIs to achieve this.","Q_Score":0,"Tags":"python,iphone,ios,itunes,itunes-sdk","A_Id":20518264,"CreationDate":"2013-10-08T02:53:00.000","Title":"Access iOS Apps List in iTunes via Win32 COM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dictionary with entries that are of the format\na = dict({(2,2013):[], (2,2011):[], (7,2013):[] , (4,2013):[]})\ni want my output to be like this:\n{(2,2011):[], (2,2013):[], (4,2013):[] , (7,2013):[]}\nBy the way its supposed to be (month,year), how can i achieve that?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":19255537,"Users Score":0,"Answer":"after a lot of trying i changed my approach and instead of tuples, i used datetime objects and then applied the: \n\nmonths_sorted = sorted(months.iteritems(), key=operator.itemgetter(0))","Q_Score":0,"Tags":"python,sorting,python-2.7,dictionary,calendar","A_Id":19269052,"CreationDate":"2013-10-08T18:31:00.000","Title":"sorting dates in key of tuples in dictionary","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset of time-series examples.  I want to calculate the similarity between various time-series examples, however I do not want to take into account differences due to scaling (i.e. I want to look at similarities in the shape of the time-series, not their absolute value).  So, to this end, I need a way of normalizing the data.  That is, making all of the time-series examples fall between a certain region e.g [0,100].  Can anyone tell me how this can be done in python","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":20885,"Q_Id":19256930,"Users Score":11,"Answer":"The solutions given are good for a series that aren\u2019t incremental nor decremental(stationary). In financial time series( or any other series with a a bias) the formula given is not right. It should, first be detrended or perform a scaling based in the latest 100-200 samples.\nAnd if the time series doesn't come from a normal distribution ( as is the case in finance) there is advisable to apply a non linear function ( a standard CDF funtion for example) to compress the outliers.\nAronson and Masters book (Statistically sound Machine Learning for algorithmic trading) uses the following formula ( on 200 day chunks ):  \nV = 100 * N ( 0.5( X -F50)\/(F75-F25)) -50   \nWhere:\n  X : data point\nF50 : mean of the latest 200 points\nF75 : percentile 75\nF25 : Percentile 25\n  N : normal CDF","Q_Score":9,"Tags":"python,time-series","A_Id":43874003,"CreationDate":"2013-10-08T19:46:00.000","Title":"Python - how to normalize time-series data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset of time-series examples.  I want to calculate the similarity between various time-series examples, however I do not want to take into account differences due to scaling (i.e. I want to look at similarities in the shape of the time-series, not their absolute value).  So, to this end, I need a way of normalizing the data.  That is, making all of the time-series examples fall between a certain region e.g [0,100].  Can anyone tell me how this can be done in python","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":20885,"Q_Id":19256930,"Users Score":0,"Answer":"I'm not going to give the Python code, but the definition of normalizing, is that for every value (datapoint) you calculate \"(value-mean)\/stdev\". Your values will not fall between 0 and 1 (or 0 and 100) but I don't think that's what you want. You want to compare the variation. Which is what you are left with if you do this.","Q_Score":9,"Tags":"python,time-series","A_Id":21486466,"CreationDate":"2013-10-08T19:46:00.000","Title":"Python - how to normalize time-series data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there anyway I can make a Java application communicate with a Flash Player (application) that is on a website? The flash application is quite dynamic, meaning the data changes as i refresh and visit different pages. In fact the page itself is fully flash. \nWhere should i be looking at to get this working?\nI'm thinking how can i even retrieve the text \/ objects from this flash and then send a action(click, text ) .\nAny advice would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":19296422,"Users Score":0,"Answer":"GraniteDS will allow you to access your java objects via the Flex framework.","Q_Score":0,"Tags":"java,php,python,actionscript-3,flash","A_Id":19300355,"CreationDate":"2013-10-10T12:59:00.000","Title":"Java Application Interacting with Flash on Web Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am fairly new to programming and have been learning python on codecademy. I would like to convert a python 2x program to python 3x using 2to3 on the command line but have no idea how to do it. I have looked at various other questions and articles on how to do it but I still do not understand. I have python 3.3 installed, and am running windows 8. This is the path to my python 2x program and my path to 2to3. \nMy program: \"C:\\Users\\watt\\Documents\\Tom's Stuff\\Programs\\Python\\python 2 test.py\"\n2to3 Location: \"C:\\Python33\\Tools\\Scripts\\2to3.py\"\nCan someone please tell me what I would have to enter into the command line?\nThanks in advance...","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2921,"Q_Id":19310244,"Users Score":1,"Answer":"You need to run Python, followed by the 2to3 script, followed by tags and arguments.\nRunning 2to3 on command line looks something like this:\n[python] [2tp3.py] [tags] [files to be converted (can be 1+)]\n\nC:\\python33\\python.exe C:\\python33\\Tools\\Scripts\\2to3.py -w C:\\Users\\watt\\Documents\\Tom's Stuff\\Programs\\Python\\python 2 test.py\n\nBy running Python33 followed by 2to3.py, you can run the 2to3 script. Then you add the -w tag to actually convert your program to Python 3. Then you add the files to be converted.\nThe command can be simplified by using changing directory to your Programs folder first.","Q_Score":2,"Tags":"python,python-2to3","A_Id":20411997,"CreationDate":"2013-10-11T04:25:00.000","Title":"Using 2to3 python in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install simplejson-3.3.1.tar.gz so it can be accessed by my Python project in netbeans IDE 7.3.1.\nI installed json.py in my src as a quick fix, but need more functionality.\nI am using linus mint 15 as an OS.\nI am unsure how to get my modules in netbeans to \"see\" methors e.g. json.dumps.\nI am new to netbeans and would appreciate your assistance.\nThanks and regards,\nChris","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2016,"Q_Id":19340807,"Users Score":0,"Answer":"Install Python setuptools\nsudo apt-get install python-setuptools\nNow using pip install simplejson\nsudo pip install simplejson\n\nIn general most Python packages can be installed this way.","Q_Score":0,"Tags":"python,json,netbeans","A_Id":19340898,"CreationDate":"2013-10-13T01:12:00.000","Title":"How do I install simplejson 3.3.1 for a Python project in Netbeans IDE 7.3.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install simplejson-3.3.1.tar.gz so it can be accessed by my Python project in netbeans IDE 7.3.1.\nI installed json.py in my src as a quick fix, but need more functionality.\nI am using linus mint 15 as an OS.\nI am unsure how to get my modules in netbeans to \"see\" methors e.g. json.dumps.\nI am new to netbeans and would appreciate your assistance.\nThanks and regards,\nChris","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2016,"Q_Id":19340807,"Users Score":0,"Answer":"I found the issue ...\nnetbeans defaults to jython. I had to save my project files to another directory, delete my project (changing to python 2.7. for current project had no effect) and create a new project with netbeans with python 2.7 as the default.\nThanks for helping me get simplejson into my python 2.7 Nipun! Chris","Q_Score":0,"Tags":"python,json,netbeans","A_Id":19346510,"CreationDate":"2013-10-13T01:12:00.000","Title":"How do I install simplejson 3.3.1 for a Python project in Netbeans IDE 7.3.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I find child process pid after the parent process died.\nI have program that creates child process that continues running after it (the parent) terminates.\ni.e.,\nI run a program from python script (PID = 2).\nThe script calls program P (PID = 3, PPID = 2)\nP calls fork(), and now I have another instance of P named P` (PID = 4 and PPID = 3).\nAfter P terminates P` PID is 4 and PPID is 1.\nAssuming that I have the PID of P (3), how can I find the PID of the child P`?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":947,"Q_Id":19361740,"Users Score":2,"Answer":"The information is lost when a process-in-the-middle terminates.  So in your situation there is no way to find this out.\nYou can, of course, invent your own infrastructure to store this information at forking time.  The middle process (PID 3 in your example) can of course save the information which child PIDs it created (e. g. in a file or by reporting back to the father process (PID 1 in your example) via pipes or similar).","Q_Score":1,"Tags":"python,linux,process","A_Id":19361844,"CreationDate":"2013-10-14T13:46:00.000","Title":"How to find orphan process's pid","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an image file that has multiple different images on it.  I was wondering how to make it so that I can load the individual images from the single one instead of breaking each into its own thing.  Sorry if I couldn't clarify what I am trying to ask.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":189,"Q_Id":19370567,"Users Score":0,"Answer":"You could load it all as one image and than draw the different segments onto the screen separately, or even define variables of the segments. This would effectively give you multiple images.","Q_Score":0,"Tags":"python,pygame","A_Id":20135822,"CreationDate":"2013-10-14T22:54:00.000","Title":"How do I load a single image with multiple images on it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just curious if there's a way to make the no default value warning I get from Storm to go away. I have an insert trigger in MySQL that handles these fields and everything is functioning as expected so I just want to remove this unnecessary information. I tried setting the default value to None but that causes an error because the fields do not allow nulls. So how do I make the warning go away?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":770,"Q_Id":19373289,"Users Score":0,"Answer":"Is it not possible for you to remove the 'IsNull' constraint from your MySQL database? I'm not aware of any where it is not possible to do this. Otherwise you could set a default string which represents a null value.","Q_Score":1,"Tags":"python,mysql,apache-storm","A_Id":20010872,"CreationDate":"2013-10-15T04:26:00.000","Title":"How can I avoid \"Warning: Field 'xxx' doesn't have a default value\" in Storm?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Using the module pymqi how do you get a message in MQ queue using a parameter, for example \"UserIdentifier\"? So, I would only get messages from the queue that possess this parameter \"UserIdentifier\". Thank you for your attention.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1295,"Q_Id":19394658,"Users Score":0,"Answer":"You can only get messages by MsgID, CorrelID or GroupID.","Q_Score":0,"Tags":"python,ibm-mq,pymqi","A_Id":19412440,"CreationDate":"2013-10-16T03:19:00.000","Title":"Python - PyMQI - Get a message from a queue MQ using parameter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a X-plotter like widget that plots incomming data live.\nI already searched for an solution to realize a scrolling along the x-axis if the widget has to much values and so they don't fit.\nI had the folling approaches to realize it:\n\nderive from a widget that supports scrolling and child widgets and add my own widget while making it bigger and bigger during the live updates: -> Which parent do I need to use and how do I avoid to draw all the stuff that is currently not visible?\nmodify my widget in a way that it supports the scrollbars itself -> but how?\ndraw\/handle my own scrollbars -> worstcase :(\n\nI really searched the web for suggestions or examples, but there is nothing about how to \"construct\" custom controls in a good way (beyond drawing something) esp. in the case of interaction...\nSorry but I'm a newbie at GTK in general :\/","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":574,"Q_Id":19411111,"Users Score":2,"Answer":"Most widgets in Gtk do not have scrollbars.\nIf you want to scroll the entire widget, you have to implement the GtkScrollable interface. Then, you add the widget to a GtkScrolledWindow. The scrolled window has the scrollbars, those GtkScrollbars are linked with GtkAdjustments which are passed to your custom widget through the GtkScrollable interface set_vadjustment and set_hadjustment.\nIf you just want to add a scrollbar and control its behaviour yourself, then you need to somehow add a GtkScrollbar in your widget, which means you will need to make it a container too.\nThe GtkScrollable approach is the following, first you implement vadjustment and hadjustment setters and getters, then when the GtkAdjustments are set, you set its lower and upper limits and the page size(how much of the widget is visible at once). After that, you connect their value-changed signal so you can refresh your widget when the scrollbars are dragged. A GtkScrollable doesn't get to check the scrollbars, only the adjustments that will be bound to the scrollbars. When drawing the widget you get the adjustments' value property in order to determine how much the scrollbars have shifted in the horizontal and vertical axes.","Q_Score":0,"Tags":"python,gtk,custom-controls,scrollbar,pygtk","A_Id":19477901,"CreationDate":"2013-10-16T18:34:00.000","Title":"Python: Creating own Widget with scrollbars","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to draw the curve a generic cubic function using matplotlib. I want to draw curves that are defined by functions such as: x^3 + y^3 + y^2 + 2xy^2 = 0. Is this possible to do?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2800,"Q_Id":19422749,"Users Score":0,"Answer":"my 2 cents:\nx^3+y^3+y^2+2xy^2=0\ny^2=-x^3-y^3-2xy^2\ny^2>0 => -x^3-y^3-2xy^2>0 => x^3+y^3+2xy^2<0 =>\nx(x^2+2y^2)+y^3<0 => x(x^2+2y^2)<-y^3 => (x^2+2y^2)<-y^3\/x\n0<(x^2+2y^2) => 0<-y^3\/x => 0>y^3\/x =>\n(x>0 && y<0) || (x<0 && y>0)\nyour graph will span across the 2nd and 4th quadrants","Q_Score":2,"Tags":"python,matplotlib","A_Id":19423078,"CreationDate":"2013-10-17T09:22:00.000","Title":"how to draw a nonlinear function using matplotlib?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a multiple regex which combines thousands of different regexes e.g r\"reg1|reg2|...\".\nI'd like to know which  one of the regexes gave a match in re.search(r\"reg1|reg2|...\", text), and I cannot figure how to do it since `re.search(r\"reg1|reg2|...\", text).re.pattern gives the whole regex.\nFor example, if my regex is r\"foo[0-9]|bar\", my pattern \"foo1\", I'd like to get as an answer \"foo[0-9].\nIs there any way to do this ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":19445789,"Users Score":0,"Answer":"Wrap each sub-regexp in (). After the match, you can go through all the groups in the matcher (match.group(index)). The non-empty group will be the one that matched.","Q_Score":0,"Tags":"python,regex,python-2.7","A_Id":19445831,"CreationDate":"2013-10-18T09:10:00.000","Title":"Find which part of a multiple regex gave a match","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":19448553,"Users Score":0,"Answer":"Just install an appropriate python and virtualenv for that python directly on the windows 7 machine.","Q_Score":1,"Tags":"python,windows-7,intellij-idea,virtualenv,python-2.6","A_Id":19448864,"CreationDate":"2013-10-18T11:26:00.000","Title":"IntelliJ IDEA - unix python virtualenv on WIndows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":19448553,"Users Score":0,"Answer":"I solved it. If connect with my virtual machine by remote debug tool. I add one line with IntellJ\/PyCharm generate to entry point of paster script. Before debug i run script (using IntelliJ remote tool) with run application on virtual machine.","Q_Score":1,"Tags":"python,windows-7,intellij-idea,virtualenv,python-2.6","A_Id":19809928,"CreationDate":"2013-10-18T11:26:00.000","Title":"IntelliJ IDEA - unix python virtualenv on WIndows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a few large hourly upload tables with RECORD fieldtypes. I want to pull select records out of those tables and put them in daily per-customer tables. The trouble I'm running into is that using QUERY to do this seems to flatten the data out.\nIs there some way to preserve the nested RECORDs, or do I need to rethink my approach?\nIf it helps, I'm using the Python API.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":234,"Q_Id":19458338,"Users Score":0,"Answer":"Unfortunately, there isn't a way to do this right now, since, as you realized, all results are flattened.","Q_Score":1,"Tags":"python,google-bigquery","A_Id":19459294,"CreationDate":"2013-10-18T20:17:00.000","Title":"Bigquery: how to preserve nested data in derived tables?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Someone on here asked a question similar to this, but it got quickly downvoted and closed due to the newbiness of it's nature. So I decided to answer it myself, and for others who want to know how to make this nifty program, because it isn't really such a bad idea. So here goes nothing!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":94,"Q_Id":19477250,"Users Score":1,"Answer":"I'm not going to tell you your code is horrendous. But you could simplify it.\nEverything in the try routine could be replaced by a single line:\nprint 'Space for about', int(totstor*1048576\/25), 'standard jpg image files available'\nIn other words you can print the result of the calculation directly. Let int() take care of rounding, getting rid of \".0\", etc., and rely on the fact that you can print integers (and most other data types) directly without converting them to a string. You simply chain together the items you need in the output using commas. (There are other ways of getting numbers into the desired output text, but this is simplest).","Q_Score":0,"Tags":"python,image,file","A_Id":19477441,"CreationDate":"2013-10-20T12:21:00.000","Title":"Python Program to tell amount of image files that will fit on a disk\/flash drive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I created my own modified version of a program with the GPLv3, and it's open source and everything.  \nMy question is how am I supposed to state that I modified it?\nDo I just put in a comment saying # Modified by yentup ?  \nI've tried researching about this topic but I haven't found any directions on how to do so.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":685,"Q_Id":19484981,"Users Score":2,"Answer":"You have no requirement to say that you modified it at all - your only obligation is to offer the source code to anyone who uses your version.\nHowever the best solution for you, the original authors and future users is probably to have your changes put back into the main source tree, assuming that they would be useful to other users! At which point you the version history would mark your changes, you could also add your name in a comment if you wished.","Q_Score":1,"Tags":"python,python-2.7,licensing,gpl","A_Id":19485013,"CreationDate":"2013-10-21T01:35:00.000","Title":"Is there a formal way to state modifications of a program covered with GPL?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make my python script executable without going through the terminal typing like\npython test.py\nI want to make it able to run when i click on the file.\nHow i going to do this in my fedora machine.","AnswerCount":7,"Available Count":6,"Score":0.0285636566,"is_accepted":false,"ViewCount":12507,"Q_Id":19509911,"Users Score":1,"Answer":"It's Nautilus's fault. Open Nautilus (the file manager), go to Menu > Preferences.\nSelect the \"Behaviour\" section.\nOn the field titled \"Executable text files\", select the option \"Execute executable text files when opened\".","Q_Score":2,"Tags":"python","A_Id":22898338,"CreationDate":"2013-10-22T05:47:00.000","Title":"how to make python script executable when click on the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make my python script executable without going through the terminal typing like\npython test.py\nI want to make it able to run when i click on the file.\nHow i going to do this in my fedora machine.","AnswerCount":7,"Available Count":6,"Score":0.057080742,"is_accepted":false,"ViewCount":12507,"Q_Id":19509911,"Users Score":2,"Answer":"Add #!\/usr\/bin\/env python at the very beginning of file.\nMake chmod u+x filename.py\nChange your extension from .py to .sh, so your linux distro's UI will recognize it as shell script and try to execute.","Q_Score":2,"Tags":"python","A_Id":19510082,"CreationDate":"2013-10-22T05:47:00.000","Title":"how to make python script executable when click on the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make my python script executable without going through the terminal typing like\npython test.py\nI want to make it able to run when i click on the file.\nHow i going to do this in my fedora machine.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":12507,"Q_Id":19509911,"Users Score":0,"Answer":"If you don't have any specific version requirement then using first line as #!\/usr\/bin\/env python will be more efficient and give the execute permission chmod u+x test.py","Q_Score":2,"Tags":"python","A_Id":19510040,"CreationDate":"2013-10-22T05:47:00.000","Title":"how to make python script executable when click on the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make my python script executable without going through the terminal typing like\npython test.py\nI want to make it able to run when i click on the file.\nHow i going to do this in my fedora machine.","AnswerCount":7,"Available Count":6,"Score":0.1418931938,"is_accepted":false,"ViewCount":12507,"Q_Id":19509911,"Users Score":5,"Answer":"Add #!\/bin\/python as the very first line of your file. Or, if you don't know where your python executable is, type which python in a terminal; then copy the result of that and put it after the #!.\nChange the permissions of the file so that its executable chmod u+x test.py\n\n\n\ni try but it still open back as gedit\n\n\nRight click on the file in your gnome file browser or desktop.\nSelect Properties\nGo to Open with and choose Python. If you don't see python in the list, add the command. Just type python in the command to be added.","Q_Score":2,"Tags":"python","A_Id":19509956,"CreationDate":"2013-10-22T05:47:00.000","Title":"how to make python script executable when click on the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make my python script executable without going through the terminal typing like\npython test.py\nI want to make it able to run when i click on the file.\nHow i going to do this in my fedora machine.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":12507,"Q_Id":19509911,"Users Score":0,"Answer":"I use raspibian os (Linux)\n\nAdd #!\/usr\/bin\/python as the first line of the file.py\nright click file >> open with >> chose customize >> custom command line >> type python3\nexecute file with double click is working","Q_Score":2,"Tags":"python","A_Id":55925012,"CreationDate":"2013-10-22T05:47:00.000","Title":"how to make python script executable when click on the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make my python script executable without going through the terminal typing like\npython test.py\nI want to make it able to run when i click on the file.\nHow i going to do this in my fedora machine.","AnswerCount":7,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":12507,"Q_Id":19509911,"Users Score":0,"Answer":"Add #!\/usr\/bin\/python as the first line of the file and set the permission to executable chmod 755 yourfile.","Q_Score":2,"Tags":"python","A_Id":19509975,"CreationDate":"2013-10-22T05:47:00.000","Title":"how to make python script executable when click on the file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"so I am adoring the new IPython notebook slideshow feature, however I could not figure out how to distribute such a slideshow in a userfriendly (I am no HTML\/JS guy) way.\nMy usecase is:\nI have a somewhat messy notebook which I want to filter by tagging cells as slides\/skip\/- etc.\nIn an optimal world there would be a fire-and-forget 'give me a pdf' button somewhere.\nSo I did already view the slides locally via ipython nbconvert ... --to slides -- post serve\nBut how do I distribute that to others? Can I get a pdf from such a slideshow easily (I do not care about transition animations etc.)\nI hope this is developed further, great features so far!","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2339,"Q_Id":19513621,"Users Score":1,"Answer":"$ ipython nbconvert ... --to slides (no serve option necessary) create a standalone html file you should be able to mail, or whatever. \nThe skip\/- logic can be applied to pdf generation too, you just have to write your own extended template (which is not that hard, wild guess ~20 lines)","Q_Score":2,"Tags":"ipython-notebook","A_Id":19535347,"CreationDate":"2013-10-22T09:11:00.000","Title":"Distribute a slideshow from IPython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"so I am adoring the new IPython notebook slideshow feature, however I could not figure out how to distribute such a slideshow in a userfriendly (I am no HTML\/JS guy) way.\nMy usecase is:\nI have a somewhat messy notebook which I want to filter by tagging cells as slides\/skip\/- etc.\nIn an optimal world there would be a fire-and-forget 'give me a pdf' button somewhere.\nSo I did already view the slides locally via ipython nbconvert ... --to slides -- post serve\nBut how do I distribute that to others? Can I get a pdf from such a slideshow easily (I do not care about transition animations etc.)\nI hope this is developed further, great features so far!","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":2339,"Q_Id":19513621,"Users Score":1,"Answer":"You can print it as a pdf file from Chrome.\n\nAdd \"?print-pdf\" at the end of your URL.e.g: 127.0.0.1:8000\/index.html?print-pdf\nSelect print menu from Chrome.\nSelect Save As pdf, then print it out.","Q_Score":2,"Tags":"ipython-notebook","A_Id":21978035,"CreationDate":"2013-10-22T09:11:00.000","Title":"Distribute a slideshow from IPython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We are using the python\/Django for web development. While development phase wile coding i tends to put print statement a lot places to check the control flow of the code.\nAnd same code with print statement is uploaded for server,\nI know logging is a place to be more suitable but i find myself more comfortable with print.\nI want to know how few lines of code will make site slow, if it makes it slow.\nLets say i have 100 line of code and upon that i added 5 print statements. another way of looking into it is to i wrote a 105 line of code. Then in that sense i should not make difference (i suppose). \nDoes this will make the website slow ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1976,"Q_Id":19527097,"Users Score":2,"Answer":"Yes, since the arguments will need to be converted to strings before outputting and that can be a costly operation.\nHowever, using print causes another issue. Some WSGI containers, notably mod_wsgi among them, do not like anything sent to stdout by default and so will raise an exception whenever that happens. You can fix this by printing to stderr instead, but the performance issue will remain.","Q_Score":0,"Tags":"python,django,web","A_Id":19527376,"CreationDate":"2013-10-22T19:54:00.000","Title":"Does print statement will make performance issue for a website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My server has 3 ip addresses, 127.0.0.1, 192.168.0.100 and an internet ip address. I'm going to run a service written by python on this server, but I don't want it to expose on internet.\nI'm using BaseHTTPRequestHandler class to implement this service, so how to bind only 127.0.0.1 and 192.168.0.100 but not the other one?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":758,"Q_Id":19556467,"Users Score":0,"Answer":"I think you have two choices.\n1) Listen to all interfaces, but override BaseHTTPRequestHandler.init to check the client address and drop the connection if it comes from an undesired interface\n2) Create multiple sockets, one per address you want to listen on.  SocketServer.serve_forever() is blocking, so you will either need to use one thread per address or switch to a more sophisticated framework like twisted.","Q_Score":0,"Tags":"python,basehttprequesthandler","A_Id":19556787,"CreationDate":"2013-10-24T03:38:00.000","Title":"how to bind multiple specified ip address on BaseHTTPRequestHandler of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My server has 3 ip addresses, 127.0.0.1, 192.168.0.100 and an internet ip address. I'm going to run a service written by python on this server, but I don't want it to expose on internet.\nI'm using BaseHTTPRequestHandler class to implement this service, so how to bind only 127.0.0.1 and 192.168.0.100 but not the other one?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":758,"Q_Id":19556467,"Users Score":0,"Answer":"Generally, routers have an option where you can allow servers to be visible or not visible. If on the router you set you server to not be visible, then your server will not be accessible through the internet.","Q_Score":0,"Tags":"python,basehttprequesthandler","A_Id":19556500,"CreationDate":"2013-10-24T03:38:00.000","Title":"how to bind multiple specified ip address on BaseHTTPRequestHandler of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"On windows 7, I currently don't have a python path. Can I safely make one? If so, how do I do it?\nUpon making this variable, I can no longer load Spyder (IDE) without it crashing. Does anyone know why?\nI would like to edit my existing python path if possible, but just don't know why it isn't already there in environmental variables.\nI would ultimately like to be able to run \"python myscript.py\" and have myscript be in a different directory from the call directory.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1331,"Q_Id":19600545,"Users Score":0,"Answer":"it has role similar to path.  this variable tells the python interpreter where to \nlocate the module files imported into a program.  it should include the python source library directory and the directories contain in python source code","Q_Score":0,"Tags":"python,python-2.7","A_Id":47374011,"CreationDate":"2013-10-25T22:46:00.000","Title":"What is the purpose of the environmental variable PYTHONPATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been learning how to use the paramiko package only to discover that all I stored passwords in plain text in IPython's %hist. Not so good.\nI therefore need to get rid of particular parts of what is stored in %hist. Saying that, I do not want to wipe the whole history. - Only the parts where I have been careless enough to type password = or similar chosen terms.\nThanks\n\nComments I don't need:\n\n%clear only clears the session. It does not wipe the history.\nYes. I will only use xSA_keys from now on.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":17232,"Q_Id":19606275,"Users Score":0,"Answer":"If you want completely from beginning, Just go and delete the following file manually(It worked for me)\n\/home\/user\/.ipython\/profile_default\/history.sqlite","Q_Score":40,"Tags":"ipython,ipython-notebook","A_Id":51346139,"CreationDate":"2013-10-26T11:43:00.000","Title":"IPython: How to wipe IPython's history selectively & securely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been learning how to use the paramiko package only to discover that all I stored passwords in plain text in IPython's %hist. Not so good.\nI therefore need to get rid of particular parts of what is stored in %hist. Saying that, I do not want to wipe the whole history. - Only the parts where I have been careless enough to type password = or similar chosen terms.\nThanks\n\nComments I don't need:\n\n%clear only clears the session. It does not wipe the history.\nYes. I will only use xSA_keys from now on.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":17232,"Q_Id":19606275,"Users Score":1,"Answer":"I couldn't find the way to wipe IPython's history selectively, but I found out how to wipe data by built-in func, non-sqlite way:\n%clear out #it clears output history\nby the way, you can also clear in history by %clear in","Q_Score":40,"Tags":"ipython,ipython-notebook","A_Id":52141421,"CreationDate":"2013-10-26T11:43:00.000","Title":"IPython: How to wipe IPython's history selectively & securely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This goes out to anyone who is well versed in the Eclipse IDE and or PyDev perspective plug-in who is willing to offer some technical support.\nI am trying to write a python module that must take in arguments from the command prompt with sys.argv function calls. Rather than printing out the correct output when I enter E:\\ ... \\src>program.py arg1 arg2, all that happens is a new command line (E:\\ ... \\src>) is output and the Eclipse IDE window flashes orange without any code in my python module actually being executed. Also, if I close the Eclipse IDE and try to run program.py, it will just open Eclipse again and open my program in a new tab.\nI'm confused as to why it is not working now when just last week it was working perfectly while testing another program that took in arguments from the command prompt by sys.argv function calls. My question for everyone is whether or not you are aware of any settings that may have been altered by updates, etc. that could cause this problem; or has anybody out there ever run into this problem and figured out how to resolve it? I have already checked my PATH variable, so that is not the problem :-(. Any help you can provide would be greatly appreciated ... thank you.\nOS: Windows 8.1 Pro \/ Eclipse ver.: Kepler (4.3) \/ Python ver.: 3.3.2","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":19612221,"Users Score":0,"Answer":"I answered my own question in the comment above. I just had to wait to post an answer due to the fact that I just created a stackoverflow account yesterday.","Q_Score":0,"Tags":"eclipse,python-3.x,command-line-arguments,pydev,windows-8.1","A_Id":19624100,"CreationDate":"2013-10-26T21:42:00.000","Title":"Python module will not run correctly from command prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Am I confused as to what is possible between an Android Client and Google App Engine? I would like to be able to create a Python API that would handle requests between GAE services such as Datastore, and an Android Client.\nI have found some examples that detail how to make a call from within an Android Client, but it doesn't seem to outline whether or not you can pass data to any specific API language. The question I have is whether or not it is possible to use a Python API deployed on GAE and making calls through Google End Points, or would I have to use Java Servlets to handle requests?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":127,"Q_Id":19612642,"Users Score":1,"Answer":"Yes, you can use Python to do what you want.\nGoogle designs their services (such as GAE and endpoints) to be language agnostic, e.g. using JSON to serialize objects.\nThere are a few advantages to using Java on both, such as being able to share code between client and service projects, but Google does not promote such dependencies at all - you will have no problem using Python instead.","Q_Score":0,"Tags":"java,android,python,google-app-engine","A_Id":19613781,"CreationDate":"2013-10-26T22:37:00.000","Title":"Android Client and Google App Engine APIs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? \nI know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","AnswerCount":5,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":19622526,"Users Score":0,"Answer":"The general formula for base B is as follows:\n(B^N + ... + B^1 + B^0)*(B-1) = \n(B^(N+1) + ... + B^2 + B^1) - (B^N + ... + B^1 + B^0) = \nB^(N+1) - B^0 = B^(N+1)-1\nExamples:\n\nB=2 and N=3 gives 2^4 - 1 = 1111 binary\nB=10 and N=3 gives 10^3 - 1 = 999 decimal","Q_Score":2,"Tags":"python,python-3.x,binary,numbers,decimal","A_Id":19622796,"CreationDate":"2013-10-27T19:34:00.000","Title":"Binary to decimal conversion - formula explanation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? \nI know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":426,"Q_Id":19622526,"Users Score":1,"Answer":"Think of it like this, 111 is 1 less than 1000 (8 in binary).","Q_Score":2,"Tags":"python,python-3.x,binary,numbers,decimal","A_Id":19622562,"CreationDate":"2013-10-27T19:34:00.000","Title":"Binary to decimal conversion - formula explanation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? \nI know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","AnswerCount":5,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":426,"Q_Id":19622526,"Users Score":2,"Answer":"It is a unique property of number 2 that the sum of it's previous powers is equal to the next power level subtracted by 1.\nIn other words:\n\n2^n=2^0+2^1+2^2+...+2^(n-1)+1 for n in (1,2,3...)\n\nIf you need proof, use mathematical induction.\nBase: n=1; 2^1=2=2^0+1=1+1\nSuppose that for n=k the property 2^n=2^0+2^1+...+2^(n-1)+1 is satisfied\nFor n=k+1 you have 2^n=(2^k)*(2^1) then apply the hypothesis and you have \n2^n=(2^0+2^1+...+2^(n-2)+1)*2 which yields\n2^n=(2^1+2^2+...+2^(n-1)+2)=1+2^0+2^1+...+2^(n-1) which concludes our proof.","Q_Score":2,"Tags":"python,python-3.x,binary,numbers,decimal","A_Id":19622553,"CreationDate":"2013-10-27T19:34:00.000","Title":"Binary to decimal conversion - formula explanation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? \nI know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","AnswerCount":5,"Available Count":4,"Score":0.0399786803,"is_accepted":false,"ViewCount":426,"Q_Id":19622526,"Users Score":1,"Answer":"Add 1 to 111: the result is 1000. \nIt follows, therefore, that:\n\n111 + 1 = 1000 \u2192 1000 - 1 = 111\n\nNow, 1000 is 23, hence:\n\n23 - 1 = 111\n\nOf course, you can say something similar about binary numbers with any number of 1s","Q_Score":2,"Tags":"python,python-3.x,binary,numbers,decimal","A_Id":19622560,"CreationDate":"2013-10-27T19:34:00.000","Title":"Binary to decimal conversion - formula explanation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a program, which uses tkinter to create a window where stuff happens. It contains images and loops to constantly shift and move the images.\nNow, when I close the window, the scripts are still running and it creates error messages that it has nowhere to place the images with new coordinates.\nI think that the loops are still running. So my question is, how do I close the program all together after clicking the x on the window. Is there a way to bind the x(close window) to terminate the program, or cat n ibe done inside a code, to see when the tkinter window is closed(to me this way seems to be bad, because it would keep checking for if the window is still existing or not).\nThanks a lot!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1700,"Q_Id":19624968,"Users Score":0,"Answer":"I had the same issue caused by a top level window I had created and withdrawn but didn't destroy.  Properly destroying it fixed my issue.","Q_Score":1,"Tags":"python","A_Id":54815571,"CreationDate":"2013-10-27T23:30:00.000","Title":"Closing a python program window leaves program still running in the background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I\u2019m trying to print a string that is too long to be displayed on one line, so it automatically wraps to the next line. The problem is that I need it to all stay on one line and just go off the screen (where I can just scroll left to right to see it all).Is there a way to to disable word wrap in python IDLE\nby changing somethings in configure option","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6081,"Q_Id":19663625,"Users Score":6,"Answer":"Text wrapping is a function of your terminal, not python. All that python does is send a string to the terminal - think about it, when you say print \"abcdef\\n\", there's no character in there that tells the terminal to wrap-text! \nYou just need to configure the environment you're coding in. There should be a pretty easily accessible 'settings' option. However, if you can't find it, then tell us what environment you're using - we might be able to help.","Q_Score":1,"Tags":"python,python-3.x,word-wrap","A_Id":19664045,"CreationDate":"2013-10-29T16:12:00.000","Title":"how to disable WORD WRAP in python IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python on Ubuntu.\ncall([\"xdotool\", \"mousemove\", \"500\",\"600\"])works fine.\nBut if x=500, y=600,\ncall([\"xdotool\", \"mousemove\", \"x\",\"y\"])\ndoes not work. \nWhat should be the syntax of x and y?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":159,"Q_Id":19674364,"Users Score":0,"Answer":"Remove the quotes. If you keep quotes, it will treat as a string.\ncall([\"xdotool\", \"mousemove\", \"500\",\"600\"])","Q_Score":0,"Tags":"python,call,mousemove,xdotool","A_Id":19674382,"CreationDate":"2013-10-30T05:16:00.000","Title":"In Python how to use variables in call function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using apscheduler and wmi to create and install new python based windows services where the service determines the type of job to be run. The services are installed across all the machines on the same network. Given this scenario I want to make sure that these services run only on one machine and not all the machines. \nIf a machine goes down I still want the job to be run from another machine on the same network. How would I accomplish this task?\nI know I need to do some kind of synchronization across machines but not sure how to address it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":19692437,"Users Score":0,"Answer":"I tried to include functionality like this in APScheduler 2.0 but it didn't pan out. Maybe The biggest issue is handling concurrent accesses to jobs and making sure jobs get run even if a particular node crashes. The nodes also need to communicate somehow.\nAre you sure you don't want to use Celery instead?","Q_Score":1,"Tags":"python,networking,synchronization,wmi,apscheduler","A_Id":19737941,"CreationDate":"2013-10-30T19:44:00.000","Title":"syncronizing across machines for a python apscheduler and wmi based windows service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had PyQt4 running fine with python2 on Ubuntu 12.04.  I then installed python-PySide.  But the installation test would give me a module not found error.  Then I installed python3-PySide and it works fine.  So obviously something to do with my environment paths, but I'm not sure what I need to do.  I'm guessing PySide is automatically checking if python3 exists and if it does then it'll use it regardless.  I need PySide to work with python2.7 because of Qt4.8 compatibility issues.  Any suggestions?\nsome info about my system:\nwhich python \n\n\n\/usr\/bin\/local\/python\n\n\nwhich python3\n\n\n\/usr\/bin\/python3\n\n\nEDIT:\nMore details about installation test.\nAfter installation, I bring up the python console and try import PySide, as follows:\npython\n\n\n\nimport PySide\n\n\n\nImportError: No module name PySide\nBut it works fine for python3:\npython3\n\n\n\nimport PySide\nPySide.version\n\n\n\n'1.1.2'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1553,"Q_Id":19696973,"Users Score":1,"Answer":"You have two independent Python 2.7 installations, one in \/usr and one in \/usr\/local. (And that's on top of the Python 3.x installation you also have.)\nThis is bound to cause confusion, especially for novices. And it has caused exactly the kind of consuion it was bound to cause.\nYou've installed PySide into the \/usr installation, so it ended up in \/usr\/lib\/python2.7\/dist-packages. If you run \/usr\/bin\/python, that import PySide will probably work fine. (If not, see below.)\nBut the default thing called python and python2.7 on your PATH is the \/usr\/local installation, hence which python says \/usr\/local\/bin\/python, so it can't see PySide at all. So you need to get it installed for the other Python as well.\n\nUnless you know that you need a second Python 2.7 in \/usr\/local for some reason, the simplest thing to do would be to scrap it. Don't uninstall it and reinstall it; just uninstall it. You've already got a Python 2.7 in \/usr, and you don't need two of them.\n\nIf you really need to get PySide working with the second 2.7\u2026\nSince you still haven't explained how you've been installing PySide despite being asked repeatedly, I can't tell you exactly how to do that. But generally, the key is to make sure to use explicit paths for all Python programs (python itself, python-config, pip, easy_install, etc.) that you have to run. For example, if the docs or blog or voices in your head tell you to run easy_install at some step, run \/usr\/local\/bin\/easy_install instead. If there is no such program, then you need to install that. The fact that you already have \/usr\/bin\/easy_install doesn't help\u2014in fact, it hurts.\n\nIf you can get rid of the second Python, but that doesn't fix PySide yet, uninstall, rebuild, and reinstall PySide. Or, even simpler\u2026\u00a0PySide has pre-made, working binary Ubuntu packages for all of the major Python versions that have Ubuntu packages. Just install it that way.","Q_Score":1,"Tags":"python,ubuntu,python-2.7,python-3.x,pyside","A_Id":19697689,"CreationDate":"2013-10-31T01:40:00.000","Title":"Ubuntu - PySide module not found for python2 but works fine for python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"For example, I may have installed pkg1, which requires pkg2 and pkg3. No other packages I have installed require these two. So, during or after pip uninstall pkg1, how can I make pip uninstall pkg2 and pkg3?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":290,"Q_Id":19697730,"Users Score":0,"Answer":"I don't think pip can do this.\nIf you are in virtualenv you just delete it and reinstall into new one.\nIf you are in system, you should never use pip but the distribution package manager.","Q_Score":2,"Tags":"python,pip","A_Id":19698648,"CreationDate":"2013-10-31T03:00:00.000","Title":"How can I make pip uninstall packages that are no longer required by other packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Django 1.5.4 to design a web page in which i want to use GPIO, but i got following error:\n\"No\uffa0access\uffa0to\uffa0\/dev\/mem. Try\uffa0running\uffa0as\uffa0root! \"\nin browser. Since web browser itself is an application, how can i assign \"root\" privileges to it when it tried to render a web page ? If it can be done without any need to install anything that would be better as other frameworks\/applications who are able to use GPIO in web page must have made some tweaks.I tried searching for similar questions for this area but couldn't find this specific case ( django + gpio access).\nAny help would be greatly appreciated.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":467,"Q_Id":19702170,"Users Score":2,"Answer":"You don't have to run the webbrowser as root but your django app (the webserver).\nOf course running a web application as root is an incredibly bad idea (even on a pi), so you might want to use a separate worker process (e.g. using celery) that runs as root and accesses the GPIOs.","Q_Score":0,"Tags":"python,django,raspberry-pi","A_Id":19702189,"CreationDate":"2013-10-31T08:59:00.000","Title":"Using GPIO in webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I have never used amazon web services so I apologize for the naive question. I am looking to run my code on a cluster as the quad-core architecture on my local machine doesn't seem to be doing the job. The documentation seems overwhelming and I don't even know which AWS services are going to be used for running my script on EC2. Would I have to use their storage facility (S3) because I guess if I have to run my script, I'm going to have to store it on the cloud in a place where the cluster instance has access to the files or do I upload my files somewhere else while working with EC2? If this is true is it possible for me to upload my entire directory which has all the contents of the files required by my application onto s3. Any guidance would be much appreciated. So I guess my question is do I have to use S3 to store my code in a place accessible by the cluster? If so is there an easy way to do it? Meaning I have only seen examples of creating buckets wherein one file can be transferred per bucket. Can you transfer an entire folder into a bucket? \nIf we don't require to use S3 then which other service should I use to give the cluster access to my scripts to be executed?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":718,"Q_Id":19713141,"Users Score":0,"Answer":"You do not need to use S3, you would likely want to use EBS for storing the code if you need it to be preserved between instance launches. When you launch an instance you have the option to add an ebs storage volume to the drive. That drive will automatically be mounted to the instance and you can access it just like you would on any physical machine. ssh your code up to the amazon machine and fire away.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,amazon-ec2,cluster-computing","A_Id":19714085,"CreationDate":"2013-10-31T17:35:00.000","Title":"how to run python code on amazon ec2 webservice?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have to archive a large amount of data off of CDs and DVDs, and I thought it was an interesting problem that people might have useful input on. Here's the setup:\n\nThe script will be running on multiple boxes on multiple platforms, so I thought python would be the best language to use. If the logic creates a bottleneck, any other language works.\nWe need to archive ~1000 CDs and ~500 DVDs, so speed is a critical issue\nThe data is very valuable, so verification would be useful\nThe discs are pretty old, so a lot of them will be hard or impossible to read\n\nRight now, I was planning on using shutil.copytree to dump the files into a directory, and compare file trees and sizes. Maybe throw in a quick hash, although that will probably slow things down too much.\nSo my specific questions are:\n\nWhat is the fastest way to copy files off a slow medium like CD\/DVDs? (or does the method even matter)\nAny suggestions of how to deal with potentially failing discs? How do you detect discs that have issues?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1815,"Q_Id":19717288,"Users Score":0,"Answer":"Writing your own backup system is not fun. Have you considered looking at ready-to-use backup solutions? There are plenty, many free ones...\nIf you are still bound to write your own... Answering your specific questions:\n\nWith CD\/DVD you first typically have to master the image (using a tool like mkisofs), then write image to the medium. There are tools that wrap both operations for you (genisofs I believe) but this is typically the process.\nTo verify the backup quality, you'll have to read back all written files (by mounting a newly written CD) and compare their checksums against those of the original files. In order to do incremental backups, you'll have to keep archives of checksums for each file you save (with backup date etc).","Q_Score":3,"Tags":"python,backup,archive,cd,dvd","A_Id":19717555,"CreationDate":"2013-10-31T21:56:00.000","Title":"What is the best way to archive a data CD\/DVD in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have to archive a large amount of data off of CDs and DVDs, and I thought it was an interesting problem that people might have useful input on. Here's the setup:\n\nThe script will be running on multiple boxes on multiple platforms, so I thought python would be the best language to use. If the logic creates a bottleneck, any other language works.\nWe need to archive ~1000 CDs and ~500 DVDs, so speed is a critical issue\nThe data is very valuable, so verification would be useful\nThe discs are pretty old, so a lot of them will be hard or impossible to read\n\nRight now, I was planning on using shutil.copytree to dump the files into a directory, and compare file trees and sizes. Maybe throw in a quick hash, although that will probably slow things down too much.\nSo my specific questions are:\n\nWhat is the fastest way to copy files off a slow medium like CD\/DVDs? (or does the method even matter)\nAny suggestions of how to deal with potentially failing discs? How do you detect discs that have issues?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1815,"Q_Id":19717288,"Users Score":1,"Answer":"When you read file by file, you're seeking randomly around the disc, which is a lot slower than a bulk transfer of contiguous data. And, since the fastest CD drives are several dozen times slower than the slowest hard drives (and that's not even counting the speed hit for doing multiple reads on each bad sector for error correction), you want to get the data off the CD as soon as possible.\nAlso, of course, having an archive as a .iso file or similar means that, if you improve your software later, you can re-scan the filesystem without needing to dig out the CD again (which may have further degraded in storage).\nMeanwhile, trying to recovering damaged CDs, and damaged filesystems, is a lot more complicated than you'd expect.\nSo, here's what I'd do:\nBlock-copy the discs directly to .iso files (whether in Python, or with dd), and log all the ones that fail.\nHash the .iso files, not the filesystems. If you really need to hash the filesystems, keep in mind that the common optimization of compression the data before hashing (that is, tar czf - | shasum instead of just tar cf - | shasum) usually slows things down, even for easily-compressable data\u2014but you might as well test it both ways on a couple discs. If you need your verification to be legally useful you may have to use a timestamped signature provided by an online service, instead, in which case compressing probably will be worthwhile.\nFor each successful .iso file, mount it and use basic file copy operations (whether in Python, or with standard Unix tools), and again log all the ones that fail.\nGet a free or commercial CD recovery tool like IsoBuster (not an endorsement, just the first one that came up in a search, although I have used it successfully before) and use it to manually recover all of the damaged discs.\nYou can do a lot of this work in parallel\u2014when each block copy finishes, kick off the filesystem dump in the background while you're block-copying the next drive.\nFinally, if you've got 1500 discs to recover, you might want to invest in a DVD jukebox or auto-loader. I'm guessing new ones are still pretty expensive, but there must be people out there selling older ones for a lot cheaper. (From a quick search online, the first thing that came up was $2500 new and $240 used\u2026)","Q_Score":3,"Tags":"python,backup,archive,cd,dvd","A_Id":19775252,"CreationDate":"2013-10-31T21:56:00.000","Title":"What is the best way to archive a data CD\/DVD in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Given a large 2d numpy array, I would like to remove a range of rows, say rows 10000:10010 efficiently. I have to do this multiple times with different ranges, so I would like to also make it parallelizable.\nUsing something like numpy.delete() is not efficient, since it needs to copy the array, taking too much time and memory. Ideally I would want to do something like create a view, but I am not sure how I could do this in this case. A masked array is also not an option since the downstream operations are not supported on masked arrays.\nAny ideas?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2948,"Q_Id":19719746,"Users Score":3,"Answer":"Because of the strided data structure that defines a numpy array, what you want will not be possible without using a masked array.  Your best option might be to use a masked array (or perhaps your own boolean array) to mask the deleted the rows, and then do a single real delete operation of all the rows to be deleted before passing it downstream.","Q_Score":8,"Tags":"python,numpy","A_Id":19719936,"CreationDate":"2013-11-01T02:07:00.000","Title":"How can one efficiently remove a range of rows from a large numpy array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Listmates:\nI am designing a google app engine (python) app to automate law office documents.\nI plan on using GAE, google docs, and google drive to create and store the finished documents.   My plan is to have case information (client name, case number, etc.) entered and retrieved using GAE web forms and the google datastore. Then I will allow the user to create a motion or other document by inserting the form data into template. \nThe completed document can be further customized by the user, email, printed, and\/or stored in a google drive folder.\nI found information on how to create a web page that can be printed.  However, I am looking for information for how to create an actual google doc and insert the form data into that document or template.\nCan someone point me to a GAE tutorial of any type that steps me through how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":559,"Q_Id":19745169,"Users Score":0,"Answer":"There is currently no API to create google docs directly except for:\n1) make a google apps script service, which does have access to the docs api.\n2) create a \".doc\" then upload and convert to gdoc.\n1 is best but a gas service has some limitations like quotas. If you are only creating dozens\/hundreds per day you will be ok with quotas. Ive done it this way for something similar as your case.","Q_Score":0,"Tags":"python,google-app-engine,google-docs-api","A_Id":19746281,"CreationDate":"2013-11-02T18:16:00.000","Title":"How can I automate google docs with Google App Engine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm only looking to format a specific string within a cell.  I change that cell's format to \"Markdown\" but I'm not sure how to change text color of a single word. \nI don't want to change the look of the whole notebook (via a CSS file).","AnswerCount":10,"Available Count":1,"Score":0.0199973338,"is_accepted":false,"ViewCount":244278,"Q_Id":19746350,"Users Score":1,"Answer":"This is a very simple and effective trick for google colab.\nUse the (empty) link syntax of the markdown.\n[your_message]()\nThen you'll get the blue text (underline).","Q_Score":155,"Tags":"jupyter-notebook,ipython,markdown","A_Id":71530683,"CreationDate":"2013-11-02T20:11:00.000","Title":"How to change color in markdown cells ipython\/jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a list of strings, where each string is in the format \"A - something\" or \"B - somethingelse\", and list items mostly alternate between pieces of \"A\" data and \"B\" data, how can irregularities be removed?\n\nIrregularities being any sequence that breaks the A B pattern.\nIf there are multiple A's, the next B should also be removed.\nIf there are multiple B's, the preceding A should also be removed.\nAfter removal of these invalid sequnces, list order should be kept.\n\nExample: A B A B A A B A B A B A B A B B A B A B A A B B A B A B\nIn this case, AAB (see rule 2), ABB (see rule 3) and AABB should be removed.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":188,"Q_Id":19747751,"Users Score":1,"Answer":"I'd write it as a generator. Repeat:\n\nread as many A's as possible,\nread as many B's as possible,\nif you've read exactly 1 A and 1 B, yield them; otherwise ignore and proceed.\n\nAlso this needs an additional special case in case you want to allow the input to end with an A.","Q_Score":4,"Tags":"python,list","A_Id":19747785,"CreationDate":"2013-11-02T22:45:00.000","Title":"How to maintain a strict alternating pattern of item \"types\" in a list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an existing django website, and I would like to sell some pdf files through it using paypal.  The buyer needs to be able to select 1 or more books, get transferred to the paypal site to enter in payment info.  Then after a successful payment, the buyer gets redirected back to my website and the books start downloading automatically. \nI have looked at the django-paypal and django-merchent apps, but I don't know how to handle the multiple downloads.  As far as I know, using these apps, after a successful purchase, the app sends a success signal, but doesn't tell me which books were ordered.\nWhat is the best way to implement this either with the django-paypal app or using some other method?  Again, I'm looking for the easiest\/quickest solution.\nThanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":19756725,"Users Score":0,"Answer":"With respect, the question is slightly naive, in that there is typically a separation between the shopping cart, and the payment processing.  A payment returns a binary result - it either worked or it didn't. It is up to your application to recall what was being paid for.\nThe Paypal API returns the success or failure of an identified payment; plus will happily consume a list of items you give it, so that the user is presented with a breakdown of the total amount.  But note that you are telling paypal what is being paid for. It is consuming that data, not providing it.\nSo the answer depends entirely upon your chosen solution (django-paypal or django-merchant or whatever).  Read their documentation.  Presumably there is some way to inspect the contents of a recently approved transaction. Cycle through the cart and enable a download of each.\nDjango-paypal, for example, has no interest of what is in the cart. It just fires a signal when a payment is successful, and passes back the transaction identifier.  Your application  must recall what the transaction was for.\nOften it's not as easy as you'd hope.","Q_Score":2,"Tags":"python,django,paypal,django-paypal","A_Id":21199468,"CreationDate":"2013-11-03T18:57:00.000","Title":"Easiest way to implement paypal shopping for e-books","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to create Validators for inputs on forms. I learned already that in wxPython it is necessary to inherit from wx.Validator due to lack of support for standard wxTextValidator and others.\nMy question is:\n\nhow effectively check that string complies to simple rules (no regexp please)\nacceptableChars = ['a', 'b', ...]\nall(char in acceptableChars for char in string)\nis something like this efficient? and how to cleanly specify all alphanumeric or digits? or maybe is there any ready class or function?\nwill overriding Validate method only keep the constraints while inputing data - I mean  will it prevent user from entering digits into alphanumerical TextCtrl or will it check only at closing the modal diagog?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":19759096,"Users Score":1,"Answer":"Validate() is called only when the dialog is about to close by default, but you may also call it yourself when the control loses focus. Finally, if your control doesn't accept some characters at all, you can also intercept wxEVT_CHAR events to prevent them from being entered. I do believe wxPython demo shows how to do it.","Q_Score":0,"Tags":"python,wxpython,wxwidgets","A_Id":19760286,"CreationDate":"2013-11-03T22:42:00.000","Title":"Validating data in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking to run a file I created in python from a matlab script. I have checked that my python file works if I run it from the python interface. However I have not been able to get my python to run from matlab. The following is the code situation I am in.\nIn matlab., I have the following code:(My file name is pgcode.py)\n! python pgcode.py\nand interchangeably I have use this code as well:\nsystem('python pgcode.py')\nThe error that results in matlab is:\n\"python: can't open file 'pgcode.py': [Errno 2] No such file or directory\" \nI have set my PATH directory and I really think this is an issue with setting the path so that I can find the file I have created but I haven't been able to figure out how to do this. I am using windows and Python 2.7.5. Any help is much appreciated. Thanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":746,"Q_Id":19761351,"Users Score":1,"Answer":"Your $PATH should control where python comes from, but I don't believe it will control where your pgcode.py comes from - at least, not in the way you're using it now.\nYou might want to either use a #!\/usr\/bin\/env python and make your script executable, or be very mindful of what directory you're in when you try to python pgcode.py (you can prepend \"pwd;\" to your python command to see), or specify a full path to pgcode.py.\nHTH","Q_Score":0,"Tags":"python,matlab,python-2.7,path,directory","A_Id":19761894,"CreationDate":"2013-11-04T03:47:00.000","Title":"Run Python file from matlab .m file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have several django projects and they work well on my desktop. But when I run them on my laptop, they run ok for sometime. Then on a random occasion, opening a page won't work. The browser keeps trying to load the page (title tab keeps spinning, URL changes to the page its trying to open, and the page turns blank), while the development server (django on windows shell) says it has successfully served the page (200 status).\nThis behavior is consistent among Firefox, IE and Chrome. I tried changing ports, using machine IP instead of localhost, loading static files on external server, but nothing works. I tried opening the site (using laptop computer name) from desktop browsers and behaves the same. Another interesting thing is, even if I shutdown and restart the django server, I wont be able to open the page that have failed previously unless I close the loading page.\nMy laptop is running a basic Windows 8, while desktop is Windows 8 Pro. I think the windows version has something to do with it.\nDoes anyone know how to solve this? I hope I made myself clear. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":908,"Q_Id":19761898,"Users Score":0,"Answer":"It is hard to tell whether the issue is related to Windows specifically, rather than compatibility issues with images\/CSS\/Javascript\/plugins such as Flash. Are you running the latest versions of those browsers (or at least the same versions as on your desktop)? Do you have different security software\/firewalls? Do other sites load inconsistently? Seems unlikely to be a Django issue (although you can try loading sites like djangoproject.com).","Q_Score":0,"Tags":"python,django,windows","A_Id":19762217,"CreationDate":"2013-11-04T05:01:00.000","Title":"Why does django stops loading a page after opening several pages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a newbie in this field. My laptop is Macbook air, Software: OS X 10.8.5 (12F45). I am running a code which gives me the following error:\n\ndlopen(\/Users\/ramesh\/offline\/build_icerec\/lib\/icecube\/phys_services.so, 2): Library not loaded: \/Users\/ramesh\/offline\/build_icerec\/lib\/libphys-services.dylib\n    Referenced from: \/Users\/ramesh\/offline\/build_icerec\/lib\/icecube\/phys_services.so\n    Reason: image not found\n\nI did google search and found variety of answers. I think the one that works is to use \n\n\" -install_name @rpath\/lib \". \n\nMy question is, how to use -install_name @rpath\/lib in my case?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27135,"Q_Id":19776571,"Users Score":30,"Answer":"Shared object location under OS X is sometimes tricky. When you directly call dlopen() you have the freedom of specifying an absolute path to the library, which works fine. However, if you load a library which in turn needs to load another (as appears to be your situation), you've lost control of specifying where the library lives with its direct path.\nThere are environment variables that you could set before running your main program that tell the dynamic loader where to search for things. In general these are a bad idea (but you can read about them via the man dyld command on an OS X system).\nWhen an OS X dynamic library is created, it's given an install name; this name is embedded within the binary and can be viewed with the otool command. otool -L mach-o_binary will list the dynamic library references for the mach-o binary you provide the file name to; this can be a primary executable or a dylib, for example.\nWhen a dynamic library is statically linked into another executable (either a primary executable or another dylib), the expected location of where that dylib being linked will be found is based on the location written into it (either at the time it was built, or changes that have been applied afterwards). In your case, it seems that phys_services.so was statically linked against libphys-services.dylib. So to start, run otool -L phys_services.so to find the exact expectation of where the dylib will be.\nThe install_name_tool command can be used to change the expected location of a library. It can be run against the dylib before it gets statically linked against (in which case you have nothing left to do), or it can be run against the executable that loads it in order to rewrite those expectations. The command pattern for this is install_name_tool -change <old_path> <new_path> So for example, if otool -L phys_services.so shows you \/usr\/lib\/libphys-services.dylib and you want to move the expectation as you posed in your question, you would do that with install_name_tool -change \/usr\/lib\/libphys-services.dylib @rpath\/lib\/libphys-services.dylib phys_services.so.\nThe dyld man page (man dyld) will tell you how @rpath is used, as well as other macros @loader_path and @executable_path.","Q_Score":12,"Tags":"macos,error-handling,ipython,dlopen","A_Id":22560206,"CreationDate":"2013-11-04T20:31:00.000","Title":"Error: dlopen() Library not loaded Reason: image not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a script that I am running at \/var\/scripts\/SomeAppName\/source\/importer\/processor.py\nThat script triggers an error that has a line that says:\nFile \"build\/bdist.linux-i686\/egg\/something\/cms\/browser.py\", line 43, in GetBrowser \nThe problem I'm running into is that I'm unable to locate build\/bdist.linux-i686\/egg\/something\/cms\/browser.py but I can locate \/var\/scripts\/AnotherApp\/appcommon\/cms\/browser.py and \/var\/scripts\/AnotherApp\/build\/lib\/appcommon\/cms\/browser.py \nI have modieified both of those files to remove the part that is throwing the error but am still getting the same error as if the file hasn't been modified at all.\nI'm guessing the problem is that I'm not modifying the correct file or I need to compile the script some how but I'm just not able to find out where\/how to do this.\nI have tried restarting apache but with no luck.\nAny help or guidance as to where I should be looking or if I need to run some sort of command to re-compile to browser.py file would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":40,"Q_Id":19779371,"Users Score":1,"Answer":"Closing the loop: bdist in the path is a sign that the package was installed with setup.py install and is running from the standard Python system path, not from wherever you have it checked out.\nEasy fix is to setup.py install it again.\nHarder fix is to uninstall it and fiddle with Apache's working directory, but that's not quite my area.  :)","Q_Score":0,"Tags":"python,command-line,compiler-construction,command-line-interface,python-2.6","A_Id":19783232,"CreationDate":"2013-11-04T23:36:00.000","Title":"I can't locate correct Python script to update","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Pressing command-H in OSX immediately hides the active window. How do I achieve the same effect, programmatically, from Python? Specifically, I'd like to find a particular window that my application creates and then be able to show & hide it programmatically.\nI already know how to do this with pywin32 but I'm afraid my expertise there doesn't quite cover OSX as well.\nIf it helps, the window in question is one created by pygame. I know that pygame has pygame.display.iconify() but that doesn't satisfy my requirements - the window doesn't disappear immediately, but rather the disappearance is animated, and there's no corresponding \"uniconify\" function that I can find.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":819,"Q_Id":19787324,"Users Score":0,"Answer":"Well, this ended up working. When I want to hide the window, I do pygame.display.quit() and make my code properly handle not having a display. When I want to show it, I do pygame.display.set_mode(...) with the former resolution. \nThe net effect is that of hiding & showing the window. Unfortunately the window gets created in a different spot than where it started, and although apparently you can tell SDL to create the window in a particular spot, I haven't been able to find a way to get the window's location...","Q_Score":1,"Tags":"python,macos,user-interface,pygame","A_Id":19800717,"CreationDate":"2013-11-05T10:55:00.000","Title":"hide pygame window on OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using pandas to get hourly data from a dataset with fifteen minute sampling intervals.  My problem using the resample('H', how='ohlc') method is that it provides values within that hour and I want the value closest to the hour.  For instance, I would like to take a value sampled at 2:55 instead of one from 3:10, but can't figure out how to find the value that is closest if it occurs prior to the timestamp being evaluated against.\nAny help would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":630,"Q_Id":19799893,"Users Score":0,"Answer":"I suppose you could create another column that is the Hour and subtract the time in question and get the absolute (unsigned) value that you could then do the min function on.. It is not code but I think the logic is right (or at least close.. after you find the mins,, then you can select them and then do your resample..","Q_Score":1,"Tags":"python,pandas","A_Id":19800482,"CreationDate":"2013-11-05T21:59:00.000","Title":"Using Pandas to get the closest value to a timestamp","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a forms.ModelForm to set a model's attributes.  For one of the attributes, I'd like to set a default value, and I want to handle it in the form, thus no default=value on the model attribute in the model class.\nOn the form, though, I don't want to show the user the value, not even a hidden value, therefore, I can't put the field in fields=(...) and because of that, I can't use the field.initial=value way of setting the default.  \nI could override validation or saving methods and squeeze a attribute setting in there, but this is not what I would prefer to do.\nAre there any \"proper\" or more elegant ways of solving this problem?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6103,"Q_Id":19815949,"Users Score":0,"Answer":"if you just want to set an initial value in the form,\nform = MyForm(initial={'field': field_var})","Q_Score":4,"Tags":"python,django","A_Id":65434713,"CreationDate":"2013-11-06T15:23:00.000","Title":"How to set form field default value without showing the field in django forms?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to get the installed path of python?\nAny idea how to get the python installed path from command line in windows. I don't want to set the environment variable?\nThanks,","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":85755,"Q_Id":19829516,"Users Score":2,"Answer":"You can check registry by: \nHKLM SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION}\\InstallPath\nor HKCU","Q_Score":30,"Tags":"python,windows,python-2.7,cmd","A_Id":19829607,"CreationDate":"2013-11-07T06:39:00.000","Title":"how to get python installed path from command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to automate closing the remote desktop application using python. I open the remote desktop using mstsc. When I do\nos.system(\"TASKKILL \/F \/IM mstsc.exe\")\nIt is killing all the remote desktop applications that are open. Is there a way I can specify through python which remote desktop it has to close.\nI have 2 or more instances of remote desktop open and I require my program to close only specific connection. Is there a way I can pass the IP address or process ID or something.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1415,"Q_Id":19854866,"Users Score":0,"Answer":"To close one of the mstsc, you should know the pid of it. If you are opening mstsc.exe from a python script itself, then you could capture the pid of that instance.\np = Popen('C:\\Windows\\System32\\mstsc.exe \"connection.rdp\"')\nprint p.pid\nThen kill the exe using pid.","Q_Score":1,"Tags":"python,desktop,os.system,mstsc","A_Id":29933838,"CreationDate":"2013-11-08T08:47:00.000","Title":"how to close remote desktop window using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to develop GUI for a who wants to be a millionaire game using pygame. If the user is presented with the welcome screen and clicks new game, it should clear the welcome screen and bring up the main game screen.\nI tried using os.system('xxx.py') but it doesnt stay on, it just flashes and goes off. \nAny ideas on how to make this work?\nThanks in anticipation.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":208,"Q_Id":19864484,"Users Score":3,"Answer":"You probably shouldn't be trying to launch a new instance of your game. You should create a reset method which can be called to restart everything. It would clear all variables, set the game state back to the start, etc.","Q_Score":0,"Tags":"python,pygame","A_Id":19864546,"CreationDate":"2013-11-08T16:55:00.000","Title":"Clear previous screen to show next screen pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've built a small project on my system.\nAfter building the project, I put it on a USB drive, and copied to another system.\nWhen I run the project, how can it detect if django is installed in the system or if the system has all of the the requirements for the project?\nFor example, I made a blog example project on a laptop, then copied that project(blog) onto a USB drive and then I copied that project(blog) to my own system. After copying, I tried to run the project. If django is installed then the project runs successfully. But when django is not installed it gives an error in the terminal. \nHow can the program detect if the required (Django\/Python) is installed or not?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":262,"Q_Id":19883186,"Users Score":1,"Answer":"Simply the module won't be found when you try to run your project.\nYou can run 'python' in your command line and try to 'import django' if it returns an error then django isn't found it means that django isn't installed on the current machine.","Q_Score":4,"Tags":"python,django","A_Id":19883259,"CreationDate":"2013-11-09T21:15:00.000","Title":"How can a django project detect if the system has django installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am still working on my text editor, and now I want to make it run faster. So I thought I may somehow get currently visible text, and parse it as I want. So is there a way to get currently visible lines?\nP.S. Or maybe there is another way to increase StyledTextCtrl's performance? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":273,"Q_Id":19896965,"Users Score":2,"Answer":"Use GetFirstVisibleLine() to determine the first visible line. Lines are numbered starting at zero.\nUse LinesOnScreen() to determine how many lines are visible on the screen.\nYou can use GetLine(line) to get a string of an individual line.","Q_Score":2,"Tags":"python,performance,wxpython,scintilla","A_Id":19897133,"CreationDate":"2013-11-11T00:16:00.000","Title":"wxPython - StyledTextCtrl get currently visible lines","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I accustomed of using WTForms by means of Flask-WTF in my flask application. Doing server side validation is trivial. But how do I leverage this server validation to become a field level, ajax, client side validation? So, when user tab to another input fields, my application can directly goes on validating it and give validation warning\/info\/error.\nI haven't found a resource in the internet yet","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":8644,"Q_Id":19898967,"Users Score":3,"Answer":"A great question. This is what we do (flask backend, jquery frontend):\n\nuse jquery.forms plugin to ajax forms. Pretty solid mature code. Shortcoming, cannot send json encoded data, only form-urlencoded. Receives plain or json data. \nuse wtfroms for form validation. Very mature codebase.\ntried to use wtforms-json for accepting json, very screwy problems.","Q_Score":16,"Tags":"python,flask,wtforms,flask-wtforms","A_Id":25145753,"CreationDate":"2013-11-11T04:42:00.000","Title":"How to use WTForms in Ajax validation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new on Raspberry Pi and I would to know how can we simulate\/mock the sensors (or GPIO) so I can test just my python code, mocking the Highs and Lows of the pins? \nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6042,"Q_Id":19913092,"Users Score":1,"Answer":"IF you just don't want to trust a software layer, you could try manually setting the pin high:\nThe GPIO pins on the Raspberry Pi work with a voltage of 3.3VDC.\nPins 1 & 17 on the P1-GPIO header outputs 3.3VDC.\nYou could CAREFULLY try to connect a jumper from Pin 1 or 17 to the GPIO input pin you want to test.  Connect it to test high, disconnect to test for low.\nMAKE SURE YOU DON\"T USE THE 5VDC GPIO PINS, YOU COULD\/WILL DAMAGE\/KILL YOUR PI!","Q_Score":5,"Tags":"python,mocking,simulation,raspberry-pi,gpio","A_Id":25086750,"CreationDate":"2013-11-11T18:17:00.000","Title":"Simulate Raspberry Pi GPIO signal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been recently working with Python, and I wish to make a program that tells me how long was the last time I inputted something without it closing (e.g. The first thing I input is the word \"foo\". After 15 minutes, I input foo again, so the program prints that I last inputted the word foo 15 minutes ago).\nAny ideas on how to make such a script? (Thanks in advance)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":19920246,"Users Score":0,"Answer":"Do you mean to tell you the last time you entered anything or a specific word?\nIf it's a specific one, make a dictionary where you use words as keys, and then store the time there.","Q_Score":0,"Tags":"python-2.7","A_Id":19920270,"CreationDate":"2013-11-12T03:18:00.000","Title":"Permanent timer on Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've created a form in Qt Creator 4 and 'compile' it to python module with pyuic4. Everything is ok but when I call the class represented my for it contains over 20 form elements as a public members (including Spacers etc.). But I need only 5 of them. It's not fatal but annoying... Is there a way to declare an element in Qt Creator as private\/hidden? I mean it has to be done in Qt Creator because if I'll make any changes and recompile .ui file all changes in .py file would be overwritten.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":19939598,"Users Score":0,"Answer":"The pyuic tool uses the objectName to generate the names of the top-level class and its members. So to make a member \"private\", just prepend some underscores to the objectName property in the designer component.","Q_Score":0,"Tags":"python,qt,pyqt,pyqt4","A_Id":19943638,"CreationDate":"2013-11-12T20:50:00.000","Title":"Qt Creator: how to hide members?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to have .aspx  and .aspx.py (IronPython codefile) nested underneath aspx files in VS 2010 ? I've seen some people added Windows registry entries for Visual Studio so other files would show up as nested underneath aspx, but I've no idea how to do it for IronPython if possible","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":19952513,"Users Score":0,"Answer":"I found the solution just in case someone needs the same, for websites which is what I needed (for web applications is easier because there's an installable tool)\nAdd a registry entry key \".py\" in \nHKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0_Config\\Projects{E24C65DC-7377-472b-9ABA-BC803B73C61A}\\RelatedFiles.aspx","Q_Score":0,"Tags":"asp.net,visual-studio-2010,ironpython","A_Id":20004327,"CreationDate":"2013-11-13T11:25:00.000","Title":"Visual Studio file nesting aspx - aspx.py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've developed a small write-only REST api with Flask Restful that accepts PUT request from a handful of clients that can potentially have changing IP addresses. My clients are embedded Chromium clients running an AngularJS front-end; they authenticate with my API with a simple magic key -- it's sufficient for my very limited scale. \nI'm testing deploying my API now and I notice that the Angular clients are attempting to send an OPTIONS http methods to my Flask service. My API meanwhile is replying with a 404 (since I didn't write an OPTIONS handler yet, only a PUT handler). It seems that when sending cross-domain requests that are not POST or GET, Angular will send a pre-flight OPTIONS method at the server to make sure the cross-domain request is accepted before it sends the actual request. Is that right?\nAnyway, how do I allow all cross-domain PUT requests to Flask Restful API? I've used cross-domaion decorators with a (non-restful) Flask instance before, but do I need to write an OPTIONS handler as well into my API?","AnswerCount":9,"Available Count":2,"Score":0.1106561105,"is_accepted":false,"ViewCount":58328,"Q_Id":19962699,"Users Score":5,"Answer":"Just an update to this comment. Flask CORS is the way to go, but the flask.ext.cors is deprecated.\nuse:\n\nfrom flask_cors import CORS","Q_Score":47,"Tags":"python,angularjs,flask,cors,flask-restful","A_Id":47288580,"CreationDate":"2013-11-13T19:31:00.000","Title":"Flask RESTful cross-domain issue with Angular: PUT, OPTIONS methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've developed a small write-only REST api with Flask Restful that accepts PUT request from a handful of clients that can potentially have changing IP addresses. My clients are embedded Chromium clients running an AngularJS front-end; they authenticate with my API with a simple magic key -- it's sufficient for my very limited scale. \nI'm testing deploying my API now and I notice that the Angular clients are attempting to send an OPTIONS http methods to my Flask service. My API meanwhile is replying with a 404 (since I didn't write an OPTIONS handler yet, only a PUT handler). It seems that when sending cross-domain requests that are not POST or GET, Angular will send a pre-flight OPTIONS method at the server to make sure the cross-domain request is accepted before it sends the actual request. Is that right?\nAnyway, how do I allow all cross-domain PUT requests to Flask Restful API? I've used cross-domaion decorators with a (non-restful) Flask instance before, but do I need to write an OPTIONS handler as well into my API?","AnswerCount":9,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":58328,"Q_Id":19962699,"Users Score":36,"Answer":"You can use the after_request hook:\n\n@app.after_request\ndef after_request(response):\n    response.headers.add('Access-Control-Allow-Origin', '*')\n    response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')\n    response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')\n    return response","Q_Score":47,"Tags":"python,angularjs,flask,cors,flask-restful","A_Id":28923164,"CreationDate":"2013-11-13T19:31:00.000","Title":"Flask RESTful cross-domain issue with Angular: PUT, OPTIONS methods","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm curious about this, from a performance point of view only, how do their differ considering the proper use?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":346,"Q_Id":19965270,"Users Score":1,"Answer":"They don't differ in performance at all.","Q_Score":1,"Tags":"python,django","A_Id":19967173,"CreationDate":"2013-11-13T22:00:00.000","Title":"Performance: Class Based Views VS Function Based Views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I see what is the version of the python-mosquitto package used by my program?  How do I find an old version of python-mosquitto (version 0.15) and remove it?\nI'm running on Raspberry Pi, raspian","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3471,"Q_Id":19975234,"Users Score":1,"Answer":"If you are using pip, use pip freeze | grep 'python-mosquitto' to get the package version, and pip remove python-mosquitto to remove it.","Q_Score":0,"Tags":"python,raspberry-pi,mqtt,mosquitto","A_Id":19975285,"CreationDate":"2013-11-14T10:28:00.000","Title":"how to find python-mosquitto version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am familiar with Selenium using C# and integrating it with TeamCity - as a background.  I am at a new company now.  We have HP Quality Center and I saw a few articles how to use QC, Selenium, and Python Script to automate tests.  I am having a major issue even getting a basic TDOutput.Print(\"test\") to show up in the output log, unless I am wrong in expecting any TDOutput.Print lines to show up in that space.\nI have a Windows 7 box.\nThe steps I have followed are:\n\ninstalled Python on my machine (2.7) \ninstalled steuptools \ninstalled pip I can install items using pip on the command line, including\nselenium In QC\nI create a new VAPI-XP test  \nChoose PythonScript in the Wizard \nThen click Finish (and do not go any further on the wizard) \nQuality Center will then generate a skeleton script. \nIn the skeleton, Under TDOutput.Clear(), I type: TDOutput.Print(\"Hello\nWorld\") \nThe output window never clears and it never prints \"Hello\nWorld\" \nThis is what I see in output window: Test is completed\n\nAny suggestions on what easy step I have missed?  I obviously do not have a lot of experience with this tool so its hard for me to see why I can't even get a print statement to execute - let alone worry about the selenium portion of my testing.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":791,"Q_Id":19986604,"Users Score":1,"Answer":"I found an article by fijiaaron that let me know even if you\/I have a 64 bit machine, we need the 32 bit version of Python installed, as soon as I installed the 32 bit version, I was able to see the print lines.  Now on to the selenium...","Q_Score":0,"Tags":"python-2.7,hp-quality-center","A_Id":19987148,"CreationDate":"2013-11-14T19:29:00.000","Title":"HP Quality Center Python Tests not executing any lines of script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have mac os x, recently I have install python version 3.2 before I had version 2.6.1. but when I type \"python\" in terminal it prints Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49). what does it mean? how can I use python 3.2 that have install this week?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":19986895,"Users Score":0,"Answer":"instead of using python I typed python3 in terminal and it was the solution","Q_Score":0,"Tags":"python,python-3.x","A_Id":19987194,"CreationDate":"2013-11-14T19:45:00.000","Title":"install new version of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to attach a user to a request, this seems like a fairly common thing to need to do, but it's turning out to be damn near impossible.\nThe docs for the Django REST Framework suggest using the pre_save method of the serializer class, which I did, but it doesn't get called when serializer.is_valid() is called, which makes it kind of worthless since without the user field the serializer fails validation.\nI've seen a few suggestions but they seem like crazy hacks and\/or don't work. Plus, I feel like this is way too common of a task to really need all the stuff I see people suggesting. I can't be the only person to need to attach a user to a object created in a REST request.","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9143,"Q_Id":19993951,"Users Score":2,"Answer":"It turned out the problem was that I was using ListAPIView as the base class for my view class and it doesn't have the pre_save method defined. When I added some of the mixins which had it defined everything started working.\nSeems weird that something used in a lot of the basic tutorials doesn't support such a basic feature, but live and learn.","Q_Score":11,"Tags":"python,django,rest,django-rest-framework","A_Id":22542900,"CreationDate":"2013-11-15T05:08:00.000","Title":"Django REST Framework, pre_save() and serializer.is_valid(), how do they work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have multiple users in django auth setup and a few simple models.\nFor superusers I can view my model objects. For non superusers that have is_staff checked I get\na 403 Permission denied when trying to view my models.\nI have tried adding all permissions to those users to find out if that was the cause but still receive the forbidden message. Other than making them superusers I can't assign any more permissions.\nOn the command line where I'm running the development server I see messages like\n\"GET \/admin\/bcp\/buildingsensor\/24\/ HTTP\/1.1\" 403 190614\nDoes anyone know how to get a more useful traceback for this so I know where to start looking. ?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6383,"Q_Id":20010125,"Users Score":1,"Answer":"If you're using Firefox (or any browser) with Web Developer Toolbar, make sure you have cookies enabled. I temporarily had cookies turned off and forgot to turn it back on.\nCookies => Disable Cookies => Disable All Cookies\nSolved my problem in Django 1.9.","Q_Score":2,"Tags":"python,django","A_Id":36814048,"CreationDate":"2013-11-15T20:36:00.000","Title":"Finding the cause of of 403 forbidden error in django admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to place group of buttons ontop of a QLabel showing image, the question is how do I animate the fade in visibility of the QButtonGroup, I want to place my buttons at the bottom area so whenever pointer is at the bottom area the button group should animate to fully visible but if I move the pointer out of the bottom area, the button group should animate to a gradual fade out.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":20026876,"Users Score":0,"Answer":"I did same thing with QLabels, QButtons and other Widgets. There are different solutions accordingly on what you need. In my case I just created a custom component with a QTimer and a QGraphicsOpacityEffect. The timer increases or decreases the opacity value (by a coefficient)..","Q_Score":0,"Tags":"python,qt,pyqt4,fadein","A_Id":20217728,"CreationDate":"2013-11-17T03:33:00.000","Title":"animate visibility of QButtonGroup or layout containing it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am now using Django frame work to build a website which has the ability to control a remote embedded system (simply with functions like \"Turn ON\/OFF\"). What i can image now is to use Socket Programming with Python (because Django is pure Python). As i have learnt, i only know how to send and receive messages with sockets between the client machine and server. \nCan any one tell me \n1. What else is needed to learn for this remote control function? \n2. Or is there any better ways (better frameworks) to implement this?\n3. Dose Django have built in methods for Socket Programming? (If not, is it possible to implement it with self-defined app)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":20039657,"Users Score":0,"Answer":"You basically have one major thing to decide:\n\nIs your embedded machine going to open up a port that allows any\nthing that knows it's IP and port details to control it and your web\npage write to that IP\/Port OR\nIs your embedded device going to poll the web app to find out which\nstate it should be in.\n\nThe first option will normally respond faster but your embedded machine will be more vulnerable to outside interference, you will need to be able to run active code on your web server, which a lot of servers do not allow, etc.\nThe second will only respond to state changes at an average of half the polling rate but will probably be simpler to program and manage.  Plus your server is not also acting as a client.","Q_Score":0,"Tags":"python,django,sockets,web,remote-server","A_Id":20039992,"CreationDate":"2013-11-18T03:36:00.000","Title":"Remote control of an embedded system from Website","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry, but I really don't know what's the meaning of the defination of round in python 3.3.2 doc:\n\nround(number[, ndigits])\n  Return the floating point value number rounded to ndigits digits after the decimal point. If ndigits is omitted, it defaults to zero. Delegates to number.__round__(ndigits).\nFor the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus ndigits if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). The return value is an integer if called with one argument, otherwise of the same type as number.\n\nI don't know how come the multiple of 10 and pow.\nAfter reading the following examples, I think round(number,n) works like:\nif let number be 123.456, let n be 2\n\nround will get two number:123.45 and 123.46\nround compares abs(number-123.45) (0.006) and abs(number-123.46) (0.004),and chooses the smaller one.\nso, 123.46 is the result.\n\nand if let number be 123.455, let n be 2:\n\nround will get two number:123.45 and 123.46\nround compares abs(number-123.45) (0.005) and abs(number-123.46) (0.005). They are equal. So round checks the last digit of 123.45 and 123.46. The even one is the result.\nso, the result is 123.46 \n\nAm I right?\nIf not, could you offer a understandable version of values are rounded to the closest multiple of 10 to the power minus ndigits?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":675,"Q_Id":20048986,"Users Score":2,"Answer":"It helps to know that anything to the power of 0 equals 1. As ndigits increases, the function:\nf(ndigits) = 10-ndigits gets smaller as you increase ndigits. Specifically as you increase ndigits by 1, you simply shift the decimal place of precision one left. e.g. 10^-0 = 1, 10^-1 = .1 and 10^-2 = .01. The place where the 1 is in the answer is the last point of precision for round.\nFor the part where it says \n\nFor the built-in types supporting round(), values are rounded to the\n  closest multiple of 10 to the power minus ndigits; if two multiples\n  are equally close, rounding is done toward the even choice (so, for\n  example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2).\n\nThis has unexpected behavior in Python 3 and it will not work for all floats. Consider the example you gave, round(123.455, 2) yields the value 123.45. This is not expected behavior because the closest even multiple of 10^-2 is 123.46, not 123.45!\nTo understand this, you have to pay special attention to the note below this:\n\nNote The behavior of round() for floats can be surprising: for\n  example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This\n  is not a bug: it\u2019s a result of the fact that most decimal fractions\n  can\u2019t be represented exactly as a float.\n\nAnd that is why certain floats will round to the \"wrong value\" and there is really no easy workaround as far as I am aware. (sadface) You could use fractions (i.e. two variables representing the numerator and the denominator) to represent floats in a custom round function if you want to get different behavior than the unpredictable behavior for floats.","Q_Score":3,"Tags":"python,rounding","A_Id":20049872,"CreationDate":"2013-11-18T13:27:00.000","Title":"python 3.3.2 do I get the right understanding of the function \"round\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a web app in Python (Flask) that, essentially, shows the user information from a PostgreSQL database (via Flask-SQLAlchemy) in a random order, with each set of information being shown on one page. Hitting a Next button will direct the user to the next set of data by replacing all data on the page with new data, and so on.\nMy conundrum comes with making the presentation truly random - not showing the user the same information twice by remembering what they've seen and not showing them those already seen sets of data again.\nThe site has no user system, and the \"already seen\" sets of data should be forgotten when they close the tab\/window or navigate away.\nI should also add that I'm a total newbie to SQL in general.\nWhat is the best way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":512,"Q_Id":20072309,"Users Score":1,"Answer":"The easiest way is to do the random number generation in javascript at the client end...\nTell the client what the highest number row is, then the client page keeps track of which ids it has requested (just a simple js array).  Then when the \"request next random page\" button is clicked, it generates a new random number less than the highest valid row id, and providing that the number isn't in its list of previously viewed items, it will send a request for that item.\nThis way, you (on the server) only have to have 2 database accessing views:\n\nmain page (which gives the js, and the highest valid row id)\ndisplay an item (by id) \n\nYou don't have any complex session tracking, and the user's browser is only having to keep track of a simple list of numbers, which even if they personally view several thousand  different items is still only going to be a meg or two of memory.\nFor performance reasons, you can even pre-fetch the next item as soon as the current item loads, so that it displays instantly and loads the next one in the background while they're looking at it. (jQuery .load() is your friend :-) )\nIf you expect a large number of items to be removed from the database (so that the highest number is not helpful), then you can instead generate a list of random ids, send that, and then request them one at a time.  Pre-generate the random list, as it were.\nHope this helps! :-)","Q_Score":1,"Tags":"python,sql,flask,flask-sqlalchemy","A_Id":20081554,"CreationDate":"2013-11-19T13:03:00.000","Title":"Best way to show a user random data from an SQL database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way I've done it before, which is:\n\nDownload pyserial from pypi \nuntar pyserial.tgz\ncd pyserial\npython3 setup.py install\n\nBut I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.","AnswerCount":16,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":296833,"Q_Id":20082935,"Users Score":12,"Answer":"brew install python3\ncreate alias in your shell profile\n\neg. alias pip3=\"python3 -m pip\" in my .zshrc\n\n\n\u279c  ~ pip3 --version\npip 9.0.1 from \/usr\/local\/lib\/python3.6\/site-packages (python 3.6)","Q_Score":140,"Tags":"python,macos,python-3.x,pip,python-3.3","A_Id":45603115,"CreationDate":"2013-11-19T21:57:00.000","Title":"How to install pip for Python 3 on Mac OS X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way I've done it before, which is:\n\nDownload pyserial from pypi \nuntar pyserial.tgz\ncd pyserial\npython3 setup.py install\n\nBut I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.","AnswerCount":16,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":296833,"Q_Id":20082935,"Users Score":4,"Answer":"pip is installed automatically with python2 using brew:\n\nbrew install python3\npip3 --version","Q_Score":140,"Tags":"python,macos,python-3.x,pip,python-3.3","A_Id":52130224,"CreationDate":"2013-11-19T21:57:00.000","Title":"How to install pip for Python 3 on Mac OS X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way I've done it before, which is:\n\nDownload pyserial from pypi \nuntar pyserial.tgz\ncd pyserial\npython3 setup.py install\n\nBut I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.","AnswerCount":16,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":296833,"Q_Id":20082935,"Users Score":0,"Answer":"For a fresh new Mac, you need to follow below steps:-\n\nMake sure you have installed Xcode\nsudo easy_install pip\n\/usr\/bin\/ruby -e \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/master\/install)\"\n\nbrew doctor\n\nbrew doctor\nbrew install python3\n\nAnd you are done, just type python3 on terminal and you will see python 3 installed.","Q_Score":140,"Tags":"python,macos,python-3.x,pip,python-3.3","A_Id":55175708,"CreationDate":"2013-11-19T21:57:00.000","Title":"How to install pip for Python 3 on Mac OS X?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So basically, I'm going to make a Brick Breaker type of game.  Just my beginning CS Python class didn't teach much OO programming, and I was wondering how I could make this free moving ball register when it hits the slider.  I think I have an idea, but I would like to see other peoples explanations.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":147,"Q_Id":20086958,"Users Score":0,"Answer":"You know the position of the two objects that can collide and compute the distance. When this is smaller than a threshold then they collide\nYou use the Canvas.find_overlapping(*rectangle). to find out the figures on the canvas in a rectangle.\n\nI always prefer option 1. It helps dividing model and presentation to the user which do not always need to be linked.","Q_Score":0,"Tags":"python,canvas","A_Id":20093393,"CreationDate":"2013-11-20T03:47:00.000","Title":"How can I make one canvas object collside with another canvas object using Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have following problem. When i am trying to open Python game files which i downloaded from internet (on the cmd), then i cant run them, because my computer doesn't find pictures which are in code. Even though the main code and pictures are in the same folder.\nIf i insert full paths of the pictures locations, then everything is fine, but it takes too much time, with long code.\nSo, my question is, how could i make my computer to open picture files, without me inserting full paths.\nThanks if anyone could help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":20121794,"Users Score":0,"Answer":"Try looking at Relative Paths.\nAdditionally, without seeing your image loading code it is really quite hard to help you.","Q_Score":0,"Tags":"python,image,path,cmd,pygame","A_Id":20121823,"CreationDate":"2013-11-21T13:03:00.000","Title":"The paths of picture locations in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to know if specific version is outdated? I know I can use pip list -o, but this goes over all packages, and I would like to get only for specific version.\nthanks.\nEran","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":20128461,"Users Score":0,"Answer":"Ugly workaround:\ncreate virtualenv, install demanded package with pip, use pip list -o in both real environment and virtual one, compare output...","Q_Score":0,"Tags":"python,pip","A_Id":20129765,"CreationDate":"2013-11-21T17:57:00.000","Title":"how to find if specifc version is outdated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background knowledge: Website in Django run under apache. \nBriefly speaking, I need to call an .exe program in a windows machine from a Linux machine. \nThe reason for this is our website runs on Linux, but one module relies on Windows DLL. So we plan to put it on a separate windows server, and use some methods to call the exe program, and get the result back. \nMy idea is: setup a web service on that windows machine, post some data to it, let itself deals with the exe program, and return some data as response. Notice that request data and response data will both contains files. \nI wonder if there is any neater way for this? \nEDIT: Thanks for @fhs, I found I didn't make my main problem clearly enough. Yes, the webservice could work. But the main disadvantages for this is: basically, I need to post several files to windows; windows receive files, save them, call the program using these files as parameters, and then package the result files into a zip and return it. In linux, receive the file, unpack it to local file system. It's kind of troublesome. \nSo, is there any way to let both machines access the other one's files as easily as in local file system?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":20139979,"Users Score":0,"Answer":"I can think of some ways to do this:  \n\nUse web services with real REST protocol and cross-site scripting protection\nUse WINE (As OneOfOnes suggested in his comment)\nBut this is very risky for real production and might not work at all (or just when the load will become heavier) \nWrite some code in the windows machine and call this code using something like Zero-MQ (ZMQ) or similar product \n\nDepending on the way your are using this library, One solution can fit better than the others.\nFor most cases, I would suggest to go with ZMQ\nThis way you can use much more complex models of communication (subscription-subscribers, send-response, and more)\nAlso, using ZMQ would let you to scale in a very easy way if the need will come (you will be able to put few windows machines to process the requests)\nEdit:\nTo support file transfer between machines, you have few options as well.\n\nUse ZMQ. File can be just a stream of data.\nNo problem to support such a stream with ZMQ\nUse file server with some Enq. procedure\nEnq. can be done via ZMQ msg to inform the other side that the file is ready\nYou can use folder share instead of a file server, but sharing files on the windows machine will not be a scale-able solution  \nWindows program can send the file via FTP or SSH to the Linux server.\nOnce again, signaling (file ready, file name,...) can be done with ZMQ","Q_Score":0,"Tags":"python,linux,django,windows,apache","A_Id":20140905,"CreationDate":"2013-11-22T08:09:00.000","Title":"Calling exe in Windows from Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a server using python but the server can communicate with only one client at a time . Even if the server establish connection with more than one clients, it can't make conversation with all clients at the same time. \nOne client should wait until the started conversation end, which may last for several minutes. This problem would create Tremendous delay up on the client which hasn't started conversation. \nSo, how could I let my python server to communicate with more than one clients at the same time ? \nThank you in advance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":20172765,"Users Score":0,"Answer":"You may use Tornado. It is asynchronic multithreading web-server framework.","Q_Score":2,"Tags":"python,network-programming,client-server","A_Id":20173028,"CreationDate":"2013-11-24T08:55:00.000","Title":"how can I make a server communicate with more than 1 client at the same time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using nbconvert to produce something as close as possible to a polished journal article. \nI have successfully hidden input code using a custom nbconvert template. The doc is now looking very nice. \nBut I don't know how to suppress the bright red 'out[x]' statement in the top left corner of the output cells. Anyone know of any settings or hacks that are able to remove this also ?\nThanks, \nJohn","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":5150,"Q_Id":20184994,"Users Score":5,"Answer":"%%HTML\n<style>\ndiv.prompt {display:none}\n<\/style>\nThis will hide both In and Out prompts\nNote that this is only in your browser, the notebook itself isn't modified of course, and nbconvert will work just the same as before.\nIn case you want this in the nbconverted code as well, just put the <style>div.prompt {display:none}<\/style> in a Raw NBConvert cell.","Q_Score":8,"Tags":"ipython,ipython-notebook","A_Id":30234937,"CreationDate":"2013-11-25T04:53:00.000","Title":"ipython notebook nbconvert - how to remove red 'out[N]' text in top left hand corner of cell output?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I'm developing in Python I often want to debug a specific method, in which case it makes sense to call the method from the interactive console or debug interactive console. However, when a method is called from the interactive windows in PTVS, it doesn't stop at the break points in said method.\nIf it's possible, please tell me how to do it. If not, I would like to request this feature, and also to know if there is any quicker way to debug a specific method than calling it from the main script.\nI'm using PTVS 2.0 RC in Visual Studio 2013 Ultimate","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1144,"Q_Id":20198589,"Users Score":2,"Answer":"When using the regular (non-debug) Python Interactive window, you can actually attach VS to the python.exe process that it is running by using Debug -> Attach to Process. Once that is done, if the interactive window does something to e.g. hit a breakpoint, the debugger will hit on that breakpoint.\nThe tricky part is loading the code from a file in such a way that breakpoints are resolved. In particular, $load REPL command will not work because it just reads the file and evals it in the REPL line by line, without preserving the original file context. What you need is to load your script using Python facilities - e.g. import, or open+exec.\nThere are also some gotchas there - e.g. the REPL window will become unresponsive whenever you are paused on a breakpoint.","Q_Score":1,"Tags":"python,ptvs","A_Id":20203996,"CreationDate":"2013-11-25T16:49:00.000","Title":"Is it possible to debug a method called from the interactive window in PTVS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an efficient way to remove the first bit of a number in C++ \/ Python, assuming you don't know how large the number is or its datatype?\nI know in Python I can do it by getting the bin(n), truncating the string by 1, and then recasting it to an int, but I am curious if there is a more \"mathematical\" way to do this.\ne.g. say the number is 6, which is 110 in binary. Chop the first bit and it becomes 10, or 2.","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":9490,"Q_Id":20200295,"Users Score":5,"Answer":"looking at 110 (6 decimal)\nThe Most Significant bit is 100 (4 decimal)   \/\/ -- Note that this is always a power of 2\nCreate a mask: one less than the MSB is 011 (3 decimal)\nMask off the highest bit using bitwise-and: 110 & 011 = 10 (2 decimal)\nCalculating the MSB (Most Significant Bit) has been handled here and elsewhere quite often","Q_Score":5,"Tags":"c++,python","A_Id":20200392,"CreationDate":"2013-11-25T18:18:00.000","Title":"Removing first bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there an efficient way to remove the first bit of a number in C++ \/ Python, assuming you don't know how large the number is or its datatype?\nI know in Python I can do it by getting the bin(n), truncating the string by 1, and then recasting it to an int, but I am curious if there is a more \"mathematical\" way to do this.\ne.g. say the number is 6, which is 110 in binary. Chop the first bit and it becomes 10, or 2.","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":9490,"Q_Id":20200295,"Users Score":2,"Answer":"Well, you could create a loop in which you would double some variable (say x) in each iteration and then check whether this variable is greater than your number. If it is, divide it by two and subtract from your number. For example, if your number is 11:\n-first iteration: x=1<11, so continue\n-second iteration: x =2<11, so continue\n-third iteration: x=4<11, so continue\n-fourth iteration: x=8<11, so continue\n-fifth iteration: x=16>11, so divide x by two: x=8. Then subtract 8 from your number and get answer: \n11-8=3.","Q_Score":5,"Tags":"c++,python","A_Id":20200463,"CreationDate":"2013-11-25T18:18:00.000","Title":"Removing first bit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install bigfloat in Python 3.2 on a Windows 7 machine. The documentation says that I first need to install GMP and MPFR. I have downloaded both of these to my desktop (as well as the bigfloat package). However as they are C packages I am not sure how to install them in python (I have tried to find a clear explanation for the last several hours and failed). Can any one either tell me what I need to do or point me to a tutorial? Thanks a lot, any help is greatly appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4016,"Q_Id":20209874,"Users Score":1,"Answer":"There are two versions of gmpy - version 1 (aka gmpy) and version 2 (aka gmpy2). gmpy2 includes MPFR. If you install gmpy2 then you probably don't need bigfloat since the functionality of MPFR can be directly accessed from gmpy2. \nDisclaimer: I maintain gmpy and gmpy2.","Q_Score":1,"Tags":"python,installation,gmp,mpfr,bigfloat","A_Id":20229129,"CreationDate":"2013-11-26T06:19:00.000","Title":"Installing bigfloat, GMP and MPFR in windows for python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed a search engine for restaurants. I have a social network wherein users can add friends and form groups and recommend restaurants to each other. Each restaurant may serve multiple cuisines. All of this in Python.\nSo based on what restaurants a user has recommended, we can zero in on the kind of cuisines a user might like more. At the same time, we will know which price tier the user is more likely to explore(high-end, fast food, cafe, lounges etc)\nHis friends will recommend some places which will carry more weightage. There are similar non-friend users who have the recommended some the restaurants the user has recommended and some more which the user hasn't. \nThe end problem is to recommend restaurants to the user based on:\n1) What he has recommended(Other restaurants with similar cuisines) - 50% weightage\n2) What his friends have recommended(filtering restaurants which serve the cuisines the user likes the most) - 25% weightage\n3) Public recommendation by 'similar' non-friend users - 25% weightage.\nI am spending a lot of time reading up on Neo4j, and I think Neo4j looks promising. Apart from that I tried pysuggest, but it didn't suit the above problem. I also tried reco4j but it is a Java based solution, whereas I'm looking for a Python based solution. There is also no activity on the Reco4j community, and it is still under development.\nAlthough I've researched quite a lot, I might be missing out on something.\nI'd like to know how would you go about implementing the above solution? Could you give any use cases for the same?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1190,"Q_Id":20227834,"Users Score":0,"Answer":"I think you won't find any out-of-the box solution for you problem, as it is quite specific. What you could do with Neo4j is to store all your data that you use for building recommendations (users, friendships links, users' restaurants recommendations and reviews etc) and then build you recommendation engine on this data. From my experience it is quite straightforward to do once you get all your data in Neo4j (either with Cypher or Gremlin).","Q_Score":0,"Tags":"python,algorithm,neo4j,recommendation-engine","A_Id":20237347,"CreationDate":"2013-11-26T20:59:00.000","Title":"Recommendation engine using collaborative filtering in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I write a python script in which there are several print statement. The printed information can help me to monitor the progress of the script. But when I qsub the bash script, which contains python my_script &> output, onto computing nodes, the output file contains nothing even when the script is running and printing something.  The output file will contains the output when the script is done. So how can I get the output in real time through the output file when the script is running.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":641,"Q_Id":20233650,"Users Score":0,"Answer":"I like to write data to sys.stderr sometimes for this sort of thing.  It obviates the need to flush so much.  But if you're generating output for piping sometimes, you remain better off with sys.stdout.","Q_Score":1,"Tags":"python,bash,pbs","A_Id":20234550,"CreationDate":"2013-11-27T04:01:00.000","Title":"Output file contains nothing before script finishing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it somehow possible, to add custom sort method to values generated using TemplateColumn? because on basic it tries to find column name in model and returns FieldError: Cannot resolve keyword u'coulmn_name' into field. Choices are: [all fields in model].","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":448,"Q_Id":20243803,"Users Score":0,"Answer":"In the matter of fact, this can't be done. if TemplateColumn name is based on name in model, sorting works fine. As far as I am concerned If you want present other data it is impossible.","Q_Score":2,"Tags":"python,django,sorting,django-tables2","A_Id":21063484,"CreationDate":"2013-11-27T13:28:00.000","Title":"Django-tables2 Sorting TemplateColumn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok, this is really weird. I have an old Mercurial 2.02. with python 2.6 on an old Ubuntu-something (I think 10.4). \nWe are a windows shop, und push regularly, so I wanted kind of a review service. It absolutely worked on windows.. pretxnchangegroup referencing the python file on the drive, worked..\nBut I made the mistake to create the Mercurial hook on a new Mercurial 2.7, but then recognized the internal API changed, so I got back and fixed it, or tried to. I'm using windows, but need to deploy the hook to Linux, so I use WinSCP to copy the py file to my home directory. And then sudo cp it to the python 2.6 distro folder where the other hook file lie.\nI invoke the hook via the module pattern on the linux box:\npretxnchangegroup.pushtest = python:mycompanyname.testcommit.exportpatches\nIn the folder \"mycompanyname\" is the file testcommit.py and the function is named exportpatches. It works locally without a problem.\nThe strange thing: It worked once, and kind of unstable: sometime it just says that the function \"mycompanyname.testcommit.exportpatches\" is not defined. And sometimes it just uses an old version of the hook (I see that because it gives an old exception message instead of the newer one). And I don't know how to get exception messages in python, so I'm lost there..\nSecond strange thing: these hook files also have a .pyc version, probably compiled, but my hook doesn't get such treatment. Is that autocompilation?\nIf I try the directory approach to point to the file, I get a straight 500 internal error on push.\nI'm really lost and desperate by now, because the stuff has to work pretty soon, and I'm banging my head against the wall right now..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":20271881,"Users Score":0,"Answer":"I don't know exactly what happened, but it seams like it was not using the script because an exceptions somehow prohibited it from compiling to a pyc, and Mercurial somehow fetched the old version of that pyc file. Not too sure, but that's my best guess (as somehow noone else seems to have an idea and the Mercurial guys made it really clear they only answer stuff on their mailing list instead of SO.. how .. nice).","Q_Score":0,"Tags":"python,mercurial,mercurial-hook","A_Id":20836549,"CreationDate":"2013-11-28T17:32:00.000","Title":"Mercurial hook: isn't recompiled after change?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is there a way using StarUML for reverse engineering Python code to a class diagramm?\nIn the StarUML docs, they say there are modules for language support, but I couldn't find any further information about where and how to install and use.\nOther UML tools I found didn't match my idea of how a diagramm should look like.\nI know it is a bit problematic generating class diagramms for python, because it's compiled to runtime and will probably change then. \nBut I'm using Python to build my bachelor thesis and my Prof. loves UML. He really takes care of doing this correctly.\nCan anybody help me pls?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2332,"Q_Id":20283021,"Users Score":1,"Answer":"There is a simple possibility: Use PyCharm, a python IDE, which has an integrated UML generator (only in the pro version which is free for students).","Q_Score":3,"Tags":"python,staruml","A_Id":45105412,"CreationDate":"2013-11-29T10:00:00.000","Title":"StarUML for Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Jinja2 template in python for Google App Engine. I need to iterate through 2 lists list1 and list2 in the same loop in the html file. I tried using zip as described in some of the posts but it is not working. \nSomething similar in C : for(i=0.j=0; I<len(list1) && j < len(list2) ; I++,j++)\nCan anyone suggest some ways to implement the same?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":20291176,"Users Score":0,"Answer":"It sounds like you want to use itertools.product(list1, list2). This will create all combinations of list1 and list2.\nFor example, if list1 =  [1,2] and list2 = [1,2,3] then itertools.products(list1,list2) = [ (1,1),(2,1),(3,1),(2,1),(2,2),(2,3)]","Q_Score":0,"Tags":"python,list,google-app-engine,jinja2","A_Id":20301699,"CreationDate":"2013-11-29T17:53:00.000","Title":"Iterate through 2 loops in GAE Python templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example I know this method: os.system(\"cmd\") but it starts console in the directory of the script or in the dir of the interpreter, is there a way to gain control of this issue ?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":46,"Q_Id":20293848,"Users Score":-1,"Answer":"You can use os.chdir(target_directory) to change your program's working directory before starting the external application.","Q_Score":0,"Tags":"python,windows","A_Id":20293883,"CreationDate":"2013-11-29T21:54:00.000","Title":"how to start external system application in python specifying startup directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I am given an array of n points(pair of coordinates). I want to generate a 2D array of points, where ith row has all elements sorted according to their distance from the ith  point. There may be better and more efficient algorithms to get the final result, but for some reasons I want to do it by naive algorithm, i.e., brute-force. Also I don't want to write my own sorting function.\nIn C language, one can use the qsort function, but it's compare function only takes two parameters whereas I will be needing to pass three parameters: the reference point and two other points to be compared.\nIn Python too, one can use sorted function, but again, it's key function only takes one parameter, whereas in this case, I will need to pass two parameters.\nSo how do I do it?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":20295446,"Users Score":0,"Answer":"Maybe use a nested for loop with the outside one looking at the ith point.  then inside loop and calculate all the distances.  After calculation use a native python sort for that row and then add it to the main 2d array.","Q_Score":0,"Tags":"python,c,arrays,algorithm,sorting","A_Id":20295483,"CreationDate":"2013-11-30T01:18:00.000","Title":"Custom sorting in for loop","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Assuming I have a line with coordinates x1,y1 and x2,y2, and I know the length of the hypotenuse connecting those two points (thus also knowing the angle of rotation of the line through trig), if the line is 1 pixel thick how can I find every pixel on that line and store it to a list?\nI first proposed the simple vector calculation, stating with x1,y1 and performing line\/z*math.cos(angle),line\/z*math.sin(angle) (for x1 and y1 respectively) until I reached point x2,y2, but the problem with that is finding variable 'z' such that every single pixel is covered without duplicating pixels.\nSo what would be the best way of calculating this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":369,"Q_Id":20296712,"Users Score":0,"Answer":"Using float you should get all points without duplications - but you need int. \nUsing int you always get duplications - int(0.1) == int(0.2) == int(0.3) == etc.. \nSo you have to check if point is on your list.","Q_Score":0,"Tags":"python,pygame,lines,pixels","A_Id":20298727,"CreationDate":"2013-11-30T04:57:00.000","Title":"How can I find every pixel on a line with pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using python2.7 and argparse for my script. I am executing script as below:\n\npython2.7 script.py -a valuefora -b valueforb -c valueforc -d valueford\n\nNow what I want is that, \n\nif option  -a is given, then only -b, -c, -d options should be asked.\nIn addition to above, I also want to make this group -a -b -c -d as a EITHER OR for -e i.e. ([-a -b -c -d] | -e )\n\nPlease correct me anywhere I am wrong.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":348,"Q_Id":20311225,"Users Score":3,"Answer":"Your best choice is to test for the presence of various combinations after parse_args and use parser.error to issue an argparse compatible error message.  And write your own usage line.  And make sure the defaults clearly indicate whether an option has been parsed or not.\nIf you can change the -a and -e options to command names like cmda or build, you could use subparsers.  In this case you might define a command_a subparser that accepts -b, -c, and -d, and another command_e subparser that has none of these.  This is closes argparse comes to 'required together' groups of arguments.\nmutually exclusive groups can define something with a usage like [-a -b -c], but that just means -b cannot occur along with -a and -c.  But there's nothing fancy about that mechanism.  It just constructs a dictionary of such exclusions, and checks it each time it parses a new option.  If there is a conflict it issues the error message and quits.  It is not set up to handle fancy combinations, such as your (-e | agroup).\nCustom actions can also check for the absence or presence of non-default values in the namespace, much as you would after parsing.  But doing so during parsing isn't any simpler.  And it raises questions about order.  Do you want to handle -b -c -a the same way as -a -c -b?  Should -a check for the presence of the others, or should -b check that -a has already been parsed?  Who checks for the presence, or absence of -e.\nThe are a number of other stack questions about argparse groups, exclusive and inclusive, but I think these are the essential issues.","Q_Score":0,"Tags":"python,python-2.7,argparse,command-line-arguments","A_Id":20314797,"CreationDate":"2013-12-01T10:36:00.000","Title":"argparse: how to make group of options required only as group","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to change an openerp module menu name.\nI know how to do it, i'ts actually pretty easy, but this one is a core module sale and i don't want to touch it's code, because of updates issues and stuff.\nSo, i'll need to inherit this view and change it's name, from another module, can i do this without a module.py or a full __init__.py file?\nJust the openerp manifest file and an xml to overwrite it?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":325,"Q_Id":20315057,"Users Score":3,"Answer":"yes you can. you just need to create a module with two files. one is __openerp__.py with correct dependency to the base modules and an xml file for updating the menu name.","Q_Score":2,"Tags":"python,xml,openerp,overwrite","A_Id":20322373,"CreationDate":"2013-12-01T17:29:00.000","Title":"Change menu name openerp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"and thanks ahead of time.\nI am relatively new to Linux and am using Ubuntu 12.04.3.  Basically, I've been messing around with some files trying to get Django to work.  Well, I though I should do another install of Python2.7 for some reason.  Stupidly, I manually installed it.  Now when I open the Python shell and do 'import django', it can't be found.\nI just want to go back to using the Python that was on Ubuntu by default, or overwrite the one I installed manually with one using apt-get.  However, I am unable to figure out how to do this nor have I found a question that could help me.\nAny help is much appreciated.  I've been working on this for 6 hours now...\n--EDIT--\nOk well I'm just trying to go ahead and have the PYTHONPATH look in the right place. I've seen in other posts that you should do this in the ~\/.profile file.  I went into that file and added this line\nexport PYTHONPATH=$PYTHONPATH:\/usr\/local\/lib\/python2.7\/dist-packages\n\"import django\" is still coming up with \"no module found\"\nI tried doing \"import os\" and then \"os.environ[\"PYTHONPATH\"], which gave me:\nTraceback (most recent call last):\n   File \"\", line 1, in \n   File \"\/usr\/local\/lib\/python2.7\/UserDict.py\", line 23, in getitem\n   raise KeyError(key)\nKeyError: 'PYTHONPATH'\nAs far as I can tell, this means that I do not have a PYTHONPATH variable set, but I am unsure as to what I am doing wrong.\n--ANOTHER EDIT--\nAs I am not a very reputable member, I am not allowed to answer my own question before 8 hours from my original question, so I am putting it as an update.\nHey guys, thank you all for the quick responses and helpful tips.  What I did was open a python shell and type:\n\n\n\nsys.path.append('\/usr\/local\/lib\/python2.7\/dist-packages')\n\n\n\nand it worked!\nI should have done this from the beginning instead of trying to overwrite my manual Python installation.\nOnce again, thank you all for the help.\nI feel so relieved now :)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":533,"Q_Id":20324828,"Users Score":0,"Answer":"Sounds like an issue with your path - python not finding django becuase it doesnt know where to look for it. Look up issues regarding path and see if those help.","Q_Score":0,"Tags":"python,django,ubuntu","A_Id":20324883,"CreationDate":"2013-12-02T09:29:00.000","Title":"I need to overwrite an existing Python installation in ubuntu 12.04.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For instance, consider 3 modules namely \"apple\", \"orange\" and \"fruit\". Module \"apple\" imports \"orange\" and \"fruit\". Module \"orange\" imports \"fruit\" only. Since \"fruit\" is common for both, could this be done in a different way? Is this inefficient in terms of memory usage and speed?\n\nI wonder how this is done in professionally distributed packages. Say, if a standard library module (viz. httplib) is needed throughout various modules that has GUI code and other complicated stuff. importing this module in every GUI file would be impractical, wouldn't it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":20337169,"Users Score":1,"Answer":"Modules that are imported more than one are generally only initialized once and the namespace is introduced into the scope of the module.  So in your example above there is one class fruit and the two classes that inherit from it and if you were to introduce 3 varieties of apple there would still only be one underlying fruit class.\nThis is how professional packages do it.  In other languages like C\/C++ you need to use wards to prevent multiple imports python does if for you.","Q_Score":1,"Tags":"python,import","A_Id":20337294,"CreationDate":"2013-12-02T20:27:00.000","Title":"Import in python, two modules sharing common resource","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two databases (infact two database dump  ... db1.sql and db2.sql)\nboth database have only 1 table in each.\nin each table there are few columns (not equal number nor type) but 1 or 2 columns have same type and same value \ni just want to go through both databases and find a row from each table so that they both have one common value\nnow from these two rows(one from each table) i would extract some information and would write into a file.\nI want efficient methods to do that \nPS: If you got my question please edit the title \nEDIT: I want to compare these two tables(database) by a column which have contact number as primary key.\nbut the problem is one table has it is as an integer(big integer) and other table has it is as a string. now how could i inner-join them.\nbasically i dont want to create another database, i simply want to store two columns from each table into a file so I guess i dont need inner-join. do i? \ne.g. \nin table-1 = 9876543210\nin table-2 = \"9876543210\"","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1032,"Q_Id":20348584,"Users Score":0,"Answer":"Not sure if I understand what it is you want to do. You want to match a value from a column from one table to a value from a column from another table?\nIf you'd have the data in two tables in a database, you could make an inner join.\nDepending on how big the file is, you could use a manual comparison tool like WinMerge.","Q_Score":0,"Tags":"python,mysql,sql,database,mysql-python","A_Id":20348851,"CreationDate":"2013-12-03T10:28:00.000","Title":"Compare two databases and find common value in a row","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two databases (infact two database dump  ... db1.sql and db2.sql)\nboth database have only 1 table in each.\nin each table there are few columns (not equal number nor type) but 1 or 2 columns have same type and same value \ni just want to go through both databases and find a row from each table so that they both have one common value\nnow from these two rows(one from each table) i would extract some information and would write into a file.\nI want efficient methods to do that \nPS: If you got my question please edit the title \nEDIT: I want to compare these two tables(database) by a column which have contact number as primary key.\nbut the problem is one table has it is as an integer(big integer) and other table has it is as a string. now how could i inner-join them.\nbasically i dont want to create another database, i simply want to store two columns from each table into a file so I guess i dont need inner-join. do i? \ne.g. \nin table-1 = 9876543210\nin table-2 = \"9876543210\"","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1032,"Q_Id":20348584,"Users Score":0,"Answer":"You can use Join with alias name.","Q_Score":0,"Tags":"python,mysql,sql,database,mysql-python","A_Id":20348719,"CreationDate":"2013-12-03T10:28:00.000","Title":"Compare two databases and find common value in a row","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First, here is a sample JSON feed that I want to read in Python 2.7 with either simplejson or the built in JSON decoder. I am loading the .json file in Python and then searching for a key like \"Apple\" or \"Orange\" and when that key is found, I want to bring in the information for it like the types and quantities.\nRight now there is only 3 items, but I want to be able to search one that may have up to 1000 items. Here is the code:\n\n{\n    \"fruits\": [\n        {\n            \"Apple\": [\n                {\n                    \"type\": \"Gala\",\n                    \"quant\": 5\n                },\n                {\n                    \"type\": \"Honeycrisp\",\n                    \"quant\": 10\n                },\n                {\n                    \"type\": \"Red Delicious\",\n                    \"quant\": 4\n                }\n            ]\n        },\n        {\n            \"Banana\": [\n                {\n                    \"type\": \"Plantain\",\n                    \"quant\": 5\n                }\n            ]\n        },\n        {\n            \"Orange\": [\n                {\n                    \"type\": \"Blood\",\n                    \"quant\": 3\n                },\n                {\n                    \"type\": \"Navel\",\n                    \"quant\": 20\n                }\n            ]\n        }\n    ]\n}\n\nMy sample Python code is as follows:\n\nimport simplejson as json\n\n# Open file\nfjson = open('\/home\/teg\/projects\/test\/fruits.json', 'rb')\nf = json.loads(fjson.read())\nfjson.close()\n\n# Search for fruit\nif 'Orange' in json.dumps(f):\n\n    fruit = f['fruits']['Orange']\n    print(fruit)\n\nelse:\n\n    print('Orange does not exist')\n\n\n\nBut whenever I test it out, it gives me this error:\nTypeError: list indices must be integers, not str\nWas it wrong to have me do a json.dumps and instead should I have just checked the JSON feed as-is from the standard json.loads? I am getting this TypeError because I am not specifying the list index, but what if I don't know the index of that fruit?\nDo I have to first search for a fruit and if it is there, get the index and then reference the index before the fruit like this?\nfruit = f['fruits'][2]['Orange']\nIf so, how would I get the index of that fruit if it is found so I could then pull in the information? If you think the JSON is in the wrong format as well and is causing this issue, then I am up for that suggestion as well. I'm stuck on this and any help you guys have would be great. :-)","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":65,"Q_Id":20355886,"Users Score":1,"Answer":"The problem is that the data structure has a list enclosing the dictionaries. If you have any control over the data source, that's the place to fix it. Otherwise, the best course is probably to post-process the data after parsing it to eliminate these extra list structures and merge the dictionaries in each list into a single dictionary. If you use an OrderedDict you can even retain the ordering of the items (which is probably why the list was used).","Q_Score":0,"Tags":"python,json","A_Id":20356067,"CreationDate":"2013-12-03T16:01:00.000","Title":"Python: TypeError in referencing item in JSON feed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is there a way to know how many rows were commited on the last commit on a SQLAlchemy Session? For instance, if I had just inserted 2 rows, I wish to know that there were 2 rows inserted,  etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":193,"Q_Id":20389368,"Users Score":1,"Answer":"You can look at session.new, .dirty, and .deleted to see what objects will be committed, but that doesn't necessarily represent the number of rows, since those objects may set extra rows in a many-to-many association, polymorphic table, etc.","Q_Score":0,"Tags":"python,sqlalchemy","A_Id":20389560,"CreationDate":"2013-12-05T00:59:00.000","Title":"SQLAlchemy, how many rows were commited on last commit","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I remove a package from Pypi?\nI uploaded a package to Pypi several months ago.  The package is now obsolete and I'd like to formally remove it.  I cannot find any documentation on how to remove my package.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27292,"Q_Id":20403387,"Users Score":53,"Answer":"Login.\nGo to your packages.\nCheck the \"remove\" checkbox for the particular package.\nClick \"Remove\" button.","Q_Score":58,"Tags":"python,pypi","A_Id":20403468,"CreationDate":"2013-12-05T15:03:00.000","Title":"How to remove a package from Pypi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a web frontend which uses data from a task that must be run frequently in bulk (which takes more time than I'd like to use PHP for). The data can be stored in a database so I was planning on writing a Java application to run the task and use the database as a middleman to get the results of this task accessible to the web. \nProblem is, a \"preview\" of this data is needed occasionally. IE, sometimes the user needs to request a sample of the data (which can be computed quickly) to be generated on cue. \nThis presents a real problem for me, this preview IS more suited for a language like PHP even though it's essentially the same task. It's just two cases, in case A there are real jobs from many users to be done so the task takes a sufficiently long time to complete (longer than a PHP request can hold), in case B it's a baby job for just one user ran on the spot which could be completed in PHP without issue. \nI don't want to write this code twice, it would make maintenance a nightmare so I kind of need to pick a language and stick with it. The frontend is designed but not implemented so I have an oppertunity to write the site in PHP, Ruby or Python if need be. I know PHP, so I would only consider switching to Python or Ruby if one of those languages offered a solution to this problem. but I know so little about these languages that I really cannot begin to know if they offer a solution without learning them (which I don't have the time for atm). \nIn short, is there a non-hackish way to write short, quick event-driven code AND long-running repetitive code with Ruby on Rails or Python? If not do you have any ideas how to satifsy these two cases with either PHP or Java?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":20406998,"Users Score":2,"Answer":"Language is irrelevant.\nJust put \"short\" operation in function (object, if it is complex) and use it from 2 places:\n\nweb-code which needs \"preview\" will call it once and get its piece of data\nlong-running background process will call it iteratively as much as needed and will store result of function in DB instead of returning it to user immediately\n\nCan be easily done in PHP. Long-running processeses are not a problem since 5.3","Q_Score":0,"Tags":"php,python,ruby","A_Id":20409383,"CreationDate":"2013-12-05T17:44:00.000","Title":"PHP \/ Python \/ Ruby - Long running tasks with short previews","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two pyqt files that I made in qt4 designer. I put them both in a directory and created a  file outside the directory, which I imported them with. The first file is a window with a button, that when clicked, should close the first window, and open the second window. \nI can import them, and launch them both at the same time, but I can't figure out how to have the button in the first window affect the other, yet alone have it close itself and spawn the other.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":20411315,"Users Score":0,"Answer":"In the handler of the button-click in the first window, instantiate the second window and invoke its show-method, and then close (emit the close-signal to) the first window.","Q_Score":0,"Tags":"python,qt,pyqt4","A_Id":20411550,"CreationDate":"2013-12-05T21:38:00.000","Title":"How to tie two windows together in pyqt4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I find the index of the 3 smallest and 3 largest values in a column in my pandas dataframe? I saw ways to find max and min, but none to get the 3.","AnswerCount":5,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7247,"Q_Id":20415414,"Users Score":5,"Answer":"What have you tried? You could sort with s.sort() and then call s.head(3).index and s.tail(3).index.","Q_Score":4,"Tags":"python,pandas,dataframe","A_Id":20415698,"CreationDate":"2013-12-06T03:29:00.000","Title":"python pandas 3 smallest & 3 largest values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just wondering how to store files in the google app engine datastore.\nThere are lots of examples on the internet, but they are using blobstore\nI have tried importing db.BlobProperty, but when i put() the data\nit shows up as a <Blob> i think. It appears like there is no data\nSimilar to None for a string\nAre there any examples of using the Datastore to store files\nOr can anyone point me in the right direction\nI am new to programming, so not to complex, but I have a good\nhang of Python, just not an expert yet.\nThanks for any help","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":20421965,"Users Score":0,"Answer":"Datastore has a limit on the size of objects stored there, thats why all examples and documentation say to use the blobstore or cloud storage. Do that.","Q_Score":0,"Tags":"python,google-app-engine,blob,google-cloud-datastore","A_Id":20424484,"CreationDate":"2013-12-06T10:47:00.000","Title":"How do I store files in googleappengine datastore","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need a launch script which has access to \"db\" and other web2py modules. This script must be running constantly. I know that Web2py has launch parameters from which you can run python files in the web2py enviroment, but i don't know how that works. Can this parameter solve my problem and if so, how do I go about it? Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1158,"Q_Id":20427217,"Users Score":1,"Answer":"Look at section 4.17.1 of the web2py manual (or Google \"web2py cron\").\nYou can run a script on startup of web2py by registering it in the crontab file as:\n\"@reboot web2py *scripts\/myscript.py\"\nweb2py should be the username that it will run as, which should be the same as what web2py runs as. In my setup I have a user named 'web2py' to run the app.\nThe asterix before scripts\/myscript.py indicates that you want to run the script in the web2py environment. \nKeep in mind that you run the risk of locking issues if your script is trying to use the database at the same time as the normal web2py process.","Q_Score":0,"Tags":"python,web2py","A_Id":20437241,"CreationDate":"2013-12-06T15:09:00.000","Title":"Web2py launch script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm investigating ways to add vagrant to my development environment. I do most of  my web development in python, and I'm interested in python-related specifics, however the question is more general.\nI like the idea of having all development-related stuff isolated in virtual machine, but I haven't yet discovered an effective way to work with it. Basically, I see 3 ways to set it up:\n\nHave all services (such as database server, MQ, etc) as well as an application under development to run in VM. Developer would ssh to VM and edit sources there, run app, tests, etc, all in an ssh terminal.\nSame as 1), but edit sources on host machine in mapped directory with normal GUI editor. Run application and tests on vagrant via ssh. This seems to be most popular way to use vagrant.\nHost only external services in VM. Install app dependencies into virtualenv on host machine and run app and tests from there. \n\nAll of these approaches have their own flaws:\n\nDeveloping in text console is just too inconvenient, and this is the show-stopper for me. While I'm experienced ViM user and could live with it, I can't recommend this approach to anyone used to work in any graphical IDE.\nYou can develop with your familiar tools, but you cannot use autocompletion, since all python libs are installed in VM. Your tracebacks will point to non-local files. You will not be able to open library sources in your editor, ctags will not work.\nLosing most of \"isolation\" feature: you have to install all compilers, *-dev libraries yourself to install python dependencies and run an app. It is pretty easy on linux, but it might be much harder to set them all up on OSX and on Windows it is next to impossible I guess.\n\nSo, the question is: is there any remedy for problems of 2nd and 3rd approaches? More specifically, how is it possible to create an isolated and easily replicatable environment, and yet enjoy all the comfort of development on host machine?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1504,"Q_Id":20433712,"Users Score":0,"Answer":"In most IDE you can add \"library\" path which are outside the project so that your code completion etc works. About the traceback, I'm unfamiliar with python but this sounds like issue that are resolved by \"mapping\" paths between servers and dev machine. This is generally the reason why #2 is often the way to go (Except when you have a team willing to do #1).","Q_Score":5,"Tags":"python,development-environment,vagrant","A_Id":21195137,"CreationDate":"2013-12-06T21:16:00.000","Title":"Using vagrant as part of development environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Problem\nI have a list of ~5000 locations with latitude and longitude coordinates called A, and a separate subset of this list called B. I want to find all locations from A that are within n miles of any of the locations in B.\nStructure\nAll of this data is stored in a mysql database, and requested via a python script.\nApproach\nMy current approach is to iterate through all locations in B, and request locations within n miles of each location, adding them to the list if they don't exist yet.\nThis works, but in the worst case, it takes a significant amount of time, and is quite inefficient. I feel like there has to be a better way, but I am at a loss as for how to do it.\nIdeas\n\nLoad all locations into a list in python, and calculate distances there. This would reduce the number of mysql queries, and likely speed up the operation. It would still be slow though.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":20455129,"Users Score":1,"Answer":"Load B into a python list and for each calculate maxlat, minlat, maxlong, minlong that everything outside of the box is definitely outside of your radius, if your radius is in nautical miles and lat\/long in degrees.  You can then raise an SQL query for points meeting criteria of minlat < lat < maxlat and minlong < long < maxlong.  The resulting points can then be checked for exact distance and added to the in range list if they are in range.  \nI would suggest doing this in multiple processes.","Q_Score":0,"Tags":"python,mysql,latitude-longitude","A_Id":20455724,"CreationDate":"2013-12-08T15:29:00.000","Title":"Finding Locations with n Miles of Existing Locations","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some code in python 2.7 and I want to convert it all into python 3.3 code.  I know 2to3 can be used but I am not sure exactly how to use it.","AnswerCount":9,"Available Count":3,"Score":0.1106561105,"is_accepted":false,"ViewCount":73248,"Q_Id":20458011,"Users Score":5,"Answer":"To convert all python 2 files in a directory to 3, you simply could run $ C:\\Program Files\\Python\\Tools\\Scripts\\2to3.py -w -n. inside the directory that you want to translate. It would skip all the non .py files anyway, and convert the rest.\nnote: remove the -n flag, if you want the backup file too.","Q_Score":69,"Tags":"python,python-2.7,python-3.3,python-2to3","A_Id":47106899,"CreationDate":"2013-12-08T19:35:00.000","Title":"How to use 2to3 properly for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some code in python 2.7 and I want to convert it all into python 3.3 code.  I know 2to3 can be used but I am not sure exactly how to use it.","AnswerCount":9,"Available Count":3,"Score":0.022218565,"is_accepted":false,"ViewCount":73248,"Q_Id":20458011,"Users Score":1,"Answer":"Running it is very simple! I am going to consider you already have it installed and explain step-by-step how to proceed after that:\n\nOpen terminal (or cmd for win users) inside the main folder containing the files you want to convert\n\ne.g.\nC:\\Users\\{your_username}\\Desktop\\python2folder\n\nType\n\npython {your_2to3.py_install_directory} -w .\\\ne.g. in my case (win10) it would be:\npython C:\"\\Program Files\"\\Python39\\Tools\\scripts\\2to3.py -w .\\\nThis is going to make the program scan the entire directory (and sub directories as well) and automatically convert everything that is written in Python2 to Python3.\n-w flag makes the script apply the changes creating new converted files. So remove this you'd like to just scan and see what needs conversion (but without actually doing anything)\nIf you'd like to convert just one file instead of entire folders simply substitute .\\ for python2_file_name.py:\ne.g. python {your_2to3.py directory} -w python2_file_name.py\nAlso, by default it creates a .bak file for everything it converts. It is highly advised to keep it this way since any conversion is prone to errors but if you'd like to disable the automatic backup you could also add the -n flag.\ne.g. python C:\"\\Program Files\"\\Python39\\Tools\\scripts\\2to3.py -w -n python2_file_name.py\n3.Done!","Q_Score":69,"Tags":"python,python-2.7,python-3.3,python-2to3","A_Id":65057406,"CreationDate":"2013-12-08T19:35:00.000","Title":"How to use 2to3 properly for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some code in python 2.7 and I want to convert it all into python 3.3 code.  I know 2to3 can be used but I am not sure exactly how to use it.","AnswerCount":9,"Available Count":3,"Score":-0.0444152037,"is_accepted":false,"ViewCount":73248,"Q_Id":20458011,"Users Score":-2,"Answer":"The python 2to3.py file is mostly found in the directory C:\/Program Files\/Python\/Tools\/scripts if you already have python installed. I have python 3.6 and 2to3 is in the directory C:\/Program Files\/Python36\/Tools\/scripts.\nTo convert a certain python 2 code to python 3, go to your command promt, change the directory to C:\/Program Files\/Python36\/Tools\/scripts where the 2to3 file is found. Then add the following command:\npython 2to3.py -w (directory to your script).\neg. C:\\Program Files\\Python36\\Tools\\scripts\uff1e python 2to3.py -w C:Users\\Iykes\\desktop\\test.py. \nthe '-w' here ensures a backup file for your file is created.","Q_Score":69,"Tags":"python,python-2.7,python-3.3,python-2to3","A_Id":48277515,"CreationDate":"2013-12-08T19:35:00.000","Title":"How to use 2to3 properly for python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"as we know, python has two built-in url lib:   \n\nurllib \nurllib2\n\nand a third-party lib:   \n\nurllib3\n\nif my requirement is only to request a API by GET method, assume it return a JSON string.\nwhich lib I should use? do they have some duplicated functions?\nif the urllib can implement my require, but after if my requirements get more and more complicated, the urllib can not fit my function, I should import another lib at that time, but I really want to import only one lib, because I think import all of them can make me confused, I think the method between them are totally different.   \nso now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":22979,"Q_Id":20467107,"Users Score":1,"Answer":"Personally I avoid to use third-party library when possible, so I can reduce the dependencies' list and improve portability.\nurllib and urllib2 are not mutually exclusive and are often mixed in the same project.","Q_Score":9,"Tags":"python,urllib2,urllib,urllib3","A_Id":20467364,"CreationDate":"2013-12-09T09:23:00.000","Title":"Which urllib I should choose?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"as we know, python has two built-in url lib:   \n\nurllib \nurllib2\n\nand a third-party lib:   \n\nurllib3\n\nif my requirement is only to request a API by GET method, assume it return a JSON string.\nwhich lib I should use? do they have some duplicated functions?\nif the urllib can implement my require, but after if my requirements get more and more complicated, the urllib can not fit my function, I should import another lib at that time, but I really want to import only one lib, because I think import all of them can make me confused, I think the method between them are totally different.   \nso now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":22979,"Q_Id":20467107,"Users Score":10,"Answer":"As Alexander says in the comments, use requests. That's all you need.","Q_Score":9,"Tags":"python,urllib2,urllib,urllib3","A_Id":20467287,"CreationDate":"2013-12-09T09:23:00.000","Title":"Which urllib I should choose?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I find out if there is even, or odd, number of elements in an arbitrary list.\nI tried list.index() to get all of the indices... but I still don't know how I can tell the program what is an even and what is an odd number.","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14621,"Q_Id":20476969,"Users Score":0,"Answer":"Even numbers are divisible by 2. Odd numbers are not.\nlen(X) will get the length of X\nIf the length of X is divisible by 2, then it is an Even number\nIf the length of X is not divisible by 2 then it is an Odd Number\nlen(X)%2 returns the \"remainder\" of a division problem\nfor example 5%2 will return 1 which is NOT zero, (because 5 divided by 2 is 2 with a remainder of 1), therefore it is not even.\nSame thing as 6%4 which would return a 2, because 6 divided by 4 is 1 with a remainder of 2.\nso len(X)%2 where X is your list, will return either a 1, indicating it is Odd, or a 0 indicating it is Even.","Q_Score":2,"Tags":"python,list,python-3.x","A_Id":20477231,"CreationDate":"2013-12-09T17:37:00.000","Title":"How to know if a list has an even or odd number of elements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a pretty big Python package I've written, about 3500 statements, with a robust unit and acceptance test suite. I feel quite confident about the quality of the code itself, but I'm uneasy about the install process going smoothly for users of the package as I don't know how to reliably test the install in an appropriately isolated environment, short of something like keeping a spare machine around and re-imaging it with a fresh OS install for each test run.\nI suspect using virtualenv in the right way might provide a proper test fixture for testing installation, but after extended web searches have uncovered no helpful guidance.\nHow can I effectively test my setup.py and other installation bits on my development machine?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1343,"Q_Id":20489514,"Users Score":2,"Answer":"If you really want isolation instead just doing python setup.py install in virtualenv. Then use virtualbox and install some free linux os in it. Take a snapshot of the machine after the install so you can revert easily with one click to the starting point at any time and try python setup.py install there.","Q_Score":8,"Tags":"python,integration-testing,setup.py","A_Id":20489835,"CreationDate":"2013-12-10T08:32:00.000","Title":"How do I test the setup.py for my package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to do file uploading in turbogears 2.3.1? I am using CrudRestController and tgext.datahelpers and it is uploading the file in the sqlite3 database but in an unknown format. I want to make a copy of the uploaded file in the hard drive. My query is how to ensure that when user uploads a file, it is loaded both in the database and the hard drive.\n(Thank you for suggestions)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":226,"Q_Id":20492587,"Users Score":0,"Answer":"tgext.datahelpers uploads files on disk inside the public\/attachments directory (this can be change with tg.config['attachments_path']).\nSo your file is already stored on disk, only the file metadata, like the URL, filename, thumbnail_url and so on are stored on database in JSON format","Q_Score":1,"Tags":"python-2.7,turbogears2","A_Id":20525832,"CreationDate":"2013-12-10T10:57:00.000","Title":"file upload turbogears 2.3.1","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The only time I ever use the with keyword is when reading and writing files, mostly because that's the only case I actually know that I can use it. I can imagine there are numerous instances where I preferably could have used with, but didn't know a class or method accepted it. \nSo, how do I detect instances where the with keyword can be used?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":44,"Q_Id":20500717,"Users Score":3,"Answer":"Context managers all have __enter__() and __exit__() methods, so checking to see if those attributes exist and that they have __call__ attributes will work almost all the time.\nBut yeah, read the code and\/or documentation for the class first.","Q_Score":4,"Tags":"python","A_Id":20500806,"CreationDate":"2013-12-10T17:05:00.000","Title":"How can I easily find out if a Python class accepts the with keyword?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a function that will cause a giraffe to move in a certain direction and distance (don't ask). \nIf the user types \"west\" in the parameters, the turtle should move west however the direction is. But the turtle's angle changes every time, I can't fix a value for my turtle to turn to go a certain direction.\nI need to set the angle to, say, 90 so that it can move East. I can't find useful functions for this purpose. I tried to use Pen().degrees(90) but that didn't work. Does anyone know how I can do this?","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":18276,"Q_Id":20502766,"Users Score":-3,"Answer":"turtle.right(90)\nthis will turn the turtle 90","Q_Score":6,"Tags":"python,angle,turtle-graphics","A_Id":49330538,"CreationDate":"2013-12-10T18:45:00.000","Title":"Setting the angle of a turtle in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a program that takes infrared values serially, transmits them them to another program(the one im having trouble with), and uses the win32 python api to react to a matched value. It all works, but I need this program to run on the startup of my computer.\nIt uses the IDLE python shell to run, and I need to open\/run the file directly from that program. Is there any way to do this? I can't just put a shortcut into the startup directory because its an unrecognized file, and it needs to be run, not just opened. Any help would be great, thanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6240,"Q_Id":20507907,"Users Score":4,"Answer":"Create a batch file with the line start C:\\python27\\python.exe D:your_program_location\\your_program.py'\n\nDrag the batch file from desktop to \"Start - All Programs - Startup\". That should do the trick.","Q_Score":0,"Tags":"python,windows,shell,startup","A_Id":20508067,"CreationDate":"2013-12-11T00:00:00.000","Title":"how to Start python shell program on windows 7 startup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a program that takes infrared values serially, transmits them them to another program(the one im having trouble with), and uses the win32 python api to react to a matched value. It all works, but I need this program to run on the startup of my computer.\nIt uses the IDLE python shell to run, and I need to open\/run the file directly from that program. Is there any way to do this? I can't just put a shortcut into the startup directory because its an unrecognized file, and it needs to be run, not just opened. Any help would be great, thanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6240,"Q_Id":20507907,"Users Score":0,"Answer":"It sounds like your actual problem is just that you didn't put the right extension on the file.\nJust rename it to, e.g., script.py, or script.pyw, and, unless you've changed the settings from the default, that should open the file with the command-line or windowed Python launcher, which will just run it.\nIf you've changed your settings so .py files open in IDLE instead of in the Python launcher\u2026 is there a reason you want those weird settings? If not, just undo it.","Q_Score":0,"Tags":"python,windows,shell,startup","A_Id":20508698,"CreationDate":"2013-12-11T00:00:00.000","Title":"how to Start python shell program on windows 7 startup?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I really appreciate any responses. I am thoroughly confused and never knew this experiment design\/builder software was so complicated!\nI am a fast learner, but still a newbie so please be patient.\nYes I have googled the answers for my question but no answers to similar questions seem to work.\nI have an experiment, there are 8 conditions,\neach condition needs to show 1 image, chosen at random from a folder of similar images.\nEach trial needs to be different (so each participant sits a differently ordered set of conditions) AND each condition's selected image will be different.\nSo;\nCondition- Image\nA        - 1 to 140\nB        - 1 to 80\netc..\nRecording data is not a problem as this can be done by hand, but I just need the images to be randomly selected from a pre-defined group.\nI have tried using code to randomise and shuffle the order, but have got nowhere.\nPlease help,\nTom","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":65,"Q_Id":20509103,"Users Score":1,"Answer":"To generate retrieve the path of a random image in a folder img_folder, it's not too difficult. You can use img_path_array = os.listdir('...\/img_folder'). Randomly generate an integer between 0 and len(img_path_array) using random_index = randrange(len(img_path_array)) (import random to use this function), and gain access to the random file url by calling img_path_array[random_index].","Q_Score":1,"Tags":"python,random","A_Id":20509223,"CreationDate":"2013-12-11T01:54:00.000","Title":"how to randomise the image shown in a sketchpad","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a multiple choice quiz in Tkinter.\nEach question has between 2-4 different answers all displayed as checkboxes, how do I ensure the user can only tick one check box and not all of them?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1562,"Q_Id":20528082,"Users Score":1,"Answer":"Don't use checkboxes; use radoibuttons instead. The behavior of checkboxes and radiobuttons is well established -- checkboxes allow you to select N of N choices, radiobuttons are designed to allow you to select exactly 1 of N. Don't violate this design pattern or your users will be confused. \nTo make radiobuttons work, create a single StringVar and associate it with two or more radiobuttons. All of the radiobuttons that share the same variable will work as a set, allowing only one to be selected.","Q_Score":0,"Tags":"python,validation,user-interface,checkbox,tkinter","A_Id":20528169,"CreationDate":"2013-12-11T19:19:00.000","Title":"Checkbox validation: how do i ensure user can only tick one box only?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've to calculate the time-complexity of an algorithm, but in it I'm calling os.walk which I can't consider as a single operation but many. \nThe sources of os.walk left me confused as the filetree may be ordered in many ways (1.000.000 files in a folder or a file per folder and 1.000.000 folders.\nI'm not an expert on time-complexities, I can't be sure on what I should consider as only an operation or many, so this left me stuck. Don't count the simlink flag, which I assume set to false to ignore them.\nPD: I found the sources of os.walk in the Komodo IDE, but I wouldn't know how to find them as the javadocs.","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":2735,"Q_Id":20529878,"Users Score":5,"Answer":"This is too long for a comment:  in CPython, a yield passes its result to the immediate caller, not directly to the ultimate consumer of the result.  So, if you have recursion going R levels deep, a chain of yields at each level delivering a result back up the call stack to the ultimate consumer takes O(R) time.  It also takes O(R) time to resume the R levels of recursive call to get back to the lowest level where the first yield occurred.\nSo each result yield'ed by walk() takes time proportional to the level in the directory tree at which the result is first yield'ed.\nThat's the theoretical ;-) truth.  In practice, however, this makes approximately no difference unless the recursion is very deep.  That's because the chain of yields, and the chain of generator resumptions, occurs \"at C speed\".  In other words, it does take O(R) time, but the constant factor is so small most programs never notice this.\nThis is especially true of recursive generators like walk(), which almost never recurse deeply.  Who has a directory tree nested 100 levels?  Nope, me neither ;-)","Q_Score":3,"Tags":"python,python-3.x,time-complexity","A_Id":20531306,"CreationDate":"2013-12-11T21:04:00.000","Title":"Time complexity of os.walk in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've to calculate the time-complexity of an algorithm, but in it I'm calling os.walk which I can't consider as a single operation but many. \nThe sources of os.walk left me confused as the filetree may be ordered in many ways (1.000.000 files in a folder or a file per folder and 1.000.000 folders.\nI'm not an expert on time-complexities, I can't be sure on what I should consider as only an operation or many, so this left me stuck. Don't count the simlink flag, which I assume set to false to ignore them.\nPD: I found the sources of os.walk in the Komodo IDE, but I wouldn't know how to find them as the javadocs.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2735,"Q_Id":20529878,"Users Score":2,"Answer":"os.walk (unless you prune it, or have symlink issues) guarantees to list each directory in the subtree exactly once.\nSo, if you assume that listing a directory is linear on the number of entries in the directory,* then if there are N total directory entries in your subtree, os.walk will take O(N) time.\nOr, if you want the time for walk to produce each value (the root, dirnames, filenames tuple): if those N directory entries are split among M subdirectories, then each of the M iterations takes amortized O(N\/M) time.\n\n* Really, that's up to your OS, C library, and filesystem not Python, and it can be much worse than O(N) for older filesystems\u2026 but let's ignore that.","Q_Score":3,"Tags":"python,python-3.x,time-complexity","A_Id":20530026,"CreationDate":"2013-12-11T21:04:00.000","Title":"Time complexity of os.walk in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to save a value in a security token memory by using PyKCS11 and M2Crypto?\nI need to save an integer to token memory, so that the value can be carried out with the token\nI know how to create objects, but is it possible to create attributes in a token, so whenever I read that attribute I will know the status of that token.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":203,"Q_Id":20543708,"Users Score":0,"Answer":"using PKCS#11, the only way to store 'home made' data, it through the use of a CKO_DATA object type. Like any object, it can be persistent on the token (not lost when the token is powered off) or it can be a memory object (lost when the session to the token is closed).\nTo create a CKO_DATA object is similar to any other object creation:\n\nopen a r\/w session on the slot\nif the object is to be protected by user authentication (CKU_USER) then Login as user\ncreate the object template with mandatory attributes such as CKA_CLASS etc. (refer to the PKCS#11 specifications for details)\nset the CKA_TOKEN to TRUE if the object is to be persistent, or FALSE if it is a memory object\nset the CKA_PRIVATE to TRUE* if you want this object to be read\/writen only upon successfull user authentication or set it to **FALSE if anybody can access it.\nset a CKA_LABEL and CKA_APPLICATION attributes with values you want to help you find the object next time\nset the CKA_VALUE attribute to the value you want (your integer)\nCall C_CreateObject, using this template will create the desired object.\n\nHTH,","Q_Score":2,"Tags":"python,security,token,m2crypto,pkcs#11","A_Id":41831467,"CreationDate":"2013-12-12T12:34:00.000","Title":"How to save a temporary value in a security token?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've recently moved from Matlab to Python. Python is a much better language (from the point of view of a computer scientist), but Python IDEs all seem to lack one important thing:\nA proper interactive debugger.\nI'm looking for:\n\nThe ability to set breakpoints graphically by clicking next to a line of code in the editor.\nThe ability to run ANY CODE while stopped in the debugger, including calling functions from my code, showing new windows, playing audio, etc.\nWhen an error occurs, the debugger should automatically open an interactive console at the error line.\nOnce done with the interactive console, you can resume normal execution.\n\nMatlab has all these features and they work incredibly well, but I can't find them anywhere in Python tools.\nI've tried: \n\nPyCharm: the interactive console is clunky, often fails to appear, and crashes all the time (I've tried several different versions and OSs). \nIPython: can't set breakpoints -Launching a Python console programatically: you have to stop your code, insert an extra line of code, and run again from the beginning to do this. Plus, you can't access functions already imported without re-importing them.\n\nBeing able to debug and fix problems THE FIRST TIME THEY APPEAR is very important to me, as I work in programs that often take dozens of minutes to re-run (computational neuroscience).\nCONCLUSION: there is NO way to do all of these in Python at the moment. Let us hope that PyLab development accelerates.","AnswerCount":6,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4947,"Q_Id":20547049,"Users Score":0,"Answer":"You can do all this in the iPython Notebook. Use the magic command %pdb to stop on error.","Q_Score":9,"Tags":"python,debugging,console,interactive","A_Id":34922501,"CreationDate":"2013-12-12T15:08:00.000","Title":"In Python, how do I debug with an interactive command line (and visual breakpoints?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a list of fruits\n\nexample:\n\"banana\",\n\"apple\",\n\"grape\",\n\"strawberry\"\n\nand I want to create files \nwith the text:\n\"This fruit is %fruit name%, its delicious\"\nand save as %fruit name%.fruits\nhow i do that? cam be in any language","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":41,"Q_Id":20557627,"Users Score":-1,"Answer":"I don't recommend trying this in batch file.  Learning the basics of a scripting language such as Python or Perl is much better for this type of work.","Q_Score":0,"Tags":"python","A_Id":20557641,"CreationDate":"2013-12-13T01:36:00.000","Title":"create files, with a template and a list of name and save on files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project needed to be installed in Debian. I make packages via stdeb. I do not understand two things, on which I can`t find answers:\n\nHow to install not only Django project, but also Python and Django with it? What and where and how should I write the script?\nThis project demand different additions, such as grappelli, tinymce, filebrowser. Should I do anything with it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":20574073,"Users Score":0,"Answer":"How to install not only Django project, but also Python and Django with it? What and where and how should I write the script?\n\nIf you created a deb file, as it gets interpreted, you should write the python dependency in the debian\/control file.\n\nThis project demand diffrent additions, such as grappelli, tinymce, filebrowser. Should I do anything with it?\n\nIf this packages are in any repository (or your repository) then you can either, put them as recommendation or as suggestion in the control file.","Q_Score":0,"Tags":"python,django,debian-packaging","A_Id":20574224,"CreationDate":"2013-12-13T19:04:00.000","Title":"Distribution Python package to Debian package with installing additional things","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tend to start projects that are far beyond what I am capable of doing, bad habit or a good way to force myself to learn, I don't know. Anyway, this project uses a postgresql database, python and sqlalchemy. I am slowly learning everything from sql to sqlalchemy and python. I have started to figure out models and the declarative approach, but I am wondering: what is the easiest way to populate the database with data that needs to be there from the beginning, such as an admin user for my project? How is this usually done?\nEdit:\nPerhaps this question was worder in a bad way. What I wanted to know was the possible ways to insert initial data in my database, I tried using sqlalchemy and checking if every item existed or not, if not, insert it. This seemed tedious and can't be the way to go if there is a lot of initial data. I am a beginner at this and what better way to learn is there than to ask the people who do this regularly how they do it? Perhaps not a good fit for a question on stackoverflow, sorry.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":995,"Q_Id":20587888,"Users Score":0,"Answer":"You could use a schema change management tool like liquibase. Normally this is used to keep your database schema in source control, and apply patches to update your schema.\nYou can also use liquibase to load data from CSV files. So you could add a startup.csv file in liquibase that would be run the first time you run liquibase against your database. You can also have it run any time, and will merge data in the CSV with the database.","Q_Score":1,"Tags":"python,sql,postgresql,sqlalchemy","A_Id":20589295,"CreationDate":"2013-12-14T20:26:00.000","Title":"Sqlalchemy, python, easiest way to populate database with data","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I was wanting to use some non-standard python packages in my project and was wondering how to add them. What is the benefit of using the AWS eb config files (.ebextensions and requirements.txt) rather than just downloading and including the package in my actual project under a lib directory like you would with a java application?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":20605544,"Users Score":2,"Answer":"by including it in the requirements.txt, you can include only the packages you are calling.  Pip then takes care of installing the dependencies and checking the versions.\nThis has the additional advantage of when you are changing or upgrading your project, you can specify a new version of the library you are using and all the dependent libraries will also be updated.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-elastic-beanstalk","A_Id":20607574,"CreationDate":"2013-12-16T07:31:00.000","Title":"Adding external packages to elastic beanstalk python app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a graph of the dependencies of all tasks, and the costs of each task. Now I want to calculate a scheduling for a given amount of CPUs. I've found many papers on scheduling algorithms, optimal schedulers seem to be too expensive for my problem size (around 100 nodes) as it's an NP-hard problem. I'd settle for a heuristic, preferably one that has a bound how close it gets to the optimum. My problem now is: do I really have to code it myself?? This should have been solved many times before, it can be easily applied to project management, maybe there something exists?\nIf you happen to know a library in python that'd be perfect or the next best thing would be C++, otherwise i'd settle for anything else.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":606,"Q_Id":20614349,"Users Score":2,"Answer":"This is a pretty common problem.   It also shows up in hardware design. \nThere has been a lot of work on algorithms to solve it. \nIf you are going to write something yourself, start by checking out \"Hu's Algorithm\". \nIf you just want a solution, these functions are built into architectural synthesis programs. \nLook at the Wikipedia pages on high level synthesis and logic synthesis. \nThere are several professional tools that can handle this, if you can get access to them through school or work.   \nThere are university programs you can often get for free that can also handle this problem. \nI'm not up-to-date on what is currently available.   An very old one is MIS II from Berkeley.   It's scripting language was Tcl, not Python.","Q_Score":4,"Tags":"c++,python,parallel-processing,scheduling,directed-acyclic-graphs","A_Id":20619386,"CreationDate":"2013-12-16T15:20:00.000","Title":"finding static scheduling of DAG for multiprocessors - library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to apply a modifier to large number of meshes stored in different .ply files.\nI wish to do this through command line so that the process can be automated. I know the basic of blender python API like how to write the modifier in python. But that required me to first import .ply file in blender using UI and then run my python script.\nHowever, I want to automate the process of loading ply file, do the required operations and save back the result in ply format so that all the files can be processed one by one with minimum manual work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1414,"Q_Id":20634301,"Users Score":1,"Answer":"I finally got the solution to the problem. \n1. Invoke blender through command line\nblender.exe --background --python yourFile.py\n2. In your python file, you could use the modules provided by blender such as import_ply\n(....Blender\/2.68\/scripts\/addons\/import_ply), etc. Just go through the module and you will be able to use the function written inside and manage to write code according to your need.","Q_Score":2,"Tags":"python,blender-2.67","A_Id":20701809,"CreationDate":"2013-12-17T12:35:00.000","Title":"How can I load a .ply file in blender-2.68 and apply modifier to it through command line\/script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to import a .csv file using pandas.read_csv(), however, I don't want to import the 2nd row of the data file (the row with index = 1 for 0-indexing).\nI can't see how not to import it because the arguments used with the command seem ambiguous:\nFrom the pandas website:\n\nskiprows : list-like or integer\nRow numbers to skip (0-indexed) or number of rows to skip (int) at the\nstart of the file.\"\n\nIf I put skiprows=1 in the arguments, how does it know whether to skip the first row or skip the row with index 1?","AnswerCount":6,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":269629,"Q_Id":20637439,"Users Score":-2,"Answer":"skip[1] will skip second line, not the first one.","Q_Score":121,"Tags":"python,pandas,csv,readfile","A_Id":55944660,"CreationDate":"2013-12-17T14:59:00.000","Title":"Skip rows during csv import pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently I've been working on a PyQt program. In the beginning I used python re module to process the regex, but the transformation between python string and QString makes me confused. So I tried to change QRegExp.\nHowever, I want to use the IGNORECASE, MULTILINE, DOTALL of the python re. I've found the QRegExp.setCaseSensitivity() to replace the re.I, but I can't find the rest two features. Can anybody help?\nOr tell me how to transform the QString to python string? Both the regex pattern and data are input by the user, so their types are QString.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":607,"Q_Id":20660579,"Users Score":0,"Answer":"Just to post an answer on this side of things...\nIn most cases I've played with, the DOTALL \"(.*?)\" approach doesn't seem to match anything when it comes to QRegExp().\nHowever, here's something I use that works in almost all my cases for matching triple-quoted strings:\nsingle: \"[^#][uUbB]?[rR]?(''')[^']*(''')\"\ndouble: '[^#][uUbB]?[rR]?(\"\"\")[^\"]*(\"\"\")'\nThe only cases that don't work: ''' ' ''' and \"\"\" \" \"\"\".\nbest thing I could find for now...\nEDIT:\nif I don't have those as the stop characters, it continues to match through the rest of the document.","Q_Score":1,"Tags":"python,regex,pyqt4,qregexp","A_Id":32671451,"CreationDate":"2013-12-18T14:17:00.000","Title":"Can QRegExp do MULTILINE and DOTALL match?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to machine learning and wondering the difference between kmeans and kmeans2 in scipy. According to the doc both of them are using the 'k-means' algorithm, but how to choose them?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3357,"Q_Id":20661142,"Users Score":7,"Answer":"Based on the documentation, it seems kmeans2 is the standard k-means algorithm and runs until converging to a local optimum - and allows you to change the seed initialization. \nThe kmeans function will terminate early based on a lack of change, so it may not even reach a local optimum. Further, the goal of it is to generate a codebook to map feature vectors to. The codebook itself is not necessarily generated from the stoping point, but will use the iteration that had the lowest \"distortion\" to generate the codebook. This method will also run kmeans multiple times. The documentation goes into more specifics. \nIf you just want to run k-means as an algorithm, pick kmeans2. If you just want a codebook, pick kmeans.","Q_Score":10,"Tags":"python,machine-learning,scipy,k-means","A_Id":20661301,"CreationDate":"2013-12-18T14:44:00.000","Title":"What's the difference between kmeans and kmeans2 in scipy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to establish a \"supports-screens\" kind of configuration to make my application available only for normal and large screens android devices.is there a way to do this with the build.py script?(i have bets on --intent-filters option but not sure how it might be used)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":20666947,"Users Score":1,"Answer":"There is no way to do it from the build.py. However, you can change manually the templates\/AndroidManifest.xml.tmpl and adapt it for your needs.","Q_Score":1,"Tags":"android,python-2.7,kivy","A_Id":22365294,"CreationDate":"2013-12-18T19:40:00.000","Title":"screen support in kivy set to normal and large screens","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a program with python that downloads a large .scd file, unpacks it, and then installs it. It is not at all difficult for me to download it or install it, (which is pretty much just using urllib and moving a few files around) but unpacking it seems to be a problem. After a couple hours of Googling I can't seem to find any modules for Python capable of opening .scd archives. One idea is to try to convert is to a .zip file with Python, replace the .scd with that, and the just use zipfile.extractall(). I am fine with this if someone can tell me how to do the conversion. The conversion\/extraction MUST be automated.\nEDIT: It is OK with me if a use 3rd party software, but I still would like the following things: the process must be totally automated, (the user does not have to hit an extract button or anything along those lines) the 3rd party software must have a license that allows me to use it as part of my Python program, (and distribute it as part of my program's package to the general public) and the software is compatible with Windows.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":459,"Q_Id":20684509,"Users Score":1,"Answer":"OK, after numerous hours on google I found out that .scd's are basically .zip's with a 0% compression rate. Try using the built in zipfile module on your file as though it were a .zip.","Q_Score":2,"Tags":"python,python-3.x","A_Id":20714626,"CreationDate":"2013-12-19T14:40:00.000","Title":"Open .scd files in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I dont even know if this is possible. But if it is, can someone give me the broadstrokes on how I can use a Python script to populate a Google spreadsheet?\nI want to scrape data from a web site and dump it into a google spreadsheet. I can imagine what the Python looks like (scrapy, etc). But does the language support writing to Google Drive? Can I kick off the script within the spreadsheet itself or would it have to run outside of it?\nIdeal scenario would be to open a google spreadsheet, click on a button, Python script executes and data is filled in said spreadsheet.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3149,"Q_Id":20693168,"Users Score":0,"Answer":"Yes, it is possible and this is how I am personally doing it so.\nsearch for \"doGet\" and \"doPost(e)","Q_Score":0,"Tags":"python,google-sheets","A_Id":50629830,"CreationDate":"2013-12-19T22:45:00.000","Title":"Is this possible - Python script to fill a Google spreadsheet?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a program where when you press a keyboard key it plays the next sound in a list of sounds (preferably using C++ or python), but I want this to work in any program (Microsoft Word etc.) and just be running in the background. I have no idea how to do this or even where to look.\nAlso, if anyone knows a good link for learning how to make a program read midi files, that would be nice too.\nThanks a lot.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":231,"Q_Id":20693528,"Users Score":0,"Answer":"You need to search for Keyboard Hooks.\nMost systems provide a away for you to ask to see any events that go by, either all events, or a subset (keyboard\/mouse\/etc). This can then be used to respond to them. Its used by  Macro software such as AutoHotKey, and by Keyloggers, that try to capture peoples passwords and such.\nIf you search for keylogger software, you will probably find some simple examples of use.","Q_Score":0,"Tags":"c++,python,input,keyboard,background-process","A_Id":20693595,"CreationDate":"2013-12-19T23:13:00.000","Title":"How do I run a keyboard program in the background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to work out a method for dynamically generating image files with PIL\/Pillow that are a certain file size in order to better exercise certain code paths in my unit tests.\nFor example, I have some image validation code that limits the file size to 100kb.  I'd like to generate an image dynamically that is 150kb to ensure that the validation works.  It needs to be a valid image and within given dimensions (ie 400x600).\nAny thoughts on how to add sufficient \"complexity\" to an image canvas for testing?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":652,"Q_Id":20695601,"Users Score":1,"Answer":"Does it have to be exactly 150kb, or just somewhere comfortably over 100kb? \nOne approach would be to create a JPEG at 100% quality, and insert lots of (random) text into all the available EXIF and IPTC headers. Including a large thumbnail image will also push the size up. \n(And like Bo102010 suggested, you could also use random RGB values to minimise the compression.)","Q_Score":5,"Tags":"python,unit-testing,python-imaging-library,pillow","A_Id":23596144,"CreationDate":"2013-12-20T03:00:00.000","Title":"Dynamically generate valid image of a certain filesize for testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a newbie here, and much of what I have learned about django and python have come from this website.  Thank you all for being so helpful!  This is my first question post.\nI've got 2 problems as I try to extend what I've learned from the Django tutorial (1.6) and try to get the Polls app to load via AJAX.  I want to use the main mysite app as a home page, and pull in content from other apps in the mysite project using ajax.  The tutorial doesn't really cover integrating content from different apps on a single page.\nI have 2 ajax elements already working on the main mysite page (a \"trick or treat\" button that retrieves some silly text, and a small dns lookup form\/button) but those are part of the mysite app, so all of the logic is handled using the mysite app urlconf, views and templates.\nThere is another div on the page which is for a \"Featured App\" that will get pulled in, also via ajax.  Basically, mysite.views builds a list of apps that have a 'ajaxFeaturedAppView', and then chooses one at random to display in the \"Featured App\" section on the mysite page. This is my novice attempt at decoupling the mysite app from the other apps as much as possible.\nProblem 1)  The initial poll question and choices and vote button all appear correctly on page load, but the vote button just loads another poll question.  It should display poll results.\nProblem 2)  The other ajax elements on the page get triggered when I hit the Vote button, also.  I think this is because the Vote button action triggers the document ready() event, which initializes the ajax elements.  But the other ajax elements don't do that; they do not trigger the document ready() event.\nI think that it may be one problem with two symptoms, actually.  So, how do I get the vote button to not trigger a document ready event, and will that allow me to see the poll results?  Or am I doing something else wrong?  \nEDIT: \nOkay, there were a few problems with that pieced-together code.  Thanks for the help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":356,"Q_Id":20750119,"Users Score":1,"Answer":"This is a frequent mistake when writing JavaScript. You haven't disabled the default actions on click or submit. This means that the JS execute, calling the ajax, but then immediately the normal browser submit is also executed, causing a refresh.\nvoteBehavior should accept an event parameter, and you should call event.preventDefault() at the start of the function.","Q_Score":0,"Tags":"jquery,python,ajax,django","A_Id":20750187,"CreationDate":"2013-12-23T19:42:00.000","Title":"AJAX and Django using the polls app from the tutorial: 2 problems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My question is the following, I have sublime 2 and sublime repl plugin installed all working fine, the only thing i need is to change the version of python that is running on the sublimerepl built in console. What I mean is, I have python 2.7.5 (which is pre installed with maveriks) running fine in sublime (via sublimerepl), and I have installed via the installer from python.org, python 3.3.3 , that I need to use, I want to run this version of python on the sublimerepl console but I don't know how.\nI know that there are alternatives to sublime but none of those are so beautiful as sublime is.\nCan someone help me with this ? I've searched for all over the internet and couldn't find anything helpful.\nBtw if I use terminal python 3.3.3 is working fine (Terminal>'python3'), I know this is possible beacause a friend of mine got it working and I have installed mine like he did, but mine is not working.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6952,"Q_Id":20777307,"Users Score":0,"Answer":"I would suggest to change the directory to\n\/Library\/Frameworks\/Python.framework\/Versions\/Current\/bin\/python3\nThis way whenever you update python, SublimeREPL will always get the updated version.","Q_Score":5,"Tags":"python,macos,sublimetext,read-eval-print-loop,sublimerepl","A_Id":65398436,"CreationDate":"2013-12-25T22:33:00.000","Title":"How to run Python 3 in Sublime 2 REPL Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I configure windows command dialog to run different python versions in it? For example when I type python2 it runs python 2.7 and when I type python3 it runs python 3.3? I know how to configure environment variables for one version but two? I mean something like Linux terminal.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":170536,"Q_Id":20786478,"Users Score":47,"Answer":"I also met the case to use both python2 and python3 on my Windows machine. Here's how i resolved it: \n\ndownload python2x and python3x, installed them. \nadd C:\\Python35;C:\\Python35\\Scripts;C:\\Python27;C:\\Python27\\Scripts to environment variable PATH.\nGo to C:\\Python35 to rename python.exe to python3.exe, also to C:\\Python27, rename python.exe to python2.exe.\nrestart your command window. \ntype python2 scriptname.py, or python3 scriptname.py in command line to switch the version you like.","Q_Score":32,"Tags":"python,windows,python-2.7,python-3.x,cmd","A_Id":34838251,"CreationDate":"2013-12-26T14:27:00.000","Title":"How to run different python versions in cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a game using Ren'py (based on python) and most errors aren't shown, especially the errors in python code. Is there a possibility to check for possible errors at compile time and how do I get where some errors occur? If there are errors the game normally doesn't run or breaks at the a errors appearance without a message.Is there maybe a file, where they are written in or something like that? Or do I have to debug using logs everywhere?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":2449,"Q_Id":20793740,"Users Score":1,"Answer":"Compile errors will be shown when you first try to compile the RPY files.  They will be put in \"errors.txt\" in your project directory.  Most errors are not found at compile-time, however, and will only show up once you encounter them at run-time.\nYou can use Lint to check for some common errors (It's called \"Check Script (Lint)\"), but mostly you'll have to playtest to ensure there are no errors.  Errors during playback should pop up a gray screen showing the error and traceback with the option to Ignore, Rollback, or Quit.  Is this screen not showing up for you?","Q_Score":2,"Tags":"python,error-handling","A_Id":28821129,"CreationDate":"2013-12-27T02:01:00.000","Title":"How do I handle errors in Ren'py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm making a game using Ren'py (based on python) and most errors aren't shown, especially the errors in python code. Is there a possibility to check for possible errors at compile time and how do I get where some errors occur? If there are errors the game normally doesn't run or breaks at the a errors appearance without a message.Is there maybe a file, where they are written in or something like that? Or do I have to debug using logs everywhere?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2449,"Q_Id":20793740,"Users Score":0,"Answer":"If you're looking for some kind of intellisense like you have for some languages, where as you write the code the IDE shows errors, then it doesn't exist. You have to launch the game so that the code is compiled, just then Ren'py will show you errors. You can see them in the editor or in the errors.txt that Ren'Py creates. To test you python code you can launch the game and type Shift + O to open the console.","Q_Score":2,"Tags":"python,error-handling","A_Id":56918348,"CreationDate":"2013-12-27T02:01:00.000","Title":"How do I handle errors in Ren'py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Lets say I have directory with subdirectories where are projects stored.\nHow to lock Python script inside that subdirectory ? That it can not scan parent directories, read files, import etc. Is it possible with mod_wsgi ?\nAnd how to disable any python functions ?\nThank","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":20808909,"Users Score":0,"Answer":"There are two options. Use mod_wsgi daemon mode and run the daemon process as a distinct user. Then lock down all your file permissions appropriately to deny access from that user. The second is that mod_wsgi daemon mode also supports a chroot option. Using a chroot is obviously a lot more complicated to set up however.","Q_Score":0,"Tags":"python,apache,mod-wsgi","A_Id":20809616,"CreationDate":"2013-12-27T22:52:00.000","Title":"Apache: python directory restriction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following set-up\n\nA Python script\nA Mac OSX Automator application with said script\nAn iCal alert that runs the Automator (and thus the Python script) on a regular schedule\n\nAll of the above works just fine. But I need to make a change. I need the script to check a web site for a time in the future (that same day) and then come back prior to that time and run itself again. I know how to do the first part (get the time) but I have no clue how to do the second part. How do you get a Python script to (1) run itself at a regular time and then (2) run again at some point in the future? The point in the future will change on a regular basis. Sometimes it would be as early as 10AM, other times it may be 7PM. \nAny thoughts on this and pseudo-code are welcome. Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":20816257,"Users Score":0,"Answer":"Set a variable to the future time, and check it in a while() loop","Q_Score":0,"Tags":"python,macos,automation","A_Id":20816671,"CreationDate":"2013-12-28T15:38:00.000","Title":"Architecture for a self-running Python script on Mac OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to PyCharm and haven't been able to figure out what I'm sure is a very simple thing -- what's the key stroke to go to the top of the current file? \n(Bonus question -- is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?)","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":8443,"Q_Id":20817133,"Users Score":1,"Answer":"Another way is to navigate to the first line using goto line: Ctrl-G and then 1. But this will move the cursor to the first line.\nA small disadvantage is it is a two step process and adds a navigation step. Moving back to your previous location with CtrlAlt-< will have to be done in two steps if you do an edit.","Q_Score":23,"Tags":"python,django,pycharm","A_Id":63396738,"CreationDate":"2013-12-28T17:07:00.000","Title":"In PyCharm, how to navigate to the top of the file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to PyCharm and haven't been able to figure out what I'm sure is a very simple thing -- what's the key stroke to go to the top of the current file? \n(Bonus question -- is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?)","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8443,"Q_Id":20817133,"Users Score":19,"Answer":"You navigate to the top of the file using Ctrl+Home. It moves cursor too. So does navigating via Page Up and Page Down keys.\nCtrl+Up and Ctrl+Down move the view without moving cursor but scrolling the long file takes some time.\nAdditionally You can change the keymap (Settings > Keymap). There is 'Scroll to Top' in 'Editor Actions'. You can use Your own key binding for this action, by default (in PyCharm 4 and later) it is not set.","Q_Score":23,"Tags":"python,django,pycharm","A_Id":20817174,"CreationDate":"2013-12-28T17:07:00.000","Title":"In PyCharm, how to navigate to the top of the file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"New to Python & Sublime\nProblem:\nI type 'print (\"Hello world\")\nHow do I get it to show me the output (Hello world), is it in a separate window? or...\nI understand I can use the Python Console built in, but that's a command line, what about when I get to use a ton of code, how do I get the output?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":29017,"Q_Id":20832826,"Users Score":8,"Answer":"Click on tools > build systems > select Python, then Build with using ctr+shif B and select python, and it ll work. Second time you can use the build command, ctr + B since python is now set as default","Q_Score":7,"Tags":"python,python-3.x,sublimetext","A_Id":33468290,"CreationDate":"2013-12-30T03:17:00.000","Title":"Display Python Output in Sublime text","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Flask and I want to show the user how many visits that he has on his website in realtime.\nCurrently, I think a way is to, create an infinite loop which has some delay after every iteration and which makes an ajax request getting the current number of visits. \nI have also heard about node.js however I think that running another process might make the computer that its running on slower (i'm assuming) ?\nHow can I achieve the realtime updates on my site? Is there a way to do this with Flask?\nThank you in advance!","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":5285,"Q_Id":20847122,"Users Score":1,"Answer":"In my opinion, the best option for achieving real time data streaming to a frontend UI is to use a messaging service like pubnub. They have libraries for any language you are going to want to be using. Basically, your user interfaces subscribe to a data channel. Things which create data then publish to that channel, and all subscribers receive the publish very quickly. It is also extremely simple to implement.","Q_Score":3,"Tags":"javascript,python","A_Id":31151979,"CreationDate":"2013-12-30T20:36:00.000","Title":"How to achieve realtime updates on my website (with Flask)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Aptana Studio is my primary Python IDE and I have been using it for years with much joy and success! Recently, when I start Aptana Studio it fails to recognize any PyDev projects that I have previously created. I noticed that this was happening after installing a recent update of the IDE. I tried uninstalling Aptana and resinstalling the latest version from the website. Nada...I updated Java thinking there might be a misalignment between Java versions or something like that. Nada...The latest version of Eclipse works fine and Aptana seems to be functioning correctly for everything except for PyDev (Python).\nI am running a current version of Windows 8. Does anyone know how to fix this or maybe trouble shoot the problem? PyDev worked perfectly in Aptana Studio until I installed the update. Has anyone come across this and know how to fix it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":666,"Q_Id":20847649,"Users Score":0,"Answer":"Aptana 3.5.0 and PyDev 3.0 does not work under Mac OS X 10.9 Mavericks yet. PyDev reports builtin symbols such as None could not be recognized.\nI rolled back to 3.4.2 as well.","Q_Score":0,"Tags":"python,aptana,pydev","A_Id":21073033,"CreationDate":"2013-12-30T21:11:00.000","Title":"PyDev won't start in Aptana Studio3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Aptana Studio is my primary Python IDE and I have been using it for years with much joy and success! Recently, when I start Aptana Studio it fails to recognize any PyDev projects that I have previously created. I noticed that this was happening after installing a recent update of the IDE. I tried uninstalling Aptana and resinstalling the latest version from the website. Nada...I updated Java thinking there might be a misalignment between Java versions or something like that. Nada...The latest version of Eclipse works fine and Aptana seems to be functioning correctly for everything except for PyDev (Python).\nI am running a current version of Windows 8. Does anyone know how to fix this or maybe trouble shoot the problem? PyDev worked perfectly in Aptana Studio until I installed the update. Has anyone come across this and know how to fix it?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":666,"Q_Id":20847649,"Users Score":0,"Answer":"I went back to the Aptana website and this time around it gave me Aptana Studio 3, build: 3.4.2.201308081805 which works fine. 3.5.0 does still not appear to work for Python development at the moment.","Q_Score":0,"Tags":"python,aptana,pydev","A_Id":20851621,"CreationDate":"2013-12-30T21:11:00.000","Title":"PyDev won't start in Aptana Studio3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how can i  get a list of all built-in objects in python recursively?\nwhat i'm exactly searching for is a function like dir() which returns a list of objects instead of strings.\nalso, why does \"dir(__builtins__.print)\" fail in python's interactive mode with a syntax error?\nthanks for your answers!","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":23981,"Q_Id":20852789,"Users Score":4,"Answer":"A dictionary of key value pairs: __builtins__.__dict__\nOnly the objects: __builtins__.__dict__.values()\nThese will give you a list of a dictionary you can iterate over to your hearts content!\nEDIT: Not recommended, see below comment and that users answer","Q_Score":1,"Tags":"python","A_Id":20852864,"CreationDate":"2013-12-31T06:18:00.000","Title":"How can i get a list of all built-in objects in python recursively?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is a Python interpreter in naclports (to run as Google Chrome Native Client App).\nAre there any examples for bundling the interpreter with a custom Python application and how to integrate this application with a HTML page?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":779,"Q_Id":20854222,"Users Score":2,"Answer":"The interpreter is currently the only python example in naclports.   However, it should be possible to link libpython into any nacl binary, and use it just as you would embed python in any other C\/C++ application.   A couple of caveats: you must initialize nacl_io before making any python calls, and as you should not make python calls on the main (PPAPI) thread.\nIn terms of interacting with the HTML page, as with all NaCl applications this must be done by sending messages back and forth between native and javascript code using PostMessage().  There is no way to directly access the HTML or JavaScript from native code.","Q_Score":1,"Tags":"python,google-nativeclient","A_Id":20912809,"CreationDate":"2013-12-31T08:24:00.000","Title":"Practical use of Python as Chrome Native Client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a web2py application where I have written various modules which hold business logic and database related stuff. In one of the files I am trying to access auth.settings.table_user_name but it doesn't work and throws and error as global name 'auth' is not defined. If I write the same line in controller, it works. But I want it to be accessed in module file. Please suggest how do I do that.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2882,"Q_Id":20856854,"Users Score":0,"Answer":"I was getting a very similar error (\"name 'auth' is not defined\"). Had to add from django.contrib import auth at the top of views.py and it worked.","Q_Score":1,"Tags":"python,web2py","A_Id":54032848,"CreationDate":"2013-12-31T11:44:00.000","Title":"auth is not available in module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a Django app that has several database backends - all connected to different instances of Postgresql database. One of them is not guaranteed to be always online. It even can be offline when application starts up.\nCan I somehow configure Django to use lazy connections? I would like to:\n\nTry querying\nreturn \"sorry, try again later\" if database is offline\nor return the results if database is online\n\nIs this possible?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":380,"Q_Id":20878709,"Users Score":2,"Answer":"The original confusion is that Django tries to connect to its databases on startup. This is actually not true. Django does not connect to database, until some app tries to access the database.\nSince my web application uses auth and site apps, it looks like it tries to connect on startup. But its not tied to startup, its tied to the fact that those app access the database \"early\".\nIf one defines second database backend (non-default), then Django will not try connecting to it unless application tries to query it.\nSo the solution was very trivial - originally I had one database that hosted both auth\/site data and also \"real\" data that I've exposed to users. I wanted to make \"real\" database connection to be volatile. So I've defined separate psql backend for it and switched default backend to sqlite. \nNow when trying to access \"real\" database through Query, I can easily wrap it with try\/except and handle \"Sorry, try again later\" over to the user.","Q_Score":1,"Tags":"python,django,django-models","A_Id":21235393,"CreationDate":"2014-01-02T08:01:00.000","Title":"Lazy psql connection with Django","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here goes a difficult one for the expert Numpyer!\nDoes someone know or can come up with a way to use pure Numpy arrays and functions to draw as well as fill colored polygons on top of a numpy array grid? \nThis I think would take two steps:\n\nThe ability to fill the grid array with color values so that the\npolygon filling could be written in one color, and the outline in\nanother one. What would be ideal and fastest for such a system, eg\ntuples of rgb values, color name strings, etc?\nThe ability to draw and fill the inside of a polygon based on an\narray of its pixel coordinates. Drawing the outline of it I think\nshould be pretty easy by just using the coordinates as indexes to\nthe grid array and setting them to the outline color values. More\ndifficult would be to fill the polygon. One way would be to iterate\nthrough all pixel cell coordinates (or better yet only for the\nneighboring cells of each polygon coordinate point) and test if its\ncoordinates are within the polygon pixel coordinates. I know there\nare some simple inside-outside\/biggerthan-smallerthan algorithms to\ntest for point in poly using regular Python, but for my purpose this\nwould be too slow and I am wondering if someone has the numpy skills\nto set up such an advanced linked code using only the speed of the\nnumpy builtin functions to return True if a numpy pixel coordinate\nis inside a polygon.\nLastly, if someone would know how to draw a line between two\npixel\/grid\/array coordinates by filling in all the cells in between\ntwo pixels with a True or color value?\n\nI know this is a tall order, but I was just curious to see if anyone would know. If so, then this could make for a pretty powerful and fast Numpy-based drawing library. In the end I would like to save the grid array as an image which is easy by passing it to PIL. \nI am aware that PIL and Aggdraw can do the polygon drawings and that this has been suggested in many similar posts, but they are not very effective when receiving a numpy array of xy polygon\/line coordinates. The assumption here is that my polygon coordinates are already in a numpy array format and I want to avoid the overhead of having to copy them into lists for every drawing (when we're talking about thousands of polygons frequently). So the difference in this post is about how to fill a polygon using pure Numpy.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2144,"Q_Id":20897140,"Users Score":1,"Answer":"In this case the point to achieve speed is more the used algorithms than the language of choice. Drawing and filling poligons rasterized over a grid of pixel falls into the domain of image processing algorithms and for sure AggDraw is using algorithms from that field.\nThe idea is that if you evaluate for each points a function that considers the vectorial nature of the polygon you need to do a number of operations that is at least O(2*p*A) where:\n\nA = image area\np = average number of points in the perimeter of the polygons.\n\nConversely if you use image processing algorithms for each point you can consider to have a fixed and low number of operations. For example if you consider the FloodFill algorithm it is O(A) and I can say it is less than 30*A (about 30 operations per pixel).\nSo basically since the GADM polygons has many vertex is better to eliminate the vectorial nature of the problem as soon as possible and go with something like this:\n\nconstruct the pixel map of the boundary\nfind one internal pixel\nuse the Floodfill algorithm that will work without any need to know about polygons as vectorial entities\n\nThe same algorithms can for sure be implemented in Numpy but before going for a Numpy graphical lib I would suggest to do the following:\n\nmeasure the time spent in your code for the various steps:\n\nNumpy array to AggDraw lists\/sequences conversion\ntime taken by AggDraw\n\ntry to decimate the vertex of the polygons removing the ones that stay in the same pixel based on the current Zoom level and see if an how the times will be reduced","Q_Score":3,"Tags":"python,image,numpy,fill,polygons","A_Id":20914427,"CreationDate":"2014-01-03T05:28:00.000","Title":"How to draw and fill a polygon on a grid array using pure Numpy functions?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to execute my python code on the side even though there might be security problem \nHow can I write with importing modules and all?\n    I have tried using of pyjs to convert the below code to JS\nimport socket\nprint socket.gethostbyname_ex(socket.gethostname())[2][0]\nbut I am not find how to do the same.\nPlease help me how to how can convert this to JS and how to write other the python scripts and how to  import modules in HTML.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":152,"Q_Id":20900530,"Users Score":1,"Answer":"There are more than just security problems. It's just not possible. You can't use the Python socket library inside the client browser. You can convert Python code to JS (probably badly) but you can't use a C based library that is probably not present on the client. You can access the browser only. You cannot reliably get the hostname of the client PC. Maybe ask another question talking about what you are trying to achieve and someone might be able to help","Q_Score":0,"Tags":"javascript,html,python-2.7,pyjamas","A_Id":20901453,"CreationDate":"2014-01-03T09:36:00.000","Title":"How to Write Python Script in html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to choose a random seed for numpy.random and save it to a variable.  I can set the seed using numpy.random.seed(seed=None) but how do you get numpy to choose a random seed and tell you what it is?\nNumber seems to use \/dev\/urandom on linux by default.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":6170,"Q_Id":20911147,"Users Score":1,"Answer":"When people need a random seed that can be recorded, people usually use the system time as a random seed. This means your program will act differently each time it is run, but can be saved and captured. Why don't you try that out?\nIf you don't want to do that for some reason, use the null version, numpy.random.seed(seed=None), then get a random number from it, then set the seed to that new random number.","Q_Score":11,"Tags":"python,numpy","A_Id":20911192,"CreationDate":"2014-01-03T19:20:00.000","Title":"Choose random seed and save it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a class called Mobilesuits and each instance of that class has an attribute called coordinates, which consists of its grid coordinates, which are in a list(x,y,z).\nI am trying to make a radar method which would detect how close a given vehicle is to other vehicles, but can't find a way to reference every objects coordinates simultaneously. Is there an easy way to do this in Python? I don't want to have to maintain a list of all vehicles and every time I want to perform a global change go through the whole list with a for loop, but that is the only way I can think of.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":20916549,"Users Score":0,"Answer":"I don't want to have to maintain a list\n\nIt's what you are meant to do; and you would have to use loops anyway. You're effectively asking the language to create a list for you automatically. Well, why would it? Contrary to what you might expect, you almost always will not need or want a list of every single instance of a class ever created. In fact, it's entirely possible that you don't even really want that for your current program (whether you yet realize it or not). There are all kinds of possible reasons, in practice, why you might want to create instances that are not subject to the \"usual\" handling.","Q_Score":2,"Tags":"python","A_Id":20916569,"CreationDate":"2014-01-04T03:40:00.000","Title":"How do I reference all class instances at the same time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a webscraping project, and I am running into problems with cloudflare scrapeshield. Does anyone know how to get around it? I'm using selenium webdriver, which is getting redirected to some lightspeed page by scrapeshield. Built with python on top of firefox. Browsing normally does not cause it to redirect. Is there something that webdriver does differently from a regular browser?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4617,"Q_Id":20931426,"Users Score":1,"Answer":"See, what scrapeshield does is checking if you are using a real browser, it's essentially checking your browser for certain bugs in them. Let's say that Chrome can't process an IFrame if there is a 303 error in the line at the same time, certain web browser react differently to different tests, so webdriver must not react to these causing the system to say \"We got an intruder, change the page!\". I might be correct, not 100% sure though... \nMore Info on source:\nI found most of this information on a Defcon talk about web sniffers and preventing them from getting the proper vulnerability information on the server, he made a web browser identifier in PHP too.","Q_Score":7,"Tags":"python,selenium,web-scraping,cloudflare","A_Id":23142928,"CreationDate":"2014-01-05T08:04:00.000","Title":"Bypassing Cloudflare Scrapeshield","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using tastypie and I want to create a Resource for a \"singleton\" non-model object. \nFor the purposes of this question, let's assume what I want the URL to represent is some system settings that exist in an ini file.\nWhat this means is that...:\n\nThe fields I return for this URL will be custom created for this Resource - there is no model that contains this information.\nI want a single URL that will return the data, e.g. a GET request on \/api\/v1\/settings.\nThe returned data should return in a format that is similar to a details URL - i.e., it should not have meta and objects parts. It should just contain the fields from the settings.\nIt should not be possible to GET a list of such object nor is it possible to perform POST, DELETE or PUT (this part I know how to do, but I'm adding this here for completeness).\nOptional: it should play well with tastypie-swagger for API exploration purposes.\n\nI got this to work, but I think my method is kind of ass-backwards, so I want to know what is the common wisdom here. What I tried so far is to override dehydrate and do all the work there. This requires me to override obj_get but leave it empty (which is kind of ugly) and also to remove the need for id in the details url by overriding override_urls.\nIs there a better way of doing this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1156,"Q_Id":20933214,"Users Score":1,"Answer":"This sounds like something completely outside of TastyPie's wheelhouse. Why not have a single view somewhere decorated with @require_GET, if you want to control headers, and return an HttpResponse object with the desired payload as application\/json?\nThe fact that your object is a singleton and all other RESTful interactions with it are prohibited suggests that a REST library is the wrong tool for this job.","Q_Score":8,"Tags":"python,django,rest,tastypie","A_Id":21005266,"CreationDate":"2014-01-05T11:51:00.000","Title":"Creating a tastypie resource for a \"singleton\" non-model object","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am attempting to create a django based website.  The goal of one part of the site is to show the contents of a database in reference to its file structure.  \nI would like to keep the URL the same while traveling deeper into the file structure, as opposed to developing another view for each level of the file structure a person goes into.\nThe simplest way I can think to achieve this is to pass the current directory path in the request variable but I am not sure how to do this or if it is possible since it would have to be linked in the html file, and not the view file that is written in python.  \nIf you are able to at very least point me in the right direction it would be greatly appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":163,"Q_Id":20954090,"Users Score":0,"Answer":"I would suggest looking into forms on the Django documentation site. When the user submits the form the appropriate file structure information will be passed to your view code. The view code can then pass the new file structure information to your template. The template will create the forms and the process will start over again.","Q_Score":0,"Tags":"python,django,url,filepath,file-structure","A_Id":20954419,"CreationDate":"2014-01-06T16:07:00.000","Title":"Keep URL while surfing data Structure in Django web app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a (large) directory CSV with columns [0:3] = Phone Number, Name, City, State.\nI created a random sample of 20,000 entries, but it was, of course, weighted drastically to more populated states and cities.\nHow would I write a python code (using CSV or Pandas - I don't have linecache available) that would equally prioritize\/weight each unique city and each state (individually, not as a pair), and also limit each unique city to 3 picks?\n\nTRICKIER idea: How would I write a python code such that for each random line that gets picked, it checks whether that city has been picked before.  If that city has been picked before, it ignores it and picks a random line again, reducing the number of considered previous picks for that city by one.  So, say that it randomly picks San Antonio, which has been picked twice before.  The script ignores this pick, places it back into the list, reduces the number of currently considered previous San Antonio picks, then randomly chooses a line again.  IF it picks a line from San Antonio again, then it repeats the previous process, now reducing considered San Antonio picks to 0.  So it would have to pick San Antonio three times in a row to add another line from San Antonio.  For future picks, it would have to pick San Antonio four times in a row, plus one for each additional pick.\nI don't know how well the second option would work to \"scatter\" my random picks - it's just an idea, and it looks like a fun way to learn more pythonese.  Any other ideas along the same line of thought would be greatly appreciated.  Insights into statistical sampling and sample scattering would also be welcome.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":114,"Q_Id":20984266,"Users Score":2,"Answer":"There are many ways to implement this, but the abstract algorithm should be something like this.\nFirst, to create a new CSV that meets your second critera about each state being drawn with equal probability, draw each row as follows. \n1) From the set of states, draw a state (each state is drawn with probability 1 \/ # of states). Let that state be s.\n2) From the large CSV, draw a row from the set of rows where STATE = s. \nAs you draw rows, keep a record of the number of rows drawn from a given state\/city pair. You could do this with a dictionary. Then, each time you draw a successive row, if there are any state\/city pairs equal to the cap set by the user, exclude those state\/city pairs from your conditional draw in step 2 above. This will satisfy your first requirement. \nDoes that make sense? If you get started with a bit of code that attempts to implement this, I'll happily tidy it up for you if it has any problems. \nIf you wanted to do the \"somewhat trickier\" algorithm in which the probability of selecting a city decreases with each selection, you could do that without much trouble. Basically, condition on the cities within state s after you draw s, then weight according to the number of times each city in that state has been drawn (you have this information because you've been storing it to implement the first requirement). You'll have to come up with the form of the weighting function, as it isn't implied by your description. \nAgain, if you try to code this up, I'm happy to take a look at any code you post and make suggestions.","Q_Score":0,"Tags":"python,python-2.7,csv,random,pandas","A_Id":20984538,"CreationDate":"2014-01-07T23:39:00.000","Title":"Dispersing Random Sampling in CSV through Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for a PyQt5 tutorial. It is rather complicated to start GUI development with Python for the first time without a tutorial.\nI only found some PyQt4 tutorials so far, and since something changed from Qt4 to Qt5, for example the fact SIGNAL and SLOT are no more supported in Qt5, it would be nice to have specific tutorials for PyQt5.\nCan someone please provide a tutorial on how to start GUI development with PyQt5?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":57823,"Q_Id":20996193,"Users Score":29,"Answer":"Been looking for PyQt5 tutorials for some time? Look no further! You won't find many around the internet. \nNot really tutorials, but pretty self-explanatory basic scripts under the following path:\n\n\/python\/lib\/site-packages\/PyQt5\/examples \n\nyou will find about 100 examples in 30 folders ranging from beginner to advanced, covering basic windows, menus, tabs, layouts, network, OpenGL, etc.","Q_Score":65,"Tags":"python,user-interface,qt5,pyqt5","A_Id":21359084,"CreationDate":"2014-01-08T12:51:00.000","Title":"Is there a tutorial specifically for PyQt5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am messing around in PsychoPy now, trying to modify the Sternberg demo for a class project. I want the stimulus text\u2014the number set\u2014to display in a variety of colors: say, one digit is red, the next blue, the next brown, etc. A variety within the same stimulus.\nI can only find how to change the color of the entire set. I was wondering if I could add another variable to the spreadsheet accompanying the experiment and have the values in the cells be comma separated (red,blue,brown\u2026). Is this possible?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1012,"Q_Id":21026487,"Users Score":5,"Answer":"No, that isn't possible right now. There's an experimental new stimulus class called TextBox that will allow it, but you'd have to write code to use that (not available yet from the Builder interface). Or just create some tif images of your stimuli and use those?","Q_Score":3,"Tags":"python,text,colors,psychopy","A_Id":21063050,"CreationDate":"2014-01-09T16:57:00.000","Title":"Text with multiple colors in PsychoPy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am messing around in PsychoPy now, trying to modify the Sternberg demo for a class project. I want the stimulus text\u2014the number set\u2014to display in a variety of colors: say, one digit is red, the next blue, the next brown, etc. A variety within the same stimulus.\nI can only find how to change the color of the entire set. I was wondering if I could add another variable to the spreadsheet accompanying the experiment and have the values in the cells be comma separated (red,blue,brown\u2026). Is this possible?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1012,"Q_Id":21026487,"Users Score":2,"Answer":"The current way to implement this is to have a separate text stimulus for each digit, each with the desired colour.\nIf the text representation of the number is contained in a variable called, say, stimulusText then in the Text field for the first text component put \"$stimulusText[0]\" so that it contains just the first digit. In the next text component , use \"$stimulusText[1]\", and so on.\nThe colour of each text component can be either fixed or vary according to separate column variables specified in a conditions file.","Q_Score":3,"Tags":"python,text,colors,psychopy","A_Id":23425589,"CreationDate":"2014-01-09T16:57:00.000","Title":"Text with multiple colors in PsychoPy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having difficulties with writing a Python program that reads from a text file, and builds a dictionary which maps each word that appears in the file to a list of all the words that immediately follow that word in the file. The list of words can be in any order and should include duplicates. \nFor example,the key \"and\" might have the list [\"then\", \"best\", \"after\", ...] listing all the words which came after \"and\" in the text.\nAny idea would be great help.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":363,"Q_Id":21033857,"Users Score":1,"Answer":"A couple of ideas:\n\nSet up a collections.defaultdict for your output. This is a dictionary with a default value for keys that don't yet exist (in this case, as aelfric5578 suggests, an empty list);\nBuild a list of all the words in your file, in order; and \nYou can use zip(lst, lst[1:]) to create pairs of consecutive list elements.","Q_Score":0,"Tags":"python,list,python-2.7,dictionary","A_Id":21034096,"CreationDate":"2014-01-10T00:10:00.000","Title":"how to write a Python program that reads from a text file, and builds a dictionary which maps each word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written a Spider which has one start_url. The parse method of my spider scraps some data and returns a list of FormRequests. \nThe problem comes with the response of that post request. It redirects me to another site with some irrelevant GET Parameters. The only parameter which seems to matter is a SESSION_ID posted along in the header. Unfortunately Scrapys behavior is to execute my requests, one after another and queues the redirect response at the end of the queue. If all returned FormRequests are executed, scrapy starts to execute all redirects, which all return the same site. \nHow can I circumvent this behavior, so that a FormRequest is executed, and the redirect returned in the requests response is executed befor any new FormRequest? Maybe there is another way, like forcing the site somehow to get a new SESSION_ID cookie for each FormRequest. I'm open to any idea that could probably solve the problem.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":302,"Q_Id":21064467,"Users Score":0,"Answer":"I found my own solution to this promlem. Instead of building a list of requests and return them at once, I build a chain of them and passed the next one inside the requests meta_data. \nInside the callback I pass either the next request, storing the parsed item in a spider member, or the parsed list of items if there is no next request to execute.","Q_Score":0,"Tags":"redirect,python-2.7,scrapy,http-post","A_Id":21065555,"CreationDate":"2014-01-11T16:01:00.000","Title":"Handle Redirects one by one with scrapy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to use the standard DatastoreInputReader from AppEngine's mapreduce with entity kind requiring ancestors ?\nLet's say I have an entity kind Domain with ancestor kind SuperDomain (useful for transactions), where do I specify in mapreduce_pipeline.MapreducePipeline how to use a specific SuperDomain entity as ancestor to all queries?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":21068311,"Users Score":0,"Answer":"You cannot specify an ancestor for the DatastoreInputReader -- except for a namespace -- so the pipeline will always go through all your Domain entities in a given namespace.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":21069451,"CreationDate":"2014-01-11T21:48:00.000","Title":"DatastoreInputReader using entity kind with ancestor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just installed python 3.3.3 on my OS X 10.9.1, however when I run python from the terminal the version that is indicated is 2.7.5. What have I done wrong and how can I make it right?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":21069586,"Users Score":0,"Answer":"As per Martijn Pieters's comment, I used python3 and now it works as expected.","Q_Score":1,"Tags":"macos,python-3.x,upgrade","A_Id":21069629,"CreationDate":"2014-01-12T00:07:00.000","Title":"python version doesn't update on OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a listbox on a GUI in Tkinter. I would like to implement a routine where if a listbox item is selected a function is called (based on this selection) to modify the gui (add another adjacent listbox). Then if that selection changes, the gui reverts back to its default view. Can this be done? Seems you would need to associate a function to a listbox selection, not sure how to do this or if its possible... Does anyone have the secret? \nIts possible to add \"select\" buttons to the bottom of my listbox, but I wanted to avoid this extra work for user and save space on the GUI.\nThanks to all in advance! Daniel","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1733,"Q_Id":21078720,"Users Score":0,"Answer":"The listbox will fire the virtual event <<ListboxSelect>> whenever the selection changes. If you bind to it, your function will be called whenever the selection changes, even if it was changed via the keyboard.","Q_Score":0,"Tags":"python,listbox,tkinter","A_Id":21079948,"CreationDate":"2014-01-12T18:40:00.000","Title":"Calling a function based on a Listbox current selection \"curselection()\" in Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a website (which running in Amazon EC2 Instance) running Python Bottle application with CherryPy as its front end web server.\nNow I need to add another website with a different domain name already registered. To reduce the cost, I want to utilize the existing website host to do that. \nObviously, virtual host is the solution. \nI know Apache mod_wsgi could play the trick. But I don't want to replace CherryPy. \nI've googled a a lot, there are some articles showing how to make virtual hosts on CherryPy, but they all assume Cherrypy as Web Sever + Web application, Not CherrPy as Web server and Bottle as Application. \nHow to use CherrPy as Web server and Bottle as Application to support multiple virtual hosts?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":882,"Q_Id":21117002,"Users Score":0,"Answer":"perhaps you can simply put nginx as reverse proxy and configure it to send the traffic to the two domains to the right upstream (the cherryPy webserver).","Q_Score":2,"Tags":"python,virtualhost,cherrypy,bottle","A_Id":21117703,"CreationDate":"2014-01-14T15:13:00.000","Title":"How to use CherrPy as Web server and Bottle as Application to support multiple virtual hosts?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Several questions address the way to make a virtualenv that does include global site-packages. I'm looking for something different: how to create a new virtualenv based on a Python executable from another location in my network, and also to include the libraries that are installed in that location in the network.\nI have a local desktop machine, but there is an IT-maintained version of Python and associated installed libraries, and it is the ubiquitous Python used by developers. I'm using virtualenv to create several local versions of Python that allow me to try out libraries or change settings, but I'd also like to maintain an installation that is nothing but a pure mirror of that IT-maintained system. \nSo the question is how to make a virtualenv that points at that IT-maintained Python, and which does reference the previously installed packages for that Python and not for my local machine's global site-packages, etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":21118740,"Users Score":0,"Answer":"It's not completely the same thing, but you could try running pip freeze > requirements.txt against that version of Python, then using the resulting file inside your virtualenv with pip install -r requirements.txt to install copies of the modules there.","Q_Score":1,"Tags":"python,virtualenv","A_Id":21119115,"CreationDate":"2014-01-14T16:33:00.000","Title":"How to create virtualenv and include non-global associated installed libraries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"(This may not be an appropriate question--if there is a better stack site for it, please let me know.)\nI belong to an organization that distributes sheet music to its users.  Right now, we have to individually download each file, and it's a pain.  Files are frequently updated, and every time there's a new version we have to download the new one, delete the old one, blah blah blah.  \nI've automated the process myself with Python, so when I run my script I have a nice folder with all the current files.  I'm looking for a way to share this with others.  I initially thought Dropbox, but that just requires users to go to my Dropbox folder and still do it all manually (I know there's an option to download as a .zip, but many of our members are not very technically proficient).\nIs there a way to have users sign up and somehow have a folder on their computers download what's in mine?  A helpful Google suggestion may be all I need.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":21141026,"Users Score":0,"Answer":"I would use .. a VCS ? If it were feasible, I'd hack up a windows installer that:\n- installs git\/subversion\/your favorite vcs\n- does an initial checkout\/clone of the repository\n- add a scheduled job to the machine (windows equiv of cronjobs) to run every hour and update the working copies\nCould be done in a couple hours work and should be simple enough that users just need to run the installer and eventually choose the location of where to clone the repo (which directory to place it in). Then from there you push your changes to the repo and the clients computers will check for updates every hour or so.","Q_Score":1,"Tags":"python","A_Id":21144008,"CreationDate":"2014-01-15T15:10:00.000","Title":"Distribute files to users automatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We're using Selenium's Python bindings at work. Occasionally I forget to put the call to WebDriver.quit() in a finally clause, or the tear down for a test. Something bad happens, an exception is thrown, and the session is abandoned and stuck as \"in use\" on the grid.\nHow can I quit those sessions and return them to being available for use without restarting the grid server?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":288,"Q_Id":21168690,"Users Score":0,"Answer":"You can restart the node instead of the server.","Q_Score":0,"Tags":"python,selenium,selenium-grid2","A_Id":21194979,"CreationDate":"2014-01-16T17:26:00.000","Title":"how do I quit a web driver session after the code has finished executing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Preface: I am fully aware that this could be illegal if not on a test machine. I am doing this as a learning exercise for learning python for security and penetration testing. This will ONLY be done on a linux machine that I own and have full control over.\nI am learning python as my first scripting language hopefully for use down the line in a security position. Upon asking for ideas of scripts to help teach myself, someone suggested that I create one for user enumeration.The idea is simple, cat out the user names from \/etc\/passwd from an account that does NOT have sudo privileges and try to 'su' into those accounts using the one password that I have. A reverse brute force of sorts, instead of a single user with a list of passwords, Im using a single password with a list of users.\nMy issue is that no matter how I have approached this, the script hangs or stops at the \"Password: \" prompt. I have tried multiple methods, from using os.system and echoing the password in, passing it as a variable, and using the pexpect module. Nothing seems to be working.\nWhen I Google it, all of the recommendations point to using sudo, which in this scenario, isnt a valid option as the user I have access to, doesnt have sudo privileges. \nI am beyond desperate on this, just to finish the challenge. I have asked on reddit, in IRC and all of my programming wizard friends, and beyond echo \"password\" |sudo -S su, which cant work because the user is not in the sudoers file, I am coming up short. When I try the same thing with just echo \"password\"| su  I get su: must be run from a terminal. This is at a # and $ prompt.\nIs this even possible?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":230,"Q_Id":21179274,"Users Score":-1,"Answer":"If you just want to do this for learning, you can easily build a fake environment with your own faked passwd-file. You can use some of the built-in python encrypt method to generate passwords. this has the advantage of proper test cases, you know what you are looking for and where you should succeed or fail.","Q_Score":4,"Tags":"python,linux,security","A_Id":21179425,"CreationDate":"2014-01-17T06:29:00.000","Title":"Learning python for security, having trouble with su","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program that takes pictures and I am wondering how I would write a program that sends those pictures to a particular URL. \nIf it matters, I am running this on a Raspberry Pi.\n(Please excuse my simplicity, I am very new to all this)","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2487,"Q_Id":21200565,"Users Score":0,"Answer":"The requests library is most supported and advanced way to do this.","Q_Score":0,"Tags":"python,linux,curl","A_Id":21940288,"CreationDate":"2014-01-18T05:46:00.000","Title":"Curl Equivalent in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to use random.randint() to select random names given in a list in python.\nI want to print 5 names from that list. Actually i know how to use random.randint() for numbers. but i don't know how to select random names from a given list.\nwe are not allowed to use random.choice.\nhelp me please","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2543,"Q_Id":21201970,"Users Score":0,"Answer":"Yes, for repeat sample from one population, @MaxLascombe's answer is OK. If you do not want tiles in samples, you should kick the chosen one out. Then use @MaxLascombe's answer on the rest of the list.","Q_Score":0,"Tags":"python,random","A_Id":21202082,"CreationDate":"2014-01-18T08:44:00.000","Title":"randomly choose from list using random.randint in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this is a really dumb question but I've been searching for ages and just can't figure it out.\nSo I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it.\nI get the idea of unit testing, but the only thing I can find on the internet are the very simple unit tests. Like testing if the method sum(a, b) returns the sum of a + b.\nBut how do you apply unit testing when dealing with a more complex program? As an example, I have written a crawler. I don't know what it will return, else I wouldn't need the crawler. So how can I test that the crawler works properly without knowing what the method will return?\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":569,"Q_Id":21203648,"Users Score":0,"Answer":"Unit testing verifies that your code does what you expect in a given environment. You should make sure all other variables are as you expect them to be and test your single method. To do that for methods which use third party APIs, you should probably mock them using a mocking library. By mocking you provide data you expect and verify that your method works as expected. You can also try to separate your code so that the part which makes API request and the part that parses\/uses it are separate and unit test that second part with a certain API example response you provide.","Q_Score":3,"Tags":"python,unit-testing,web-crawler","A_Id":21203787,"CreationDate":"2014-01-18T11:47:00.000","Title":"Python - unit testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if this is a really dumb question but I've been searching for ages and just can't figure it out.\nSo I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it.\nI get the idea of unit testing, but the only thing I can find on the internet are the very simple unit tests. Like testing if the method sum(a, b) returns the sum of a + b.\nBut how do you apply unit testing when dealing with a more complex program? As an example, I have written a crawler. I don't know what it will return, else I wouldn't need the crawler. So how can I test that the crawler works properly without knowing what the method will return?\nThanks in advance!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":569,"Q_Id":21203648,"Users Score":4,"Answer":"The whole crawler would be probably tested functionally (we'll get there). As for unit testing, you have probably written your crawler with several components, like page parser, url recogniser, fetcher, redirect handler, etc. These are your UNITS. You should unit tests each of them, or at least those with at least slightly complicated logic, where you can expect some output for some input. Remember, that sometimes you'll test behaviour, not input\/output, and this is where mocks and stubs may come handy.\nAs for functional testing - you'll need to create some test scenarios, like webpage with links to other webpages that you'll create, and set them up on some server. Then you'll need to perform crawling on webpages YOU created, and check whether your crawler is behaving as expected (you should know what to expect, because you;ll be creating those pages).\nAlso, sometimes it is good to perform integration tests between unit and functional testing. If you have some components working together (for example fetcher using redirect handler) it is good to check whether those two work together as expected (for example, you may create resource on your own server, that when fetched will return redirect HTTP code, and check whether it is handled as expected).\nSo, in the end:\n\ncreate unit tests for components creating your app, to see if you haven't made simple mistake\ncreate integration tests for co-working components, to see if you glued everything together just fine\ncreate functional tests, to be sure that your app will work as expected (because some errors may come from project, not from implementation)","Q_Score":3,"Tags":"python,unit-testing,web-crawler","A_Id":21203798,"CreationDate":"2014-01-18T11:47:00.000","Title":"Python - unit testing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a small program with Python, and I would like to have a GUI for some configuration stuff. Now I have started with a BaseHTTPServer, and I am implementing a BaseHTTPRequestHandler to handle GET and POST requests. But I am wondering what would be best practice for the following problem.\nI have two separate requests that result in very similar responses. That is, the two pages that I return have a lot of html in common. I could create a template html page that I retrieve when either of these requests is done and fill in the missing pieces according to the specific request. But I feel like there should be a way where I could directly retrieve two separate html pages, for the two requests, but still have one template page so that I don't have to copy this.\nI would like to know how I could best handle this, e.g. something scalable. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":21206568,"Users Score":1,"Answer":"This has nothing to do with BaseHTTPRequestHandler as its purpose is to serve HTML, how you generate the HTML is another topic.\nYou should use a templating tool, there are a lot available for Python, I would suggest using Mako or Jinja2. then, on your code, just get the real HTML using the template and use it on your handler response.","Q_Score":0,"Tags":"python,html,webserver","A_Id":21260040,"CreationDate":"2014-01-18T16:14:00.000","Title":"Use template html page with BaseHttpRequestHandler","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do you get width and height of an image imported into pygame. I got the size using:\n    Surface.get_size\n, but I dont know how to get the width and height.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7226,"Q_Id":21209496,"Users Score":5,"Answer":"There are 2 methods available for getting the width and height of a surface.\nThe first one is get_size(), it returns a tuple (width,height). To access width for instance, you would do: surface.get_size()[0] and for height surface.get_size()[1].\nThe second method is to use get_width(), and get_height(), which return the width and the height.\nI suggest going through the python tutorial, to learn more about basic data structures such as tuples.","Q_Score":1,"Tags":"python-3.x,pygame","A_Id":21209675,"CreationDate":"2014-01-18T20:31:00.000","Title":"Getting width and height of an image in Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The issue:\nI have written a ton of code (to automate some pretty laborious tasks online), and have used the mechanize library for Python to handle network requests. It is working very well, except now I have encountered a page which I need javascript functionality... mechanize does not handle javascript.\nProposed Solution:\nI am using PyQt to write the GUI for this app, and it comes packaged with QtWebKit, which DOES handle javascript. I want to use QtWebKit to evaluate the javascript on the page that I am stuck on, and the easiest way of doing this would be to transfer my web session from mechanize over to QtWebKit.\nI DO NOT want to use PhantomJS, Selenium, or QtWebKit for the entirety of my web requests; I 100% want to keep mechanize for this purpose. I'm wondering how I might be able to transfer my logged in session from mechanize to QtWebKit.\nWould this work?\n\nTransfer all cookies from mechanize to QtWebView\nTransfer the values of all state variables (like _VIEWSTATE, etc.) from mechanize to QWebView (the page is an ASP.net page...)\nChange the User-Agent header of QWebView to be identical to mechanize...\n\nI don't really see how I could make the two \"browsers\" appear more identical to the server... would this work? Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":384,"Q_Id":21221141,"Users Score":0,"Answer":"Since nobody answered, I will post my work-around.\nBasically, wanted to \"transfer\" my session from Mechanize (the python module) to the QtWebKits QWebView (PyQt4 module) because the vast majority of my project was automated headless, but I had encountered a road block where I had no choice but to have the user manually enter data into a possible resulting page (as the form was different each time depending on circumstances).\nInstead of transferring sessions, I met this requirement by utilizing QWebViews javascript functionality. My method went like this:\n\nLoad page in Mechanize, and save the downloaded HTML to a local temporary file.\nLoad this local file in QWebView.\nThe user can now enter required data into the local copy of this page.\nLocate the form fields on this page, and pull the data the user entered using javascript. You can do this by getting the main frame object for the page (QWebView->Page()->MainFrame()), and then evaluating javascript code to accomplish the above task (use evaluateJavaScript()).\nTake the data you have extracted from the form fields, and use it to submit the form with the connection you still have open with mechanize.\n\nThat's it! A bit of a work-around, but it works none-the-less :\\","Q_Score":1,"Tags":"javascript,python,asp.net,pyqt,qtwebkit","A_Id":21532850,"CreationDate":"2014-01-19T18:57:00.000","Title":"Python - Transferring session between two browsers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to run code line by line with Python. \nIncluding running any module code, when used, line by line as well.\nI would like to go out and run some code line by line and watch as each of the lines goes through the processing phase and see just what code is getting executed when certain actions occur.  I'm curious how certain values are getting passed off to the interpreter.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":323,"Q_Id":21221431,"Users Score":5,"Answer":"Just use python -m pdb mycode.py, which will run your code in the python debugger (pdb module).\nIn the debugger you can execute arbitrary code, watch variables, and jump to different places in the code. Specifically, n will execute the next line and h will show you the debugger help.","Q_Score":1,"Tags":"python","A_Id":21221460,"CreationDate":"2014-01-19T19:20:00.000","Title":"Python: Is line by line execution possible","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to pass numbers around between functions, while preserving the decimal places for the numbers.\nI've discovered that if I pass  a float like '10.00' in to a function, then the decimal places don't get used. This messes an operation like calculating percentages.\nFor example, x * (10 \/ 100) will always return 0.\nBut if I manage to preserve the decimal places, I end up doing x * (10.00 \/ 100). This returns an accurate result.\nI'd like to have a technique that enables consistency when I'm working with numbers that decimal places that can hold zeroes.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":10506,"Q_Id":21222621,"Users Score":2,"Answer":"You should use the decimal module. Each number knows how many significant digits it has.","Q_Score":2,"Tags":"python","A_Id":21222941,"CreationDate":"2014-01-19T21:02:00.000","Title":"In python, how do I preserve decimal places in numbers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a script for a colleague who runs Windows but my development environment is GNU\/Linux.\nI have a bunch of variables that need to be configurable. So I put them all in a config.py that I've imported it into the main project.\nOriginally I planned to ask him to install Cygwin but then I thought of packaging it into an exe with py2exe or pyinstaller. I've not used either of these before so I don't know how they work. Would I have problems with the config.py file or should I be using an actual module like ConfigParser to store my settings so that it can be separate from the .exe file?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":338,"Q_Id":21222632,"Users Score":4,"Answer":"The problem you would have is that if your friend decided to change something in the config, he'd have to ask you to do it, run py2exe again and send the .exe to him again. With an .ini file, he'd simply edit the file.","Q_Score":1,"Tags":"python,py2exe,pyinstaller","A_Id":21222812,"CreationDate":"2014-01-19T21:03:00.000","Title":"py2exe\/pyinstaller: Is it bad practice to put all configurable variables in a .py file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a script for a colleague who runs Windows but my development environment is GNU\/Linux.\nI have a bunch of variables that need to be configurable. So I put them all in a config.py that I've imported it into the main project.\nOriginally I planned to ask him to install Cygwin but then I thought of packaging it into an exe with py2exe or pyinstaller. I've not used either of these before so I don't know how they work. Would I have problems with the config.py file or should I be using an actual module like ConfigParser to store my settings so that it can be separate from the .exe file?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":338,"Q_Id":21222632,"Users Score":1,"Answer":"I would definitely use a config parser or even just a json or ini file.","Q_Score":1,"Tags":"python,py2exe,pyinstaller","A_Id":21222800,"CreationDate":"2014-01-19T21:03:00.000","Title":"py2exe\/pyinstaller: Is it bad practice to put all configurable variables in a .py file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a little confused about how to get started with PyGit2. \nWhen adding files (plural) to a newly created repo, should I add them to \nindex.add('path\/to\/file')\nor would I be better off creating a TreeBuilder and using \ntb.insert( 'name',oid, GIT_FILEMODE_BLOB ) to add new content ?\nIf the second case, I am stumped as to how I create the tree object needed to commit to a newly created repo?  \nAnyone?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":406,"Q_Id":21242498,"Users Score":0,"Answer":"You can do either ways.\nI find the index.add() method straightforward.  \nYou can fetch all the files to be added or removed to the index using   Repository.status()   as a dictionary. The dictionary contains the filename as key and status of file as value. Depending upon the status values deleted files will be needed to be removed from index using index.remove(filename).\nWrite this index to in-memory tree using index.write_tree() which will return a tree-id to be used in Repository.commit().\nHowever for changes to be saved to disk use index.write() too.","Q_Score":1,"Tags":"python,git,repository,pygit2","A_Id":24710103,"CreationDate":"2014-01-20T19:28:00.000","Title":"PyGit2 - TreeBuilder.insert('name',blobid,GIT_FILEMODE_BLOB) vs index.add( 'path\/to\/file' )?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I've been having a lot of trouble lately with a messy install of Scrapy. While I was learning the command line, I ended up installing with pip and then easy_install at the same time. Idk what kinda mess that made. \nI tried the command pip uninstall scrapy, and it gave me the following error:\nOSError: [Errno 13] Permission denied: '\/Library\/Python\/2.6\/site-packages\/Scrapy-0.22.0-py2.6.egg\/EGG-INFO\/dependency_links.txt'\nso, I followed the path and deleted the text file... along with anything else that said \"Scrapy\" within that path. There were two versions in the \/site-packages\/ directory. \nWhen I tried again with the  pip uninstall scrapy command, I was given the following error:\nCannot uninstall requirement scrapy, not installed\nThat felt too easy, so I went exploring through my directory hierarchy and I found the following in the usr\/local\/bin directory:\n-rwxr-xr-x   1 greyelerson  staff       173 Jan 21 06:57 scrapy*\n\nUp until this point, I've resisted the urge to just delete it. But I know that those folders are hidden by Apple for a reason... \n1.) Is it safe to just delete it? \n2.) Will that completely remove Scrapy, or are there more files that I need to remove as well? (I haven't found any robust documentation on how to remove Scrapy once it's installed)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10163,"Q_Id":21274359,"Users Score":5,"Answer":"First, next time you get a Permission Denied from pip uninstall foo, try sudo pip uninstall foo rather than trying to do it manually.\nBut it's too late to do that now, you've already erased the files that pip needs to do the uninstall.\n\nAlso:\n\nUp until this point, I've resisted the urge to just delete it. But I know that those folders are hidden by Apple for a reason...\n\nYes, they're hidden so that people who don't use command-line programs, write their own scripts, etc. will never have to see them. That isn't you. You're a power-user, and sometimes you will need to see stuff that Apple hides from novices. You already looked into \/Library, so why not \/usr\/local?\nThe one thing to keep in mind is learning to distinguish stuff installed by OS X itself from stuff installed by third-party programs. Basically, anything in \/System\/Library or \/usr is part of OS X, so you should generally not touch it or you might break the OS; anything installed in \/Library or \/usr\/local is not part of OS X, so the worst you could do is break some program that you installed.\nAlso, remember that you can always back things up. Instead of deleting a file, move it to some quarantine location under your home directory. Then, it it turns out you made a mistake, just move it back.\n\nAnyway, yes, it's safe to delete \/usr\/local\/bin\/scrapy. Of course it will break scrapy, but that's the whole point of what you're trying to do, right?\nOn the other hand, it's also safe to leave it there, except for the fact that if you accidentally type scrapy at a shell prompt, you'll get an error about scrapy not being able to find its modules, instead of an error about no such program existing. Well, that, and it may get in the way of you trying to re-install scrapy.\n\nAnyway, what I'd suggest is this: pip install scrapy again. When it complains about files that it doesn't want to overwrite, those files must be from the previous installation, so delete them, and try again. Repeat until it succeeds.\nIf at some point it complains that you already have scrapy (which I don't think it will, given what you posted), do pip install --upgrade scrapy instead. \nIf at some point it fails because it wants to update some Apple pre-installed library in \/System\/Library\/\u2026\/lib\/python, don't delete that; instead, switch to pip install --no-deps scrapy. (Combine this with the --upgrade flag if necessary.) Normally, the --no-deps option isn't very useful; all it does is get you a non-working installation. But if you're only installing to uninstall, that's not a problem. \nAnyway, once you get it installed, pip uninstall scrapy, and now you should be done, all traces gone.","Q_Score":2,"Tags":"python,macos,command-line,scrapy,bin","A_Id":21274416,"CreationDate":"2014-01-22T04:43:00.000","Title":"Safely removing program from usr\/local\/bin on Mac OSX 10.6.8?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I'm pretty new with Django, I've been reading and watching videos but there is one thing that is confusing me. It is related to the apps. I've watched a video where a guy said that is convenient to have apps that do a single thing, so if I have a big project, I will have a lot of apps. I made an analogy to a bunch of classes, where each app would be a class with their own functions and elements, is this a correct interpretation? In this case, is there like an app where I have like a main method in a class? I mean, I don't know how to wire all the applications I have, is there like a principal app in charge of manage the others? or how does it work?\nthanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":21279835,"Users Score":0,"Answer":"You could have base app if you want to, but you don't need one. All apps are wired when you declare them in the INSTALLED_APPS in the settings, each app has a urls.py file that will catch the route and call one of the views in that app if there's a match.\nI use a base app to define global templates, global static files, helpers.\nHope this helps","Q_Score":0,"Tags":"python,django","A_Id":21280027,"CreationDate":"2014-01-22T10:08:00.000","Title":"how to wire all the django apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using the python API for Jira.  I would like to get a list of all the labels that are being used in a project.  I know that issue.fields.labels will get me just the labels of an issue, but I am interested in looping through all the labels used in a project.  Found this to list all components in a project\ncomponents = jira.project_components(projectID)\nAm looking for something similar, but for labels...","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6767,"Q_Id":21287447,"Users Score":2,"Answer":"Labels are a field that is shared across all issues potentially, but I don't think there is a REST API to get the list of all labels. So you'd either have to write a JIRA add-on to provide such a resource, or retrieve all the issues in question and iterate over them. You can simplify things by excluding issues that have no label\nJQL: project = MYPROJ and labels is not empty\nAnd restrict the fields that are returned from the search using the \"fields\" parameter for search_issues","Q_Score":3,"Tags":"jira,jira-rest-api,python-jira","A_Id":21292775,"CreationDate":"2014-01-22T15:44:00.000","Title":"In the Jira Python API, how can I get a list of all labels used in a project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to python and was curious as to how, given a large set of data consisting of census information, I could plot a histogram or graph of some sort.  My main question is how to access the file, not exactly how the graph should be coded.  Do I import the file directly? How do I extract the data from the file? How is this done?\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":498,"Q_Id":21287667,"Users Score":0,"Answer":"what format is your data in?\nPython offers modules to read data from a variety of data formats (CSV, JSON, XML, ...)\nCSV is a very common one that suffices for many cases (the csv module is part of the standard library)\nTypically you write a small routine that casts the different fields as expected (string to floating point numbers, or dates, integers,...) and cast your data in a numpy matrix (np.array) where each row corresponds to a sample and each column to an observation\nfor the plots check matplotlib. It is really easy to generate graphs, especially if you have some previous experience with Matlab","Q_Score":1,"Tags":"python,histogram,data-analysis","A_Id":21287882,"CreationDate":"2014-01-22T15:53:00.000","Title":"Plotting in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a Python dictionary. I want values like 0.25, 0.30, 0.35 to be keys in this dictionary. The problems is that I have values like 0.264, 0.313, 0.367. I want this values to access the keys e.g. I want every value from 0.25(inclusive) to 0.30(exclusive) to access the value under the key 0.25. Any ideas how to do this? I think I've done that before somehow, but I have no ideas right now.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":143,"Q_Id":21312425,"Users Score":1,"Answer":"What you need is to make a custom dictionary class where the __getitem__ method rounds down the value before calling the standard __getitem__ method.","Q_Score":1,"Tags":"python,dictionary,key,multiple-value","A_Id":21312503,"CreationDate":"2014-01-23T15:24:00.000","Title":"How to make a dictionary, in which multiple values access one value(Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hey I was wondering if anyone knew how to connect to a bitcoin wallet located on another server with bitcoinrpc\nI am running a web program made in django and using a python library called bitcoinrpc to make connections.\nWhen testing locally, I can use bitcoinrpc.connect_to_local), or even bitcoinrpc.connect_to_remote('account','password') and this works as well as long as the account and password match the values specified in my 'bitcoin.conf' file. I can then use the connection object to get values and do some tasks in my django site.\nThe third parameter in connect_to_local is default localhost. I was wondering: \nA) What to specify for this third parameter in order to connect from my webserver to the wallet stored on my home comp (is it my IP address?)\nB) Because the wallet is on my PC and not some dedicated server, does that mean that my IP will change and I won't be able to access the wallet?\nC) The connection string is in the django app - which is hosted on heroku. Heroku apps are launched by pushing with git but I believe it is to a private repository. Still, if anyone could see the first few lines of my 'view' they would have all they need to take my BTC (or, more accurately, mBTC). Anyone know how bad this is - or any ways to go about doing btc payments\/movements in a more secure way.\nThanks a lot.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1399,"Q_Id":21324050,"Users Score":-1,"Answer":"You can use SSL with RPC to hide the password.\nrpcssl=1","Q_Score":0,"Tags":"python,django,heroku,rpc,bitcoin","A_Id":21972946,"CreationDate":"2014-01-24T03:48:00.000","Title":"Bitcoinrpc connection to remote server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing python app which currently is being hosted on Heroku. It is in early development stage, so I'm using free account with one web dyno. Still, I want my heavier tasks to be done asynchronously so I'm using iron worker add-on. I have it all set up and it does the simplest jobs like sending emails or anything that doesn't require any data being sent back to the application. The question is: How do I send the worker output back to my application from the iron worker? Or even better, how do I notify my app that the worker is done with the job?\nI looked at other iron solutions like cache and message queue, but the only thing I can find is that I can explicitly ask for the worker state. Obviously I don't want my web service to poll the worker because it kind of defeats the original purpose of moving the tasks to background. What am I missing here?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":209,"Q_Id":21338216,"Users Score":-1,"Answer":"Easiest way - push message to your api from worker - it's log or anything you need to have in your app","Q_Score":1,"Tags":"python,heroku,notifications,worker","A_Id":21348604,"CreationDate":"2014-01-24T16:59:00.000","Title":"Ironworker job done notification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I load a pickle using pickle.load(\"foo\") how do I know if whats read back is corrupt or not? For example, if I'm pickling a large list using pickle.dump and kill my python process before its finished, what would the consequences then be and how should I deal with them?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2020,"Q_Id":21348299,"Users Score":0,"Answer":"I've just manually corrupted a pickled file. It threw an error. Presumably, if a file does not throw an error it's either the file you pickled, or it's been so carefully tampered with that it fools the pickle module. In that case, I think you're pretty much sunk.","Q_Score":0,"Tags":"python,python-3.x","A_Id":21348388,"CreationDate":"2014-01-25T08:17:00.000","Title":"On Pickle Corruption","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If my input query is:\n\"Dog is barking at tree\"\nhere word \"bark\" is polysemous word and we know that. But how to check it through a code in python language using wordnet as a lexical database?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":261,"Q_Id":21366266,"Users Score":0,"Answer":"If a word has multiple synsets then you can say it is a polysemous word.","Q_Score":0,"Tags":"python,nlp,nltk,wordnet,word-sense-disambiguation","A_Id":21422720,"CreationDate":"2014-01-26T16:45:00.000","Title":"How to find polysemous words from given input query?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've created a dynamic property in the Designer interface. How do I access this property in my code?\nI don't see any properties listed with the name I've provided. I've found a dynamicPropertyNames property that contains a QByteArray object and the name I provided, but I cannot figure out how to access the data I stored (nor do I know if this is even the correct place to be querying).\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1777,"Q_Id":21395056,"Users Score":0,"Answer":"Just because I had a similar problem and the reason wasn't a wrong object: The property's content can be accessed with toString().","Q_Score":3,"Tags":"python,pyqt,qt-designer","A_Id":28092434,"CreationDate":"2014-01-28T01:12:00.000","Title":"How do I access a dynamic property in PyQt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Openerp.I have modified the base module and when i goto installed modules and search for BASE module and click upgrade button it is nearly taking 5mins.Can any one please say me how can i reduce the time that is taking for up-gradation of existing module.\nNote: I have Messaging,Sales,Invoicing,Human-resource,Tools and Reporting modules installed,is it due to i have more modules installed??\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":155,"Q_Id":21397605,"Users Score":0,"Answer":"why you going in installed modules and search for base module and update it?\nyou have to only update that module in which you have done changes in xml file not event py file.\nif you have changes in xml file of those module you have to update only those module.\nif you going to update base module it will update all module which installed in your databae,\nbecause every module depend on base, we can call base is the kernal of our all modules, all module depend on this module, if you update base it will going to update all modules\nif you have done some changes in sale then you have to search for sale and update the only \nsale module not go to update base module\nregards,","Q_Score":0,"Tags":"python-2.7,openerp,base","A_Id":21398386,"CreationDate":"2014-01-28T05:30:00.000","Title":"Why is it taking more time, When i upgrade a module in Openerp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Openerp.I have modified the base module and when i goto installed modules and search for BASE module and click upgrade button it is nearly taking 5mins.Can any one please say me how can i reduce the time that is taking for up-gradation of existing module.\nNote: I have Messaging,Sales,Invoicing,Human-resource,Tools and Reporting modules installed,is it due to i have more modules installed??\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":155,"Q_Id":21397605,"Users Score":1,"Answer":"As you have said that You are new to OpenERP, Let me tell you something which would be very helpful to you. i.e Never Do changes in Standard modules not in base. If you      want to add or remove any functionality of any module, you can do this by creating a customzed module. in which inherit the object you want, and do the changes as per \nyour requirement. \nNow regarding the time spent when upgrading base module, This is because when you update base module it will automatically update all the other modules which are already installed (in your case - Sales,Invoicing,Human-resource,Tools and Reporting) as base is the main module on which all the other modules are dependedent.\nSo, Better is to do your changes in customized module and upgrade that perticular module only, not the base.\nHope this will help you.","Q_Score":0,"Tags":"python-2.7,openerp,base","A_Id":21398452,"CreationDate":"2014-01-28T05:30:00.000","Title":"Why is it taking more time, When i upgrade a module in Openerp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand it's easy to convert an int to a string by using the built-in method str(). However, what's actually happening? I understand it may point to the \n   __str__ method of the int object but how does it then compute the \u201cinformal\u201d string representation? Tried looking at the source and didn't find a lead; any help appreciated.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":21419369,"Users Score":1,"Answer":"Internally the Int object is stored as 2's complement representation like in C (well, this is true if range value allow it, python can automagically convert it to some other representation if it does not fit any more).\nNow to get the string representation you have to change that to a string (and a string merely some unmutable list of chars). The algorithm is simple mathematical computing: divide the number by 10 (integer division) and keep the remainder, add that to character code '0'. You get the unit digit. Go on with the result of the division until the result of the division is zero. It's as simple as that.\nThis approach works with any integer representation but of course it will be more efficient to call the ltoa C library function or equivalent C code to do that if possible than code it in python.","Q_Score":5,"Tags":"python","A_Id":21419493,"CreationDate":"2014-01-28T23:49:00.000","Title":"What's actually happening when I convert an int to a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to save high scores in a game that I am creating, but each time I do a pickle.dump, it overwrites my previous data. Any help?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":262,"Q_Id":21420269,"Users Score":2,"Answer":"You would need to load your existing pickle'd object, modify it, and then dump it again with the modifications.","Q_Score":1,"Tags":"python,python-2.7,max,pickle","A_Id":21420290,"CreationDate":"2014-01-29T01:20:00.000","Title":"I am trying to save high scores with pickle, but how do I add to an already pickled document and then get the max?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am making a word generator that takes several inputted letters, puts them in all possible positions, and matches them with a document to find words. If I am approaching this wrong please tell me! If not how can I do this?\nThanks","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":11854,"Q_Id":21439346,"Users Score":2,"Answer":"It might be faster to run it in reverse: index your document, and for each word, see if it is a subset of your list of letters.","Q_Score":4,"Tags":"python,permutation,alphabetical","A_Id":21439435,"CreationDate":"2014-01-29T18:19:00.000","Title":"How can I generate a list of all possible permutations of several letters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Has anyone out there created a a.) web service for Qualtrics or b.) a Python web service on Google App Engine?\nI need to build in some functionality to a Qualtrics survey that seems only a web service (in the Qualtrics Survey Flow) could do, like passing parameters to a web service then getting a response back. \nI've looked at GAE Protocol RPC, but I'm not quite sure if that's the right path. Qualtrics gave me a PHP code example but I don't know how to begin translating it to python and\/or GAE.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":909,"Q_Id":21445897,"Users Score":0,"Answer":"I am familiar with Qualtrics but I will answer (b) first.\nYou can write a Python Web Service in a variety of ways, depending on your choice:\n\nYou could write a simple get handler\nUse Google Cloud Endpoints\nUse one of several Web Services Python libraries\n\nHaving said that, a quick glance at Qualtrics indicated that it required a RSS feed in the result format(I could be wrong). So what you will need to take care of while doing (b) is to ensure that it is in a format that Qualtrics understand and parses out the response format for you.\nFor e.g. if you have to return RSS, you could write your Python Web Service to return that data. Optionally, it can also take one or more parameters to fine tune the results.","Q_Score":0,"Tags":"python,web-services,google-app-engine,rest,qualtrics","A_Id":21449385,"CreationDate":"2014-01-30T00:55:00.000","Title":"Creating a web service for Qualtrics written in Python on Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a fresh Python 3.3 installation on Red Hat Enterprise Linux 6.5, including Tkinter \u2014 python3.3 -m tkinter works and shows a dialogue.  However, when I run pip3.3 install matplotlib, at the Optional Backend Dependencies, it says:    \n\nTkinter: no\n         * TKAgg requires Tkinter\n\nHow does matplotlib determine the availability of Tkinter, and how can I give it a hint?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":492,"Q_Id":21457402,"Users Score":-1,"Answer":"I suggest you get matplotlib from your distro's repositories. Pip is fine for installing simple, pure Python packages but isn't very convenient for packages such as matplotlib or numpy, for which a lot of non-Python dependencies need to be solved. Your package manager should nicely take care of all this stuff for you.","Q_Score":2,"Tags":"python,matplotlib,tkinter,python-3.3","A_Id":21458494,"CreationDate":"2014-01-30T13:06:00.000","Title":"When installing through pip, how do I tell matplotlib how to find tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Ubuntu, how do I instruct pip to use the Python3 installation and not Python2.6? 2.6 is the default installation on Ubuntu. I can't upgrade that as it will break Ubuntu.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":21490336,"Users Score":3,"Answer":"Any single pip installation is (roughly) specific to one Python installation. You can, however, have multiple parallel pip installations. Your package manager probably has a package called pip-3.3 or similar. If not, you can manually install it (run the get-pip.py script using Python 3.3), though you'll have to be careful that it ends up in the right place in PATH. You can also use a virtualenv.","Q_Score":1,"Tags":"python,ubuntu,pip","A_Id":21490370,"CreationDate":"2014-01-31T21:23:00.000","Title":"Instructing Pip to Use Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am launching the text editor but for different users the default text editor could be different, so how do I get the name of which text editor is being used just to handle if an error occur switch to different text editor ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":21498342,"Users Score":1,"Answer":"Given you're working in a Linux\/POSIX environment you could read the EDITOR environment variable using the os.environ map.","Q_Score":0,"Tags":"python,subprocess","A_Id":21498354,"CreationDate":"2014-02-01T12:57:00.000","Title":"how do I get the name of application launched by subprocess in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Problem:\nI am given a long list of various position titles for jobs in the IT industry (support or development); I need to automatically categorize them based on the general type of job they represent. For example, IT-support analyst, help desk analyst... etc. Could all belong to the group IT-Support.\nCurrent Approach:\nCurrently, I am manually building regex patterns to accomplish this, which change as I encounter new titles which should be included in a group. For example, I originally used the pattern:\n\"(HELP|SERVICE) DESK\"\nto match IT-Support type jobs, and this eventually became:\n\"(HELP|SUPPORT|SERVICE) (DESK|ANALYST)\"\nwhich was even more inclusive.\nQuestion:\nI feel like there should be a fairly intuitive way to automatically build these regex patterns with some sort of algorithm, but I have no idea how this might work... I've read about NLP briefly in the past, but its extremely alien to me... Any suggestions on how I might implement such an algorithm with\/without NLP?\nEDIT:\nI'm considering using a decision tree, but it has some limitations which prevent it from working (in this situation) \"out-of-the-box\"; for example, if I have built the following tree: \n(Service)->(Desk)->(Support) OR ->(Analyst) ...where Support and Analyst are both children of Desk\nSay I get the string \"Level-1 Service Desk Analyst\"... This should be categorized using the decision tree above, but it will not inherantly match the tree (since there is no root node named \"Level\" or \"Level-1\").\nI believe I am heading in the right direction now, but I need additional logic. For example, if I am given the following hypothetical strings:\n\nIT Service Desk Analyst\nLevel-1 Help Desk Analyst\nComputer Service Desk Support\n\nI would like my algorithm to create something like below:\n(Service OR Help)->(Desk)->(Analyst OR Support) ...where Service and Help are both root nodes, and both Analyst and Support are children of Desk\nBasically, I need the following: I would like this matching algorithm to be able to reduce the strings it is presented with to a minimal number of sub-strings which effectively match all of the strings in a given cateogory (preferably using a decision tree).\nIf I am not being clear enough, just let me know!","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":13027,"Q_Id":21500736,"Users Score":0,"Answer":"There were suggestions about unsupervised learning, but I recommend to use supervised learning, so you'll categorize 100-200 positions manually, and then algo will do the rest. \nThere are number of resources, libraries, etc. - look please at \"Programming Collective Intelligence\" book - they provided good machine learning topics with python examples.","Q_Score":11,"Tags":"python,regex,machine-learning","A_Id":21604563,"CreationDate":"2014-02-01T16:47:00.000","Title":"Python - A way to learn and detect text patterns?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Problem:\nI am given a long list of various position titles for jobs in the IT industry (support or development); I need to automatically categorize them based on the general type of job they represent. For example, IT-support analyst, help desk analyst... etc. Could all belong to the group IT-Support.\nCurrent Approach:\nCurrently, I am manually building regex patterns to accomplish this, which change as I encounter new titles which should be included in a group. For example, I originally used the pattern:\n\"(HELP|SERVICE) DESK\"\nto match IT-Support type jobs, and this eventually became:\n\"(HELP|SUPPORT|SERVICE) (DESK|ANALYST)\"\nwhich was even more inclusive.\nQuestion:\nI feel like there should be a fairly intuitive way to automatically build these regex patterns with some sort of algorithm, but I have no idea how this might work... I've read about NLP briefly in the past, but its extremely alien to me... Any suggestions on how I might implement such an algorithm with\/without NLP?\nEDIT:\nI'm considering using a decision tree, but it has some limitations which prevent it from working (in this situation) \"out-of-the-box\"; for example, if I have built the following tree: \n(Service)->(Desk)->(Support) OR ->(Analyst) ...where Support and Analyst are both children of Desk\nSay I get the string \"Level-1 Service Desk Analyst\"... This should be categorized using the decision tree above, but it will not inherantly match the tree (since there is no root node named \"Level\" or \"Level-1\").\nI believe I am heading in the right direction now, but I need additional logic. For example, if I am given the following hypothetical strings:\n\nIT Service Desk Analyst\nLevel-1 Help Desk Analyst\nComputer Service Desk Support\n\nI would like my algorithm to create something like below:\n(Service OR Help)->(Desk)->(Analyst OR Support) ...where Service and Help are both root nodes, and both Analyst and Support are children of Desk\nBasically, I need the following: I would like this matching algorithm to be able to reduce the strings it is presented with to a minimal number of sub-strings which effectively match all of the strings in a given cateogory (preferably using a decision tree).\nIf I am not being clear enough, just let me know!","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":13027,"Q_Id":21500736,"Users Score":0,"Answer":"This sounds like a clustering, or unsupervised, problem rather than a decision tree one (do you know all the roles in advance, and can you provide labelled data).\nIf it were me, I'd be tempted to build a bag-of-words style representation of your strings and run a generic clustering algorithm (k-means, say) to see what came out. Deciding on a category to assign a new string to is then a fairly simple matching operation (depending on what you use to do the clustering).\nYou could also look at topic models, with the simplest being Latent Dirichlet Allocation, as being of potential application here. You'd get an assignment to a topic per-word, not per string, but that could be altered if you tweaked the method.","Q_Score":11,"Tags":"python,regex,machine-learning","A_Id":21549987,"CreationDate":"2014-02-01T16:47:00.000","Title":"Python - A way to learn and detect text patterns?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I did some searches on this topic and the solutions didn't work for me.  I am running both a Linux (Ubuntu) environment and Windows.  My system is Windows 8.1 but I have virtualbox with Ubuntu on that.\nStarting with Windows...  I created a venv directory off the root of the e drive.  Created a project folder and then ran the activate command, which is in the venv>Scripts directory.  So, after activating that (note, I had installed virtualenv already)... so after activating that I then changed into the folder with my module and it ran fine, with the shebang, I didn't even have to type python in front of my filename.  However, in Aptana Studio, it cannot find the module I installed with pip.  So, it doesn't work.  In an earlier post it was recommended that one choose a different interpreter and browse to the env and select that.  \nSo, how does one get this installed and working with an IDE like Eclipse and Aptana Studio?\nI am having problems on Ubuntu.  The instructions I found had me using package installer to install virtualenv, pip and a few other tools that package these.  The problem is that on Ubuntu the default version of python is 2.7.x.  I need 3.3 or 3.x.  So, can someone point me in the direction of how to setup virtual environments  for the 2.7.x branch of python and the 3.x branch.  \nAlso, how does one tell the IDE (Eclipse or Aptana Studio) to use the virtualenv?\nThanks,\nBruce","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":2520,"Q_Id":21504617,"Users Score":5,"Answer":"Configure Aptana Studio's python interpreter( you can configure more than one)\nIn aptana, Window -> Preferences -> Interpreter Python and create a New interpreter. Select the python executable from the virtual environment (in windows it is python.exe which resides in Scripts subfoler of the virtualenv,where as in ubuntu python is under bin subfolder) . Now Aptana will show a list of directories to add also remember to check C:\\Python27\\Lib or Ubuntu conterpart.\nNow on creating use this interpreter. \nOr if to use with existing project \nStep 1.Take project properties(File -> Properties OR By right clicking on Project).\nStep 2.From PyDev Interpreter\/Grammer select the interpreter you configured above.\nEdit :\nIn this way you can even configure both python 3 and python 2 for Aptana. You have to configure an interpreter for each python 3 and python 2. Then follow steps above to select the interpreter.","Q_Score":3,"Tags":"python,eclipse,python-2.7,ubuntu","A_Id":24506641,"CreationDate":"2014-02-01T22:40:00.000","Title":"How do I tell Aptana Studio to use Python virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Tkinter to create an application which requires a 0-9 numerical keypad to be built in to the UI.\nI plan to do this with 10 button widgets which enter the relevant number(s) into the currently selected Entry widget. \nI do not want to use one of the pre-made on-screen keyboards (e.g. Matchbox-keyboard) that are available, it needs to be bespoke to the application.\nSo essentially - how do I simulate key-press events using on-screen buttons to enter values into entry fields without taking the focus off the entry field?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1024,"Q_Id":21509623,"Users Score":0,"Answer":"You don't need to simulate keypresses if all you want to do is insert the numbers into the entry widget. Just have the buttons directly insert their value into the entry widget with the entry widget insert method.","Q_Score":0,"Tags":"python,tkinter,raspberry-pi,on-screen-keyboard","A_Id":21511280,"CreationDate":"2014-02-02T10:46:00.000","Title":"In Python (on Raspberry Pi) how do I create an embedded keypad within my Tkinter window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Python in my PC. how to find out which VM came with it.\nis it cpython or ipython or jpython?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":21510739,"Users Score":0,"Answer":"Run this in command prompt \npython -c \"from platform import python_implementation; print python_implementation()\"","Q_Score":4,"Tags":"python,virtual-machine","A_Id":21511103,"CreationDate":"2014-02-02T12:46:00.000","Title":"How to find out which VM i have in my Python installation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Once sphinx-apidoc has been run the command C:\\path\\to\\doc\\make html produces an error beginning:\n\nThe 'sphinx-build' command was not found [snip]\n\nHowever the command does exist and the relevant environment variables are set.\nMore detail:\n1 - Trying to run sphinx_apidoc:\n\n'C:\\path\\to\\jython\\bin\\sphinx-apidoc' is not recognised as an internal or external command\n\n2 - Called using Jython works: jython C:\\path\\to\\jython\\bin\\sphinx-apidoc with sensible options produces the documentation *.rst files, conf.py, etc files.\n3 - make html then produces the following error:\n\nThe 'sphinx-build' command was not found [snip]\n\nIt then recommends setting the SPHINXBUILD environment variable, and even the PATH. I already have these two environment variables set, proven to myself by calling echo %PATH% and echo %SPHINXBUILD%.\nThis is where I get stuck. It appears that the files that Sphinx uses (sphinx-apidoc and sphinx-build in this case), which are in the C:\\path\\to\\jython\\bin\\ directory, do not have any file suffixes. When called directly from Jython they work as expected (see point 2 above), however when called as part of another process (e.g. make html) they are not recognised and the execution fails (see points 1 and 3 above).\nDoes anyone know the what, why and most importantly 'how to fix' of this problem?\nMy setup process is on an unnetworked Windows 7 computer. Jython (2.5.2) was installed using the Jython installer. Then each of the following packages (except setuptools) was installed by extracting it locally and then running jython setup.py install in its extracted directory:\n\nsetuptools: by calling jython ez_setup.py with setuptools-1.4.2.tar.gz in the same directory (so there is no attempt to download it)\nJinja2 (2.5)\ndocutils (0.11)\nPygments (1.6)\nSphinx (1.2.1)\nnumpydoc (0.4) - Only mentioned because it is also isntalled on the machine.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":376,"Q_Id":21527115,"Users Score":1,"Answer":"I have managed to get it working. The problem was that the manual installation and the use of Jython meant that certain environment variables that were expected were not in place. Also, the use of Windows 7 (and I believe MS Windows in general) means that Python scripts without an extension cannot be run without calling them explicitly through Jython (Windows doesn't check for shebangs). Finally, file associations had not been set up (as happens automatically with CPython installation, but has not happened with Jython).\nFor anyone else with similar problems the following setup works for me:\nLocations:\n\nJava Runtime: C:\\Java\\jre7\nJython: C:\\Jython\\jython2.5.2\n\nUser Environment Variables:\n\nJRE_HOME: C:\\Java\\jre7\nJAVA_HOME: %JRE_HOME%\nCLASSPATH: .\nJYTHON_HOME: C:\\Jython\\jython2.5.2\nPATH: %JRE_HOME%\\bin;%JYTHON_HOME%\\bin\n\nFile Associations:\n\nAt the command prompt type assoc .py=Python.File to associate 'Python.File' with the '.py' extension.\nAt the command prompt type ftype Python.File=C:\\Jython\\jython2.5.2\\jython.bat \"%1\" %* to associate the Jython command with files of type 'Python.File'.\nAppend '.py' (;.PY) to the PATHEXT system environment variable. This will make it possible to execute Python files without having to provide their '.py' extension. (N.B. This does not make it possible to run Python files that do not have a '.py' extension.)\n\nFile Extensions:\n\nRename the four Sphinx commands to include '.py' extensions. This is remarkably difficult with vanilla Windows 7 as it does everything it can to distance the user from such 'low level' details as file extensions, however the rename command at the command prompt does the job: type ren sphinx* sphinx*.py when in the Jython bin directory.\n\nIt should now be possible to call sphinx-apidoc or similar from anywhere. Once this is complete the command make html, when called from the documentation directory, should work as expected.","Q_Score":1,"Tags":"windows,jython,python-sphinx,jython-2.5","A_Id":21824353,"CreationDate":"2014-02-03T12:11:00.000","Title":"How to get Sphinx working with Jython on an unnetworked Windows 7 computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Issues using SoundCloud API with python to get user info\nI've downloaded the soundcloud library and followed the tutorials, and saw on the soundcloud dev page that user syntax is, for example \/users\/{id}\/favorites.\nI just don't know how to use python to query user information.  Specifically, i would like to print a list of tracks that a given user liked, (or favorited, but liked would be better).\nany help would be greatly appreciated. thanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":503,"Q_Id":21535003,"Users Score":1,"Answer":"You can also do the following :\nimport soundcloud\ntoken= 'user_access_token' \nclient = soundcloud.Client(access_token=token)\nuser_info = client.get('\/me')\nuser_favorites = client.get('\/me\/favorites')\nuser_tracks = client.get('\/me\/tracks')\nand so on...","Q_Score":1,"Tags":"python,api,soundcloud","A_Id":30069248,"CreationDate":"2014-02-03T18:36:00.000","Title":"soundcloud api python user information","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I want to do pagination in google app engine search api using cursors (not offset). the forward pagination is straight forward , the problem is how to implement the backward pagination.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":575,"Q_Id":21545635,"Users Score":1,"Answer":"Sorry to revive this old question, but I have a solution for this issue given a few constraints with possible workarounds. Basically, the cursors for previous pages can be stored and reused for revisiting that page.\nConstraints:\nThis requires that pagination is done dynamically (e.g. with Javascript) so that older cursors are not lost. Workaround if pagination is done across html pages, the cursors would need to be passed along.\nUsers would not be able to arbitrarily select a forward page, and would only be given next\/back buttons. Though any previously visited page could easily be jumped to. Workaround could be to internally iterate and discard entries while generating cursors at pagination points until finally reaching the desired results. Then return the list of previous page cursors as well.\nAll of this requires a lot of extra bookkeeping and complexity, which almost makes the solution purely academic, but I suppose that would depend on how much more efficient cursors are than simply limit\/offset. This could be a worthwhile endeavor if your data is such that you don't expect your users to want to jump ahead more than one page at a time (which includes most type of searches).","Q_Score":6,"Tags":"python,google-app-engine","A_Id":37264173,"CreationDate":"2014-02-04T06:40:00.000","Title":"Pagination in Google App EngineSearch API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a Django-based app, and I need it to use secure requests. The secure requests in my site are enabled and manually writing the url gets it through fine.\nAs I have quite a lot of urls I don't want to do it manually, but instead do something so Django always sends secure requests.\nHow can I make it so it always send https?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1587,"Q_Id":21556278,"Users Score":1,"Answer":"The protocol has nothing to do with django. That part is handled by your http server","Q_Score":0,"Tags":"python,https,gunicorn,url-pattern","A_Id":21556311,"CreationDate":"2014-02-04T15:17:00.000","Title":"how do I re-write\/redirect URLs in Gunicorn web server configuration?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a executable file working in Ubuntu that runs a script in Python and works fine. I have also a shared directory with Samba server. The idea is that everyone (even Windows users) can execute this executable file located in this shared folder to run the script located in my computer. \nBut, how can I make an executable file that runs the python script of MY computer from both Linux and Windows remote users?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":21558022,"Users Score":0,"Answer":"As you've said, this executable file would need to be something that runs on both Linux and Windows. That will exclude binary files, such as compiled C files.\nWhat you are left with would be an executable script, which could be\n\nBash\nRuby\nPython\nPHP\nPerl\n\nIf need be the script could simply be a bootstrapper that loads the appropriate binary executable depending on the operating system.","Q_Score":1,"Tags":"python,bash,exe,samba","A_Id":21559703,"CreationDate":"2014-02-04T16:32:00.000","Title":"Executable shell file in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the app in python, using flask and iron worker. I'm looking to implement the following scenario:\n\nUser presses the button on the site\nThe task is queued for the worker\nWorker processes the task\nWorker finishes the task, notifies my app\nMy app redirects the user to the new endpoint\n\nI'm currently stuck in the middle of point 5, I have the worker successfully finishing the job and sending a POST request to the specific endpoint in my app. Now, I'd like to somehow identify which user invoked the task and redirect that user to the new endpoint in my application. How can I achieve this? I can pass all kind of data in the worker payload and then return it with the POST, the question is how do I invoke the redirect for the specific user visiting my page?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":21558984,"Users Score":1,"Answer":"You can do it as follows:\n\nWhen the user presses the button the server starts the task, and then sends a response to the client, possibly a \"please wait...\" type page. Along with the response the server must include a task id that references the task accessible to Javascript.\nThe client uses the task id to poll the server regarding task completion status through ajax. Let's say this is route \/status\/<taskid>. This route returns true or false as JSON. It can also return a completion percentage that you can use to render a progress bar widget.\nWhen the server reports that the task is complete the client can issue the redirect to the completion page. If the client needs to be told what is the URL to redirect to, then the status route can include it in the JSON response.\n\nI hope this helps!","Q_Score":2,"Tags":"python,redirect,flask,worker","A_Id":21561671,"CreationDate":"2014-02-04T17:12:00.000","Title":"Redirect user when the worker is done","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm doing some work in an IPython Notebook session, and I now have a large-ish notebook containing code, some plots, and some embedded videos (of plot stacks; it seemed like the easiest way to be able to scroll through a sequence of plots interactively in the Notebook view). I'm working in Chrome (Mac, 32.0.1700.102) since H.264 encoding worked best (Vp8 compressed out shading detail in the plots that I needed), and Safari and Firefox don't render the videos.\nRecently, this notebook has started crashing Chrome tabs every couple minutes (showing the 'Aw Snap' page). It's become basically unusable. I can work, saving very frequently, but saving the notebook causes the Chrome tab to crash about half the time (which makes me wonder if the random crashes that occur when I'm working are caused by the autosaves, but I don't know).\nHas anyone else encountered this? Does anyone know how to fix it? Is there some more information I can provide to diagnose the problem? Thanks for any help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6425,"Q_Id":21559666,"Users Score":1,"Answer":"I was experiencing the same issue. Actually I found this is related to chrome extensions installed.\nTry disabling all the extensions and re-enabling them one by one. You'll find which is crashing your tab. In my case, crashes were due to the Evernote extension.\nAlternatively, you can open up an incognito window, which has all the extensions disabled by default, and try opening your notebook there.\nCiao","Q_Score":9,"Tags":"google-chrome,ipython,ipython-notebook","A_Id":24776086,"CreationDate":"2014-02-04T17:46:00.000","Title":"IPython Notebook crashing Chrome tabs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have several configuration objects in django admin panel.\nThey are listed in the following order\n\nEmail config\nGeneral config\nNetwork config\n\nEach object can be configured separately, but all of them are included in General config. So basically you will need mostly General config, so I want to move it to the top.\nI know how to order fields in a model itself, but how to reorder models?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5031,"Q_Id":21578382,"Users Score":4,"Answer":"I don't see an obvious solution to this \u2014 the models are sorted by their _meta.verbose_name_plural, and this happens inside the AdminSite.index view, with no obvious place to hook custom code, short of subclassing the AdminSite class and providing your own index method, which is however a huge monolithic method, very inheritance-unfriendly.","Q_Score":13,"Tags":"python,django,django-models,django-admin","A_Id":21579803,"CreationDate":"2014-02-05T13:14:00.000","Title":"Reorder model objects in django admin panel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to find how to execute ipdb (or pdb) commands such as disable.\nCalling the h command on disable says \n\ndisable bpnumber [bpnumber ...]\n  Disables the breakpoints given as a space separated list of\n  bp numbers.\n\nSo how whould I get those bp numbers? was looking through the list of commands and couldn't get any to display the bp numbers\n[EDIT]\nThe break, b and info breakpoints commands don't do anything, although in my module i clearly have 1 breakpoint set like this import pdb; pdb.set_trace( ) - same for ipdb. Moreover info is not defined.\nThe output of help in pdb:\n\nDocumented commands (type help ):\n  ======================================== EOF    bt         cont      enable  jump  pp       run      unt    a      c          continue \n  exit    l     q        s        until  alias  cl         d         h\n  list  quit     step     up     args   clear      debug     help    n\n  r        tbreak   w      b      commands   disable   ignore  next \n  restart  u        whatis break  condition  down      j       p\n  return   unalias  where \nMiscellaneous help topics:\n  ========================== exec  pdb\nUndocumented commands:\n  ====================== retval  rv\n\nAnd for ipdb:\n\nDocumented commands (type help ):\n  ======================================== EOF    bt         cont      enable  jump  pdef    psource  run      unt    a      c\n  continue  exit    l     pdoc    q        s        until  alias  cl\n  d         h       list  pfile   quit     step     up     args   clear \n  debug     help    n     pinfo   r        tbreak   w      b\n  commands   disable   ignore  next  pinfo2  restart  u        whatis\n  break  condition  down      j       p     pp      return   unalias \n  where \nMiscellaneous help topics:\n  ========================== exec  pdb\nUndocumented commands:\n  ====================== retval  rv\n\nI have saved my module as pb3.py and am executing it within the command line like this\n\npython -m pb3\n  The execution does indeed stop at the breakpoint, but within di pdb (ipdb) console, the commands indicated don't display anything - or display a NameError\n\nIf more info is needed, i will provide it.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":4097,"Q_Id":21582358,"Users Score":11,"Answer":"Use the break command. Don't add any line numbers and it will list all instead of adding them.","Q_Score":13,"Tags":"python,breakpoints,ipdb","A_Id":21582431,"CreationDate":"2014-02-05T16:10:00.000","Title":"How to find the breakpoint numbers in pdb (ipdb)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to find how to execute ipdb (or pdb) commands such as disable.\nCalling the h command on disable says \n\ndisable bpnumber [bpnumber ...]\n  Disables the breakpoints given as a space separated list of\n  bp numbers.\n\nSo how whould I get those bp numbers? was looking through the list of commands and couldn't get any to display the bp numbers\n[EDIT]\nThe break, b and info breakpoints commands don't do anything, although in my module i clearly have 1 breakpoint set like this import pdb; pdb.set_trace( ) - same for ipdb. Moreover info is not defined.\nThe output of help in pdb:\n\nDocumented commands (type help ):\n  ======================================== EOF    bt         cont      enable  jump  pp       run      unt    a      c          continue \n  exit    l     q        s        until  alias  cl         d         h\n  list  quit     step     up     args   clear      debug     help    n\n  r        tbreak   w      b      commands   disable   ignore  next \n  restart  u        whatis break  condition  down      j       p\n  return   unalias  where \nMiscellaneous help topics:\n  ========================== exec  pdb\nUndocumented commands:\n  ====================== retval  rv\n\nAnd for ipdb:\n\nDocumented commands (type help ):\n  ======================================== EOF    bt         cont      enable  jump  pdef    psource  run      unt    a      c\n  continue  exit    l     pdoc    q        s        until  alias  cl\n  d         h       list  pfile   quit     step     up     args   clear \n  debug     help    n     pinfo   r        tbreak   w      b\n  commands   disable   ignore  next  pinfo2  restart  u        whatis\n  break  condition  down      j       p     pp      return   unalias \n  where \nMiscellaneous help topics:\n  ========================== exec  pdb\nUndocumented commands:\n  ====================== retval  rv\n\nI have saved my module as pb3.py and am executing it within the command line like this\n\npython -m pb3\n  The execution does indeed stop at the breakpoint, but within di pdb (ipdb) console, the commands indicated don't display anything - or display a NameError\n\nIf more info is needed, i will provide it.","AnswerCount":2,"Available Count":2,"Score":-0.2913126125,"is_accepted":false,"ViewCount":4097,"Q_Id":21582358,"Users Score":-3,"Answer":"info breakpoints\n\nor just \n\ninfo b \n\nlists all breakpoints.","Q_Score":13,"Tags":"python,breakpoints,ipdb","A_Id":21582459,"CreationDate":"2014-02-05T16:10:00.000","Title":"How to find the breakpoint numbers in pdb (ipdb)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Emacs and I'm trying to set up my python environment. So far I've learned that using \"python-mode.el\" in a python buffer C-c C-c loads the contents of the current buffer into an interactive python shell, apparently using what which python yields. In my case that is python 3.3.3. But since I need to get a python 2.7 shell, I'm trying to get Emacs to spawn such a shell on C-c C-c. Unfortunatly I can't figure out, how to do this. Setting py-shell-name to what which python2.7 yields (i.e. \/usr\/bin\/python2.7) does not work. How can get Emacs to do this, or how can I trace back what Emacs executes when I hit C-c C-c?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1019,"Q_Id":21588464,"Users Score":0,"Answer":"I don't use python, but from the source to python-mode, I think you should look into customizing the variable python-python-command - It seems to default to the first path command matching \"python\"; perhaps you can supply it with a custom path?","Q_Score":2,"Tags":"python,python-2.7,emacs,emacs24","A_Id":21590370,"CreationDate":"2014-02-05T21:03:00.000","Title":"Using python2.7 with Emacs 24.3 and python-mode.el","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to have my app on Amazon appstore. \nIn order to do this Amazon needs to park a small json file (web-app-manifest.json).\nIf I upload it to the the root of my web site (as suggested), Amazon bot says it cannot access file. Amazon support mention I should save it to \/var\/www\/static but either I don't know how to get there or I don't have access to this part of the server.\nAny ideas ?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":155,"Q_Id":21617616,"Users Score":2,"Answer":"You can get to \/var\/www\/static in the File browser. Just click on the '\/' in the path at the top of the page and then follow the links.\nYou can also just copy things there from a Bash console.\nYou may need to create the static folder in \/var\/www if it's not there already.","Q_Score":1,"Tags":"json,pythonanywhere","A_Id":21627045,"CreationDate":"2014-02-07T01:25:00.000","Title":"Where should I save the Amazon Manifest json file on an app hosted at PythonAnywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using the AdaBoostClassifier in Scikit-learn and always get an average probability of 0.5 regardless of how unbalanced the training sets are. The class predictions (predict_) seems to give correct estimates, but these aren't reflected in the predict_probas method which always average to 0.5.\nIf my \"real\" probability is 0.02, how do I transform the standardized probability to reflect that proportion?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":21633136,"Users Score":0,"Answer":"Do you mean you get probabilities per sample that are 1\/n_classes on average? That's necessarily the case; the probabilities reported by predict_proba are the conditional class probability distribution P(y|X) over all values for y. To produce different probabilities, perform any necessary computations according to your probability model.","Q_Score":0,"Tags":"python-2.7,probability,scikit-learn,prediction,adaboost","A_Id":21645757,"CreationDate":"2014-02-07T16:38:00.000","Title":"The predict method shows standardized probability?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a large dataset stored in a numpy array (A) I am trying to sum by block's using:\nB=numpy.add.reduceat(numpy.add.reduceat(A, numpy.arange(0, A.shape[0], n),axis=0), numpy.arange(0, A.shape[1], n), axis=1)\nit work's fine when i try it on a test array but with my data's I get the following message:  \nTypeError: Cannot cast array data from dtype('float64') to dtype('int32') according to the rule 'safe'\nDoes someone now how to handle this?\nThanks for the help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4600,"Q_Id":21640028,"Users Score":1,"Answer":"In case anyone else has a similar problem but the chosen answer doesn't solve it, one possibility could be that in Python3, some index or integer quantity fed into a np function is an expression using '\/' for example n\/2, which ought to be '\/\/'.","Q_Score":3,"Tags":"python,arrays,numpy","A_Id":24217870,"CreationDate":"2014-02-08T00:08:00.000","Title":"Error when trying to sum an array by block's","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Model class which is part of my self-crafted ORM. It has all kind of methods like save(), create() and so on. Now, the thing is that all these methods require a connection object to act properly. And I have no clue on what's the best approach to feed a Model object with a connection object.\nWhat I though of so far:\n\nprovide a connection object in a Model's __init__(); this will work, by setting an instance variable and use it throughout the methods, but it will kind of break the API; users shouldn't always feed a connection object when they create a Model object;\ncreate the connection object separately, store it somewhere (where?) and on Model's __init__() get the connection from where it has been stored and put it in an instance variable (this is what I thought to be the best approach, but have no idea of the best spot to store that connection object);\ncreate a connection pool which will be fed with the connection object, then on Model's __init__() fetch the connection from the connection pool (how do I know which connection to fetch from the pool?).\n\nIf there are any other approached, please do tell. Also, I would like to know which is the proper way to this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":21650889,"Users Score":1,"Answer":"Here's how I would do:\n\nUse a connection pool with a queue interface. You don't have to choose a connection object, you just pick the next on the line. This can be done whenever you need transaction, and put back afterwards.\nUnless you have some very specific needs, I would use a Singleton class for the database connection. No need to pass parameters on the constructor every time.\nFor testing, you just put a mocked database connection on the Singleton class.\n\nEdit:\nAbout the connection pool questions (I could be wrong here, but it would be my first try):\n\nKeep all connections open. Pop when you need, put when you don't need it anymore, just like a regular queue. This queue could be exposed from the Singleton.\nYou start with a fixed, default number of connections (like 20). You could override the pop method, so when the queue is empty you block (wait for another to free if the program is multi-threaded) or create a new connection on the fly.\nDestroying connections is more subtle. You need to keep track of how many connections the program is using, and how likely it is you have too many connections. Take care, because destroying a connection that will be needed later slows the program down. In the end, it's a n heuristic problem that changes the performance characteristics.","Q_Score":0,"Tags":"python,database-connection","A_Id":21651170,"CreationDate":"2014-02-08T19:39:00.000","Title":"Getting connection object in generic model class","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I recently spent some time working out how to use a QDataStream with a QTreeWidget in PyQt.  I never found specific examples for doing exactly this, and pyqt documentation for QDataStream seems to be pretty scarce in general.  So I thought I'd post a question here as a breadcrumb trail in case someone else down the line needs a hint.  I'll wait a bit in case someone would like to jump in and take a shot at it, and I'll post back in a bit with my own efforts.\nThe question is: In PyQt, how can I use a QDataStream to save QTreeWidgetItems to a file as native QT objects, and then read the file back to restore the tree structure exactly as it was saved?\nEric","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2494,"Q_Id":21653108,"Users Score":0,"Answer":"The QTreeWidget is a red herring. What you are saving is a generic QAbstractItemModel (treeWidget->model()) - after all, a QTreeWidget is a view, and has a built-in model. Now, those model's items are simply QVariants, and those are simply Python types, but also fully supported by QDataStream::operator<<. All you need is to choose a tree traversal (depth-first, breadth-first, or something else), and dump the items and their depth in the tree to the stream. When you read the stream, that's sufficient information to reconstruct the tree.","Q_Score":4,"Tags":"python,qt,python-2.7,pyqt,pyqt4","A_Id":21654212,"CreationDate":"2014-02-08T23:30:00.000","Title":"PyQt: Saving native QTreeWidgets using QDataStream","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a Google App Engine application (python) and I'm learning about the general framework. I've been looking at the tutorial and documentation for the NDB datastore, and I'm having some difficulty wrapping my head around the concepts. I have a large background with SQL databases and I've never worked with any other type of data storage system, so I'm thinking that's where I'm running into trouble.\nMy current understanding is this: The NDB datastore is a collection of entities (analogous to DB records) that have properties (analogous to DB fields\/columns). Entities are created using a Model (analogous to a DB schema). Every entity has a key that is generated for it when it is stored. This is where I run into trouble because these keys do not seem to have an analogy to anything in SQL DB concepts. They seem similar to primary keys for tables, but those are more tightly bound to records, and in fact are fields themselves. These NDB keys are not properties of entities, but are considered separate objects from entities. If an entity is stored in the datastore, you can retrieve that entity using its key. \nOne of my big questions is where do you get the keys for this? Some of the documentation I saw showed examples in which keys were simply created. I don't understand this. It seemed that when entities are stored, the put() method returns a key that can be used later. So how can you just create keys and define ids if the original keys are generated by the datastore?\nAnother thing that I seem to be struggling with is the concept of ancestry with keys. You can define parent keys of whatever kind you want. Is there a predefined schema for this? For example, if I had a model subclass called 'Person', and I created a key of kind 'Person', can I use that key as a parent of any other type? Like if I wanted a 'Shoe' key to be a child of a 'Person' key, could I also then declare a 'Car' key to be a child of that same 'Person' key? Or will I be unable to after adding the 'Shoe' key?\nI'd really just like a simple explanation of the NDB datastore and its API for someone coming from a primarily SQL background.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7423,"Q_Id":21655862,"Users Score":13,"Answer":"I think you've overcomplicating things in your mind. When you create an entity, you can either give it a named key that you've chosen yourself, or leave that out and let the datastore choose a numeric ID. Either way, when you call put, the datastore will return the key, which is stored in the form [<entity_kind>, <id_or_name>] (actually this also includes the application ID and any namespace, but I'll leave that out for clarity).\nYou can make entities members of an entity group by giving them an ancestor. That ancestor doesn't actually have to refer to an existing entity, although it usually does. All that happens with an ancestor is that the entity's key includes the key of the ancestor: so it now looks like [<parent_entity_kind>, <parent_id_or_name>, <entity_kind>, <id_or_name>]. You can now only get the entity by including its parent key. So, in your example, the Shoe entity could be a child of the Person, whether or not that Person has previously been created: it's the child that knows about the ancestor, not the other way round.\n(Note that that ancestry path can be extended arbitrarily: the child entity can itself be an ancestor, and so on. In this case, the group is determined by the entity at the top of the tree.)\nSaving entities as part of a group has advantages in terms of consistency, in that a query inside an entity group is always guaranteed to be fully consistent, whereas outside the query is only eventually consistent. However, there are also disadvantages, in that the write rate of an entity group is limited to 1 per second for the whole group.","Q_Score":17,"Tags":"python,google-app-engine,app-engine-ndb","A_Id":21658988,"CreationDate":"2014-02-09T05:53:00.000","Title":"Simple explanation of Google App Engine NDB Datastore","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a text editor with autocompletion feature. What I need is somehow get the text which is selected by mouse (case #1) or just a word under cursor(case #2) to compare it against a list of word I want to be proposed for autocompletion. By get I mean return as a a string value.\nCan it be done with tkinter at all? I'm not familiar with qt but I'll try to use it if the feature can be achieved with it.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1225,"Q_Id":21675320,"Users Score":-2,"Answer":"You can use QTextEdit::cursorForPosition to get a cursor for mouse position. After that you can call QTextCursor::select with QTextCursor::WordUnderCursor to select the word and QTextCursor::selectedText to get the word.","Q_Score":3,"Tags":"python,qt,autocomplete,tkinter","A_Id":21675660,"CreationDate":"2014-02-10T10:59:00.000","Title":"How do I return word under cursor in tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python \/ django app on heroku. how do i find the postgres version running on my app?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":21700792,"Users Score":2,"Answer":"$ heroku pg:info --app yourapp","Q_Score":2,"Tags":"python-2.7,heroku-postgres","A_Id":21710704,"CreationDate":"2014-02-11T11:39:00.000","Title":"How do I find the postgres version running on my heroku app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I seem to be having a problem finding the correct regex for weekdays in Python. I have tried this: \n\/(mon|tues|wednes|thurs|fri|satur|sun)day\/\nThe problem is that this regex accepts if I just have \"mon\" in a text, but I only want it to accept if I have \"monday\". How do I fix this? I can't seem to understand how to do this.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4421,"Q_Id":21708859,"Users Score":0,"Answer":"You can also try like below,\n\na = 'your-string'\nresult = re.findall('(mon|tues|wed|thurs|fri|sat|sun)day', a)\nif result:    _day = result[0] + 'day'","Q_Score":0,"Tags":"python,regex","A_Id":21709113,"CreationDate":"2014-02-11T17:30:00.000","Title":"Regex for weekdays in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am using Flask to serve some files. I recently downgraded the project from Python 3 to Python 2.7 so it would work with more extensions, and ran into a problem I did not have before. I am trying to serve a file from the filesystem with a Japanese filename, and when I try return send_from_directory(new_folder_path, filename, as_attachment=True)\nI get UnicodeEncodeError: 'ascii' codec can't encode characters in position 15-20: ordinal not in range(128). in quote_header_value = str(value) (that is a werkzeug thing).\nI have template set to display the filename on the page by just having {{filename}} in the HTML and it is displaying just fine, so I'm assuming it is somehow reading the name from the filesystem? Only when I try send_from_directory so the user can download it does it throw this error. I tried a bunch of combinations of .encode('utf-8') and.decode('utf-8')`none of which worked at all and I'm getting very frustrated with this. In Python 3 everything just worked seamlessly because everything was treated as unicode, and searching for a way to solve this brought up results that it seems I would need a degree in compsci to wrap my head around. Does anyone have a fix for this? \nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":887,"Q_Id":21715132,"Users Score":0,"Answer":"OK, after wrestling with it under the hood for a while I fixed it, but not in a very elegant way, I had to modify the source of some werkzeug things. In \"http.py\", I replaced str(value) with unicode(value), and replaced every instance of \"latin-1\" with \"utf-8\" in both http.py and datastructures.py. It fixed the problem, file gets downloaded fine in both the latest Firefox and Chrome. As I said before, I would rather not have to modify the source of the libraries I am using because this is a pain when deploying\/testing on different systems, so if anyone has a better fix for this please share. I've seen some people recommend just making the filename part of the URL but I cannot do this as I need to keep my URLs simple and clean.","Q_Score":1,"Tags":"python,unicode,flask","A_Id":21716642,"CreationDate":"2014-02-11T23:07:00.000","Title":"Python - how to send file from filesystem with a unicode filename?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have data that is best represented by a tree. Serializing the structure makes the most sense, because I don't want to sort it every time, and it would allow me to make persistent modifications to the data.\nOn the other hand, this tree is going to be accessed from different processes on different machines, so I'm worried about the details of reading and writing. Basic searches didn't yield very much on the topic. \n\nIf two users simultaneously attempt to revive the tree and read from it, can they both be served at once, or does one arbitrarily happen first?\nIf two users have the tree open (assuming they can) and one makes an edit, does the other see the change implemented? (I assume they don't because they each received what amounts to a copy of the original data.)\nIf two users alter the object and close it at the same time, again, does one come first, or is an attempt made to make both changes simultaneously?\n\nI was thinking of making a queue of changes to be applied to the tree, and then having the tree execute them in the order of submission. I thought I would ask what my problems are before trying to solve any of them.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2682,"Q_Id":21716890,"Users Score":1,"Answer":"Without trying it out I'm fairly sure the answer is:\n\nThey can both be served at once, however, if one user is reading while the other is writing the reading user may get strange results.\nProbably not.  Once the tree has been read from the file into memory the other user will not see edits of the first user.  If the tree hasn't been read from the file then the change will still be detected.\nBoth changes will be made simultaneously and the file will likely be corrupted.\n\nAlso, you mentioned shelve.  From the shelve documentation:\n\nThe shelve module does not support concurrent read\/write access to\n  shelved objects. (Multiple simultaneous read accesses are safe.) When\n  a program has a shelf open for writing, no other program should have\n  it open for reading or writing. Unix file locking can be used to solve\n  this, but this differs across Unix versions and requires knowledge\n  about the database implementation used.\n\nPersonally, at this point, you may want to look into using a simple key-value store like Redis with some kind of optimistic locking.","Q_Score":0,"Tags":"python,serialization,pickle,shelve","A_Id":21718777,"CreationDate":"2014-02-12T01:36:00.000","Title":"Can serialized objects be accessed simultaneously by different processes, and how do they behave if so?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt?\nIf someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0.\nThank you in advance :)","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":13981,"Q_Id":21755574,"Users Score":1,"Answer":"ipython nbconvert notebook.ipynb --to pdf","Q_Score":3,"Tags":"python,pdf,ipython,ipython-notebook","A_Id":55154772,"CreationDate":"2014-02-13T13:25:00.000","Title":"IPython notebook - unable to export to pdf","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt?\nIf someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0.\nThank you in advance :)","AnswerCount":6,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":13981,"Q_Id":21755574,"Users Score":2,"Answer":"open terminal\nnavigate to the directory of your notebook\nipython nbconvert mynotebook.ipynb --to latex --post PDF","Q_Score":3,"Tags":"python,pdf,ipython,ipython-notebook","A_Id":25941564,"CreationDate":"2014-02-13T13:25:00.000","Title":"IPython notebook - unable to export to pdf","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt?\nIf someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0.\nThank you in advance :)","AnswerCount":6,"Available Count":3,"Score":0.0333209931,"is_accepted":false,"ViewCount":13981,"Q_Id":21755574,"Users Score":1,"Answer":"I was facing the same problem. I tried to use the option select File --> Download as --> Pdf via LaTeX (.pdf) in the notebook but it did not worked for me(It is not working for me). I tried other options too still not working.\nI solved it by using the following very simple steps. I hope it will help you too:\nYou can do it by 1st converting the notebook into HTML and then into PDF format:\nFollowing steps I have implemented on:\nOS: Ubuntu, Anaconda-Jupyter notebook, Python 3\n1 Save Notebook in HTML format:\n\nStart the jupyter notebook that you want to save in HTML format. First save the notebook properly so that HTML file will have a latest saved version of your code\/notebook.\n\nRun the following command from the notebook itself:\n!jupyter nbconvert --to html notebook_name.ipynb\n\n\nAfter execution will create HTML version of your notebook and will save it in the current working directory. You will see one html file will be added into the current directory with your_notebook_name.html name\n(notebook_name.ipynb --> notebook_name.html).\n2 Save html as PDF:\n\nNow open that notebook_name.html file (click on it). It will be opened in a new tab of your browser.\nNow go to print option. From here you can save this file in pdf file format.\n\nNote that from print option we also have the flexibility of selecting a portion of a notebook to save in pdf format.","Q_Score":3,"Tags":"python,pdf,ipython,ipython-notebook","A_Id":54918257,"CreationDate":"2014-02-13T13:25:00.000","Title":"IPython notebook - unable to export to pdf","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to find a way to display a txt\/csv file to the user of my Python script. Everytime I search how to do it, I keep finding information on how to open\/read\/write etc ... But I just want to display the file to the user.\nThank you in advance for your help.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":47,"Q_Id":21785951,"Users Score":1,"Answer":"It really depends what you mean by \"display\" the file. When we display text, we need to take the file, get all of its text, and put it onto the screen. One possible display would be to read every line and print them. There are certainly others. You're going to have to open the file and read the lines in order to display it, though, unless you make a shell command to something like vim file.txt.","Q_Score":0,"Tags":"python","A_Id":21785991,"CreationDate":"2014-02-14T17:38:00.000","Title":"Display a file to the user with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python programming and development. After much self study through online tutorials I have been able to make a GUI with wxpython. This GUI interacts with a access database in my computer to load list of teams and employees into the comboboxes. \nNow my first question is while converting the whole program into a windows exe file can I also include the .accdb file with it...as in I only need to send the exe file to the users and not the database..if yes how.\nMy second question is... I actually tried converting the program into exe using the py2exe (excluding the database...am not sure how to do that) and I got the .exe file of my program into the \"Dist\" folder. But when I double click it to run it a black screen (cmd) appears for less than a second and disappears. Please help me understand the above issue and resolve it.\nam not sure if I have a option of attaching files...then I could have attached my wxpython program for reference.\nThanks in advance.\nRegards,\nPremanshu","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":373,"Q_Id":21788522,"Users Score":0,"Answer":"The console could possibly appear if you used the 'console' parameter to setup(). Switch to 'windows' instead if that is the case. Can't say for sure without seeing your setup.py script. Possibly your app could also be opening console, but again hard to say without seeing source. One thing to check is to make sure you are not printing anything to stdout or stderr. You might want to redirect all of stdout and stderr to your log just in case, and do this right at the top of your start script so that if some 3rd party import was writing to stdout you'd be able to capture that.\nThe db is not part of your executable, so py2exe will not do anything with it. However, you should probably package your application with an installer, and you can make the installer include the db and install it along with the executable.","Q_Score":0,"Tags":"python,user-interface","A_Id":21789391,"CreationDate":"2014-02-14T20:01:00.000","Title":"wxpython GUI program to exe using py2exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a pandas dataframe, containing timestamps 'expiration' and 'date'.\nI want to filter for rows with a certain maximum delta between expiration and date.\nWhen doing fr.expiration - fr.date I obtain timedelta values, but don't know how \nto get a filter criteria such as fr[timedelta(fr.expiration-fr.date)<=60days]","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2238,"Q_Id":21790816,"Users Score":3,"Answer":"for the 60 days you're looking to compare to, create a timedelta object of that value timedelta(days=60) and use that for the filter. and if you're already getting timedelta objects from the subtraction, recasting it to a timedelta seems unnecessary.\nand finally, make sure you check the signs of the timedeltas you're comparing.","Q_Score":3,"Tags":"python-2.7,pandas","A_Id":21791001,"CreationDate":"2014-02-14T22:43:00.000","Title":"filter pandas dataframe for timedeltas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Mac, and I have OS X 10.9.1. The main question is whether it is better to create a virtual machine with Linux and do port forwarding or set all packages directly to the Mac OS and work with it directly? If I create a virtual machine, I'm not sure how it will affect the health of SSD and ease of development. On the other hand, I also do not know how to affect the stability and performance of Mac OS installation packages directly into it. Surely there are some best practices, but I do not know them.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1076,"Q_Id":21791565,"Users Score":2,"Answer":"I do all of my main development on OSX. I deploy on a linux box. Pycharm (CE) is your friend.","Q_Score":1,"Tags":"python,macos","A_Id":21791729,"CreationDate":"2014-02-14T23:57:00.000","Title":"Python development on Mac OS X: pure Mac OS or linux in virtualbox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Mac, and I have OS X 10.9.1. The main question is whether it is better to create a virtual machine with Linux and do port forwarding or set all packages directly to the Mac OS and work with it directly? If I create a virtual machine, I'm not sure how it will affect the health of SSD and ease of development. On the other hand, I also do not know how to affect the stability and performance of Mac OS installation packages directly into it. Surely there are some best practices, but I do not know them.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1076,"Q_Id":21791565,"Users Score":3,"Answer":"On my Mac, I use Python and PyCharm and all the usual Unix tools, and I've always done just fine. Regard OS X as a Unix machine with a very nice GUI on top of it, because it basically is -- Mac OS X is POSIX-compliant, with BSD underpinnings. Why would you even consider doing VirtualBox'd Linux? Even if you don't want to relearn the hotkeys, PyCharm provides a non-OS X mapping, and in Terminal, CTRL and ALT work like you expect.\nIf you're used to developing on Windows but interfacing with Unix machines through Cygwin, you'll be happy to use Terminal, which is a normal bash shell and has (or can easily get through Homebrew) all the tools you're used to. Plus the slashes go the right way and line endings don't need conversion.\nIf you're used to developing on a Linux distro, you'll be happy with all the things that \"just work\" and let you move on with your life.\nSo in answer to your question, do straight Mac OS X. Working in a virtualized Linux environment imparts a cost and gains you nothing.","Q_Score":1,"Tags":"python,macos","A_Id":21791847,"CreationDate":"2014-02-14T23:57:00.000","Title":"Python development on Mac OS X: pure Mac OS or linux in virtualbox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset of users and their music plays, with every play having location data. For every user i want to cluster their plays to see if they play music in given locations.\nI plan on using the sci-kit learn k-means package, but how do I get this to work with location data, as opposed to its default, euclidean distance? \nAn example of it working would really help me!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":976,"Q_Id":21802946,"Users Score":2,"Answer":"Is the data already in vector space e.g. gps coordinates? If so you can cluster on it directly, lat and lon are close enough to x and y that it shouldn't matter much. If not, preprocessing will have to be applied to convert it to a vector space format (table lookup of locations to coords for instance). Euclidean distance is a good choice to work with vector space data.\nTo answer the question of whether they played music in a given location, you first fit your kmeans model on their location data, then find the \"locations\" of their clusters using the cluster_centers_ attribute. Then you check whether any of those cluster centers are close enough to the locations you are checking for. This can be done using thresholding on the distance functions in scipy.spatial.distance.\nIt's a little difficult to provide a full example since I don't have the dataset, but I can provide an example given arbitrary x and y coords instead if that's what you want.\nAlso note KMeans is probably not ideal as you have to manually set the number of clusters \"k\" which could vary between people, or have some more wrapper code around KMeans to determine the \"k\". There are other clustering models which can determine the number of clusters automatically, such as meanshift, which may be more ideal in this case and also can tell you cluster centers.","Q_Score":2,"Tags":"python,scikit-learn,cluster-analysis,data-mining,k-means","A_Id":21824056,"CreationDate":"2014-02-15T20:07:00.000","Title":"Computing K-means clustering on Location data in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset of users and their music plays, with every play having location data. For every user i want to cluster their plays to see if they play music in given locations.\nI plan on using the sci-kit learn k-means package, but how do I get this to work with location data, as opposed to its default, euclidean distance? \nAn example of it working would really help me!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":976,"Q_Id":21802946,"Users Score":5,"Answer":"Don't use k-means with anything other than Euclidean distance.\nK-means is not designed to work with other distance metrics (see k-medians for Manhattan distance, k-medoids aka. PAM for arbitrary other distance functions).\nThe concept of k-means is variance minimization. And variance is essentially the same as squared Euclidean distances, but it is not the same as other distances.\nHave you considered DBSCAN? sklearn should have DBSCAN, and it should by now have index support to make it fast.","Q_Score":2,"Tags":"python,scikit-learn,cluster-analysis,data-mining,k-means","A_Id":21825022,"CreationDate":"2014-02-15T20:07:00.000","Title":"Computing K-means clustering on Location data in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to programmatically find out why a Python program closed?\nI'm making a game in python, and I've been using the built in open() function to create a log in a .txt file. A major problem I've come across is that when it occasionally crashes, the log doesn't realise it's crashed.\n I've managed to record if the user closes the game through pressing an exit button, but I was wondering if there is a way to check how the program closed. For instance if the user presses exit, if it crashes or if it is forcefully closed(through the task manager for instance)","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":114,"Q_Id":21817135,"Users Score":2,"Answer":"A few tips:\n\nuse try catch wherever possible.\nEven if it crashes, stack trace will tell which line was last executed.","Q_Score":0,"Tags":"python,file-io","A_Id":21818173,"CreationDate":"2014-02-16T21:47:00.000","Title":"Is there a way to find out why a python program closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using robot framework to test a GUI application , I need to select a span element which is a list box , but I have multiple span elements with same class ID in the same page  , So how can I select each span element(list box) ???\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":313,"Q_Id":21846978,"Users Score":0,"Answer":"Could you please provide a part of your code you use to get the span element and a part of your GUI application where you are trying to get the element from (HTML, or smth.)?","Q_Score":0,"Tags":"python,selenium,automated-tests,robotframework","A_Id":22005969,"CreationDate":"2014-02-18T07:32:00.000","Title":"How to select a span element which is a list box ,when multiple span elements with same class ID are present in the same page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using robot framework to test a GUI application , I need to select a span element which is a list box , but I have multiple span elements with same class ID in the same page  , So how can I select each span element(list box) ???\nThanks in advance","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":313,"Q_Id":21846978,"Users Score":0,"Answer":"Selenium provides various ways to locate elements in the page. If you can't use id, consider using CSS or Xpath.","Q_Score":0,"Tags":"python,selenium,automated-tests,robotframework","A_Id":22013855,"CreationDate":"2014-02-18T07:32:00.000","Title":"How to select a span element which is a list box ,when multiple span elements with same class ID are present in the same page?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a Django project and right now everything works fine. i have a Django admin site and now, i want that when i add a new record to my model, a function calls simultaneously and a process starts. how i can do this? what is this actions name?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2361,"Q_Id":21852518,"Users Score":0,"Answer":"1 WAY\n\nYou can go to your models.py into your app by using django signal you can do this.    \n\nfrom django.db.models.signals import post_save\n\nclass Test(models.Model):\n    # ... fields here\n\n# method for updating\ndef update_on_test(sender, instance, **kwargs):\n     # custome operation as you want to perform\n\n# register the signal\npost_save.connect(update_on_test, sender=Test)\n\n\n2 WAY\n\nYou can ovveride save() method of modeladmin class if you are filling data into table by using django admin.\n\nclass TestAdmin( admin.ModelAdmin ):\n    fields  = ['title', 'body' ]\n    form = TestForm\n\n    def save_model(self, request, obj, form, change):\n         # your login if you want to perform some comutation on save \n         # it will help you if you need request into your work\n         obj.save()","Q_Score":1,"Tags":"python,django,django-admin,django-sites","A_Id":21852651,"CreationDate":"2014-02-18T11:34:00.000","Title":"call a method in Django admin site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an HTTP API using Flask and in one particular operation clients use it to retrieve information obtained from a 3rd party API. The retrieval is done with a celery task. Usually, my approach would be to accept the client request for that information and return a 303 See Other response with an URI that can be polled for the response as the background job is finished.\nHowever, some clients require the operation to be done in a single request. They don't want to poll or follow redirects, which means I have to run the background job synchronously, hold on to the connection until it's finished, and return the result in the same response. I'm aware of Flask streaming, but how to do such long-pooling with Flask?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2430,"Q_Id":21868709,"Users Score":1,"Answer":"Tornado would do the trick.\nFlask is not designed for asynchronization. A Flask instance processes one request at a time in one thread. Therefore, when you hold the connection, it will not proceed to next request.","Q_Score":0,"Tags":"python,api,flask","A_Id":25578832,"CreationDate":"2014-02-19T00:47:00.000","Title":"Flask request waiting for asynchronous background job","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am doing automation task in which I have to open notepad, write some contents and save that file. I know how to open and do keyboard simulation. Is there any way through which I can save that opened Notepad file through script","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3320,"Q_Id":21877935,"Users Score":0,"Answer":"First check how to open notepad through command then use this command in subprocess or os.system.\nor use open() in os module which allow to open file.","Q_Score":0,"Tags":"python,notepad","A_Id":21878937,"CreationDate":"2014-02-19T10:37:00.000","Title":"Opening Notepad and saving using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am recently started to use pycharm. Its embedded terminal is really cool. We can create multiple sessions of terminal using 'ctr+shift+t'. Also we can close sessions using 'ctrl+sht+w'. But how to toggle between these sessions? Is there any keyboard shortcut? Also where should I get list of all shortcuts?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":410,"Q_Id":21884127,"Users Score":3,"Answer":"The shortcuts:\n\nNext Tab = 'Alt'+'Right'\nPrevious Tab = 'Alt' + 'Left'\n\nWhile the cursor is in the Terminal.\nYou can see all the shortcuts in the menu (and add more, or change, or delete):\nFile -> Setting... -> [IDE Settings] Keymap","Q_Score":2,"Tags":"python,editor,keyboard-shortcuts,pycharm","A_Id":21885102,"CreationDate":"2014-02-19T14:56:00.000","Title":"keyboard shortcut for toggling sessions of terminals in pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a script where I create many figures with fix, ax = plt.subplots(...), I get the warning RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (matplotlib.pyplot.figure) are retained until explicitly closed and may consume too much memory. \nHowever, I don't understand why I get this warning, because after saving the figure with fig.savefig(...), I delete it with fig.clear(); del fig. At no point in my code, I have more than one figure open at a time. Still, I get the warning about too many open figures.  What does that mean \/ how can I avoid getting the warning?","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":164804,"Q_Id":21884271,"Users Score":1,"Answer":"matplotlib by default keeps a reference of all the figures created through pyplot. If a single variable used for storing matplotlib figure (e.g \"fig\") is modified and rewritten without clearing the figure, all the plots are retained in RAM memory. Its important to use plt.cla() and plt.clf() instead of modifying and reusing the fig variable.  If you are plotting thousands of different plots and saving them without clearing the figure, then eventually your RAM will get exhausted and program will get terminated. Clearing the axes and figures have a significant impact on memory usage if you are plotting many figures. You can monitor your RAM consumption in task manager (Windows) or in system monitor (Linux). First your RAM will get exhausted, then the OS starts consuming SWAP memory. Once both are exhausted, the program will get automatically terminated. Its better to clear figures, axes and close them if they are not required.","Q_Score":233,"Tags":"python,python-3.x,matplotlib","A_Id":71455335,"CreationDate":"2014-02-19T15:00:00.000","Title":"warning about too many open figures","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to implement custom navigation to my sphinx docs.\nI use my custom theme based on basic sphinx theme. But I don't know how to create new tag for template system or use my custom sphinx plugin's directive in html templates.\nAny ideas where I can plug in?\nUpdate\nAs I can see in sphinx sources, jinja2 environment constructed in websupport jinja2glue module. Though I can't understand the way it can be reconfigured besides monkey-patching.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":737,"Q_Id":21885856,"Users Score":1,"Answer":"I've found a good way to do this. Sphinx's configuration parameter template_bridge allows to control over TemplateBribge object - which is responsible for themes rendering.\nStandard sphinx.jinja2glue.TemplateBridge constructs environment attribute in init method (it's not a constructor, unfortunate name for method) - which is jinja2's environment itself used for templates rendering. So just subclass TemplateBridge and override init method.","Q_Score":0,"Tags":"python,jinja2,python-sphinx","A_Id":21909382,"CreationDate":"2014-02-19T16:03:00.000","Title":"Custom jinja2 tag in sphinx template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to create shedule on OpenShift hosting to run python script that parses RSS feeds and will send filtered information to my email? It feature is available? Please help, who works with free version of this hosting. I have script that works fine. But i dont know how to run it every 10 min to catch freelance jobs. Or anyone does know free hosting with python that can create shedule for scripts.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1892,"Q_Id":21890973,"Users Score":3,"Answer":"You are looking for the add-on cartridge that is called cron.  However, by default the cron cartridge only supports jobs that run every minute or every hour.  You would have to write a job that runs minutely to determine if its a 10 minute interval and then execute your script.\nMake sense?\nrhc cartridge add cron -a yourAppName\nThen you will have a cron directory in application directory under .openshift for placing the cron job.","Q_Score":1,"Tags":"python,openshift","A_Id":21893287,"CreationDate":"2014-02-19T19:54:00.000","Title":"OpenShift, Python Application run script every 10 min","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a solution to the following graph problem in order to perform graph analysis in Python. \nBasically, I have a directed graph of N nodes where I know the following:\n\nThe sum of the weights of the out-edges for each node\nThe sum of the weights of the in-edges for each node\nFollowing from the above, the sum of the sum across all nodes of the in-edges equals the sum of the sum of out-edges\nNo nodes have edges with themselves\nAll weights are positive (or zero)\nHowever, I know nothing about to which nodes a given node might have an edge to, or what the weights of any edges are\n\nRepresented as a weighted adjacency matrix, I know the column sums and row sums but not the value of the edges themselves. I've realized that there is not a unique solution to this problem (Does anyone how to prove that, given the above, there is an assured solution?). However, I'm hoping that I can at least arrive at a solution to this problem that minimizes the sum of the edge weights or maximizes the number of 0 edge weights or something along those lines (Basically, out of infinite choices, I'd like the most 'simple' graph).\nI've thought about representing it as:\nMin Sum(All Edge Weights) s.t. for each node, the sum of its out-edge weights equals the known sum of these, and the sum of its in-edge weights equals the known sum of these. Additionally, constrained such that all weights are >= 0\nI'm primarily using this for data analysis in Scipy and Numpy. However, using their constrained minimization techniques, I'll end up with approximately 2N^2-2N constraints from the edge-weight sum portion, and N constraints from the positive portion. I'm worried this will be unfeasible for large data sets. I could have up to 500 nodes. Is this a feasible solution using SciPy's fmin_cobyla? Is there another way to layout this problem \/ another solver in Python that would be more efficient?\nThanks so much! First post on StackOverflow.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":21893973,"Users Score":0,"Answer":"The prohibition against self-flows makes some instances of this problem infeasible (e.g., one node that has in- and out-flows of 1). Otherwise, a reasonably sparse solution with at most one self-flow always can be found as follows. Initialize two queues, one for the nodes with positive out-flow from lowest ID to highest and one for the nodes with positive in-flow from highest ID to lowest. Add a flow from the front node of the first queue to the front node of the second, with quantity equal to the minimum of the out-flow of the former and the in-flow of the latter. Update the out- and in-flows to their residual values and remove the exhausted node(s) from their queues. Since the ID of the front of the first queue increases, and the ID of the front of the second queue decreases, the only node that self-flows is the one where the ID numbers cross.\nMinimizing the total flow is trivial; it's constant. Finding the sparsest solution is NP-hard; there's a reduction from subset sum where each of the elements being summed has a source node with that amount of out-flow, and two more sink nodes have in-flows, one of which is equal to the target sum. The subset sum instance is solvable if and only if no source flows to both sinks. The algorithm above is a 2-approximation.\nTo get rid of the self-flow on that one bad node sparsely: repeatedly grab a flow not involving the bad node and split it into two, via the bad node. Stop when we exhaust the self-flow. This fails only if there are no flows left that don't use the bad node and there is still a self-flow, in which case the bad node has in- and out-flows that sum to more than the total flow, a necessary condition for the existence of a solution. This algorithm is a 4-approximation in sparsity.","Q_Score":0,"Tags":"python,algorithm,graph,scipy,mathematical-optimization","A_Id":21894459,"CreationDate":"2014-02-19T22:28:00.000","Title":"SciPy - Constrained Minimization derived from a Directed Graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to plot weather data over the span of several days every half hour, but I only want to label the days at the start as a string in the format 'mm\/dd\/yy'. I want to leave the rest unmarked.\nI would also want to control where such markings are placed along the x axis, and control the range of the axis.\nI also want to plot multiple sets of measurements taken over different intervals on the same figure. Therefore being able to set the axis and plot the measurements for a given day would be best.\nAny suggestions on how to approach this with matplotlib?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2934,"Q_Id":21918718,"Users Score":1,"Answer":"Matplotlib xticks are your friend. Will allow you to set where the ticks appear. \nAs for date formatting, make sure you're using dateutil objects, and you'll be able to handle the formatting.","Q_Score":0,"Tags":"python,matplotlib,plot,weather","A_Id":21919317,"CreationDate":"2014-02-20T20:23:00.000","Title":"How to label certain x values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to plot weather data over the span of several days every half hour, but I only want to label the days at the start as a string in the format 'mm\/dd\/yy'. I want to leave the rest unmarked.\nI would also want to control where such markings are placed along the x axis, and control the range of the axis.\nI also want to plot multiple sets of measurements taken over different intervals on the same figure. Therefore being able to set the axis and plot the measurements for a given day would be best.\nAny suggestions on how to approach this with matplotlib?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2934,"Q_Id":21918718,"Users Score":2,"Answer":"You can use a DayLocator as in: plt.gca().xaxis.set_major_locator(dt.DayLocator())\nAnd DateFormatter as in: plt.gca().xaxis.set_major_formatter(dt.DateFormatter(\"%d\/%m\/%Y\"))\nNote: import matplotlib.dates as dt","Q_Score":0,"Tags":"python,matplotlib,plot,weather","A_Id":21919748,"CreationDate":"2014-02-20T20:23:00.000","Title":"How to label certain x values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to be able to gather the values for number of CPUs on a server and stuff like storage space etc and assign them to local variables in a python script. I have paramiko set up, so I can SSH to remote Linux nodes and run arbitrary commands on them, and then have the output returned to the script. However, many commands are very verbose \"such as df -h\", when all I want to assign is a single integer or value. \nFor the case of number of CPUs, there is Python functionality such as through the psutil module to get this value. Such as 'psutil.NUM_CPUS' which returns an integer. However, while I can run this locally, I can't exactly execute it on remote nodes as they don't have the python environment configured. \nI am wondering how common it is to manually parse output of linux commands (such as df -h etc) and then grab an integer from it (similar to how bash has a \"cut\" function). Or whether it is somehow better to set up an environment on each remote server (or a better way).","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1205,"Q_Id":21923046,"Users Score":0,"Answer":"If you can put your own programs or scripts on the remote machine there are a couple of things you can do:\n\nWrite a script on the remote machine that outputs just what you want, and execute that over ssh.\nUse ssh to tunnel a port on the other machine and communicate with a server on the remote machine which will respond to requests for information with the data you want over a socket.","Q_Score":1,"Tags":"python","A_Id":21923164,"CreationDate":"2014-02-21T00:56:00.000","Title":"Reading values over ssh in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here is the deal, how do I put the simplest password protection on an entire site. I simply want to open the site to beta testing but don't really care about elegance - just a dirty way of giving test users a username and password without recourse to anything complex and ideally i'd like to not to have to install any code or third party solutions. I'm trying to keep this simple.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4949,"Q_Id":21937072,"Users Score":0,"Answer":"Why you do not do simple form on index page when user is not authenticated?","Q_Score":3,"Tags":"python,html,django","A_Id":21937650,"CreationDate":"2014-02-21T14:25:00.000","Title":"Whats the smartest way to password protect an entire Django site for testing purposes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to DSL area and I am developing a DSL language. I will need to provide an editor to write the in that language what makes Xtext a very good option. However, some of my libraries are in Python and I need to \"run\" the DSL in python. Any idea how to integrate them?\nthe perfect scenario would be:\nXtext -> Pass the Tokens to Python -> Semantics in Python  \nthank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":780,"Q_Id":21967466,"Users Score":0,"Answer":"Well, I think the answer is quite simple:\nI can generate the code in a XML or pyconf format and read from python\n:)\nthank you anyway","Q_Score":0,"Tags":"python,dsl,xtext","A_Id":22065084,"CreationDate":"2014-02-23T11:14:00.000","Title":"Xtext integration with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to access some functions from a large C-project from Python. It seems to me that SWIG is the way to go. I'm not very used to programming i C and my experience with \"make\" is mostly from downloading source tars. The functions I want to access resides in a large C-project (Gnuplot) and I have no idea who to use SWIG on such a large number of source files. The functions I want to access are all in a single c-file but there are many recursive includes. I would like some suggestions on how to get started. \nWhat I want to access: term\/emf.trm\nReason: Missing support for symbols an LaTex in the EMF-backend to matplotlib (this backend has even been removed from matplotlib). I'm stuck with an old version of Word at work and there is no way to get plots in this program that are suitable for my purpose without EMF. I could use Gnuplot instead of matplotlib but many of the plots are specialized for a certain purpose and matplotlib is much easier to use than Gnuplot. \nAny suggestions would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":728,"Q_Id":21973249,"Users Score":0,"Answer":"You should start by reading the first few chapters of swig manual, and making some of its example projects for python, the distrib has many that illustrate many different capabilities of swig and the make files are already built so one less thing to learn.","Q_Score":0,"Tags":"python,matplotlib,gnuplot,swig","A_Id":21977146,"CreationDate":"2014-02-23T19:19:00.000","Title":"Using SWIG to interface large C-project with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using pip to pull down libraries but didnt realize the key one is only for 2.7.  So now I am working in the 2.7 directory but pip is still installing libs in 3.3. So pyCharm keeps saying the lib is missing. \nI have the PATH var set (this is gasp fn windows 8) so that Python 2.7 comes first but i think the python exe isn't looking in the first place I had pip install things.  Maybe there is a setting in pip that will install it elsewhere now?\nAny hints on how to make this work would be great.  Maybe I just need to start over w\/o python 3.3?\nThank you for your time!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":739,"Q_Id":21974997,"Users Score":4,"Answer":"Try these two solutions:\n1)Remove python3.3 from the path variable and try installing library using pip now. so that pip from python27 can install things.\n2)if this doesn't work then use \n\nC:\\python27\\Scripts\\pip.exe install","Q_Score":0,"Tags":"python,python-2.7,python-3.x,pip","A_Id":22714674,"CreationDate":"2014-02-23T21:45:00.000","Title":"Is it practical to have both Python 2.7 and 3.3 installed at the same time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a javascript placed on third party site and this js makes API calls to my server. JS is publicly available and third party cannot save credentials in JS. \nI want to authenticate API calls before sharing JSON and also want to rate limit. Any one has ideas on how can i authenticate API?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":22013532,"Users Score":0,"Answer":"It all depends on what you're authenticating.\nIf you're authenticating each user that uses your API, you have to do something like the following:\n\nYour site has to somehow drop a cookie in that user's browser, \nYour API needs to support CORS (we use easyXDM.js),\nsomehow upon logging in to their site, their site needs to send the user to your site to have a token passed that authenticates the user against your API (or vice versa, depending on the relationship). \n\nIf you're just authenticating that a certain site is authorized to use your API, you can issue that site an API key.  You check for that API key whenever your API is called.\nThe problem with this approach is that JavaScript is visible to the end user. Anyone who really wants to use your API could simply use the same API key. \nIt's not really authentication without some sort of server to server call. At best, you're simply offering a very weak line of defense against the most obvious of attacks.","Q_Score":1,"Tags":"javascript,jquery,python,api","A_Id":25426295,"CreationDate":"2014-02-25T11:59:00.000","Title":"how to do authentication of rest api from javascript, if javascript is on third party site?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am making use of Python's multiprocessor library and wondering what would be the maximum of worker processes I can call?\nE.g. I have defined async.pool = Pool(100) which would allow me to have max 100 async processes running at the same time, but I have no clue what would be the real maximum value for this?\nDoes anyone know how to find the max value for my Pool? I'm guessing it depends on CPU or  memory.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":6331,"Q_Id":22017118,"Users Score":3,"Answer":"You can use as many workers as you have memory for.\nThat being said, if you set up a pool without any process flag, you'll get workers equal to the machine CPUs:\nFrom Pool docs:\n\nprocesses is the number of worker processes to use. If processes is None then the number returned by os.cpu_count() is used.\n\nIf you're doing CPU intensive work, i wouldn't want more workers in the pool than your CPU count. More workers would force the OS to context switch out your processes, which in turn lowers the system performance. Even resorting to using hyperthreading cores can, depending on your work, choke the processor.\nOn the other hand, if your task is like a webserver with many concurrent requests that individually are not maxing out your processor, go ahead and spawn as many workers as you've got memory and\/or IO capacity for.\nmaxtasksperchild is something different. This flag forces the pool to release all resources accumulated by a worker, once the worker has been used\/reused a certain number of times.\nIf you imagine your workers read from a disk, and this work has some setup overhead, maxtasksperchild will clear that overhead once a worker has done this many tasks.","Q_Score":6,"Tags":"python,multiprocessing,pool","A_Id":33544728,"CreationDate":"2014-02-25T14:28:00.000","Title":"Python multiprocessing: max. number of Pool worker processes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got nbviewer installed and working. I see it has a --localfiles option that takes a folder name. It says: \"Serving local notebooks in \/home\/gb\/S14\/inclass, this can be a security risk\"\nBut I can't figure out the URL format to get it to look for the file there. The code adds a handler for \/localfile\/(.*) but that doesn't seem to get triggered.\nAnyone know how to format name to give to trigger loading a local file?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4226,"Q_Id":22020129,"Users Score":4,"Answer":"One minute later and it occurs to me that the front page might not support even though the server does. Sure enough, http:\/\/localhost:5000\/localfile\/PythonReference.ipynb?create=1 renders the local notebook.","Q_Score":5,"Tags":"ipython-notebook","A_Id":22020213,"CreationDate":"2014-02-25T16:24:00.000","Title":"How to make nbviewer display local files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I already know how to use scipy.optimize.curve_fit for normal fitting needs, but what do I do if both my x data and my y data both have error bars?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":22029142,"Users Score":2,"Answer":"Try scipy.odr. It allows to specify weights\/errors in both input and response variable.","Q_Score":0,"Tags":"python,scipy","A_Id":22044916,"CreationDate":"2014-02-26T00:21:00.000","Title":"Scipy: Fitting Data with Two Dimensional Error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am new to Django, but heard it was promising when attempting to create a a custom CMS.\nI am looking to get started, but their seems to be a lack of documentation, tutorials, etc on how to actually get something like this going. \nI am curious if their are any books\/tutorials\/guides that can help me get started with CMS django building.\nPS- I have heard of django-cms, but am unsure what exactly it is and how it is different from django.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2589,"Q_Id":22030696,"Users Score":0,"Answer":"django CMS is a CMS on top of django. It supports multiple languages really well and plays nice together with your own django apps. The basic idea is that you define placeholders in your template and then are able to fill those placeholders with content plugins. A content plugin can be a anything from text, picture, twitter stream, multi column layout etc.","Q_Score":1,"Tags":"python,django,content-management-system,django-cms","A_Id":22035806,"CreationDate":"2014-02-26T02:47:00.000","Title":"Best way to build a custom Django CMS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"On Windows 7, I install pip with easy_install and want to install a lower version of pip.\nI want to remove the old version, but have no idea how to completely remove the pip installed by easy_install (or if there is a way to do it without going through easy_install, that is fine). How do I do this?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":63563,"Q_Id":22051158,"Users Score":2,"Answer":"To uninstall pip in windows:\n\nRun command prompt as administrator\nGive the command easy_install -m pip\nThis may not uninstall pip completely. So again give this command pip uninstall pip If by previous command pip got uninstalled then this command wont run, else it will completely remove pip\nNow check by giving command pip --version This should give pip is not recognized as an internal or external command","Q_Score":7,"Tags":"python,pip,easy-install","A_Id":51204337,"CreationDate":"2014-02-26T19:22:00.000","Title":"How to fully uninstall pip installed with easy_install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":417,"Q_Id":22057077,"Users Score":-1,"Answer":"Have you tried using pip-2.6 install package?","Q_Score":1,"Tags":"python,linux,tkinter,tk,python-2.6","A_Id":22057396,"CreationDate":"2014-02-27T01:15:00.000","Title":"Installed Python from source and cannot import Tkinter - how to install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":417,"Q_Id":22057077,"Users Score":1,"Answer":"I solved this by adding '\/usr\/lib\/x86_64-linux-gnu' to lib_dirs in setup.py, then rebuilding python","Q_Score":1,"Tags":"python,linux,tkinter,tk,python-2.6","A_Id":22058494,"CreationDate":"2014-02-27T01:15:00.000","Title":"Installed Python from source and cannot import Tkinter - how to install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":417,"Q_Id":22057077,"Users Score":1,"Answer":"Install the TCL and Tk development files and rebuild Python.","Q_Score":1,"Tags":"python,linux,tkinter,tk,python-2.6","A_Id":22057115,"CreationDate":"2014-02-27T01:15:00.000","Title":"Installed Python from source and cannot import Tkinter - how to install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently I am working on a portal which is exposed to end users. This portal is developed using Python 2.7, Django 1.6 and MySQL.\nNow we want to expose this portal as a mobile app. But current design does not support that as  templates, views and database are tightly coupled with each other. So we decided to re-architect the whole portal. After some research I found following:\n\nClient side: AngularJS for all client side operations like show data and get data using ajax.\nServer side: Rest API exposed to AngularJS. This Rest API can be developed using either Tastypie or Django Rest Framework (still not decided). Rest API will be exposed over Django.\n\nI have few questions:\n\nWhat you guys think about architecture? Is this is a good or bad design? How it can be improved?\nWill performance of portal will go down after adding above layers in architecture?\nIn the above architecture whether 2 servers should be used to run this (like one for client and other for serving the API's) or one server will be enough. Currently Heroku is used for deployment.\n\nCurrently portal is getting 10K hits in a day and it is expected to go to 100K a day in 6 months. Will be happy to provide more information if needed.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":183,"Q_Id":22067766,"Users Score":0,"Answer":"What you guys think about architecture?\n\nThis is a common Service Oriented Architecture with decoupled Clients. You just have REST endpoints on your backend, and any Client can consume those endpoints.\nYou should also think about:\n\nDo you need RESTful service (RESTful == stateless, will you store any state on the server?)\nHow to scale the service in the future? (this is a legit thing as you already aware of huge traffic increase and assume 2 servers)\n\n\nHow it can be improved?\n\nUse scala instead of python :)\n\nWill performance of portal will go down after adding above layers in architecture?\n\nIt depends. \nIt will get some performance penalty (any additional abtract layer has it's tax), but most probably you won't event notice it. But still, you should measure it using some stress tests.\n\nIn the above architecture whether 2 servers should be used to run this (like one for client and other for serving the API's) or one server will be enough. Currently Heroku is used for deployment.\n\nWell, as usual, it depends.\nIt depends on the usage profile you have right now and on the resources available. \nIf you are interested in whether the new design will perform better than the old one? - there are a number of parameters.\nResume\nThis is a good overall approach for the system with different clients.\nIt will allow you:\n\nTotally decouple mobile app and frontend development from backend development. (It could be different independent teams, outsourceable)\nStandardize your API layer (as all clients will consume the same endpoints)\nMake you service scalable easier (this includes the separate webserver for static assets and many more).","Q_Score":0,"Tags":"python,django,angularjs,heroku,architecture","A_Id":22103027,"CreationDate":"2014-02-27T11:54:00.000","Title":"How to re-architect a portal for creating mobile app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am using PySide in a not-so-MVC fashion, meaning, I try as much as possible not to edit the generated .ui to .py file, I put my application logic in packages (models) and I have one module (.pyw file) more like a controller for them all to initialize and perform management. Not too best of practice but I'm doing fine, all I want is I dont want to add code to the generated ui .py file (more like my view)\nNow here is the problem\nI Noticed that the generated PySide file doesn't inherit from the QDialog or QMainWindow as you have to create it when you are instantiating the class, as a result, events like closeEvent(self, event) doesn't work inside the class even when you put it there. I know hoe to write functions for QActions and widget connections, but I DONT KNOW HOW TO ADD A CLASS BASED FUNCTION TO A GENERATED PYSIDE CLASS OUTSIDE THE CLASS.\nIf I have to edit the generated view class, I can perfectly tweak it to what I want BUT i dont want to because I can make amendment in QtDesigner and compile at any time\nThis is my question, since I dont want to how do i attach say a closeEvent to the object created from the class in my controller class without touching the generated view class.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1710,"Q_Id":22071291,"Users Score":0,"Answer":"Monkey Patching did the job, I dont know why I didn't taught of that","Q_Score":0,"Tags":"python,events,pyqt,pyside,qt-designer","A_Id":22102393,"CreationDate":"2014-02-27T14:22:00.000","Title":"Adding Event functions outside PyQt\/PySide Generated Code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to read a HTML and I show it on a Tkinter window. I would like to know if this is possible with any module and if it's how can I do it, as I'm totally lost finding solutions.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3286,"Q_Id":22077846,"Users Score":5,"Answer":"There is no support for viewing rendered HTML in a tkinter widget. There was a project (tkhtml) to build a modern web browser using tcl\/tk (which is what powers tkinter), but the project never got past a very early alpha release and the last check-in was in 2009.","Q_Score":3,"Tags":"python,html,tkinter","A_Id":22094453,"CreationDate":"2014-02-27T18:57:00.000","Title":"Read a HTML file and show it on a Tkinter window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use Sphinx to document a large project that is currently not well-documented. In particular I want to use sphinx-apidoc to produce the documentation from the code as I document it. \nHowever I also want to have some pages of tutorial on how to use the project etc., but it seems when I call sphinx-apidoc it generates the whole document at once.\nSo my question is: What is the correct workflow here so I could write the tutorial pages that are to be written manually and at the same time update the documentation in the code? Note that if I update the manually written tutorial pages (e.g. included in the index.txt) and run sphinx-apidoc I will lose them as the whole document is generated at once.\nIn general are there any guidelines as how to proceed in building the documentation?\nNote: The source of inconvenience is that the basic procedure assumes you have all the code documentation already in place and will not make any updates as you proceed in producing the documentation. At least this is what I need to resolve.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2050,"Q_Id":22087875,"Users Score":7,"Answer":"First you run sphinx-quickstart and accept the defaults to set up your basic structure this is only done once and you edit the table of contents section of index.rst to point to your tutorials, give an introduction, etc. - the you at least outline your tutorials in separate .rst files.  You also edit config.py to add autodoc - from the website:\n\nWhen documenting Python code, it is common to put a lot of\n  documentation in the source files, in documentation strings. Sphinx\n  supports the inclusion of docstrings from your modules with an\n  extension (an extension is a Python module that provides additional\n  features for Sphinx projects) called \u201cautodoc\u201d.\nIn order to use autodoc, you need to activate it in conf.py by putting\n  the string 'sphinx.ext.autodoc' into the list assigned to the\n  extensions config value. Then, you have a few additional directives at\n  your disposal.\nFor example, to document the function io.open(), reading its signature\n  and docstring from the source file, you\u2019d write this:\n.. autofunction:: io.open You can also document whole classes or even\n  modules automatically, using member options for the auto directives,\n  like\n.. automodule:: io    :members: autodoc needs to import your modules\n  in order to extract the docstrings. Therefore, you must add the\n  appropriate path to sys.path in your conf.py.\n\nAdd your code modules to the list as above and then call make html to buildyour documentation and use a web browser look at it.\nMake some changes and then run make html again.\nIf you have to use the sphinx-apidoc then I would suggest:\n\nputting your tutorials in a separate directory as .rst files and\nreferencing the documentation produced from the API doc from within them plus\nreferencing the tutorials from within your code comments at the points that they are intended to illustrate.  \n\nThis should allow you to build your tutorials and API documentation separately depending on where you have made changes and still have linkage between them.\nI would strongly recommend the following:\n\nUse a version control system such as mercurial or git so that you can commit your changes before running sphinx,\nPut your tutorial .rst files under the VCS for your project but not the generated documentation files.\nPut all of the tutorial files under a separate directory with a clear name, e.g. tutorials.\nIf you are delivering documentation then use a separate repository for your generated documents that is used to store the deliveries.\nAlways generate documents to a location outside of you code tree.\nPut your invocation of sphinx-apidoc into a batch or make file so that you are consistent with the settings that you use.","Q_Score":6,"Tags":"python,python-sphinx,sphinx-apidoc","A_Id":22088341,"CreationDate":"2014-02-28T06:29:00.000","Title":"What is the correct workflow in using Sphinx for Python project documentation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"As a newbie... I am having difficulties installing pyPDF2 module.  I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":94939,"Q_Id":22106380,"Users Score":21,"Answer":"If you have pip, PyPDF2 is on the Python Package Index, so you can install it with the following in your terminal\/command prompt:\nPython 2:\npip install PyPDF2\nPython 3:\npip3 install PyPDF2","Q_Score":15,"Tags":"python,pypdf2","A_Id":42181449,"CreationDate":"2014-02-28T21:42:00.000","Title":"How do I install pyPDF2 module using windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As a newbie... I am having difficulties installing pyPDF2 module.  I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":94939,"Q_Id":22106380,"Users Score":1,"Answer":"Here's how I did it: \nAfter you have downloaded and installed Python (it usually installs under C:\\Python** (** being python version - usually 27)), copy the extracted PyPDF2 contents to C:\\Python** folder, after that enter in command prompt\/terminal \"cd C:\\Python27\\python.exe setup.py install\". If you did everything right it should start installing PyPDF2.","Q_Score":15,"Tags":"python,pypdf2","A_Id":33626099,"CreationDate":"2014-02-28T21:42:00.000","Title":"How do I install pyPDF2 module using windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that Redis have 16 databases by default, but what if i need to add another database, how can i do that using redis-py?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":460,"Q_Id":22110562,"Users Score":0,"Answer":"You cannot. The number of databases is not a dynamic parameter in Redis.\nYou can change it by updating the Redis configuration file (databases parameter) and restarting the server.\nFrom a client (Python or other), you can retrieve this value using the \"GET CONFIG DATABASES\" command. But the \"SET CONFIG DATABASES xxx\" command will be rejected.","Q_Score":1,"Tags":"python,database,redis,redis-py","A_Id":22111910,"CreationDate":"2014-03-01T05:29:00.000","Title":"Insert a new database in redis using redis.StrictRedis()","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been trying to make a decision about my student project before going further. The main idea is get disk usage data, active linux user data, and so on from multiple internal server and publish them with Django. \nBefore I came to RabbitMQ I was thinking about developing a client application for each linux server and geting this data through a socket. But I want to make that student project simple. Also, I don't know how difficult it is to make a socket connection via Django.\nSo, I thought I could solve my problem with RabbitMQ without socket programming. Basically, I send a message to rabbit queue. Then get whatever I want from the consumer server.\nOn the Django side, the client will select one of the internal servers and click the \"details\" button. Then I want to show this information on web page.\nI already read almost all documentation about rabbitmq, celery and pika. Sending messages to all internal servers(clients) and the calculation of information that I want to get is OKAY but I can't figure out how I can put this data on a webpage with Django?\nHow would you figure out that problem if you were me?\nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3991,"Q_Id":22121368,"Users Score":0,"Answer":"You need the following two programs running at all times:\n\nThe producer, which will populate the queue. This is the program that will collect the various messages and then post them on the queue.\nThe consumer, which will process messages from the queue. This consumer's job is to read the message and do something with it; so that it is processed and removed from the queue. The function that this consumer does is entirely up to you, but what you want to do in this scenario is write information from the message to a database model; the same database that is part of your django app.\n\nAs the producer pushes messages and the consumer removes them from the queue, your database will get updated.\nOn the django side, the process is simply to filter this database and display records for a particular machine. As such, django does not need to be aware of how the records are being populated in the database - all django is doing is fetching, filtering, sending to the template and rendering the views.\nThe question comes how best (well actually, easily) populate the databases.  You can do it the traditional way, by using Python's well documentation DB-API and write your own SQL statements; but since celery is so well integrated with django - you can use the django's ORM to do this work for you as well.\nI hope this gets you going in the right direction.","Q_Score":4,"Tags":"python,linux,django,sockets","A_Id":22125431,"CreationDate":"2014-03-01T22:42:00.000","Title":"Using RabbitMQ with Django to get information from internal servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently I was contemplating the choice of using either R or Python to train support vector machines.\nAside from the particular strengths and weaknesses intrinsic to both programming languages, I'm wondering if there is any heuristic guidelines for making a decision on which way to go, based on the packages themselves.\nI'm thinking in terms of speed of training a model, scalability, availability of different kernels, and other such performance-related aspects.\nGiven some data sets of different sizes, how could one decide which path to take?  \nI apologize in advance for such a possibly vague question.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":381,"Q_Id":22122506,"Users Score":4,"Answer":"I do not have experiece with e1070, however from googling it it seems that it either uses or is based on LIBSVM (I don't know enough R to determine which from the cran entry). Scilearnkit also uses LIBSVM. \nIn both cases the model is going to be trained by LIBSVM. Speed, scalability, variety of options available is going to be exactly the same, and in using SVMs with these libraries the main limitations you will face are the limitations of LIBSVM.\nI think that giving further advice is going to be difficult unless you clarify a couple of things in your question: what is your objective? Do you already know LIBSVM? Is this a learning project? Who is paying for your time? Do you feel more comfortable in Python or in R?","Q_Score":1,"Tags":"python,r,machine-learning,scikit-learn,svm","A_Id":22123913,"CreationDate":"2014-03-02T00:52:00.000","Title":"What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently I was contemplating the choice of using either R or Python to train support vector machines.\nAside from the particular strengths and weaknesses intrinsic to both programming languages, I'm wondering if there is any heuristic guidelines for making a decision on which way to go, based on the packages themselves.\nI'm thinking in terms of speed of training a model, scalability, availability of different kernels, and other such performance-related aspects.\nGiven some data sets of different sizes, how could one decide which path to take?  \nI apologize in advance for such a possibly vague question.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":381,"Q_Id":22122506,"Users Score":0,"Answer":"Sometime back I had the same question. Yes, both e1070 and scikit-learn use LIBSVM. I have experience with e1070 only.\nBut there are some areas where R is better. I have read in the past that Python does not handle categorical features properly (at least not right out of the box). This could be a big deal for some.\nI also prefer R's formula interface. And some of the nice data manipulation packages.\nPython is definitely better for general purpose programming and scikit-learn aids in using a single programming language for all tasks.","Q_Score":1,"Tags":"python,r,machine-learning,scikit-learn,svm","A_Id":22189863,"CreationDate":"2014-03-02T00:52:00.000","Title":"What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"what does \n\n+=, -=, *= and \/=\n\nstand for in Python? and how do you use it for while loop?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":25742,"Q_Id":22132285,"Users Score":1,"Answer":"That is not only python , that is in most of programming languages\nx=1;\nx+=1;\nx will be 2\nx=1;\nx-=1;\nx will be 0\nx=3;\nx*=2;\nx will be 6\nx=6;\nx\/=2;\nx will be 3","Q_Score":0,"Tags":"python,loops,while-loop","A_Id":22132302,"CreationDate":"2014-03-02T19:27:00.000","Title":"what does +=, -=, *= and \/= stand for in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.\nCan you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used  numpy.sum(array, axis=5) for a 5D array would what happen?","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":22143644,"Users Score":0,"Answer":"They are very applicable in scientific computing. Right now, for instance, I am running simulations which output data in a 4D array: specifically \n| Time | x-position | y-position | z-position |.\nAlmost every modern spatial simulation will use multidimensional arrays,  along with programming for computer games.","Q_Score":1,"Tags":"python,arrays,numpy","A_Id":37731398,"CreationDate":"2014-03-03T10:02:00.000","Title":"Examples on N-D arrays usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.\nCan you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used  numpy.sum(array, axis=5) for a 5D array would what happen?","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":22143644,"Users Score":0,"Answer":"There are so many examples... The way you are trying to represent it is probably wrong, let's take a simple example:\n\nYou have boxes and a box stores N items in it. You can store up to 100 items in each box.\nYou've organized the boxes in shelves. A shelf allows you to store M boxes. You can identify each box by a index.\nAll the shelves are in a warehouse with 3 floors. So you can identify any shelf using 3 numbers: the row, the column and the floor.\n\nA box is then identified by: row, column, floor and the index in the shelf.\nAn item is identified by: row, column, floor, index in shelf, index in box.\nBasically, one way (not the best one...) to model this problem would be to use a 5D array.","Q_Score":1,"Tags":"python,arrays,numpy","A_Id":22146242,"CreationDate":"2014-03-03T10:02:00.000","Title":"Examples on N-D arrays usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.\nCan you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used  numpy.sum(array, axis=5) for a 5D array would what happen?","AnswerCount":5,"Available Count":5,"Score":0.0399786803,"is_accepted":false,"ViewCount":141,"Q_Id":22143644,"Users Score":1,"Answer":"A few simple examples are:\n\nA n x m 2D array of p-vectors represented as an n x m x p 3D matrix, as might result from computing the gradient of an image\nA 3D grid of values, such as a volumetric texture\nThese can even be combined in the case of a gradient of a volume in which case you get a 4D matrix\nStaying with the graphics paradigm, adding time adds an extra dimension, so a time-variant 3D gradient texture would be 5D\n\nnumpy.sum(array, axis=5) is not valid for a 5D-array (as axes are numbered starting at 0)","Q_Score":1,"Tags":"python,arrays,numpy","A_Id":22144505,"CreationDate":"2014-03-03T10:02:00.000","Title":"Examples on N-D arrays usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.\nCan you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used  numpy.sum(array, axis=5) for a 5D array would what happen?","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":22143644,"Users Score":0,"Answer":"For example, a 3D array could be used to represent a movie, that is a 2D image that changes with time.\nFor a given time, the first two axes would give the coordinate of a pixel in the image, and the corresponding value would give the color of this pixel, or a grey scale level. The third axis would then represent time. For each time slot, you have a complete image. \nIn this example, numpy.sum(array, axis=2) would integrate the exposure in a given pixel. If you think about a film taken in low light conditions, you could think of doing something like that to be able to see anything.","Q_Score":1,"Tags":"python,arrays,numpy","A_Id":22144263,"CreationDate":"2014-03-03T10:02:00.000","Title":"Examples on N-D arrays usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them.\nCan you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used  numpy.sum(array, axis=5) for a 5D array would what happen?","AnswerCount":5,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":22143644,"Users Score":0,"Answer":"Practical applications are hard to come up with but I can give you a simple example for 3D.\nImagine taking a 3D world (a game or simulation for example) and splitting it into equally sized cubes. Each cube could contain a specific value of some kind (a good example is temperature for climate modelling). The matrix can then be used for further operations (simple ones like calculating its Transpose, its Determinant etc...).\nI recently had an assignment which involved modelling fluid dynamics in a 2D space. I could have easily extended it to work in 3D and this would have required me to use a 3D matrix instead.\nYou may wish to also further extend matrices to cater for time, which would make them 4D. In the end, it really boils down to the specific problem you are dealing with.\nAs an end note however, 2D matrices are still used for 3D graphics (You use a 4x4 augmented matrix).","Q_Score":1,"Tags":"python,arrays,numpy","A_Id":22144157,"CreationDate":"2014-03-03T10:02:00.000","Title":"Examples on N-D arrays usage","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The celery docs suggest that Rabbit-MQ must act like a middleman, where it is used as a messaging platform. \nIn my infrastructure, Rabbit-MQ is the primary server that serves me with some data every second. Now, whenever the data is served, I want Celery to do certain tasks. \nNow, this throws out the whole publisher-worker model, as we're not using Celery where the messages are being produced. \nSo, how do I go about this?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1369,"Q_Id":22146944,"Users Score":1,"Answer":"Celery can use several back-ends. If you are already using RabbitMQ, it makes that option attractive. \nThese are however different concerns. Use a generic RabbitMQ client library such as pika to implement a consumer for your messages, then, if needed, use Celery to schedule tasks.","Q_Score":5,"Tags":"python,rabbitmq,celery","A_Id":56632082,"CreationDate":"2014-03-03T12:34:00.000","Title":"How to use celery to get messages from a rabbit-mq server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a Python script to use Rackspace's API (Pyrax) to handle some image processing. It works perfect locally, but when I upload it to Iron.io worker, it builds but does not import. \nI am using a Windows 8 pc, but my boss runs OS X and uploading the exact worker package, it works fine. So I'm thinking it's something with Windows 8 but I don't know how to check\/fix.\nI do apologize in advance if I ramble or do not explain things clearly enough but any help would be greatly appreciated. \nMy worker file looks like this:\nruntime \"python\"\nexec \"rackspace.py\"\npip \"pyrax\"\nfull_remote_build true\nThen I simply import pyrax in my python file.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":22148917,"Users Score":0,"Answer":"It's difficult to know for sure what's happening without being able to see a traceback. Do you get anything like that which could be used to help figure out what's going on?","Q_Score":1,"Tags":"python,pip,rackspace,iron.io,pyrax","A_Id":22153710,"CreationDate":"2014-03-03T14:10:00.000","Title":"pip \"pyrax\" dependency with iron worker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a Python script to use Rackspace's API (Pyrax) to handle some image processing. It works perfect locally, but when I upload it to Iron.io worker, it builds but does not import. \nI am using a Windows 8 pc, but my boss runs OS X and uploading the exact worker package, it works fine. So I'm thinking it's something with Windows 8 but I don't know how to check\/fix.\nI do apologize in advance if I ramble or do not explain things clearly enough but any help would be greatly appreciated. \nMy worker file looks like this:\nruntime \"python\"\nexec \"rackspace.py\"\npip \"pyrax\"\nfull_remote_build true\nThen I simply import pyrax in my python file.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":116,"Q_Id":22148917,"Users Score":2,"Answer":"I figured out that it was a bad Ruby install. No idea why, but reinstalling it worked.","Q_Score":1,"Tags":"python,pip,rackspace,iron.io,pyrax","A_Id":22153804,"CreationDate":"2014-03-03T14:10:00.000","Title":"pip \"pyrax\" dependency with iron worker","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm making a python class which calculates the tfidf weight of each word in a document. Now in my dataset I have 50 documents. In these documents many words intersect, thus having multiple same word features but with different tfidf weight. So the question is how do I sum up all the weights into one singular weight?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":722,"Q_Id":22159351,"Users Score":2,"Answer":"First, let's get some terminology clear.  A term is a word-like unit in a corpus.  A token is a term at a particular location in a particular document.  There can be multiple tokens that use the same term.  For example, in my answer, there are many tokens that use the term \"the\".  But there is only one term for \"the\".\nI think you are a little bit confused.  TF-IDF style weighting functions specify how to make a per term score out of the term's token frequency in a document and the background token document frequency in the corpus for each term in a document.  TF-IDF converts a document into a mapping of terms to weights.  So more tokens sharing the same term in a document will increase the corresponding weight for the term, but there will only be one weight per term.  There is no separate score for tokens sharing a term inside the doc.","Q_Score":0,"Tags":"python,text,machine-learning,classification,tf-idf","A_Id":22159481,"CreationDate":"2014-03-03T22:58:00.000","Title":"(Text Classification) Handling same words but from different documents [TFIDF ]","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on creating a web spider in python. Do i have to worry about permissions from any sites for scanning there content? If so, how do i get those? Thanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":22165086,"Users Score":0,"Answer":"robots.txt file does have limits.\nIts better to inform the owner of the site if you are crawling too often and read reserved rights at the bottom of the site. It is a good idea to provide a link, to the source of your content.","Q_Score":1,"Tags":"python,web-scraping","A_Id":22165257,"CreationDate":"2014-03-04T07:01:00.000","Title":"Permission to get the source code using spider","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working for a university and they have their own libraries and paths for python libraries. Every time I start ipython, I need to run a shell script (e.g. \/etc\/university\/env.sh)\nThe problem is that emacs doesn't recognize the env.sh file. When I do py-shell, emacs always envokes Python WITHOUT any pre-set environment variables. \nIs there a way to make emacs run \/etc\/corporate\/env.sh before starting python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":392,"Q_Id":22175349,"Users Score":0,"Answer":"After running your \/etc\/university\/env.sh, start Emacs from this shell.\nThen the variables set before are known.","Q_Score":1,"Tags":"python,bash,shell,emacs,ipython","A_Id":22208324,"CreationDate":"2014-03-04T14:56:00.000","Title":"how to load shell environment variables when Emacs starts py-shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can we traverse back to parent in xpath?\nI am crawling IMDB, to obtain genre of films, I am using\nelem =  hxs.xpath('\/\/*[@id=\"titleStoryLine\"]\/div\/h4[text()=\"Genres:\"]')\n\nNow,the genres are listed as anchor links, which are siblings to this tag. how can this be achieved?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":405,"Q_Id":22177872,"Users Score":2,"Answer":"This will select the parent element of the XPath expression you gave:\n\/\/*[@id=\"titleStoryLine\"]\/div\/h4[text()=\"Genres:\"]\/..","Q_Score":2,"Tags":"python,lxml,lxml.html","A_Id":22177986,"CreationDate":"2014-03-04T16:45:00.000","Title":"Traversing back to parent with lxml.html.xpath","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"so I am actually trying to get into software development and I currently have just spent a few days making a GUI in Photoshop. Now I know how to code in Java and Python but I have never implemented a GUI before. I am stuck on this because I know I can write the code and everything but how do I take what I made in Photoshop add some java or python code to it to make certain things happen? I have zero experience in this and I have only written code to accomplish tasks without the need for a GUI.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1055,"Q_Id":22215361,"Users Score":2,"Answer":"but how do I take what I made in Photoshop add some java or python code to it to make certain things happen\n\nNo, you cannot expect things to happen magically, for that you need to learn front-end technologies like HTML, CSS, JavaScript etc and manually convert the UI which is in Photoshop to corresponding code. This applies for web applications.\nIf you want to build desktop application, you need to use Swings, SWT etc to achieve the same.\n\nI have zero experience in this\n\nIf this is the case, I recommend to read some basic tutorials, then you will get idea what to do","Q_Score":0,"Tags":"java,python,user-interface,photoshop","A_Id":22215461,"CreationDate":"2014-03-06T04:57:00.000","Title":"UI Designed in Photoshop for Software","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python application that I launch from a form using mod_wsgi. I would like to display in real time the output of the script, while it is running, to a web page.\nDoes anybody know how I can do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":406,"Q_Id":22268968,"Users Score":1,"Answer":"You'll need JavaScript to do this\nPossibility 1, data generated by server\n- Make a static HTML page with an empty div.\n- Place a piece of Javascript code onto it that is run after the page is loaded.\n- The JavaScript will contain a timer that downloads the output of your script say every 5 seconds, using AJAX ands sets your div's html to the result.\n- The easiest way to get this working is probably to use the AJAX facilities in JQuery.\nPossibility 2, data generated by client\n- If it is possible to have your dynamic output generated on the client by a piece of JavaScript code this will scale better (since it takes the burden off the server.)\n- You may still load the input data needed to compute the dynamic output formatted as JSON by means of AJAX.","Q_Score":1,"Tags":"python,web,mod-wsgi","A_Id":22933666,"CreationDate":"2014-03-08T11:53:00.000","Title":"Real time output of script on web page using mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to write a hopefully short python script that would do things with the contents of a specially formatted text cell of an spss data table.\nHow can I hook on the event that the user clicked into a data cell? How can I then get its value and do things I want? Does spss have clear-cut interface for doing this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":22274048,"Users Score":0,"Answer":"You cannot catch events using the programmability or scripting apis.  The only formatting in the Data Editor comes from variable formats (and column width) except for the special coloring using with missing data imputation.  Tables in the Viewer, of course, have extensive cell formatting capabilities.","Q_Score":0,"Tags":"python,events,event-handling,spss","A_Id":22282456,"CreationDate":"2014-03-08T19:35:00.000","Title":"how to hook on a table cell in spss using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do two subplots with imshow using the same colormap by which I mean: if points in both plots have the same color, they correspond to the same value. But how can I get imshow to use only 9\/10 or so of the colormap for the first plot, because it's maximal value is only 9\/10 of the maximal value in the second plot?\nThanks,\nAlice","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":22274186,"Users Score":1,"Answer":"imgshow takes two arguments vmin and vmax for the color scale. You could do what you want by putting the same vmin and vmax for both your subplots. \nTo find vmin you can take the minimum between the minimum of all the values in your data (and same reasoning for vmax).","Q_Score":0,"Tags":"python,matplotlib,color-mapping","A_Id":22274333,"CreationDate":"2014-03-08T19:45:00.000","Title":"one colormap for multiple subplots with different maximum values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a form where users are submitting data. One of the fields is \"author\" which i automatically fill in by using the {{ user }} variable in the template, it will have the username if the user is logged in and AnonymousUser if not. This {{ user }} is not part of the form, just text.\nWhen a user submits the form i need to see which user, or if this was an anonymous user that submitted the data so i though i would use the request.session['user'] but this doesnt work since the user key is not available. I tried setting the request.session['user'] value to the user object but the session dictionary doesnt accept objects, it says its not JSON serializable.\nI though the context processors would add this user variable to it was also available to the view but it isnt. I need a user object and not just the user name to save to the database along with the form. Is there any way to extract the user object when its not part of the form and the user is logged in ? I need to associate the submitted data with a user or an anonymous user and the foreign key requires an object which i also think is must convient to work with when extracting the data from the DB again.\nI dont see it being helpful to post any code here since this is a question of how to extract a user object after a post and not specifically a problem with the code.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":22282264,"Users Score":0,"Answer":"The user is never in request.session. It's directly on the request object as request.user.","Q_Score":0,"Tags":"python,django,forms,session","A_Id":22282298,"CreationDate":"2014-03-09T12:39:00.000","Title":"User session object is not available on POST in django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using celery 3.X and RabbitMQ backend. From time to time it needs to restart celery (to push a new source code update to the server). But there is a task with big loop and try\/catch inside of the loop; it can takes a few hours to accomplish the task. Nothing critical will happen if I will stop it and will restart it later. \nQUESTION: The problem is every time after I stopped the workers (via sudo service celeryd stop) I have to KILL the task manually (via kill -9); the task ignores SIGTERM from worker. I've read throw Celery docs & Stackoverflow but I can't find working solution. Any ideas how to fix the problem?","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1753,"Q_Id":22301208,"Users Score":-2,"Answer":"Celery is not intended to run long tasks cause it blocks the worker for your task only. I recommend re-arranging your logic, making the task invoke itself instead of making the loop. Once shutdown is in progress, your current task will complete and will resume right at the same point where it stopped before celery shutdown.\nAlso, having task split into chunks, you will be able to divert the task to another worker\/host which is probably what you would like to do in the future.","Q_Score":4,"Tags":"python,celery","A_Id":29481481,"CreationDate":"2014-03-10T13:16:00.000","Title":"Notify celery task to stop during worker shutdown","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a website in python (with django and GIT) for an association, and I am to a point where I need to share my work for approval from the team.\nI have around 50 people who need to be able to access my \"website\" 24\/7.\nApparently, free hosting is not the best way to do it (see answers to my original question).\nI've never done such a thing, so I'm a bit lost. It looks like I can use without too many investment in effort my ubuntu computer. And apparently there is other tools for this application.\nI'm looking for advise and explanation on how to implement a working solution.\nEDIT: The 50 people are not in my local network.\n[ORIGINAL POST BELOW]\nWhat is the best way to share my website to partners?\nI'm developing a website for an association, and I want to know if there is a way to let them access to my work in progress.\nI was thinking of free hosting solutions?\nI'm not looking for a professional host, I'm just looking for a way to share my work with maximum 50 peoples.\nIs there another solution?\nI have an ubuntu pc that I could use as server (I have high speed connection).\n(I don't know if this is relevant, but I'm using python-django and bootstrap for the design)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":122,"Q_Id":22357298,"Users Score":1,"Answer":"Well, then use your ubuntu system, forward the right ports in your router and give your customers a link to your IPadres. I assume you use your ubuntu system as an webserver already for testing your site?","Q_Score":2,"Tags":"python,twitter-bootstrap,hosting","A_Id":22357361,"CreationDate":"2014-03-12T16:07:00.000","Title":"How can I share my website in progress to partner?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using Windows 8.\nPython version 2.7.3 have been installed on my computer together with another software. \nNow I have installed python 3.3.5 and i want to use this version from now.\nBut everytime I run Python IDLE it runs version 2.7.3.\nEven if I go to C:\\Python33\\Lib\\idlelib\\idle.pyw and run idle.pyw it runs with the 2.7.3 version.\nI thought that every python version install its own IDLE so I am quiet confused here.\nWhen I run Hello world program from the console it runs using the version 3.3.5 I have checked that.\nSo what I need to do is to run IDLE using 3.3.5 version\nAnybody knows what to do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":271,"Q_Id":22358713,"Users Score":2,"Answer":"Each installation of Python comes with its own respective version if IDLE. I suggest you explore your Python installation folder, and find the version of IDLE you're looking for and create a shortcut to it, or add it to your environment variable list, so you can invoke a specific version from the command line.","Q_Score":0,"Tags":"python-3.x","A_Id":22358774,"CreationDate":"2014-03-12T17:01:00.000","Title":"How to set Python IDLE to use certain python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning some model based on examples ${((x_{i1},x_{i2},....,x_{ip}),y_i)}_{i=1...N}$ using a neural network of Feed Forward Multilayer Perceptron (newff) (using python library neurolab). I expect the output of the NN to be positive for any further simulation of the NN. \nHow can I make sure that the results of simulation of my learned NN are always positive? \n(how I do it in neurolab?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":948,"Q_Id":22360412,"Users Score":0,"Answer":"Simply use a standard sigmoid\/logistic activation function on the output neuron. sigmoid(x) > 0 forall real-valued x so that should do what you want.\nBy default, many neural network libraries will use either linear or symmetric sigmoid outputs (which can go negative).\nJust note that it takes longer to train networks with a standard sigmoid output function. It's usually better in practice to let the values go negative and instead transform the outputs from the network into the range [0,1] after the fact (shift up by the minimum, divide by the range (aka max-min)).","Q_Score":1,"Tags":"python,neural-network","A_Id":22360726,"CreationDate":"2014-03-12T18:17:00.000","Title":"Python Neurolab - fixing output range","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source.\nI've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only the DLL file.  Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like.\nIs SWIG the right route to use in this case?  I am trying to load this DLL in Python so I can utilize a function.  From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this.  Boost.python seems to require changing the underlying C++ code to make it work with Python.\nTo sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1508,"Q_Id":22378590,"Users Score":0,"Answer":"To use a library (static or dynamic), you need headers and library file .a, .lib...\nIts true for c++ and I think its the same for Python","Q_Score":0,"Tags":"python,c++,dll,swig","A_Id":22378831,"CreationDate":"2014-03-13T12:25:00.000","Title":"SWIG C++ Precompiled DLL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a third party DLL (no header file) written in C++ and I am able to get the function prototype information from the developer, but it is proprietary and he will not provide the source.\nI've gone through the SWIG tutorial but I could not find anywhere specifying how to use SWIG to access any functions with only the DLL file.  Everything on the tutorial shows that I need to have the header so SWIG knows what the function prototypes look like.\nIs SWIG the right route to use in this case?  I am trying to load this DLL in Python so I can utilize a function.  From all of my research, it looks like Python's ctypes does not work with C++ DLL files and I am trying to find the best route to follow to do this.  Boost.python seems to require changing the underlying C++ code to make it work with Python.\nTo sum up, is there a way to use SWIG when I know the function prototype but do not have the header file or source code?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1508,"Q_Id":22378590,"Users Score":0,"Answer":"SWIG cannot be used without the header files. Your only option is a lib like ctypes. If you find ctypes doesn't do it for you and you can't find alternative then post a question with why ctypes not useable in your case.","Q_Score":0,"Tags":"python,c++,dll,swig","A_Id":22389172,"CreationDate":"2014-03-13T12:25:00.000","Title":"SWIG C++ Precompiled DLL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded my code from bit-bucket which was made by my group member. It contain all the frameworks and python script folder. But when I run this code on my system it generates the following error:\n\nThis program can't start because python27.dll is missing from your\n  computer. Try reinstalling the program to fix this program\n\nI have also downloaded and installed python 2.7 on my system but when I run it generates the same error.\nPlease tell me how can I fix this problem.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":16517,"Q_Id":22381841,"Users Score":4,"Answer":"It's most probably a 32-bit or 64-bit issue. Try downloading proper version.","Q_Score":6,"Tags":"python,dll","A_Id":22383385,"CreationDate":"2014-03-13T14:32:00.000","Title":"Python27.dll File Missing - Exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded my code from bit-bucket which was made by my group member. It contain all the frameworks and python script folder. But when I run this code on my system it generates the following error:\n\nThis program can't start because python27.dll is missing from your\n  computer. Try reinstalling the program to fix this program\n\nI have also downloaded and installed python 2.7 on my system but when I run it generates the same error.\nPlease tell me how can I fix this problem.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":16517,"Q_Id":22381841,"Users Score":3,"Answer":"I also got this error when I copied my python environment from one computer to another. Both computers were 64 bit and the installation was 64 bit. What happens is that python installer updates Microsoft registry. When I simply copied the python files, the registry did not get updated, of course, resulting in the dll file missing error message.\nI solved it by installing the 64 bit version of python first on my target computer, and then did my copy of the environment, i.e. copied c:\\pythonFromComputerA to target computer's c:\\python27, effectively overwriting the python that had just been installed. But because the installer updated the registry, I could now run with my python environment on the target computer without getting the error message.\nThought I'd provide this in case others are out there scratching their heads, having correctly matching installation with OS yet getting this error message.","Q_Score":6,"Tags":"python,dll","A_Id":30247563,"CreationDate":"2014-03-13T14:32:00.000","Title":"Python27.dll File Missing - Exception","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project in which I have changed the default 'Django Administration' text in the header.\nNow I have implemented translation of strings that django knows about, but I cannot figure out how to translate this title.\nI put the translation function in models.py but it doesn't change when I change Language.\nI've edited the base.html template like so\n{% trans 'My Console' %}\nAnd added the msgstr in my .po files and ran makemessages and compilemessages\nI am running out of things to try.\nCan anyone shed some light on how to do this?\nI can supply code if it will help.\nThanks for reading.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":90,"Q_Id":22384473,"Users Score":0,"Answer":"Try to move your app name up to admin app in your INSTALLED_APPS settings.py tuple.","Q_Score":0,"Tags":"python,django","A_Id":22384701,"CreationDate":"2014-03-13T16:11:00.000","Title":"Where do I put the specific translation functions in Django App?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a number of huge delimited text files containing information logged by date. Some of the files overlap slightly with each other by date (which I don't want since it leads to duplicates). I know what the overlapping dates are so I want to be able to go through some of the files and delete each of the rows that contains those specified dates.\nI know how to do this in python (rewriting each of the lines I want) but because of the size of the files (each is a few GBs) I was wondering if it would be a lot faster to do this through linux?\nThe text files will be sorted by date, earliest to latest, and the dates I need to delete are always going to be in the beginning of the file so I can search until I hit a row that has a date right after the ones I want to delete and write out the rest of the file to another file (or delete all the contents above).","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":22391805,"Users Score":0,"Answer":"There are various command line applications that would be able to accomplish this when working together. For example, you could cat all the files one after another, grep -v the patterns you don't want, redirecting >> to a new file. In effect this is doing the same thing as your Python script would do, because every line of every file must be copied (except the duplicates). It might be faster than Python, though, because those tools are written in C.","Q_Score":0,"Tags":"python,linux,bash,file-io","A_Id":22392153,"CreationDate":"2014-03-13T21:54:00.000","Title":"deleting rows in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am programming a small web app on GAE using python webapp2 framework.\nWhat I want to achieve is displaying server data to the html view through javascript or angularjs. Actually the app draws some graph using d3.js based on the server data. I know I can use $http.get to retrieve the data from server. But this way I need to create another page or handler. I am wondering if there is some way which I can do the below actions.\n\nOn the server python handler, retrieve the stored data, then passing to the jinja2 template values. Render the html.\nDisplay some of the data on the html view via jinja2 template values. \n(The missing part) How to pass the data to js from the python handler? Or how to pass the data to js from html view? I know two ways from the html view. One is using embedded javascript code.\n var data = {{serverData}}; \n\nThe other is using hidden input form with angular data bind. Both of them not so nicely. \n4.Compute the data and draw back to the view using d3js or other js lib.\nAny idea about this? I reckon there might be some angular way to do this beautifully but didnt figure out.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":586,"Q_Id":22404358,"Users Score":2,"Answer":"Since you are already going to build an Angular app for the front-end, why not make the whole architecture RESTful? That way the front-end Angular app will be in charge of presentation and the server of just the data. You can pass data between the server and front-end through JSON which has the benefit of not needing to deal with html or templates in the back end? Angular already has Service and $http that can abstract away the two-way data binding, and using webapp2's RESTful nature you can make this happen fairly painlessly.","Q_Score":0,"Tags":"javascript,python,angularjs,google-app-engine,jinja2","A_Id":22408064,"CreationDate":"2014-03-14T11:58:00.000","Title":"How to transfer html view data or (Python) server data to Angular or Javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to combine the regular expressions \\w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that.  Does anyone know how?","AnswerCount":6,"Available Count":2,"Score":-0.0333209931,"is_accepted":false,"ViewCount":449,"Q_Id":22413763,"Users Score":-1,"Answer":"So I was actually able to get it to work like this : [a-z]\\w+.","Q_Score":0,"Tags":"python,regex,expression","A_Id":22430200,"CreationDate":"2014-03-14T19:10:00.000","Title":"Combining regular expressions in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to combine the regular expressions \\w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that.  Does anyone know how?","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":449,"Q_Id":22413763,"Users Score":1,"Answer":"If you only want lowercase words, all you need is [a-z]+\n\\w includes uppercase letters, digits, and underscore","Q_Score":0,"Tags":"python,regex,expression","A_Id":22413846,"CreationDate":"2014-03-14T19:10:00.000","Title":"Combining regular expressions in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My service return up to 500 objects at time i've notice that my iphone application is crashing when the amount of data goes over 60 objects. to workaround this issue I'm running a query that brings back only the top 40 results but that is slower than just returning the entire data\n\nwhat are the best practices and how can i retrieve more objects?\nwhat is the maximum amount of memory allocated to an application in iphone and is there a way to extend it?\nHow many objects should I retrieve from server\nHow many can be stored in NSCache?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":22425631,"Users Score":0,"Answer":"Maybe you should use NSData to retrieve data from your service instead of NSCache.\nNSCache is for temporary objects, however NSData is used to move data between applications (from your service to your app) \nDescription of NSCache by Apple:\nAn NSCache object is a collection-like container, or cache, that stores key-value pairs, similar to the NSDictionary class. Developers often incorporate caches to temporarily store objects with transient data that are expensive to create. Reusing these objects can provide performance benefits, because their values do not have to be recalculated. However, the objects are not critical to the application and can be discarded if memory is tight. If discarded, their values will have to be recomputed again when needed.\nDescription of NSData by Apple:\n*NSData and its mutable subclass NSMutableData provide data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation objects.\nNSData creates static data objects, and NSMutableData creates dynamic data objects. NSData and NSMutableData are typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications.*","Q_Score":1,"Tags":"python,iphone,nscache,memory-optimization","A_Id":22482214,"CreationDate":"2014-03-15T15:19:00.000","Title":"How many objects should I retrieve from server and How many can be stored in NSCache?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm writing a prototype for the tactical spaceship combat in a game I'm working on.\nThe basic idea of the part I'm working on right now is that a 'ship' object (which represents a single individual ship) contains a list of 'system' objects. When a ship is first initialized, it calls an initialize() function on each of its systems (which is not the same as the standard __init__ function called whenever an instance of an object is made) that will (among other things) call a register() function on the ship the system is a part of.\nThat register() function takes a string as a parameter, which is the name of a function that the system expects to be called on the ship object. Whenever that function is called on the ship object, the ship object will call it on all systems that registered to receive it until either one of them returns True (indicating that the system 'dealt with' the action in a final manner) or it runs out of systems that have signed up to receive the call. So far so good.\nHowever, some systems might want to get their calls before other systems do. For example, your hull system will want to be the last system to receive a hit(); the shields will want to hear it first. The simplest solution might be to implement a priority system: the shields will call myship.register(\"hit\",priority=1), and the hull will call myship.register(\"hit\",priority=0).\nBut now we imagine that there ought to be \"super-shields\" that intercept the hit before the main shields take it. Simple enough: give them priority 2. This might get annoying for the developer if a whole lot of systems want to take a certain request, but he can manage it.\nHowever, this game is intended to be highly user-extensible. If someone releases an addon that (for a stupid example) plays Full Metal Jacket sound clips every time the player's ship is hit, the developer of that addon might not be aware of the addon that adds the \"super-shields\", and give his Annoying Drill Sergeant system the same or lower priority as the super-shields, and thus may not receive hit messages before they are acknowledged by the super-shield. This is, of course, undesirable behavior.\nDoes anyone have any ideas as to how to avoid this problem? \nOthers have suggested having a way a system can request the priority level one higher than or one lower than the highest\/lowest current priority level, but that causes largely undefined behavior, since the priority levels would be based on the order in which the systems are initialized.\nI've also considered adding a \"super-priority\", where a system always receives the message before other systems but cannot acknowledge and stop it. This would be only a partial solution though; it'd fix the given example, but not a situation where there are super-shields layered under super-super-shields that need to block the message.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":112,"Q_Id":22438569,"Users Score":1,"Answer":"The issue is trying to give an absolute value to the priority. Rather you need to build a relative priority data structure for each call. This way you can say that hit() is highest priority for super-shields then shields then hull. The mod would then simply need to change the hit sound effects for the hull or add an additional sound effect to be played as well.\nThe most straightforward way to go about it would requiring that any new object's priority for a given call be linked to another object with that call. It then requires selecting if the new object's priority is lower or higher. So shields and hull are linked (hull < shields) and super-shields and shields are linked (shields < super-shields). That information would make it fairly easy to build a 2D multiple items (2D to have allow for same priority) linked list that holds the priorities for each call. Thus the register function might look like this, \"myship.register(\"hit\",shields,\"lower\",super-shields)\" and give shields a lower priority than super-shields. You could allow for additional conditions such as myship.register(\"hit\",hull,\"lower\",shields,\"lower\",super-shields) if you already had the hull and super-shields, and wanted to add shields between them. However, then you run the risk of having to deal with contradictions or violating the conditions.","Q_Score":0,"Tags":"algorithm,python-3.x,message-passing","A_Id":22452071,"CreationDate":"2014-03-16T15:06:00.000","Title":"Algorithm design for systems on a spaceship taking messages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I try to install PIL library on Macosx 10.9.2, it's giving following error, how to install it.\n\n$: sudo pip install pillow\ncc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DHAVE_LIBJPEG -DHAVE_LIBZ -DHAVE_LIBTIFF -I\/System\/Library\/Frameworks\/Tcl.framework\/Versions\/8.5\/Headers -I\/System\/Library\/Frameworks\/Tk.framework\/Versions\/8.5\/Headers -I\/usr\/local\/Cellar\/freetype\/2.5.2\/include\/freetype2 -I\/private\/tmp\/pip_build_root\/pillow\/libImaging -I\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/include -I\/usr\/local\/include -I\/usr\/include -I\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/include\/python2.7 -c _imaging.c -o build\/temp.macosx-10.9-intel-2.7\/_imaging.o\nclang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]\nclang: note: this will be a hard error (cannot be downgraded to a warning) in the future\nerror: command 'cc' failed with exit status 1","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":751,"Q_Id":22449304,"Users Score":2,"Answer":"following line helped me.\n\nsudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pillow","Q_Score":2,"Tags":"python,macos,python-imaging-library","A_Id":22470752,"CreationDate":"2014-03-17T08:02:00.000","Title":"how to install PIL on Macosx 10.9?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm wondering how I can change the font of a Python Tkinter label widget so that half the displayed text is bold and half is not without having to use two labels. The text for the widget is assigned prior to the label actually being created and stored in a variable so I need some kind of flag presumably to tell it how much of the string should be bold. I don't it is possible but suggestions appreciated.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":9774,"Q_Id":22453554,"Users Score":3,"Answer":"There is nothing you can do with the label widget -- it only supports a single font and single color for the entire label. However, you can easily substitute a canvas or text widget anywhere you need this feature. There's no reason why you can't use a text widget that is one line tall and a dozen or so characters wide.","Q_Score":2,"Tags":"python,widget,tkinter,label,styling","A_Id":22455831,"CreationDate":"2014-03-17T11:51:00.000","Title":"How to change font style for part of a tkinter label","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing some Python scripts to read\/parse\/process some .vrscene files.\nFrom others' examples, I can see that there is a Python SDK for VRay called vrayutils.\nI want to get this information from the SettingsOutput object.\nFrom a .vrscene file I want to get the total frame numbers.\nDoes anyone know where I can get that Python library or how I can call it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1560,"Q_Id":22456509,"Users Score":1,"Answer":"I was able to do some of the things by parsing the file using basic Python and then extracting the things I needed.\nThe V-Ray API has a proprietary license, and there is no open source way to access the .vrscene \nI decided to try with a trial version of the SDK, and by using the SDK you will be able to find a nice Python build wrapped with a bunch of examples within the V-Ray Application SDK.\nThe price is 1250 euro annually for a single development license (for one server node). \nSupport is included.\nThey can give you a preliminary evaluation version for 3 months under NDA (What I used).\nNo reverse engineering is permitted so if you are planning to develop over V-Ray you should buy it.","Q_Score":0,"Tags":"python,sdk,render,maya,autodesk","A_Id":22980455,"CreationDate":"2014-03-17T14:07:00.000","Title":"Getting access to VRay Python SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have searched the forums for my question but im either searching for a thing naming it wrongly or the question is hard which i really doubt.\nI am developing a web-app which would have an web-interface written in one of the MVC frameworks like django or even flask and allow user to login, will identify users session and allow to make some settings and also my app needs to run some python process(script which basically is a separate file) on the server on a per-session per-settings made by user basis. This process is quite long - can take even days to perform and shouldn't affect the execution and performance of MVC part of an app. Another issue is that this process should be run per user so the basic usage model of such app would be:\n1. the user enters the site.\n2. the user makes some settings which are mirrored to database.\n3. the user pushes the launch button which executes some python script just for this user with the settings he has made.\n4. the user is able to monitor some parameters of the script running based on some messages that the script itself generates.\nI do understand that my question is related to the architecture of the app itself and i'm quite new to python and haven't had any experience of developing such complex application but I'm also quite eager to learn about it. I do understand the bricks from which my app should be built (like django or flask and the server-side script itself) but i know very little about how this elements should be glued together to create seamless environment. Please direct me to some articles related to this topic or recommend some similar threads or just give a clear high level explanation how such separate python processes could be triggered,run and monitored further on a per-user basis from controller part of MVC.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":183,"Q_Id":22495767,"Users Score":1,"Answer":"Celery is a great solution, but it can be overpowered for many setups. If you just need tasks to run periodically (once an hour, once a day, etc) then consider just using cron. \nThere's a lot less setup and it can get you quite far.","Q_Score":0,"Tags":"python,django,session,flask,server-side","A_Id":22520376,"CreationDate":"2014-03-19T03:42:00.000","Title":"Server side python code runing continuosly per session","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning python and came into a situation where I need to change the behvaviour of a function. I'm initially a java programmer so in the Java world a change in a function would let Eclipse shows that a lot of source files in Java has errors. That way I can know which files need to get modified. But how would one do such a thing in python considering there are no types?! I'm using TextMate2 for python coding.\nCurrently I'm doing the brute-force way. Opening every python script file and check where I'm using that function and then modify. But I'm sure this is not the way to deal with large projects!!!\nEdit: as an example I define a class called Graph in a python script file. Graph has two objects variables. I created many objects (each with different name!!!) of this class in many script files and then decided that I want to change the name of the object variables! Now I'm going through each file and reading my code again in order to change the names again :(. PLEASE help!\nExample: File A has objects x,y,z of class C. File B has objects xx,yy,zz of class C. Class C has two instance variables names that should be changed Foo to Poo and Foo1 to Poo1. Also consider many files like A and B. What would you do to solve this? Are you serisouly going to open each file and search for x,y,z,xx,yy,zz and then change the names individually?!!!","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":696,"Q_Id":22498877,"Users Score":0,"Answer":"One of the tradeoffs between statically and dynamically typed languages is that the latter require less scaffolding in the form of type declarations, but also provide less help with refactoring tools and compile-time error detection. Some Python IDEs do offer a certain level of type inference and help with refactoring, but even the best of them will not be able to match the tools developed for statically typed languages.\nDynamic language programmers typically ensure correctness while refactoring in one or more of the following ways:\n\nUse grep to look for function invocation sites, and fix them. (You would have to do that in languages like Java as well if you wanted to handle reflection.)\nStart the application and see what goes wrong.\nWrite unit tests, if you don't already have them, use a coverage tool to make sure that they cover your whole program, and run the test suite after each change to check that everything still works.","Q_Score":4,"Tags":"python,migration,dynamic-typing","A_Id":22498955,"CreationDate":"2014-03-19T07:18:00.000","Title":"Tracking changes in python source files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I started to use celery flower for tasks monitoring and it is working like a charm. I have one concern though, how can i \"reload\" info about monitored tasks after flower restart ?\nI use redis as a broker, and i need to have option to check on tasks even in case of unexpected restart of service (or server).\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1345,"Q_Id":22553659,"Users Score":2,"Answer":"I found i out. \nIt is the matter of setting the persistant flag in command running celery flower.","Q_Score":1,"Tags":"python,celery,celery-task,flower","A_Id":22554555,"CreationDate":"2014-03-21T08:26:00.000","Title":"Celery Flower - how can i load previous catched tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm evaluating Kivy for android development. I need to know if is it possible to create an application with multiple windows using Kivy. I dont know for sure how android works with this kind of approach.\nIn c#, windows forms, we have a main window and from that we open\/close another forms. How can I accomplish this approach using Kivy for android ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1083,"Q_Id":22563386,"Users Score":3,"Answer":"What do you mean by 'window'? In the practical sense, you can easily create different screens with kivy and switch between them, e.g. to have a menu screen, settings screen, game screen etc. Is this the kind of thing you mean? More generally, you can easily achieve any particular windowing behaviour you want within kivy.\nAndroid itself works with activities, a particular way of choosing what is displayed, how apps move between screens, and also how apps may call particular subsets of one another (plus a lot more of course). You don't need to know about this to use kivy, it works within a single activity (plus appropriate interaction with the rest of the system), but you should read up on it if you want to understand how android manages programs and how this is different to most desktop environments.","Q_Score":0,"Tags":"android,python,kivy","A_Id":22563987,"CreationDate":"2014-03-21T15:49:00.000","Title":"Kivy Multiple windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to call Python within an Oracle procedure? I've read plenty of literature about the reverse case (calling Oracle SQL from Python), but not the other way around.\nWhat I would like to do is to have Oracle produce a database table, then I would like to call Python and pass this database table to it in a DataFrame so that I could use Python to do something to it and produce results. I might need to call Python several times during the Oracle procedure. Does anyone know if this is possible and how could it be done?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12854,"Q_Id":22564503,"Users Score":0,"Answer":"kind of complicated but possible. I have seen it once. You need to \n\ncreate a javaclass inside oracle database. This class calls a .py file in the directory which contains it.\ncreate a procedure that calls the java class of item 1.\nin your sql query, call the procedure of item 2 whenever you need it.","Q_Score":18,"Tags":"python,sql,oracle,pandas,cx-oracle","A_Id":53431165,"CreationDate":"2014-03-21T16:40:00.000","Title":"Calling Python from Oracle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've recently started using openCV in python. I've come across various posts comparing cv and cv2 and with an overview saying how cv2 is based on numpy and makes use of an array (cvMat) as opposed  to cv makes use of old openCV bindings that was using Iplimage * (correct me if i'm wrong).\nHowever I would really like know how basic techniques (Iplimage* and cvMat) differ and why later is faster and better and how that being used in cv and cv2 respectively makes difference in terms of performance.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":230,"Q_Id":22590811,"Users Score":1,"Answer":"there is no question at all, - use cv2\nthe old cv api, that wraps IplImage and CvMat is being phased out, and will be no more available in the next release of opencv\nthe newer cv2 api uses numpy arrays for almost anything, so you can easily combine it with scipy, matplotlib, etc.","Q_Score":1,"Tags":"python,c++,opencv,numpy","A_Id":22591329,"CreationDate":"2014-03-23T12:18:00.000","Title":"Can anyone in detail explain how cv and cv2 are different and what makes cv2 better and faster than cv?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a stack based virtual machine in RPython using the PyPy toolchain to convert the RPython to C. So far I have 4 instructions.\n\nEOP - End of Program\nEOI - End of Instruction\nPUSH - Push item onto the stack\nPRINT - Print the top of the stack\n\nMy question is, how do you push a String to the top of the stack. Is it the same as when you push a number to the top of the stack or do I have to do something else when working with strings?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":393,"Q_Id":22591947,"Users Score":1,"Answer":"That depends. Do you want to push the string, or a pointer to a string? If it's the former, you have a problem, because the string will have variable length, unlike a pointer or a number. If it's the latter, you have to consider memory management aside from your stack.","Q_Score":0,"Tags":"c,stack,pypy,vm-implementation,rpython","A_Id":22592504,"CreationDate":"2014-03-23T14:08:00.000","Title":"Stack Machine with Strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been developing modules in OpenERP-7 using Python on Ubuntu-12.04. I want to give my users a feature by which they will have the ability to create what ever fields they want to . Like they will set the name, data_type etc for the field and then on click , this field will be created. I dont have any idea how this will be implemented. I have set up mind to create a button that will call a function and it will create a new field according to the details entered by the user . Is this approach of mine is right or not? And will this work . ? Please guide me so that I can work smartly.\nHopes for suggestion","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":22604620,"Users Score":0,"Answer":"The user can add fields, models, can customize the views etc from client side. These are in Settings\/Technical\/Database Structure, here you can find the menus Fields, Models etc where the user can add fields. And the views can be customized in Settings\/Technical\/User Interface.","Q_Score":0,"Tags":"python,openerp","A_Id":22627251,"CreationDate":"2014-03-24T08:46:00.000","Title":"How to code in openerp so that user can create his fields?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can i see in if a binary image is almost all black or all white in numpy or scikit-image modules ?\nI thought about numpy.all function or numpy.any but i do not know how neither for a total black image nor for a almost black image.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1554,"Q_Id":22619506,"Users Score":2,"Answer":"Here is a list of ideas I can think of:\n\nget the np.sum() and if it is lower than a threshold, then consider it almost black\ncalculate np.mean() and np.std() of the image, an almost black image is an image that has low mean and low variance","Q_Score":0,"Tags":"python,opencv,image-processing,numpy,scikit-image","A_Id":22619589,"CreationDate":"2014-03-24T20:04:00.000","Title":"How can i check in numpy if a binary image is almost all black?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can i see in if a binary image is almost all black or all white in numpy or scikit-image modules ?\nI thought about numpy.all function or numpy.any but i do not know how neither for a total black image nor for a almost black image.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1554,"Q_Id":22619506,"Users Score":2,"Answer":"Assuming that all the pixels really are ones or zeros, something like this might work (not at all tested):\n\ndef is_sorta_black(arr, threshold=0.8):\n    tot = np.float(np.sum(arr))\n    if tot\/arr.size  > (1-threshold):\n       print \"is not black\" \n       return False\n    else:\n       print \"is kinda black\"\n       return True","Q_Score":0,"Tags":"python,opencv,image-processing,numpy,scikit-image","A_Id":22619838,"CreationDate":"2014-03-24T20:04:00.000","Title":"How can i check in numpy if a binary image is almost all black?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I finally have some idea how to build Kivy app in Xcode with help of Kivy-ios. But Xcode and mac environment is new to me. My issue is: how to compile other python modules that required for my application. There is 'build-all.sh' in 'kivy-ios\/tools' that builds standard things, but how to add some other module. In particular, I need Requests module. Maybe there's some template script to include custom python modules? Thanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":462,"Q_Id":22621259,"Users Score":3,"Answer":"I don't know how kivy-ios manages different modules, but in the absence of anything else you can simply copy the requests module into your app dir so it's included along with everything else.","Q_Score":3,"Tags":"python,ios,xcode,python-requests,kivy","A_Id":22622162,"CreationDate":"2014-03-24T21:46:00.000","Title":"Compile custom module for Kivy-ios","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to set a custom background for selected items in wxPython 2.8. I cannot figure out how to do so. I've tried SetItemBackground with no luck.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":209,"Q_Id":22624070,"Users Score":0,"Answer":"Selected items in wxListCtrl, wxListBox and so on always use the system background selection colour, it can't be changed.","Q_Score":0,"Tags":"python,wxpython,wxwidgets","A_Id":22635854,"CreationDate":"2014-03-25T01:55:00.000","Title":"Setting selection background in ListCtrl","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not sure whether this is possible even theoretically; but if it is, I'd like to know how to do it in Python.\nI want to generate a big, random permutation cheaply. For example, say that I want a permutation on range(10**9). I want the permutation to be uniform (i.e. I want the numbers to be all over the place without  any seeming structure.) I want to have a function available to get the nth item in the permutation for each n, and I want to have another function available to get the index of every number in the permutation. \nAnd the big, final condition is this: I want to do all of that without having to store all the items of the permutation. (Which can be a huge amount of space.) I want each item to be accessible, but I don't want to store all the items, like range in Python 3.\nIs this possible?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":151,"Q_Id":22633008,"Users Score":1,"Answer":"I believe that a block cipher, like AES, provides exactly this functionality.","Q_Score":4,"Tags":"python,permutation,combinatorics","A_Id":22666834,"CreationDate":"2014-03-25T11:19:00.000","Title":"Python: Generating a big uniform permutation cheaply","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to launch a python program.exe to test it from another python code i,e launch it on the cmd (myprogram.exe -a arg1 -b arg2) and eventually get the error message it can print or any console output \ndoes anyone have an idea how to do this?\nthanks\nEDIT \nActually I launch it with os.popen(command) but what I want is to know if it ended with sys.exit or any exception or if it ended normally\nPS:I'm running python 2.6 (can't use subprocess.check_output ) \nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":22634264,"Users Score":0,"Answer":"You can run any python command from cmd using Python.exe -c \/\/code\nFor example, Python.exe -c print(10*10) will print 100 to your console. \nDoes this help? Your question is a little unclear, sorry.","Q_Score":0,"Tags":"python","A_Id":22634599,"CreationDate":"2014-03-25T12:13:00.000","Title":"launch a python program with it's arguments on cmd and get the output messages python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is it possible to switch between interfaces in Python program?\nI will have eth0 and wlan0 connection, both are different routers.\nI'm using boto to upload images to AWS server. And I need to upload using router with fast upload speed and for other downloads I need to use another interface which is connected to a router with fast download speed.\nIf this is possible how I can do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":409,"Q_Id":22636894,"Users Score":0,"Answer":"Its possible by using route add command in linux","Q_Score":1,"Tags":"python,router","A_Id":22789614,"CreationDate":"2014-03-25T14:01:00.000","Title":"Use different interfaces (eth0 and wlan0) for sending and receiving in Python program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok for my work we handle a lot of calculation documents. All of these have coversheets and revlogs that must be generated. We can easily create an excel file that has most of the information needed to fill in the forms but automating the actual process of filling in these forms that are premade in word has proven tricky. I used macros to some success but if something about a specific form differed to greatly the entire thing would mess up and I still had to open each word file individually and then hit the macro. \nSome of this process isn't going to be automatable as it requires pulling information from pdfs that isn't always in a standard format but any fast automation would be better than none. I have a good bit of c++ experience (by a good bit I just mean several courses on data structures etc, nothing way too high level). I have also used python some and stumbled my way through visual basic a tad.\nAny idea on how to go about automating generating sometimes 100+ of these forms?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":602,"Q_Id":22689597,"Users Score":0,"Answer":"MS-Word has extensive programming capabilities built in (\"Visual Basic for Applications (VBA)\" These exact same programming capabilities are available to applications you write in any language, including C++, that can access Word via COM. Depending on your needs, it could be possible to fill in an entire Word document from one click to run such a program.","Q_Score":0,"Tags":"python,c++,excel,automation,ms-word","A_Id":22691619,"CreationDate":"2014-03-27T13:47:00.000","Title":"What would be the best way to automate filling in a premade form in word","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a list of dates I'd like to cluster into 3 clusters.  Now, I can see hints that I should be looking at k-means, but all the examples I've found so far are related to coordinates, in other words, pairs of list items.\nI want to take this list of dates and append them to three separate lists indicating whether they were before, during or after a certain event.  I don't have the time for this event, but that's why I'm guessing it by breaking the date\/times into three groups.\nCan anyone please help with a simple example on how to use something like numpy or scipy to do this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":7440,"Q_Id":22702428,"Users Score":1,"Answer":"k-means is exclusively for coordinates. And more precisely: for continuous and linear values.\nThe reason is the mean functions. Many people overlook the role of the mean for k-means (despite it being in the name...)\nOn non-numerical data, how do you compute the mean?\nThere exist some variants for binary or categorial data. IIRC there is k-modes, for example, and there is k-medoids (PAM, partitioning around medoids).\nIt's unclear to me what you want to achieve overall... your data seems to be 1-dimensional, so you may want to look at the many questions here about 1-dimensional data (as the data can be sorted, it can be processed much more efficiently than multidimensional data).\nIn general, even if you projected your data into unix time (seconds since 1.1.1970), k-means will likely only return mediocre results for you. The reason is that it will try to make the three intervals have the same length.\nDo you have any reason to suspect that \"before\", \"during\" and \"after\" have the same duration? If not, don't use k-means.\nYou may however want to have a look at KDE; and plot the estimated density. Once you have understood the role of density for your task, you can start looking at appropriate algorithms (e.g. take the derivative of your density estimation, and look for the largest increase \/ decrease, or estimate an \"average\" level, and look for the longest above-average interval).","Q_Score":2,"Tags":"python-2.7,numpy,scipy,cluster-analysis","A_Id":22731897,"CreationDate":"2014-03-28T01:16:00.000","Title":"Clustering a list of dates","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the community module to extract communities from a networkx graph. For the community module, the order in which the nodes are processed makes a difference. I tried to set the seed of random to get consistent results but that is not working. Any idea on how to do this?\nthanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":22719863,"Users Score":0,"Answer":"I had to change the seed inside every class I used.","Q_Score":1,"Tags":"python,networkx","A_Id":24051792,"CreationDate":"2014-03-28T17:48:00.000","Title":"Fix the seed for the community module in Python that uses networkx module","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"anyone know how to hide python GUI Tkinter, \nI 've created keylogger, for GUI I used python module Tkinter , I want to add button called HIDE, so when user click it it will  hide GUI , and when user press key like CTRL+E , it should unhide GUI....?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11986,"Q_Id":22764927,"Users Score":0,"Answer":"To get rid of a GUI window I used the following in my code.\nwindow.destroy()\nand the following to bring it up again.\nnameoffunction()\nwindow.lift()","Q_Score":3,"Tags":"python,tkinter","A_Id":46719809,"CreationDate":"2014-03-31T14:55:00.000","Title":"How To Hide Tkinter python Gui","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am making a program that asks a user a lot of questions, and I have each question defined at the top of my file.  Unfortunately because of the ridiculous number of questions I need to have, the file has become extremely packed and difficult to navigate.  The questions are organized by different sections, so I thought it would be great if I could fold all of the variables by section and label them with a comment.\nI am using Pydev for Eclipse. I have done some searching but haven't found anything promising. Any suggestions for how to do this or how to better organize my variables?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":115,"Q_Id":22775423,"Users Score":1,"Answer":"\"Data driven programming\": store your questions in a data file, and your program just needs the required logic to load and present them.","Q_Score":0,"Tags":"python,python-2.7","A_Id":22775536,"CreationDate":"2014-04-01T01:54:00.000","Title":"How to manage many variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do i use python for a Spark program in eclipse?\nI've installed PyDev plugin in eclipse and installed Python on the system but how do i use PySpark.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6907,"Q_Id":22785010,"Users Score":6,"Answer":"I started a new Python project in PyDev, then went into Project -> Properties -> PyDev - PYTHONPATH -> External libraries. I added a \"source path\" entry for \n\n\/path\/to\/spark\/spark-0.9.1\/python\n\nThis allowed PyDev to see all Spark-related code and provide auto complete, etc.\nHope this helps.","Q_Score":1,"Tags":"python,apache-spark","A_Id":23485718,"CreationDate":"2014-04-01T11:49:00.000","Title":"Starting up PySpark for using python with Spark in eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a program in which I want to evaluate a piece of code asynchronously. I want it to be isolated from the main thread so that it can raise an error, enter an infinite loop, or just about anything else without disrupting the main program. I was hoping to use threading.Thread, but this has a major problem; I can't figure out how to stop it. I have tried Thread._stop(), but that frequently doesn't work. I end up with a thread that I can't control hogging both interpreter time and CPU power. The code in the thread doesn't open any files or do anything else that would cause problems if I hard-killed it. \nPython's multiprocessing.Process.terminate() does this really well; unfortunately, initiating a process on Windows takes nearly a second, which is long enough to cause annoying delays in my GUI.\nDoes anyone know either a: how to kill a Python thread (I don't think I care how dirty the exit is), or b: how to speed up starting a process?\nA third possibility would be a third-party library that provides an alternative method for asynchronous execution, but I've never heard of any such thing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":301,"Q_Id":22800258,"Users Score":0,"Answer":"In my case, the best way to do this seems to be to maintain a running worker process, and send the code to it on an as-needed basis. If the process acts up, I kill it and then start a new one immediately to avoid any delay the next time.","Q_Score":0,"Tags":"python,multithreading,python-3.x","A_Id":22852404,"CreationDate":"2014-04-02T02:12:00.000","Title":"Isolating code with a Python thread","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to take input from the webpage, parse the data submitted using python or tcl and start the script execution based on the inputs given. \nPlease suggest me a solution, how it can be done. \nI am not sure whether some web server need to be started for this.\nThanks in Advance. \nRegards,\nSurya","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":514,"Q_Id":22807281,"Users Score":0,"Answer":"Surya, \nyou should have a look at the ncgi and htmlparse packages in tcllib to extract the information you need. \nJoachim","Q_Score":0,"Tags":"python-2.7,tcl","A_Id":22811026,"CreationDate":"2014-04-02T09:35:00.000","Title":"Read input from the webpage, parse the data submitted using python or tcl and start the script execution based on the inputs given","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I work on a project to control my PC with a remote, and a infrared receptor on an Arduino.\nI need to simulate keyboard input with a process on linux who will listen arduino output and simulate keyboard input. I can dev it with Python or C++, but i think python is more easy.\nAfter many search, i found many result for... windows u_u\nAnyone have a library for this ?\nthanks\nEDIT: I found that \/dev\/input\/event3 is my keyboard. I think write in to simulate keyboard, i'm searching how do that","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2879,"Q_Id":22811844,"Users Score":1,"Answer":"The most generic solution is to use pseudo-terminals: you connect tttyn to the standard in and standard out of the program you want to monitor, and use pttyn to read and write to it.\nAlternatively, you can create two pipes, which you connect to the standard in and standard out of the program to be monitored before doing the exec.  This is much simpler, but the pipes look more like a file than a terminal to the program being monitored.","Q_Score":2,"Tags":"python,c++,linux,input,keyboard","A_Id":22812228,"CreationDate":"2014-04-02T12:41:00.000","Title":"Simulate keyboard input linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python script print strings. Now when run it in Jenkins I didn't see the printed strings in Jenkins Builds' Console Output. \nAnyway to achieve that?","AnswerCount":3,"Available Count":2,"Score":0.2605204458,"is_accepted":false,"ViewCount":15615,"Q_Id":22826006,"Users Score":4,"Answer":"Any output to stdout from a process spawned by Jenkins should be captured by Console Output. One caveat is that it won't be displayed until a newline character is printed, so make sure your lines are terminated.\nIf you are launching python in some weird way that dis-associates it from Jenkins parent process, then I can't help you.","Q_Score":11,"Tags":"python,jenkins","A_Id":22840336,"CreationDate":"2014-04-03T01:08:00.000","Title":"how to get python print result in jenkins console output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python script print strings. Now when run it in Jenkins I didn't see the printed strings in Jenkins Builds' Console Output. \nAnyway to achieve that?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":15615,"Q_Id":22826006,"Users Score":16,"Answer":"Try using -u (unbuffered) option when running the python script.\npython -u my_script.py","Q_Score":11,"Tags":"python,jenkins","A_Id":51525067,"CreationDate":"2014-04-03T01:08:00.000","Title":"how to get python print result in jenkins console output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using xlwt to create tables in excel. In excel there is a feature format as table which makes the table have an automatic filters for each column. Is there a way to do it using python?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10141,"Q_Id":22831520,"Users Score":8,"Answer":"OK, after searching the web, I realized that with xlwt it's not possible to do it, but with XlsxWriter it's possible and very easy and convenient.","Q_Score":9,"Tags":"python,excel,python-2.7,xlwt","A_Id":22837578,"CreationDate":"2014-04-03T08:10:00.000","Title":"how to do excel's 'format as table' in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a repeated question. how to prevent that someone stop an application with the task manager. \nI now that is posible, if you try to kill avastui.exe form the task manager the task manager say \"the operation could not be completed acces denied\" and it happens when de service of avast is on, when you stop the service of avast you can kill the process avastui.exe.\nSomeone have any idea how avast do it? how can i make it on c# or python?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1098,"Q_Id":22850591,"Users Score":2,"Answer":"I think it may be because things like anti-virus software are hooked into kernel-mode as drivers and can intercept user-mode input and intervene.  The anti-virus may be hooked into the kernel APIs for process management, and reject calls through the process APIs to kill a process with the same PID as itself.\nIf this is the case, then the answer would be that no you can't as I highly doubt that C# can be run in kernel-mode.","Q_Score":1,"Tags":"c#,python","A_Id":22850707,"CreationDate":"2014-04-03T23:05:00.000","Title":"How to prevent an app from being killed in windows task manager?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an app that shows products available in the US. If i want to change the country, I simply modify the value of a variable in my settings.py file.\nNow... each country I serve needs to have its own site, e.g. example.co.uk, example.ca, etc. They'll all be hosted on the same server and use the same database. The views, static files,etc. would be almost the same for each country.\nWhat's the best way of setting this up? Should I have one main app and then have per-country apps that extend the app?\n(Using Django 1.6.2\/Python 2.7)","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":22852845,"Users Score":2,"Answer":"I recently had something similar to do.\nI have for each domain a specific setting file with an unique SITE_ID and also a wsgi file per site. Then in my http.conf (I'm using apache on webfaction) i set up multiple VirtualHost instances, each pointing out to the specific wsgi file.\nMy configuration looks something like this:\n\nrandom_django_app\/\n\n__init__.py\nmodels.py\n...\n\nanother_app\/\n\n...\n\nsettings_app\/\n\nsettings\/\n\n__init__.py\nbase.py\nexample_co_uk.py\nexample_ca.py\n...\n\nwsgis\/\n\n__init__.py\nexample_co_uk.py\nexample_ca.py \n\n__init__.py\nurls.py","Q_Score":1,"Tags":"django,python-2.7","A_Id":22856740,"CreationDate":"2014-04-04T03:14:00.000","Title":"Multiple websites using the same app - how to set this up?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just about getting started on deploying my first live Django website, and I'm wondering how to set the Ubuntu server file permissions in the optimal way for security, whilst still granting the permissions required.\nFirstly a question of directories: I'm currently storing the site in ~\/www\/mysite.com\/{Django apps}, but have often seen people using \/var\/www\/... or \/srv\/www; is there any reason picking one of these directories is better than the other? or any reason why keeping the site in my home dir is a bad idea?\nSecondly, the permissions of the dir and files themselves. I'm serving using apache with mod_wsgi, and have the file WSGIScriptAlias \/ ~\/www\/mysite.com\/mainapp\/wsgi.py file. Apache runs as www-data user. For optimal security who should own the wsgi.py file, and what permissions should I grant it and its containing dir?\nSimilarly, for the www, www\/mysite.com, and www\/mysite.com\/someapp directories? What are the minimal permissions that are needed for the dirs and files?\nCurrently I am using 755 and 644 for dir and files respecitvely, which works well enough which allows the site to function, but I wonder if it is optimal\/too liberal. My Ubuntu user is the owner of most files, and www-data owns the sqlite dbs.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1003,"Q_Id":22872888,"Users Score":1,"Answer":"In regards to serving the application from your home directory, this is primarily preference based. However, deployment decisions may be made depending on the situation. For example, if you have multiple users making use of this server to host their website, then you would likely have the files served from their home directories. From a system administrator's perspective that is deploying the applications; you may want them all accessible from \/var\/www... so they are easier to locate. \nThe permissions you set for serving the files seem fine, however they may need to run as different users... depending on the number of people using this machine. For example, lets say you have one other application running on the server and that both applications run as www-data. If the www-data user has read permissions of Django's config file, then the other user could deploy a script that can read your database credentials.","Q_Score":4,"Tags":"python,django,apache,security,permissions","A_Id":24634526,"CreationDate":"2014-04-04T20:58:00.000","Title":"Security optimal file permissions django+apache+mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had trouble to run the pyDev Google App run on Eclipse. I can't create a new run configuration and I get this error message: Path for project must have only one segment.\nAny ideas about how to fix it? I am running Eclipse Kepler on Ubuntu 13.10","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1009,"Q_Id":22877052,"Users Score":8,"Answer":"This is clearly a bug, but there's a possible workaround: In a .py file in your project, right-click and go to \"Run As.\"  Then, select \"Python Run\" (not a custom configuration).  Let it run and crash or whatever this particular module does.  Now, go look at your run configurations - you'll see one for this run.  You can customize it as if you had made it anew.","Q_Score":4,"Tags":"eclipse,google-app-engine,python-2.7","A_Id":23118828,"CreationDate":"2014-04-05T05:40:00.000","Title":"pydev Google App run Path for project must have only one segment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm struggling with how I should interpret class inheritance. What does it actually do? As far as I know, it allows your class to:\n\nUse the inherited class function\/methods \nUse the inherited class local variables (self variables)\n\nDoes this go both ways? If something is inherited, will it be able to read his inheriter as well?\nPlease give your answer in as much layman's terms as possible. I'm not an native Englisch speaker and I've never had proper programming education. Give me an explenation, not a definiton :]","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":80,"Q_Id":22879518,"Users Score":2,"Answer":"Let's say you have a class called Animal. In this class you have a method called walk, that prints \"Animal is walking\"\nNow you have 2 other classes:\n1. Class Bird that is inherited from Animal. You can now add an additional method to it: fly. This will print that a bird can fly.\n2. Class Monkey that is inherited from Animal as well.  You can now add an additional method to it: climb. This will print that a monkey can climb trees.\nBoth Monkey and Bird derive from Animal, so they can walk, they have a same functionality\/feature. But both have a distinct feature as well: birds can fly and monkeys can climb trees. So it takes sense, right?\nThe reverse is false, because not every Animal can fly or can climb trees.\nEDIT: I exaplined it to you in terms of methods. But this can apply to variables as well. The Animal class can have a weight field. Which is accessible from both inherited classes: Monkey and Bird.\nBut Monkey can also have a field called max_power and Bird can have a class variable called max_fly_altitude. This fields are unique for these certain types of animal and NOT for the generic Animal. Which can also be a crocodile. And a crocodile can't fly to have a max_fly_altitude attribute.","Q_Score":2,"Tags":"python,class,inheritance","A_Id":22879590,"CreationDate":"2014-04-05T10:17:00.000","Title":"What does inheritance actually do in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to make a computer graphics project on \"Vote for better Nation\" using python in a week..I have a knowledge of pygame but don't know how to create a particular object(like small cartoon man)..And then how to make it move..So please help me if anyone knows how to make a moving object..\nSorry For The English\nThank You","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1621,"Q_Id":22884351,"Users Score":0,"Answer":"There is a series of books on Python Graphics called \"Python Graphics for Games\" (Amazon). It covers vector drawing and animation. Author Mike Ohlson de Fine.","Q_Score":0,"Tags":"python,python-2.7,graphics,pygame,turtle-graphics","A_Id":31048800,"CreationDate":"2014-04-05T17:37:00.000","Title":"Computer Graphics with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have y - a 100 row by 5 column Pandas DataFrame\nI have x - a 100 row by 5 column Pandas DataFrame\nFor i=0,...,4 I want to regress y[:,i] against x[:,i].\nI know how to do it using a loop.\nBut is there a way to vectorise the linear regression, so that I don't have the loop in there?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":472,"Q_Id":22897243,"Users Score":0,"Answer":"as far as I know, there is no way to put this all at once in the optimized Fortran library, LAPACK, since each regression is it's own independent optimization problem.\nnote that the loop over 4 items is not taking any time relative to the regression itself, that you need to fully compute because each regression is an isolated linear algebra problem... so I don't think there is much time to save here...","Q_Score":0,"Tags":"python,pandas,linear-regression","A_Id":22897471,"CreationDate":"2014-04-06T17:12:00.000","Title":"Perform n linear regressions, simultaneously","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a simple threaded python server, and I have two parameters for format, one is JSON (return string data) and the other is zip.  When a user selects the format=zip as one of the input parameters, I need the server to return a zip file back to the user.  How should I return a file to a user on a do_GET() for my server?  Do I just return the URL where the file can be downloaded or can I send the file back to the user directly?  If option two is possible, how do I do this?\nThank you","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":257,"Q_Id":22910772,"Users Score":0,"Answer":"The issue was that I hadn't closed the zipfile object before I tried to return it.  It appeared there was a lock on the file.\nTo return a zip file from a simple http python server using GET, you need to do the following:\n\nSet the header to 'application\/zip'\nself.send_header(\"Content-type:\", \"application\/zip\")\nCreate the zip file using zipfile module\nUsing the file path (ex: c:\/temp\/zipfile.zip) open the file using 'rb' method to read the binary information\nopenObj = open( < path > , 'rb')\nreturn the object back to the browser\nopenObj.close()\n del openObj\n self.wfile.write(openObj.read())\nThat's about it. Thank you all for your help.","Q_Score":0,"Tags":"python,json,rest,python-2.7,simplehttpserver","A_Id":22915936,"CreationDate":"2014-04-07T11:14:00.000","Title":"Issue with Python Server Returning File On GET","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm totally new to Python and I've been learning how to use Django and it's admin functionality to work with my models. My question really is how, if I were to install Django CMS, would work with the admin?\nMy understanding it limited so I wanted to check as I'm struggling to know if it will still show the model's that I've been making in the same \/admin\/ url (as i read you login to the cms part via the \/admin\/ url).\nWould installing the CMS overwrite anything current in my \/admin\/ view, or would the data management merely appear within the CMS control panel?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":34,"Q_Id":22913080,"Users Score":0,"Answer":"The Django CMS is a totally different environment. You can't install it on top of your current project. So if you want your models inside django cms you have to migrate them manually to the new enviroment. Maybe their are solutions for it but I'm not aware of them.","Q_Score":0,"Tags":"python,django","A_Id":22915407,"CreationDate":"2014-04-07T12:56:00.000","Title":"If I install Django CMS will it still show my current work in Django admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to find a way, using built-in functions, to list every way to organize N balls in M slots. The balls can stack in the slots. For example:\n\nN = 2, M = 3 -> {|0|1|1|, |1|0|1|, |1|1|0|, |2|0|0|, |0|2|0|, |0|0|2|}\n\nitertools.permutations() is part of the puzzle, but how can you go through all possible stacks of balls that preserves N?","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":1779,"Q_Id":22939260,"Users Score":1,"Answer":"To find all assignments of N balls to M slots:\n\nif N is 0 then\n\nleave all M slots empty\n\notherwise, if M is 1, then\n\nput all N balls to the only slot\n\notherwise\n\nFor each i in 0 .. N\n\nput i balls in M-th slot, and\nfind all assignments of remaining N-i balls to remaining M-1 slots","Q_Score":2,"Tags":"python,itertools","A_Id":22940159,"CreationDate":"2014-04-08T13:56:00.000","Title":"Every way to organize N objects in M list slots","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to send this string on Python SQS:\n\"Talh\u00e3o\", with no quotes.\nHow do I do that?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":22939822,"Users Score":0,"Answer":"install the newest version of boto (2.27 or more, lower versions have an issue with unicode strings)\nsend it as unicode, and you will succeed","Q_Score":0,"Tags":"python,amazon-web-services,boto,amazon-sqs","A_Id":23070269,"CreationDate":"2014-04-08T14:18:00.000","Title":"Amazon SQS Python\/boto: how do I send messages with accented characters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a file browser using Gtk.IconView in python. I am trying to find the path of an icon selected using \" selection-changed\" signal using gtk.IconView.get_path_at_pos(x,y).\nThe docs are mum on how to obtain the (x,y). How do I find them?\nusing python 2.7 and pygtk 2.24","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":22940269,"Users Score":1,"Answer":"You don't use get_path_at_pos. It is meant for cases where you handle the button presses directly (which you should avoid unless you really have good reasons to do so).\nSimply use gtk_icon_view_get_selected_items (C) or the pygtk equivalent iconview.get_selected_items() which gives you a list (in C a GList) of currently selected Gtk.TreePaths which is what you desire.","Q_Score":0,"Tags":"python,gtk","A_Id":22942890,"CreationDate":"2014-04-08T14:35:00.000","Title":"Finding Mouse click position in IconView in GTK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with numpy in python to calculate a vector multiplication.\nI have a vector x of dimensions n x 1 and I want to calculate x*x_transpose. \nThis gives me problems because x.T or x.transpose() doesn't affect a 1 dimensional vector (numpy represents vertical and horizontal vectors the same way). \nBut how do I calculate a (n x 1) x (1 x n) vector multiplication in numpy?\nnumpy.dot(x,x.T) gives a scalar, not a 2D matrix as I want.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":11187,"Q_Id":22949966,"Users Score":1,"Answer":"If you want an inner product then use numpy.dot(x,x) for outer product use numpy.outer(x,x)","Q_Score":13,"Tags":"python,numpy","A_Id":22949986,"CreationDate":"2014-04-08T23:11:00.000","Title":"dot product of two 1D vectors in numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to store user data for a website in Python I'm making. Which is more efficient: \n-Storing all the user data in one huge table\n-Storing all the user data in several tables, one per user, in one database. \n-Storing each user's data in a XML or JSON file, one file per user. Each file has a unique name based on the user id. \nAlso, which is safer? I'm biased towards storing user data in JSON files because that is something I already know how to do. \nAny advice? I'd post some code I already have, but this is more theoretical than code-based.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":242,"Q_Id":22951806,"Users Score":1,"Answer":"I don't think efficiency should be part of your calculus.\nI don't like either of your proposed designs.\nOne table?  That's not normalized.  I don't know what data you're talking about, but you should know about normalization.\nMultiple copies?  That's not scalable.  Every time you add a user you add a table?  Sounds like the perfect way to ensure that your user population will be small.\nIs all the data JSON?  Document based?  Maybe you should consider a NoSQL document based solution like MongoDB.","Q_Score":0,"Tags":"python,json,database,performance,security","A_Id":22951848,"CreationDate":"2014-04-09T02:39:00.000","Title":"Storing user data in one big database or in a different file for each user - which is more efficient?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have a sqlite3 db, which I access from Python (2.7), where I would like to store more than the by default allowed 2.000 columns. I understand that there is a setting or command, SQLITE_MAX_COLUMN, which I can alter, so that my database can store up to ~32.000 columns. My question is how do I in practice set the maximum number of columns to for example 30.000 - what is the specific code, that I should run? Hope my question is clearly stated. Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1019,"Q_Id":22964033,"Users Score":2,"Answer":"That's a compile-time parameter for SQLite itself.  As in, you'll need to recompile the SQLite library in order to change it.  Nothing you can do in Python will be able to overcome this.","Q_Score":1,"Tags":"python-2.7,sqlite,max","A_Id":22964138,"CreationDate":"2014-04-09T13:27:00.000","Title":"How to actually change the maximum number of columns in SQLITE","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to test out some periodic tasks I'm running in Celery, which are supposed to run at midnight of the first day of each month. To test these, I have a cron job running every few minutes which bumps the system time up to a few minutes before midnight on the last day of the month. When the clock strikes midnight (every few minutes), the tasks are not run. \nAll the times are UTC, and celery is set to UTC mode. \nCelery itself is working fine, I can run the tasks manually. What might be going on here? Also, how does celery keep track of the system time for its scheduling, how does it handle a system time update? Could it be that celery's time and the system time get out of sync somehow? \nThis is Celery 3.1.0 with redis as broker\/backend","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":283,"Q_Id":22969365,"Users Score":1,"Answer":"The solution for me was to restart redis after the time update, and also restart celerybeat. That combination seems to work.","Q_Score":1,"Tags":"python,celery","A_Id":23090632,"CreationDate":"2014-04-09T17:08:00.000","Title":"Celery periodic tasks: testing by modifying system time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My django project uses django-helpdesk app.\nThis app has Ticket model.\nMy app got a Client model, which should have one to many relationship with ticket- so I could for example list all tickets concerning specific client. \nNormally I would add models.ForeignKey(Client) to Ticket\nBut it's an external app and I don't want to modify it (future update problems etc.).\nI wold have no problem with ManyToMany or OneToOne but don't know how to do it with ManyToOne (many tickets from external app to one Client from my app)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":564,"Q_Id":22989689,"Users Score":1,"Answer":"There are (at least) two ways to accomplish it:\nMore elegant solution: Use a TicketProfile class which has a one-to-one relation to Ticket, and put the Client foreign key into it.\nHacky solution: Use a many-to-many relation, and manually edit the automatically created table and make ticket_id unique.","Q_Score":5,"Tags":"python,django,foreign-key-relationship","A_Id":22990016,"CreationDate":"2014-04-10T13:38:00.000","Title":"How to add many to one relationship with model from external application in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using emacs 24.3 and Ubuntu 12.04 LTS. How do I make emacs automatically indent lines in Python, like in IDLE? Currently, it does not do that.\nAlso, in general, how would I do this for any programming language, say, Java or c++?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4538,"Q_Id":22993206,"Users Score":0,"Answer":"Open a newline with C-j, you should get the indentation.","Q_Score":1,"Tags":"python,emacs","A_Id":22996440,"CreationDate":"2014-04-10T16:02:00.000","Title":"How to make emacs automatically indent Python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using emacs 24.3 and Ubuntu 12.04 LTS. How do I make emacs automatically indent lines in Python, like in IDLE? Currently, it does not do that.\nAlso, in general, how would I do this for any programming language, say, Java or c++?","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":4538,"Q_Id":22993206,"Users Score":3,"Answer":"Try electric-indent-mode.  It will be ebabled by default in Emacs-24.4.  But note that the version in 24.3 probably doesn't work too well in python-mode buffers.","Q_Score":1,"Tags":"python,emacs","A_Id":23000155,"CreationDate":"2014-04-10T16:02:00.000","Title":"How to make emacs automatically indent Python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two raster files which I have converted into NumPy arrays (arcpy.RasterToNumpyArray) to work with the values in the raster cells with Python.\nOne of the raster has two values True and False. The other raster has different values in the range between 0 to 1000. Both rasters have exactly the same extent, so both NumPy arrays are build up identically (columns and rows), except the values.\nMy aim is to identify all positions in NumPy array A which have the value True. These positions shall be used for getting the value at these positions from NumPy array B.\nDo you have any idea how I can implement this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":143,"Q_Id":22996507,"Users Score":4,"Answer":"If I understand your description right, you should just be able to do B[A].","Q_Score":2,"Tags":"python,arrays,numpy,arcgis,arcpy","A_Id":22996581,"CreationDate":"2014-04-10T18:48:00.000","Title":"How to search in one NumPy array for positions for getting at these position the value from a second NumPy array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Assuming that in each row of the array, all 1's come before the 0's, how would I be able to come up with an (O)nlogn algorithm to count the 1's in the array. I think first I would have to make a counter, search each row for 1's (n), and add that to the counter. Where does the \"log n part\" come into play? I read that a recursive algorithm to do this has nlogn complexity, but Im not too sure how I would do this. I know how to do this in O(n^2) with for loops. Pseudo code or hints would be helpful! Thank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":23001932,"Users Score":4,"Answer":"Since all 1's come before the 0's, you can find the index of the first 0 using Binary search algorithm (which is log N) and you just have to do this for all the N rows. So the total complexity is NlogN.","Q_Score":1,"Tags":"python,algorithm,count","A_Id":23001960,"CreationDate":"2014-04-11T01:26:00.000","Title":"Counting 1's in a n x n array of 0's and 1's","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've written a script that pulls data from my school's website and I'm having some trouble with execution time. \nThere are over 20 campuses, each with data for three semesters. The script looks up those school names, then the semesters available for each school, then the subjects\/departments that are offering classes each semester. Then the script  searches for the classes per department and then I do things with that data. \nI timed the execution of the script on just one campus, and it ran for over three minutes. When I ran it for all 24 campuses it took over an hour. I'm using the \"requests\" library, which runs each HTTP request in synchronously. I'm using the \"requests\" library, primarily because it handles sessions nicely.\nI'm looking for ways to bring down the time the script takes to run, by making the various requests for each semester run in parallel. I suspect that if I run three semesters asynchronously, then each school should take a minute, instead of three. Then, I can run all schools in parallel and achieve the same minute for all of the data. A minute is a lot less than an hour and a quarter!\n\nAm I wrong in my guess that multithreading\/processing will bring down the execution time so drastically? What Python libraries should I be using for threads or processes? \nOnce I've got each school being processed on a  thread, how do I consolidate the data from all the schools into one place? I know that it's considered poor practice for threads to alter global state, but what's the alternative here?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":23014432,"Users Score":0,"Answer":"In python you want multiprocessing over multithreading. Threads don't do well in Python beacause of the GIL.","Q_Score":0,"Tags":"python,multithreading,performance,multiprocessing","A_Id":23014920,"CreationDate":"2014-04-11T13:46:00.000","Title":"Performance Improvements with Processes or Threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know the httpserver module in tornado is implemented based on the tcpserver module, so I can  write a socket server based on tornado. But how can I write a server that is both a socket server and a web server?\nFor example, if I want to implement a chat app. A user can either login through a browser or a client program. The browser user can send msg to the client user through the back-end server. So the back-end server is a web and socket server.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1209,"Q_Id":23028941,"Users Score":3,"Answer":"You can start multiple servers that share an IOLoop within the same process. Your HTTPServer could listen on one port, and the TCPServer could listen on another.","Q_Score":2,"Tags":"python,sockets,web,tornado","A_Id":23031157,"CreationDate":"2014-04-12T10:07:00.000","Title":"How to use tornado as both a socket server and web server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to install pycrypto for python 3.x.x on raspberry pi\nbut when i run python setup.py install\nfrom the command line, it is by default installed to python 2.7.x\ni have installed python-dev and still with no luck, i have read that using a PIP might help, but unfortunately i don't know how to use it. all my codes are written for python 3.3.x  and it would take me a very long time to re-write them all for 2.7.\nso how can i fix it without re-writing my codes","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":419,"Q_Id":23031149,"Users Score":0,"Answer":"Having looked into it there does not seem to be a pycrypto version for python3 at the moment. I think you're options are to look for an alternative package or to convert your code to python 2. There are tools available which can do this automatically, for example 3to2 is available in pip.","Q_Score":0,"Tags":"python,python-3.x,raspbian,pycrypto","A_Id":23031224,"CreationDate":"2014-04-12T13:42:00.000","Title":"how to install python package in Raspbian?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install the leap motion sdk into Enthought Canapy. The page called Hello World on leap motion mentions i need to put these four files:\nSample.py, Leap.py, LeapPython.so and libLeap.dylib\ninto my \"current directory\". I don't know how to find my current directory. I have tried several things including typing into terminal \"python Sample.py\" which tells me:\n\/Users\/myname\/Library\/Enthought\/Canopy_64bit\/User\/Resources\/Python.app\/Contents\/MacOS\/Python: can't open file 'Sample.py': [Errno 2] No such file or directory\nI've tried to put the 4 files in the MacOS file, but it still gives me this error. Any suggestions would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":671,"Q_Id":23038209,"Users Score":0,"Answer":"Try this:\nPut the four files into one folder.\nRight click on the Sample.py until it says \"Open with\" and gives some choices.\nSelect Python Launcher.app (2.7.6) # This version of Python Launcher must match the Mac built in Python Version.\nIf your version of LeapPython.so is constructed correctly, it should run.","Q_Score":0,"Tags":"python,python-2.7,enthought,leap-motion","A_Id":24131195,"CreationDate":"2014-04-13T01:48:00.000","Title":"Installing Leap Motion sdk into Enthought SDK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have downloaded pymunk module on my computer. When I typed in \"python setup.py install\" in terminal, it says \"no such file or directory\", then I typed in the complete path of setup.py instead of setup.py, and it still could not run since the links to other files in the code of setup.py are not complete paths. (Like README.txt, terminal said \"no such file or directory\". Sorry I'm a python newbie. Someone tell me how can I fix it?\nThanks!!!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":118,"Q_Id":23070922,"Users Score":0,"Answer":"Try and go to the folder where setup.py is first and then do python setup.py install. As you have noticed, it assumes that you run it from the same folder as where its located.","Q_Score":1,"Tags":"python,chipmunk,pymunk","A_Id":23200199,"CreationDate":"2014-04-14T21:37:00.000","Title":"Compile pymunk on mac OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning python now using a mac which pre-installed python 2.7.5. But I have also installed the latest 3.4.\nI know how to choose which interpreter to use in command line mode, ie python vs python 3 will bring up the respective interpreter. \nBut if I just write a python script with this header in it \"#!\/usr\/bin\/python\" and make it executable, how can I force it to use 3.4 instead of 2.7.5?\nAs it stands, print sys.version says:\n2.7.5 (default, Aug 25 2013, 00:04:04) \n[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":28056,"Q_Id":23088338,"Users Score":3,"Answer":"You know, you can start python with py -specific version \nTo run a script on interpreter with a specific version you'll just start your script with following parameters, py yourscript.py -version","Q_Score":4,"Tags":"python","A_Id":51430363,"CreationDate":"2014-04-15T15:36:00.000","Title":"how to specify version of python to run a script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a program that breaks down files like HTML or CSS into chunks like that of a torrent. I am completely unsure how to do this. They need to be broken down, than later reassembled in order. anybody know how to do this?\nIt doesn't have to be in Python, that was just my starting point.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":350,"Q_Id":23096631,"Users Score":0,"Answer":"It's trivial to \"break down\" files as you put it. You'll need an algorithm to disassemble them, and then to reassemble them later, presumably by a browser since you mentioned HTML and CSS. Bittorrents implements this, and additionally the ability upload and download from a distributed \"swarm\" of peers also interested in the same data. Without reinventing the wheel by creating your own version of bittorrent, and again assuming you want to use this data in a browser, you'll want to create a torrent of all the HTML, CSS and other files relevant to your web application, and seed that using bittorrent. Next you'll want to create a bootstrap \"page\" that makes use of one of the several Javascript bittorrent clients now available to download the torrent, and then load the desired pages and resources when the client completes the download.","Q_Score":0,"Tags":"python,bittorrent","A_Id":25778457,"CreationDate":"2014-04-15T23:59:00.000","Title":"How do I break down files in a similar way to torrents?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I apologize in advance for this being a bit vague, but I'm trying to figure out what the best way is to write my program from a high-level perspective. Here's an overview of what I'm trying to accomplish:\n\nRasPi takes input from altitude sensor on serial port at 115000 baud.\nDoes some hex -> dec math and updates state variables (pitch, roll, heading, etc)\nUses pygame library to do some image manipulation based on the state variables on a simulated heads up display\nOutputs the image to a projector at 30 fps.\n\nNote that there's no user input (for now).\nThe issue I'm running into is the framerate. The framerate MUST be constant. I'd rather skip a data packet than drop a frame. \nThere's two ways I could see structuring this:\n\nWrite one function that, when called, grabs data from the serial bus and spits out the state variables as the output. Then write a pygame loop that calls this function from inside it. My concern with this is that if the serial port starts being read at the end of an attitude message, it'll have to pause and wait for the message to start again (fractions of a second, but could result in a dropped frame)\nWrite two separate modules, both to be running simultaneously. One continuously reads data from the serial port and updates the state variables as fast as possible. The other just does the image manipulation, and grabs the latest state variables when it needs them. However, I'm not actually sure how to write a multithreaded program like this, and I don't know how well the RasPi will handle such a program.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":23097604,"Users Score":0,"Answer":"I don't think that RasPi would work that well running multithreaded programs.  Try the first method, though it would be interesting to see the results of a multithreaded program.","Q_Score":0,"Tags":"python,multithreading,buffer,raspberry-pi","A_Id":23097644,"CreationDate":"2014-04-16T01:51:00.000","Title":"How to structure my Python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I upgraded from Ipython 1.2.1 to Ipython 2.0. When I try to open an existing notebook or create a new notebook in Firefox, I only get a blank screen. There is no error message in the terminal window that I used to start the notebook server. This happens on CentOs 6.5 with Python 2.7.5 and Firefox 24.4 as well as on Mac OS 10.8.5 with Python 2.7.6 and Firefox 28. Starting Firefox in safe-mode did not make any difference. If I use Safari instead of Firefox, the notebooks display as expected. Any ideas what could be wrong or how to debug this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":247,"Q_Id":23098583,"Users Score":0,"Answer":"I found that the problem occurs when changing the cookie preference \"Keep until:\" \" they expire\" to \"ask me every time\" (in Preferences->Privacy->History). As soon as I switch to \"they expire\" or \"I close Firefox\" and reload the page with my notebook, it renders as expected and the notebook is shown as running. Creating new notebooks works also correctly. \nThere is an issue open for this: github.com\/ipython\/ipython\/issues\/5703","Q_Score":0,"Tags":"firefox,ipython,ipython-notebook","A_Id":23773427,"CreationDate":"2014-04-16T03:42:00.000","Title":"Opening notebook with Ipython 2.0 in Firefox yields only a blank screen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm currently writing a Visual Studio extension, which provides scripting capabilities. I'm using IronPython (the newest one), but I have some problems with Python's standard libraries.\nAs I understand, all necessary files reside in the <IronPython folder>\\Lib folder. I cannot rely on my users installing IronPython, so I have to provide these files in other way.\nIf it is possible, I'd simply embed the whole Lib folder in my assembly and allow IronPython access to it from the code, but I'm not sure, if this is possible. I can try to add the Lib folder to extension's package and extract it to wherever Visual Studio will copy my extension's files, but I'm unsure, how to get access to them during extension's runtime. Also, I'd like to set appropriate paths transparently to the user and I'm also unsure, whether this can be done.\nHow can I solve this problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":23104754,"Users Score":1,"Answer":"I would presume that there is a way to include them in the VSIX file and also know where they are on disk - at least, you could use AppDomain.CurrentDomain.GetAssemblies() for find the IronPython assembly and Assembly.Location to find where it is, and hope the VSIX puts the Lib directory near that. (My only experience with VSIX was a while ago and I hated it, so I can't provide much advice in that department.)\nAssuming you're embedding IronPython, once you have the location you can just use ScriptEngine.SetSearchPaths to tell IronPython where the Lib directory is. If you're shelling out to ipy.exe then set the IRONPYTHONPATH environment variable before starting it.","Q_Score":0,"Tags":"c#,visual-studio-2013,ironpython,vsix","A_Id":23131781,"CreationDate":"2014-04-16T09:05:00.000","Title":"Embedding IronPython's stdlib in VS extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that the equation for a straight line is:\ny = (m * x) + c\nwhere m is the slope of the line which would be (ydelta\/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points.\nAny help is appreciated. Thanks in advance.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":928,"Q_Id":23110542,"Users Score":3,"Answer":"With just a single point (and nothing else) you cannot solve such a problem, there are infinitely many lines going through a single point.\nIf you know the angle to x axis then simply m=tan(angle) (you do not need any points to do that, point is only required to figure out c value, which should now be simple).\nTo convert angle from the y-axis to the x-axis simply compute pi\/2 - angle","Q_Score":0,"Tags":"python,math","A_Id":23110634,"CreationDate":"2014-04-16T13:13:00.000","Title":"How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that the equation for a straight line is:\ny = (m * x) + c\nwhere m is the slope of the line which would be (ydelta\/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points.\nAny help is appreciated. Thanks in advance.","AnswerCount":3,"Available Count":3,"Score":-0.0665680765,"is_accepted":false,"ViewCount":928,"Q_Id":23110542,"Users Score":-1,"Answer":"Okay, let's say your point is (x,y)=(1,2)\nThen you want to solve 2 = m + c. Obviously there is no way you can do this.","Q_Score":0,"Tags":"python,math","A_Id":23110747,"CreationDate":"2014-04-16T13:13:00.000","Title":"How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that the equation for a straight line is:\ny = (m * x) + c\nwhere m is the slope of the line which would be (ydelta\/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points.\nAny help is appreciated. Thanks in advance.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":928,"Q_Id":23110542,"Users Score":0,"Answer":"The equation of a line is y = mx + c.\nYou are given a point on this line, and the angle of this line from the y-axis.\nThe gradient m will be math.cot(angle_in_radians). The x and y values will be the same as your given point. To find c, simply evaluate y - mx.","Q_Score":0,"Tags":"python,math","A_Id":23111191,"CreationDate":"2014-04-16T13:13:00.000","Title":"How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using OpenSUSE 13.1 64-bit on an Lenovo ThinkPad Edge E145.\nI tryed to play a bit around with Python(2.7) and Python-OpenCV(2.4). Both is installed by using YAST.\nWhen i start the Python-Interactive-Mode (by typing \"python\") and try to \"import cv\" there are 2 things that happen:\ncase 1: \"import cv\" --> End's up with:\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\n  File \"\/usr\/lib64\/python2.7\/site-packages\/cv.py\", line 1, in <module>\n    from cv2.cv import *\nImportError: \/usr\/lib64\/python2.7\/site-packages\/cv2.so: undefined symbol: _ZN2cv23adaptiveBilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddNS_6Point_IiEEi\ncase 2: \"import cv2\" --> End's up with:\n\nMemoryAccessError\n\nand the interactive mode shutdown and i'm back at the normal commandline.\nHave anyone any idea how can i solve this problem?\nGreetings","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":892,"Q_Id":23117242,"Users Score":0,"Answer":"Not exactly a prompt answer (nor a direct one). I had the same issue and (re)installing various dependencies didn't help either.\nUltimately, I cloned (from git) and compiled opencv (which includes the cv2.so library) from scratch, replaced the old cv2.so library and got it to work.\nHere is the git repo: https:\/\/github.com\/Itseez\/opencv.git","Q_Score":0,"Tags":"python-2.7,opencv,opensuse,undefined-symbol","A_Id":25503548,"CreationDate":"2014-04-16T18:21:00.000","Title":"Python OpenCV \"ImportError: undefined Symbol\" or Memory Access Error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to access data from google-analytics. I am following the guide and is able to gauthorize my user and get the code from oauth. \nWhen I try to access data from GA I only get 403 Insufficient Permission back. Do I somehow have to connect my project in Google API console to my analytics project? How would I do this? Or is there some other reason why I get 403 Insufficient Permission back?\nI am doing this in Python with Django and I have Analytics API turned on i my API console!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5740,"Q_Id":23128964,"Users Score":0,"Answer":"You  should use View ID Not account ID, the 'View ID', you can go:\nAdmin -> Select Site -> Under \"View\" -> View Settings , if it doesn't works\nyou can go: Admin->Profiles->Profile Settings","Q_Score":3,"Tags":"python,django,python-2.7,google-analytics-api,http-status-code-403","A_Id":29837598,"CreationDate":"2014-04-17T09:07:00.000","Title":"Google Analytics reports API - Insufficient Permission 403","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to access data from google-analytics. I am following the guide and is able to gauthorize my user and get the code from oauth. \nWhen I try to access data from GA I only get 403 Insufficient Permission back. Do I somehow have to connect my project in Google API console to my analytics project? How would I do this? Or is there some other reason why I get 403 Insufficient Permission back?\nI am doing this in Python with Django and I have Analytics API turned on i my API console!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5740,"Q_Id":23128964,"Users Score":9,"Answer":"Had the same problem, but now is solved.\nUse View ID Not account ID, the 'View ID', can be found in the Admin->Profiles->Profile Settings tab\nUPDATE\nnow, if you have more a account , you must go:   Admin -> Select account -> under View-> click on View Settings","Q_Score":3,"Tags":"python,django,python-2.7,google-analytics-api,http-status-code-403","A_Id":24274077,"CreationDate":"2014-04-17T09:07:00.000","Title":"Google Analytics reports API - Insufficient Permission 403","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I ve recently started with python and am working on building a Family tree using python. My idea is that the tree should grow in both sides, i.e) both the older generations as well as younger generations can be added to the same tree. \nI tried implementing with Binary tree ADT and N-ary tree ADT, but that doesn't work well. Can anyone suggest me an ADT that is best for building that family tree, and guide me how to implement that?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5025,"Q_Id":23147008,"Users Score":0,"Answer":"After searching a lot, I found that the Graph ADT suits the above problem better. Since a family has relations over a wide span in all directions, using a graph ADT would be conventional.          \n\nEach node can store details about a person.  \nNode can consist of parent node links, and some functionalities\nto find relation between two nodes etc..\nTo find relationships, assume the parent nodes as the    Parents, and\nthe parent of the parent nodes as grandparents etc..\nTraverse to the parent node, find if there is any other child nodes, \nmark them as siblings etc..\n\nThe idea is this, I think it will help to solve this problem!","Q_Score":1,"Tags":"python,tree,family-tree","A_Id":34161376,"CreationDate":"2014-04-18T03:41:00.000","Title":"Creating Family Trees Using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to implement a secure google cloud endpoint in python for multi-clients (js \/ ios \/ android)\nI want my users to be able to log by three ways loginForm \/ Google \/ Facebook.\nI read a lot of docummentation about that but I didn't realy understood how I have to handle connection flow and session (or something else) to keep my users logged.\nI'm also looking for a way to debug my endpoint by displaying objects like Request for exemple.\nIf someone know a good tutorial talking about that, it will be verry helpfull.\nthank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":23154120,"Users Score":0,"Answer":"For request details, add 'HttpServletRequest' (java) to your API function parameter.\nFor Google authentication, add 'User' (java) to your API function parameter and integrate with Google login on client.\nFor twitter integration, use Google app-engine OpenID.\nFor facebook\/loginForm, its all on you to develop a custom auth.","Q_Score":1,"Tags":"python,facebook,google-app-engine,authentication,google-cloud-endpoints","A_Id":23223929,"CreationDate":"2014-04-18T12:26:00.000","Title":"google endpoint custom auth python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that basically runs forever and checks a webpage every second and notifies me if any value changes. I placed it on an AWS EC2 instance and ran it through ssh. The script was running fine when I checked after half an hour or so after I started it. \nThe problem is that after a few hours when I checked again, the ssh had closed. When I logged back in, there was no program running. I checked all running processes and nothing was running. \nCan anyone teach me how to make it run forever (or until I stop it) on AWS EC2 instances? Thanks a lot. \n\nEdit: I used the Java SSH Client provided by AWS to run the script","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8060,"Q_Id":23166158,"Users Score":17,"Answer":"You can run the program using the nohup command, so that even when the SSH session closes your program continues running.\nEg: nohup python yourscriptname.py &\nFor more info you can check the man page for it using\nman nohup.","Q_Score":13,"Tags":"python,amazon-web-services,ssh,amazon-ec2","A_Id":23166196,"CreationDate":"2014-04-19T05:16:00.000","Title":"Make python script to run forever on Amazon EC2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Python 2.7.5 running on OS X 10.9.2. \nI downloaded the Python installer \"python-3.4.0-macosx10.6.dmg\" from python.org. \nAfter the installation, I still get 2.7.5 when querying python -V.\nI am not sure what I need to do to replace 2.7.5 with 3.4 besides installing python-3.4.0-macosx10.6.dmg.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":23166386,"Users Score":0,"Answer":"I simply replaced the executable link in my IDE from \"\/usr\/bin\/python\" to \"\/Library\/Frameworks\/Python.framework\/Versions\/3.4\/bin\".","Q_Score":1,"Tags":"python","A_Id":23376739,"CreationDate":"2014-04-19T05:45:00.000","Title":"Replacing Python 2.7.5 with Python 3.4 on OS X 10.9.2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use one of the random graph-generators of NetworkX (version 1.8.1):\nrandom_powerlaw_tree(n, gamma=3, seed=None, tries=100)\nHowever, I always get this error\nFile \"\/Library\/Python\/2.7\/site-packages\/networkx\/generators\/random_graphs.py\", line 840, in random_powerlaw_tree\n\"Exceeded max (%d) attempts for a valid tree sequence.\"%tries)\nnetworkx.exception.NetworkXError: Exceeded max (100) attempts for a valid tree sequence.\nfor any n > 10, that is starting with\nG = nx.random_powerlaw_tree(11)\nI would like to generate trees with hundreds of nodes. Does anyone know how to correctly set these parameters in order to make it run correctly?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":451,"Q_Id":23173427,"Users Score":1,"Answer":"To generate trees with more nodes it is only needed to increase the \"number of tries\" (parameter of random_powerlaw_tree). 100 tries is not enough even to have a tree with 11 nodes (it gives an error). For example, with 1000 tries I manage to generate trees with 100 nodes, using networkX 1.8.1 and python 3.4.0","Q_Score":1,"Tags":"python,networkx","A_Id":23183710,"CreationDate":"2014-04-19T17:49:00.000","Title":"Parameters to let random_powerlaw_tree() generate trees with more than 10 nodes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am new to GAE, web dev and python, but am working my way up.\nI have been trying to get xhtml2pdf working on GAE for some time now but have had no luck.  I have downloaded  various packages but keep getting errors of missing modules. These errors vary depending on what versions of these packages and dependencies I use. I have even tried using the xhtml2pdf \"required dependency\" versions.\nI know xhtml2pdf used to be hosted on GAE according to a stackoverflow post from 2010, but I don't know if this is the case anymore. Have they replaced it with something else that the GAE team think is better?\nI have also considered that the app.yaml is preventing my app from running. As soon as I try importing the pisca module, my app stops.\nCould anyone please give me some direction on how to get this working? In the sense of how to install these packages with dependencies and where they should be placed in my project folder (note that I am using Windows). And what settings I would need to add to my app.yaml file.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":23184702,"Users Score":0,"Answer":"I got it now!  Don't use XHTML2PDF - use ReportLab on its own instead.","Q_Score":0,"Tags":"python,google-app-engine,app.yaml,xhtml2pdf","A_Id":23335617,"CreationDate":"2014-04-20T16:17:00.000","Title":"How do I get xhtml2pdf working on GAE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to pass a variable in one python cgi script to other cgi script? how can i do this as in php. using url or something...?\ni saved variable in text file, thus read and get saved variable when other page load  \nIs this method good?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":241,"Q_Id":23190913,"Users Score":0,"Answer":"Traditionally this is done using cookies or hidden form fields.","Q_Score":0,"Tags":"python,variables,cgi,text-files","A_Id":23190978,"CreationDate":"2014-04-21T04:42:00.000","Title":"How to pass variable in one .py cgi to other python cgi script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python 2.7 + bottle on cygwin and I wanted to access a sample webpage from chrome.\nI am unable to access the website running on http:\/\/localhost:8080\/hello but when I do a curl within cygwin I am able to access it.\nError Message when accessing through Chrome\nConnection refused\nDescription: Connection refused\nPlease let me know how I can access my local bottle website running inside Cygwin from windows  browser.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1043,"Q_Id":23191241,"Users Score":1,"Answer":"Since you get a connection refused error, the best I can think of is that this is a browser issue. Try editing the LAN settings on your Chrome browser to bypass proxy server for local address.","Q_Score":1,"Tags":"python,cygwin,bottle","A_Id":23191551,"CreationDate":"2014-04-21T05:16:00.000","Title":"Accessing localhost from windows browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I searched around and couldn't really find any information on this. Basically i have a database \"A\" and a database \"B\". What i want to do is create a python script (that will likely run as a cron job) that will collect data from database \"A\" via sql, perform an action on it, and then input that data into database \"B\".\nI have written it using functions something along the lines of:\n\nFunction 1 gets the date the script was last run\nFunction 2 Gets the data from Database \"A\" based on function 1\nFunction 3-5 Perform the needed actions\nFunction 6 Inserts data into Database \"B\"\n\nMy question is, it was mentioned to me that i should use a Class to do this rather than just functions. The only problem is, I am honestly a bit hazy on Classes and when to use them.\nWould a Class be better for this? Or is writing this out as functions that feed into each other better? If i would use a Class, could you tell me how it would look?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":156,"Q_Id":23237444,"Users Score":4,"Answer":"Would a Class be better for this?\n\nProbably not.\nClasses are useful when you have multiple, stateful instances that have shared methods.  Nothing in your problem description matches those criteria.\nThere's nothing wrong with having a script with a handful of functions to perform simple data transfers (extract, transform, store).","Q_Score":3,"Tags":"python,mysql,database,class,oop","A_Id":23237519,"CreationDate":"2014-04-23T07:17:00.000","Title":"Collecting Data from Database, functions vs classes","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have opened a FITS file in pyfits. The HEADER file reads XTENSION='BINTABLE' with DIMENSION= 52989R x 36C with 36 column tags like, 'ZBEST', 'ZQUALITY', 'M_B', 'UB', 'PGAL' etc.\nNow, I have to choose objects from the data with 'ZQUALITY' greater than 2 & 'PGAL' equals to 3. Then I have to make a histogram for the 'ZBEST' of the corresponding objects obeying the above conditions. Also I have to plot 'M_B' vs 'UB' for those objects. \nAt last I want to slice the 'ZBEST' into three slices (zbest < 0.5), (0.5 < zbest < 1.0), (zbest > 1.0) and want to plot histogram and 'M_B' vs 'UB' diagram of them separately. \nI am stuck at choosing the data obeying the two conditions. Can anyone please tell me how can I choose the objects from the data satisfying both the conditions ('ZQUALITY' > 2 & 'PGAL' == 3 )? I am using like: data.field[('zquality' > 2) & ('pgal'==3)] but it's not working.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":229,"Q_Id":23246013,"Users Score":1,"Answer":"The expression data.field[('zquality' > 2) & ('pgal'==3)] is asking for fields where the string 'zquality' is greater than 2 (always true) and where the string 'pgal' is equal to 3 (also always false).\nActually chances are you're getting an exception because data.field is a method on the Numpy recarray objects that PyFITS returns tables in.\nYou want something like data[(data['zquality'] > 2) & (data['pgal'] == 3)].\nThis expression means \"give me the rows of the 'zquality' column of data containing values greater than 2.  Then give me the rows of the 'pgal' column of data with values equal to three.  Now give me the full rows of data selected from the logical 'and' of the two row masks.","Q_Score":0,"Tags":"python,numpy,fits,pyfits","A_Id":23254015,"CreationDate":"2014-04-23T13:34:00.000","Title":"Condtionally selecting values from a Numpy array returned from PyFITS","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So my question today is about the translation process of Java. I understand the general translation process itself but I am not too sure how it applies to Java. \nWhere does the lexical analysis take place? When is symbol table created? When is the syntax analysis and how is the syntax tree created?\nFrom what I have already research and able to understand is that the Java source code is then translated into a independent byte-code through a JVM or Java Virtual Machine. Is this when it undergoes a lexical analysis?\nI also know that after it is translated into byte-code it is translated into machine code but I don't know how it progress after that.\nLast but not least, is the Translation process of Java and different from C++ or Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":954,"Q_Id":23258176,"Users Score":0,"Answer":"All of the translation process is done when you compile a Java program. This is no different than compiling a C++ program or any other compiled language. The biggest difference is that this translation is targeted to the Java Byte Code language rather than assembly or machine language. The Byte Code undergoes its own translation process (including many of the same stages) when the program is run.","Q_Score":4,"Tags":"java,python,c++,compilation,translation","A_Id":23258361,"CreationDate":"2014-04-24T01:28:00.000","Title":"What is the Translastion Process of Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I logon to my company's computer with the AD username\/password, I find that my Outlook will launch successfully. That means the AD authentication has passed.\nIn my opinion, outlook retrieves the AD user information, then sends it to an LDAP server to verify.\nBut I don't know how it retrieves the information, or by some other methods?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":104,"Q_Id":23262767,"Users Score":0,"Answer":"You are right, there is an ongoing communication between your workstation and the Active Directory server, which can use LDAP protocol.\nSince I don't know what you tried so far, I suggest that you look into the python module python-ldap. I have used it in the past to connect, query and modify information on Active-Directory servers.","Q_Score":0,"Tags":"python,ldap","A_Id":23263099,"CreationDate":"2014-04-24T07:41:00.000","Title":"How does auto-login Outlook successfully when in AD environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have made a database file using SQL commands in python. i have used quite a lot of foreign keys as well but i am not sure how to display this data onto qt with python? any ideas? i would also like the user to be able to add\/edit\/delete data","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4532,"Q_Id":23268179,"Users Score":1,"Answer":"This question is a bit broad, but I'll try answering it anyway. Qt does come with some models that can be connected to a database. Specifically classes like QSqlTableModel. If you connect such a model to your database and set it as the model for a QTableView it should give you most of the behavior you want.\nUnfortunately I don't think I can be any more specific than that. Once you have written some code, feel free to ask a new question about a specific issue (remember to include example code!)","Q_Score":1,"Tags":"python,sql,qt,pyqt","A_Id":23281662,"CreationDate":"2014-04-24T11:55:00.000","Title":"How to display data from a database file onto pyqt so that the user can add\/delete\/edit the data?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a project on Python using Django. The project is doing lot of work in the background so i want to notify users what's going on now in the system. For this i have declared a p tag in HTML and i want to send data to it. \nI know i can do this by templates but i am little confused as 5 functions need to pass the status to the p tag and if i use render_to_response() it refreshes the page every time a status is passed from the function \nAnyone please tell me how to do this in the correct way","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":23288911,"Users Score":1,"Answer":"Part of your page that contains the paragraph tags is a piece of JavaScript that contains a timer.\nEvery once in a while it does an Ajax request to get the data with regard to \"what's going on now in the system\".\nIf you use the Ajax facilites of JQuery, which is probably the easiest, you can pass a JavaScript callback function that will be called if the request is answered. This callback function receives the data served by Django as response to the asynchroneous request. In the body of this callback you put the code to fill your paragraph.\nDjango doesn't have to \"know\" about Ajax, it just serves the required info from a different URL than your original page containing the paragraph tags. That URL is part the your Ajax request from the client.\nSo it's the client that takes the initiative. Ain't no such thing as server push (fortunately).","Q_Score":0,"Tags":"python,html,django","A_Id":23297917,"CreationDate":"2014-04-25T09:14:00.000","Title":"Pass Data From Python To Html  Tag","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to write my own proxy extensions. Both, burp suite as well as mitmproxy allows us to write extensions. \nTill now, I am successful with intercepting the request and response headers, and write it to my own output file.\nThe problem is, I get frequent requests and responses at anonymous time and at the same time, the output is getting written in the file. \nHow should I identify that which response belongs to which particular request ?? \nIf we see in burp suite, when we click on particulat URL in target, we see two different tabs- \"Request\" and \"Response\". How is burp suite identifying this ? \nSimilar is the case with mitmproxy. \nI am new to proxy extensions, so any help would be great. \n----EDIT----\nIf any additional information is required then pls let me know.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":175,"Q_Id":23306361,"Users Score":1,"Answer":"In mitmproxy 0.10, a flow object is passed to the response handler function. You can access both flow.request and flow.response.","Q_Score":0,"Tags":"python,proxy","A_Id":23442148,"CreationDate":"2014-04-26T03:40:00.000","Title":"how to identify http response belongs to which particular request through python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a python 'sensor'. The sensor spawns two children, one that reads in data and the other processes and outputs the data in db format. I need to run it in the background with the ability to start, stop pretty much as a service\/daemon. I've looked at various options: daemonizing, init scripts etc. The problem is I need more than just start, stop, restart and status. I also want to add a 'pause' option'. I am thinking that an init script would be the best option adding start, stop, restart, status, pause cases but how would I implement this the pause functionality?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":23311233,"Users Score":1,"Answer":"The communication with daemons is usually done by signals. You can use userdefined signals or SIGSTOP(17) and SIGCONT(19) to pause and continue your daemon.","Q_Score":0,"Tags":"python,service","A_Id":23311785,"CreationDate":"2014-04-26T13:00:00.000","Title":"Python pseudo service","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know , how an ECMP and hash mapping are used in load balancing or routing of a tcp packet .Any help with links,examples or papers would be really useful. Sorry for the inconvinience , as I am completely new to this type of scenario. \nThanks for your time and consideration.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":460,"Q_Id":23319138,"Users Score":0,"Answer":"Typical algorithms split the traffic into semi-even groups of N pkts, where N is the number of ECMP links.  So if the pkt sizes differ, or if some \"streams\" have more pkts than others, the overall traffic rates will not be even.  Some algorithms factor for this.  Breaking up or moving strean is bad (for many reasons).  ECMP can be tiered --at layers1,2,3, and above; or at different physical pts.  Typically, the src & dst ip-addr & protocol\/port are used to define each stream.  Sometimes it is configurable.  Publishing the details can create \"DoS\/\"IP\"(Intellectual Property) vulnerabilities.  Using the same algorithm at different \"tiers\" with certain numbers of links at each tier can lead to \"polarization\" (some links getting no traffic).  To address this, a configurable or random input can be added to the algorithm.  BGP ECMP requires IGP cost to be the same, else routing loops can happen(link\/info @ cisco).  Multicast adds more issues(link\/info @ cisco).  There are 3 basic types (link\/info @ cisco).  This is a deep subject.","Q_Score":0,"Tags":"python,hash,routing","A_Id":69093482,"CreationDate":"2014-04-27T03:43:00.000","Title":"Hash Mapping and ECMP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a set of {(v_i, c_i), i=1,..., n}, where v_i in R and c_i in {-1, 0, 1} are the discrimination value  and  label of the i-th training example. \nI would like to learn a threshold t so that the training error is the minimum when I declare the i-th example has label -1 if v_i < t, 0 if v_i=t, and 1 if v_i>t.\nHow can I learn the threshold t from {(v_i, c_i), i=1,..., n}, and what is an efficient algorithm for that? \nI am implementing that in Python, although I also hope to know how to implement that in  R efficiently.\nThanks!\nBtw, why SO doesn't support LaTeX for math expressions? (I changed them to be code instead).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":72,"Q_Id":23326430,"Users Score":1,"Answer":"Sort the points, group them by value, and try all <=2n+1 thresholds that classify differently (<=n+1 gaps between distinct data values including the sentinels +-infinity and <=n distinct data values). The latter step is linear-time if you try thresholds lesser to greater and keep track of how many points are misclassified in each way.","Q_Score":0,"Tags":"python,r,algorithm","A_Id":23326609,"CreationDate":"2014-04-27T17:13:00.000","Title":"learn a threshold from labels and discrimination values?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a web page with a form each time a form is submitted same page loads but with different data relevant to the query. On the back-end i am using python for finding data relevant to query.\nI want to process all this with ajax as back-end process needs more time so i need to show status to the user i -e whats going on now in the system\nAlso the data returned is the same html file but with some other data. so how can i display it on the current page. It should not be appended to current html file. it is standalone\nAnyone please give me a solution to this problem","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":540,"Q_Id":23327609,"Users Score":1,"Answer":"You can use jQuery, which gives you a very simple way to do that:\n$.post( \"yourpage.html\", $('form').serialize() + \"&ajax=true\", function(response) {\n    $('#results').html(response);\n});\nServer side, detect if ajax is true and then return only the query results instead of the whole page. They will be saved in the element of id=\"results\". Replacing the whole page is generally not a good idea.","Q_Score":0,"Tags":"javascript,jquery,python,ajax","A_Id":23328225,"CreationDate":"2014-04-27T18:58:00.000","Title":"Refresh same page with ajax with different data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hello I'm trying to run twisted along with python but python cannot find twisted. \nI did run $pip install twisted successfully but it is still not available.\nImportError: No module named twisted.internet.protocol\nIt seems that most people have $which python  at \/usr\/local\/bin\/python \nbut I get \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python \nMay this be the issue? If so, how can I change the PATH env?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35517,"Q_Id":23329034,"Users Score":0,"Answer":"I too was getting a ImportError: No module named xxxeven though I did a pip install xxx and pip2 install xxx.\npip2.7 install xxx worked for me. This installed it in the python 2.7 directory.","Q_Score":10,"Tags":"python,macos,python-2.7,twisted","A_Id":40758241,"CreationDate":"2014-04-27T21:10:00.000","Title":"Python OSX $ which Python gives \/Library\/Frameworks\/Python.framework\/Versions\/2.7\/bin\/python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program that imports a .py file that contains lists and dictionaries and uses them in the program. I am making another program that's purpose is to change the lists and dictionaries in this database .py file (either adding or removing parts of the lists\/dictionaries). How would I go about doing this? Do i need to read in the .py file line by line, modify the lists, and overwrite the document? Is there a better way?\nAny ideas would be much appreciated. If overwriting the file is the best plan, how do you do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3423,"Q_Id":23366047,"Users Score":0,"Answer":"You can use SQLite or Pickle module instead, to allow easier data retrieval\/manipulation from multiple programs\/scripts.","Q_Score":2,"Tags":"python,read-write","A_Id":23366357,"CreationDate":"2014-04-29T13:27:00.000","Title":"Modifying a .py file within Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some C# code that needs to call a Python script several thousand times, each time passing a string, and then expecting a float back. The python script can be run using ANY version of Python, so I cannot use Iron python. It's been recommended that I use IPC named pipes. I have no experience with this, and am having trouble figuring out how to do this between C# and Python. Is this a simple process, or am I looking at a decent amount of work? Is this the best way to solve my problem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9440,"Q_Id":23374854,"Users Score":0,"Answer":"Based on the what you have said, you can connect to the python process and catch standard output text. Easy, fast and reliable!","Q_Score":5,"Tags":"c#,python,ipc","A_Id":62980335,"CreationDate":"2014-04-29T20:42:00.000","Title":"Simplest way to communicate between Python and C# using IPC?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to use the data collected by a form I to a sqlite query. In this form I've made a spin button which gets any numeric input (ie. either2,34 or 2.34) and sends it in the form of 2,34 which python sees as str.\nI've already tried to float() the value but it doesn't work. It seems to be a locale problem but somehow locale.setlocale(locale.LC_ALL, '') is unsupported (says WinXP).\nAll these happen even though I haven't set anything to greek (language, locale, etc) but somehow Windows does its magic.\nCan someone help?\nPS: Of course my script starts with # -*- coding: utf-8 -*- so as to have anything in greek (even comments) in the code.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":23388647,"Users Score":1,"Answer":"AFAIK, WinXP supports setlocale just fine.\nIf you want to do locale-aware conversions, try using locale.atof('2,34') instead of float('2,34').","Q_Score":0,"Tags":"python,sqlite,pygtk","A_Id":23389055,"CreationDate":"2014-04-30T12:53:00.000","Title":"pygtk spinbutton \"greek\" floating point","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My problem is as follows:\nI am given a number of chi-squared values for the same collection of data sets, fitted with different models. (so, for example, for 5 collections of points, fitted with either a single binomial distribution, or both binomial and normal distributions, I would have 10 chi-squared values).\nI would like to use machine learning categorization to categorize the data sets into \"models\":\ne.g. data sets (1,2,5 and 7) are best fitted using only binomial distributions, whereas sets (3,4,6,8,9,10) - using normal distribution as well. \nNotably, the number of degrees of freedom is likely to be different for both chi-squared distributions and is always known, as is the number of models.\nMy (probably) naive guess for a solution would be as follows:\n\nRandomly distribute the points (10 chi-squared values in this case) into the number of categories (2).\nFit each of the categories using the particular chi-squared distributions (in this case with different numbers of degrees of freedom) \nMove outlying points from one distribution to the next.\nRepeat steps 2 and 3 until happy with result.\n\nHowever I don't know how I would select the outlying points, or, for that matter, if there already is an algorithm that does it.\nI am extremely new to machine learning and fairly new to statistics, so any relevant keywords would be appreciated too.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":23393456,"Users Score":0,"Answer":"The principled way to do this is to assign probabilities to different model types and to different parameters within a model type. Look for \"Bayesian model estimation\".","Q_Score":0,"Tags":"python,machine-learning,statistics,categorization","A_Id":23421883,"CreationDate":"2014-04-30T16:31:00.000","Title":"Categorizing points using known distributions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using NLTK to extract named entities and I'm wondering how it would be possible to determine the sentiment between entities in the same sentence. So for example for \"Jon loves Paris.\" i would get two entities Jon and Paris. How would I be able to determine the sentiment between these two entities? In this case should be something like Jon -> Paris = positive","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":301,"Q_Id":23396807,"Users Score":1,"Answer":"In short \"you cannot\". This task is far beyond simple text processing which is provided with NLTK. Such objects relations sentiment analysis could be the topic of the research paper, not something solvable with a simple approach. One possible method would be to perform a grammar analysis, extraction of the conceptual relation between objects and then independent sentiment analysis of words included, but as I said before - it is rather a reasearch topic.","Q_Score":0,"Tags":"python,nlp,nltk","A_Id":23396854,"CreationDate":"2014-04-30T19:47:00.000","Title":"How to determine the \"sentiment\" between two named entities with Python\/NLTK?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been using ipython notebook with console2 for a while now and recently installed a different version of python and now my console is giving me an error saying \"No module named IPython\". I think the path has been changed or something, but I don't know how to fix it. Any help is greatly appreciated!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1050,"Q_Id":23399888,"Users Score":1,"Answer":"I am pulling the answer out of the comments.\nPoint your PATH system variable to the correct version of Python. This is accomplished (on Windows) by going to System Properties -> Advanced -> Environment Variables. If you already have a Python directory in there, modify it to the correct, new path. Otherwise, append it to the end of the existing string. Do not remove what is already present.","Q_Score":0,"Tags":"python,path,console,ipython","A_Id":23588025,"CreationDate":"2014-04-30T23:38:00.000","Title":"ipython console2 no module named Ipython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to develop a small project to learn how mezzanine and cartridge work.\nI have the problem that items in the shop are listed only if I am logged in, while I'd like to be able to show them to unauthorized users.\nIs there a setting that has to be toggled?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":23426916,"Users Score":1,"Answer":"The products most likely aren't published, but can be previewed by an authenticated administrator.\nCheck the \"status\" and \"published from\" fields for each product.","Q_Score":0,"Tags":"python,django,mezzanine,cartridge","A_Id":23427146,"CreationDate":"2014-05-02T11:20:00.000","Title":"Products are not shown if the user is not logged in","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was learning python use sublime text2 dev.\nwhen I code \"hello world\" and build it, the \"cmd\"window appears and disappears in a moment.\nI want to make the output hold on,but I don't know how.\nhelp me, thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":23440391,"Users Score":0,"Answer":"Just add raw_input(\"Press ENTER to exit\") and it will \"pause\" until you press a key. You should be able to add this line anywhere and as often as needed.","Q_Score":0,"Tags":"python,sublimetext2","A_Id":23440406,"CreationDate":"2014-05-03T04:49:00.000","Title":"how to prevent the window from self-close when building program in sublime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a web-app using Python Flask framework on Raspberry Pi running Raspbian. I want to control the hardware and trigger some sudo tasks on the Pi through web.\nThe Flask based server runs in non-sudo mode listening to port 8080. When a web client sends request through HTTP, I want to start a subprocess with sudo privileges. (for ex. trigger changes on gpio pins, turn on camera etc.). What is the best practice for implementing this kind of behavior?\nThe webserver can ask for sudo password to the client, which can be used to raise the privileges. I want some pointers on how to achieve this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":166,"Q_Id":23454521,"Users Score":0,"Answer":"Best practice is to never do this kind of thing. If you are giving sudo access to your pi from internet and then executing user input you are giving everyone in the internet the possibility of executing arbitrary commands in your system. I understand that this is probably your pet project, but still imagine someone getting access to your computer and turning camera when you don't really expect it.","Q_Score":0,"Tags":"python,linux,web,flask,raspberry-pi","A_Id":23454864,"CreationDate":"2014-05-04T09:16:00.000","Title":"How to start a privileged process through web on the server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Our Django project provides interfaces to users to create repository\n\ncreate new repo\nadd new changes to existing repo\n\nAny user can access any repo to make changes directly via an HTTP POST containing changes.\nIts totally fine if the traffic is less. But if the traffic increases up to the point that multiple users want to add changes to same repo at exactly same time, how to handle it?\nWe currently use Hg (Mercurial) for repos","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":23468132,"Users Score":0,"Answer":"This is something you should fix at the web application level, not at the Mercurial level.  If you're fine with having people wait you set up a distributed locking scheme where the web worker thread tries to acquire a repository-specific lock from shared memory\/storage before taking any actions.  If it can't acquire the lock you respond with either a status-code 503 with a retry-after header or you have the web-worker thread retry until it can get the lock or times out.","Q_Score":0,"Tags":"python,django,mercurial","A_Id":23479318,"CreationDate":"2014-05-05T08:33:00.000","Title":"Django: Atomic operations on a directory in media storage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded and unzip the cabot(python tool) in my linux system.But then I don't know how to install it.In the cabot folder there is setup.sh file. But when I put build or install it is not working.So What to do?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1740,"Q_Id":23513981,"Users Score":0,"Answer":".sh is a shell script, you can just execute it.\n.\/setup.sh","Q_Score":0,"Tags":"python,github","A_Id":23514046,"CreationDate":"2014-05-07T09:31:00.000","Title":"How to install cabot in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded and unzip the cabot(python tool) in my linux system.But then I don't know how to install it.In the cabot folder there is setup.sh file. But when I put build or install it is not working.So What to do?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1740,"Q_Id":23513981,"Users Score":0,"Answer":"It's an \".sh\" file right?\nThen to run the same what you have to do is :-\n1)Open Terminal\n2)Change directory to file location\n3) run the following command.\n        sh setup.sh","Q_Score":0,"Tags":"python,github","A_Id":23514107,"CreationDate":"2014-05-07T09:31:00.000","Title":"How to install cabot in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two questions about using crontab file:\n1.I am using a service. When it runs, a new log file created everyday in a log directory. i want to delete all files that already exist greater 5 day in that log directory\n2.I want to delete all the infomation that exist greater than 5 days in a log file( \/var\/log\/syslog)\nI don't know how to do that with crontab in linux. Please help me! Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":374,"Q_Id":23515224,"Users Score":1,"Answer":"If you are using logrotate for log rotation then it has options to remove old files, if not you could run something as simple as this once a day in your cron:\n\n\nfind \/path\/to\/log\/folder -mtime +5 -type f -exec rm {} \\;\n\nOr more specific match a pattern in the filename\n\nfind . -mtime +5 -type f -name *.log  -exec ls -l {} \\;\n\n\nWhy not set up logrotate for syslog to rotate daily then use its options to remove anything older than 5 days.\nOther options involve parsing log file and keeping certain aspect etc removing other bits etc which involved writing to another file and back etc and when it comes to live log files this can end up causing other issues such as a requirement to restart service to relog back into files. so best option would be logrotate for the syslog","Q_Score":0,"Tags":"python,linux","A_Id":23515529,"CreationDate":"2014-05-07T10:26:00.000","Title":"How to delete some file with crontab in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make my spider start every three hours.\nI have a scrapy confinguration file located in c:\/scrapyd folder.\nI changed the poll_interval to 100\nthe spider works, but it didn't repeat each 100 seconds.\nhow to do that please?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":215,"Q_Id":23526579,"Users Score":1,"Answer":"Maybe you should do a cron job that executes every three hours and performs a curl call to Scrapyd to schedule the job.","Q_Score":0,"Tags":"python,scrapy,scrapyd","A_Id":24659705,"CreationDate":"2014-05-07T19:25:00.000","Title":"scrapyd pool_intervel to scheduler a spider","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running into a few issues on my Emacs + Org mode + Python setup. I thought I'd put this out there to see if the community had any suggestions.\nVirtualenv:\nI'm trying to execute a python script within a SRC block using a virtual environment instead of my system's python implementation. I have a number of libraries in this virtual environment that I don't have on my system's python (e.g. Matplotlib). Now, I set python-shell-virtualenv-path to my virtualenv's root directory. When I run M-x run-python the shell runs from my virtual environment. That is, I can import Matplotlib with no problems. But when I import Matplotlib within a SRC block I get an import error. \n\nHow can I have it so the SRC block uses the python in my virtual\nenvironment and not my system's python? \nIs there any way I can set\n    the path to a given virtual environment automatically when I load an\n    org file?\n\nHTML5 Export:\nI'm trying to export my org-files in 'html5', as opposed to the default 'xhtml-strict'. The manual says to set org-html-html5-fancy to t. I tried searching for org-html-html5-fancy in M-x org-customize but I couldn't find it. I tried adding (setq org-html-html5-fancy t) to my init.el, but nothing happened. I'm not at all proficient in emacs-lisp so my syntax may be wrong. The manual also says I can set html5-fancy in an options line. I'm not really sure how to do this. I tried #+OPTIONS html5-fancy: t but it didn't do anything.\n\nHow can I export to 'html5' instead of 'xhtml-strict' in org version\n7.9.3f and Emacs version 24.3.1?\nIs there any way I can view and customize the back-end that parses\nthe org file to produce the html?\n\nI appreciate any help you can offer.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":510,"Q_Id":23531555,"Users Score":0,"Answer":"Reads like a bug, please consider reporting it at emacs-orgmode@gnu.org\nAs a workaround try setting the virtualenv at the Python-side, i.e. give PYTHONPATH as argument.\nAlternatively, mark the source-block as region and execute it the common way, surpassing org","Q_Score":1,"Tags":"python,emacs,virtualenv,org-mode","A_Id":23557258,"CreationDate":"2014-05-08T02:09:00.000","Title":"Run python from virtualenv in org file & HTML5 export in org v.7.9.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Currently we have everything setup on single cloud server, that includes:\n\nDatabase server\nApache\nCelery\nredis to serve as a broker for celery and for some other tasks\netc\n\nNow we are thinking to break apart the main components to separate servers e.g. separate database server, separate storage for media files, web servers behind load balancers. The reason is to not to pay for one heavy server and use load balancers to create servers on demand to reduce cost and improve overall speed.\nI am really confused about celery only, have anyone ever used celery on multiple production servers behind load balancers? Any guidance would be appreciated.\nConsider one small use case which is currently how it is been done on single server (confusion is that how that can be done when we use multiple servers):\n\nUser uploads a abc.pptx file->reference is stored in database->stored on server disk\nA task (convert document to pdf) is created and goes in redis (broker) queue\ncelery which is running on same server picks the task from queue\n\nRead the file, convert it to pdf using software called docsplit\ncreate a folder on server disk (which will be used as static content later on) puts pdf file and its thumbnail and plain text and the original file\n\n\nConsidering the above use case, how can you setup up multiple web servers which can perform the same functionality?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":2804,"Q_Id":23551808,"Users Score":3,"Answer":"Celery actually makes this pretty simple, since you're already putting the tasks on a queue. All that changes with more workers is that each worker takes whatever's next on the queue - so multiple workers can process at once, each on their own machine.\nThere's three parts to this, and you've already got one of them.\n\nShared storage, so that all machines can access the same files \nA broker that can hand out tasks to multiple workers - redis is fine for that \nWorkers on multiple machines\n\nHere's how you set it up:\n\nUser uploads file to front-end server, which stores in your shared storage (e.g. S3, Samba, NFS, whatever), and stores the reference in the database\nFront-end server kicks off a celery task to process the file e.g.\n\ndef my_view(request):\n    # ... deal with storing the file\n    file_in_db = store_file(request)\n    my_process_file_task.delay(file_in_db.id)  # Use PK of DB record\n    # do rest of view logic...\n\n\nOn each processing machine, run celery-worker:\npython manage.py celery worker --loglevel=INFO -Q default -E\n\nThen as you add more machines, you'll have more workers and the work will be split between them.\nKey things to ensure:\n\nYou must have shared storage, or this gets much more complicated\nEvery worker machine must have the right Django\/Celery settings to be able to find the redis broker and the shared storage (e.g. S3 bucket, keys etc)","Q_Score":1,"Tags":"python,django,architecture,celery","A_Id":23846005,"CreationDate":"2014-05-08T20:24:00.000","Title":"django-celery infrastructure over multiple servers, broker is redis","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently we have everything setup on single cloud server, that includes:\n\nDatabase server\nApache\nCelery\nredis to serve as a broker for celery and for some other tasks\netc\n\nNow we are thinking to break apart the main components to separate servers e.g. separate database server, separate storage for media files, web servers behind load balancers. The reason is to not to pay for one heavy server and use load balancers to create servers on demand to reduce cost and improve overall speed.\nI am really confused about celery only, have anyone ever used celery on multiple production servers behind load balancers? Any guidance would be appreciated.\nConsider one small use case which is currently how it is been done on single server (confusion is that how that can be done when we use multiple servers):\n\nUser uploads a abc.pptx file->reference is stored in database->stored on server disk\nA task (convert document to pdf) is created and goes in redis (broker) queue\ncelery which is running on same server picks the task from queue\n\nRead the file, convert it to pdf using software called docsplit\ncreate a folder on server disk (which will be used as static content later on) puts pdf file and its thumbnail and plain text and the original file\n\n\nConsidering the above use case, how can you setup up multiple web servers which can perform the same functionality?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":2804,"Q_Id":23551808,"Users Score":4,"Answer":"What will strongly simplify your processing is some shared storage, accessible from all cooperating servers. With such design, you may distribute the work among more servers without worrying on which server will be next processing step done.\nUsing AWS S3 (or similar) cloud storage\nIf you can use some cloud storage, like AWS S3, use that.\nIn case you have your servers running at AWS too, you do not pay for traffic within the same region, and transfers are quite fast.\nMain advantage is, your data are available from all the servers under the same bucket\/key name, so you do not have to bother about who is processing which file, as all have shared storage on S3.\nnote: If you need to get rid of old files, you may even set up some policy file on give bucket, e.g. to delete files older than 1 day or 1 week.\nUsing other types of shared storage\nThere are more options\n\nSamba\ncentral file server\nFTP\nGoogle storage (very similar to AWS S3)\nSwift (from OpenStack)\netc.\n\nFor small files you could even use Redis, but such solutions are for good reasons rather rare.","Q_Score":1,"Tags":"python,django,architecture,celery","A_Id":23552055,"CreationDate":"2014-05-08T20:24:00.000","Title":"django-celery infrastructure over multiple servers, broker is redis","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a multi-threaded (via pyqt) application which plots realtime data (data is processed in the second thread and passed to the gui thread to plot via a pyqt-signal). If I place the mouse over the application it continues to run at full speed (as measured by the time difference between calls to app.processEvents()). As soon as I begin moving the mouse, the update rate slows to a crawl, increasing again when I stop moving the mouse. \nDoes anyone know how I can resolve this\/debug the issue?  \nThe code is quite lengthy and complex so I'd rather not post it here. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":742,"Q_Id":23567726,"Users Score":2,"Answer":"It's likely you have items in the scene that accept their own mouse input, but it's difficult to say without seeing code. In particular, be wary of complex plot lines that are made clickable--it is very expensive to compute the intersection of the mouse cursor with such complex shapes. \nThe best (some would say only) way to solve performance issues is to profile your application: run python -m cProfile -s cumulative your_script.py once without moving the mouse, and again with mouse movement (be sure to spend plenty of time moving the mouse), and then compare the outputs to see where the interpreter is spending all of its time.","Q_Score":0,"Tags":"python,qt,pyqt,pyqtgraph","A_Id":23572444,"CreationDate":"2014-05-09T14:53:00.000","Title":"PYQTGraph application slows down when mouse moves over application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Programming noob here. I'm on Mac OS 10.5.8. I have Python 2.7.6 and have installed NLTK. If I run Python from Terminal, I can \"import nltk\" with no problem. But if I open IDLE (either from Terminal or by double-clicking on the application) and try the same thing there, I get an error message, \"ImportError: No module named nltk\". I assume this is a path problem, but what exactly should I do?\nThe directory where I installed NLTK is \"My Documents\/Python\/nltk-2.0.4\". But within this there are  various other directories called  build, dist, etc. Which of these is the exact directory that IDLE needs to be able to find? And how do I add that directory to IDLE's path?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2634,"Q_Id":23572471,"Users Score":1,"Answer":"Supplementing the answer above, when you install python packages they will install under the default version of python you are using. Since the module imports in python 2.7.6 make sure that you aren't using the Python 3 version of IDLE.","Q_Score":1,"Tags":"python,nltk,python-idle","A_Id":23572642,"CreationDate":"2014-05-09T19:27:00.000","Title":"How do I get IDLE to find NLTK?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I upgraded to IPython 2.0 today.\nAlot of changes seem good, but the button to insert a new cell, above\/below seems to be gone.\nThe option is still in the menu, and I believe the keyboard short cut works.\nBut the button is gone.\nI'm sure there is a way to turn it back on, but the documentation for the new version doesn't seem super complete.\nPossibly to turn it back on I need to adjust something in the config.\nWhich is just python script.\nMaybe even tell it to insert a new element, and bind some javascript to it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":23577208,"Users Score":0,"Answer":"as now in 5.7.4 version shortcut to create cell above is esc + a","Q_Score":1,"Tags":"javascript,ipython,ipython-notebook","A_Id":61441244,"CreationDate":"2014-05-10T04:49:00.000","Title":"IPython 2.0 Notebook: where has the \"Add Cell Above\" button gone, and how do I get it back?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just starting to build a web app with web2py for the first time.  It's great how well PyCharm integrates with web2py.\nOne thing I'd like to do, however, is avoid the web2py ticketing system and just allow exceptions to be caught in the normal way in PyCharm.  Currently, any attempt to catch exceptions, even via an \"All Exceptions\" breakpoint, never results in anything getting caught by Pycharm.\nCan someone tell me if this is possible, and if so, how to do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":23583017,"Users Score":0,"Answer":"I figured this out by looking through the web2py source code.  Apparently, web2py is set up to do what I want to do for a particular debugger, seemingly called Wing Db.  There's a constant env var ref in the code named WINGDB_ACTIVE that, if set, redirects exceptions to an external debugger.\nAll I had do to was define this env var, WINGDB_ACTIVE, as 1 in my PyCharm execution configuration, and voila, exceptions are now passed through to my debugger!","Q_Score":0,"Tags":"python,debugging,exception,web2py,pycharm","A_Id":23634516,"CreationDate":"2014-05-10T15:40:00.000","Title":"Can web2py be made to allow exceptions to be caught in my PyCharm debugger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am building a quiz application which pulls questions randomly from a pool of questions.  However, there is a requirement that the pool of questions be limited to questions that the user has not already seen.  If, however, the user has seen all the questions, then the algorithm should \"reset\" and only show questions the user has seen once.  That is, always show the user questions that they have never seen or, if they have seen all of them, always show them questions they have seen less frequently before showing questions they have seen more frequently.\nThe list (L) is created in a such a way that the following is true: any value in the list (I), may exist once or be repeated in the list multiple times.  Let's define another value in the list, J, such that it's not the same value as I.  Then 0 <= abs(frequency(I) - frequency(J)) <= 1 will always be true.\nTo put it another way: if a value is repeated in the list 5 times, and 5 times is the maximum number of times any value has been repeated in the list, then all values in the list will be repeated either 4 or 5 times.  The algorithm should return all values in the list with frequency == 4 before it returns any with frequency == 5.\nSorry this is so verbose, I'm struggling to define this problem succinctly.  Please feel free to leave comments with questions and I will further qualify if needed.\nThanks in advance for any help you can provide.\nClarification\nThank you for the proposed answers so far.  I don't think any of them are there yet.  Let me further explain.\nI'm not interacting with the user and asking them questions.  I'm assigning the question ids to an exam record so that when the user begins an exam, the list of questions they have access to is determined.  Therefore, I have two data structures to work with:\n\nList of possible question ids that the user has access to\nList of all question ids this user has ever been assigned previously.  This is the list L described above.\n\nSo, unless I am mistaken, the algorithm\/solution to this problem will need to involve list &\/or set based operations using the two lists described above.\nThe result will be a list of question ids I can associate with the exam record and then insert into the database.","AnswerCount":5,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":314,"Q_Id":23587568,"Users Score":5,"Answer":"Why not have two lists, one for questions not yet picked and one for questions that have been picked. Initially, the not-yet-picked list will be full, and you will pick elements from it which will be removed and added to the picked list. Once the not-yet-picked list is empty, repeat the same process as above, this time using the full picked list as the not-yet-picked list and vice versa.","Q_Score":4,"Tags":"python,algorithm,list,frequency","A_Id":23587628,"CreationDate":"2014-05-10T23:57:00.000","Title":"Efficient algorithm for determining values not as frequent in a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a quiz application which pulls questions randomly from a pool of questions.  However, there is a requirement that the pool of questions be limited to questions that the user has not already seen.  If, however, the user has seen all the questions, then the algorithm should \"reset\" and only show questions the user has seen once.  That is, always show the user questions that they have never seen or, if they have seen all of them, always show them questions they have seen less frequently before showing questions they have seen more frequently.\nThe list (L) is created in a such a way that the following is true: any value in the list (I), may exist once or be repeated in the list multiple times.  Let's define another value in the list, J, such that it's not the same value as I.  Then 0 <= abs(frequency(I) - frequency(J)) <= 1 will always be true.\nTo put it another way: if a value is repeated in the list 5 times, and 5 times is the maximum number of times any value has been repeated in the list, then all values in the list will be repeated either 4 or 5 times.  The algorithm should return all values in the list with frequency == 4 before it returns any with frequency == 5.\nSorry this is so verbose, I'm struggling to define this problem succinctly.  Please feel free to leave comments with questions and I will further qualify if needed.\nThanks in advance for any help you can provide.\nClarification\nThank you for the proposed answers so far.  I don't think any of them are there yet.  Let me further explain.\nI'm not interacting with the user and asking them questions.  I'm assigning the question ids to an exam record so that when the user begins an exam, the list of questions they have access to is determined.  Therefore, I have two data structures to work with:\n\nList of possible question ids that the user has access to\nList of all question ids this user has ever been assigned previously.  This is the list L described above.\n\nSo, unless I am mistaken, the algorithm\/solution to this problem will need to involve list &\/or set based operations using the two lists described above.\nThe result will be a list of question ids I can associate with the exam record and then insert into the database.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":314,"Q_Id":23587568,"Users Score":0,"Answer":"Let's define a \"pivot\" that separates a list into two sections. The pivot partitions the array such that all numbers before the pivot has been picked one more than the numbers after the pivot (or more generally, all numbers before pivot are ineligible for picking, while all numbers after the pivot are eligible for picking). \nYou simply need to pick a random item from the list of numbers after the pivot, swap it with the number on the pivot, and then increment the pivot. When the pivot reaches the end of the list, you can reset it back to the start. \nAlternatively, you can also use two lists, which is much easier to implement, but is slightly less efficient as it needs to expand\/shrink the list. Most of the time, the ease of implementation would trump the inefficiency so the two-list would usually be my first choice.","Q_Score":4,"Tags":"python,algorithm,list,frequency","A_Id":23587653,"CreationDate":"2014-05-10T23:57:00.000","Title":"Efficient algorithm for determining values not as frequent in a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two versions of Python installed in my computer, Python 3.4 and Python 2.7, and I use both of these installations. When I run a script, how do I choose which versions I want to use? May I rename the names of the executables for that (Python.exe -> Python27.exe)?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":327,"Q_Id":23595346,"Users Score":1,"Answer":"Both python 2.7 and python 3 coexist on one machine happily.\nIf you name the scripts .py for those you would like to run with python 2.3 and .py3 for those that you would like to run with python3 then you can just invoke the scripts by typing their names or by double clicking.  These associations are set up by default by the installer.\nYou can force the python version on the command line, assuming both are on the path by typing python or python3 for any script file regardless of the extension.\nIt is also worth looking at virtualenv for your testing.\nN.B. For installing from pypi you can use pip or pip3 and the install for the appropriate version will be done.","Q_Score":0,"Tags":"python","A_Id":23595617,"CreationDate":"2014-05-11T16:53:00.000","Title":"Multiple Python versions in one computer (windows 7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We are developing a Python server on Google App Engine that should be capable of handling incoming HTTP POST requests (around 1,000 to 3,000 per minute in total). Each of the requests will trigger some datastore writing operations. In addition we will write a web-client as a human-usable interface for displaying and analyse stored data.\nFirst we are trying to estimate usage for GAE to have at least an approximation about the costs we would have to cover in future based on the number of requests. As for datastore write operations and data storage size it is fairly easy to come up with an approximate number, though it is not so obvious for the frontend and backend instance hours. \nAs far as I understood each time a request is coming in, an instance is being started which then is running for 15 minutes. If a request is coming in within these 15 minutes, the same instance would have been used. And now it is getting a bit tricky I think: if two requests are coming in at the very same time (which is not so odd with 3,000 requests per minute), is Google firing up another instance, hence Google would count an addition of (at least) 0.15 instance hours? Also I am not quite sure how a web-client that is constantly performing read operations on the datastore in order to display and analyse data would increase the instance hours. \nDoes anyone know a reliable way of counting instance hours and creating meaningful estimations? We would use that information to know how expensive it would be to run an application on GAE in comparison to just ordering a web server.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1362,"Q_Id":23610748,"Users Score":4,"Answer":"There's no 100% sure way to assess the number of frontend instance hours. An instance can serve more than one request at a time. In addition, the algorithm of the scheduler (the system that starts the instances) is not documented by Google.\nDepending on how demanding your code is, I think you can expect a standard F1 instance to hold up to 5 requests in parallel, that's a maximum. 2 is a safer bet.\nMy recommendation, if possible, would be to simulate standard interaction on your website with limited number of users, and see how the number of instances grow, then extrapolate.\nFor example, let's say you simulate 100 requests per minute during 2 hours, and you see that GAE spawns 5 instances for that, then you can extrapolate that a continuous load of 3000 requests per minute would require 150 instances during the same 2 hours. Then I would double this number for safety, and end up with an estimate of 300 instances.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":23612408,"CreationDate":"2014-05-12T13:44:00.000","Title":"GAE: how to quantify Frontend Instance Hours usage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use Python Selenium to click a button on a webpage, but Selenium is giving exception \"Element is not currently visible and so may not be interacted with\".\nThe DOM structure is quite simple:\n<body style=\"overflow: hidden;\">\n...\n    <div aria-hidden=\"false\" style=\"display: block; ...\">\n        ...\n        <button id=\"button-aaa\" aria-hidden=\"true\" style=\"...\">\n        ...\n    <\/div>\n...\n<\/body>\nI have searched Google and Stackoverflow. Some users say Selenium cannot click a web element which is under a parent node with overflow: hidden. But surprisingly, I found that Selenium is able to click some other buttons which are also under a parent node with overflow: hidden.\nAnyway, I have tried to use driver.execute_script to change the <body> style to overflow: none, but Selenium is still unable to click this button.\nI have also tried to change the button's aria-hidden=\"true\" to aria-hidden=\"false\", but Selenium still failed to click.\nI have also tried to add \"display: block;\" to the button's style, and tried all different combination of style changes, but Selenium still failed to click.\nI have used this commands to check the button: buttonelement.is_displayed(). It always returns False no matter what style I change in the DOM. The button is clearly visually visible in the Firefox browser, and it is clickable and functioning. By using the Chrome console, I am able to select the button using ID.\nMay I know how can I check what is causing a web element to be invisible to Python Selenium?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1022,"Q_Id":23613260,"Users Score":1,"Answer":"Overflow takes only one of five values (overflow: auto | hidden | scroll | visible | inherit). Use visible","Q_Score":1,"Tags":"javascript,python,css,selenium","A_Id":23649576,"CreationDate":"2014-05-12T15:37:00.000","Title":"How to check what is causing a web element to be invisible to Python Selenium?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Lately I have observed that xdot utility which is implemented in python to view dot graphs is giving me following error when I am trying to open any dot file.\n\nFile \"\/usr\/bin\/xdot\", line 4, in xdot.main()\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1947, in main win.open_file(args[0])\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1881, in open_file self.set_dotcode(fp.read(), filename)\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1863, in set_dotcode if self.widget.set_dotcode(dotcode, filename):\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1477, in set_dotcode self.set_xdotcode(xdotcode)\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1497, in set_xdotcode self.graph = parser.parse()\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1167, in parse DotParser.parse(self)\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 977, in parse self.parse_graph()\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 986, in parse_graph self.parse_stmt()\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1032, in parse_stmt   self.handle_node(id, attrs)\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 1142, in handle_node shapes.extend(parser.parse()) \n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 612, in parse w = s.read_number()\n  File \"\/usr\/lib\/python2.7\/dist-packages\/xdot.py\", line 494, in read_number return   int(self.read_code())\n  ValueError: invalid literal for int() with base 10: '206.05'\n\nI have observed few things;\n\nThe same utility works fine for me on previous ubuntu versions(12.04, 13.04). The problem is when this is run on ubuntu 14.04. I am not sure if it is an ubuntu problem.\nAs per the trace log above the int() function has encounterd some float value which is causing the exception at the end of log.But the contents of my dot files does not contain any float value, so how come the trace shows ValueError: invalid literal for int() with base 10: '206.05'?\n\nAny clue will be helpful.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1384,"Q_Id":23623717,"Users Score":0,"Answer":"This is a bug in latest ubuntu xdot package, please use xdot in pip repository:\nsudo apt-get remove xdot\nsudo pip install xdot","Q_Score":0,"Tags":"python,python-2.7,ubuntu,graphviz","A_Id":34070637,"CreationDate":"2014-05-13T05:54:00.000","Title":"Graphviz xdot utility fails to parse graphs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have been going through the Google App Engine documentation (Python) now and found two different types of storage.\n\nNDB Datastore\nDB Datastore \n\nBoth quota limits (free) seem to be same, and their database design too. However NDB automatically cache data in Memcache!\nI am actually wondering when to use which storage? What are the general practices regarding this? \nCan I completely rely on NDB and ignore DB? How should it be done?\nI have been using Django for a while and read that in Django-nonrel the JOIN operations can be somehow done in NDB! and rest of the storage is used in DB! Why is that? Both storages are schemaless and pretty well use same design.. How is that someone can tweak JOIN in NDB and not in DB?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":568,"Q_Id":23645572,"Users Score":5,"Answer":"In simple words these are two versions of datastore . db being the older version and ndb the newer one. The difference is in the models, in the datastore these are the same thing. NDB provides advantages like handling caching (memcache) itself. and ndb is faster than db. so you should definitely go with ndb. to use ndb datastore just use ndb.Model while defining your models","Q_Score":2,"Tags":"python,django,google-app-engine","A_Id":23646875,"CreationDate":"2014-05-14T04:19:00.000","Title":"App Engine: Difference between NDB and Datastore","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've a strange issue. pserve --reload has stopped reloading the templates. It is reloading if some .py-file is changing, but won't notice .mak-file changes anymore. \nI tried to fix it by:\n\nChecking the filepermissions\nCreating the new virtualenv, which didn't help.\nInstalling different version of mako without any effect.\nChecking that the python is used from virtualenv\nplaying with the development.ini. It has the flag: pyramid.reload_templates = true\n\nAny idea how to start debugging the system?\nVersions:\n\nPython 2.7\npyramid 1.5\npyramid_mako 1.02\nmako 0.9.1\n\nYours\nHeikki","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":216,"Q_Id":23646485,"Users Score":1,"Answer":"Oh my,\nI found the thing... I had <%block cached=\"True\"  cache_key=\"${self.filename}+body\"> and the file inclusion was inside of that block.\nCheerious:)","Q_Score":0,"Tags":"python,pyramid,mako,waitress","A_Id":23654584,"CreationDate":"2014-05-14T05:42:00.000","Title":"Pyramid Mako pserver --reload not reloading in Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can someone please tell me how I can detach from an IPython kernel without terminating it?\nI see in the documentation of quit() that there is a parameter keep_kernel, but unfortunately quit(keep_kernel=True) won't work.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":682,"Q_Id":23680786,"Users Score":2,"Answer":"If you are connected to the kernel via the IPython console client and are on a Unix-like OS, you can detach using Ctrl-\\","Q_Score":4,"Tags":"python,ipython","A_Id":30603070,"CreationDate":"2014-05-15T14:12:00.000","Title":"Detach from IPython kernel without terminating it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a tkinter program written in python 3.3.3. I see myself in the need of making the the program get focus when the user unlocks the computer. I don't really know how to go ahead and start with this, users have a .exe version of the program that I created with cxfreeze. I f i need to modify the .py and create another .exe, that wouldn't be a problem. \nAfter some research I found that one can use the ctypes module to lock the computer, but it's not very helpful because i need to know if it is locked or unlocked. I also saw commands from win32com, but i can't seem to be able to find a way to trigger a command when it gets unlocked.\nWhat is the best way to get focus on my program after the computer is unlocked??\nAny help is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":23691819,"Users Score":0,"Answer":"I cannot answer this specifically for 'unlock' event (if there even is one in the GUI; I can't find one by cursory search.).  \nBut I think the real answer is to change the question.  Having a program simply take focus when user unlocks the display is very un-Windows-ish behavior.  The Windows user expects to see the desktop just as s\/he left it before the display was locked -- why does s\/he want to see your program on top when unlocking, regardless of why Windows might have locked the display?  \nMaybe you want to recast your program as something that runs in the background and pops up a notification (in the notification area on the right side of toolbar) when it wants user to do something?","Q_Score":0,"Tags":"python,python-3.x,tkinter","A_Id":23704276,"CreationDate":"2014-05-16T02:43:00.000","Title":"Get focus on tkinter program after pc is unlocked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I would like to install scipy on openshift but I don't know how to do it. I'm an absolute beginner with python and openshift. Therefore it would be great if somebody could provide a step by step explanation on how to proceed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":232,"Q_Id":23695305,"Users Score":0,"Answer":"Either add scipy to your setup.py file or login to openshift rhc ssh yourapp and install manually: pip install scipy","Q_Score":0,"Tags":"python,scipy,openshift","A_Id":33723529,"CreationDate":"2014-05-16T12:45:00.000","Title":"install scipy on openshift","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to resample a 1-D signal using an FFT method (basically, the one from scipy.signal). However, the code is taking forever to run, even though my input signal is a power of two in length. After looking at profiling, I found the root of the problem.\nBasically, this method takes an FFT, then removes part of the fourier spectrum, then takes an IFFT to bring it back to the time domain at a lower sampling rate.\nThe problem is that that the IFFT is taking far longer to run than the FFT:\nncalls  tottime  percall  cumtime  percall filename:lineno(function)\n     1 6263.996 6263.996 6263.996 6263.996 basic.py:272(ifft)\n     1    1.076    1.076    1.076    1.076 basic.py:169(fft)\n\nI assume that this has something to do with the amount of fourier points remaining after the cutoff. That said, this is an incredible slowdown so I want to make sure that:\nA. This behavior is semi-reasonable and isn't definitely a bug.\nB. What could I do to avoid this problem and still downsample effectively.\nRight now I can pad my input signal to a power of two in order to make the FFT run really quickly, but not sure how to do the same kind of thing for the reverse operation. I didn't even realize that this was an issue for IFFTs :P","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":285,"Q_Id":23716904,"Users Score":1,"Answer":"If your IFFT's length is different from that of the FFT, and the length of the IFFT isn't composed of only very small prime factors (2,3,etc.), then the efficiency can drop off significantly.\nThus, this method of resampling is only efficient if the two sample rates are different by ratios with small prime factors, such as 2, 3 and 7 (hint).","Q_Score":0,"Tags":"python,numpy,scipy,signal-processing,fft","A_Id":23717381,"CreationDate":"2014-05-17T22:58:00.000","Title":"IFFT taking orders of magnitude more than FFT","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to summarize text documents that belong to legal domain. \nI am referring to the site deeplearning.net on how to implement the deep learning architectures. I have read quite a few research papers on document summarization (both single document and multidocument) but I am unable to figure to how exactly the summary is generated for each document. \nOnce the training is done, the network stabilizes during testing phase. So even if I know the set of features (which I have figured out) that are learnt during the training phase, it would be difficult to find out the importance of each feature (because the weight vector of the network is stabilized) during the testing phase where I will be trying to generate summary for each document. \nI tried to figure this out for a long time but it's in vain. \nIf anybody has worked on it or have any idea regarding the same, please give me some pointers. I really appreciate your help. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2167,"Q_Id":23729919,"Users Score":2,"Answer":"I think you need to be a little more specific. When you say \"I am unable to figure to how exactly the summary is generated for each document\", do you mean that you don't know how to interpret the learned features, or don't you understand the algorithm? Also, \"deep learning techniques\" covers a very broad range of models - which one are you actually trying to use?\nIn the general case, deep learning models do not learn features that are humanly intepretable (albeit, you can of course try to look for correlations between the given inputs and the corresponding activations in the model). So, if that's what you're asking, there really is no good answer. If you're having difficulties understanding the model you're using, I can probably help you :-) Let me know.","Q_Score":3,"Tags":"python,theano,summarization,deep-learning","A_Id":23765727,"CreationDate":"2014-05-19T04:53:00.000","Title":"Text summarization using deep learning techniques","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Hi I am trying to write python functional tests for our application. It involves several external components and we are mocking them all out.. We have got a better framework for mocking a service, but not for mocking a database yet. \nsqlite is very lite and thought of using them but its a serverless, is there a way I can write some python wrapper to make it a server or I should look at other options like HSQL DB?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":535,"Q_Id":23744128,"Users Score":-1,"Answer":"I don't understand your problem. Why do you care that it's serverless?\nMy standard technique for this is:\n\nuse SQLAlchemy\nin tests, configure it with sqlite:\/\/\/ or sqlite:\/\/\/:memory:","Q_Score":0,"Tags":"python,sqlite,unit-testing","A_Id":23744831,"CreationDate":"2014-05-19T17:52:00.000","Title":"how to do database mocking or make sqlite run on localhost?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on my Python project using PySide as my Ui language. My projet is a game which require an internet connection to update the users'score and store in the database.\nMy problem is how can I store my database in the internet. I mean that all users can access this information when they are connected to an internet (when they are playing my game) and the information\/database must be updated all the time.\nI am not sure which database is the most appropriate, how to store this information\/database in the internet, how to access this information.\nI am using Python and PySide.\nFor the database, I currently use PySide.QtSql .\nThank you for answer(s) or suggestion(s).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":23754108,"Users Score":0,"Answer":"I'm not familiar with PySide .. but the idea is \nyou need to build a function that when internet connection is available it should synchronize your local database with online database and in the server-side you need to build a script that can handle requests ( POST \/ GET ) to receive the scores and send it to database and I suggest MySQL .. \nHope that helps","Q_Score":0,"Tags":"python,database,sockets,pyside,qtsql","A_Id":23754331,"CreationDate":"2014-05-20T07:59:00.000","Title":"Using Database with Pyside and Socket","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Python 2.7 and Django 1.4\nIf I have a string variable result = \"fred\\xbf\", how do I tell the Django template to display \"fred\\xbf\" rather than process the backslash and display some strange character? \nI know I can escape the backslash: \"fred\\\\xbf\" , but can I get the Django template to understand I want the backslash not to be processed?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2703,"Q_Id":23763365,"Users Score":2,"Answer":"This has nothing to do with the Django template, but how you define the variable in the first place.\nBasckslashes are only \"interpreted\" when you specify them as literals in your Python code. So given your Python code above, you can either use the double backslash, or use a raw string.\nIf you were loading the string \"fred\\xbf\" from your database and outputting it in a template, it would not be \"escaped\".","Q_Score":2,"Tags":"python,django","A_Id":23763477,"CreationDate":"2014-05-20T14:59:00.000","Title":"How do I tell Python not to interpret backslashes in strings?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know python and want to contribute on OpenSource projects that features python. Anyone can help me where to contribute and how.\nI already googled it and find github and code.google as a good place to contribute but how to start it I don't know.\nSuggest how to get started.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":435,"Q_Id":23764710,"Users Score":2,"Answer":"Not sure if this is an appropriate question for SO - you might get voted down. But ...\nWhenever I have seen this question, the answer is almost always:\n\nfind a project you like \/ you're interested in\nfind something in that project that you feel you can fix \/ enhance (have a look through their bug tracker)\nfork the project (github makes this easy)\nmake the change, find out what is appropriate for that project (documentation, unit tests, ...)\nsubmit the change back to the project (github has \"request pull\")\n\nGood luck!","Q_Score":0,"Tags":"python,open-source","A_Id":23764809,"CreationDate":"2014-05-20T15:56:00.000","Title":"how to contribute on open source project featuring python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have this wired protocol I am implementing and I have to write binary and ASCII data into the same file, how can I do this at the same time or at least the result in the end will be the file with mixed asci and binary data ?\nI know that open(\"myfile\", \"rb\") does open myfile in the binary mode, except that I can't find a solution how to go about this!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":782,"Q_Id":23781823,"Users Score":1,"Answer":"Under Python 2, the only difference binary mode makes is how newlines are translated when writing; \\n would be translated to the platform-dependant line separator.\nIn other words, just write your ASCII byte strings directly to your binary file, there is no difference between your ASCII data and the binary data as far as Python is concerned.","Q_Score":0,"Tags":"python,file,binary","A_Id":23781948,"CreationDate":"2014-05-21T11:24:00.000","Title":"How to write binary and asci data into a file in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First: Any recs on how to modify the title?\nI am using my own named entity recognition algorithm to parse data from plain text.  Specifically, I am trying to extract lawyer practice areas.  A common sentence structure that I see is:\n1) Neil focuses his practice on employment, tax, and copyright litigation.\nor\n2) Neil focuses his practice on general corporate matters including securities, business organizations, contract preparation, and intellectual property protection.\nMy entity extraction is doing a good job of finding the key words, for example, my output from sentence one might look like this:\nNeil focuses his practice on (employment), (tax), and (copyright litigation).\nHowever, that doesn't really help me.  What would be more helpful is if i got an output that looked more like this:\nNeil focuses his practice on (employment - litigation), (tax - litigation), and (copyright litigation).\nIs there a way to accomplish this goal using an existing python framework such as nltk (after my algo extracts the practice areas) can I use ntlk to extract the other words that my \"practice areas\" modify in order to get a more complete picture?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1842,"Q_Id":23793628,"Users Score":1,"Answer":"I do not think your \"algo\" is even doing entity recognition... however, stretching the problem you presented quite a bit, what you want to do looks like coreference resolution in coordinated structures containing ellipsis. Not easy at all: start by googling for some relevant literature in linguistics and computational linguistics. I use the standard terminology from the field below.\nIn practical terms, you could start by assigning the nearest antecedent (the most frequently used approach in English). Using your examples:\n\nfirst extract all the \"entities\" in a sentence\nfrom the entity list, identify antecedent candidates (\"litigation\", etc.). This is a very difficult task, involving many different problems... you might avoid it if you know in advance the \"entities\" that will be interesting for you.\nfinally, you assign (resolve) each anaphora\/cataphora to the nearest antecedent.","Q_Score":0,"Tags":"python,nlp,nltk","A_Id":23816393,"CreationDate":"2014-05-21T20:56:00.000","Title":"How to extract meaning from sentences after running named entity recognition?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to read values from excel worksheet into 2d array.can anyone tell me how to do this using pythonwin32com.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":23801986,"Users Score":0,"Answer":"You can have multi dimensional arrays or objects, your choice :)\narr = []; arr.append([1,2]); print arr;\nwould output \n[[1,2]]","Q_Score":1,"Tags":"python,win32com","A_Id":23802237,"CreationDate":"2014-05-22T08:49:00.000","Title":"Two dimensional array in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how to launch a new python virtual machine from inside a python script, and then interact with it to execute code in a completely separate object space? In addition to code execution, I'd like to be able to access the objects and namespace on this virtual machine, look at exception information, etc.\nI'm looking for something similar to python's InteractiveInterpreter (in the code module), but as far as I've been able to see, even if you provide a separate namespace for the interpreter to run in (through the locals parameter), it still shares the same object space with the script that launched it. For instance, if I change an attribute of the sys module from inside InteractiveInterpreter, the change takes affect in the script as well. I want to completely isolate the two, just like if I was running two different instances of the python interpreter to run two different scripts on the same machine.\nI know I can use subprocess to actually launch python in a separate process, but I haven't found any good way to interact with it the way I want. I imagine I could probably invoke it with '-i' and push code to it through it's stdin stream, but I don't think I can get access to its objects at all.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":923,"Q_Id":23807459,"Users Score":1,"Answer":"It may depend on Python implementation such as Pypy, Jython. In CPython, you have to use a separate process if you want an independent interpreter otherwise at the very least GIL is shared. \nmultiprocessing, concurrent.futures modules allow you to run arbitrary Python code in separate processes and to communicate with the parent easily.","Q_Score":3,"Tags":"python,vm-implementation","A_Id":30846061,"CreationDate":"2014-05-22T12:55:00.000","Title":"Programmatically launch and interact with python virtual machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am following a python bbok which says to install Distribute. However I am confused should I install Distribute or Setuptools as both of them have merged now. Is there still a difference between the two? Since I have installed pip and that automaticallly installs setuptools I want to know how can I check if Distribute or Setuptools is installed or not?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":23823519,"Users Score":2,"Answer":"The situation is legitimately confusing as there are too many installers available for Python and the landscape has changed recently.\nDistribute was a fork of setuptools which itself is an extension to distutils. They merged back with setuptools in 2013. Your book is most likely out of date. The documentation of setuptools and distribute has been a confusing mess since it assumes you already have intimate knowledge of distutils. Distutils2 was an abandoned effort to get a more capable distutils into the Py3.3 standard lib.\nSince distutils still lacks key features like generating executable wrapper scripts you would be best off working with a recent version of setuptools. Read through the distutils documentation first as setuptools is a superset of its functionality.\nYou can't depend on your users having setuptools installed so it is helpful to include the ez_setup.py bootstrapping script with your code. This will let your setup.py install setuptools if needed.","Q_Score":0,"Tags":"python,setuptools,distribute","A_Id":24061938,"CreationDate":"2014-05-23T07:35:00.000","Title":"What should I install Distribute or Setuptools","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using file.write() with 'wb' flag does Python use big or litte endian, or sys.byteorder value ? how can i be sure that the endianness is not random, I am asking because I am mixing ASCII and binary data in the same file and for the binary data i use struct.pack() and force it to little endian, but I am not sure what happen to the ASCII data !\nEdit 1: since the downvote, I'll explain more my question !\nI am writing a file with ASCII and binary data, in a x86 PC, the file will be sent over the network to another computer witch is not x86, a PowerPC, witch is on Big-endian, how can I be sure that the data will be the same when parsed with the PowerPC ?\nEdit 2: still using Python 2.7","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":8145,"Q_Id":23831422,"Users Score":1,"Answer":"Note: I assume Python 3.\nEndianness is not a concern when writing ASCII or byte strings. The order of the bytes is already set by the order in which those bytes occur in the ASCII\/byte string. Endianness is a property of encodings that maps some value (e.g. a 16 bit integer or a Unicode code point) to several bytes. By the time you have a byte string, the endianness has already been decided and applied (by the source of the byte string).\nIf you were to write unicode strings to file not opened with b mode, the question depends on how those strings are encoded (they are necessarily encoded, because the file system only accept bytes). The encoding in turn depends on the file, and possibly on the locale or environment variables (e.g. for the default sys.stdout). When this causes problems, the problems extend beyond just endianness. However, your file is binary, so you can't write unicode directly anyway, you have to explicitly encode and decode. Do this with any fixed encoding and there won't be endianness issues, as an encoding's endianness is fixed and part of the definition of the encoding.","Q_Score":4,"Tags":"python,binary,endianness","A_Id":23831750,"CreationDate":"2014-05-23T14:08:00.000","Title":"What endianness does Python use to write into files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to download\/install Light Table. I want it to show up in the start menu.\nWhen downloading light table, it shows up as a Zip folder in the TEMP file. I've extracted the files and am unable to get it to show up in the start menu.\nNormally the programs I download have an installer that does this automatically. Light Table doesn't seem to have this.\nI'm sure I can use it from the TEMP folder, but would really like it in the start menu, program files folder or C drive.\nI've only done basic use of PCs (gaming, web browsing, MS Office).","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2589,"Q_Id":23846899,"Users Score":3,"Answer":"It's pretty easy to do.\n\nUnzip to where ever \nMove the LightTable directory (from inside LightTableWin) to your Program Files (x86) directory.  \n2.1 If you are using Windows Explorer, you'll need to start windows explorer as an administrator (found by right clicking the program icon) \nopen your Program Files (x86)\\LightTable directory, right click\nand drap the LightTable.exe file into the same directory and select\nCreate Shortcut \nLeft Click your short cut and drag it to\nyour start menu.  When it asks if you want to pin it to your start\nmenu, select yes. \nClick on Start, and then click on the light table short cut. \nUse Light Table","Q_Score":2,"Tags":"python,windows-7,installation,lighttable","A_Id":29813451,"CreationDate":"2014-05-24T15:45:00.000","Title":"Install Light Table editor on Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have searched a lot and I know how to open a directory dialog window. \nBut what I am looking for is the method to open a directory folder under windows OS, just like you right click one of your local folder and select open. \nAny suggestions?","AnswerCount":6,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":21145,"Q_Id":23859613,"Users Score":4,"Answer":"You may simply try this:\nos.startfile(whatever_valid_filename)\nThis starts the default OS application for whatever_valid_filename, meaning Explorer for a folder name, default notepad for a .txt file, etc.","Q_Score":4,"Tags":"python,pyqt,pyqt4","A_Id":41981238,"CreationDate":"2014-05-25T20:22:00.000","Title":"PyQt - How to open a directory folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to make excel workbook calculation to automatic in both vba and python script?\nI tried this Application.Calculation = xlCalculateAutomatic but it is not working.\nIt throws me below error.\nglobal name 'xlCalculateAutomatic' is not defined.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":93,"Q_Id":23869132,"Users Score":1,"Answer":"It is xlCalculationAutomatic or you could use the number -4105 in Python.","Q_Score":1,"Tags":"python,excel,vba","A_Id":23869285,"CreationDate":"2014-05-26T11:31:00.000","Title":"workbook calculation to automatic in both vba and python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm new in this area so I have a question. Recently, I started working with Python and Django. I installed PyCharm Community edition as my IDE, but I'm unable to create a Django project.\nI looked for some tutorials, and there is an option to select \"project type\", but in the latest version this option is missing. Can someone tell me how to do this?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":89573,"Q_Id":23870365,"Users Score":7,"Answer":"I have met the problems today. At last, I finished it by:\n\nCreate project in command line\nCreate app in command line\nJust open the existing files and code in pycharm\n\nThe way I use have the benefits:\n\ndon't need by professional pycharm\ncode django project in pycharm","Q_Score":51,"Tags":"python,django,pycharm","A_Id":32492931,"CreationDate":"2014-05-26T12:38:00.000","Title":"How to set up a Django project in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a mediaplayer-gui fitting some needs of a medialibrary containing classical music only.\nLanguage is python3\/tkinter.\nOne backend is gstreamer1.0, playbin (seems to be the only one, playing gapless).\nWhen playbin gets the uri of a file with 5.0 channels\n(FRONT_LEFT,FRONT_RIGHT,FRONT_CENTER,REAR_LEFT,REAR_RIGHT)\nit gives following warning:\n** (python3:13745): WARNING **: Unpositioned audio channel position flag set but channel positions present\nand plays the file downmixed to stereo.\n5.0 is most common in classical-music media(LFE is mostly unwanted).\nWhich gstreamer-object is the one, i can tell about channel-layout and what signal do i have to connect to, to get that object?\nAdditional info:\n5.1 gives the same warning, but plays without downmixing; \n5.0 using gstplay-1.0 from commandline gives warning & downmixing; \nusing gst123 based on gstreamer0.1 plays everything right","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":193,"Q_Id":23884156,"Users Score":1,"Answer":"I'd suggest to file a bug and ideally make your test files available.\nIf you want to track this down yourself take a look at the GST_DEBUG=\"*:3\" .\/your-app output to see which element is emitting the warning.","Q_Score":0,"Tags":"python,gstreamer","A_Id":23921536,"CreationDate":"2014-05-27T08:08:00.000","Title":"how to make playbin of gstreamer1.0 playing multichannel-audio 5.0 playing without downmixing to stereo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a case for needing to add a path to a python package to sys.path (instead of its parent directory), but then refer to the package normally by name. \nMaybe that's weird, but let me exemplify what I need and maybe you guys know how to achieve that.\nI have all kind of experimental folders, modules, etc inside a path like \/home\/me\/python.\nNow I don't want to add that folder to my sys.path (PYTHONPATH) since there are experimental modules which names could clash with something useful. \nBut, inside \/home\/me\/python I want to have a folder like pyutils. So I want to add \/home\/me\/python\/pyutils to PYTHONPATH, but, be able to refer to the package by its name pyutils...like I would have added \/home\/me\/python to the path.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2392,"Q_Id":23891195,"Users Score":-1,"Answer":"I'll answer to my own question since I got an idea while writing the question, and maybe someone will need that.\nI added a link from that folder to my site-packages folder like that:\nln -s \/home\/me\/python\/pyutils \/path\/to\/site-packages\/pyutils\nThen, since the PYTHONPATH contains the \/path\/to\/site-packages folder, and I have a pyutils folder in it, with init.py, I can just import like:\nfrom pyutils import mymodule\nAnd the rest of the \/home\/me\/python is not in the PYTHONPATH","Q_Score":1,"Tags":"python","A_Id":23891448,"CreationDate":"2014-05-27T13:46:00.000","Title":"Add path to python package to sys.path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a single task to complete X number of times in Python and I will be using LSF to speed that up. Is it better to submit a job containing several Python scripts which can be run separately in parallel or one Python script that utilizes the multiprocessor module?\nMy issue is I don't trust LSF to know how to split up the Python code into several processes (I'm not sure how LSF does this). However, I also don't want several Python scripts floating around as that seems inefficient and disorganized.\nThe task at hand involves parsing six very large ASCII files and saving the output in a Python dict for later use. I want to parse the six files in parallel (they take about 3 minutes each). Does LSF allow Python to tell it something like \"Hey, here's one script, but you're going to split it into these six processes\"? Does LSF need Python to tell it that or does it already know how to do that?\nLet me know if you need more info. I have trouble balancing between \"just enough\" and \"too much\" background.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1380,"Q_Id":23897254,"Users Score":3,"Answer":"One (very simplified) way to think of LSF is as a system that launches a process and lets the process know how many cores (potentially on different hosts) have been allocated to it.  LSF can't prevent your program from doing something stupid (like for example, if multiple instances of it run at the same time, and one instance overwrites the other's output).\nSome common ways of using LSF.\n\nRun 6 sequential jobs that process one file each. These 6 can run in parallel. Have a dependant seventh job that runs after the previous 6 finish, which will combine the output of the previous 6 into a single output.\nRun a parallel job that is assigned 6 cores on a single host. Seems that the python multiprocessing module would fit in well here.  The env variable $LSB_MCPU_HOSTS will tell you how many cores are assigned to the job, so you know how big to make the pool.\nRun a parallel jobs that is assigned 6 cores, and could run on multiple hosts. Again, your process must be able to start itself on these other hosts.  (or use blaunch to help out)\n\nI'm not sure which of these 3 ways best fits you needs.  But I hope that the explanation helps you decide.","Q_Score":3,"Tags":"python,multiprocessing,lsf","A_Id":23901931,"CreationDate":"2014-05-27T19:16:00.000","Title":"LSF: Submit one Python script that uses multiprocessor module *or* submit several scripts at once that are \"pre-split\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to teach myself a concept by writing a script.  Basically, I'm trying to write a Python script that, given a few keywords, will crawl web pages until it finds the data I need.  For example, say I want to find a list of venemous snakes that live in the US.  I might run my script with the keywords list,venemous,snakes,US, and I want to be able to trust with at least 80% certainty that it will return a list of snakes in the US.\nI already know how to implement the web spider part, I just want to learn how I can determine a web page's relevancy without knowing a single thing about the page's structure.  I have researched web scraping techniques but they all seem to assume knowledge of the page's html tag structure.  Is there a certain algorithm out there that would allow me to pull data from the page and determine its relevancy?\nAny pointers would be greatly appreciated.  I am using Python with urllib and BeautifulSoup.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3298,"Q_Id":23921986,"Users Score":2,"Answer":"You're basically asking \"how do I write a search engine.\"  This is... not trivial.\nThe right way to do this is to just use Google's (or Bing's, or Yahoo!'s, or...) search API and show the top n results.  But if you're just working on a personal project to teach yourself some concepts (not sure which ones those would be exactly though), then here are a few suggestions:\n\nsearch the text content of the appropriate tags (<p>, <div>, and so forth) for relevant keywords (duh)\nuse the relevant keywords to check for the presence of tags that might contain what you're looking for.  For example, if you're looking for a list of things, then a page containing <ul> or <ol> or even <table> might be a good candidate\nbuild a synonym dictionary and search each page for synonyms of your keywords too.  Limiting yourself to \"US\" might mean an artificially low ranking for a page containing just \"America\"\nkeep a list of words which are not in your set of keywords and give a higher ranking to pages which contain the most of them.  These pages are (arguably) more likely to contain the answer you're looking for\n\ngood luck (you'll need it)!","Q_Score":8,"Tags":"python,web-scraping,beautifulsoup,web-crawler","A_Id":23922228,"CreationDate":"2014-05-28T21:13:00.000","Title":"Web scraping without knowledge of page structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that GMPY2 supports the GMP library and numpy has fast numerical libraries. I want to know how the speed compares to actually writing C (or C++) code with GMP. Since Python is a scripting language, I don't think it will ever be as fast as a compiled language, however I have been wrong about these generalizations before. \nI can't get GMP to work on my computer, so I can't run any tests. If I could, just general math like addition and maybe some trig functions. I'll figure out GMP later.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2014,"Q_Id":23944242,"Users Score":7,"Answer":"numpy and GMPY2 have different purposes.\nnumpy has fast numerical libraries but to achieve high performance, numpy is effectively restricted to working with vectors or arrays of low-level types - 16, 32, or 64 bit integers, or 32 or 64 bit floating point values. For example, numpy access highly optimized routines written in C (or Fortran) for performing matrix multiplication.\nGMPY2 uses the GMP, MPFR, and MPC libraries for multiple-precision calculations. It isn't targeted towards vector or matrix operations.\nThe Python interpreter adds overhead to each call to an external library. Whether or not the slowdown is significant depends on the how much time is spend by the external library. If the running time of the external library is very short, say 10e-8 seconds, then Python's overhead is significant. If the running time of the external library is relatively long, several seconds or longer, then Python's overhead is probably insignificant.\nSince you haven't said what you are trying to accomplish, I can't give a better answer.\nDisclaimer: I maintain GMPY2.","Q_Score":2,"Tags":"python,c,numpy,gmp,gmpy","A_Id":23946348,"CreationDate":"2014-05-29T22:46:00.000","Title":"How do numpy and GMPY2 compare with GMP in terms of speed?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to serve files securely (images in this case) to my users. I would like to do this using flask and preferably amazon s3 however I would be open to another cloud storage solution if required. \nI have managed to get my flask static files like css and such on s3 however this is all non-secure. So everyone who has the link can open the static files. This is obviously not what I want for secure content. I can't seems to figure out how I can make a file available to just authenticated user that 'owns' the file.  \nFor example: When I log into my dropbox account and copy a random file's download link. Then go over to anther computer and use this link it will denie me access. Even though I am still logged in and the download link is available to user on the latter pc.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":890,"Q_Id":23985795,"Users Score":1,"Answer":"Make the request to your Flask application, which will authenticate the user and then issue a redirect to the S3 object. The trick is that the redirect should be to a signed temporary URL that expires in a minute or so, so it can't be saved and used later or by others.\nYou can use boto.s3.key.generate_url function in your Flask app to create the temporary URL.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-s3,flask","A_Id":23986820,"CreationDate":"2014-06-02T00:19:00.000","Title":"Secure access of webassets with Flask and AWS S3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So in my spare time, I've been developing a piece of network monitoring software that essentially can be installed on a bunch of clients, and the clients report data back to the server(RAM\/CPU\/Storage\/Network usage, and the like). For the administrative console as well as reporting, I've decided to use Django, which has been a learning experience in itself. \nThe Clients report to the Server asynchronously, with whatever data they happen to have(As of right now, it's just received and dumped, not stored in a DB). I need to access this data in Django. I have already created the models to match my needs. However, I don't know how to go about getting the actual data into the django DB safely. \nWhat is the way to go about doing this?  I thought of a few options, but they all had some drawbacks:\n\nGive the Django app a reference to the Server, and just start a thread that continuously checks for new data and writes it to the DB. \nHave the Server access the Django DB directly, and write it's data there. \n\nThe problem with 1 is that im even more tightly coupling the server with the django app, but the upside is that I can use the ORM to write the data nicely. \nThe problem with 2 is that I can't use the ORM to write data, and I'm not sure if it could cause blocking on the DB in some cases. \nIs there some obvious good option I'm missing? I'm sorry if this question is vague. I'm very new to Django, and I don't want to write myself into a corner.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":849,"Q_Id":23987050,"Users Score":1,"Answer":"I chose option 1 when I set up my environment, which does much of the same stuff.\nI have a JSON interface that's used to pass data back to the server.  Since I'm on a well-protected VLAN, this works great.  The biggest benefit, like you say, is the Django ORM.  A simple address call with proper data is all that's needed.  I also think this is the simplest method.\nThe \"blocking on the DB\" issue should be non-existent.  I suppose that it would depend on the DB backend, but really, that's one of the benefits of a DB.  For example, a single-threaded file-based sqlite instance may not work.\nI keep things in Django as much as I can.  This could also help with DB security\/integrity, since it's only ever accessed in one place.  If your client accesses the DB directly, you'll need to ship username\/password with the Client.\nMy recommendation is to go with 1.  It will make your life easier, with fewer lines of code.  Besides, as long as you code Client properly, it should be easy to modify DB access later on down the road.","Q_Score":2,"Tags":"python,django,orm","A_Id":23987194,"CreationDate":"2014-06-02T03:41:00.000","Title":"How to access Django DB and ORM outside of Django","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project consisting on Client\/Server. Client is written in Python (will run on linux) and server in C#. I'm communicating through standard sockets and I'm using protobuf-net for protocol definition. However, I'm wondering how would protobuf-net handle DateTime serialization. Unix datetime differs from .net standard datetime, so how should I handle this situation?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3765,"Q_Id":24036291,"Users Score":11,"Answer":"DateTime is spoofed via a multi-field message that is not trivial, but not impossible to understand. In hindsight, I wish I had done it a different way, but it is what it is. The definition is available in bcl.proto in the protobuf-net project.\nHowever! If you are targering multiple platforms, I strongly recommend you simply use a long etc in your DTO model, representing some time granularity into some epoch (seconds or milliseconds since 1970, for example).","Q_Score":8,"Tags":"c#,python,protocol-buffers,protobuf-net","A_Id":24038019,"CreationDate":"2014-06-04T11:33:00.000","Title":"How protobuf-net serialize DateTime?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a library whose main functionality is implemented in C (speed is critical), with a thin Python layer around it to deal with the ctypes nastiness.\nI'm coming to package it and I'm wondering how I might best go about this. The code it must interface with is a shared library. I have a Makefile which builds the C code and creates the .so file, but I don't know how I compile this via distutils. Should I just call out to make with subprocess by overriding the install command (if so, is install the place for this, or is build more appropriate?)\nUpdate: I want to note that this is not a Python extension. That is, the C library contains no code to itself interact with the Python runtime. Python is making foreign function calls to a straight C shared library.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":4767,"Q_Id":24062830,"Users Score":1,"Answer":"I'd consider building the python module as a subproject of a normal shared library build.  So, use automake, autoconf or something like that to build the shared library, have a python_bindings directory with a setup.py and your python module.","Q_Score":16,"Tags":"python,c,distutils","A_Id":24066500,"CreationDate":"2014-06-05T14:26:00.000","Title":"Best way to package a Python library that includes a C shared library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I downloaded the freebase data dump and I want to use it to get information about a query just like how I do it using the web API. How exactly do I do it? I tried using a simple zgrep but the result was a mess and takes too much time. Any graceful way to do it (preferably something that plays nicely with python)?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":964,"Q_Id":24069711,"Users Score":1,"Answer":"The Freebase dump is in RDF format.  The easiest way to query it is to dump it (or a subset of it) into an RDF store.  It'll be quicker to query, but you'll need to pay the database load time up front first.","Q_Score":3,"Tags":"python,rdf,freebase","A_Id":25625683,"CreationDate":"2014-06-05T20:31:00.000","Title":"How to search freebase data dump","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am taking the backup of datastore , using Taskqueues. I want to check whether the backup has completed successfully or not. I can check the end of the backup job by checking the taskqueue, but how can i check whether the backup was successful or it failed due to some errors.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":24077041,"Users Score":1,"Answer":"Unfortunately there is not currently a well-supported way to do this.\nHowever, with the disclaimer that this is likely to break at some point in the future, as it depends on internal implementation details, You can fetch the relevant _AE_Backup_Information and _AE_DatastoreAdmin_Operation entities from your datastore and inspect them for information regarding the backup. In particular, the _AE_DatastoreAdmin_Operation has fields active_jobs, completed_jobs, and status.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":24088125,"CreationDate":"2014-06-06T08:05:00.000","Title":"Google App Engine Check Success of backup programmatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have read a few posts on how to enable remote login to mysql. My question is: is this a safe way to access data remotely? \nI have a my sql db located at home (on Ubuntu 14.04) that I use for research purposes. I would like to run python scripts from my Macbook at work. I was able to remote login from my old windows OS using workbench connection (DNS ip). However the OS change has got me thinking what is the best\/most secure way to accomplish this task?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":24112422,"Users Score":0,"Answer":"Use ssh to login to your home computer, setup authorized keys for it and disable password login. setup iptables on your linux machine if you don't have a firewall on your router, and disable traffic on all ports except 80 and 22 (ssh and internet). That should get you started.","Q_Score":0,"Tags":"python,mysql,ruby-on-rails","A_Id":24112483,"CreationDate":"2014-06-09T01:02:00.000","Title":"Best way to access data from mysql db on other non-local machines","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing git commands through a Python script (on Windows)\nWhen I double click on myScript.py, commands are launched in the Windows Command Prompt.\nI would like to execute them in Git Bash.\nAny idea how to do that without opening Git Bash and write python myScript.py?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28190,"Q_Id":24123128,"Users Score":0,"Answer":"in the top of your python file add #!\/usr\/bin\/python then you can rename mv myScript.py myScript and run chmod 755 myScript. This will make it so you can run the file with .\/myScript look into adding the file directory to your path or linking it to the path if you want to be able to run it from anywhere.","Q_Score":3,"Tags":"python,git","A_Id":24123328,"CreationDate":"2014-06-09T15:05:00.000","Title":"Launch Python script in Git Bash","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running django on port 8001, while nginx is handling webserver duties on port 80.  nginx proxies views and some REST api calls to Django.  I'm using django-allauth for user registration\/authentication.\nWhen a new user registers, django-allauth sends the user an email with a link to click.  Because django is running on port 8001, the link looks like http:\/\/machine-hostname:8001\/accounts\/confirm-email\/xxxxxxxxxxxxxx\nHow can I make the url look like http:\/\/www.example.com\/accounts\/confirm-email\/xxxxxxxx ?\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2367,"Q_Id":24128433,"Users Score":6,"Answer":"Django get hostname and port from HTTP headers. \nAdd proxy_set_header Host $http_host; into your nginx configuration before options proxy_pass.","Q_Score":8,"Tags":"python,django,email,nginx,django-allauth","A_Id":24129038,"CreationDate":"2014-06-09T20:26:00.000","Title":"django-allauth: how to modify email confirmation url?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to calculate the performance testing through selenium with python?\nIf it is possible, how should I do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":304,"Q_Id":24135896,"Users Score":0,"Answer":"Selenium is not the right tool to use for performance testing. \njmeter is a great tool for this. You would be able to see the response for each request.","Q_Score":3,"Tags":"python,selenium-webdriver,selenium-firefoxdriver","A_Id":25492157,"CreationDate":"2014-06-10T08:06:00.000","Title":"Is it possible to calculate the performance testing through selenium with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anybody tell me how the internal implementation of set and dict is different in python? Do they use the same data structure in the background? \n++ In theory, one can use dict to achieve set functionality.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1691,"Q_Id":24159713,"Users Score":-1,"Answer":"These two are use the same datastructure in the backend. e.g in sets you cannot store duplicate values but in dict you can store multople same values and you can turn the dict to sets by changing the behavior of dict","Q_Score":4,"Tags":"python,python-2.7,dictionary,set,python-internals","A_Id":24159900,"CreationDate":"2014-06-11T09:47:00.000","Title":"difference between python set and dict \"internally\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"At a high level, what I need to do is have a python script that does a few things based on the commands it receives from various applications. At this stage, it's not clear what the application may be. It could be another python program, a MATLAB application, or a LAMP configuration. The commands will be sent rarely, something like a few times every hour.\nThe problem is - What is the best way for my python script to receive these commands, and indicate to these applications that it has received them?\nRight now, what I'm trying to do is have a simple .txt file. The application(s) will write commands to the file. The python script will read it, do its thing, and remove the command from the file.\nI didn't like this approach for 2 reasons-\n1) What happens if the file is being written\/read by python and a new command is sent by an application?\n2) This is a complicated approach which does not lead to anything robust and significant.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2813,"Q_Id":24169539,"Users Score":1,"Answer":"Python has since early stages a very comfortable PyZMQ binding for ZeroMQ.\nMATLAB can have the same, a direct ZeroMQ at work for your many-to-many communications.\nLet me move in a bit broader view, from a few, but KEY PRINCIPAL POINTS, that are not so common in other software-engineering \"products\" & \"stacks\" we meet today around us:\n[1] ZeroMQ is first of all a very powerful concept rather than a code or a DIY kit\n[2] ZeroMQ's biggest plus for any professional grade project sits in rather using the genuine Scaleable Formal Communication Patterns end-to-end, not in the ability to code pieces or to \"trick\/mod\" the published internals\n[3] ZeroMQ team has done a terrific job and saves users from re-inventing wheels (\"inside\") and allows to rather stay on the most productive side by a re-use of the heroic knowledge ( elaborated, polished & tested by the ZeroMQ gurus, supporters & team-members ) from behind the ZMQ-abstraction-horizon.\nHaving said these few principles, my recommendation would be to spend some time on the concepts in a published book from Peter Hintjens on ZeroMQ ( also available in PDF). This a worthwhile place to start from, to get the bigger picture.\nThen, there it would be a question of literally a few SLOC-s to make these world most powerful ( and believe me, that this sounds bold only on first sight, as there are not many real alternatives to compare ZeroMQ with ... well, ZeroMQ co-architect Martin Sustrik's [nanomsg] is that case, to mention at least one, if you need to go even higher in speed \/ lower in latency, but the above key principal points hold & remain the same even there ... )\nHaving used a ZeroMQ orchestrated Python & MQL4 & AI\/ML system in FOREX high speed trading infrastructure environment is just a small example, where microseconds matter and nanosecond make a difference in the queue ...\nPresented in a hope that your interest in ZeroMQ library will only grow & that you will benefit as much as many other uses of this brilliant piece of art have gained giant leap & benefited from whatever the PUB\/SUB, PAIR\/PAIR, REQ\/REP formal patterns does best match the very communication need of your MATLAB \/ Python \/ * heterogeneous multi-party \/ multi-host Project.","Q_Score":0,"Tags":"python,database,web-applications,ipc","A_Id":24171852,"CreationDate":"2014-06-11T17:59:00.000","Title":"How do I communicate and share data between python and other applications?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am working on a project that involves using an Google App Engine (GAE) server to control one or more Google Compute Engine (GCE) instances.  The rest of the project is working well, but I am having a problem with one specific aspect: file management.  I want my GAE to edit a file on my GCE instance, and after days of research I have come up blank on how to do that.\nThe most straightforward example of this is:\nStep 1) User enters text into a GAE form.\nStep 2) User clicks a button to indicate they would like to \"submit\" the text to GCE\nStep 3) GAE replaces the contents of a particular (hard-coded path) text file on the GCE with the user's new content.\nStep 4) (bonus step)  GCE notices that the file has changed (either by detecting a change or by way of GAE alerting it when the new content is pushed) and runs a script to process the new file.\nI understand that this is easy to do using SCP or other terminal commands.  I have already done that, and that works fine.  What I need is a way for GAE to send that content directly, without my intervention.\nI have full access to all instances of GAE and GCE involved in this project, and can set up whatever code is needed on either of the platforms.\nThank you in advance for your help!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":24194217,"Users Score":0,"Answer":"The most straightforward approach seems to be:\n\nA user submit a form on App Engine instance.\nApp Engine instance makes a POST call to a handler on GCE instance with the new data.\nGCE instance updates its own file and processes it.","Q_Score":0,"Tags":"python,google-app-engine,file-transfer,google-compute-engine","A_Id":24194583,"CreationDate":"2014-06-12T21:28:00.000","Title":"Using Google App Engine to update files on Google Compute Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project that involves using an Google App Engine (GAE) server to control one or more Google Compute Engine (GCE) instances.  The rest of the project is working well, but I am having a problem with one specific aspect: file management.  I want my GAE to edit a file on my GCE instance, and after days of research I have come up blank on how to do that.\nThe most straightforward example of this is:\nStep 1) User enters text into a GAE form.\nStep 2) User clicks a button to indicate they would like to \"submit\" the text to GCE\nStep 3) GAE replaces the contents of a particular (hard-coded path) text file on the GCE with the user's new content.\nStep 4) (bonus step)  GCE notices that the file has changed (either by detecting a change or by way of GAE alerting it when the new content is pushed) and runs a script to process the new file.\nI understand that this is easy to do using SCP or other terminal commands.  I have already done that, and that works fine.  What I need is a way for GAE to send that content directly, without my intervention.\nI have full access to all instances of GAE and GCE involved in this project, and can set up whatever code is needed on either of the platforms.\nThank you in advance for your help!","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":273,"Q_Id":24194217,"Users Score":0,"Answer":"You can set an action URL in your form to point to the GCE instance (it can be load-balanced if you have more than one). Then all data will be uploaded directly to the GCE instance, and you don't have to worry about transferring data from your App Engine instance to GCE instance.","Q_Score":0,"Tags":"python,google-app-engine,file-transfer,google-compute-engine","A_Id":24215374,"CreationDate":"2014-06-12T21:28:00.000","Title":"Using Google App Engine to update files on Google Compute Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'll explain you better my problem. \nI've code a simple python server who listening for web client connection. \nThe server is running but i must add a function and i don't know how resolve this..\nI must set up a timer, if the client don't connect every N seconds, I've to log it.\nI already looked for set up a timeout but in the lib socket, the timeout doesn't do what i want ...\nI tried to set up a timer with timestamps and compare values, but the socket.listen() method don't stop operation until a client connects. And i wanna stop the listen() method if the time is exceeded.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":458,"Q_Id":24218114,"Users Score":0,"Answer":"How about using a token that is switched when the client connects? Put it in a while loop and if the token is ever the same non-switched value twice in a row kill the loop and stop listen().","Q_Score":0,"Tags":"python,sockets,tcp,timer","A_Id":24218375,"CreationDate":"2014-06-14T08:34:00.000","Title":"Python set up a timer for client connection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So far I have a pretty basic server (I haven't built in any security features yet, like cookie authentication). What I've got so far is an iOS app where you enter a username and password and those arguments are plugged into a URL and passed to a server. The server checks to see if the username is in the database and then sends a confirmation to the app. Pretty basic but what I can't figure out is what the confirmation should look like?\nThe server is a Python Tornado server with a MySQL dbms.. \nWhat I'm unsure of is what Tornado should\/can send in response? Do I use self.write or self.response or self.render? I don't think it's self.render because I'm not rendering an HTML file, I'm just sending the native iOS app a confirmation response which, once received by the app, will prompt it to load the next View Controller.\nAfter a lot of googling I can't seem to find the answer (probably because I don't know how to word the question correctly). \nI'm new to servers so I appreciate your patience.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":246,"Q_Id":24224539,"Users Score":1,"Answer":"You can send your response with either self.write() or self.finish() (the main difference is that with write() you can assemble your response in several pieces, while finish() can only be called once.  You also have to call finish() once if you're using asynchronous functions that are not coroutines, but in most cases it is done automatically).  \nAs for what to send, it doesn't really matter if it's a non-browser application that only looks at the status code, but I generally send an empty json dictionary for cases like this so there is well-defined space for future expansion.","Q_Score":1,"Tags":"python,ios,tornado","A_Id":24232201,"CreationDate":"2014-06-14T21:38:00.000","Title":"What's the proper Tornado response for a log in success?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox.\nNow i need to pass a shared object to python script as an argument from my app.\nwhat type of shared object should i create so that python script can accept it and run it or in simple words how do i create shared object which can be used by python script.\nthanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":912,"Q_Id":24237335,"Users Score":1,"Answer":"Since python is running as another process. This is no way for python to access object in c# directly since process isolation.\nA way of marshal and un-marshal should be included to communicate between processes.\nThere are many way to communicate between processes. Share memory, file, TCP and so on.","Q_Score":3,"Tags":"c#,python,.net,share,shared-objects","A_Id":24281523,"CreationDate":"2014-06-16T05:54:00.000","Title":"shared object in C# to be used in python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox.\nNow i need to pass a shared object to python script as an argument from my app.\nwhat type of shared object should i create so that python script can accept it and run it or in simple words how do i create shared object which can be used by python script.\nthanks","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":912,"Q_Id":24237335,"Users Score":1,"Answer":"5.4. Extending Embedded Python \nwill help you to access the application object.\nIn this case both application and python running in single process.","Q_Score":3,"Tags":"c#,python,.net,share,shared-objects","A_Id":32651105,"CreationDate":"2014-06-16T05:54:00.000","Title":"shared object in C# to be used in python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the Java world, we know that the exceptions are classified into checked vs runtime and whenever something throws a checked exception, the caller of that something will be forced to handle that exception, one way or another. Thus the caller would be well aware of the fact that there is an exception and be prepared\/coded to handle that.\nBut coming to Python, given there is no concept of checked exceptions (I hope that is correct), how does the caller of something know if that something would throw an exception or not? Given this \"lack of knowledge that an exception could be thrown\", how does the caller ever know that it could have handled an exception until it is too late?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":24249796,"Users Score":0,"Answer":"how does the caller of something know if that something would throw an exception or not?\n\nBy reading the documentation for that something.","Q_Score":0,"Tags":"python,exception,exception-handling","A_Id":24249840,"CreationDate":"2014-06-16T18:20:00.000","Title":"In python how does the caller of something know if that something would throw an exception or not?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In the Java world, we know that the exceptions are classified into checked vs runtime and whenever something throws a checked exception, the caller of that something will be forced to handle that exception, one way or another. Thus the caller would be well aware of the fact that there is an exception and be prepared\/coded to handle that.\nBut coming to Python, given there is no concept of checked exceptions (I hope that is correct), how does the caller of something know if that something would throw an exception or not? Given this \"lack of knowledge that an exception could be thrown\", how does the caller ever know that it could have handled an exception until it is too late?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":24249796,"Users Score":0,"Answer":"As far as I know Python (6 years) there isn't anything similar to Java's throws keyword in Python.","Q_Score":0,"Tags":"python,exception,exception-handling","A_Id":24249818,"CreationDate":"2014-06-16T18:20:00.000","Title":"In python how does the caller of something know if that something would throw an exception or not?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to organize a blog into multiple categories. For each category index page I want to add some metadata like title, description, meta etc. specific to the category.\nPelican uses folders to split posts into categories but how do I define the metadata for each category? Is it possible to use a metadata file to put into each category folder?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":590,"Q_Id":24250152,"Users Score":2,"Answer":"You might try adding a key\/value dictionary to your Pelican settings file that contains your category metadata, and then access that information from within your theme's index.html template.","Q_Score":4,"Tags":"python,metadata,categories,pelican","A_Id":24419741,"CreationDate":"2014-06-16T18:44:00.000","Title":"pelican blog define metadata for category index page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python's Django (w\/ Rest framework) to create an application similar to Twitter or Instagram.\nWhat's the best way to deal with caching content (JSON data, images, etc.) considering the constantly changing nature of a social network? How to still show updated state a user creates a new post, likes\/comments on a post, or deletes a post while still caching the content for speedy performance?\nIf the cache is to be flushed\/recreated each time a user takes an action, then it's not worth having a cache because the frequency of updates will be too rapid to make the cache useful. What are some techniques of dealing with this problem.\nPlease feel free to share your approach and some wisdom you learned while implementing your solution. Any suggestions would be greatly appreciated. :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":24271006,"Users Score":0,"Answer":"One technique is to key the URLs on the content of the media they are referring too.  For example if you're hosting images then use the sha hash of the image file in the url \/images\/<sha>.\nYou can then set far-future cache expiry headers on those URLs.  If the image changes then you also update the URL referring to it, and a request is made for an image that is no longer cached.\nYou can use this technique for regular database models as well as images and other media, so long as you recompute the hash of the object whenever any of its fields change.","Q_Score":1,"Tags":"python,django,caching,django-rest-framework","A_Id":24293403,"CreationDate":"2014-06-17T18:36:00.000","Title":"Handling Cache with Constant Change of Social Network","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can a virtualenv be modified after it is created so as to achieve the same effect as creating it with virtualenv --system-site-packages?  In other words, how to enable accessing any systemwide installed packages in a virtualenv which was originally created with that access disabled?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":76,"Q_Id":24279321,"Users Score":1,"Answer":"Delete or rename the file \/virtualenv_root\/lib\/python3.4\/no-global-site-packages.txt\nOR\nAdd a symlink between \/virtualenv_root\/lib\/python3.4\/site-packages\/ and \/path\/to\/desired\/site-packages\/\nHere virtualenv_root is the name of your virtual environment.","Q_Score":0,"Tags":"python,virtualenv","A_Id":24279522,"CreationDate":"2014-06-18T07:19:00.000","Title":"How to modify virtualenv to achieve the same effect as --system-site-packages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I knew that there is no builtin sph_hankel1 in scipy then i want to know that how to implement it in the right way?\nAdditional: Just show me one correct implementation of sph_hankel1 either using of Scipy or Sympy.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":997,"Q_Id":24284390,"Users Score":3,"Answer":"Although it would be nice if there were an existing routine for calculating the spherical Hankel functions (like there is for the ordinary Hankel functions), they are just a (complex) linear combination of the spherical Bessel functions of the first and second kind so can be easily calculated from existing routines.  Since the Hankel functions are complex and depending on your application of them, it can be advantageous to rewrite your expression in terms of the Bessel functions of the first and second kind, ie entirely real quantities, particularly if your final result is real.","Q_Score":3,"Tags":"python,numpy,scipy,sympy","A_Id":24289392,"CreationDate":"2014-06-18T11:30:00.000","Title":"How can i implement spherical hankel function of the first kind by scipy\/numpy or sympy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm packaging a GUI app for MacOS with Pyinstaller, using --windowed flag. Is it possible to package it so that it would show a console in addition to the GUI? When I tried to set console=True, the GUI part fails.\nIn other words, when I start the App from the terminal by typing \"open My.App\/Contents\/MacOS\/myapp\", then I do get both GUI and console. I'd like to get similar behaviour by just double-clicking on the App without starting the terminal. Is there a way to do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":425,"Q_Id":24333323,"Users Score":0,"Answer":"while you create application don't add those options\n\n--windowed and --noconsole","Q_Score":6,"Tags":"python,macos,pyinstaller","A_Id":53956162,"CreationDate":"2014-06-20T18:15:00.000","Title":"How to package a Mac OS app with Pyinstaller that shows both a console and a GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"New to RabbitMQ and I am trying to determine a way in which to retrieve the routing key information of an AMQP message.  Has anyone really tried this before?  I am not finding a lot of documentation that explicitly states how to query AMQP using pika (python).  \nThis is what I am trying to do:\nbasically I have a Consumer class, for example:\nchannel.exchange_declare(exchange='test', type='topic')\n channel.queue_declare(queue='topic_queue',auto_delete=True)\n channel.queue_bind(queue='topic_queue', exchange='test', routing_key = '#')\nI set up a queue and I bind to an exchange and all the routing_keys (or binding keys I suppose) being passed through that exchange. \nI also have a function:\ndef amqmessage(ch, method, properties, body):\n       channel.basic_consume(amqmessage, queue=queue_name, no_ack=True)\n       channel.start_consuming() \nI think that the routing_key should be \"method.routing_key\" from the amqmessage function but I am not certain how to get it to work correctly.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3298,"Q_Id":24333423,"Users Score":2,"Answer":"I would like to write the answer down because it this question was before the documentation on google. \ndef amqmessage(ch, method, properties, body):\n       channel.basic_consume(amqmessage, queue=queue_name, no_ack=True)\n       channel.start_consuming()\nThe routing key can be found with:method.routing_key","Q_Score":5,"Tags":"python,amqp,pika","A_Id":41400921,"CreationDate":"2014-06-20T18:22:00.000","Title":"Retrieving AMQP routing key information using pika","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"It seems to me the buffer protocol is more for exposing Python buffer to C.\nI couldn't find a way to create a bytes object using existing buffer without copying in C.\nBasically what I want is to implement something similar to PyBytes_FromStringAndSize() but without copying, and with a callback to free the buffer when the object is released. I don't know how big the buffer is before I receive the buffer returned from a C API. So creating bytes object in Python first and later fill it in is not an option.\nI also looked into memoryview, PyMemoryView_FromMemory() doesn't copy but there is no way to pass a callback to free my buffer. And I'm not suse Python lib (e.g. Psycopg) can use memoryview object or not.\nDo I have to create my own object to achieve these 2 requirements? Any other shortcut?\nIf I have to, how can I make sure this object works same as bytes so I can pass it to Python lib safely?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":444,"Q_Id":24336655,"Users Score":1,"Answer":"The only way to do this is to create a new object with PyBufferProcs* PyTypeObject.tp_as_buffer. I checked cpython source code thoroughly, as of 3.4.1, there is no out-of-box (so to speak) solution.","Q_Score":7,"Tags":"python-3.x,python-c-api,python-c-extension","A_Id":26024351,"CreationDate":"2014-06-20T22:38:00.000","Title":"python c-api: create bytes using existing buffer without copying","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a simple Flask web application. I use Eclipse\/Pydev. When I'm working on the app, I have to restart this app very often because of code changes. And that's the problem. When I run the app, I can see the frame on my localhost, which is good. But when I want to close this app, just click on the red square which should stop applications in Eclipse, sometimes (often), the old version of application keeps running so I can't test the new version. In this case the only thing which helps is to force close every process in Windows Task Manager.\nWill you give me any advice how to manage this problem? Thank you in advance.\nEDIT: This maybe helps: Many times, I have to run the app twice. Otherwise I can't connect.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3981,"Q_Id":24349335,"Users Score":0,"Answer":"I've had a very similar thing happen to me. I was using CherryPy rather than Flask, but my solution might still work for you. Oftentimes browsers save webpages locally so that they don't have to re-download them every time the website is visited. This is called caching, and although it's very useful for the average web user, it can be a real pain to app developers. If you're frequently generating new versions of the application, it's possible that your browser is displaying an old version of the app that it has cached instead of the most up to date version. I recommend clearing that cache every time you restart your application, or disabling the cache altogether.","Q_Score":3,"Tags":"python,eclipse,web-applications,flask,pydev","A_Id":24350506,"CreationDate":"2014-06-22T08:07:00.000","Title":"Python\/Flask: Application is running after closing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm used to having a remote server I can use via ssh but I am looking at using Amazon Web Services for a new project to give me better performance and resilience at reduced costs but I'm struggling to understand how to  use it.\nThis is what I want to do:\nFirst-time:\n\nCreate a Postgres db\nConnect to Amazon Server\nDownload code to server\n\nOnce a month:\n\nDownload large data file to server\nRun code (written in python) to load database with data\nRun code (written in Java) to create a Lucene Search Index file from data in the database\n\nContinuously:\n\nRun Java code in servlet container, this will use lucense search index file but DOES NOT require access to the database.\n\nNote: Technically I could create do the database population locally the trouble is the resultant lucene index file is about 5GB and I dont have a good enough Internet connection \nto upload a file of that size to Amazon.\nAll that I have managed to do so far is create a Postgres database but I don't understand how to connect to it or get a ssh\/telnet connection to my server (I requested a Direct Connect but this seems to be a different service).\nUpdate so far\nFYI:\n\nSo I created a Postgres database using RDS\nI created a Ubuntu linux installation using EC2\nI connected to the linux installation using ssh\nI installed required software (using apt-get)  \nI downloaded data file to my linux installation\n\nI think according to the installation should be able to connect to my Postgres db from my EC2 instance and even from my local machine however in both cases it just times out.\n* Update 2 **\nProbably security related but I cannot for the life of me understand what I'm meant to do with security groups ands why they don't make the EC2 instance able to talk to my database by default.\nIve checked both RDS and EC2 have the3 same vpc id, and both are in the same availability zone. Postgres is using port 5432 (not 3306) but havent been able to access it yet. So taking my working EC2 instance as the starting point should I create a new security group before creating a database, and if so what values do I need to put into it so I can access the db with psql from within my ec2 ssh session - thats all that is holding me up for now and all I need to do \n* Update 3 *\nAt last I have access to my database, my database had three security groups ( I think the other two were created when I created a new EC2 instance) I removed two of them and in the remaining on the inbound tab I set rule to\n\nAll Traffic\nPorts 0-65535\nProtocol All\nIPAddress 0.0.0.0\/0\n\n(The outbound tab already had the same rule) and it worked !\nI realize this is not the most secure setup but at least its progress.\nI assume to only allow access from my EC2 instance I can change the IPAddress of the inbound rule but I don't how to calculate the CIDR for the ipaddress ?\nMy new problem is having successfully downloaded my datafile to my EC2 instance I am unable to unzip it because I don't not have enough diskspace. I assume I have to use S3 Ive created a bucket but how do I make it visible as diskspace from my EC2 instance so I can\n\nMove my datafile to it\nUnzip the datafile into it\nRun my code against the unzipped datafile to load the database\n\n(Note the datafile is an Xml format and has to be processed with custom code to get it into the database it cannot just be loaded directly into the database using some generic tool)  \nUpdate 4\nS3 is the wrong solution for me instead I can use EBS which is basically disc storage accessible not as a service but by clicking Volumes in EC2 Console. Ensure create the volume in the same Availability zone as the instance, there maybe more than one in each location, for example my EC2 instance was created in eu-west-1a but the first time I created a volume it was in eu-west-1b and therefore could not be used.\nThen attach volume to instance\nBut I cannot see the volume from the linux commandline, seems there is something else required.\nUpdate 5\nOkay, have to format the disk and mount it in linux for it to work\nI now have my code for uploading the data to database working but it is running incredibly slow, much slower than my cheap local server I have at home. I'm guessing that because the data is being loaded one record at a time that the bottleneck is not the micro database but my micro instance, looks like I need to redo with a more expensive instance\nUpdate 6\nUpdated to a large Computative instance still very slow. Im now thinking the issue is the network latency between server and database perhaps need to install a postgres server directly onto my instance to cut that part out.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":186,"Q_Id":24367485,"Users Score":0,"Answer":"First-time:\nCreate a Postgres db - Depending on size(small or large), might want RDS or Redshift\nConnect to Amazon Server - EC2\nDownload code to server - upload your programs to an S3 bucket\nOnce a month:\nDownload large data file to server - Move data to S3, if using redshift data can be loaded directly from s3 to redshift\nRun code (written in python) to load database with data \nRun code (written in Java) to create a Lucene Search Index file from data in the database - might want to look into EMR with this\nContinuously:\nRun Java code in servlet container, this will use lucense search index file but DOES NOT require access to the database - If you have a java WAR file, you can host this using Elasticbean stalk\nIn order to connect to your database, you must make sure the security group allows for this connection, and for an ec2 you must make sure port 22 is open to your IP to conncet to it. It sounds like the security group for RDS isn't opening up port 3306.","Q_Score":0,"Tags":"java,python,amazon-web-services,amazon-ec2","A_Id":24373021,"CreationDate":"2014-06-23T13:40:00.000","Title":"How do i get started with Amazon Web Services for this scenario?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using FormView with ModelForm to process a registration form. In case of duplication of email i'm raising ValidationError. But this error message is not available on registration template as non_field_errors.\nWhen i tried to find what is the form.errors in form_invalid method in RegistrationView, its showing the expected the errors, but somehow its not getting passed to template.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1090,"Q_Id":24371646,"Users Score":1,"Answer":"First of all, We will have to make sure if its a non_field_error or a field error.\nWhere have you raise ValidationError in the ModelForm you have defined ?\n\nIf its raised in def clean() of the Form, then it would be present in non_field_errors and can be accessed via form.non_field_errors in template\nIf it is raised in def clean_<field_name>() then, it would be a field error and can be accessed via form.errors or form.<field_name>.error  in template\n\nPlease decide for yourself where do you want to raise it.\nNote: ModelForm can work with with FormView. But Ideally, there are CreateView and UpdateView for that","Q_Score":0,"Tags":"django,python-2.7,django-forms,django-templates,django-views","A_Id":24379552,"CreationDate":"2014-06-23T17:17:00.000","Title":"How to get non_field_errors on template when using FormView and ModelForm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am new to python and trying to add a project folder to the PYTHONPATH. I created a .pth file and add my root path of the file in my site-packages folder. However, when I trying to import the .py files in this folder, only those located under the root folder (for example '\/sample') can be imported, but those subfolders under the \/sample folder were not able to be imported (for example \/sample\/01). So my question is what file and how to change it to make my whole folder including all its subfolders can be importable.\nIn the worst case I can think of is to write down all the folders name in the .pth file in site-packages. But I just believe that Python will provide a more efficient way to achieve that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":287,"Q_Id":24376961,"Users Score":0,"Answer":"I haven't had occasion to ever use a .pth file. I prefer a two-pronged approach:\n\nUse a shebang which runs env python, so it uses the first python on your path, i.e.:\n\n#!\/usr\/bin\/env python\n\nUse virtualenv to keep separate different environments and group the necessary libraries for any given program\/program set together. This has the added benefit that the requirements file (from pip freeze output) can be stored in source control, and the environment can be recreated easily anywhere, such as for use with Jenkins tests, et al.\n\nIn the virtualenv case the python interpreter can be explicitly invoked from the virtualenv's bin directory.\nFor local modules in this case, a local PyPI server can be used to centralize custom modules, and they can also be included in the requirements file (via the --extra-index  option of pip).\nEdit with response to comment from OP:\nI have not used SublimeREPL before, however, based on the scenario you have described, I think the overall simplest approach might be to simply symlink the directories into your site-packages (or dist-packages, as the case may be) directory.\nIt's not an ideal scenario for a production server, but for your purposes, on a client box, I think it would be fine. If you don't want to have to use the folder name, i.e. import ch1\/foo, you'll need to symlink inside of those directories so you can simply import foo. If you're OK with using the dir name, i.e. import ch1\/foo, then you should only need to symlink the top-level code directory.","Q_Score":0,"Tags":"python,import,pythonpath","A_Id":24377167,"CreationDate":"2014-06-24T01:18:00.000","Title":"How to use PYTHONPATH to import the whole folder in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't connect with mysql and I can't do \"python manage.py syncdb\" on it\nhow to connect with mysql in django and django-cms without any error?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":9227,"Q_Id":24380269,"Users Score":3,"Answer":"This is an error message you get if MySQLdb isn't installed on your computer.\nThe easiest way to install it would be by entering pip install MySQL-python into your command line.","Q_Score":1,"Tags":"python,mysql,django,django-cms","A_Id":24380525,"CreationDate":"2014-06-24T06:59:00.000","Title":"Getting \u201cError loading MySQLdb module: No module named MySQLdb\u201d in django-cms","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to Django and I'm trying to create a simple app!\nI basically want to create something like StackOverflow, I have many User and many Question. I don't know how I should define the relationship between these two Models. \nMy Requirements:\n\nI want each Question to have a single author User, and a list of User that followed the Question.\nI want each User to have a list of posted Question and a list of followed Question.\n\nI'm pretty much lost, and I don't know how to define my relationship. Is this a many-to-many relationship? If so, how do I have like 2 lists of Question in my User model (Posted\/Followed)?\nPlease help!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":85,"Q_Id":24396591,"Users Score":3,"Answer":"To do this, I would recommend breaking down each individual relationship. Your relationships seem to be:\n\nAuthoring\nFollowing\n\nFor authoring, the details are:\n\nEach Question is authored by one User\nEach User can author many questions\n\nAs such, this is a One-to-Many relationship between the two. The best way to do this is a foreign key from the Question to the User, since there can only be one author.\nFor following, the details are:\n\nEach Question can have many following Users\nEach User can be following many Questions\n\nAs such, this is a Many-to-Many relationship. The Many-to-Many field in Django is a perfect candidate for this. Django will let you use a field through another model, but in this case this is not needed, as you have no other information associated with the fact that a user is following a question (e.g. a personal score\/ranking).\nWith both of these relationships, Django will create lists of related items for you, so you do not have to worry about that. You may need to define a related_name for this field, as there are multiple users associated with a question, and by default django would make the related set for both named user_set.","Q_Score":2,"Tags":"python,sql,django","A_Id":24396885,"CreationDate":"2014-06-24T21:25:00.000","Title":"Define models in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using scikit to perform text classification and I'm trying to understand where the points lie with respect to my hyperplane to decide how to proceed. But I can't seem to plot the data that comes from the CountVectorizer() function. I used the following function: pl.scatter(X[:, 0], X[:, 1]) and it gives me the error: ValueError: setting an array element with a sequence.\nAny idea how to fix this?`","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":24400012,"Users Score":0,"Answer":"If X is a sparse matrix, you probably need X = X.todense() in order to get access to the data in the correct format. You probably want to check X.shape before doing this though, as if X is very large (but very sparse) it may consume a lot of memory when \"densified\".","Q_Score":0,"Tags":"python,numpy,matplotlib,scikit-learn","A_Id":24424870,"CreationDate":"2014-06-25T04:05:00.000","Title":"How to plot text documents in a scatter map?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using pandas to organize and manipulate data I am getting from the twitter API. The 'id' key returns a very long integer (int64) that pandas has no problem handling (i.e. 481496718320496643). \nHowever, when I send to SQL:\ndf.to_sql('Tweets', conn, flavor='sqlite', if_exists='append', index=False)\nI now have tweet id: 481496718320496640 or something close to that number.\nI converted the tweet id to str but Pandas SQLite Driver \/ SQLite still messes with the number. The data type in the SQLite database is [tweet_id] INTEGER. What is going on and how do I prevent this from happening?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":24416140,"Users Score":0,"Answer":"I have found the issue -- I am using SQLite Manager (Firefox Plugin) as a SQLite client. For whatever reason, SQLite Manager displays the tweet IDs incorrectly even though they are properly stored (i.e. when I query, I get the desired values). Very strange I must say. I downloaded a different SQLite client to view the data and it displays properly.","Q_Score":0,"Tags":"python,sqlite,pandas","A_Id":24419432,"CreationDate":"2014-06-25T18:39:00.000","Title":"Long integer values in pandas dataframe change when sent to SQLite database using to_sql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on an online multiplayer game. I already developed the login servers and database for any persistent storage; both are written in Python and will be hosted with Google's App Engine. (For now.)\nI'm relatively comfortable with two languages - Java and Python. I'd like to write the actual gameplay server in one of those languages, and I'd like for the latency of the client to gameplay-server connection to be as low as possible, so I assume that the majority of gameplay data (e.g. fine player movements) will need to be sent via UDP connections. I'm unfamiliar with UDP connections so I really don't know where to begin designing the server.\nHow should the server be threaded? One thread per client connection that retains session info, and then a separate thread(s) to control autonomous world changes (NPCs moving, etc.)?\nHow should relatively large packets be transmitted? (e.g. ~25 nearby players and all of their gameplay data, usernames, etc.) TCP or UDP?\nLastly - is it safe for the gameplay server to interface with the login server via HTTP requests, how do I verify (from the login server's perspective) the gameplay server's identity - simple password, encryption?\nDidn't want to ask this kind of question because I know they're usually flagged as unproductive - which language would be better for me (as someone inexperienced with socketing) to write a sufficiently efficient server - assume equal experience with both?\nLastly - if this is relevant - I have not begun development on the client - not sure what my goals for the game itself are yet, I just want the servers to be scalable (up to ~150 players, beyond that I expect and understand that major rewrite will probably be necessary) and able to support a fair amount of players and open-world style content. (no server-taxing physics or anything like that necessary)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1168,"Q_Id":24417793,"Users Score":1,"Answer":"\"I assume that the majority of gameplay data (e.g. fine player\n  movements) will need to be sent via UDP connections. I'm unfamiliar\n  with UDP connections so I really don't know where to begin designing\n  the server.\"\n\nUDP can be lower latency, but sometimes, it is far more important that packets aren't dropped in a game.  If it makes any difference to you, World of Warcraft uses TCP.  If you chose to use UDP, you would have to implement something to handle dropped packets.  Otherwise, what happens if a player uses an important ability (Such as a spell interrupt or a heal) and the packet gets dropped?  You COULD use both UDP and TCP to communicate different things, but that adds a lot of complexity.  WoW uses only a single port for all gameplay traffic, plus a UDP port for the in-game voice chat that nobody actually uses.\n\n\"How should the server be threaded? One thread per client connection that retains session info, and then a separate thread(s) to control autonomous world changes (NPCs moving, etc.)?\"\n\nOne thread per client connection can end up with a lot of threads, but would be a necessity if you use synchronous sockets.  I'm not really sure of the best answer for this.\n\n\"How should relatively large packets be transmitted? (e.g. ~25 nearby players and all of their gameplay data, usernames, etc.) TCP or UDP?\"\n\nThis is what makes MMORPG servers so CPU and bandwidth intense.  Every action has to be relayed to potentially dozens of players, possibly hundreds if it scales that much.  This is more of a scaling issue than a TCP vs UDP issue.  To be honest, I wouldn't worry much about it unless your game catches on and it actually becomes an issue.\n\n\"Lastly - is it safe for the gameplay server to interface with the login server via HTTP requests, how do I verify (from the login server's perspective) the gameplay server's identity - simple password, encryption?\"\n\nYou could easily use SSL.\n\n\"Lastly - if this is relevant - I have not begun development on the client - not sure what my goals for the game itself are yet, I just want the servers to be scalable (up to ~150 players, beyond that I expect and understand that major rewrite will probably be necessary) and able to support a fair amount of players and open-world style content. (no server-taxing physics or anything like that necessary)\"\n\nI wouldn't use Python for your server.  It is horrendously slow and won't scale well.  It's fine for web servers and applications where latency isn't too much of an issue, but for a real-time game server handling 100+ players, I'd imagine it would fall apart.  Java will work, but even THAT will run into scaling issues before a natively coded server does.  I'd use Java to rapidly prototype the game and get it working, then consider a rewrite in C\/C++ to speed it up later.\nAlso, something to consider regarding Python...if you haven't read about the Global Interpreter Lock, I'd make sure to do that.  Because of the GIL, Python can be very ineffective at multithreading unless you're making calls to native libraries.  You can get around it with multiprocessing, but then you have to deal with the overhead of communication between processes.","Q_Score":0,"Tags":"java,python,multithreading,sockets,udp","A_Id":24419007,"CreationDate":"2014-06-25T20:18:00.000","Title":"Structuring a server for an online multiplayer game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using Eclipse Indigo for python coding.\nWhen I comment something, I want the color of the comment to be blue\nhow can I achieve?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":442,"Q_Id":24446884,"Users Score":1,"Answer":"Assuming you use the PyDev plug-in you can access the color settings in the Window\/Preferences\/PyDev\/Editor menu.","Q_Score":0,"Tags":"python,eclipse,syntax-highlighting","A_Id":24447038,"CreationDate":"2014-06-27T08:03:00.000","Title":"Changing python syntax coloring in eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to automate emails using python. Unfortunately, the network administrators at my work have blocked SMTP relay, so I cannot use that approach to send the emails (they are addressed externally).\nI am therefore using win32com to automatically send these emails via outlook. This is working fine except for one thing. I want to choose the \"FROM\" field within my python code, but I simply cannot figure out how to do this.\nAny insight would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2282,"Q_Id":24454538,"Users Score":5,"Answer":"If you configured a separate POP3\/SMTP account, set the MailItem.SendUsingAccount property to an account from the Namespace.Accounts collection.\nIf you are sending on behalf of an Exchange user, set the MailItem.SentOnBehalfOfName property","Q_Score":3,"Tags":"python,outlook,win32com","A_Id":24454678,"CreationDate":"2014-06-27T14:39:00.000","Title":"Choosing \"From\" field using python win32com outlook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value.\nHowever, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make? \nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":767,"Q_Id":24491143,"Users Score":0,"Answer":"The simplest way to select your move is to choose your move that has the maximum number of winning positions stemming from that move.\nI would, for each node in your search tree (game state) keep a record of possible win states that can be created by the current game state.","Q_Score":0,"Tags":"python,algorithm,minimax","A_Id":24496933,"CreationDate":"2014-06-30T13:22:00.000","Title":"How to Get Move From Minimax Algorithm in Tic-Tac-Toe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value.\nHowever, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make? \nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":767,"Q_Id":24491143,"Users Score":0,"Answer":"In using the MM algorithm, you must have had a way to generate the possible successor boards; each of those was the result of a move.  As has been suggested, you can modify your algorithm to include tracking of the move that was used to generate a board (for example, adding it to the definition of a board, or using a structure that has the board and the move); or, you could have a special case for the top level of the algorithm, since that is the only one in which the particular move is important.\nFor example, if your function currently returns just the computed value of the board it was passed, it could instead return a dict (or tuple, which isn't as clear) with both the value and the first move used to obtain that value, and then modify your code to use whichever bit is needed.","Q_Score":0,"Tags":"python,algorithm,minimax","A_Id":24491647,"CreationDate":"2014-06-30T13:22:00.000","Title":"How to Get Move From Minimax Algorithm in Tic-Tac-Toe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value.\nHowever, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make? \nThanks.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":767,"Q_Id":24491143,"Users Score":0,"Answer":"Conceptualize the minimax algorithm like a graph, where every vertex is a possible configuration of the board, and every edge from a vertex to its neighbor is a transition\/move from one board configuration to the next.\nYou need to look at the heuristic value of each board state neighboring your current state, then choose the state with the best heuristic value, then update your screen to show that board state.\nIf you are doing animations\/transitions between board states, then you would have to look at the edge and figure out which piece is different between the two states, and animate that piece accordingly.","Q_Score":0,"Tags":"python,algorithm,minimax","A_Id":24491495,"CreationDate":"2014-06-30T13:22:00.000","Title":"How to Get Move From Minimax Algorithm in Tic-Tac-Toe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I initiate a request client-side, then I change my mind and call xhr.abort().  \nHow does Django react to this?  Does it terminate the thread somehow?  If not, how do I get Django to stop wasting time trying to respond to the aborted request?  How do I handle it gracefully?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1318,"Q_Id":24497239,"Users Score":-1,"Answer":"Just think of the Web as a platform for building easy-to-use, distributed, loosely couple systems, with no guarantee about the availability of resources as 404 status code suggests.\nI think that creating tightly coupled solutions such as your idea is going against web principles and usage of REST. xhr.abort() is client side programming, it's completely different from server side. It's a bad practice trying to tighten client side technology to server side internal behavior.\nNot only this is a waste of resources, but also there is no guarantee on processing status of the request by web server. It may lead to data inconsistency too.\nIf your request generates no server-side side effects for which the client\ncan be held responsible. It is better just to ignore it, since these kind of requests does not change server state & the response is usually cached for better performance.\nIf your request could cause changes in server state or data, for the sake of data consistency you can check whether the changes have taken effect or not using an API. In case of affection try to rollback using another API.","Q_Score":11,"Tags":"python,ajax,django","A_Id":32511257,"CreationDate":"2014-06-30T19:10:00.000","Title":"How do I terminate a long-running Django request if the XHR gets an abort()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I initiate a request client-side, then I change my mind and call xhr.abort().  \nHow does Django react to this?  Does it terminate the thread somehow?  If not, how do I get Django to stop wasting time trying to respond to the aborted request?  How do I handle it gracefully?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1318,"Q_Id":24497239,"Users Score":1,"Answer":"Due to how http works and that you usually got a frontend in front of your django gunicorn app processes (or uswgi etc), your http cancel request is buffered by nginx. The gunicorns don't get a signal, they just finish processing and then output whatever to the http socket. But if that socket is closed it will have an error (which is caught as a closed connection and move one).\nSo it's easy to DOS a server if you can find a way to spawn many of these requests.\nBut to answer your question it depends on the backend, with gunicorn it will keep going until the timeout.","Q_Score":11,"Tags":"python,ajax,django","A_Id":52607897,"CreationDate":"2014-06-30T19:10:00.000","Title":"How do I terminate a long-running Django request if the XHR gets an abort()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm attempting to store information from a decompiled file in Dynamo.\nI have all of the files stored in s3 however I would like to change some of that.\nI have an object id with properties such as a date, etc which I know how to create a table of in dynamo. My issue is that each object also contains images, text files, and the original file. I would like to have the key for s3 for the original file in the properties of the file:\nEx: FileX, date, originalfileLoc, etc, images pointer, text pointer.\nI looked online but I'm confused how to do the nesting. Does anyone know of any good examples? Is there another way? I assume I create an images and a text table. Each with the id and all of the file's s3 keys. Any example code of how to create the link itself?  \nI'm using python boto btw to do this.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":477,"Q_Id":24520176,"Users Score":0,"Answer":"From what you described, I think you just need to create one table with hashkey. The haskey should be object id. And you will have columns such as \"date\", \"image pointer\", \"text pointer\", etc.\nDynamoDB is schema-less so you don't need to create the columns explicitly. When you call getItem the server will return you a dictionary with column name as key and the value.\nBeing schema-less also means you can create new column dynamically. Assuming you already have a row in the table with only \"date\" column. now you want to add the \"image pointer\" column. you just need to call UpdateItem and gives it the hashkey and image-pointer key-value pair.","Q_Score":0,"Tags":"python,database,amazon-s3,amazon-dynamodb,boto","A_Id":24642053,"CreationDate":"2014-07-01T22:25:00.000","Title":"How to correctly nest tables in DynamoDb","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm attempting to store information from a decompiled file in Dynamo.\nI have all of the files stored in s3 however I would like to change some of that.\nI have an object id with properties such as a date, etc which I know how to create a table of in dynamo. My issue is that each object also contains images, text files, and the original file. I would like to have the key for s3 for the original file in the properties of the file:\nEx: FileX, date, originalfileLoc, etc, images pointer, text pointer.\nI looked online but I'm confused how to do the nesting. Does anyone know of any good examples? Is there another way? I assume I create an images and a text table. Each with the id and all of the file's s3 keys. Any example code of how to create the link itself?  \nI'm using python boto btw to do this.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":477,"Q_Id":24520176,"Users Score":0,"Answer":"If you stay between the limits of Dynamodb of 64Kb per item.\nYou can have one item (row) per file.\nDynamoDB has String type (for file name, date, etc) and also a StringSet (SS) for list of attributes (for text files, images).\nFrom what you write I assume you are will only save pointers (keys) to binary data in the S3. \nYou could also save binary data and binary sets in DynamoDB but I believe you will reach the limit AND have an expensive solution in terms of throughput.","Q_Score":0,"Tags":"python,database,amazon-s3,amazon-dynamodb,boto","A_Id":24536208,"CreationDate":"2014-07-01T22:25:00.000","Title":"How to correctly nest tables in DynamoDb","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently started to learn Python 3 and have run into an issue while trying to learn how to debug using IDLE. I have created a basic program following a tutorial, which then explains how to use the debugger. However, I keep running into an issue while stepping through the code, which the tutorial does not explain (I have followed the instructions perfectly) nor does hours of searching on the internet. Basically if I step while already inside a function, usually following print() the debugger steps into pyshell.py, specifically, PyShell.py:1285: write() if i step out of pyshell, the debugger will simple step back in as soon as I try to move on, if this is repeated the step, go, etc buttons will grey out.\nAny help will be greatly appreciated.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":24535601,"Users Score":0,"Answer":"pyshell.py file opens during the debugging process when the function that is under review is found in Python's library - for example print() or input(). If you want to bypass this file\/process click Over and it will step over this review of the function in Python's library.","Q_Score":0,"Tags":"python,debugging,python-idle","A_Id":28057981,"CreationDate":"2014-07-02T15:48:00.000","Title":"Python 3 Debugging issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently started to learn Python 3 and have run into an issue while trying to learn how to debug using IDLE. I have created a basic program following a tutorial, which then explains how to use the debugger. However, I keep running into an issue while stepping through the code, which the tutorial does not explain (I have followed the instructions perfectly) nor does hours of searching on the internet. Basically if I step while already inside a function, usually following print() the debugger steps into pyshell.py, specifically, PyShell.py:1285: write() if i step out of pyshell, the debugger will simple step back in as soon as I try to move on, if this is repeated the step, go, etc buttons will grey out.\nAny help will be greatly appreciated.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":24535601,"Users Score":0,"Answer":"In Python 3.4, I had the same problem. My tutorial is from Invent with Python by Al Sweigart, chapter 7.\nNew file editor windows such as pyshell.py and random.pyopen when built-in functions are called, such as input(), print(), random.randint(), etc. Then the STEP button starts stepping through the file it opened.\nIf you click OVER, you will have to click it several times, but if you click OUT, pyshell.py will close immediately and you'll be back in the original file you were trying to debug. \nAlso, I encountered problems confusing this one--the grayed-out buttons you mentioned--if I forgot to click in the shell and give input when the program asked. I tried Wing IDE and it didn't run the program correctly, although the program has no bugs. So I googled the problem, and there was no indication that IDLE is broken or useless.\nTherefore, I kept trying till the OUT button in the IDLE debugger solved the problem.","Q_Score":0,"Tags":"python,debugging,python-idle","A_Id":28735903,"CreationDate":"2014-07-02T15:48:00.000","Title":"Python 3 Debugging issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to do an image processing in python. i want to use wavelet transform as the filterbank. Can anyone suggest me which one library should i use? \nI had pywavelet installed, but i don't know how to combine it with opencv. If i use wavedec2 command, it raise ValueError(\"Expected 2D input data.\")\nCan anyone help me?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":11865,"Q_Id":24536552,"Users Score":5,"Answer":"Answer of Navaneeth is correct but with two correction:\n1- Opencv read and save the images as BGR not RGB so you should do cv2.COLOR_BGR2GRAY to be exact.\n2- Maximum level of _multilevel.py is 7 not 10, so you should do : w2d(\"test1.png\",'db1',7)","Q_Score":7,"Tags":"python,opencv,image-processing,dwt","A_Id":45240779,"CreationDate":"2014-07-02T16:36:00.000","Title":"How to Combine pyWavelet and openCV for image processing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"While browsing the code in PyCharm(community edition) how to go back to the previously browsed section? I am looking for eclipse back button type functionality with Pycharm.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":17353,"Q_Id":24548398,"Users Score":7,"Answer":"Ubuntu 16.04 defines Ctrl + Alt + Left as a workspace switch shortcut\nThen it does nothing on Pycharm.\nSo you have to either disable the Ubuntu shortcut with:\n\ndash\nkeyboard\nshortcuts\nnavigation\n\nor redefine the PyCharm shortcuts to something else.\nLinux distro desktop devs: please make all desktop system wide shortcuts contain the Super key.","Q_Score":37,"Tags":"python,intellij-idea,pycharm,intellij-plugin","A_Id":45478266,"CreationDate":"2014-07-03T08:15:00.000","Title":"How to go back in PyCharm while browsing code like we have a back button in eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed django-page-cms successfully i think. Like other cms, it is also for creating new pages. But I already have html pages in my project. How to integrate with that? \nThey want me to put place holder in html page, like:\n\n{% load pages_tags %}\n\nbut I think this will bring the content from the already created page in admin\nCan anyone tell me how to integrate with my existing pages?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":64,"Q_Id":24552964,"Users Score":0,"Answer":"First you need to create page in admin console. Then add the placeholder in your template\nlike what tutorial saying \n\n{% get_page \"news\" as news_page %}\n\n  {% for new in news_page.get_children %}\n<li>\n      {{ new.publication_date }}\n      {% show_content new body %}\n\n  {% endfor %}","Q_Score":0,"Tags":"python,django","A_Id":24554222,"CreationDate":"2014-07-03T11:51:00.000","Title":"integrating with existing html page django-page-cms","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to install SublimeREPL on an offline computer (it has secure data and so can't be Internet-connected). Any ideas for how to do so?\nI can copy any installation files to a USB drive, but haven't found any--everywhere I've seen insists on using the Package Manager (which requires connection to function properly)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1408,"Q_Id":24563782,"Users Score":1,"Answer":"You could try download and install SublimeREPL using Package Control on a computer with an internet connection and then in Sublime Text go to preferences > Browse packages\u2026 where you should find a folder named SublimeREPL. Copy that folder to the same directory on the other computer. That should work.","Q_Score":0,"Tags":"python,sublimerepl","A_Id":24564624,"CreationDate":"2014-07-03T21:48:00.000","Title":"Installing SublimeREPL offline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im using openCV on Ubuntu 14.04, but some of the functions that I require particularly in cv2 library (cv2.drawMatches, cv2.drawMatchesKnn) does not work in 2.4.9. How do I uninstall 2.4.9 and install 3.0.0 from the their git? I know the procedure for installing 3.0.0 but how do I make sure that 2.4.9 get completely removed from disk?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18476,"Q_Id":24598160,"Users Score":3,"Answer":"The procedure depends on whether or not you built OpenCV from source with CMake, or snatched it from a repository.\nFrom repository\nsudo apt-get purge libopencv* will cleanly remove all traces. Substitute libopencv* as appropriate in case you were using an unofficial ppa.\nFrom source\nIf you still have the files generated by CMake (the directory from where you executed sudo make install), cd there and sudo make uninstall. Otherwise, you can either rebuild them with the exact same configuration and use the above command, or recall your CMAKE_INSTALL_PREFIX (\/usr\/local by default), and remove everything with opencv in its name within that directory tree.","Q_Score":5,"Tags":"python,opencv,ubuntu,uninstallation","A_Id":24598296,"CreationDate":"2014-07-06T16:54:00.000","Title":"Unistall opencv 2.4.9 and install 3.0.0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've looked all over the net and found no answer.\nI'm new to Django. I've done the official tutorial and read many more but unfortunately all of them focus on creating only one application. Since it's not common to have a page as a single app, I would like to ask some Django guru to explain how I can have multiple apps on a webpage. Say I go to mysite.com and I see a poll app displaying a poll, gallery app displaying some pics, news app displaying latest news etc, all accessed via one url. I know I do the displaying in template but obviously need to have access to data. Do I create the view to return multiple views? Any advice, links and examples much appreciated.","AnswerCount":5,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":11743,"Q_Id":24622714,"Users Score":11,"Answer":"A django app doesn't really map to a page, rather, it maps to a function.  Apps would be for things like a \"polls\" app or a \"news\" app.  Each app should have one main model with maybe a couple supporting ones.  Like a news app could have a model for articles, with supporting models like authors and media.\nIf you wanted to display multiple, you would need an integration app.  One way to do this is to have a \"project\" app next to your polls and news apps.  The project app is for your specific website- it is the logic that is specific to this application.  It would have your main urls.py, your base templat(s), things like that.  If you needed information from multiple apps in one page, you have to have a view that returns info from multiple apps.  Say, for example, that you have a view that returns the info for a news article, and one that returns info for a poll.  You could have a view in your project app that calls those two view functions and sticks the returned data into a different template that has spots for both of them.\nIn this specific example, you could also have your polls app set up so that its return info could be embedded- and then embed the info into a news article.  In this case you wouldn't really have to link the apps together at all as part of your development, it could be done as needed on the content creation end.","Q_Score":15,"Tags":"python,django","A_Id":24644610,"CreationDate":"2014-07-08T02:16:00.000","Title":"Django - Multiple apps on one webpage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used img2py to convert an image into a .py file. But how to use that converted file in pygame. Is there any specific code for it?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":748,"Q_Id":24639577,"Users Score":2,"Answer":"The PyEmbeddedImage class has a GetData method (or Data property) that can be used to fetch the raw data of the embedded image, in PNG format.","Q_Score":1,"Tags":"wxpython,pygame","A_Id":24644067,"CreationDate":"2014-07-08T18:52:00.000","Title":"How to use\/decompress the file made by img2py","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to python and I'm attempting to run a script provided to me that requires to input the name of a text file to run. I changed my pathing to include the Python directory and my input in the command line - \"python name_of_script.py\" - is seemingly working. However, I'm getting the error: \"the following arguments are required: --input\". This makes sense, as I need this other text file for the program to run, but I don't know how to input it on the command line, as I'm never prompted to enter any input. I tried just adding it to the end of my command prompt line, but to no avail.\nDoes anybody know how this could be achieved?\nThanks tons","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":24663772,"Users Score":0,"Answer":"if you pasted the code here that would help but\nthe answer you are most likely looking for is commandline arguements. \nIf I were to guess, in the command line the input would look something like:\npython name_of_script.py \"c:\\thefilepath\\totheinputfile\" {enter}\n{enter} being the actually key pressed on the keyboard and not typed in as the word\nHopefully this starts you on the right answer :)","Q_Score":0,"Tags":"python,input,command-line,command,command-prompt","A_Id":24663846,"CreationDate":"2014-07-09T21:03:00.000","Title":"Python script requires input in command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm new to python and I'm attempting to run a script provided to me that requires to input the name of a text file to run. I changed my pathing to include the Python directory and my input in the command line - \"python name_of_script.py\" - is seemingly working. However, I'm getting the error: \"the following arguments are required: --input\". This makes sense, as I need this other text file for the program to run, but I don't know how to input it on the command line, as I'm never prompted to enter any input. I tried just adding it to the end of my command prompt line, but to no avail.\nDoes anybody know how this could be achieved?\nThanks tons","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":24663772,"Users Score":0,"Answer":"Without reading your code, I guess if\n\nI tried just adding it to the end of my command prompt line, but to no avail.\n\nit means that you need to make your code aware the command line argument. Unless you do some fancy command line processing, for which you need to import optparse or argparse, try:\nimport sys\n# do something with sys.argv[-1] (ie, the last argument)","Q_Score":0,"Tags":"python,input,command-line,command,command-prompt","A_Id":24665527,"CreationDate":"2014-07-09T21:03:00.000","Title":"Python script requires input in command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a GUI program in Python which calculates graphs of certain functions. These functions are mathematical like say, cos(theta) etc. At present I save the graphs of these functions and compile them to PDF in Latex and write down the equation manually in Latex. \nBut now I wish to simplify this process by creating a template in Latex that arranges, The Function Name, Graph, Equation and Table and complies them to a single PDF format with just a click. \nCan this be done? And how do I do it? \nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2206,"Q_Id":24684316,"Users Score":1,"Answer":"generate a Latex file.tex with a Python script \nf= open(\"file.tex\", 'w')\nf.write('\\documentclass[12pt]{article}\\n')\nf.write('\\usepackage{multicol}\\n')\nf.write('\\n\\begin{document}\\n\\n')\n...\nf.write('\\end{document}')\nf.close()\nrun pdflatex on the LaTex file from the Python script as a subprocess\nsubprocess.call('latex file.tex')\n\nAs an alternative to 1. you can generate a LaTex template and just substitute the variable stuff using Python regular expressions and string substitutions.","Q_Score":0,"Tags":"python,pdf,export,latex,pdflatex","A_Id":24684691,"CreationDate":"2014-07-10T19:00:00.000","Title":"Python Export Program to PDF using Latex format","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Django Rest Framework and I'm having some trouble with permissions.  I know how to use has_permission and has_object_permission, but I have a number of cases where someone needs to be able to access retrieve but not list--e.g., a user has access to their own profile, but not to the full list of them.  The problem is, has_permission is always called before has_object_permission, so has_object_permission can only be more restrictive, not less.\nSo far, the only way I've been able to do this is to have more permissive permissions and then overwrite list() directly in the ViewSet and include the permission check in the logic, but I'd be able to actually store all of this logic in a Permissions class rather than in each individual viewset.\nIs there any way to do this?  Right now I feel like I'm goign to have to write a ViewSet metaclass to automatically apply permissions as I want to each viewset method, which isn't really something I want to do.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":24684821,"Users Score":0,"Answer":"One of the arguments to has_permission is view, which has an attribute .action, which is one of the five \"LCRUD\" actions (\"list\"\/\"create\"\/\"retrieve\"\/\"update\"\/\"destroy\").  So I think you could use that to check, in has_permission, whether the action being performed is a list or a retrieve, and deny or allow it accordingly.","Q_Score":1,"Tags":"python,django,rest,permissions,django-rest-framework","A_Id":27932256,"CreationDate":"2014-07-10T19:32:00.000","Title":"Django Rest Framework--deny access to list but not to retrieve","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I have a categorical feature, color, which takes the values\n['red', 'blue', 'green', 'orange'],\nand I want to use it to predict something in a random forest.  If I one-hot encode it (i.e. I change it to four dummy variables), how do I tell sklearn that the four dummy variables are really one variable?  Specifically, when sklearn is randomly selecting features to use at different nodes, it should either include the red, blue, green and orange dummies together, or it shouldn't include any of them.\nI've heard that there's no way to do this, but I'd imagine there must be a way to deal with categorical variables without arbitrarily coding them as numbers or something like that.","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":72780,"Q_Id":24715230,"Users Score":1,"Answer":"Maybe you can use 1~4 to replace these four color, that is, it is the number rather than the color name in that column. And then the column with number can be used in the models","Q_Score":71,"Tags":"python,scikit-learn,random-forest,one-hot-encoding","A_Id":66810359,"CreationDate":"2014-07-12T16:54:00.000","Title":"Can sklearn random forest directly handle categorical features?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I have a categorical feature, color, which takes the values\n['red', 'blue', 'green', 'orange'],\nand I want to use it to predict something in a random forest.  If I one-hot encode it (i.e. I change it to four dummy variables), how do I tell sklearn that the four dummy variables are really one variable?  Specifically, when sklearn is randomly selecting features to use at different nodes, it should either include the red, blue, green and orange dummies together, or it shouldn't include any of them.\nI've heard that there's no way to do this, but I'd imagine there must be a way to deal with categorical variables without arbitrarily coding them as numbers or something like that.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":72780,"Q_Id":24715230,"Users Score":16,"Answer":"You have to make the categorical variable into a series of dummy variables. Yes I know its annoying and seems unnecessary but that is how sklearn works. \nif you are using pandas. use pd.get_dummies, it works really well.","Q_Score":71,"Tags":"python,scikit-learn,random-forest,one-hot-encoding","A_Id":35471754,"CreationDate":"2014-07-12T16:54:00.000","Title":"Can sklearn random forest directly handle categorical features?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do you drop rows from an RDD in PySpark? Particularly the first row, since that tends to contain column names in my datasets. From perusing the API, I can't seem to find an easy way to do this. Of course I could do this via Bash \/ HDFS, but I just want to know if this can be done from within PySpark.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":49327,"Q_Id":24718697,"Users Score":1,"Answer":"Personally I think just using a filter to get rid of this stuff is the easiest way. But per your comment I have another approach. Glom the RDD so each partition is an array (I'm assuming you have 1 file per partition, and each file has the offending row on top) and then just skip the first element (this is with the scala api).\ndata.glom().map(x => for (elem <- x.drop(1){\/*do stuff*\/}) \/\/x is an array so just skip the 0th index\nKeep in mind one of the big features of RDD's is that they are immutable, so naturally removing a row is a tricky thing to do\nUPDATE:\nBetter solution.\nrdd.mapPartions(x => for (elem <- x.drop(1){\/*do stuff*\/} )\nSame as the glom but doesn't have the overhead of putting everything into an array, since x is an iterator in this case","Q_Score":28,"Tags":"python,apache-spark,pyspark","A_Id":24736966,"CreationDate":"2014-07-13T01:08:00.000","Title":"PySpark Drop Rows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just installed Google Apps Engine and am getting \"could not save\" errors.\nSpecifically if I go in to preferences I get \nCould not save into preference file\nC:\\Usera\\myname\/Google\\google_appengine_launcher.ini:No such file or directory.\nSo some how I have a weird path, would like to know where and how to change this. I have search but found nothing, I have done a repair reinstall of GAE\nCan find nothing in the registry for google_appengine_launcher.ini\nI first saw the error when I created my first Application\nCalled hellowd\nParent Directory: C:\\Users\\myname\\workspace\nRuntime 2.7 (PATH has this path)\nPort 8080\nAdmin port 8080\nclick create\nError: \nCould not save into project file\nC:\\Users\\myname\/Google\\google_appengine_launcher.ini:No such file or directory.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":53,"Q_Id":24729427,"Users Score":0,"Answer":"I think I have found the answer to my own question.\nI have a small app I have written to backup my stuff to Google Drive, this app would appear to have an error in it that does not stop it from running but does cause it to make a file called\n C:\\Usera\\myname\\Google \nTherefore GAE can not create a directory called  C:\\Usera\\myname\/Google nor a file called  C:\\Usera\\myname\/Google\\google_appengine_launcher.ini\nI deleted the file Google, made a directory called Google and ran the GAE, saved pereferences and all working","Q_Score":1,"Tags":"python,google-app-engine","A_Id":24765014,"CreationDate":"2014-07-14T04:13:00.000","Title":"could not save preference file google-apps-engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"for example if my input was \"1 2 3\", how do I check if each part is a integer and not anything else and if there was something else, be able to input the string again so its correct otherwise it wont move on","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":917,"Q_Id":24735926,"Users Score":0,"Answer":"You can split you string to a list using\n     list1=s.split()\nAnd then check wether each of them is a integer or not.","Q_Score":0,"Tags":"python","A_Id":24736026,"CreationDate":"2014-07-14T11:49:00.000","Title":"In Python, If I split a string up, how do i check if each part of it is an integer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to see installed Python packages using pip, just use pip freeze. But is there any way to see the date and time when package is installed or updated with pip?","AnswerCount":7,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36060,"Q_Id":24736316,"Users Score":0,"Answer":"pip freeze gives you all the installed packages. Assuming you know the folder:\ntime.ctime(os.path.getctime(file)) \nshould give you the creation time of a file, i.e. date of when the package has been installed or updated.","Q_Score":41,"Tags":"python,installation,pip,package","A_Id":24736486,"CreationDate":"2014-07-14T12:13:00.000","Title":"See when packages were installed \/ updated using pip","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"C++ programmer here. \nIn Python, how do you make sure that a particular class (e.g. UsefulClass) can only be created through its related factory class (e.g. FactoryClass)? But, at the same time the public methods of UsefulClass are callable directly?\nIn C++ this can be easily achieved by making the relevant methods of UsefulClass public, and by making its default constructor (and any other constructors) private. The related FactoryClass (which can be a \"friend\" of the UsefulClass) can return instances of UsefulClass and thereby strictly controlling creation, while allowing the user to directly call the public methods of UsefulClass.\nThanks.","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":136,"Q_Id":24737909,"Users Score":-2,"Answer":"Don't.\nPython is not C++ and using patterns that worked before are silly in Python. In particular, Python is not a \"Bondage and Domination\" language where phrases like \"thereby strictly controlling creation\" don't apply.\n\"If you didn't want to instantiate a UsefulClass then why did you?\" \u2014 me.\nIf you can't trust yourself or your colleagues to read and follow the code's internal documentation, you're screwed regardless of the implementation language.","Q_Score":0,"Tags":"python","A_Id":24739463,"CreationDate":"2014-07-14T13:43:00.000","Title":"Only creating object through factory class in Python - factory class related","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the \"Project Interpreter\" page. Even after installing the Python plugin, I don't see that setting anywhere.\nAm I missing something obvious?","AnswerCount":5,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":74300,"Q_Id":24769117,"Users Score":160,"Answer":"With the Python plugin installed:\n\nNavigate to File > Project Structure.  \nUnder the Project menu for Project SDK, select \"New\" and \nSelect \"Python SDK\", then select \"Local\".  \n\nProvided you have a Python SDK installed, the flow should be natural from there - navigate to the location your Python installation lives.","Q_Score":115,"Tags":"python,intellij-idea","A_Id":24769264,"CreationDate":"2014-07-15T22:18:00.000","Title":"How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the \"Project Interpreter\" page. Even after installing the Python plugin, I don't see that setting anywhere.\nAm I missing something obvious?","AnswerCount":5,"Available Count":3,"Score":0.0798297691,"is_accepted":false,"ViewCount":74300,"Q_Id":24769117,"Users Score":2,"Answer":"Follow these steps:\n\nOpen Setting (Ctrl + Alt + s)\nClick on plugins\nFind Browse Repositories and click\nSearch for \"python\"\nSelect Python SDK or pycharm\nRestart the IDE\nGo to project structure\nSelect the python SDK in projects or create a new project with python SDK.","Q_Score":115,"Tags":"python,intellij-idea","A_Id":44602198,"CreationDate":"2014-07-15T22:18:00.000","Title":"How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the \"Project Interpreter\" page. Even after installing the Python plugin, I don't see that setting anywhere.\nAm I missing something obvious?","AnswerCount":5,"Available Count":3,"Score":0.1194272985,"is_accepted":false,"ViewCount":74300,"Q_Id":24769117,"Users Score":3,"Answer":"If you have multiple modules in your project, with different languages, you can set the interpreter in the following way:\n\nFile -> Project Structure...\nSelect Modules in the list on the left\nSelect the Python module in the list of modules\nOn the right-hand side, either choose an existing Python SDK from the dropdown list, or click on the New... button to create either a virtualenv, or create a new Python SDK from a Python installation on your system.","Q_Score":115,"Tags":"python,intellij-idea","A_Id":56439498,"CreationDate":"2014-07-15T22:18:00.000","Title":"How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm fairly competent with Python but I've never 'uploaded code' to a server before and have it run automatically. \nI'm working on a project that would require some code to be running 24\/7. At certain points of the day, if a criteria is met, a process is started. For example: a database may contain records of what time each user wants to receive a daily newsletter (for some subjective reason) - the code would at the right time of day send the newsletter to the correct person. But of course, all of this is running out on a Cloud server. \nAny help would be appreciated - even correcting my entire formulation of the problem! If you know how to do this in any other language - please reply with your solutions!\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":262,"Q_Id":24769574,"Users Score":1,"Answer":"Here are two approaches to this problem, both of which require shell access to the cloud server. \n\nWrite the program to handle the scheduling itself. For example, sleep and wake up every few miliseconds to perform the necessary checks. You would then transfer this file to the server using a tool like scp, login, and start it in the background using something like python myscript.py &.\nWrite the program to do a single run only, and use the scheduling tool cron to start it up every minute of the day.","Q_Score":1,"Tags":"python,cloud","A_Id":24769619,"CreationDate":"2014-07-15T23:02:00.000","Title":"Uploading code to server and run automatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm fairly competent with Python but I've never 'uploaded code' to a server before and have it run automatically. \nI'm working on a project that would require some code to be running 24\/7. At certain points of the day, if a criteria is met, a process is started. For example: a database may contain records of what time each user wants to receive a daily newsletter (for some subjective reason) - the code would at the right time of day send the newsletter to the correct person. But of course, all of this is running out on a Cloud server. \nAny help would be appreciated - even correcting my entire formulation of the problem! If you know how to do this in any other language - please reply with your solutions!\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":262,"Q_Id":24769574,"Users Score":1,"Answer":"Took a few days but I finally got a way to work this out. The most practical way to get this working is to use a VPS that runs the script. The confusing part of my code was that each user  would activate the script at a different time for themselves. To do this, say at midnight, the VPS runs the python script (using scheduled tasking or something similar) and runs the script. the script would then pull times from a database and process the code at those times outlined. \nThanks for your time anyways!","Q_Score":1,"Tags":"python,cloud","A_Id":24983741,"CreationDate":"2014-07-15T23:02:00.000","Title":"Uploading code to server and run automatically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have terrible doubts regarding python config file approach.\nI am creating a program with a GUI (PyQt). The program loads some settings from a .cfg file using the configparser module. And the user can edit these settings from the GUI with the user preferences widget. When the preferences widget is closed the .cfg file is saved but I don't know how to update the  rest of the program using the updated settings values.\nI will try to explain with an example:\n\nI launch the program. It create a ConfigParser() named config and read settings.cfg.\nThe program retrieve the value of the option 'clock_speed' (let's say it is 5) from config and set clkSpd = 5.\nI click on Edit -> Preferences and change the clock speed via a QSpinBox to 8.\nI close the Preferences windget, settings.cfg is saved, the value of the option 'clock_speed' is now 8.\nBUT in its module, clkSpd is still 5.\n\nI know I can just load the settings, edit them, save them and reload all settings each time I close the Preferences window. It's simple but not very beautiful.\nIs there a classic and effficiant approach for config files in read\/write mode ?\nThanks by advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":699,"Q_Id":24785121,"Users Score":0,"Answer":"Updating the state of your application may not be a trivial thing if you are somewhere in the middle. Just an example:\n\nYour app = A car\nYou launch your app = You start your car\nYou set in the preferences the variable type_tyre to Winter\nYour running app still has type_tyre equals Sommer\nYou attempt to change tyres while driving on the highway\nCrash\n\nAnd this while changing the tyres before starting the car might be a trivial and safe thing to do.\nSo you just have to write a routine that adjusts the state of your application according to the change in preferences but this is in general different from initializing the app and depends on the current state of the app. But otherwise just write such a routine and call it.","Q_Score":0,"Tags":"python,pyqt,updating,configparser","A_Id":24871124,"CreationDate":"2014-07-16T15:45:00.000","Title":"Python - update configparser between modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a problem that involves creating a graph which shows the areas of intersection of three or more circles (each circle is the same size). I have many sets of circles, each set containing at least three circles. I need to graph the area common to the interior of each and every circle in the set, if it even exists. If there is no area where all the circles within the set intersect, I have nothing to graph. So the final product is a graph with little \"slivers\" of intersecting circles all over.\nI already have a solution for this written in Python with matplotlib, but it doesn't perform very well. This wasn't an issue before, but now I need to apply it to a larger data set so I need a better solution. My current approach is basically a test-and-check brute force method: I check individual points within an area to see if they are in that common intersection (by checking distance from the point to the center of each circle). If the point meets that criteria, I graph it and move on. Otherwise, I just don't graph it and move on. So it works, but it takes forever.\nJust to clarify, I don't scan through every point in the entire plane for each set of circles. First, I narrow my \"search\" area to a rectangle tightly bounded around the first two (arbitrarily chosen) circles in the set, and then test-and-check each point in there.\nI was thinking it would be nice if there were a way for me to graph each circle in a set (say there 5 circles in the set), each with an alpha value of 0.1. Then, I could go back through and only keep the areas with an alpha value of 0.5, because that's the area where all 5 circles intersect, which is all I want. I can't figure out how to implement this using matplotlib, or using anything else, for that matter, without resorting to the same brute force test-and-check strategy.\nI'm also familiar with Java and C++, if anyone has a good idea involving those languages. Thank you!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1241,"Q_Id":24793636,"Users Score":1,"Answer":"Maybe you should try something more analytical? It should not be very difficult:\n\nFind the circle pairs whose distance is less than the sum of their radii; they intersect.\nCalculate the intersection angles by simple trigonometry.\nDraw a polygon (path) by using a suitably small delta angle in both cases (half of the polygon comes from one circle, the other half from the other circle.\nCollect the paths to a PathCollection\n\nNone of the steps should be very long or difficult.","Q_Score":0,"Tags":"python,graph,matplotlib,geometry,intersection","A_Id":24797554,"CreationDate":"2014-07-17T01:51:00.000","Title":"How to find and graph the intersection of 3+ circles with Matplotlib","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sometimes, when looking at Python code examples, I'll come across one where the whole program is contained within its own class, and almost every function of the program is actually a method of that class apart from a 'main' function.\nBecause it's a fairly new concept to me, I can't easily find an example even though I've seen it before, so I hope someone understands what I am referring to.\nI know how classes can be used outside of the rest of a program's functions, but what is the advantage of using them in this way compared with having functions on their own?\nAlso, can\/should a separate module with no function calls be structured using a class in this way?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":227,"Q_Id":24796339,"Users Score":1,"Answer":"A program often has to maintain state and share resources between functions (command line options, dB connection, etc). When that's the case a class is usually a better solution (wrt\/ readability, testability and overall maintainability) than having to pass the whole context to every function or (worse) using global state.","Q_Score":3,"Tags":"python,class","A_Id":24797103,"CreationDate":"2014-07-17T06:29:00.000","Title":"What is the benefit of having a whole program contained in a class?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going through the tutorial about Monte Carlo Markov Chain process with pymc library. I am also a newbie using pymc and try to establish my own MCMC process. I have faced couple of question that I couldn't find proper answer in pymc tutorial:\nFirst: How could we define priors with pymc and then marginalise over the priors in the chain process?\nMy second question is about Dirichlet distribution , how is this distribution related to the prior information in MCMC and how should it be defined?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":513,"Q_Id":24805002,"Users Score":0,"Answer":"I recommend following the PyMC user's guide. It explicitly shows you how to specify your model (including priors). With MCMC, you end up getting marginals of all posterior values, so you don't need to know how to marginalize over priors.\nThe Dirichlet is often used as a prior to multinomial probabilities in Bayesian models. The values of the Dirichlet parameters can be used to encode prior information, typically in terms of a notional number of prior events corresponding to each element of the multinomial. For example, a Dirichlet with a vector of ones as the parameters is just a generalization of a Beta(1,1) prior to multinomial quantities.","Q_Score":0,"Tags":"python,probability,bayesian,pymc,mcmc","A_Id":24833321,"CreationDate":"2014-07-17T13:31:00.000","Title":"Defining priors and marginalizing over priors in pymc","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how I would go about emailing user emails stored in a python datastore. \nShould I create a sort of maintenance page where I can log in as an administrator and then send an email or is there a way for me to execute a python script without needing a handler pointing to a separate webpage so I don't have to worry about the page being discovered and exploited.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":88,"Q_Id":24806675,"Users Score":1,"Answer":"You can set up a CRON job to run every few minutes and process your email queue. It will require an endpoint where you can send a POST request, but you can use a secret token (like just any random guid) to verify the request is legitimate before you send the email.","Q_Score":0,"Tags":"python,google-app-engine,email","A_Id":24814266,"CreationDate":"2014-07-17T14:45:00.000","Title":"Google App Engine send batch email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an application made up of Frames, Frames in Frames and Labels in Frames. There is quite a lot of them and I am looking for a way to modify some of the default values.\nI am particularly interested in modifying .columnconfigure() since I call .columnconfigure(0, weight=1) on each of the columns, in each frame. This does not help with the code cleanness. \nIs there a way to set this behavior (ability to expand) globally?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":207,"Q_Id":24806713,"Users Score":3,"Answer":"No, there is no way to change the defaults. You can easily write your own grid function to automatically configure the weight of each column. You could do this by subclassing Frame, for instance.","Q_Score":0,"Tags":"python,tkinter","A_Id":24814914,"CreationDate":"2014-07-17T14:46:00.000","Title":"how to change default values for .columnconfigure() in tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Running Windows 7.  2.7, 3.3 and 3.4 installed.\nI just installed Python 3.3 for a recent project.  In the command prompt, python launches 3.4, and py launches 3.3.  I can access 3.3 using the 3.3 version of IDLE, but how can I access it via the command prompt?\nIs there a shortcut like py that I can use?  Do I need to define this on my own like an alias?\nOr is the best route to somehow change the path to temporarily make 3.3 the default?\nJust downloaded virtualenv, maybe that might be part of the solution.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":238,"Q_Id":24814724,"Users Score":2,"Answer":"If you want to male a file specifically open with a version you can start the file with #! python3.x the x being the version you want. If you want to be able to right click and edit with that version youll need to do some tweaking in the registry","Q_Score":1,"Tags":"python,python-3.x,path","A_Id":24814742,"CreationDate":"2014-07-17T22:43:00.000","Title":"Python: how to access 3.3 if 3.4 is the default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a iPython notebook, I have a while loop that listens to a Serial port and print the received data in real time.\nWhat I want to achieve to only show the latest received data (i.e only one line showing the most recent data. no scrolling in the cell output area)\nWhat I need(i think) is to clear the old cell output when I receives new data, and then prints the new data. I am wondering how can I clear old data programmatically ?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":263058,"Q_Id":24816237,"Users Score":1,"Answer":"If I am not wrong you mean you just need to clear the output part of a cell, which could be a valid output or some error which you don't what to look anymore. If Yes! just go to top ribbon and select Cell > Current Outputs > Clear","Q_Score":192,"Tags":"python,ipython,ipython-notebook","A_Id":68669366,"CreationDate":"2014-07-18T02:02:00.000","Title":"ipython notebook clear cell output in code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two questions that I can not answer to myself:\n\nHow can I change the size of my window, if I do not know the exact size of the phone screen? I.e. my aim is to fit all screen sizes.\nIs there any difference between clicking with mouse and touching with fingers in the code? If I write code for clicking, will it work with touch?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":399,"Q_Id":24830313,"Users Score":2,"Answer":"On mobile, your app should automatically fill the phone screen. You don't need to worry about it. On desktop, you can use the --size=WxH option to test a specific screen size, or use the screen module (-m screen:nexus7 for example - run kivy with -m screen to see the available options).\nNo. All mouse\/touchscreen interactions are considered touches in Kivy. So using on_touch_down\/on_touch_move\/on_touch_up will work regardless of the input device. The only difference is that with touchscreen you could have multi-touch - but if you write your app assuming single-touch it will work the same on both mobile and desktop.","Q_Score":1,"Tags":"android,python,kivy","A_Id":24830380,"CreationDate":"2014-07-18T17:02:00.000","Title":"Kivy: how to change window size properties and the difference between click and touch","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The most recent releases of PyDev IDE for Eclipse come with IPython 'embeded' in its interactive console. I'm just wondering if there is a way to disable this option and let PyDev uses a regular python interactive console without uninstalling IPython? I know that if IPython is not installed PyDev will use a regular python interactive console. But I think there must be a way of doing it without getting rid of IPython.\nIf somebody knows how to do this, pleas advise. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":566,"Q_Id":24836398,"Users Score":1,"Answer":"There's currently no option to do that in the UI.\nYou can do that in a hackish way by manually opening:\nplugins\\org.python.pydev\\pysrc\\pydev_ipython_console.py\nin your Eclipse installation and uncommenting the 'raise ImportError()' in the top of the file :)\nNow, I'm a bit curious on why you'd prefer the PyDev version instead of the IPython version in this case...","Q_Score":2,"Tags":"eclipse,ipython,pydev","A_Id":25066436,"CreationDate":"2014-07-19T03:20:00.000","Title":"Is it possible to disable IPython from the Eclipse\/PyDev console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a model(Neural Network) in python which I want to convert into a PMML file . I have tried the following:\n1.)py2pmml  -> Not able to find the source code for this\n2.)in R     -> PMML in R works fine but my model is in Python.(Cant run the data in R to generate the same model in R) . Does not work for my dataset.\n3.)  Now I am trying to use augustus to make the PMML file. But augustus has examples of using a already built PMML file but not how to make one\nI am not able to find proper examples on how to use augustus in Python to customize the model. \nAny suggestion will be good.\nThanks in advance.\nGGR","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":382,"Q_Id":24875008,"Users Score":0,"Answer":"Finally I found my own solution. I wrote my own PMML Parser and scorer . PMML is very much same as XML so its easy to build and retrieve fields accordingly. If anyone needs more information please comment below. \nThanks ,\nRaghu.","Q_Score":1,"Tags":"python,neural-network,pmml","A_Id":26639275,"CreationDate":"2014-07-21T21:21:00.000","Title":"Produce a PMML file for the Nnet model in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been looking for a few weeks now on how to make a .py file start on startup.\nI have had no luck on any of the methods working, does anyone have any ideas.\nThe file is reasonably small and will need GPIO input from a PIR movement sensor.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1105,"Q_Id":24875955,"Users Score":0,"Answer":"Make sure your script runs fine from the command line first.\nAlso, if you are dealing with the GPIO pins, make sure you are running your script with the proper permissions.  I know when I access the GPIO pins on my pi, I need to use root\/sudo to access them.","Q_Score":1,"Tags":"python,raspberry-pi,gpio","A_Id":24920035,"CreationDate":"2014-07-21T22:33:00.000","Title":"Autostart on raspberry pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to establish one session at the starting of the suite. That session should be stay for longer time for multiple test cases.That session should end at the last.\nThat session should be implement in Selenium Web driver by using Unittest frame works in python language.\nplease can anyone suggest any methods or how to implement it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":739,"Q_Id":24890579,"Users Score":0,"Answer":"The simplest way to achieve this is not to use the Setup() and TearDown() methods, or more specifically not to create a new instance of the WebDriver object at that start or each test case, and not to use the Quit() method at the end of each test case. \nIn your first test case create a new instance of the WebDriver object and use this object for all of your test cases. At the end of your last test case use the Quit() method to close the browser.","Q_Score":0,"Tags":"python,session,selenium,webdriver,python-unittest","A_Id":24891062,"CreationDate":"2014-07-22T14:47:00.000","Title":"how to establish a session thourghout the selenium webdriver suite by using python in firefox","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used to create web app in the same computer, but if the server and the client is not in the same computer, how can we access to the web page ?\nI mean, for example I have an html form and a button \"ok\" :\nIf the server and the client are in the same computer, in action = \" \" we put localhost\/file.py , but if the server and the client are not in the same computer how to do this ? Because the client can't to have localhost in his webbrower (url).","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":136,"Q_Id":24890739,"Users Score":1,"Answer":"The \"action\" part of a form is an url, and If you don't specify the scheme:\/\/host:port part of the URL, the client will resolve it has the current page one. IOW: just put the path part of your script's URL and you'll be fine. FWIW hardcoding the scheme:\/\/host:port of your URLs is an antipattern, as you just found out.","Q_Score":0,"Tags":"python,url,client-server,client,webclient","A_Id":24893137,"CreationDate":"2014-07-22T14:54:00.000","Title":"make a Client-Server application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used to create web app in the same computer, but if the server and the client is not in the same computer, how can we access to the web page ?\nI mean, for example I have an html form and a button \"ok\" :\nIf the server and the client are in the same computer, in action = \" \" we put localhost\/file.py , but if the server and the client are not in the same computer how to do this ? Because the client can't to have localhost in his webbrower (url).","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":136,"Q_Id":24890739,"Users Score":0,"Answer":"Your script is supposed to be run as a CGI script by a web-server, which sets environment variables like REMOTE_ADDR, REQUEST_METHOD ...\nYou are running the script by yourself, and this environment variable are not available. \nThat's why you get the KeyError.","Q_Score":0,"Tags":"python,url,client-server,client,webclient","A_Id":24907187,"CreationDate":"2014-07-22T14:54:00.000","Title":"make a Client-Server application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a python app that uses python 2.4, postgres 8.2 and old versions of pygresql, xlrd, etc. Because of this it is quite a pain to use, and has to be used in a windows xp VM. There are other problems such as the version of xlrd doesn't support .xlsx files, but the new version of xlrd doesn't work with python 2.4, understandably.\nI recently made a branch called 'upgrade' where I started to try to get it working with up to date versions of the libraries (python 2.7), for instance unicode handling has changed a bit so required some changes here and there.\nMost of the work I'm doing on the app should work in both environments, but it's nicer to work on the upgrade branch because it doesn't need to run in a vm. \nSo my question is how can I make commits using the upgrade branch but then apply them to the master branch so they will still apply to the old version of the software the client is using? I realise I can cherry pick commits off the upgrade branch onto master but it seems a bit wrong, having commits in both branches. I'm thinking maybe I should be rebasing the upgrade branch so it is always branching off head after the most recent commits, but then that would mean committing to the master branch which means working in a VM.\nHope this makes some kind of sense, I'll try and do some diagrams if not.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":24908188,"Users Score":0,"Answer":"IMHO you should probably commit in your master branch, then rebase your upgrade branch, it will make more sense in your repository history.\nIf those commits are working on both environments, you should use a different branch based on the master one, so you can work out on the newer version of python, then merge it in the master, then rebase your upgrade branch.","Q_Score":0,"Tags":"python,git,version-control,branching-and-merging","A_Id":24913304,"CreationDate":"2014-07-23T10:36:00.000","Title":"Managing a different python version as a branch in git","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to figure out how to get a process to ignore SIGKILL. The way I understand it, this isn't normally possible. My idea is to get a process into the 'D' state permanently. I want to do this for testing purposes (the corner case isn't really reproducible). I'm not sure this is possible programatically (I don't want to go damage hardware). I'm working in C++ and Python, but any language should be fine. I have root access.\nI don't have any code to show because I don't know how to get started with this, or if it's even possible. Could I possibly set up a bad NFS and try reading from it?\nApologies in advance if this is a duplicate question; I didn't find anyone else trying to induce the D state.\nMany thanks.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":2985,"Q_Id":24922174,"Users Score":5,"Answer":"It is not possible to ignore SIGKILL or handle it in any way.\nFrom man sigaction:\n\nThe sa_mask field specified in act is not allowed to block SIGKILL or SIGSTOP.  Any attempt to do so will be silently ignored.","Q_Score":6,"Tags":"python,c++,linux","A_Id":24922209,"CreationDate":"2014-07-23T22:34:00.000","Title":"How to ignore SIGKILL or force a process into 'D' sleep state?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to run an external library of python called NLopt within Abaqus through python. The issue is that the NLopt I found is compiled against the latest release of Numpy, i.e. 1.9, whereas Abaqus 6.13-2 is compiled against Numpy 1.4. I tried to replace the Numpy folder under the site-packages under the Abaqus installation folder with the respective one of version 1.9 that I created externally through an installation of Numpy 1.9 over Python 2.6 (version that Abaqus uses).\nAbaqus couldn't even start so I guess that such approach is incorrect.\nAre there any suggestions on how to overcome such issue?\nThanks guys","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":318,"Q_Id":24935230,"Users Score":0,"Answer":"I have similar problems. As an (annoying) work around I usually write out important data in text files using the regular python. Afterwards, using a bash script, I start a second python (different version) to further analyse the data (matplotlib etc).","Q_Score":2,"Tags":"python,numpy,nlopt,abaqus","A_Id":25251918,"CreationDate":"2014-07-24T13:33:00.000","Title":"How to overcome version incompatibility with Abaqus and Numpy (Python's library)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). Why? what are the advantages of one over the other?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1956,"Q_Id":24944626,"Users Score":2,"Answer":"They do two different things; compare bytes(1234) with struct.pack(\"!H\", 1234). The first just provides a 4-byte string representation of the number bytes object with 1,234 null bytes; the second provides a two-byte string with the (big-endian) value of the integer.\n(Edit: Struck out irrelevant Python 2 definition of bytes(1234).)","Q_Score":3,"Tags":"python,python-3.x","A_Id":24944710,"CreationDate":"2014-07-24T21:51:00.000","Title":"Python-bytes() vs struct.pack()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). Why? what are the advantages of one over the other?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1956,"Q_Id":24944626,"Users Score":3,"Answer":"bytes() does literally what the name implies:\n\nReturn a new \u201cbytes\u201d object, which is an immutable sequence of\n  integers in the range 0 <= x < 256\n\nstruck.pack() does something very different:\n\nThis module performs conversions between Python values and C structs represented as Python strings\n\nWhile for some inputs these might be equivalent, they are not at all the same operation. struct.pack() is essentially producing a byte-string that represents a POD C-struct in memory. It's useful for serializing\/deserializing data.","Q_Score":3,"Tags":"python,python-3.x","A_Id":24944749,"CreationDate":"2014-07-24T21:51:00.000","Title":"Python-bytes() vs struct.pack()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a large dataset which I plan to do logistic regression on. It has lots of categorical variables, each having thousands of features which I am planning to use one hot encoding on. I will need to deal with the data in small batches. My question is how to make sure that one hot encoding sees all the features of each categorical variable during the first run?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":3004,"Q_Id":24966984,"Users Score":3,"Answer":"There is no way around finding out which possible values your categorical features can take, which probably implies that you have to go through your data fully once in order to obtain a list of unique values of your categorical variables.\nAfter that it is a matter of transforming your categorical variables to integer values and setting the n_values= kwarg in OneHotEncoder to an array corresponding to the number of different values each variable can take.","Q_Score":2,"Tags":"python,scikit-learn","A_Id":25012484,"CreationDate":"2014-07-26T02:41:00.000","Title":"One-hot encoding of large dataset with scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm an eclipse noob.\nAfter adding PyDev to eclipse, I try to create a \"PyDev Django Project\", but and I get the \"Django not found\" error. \nI heard that you have to remove the python interpreter from eclipse, then add it again.  But I don't know how to do that. \nCan someone show me how to remove\/add the python interpreter in eclipse? \nIt is greatly appreciated. \nBrent.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1345,"Q_Id":24973568,"Users Score":0,"Answer":"On the menubar go to Window -> Preferences -> Pydev -> Interpreters -> Python\nRemove the interpreter and click on Quick Auto Config.\nThat should do the trick. Make sure django is installed first.","Q_Score":1,"Tags":"python,django,eclipse,interpreter","A_Id":24973729,"CreationDate":"2014-07-26T17:19:00.000","Title":"How do I remove\/add the python interpreter from eclipse?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've taken to creative coding on my iPad and iPhone using Codea, Procoding, and Pythonista. I really love the paper.js Javascript library, and I'm wondering how I might have the functionality that I find in paper.js when writing in Python.\nSpecifically, I'd love to have the vector math and path manipulation that paper.js affords. Things like finding the intersection of two paths or binding events to paths (on click, mouse move, etc).\nThere's an ImagePath module provided by Pythonista that does some path stuff but it's not as robust as paper.js (it seems).\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":901,"Q_Id":24979640,"Users Score":1,"Answer":"The ui module actually includes a lot of vector drawing functions, inside a ui.ImageContext. ui.ImageContext is a thin wrapper around part of one of the Objective-C APIs (maybe CALayer?) The drawing methods are designed to operate inside the draw method of a custom view class, but you can present these things in other contexts using a UIImageContext, from which you can get a static image.","Q_Score":4,"Tags":"python,processing,paperjs,codea,pythonista","A_Id":38641689,"CreationDate":"2014-07-27T09:28:00.000","Title":"A paperjs-equivalent for python (specifically, Pythonista for iOS)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have managed to use oauth authentication and add a Sign in with Twitter functionality to a Google App Engine web app. \nHow should I verify, during the site navigation, if the user is still logged in Twitter?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":24980103,"Users Score":0,"Answer":"Are you talking about being logged in to Twitter.com or your app? If you have received oAuth access tokens by authenticating an app, then logging out of twitter.com won't 'log you out' of any apps, the tokens will remain valid until the user revokes the access.","Q_Score":0,"Tags":"python,google-app-engine,twitter,webapp2","A_Id":25003619,"CreationDate":"2014-07-27T10:39:00.000","Title":"Sign in with Twitter: how to verify the current user is stil logged in","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"lets say that I have <input name=\"upload\" type=\"file\"> and I am uploading picture.jpg. The question is how can I get the file name+extention? By other words the correct script for request.files.filename or request.upload.filename","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6570,"Q_Id":24981184,"Users Score":20,"Answer":"Found the answer. request.files['upload'].filename gives the file name and extension in flask","Q_Score":6,"Tags":"python,flask,filenames","A_Id":24982070,"CreationDate":"2014-07-27T12:56:00.000","Title":"get input file name and file extention using flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"this question have been asked numerous times, I know and I'm sorry if by ignorance I didn't get the answers.\nI have a hosting plan which doesn't allow me to install django, which was really nice to call an rest api easily with the routing settings.\nWhat I want is to be able to call a python function from javascript code doing a get\/post (I'm using AngularJs, but it would be the same making an ajax get\/post.)\nLet's say I have a js controller 'Employee' and a view 'CreateEmployee'.\nFrom my javascript view, I can call my CreateEmployee() on the js controller, now my question is, how can I call a specific function (let's say) def CreateEmployee(params...) on my .py file?\nAll I found is making a get\/post on my .py file, but didn't find how to invoke a specific function.\nI probably don't get the python and client\/server communication paradigm, I've been coding on asp.net WebForms for a long time, and since I can't use frameworks like Django I'm stuck.\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4050,"Q_Id":24993048,"Users Score":2,"Answer":"It doesn't have much to do with Python, really. Your javascript code is executed on the client's brower, and all it can do is issuing HTTP requests (synchronous or asynchronous). At this point which webserver \/ technology \/ language is used to handle the HTTP request is totally irrelevant. So, from the client javascript code POV, you are not \"calling a Python function\", you are sending an HTTP request and handling the HTTP response.\nIf your web host doesn't let you run django (or any wsgi-compliant script) then you'll probably have to either use plain CGI (warning: very primitive techno) or migrate to PHP (no comment). Or find another hosting that doesn't live in the past ;)","Q_Score":0,"Tags":"javascript,python,angularjs,client-server","A_Id":24993506,"CreationDate":"2014-07-28T10:16:00.000","Title":"Call python FUNCTION from javascript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using cherrypy along with sqlalchemy-mysql as backend. I would like to know the ways of dealing with UNICODE strings in cherrypy web application. One brute-force way would be to convert all string coming in as parameters into UNICODE (and then decoding them to UTF-8) before storing them to database. But I was wondering if there is any standard way of handling UNICODE characters in a web application. I tried cherrypy's tools.encode but it doesn't seem to work for me (may be I haven't understood it properly yet). Or may be there are standard python libraries to handle UNICODEs which I could just import and use. What ways should I look for?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":153,"Q_Id":24997946,"Users Score":0,"Answer":"SQLAlchemy provides Unicode or UnicodeText for your purposes.\nAlso don't forget about u'text'","Q_Score":0,"Tags":"mysql,python-2.7,unicode,sqlalchemy,cherrypy","A_Id":25016312,"CreationDate":"2014-07-28T14:52:00.000","Title":"how to handle UNICODE characters in cherrypy-sqlalchemy-mysql application?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's a general example of what I need to do:\nFor example, I would initiate a back trace by sending the command \"bt\" to GDB from the program. Then I would search for a word such as \"pardrivr\" and get the line number associated with it by using regular expressions. Then I would input \"f [line_number_of_pardriver]\" into GDB. This process would be repeated until the correct information is eventually extracted.\nI want to use named pipes in bash or python to accomplish this.\nCould someone please provide a simple example of how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":289,"Q_Id":25001824,"Users Score":1,"Answer":"My recommendation is not to do this.  Instead there are two more supportable ways to go:\n\nWrite your code in Python directly in gdb.  Gdb has been extensible in Python for several years now.\nUse the gdb MI (\"Machine Interface\") approach.  There are libraries available to parse this already (not sure if there is one in Python but I assume so).  This is better than parsing gdb's command-line output because some pains are taken to avoid gratuitous breakage -- this is the preferred way for programs to interact with gdb.","Q_Score":0,"Tags":"python,linux,bash,gdb,named-pipes","A_Id":25047902,"CreationDate":"2014-07-28T18:27:00.000","Title":"Use named pipes to send input to program based on output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a Django app in which a user can upload a file (an image) using AJAX.\nWhile developing locally, I saw that PIL, which I used to process the image after upload, had a bug. After investigating I found out it's because PIL is getting the file data cut off. It's only getting the first 1MB of the file, which is why it's failing. (The file is around 3MB.)\nWhy could this be, and how can I solve it? My immediate suspicion is that runserver, which I use locally, caps AJAX uploads for some reason. But I can't be sure. And if it does, I don't know how to make it stop.\nCan anyone help?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":25003108,"Users Score":0,"Answer":"Turns out it was a \"feature\" of the client-side AJAX package we were using (flow.js) and we just had to increase chunkSize.","Q_Score":3,"Tags":"python,ajax,django","A_Id":25031586,"CreationDate":"2014-07-28T19:45:00.000","Title":"Django cutting off uploaded file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to all programming and I just started to get interested in learning how to program. So to do so I started with what most people consider the easiest language: Python.\nThe problem I am having right now though is that if I say to Python print(\"Hello!\"), save it in a file, and then run it, a black window opens up and closes right away. I just do not understand why it is doing this.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7183,"Q_Id":25005943,"Users Score":0,"Answer":"Insert input() in the last line. It will make the program wait for a input. While it doesn't occur the windows program will be open. If you press any key and then enter, it will close.","Q_Score":1,"Tags":"python,windows","A_Id":25006282,"CreationDate":"2014-07-28T23:28:00.000","Title":"Window closes immediately after running program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say that I have a paragraph with different languages in it. like:\nThis is paragraph in English. \u8fd9\u662f\u5728\u82f1\u56fd\u6bb5\u3002\u042d\u0442\u043e \u043f\u0443\u043d\u043a\u0442 \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u0627\u06cc\u0646 \u0628\u0646\u062f \u062f\u0631 \u0632\u0628\u0627\u0646 \u0627\u0646\u06af\u0644\u06cc\u0633\u06cc \u0627\u0633\u062a. \nI would like to calculate what percentage (%) of this paragraph includes English words. So would like to ask how to do that in python.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3245,"Q_Id":25012108,"Users Score":0,"Answer":"If all your words written in latin letters are in English you could use regular expressions.","Q_Score":1,"Tags":"python,character,word-count","A_Id":25012260,"CreationDate":"2014-07-29T09:30:00.000","Title":"How to calculate percentage of english words in a paragraph using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to get the data from inspect element using Python. I'm able to download the source code using BeautifulSoup but now I need the text from inspect element of a webpage. I'd truly appreciate if you could advise me how to do it. \nEdit:\nBy inspect element I mean, in google chrome, right click gives us an option called inspect element which has code related to each element of that particular page. I'd like to extract that code\/ just its text strings.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":34323,"Q_Id":25027339,"Users Score":0,"Answer":"BeautifulSoup could be used to parse the html document, and extract anything you want. It's not designed for downloading. You could find the elements you want by it's class and id.","Q_Score":6,"Tags":"python,html,extract","A_Id":25027442,"CreationDate":"2014-07-30T01:11:00.000","Title":"How to get data from inspect element of a webpage using Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a combobox in wxpython but I cant figure out how to align the text it contains to the right?\nI have tried to use wx.ComboBox(self, choices=[\"1\",\"2\",\"3\"], style=wx.TEXT_ALIGNMENT_RIGHT) but that didnt work.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":835,"Q_Id":25057937,"Users Score":1,"Answer":"The widget probably doesn't support text alignment. If you want complete control over how it displays its contents, then you should probably switch to a custom drawn control, such as ComboCtrl.","Q_Score":0,"Tags":"wxpython,wxwidgets","A_Id":25059718,"CreationDate":"2014-07-31T11:38:00.000","Title":"How do I right align the text in a wx.ComboBox?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed a python package slimit and I have cloned the source code from github.\nI am doing changes to this package in my local folders which I want to test (often) but I don't want to do allways python setup.py install.\nMy folder structure is:\n..\/develop\/slimit\/src\/slimit (contains package files)\n..\/develop\/test\/test.py\nI'm using eclipse + pydev + python 2.7, on linux\nShould I run eclipse with \"sudo rights\"?\nEven better, is there a way to import the local development package into my testing script?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":25093943,"Users Score":1,"Answer":"When you're working on a library you can use python setup.py develop instead of install. This will install the package into your local environment and keep it updated as you develop. \nTo be clear, if you use develop you don't have to run it again when you change your source files.","Q_Score":0,"Tags":"python","A_Id":25106484,"CreationDate":"2014-08-02T10:17:00.000","Title":"how to test changes to an installed package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to adjust display left to right \/ right to left with openpyxl or if its even possible.\nhaven't really found anything in the documantation, maybe im blind.\nthanks in advance :)","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":930,"Q_Id":25106897,"Users Score":-1,"Answer":"As A-Palgy said you have to add\nworksheet.sheet_view.rigtToleft = True\nbut first, you have to enable that feature in the views.py file in this path: \nC:\\python36\\Lib\\site-packages\\openpyxl\\worksheet\\views.py\nand edit the line : \nrightToLeft = Bool(allow_none=True)\nto \nrightToLeft = Bool(allow_none=False)","Q_Score":4,"Tags":"python,openpyxl","A_Id":47234993,"CreationDate":"2014-08-03T16:52:00.000","Title":"Python Openpyxl display left to right","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to run a cron script in python 3 so I had to setup a virtual environment (if there is an easier way, please let me know) and in order to run the script I need to be in the script's parent folder as it writes to text files there. So here is the long string of commands I have come up with and it works in console but does not work in cron (or I can't find the output..)\nI can't type the 5 asterisks without it turning into bullet points.. but I have them in the cron tab.\n\ncd usr\/local\/sbin\/cronjobs && . virtualenv\/secret_ciphers\/bin\/activate\n  && cd csgostatsbot && python3 CSGO_STATS_BOT_TASK.py && deactivate","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":822,"Q_Id":25110635,"Users Score":1,"Answer":"It looks like you may have a stray . in there that would likely cause an error in the command chain.\nTry this:\n\ncd usr\/local\/sbin\/cronjobs && virtualenv\/secret_ciphers\/bin\/activate\n  && cd csgostatsbot && python3 CSGO_STATS_BOT_TASK.py && deactivate\n\nAssuming that the virtualenv directory is in the cronjobs directory.\nAlso, you may want to skip the activate\/deactivate, and simply run the python3 interpreter right out of the virtualenv. i.e.\n\n\/usr\/local\/sbin\/cronjobs\/virtualenv\/secret_ciphers\/bin\/python3 \/usr\/local\/sbin\/cronjobs\/csgostatsbot\/CSGO_STATS_BOT_TASK.py\n\nEdit in response to comments from OP:\nThe activate call is what activates the virtualenv. Not sure what the . would do aside from cause shell command parsing issues.\nBoth examples involve the use of the virtualenv. You don't need to explicitly call activate. As long as you invoke the interpreter out of the virtualenv's directory, you're using the virtualenv. activate is essentially a convenience method that tweaks your PATH to make python3 and other bin files refer to the virtualenv's directory instead of the system install.\n2nd Edit in response to add'l comment from OP:\nYou should redirect stderr, i.e.:\n\n\/usr\/local\/sbin\/cronjobs\/virtualenv\/secret_ciphers\/bin\/python3\n  \/usr\/local\/sbin\/cronjobs\/csgostatsbot\/CSGO_STATS_BOT_TASK.py >\n  \/tmp\/botlog.log 2>&1\n\nAnd see if that yields any additional info.\nAlso, 5 asterisks in cron will run the script every minute 24\/7\/365. Is that really what you want?\n3rd Edit in response to add'l comment from OP:\nIf you want it to always be running, I'm not sure you really want to use cron. Even with 5 asterisks, it will run it once per minute. That means it's not always running. It runs once per minute, and if it takes longer than a minute to run, you could get multiple copies running (which may or may not be an issue, depending on your code), and if it runs really quickly, say in a couple seconds, you'll have the rest of the minute to wait before it runs again.\nIt sounds like you want the script to essentially be a daemon. That is, just run the main script in a while (True) loop, and then just launch it once. Then you can quit it via <crtl>+c, else it just perpetually runs.","Q_Score":0,"Tags":"python,linux,unix,cron,raspberry-pi","A_Id":25110706,"CreationDate":"2014-08-04T01:23:00.000","Title":"how to write a multi-command cronjob on a raspberry pi or any other unix system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"as i have found on thread safety of socket, it was not,\nBut how about each thread accesses a socket to write or read only one byte at a once.(1 byte means 1 character)\nis it also un-safe? \ni am coding in python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":356,"Q_Id":25120159,"Users Score":2,"Answer":"The socket API is thread safe (at least on linux and windows) to the extent that the system won't crash and the data will all be transferred. Its just that data sent among threads may be interleaved and there is no guarantee what any given thread will receive. But the minumum unit of transfer is 1 byte so if you have a protocol where messages are only 1 byte and interleaving doesn't make a difference, ... send away!","Q_Score":0,"Tags":"python,sockets,thread-safety","A_Id":25122539,"CreationDate":"2014-08-04T13:44:00.000","Title":"is socket thread safe in writing or reading a 1byte?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"ok so i've used iexpress a few times without a problem. i created a nice little program for my buddies and i and i'm now in the process of creating a installation package for it. i like iexpress cause it makes it easy and has the license agreement window n whatnot. \nok so program is made. using windows & iexpress i attempt to make the installer, problem is there is one folder that contains an item i need and it needs to be in that folder directory when the installed program needs to run. Problem: i can select files but not folders for the list of items to be in the installer. \nQuestion: how do i include the folder in the install package so there doesnt need to be a few more additional steps for the installation. \ni have thought about zipping it, but there isnt a way (that i know of) to add a extract command after the initial install extract.  \ni figure installers are to programs what instruction booklets are to Ikea furniture so i figured this would be the best place for help. tyvm","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":535,"Q_Id":25125532,"Users Score":1,"Answer":"iexpress doesn't let you include folders, but you can include a batch file, which may create folders and copy files to the respective folder. To run a batch file, specify cmd \/c IncludedBatchFile.bat under Install Program in the iexpress wizard.","Q_Score":0,"Tags":"python,installation,iexpress","A_Id":31952116,"CreationDate":"2014-08-04T18:49:00.000","Title":"iexpress assistance for my program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used micro CT (it generates a kind of 3D image object) to evaluate my samples which were shaped like a cone. However the main surface which should be flat can not always be placed parallel to the surface of image stacks. To perform the transform, first of all, I have to find a way to identify the flat surface. Therefore I learnt python to read the image data into numpy array. \nThen I realized that I totally have no clue how to achieve the idea in a mathematical way. \nIf you have any idea or any suggestion or even packages would be so appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":435,"Q_Id":25138508,"Users Score":0,"Answer":"Firstly, all lines in 3d correspond to an equation; secondly, all lines in 3d that lie on a particular plane for part of their length correspond to equations that belong to a set of linear equations that share certain features, which you would need to determine. The first thing you should do is identify the four corners of the supposed plane - they will have x, y or z values more extreme than the other points. Then check that the lines between the corners have equations in the set - three points in 3d always define a plane, four points may not. Then you should 'plot' the points of two parallel sides using the appropriate linear equations. All the other points in the supposed plane will be 'on' lines (whose equations are also in the set) that are perpendicular between the two parallel sides. The two end points of a perpendicular line on the sides will define each equation. The crucial thing to remember when determining whether a point is 'on' a line is that it may not be, even if the supposed plane was inputted as a plane. This is because x, y and z values as generated by an equation will be rounded so as correspond to 'real' points as defined by the resolution that the graphics program allows. Therefore you must allow for a (very small) discrepancy between where a point 'should be' and where it actually is - this may be just one pixel (or whatever unit of resolution is being used). To look at it another way - a point may be on a perpendicular between two sides but not on a perpendicular between the other two solely because of a rounding error with one of the two equations. If you want to test for a 'bumpy' plane, for whatever reason, just increase the discrepancy allowed. If you post a carefully worded question about the set of equations for the lines in a plane on math.stackexchange.com someone may know more about it.","Q_Score":0,"Tags":"python,image,3d,transform","A_Id":25142706,"CreationDate":"2014-08-05T12:11:00.000","Title":"How to check a random 3d object surface if is flat in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Before my testing library of choice was unittest. It was working with my favourite debugger - Pudb. Not Pdb!!! \nTo use Pudb with unittest, I paste import pudb;pudb.set_trace() between the lines of code.\nI then executed python -m unittest my_file_test, where my_file_test is module representation of my_file_test.py file.\nSimply using nosetests my_file_test.py won't work - AttributeError: StringIO instance has no attribute 'fileno' will be thrown.\nWith py.test neither works:\npy.test my_file_test.py\nnor\npython -m pytest my_file_test.py \nboth throw ValueError: redirected Stdin is pseudofile, has no fileno()\nAny ideas about how to use Pudb with py.test","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4263,"Q_Id":25182812,"Users Score":27,"Answer":"Simply by adding the -s flag pytest will not replace stdin and stdout and debugging will be accessible, i.e. pytest -s my_file_test.py will do the trick.\nIn documentation provided by ambi it is also said that previously using explicitly -s was required for regular pdb too, now -s flag is implicitly used with --pdb flag.\nHowever pytest does not implicitly support pUdb, so setting -s is needed.","Q_Score":24,"Tags":"python,pytest,pudb","A_Id":25183130,"CreationDate":"2014-08-07T12:39:00.000","Title":"Using Python pudb debugger with pytest","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is not a question of a code, I need to extract some BLOB data from an Oracle database using python script. My question is what are the steps in dealing with BLOB data and how to read as images, videos and text? Since I have no access to the database itself, is it possible to know the type of BLOBs stored if it is pictures, videos or texts? Do I need encoding or decoding in order to tranfer these BLOBs into .jpg, .avi or .txt files ? These are very basic questions but I am new to programming so need some help to find a starting point :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1342,"Q_Id":25205157,"Users Score":0,"Answer":"If you have a pure BLOB in the database, as opposed to, say, an ORDImage that happens to be stored in a BLOB under the covers, the BLOB itself has no idea what sort of binary data it contains. Normally, when the table was designed, a column would be added that would store the data type and\/or the file name.","Q_Score":0,"Tags":"oracle,python-2.7,blob","A_Id":25205260,"CreationDate":"2014-08-08T13:54:00.000","Title":"Reading BLOB data from Oracle database using python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I keep receiving the following error message when trying to install Python-Django on my OpenSuse Linux VM:\n\nThe installation has failed. For more information, see the log file at\n  \/var\/log\/YaST2\/y2log. Failure stage was: Adding Repositories\n\nNot sure how to add additional Repositories when I am using the opensuse download center. Does anyone know how to resolve this error?\nThank you.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1428,"Q_Id":25219911,"Users Score":0,"Answer":"zypper install python-pip\npip install virtualenv\nvirtualenv name-env\n\nSource name-env\/bin\/activate\n(name-env) pip install django==version \n\npip install django","Q_Score":0,"Tags":"python,django","A_Id":46187663,"CreationDate":"2014-08-09T15:08:00.000","Title":"OpenSuse Python-Django Install Issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"For example:    EAX = 10101010 00001110 11001010 00100000\nI want to move EAX high 8 bits to right 7 times,what can i do in c or in python?\nIn asm :    SHR ah,7\nThe result of EAX is:10101010 00001110 00000001 00100000\nAnd how about     SHR ax,7?\nI have tried ((EAX & 0xff00) >> 8 ) >> 7,but i don't how to add it back to EAX?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":384,"Q_Id":25235040,"Users Score":-1,"Answer":"You can store bits from 9th onwards in other variable. Then make those vits 0 in EAX. Then do EAX << 7 and add those bits again to it.","Q_Score":0,"Tags":"python,c,assembly,bit","A_Id":25236304,"CreationDate":"2014-08-11T02:17:00.000","Title":"how to move a number's high 8 bits 7 times in c or python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've done some research, and I don't fully understand what I found. \nMy aim is to, using a udp listener I wrote in python, store data that it receives from an MT4000 telemetry device. This data is received and read in hex, and I want that data to be put into a table, and store it as a string in base64. In terms of storing something as an integer by using the 'columnname' INT format, I would like to know how to store the information as base64? ie. 'data' TEXT(base64)? or something similar. \nCould I do this by simply using the TEXT datatype, and encode the data in the python program?\nI may be approaching this in the wrong way, as I may have misinterpreted what I read online.\nI would be very grateful for any help. Thanks,\nEd","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5730,"Q_Id":25239361,"Users Score":2,"Answer":"You can just save the base64 string in a TEXT column type. After retrieval just decode this string with base64.decodestring(data) !","Q_Score":2,"Tags":"python,mysql","A_Id":25239591,"CreationDate":"2014-08-11T08:57:00.000","Title":"How to store base64 information in a MySQL table?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I've done some research, and I don't fully understand what I found. \nMy aim is to, using a udp listener I wrote in python, store data that it receives from an MT4000 telemetry device. This data is received and read in hex, and I want that data to be put into a table, and store it as a string in base64. In terms of storing something as an integer by using the 'columnname' INT format, I would like to know how to store the information as base64? ie. 'data' TEXT(base64)? or something similar. \nCould I do this by simply using the TEXT datatype, and encode the data in the python program?\nI may be approaching this in the wrong way, as I may have misinterpreted what I read online.\nI would be very grateful for any help. Thanks,\nEd","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5730,"Q_Id":25239361,"Users Score":0,"Answer":"You can storage a base64 string in a TEXT column type, but in my experience I recommend to use LONGTEXT type to avoid truncated errors in big base64 texts.","Q_Score":2,"Tags":"python,mysql","A_Id":62777767,"CreationDate":"2014-08-11T08:57:00.000","Title":"How to store base64 information in a MySQL table?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"My python list named l contains 100 items.\nIf I do,\nl = l[25:100]\nWill this release the memory for the first 25 items?\nIf not, how can this be achieved?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":25247910,"Users Score":3,"Answer":"Provided there are no other references to l, then memory will be released yes.\nWhat happens is:\n\nl[25:100] creates a new list object with references to the values from l indices 25 through to 100 (exclusive).\nl is rebound to now refer the new list object.\nThe reference count for the old list object formerly bound by l is decremented by 1.\nIf the reference count dropped to 0, the old list object formerly bound by l is deleted and memory is freed.","Q_Score":0,"Tags":"python,list,python-2.7","A_Id":25247976,"CreationDate":"2014-08-11T16:22:00.000","Title":"Will slicing a list release memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My python list named l contains 100 items.\nIf I do,\nl = l[25:100]\nWill this release the memory for the first 25 items?\nIf not, how can this be achieved?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":25247910,"Users Score":0,"Answer":"There is also an option that doesn't allocate a new list: del l[:25] will remove the first 25 entries from the existing list, shifting the following ones down. Any other references to l will still point to it, but it is altered into a shorter list. \nNote that reference semantics also apply to each of the items; they may have references from elsewhere than the list. It is also not guaranteed that they will be freed right away.","Q_Score":0,"Tags":"python,list,python-2.7","A_Id":25249574,"CreationDate":"2014-08-11T16:22:00.000","Title":"Will slicing a list release memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a multiplayer game for iPhone(cocos2d), which is almost finished, but the multiplayer part is left. I have searched the web for two days now, and can\u00b4t find any thing that answers my question.\nI have created a search room(tcp socket on port 2000) that matches players that searches for a quick match to play. After two players has been matched, that server disconnects them from the search room to leave space for incoming searchers(clients\/players)\nNow I\u00b4m wondering how to create the play room(where two players interact and play)?\nI was thinking I could create a new tcp\/udp socket on a new port and let the matched(matched in the search room) players connect to that socket and then have a perfect isolated room for the two to interact with each another.\nOr do I need a new server (machine\/hardware) and than create a new socket on that one and let the peered players connect to it.\nOr maybe there is another way of doing this.\nOBS. I am not going to have the game running on the server to deal with cheaters for now. Because this will be to much load for the server cpu on my setup.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":902,"Q_Id":25261552,"Users Score":1,"Answer":"I was thinking I could create a new tcp\/udp socket on a new port and let the matched(matched in the search room) players connect to that socket and then have a perfect isolated room for the two to interact with each another.\n\nYes, you can do that. And there shouldn't be anything hard about it at all. You just bind a socket on the first available port, pass that port to the two players, and wait for them to connect. If you're worried about hackers swooping in by, e.g., portscanning for new ports opening up, there are ways to deal with that, but given that you're not attempting any cheap protection I doubt it's an issue.\n\nOr do I need a new server (machine\/hardware) and than create a new socket on that one and let the peered players connect to it.\n\nWhy would you need that? What could it do for you? Sure, it could take some load off the first server, but there are plenty of ways you could load-balance if that's the issue; doing it asymmetrically like this tends to lead to one server at 100% while the other one's at 5%\u2026\n\nOr maybe there is another way of doing this.\n\nOne obvious way is to not do anything. Just let them keeping talking to the same port they're already talking to, just attach a different handler (or a different state in the client state machine, or whatever; you haven't given us any clue how you're implementing your server). I don't know what you think you're getting out of \"perfect isolation\". But even if you want it to be a different process, you can just migrate the two client sockets over to the other process; there's no reason to make them connect to a new port.\nAnother way to do it is to get the server out of the way entirely\u2014STUN or hole-punch them together and let them P2P the game protocol.\nAnything in between those two extremes doesn't seem worth doing, unless you have some constraints you haven't explained.\n\nOBS. I am not going to have the game running on the server to deal with cheaters for now. Because this will be to much load for the server cpu on my setup.\n\nI'm guessing that if putting even minimal game logic on the server for cheat protection is too expensive, spinning off a separate process for every pair of clients may also be too expensive. Another reason not to do it.","Q_Score":1,"Tags":"python,sockets,tcp,udp,multiplayer","A_Id":25261988,"CreationDate":"2014-08-12T10:04:00.000","Title":"Multi multiplayer server sockets in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I may be being ignorant here, but I have been researching for the past 30 minutes and have not found how to do this. I was uploading a bunch of files to my server, and then, prior to them all finishing, I edited one of those files. How can I update the file on the server to the file on my local computer? \nBonus points if you tell me how I can link the file on my local computer to auto update on the server when I connect (if possible of course)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2518,"Q_Id":25265148,"Users Score":0,"Answer":"Have you considered Dropbox or SVN ?","Q_Score":0,"Tags":"python,ssh","A_Id":25265180,"CreationDate":"2014-08-12T13:08:00.000","Title":"update file on ssh and link to local computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I may be being ignorant here, but I have been researching for the past 30 minutes and have not found how to do this. I was uploading a bunch of files to my server, and then, prior to them all finishing, I edited one of those files. How can I update the file on the server to the file on my local computer? \nBonus points if you tell me how I can link the file on my local computer to auto update on the server when I connect (if possible of course)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2518,"Q_Id":25265148,"Users Score":0,"Answer":"I don't know your local computer OS, but if it is Linux or OSX, you can consider LFTP. This is an FTP client which supports SFTP:\/\/. This client has the \"mirror\" functionality. With a single command you can mirror your local files against a server. \nNote: what you need is a reverse mirror. in LFTP this is mirror -r","Q_Score":0,"Tags":"python,ssh","A_Id":25265274,"CreationDate":"2014-08-12T13:08:00.000","Title":"update file on ssh and link to local computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a desktop application in kivy and able to make single executable(.app) with pyinstaller. Now I wanted to give it to customers with the trial period of 10 days or so. \nThe problem is how to make a trial version which stop working after 10 days of installation and even if the user un-install and install it again after trial period get over it should not work.\nGiving partial feature in trial version is not an option.\nEvnironment\nMac OS and Python 2.7 with Kivy","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2478,"Q_Id":25269845,"Users Score":4,"Answer":"You need a web server and a database to get this working.\n\nCreate a licenses table in your database.\nEach time a new client pays for your software or asks for a trial, you generate a new long random license, insert it in the licenses table, associate it to the client's email address and send it to the client via email.\nEach time a client tries to install the software on their computers, you ask for a license and contact the webserver to ensure that the license exists and is still valid.\n\nUsing that, people can still just create multiple emails and thus potentially get an infinite amount of trial versions. \nYou can then try to add a file somewhere in the person's computer, a place where nobody would ever look for, and just paste the old license there so that when the app starts again (even from a new installation), it can read the license from there and contact the webserver without asking for a license. With this method, when your app contacts the server with an expired trial license, your server can reply with a \"license expired\" signal to let your app know that it has to ask for a non-trial license now, and the server should only accept non-trial licenses coming from that app from now on. This whole method breaks if your clients realize that your app is taking this information from a local file because they can just delete it when found.\nAnother idea that comes to mind is to associate the MAC address of a laptop (or any other unique identifier you can think of) to one license instead of an email address, either at license-creation time (the client would need to send you his MAC address when asking for a trial) or at installation time (your app can check for the MAC address of the laptop it's running on).","Q_Score":7,"Tags":"python,kivy,setup-deployment","A_Id":61918928,"CreationDate":"2014-08-12T16:52:00.000","Title":"How to make trial period for my python application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a desktop application in kivy and able to make single executable(.app) with pyinstaller. Now I wanted to give it to customers with the trial period of 10 days or so. \nThe problem is how to make a trial version which stop working after 10 days of installation and even if the user un-install and install it again after trial period get over it should not work.\nGiving partial feature in trial version is not an option.\nEvnironment\nMac OS and Python 2.7 with Kivy","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2478,"Q_Id":25269845,"Users Score":0,"Answer":"My idea is\n\nMake a table in database\nUse datetime module and put system date in that table  as begining date\nUse timedelta module timedelta(15)( for calculating the date that program needs to be expired here i used 15 day trial in code) and store it  in  table of database as expiry date\nNow each time your app start put this logic that it checks on if current date is matches with expiry if it does show error it is expired of your explicit logic\n\nNote:- make sure begining and expiry runs only once instead date will be changed again and again.","Q_Score":7,"Tags":"python,kivy,setup-deployment","A_Id":69546902,"CreationDate":"2014-08-12T16:52:00.000","Title":"How to make trial period for my python application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a script that is dependent on knowing the geometry type of the loaded shapefile.\nbut I've looked in the pyqgis cookbook and API and can't figure out how to call it. \ninfact, I have trouble interpreting the API, so any light shed on that subject would be appreciated. \nThank you","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":8852,"Q_Id":25273987,"Users Score":1,"Answer":"QgsGeometry has the method wkbType that returns what you want.","Q_Score":7,"Tags":"python,shapefile,qgis","A_Id":29585421,"CreationDate":"2014-08-12T21:03:00.000","Title":"How to get shapefile geometry type in PyQGIS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a test application in python and to test some particular scenario, I need to launch my python child process in windows SYSTEM account.\nI can do this by creating exe from my python script and then use that while creating windows service. But this option is not good for me because in future if I change anything in my python script then I have to regenerate exe every-time. \nIf anybody have any better idea about how to do this then please let me know.\nBishnu","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1368,"Q_Id":25279746,"Users Score":2,"Answer":"Create a service that runs permanently. \nArrange for the service to have an IPC communications channel. \nFrom your desktop python code, send messages to the service down that IPC channel. These messages specify the action to be taken by the service. \nThe service receives the message and performs the action. That is, executes the python code that the sender requests. \n\nThis allows you to decouple the service from the python code that it executes and so allows you to avoid repeatedly re-installing a service. \nIf you don't want to run in a service then you can use CreateProcessAsUser or similar APIs.","Q_Score":0,"Tags":"python,windows","A_Id":25279812,"CreationDate":"2014-08-13T06:48:00.000","Title":"How to launch a python process in Windows SYSTEM account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a test application in python and to test some particular scenario, I need to launch my python child process in windows SYSTEM account.\nI can do this by creating exe from my python script and then use that while creating windows service. But this option is not good for me because in future if I change anything in my python script then I have to regenerate exe every-time. \nIf anybody have any better idea about how to do this then please let me know.\nBishnu","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1368,"Q_Id":25279746,"Users Score":0,"Answer":"You could also use Windows Task Scheduler, it can run a script under SYSTEM account and its interface is easy (if you do not test too often :-) )","Q_Score":0,"Tags":"python,windows","A_Id":25281143,"CreationDate":"2014-08-13T06:48:00.000","Title":"How to launch a python process in Windows SYSTEM account","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background: I got a lot of text that has some technical expressions, which are not always standard.\nI know how to find the bigrams and filter them. \nNow, I want to use them when tokenizing the sentences. So words that should stay together (according to the calculated bigrams) are kept together. \nI would like to know if there is a correct way to doing this within NLTK. If not, I can think of various non efficient ways of rejoining all the broken words by checking dictionaries.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":317,"Q_Id":25288032,"Users Score":1,"Answer":"The way how topic modelers usually pre-process text with n-grams is they connect them by underscore (say, topic_modeling or white_house). You can do that when identifying big rams themselves. And don't forget to make sure that your tokenizer does not split by underscore (Mallet does if not setting token-regex explicitly).\nP.S. NLTK native bigrams collocation finder is super slow - if you want something more efficient look around if you haven't yet or create your own based on, say, Dunning (1993).","Q_Score":0,"Tags":"python,python-2.7,nlp,nltk","A_Id":25298846,"CreationDate":"2014-08-13T13:52:00.000","Title":"Python NLTK tokenizing text using already found bigrams","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently got into code golfing and need to save as many characters as possible.\nI remember seeing someone say to use if a\/b: instead of if a<=b:. However, I looked through Python documentation and saw nothing of the sort.\nI could be remembering this all wrong, but I'm pretty sure I've seen this operator used and recommended in multiple instances.\nDoes this operator exist? If so, how does it work?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":482,"Q_Id":25288653,"Users Score":6,"Answer":"That's just division. And, at least for integers a >= 0 and b > 0, a\/b is truthy if a>=b. Because, in that scenario, a\/b is a strictly positive integer and bool() applied to a non-zero integer is True.\nFor zero and negative integer arguments, I am sure that you can work out the truthiness of a\/b for yourself.","Q_Score":6,"Tags":"python,python-2.7,comparison,operators","A_Id":25288736,"CreationDate":"2014-08-13T14:20:00.000","Title":"Using '\/' as greater than less than in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have written a verilog (logic gates and their connectivity description basically) simulator in python as a part of an experiment.\nI faced an issue with the stack limit so I did some reading and found that Python does not have a \"tail call optimization\" feature (i.e. removing stack entries dynamically as recursion proceeds)\nI mainly have two questions in this regard:\n1) If I bump up the stack limit to sys.setrecursionlimit(15000) does it impact performance in terms of time (memory -- I do not care)?\n2) Is there any way I can circumvent this limitation assuming that I can live without a stack-trace.\nI ask this because Verilog mainly deals with state-machines which can be implemented in an elegant way using recursive functions.\nAlso, if I may add, in case of recursive function calls, if there is a bug, I rely more on the input which is causing this bug rather than the stack trace.\nI am new to Python, so maybe experts might argue that the Python stack trace is quite useful to debug recursive function calls...if that is the case, I would be more than happy to learn how to do that.\nLastly, is it advisable to write recursive functions in Python or should I be moving to other languages?\nIf there any work-around such that I can continue using python for recursive functions, I would like to know if there any performance impact (I can do profiling though).","AnswerCount":7,"Available Count":3,"Score":0.0285636566,"is_accepted":false,"ViewCount":1765,"Q_Id":25297446,"Users Score":1,"Answer":"Note: This answer is limited to your topmost question, i.e. \"Is it advisable to write recursive functions in Python?\".\nThe short answer is no, it's not exactly \"advisable\". Without tail-call optimization, recursion can get painfully slow in Python given how intensive function calls are on both memory and processor time. Whenever possible, it's best to rewrite your code iteratively.","Q_Score":10,"Tags":"python,recursion","A_Id":25297640,"CreationDate":"2014-08-13T22:47:00.000","Title":"Is it advisable to write recursive functions in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a verilog (logic gates and their connectivity description basically) simulator in python as a part of an experiment.\nI faced an issue with the stack limit so I did some reading and found that Python does not have a \"tail call optimization\" feature (i.e. removing stack entries dynamically as recursion proceeds)\nI mainly have two questions in this regard:\n1) If I bump up the stack limit to sys.setrecursionlimit(15000) does it impact performance in terms of time (memory -- I do not care)?\n2) Is there any way I can circumvent this limitation assuming that I can live without a stack-trace.\nI ask this because Verilog mainly deals with state-machines which can be implemented in an elegant way using recursive functions.\nAlso, if I may add, in case of recursive function calls, if there is a bug, I rely more on the input which is causing this bug rather than the stack trace.\nI am new to Python, so maybe experts might argue that the Python stack trace is quite useful to debug recursive function calls...if that is the case, I would be more than happy to learn how to do that.\nLastly, is it advisable to write recursive functions in Python or should I be moving to other languages?\nIf there any work-around such that I can continue using python for recursive functions, I would like to know if there any performance impact (I can do profiling though).","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1765,"Q_Id":25297446,"Users Score":0,"Answer":"I use sys.setrecursionlimit to set the recursion limit to its maximum possible value because I have had issues with large classes\/functions hitting the default maximum recursion depth. Setting a large value for the recursion limit should not affect the performance of your script, i.e. it will take the same amount of time to complete if it completes under both a high and a low recursion limit. The only difference is that if you have a low recursion limit, it prevents you from doing stupid things (like running an infinitely recursive loop). With a high limit, rather than hit the limit, a horribly inefficient script that uses recursion too much will just run forever (or until it runs out of memory depending on the task).\nAs the other answers explain in more detail, most of the time there is a faster way to do whatever it is that you are doing other than a long series of recursive calls.","Q_Score":10,"Tags":"python,recursion","A_Id":25298141,"CreationDate":"2014-08-13T22:47:00.000","Title":"Is it advisable to write recursive functions in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a verilog (logic gates and their connectivity description basically) simulator in python as a part of an experiment.\nI faced an issue with the stack limit so I did some reading and found that Python does not have a \"tail call optimization\" feature (i.e. removing stack entries dynamically as recursion proceeds)\nI mainly have two questions in this regard:\n1) If I bump up the stack limit to sys.setrecursionlimit(15000) does it impact performance in terms of time (memory -- I do not care)?\n2) Is there any way I can circumvent this limitation assuming that I can live without a stack-trace.\nI ask this because Verilog mainly deals with state-machines which can be implemented in an elegant way using recursive functions.\nAlso, if I may add, in case of recursive function calls, if there is a bug, I rely more on the input which is causing this bug rather than the stack trace.\nI am new to Python, so maybe experts might argue that the Python stack trace is quite useful to debug recursive function calls...if that is the case, I would be more than happy to learn how to do that.\nLastly, is it advisable to write recursive functions in Python or should I be moving to other languages?\nIf there any work-around such that I can continue using python for recursive functions, I would like to know if there any performance impact (I can do profiling though).","AnswerCount":7,"Available Count":3,"Score":0.0855049882,"is_accepted":false,"ViewCount":1765,"Q_Id":25297446,"Users Score":3,"Answer":"A lot depends on the specific nature of the recursive solution you're trying to implement.  Let me give a concrete example.  Suppose you want the sum of all values in a list.  You can set the recursion up by adding the first value to the sum of the remainder of the list - the recursion should be obvious.  However, the recursive subproblem is only 1 smaller than the original problem, so the recursive stack will grow to be as big as the number of items in the list. For large lists this will be a problem.  An alternate recursion is to note that the sum of all values is the sum of the first half of the list plus the sum of the second half of the list.  Again, the recursion should be obvious and the terminating condition is when you get down to sublists of length 1. However, for this version the stack will only grow as log2 of the size of the list, and you can handle immense lists without stack problems.  Not all problems can be factored into subproblems which are half the size, but when you can this is a good way to avoid stack overflow situations.\nIf your recursive solution is a tail recursion, you can easily be converted into a loop rather than a recursive call.\nAnother possibility if you don't have tail recursion is to implement things with a loop and explicitly store your intermediate state on an explicit stack.","Q_Score":10,"Tags":"python,recursion","A_Id":25297631,"CreationDate":"2014-08-13T22:47:00.000","Title":"Is it advisable to write recursive functions in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to the web development world, to Django, and to applications that require securing the URL from users that change the foo\/bar\/pk to access other user data.\nIs there a way to prevent this? Or is there a built-in way to prevent this from happening in Django?\nE.g.:\nfoo\/bar\/22 can be changed to foo\/bar\/14 and exposes past users data.\nI have read the answers to several questions about this topic and I have had little luck in an answer that can clearly and coherently explain this and the approach to prevent this. I don't know a ton about this so I don't know how to word this question to investigate it properly. Please explain this to me like I'm 5.","AnswerCount":6,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3945,"Q_Id":25312626,"Users Score":3,"Answer":"Just check that the object retrieved by the primary key belongs to the requesting user. In the view this would be \nif some_object.user == request.user:\n    ...\n\nThis requires that the model representing the object has a reference to the User model.","Q_Score":5,"Tags":"python,django,model-view-controller","A_Id":25312789,"CreationDate":"2014-08-14T16:04:00.000","Title":"How to prevent user changing URL  to see other submission data Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I cannot find how to write empty Python struct\/dictionary in PHP. When I wrote \"{}\" in PHP, it gives me an error. What is the equivalent php programming structure to Python's dictionary?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6548,"Q_Id":25318344,"Users Score":0,"Answer":"If you are trying to pass a null value from PHP to a Python dictionary, you need to use an empty object rather than an empty array.\nYou can define a new and empty object like $x = new stdClass();","Q_Score":11,"Tags":"php,python,struct","A_Id":35089240,"CreationDate":"2014-08-14T22:09:00.000","Title":"What is the equivalent php structure to python's dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"i have a strange error with my website which created by django .\nfor the server i use gunicorn and nginx .yes it works well at first,when i use firefox to test my website.\ni create an account ,login the user ,once i submit the data,the user get login .\none day i change to chrome to test my website ,i go to the login page,fill in the user name and password,click the submit button ,this user get login ,when i refresh the page,the strange thing is ,the website ask me to login again ,it means the user do not login at that time.this happens only in chrome .i test in IE and firefox ,all works well.\nmy english is not good,i description the error again.\nwhen i use chrome ,i login one account,the page show the account get login already,however i refresh the page or i click to other page,the website show the user is not in login status.\nthis error only in chrome.\nand if i stop guncorn ,i start the website use django command .manage.py runserver.\neven i user chrome ,the error do not appear.\ni do not know what exact cause the problem. \nany one can help me.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":25341332,"Users Score":0,"Answer":"The session information, i.e. which user is logged in, is saved in a cookie, which is send from browser to server with each request. The cookie is set through the server with your login request.\nFor some reason, chrome does not send or save the correct cookie. If you have a current version of each browser, they should behave similar. Older browser versions may not be as strict as newer versions in respect to cookie security:\n\nSame origin: are all pages located at the same sub-domain, or is the login page at some other domain?\npath: do you set the cookie for a specific path, but use URLs with other paths?\nhttp-only: Do you try to set or get a cookie with javascript, which is set http-only?\nsecure-only: Do you use https for the login-page but http for other pages?\n\nLook at the developer tools in chrome Resources -> Cookies which cookies are set and if they change with each login. Delete all cookies, and try again.","Q_Score":0,"Tags":"python,django,google-chrome,gunicorn","A_Id":25341679,"CreationDate":"2014-08-16T14:53:00.000","Title":"django website with gunicorn errror using chrome when login user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to using os.system function to call command 'history'\nbut the stdout just show that 'sh :1  history: not found'\nOther example i.e. os.system('ls') is works. Can anyone can tell me why 'history' does not work, and how to call 'history' command in Python script.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":227,"Q_Id":25350882,"Users Score":-1,"Answer":"history is not an executable file, but a built-in bash command. You can't run it with os.system.","Q_Score":0,"Tags":"python,linux","A_Id":25350907,"CreationDate":"2014-08-17T15:52:00.000","Title":"Call system command 'history' in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently tasked with the difficult problem of figuring out how to efficiently pack an image and some text within a single file. In doing so, I need to make the file relatively small (it shouldn't be much bigger than the size of the image file alone), and the process of accessing and saving the information should be relatively fast.\nNow, I have already found one way that works - converting the image to a string using pygame, storing it (and the text I need) within an python object, and then pickling the object. This works fine, but the file ends up being much MUCH larger than the image, since it's not being compressed. So to help with this, I then take the pickled object and compress it using gzip. Now I have another problem - the whole process is just a tad bit too slow, since I'll need to do hundreds of these files at a time, which can take several minutes (it shouldn't take longer than a 1\/2 second to load a single file, and this method takes up to 2 seconds per file).\nI had an idea to somehow put the two separate files, as they are, into one file like how someone would with a .zip, but without the need to further compress the data. As long as the image remains in it's original, compressed format (in this case, .png), simply storing it's data with some text should theoretically be both fast and wouldn't use much more memory. The problem is, I don't know how I would go about doing this.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":25351113,"Users Score":0,"Answer":"Alex Reynolds idea to use tar archives seems to be a perfect match.","Q_Score":0,"Tags":"python,python-2.7,pygame","A_Id":25352369,"CreationDate":"2014-08-17T16:18:00.000","Title":"How would I go about serializing multiple file objects into one file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I usually use classes similarly to how one might use namedtuple (except of course that the attributes are mutable). Moreover, I try to put lengthy functions in classes that won't be instantiated as frequently, to help conserve memory. \nFrom a memory point of view, is it inefficient to put functions in classes, if it is expected that the class will be instantiated often? Keeping aside that it's good design to compartmentalize functionality, should this be something to be worried about?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":167,"Q_Id":25365036,"Users Score":2,"Answer":"Each object has its own copy of data members whereas the the member functions are shared. The compiler creates one copy of the member functions separate from all objects of the class. All the objects of the class share this one copy.\nThe whole point of OOP is to combine data and functions together. Without OOP, the data cannot be reused, only the functions can be reused.","Q_Score":2,"Tags":"python,oop","A_Id":25365197,"CreationDate":"2014-08-18T13:53:00.000","Title":"Python OOP: inefficient to put methods in classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I usually use classes similarly to how one might use namedtuple (except of course that the attributes are mutable). Moreover, I try to put lengthy functions in classes that won't be instantiated as frequently, to help conserve memory. \nFrom a memory point of view, is it inefficient to put functions in classes, if it is expected that the class will be instantiated often? Keeping aside that it's good design to compartmentalize functionality, should this be something to be worried about?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":25365036,"Users Score":6,"Answer":"Methods don't add any weight to an instance of your class.  The method itself only exists once and is parameterized in terms of the object on which it operates.  That's why you have a self parameter.","Q_Score":2,"Tags":"python,oop","A_Id":25365082,"CreationDate":"2014-08-18T13:53:00.000","Title":"Python OOP: inefficient to put methods in classes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From a pyramid middleware application I'm calling a stored procedure with pymssql. The procedure responds nicely upon the first request I pass through the middleware from the frontend (angularJS). Upon subsequent requests however, I do not get any response at all, not even a timeout. \nIf I then restart the pyramid application, the same above described happens again.\nI'm observing this behavior with a couple of procedures that were implemented just yesterday. Some other procedures implemented months ago are working just fine, regardless of how often I call them.\nI'm not writing the procedures myself, they are provided for. \nFrom what I'm describing here, can anybody tell where the bug should be hiding most probably?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":122,"Q_Id":25367508,"Users Score":1,"Answer":"The solution was rather trivial. Within one object instance, I was calling two different stored procedures without closing the connection after the first call. That caused a pending request or so in the MSSQL-DB, locking it for further requests.","Q_Score":0,"Tags":"python-2.7,stored-procedures,pyramid,pymssql","A_Id":25646833,"CreationDate":"2014-08-18T16:05:00.000","Title":"pyramid middleware call to mssql stored procedure - no response","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using Django, how long does the Python process used to service requests stay alive? Obviously, a given Python process services an entire request, but is it guaranteed to survive across across requests? \nThe reason I ask is that I perform some expensive computations at when I import certain modules and would like to know how often the modules will be imported.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":266,"Q_Id":25370287,"Users Score":4,"Answer":"This is not a function of Django at all, but of whatever system is being used to serve Django. Usually that'll be wsgi via something like mod_wsgi or a standalone server like gunicorn, but it might be something completely different like FastCGI or even plain CGI.\nThe point is that all these different systems have their own models that determines process lifetime. In anything other than basic CGI, any individual process will certainly serve several requests before being recycled, but there is absolutely no general guarantee of how many - the process might last several days or weeks, or just a few minutes.\nOne thing to note though is that you will almost always have several processes running concurrently, and you absolutely cannot count on any particular request being served by the same one as the previous one. That means if you have any user-specific data you want to persist between requests, you need to store it somewhere like the session.","Q_Score":3,"Tags":"python,django,lifecycle","A_Id":25370876,"CreationDate":"2014-08-18T19:02:00.000","Title":"Django Process Lifetime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make an OpenGL in python\/pygame but I don't know how to add shadow. I don't want to make a lot of darker images for my game. Can someone help me?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":933,"Q_Id":25373895,"Users Score":1,"Answer":"I am no expert in Python but you could try:\nMultiply the color of the image by a value like 0.1, 0.2, 0.3 (anything less that 1) which will give you a very dark texture. This would be the easiest method as it involves just reducing the color values of that texture.\nOr you could try a more complex method such as drawing a transparent black quad over the original image to give it the illusion of being in a shadow.","Q_Score":0,"Tags":"python-2.7,opengl,pygame","A_Id":25383333,"CreationDate":"2014-08-19T00:12:00.000","Title":"How can you edit the brightness of images in PyGame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having an issue with starting a new project from the command prompt. After I have created a virtual env and activated the enviroment, when I enter in .\\Scripts\\django-admin.py startproject new_project, a popup window shows up which says \"AptanaStudio3 executable launcher was unable to locate its companion shared library\" \nI have tried uninstalling Aptana studio, but even when it is uninstalled, the error still occurs. Not sure what I need to do fix this. I have not unistalled\/reinstalled python, i'm not even sure if that has anything to do with it. Many thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":25375903,"Users Score":0,"Answer":"After some searching, finally figured out that the default program to run the django-admin.py was aptana studio 3, even though the program had supposedly been uninstalled completely from my system. I changed the default program to be the python console launcher and now it works fine. There goes 2 hours down the drain..","Q_Score":0,"Tags":"python,django,windows-7-x64,aptana3","A_Id":25376287,"CreationDate":"2014-08-19T04:58:00.000","Title":"Aptana Studio 3 newproject error with Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using python's CSV module to output a series of parsed text documents with meta data. I am using the csv.writer module without specifying a special delimiter, so I am assuming it is delimited using commas. There are many commas in the text as well as in the meta data, so I was expecting there to be way more columns in the document rows, when compared to the header row.\nWhat surprises me is that when I load the outputted file in Excel, everything looks exactly right. How does Excel know how to delimit this correctly??? How is it able to figure out which commas are text commas and which ones are delimiters?\nRelated question: Do people usually use CSV for saving text documents? Is this a standard practice? It seems inferior to JSON or creating a SQLite database in every sense, from long-term sustainability to ease of interpreting without errors.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":518,"Q_Id":25380448,"Users Score":1,"Answer":"You shall inspect the real content of CSV file you have created and you will see, that there are ways to enclose text in quotes. This allows distinction between delimiter and a character inside text value.\nCheck csv module documentation, it explains these details too.","Q_Score":1,"Tags":"python,excel,csv,export-to-csv","A_Id":25380579,"CreationDate":"2014-08-19T09:52:00.000","Title":"Python CSV module - how does it avoid delimiter issues?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In perl there was this idea of the tie operator, where writing to or modifying a variable can run arbitrary code (such as updating some underlying Berkeley database file).  I'm quite sure there is this concept of overloading in python too.\nI'm interested to know what the most idiomatic way is to basically consider a local JSON file as the canonical source of needed hierarchical information throughout the running of a python script, so that changes in a local dictionary are automatically reflected in the JSON file.  I'll leave it to the OS to optimise writes and cache (I don't mind if the file is basically updated dozens of times throughout the running of the script), but ultimately this is just about a kilobyte of metadata that I'd like to keep around.  It's not necessary to address concurrent access to this.  I'd just like to be able to access a hierarchical structure (like nested dictionary) within the python process and have reads (and writes to) that structure automatically result in reads from (and changes to) a local JSON file.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":500,"Q_Id":25392779,"Users Score":0,"Answer":"If concurrency is not required, maybe consider writing 2 functions to read and write the data to a shelf file? Our is the idea to have the dictionary\" aware\" of changes to update the file without this kind of thing?","Q_Score":5,"Tags":"python,json,synchronization","A_Id":25403785,"CreationDate":"2014-08-19T20:53:00.000","Title":"In Python, how do I tie an on-disk JSON file to an in-process dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In perl there was this idea of the tie operator, where writing to or modifying a variable can run arbitrary code (such as updating some underlying Berkeley database file).  I'm quite sure there is this concept of overloading in python too.\nI'm interested to know what the most idiomatic way is to basically consider a local JSON file as the canonical source of needed hierarchical information throughout the running of a python script, so that changes in a local dictionary are automatically reflected in the JSON file.  I'll leave it to the OS to optimise writes and cache (I don't mind if the file is basically updated dozens of times throughout the running of the script), but ultimately this is just about a kilobyte of metadata that I'd like to keep around.  It's not necessary to address concurrent access to this.  I'd just like to be able to access a hierarchical structure (like nested dictionary) within the python process and have reads (and writes to) that structure automatically result in reads from (and changes to) a local JSON file.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":500,"Q_Id":25392779,"Users Score":1,"Answer":"This is a developpement from aspect_mkn8rd' answer taking into account Gerrat's comments, but it is too long for a true comment.\nYou will need 2 special container classes emulating a list and a dictionnary. In both, you add a pointer to a top-level object and override the following methods : \n\n__setitem__(self, key, value)\n__delitem__(self, key)\n__reversed__(self)\n\nAll those methods are called in modification and should have the top-level object to be written to disk.\nIn addition, __setitem__(self, key, value) should look if value is a list and wrap it into a special list object or if it is a dictionary, wrap it into a special dictionnary object. In both case, the method should set the top-level object into the new container. If neither of them and the object defines __setitem__, it should raise an Exception saying the object is not supported. Of course you should then modify the method to take in account this new class.\nOf course, there is a good deal of code to write and test, but it should work - left to the reader as an exercise :-)","Q_Score":5,"Tags":"python,json,synchronization","A_Id":25406625,"CreationDate":"2014-08-19T20:53:00.000","Title":"In Python, how do I tie an on-disk JSON file to an in-process dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"okay, So for a school project I'm using raspberry pi to make a device that basically holds both the functions of an ocr and a tts. I heard that I need to use Google's tesseract through a terminal but I am not willing to rewrite the commands each time I want to use it. so i was wondering if i could either:\nA: Use python to print commands into the LX Terminal\nB: use a type of loop command on the LX terminal and save as a script?\nIt would also be extremely helpful if I could find out how to make my RPI go staight to my script rather than the raspbian desktop when it first boote up. \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":428,"Q_Id":25395814,"Users Score":0,"Answer":"There are ways to do what you asked, but I think you lack some research of your own, as some of these answers are very \"googlable\".\nYou can print commands to LX terminal with python using \"sys.stdout.write()\"\nFor the boot question:\n1 - sudo raspi-config\n2 - change the Enable Boot to Desktop to Console\n3 - there is more than one way to make your script auto-executable:\n-you have the Crontab (which I think it will be the easiest, but probably not the best of the 3 ways)\n-you can also make your own init.d script (best, not easiest)\n-or you can use the rc.local\nAlso be carefull when placing an infinite loop script in auto-boot.\nMake a quick google search and you will find everything you need.\nHope it helps.\nD.Az","Q_Score":0,"Tags":"python,terminal,raspberry-pi,tesseract,raspbian","A_Id":25409597,"CreationDate":"2014-08-20T02:22:00.000","Title":"can I use python to paste commands into LX terminal?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning the web framework Tornado. During the study of this framework, I found the class  tornado.httpserver.HTTPserver. I know how to create a constructor of this class and create instance tornado.httpserver.HTTPserver in main() function. But this class tornado.httpserver.HTTPserver  has 4 methods. I have not found how to use these methods.\n1) def close_all_connections(self):\n2)  def handle_stream(self, stream, address):\n3)  def start_request(self, server_conn, request_conn):\n4)  def on_close(self, server_conn):\nI know that 2-4 methods are inherited from the class tornado.tcpserver.TCPServer\nCan someone illustrate how to use these methods of a class tornado.httpserver.HTTPserver?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":25403160,"Users Score":1,"Answer":"These methods are used internally; you shouldn't call them yourself.","Q_Score":1,"Tags":"python,tornado","A_Id":25410159,"CreationDate":"2014-08-20T11:07:00.000","Title":"How to call methods of class tornado.httpserver.HTTPserver?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I run into an OOP problem when coding something in python that I don't know how to address in an elegant solution. I have a class that represents the equation of a line (y = mx + b) based on the m and b parameters, called Line. Vertical lines have infinite slope, and have equation x = c, so there is another class VerticalLine which only requires a c parameter. Note that I am unable to have a Line class that is represented by two points in the xy-plane, if this were a solution I would indeed use it.\nI want to be able to rotate the lines. Rotating a horizontal line by pi\/2 + k*pi (k an integer) results in a vertical line, and vice versa. So a normal Line would have to somehow be converted to a VerticalLine in-place, which is impossible in python (well, not impossible but incredibly wonky). How can I better structure my program to account for this problem?\nNote that other geometric objects in the program have a rotation method that is in-place, and they are already used frequently, so if I could I would like the line rotation methods to also be in place. Indeed, this would be a trivial problem if the line rotation methods could return a new rotated Line or VerticalLine object as seen fit.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":25416553,"Users Score":0,"Answer":"Geometric objects that have a fixed boundary\/end-points can be translated and rotated in place. But for a line, unless you talk about a line from point A to point B with a fixed length, you are looking at both end-points either being at infinity or -infinity (y = mx + c). Division using infinity or -infinity is not simple math and hence I believe complicates the rotation and translation algorithms","Q_Score":1,"Tags":"python,oop,rotation","A_Id":25417646,"CreationDate":"2014-08-21T00:32:00.000","Title":"Elegant Solution to an OOP Issue involving type-changing in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This seems to be a dumb question, but how do I ssh into the kivy-remote-shell?\nI'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via USB.\nHowever, when I try ssh -p8000 admin@127.0.0.1 from a terminal on the ubuntu machine I pushed the app from I get Connection Refused.\nIt seems to me that there should be a process on the host (ubuntu) machine in order to proxy the connection, or maybe I just don't see how this works?\nAm I missing something simple, or do I need to dig in a debug a bit more?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1540,"Q_Id":25419510,"Users Score":0,"Answer":"Don't know you found the answer or not. But what i have understood is that you are trying to connect android device from Ubuntu. If I am right then (go on reading) you are following wrong steps.\nFirst :- Your Ubuntu does not have ssh server by default so you get this error message.\nSecond :- You are using 127.0.0.1 address i.e your Ubuntu machine itself.\nMethod to do this shall be\nGive your android machine a static address or if it gets dynamic its OK.\nknow the IP address of android and then from Ubuntu typessh -p8000 admin@IP_Of_andrid_device and this should solve the issue.","Q_Score":1,"Tags":"android,python,ssh,kivy","A_Id":41788451,"CreationDate":"2014-08-21T06:23:00.000","Title":"How to connect to kivy-remote-shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This seems to be a dumb question, but how do I ssh into the kivy-remote-shell?\nI'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via USB.\nHowever, when I try ssh -p8000 admin@127.0.0.1 from a terminal on the ubuntu machine I pushed the app from I get Connection Refused.\nIt seems to me that there should be a process on the host (ubuntu) machine in order to proxy the connection, or maybe I just don't see how this works?\nAm I missing something simple, or do I need to dig in a debug a bit more?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1540,"Q_Id":25419510,"Users Score":1,"Answer":"127.0.0.1\n\nThis indicates something has gone wrong - 127.0.0.1 is a standard loopback address that simply refers to localhost, i.e. it's trying to ssh into your current computer.\nIf this is the ip address suggested by kivy-remote-shell then there must be some other problem, though I don't know what - does it work on another device?","Q_Score":1,"Tags":"android,python,ssh,kivy","A_Id":25423631,"CreationDate":"2014-08-21T06:23:00.000","Title":"How to connect to kivy-remote-shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This seems to be a dumb question, but how do I ssh into the kivy-remote-shell?\nI'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via USB.\nHowever, when I try ssh -p8000 admin@127.0.0.1 from a terminal on the ubuntu machine I pushed the app from I get Connection Refused.\nIt seems to me that there should be a process on the host (ubuntu) machine in order to proxy the connection, or maybe I just don't see how this works?\nAm I missing something simple, or do I need to dig in a debug a bit more?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1540,"Q_Id":25419510,"Users Score":2,"Answer":"When the app is running, the GUI will tell you what IP address and port to connect to.","Q_Score":1,"Tags":"android,python,ssh,kivy","A_Id":25426085,"CreationDate":"2014-08-21T06:23:00.000","Title":"How to connect to kivy-remote-shell?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Robot Framework, the execution status for each test case can be either PASS or FAIL. But I have a specific requirement to mark few tests as NOT EXECUTED when it fails due to dependencies.\nI'm not sure on how to achieve this. I need expert's advise for me to move ahead.","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":3561,"Q_Id":25422847,"Users Score":-1,"Answer":"Actually, you can SET TAG to run whatever keyword you like (for sanity testing, regression testing...)\nJust go to your test script configuration and set tags\nAnd whenever you want to run, just go to Run tab and select check-box Only run tests with these tags \/ Skip tests with these tags\nAnd click Start button :) Robot framework will select any keyword that match and run it.\nSorry, I don't have enough reputation to post images :(","Q_Score":1,"Tags":"python,robotframework","A_Id":25830228,"CreationDate":"2014-08-21T09:29:00.000","Title":"Customized Execution status in Robot Framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running ipython remotely on a remote server. I access it using serveraddress:8888\/ etc to write code for my notebooks.\nWhen I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machine and all the number crunching on the server machine? This is something very basic....but somehow after rumaging through google for quite a while i can't figure it out.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2520,"Q_Id":25440006,"Users Score":0,"Answer":"You want to get the regular (zoomable) plot window, right? I think you can not do it in the same kernel as, unfortunately, you can't switch from inline to qt and such because the backend has already been chosen: your calls to matplotlib.use() are always before pylab.","Q_Score":3,"Tags":"python,matplotlib","A_Id":25440301,"CreationDate":"2014-08-22T05:17:00.000","Title":"how to display matplotlib plots on local machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running ipython remotely on a remote server. I access it using serveraddress:8888\/ etc to write code for my notebooks.\nWhen I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machine and all the number crunching on the server machine? This is something very basic....but somehow after rumaging through google for quite a while i can't figure it out.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2520,"Q_Id":25440006,"Users Score":3,"Answer":"There are a few possibilities\n\nIf your remote machine is somehow unixish, you may use the X Windows (then your session is on the remote machine and display on the local machine)\nmpld3\nbokeh and iPython notebook\nnbagg backend of matplotlib.\u00a8\n\nAlternative #1 requires you to have an X server on your machine and a connection between the two machines (possibly tunneled through ssh, etc.) So, this is OS dependent, and the performance depends on the connection between the two machines.\nAlternatives #2 and #3 are very new but promising. They have quite different approaches, mpl3d enables the use of standard matplotlib plotting commands, but with large datasets bokeh may be more useful.\nAlternative #4 is probably the ultimate solution (see tcaswell's comments), but not yet available without using a development version of matplotlib (i.e. there may be some installation challenges). On the other hand, if you can hold your breath for a week, 1.4.0 will be out.","Q_Score":3,"Tags":"python,matplotlib","A_Id":25442617,"CreationDate":"2014-08-22T05:17:00.000","Title":"how to display matplotlib plots on local machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have converted a python script to .exe file. I just want to run the exe file from a VB script. Now the problem is that the python script accepts arguments during run-time (e.g.: serial port number, baud rate, etc.) and I cannot do the same with the .exe file. Can someone help me how to proceed?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":185,"Q_Id":25440747,"Users Score":1,"Answer":"If you don't have the source to the python exe convertor and if the arguments don't need to change on each execution, you could probably open the exe in a debugger like ollydbg and search for shellexecute or createprocess and then create a string in a code cave and use that for the arguments. I think that's your only option.\nAnother idea: Maybe make your own extractor that includes the python script, vbscript, and python interpreter. You could just use a 7zip SFX or something.","Q_Score":1,"Tags":"python,vb.net,arguments","A_Id":25442205,"CreationDate":"2014-08-22T06:22:00.000","Title":"Running an .exe script from a VB script by passing arguments during runtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two screens and want to change the SlideTransition from my second to first screen to direction: 'right' while keeping the first to second transition the default. The docs only show how to change the transition for every transition. How would I make a transition unique to one screen, done in the kv file?\nNote: I have declared my screen manager screens in the kv file also.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":25459285,"Users Score":0,"Answer":"There isn't a property that lets you simply do this - the transition is a property of the screenmanager, not of the screen.\nYou could add your own screen change method for the screenmanager that knows about the screen names and internally sets the transition.","Q_Score":0,"Tags":"python,kivy","A_Id":25461440,"CreationDate":"2014-08-23T06:55:00.000","Title":"Making unique screen transitions - kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am dealing with the following string of bytes in Python 3.\nb'\\xf9', b'\\x02', b'\\x03', b'\\xf0', b'y', b'\\x02', b'\\x03', b'S', b'\\x00', b't', b'\\x00', b'a'\nThis is a very confusing bunch of bytes for me because it is coming from a microcontroller which is emitting information according to the MIDI protocol. \nMy first question is about the letters near the end.  Most all of the other bytes are true hexadecimal values (i.e. I know the b'\\x00' is supposed to be a null character).  However, the capital S, which is supposed to be a capital S, appears as such (a b'S'). According to the ASCII \/ HEX charts I have looked at, Uppercase S should be x53 (which is what b'\\x53'.decode('utf-8') returns.\nHowever, in Python when I do b'S'.decode('utf-8') it also returns a capita S, (how can it be both?)\nAlso, Some of the bytes (such as b'\\xf9') are truly meant to be escaped (which is why they have the \\x however, I am running into issues when trying to decode them.  When running [byteString].decode('utf-8') on a longer version of the above string I get the following error:\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0xf9 in position 0: invalid start byte\nShouldn't those bytes be skipped over or printed as? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":312,"Q_Id":25468191,"Users Score":1,"Answer":"They return the same thing because b'\\x53' == b'S'. It's the same of other characters in the ASCII table as they're represented by the same bytes.\nYou're getting a UnicodeDecodeError because you seem to be using a wrong encoding. If I run b'\\xf9'.decode('iso-8859-1') I get \u00f9 so it's possible that the encoding is ISO-8859-1. \nHowever, I'm not familiar with the MIDI protocol so you have to review it to see what bytes need to be interpreted as what encoding. If decode all the given bytes as ISO-8859-1 it doesn't give me a meaningful string so it may mean that these bytes stand for something else, not text?","Q_Score":0,"Tags":"python,unicode,utf-8,decode,encode","A_Id":25468417,"CreationDate":"2014-08-24T03:09:00.000","Title":"Issues decoding a Python 3 Bytes object based on MIDI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am very new to Python and I have been trying to find a way to write in cmd with python.\nI tried os.system and subprocess too. But I am not sure how to use subprocess.\nWhile using os.system(), I got an error saying that the file specified cannot be found.\nThis is what I am trying to write in cmd os.system('cd '+path+'tesseract '+'a.png out')\nI have tried searching Google but still I don't understand how to use subprocess.\nEDIT:\n    It's not a problem with python anymore, I have figured out. Here is my code now.\nos.system(\"cd C:\\\\Users\\\\User\\\\Desktop\\\\Folder\\\\data\\\\\")\nos.system(\"tesseract a.png out\")\nNow it says the file cannot be open. But if I open the cmd separately and write the above code, it successfully creates a file in the folder\\data.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":727,"Q_Id":25489450,"Users Score":2,"Answer":"Each call to os.system is a separate instance of the shell.  The cd you issued only had effect in the first instance of the shell.  The second call to os.system was a new shell instance that started in the Python program's current working directory, which was not affected by the first cd invocation.\nSome ways to do what you want:\n1 -- put all the relevant commands in a single bash file and execute that via os.system\n2 -- skip the cd call; just invoke your tesseract command using a full path to the file\n3 -- change the directory for the Python program as a whole using os.chdir but this is probably not the right way -- your Python program as a whole (especially if running in a web app framework like Django or web2py) may have strong feelings about the current working directory.\nThe main takeaway is, os.system calls don't change the execution environment of the current Python program.  It's equivalent to what would happen if you created a sub-shell at the command line, issued one command then exited.  Some commands (like creating files or directories) have permanent effect.  Others (like changing directories or setting environment variables) don't.","Q_Score":0,"Tags":"python,cmd","A_Id":25490166,"CreationDate":"2014-08-25T15:35:00.000","Title":"Writing a line to CMD in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In my project workflow, i am invoking a sh script from a python script file. I am planning to introduce a web user interface for this, hence opted for flask framework. I am yet to figure out how to display the terminal output of the shell script invoked by my python script in a component like text area or label. This file is a log file which is constantly updated till the script run is completed. \nThe solution i thought was to redirect terminal output to a text file and read the text file every X seconds and display the content. I can also do it via the Ajax way from my web application. Is there any other prescribed way to achieve this ?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":25495410,"Users Score":0,"Answer":"The one way I can think of doing this is to refresh the page. So, you could set the page to refresh itself every X seconds.\nYou would hope that the file you are reading is not large though, or it will impact performance. Better to have the output in memory.","Q_Score":0,"Tags":"python,shell,flask","A_Id":25496797,"CreationDate":"2014-08-25T22:40:00.000","Title":"Display a contantly updated text file in a web user interface using Python flask framework","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a web application on my local computer in Django.\nNow I want my webapp to be accessible to other computers on my network. We have a common network drive \"F:\/\". Should I place my files on this drive or can I just write something like \"python manage.py runserver test_my_app:8000\" in the command prompt to let other computers in the network access the web server by writing \"test_my_app:8000\" in the browser address field? Do I have to open any ports and how can I do this?","AnswerCount":7,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":29704,"Q_Id":25550116,"Users Score":0,"Answer":"very simple,\nfirst you need to add ip to allowed host,\nALLOWED_HOST =['*']\n2. then execute python manage.py runserver 0.0.0.0:8000\nnow you can access the local project on different system in the same network","Q_Score":23,"Tags":"python,django,webserver,localhost","A_Id":70518273,"CreationDate":"2014-08-28T13:33:00.000","Title":"Access Django app from other computers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a web application on my local computer in Django.\nNow I want my webapp to be accessible to other computers on my network. We have a common network drive \"F:\/\". Should I place my files on this drive or can I just write something like \"python manage.py runserver test_my_app:8000\" in the command prompt to let other computers in the network access the web server by writing \"test_my_app:8000\" in the browser address field? Do I have to open any ports and how can I do this?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":29704,"Q_Id":25550116,"Users Score":11,"Answer":"Just add your own IP Address to ALLOWED_HOSTS \nALLOWED_HOSTS = ['192.168.1.50', '127.0.0.1', 'localhost']\nand run your server python manage.py runserver 192.168.1.50:8000\nand access your own server to other computer in your network","Q_Score":23,"Tags":"python,django,webserver,localhost","A_Id":57634195,"CreationDate":"2014-08-28T13:33:00.000","Title":"Access Django app from other computers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a web application on my local computer in Django.\nNow I want my webapp to be accessible to other computers on my network. We have a common network drive \"F:\/\". Should I place my files on this drive or can I just write something like \"python manage.py runserver test_my_app:8000\" in the command prompt to let other computers in the network access the web server by writing \"test_my_app:8000\" in the browser address field? Do I have to open any ports and how can I do this?","AnswerCount":7,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":29704,"Q_Id":25550116,"Users Score":6,"Answer":"Run the application with IP address then access it in other machines.\npython manage.py runserver 192.168.56.22:1234\nBoth machines should be in same network, then only this will work.","Q_Score":23,"Tags":"python,django,webserver,localhost","A_Id":43633252,"CreationDate":"2014-08-28T13:33:00.000","Title":"Access Django app from other computers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to know, what are the steps to generate an Excel sheet in OpenERP?\nOr put it this way, I want to generate an Excel sheet for data that I have retrieved from different tables through queries with a function that I call from a button on wizard. Now I want when I click on the button an Excel sheet should be generated.\nI have installed OpenOffice, the problem is I don't know how to create that sheet and put data on it. Please will you tell me the steps?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":596,"Q_Id":25552075,"Users Score":1,"Answer":"You can do it easily with python library called XlsxWriter. Just download it and add in openerp Server, look for XlsxWriter Documentation , plus there are also other python libraries for generating Xlsx reports.","Q_Score":0,"Tags":"python,openerp","A_Id":25993349,"CreationDate":"2014-08-28T15:00:00.000","Title":"What are the steps to create or generate an Excel sheet in OpenERP?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After installing all dependencies for scrapy on windows 32bit. I've tried to build an executable from my scrapy spider. Spider script \"runspider.py\" works ok when running as \"python runspider.py\"\nBuilding executable \"pyinstaller --onefile runspider.py\": \n\nC:\\Users\\username\\Documents\\scrapyexe>pyinstaller --onefile\n  runspider.py 19 INFO: wrote\n  C:\\Users\\username\\Documents\\scrapyexe\\runspider.spec 49 INFO: Testing\n  for ability to set icons, version resources... 59 INFO: ... resource\n  update available 59 INFO: UPX is not available. 89 INFO: Processing\n  hook hook-os 279 INFO: Processing hook hook-time 279 INFO: Processing\n  hook hook-cPickle 380 INFO: Processing hook hook-_sre 561 INFO:\n  Processing hook hook-cStringIO 700 INFO: Processing hook\n  hook-encodings 720 INFO: Processing hook hook-codecs 1351 INFO:\n  Extending PYTHONPATH with C:\\Users\\username\\Documents\\scrapyexe 1351\n  INFO: checking Analysis 1351 INFO: building Analysis because\n  out00-Analysis.toc non existent 1351 INFO: running Analysis\n  out00-Analysis.toc 1351 INFO: Adding Microsoft.VC90.CRT to dependent\n  assemblies of final executable\n1421 INFO: Searching for assembly\n  x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21\n  022.8_none ... 1421 INFO: Found manifest C:\\Windows\\WinSxS\\Manifests\\x86_microsoft.vc90.crt_1fc\n  8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest 1421 INFO:\n  Searching for file msvcr90.dll 1421 INFO: Found file\n  C:\\Windows\\WinSxS\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_\n  9.0.21022.8_none_bcb86ed6ac711f91\\msvcr90.dll 1421 INFO: Searching for file msvcp90.dll 1421 INFO: Found file\n  C:\\Windows\\WinSxS\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_\n  9.0.21022.8_none_bcb86ed6ac711f91\\msvcp90.dll 1421 INFO: Searching for file msvcm90.dll 1421 INFO: Found file\n  C:\\Windows\\WinSxS\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_\n  9.0.21022.8_none_bcb86ed6ac711f91\\msvcm90.dll 1592 INFO: Analyzing C:\\python27\\lib\\site-packages\\PyInstaller\\loader_pyi_boots trap.py\n  1621 INFO: Processing hook hook-os 1661 INFO: Processing hook\n  hook-site 1681 INFO: Processing hook hook-encodings 1872 INFO:\n  Processing hook hook-time 1872 INFO: Processing hook hook-cPickle 1983\n  INFO: Processing hook hook-_sre 2173 INFO: Processing hook\n  hook-cStringIO 2332 INFO: Processing hook hook-codecs 2963 INFO:\n  Processing hook hook-pydoc 3154 INFO: Processing hook hook-email 3255\n  INFO: Processing hook hook-httplib 3305 INFO: Processing hook\n  hook-email.message 3444 INFO: Analyzing\n  C:\\python27\\lib\\site-packages\\PyInstaller\\loader\\pyi_import ers.py\n  3535 INFO: Analyzing\n  C:\\python27\\lib\\site-packages\\PyInstaller\\loader\\pyi_archiv e.py 3615\n  INFO: Analyzing\n  C:\\python27\\lib\\site-packages\\PyInstaller\\loader\\pyi_carchi ve.py 3684\n  INFO: Analyzing\n  C:\\python27\\lib\\site-packages\\PyInstaller\\loader\\pyi_os_pat h.py 3694\n  INFO: Analyzing runspider.py 3755 WARNING: No django root directory\n  could be found! 3755 INFO: Processing hook hook-django 3785 INFO:\n  Processing hook hook-lxml.etree 4135 INFO: Processing hook hook-xml\n  4196 INFO: Processing hook hook-xml.dom 4246 INFO: Processing hook\n  hook-xml.sax 4296 INFO: Processing hook hook-pyexpat 4305 INFO:\n  Processing hook hook-xml.dom.domreg 4736 INFO: Processing hook\n  hook-pywintypes 5046 INFO: Processing hook hook-distutils 7750 INFO:\n  Hidden import 'codecs' has been found otherwise 7750 INFO: Hidden\n  import 'encodings' has been found otherwise 7750 INFO: Looking for\n  run-time hooks 7750 INFO: Analyzing rthook\n  C:\\python27\\lib\\site-packages\\PyInstaller\\loader\\rth\n  ooks\\pyi_rth_twisted.py 8111 INFO: Analyzing rthook\n  C:\\python27\\lib\\site-packages\\PyInstaller\\loader\\rth\n  ooks\\pyi_rth_django.py 8121 INFO: Processing hook hook-django.core\n  8131 INFO: Processing hook hook-django.core.management 8401 INFO:\n  Processing hook hook-django.core.mail 8862 INFO: Processing hook\n  hook-django.db 9112 INFO: Processing hook hook-django.db.backends 9153\n  INFO: Processing hook hook-django.db.backends.mysql 9163 INFO:\n  Processing hook hook-django.db.backends.mysql.base 9163 INFO:\n  Processing hook hook-django.db.backends.oracle 9183 INFO: Processing\n  hook hook-django.db.backends.oracle.base 9253 INFO: Processing hook\n  hook-django.core.cache 9874 INFO: Processing hook hook-sqlite3 10023\n  INFO: Processing hook hook-django.contrib 10023 INFO: Processing hook\n  hook-django.contrib.sessions 11887 INFO: Using Python library\n  C:\\Windows\\system32\\python27.dll 12226 INFO: Warnings written to\n  C:\\Users\\username\\Documents\\scrapyexe\\build\\runspid\n  er\\warnrunspider.txt 12256 INFO: checking PYZ 12256 INFO: rebuilding\n  out00-PYZ.toc because out00-PYZ.pyz is missing 12256 INFO: building\n  PYZ (ZlibArchive) out00-PYZ.toc 16983 INFO: checking PKG 16993 INFO:\n  rebuilding out00-PKG.toc because out00-PKG.pkg is missing 16993 INFO:\n  building PKG (CArchive) out00-PKG.pkg 19237 INFO: checking EXE 19237\n  INFO: rebuilding out00-EXE.toc because runspider.exe missing 19237\n  INFO: building EXE from out00-EXE.toc 19237 INFO: Appending archive to\n  EXE C:\\Users\\username\\Documents\\scrapyexe\\dist\\run spider.exe\n\nrunning built exe \"runspider.exe\": \n\nC:\\Users\\username\\Documents\\scrapyexe\\dist>runspider.exe\nTraceback (most recent call last):\nFile \"\", line 2, in \nFile \"C:\\python27\\Lib\\site-packages\\PyInstaller\\loader\\pyi_importers.py\", line\n  270, in load_module\nexec(bytecode, module.dict)\nFile \"C:\\Users\\username\\Documents\\scrapyexe\\build\\runspider\\out00-PYZ.pyz\\scrapy\"\n  , line 10, in \nFile \"C:\\Users\\username\\Documents\\scrapyexe\\build\\runspider\\out00-PYZ.pyz\\pkgutil\n  \", line 591, in get_data\nFile \"C:\\python27\\Lib\\site-packages\\PyInstaller\\loader\\pyi_importers.py\", line\n   342, in get_data\nfp = open(path, 'rb')\nIOError: [Errno 2] No such file or directory: 'C:\\Users\\username\\AppData\\Local\\\n  \\Temp\\_MEI15522\\scrapy\\VERSION'\n\nI'm extremely helpful for any kind of help. I need to know how to build standalone exe from scrapy spider for windows. \nThank you very much for any help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2324,"Q_Id":25557693,"Users Score":0,"Answer":"You need to create a scrapy folder under the same directory as runspider.exe (the exe file generated by pyinstaller).\nThen copy the \"VERSION\" and \"mime.types\" files(default path: %USERPROFILE%\\AppData\\Local\\Programs\\Python\\Python37\\Lib\\site-packages\\scrapy) to the scrapy you just created in the scrappy folder you create . (If you only copy \"VERSION\", you will be prompted to find the \"mime.types\" file)","Q_Score":1,"Tags":"python,windows-7,scrapy,pyinstaller,scrapy-spider","A_Id":52980333,"CreationDate":"2014-08-28T20:43:00.000","Title":"Pyinstaller scrapy error:","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to set an IAM role to my EMR cluster with mrjob 0.4.2.\nI saw that there is a new option in 0.4.3 to do this, but it is still in development and I prefer to use the stable version instead.\nAny idea on how to do this? I have tried to create the cluster using Amazon's console and then run the bootstrap+step actions using mrjob (by connecting to that cluster) but it didn't worked.\nAnother option is being able to change the default permissions for EMR instances so mrjob will be able to take advantage of it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":142,"Q_Id":25604247,"Users Score":0,"Answer":"Well, after many searches, it seems there is no such option","Q_Score":2,"Tags":"python,emr,mrjob","A_Id":26083485,"CreationDate":"2014-09-01T10:53:00.000","Title":"How to set IAM role with MrJob 0.4.2 on EMR","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to install Pygame and it returns me the following error \"Python version 3.4 required which was not found in the registry\". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem? \nI've been using Windows 8.1\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":1096,"Q_Id":25625097,"Users Score":3,"Answer":"Are you using a 64-bit operating system? Try using the 32-bit installer.","Q_Score":2,"Tags":"python-3.x,pygame","A_Id":25628838,"CreationDate":"2014-09-02T13:51:00.000","Title":"Error installing Pygame \/ Python 3.4.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to install Pygame and it returns me the following error \"Python version 3.4 required which was not found in the registry\". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem? \nI've been using Windows 8.1\nThanks in advance.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1096,"Q_Id":25625097,"Users Score":0,"Answer":"Tips I can provide:\n\nAdd Python to your Path file in the Advanced settings of your Environmental Variables (just search for it in the control panel)\nSomething may have gone wrong with the download of Python, so re-install it. Also don't download the 64-bit version, just download the 32-bit version from the main pygame website\nOnce that's sorted out, transfer the entire Pygame file to the site packages in the Python directory and open up the pygame file and go to this directory in command prompt. Finally, run the Pygame setup from the command prompt which should be something like:\npython setup.py\n\nBut this will only work if the pygame setup file is called setup.py (it's been a while since I downloaded it), you added Python to the Path file and you're currently in the correct directory in command prompt.\nTo test if it worked try importing pygame and see if you got an error or not.","Q_Score":2,"Tags":"python-3.x,pygame","A_Id":25628949,"CreationDate":"2014-09-02T13:51:00.000","Title":"Error installing Pygame \/ Python 3.4.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Comically enough, I was really annoyed when tkinter windows opened in the background on Mac. However, now I am on Linux, and I want tkinter to open in background.\nI don't know how to do this, and when I google how to do it, all I can find are a lot of angry Mac users who can't get tkinter to open in the foreground.\nI should note that I am using python2.7 and thus Tkinter not tkinter (very confusing).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":25648912,"Users Score":0,"Answer":"I am using Linux Mint. In order to make a program not show up in the foreground (i.e. be hidden behind all of the other windows), one should use root.lower() as aforementioned in the comments. However, please note (and this seems to happen on multiple platforms) that root.lower() will not change the focus of the window. Therefore, even if you use .lower() and run the script, and if you press [alt] + [F4], for example, the Tkinter window that was just opened (even though you cannot see it) will be closed.\nI noticed, however, that it is prudent to place the root.lower() after attributes for the Tkinter root. For example, if you use root.attributes(\"-zoomed\", True) to expand the window, be sure to place root.lower() after the root.attributes(..). Moreover, it did not work for me when I put root.lower() before root.attributes(..).","Q_Score":0,"Tags":"python-2.7,tkinter","A_Id":25689654,"CreationDate":"2014-09-03T16:04:00.000","Title":"Start Tkinter in background","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use abbrev-mode in python-mode.\nAbbrevs work fine in python code but doesn't work in python comments. \nHow can I make them work in python comments too?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":25681118,"Users Score":0,"Answer":"IIRC this was a bug in python.el and has been fixed in more recent versions.  Not sure if the fix is in 24.3 or in 24.4.\nIf it's still in the 24.4 pretest, please report it as a bug.","Q_Score":0,"Tags":"python,emacs,comments,abbreviation,python-mode","A_Id":25692694,"CreationDate":"2014-09-05T07:58:00.000","Title":"Emacs: how to make abbrevs work in python comments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create my own VNC client and would like to know how to directly access system display memory on Linux? So that I can send it over a Socket or store it in a file locally.\nI have researched a bit and found that one way to achieve this is to capture the screen at a high frame rate (screenshot), convert it into RAW format, compress it and store it in an ArrayList.\nBut, I find this method a bit too resource heavy. So, was searching for alternatives.\nPlease, let me also know if there are other ways for the same (using Java or Python only)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":886,"Q_Id":25699308,"Users Score":0,"Answer":"directly access system display memory on Linux\n\nYou can't. Linux is a memory protected virtual address space operating system. Ohh, the kernel gives you access to the graphics memory through some node in \/dev but that's not how you normally implement this kind of thing.\nAlso in Linux you're normally running a display server like X11 (or in the future something based on the Wayland protocol) and there might be no system graphics memory at all.\n\nI have researched a bit and found that one way to achieve this is to capture the screen at a high frame rate (screen shot), convert it into RAW format, compress it and store it in an ArrayList.\n\nThat's exactly how its done. Use the display system's method to capture the screen. It's the only reliable way to do this. Note that if conversion or compression is your bottleneck, you'd have that with fetching it from graphics memory as well.","Q_Score":1,"Tags":"java,python,memory,vnc","A_Id":25699358,"CreationDate":"2014-09-06T10:28:00.000","Title":"How to access system display memory \/ frame buffer in a Java program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have got a problem. I want to get the pixeled size of my turtle in Python, but how do I get it?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":8354,"Q_Id":25712856,"Users Score":1,"Answer":"I know exactly what you mean, shapesize does not equal the width in pixels and it had me buggered for a day or 2.\nI ended up changing the turtle shape to a square and simply using print screen in windows to take a snap shot of the canvas with the square turtle in the middle, then took that print screen into Photoshop to zoom right up to the square until i could see the pixel grid, i found that the default size of the square turtle is 21x21 pixels, who knows why they made it 21 but i found if i take some solid value i want the turtle to be in pixels like 20 and divide that by the 21 i get 0.9523...\nRounding the value to 0.95 and putting that into the shapesize gave me a square turtle of exactly 20x20 pixels and made it much easier to work with, you can do this with any number you want the turtle to be in pixels but i have only tried it with the square turtle.\nI hope that helps somewhat or gives you an idea of how to find the turtle size in pixels, ms-paint will do the same providing you goto the view tab and turn on grid then zoom in as far as you can.","Q_Score":1,"Tags":"python,size,pixels,turtle-graphics","A_Id":35849771,"CreationDate":"2014-09-07T17:19:00.000","Title":"Python: Turtle size in pixels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Celery and I can't figure out at all how I can do what I need. I have seen how to create tasks by myself and change Django's file settings.py in order schedule it. But I want to allow users to create \"customized\" tasks.\nI have a Django application that is supposed to give the user the opportunity to create the products they need (files that gather weather information) and to send them emails at a frequency they choose.\nI have a database that contains the parameters of every product like geographical time, other parameters and frequency. I also have a script sendproduct.py that sends the product to the user.\nNow, how can I simply create for each product, user created a task that execute my script with the given parameters and the given frequency?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":25728378,"Users Score":0,"Answer":"As you know how to create & execute tasks, it's very easy to allow customers to create tasks.\nYou can create a simple form to get required information from the user. You can also have a profile page or some page where you can show user preferences.\nThe above form helps to get data(like how frequently he needs to receive eamils) from user. Once the form is submitted, you can trigger a task asynchronously which will does processing & send emails to customer.","Q_Score":0,"Tags":"python,django,task,customization,celery","A_Id":25728619,"CreationDate":"2014-09-08T16:03:00.000","Title":"How the user of my Django app can create \"customized\" tasks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a web app in django and I want to integrate it with the php web app that my friend has build.\nPhp web app is like forum where students can ask question to the teachers. For this they have to log in. \nAnd I am making a app in django that displays a list of colleges and every college has information about teachers like the workshop\/classes timing of the teachers. In my django app colleges can make their account and provide information about workshop\/classes of the teachers. \nNow what I want is the student that are registered to php web app can book for the workshop\/classes provided by colleges in django app and colleges can see which students and how many students have booked for the workshop\/classes. \nHere how can I get information of students from php web app to django so that colleges can see which students have booked for workshop. Students cannot book for workshop untill they are logged in to php web app. \nPlease give me any idea about this.. How can I make this possible","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":25739840,"Users Score":2,"Answer":"You must use one of these possibilities:\n\nYour friend gives you direct access (even only read access) to his database and you represent everything as Django models or use raw SQL. The problem with that approach is that you have a very high-coupling between the two systems. If he changes his table or scheme structure for some reason you will also have to be notified and change stuff on your end. Which is a real headache. \nYour friend provides an API end-point from his system that you can access. This protocol can be simple GET requests to retrieve information that return JSON or any other format that suites you both. That's the simplest and best approach for the long run.\nYou can \"fetch\" content directly from his site, that returns raw HTML for every request, and then you can scrape the response you receive. That's also a headache in case he changes his site structure, and you'll need to be aware of that.","Q_Score":0,"Tags":"php,python,django","A_Id":25740202,"CreationDate":"2014-09-09T08:23:00.000","Title":"passing user information from php to django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I wish to make some modifications to the Django admin interface (specifically, remove the \"change\" link, while leaving the Model name as a link to the page for changes to the instances). I can achieve this by copying and pasting index.html from the admin application, and making the modifications to the template, but I would prefer to only override the offending section by extending the template - however I am unsure how to achieve this as the templates have the same name. I am also open to alternative methods of achieving this effect. (django 1.7, python 3.4.1)","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4302,"Q_Id":25748396,"Users Score":7,"Answer":"Worked it out - I set admin.site.index_template = \"my_index.html\" in admin.py, and then the my_index template can inherit from admin\/index.html without a name clash.","Q_Score":4,"Tags":"python,django,django-admin","A_Id":25763182,"CreationDate":"2014-09-09T15:23:00.000","Title":"Django Extend admin index","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Python api to insert message into the RabbitMQ,and then use go api to get message from the RabbitMQ.\nKey 1: RabbitMQ ACK is set false because of performance.\nI insert into RabbitMQ about over 100,000,000 message by python api,but when I use go api to  get\nmessage,I find the insert number of message isn\u2019t equal to the get number.The insert action and the\nget action are concurrent.\nKey 2:Lost message rate isn\u2019t over 1,000,000 percent 1.\nInsert action has log,python api shows that all inserted message is successful. \nGet action has log,go api shows that all get message is successful.\nBut the number isn\u2019t equal.\nQuestion1:I don\u2019t know how to find the place where the message lost.Could anyone give me a suggestion how to find where the message lost?\nQuestion2:Is there any strategy to insure the message not lose?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2544,"Q_Id":25749566,"Users Score":1,"Answer":"In order for you to test that all of your messages are published you may do it this way:\n\nStop consumer.\nEnable acknowledgements in publisher. In python you can do it by adding extra line to your code: channel.confirm_delivery(). This will basically return a boolean if message was published. Optionally you may want to use mandatory flag in basic_publish.\nSend as many messages as you want. \nMake sure that all of the basic_publish() methods returnes True.\nCount number of messages in Rabbit.\nEnable Ack in consumer by doing no_ack = False \nConsume all the messages.\n\nThis will give you an idea where your messages are getting lost.","Q_Score":0,"Tags":"python,go,rabbitmq","A_Id":25749840,"CreationDate":"2014-09-09T16:21:00.000","Title":"RabbitMQ message lost","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently developing a site with Python + Django and making the login I started using the request.session[\"\"] variables for the session the user was currently in, and i recently realized that when i do that it generates a cookie with the \"sessionid\" in it with a value every time the user logs in, something like this \"c1cab412bc71e4xxxx1743344b3edbcc\" and if I take that string and paste it in the cookie on other computer in other network and everything, i can have acces to the session without login in.\nSo what i'm asking here actually is if anyone can give me any tips of how can i add some security on my system or if i'm doing something wrong setting session variables?\nCan anyone give me any suggestions please?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":357,"Q_Id":25770457,"Users Score":0,"Answer":"Sadly, there is no best way you can prevent this from what I know but you can send the owner of an account an email and set some type of 2fa.","Q_Score":3,"Tags":"python,django,cookies","A_Id":72094059,"CreationDate":"2014-09-10T16:21:00.000","Title":"Django session id security tips?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to figure out a way to call wget from my python script on a windows machine.  I have wget installed under \/bin on the machine.  Making a call using the subprocess or os modules seems to raise errors no matter what I try.  I'm assuming this is related to the fact that I need to route my python system call through minGW so that wget is recognized.\nDoes anyone know how to handle this?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1827,"Q_Id":25776832,"Users Score":1,"Answer":"There's no such thing as under \"MinGW\". You probably mean under MSYS, a Unix emulation environment for Windows. MSYS makes things look like Unix, but you're still running everything under Windows. In particular MSYS maps \/bin to the drive and directory where you install MSYS. If you installed MSYS to C:\\MSYS then your MSYS \/bin directory is really C:\\MSYS\\bin.\nWhen you add \/bin to your MSYS PATH environment variable, MSYS searches the directory C:\\MSYS\\bin. When you add \/bin to the Windows PATH environment using the command SETX, Windows will look in the \\bin directory of the current drive. \nPresumably your version of Python is the standard Windows port of Python. Since it's a normal Windows application, it doesn't interpret the PATH environment variable the way you're expecting it to. With \/bin in the path, it will search the \\bin directory of the current drive. Since wget is in C:\\MSYS\\bin not \\bin of the current directory you an error when trying to run it from Python.\nNote that if you run a Windows command from the MSYS shell, MSYS will automatically convert its PATH to a Windows compatible format, changing MSYS pathnames into Windows pathnames. This means you should be able to get your Python script to work by running Python from the MSYS shell.","Q_Score":0,"Tags":"python,windows,wget,system-calls,mingw32","A_Id":25780451,"CreationDate":"2014-09-10T23:44:00.000","Title":"System Call in Python via MINGW32 on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need to test whether several .py scripts (all part of a much bigger program) work after updating python. The only thing I have is their path. Is there any intelligent way how to find out from which other scripts are these called? Brute-forece grepping wasn't as good aas I expected.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":497,"Q_Id":25792285,"Users Score":0,"Answer":"I combined two things:\n\nran automated tests with the old and new version of pythona nd compared results\nused snakefood to track the dependencies and ran the parent scripts\n\nThanks for the os.walk and os.getppid suggestion, however, I didn't want to write\/use any additional code.","Q_Score":1,"Tags":"python,bash,shell","A_Id":25974955,"CreationDate":"2014-09-11T16:09:00.000","Title":"How to find out from where is a Python script called?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a python application that can continuously receive data from a webserver. This python application will be running on multiple personal computers, and whenever new data is available it will receive it. I realize that I can do this either by long polling or web sockets, but the problem is that sometimes data won't be transferred for days and in that case long polling or websockets seem to be inefficient. I won't be needing that long of a connection but whenever data is available I need to be able to push it to the application. I have been reading about webhooks and it seems that if I can have a url to post that data to, I won't need to poll. But I am confused as to how each client would have a callback url because in that case a client would have to act as a server. Are there any libraries that help in getting this done? Any kind of resources that you can point me to would be really helpful!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":25797494,"Users Score":0,"Answer":"There is no way to send data to the client without having some kind of connection, e.g. either websockets or (long) polling done by the client. While it would be possible in theory to open a listener socket on the client and let the web server could connect to and sent the data to this socket, this will not work in reality. The main reason for thi is, that the client is often inside an internal network not reachable from outside, i.e. a typical home setup with multiple computers behind a single IP or a corporate setup with a firewall in between. In this case it is only possible to establish a connection from inside to outside, but not the other way.","Q_Score":0,"Tags":"python,sockets,real-time,long-polling,webhooks","A_Id":25800249,"CreationDate":"2014-09-11T21:48:00.000","Title":"Is it possible to implement webhooks on regular clients?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a C application that makes use of Python's AST API to transform Python code expressions before emitting bytecode. I've been a longtime POSIX developer (currently OS X), but I wish learn how to port my projects to Windows as well.\nI'm using the static libraries (.lib) generated by build.bat in Python's PCBuild directory. The trouble with these libraries is they somehow skip over the symbols in Python\/Python-ast.c as well as Python\/asdl.c. I need these APIs for their AST constructors, but I'm not sure how to get Visual Studio to export them.\nDo I need to add __declspec(dllexport) for static libraries? \nEDIT: I do not have this problem with static libraries generated on POSIX platforms","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":25800481,"Users Score":0,"Answer":"OK, I figured it out\nI was using VS 2013 while Python's build system was designed for VS 2010.\nI ended up retargeting everything for 2013 (including a small modification to the tix makefile) and it compiled with all non-static symbols (AST and all) as expected.\nPython.org's official pre-built Windows libraries still seem to omit the AST symbols. I don't mind building Python from source myself, but I think the official builds should package the whole shebang.","Q_Score":0,"Tags":"python,visual-studio,cpython","A_Id":25815355,"CreationDate":"2014-09-12T03:56:00.000","Title":"Exporting cpython AST symbols on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a (probably) simple question that the internet seems to be of no help with. I would like to make several python programs interact within another python program and have no idea how to get them to put input into each other. My eventual idea is to (as a proof of concept) have one program act as the environment and the others act as creatures in that environment. let me clarify: I am sure you have seen those programs that simulate natural environments with the creatures in them interacting. I would like to do the same kind of thing just on a smaller scale (text in the place of fancy 3d graphics if at all). The ultimate goal of this is not to have a complex ecosystem but to see how far I can push the communication between the programs (and my computer's power along the way). \nP.S. I would like to continue to run it from the IDLE or from the command line.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":25814134,"Users Score":0,"Answer":"You have a lot of choices for exhanging messages between programs or components:\n\nYou can write output files that other programs can read and act on.  You'd like to see if the consumer could watch a directory for a file and react when it arrived.\nYou could make them distributed components that exchanged messages via sockets or some higher level protocol like HTTP.  The communication could be synchronous or asynchronous.\nYou could connect them as producers writing to message queues or topics and consumers listening to the queue or topic for events.","Q_Score":0,"Tags":"python,controls,communication","A_Id":25814194,"CreationDate":"2014-09-12T17:59:00.000","Title":"Python programs communicating","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I installed PyDev in Eclipse and started testing it and I have come to an issue.  \nWhile using IDLE to run Python I could, for example, create a file, set a variable x = 10 and then make IDLE run said file.  I would then be able to ask python for x and it would give me 10.  I don't know how to do that in PyDev.   \nI created a python interactive console and then when prompted chose the \"Console for currently active editor\" but the console will not recognize x even though the editor has x defined to 10.  I did save before creating the console, I also ran the file before I opened the console... I do not know what to do...\nThank you!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":251,"Q_Id":25820713,"Users Score":0,"Answer":"Hmmm, I am not familiar with the IDE IDLE, nor do I typically run a file via the console, but maybe I understand your question. The core answer is you need a breakpoint so that execution does not terminate and therefore x=10 is resident in memory. If the breakpoint is set post x=10, then when you reach the breakpoint  and execution stops and you type \"x\" you will get 10.\n   There is documentation online on the console about how to use it in context of a load of file from with the console.  I tend instead to hit shift-F9 while in the file to run it in debug mode. This leaves you in debug console rather than interactive console (you'll see no prompting \">\") but you'll still be able to have x=10 when you enter x at break.\n   Probably misunderstood but though I would give it a shot. Good luck!","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":25823825,"CreationDate":"2014-09-13T06:59:00.000","Title":"PyDev Interactive Console Issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My Sphinx input is six rst files and a bunch of PNGs and JPGs. Sphinx generates the correct HTML, but when I make pdf I get an output file that comes up blank in Adobe Reader (and comes up at over 5000%!) and does not display at all in Windows Explorer. \nThe problem goes away if I remove various input files or if I edit out what looks like entirely innocuous sections of the input, but I cannot get a handle on the specific cause. Any ideas on how to track this one down? Running Sphinx build with the -v option shows no errors.\nI'm using the latest Sphinx (1.2.3) and the latest rst2pdf (0.93), with the default style. On Win7.\n(added) This may help others with the same problem: I tried concatenating the rst files, then running rst2pdf on the concatenated file. That worked, though it gave me a bunch of warnings for bad section hierarchy and could not handle the Sphinx :ref: stuff. Could the bad section hierarchy thing (i.e. ==, --, ~~ in one file, ==, ~~, -- in another) be connected to the hopeless PDFs? Removing the conflict does not solve the problem, but that doesn't mean it's not a clue!\nI could explore more if I could capture the output that Sphinx sends to rst2pdf.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1143,"Q_Id":25838717,"Users Score":0,"Answer":"We had a similar problem: bad pdf output on project with a lot of chapters and images.\nWe solved disabling the break page: in the conf.py, set the pdf_break_level value at 0.","Q_Score":0,"Tags":"pdf,python-sphinx,rst2pdf","A_Id":37615276,"CreationDate":"2014-09-14T22:39:00.000","Title":"Sphinx PDF output is bad. How do I chase down the cause?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program, stored on Dropbox, which runs via cron on a couple of different machines. For some reason, recently one of the .pyc files is being created with root as the owner, which means that Dropbox doesn't have permission to sync it anymore.\nWhy would it do that, and how do I change it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":935,"Q_Id":25852330,"Users Score":1,"Answer":"That would happen if you're running the python program as root (which would happen if you're using root's crontab).\nTo fix it, just remove it with sudo rm \/path\/to\/file.pyc, and make sure to run the program as your user next time. If you want to keep using root's crontab, you could use su youruser -c yourprogram, but the cleanest way would be simply to use your user's crontab","Q_Score":1,"Tags":"python,cron,crontab","A_Id":25852354,"CreationDate":"2014-09-15T16:09:00.000","Title":"Python pyc files created with root as owner","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to use the OS module in python to save a jpeg created by the screenshot() function in Kivy? I am on Android so I want to find a way to make it so that the screenshot() gets saved in \/sdcard\/Pictures.\nIf I don't have to use the OS module, how would I do it?\nPlease use examples and add code snippets that other users and I can use for future reference.\nI have been stuck on this issue for a long time.\nThanks in advance!!!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":77,"Q_Id":25858087,"Users Score":1,"Answer":"I want to find a way to make it so that the screenshot() gets saved in \/sdcard\/Pictures.\n\nThe argument to screenshot is the filepath to save at, just write Window.screenshot('\/sdcard\/Pictures').","Q_Score":0,"Tags":"android,python,python-2.7,kivy","A_Id":25858139,"CreationDate":"2014-09-15T22:52:00.000","Title":"How to use os module to save a jpeg to a cretin path- Using kivy screenshot()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a graph in Networkx by importing edge information in through nx.read_edgelist(). This all works fine and the graph loads. \nThe problem is when I print the neighbors of a node, I get the following for example... \n[u'own', u'record', u'spending', u'companies', u'back', u'shares', u'their', u'amounts', u'are', u'buying']\nThis happens for all calls to the nodes and edges of the graph. It is obviously not changing the names of the nodes seeing as it is outside of the quotations. \nCan someone advise me how to get rid of these 'u's when printing out the graph nodes.\nI am a Python novice and I'm sure it is something very obvious and easy.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":539,"Q_Id":25872043,"Users Score":1,"Answer":"You don't need to get rid of them, they don't do anything other than specify the encoding type. This can be helpful sometimes, but I can't think of a time when it isn't helpful.","Q_Score":1,"Tags":"python,graph,networkx","A_Id":25872307,"CreationDate":"2014-09-16T14:54:00.000","Title":"Networkx appends 'u' before node names after reading in from an edge list. How to get rid?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to store the job in mongodb using python and it should schedule on specific time. \nI did googling and found APScheduler will do. i downloaded the code and tried to run the code.\nIt's schedule the job correctly and run it, but it store the job in apscheduler database of mongodb, i want to store the job in my own database.\nCan please tell me how to store the job in my own database instead of default db.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":708,"Q_Id":25884242,"Users Score":1,"Answer":"Simply give the mongodb jobstore a different \"database\" argument. It seems like the API documentation for this job store was not included in what is available on ReadTheDocs, but you can inspect the source and see how it works.","Q_Score":0,"Tags":"mongodb,python-2.7,apscheduler","A_Id":25898609,"CreationDate":"2014-09-17T07:01:00.000","Title":"APScheduler store job in custom database of mongodb","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I originally installed Canopy to use Python, but it would not recognize the SPSS modules, so I removed canopy, re-downloaded python2.7, and changed my PATH to ;C:\\Python27. In SPSS, I changed the default python file directory to C:\\Python27.\nPython still will not import the SPSS modules. I have a copy of SPSS 22, so python is integrated into it...\nAny thoughts on what might be causing this, and how to fix it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":399,"Q_Id":25891415,"Users Score":1,"Answer":"Glad that is solved.  The 32\/64-bit issue has been a regular confusion for Statistics users.","Q_Score":0,"Tags":"python,spss","A_Id":25896919,"CreationDate":"2014-09-17T13:05:00.000","Title":"How can I get Python to recognize the SPSSClient Module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I originally installed Canopy to use Python, but it would not recognize the SPSS modules, so I removed canopy, re-downloaded python2.7, and changed my PATH to ;C:\\Python27. In SPSS, I changed the default python file directory to C:\\Python27.\nPython still will not import the SPSS modules. I have a copy of SPSS 22, so python is integrated into it...\nAny thoughts on what might be causing this, and how to fix it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":399,"Q_Id":25891415,"Users Score":1,"Answer":"I figured this out only with some help from a friend who had a similar issue. I had downloaded python from python.org, without realizing it was 32 bit. All of the SPSS modules are 64 bit! I downloaded the correct version of python, and then copied the spss modules from my spss install (inside the python folder within spss) into my python library. modules are working now!","Q_Score":0,"Tags":"python,spss","A_Id":25892696,"CreationDate":"2014-09-17T13:05:00.000","Title":"How can I get Python to recognize the SPSSClient Module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using PyCharm, and in the shell, I can't run a file that isn't in the current directory. I know how to change directories in the terminal. But I can't run files from other folders. How can I fix this? Using Mac 2.7.8. Thanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1132,"Q_Id":25902367,"Users Score":1,"Answer":"There are multiple ways to solve this. \n\nIn PyCharm go to Run\/Edit Configurations and add the environment variable PYTHONPATH to $PYTHONPATH: and hit apply. The problem with this approach is that the imports will still be unresolved but the code will run fine as python knows where to find your modules at run time.\nIf you are using mac or unix systems. Use the command \"EXPORT PYTHONPATH=$PYTHONPATH:\". If Windows, you will have to add the directory to the PYTHONPATH environment variable.\nThis is as plarke suggested.","Q_Score":1,"Tags":"python,pycharm,pythonpath","A_Id":26268411,"CreationDate":"2014-09-18T00:24:00.000","Title":"In Python, how can I run a module that's not in my path?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Write a function called getUsername which takes two input parameters, firstname (string) and surname (string), and both returns and prints a username made up of the first character of the firstname and the first four characters of the surname. Assume that the given parameters always have at least four characters.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":25924639,"Users Score":0,"Answer":"This is how you build the string: firstname[0] + surname[:4]","Q_Score":0,"Tags":"python","A_Id":25924663,"CreationDate":"2014-09-19T00:42:00.000","Title":"python idle how to create username?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to python. I'm trying to write an application with command line interface. The main application is communicating with server using tcp protocol. I want it to work in the background so I won't have to connect with the server every time I use interface. What is a proper approach to such a problem? \nI don't want the interface to be an infinite loop. I would like to use it like this:\nmy_app.py command arguments. \nPlease note that I have no problems with writing interface (I'm using argparse library right now) but don't know what architecture would suit me best and how to implement it in python.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":25935799,"Users Score":0,"Answer":"If you put something in the background, then it's no longer connected to the current shell (or the terminal). So you would need the background process to open a socket so the command line part could send it the command.\nIn the end, there is no way around creating a new connection to the server every time you start the command line process and close the connection when the command line process exits.\nThe only alternative is to use the readline module to simulate the command line inside of your script. That way, you can open the connection, use readline to ask for any number of commands to send to the server. Plus you need an \"exit\" command which terminates the command line process (which also closes the server connection).","Q_Score":0,"Tags":"python,linux","A_Id":25936008,"CreationDate":"2014-09-19T14:02:00.000","Title":"Command line interface application with background process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in what order should I install things? My goal is to have python 2.7.6 running on a virtualenv for a project for work. I am working on a Virtual Box machine in CentOS 6.5. \nWhat folders should I be operating in to install things? I have never used linux before today, and was just kind of thrust into this task of getting a program running that requires python 2.7.6 and a bunch of packages for it. Thanks in advance if you can get me command line entries. I have opened about 3 Virtual Boxes and deleted them because I installed things in the wrong order. Please let me know how things should be installed, with command line entries, if possible.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1684,"Q_Id":25943156,"Users Score":0,"Answer":"With Linux you don't need to worry about where to install files, the OS takes care of that for you.  Google CentOS Yum and read the Yum docs on how to install everything.  You probably already have Python 2.7 installed, to check just open the terminal CTRL + ALT + T, and type python.  This will start the python interpreter and display the version.  The next step would be to see if pip and virtualenv are installed. You can simply type the command at the command prombt (exit python first).  If you get something to the effect of command not found then you need to install them. Install pip with the Yum installer and virtualenv with pip. If everything is install then you just need to make your virtual environment, ex virtualenv name_of_directory, if the directory doesn't exist then yum will create it. And now you're done.","Q_Score":0,"Tags":"python,linux,installation,virtualenv,redhat","A_Id":25943276,"CreationDate":"2014-09-19T22:18:00.000","Title":"Redhat Python 2.7.6 installation on virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently started learning Python, and I received a question: \"Write a Python program that asks the user to enter full name in the following format:\nLastName, FirstName MiddleName\n(for Example: \"Hun, Attila The\u201d).\nThe input will have a single space after the comma and only a single space between the first name and the middle name. Use string methods and operators in Python to convert this to a new string having the form:\nFirstName MiddleInitial Period LastName (for example: \"Attila T. Hun\") and output it.\"\nIt is easy for me to do this if I make three different variables, and then reorder\/slice them later. But how do I do this in one variable only. I know I will need to slice up until \",\" for the LastName, but I can't do \"[0:,]\" as I am not using an integer value, so how do i find the integer value for it, if the lastName will vary from user to user.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":261,"Q_Id":25964881,"Users Score":0,"Answer":"Instead of using index, use split and split on the various separators. E.g., full_name.split(', ')[0] == 'Hun', full_name.split(', ')[1] == 'Attila', and full_name.split(' ')[-1] == 'The'. You can then easily recombine them with string formatting or simple concatenation.","Q_Score":0,"Tags":"python,indexing,slice","A_Id":25964934,"CreationDate":"2014-09-21T23:22:00.000","Title":"How to use the index method efficiently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"One of the Scrapy spiders (version 0.21) I'm running isn't pulling all the items I'm trying to scrape.\nThe stats show that 283 items were pulled, but I'm expecting well above 300 here. I suspect that some of the links on the site are duplicates, as the logs show the first duplicate request, but I'd like to know exactly how many duplicates were filtered so I'd have more conclusive proof. Preferably in the form of an additional stat at the end of the crawl.\nI know that the latest version of Scrapy already does this, but I'm kinda stuck with 0.21 at the moment and I can't see any way to replicate that functionality with what I've got. There doesn't seem to be a signal emitted when a duplicate url is filtered, and DUPEFILTER_DEBUG doesn't seem to work either. \nAny ideas on how I can get what I need?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":108,"Q_Id":25965606,"Users Score":0,"Answer":"You can maintain a list of urls that u have crawled , whenever you came across a url that is already in the list you can log it and increment a counter.","Q_Score":1,"Tags":"python,scrapy","A_Id":25967819,"CreationDate":"2014-09-22T01:33:00.000","Title":"Display the number of duplicate requests filtered in the post-crawler stats","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a calculator that converts cms into yards, feet, and inches. Example: 127.5 cm is 1 yard, 1 inch, etc. But I am just wondering how I am able to retain the value after the decimal place, is there a way to truncate the number before the decimal place. So if the user inputs a value that results into 3.4231 yards, I want to retain the value \".4231\" so that I can convert that into feet, and then the same for inches from feet. Sorry if this is unclear. This is for python 3","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":177,"Q_Id":26001543,"Users Score":1,"Answer":"What's wrong with the good old-fashioned value - int(value)?","Q_Score":1,"Tags":"python,decimal,truncate","A_Id":26002508,"CreationDate":"2014-09-23T17:49:00.000","Title":"Truncating values before the decimal point","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I change file extensions in windows 8? I tried and my system will not recognize the change.\nI tried changing from .txt to .py for python so i can use in IDLE.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5230,"Q_Id":26028253,"Users Score":1,"Answer":"I created a file called myfile.txt. It showed up in Explorer as myfile.txt. If you just see myfile (no extension), then go to Folder Options, Advanced, and uncheck \"Hide extensions for known file types\".\nI Right-clicked myfile.txt, selected Rename, and Windows selected just \"myfile\", not \".txt\". I changed the selection to \"txt\", overwrote it with \"py\" and hit enter. Windows popped up a message warning that I was changing the extension. I clicked OK and the file was renamed.\nAn alternate approach is to open a command prompt, cd to the directory and use \"move\" to change the name.\nYet another option, if you are doing this from a text editor, click \"Save As\", change the save dialog's \"Save As Type\" drop-down to All Files, change the name to .py and hit OK. You end up with a .txt and a .py.","Q_Score":1,"Tags":"python,windows-8","A_Id":26028450,"CreationDate":"2014-09-24T23:41:00.000","Title":"how to change file extensions in windows 8? i tried and it will not recognize the change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know if it is possible to run python-gui apps, like wxPython, on a c9.io remote server? I have my home server set up with c9 via SSH, and no issues logging in and running apps in the terminal on the VM. However, when I try to run GUI apps, I get the following error message. \nUnable to access the X Display, is $DISPLAY set properly?\nAfter searching and searching, I can't seem to find a guide or anything in the docs that detail how to set $DISPLAY in the script. X display is installed and active on my server, but I don't know how to configure the c9 script to access it properly. Any assistance would be appreciated!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":686,"Q_Id":26050414,"Users Score":1,"Answer":"I don't know if Cloud9 supports it but normally to run a remote GUI application you would have ssh forward the X11 communication over the ssh connection via a tunnel.  So basically the application is running on the remote system and it is communicating with a local X11 server which provides you with the display and handling of the mouse and keyboard.  \nIf you run ssh with the -X parameter then it will attempt to set up the X11 tunnel and set $DISPLAY in the remote shell so any GUI applications you run there will know how to connect to the X11 tunnel.  Bw aware however that this is something that can be turned off on the remote end, so ultimately it is up to Cloud9 whether they will allow you to do this.","Q_Score":0,"Tags":"python-2.7,wxpython","A_Id":26051264,"CreationDate":"2014-09-26T00:53:00.000","Title":"Running Python GUI apps on C9.io","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a question. In my c# application I need to get the free space of a directory. According to my research, GetdiskfreespaceEx is proper and it works for me in my windows xp. Now I'm wondering if it works the same in a linux system. Since I wrote my c# program according to a python one, and for this function the developer of the python one made 2 cases: the windows os or else. For the windows case                        \"ctypes.windll.kernel32.GetDiskFreeSpaceExW\" is used while in else case \"os.statvfs(folder)\" is used.\nI did some more research but haven't found anything saying if GetdiskfreespaceEx could be used for linux. Anyone could tell me that? If no, any ways to get free disk space for linux in c#? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":854,"Q_Id":26054851,"Users Score":0,"Answer":"For Linux you will find Statvfs in Mono.Unix.Native, in the Mono.Posix assembly.","Q_Score":2,"Tags":"c#,python,linux","A_Id":39438068,"CreationDate":"2014-09-26T08:04:00.000","Title":"Get free space of a directory in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I am a beginner on Python and was wondering how you can make a user input a number that contains two decimal places or less","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":26069257,"Users Score":0,"Answer":"Check out the wxPython demo, I would probably use the wx.lib.masked.numctrl for that.","Q_Score":0,"Tags":"python,python-2.7,python-3.x,wxpython,ipython","A_Id":26082455,"CreationDate":"2014-09-26T22:36:00.000","Title":"Python How to force user input to be to 2dp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python script running as a daemon. At startup, it spawns 5 processes, each of which connects to a Postgres database. Now, in order to reduce the number of DB connections (which will eventually become really large), I am trying to find a way of sharing a single connection across multiple processes. And for this purpose I am looking at the multiprocessing.sharedctypes.Value API. However, I am not sure how I can pass a psycopg2.connection object using this API across processes. Can anyone tell me how it might be done?\nI'm also open to other ideas in order to solve this issue.\nThe reason why I did not consider passing the connection as part of the constructor to the 5 processes is mutual exclusion handling. I am not sure how I can prevent more than one process from accessing the connection if I follow this approach. Can someone tell me if this is the right thing to do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5128,"Q_Id":26070040,"Users Score":12,"Answer":"You can't sanely share a DB connection across processes like that. You can sort-of share a connection between threads, but only if you make sure the connection is only used by one thread at a time. That won't work between processes because there's client-side state for the connection stored in the client's address space.\nIf you need large numbers of concurrent workers, but they're not using the DB all the time, you should have a group of database worker processes that handle all database access and exchange data with your other worker processes. Each database worker process has a DB connection. The other processes only talk to the database via your database workers.\nPython's multiprocessing queues, fifos, etc offer appropriate messaging features for that.","Q_Score":4,"Tags":"python,postgresql,psycopg2,python-multiprocessing","A_Id":26072257,"CreationDate":"2014-09-27T00:16:00.000","Title":"Share connection to postgres db across processes in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a django app which need to receive post requests from  another site using html+javascript.\nFor example i have mydjangosite.com and  smallhtmlsite.com\nWhat i want is : user visit smallhtmlsite.com and fill a form, then he pushing submit button and mydjangosite.com receive request and create objects(form saving models actually).\nSo i will have a view which will handle this requests. But how can these been done securely?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":389,"Q_Id":26080694,"Users Score":1,"Answer":"I have a django app which need to receive post requests from another\n  site using html+javascript.\n\nYou don't have to ! You can build an API instead ;)\nYou create an API call - small site calls the API of main site. In that situation, the form is handled by a view in small site and the API is called via the server. Check out Django REST Framework. \nNote: That solution wouldn't stop you from using AJAX but it would avoid cross domain issues.","Q_Score":0,"Tags":"javascript,python,django,forms,security","A_Id":26081085,"CreationDate":"2014-09-28T01:13:00.000","Title":"How to post a form to django site, securely and from another site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have developed an app in python and are using flask to expose its api via http requests.\n\nall this on WINDOWS - \n\nEverything works ok and we have tested in-house with no problems and we are now trying to use the app in the real world - we have gotten our IT dept to give us a public facing ip\/port address (forwarded through a firewall ??) and now we can't access the server\/app at all. \nAfter a bit of digging, we've found the problem has something to do with the Windows Firewall configuration, when its on it won't work, when its off everything is fine.\nthe flask app code is run like so: app.run(debug=False, host='0.0.0.0', port=8080)\nthe port 8080 is setup in the Firewall Exceptions as is python.exe in the Program Exceptions\nnetstat -a shows the app is sitting there awaiting connection.\nIf I try to access the site though chrome I get the error: ERR_CONNECTION_TIMED_OUT.\nWith the firewall on i'm never seeing any \"hits\" come through to the app at all.\nIs there some other configuration I'm missing?\nMany thanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8285,"Q_Id":26102680,"Users Score":1,"Answer":"When running as a service the program running the service is not python.exe but rather pythonservice.exe. You will have to add that to the allowed programs in the Windows Firewall Setup.  In my case it is located under C:\\Python33\\Lib\\site-packages\\win32\\pythonservice.exe.","Q_Score":3,"Tags":"python,flask,windows-firewall","A_Id":28746633,"CreationDate":"2014-09-29T14:49:00.000","Title":"how do i configure python\/flask for public access with windows firewall","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have CSV files that I want to make database tables from in mysql. I've searched all over and can't find anything on how to use the header as the column names for the table. I suppose this must be possible. In other words, when creating a new table in MySQL do you really have to define all the columns, their names, their types etc in advance. It would be great if MySQL could do something like Office Access where it converts to the corresponding type depending on how the value looks. \nI know this is maybe a too broadly defined question, but any pointers in this matter would be helpful. I am learning Python too, so if it can be done through a python script that would be great too. \nThank you very much.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3067,"Q_Id":26108160,"Users Score":0,"Answer":"The csv module can easily give you  the column names from the first line, and then the values from the other ones. The hard part will be do guess the correct column types. When you load a csv file into an Excel worksheet, you only have few types : numeric, string, date.\nIn a database like MySQL, you can define the size of string columns, and you can give the table a primary key and eventually other indexes. You will not be able to guess that part automatically from a csv file.\nAt the simplest way, you can treat all columns as varchar(255). It is really uncommon to have fields in a csv file that do not fit in 255 characters. If you want something more clever, you will have to scan the file twice : first time to control the maximum size for each colum, and at the end, you could take the minimum power of 2 greater than that. Next step would be to control if any column contains only integers or floating point values. It begins to be harder to do that automatically, because the representation of floating point values may be different depending on the locale. For example 12.51 in an english locale would be 12,51 in a french locale. But Python can give you the locale.\nThe hardest thing would be eventual date or datetime fields, because there are many possible formats only numeric (dd\/mm\/yyyy or mm\/dd\/yy) or using plain text (Monday, 29th of september).\nMy advice would be to define a default mode, for example all string, or just integer and strings, and use configuration parameters or even a configuration file to finely tune conversion per column.\nFor the reading part, the csv module will give you all what you need.","Q_Score":0,"Tags":"python,mysql,sql,csv","A_Id":26108522,"CreationDate":"2014-09-29T20:19:00.000","Title":"create database by load a csv files using the header as columnnames (and add a column that has the filename as a name)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a log file by the name log.json.\nA simple insert in rethinkdb works perfectly.\nNow this json file get updated every second, how to make sure that the rethinkdb gets the new data automatically, is there a way to achieve this, or i have to simply use the API and insert into db as well as log in a file if i want to.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":167,"Q_Id":26109520,"Users Score":2,"Answer":"The process that appends new entries in your json file should probably run query to insert the same entries in RethinkDB.\nOr you can have a cron job that\n\nget the last entry saved from rethinkdb\nread your json file for new entries\ninsert new entries","Q_Score":1,"Tags":"rethinkdb,rethinkdb-python","A_Id":26109631,"CreationDate":"2014-09-29T21:52:00.000","Title":"Insert json log files in rethinkdb?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to remove null padding from UDP packets sent from a Linux computer. Currently it pads the size of the packet to 60 bytes.\nI am constructing a raw socket using AF_PACKET and SOCK_RAW. I created everything from the ethernet frame header, ip header (in which I specify a packet size of less than 60) and the udp packet itself.\nI send over a local network and the observed packet in wireshark has null padding.\nAny advice on how to overcome this issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1669,"Q_Id":26113419,"Users Score":2,"Answer":"This is pretty much impossible without playing around with the Linux drivers. This isn't the best answer but it should guide anyone else looking to do this in the right direction.3\nType \nsudo ethtool -d eth0 \nto see if your driver has pad short packets enabled.","Q_Score":0,"Tags":"python,sockets,udp,padding","A_Id":26326206,"CreationDate":"2014-09-30T05:33:00.000","Title":"Removing padding from UDP packets in python (Linux)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When creating a TextItem to be added to a plotItem in PyQtGraph, I know it is possible to format the text using html code, however I was wondering how to format the text (i.e. change font size) when updating the text through TextItem.setText()? or do I need to destroy\/re-create a TextItem?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1991,"Q_Id":26116350,"Users Score":5,"Answer":"It is not documented, but the method you want is TextItem.setHtml().","Q_Score":1,"Tags":"python,text,plot,formatting,pyqtgraph","A_Id":26129313,"CreationDate":"2014-09-30T08:39:00.000","Title":"How to set font size using TextItem.setText() in PyQtGraph?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I understand breadth first search, but I am having trouble with the implementation.  When there are multiple branches you are expanding the edges or successors of each branch on every iteration of the function.  But when one of your nodes returns GOAL how do you get all of the previous moves to that location?\nDo you create a list of actions you took, and if there is a fork in the path you create two new lists with the actions you took to get to the branch, plus the moves you will take while on the branch?\nThis is a pain in the butt to implement, especially in Python, in which I'm fairly new too.  Is there a better way to organize this and get the path I need?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":26136042,"Users Score":0,"Answer":"I found the answer.  The split lists was a bad idea. I used linked lists instead.  You can create a class called \"Node\" then connect the nodes yourself.  Once of the properties of the node is the parent node.  With the parent node, you can track all the way back up the tree.  Look into linked lists.","Q_Score":0,"Tags":"python,path-finding,breadth-first-search","A_Id":26190251,"CreationDate":"2014-10-01T07:18:00.000","Title":"Breadth first search how to find a particular path out of several branches","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In order to start Google app engine through the cmd i use: dev_appserver.py --port=8080, but i can't figure how does it pick a file to run from the current directory.\nMy question is, is there an argument specifying a file to run in the server from all possible files in the directory?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":26136643,"Users Score":1,"Answer":"dev_appserver doesn't \"run a file\" at all. It launches the GAE dev environment, and routes requests using the paths defined in app.yaml just like the production version.\nIf you need to route your requests to a specific Python file, you should define that in app.yaml.","Q_Score":0,"Tags":"python,google-app-engine,cmd","A_Id":26136777,"CreationDate":"2014-10-01T07:53:00.000","Title":"use dev_appserver.py for specific file in a directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a GUI in python using pyqt4 which incorporates a waterfall sink which is connected with an USRP. The problem is that the data should be shown in waterfall sink continuously which makes the GUI to freeze and I can not use the other buttons in meanwhile. I was checking to use threads, but till now what I understood is that in threads I can put just functions which will give an result at the end, but not the functions which will give results continuously and I want to see it in the main GUI.\nAny idea how to make it possible to see the continuous results from waterfall sink and not to freeze the main GUI.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":352,"Q_Id":26138460,"Users Score":0,"Answer":"There are several ways to do this, but basically either\n\nBreakup your waterfall sink into chunks of work, which the GUI can execute periodically. For example, instead of continuously updating the waterfall sink in a function that GUI calls, have only a \"short\" update (one \"time step\"), and have the function return right after; make the function called periodically via QTimer. \nMake the waterfall sink execute in a separate thread by using a QObject instantiated in a QThread instance; and make the sink function emit a signal at regular interval, say at every \"time step\" of the waterfall update.","Q_Score":0,"Tags":"python,multithreading,pyqt,pyqt4,usrp","A_Id":26153975,"CreationDate":"2014-10-01T09:43:00.000","Title":"Using threads with python pyqt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using django-countries to get a flag from the CountryField and it works. However, some users don't have a country set on their profiles, but I still have to display a flag. My idea was to get a country from IP and then get a flag from the country or anything similar to that.\nUnfortunately, this is not happening in the view, so I don't have the request. I can set the IP in the template and then, in the backend, check if no flag was found (if a country is not provided) and then somehow use the IP that I got from the template to get a flag. Is something like that possible? If needed, GeoDjango is already included in the project.\nPerhaps there is a totally different way of doing this, but I am new to Django and still learning. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1719,"Q_Id":26142468,"Users Score":0,"Answer":"Personally I would set a generic flag as a fallback (django flag perhaps?) if user does not set their country, and to be fair there must be a reason if user doesn't. Or you can simply make that country field mandatory.\nAnd assuming that person in that country based on their existing IP just doesn't sound right.\nImagine if you are working remotely via VPN or behind a proxy server... you get the idea.\nIt makes more sense if you just want to redirect people to sub-domain (different language) site base on IP.","Q_Score":0,"Tags":"python,django,geodjango,django-countries","A_Id":26143098,"CreationDate":"2014-10-01T13:23:00.000","Title":"Python\/Django get country flag from IP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my project there is two models ,ORGANISATION and CUSTUMER .Here what i am doing is while i am adding new customer to the organisation i save the organisation_id to the table CUSTOMER .But now i am worrying about the performance of my project when the database becomes huge.\nSo now i am planning to create new database for every newly creating organisation .And save all the information of the organisation in that organisation's database. But i don't know how to create a new database for every newly creating organisation.And i'd like to know which method is better in performance.Please correct the question if not.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":181,"Q_Id":26157625,"Users Score":1,"Answer":"It doesn't make sense to create a new database for each organization. Even if the number of customers or organizations grows to the hundreds or thousands, keeping data in a single database is your best option.\nEdit:\nYour original concern was that an increase in the number of organizations would impact performance. Well then, imagine if you had to create an entire database for each organization. You would have the same tables, indexes, views, etc replicated n-times. Each database would need system resources and disk space. Not to mention the code needed to make Django aware of the split. You would have to get data from n databases instead of just one table in one database.\nAlso keep in mind that robust databases like PostgreSQL or MySQL are very capable of managing thousands or millions of records. They will do a better job out of the box than any code you may come up with. Just trust them with the data and if you notice a performance decline then you can find plenty of tips online to optimize them.","Q_Score":0,"Tags":"mysql,django,python-2.7","A_Id":26158170,"CreationDate":"2014-10-02T09:07:00.000","Title":"django multiple database for multiple organisation in a single project","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using an SGDClassifier in combination with the partial fit method to train with lots of data. I'd like to monitor when I've achieved an acceptable level of convergence, which means I'd like to know the loss every n iterations on some data (possibly training, possibly held-out, maybe both).\nI know this information is available if I pass verbose=1 in the constructor of the classifier, but I'd like to query it programmatically rather than visually. I also know I can use the score method to get accuracy, but I'd like actual loss as measured by my chosen loss function.\nDoes anyone know how to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1528,"Q_Id":26178035,"Users Score":0,"Answer":"The above answer was too short, outdated and might result in misleading. \nUsing score method could only give accuracy (it's in the BaseEstimator). If you want the loss function, you could either call private function _get_loss_function (defined in the BaseSGDClassifier). Or accessing BaseSGDClassifier.loss_functions class attribute which will give you a dict and whose entry is the callable for loss function (with default setting)\nAlso using sklearn.metrics might not get exact loss used for minimization (due to regularization and what to minimize, but you can hand compute anyway). The exact code for Loss function is defined in cython code (sgd_fast.pyx, you could look up the code in scikit-learn github repo)\nI'm looking for a good way to plot the minimization progress. Probably will redirect stdout and parse the output. \nBTW, I'm using 0.17.1. So a update for the answer.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":38604808,"CreationDate":"2014-10-03T11:19:00.000","Title":"Way to compute the value of the loss function on data for an SGDClassifier?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"How can i create Django sqlite3 dump file (*.sql) using terminal?\nThere is a fabric fabfile.py with certain dump scripts, but when i try to use fab command next massage shows up:\nThe program 'fab' is currently not installed.  To run fab please ask your administrator to install the package 'fabric'. \nBut there are fabric files in \/python2.7\/site-packages\/fabric\/.\nI'm not good at Django and Python at all. The guy, who was responsible for our Django project, just left without any explanations.\nIn general i need to know how to create Django sqlite3 dump file (*.sql) via terminal.\nHelp? :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1114,"Q_Id":26178633,"Users Score":0,"Answer":"You could also use fixtures. And generate fixtures for your app. Dependes on what you're planing to do with them.\nYou'll just make a loaddata after that.","Q_Score":0,"Tags":"python,django,database,sqlite","A_Id":26179396,"CreationDate":"2014-10-03T12:07:00.000","Title":"Django sqlite3 database dump","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I create an exe executable of my application made \u200b\u200bin pyqt, and everything went well, but when I run the exe in windows before opening the application opens a console and while the application is open that console is also.\nI need someone to tell me how to make the console does not come out, or at least not visible.\nI've seen some answers to this problem but with C ++ with Python I have not seen anything","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":26199115,"Users Score":0,"Answer":"The best solution is in the post linked to in a comment to your post, but on Windows you can also set a property on a shortcut that starts the app, to have the console minimized. It still shows in taskbar, there id you need it, can be handy in some situations(like during dev to use same script as user will, but not have to bother evrytime start the app to manually minimize the console). In general best to use pythonw.exe or use .pyw extension for your script.","Q_Score":0,"Tags":"python,windows,console,pyqt,exe","A_Id":26208237,"CreationDate":"2014-10-05T02:35:00.000","Title":"The exe executable of my application, also opens a console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have some 1 million lines of twitter comments data in csv format. I need to classify them in certain categories like if somebody is talking about  : \"product longevity\", \"cheap\/costly\", \"on sale\/discount\" etc. \nAs you can see I have multiple classes to classify these tweets data into.\nThe thing is that how do I even generate\/create a training data for such a huge data.Silly question but I was wondering whether\/not there are already preclassified\/tagged comments data to train our model with? If not then what is the best approach to create a training data for multi-class classification of text\/comments ?\nWhile I have tried and tested NaiveBayes for sentiment classification for a smaller dataset, could you please suggest  which classifier shall I use for this problem (multiple categories to classify the comments into).\nThanks!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":26211308,"Users Score":0,"Answer":"The thing is that how do I even generate\/create a training data for\n  such a huge data\n\nI would suggest finding a training data set that could help you with the categories you are interested in. So let's say price related articles, you might want to find a training data set that is all about price related articles and then perhaps expand it by using synonyms for key-words like cheap or so. And perhaps look into sentence structure to find out whether if the structure of the sentence helps with your classifier algorithm.  \n\nIf not then what is the best approach to create a training data for\n  multi-class classification of text\/comments? key-words, pulling articles that are all about related categories and then go from there. \n\nLastly, I suggest being very familiar with NLTK's corpus library, this might also help you with retrieving training data as well. \nAs for your last question, I'm kinda confused to what you mean by 'multiple categories to classify the comments into', do you mean having multiple classifiers for a particular comment to belong in? So a comment can belong to 1 to more classifiers?","Q_Score":1,"Tags":"python,twitter,machine-learning,classification,nltk","A_Id":29718799,"CreationDate":"2014-10-06T07:04:00.000","Title":"preclassified trained twitter comments for categorization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"The data that i have is stored in a 2D list where one column represents a frequency and the other column is its corresponding dB. I would like to programmatically identify the frequency of the 3db points on either end of the passband. I have two ideas on how to do this but they both have drawbacks.\n\nFind maximum point then the average of points in the passband then find points about 3dB lower\nUse the sympy library to perform numerical differentiation and identify the critical points\/inflection points\nuse a histogram\/bin function to find the amplitude of the passband. \n\ndrawbacks\n\nsensitive to spikes, not quite sure how to do this\ni don't under stand the math involved and the data is noisy which could lead to a lot of false positives\ncorrelating the amplitude values with list index values could be tricky\n\nCan you think of better ideas and\/or ways to implement what I have described?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1113,"Q_Id":26280838,"Users Score":0,"Answer":"Assuming that you've loaded multiple readings of the PSD from the signal analyzer, try averaging them before attempting to find the bandedges. If the signal isn't changing too dramatically, the averaging process might smooth away any peaks and valleys and noise within the passband, making it easier to find the edges. This is what many spectrum analyzers can do to make for a smoother PSD.\nIn case that wasn't clear, assume that each reading gives you 128 tuples of the frequency and power and that you capture 100 of these buffers of data. Now average the 100 samples from bin 0, then samples from 1, 2, ..., 128. Now try and locate the bandpass on this data. It should be easier than on any single buffer. Note I used 100 as an example. If your data is very noisy, it may require more. If there isn't much noise, fewer.\nBe careful when doing the averaging. Your data is in dB. To add the samples together in order to find an average, you must first convert the dB data back to decimal, do the adds, do the divide to find the average, and then convert the averaged power back into dB.","Q_Score":0,"Tags":"python,math,signal-processing","A_Id":26286979,"CreationDate":"2014-10-09T14:19:00.000","Title":"How can I find the break frequencies\/3dB points from a bandpass filter frequency sweep data in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My OS is CentOS 7.0. It's embedded python version is 2.7, and I want to update it to Python 3.4.\nwhen input the \nprint sys.path\noutput is:\n\n['', '\/usr\/lib\/python2.7\/site-packages\/setuptools-5.8-py2.7.egg',\n  '\/usr\/lib64\/python27.zip', '\/usr\/lib64\/python2.7',\n  '\/usr\/lib64\/python2.7\/plat-linux2', '\/usr\/lib64\/python2.7\/lib-tk',\n  '\/usr\/lib64\/python2.7\/lib-old', '\/usr\/lib64\/python2.7\/lib-dynload',\n  '\/usr\/lib64\/python2.7\/site-packages',\n  '\/usr\/lib64\/python2.7\/site-packages\/gtk-2.0',\n  '\/usr\/lib\/python2.7\/site-packages']\n\nSo, if I download the python 3.7, then .\/configure , make , make install. Will it override all the python-related files ? Or if I use the \n\n.\/configure --prefix=***\uff08some path\uff09\n\nthen is it safe to remove all the old python files or directory?\nIn a word, hope someone gives me instructions about how to update to python 3 on linux. Thanks a lot.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":20066,"Q_Id":26282986,"Users Score":4,"Answer":"Python 2 and 3 can safely be installed together. They install most of their files in different locations. So if the prefix is \/usr\/local, you'll find the library files in \/usr\/local\/lib\/pythonX.Y\/ where X.Y are the major and minor version numbers.\nThe only point of contention is generally is the file python itself, which is generally a symbolic link.\nCurrently it seems most operating systems still use Python 2 as the default, which means that python is a symbolic link to python2. This is also recommended in the Python documentation.\nIt is best to leave it like that for now. Some programs in your distributions may depend on this, and might not work with Python 3.\nSo install Python 3 (3.5.1 is the latest version at this time) using your favorite package manager or compiling it yourself. And then use it by starting python3 or by putting #!\/usr\/bin\/env python3 as the first line in your Python 3 scripts and making them executable (chmod +x <file>).","Q_Score":4,"Tags":"python","A_Id":36884696,"CreationDate":"2014-10-09T16:04:00.000","Title":"how to update python 2.7 to python 3 in linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I deploy openerp\/odoo using mod_wsgi, I found my schedulers stop working, can any one help how can I get my cron\/schedulers working. If I deploy it using mod_proxy it will solve the issue but I want to deploy using mod_wsgi.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":26302718,"Users Score":0,"Answer":"The schedulers don't work when running through wsgi because your Odoo instances are just workers.  AFAIK you just run a standalone instance on a 127.0.0.1 port and it runs your scheduled tasks.","Q_Score":0,"Tags":"python,apache,deployment,openerp,mod-wsgi","A_Id":26330930,"CreationDate":"2014-10-10T15:18:00.000","Title":"odoo mod_wsgi schedulers not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning Django but it's difficult to me to see how should I divide a project into apps?\nI've worked on some Java EE systems, almost for procedures for government and all that stuff but I just can't see how to create a Django project for this purposes?\nFor example, if you should have to do a web app for making easier three process: Procedure to get the passport, procedure to get the driver license and procedure to get the social number.\nThe 3 procedures have steps in common: Personal information, Contact Information, Health Information. Would you do a project for each procedure, an app for each procedure, an app for each step?\nI'm sorry if I'm posting this in the wrong Stack Exchange site.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":26304413,"Users Score":0,"Answer":"When you say \"procedures\" i guess you're talking about pages (or views in Django). So I would implement a single \"app\" to do that.\nRemember a project is composed of apps. When you create a project a main app (with the same name of the project) is created. This is a good place to code the procedures you said.\nThink of apps as indepent sections of your project (site); maybe some forum, a blog, a custom administration panel, a game and stuff like that. Every one of them could be an independent app.\nA project is mostly intended as a single website, so there's no need to create another project on the example you mentioned.","Q_Score":1,"Tags":"python,django","A_Id":26305048,"CreationDate":"2014-10-10T16:57:00.000","Title":"Django apps structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've downloaded an APK onto a Velocity Cruz Tablet running Android 2.2.1 (API Level 8), and I'm trying to install it via whatever I can manage to make work. I already had ADT on my computer (Windows 8.1 if this helps) for API Level 19 for use with my phone. So I used the SDK Manager to get API Level 8. I can't for the life of me figure out how to make adb or monkeyrunner target API Level 8. I've got the paths right but the problem I'm having is making it target the proper API Level. I've gone through the adb commands, pm commands and MonkeyRunner API Documentation, but I don't see anything helpful. I've decided to come here to see if anyone knows what to do. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":225,"Q_Id":26311022,"Users Score":0,"Answer":"You are trying to install an APK which is intended for a higher version onto API level 8 and thus the package manager refuses to install it. It has nothing to do with adb or monkeyrunner.","Q_Score":0,"Tags":"android,python,adb,monkeyrunner","A_Id":26311559,"CreationDate":"2014-10-11T04:20:00.000","Title":"Android - ADB\/MonkeyRunner Setting API Levels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am writing a program for school, and I have to make a maths quiz, the quiz needs to be out of 10 questions.  I have made a button that is defined with a command that generates a new questions, clears the text box, get the answer from the dictionary, and inserts the new question into the textbox.  At the moment the user can press the button as many times as they want.  I dont actually know how to count or monitor the amount of times a button in tkinter has been pressed.  I would be very grateful if someone could provide me with some code for Python(3.1.4) that I could use to count the amount of times the button has been pressed.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":17843,"Q_Id":26315848,"Users Score":1,"Answer":"You need a variable in a global or class instance scope and a function that has access to the scope of the variable that increments the variable when called.  Set the function as the command attribute of the Button so that the function is called when the button is clicked.","Q_Score":0,"Tags":"python,button,user-interface,python-3.x,tkinter","A_Id":26315912,"CreationDate":"2014-10-11T14:44:00.000","Title":"How to count the number of times a button is clicked Python(tkinter)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have deployed my local python web service project to Heroku. I have all my dependencies in requirement.txt file. But, one module psycopg2 is not getting installed properly and I am getting installation error. So, I removed it from requirement.txt and thought I will push everything to heroku first, and then I will manually copy the psycopg2 module folder in \/app\/.heroku\/python\/lib\/python2.7\/site-packages folder. But I don't know how to access this folder!\nCan you please help?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248,"Q_Id":26316273,"Users Score":0,"Answer":"You could keep the psycopg2 directory in the same directory of apps, but that's actually a hack and you should try fix on installing psycopg2 on Heroku.","Q_Score":1,"Tags":"python,heroku,importerror,psycopg2","A_Id":26317020,"CreationDate":"2014-10-11T15:34:00.000","Title":"How to manually copy folder to \/app\/.heroku\/python\/lib\/python2.7\/site-packages\/?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm new developer in QPython (experienced with python), I want to open an url with user's default browser.\nI tried AndroidBrowser().open(\"...\") but, to my surprise, I got Segmentation Fault!\nSo I said OK, let's try to open it manually as activity, then I tried to import jnius and got Segmentation Fault as well.\nAny suggestion how to fix it or other ways to open the browser?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1277,"Q_Id":26318326,"Users Score":1,"Answer":"Apparently, this happens just in console mode, so in other QPython mods it works fine.","Q_Score":3,"Tags":"android,segmentation-fault,android-browser,qpython,pyjnius","A_Id":26428421,"CreationDate":"2014-10-11T19:16:00.000","Title":"Open a URL with default broswer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to adequate the FontSize of my text into a width-height specific context. For instance, if I got a image (512x512 pixels) and I got for instance 140 characters. What would be the ideal FontSize? \nIn the above case, a 50 pixels Fontsize seems to be ok but what happened if there's a lot more text? the text will not fit into the picture so it needs reduction. I've been trying to calculate this on my own without success.\nWhat I've tried is this:\nget total pixels, with a picture 512x512 = 262144 and divide into the length of the text. But that gives a big number. Even if I divided that number by 4 (thinking about a box-pixel-model for the font).\nDo you have any solutions for this?\nPS. I've been using truetype (if this is somehow useful)\nI've been using python for this purpose, and PIL for image manipulation.\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":376,"Q_Id":26319382,"Users Score":3,"Answer":"It's pretty tricky to do analytically.\nOne way is trial and error. Choose a large font size and render the layout to see whether it fits\nUse bisection algorithm to converge on the largest font that fits","Q_Score":0,"Tags":"python,fonts,truetype","A_Id":26319577,"CreationDate":"2014-10-11T21:22:00.000","Title":"Calculate fontsize","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was thinking of making a text-based game about detectives, case-solving, with complete freedom, loads of variables, etc. \nBut before I get serious with it I need to know how to make rooms. E.g. you start in the hall and you type in \"Go kitchen\" and you go to the kitchen. \nI have achieved this by using import file when you type in \"Go kitchen\"  (the file is the kitchen file), but if I want to go back and forth between them it gives an error. \nIs there something I am missing about this method? Is there a better way to do it? The simpler, the better, please.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":486,"Q_Id":26323942,"Users Score":3,"Answer":"Do not use import to implement application logic.\nIn your use case, a room is the classic example of an object in object-oriented programming. You should have a class Room which defines the functionality for rooms. Individual rooms are instances of that class (later you can add subclasses, but I would not worry about that initially).\nYour application will have a \"current room\" as a variable. It will ask the room about its description and display that to the user. When the user types \"go Kitchen\", your application will ask the current room \"hey, do you have a room named 'Kitchen' as a neighbor?\" This method will return the appropriate room object, which your application then can set as the current room.\nFrom the above, you can see two functionalities (methods) rooms should have: \"Give me your description\" and \"give me the adjacent room named 'X', if any\".\nThis should get you started.","Q_Score":0,"Tags":"python","A_Id":26324214,"CreationDate":"2014-10-12T10:03:00.000","Title":"How best to implement rooms for a text-based game?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to learn how to use pdb in emacs.\nI run emacs in console mode and in my python file I have something like import pdb and pdb.set_trace() at the beginning of the file. I use C-c C-c to execute the buffer and pdb starts running. It works fine except that I end up with a => inserted into my code on the line that pdb is looking at. When pdb ends, the => characters remain in my code on the last line and I have to manually delete it. How do I prevent this from happening?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":105,"Q_Id":26349503,"Users Score":0,"Answer":"Normally there is no \"=>\" inserted at all.  What there is instead is a \"=>\" that is displayed but which is not part of the buffer's content.  Are you sure it's really in the code and are you sure you can delete it as if it were normal text?","Q_Score":0,"Tags":"python,emacs,pdb","A_Id":26373563,"CreationDate":"2014-10-13T21:56:00.000","Title":"Using pdb in emacs inserts => into my code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to crawl data from a web page in a specfic order as liked i declared fields in my item class and then have to put them in csv file.problem now occuring is there its stores data not in specfic order as like its scrapping data of any field and putting in csv file but i want it should store data as i declared in my item class. I am newbie in python. can you tell me how to do this \nFor ex:\nmy item class is \nclass DmozItem(Item):\n    title = Field()\n    link = Field()\n    desc = Field()\nNow when its storing data in csv file its storing first desc ,link and then title \n\"desc\": [], \"link\": [\"\/Computers\/Programming\/\"], \"title\": [\"Programming\"]}","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":26355152,"Users Score":0,"Answer":"For this we have to make a list in fields_to_export in the BaseItemExporter class \nfield_iter = ['Offer', 'SKU', 'VendorCode'] like this\nand then have to pass this list in the field","Q_Score":0,"Tags":"python-2.7,scrapy,web-crawler","A_Id":26378448,"CreationDate":"2014-10-14T07:35:00.000","Title":"How to store data crawled in scrapy in specfic order?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a django and I wrote some views. I know how to pass my variables to template, but I also has some external modules with their own views, which I wont modify. Please help me understand how can I get one of my object \"Menu.objects.all()\" exist in all templates? So for example a I have django-registration and i want to have all my menu items appear at top when someone visits not my app url. I mean it will be registration app url, which returns templateresponse (and here I dont have my variable).","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":58,"Q_Id":26358511,"Users Score":1,"Answer":"You can add variables to context","Q_Score":0,"Tags":"python,django,templates,variables","A_Id":26358812,"CreationDate":"2014-10-14T10:26:00.000","Title":"Make an object exists in all templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have directory with many JaveScript files. Here I want to scan each file and want to replace each JavaScript variable with string like 'str1', 'str2', 'str3', ..., 'strn' and so on.\nMy question is: how to identify a JavaScript variable?\nDoubts:\n\nIf I say keyword after var is a variable, however there is no compulsion of var while declaring variable\nIf I say keyword before = is a variable, however file also contains HTML code, so inside HTML tag there is = sign between attribute and its value.\n\nSo how can I identify the variables I have to replace?","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":1278,"Q_Id":26358543,"Users Score":-3,"Answer":"If you use an IDE such as phpstorm, it can easily find variables for you. I don't see the use in programming something in Python to do this.","Q_Score":1,"Tags":"javascript,python","A_Id":26358654,"CreationDate":"2014-10-14T10:28:00.000","Title":"How to search for JavaScript variables in a file, using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Z3 Python bindings to create an And expression via z3.And(exprs) where exprs is a python list of 48000 equality constraints over boolean variables.  This operation takes 2 seconds on a MBP with 2.6GHz processor.\nWhat could I be doing wrong?  Is this an issue with z3 Python bindings?  Any ideas on how to optimize such constructions?\nIncidentally, in my experiments, the constructions of such expressions is taking more time than solving the resulting formulae :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":283,"Q_Id":26375763,"Users Score":2,"Answer":"Using Z3 over Python is generally pretty slow. It includes parameter checks and marshaling (_coerce_expr among others). \nFor scalability you will be better of using one of the other bindings or bypass the Python runtime where possible.","Q_Score":4,"Tags":"python,z3,z3py","A_Id":26385910,"CreationDate":"2014-10-15T06:21:00.000","Title":"Why is z3.And() slow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm adding a page to a complex Pyramid-based app that uses Handlebar templates.\nI need a file download URL that doesn't need a template, but the system is giving me a 404\ncode for missing template anyway.\nHow do I tell a view at configuration time \"do not use a handlebar template with this one?\"","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":26391208,"Users Score":1,"Answer":"This was a red herring; the URL was wrong but the log file mentioned a missing template so I was focused in the wrong direction.\nI had to get a custom redirection piece of code from one of the developers on this project and I have it working now.","Q_Score":0,"Tags":"javascript,python,templates,pyramid","A_Id":26392168,"CreationDate":"2014-10-15T20:09:00.000","Title":"Pyramid app with handlebar.js: I don't need a template for this view; how to disable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a major problem in my celery + rabbitmq app where queuing up my jobs is taking longer than the time for my workers to perform jobs. No matter how many machines I spin up, my queuing time will always overtake my task time.\nThis is because I have one celery_client script on one machine doing all the queuing (calling task.delay()) sequentially. I am iterating through a list of files stored in S3. How can I parallelize the queuing process? I imagine this is a widespread basic problem, yet I cannot find a solution.\nEDIT: to clarify, I am calling task.delay() inside a for loop that iterates through a list of S3 files (of which there are a huge amount of small files). I need to get the result back to me so I can return it to the client, so for this reason I iterate through a list of results after the above to see if the result is completed -- if it is, I append it to a result file.\nSome solutions I can think of immediately is some kind of multi threaded support in my for loop, but I am not sure whether .delay() would work with this. Is there no built in celery support for this problem?\nEDIT2 More details: I am using one queue in my celeryconfig -- my tasks are all the same.\nEDIT3: I came across \"chunking\", where you can group a lot of small tasks into one big one. Not sure if this can help out my problem, as although I can transform a large number of small tasks into a small number of big ones, my for loop is still sequential. I could not find much information in the docs.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":349,"Q_Id":26393540,"Users Score":0,"Answer":"If queuing up your tasks takes longer than the task, how about you increase the scope of the tasks so they operate on N files at a time. So instead of queuing up 1000 tasks for 1000 files. You queue up 10 tasks that operate on 100 files at a time.\nMake your task take a list of files, rather than a file for input. Then when you loop through your list of files you can loop 100 at time.","Q_Score":0,"Tags":"python,parallel-processing,rabbitmq,celery,django-celery","A_Id":26732448,"CreationDate":"2014-10-15T23:00:00.000","Title":"The time to queue tasks in celery bottlenecks my application - how to parallelize .delay()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on developing a test automation framework. I need to start a process(a C++ application) on a remote linux host from a  python script. I use the python module \"paramiko\" for this. However my c++ application takes sometime to run and complete the task assigned to it. So till the application completes processing, I cannot close the connection to the paramiko client. I wan thinking if I could do something like \"the c++ application executing a callback(or some kind of signalling mechanism) and informing the script on completion of the task\" Is there a way I can achieve this ? \nI'm new to python, so any help would be much appreciated.\nthanks!\nUpdate: Is it not possible to have event.wait() and event.set() mechanism between the c++ application and the python script ? If yes, can somebody explain how it can be achieved ?\nthanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":331,"Q_Id":26413505,"Users Score":0,"Answer":"The best way I can think of to do this is to run both of them in a web server. Use something like Windows Web Services for C++ or a native CGI implementation and use that to signal the python script.\nIf that's not a possibility, you can use COM to create COM objects on both sides, one in Python, and one in C++ to handle your IPC, but that gets messy with all the marshalling of types and such.","Q_Score":1,"Tags":"python,c++,linux,signals,paramiko","A_Id":26413679,"CreationDate":"2014-10-16T20:39:00.000","Title":"Can a \"C++ application signal python script on completion\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to sample only some elements of a vector from a sum of gaussians that is given by their means and covariance matrices.\nSpecifically:\nI'm imputing data using gaussian mixture model (GMM). I'm using the following procedure and sklearn:\n\nimpute with mean\nget means and covariances with GMM (for example 5 components)\ntake one of the samples and sample only the missing values. the other values stay the same.\nrepeat a few times\n\nThere are two problems that I see with this. (A) how do I sample from the sum of gaussians, (B) how do I sample only part of the vector. I assume both can be solved at the same time. For (A), I can use rejection sampling or inverse transform sampling but I feel that there is a better way utilizing multivariate normal distribution generators in numpy. Or, some other efficient method. For (B), I just need to multiply the sampled variable by a gaussian that has known values from the sample as an argument. Right?\nI would prefer a solution in python but an algorithm or pseudocode would be sufficient.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1040,"Q_Id":26442403,"Users Score":1,"Answer":"Since for sampling only relative proportion of the distribution matters, scaling preface or can be thrown away. For diagonal covariance matrix, one can just use the covariance submarine and mean subvector that has dimensions of missing data. For covariance with off-diagonal elements, the mean and std dev of a sampling gaussian will need to be changed.","Q_Score":1,"Tags":"python,numpy,random-sample,normal-distribution,mixture-model","A_Id":26565108,"CreationDate":"2014-10-18T17:10:00.000","Title":"Sampling parts of a vector from gaussian mixture model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My situation is : A server send a request to me, the request's contentType is 'text\/xml', and the request content is an xml. First I need to get the request content. But when I use 'web.input()' in 'POST' function, I couldn't get any message, the result just is ''. I know web.py can get form data from a request, so how I can get message from request when the contentType is 'text\/xml' in POST function. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":86,"Q_Id":26479903,"Users Score":1,"Answer":"Use web.data().","Q_Score":0,"Tags":"python,web.py","A_Id":26498875,"CreationDate":"2014-10-21T06:04:00.000","Title":"web.py how to get message from request when the contentType is 'text\/xml'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in myModule.py I am importing environ from os , like\nfrom os import environ since I am only using environ, but when I do dir(myModule) it shows environ as publicly visible , how ever should it be imported as protected assuming some other project may also have its own environ function ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":26479928,"Users Score":1,"Answer":"If you're doing from os import environ, then you'll reference it as environ.\nIf you do import os, it's os.environ.\nSo depending on your needs, the second option might be better.  The first will look better and read easier, whereas the second avoids namespace pollution.","Q_Score":0,"Tags":"python","A_Id":26480045,"CreationDate":"2014-10-21T06:06:00.000","Title":"when importing functions from inside builtins like os or sys is it good practice to import as protected?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a turn-based game and I'm hoping to implement client-server style networking. I really just need to send the position of a couple of objects and some other easily encodable data. I'm pretty new to networking, although I've coded some basic stuff in socket and twisted. Now, though, I need to be able to send the data to a computer that isn't on my local network, and I can't do port forwarding since I don't have admin access to the router and I'm also not totally sure that would do the trick anyways since I've never done it. So, I was thinking of running some Flask or Bottle or Django, etc. code off PythonAnywhere. The clients would then send data to the server code on PythonAnywhere, and when the turn passed, the other client would just go look up the information it needed on the server. I guess then the server would act as just a data bank with some simple getter and setter methods. My question is how can this be implemented? Can my Socket code on my client program talk to my Flask code on PythonAnywhere?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":889,"Q_Id":26480008,"Users Score":2,"Answer":"It depends what sort of connection your clients need to make to the server.  PythonAnywhere supports WSGI, which means \"normal\" HTTP request\/response interactions -- GET, POST, etc.  That works well for \"traditional\" web pages or web apps.\nIf your client side needs dynamic, two-way connections using non-HTTP protocols, using raw sockets, or even websockets, PythonAnyhwere doesn't support that at present.","Q_Score":3,"Tags":"python,sockets,flask,twisted,pythonanywhere","A_Id":26503901,"CreationDate":"2014-10-21T06:12:00.000","Title":"Using PythonAnywhere as a game server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I need to run a specific manage.py commands on an EC2 instance every X minutes. For example: python manage.py some_command.\nI have looked up django-chronograph. Following the instructions, I've added chronograph to my settings.py but on runserver it keeps telling me No module named chronograph.\nIs there something I'm missing to get this running? And after running how do I get manage.py commands to run using chronograph?\nEdit: It's installed in the EC2 instance's virtualenv.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":368,"Q_Id":26487648,"Users Score":1,"Answer":"I would suggest you to configure cron to run your command at specific times\/intervals.","Q_Score":0,"Tags":"python,django,django-chronograph","A_Id":26487761,"CreationDate":"2014-10-21T13:14:00.000","Title":"Run specific django manage.py commands at intervals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to run a specific manage.py commands on an EC2 instance every X minutes. For example: python manage.py some_command.\nI have looked up django-chronograph. Following the instructions, I've added chronograph to my settings.py but on runserver it keeps telling me No module named chronograph.\nIs there something I'm missing to get this running? And after running how do I get manage.py commands to run using chronograph?\nEdit: It's installed in the EC2 instance's virtualenv.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":368,"Q_Id":26487648,"Users Score":0,"Answer":"First, install it by running pip install django-chronograph.","Q_Score":0,"Tags":"python,django,django-chronograph","A_Id":26488221,"CreationDate":"2014-10-21T13:14:00.000","Title":"Run specific django manage.py commands at intervals","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to make an 32bit exe file using py2exe. The problem is that my machine and Python are 64bit. Is there some simple way how to make 32bit using 64bit Python and py2exe?\nI heard that I should uninstall py2exe and install new py2exe 32bit, can this help me?\nEDIT: If 32bit py2exe works, can I install 32bit py2exe next to my 64bit py2exe?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":803,"Q_Id":26488595,"Users Score":0,"Answer":"You should install the 32-bit python (in a separate directory, you can do it on the same machine).  Install 32-bit py2exe for this 32-bit Python installation plus all Python packages that you need. Then you can build a 32-bit eecutable.","Q_Score":1,"Tags":"python,64-bit,32bit-64bit,py2exe,32-bit","A_Id":26672009,"CreationDate":"2014-10-21T14:00:00.000","Title":"32bit exe on 64bit Python using py2exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question applies to dynamically interpreted code, I guess\nIn detail\nSay I have a set of data processing projects that depend on a common module called tools. Down the road of development, I find out that I want to change the interface of one of the functions or methods in tools.\nThis interface-change might not be totally backwards compatible, it might break a subset of my data processing projects. \nIf all the software involved would have to be compiled, I could simple re-compile everything and the compiler would point me to the spots where I have to adapt the calling code to the new signature. But how can this be done in an interpreted situation?\nTL;DR\nA set of script programs depend on a script module. After chaning the interface of the module in a possibly not backwards-compatible way, how do I check the dependent programs and make them compliant to the new interface?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":26503035,"Users Score":1,"Answer":"Best answer is 'write tests'. For purely syntactical checking with some code correctness, like calling a function which does not exist like you are describing, pylint is probably the best tool. Install it with pip install pylint.","Q_Score":0,"Tags":"python,ruby,scripting,powershell-2.0","A_Id":26507747,"CreationDate":"2014-10-22T08:17:00.000","Title":"Checking all code paths in a project written in a scripting language for syntax-correctness","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a numpy array for an image and am trying to dump it into the libsvm format of LABEL I0:V0 I1:V1 I2:V2..IN:VN. I see that scikit-learn has a dump_svmlight_file and would like to use that if possible since it's optimized and stable. \nIt takes parameters of X, y, and file output name. The values I'm thinking about would be:\nX - numpy array\ny - ????\nfile output name - self-explanatory \nWould this be a correct assumption for X? I'm very confused about what I should do for y though. \nIt appears it needs to be a feature set of some kind. I don't know how I would go about obtaining that however. Thanks in advance for the help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2922,"Q_Id":26509319,"Users Score":2,"Answer":"The svmlight format is tailored to classification\/regression problems. Therefore, the array X is a matrix with as many rows as data points in your set, and as many columns as features. y is the vector of instance labels.\nFor example, suppose you have 1000 objects (images of bicycles and bananas, for example), featurized in 400 dimensions. X would be 1000x400, and y would be a 1000-vector with a 1 entry where there should be a bicycle, and a -1 entry where there should be a banana.","Q_Score":1,"Tags":"python,arrays,numpy,svm,libsvm","A_Id":26509674,"CreationDate":"2014-10-22T14:02:00.000","Title":"How to convert numpy array into libsvm format","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I downloaded Snappy library sources for working with compression and everything was great on one machine, but it didn't work on another machine. They have completely same configurations of hardware\/OS + python 2.7.3.\nAll I was doing is \".\/configure && make && make install\".  \nThere were 0 errors during any of these processes and it installed successfully to the default lib directory, but python cant see it anyhow. help('modules') and pip freeze doesn't show snappy on the second machine and as the result I cant import it.  \nI tried even 'to break' structure and install it to different lib catalogs, but even that didn't work. I don't think if its related to system environment variables, since python should have completely same configuration on any of these machines (Amazon EC2).\nAnyone knows how to fix this issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":26526365,"Users Score":0,"Answer":"I just found python-snappy on github and installed it via python. Not a permanent solution, but at least something.","Q_Score":0,"Tags":"python,python-2.7,amazon-ec2,module,snappy","A_Id":26531727,"CreationDate":"2014-10-23T10:43:00.000","Title":"Python cant see installed module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"since I could not find an answer to my question neither here nor in other forums, I decided to ask it to the community:\nDoes anybody know if and how it is possible to realize automatic documentation generation for code generated with Dymola?\nThe background for this e. g. is that I want\/need to store additional information within my model files to explain the concepts of my modelling and to store and get the documentation directly from the model code, which I would later like to be in a convenient way displayable not only from within Dymola, but also by a html and LaTeX documentation.\nI know that there exist several tools for automatic documentation generation like e. g. DoxyGen and Python Sphinx, but I could not figure out if the can be used with Dymola code. Plus, I am pretty new to this topic, so that I do not really know how to find out if they will work out.\nThank you people very much for your help!\nGreetings, mindm49907","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":26529779,"Users Score":3,"Answer":"If you mean the Modelica model code, how does the HTML export in Dymola work for you? What's missing?\nIf you mean the C code generated by Dymola, the source code generation option enables more comments in the code.","Q_Score":1,"Tags":"doxygen,python-sphinx,documentation-generation,dymola","A_Id":26543595,"CreationDate":"2014-10-23T13:56:00.000","Title":"Automatic documentation generation for Dymola code","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have one EMR cluster which is running 24\/7. I can't turn it off and launch the new one. \nWhat I would like to do is to perform something like bootstrap action on the already running cluster, preferably using Python and boto or AWS CLI. \nI can imagine doing this in 2 steps:\n1) run the script on all the running instances (It would be nice if that would be somehow possible for example from boto)\n2) adding the script to bootstrap actions for case that I'd like to resize the cluster.\nSo my question is: Is something like this possible using boto or at least AWS CLI? I am going through the documentation and source code on github, but I am not able to figure out how to add new \"bootstrap\" actions when the cluster is already running.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2264,"Q_Id":26575729,"Users Score":0,"Answer":"bootstrap script executed once the cluster started (first time or at the beginning), however AWS provide ssh to master and other nodes there you can write shell script,install libs, packages, python program , git clone your repo etc...\nHope this may be helpful.\nAmit","Q_Score":17,"Tags":"python,amazon-web-services,boto,emr,amazon-emr","A_Id":72334675,"CreationDate":"2014-10-26T17:18:00.000","Title":"AWS EMR perform \"bootstrap\" script on all the already running machines in cluster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have one EMR cluster which is running 24\/7. I can't turn it off and launch the new one. \nWhat I would like to do is to perform something like bootstrap action on the already running cluster, preferably using Python and boto or AWS CLI. \nI can imagine doing this in 2 steps:\n1) run the script on all the running instances (It would be nice if that would be somehow possible for example from boto)\n2) adding the script to bootstrap actions for case that I'd like to resize the cluster.\nSo my question is: Is something like this possible using boto or at least AWS CLI? I am going through the documentation and source code on github, but I am not able to figure out how to add new \"bootstrap\" actions when the cluster is already running.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2264,"Q_Id":26575729,"Users Score":6,"Answer":"Late answer, but I'll give it a shot:\nThat is going to be tough.\nYou could install Amazon SSM Agent and use the remote command interface to launch a command on all instances. However, you will have to assign the appropriate SSM roles to the instances, which will require rebuilding the cluster AFAIK. However, any future commands will not require rebuilding.\nYou would then be able to use the CLI to run commands on all nodes (probably boto as well, haven't checked that).","Q_Score":17,"Tags":"python,amazon-web-services,boto,emr,amazon-emr","A_Id":35529652,"CreationDate":"2014-10-26T17:18:00.000","Title":"AWS EMR perform \"bootstrap\" script on all the already running machines in cluster","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Although I've been doing things with python by myself for a while now, I'm completely new to using python with external libraries. As a result, I seem to be having trouble getting numpy to work with PyDev.\nRight now I'm using PyDev in Eclipse, so I first tried to go to My Project > Properties > PyDev - PYTHONPATH > External  Libraries > Add zip\/jar\/egg, similar to how I would add libraries in Eclipse. I then selected the numpy-1.9.0.zip file that I had downloaded. I tried importing numpy and using it, but I got the following error message in Eclipse:\n\nUndefined variable from import: array.\n\nI looked this up, and tried a few different things. I tried going into Window > Preferences > PyDev > Interpreters > Python Interpreters. I selected Python 3.4.0, then went to Forced Builtins > New, and entered \"numpy\". This had no effect, so I tried going back to Window > Preferences > PyDev > Interpreters > Python Interpreters, selecting Python 3.4.0, and then, under Libraries, choosing New Egg\/Zip(s), then adding the numpy-1.9.0.zip file. This had no effect. I also tried the String Substitution Variables tab under Window > Preferences > PyDev > Interpreters > Python Interpreters (Python 3.4.0). This did nothing.\nFinally, I tried simply adding # @UndefinedVariable to the broken lines. When I ran it, it gave me the following error:\n\nImportError: No module named 'numpy'\n\nWhat can I try to get this to work?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2141,"Q_Id":26595519,"Users Score":0,"Answer":"I recommend you to either use the setup.py from the downloaded archive or to download the \"superpack\"-executable for windows, if you work on windows anyway.\nIn PyDev, i overcame problems with new libraries by using the autoconfig button. If that doesn't work, another solution could be deleting and reconfiguring the python interpreter.","Q_Score":1,"Tags":"python,eclipse,numpy,pydev","A_Id":26625834,"CreationDate":"2014-10-27T19:39:00.000","Title":"Using numpy with PyDev","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using CAS to provide authentication for a number of secure services in my stack. The authentication front-end is implemented using Django 1.6 and the django-cas module. However, I'm reading around and I don't seem to get information on how django-cas handles Ticket Granting Tickets and also validation of service tickets.\nDoes anyone know how the aspects mentioned are handled by django-cas?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":477,"Q_Id":26617865,"Users Score":0,"Answer":"Turns out django-cas handles TGT using django sessions. However, for validation of the service ticket, you have to manually make a validation request including the ST(service ticket) granted after login and the service being accessed.","Q_Score":0,"Tags":"python,django,cas","A_Id":26826648,"CreationDate":"2014-10-28T20:27:00.000","Title":"Django CAS and TGT(Ticket Granting Tickets) and service ticket validation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using web.py to run a server. I need to get a request from a remote server, however, the request sends me a data with Chunked Transfer Coding. \nI can use web.ctx.env['wsgi.input'].read(1000) to get the data. But this is not what I need since I don't know the length of the data (because it is chunked). But if I use web.ctx.env['wsgi.input'].read() the server would crash. \nCan anybody tell me how to get the chunked data in a request?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":599,"Q_Id":26649495,"Users Score":-1,"Answer":"web.py runs CherryPy as the web server and it has support for handling requests with chunked transfer coding. Have you misread the documentation?","Q_Score":1,"Tags":"python,web.py","A_Id":26651096,"CreationDate":"2014-10-30T09:38:00.000","Title":"Python: how to read 'Chunked Transfer Coding' from a request in web.py server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I found out that it's impossible to install NumPy\/SciPy via installers on Windows 64-bit, that's only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything.\nI tried to install everything via Pip and most things worked. But when I came to SciPy, it complained about missing a Fortran compiler. So I installed Fortran via MinGW\/MSYS. But you can't install SciPy right away after that, you need to reinstall NumPy. So I tried that, but now it doesn't work anymore via Pip nor via easy_install. Both give these errors:\n\nThere are a lot of errors about LNK2019 and LNK1120,.\nI get a lot of errors in the range of C: C2065,C2054,C2085,C2143`, etc. They belong together I believe.\nThere is no Fortran linker found, but I have no idea how to install that, can't find anything on it.\nAnd many more errors which are already out of the visible part of my cmd-windows...\nThe fatal error is about LNK1120:\n\nbuild\\lib.win-amd64-2.7\\numpy\\linalg\\lapack_lite.pyd : fatal error LNK1120: 7 unresolved externals\n  error: Setup script exited with error: Command \"C:\\Users\\me\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe \/DLL \/nologo \/INCREMENTAL:NO \/LIBPATH:C:\\BLAS \/LIBPATH:C:\\Python27\\libs \/LIBPATH:C:\\Python27\\PCbuild\\amd64 \/LIBPATH:build\\temp.win-amd64-2.7 lapack.lib blas.lib \/EXPORT:initlapack_lite build\\temp.win-amd64-2.7\\Release\\numpy\\linalg\\lapack_litemodule.obj \/OUT:build\\lib.win-amd64-2.7\\numpy\\linalg\\lapack_lite.pyd \/IMPLIB:build\\temp.win-amd64-2.7\\Release\\numpy\\linalg\\lapack_lite.lib \/MANIFESTFILE:build\\temp.win-amd64-2.7\\Release\\numpy\\linalg\\lapack_lite.pyd.manifest\" failed with exit status 1120\n\n\nWhat is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.","AnswerCount":14,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":131918,"Q_Id":26657334,"Users Score":0,"Answer":"Follow these steps:\n\nOpen CMD as administrator\nEnter this command : cd..\ncd..\ncd Program Files\\Python38\\Scripts\nDownload the package you want and put it in Python38\\Scripts folder.\npip install packagename.whl\nDone\n\nYou can write your python version instead of \"38\"","Q_Score":31,"Tags":"python,numpy,scipy,windows64","A_Id":62499396,"CreationDate":"2014-10-30T15:39:00.000","Title":"Installing NumPy and SciPy on 64-bit Windows (with Pip)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I found out that it's impossible to install NumPy\/SciPy via installers on Windows 64-bit, that's only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything.\nI tried to install everything via Pip and most things worked. But when I came to SciPy, it complained about missing a Fortran compiler. So I installed Fortran via MinGW\/MSYS. But you can't install SciPy right away after that, you need to reinstall NumPy. So I tried that, but now it doesn't work anymore via Pip nor via easy_install. Both give these errors:\n\nThere are a lot of errors about LNK2019 and LNK1120,.\nI get a lot of errors in the range of C: C2065,C2054,C2085,C2143`, etc. They belong together I believe.\nThere is no Fortran linker found, but I have no idea how to install that, can't find anything on it.\nAnd many more errors which are already out of the visible part of my cmd-windows...\nThe fatal error is about LNK1120:\n\nbuild\\lib.win-amd64-2.7\\numpy\\linalg\\lapack_lite.pyd : fatal error LNK1120: 7 unresolved externals\n  error: Setup script exited with error: Command \"C:\\Users\\me\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe \/DLL \/nologo \/INCREMENTAL:NO \/LIBPATH:C:\\BLAS \/LIBPATH:C:\\Python27\\libs \/LIBPATH:C:\\Python27\\PCbuild\\amd64 \/LIBPATH:build\\temp.win-amd64-2.7 lapack.lib blas.lib \/EXPORT:initlapack_lite build\\temp.win-amd64-2.7\\Release\\numpy\\linalg\\lapack_litemodule.obj \/OUT:build\\lib.win-amd64-2.7\\numpy\\linalg\\lapack_lite.pyd \/IMPLIB:build\\temp.win-amd64-2.7\\Release\\numpy\\linalg\\lapack_lite.lib \/MANIFESTFILE:build\\temp.win-amd64-2.7\\Release\\numpy\\linalg\\lapack_lite.pyd.manifest\" failed with exit status 1120\n\n\nWhat is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.","AnswerCount":14,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":131918,"Q_Id":26657334,"Users Score":0,"Answer":"for python 3.6, the following worked for me\nlaunch cmd.exe as administrator\npip install numpy-1.13.0+mkl-cp36-cp36m-win32\npip install scipy-0.19.1-cp36-cp36m-win32","Q_Score":31,"Tags":"python,numpy,scipy,windows64","A_Id":44685941,"CreationDate":"2014-10-30T15:39:00.000","Title":"Installing NumPy and SciPy on 64-bit Windows (with Pip)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've downloaded pythonxy (2.7.6.1) on my new 64 bit Windows machine (Windows 7 Enterprise, SP1). When I try to run python, I get an error saying the side-by-side configuration was incorrect. WinPython 32 bit (2.7.6.3) shows the same behavior, WinPython 64 bit is fine. \nHowever, I badly need to compile Python modules with boost and found myself taking the first few steps into what I believe will be searching-the-internet\/configuration\/compilation hell for 64 bit, so I'd rather try to make the 32-bit python work, for which I have my whole MinGW procedure set up and working. Does anybody know what I need to do in order to fix the side-by-side error? Install some redristributable package or something like that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1442,"Q_Id":26698805,"Users Score":0,"Answer":"I just got an answer from one of my colleagues who told me had the exact same problem. The solution was indeed downloading and installing a version of vcredist_x86.exe, but the trick is to find the exact right one. Apparently you can get to a page somewhere from where you can choose the right version. Sorry for not being able to give more exact information, I just have the file now and it works, but it doesn't even say the version number in the file name. This is all very obscure for my taste, but then I'm not a Windows guy.","Q_Score":1,"Tags":"python,c++,windows,boost-python","A_Id":26714852,"CreationDate":"2014-11-02T11:30:00.000","Title":"32 bit python on 64 bit windows machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using ZeroRPC for a project, where there may be multiple instances running on the same machine. For this reason, I need to abe able to auto-assign unused port numbers. I know how to accomplish this with regular sockets using socket.bind(('', 0)) or with ZeroMQ using the bind_to_random_port method, but I cannot figure out how to do this with ZeroRPC.\nSince ZeroRPC is based on ZeroMQ, it must be possible.\nAny ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":346,"Q_Id":26700204,"Users Score":0,"Answer":"Having read details about ZeroRPC-python current state, the safest option to solve the task would be to create a central LotterySINGLETON, that would receive <-REQ\/REP-> send a next free port# upon an instance's request.\nThis approach is isolated from ZeroRPC-dev\/mod(s) modifications of use of the otherwise stable ZeroMQ API and gives you the full control over the port#-s pre-configured\/included-in\/excluded-from LotterySINGLETON's draws.\nThe other way aroung would be to try to by-pass the ZeroRPC layer and ask ZeroMQ directly about the next random port, but the ZeroRPC documentation discourages from bypassing their own controls imposed on (otherwise pure) ZeroMQ framework elements ( which is quite a reasonable to be emphasised, as it erodes the ZeroRPC-layer consistency of it's add-on operations & services, so it shall rather be \"obeyed\" than \"challenged\" in trial\/error ... )","Q_Score":3,"Tags":"python,sockets,port,zeromq","A_Id":26716452,"CreationDate":"2014-11-02T14:08:00.000","Title":"ZeroRPC auto-assign free port number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently, I'm using Google's 2-step method to backup the datastore and than import it to BigQuery.\nI also reviewed the code using pipeline. \nBoth methods are not efficient and have high cost since all data is imported everytime.\nI need only to add the records added from last import.\nWhat is the right way of doing it?\nIs there a working example on how to do it in python?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":541,"Q_Id":26722127,"Users Score":2,"Answer":"There is no full working example (as far as I know), but I believe that the following process could help you :\n1- You'd need to add a \"last time changed\" to your entities, and update it. \n2- Every hour you can run a MapReduce job, where your mapper can have a filter to check for last time updated and only pick up those entities that were updated in the last hour\n3- Manually add what needs to be added to your backup.\nAs I said, this is pretty high level, but the actual answer will require a bunch of code. I don't think it is suited to Stack Overflow's format honestly.","Q_Score":2,"Tags":"python,google-app-engine,google-bigquery,google-cloud-datastore","A_Id":26722516,"CreationDate":"2014-11-03T20:00:00.000","Title":"Import Data Efficiently from Datastore to BigQuery every Hour - Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My assignment is Tic-Tac_Toe using pygame and numpy. I Have almost all of the program done. I just need help understanding how to find if a winner is found. I winner is found if the summation of ANY row, column, or diagonal is equal to 3. \nI have two 3x3 matrices filled with 0's. Let's call them xPlayer and oPlayer. The matrices get filled with 1 every time player x or player o chooses their choice at a certain location. So if, player x selects [0,0], the matrix location at [0,0] gets a 1 value. This should continue until the summation of any row, column, or diagonal is 3. If All the places in both the matrices are 1, then there is no winner. \nI need help finding the winner. I'm really new to python so I don't know much about indexing though a matrix. Any help would be greatly appreciated! \nEDIT: Basically, how do you find out the summation of every row, column, and diagonal to check if ANY of them are equal to 3.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1887,"Q_Id":26726950,"Users Score":-2,"Answer":"set a bool to checks every turn if someone has won. if it returns true, then whosever turn it is has won\nso, for instance, it is x turn, he plays the winning move, bool checks if someone has won,returns true, print out (player whose turn it is) has won! and end game.","Q_Score":1,"Tags":"python,numpy,matrix,indexing,pygame","A_Id":26727002,"CreationDate":"2014-11-04T02:49:00.000","Title":"Summation of every row, column and diagonal in a 3x3 matrix numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a little tool which is able to classify musical genres. To do this, I would like to use a K-nn algorithm (or another one, but this one seems to be good enough) and I'm using python-yaafe for the feature extraction.\nMy problem is that, when I extract a feature from my song (example: mfcc), as my songs are 44100Hz-sampled, I retrieve a lot (number of sample windows) of 12-values-array, and I really don't know how to deal with that. Is there an approach to get just one representative value per feature and per song?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":449,"Q_Id":26733418,"Users Score":2,"Answer":"One approach would be to take the least RMS energy value of the signal as a parameter for classification.\nYou should use a music segment, rather than using the whole music file for classification.Theoretically, the part of the music of 30 sec, starting after the first 30 secs of the music, is best representative for genre classification.\nSo instead of taking the whole array, what you can do is to consider the part which corresponds to this time window, 30sec-59sec. Calculate the RMS energy of the signal separately for every music file, averaged over the whole time. You may also take other features into account, eg. , MFCC. \nIn order to use MFCC, you may go for the averaged value of all signal windows for a particular music file. Make a feature vector out of it. \nYou may use the difference between the features as the distance between the data points for classification.","Q_Score":5,"Tags":"python,algorithm,classification,extraction","A_Id":29713740,"CreationDate":"2014-11-04T10:57:00.000","Title":"Processing musical genres using K-nn algorithm, how to deal with extracted feature?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I do Run Unittest .... test_foo in PyCharm it takes quite long to run the test, since all tests get collected first. PyCharm uses py.test -k to run the test.\nSince we have more than 1000 tests, collecting them takes some time (about 1.2 seconds). Often the test itself needs less time to execute!\nSince I use this very often, I want to speed this up.\nAny idea how to get this done?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1778,"Q_Id":26735790,"Users Score":0,"Answer":"Answer to own question:\nI installed pyCharm again (for other reasons) and now it uses utrunner.py.\nIt is much faster if I run Run 'Unittest test_foo', since not this does not collect all tests before running the test.\nProblem solved.","Q_Score":0,"Tags":"python,pycharm,pytest","A_Id":27827622,"CreationDate":"2014-11-04T13:00:00.000","Title":"py.test -k: collecting tests takes too much time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A bit of a beginner question.Iv just started learning Django and can pretty much create basic stuff .Now when I want to access my website on my computer I just type in the local URL and I can access the site,other links etc.\nIf I want to show this to someone else how would I do it?..They wouldn't be able to just type in the local url so what would they need to do to access it?Also If someone asks me to create an API for them what exactly does it mean?I'm a beginner with web technologies so any help would be appreciated!\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":290,"Q_Id":26743435,"Users Score":0,"Answer":"By others, do you mean someone on your local network or someone on internet. \nOn local network its very easy, instead starting the local developmnet server by\npython manage.py runserver you can do \npython manage.py runserver 10.1.0.123:8000 (assuming 10.1.0.123 is your system's ip), \nthen people on you local network can access http:\/\/10.1.0.123:8000 to see your site. \nIf you want to show it to someone on internet, then either you host it on something like heroku, or another cheap and quick method if to configure your router to divert the specific port to your machine and give that person your dynamic ip. This only applies if you have a router like in a home dev setup. You can go to google and just type what is my ip and get your dynamic static ip","Q_Score":0,"Tags":"python,django","A_Id":26743769,"CreationDate":"2014-11-04T19:30:00.000","Title":"Django site-external access","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My teacher wants us to recreate the dict class in Python using tuples and linkedlists (for collisions). One of the methods is used to return a value given a key. I know how to do this in a tuple ( find the key at location[0] and return location[1]) but I have no idea how I would do this in the case of a collision. Any suggestions? If more info is needed please let me know","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1152,"Q_Id":26749349,"Users Score":2,"Answer":"It sounds like you have some sort of hash to get a shortlist of possibilities, so, you hash your key to a small-ish number, e.g. 0-256 (as an example, it might hash to 63). You can then go directly to your data at index 63. Because you might have more than one item that hashes to 63, your entry for 63 will contain a list of (key,value) pairs, that you would have to search one by one - effectively, you've reduced your search area by 255\/256th of the full list. Optionally, when the collisions for a particular key exceeds a threshold, you could repeat the process - so you get mydict[63][92], again reducing the problem size by the same factor. You could repeat this indefinitely.","Q_Score":0,"Tags":"python,linked-list","A_Id":26749431,"CreationDate":"2014-11-05T03:43:00.000","Title":"Using tuples in a linked list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I define my model ndb in python. I want to use the email address of a user as the key, how do I do that? user is passing in the email address through an html form. I have everything setup and working. I just don't know how to specify that the email address string is the key.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":26783510,"Users Score":0,"Answer":"When you create your entity do this:\nMyModel(id=emailAddress).put()\nthen use get_by_id\nuser = MyModel.get_by_id(emailAddress)","Q_Score":0,"Tags":"python,google-app-engine,google-cloud-datastore","A_Id":26784116,"CreationDate":"2014-11-06T15:44:00.000","Title":"use email address as datastore key using python app engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to read a file in another directory. My current script is in path\/to\/dir. However, I want to read a file in ~\/. I'm not sure how to do this.\nI tried f = open(\"~\/.file\") but I am getting an error\nIOError: [Errno 2] No such file or directory: '~\/.file'","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":134,"Q_Id":26812282,"Users Score":2,"Answer":"os.path.expanduser will help you","Q_Score":0,"Tags":"python","A_Id":26812299,"CreationDate":"2014-11-08T00:25:00.000","Title":"Reading a file in home directory from another directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"guys,\nI am trying to find a python GUI library that can show and process 16bit greyscale image easily. I need to modify pixels. I have tried wxpython. It can show the images. But when I tried to convert a numpy array with single channel 16bit data to a string and loaded it in wxImage, it showed me that invalid buffer size. What's more, I have tried to decode the first element of data string in a wxImage instance that load the same image directly. Its value wasn't equal to the pixel (0,0) in numpy array. \nCould someone tell me how wxPython format its data string or introduce a better GUI library that can fix this? I know wxImage normally formats its pixel data with RGB. But I just need grey image. And I need to create a sophisticated UI. I think opencv can't meet my need.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":377,"Q_Id":26831593,"Users Score":0,"Answer":"You can use pyqt or pyside, but I would recommend pyqtgraph which is excellent for this sort of thing. You can build your ui in pyside and use pyqtgraph to manage image output","Q_Score":0,"Tags":"python,numpy,wxpython","A_Id":26832062,"CreationDate":"2014-11-09T18:20:00.000","Title":"Python GUI library to show 16bit greyscale image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have classes in a Python project that depend on an external packages. I would like these classes to be created only if their dependencies are available.\nFor example, how can I have a class YamlParser which only exists if yaml can be imported?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":26837554,"Users Score":0,"Answer":"The modular and extensible solution is to put YamlParser in its own source file, and simply put the import yaml statement at the beginning. Any code which tries to import this code will fail if the required module yaml is missing.","Q_Score":1,"Tags":"python","A_Id":26847891,"CreationDate":"2014-11-10T05:49:00.000","Title":"create a class only if a package is available on the system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've come to the realization where I need to change my design for a file synchronization program I am writing.\nCurrently, my program goes as follows:\n1) client connects to server (and is verified)\n2) if the client is verified, create a thread and begin a loop using the socket the client connected with\n3) if a file on the client or server changes, send the change through that socket (using select for asynchronous communication)\nMy code sucks because I am torn between using one socket for file transfer or using a socket for each file transfer. Either case (in my opinion) will work, but for the first case I would have to create some sort of protocol to determine what bytes go where (some sort of header), and for the second case, I would have to create new sockets on a new thread (that do not need to be verified again), so that files can be sent on each thread without worrying about asynchronous transfer.\nI would prefer to do the second option, so I'm investigating using SocketServer. Would this kind of problem be solved with SocketServer.ThreadingTCPServer and SocketServer.ThreadingMixIn? I'm having trouble thinking about it because I would assume SocketServer.ThreadingMixIn works for newly connected clients, unless I somehow have an \"outer\" socket server which servers \"inner\" socket servers?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":26848683,"Users Score":0,"Answer":"SocketServer will work for you. You create one SocketServer per port you want to listen on. Your choice is whether you have one listener that handles the client\/server connection plus per file connections (you'd need some sort of header to tell the difference) or two listeners that separate client\/server connection and per file connections (you'd still need a header so that you knew which file was coming in).\nAlternately, you could choose something like zeromq that provides a message transport for you.","Q_Score":0,"Tags":"python,sockets,socketserver","A_Id":26849719,"CreationDate":"2014-11-10T16:44:00.000","Title":"Can I use the Python SocketServer class for this implementation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i\u00b4m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me?\n->I already tried putting # coding: iso-8859-1 -*- on top,\n->using encode like print \"nome do seu ch\u00e1pa\".encode('iso-8859-1') also doesn't work and even\n-> using print u\"N\u00e2o\" doesn't work","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4338,"Q_Id":26855274,"Users Score":0,"Answer":"I got the answer: my console needed to be restarted. I use Spyder(from Python x,y) for development and this error occcured, so beware.\nUPDATE: Spyder console seems to suck, because to get it to work, I had to use string.encode('latin1') and (now here's the catch) OPEN A NEW CONSOLE! If I try to reuse my already open console, special characters just won't work.","Q_Score":0,"Tags":"python,utf-8","A_Id":26855540,"CreationDate":"2014-11-11T00:01:00.000","Title":"python 2.7 - how to print with utf-8 characters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i\u00b4m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me?\n->I already tried putting # coding: iso-8859-1 -*- on top,\n->using encode like print \"nome do seu ch\u00e1pa\".encode('iso-8859-1') also doesn't work and even\n-> using print u\"N\u00e2o\" doesn't work","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4338,"Q_Id":26855274,"Users Score":0,"Answer":"A more complete response.\nStrings have two types in Python 2, str and unicode.\nWhen using str, you are using bytes so you can write them directly to files like stdout.\nWhen using unicode, it has to be serialized or encoded to bytes before writing to files.\nSo, what happens here? print \"nome do seu ch\u00e1pa\".encode('iso-8859-1')\nYou have bytes but you try to encode them so Python 2 first decodes them behind your back and then encodes using the requested standard. This may work, if lucky, or produce gibberish.\nNow, when doing the following: print u\"N\u00e2o\".encode('utf-8')\nYou are telling Python 2 that you start with Unicode so then it will encode it without the problematic decode.\nPython 3 solved this nastiness.","Q_Score":0,"Tags":"python,utf-8","A_Id":26855341,"CreationDate":"2014-11-11T00:01:00.000","Title":"python 2.7 - how to print with utf-8 characters?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just begin to use xshell in Windows 7, it looks good, but how can I enter interactive console of iPython in xshell?\nIn cmd of windows, when I type \"ipython\", it will bring me to the interactive console automatically.\nHowever, in xshell, I've tried several command like \"ipython\", \"ipython console\", all of them would not bring me to the interactive console of ipython.\nBTW, I'm using xshell 5 (home\/school edition) in Windows 7.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":262,"Q_Id":26881673,"Users Score":2,"Answer":"According to the response from technical support team of XSHELL, it seems xshell does not support interactive shell currently.\n\n\nhow can I enter interactive console of iPython in xshell? In cmd of windows, when I type \"ipython\", it will bring me to the interactive\n  console automatically. However, in xshell, I've tried several command\n  like \"ipython\", \"ipython console\", all of them would not bring me to\n  the interactive console of ipython.\n\n\n\nXshell does not support interactive shell at this time. We are working on it.","Q_Score":1,"Tags":"ipython,xshell","A_Id":26924407,"CreationDate":"2014-11-12T07:42:00.000","Title":"how to start iPython in xshell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently debugging a memory leak in a Python program.  Since none of my objects have a __del__ method, I'm assuming the issue is some sort of global variable that continues to accumulate references to reachable objects.  Also, when I run using gc.debug(gc.DEBUG_LEAK), I see a lot of gc: collectable messages, but no gc: uncollectable messages.  To confirm this suspicion, I'd like to somehow get a count of the total number of reachable objects in my program, so I can confirm that it is steadily increasing.\nIs there any way to get this?  I was looking at gc.get_count but this seems to give me the number of objects which were actually collected (separated by generation) rather than the number of live objects which are still reachable.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":492,"Q_Id":26889459,"Users Score":1,"Answer":"It looks like gc.get_objects is what you want. Be careful using DEBUG_LEAK as it implies DEBUG_SAVEALL. DEDUG_SAVEALL causes all unreferenced objects to be saved in gc.garbage rather than freed. This means the number of objects tracked by the garbage collector can only increase. Additionally gc.get_objects does not return all currently live objects, as some types are not tracked by the garbage collector (atomic types are not tracked). For instance, [i for i in range(1000)] will only increase the objects tracked by one as the integers are not tracked by the garbage collector. Whereas, [[] for i in range(1000)] will increase the number of objects tracked by 1001.","Q_Score":1,"Tags":"python,garbage-collection","A_Id":26889994,"CreationDate":"2014-11-12T14:33:00.000","Title":"Get count of reachable live objects","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a python app that already has the protobuf messages defined. However, we need to use a custom wire format (I believe that's the correct term).\nHow do you (in python) override the base encoding functions? \nI've looked in encoder.py and that's a maze of nested functors. So what do I need to monkey patch (or whatever) to specify my own encodings?\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":819,"Q_Id":26915644,"Users Score":1,"Answer":"I wouldn't recommend trying to monkey-patch the encoding functions. You will almost certainly break something.\nWhat you can do is write an independent function which encodes a protobuf in an arbitrary way via reflection. For an example of this, see the text_format.py module in Protobufs itself. This module encodes and decodes messages in an alternative human-readable format entirely based on the public descriptor and reflection interfaces. You can follow the same pattern to write your own encoder\/decoder for any format.","Q_Score":0,"Tags":"python,protocol-buffers","A_Id":26941801,"CreationDate":"2014-11-13T18:12:00.000","Title":"how to use custom encoding\/decoding with Google Protobuf","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In ORANGE - I found that the Discretize widget is missing in my installation - where do I go to load it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":26923372,"Users Score":0,"Answer":"In my case this error was due to an old version of numpy being installed prior to installing Orange on a windows install. The Orange installer did not upgrade numpy even though for some widgets it requires it (the discretize widget being one of them which then fails to load silently^). \nUninstalling numpy and rerunning the orange installer (which then installed a current version of numpy) fixed the issue.\n^ Silently with respect to the interface - errors were shown in canvas.log which can be found in C:\\Users\\[your_username]\\AppData\\Local\\Orange Canvas","Q_Score":0,"Tags":"python,data-mining,orange","A_Id":28112745,"CreationDate":"2014-11-14T05:15:00.000","Title":"Missing widget - how do I load one (Discretize)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried using some Unix command using the subprocess module on my Python interpreter installed on a windows 7 OS. However, it errors out saying command not found. It does recognize Windows commands though. Can I somehow use Unix commands in here too?\nThanks,\nVishal","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1284,"Q_Id":26939090,"Users Score":0,"Answer":"You have to install Unix Bash for Windows, but not sure if it works correctly ... Better solution is install or virtualize some Linux distribution.","Q_Score":0,"Tags":"python,windows,shell,unix","A_Id":26939339,"CreationDate":"2014-11-14T21:22:00.000","Title":"How to run Unix commands in python installed on a windows machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an existing django project on an AWS instance.  I have copied my Python files to my local machine.  PyCharm is configured to use the Python interpreter on the remote machine.  The django file references are, naturally, not resolved by PyCharm, since the django files are not on the local machine.\nIs the usual procedure to copy all the django files from the remote server to my local machine.  Or is there another way to get PyCharm to know where to look to resolve the django references?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":26948469,"Users Score":0,"Answer":"(Using PyCharm 4.0) Go to Tools --> Deployment --> and either select an existing server connection or create a new one.  Under the Mappings tab, you can associate a local path with a remote path.  I keep my Django project folder mapped to the one on the server.\nOnce you hit OK, go back to Tools --> Deployment, and you should see a bunch of options available to you that were greyed out before, such as:\n\nUpload to [server name]\nDownload from [server name]\nSync to Deployed to [server name]\nAutomatic Upload\n\nI find Automatic Upload handy for when I want the changes in newly saved Django files reflected on the server within seconds of hitting save.","Q_Score":1,"Tags":"python,django,pycharm","A_Id":27120852,"CreationDate":"2014-11-15T17:16:00.000","Title":"With PyCharm, how do I reference django files when using remote AWS interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a non-programmer who started to learn Python. My Mac OS X Yosemite shipped with Python 2.7.6. I installed Python 3.4.2 too. If I use pip or easy_install in the terminal to install a package, how do I know which Python I installed the package in? It seems Python 3.4.2 shipped with pip and easy_install, but I think Python 2.7.6 may also have some version of pip or easy_install. I know my system can have both versions of Python, but can it have multiple versions of pip or easy_install?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":163,"Q_Id":26965450,"Users Score":2,"Answer":"There's an easy way around it - use pip2 or pip2.7 or pip-2.7 for Python 2, and pip3 or pip3.4 or pip-3.4 for Python 3. Both version ship with easy_install, but Python 2 does not contain pip by default - you have to install it yourself.","Q_Score":3,"Tags":"python,macos,pip,easy-install","A_Id":26965467,"CreationDate":"2014-11-17T04:17:00.000","Title":"Which version of Python did pip or easy_install refer to by default?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm interested in creating physics simulations with Python so I decided to download Anaconda. Inside of an IPython notebook I can use the pylab module to plot functions, for example, with ease. However, if I try to import pylab in a script outside of IPython, it won't work; Python claims that the pylab module doesn't exist. \nSo how can I use Anaconda's modules outside of IPython?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":27001985,"Users Score":0,"Answer":"As a side note,\nIf you want to keep this functionality and move to a more script-like environment I would suggest using something like Spyder IDE. It comes with an editor linked with the IPython console that supports all the same magics as the IPython notebook.","Q_Score":2,"Tags":"python,python-3.x,import,module,anaconda","A_Id":27034348,"CreationDate":"2014-11-18T19:04:00.000","Title":"Using Anaconda modules outside of IPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm interested in creating physics simulations with Python so I decided to download Anaconda. Inside of an IPython notebook I can use the pylab module to plot functions, for example, with ease. However, if I try to import pylab in a script outside of IPython, it won't work; Python claims that the pylab module doesn't exist. \nSo how can I use Anaconda's modules outside of IPython?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":238,"Q_Id":27001985,"Users Score":1,"Answer":"I bet it will work if you use Anaconda's Python distribution.\nTry running .\/anaconda\/bin\/python and importing it from that Python session.","Q_Score":2,"Tags":"python,python-3.x,import,module,anaconda","A_Id":27002473,"CreationDate":"2014-11-18T19:04:00.000","Title":"Using Anaconda modules outside of IPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running OS X 10.9.5, and IDLE w\/ Python 3.4.1.\nWhen I press the buttons for (\u00a8\/^) or (\u00b4\/`), IDLE crashes and the program closes.\nThis causes me to lose changes to files, as well as time. My fellow students using Mac experience the same problem.\nAnyone know how I can fix this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3590,"Q_Id":27014098,"Users Score":0,"Answer":"I got the similar problem, Try British pc keyboard it works for me","Q_Score":0,"Tags":"python,macos,button,crash,python-idle","A_Id":45559740,"CreationDate":"2014-11-19T10:10:00.000","Title":"IDLE crashes for certain buttons on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a directory with 94 subdirectories, each containing one or two files *.fastq. I need to apply the same python command to each of these files and produce a new file qc_*.fastq.\nI know how to apply a bash script individually to each file, but I'm wondering if there is a way to write a bash script to apply the command to all the files at once","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":115,"Q_Id":27021617,"Users Score":2,"Answer":"You can try find . -name \"*.fastq\" | xargs your_bash_script.sh, which use find to get all the files and apply your script to each one of them.","Q_Score":0,"Tags":"python,bash,fastq","A_Id":27021713,"CreationDate":"2014-11-19T16:14:00.000","Title":"applying the same command to multiple files in multiple subdirectories","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a beginner at Python and have made the mistake of mixing spaces and tabs for indentations. I see people use reindent.py, but I have no idea how to use it. please explain in the simplest way possible without trying to use too fancy words and dumb it down as best as possible as I am a beginner. \nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17316,"Q_Id":27031912,"Users Score":0,"Answer":"If you are using Eclipse IDE, there are two formatting options available that can be used to accomplish this, accessed from the Source Menu. \na) \"Source > Convert space-tabs to tabs\" or \nb) \"Source > Convert tabs to space-tabs\"\nI was able to format code that had 2 spaces instead of a tab using the first option. You simply specify the  number of spaces to be converted into a tab.","Q_Score":8,"Tags":"python,indentation","A_Id":29987945,"CreationDate":"2014-11-20T04:43:00.000","Title":"HOWTO: Use reindent.py for dummies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Java version 7 and had installed PyDev version 3.9 from Eclipse Marketplace..but it's not showing up in New project or in Windows perspective in Eclipse..Can some one please tell me what i need to do ???","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7516,"Q_Id":27034666,"Users Score":0,"Answer":"Had this same problem a few days ago.  You might have downloaded the wrong version of PyDev for your python version (2.7.5 or something is my python version, but I downloaded PyDev for version 3.x.x)\n1) Uninstall your current version PyDev\n2) you have to install the correct version by using the \"Install New Software\", then uncheck the \"Show only newest software\" or whatever it is.  Then select the version that matched your python version, and install :)","Q_Score":3,"Tags":"python,eclipse","A_Id":27035599,"CreationDate":"2014-11-20T08:11:00.000","Title":"PyDev not appearing in Eclipse after install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im using processing in python mode but I want to use the processing library sound. But I dont know how to import this into my program in python syntax.\nIn java its like this:\nImport processing.sound.*;\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":390,"Q_Id":27053070,"Users Score":0,"Answer":"Use the add_library function:\nadd_library(\"sound\")","Q_Score":1,"Tags":"java,python","A_Id":40499350,"CreationDate":"2014-11-21T02:12:00.000","Title":"How to use java libraries in python processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im using processing in python mode but I want to use the processing library sound. But I dont know how to import this into my program in python syntax.\nIn java its like this:\nImport processing.sound.*;\nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":390,"Q_Id":27053070,"Users Score":0,"Answer":"You can use add_library(processing.sound). I used it with g4p library","Q_Score":1,"Tags":"java,python","A_Id":28146057,"CreationDate":"2014-11-21T02:12:00.000","Title":"How to use java libraries in python processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","AnswerCount":10,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":122154,"Q_Id":27066366,"Users Score":6,"Answer":"well it seems that it's a bug that django hadn't provided a command to stop the development server . I thought it have one before~~~~~","Q_Score":52,"Tags":"python,django,server","A_Id":27074081,"CreationDate":"2014-11-21T16:50:00.000","Title":"django development server, how to stop it when it run in background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","AnswerCount":10,"Available Count":5,"Score":0.0599281035,"is_accepted":false,"ViewCount":122154,"Q_Id":27066366,"Users Score":3,"Answer":"As far as i know ctrl+c or kill process is only ways to do that on remote machine.\nIf you will use Gunicorn server or somethink similar you will be able to do that using Supervisor.","Q_Score":52,"Tags":"python,django,server","A_Id":27066460,"CreationDate":"2014-11-21T16:50:00.000","Title":"django development server, how to stop it when it run in background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","AnswerCount":10,"Available Count":5,"Score":0.0199973338,"is_accepted":false,"ViewCount":122154,"Q_Id":27066366,"Users Score":1,"Answer":"From task manager you can end the python tasks that are running.\nNow run python manage.py runserver from your project directory and it will work.","Q_Score":52,"Tags":"python,django,server","A_Id":50886343,"CreationDate":"2014-11-21T16:50:00.000","Title":"django development server, how to stop it when it run in background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","AnswerCount":10,"Available Count":5,"Score":-0.0599281035,"is_accepted":false,"ViewCount":122154,"Q_Id":27066366,"Users Score":-3,"Answer":"You can Quit the server by hitting CTRL-BREAK.","Q_Score":52,"Tags":"python,django,server","A_Id":53480387,"CreationDate":"2014-11-21T16:50:00.000","Title":"django development server, how to stop it when it run in background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","AnswerCount":10,"Available Count":5,"Score":0.0798297691,"is_accepted":false,"ViewCount":122154,"Q_Id":27066366,"Users Score":4,"Answer":"Ctrl+c should work.  If it doesn't Ctrl+\/ will force kill the process.","Q_Score":52,"Tags":"python,django,server","A_Id":66500994,"CreationDate":"2014-11-21T16:50:00.000","Title":"django development server, how to stop it when it run in background?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am fairly new to the SNMP protocol and have only been introduced to it recently in my computer networking course.\nI understand how the manager sends Gets, Sets, GetNext, GetBulk and all that, it will catch Traps and such.  One thing I don't entirely understand is the MIB\nFrom what I gather, the MIB is chillen on an agent and the Manager will query for the MIB tree.  That is fine, although the Manager needs the OID to be able to properly query.  One question I have regards if these are hardcoded or not.  Are the OIDs hardcoded in the manager or not?\nOther than that, I'm not sure how to build the MIB file, apparently there is some special file type that defines the MIB structure and I don't really get how to use pySNMP to build that.  I feel like I would run that on the agent side of things upon startup\nCan somebody help clear up these conceptual issues for me?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":329,"Q_Id":27081314,"Users Score":0,"Answer":"Manager needs to know the variables to query for something specific. The variables can be identified by OIDs or MIB objects names.\nMIBs give Manager information such as:\n\nHuman friendly symbolic names associated with the OIDs\nTypes of values associated with particular OIDs\nHints on variable access permissions that are implemented by the Agent\nSNMP tables indices structure and types\nReferences to other MIB objects (e.g. Notifications)\n\nIf MIB is available, Manager would be able to perform any SNMP operation knowing either symbolic name or OID of the Agent's variable it is interested in. All required details would be gathered from the MIB.\nIf MIB is not available, Manager would still have to figure out more or less of the additional details (some are listed above) so those can be hardcoded to the Manager.\nFor example, a GET operation could be performed having just an OID, however without MIB Manager may have troubles making response value looking human friendly.\nAnother example is a SET operation that requires Manager to properly encode value -- its type can be dynamically looked up at the MIB or hardcoded into the Manager for specific OIDs.\nMore complex scenarios involve dynamically building OIDs (for addressing SNMP table entries) using indices structure formally defined by the MIB. \nThe purpose of the GETNEXT\/GETBULK queries is to let Manager be unaware of the exact set of OIDs provided by the Agent. So Manager could iterate over Agent's variables starting from a well known OID (or even its prefix). One of the uses of this feature is SNMP table retrieval.\nMIBs are written in a subset of ASN.1 language. Unlike ASN.1, MIBs are very specific to SNMP domain.\nTo use MIBs with pysnmp you need to pass ASN.1 MIBs to the build-pysnmp-mib shell script (from pysnmp distribution) which would invoke smidump and other tools to convert ASN.1 MIBs into a collection of Python classes representing pysnmp-backed MIB objects.","Q_Score":0,"Tags":"python,snmp,conceptual,mib,pysnmp","A_Id":27083747,"CreationDate":"2014-11-22T19:06:00.000","Title":"Trouble grasping MIBs with PySNMP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dictionary, for which I want to calculate all values to zscores. Now I do know how to how to compute the zscore of an array, but have no idea how to do this for a dictionary. Does anybody have some tips?\nThanks!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2411,"Q_Id":27081784,"Users Score":0,"Answer":"assuming you use Scipy to calculate the Z-score and not manually\n\nfrom scipy import stats\nd = {'keys':values, ...}\ndict_values = d.values()\nz = stats.zscore(dict_values)\n\nThis will return a Numpy array with your z scores","Q_Score":1,"Tags":"python,dictionary,statistics","A_Id":27081959,"CreationDate":"2014-11-22T19:51:00.000","Title":"Python: Calculate all values of dictionary to z-scores","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a UCI data set about wine quality. I have applied multiple classifiers and k-nearest neighbor is one of them. I was wondering if there is a way to find the exact value of k for nearest neighbor using 5-fold cross validation. And if yes, how do I apply that?  And how can I get the depth of a decision tree using 5-fold CV?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":185,"Q_Id":27091319,"Users Score":0,"Answer":"I assume here that you mean the value of k that returns the lowest error in your wine quality model.\nI find that a good k can depend on your data.  Sparse data might prefer a lower k whereas larger datasets might work well with a larger k.  In most of my work, a k between 5 and 10 have been quite good for problems with a large number of cases.\nTrial and Error can at times be the best tool here, but it shouldn't take too long to see a trend in the modelling error.\nHope this Helps!","Q_Score":2,"Tags":"ipython,classification,decision-tree,nearest-neighbor,cross-validation","A_Id":27095449,"CreationDate":"2014-11-23T16:30:00.000","Title":"Using cross-validation to find the right value of k for the k-nearest-neighbor classifier","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed (or so I think) python 2.7.5. When I type \"Python --version\" I get python2.7.5\nI've narrowed this down to:\n\nWhen I run \"python\" in a terminal in my \/Home\/UsrName\/ directory it is version 2.7.5\nHowever when I run \"python\" in a terminal in \/Home\/UserName\/Downloads\/Ipython directory I get 2.6.6\n\nI went into the Ipython folder to run the Ipython Setup file. I think I need to add python27 to a system path so that when I am inside the \/Home\/UserName\/Downloads\/Ipython directory and run the install file Ipython knows I am using a required version of python.\nI am not sure how to add python27 to the system on redhat linux 6.5 (Also I am not even sure that this will fix it).","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":18214,"Q_Id":27115526,"Users Score":0,"Answer":"You have your $PATH fine, as you can run python without specifying full path, aka \/usr\/bin\/python.\nYou get 2.6.6 in Ipython directory because it has python executable in it, named, wild guess - python.  2.7.5 is installed system-wide. To call 2.7.5 from the Ipython dir, use full path \/usr\/bin\/python, or whatever which python points to.\nTry out python virtualenv if you need two or more version of python on your system. Otherwise, having different versions is not a good idea.","Q_Score":1,"Tags":"python,linux,ipython,redhat","A_Id":27115695,"CreationDate":"2014-11-24T22:41:00.000","Title":"how to get python 2.7 into the system path on Redhat 6.5 Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed (or so I think) python 2.7.5. When I type \"Python --version\" I get python2.7.5\nI've narrowed this down to:\n\nWhen I run \"python\" in a terminal in my \/Home\/UsrName\/ directory it is version 2.7.5\nHowever when I run \"python\" in a terminal in \/Home\/UserName\/Downloads\/Ipython directory I get 2.6.6\n\nI went into the Ipython folder to run the Ipython Setup file. I think I need to add python27 to a system path so that when I am inside the \/Home\/UserName\/Downloads\/Ipython directory and run the install file Ipython knows I am using a required version of python.\nI am not sure how to add python27 to the system on redhat linux 6.5 (Also I am not even sure that this will fix it).","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":18214,"Q_Id":27115526,"Users Score":0,"Answer":"I think I know what is happening - abarnert pointed out that the cwd (\".\") may be in your path which is why you get the local python when you're running in that directory. Because the cwd is not normally setup in the global bashrc file (\/etc\/bashrc) it's probably in your local ~\/.bashrc or ~\/.bash_profile. So edit those files and look for something like PATH=$PATH:. and remove that line. Then open a new window (or logout and log back in) to refresh the path setting and you should be OK.","Q_Score":1,"Tags":"python,linux,ipython,redhat","A_Id":27116633,"CreationDate":"2014-11-24T22:41:00.000","Title":"how to get python 2.7 into the system path on Redhat 6.5 Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Not a major issue but just an annoyance I've come upon while doing class work. I have my Notepad++ set up to run Python code straight from Notepad++ but I've noticed when trying to access files I have to use the full path to the file even given the source text file is in the same folder as the Python program being run.\nHowever, when running my Python program through cmd I can just type in the specific file name sans the entire path.\nDoes anyone have a short answer as to why this might be or maybe how to reconfigure Notepad++?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":510,"Q_Id":27117461,"Users Score":2,"Answer":"In the properties of the shortcut that you use to start Notepad++, you can change its working directory, to whichever directory you're more accustomed to starting from in Python. You can also begin your python program with the appropriate os.chdir() command.","Q_Score":1,"Tags":"python,file-io,cmd,notepad++","A_Id":27117505,"CreationDate":"2014-11-25T01:47:00.000","Title":"Python program needs full path in Notepad++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have \"Articles\" and \"Modules\" apps. Inside \"Modules\" app there is model which have to display articles and they're linked by ManyToManyField in \"Modules\".\nMy question is how to modify text value in select field in Django admin? As default it displays names of articles, but i want also some information from Article model here. \nIs there a simple way to do that?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":579,"Q_Id":27135428,"Users Score":0,"Answer":"The Django Admin select menus use the unicode value of the model instance to populate things like menus. Whatever your __unicode__ method returns should be what is in the select menu.","Q_Score":2,"Tags":"python,django,admin,manytomanyfield","A_Id":27135554,"CreationDate":"2014-11-25T19:49:00.000","Title":"How to modify Django admin ManyToManyField text?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The title says it all.\nI spent a lot of time designing a sketch in Processing using the Python language.\nNow, I would like to put the sketch on a webpage.\nOf course, I could just translate the sketch from python language to javascript and use a javascript library for processing.\nHowever, this would be a very lengthy process. As such, do you know if there is a way to integrate a python sketch in the website? If yes, how to do that?\nThank you in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":144,"Q_Id":27145014,"Users Score":0,"Answer":"At the moment there is no straightforward way to do this. But some workarounds can be found. For example, since Processing's python mode is using Jython language (Python on JVM) you can do the following:\n\nCompile the Jython code to Java bytecode\nDecompile Java bytecode to real Java code\nUse processing.js to make the sketch run in a webpage\n\nOf course, there are chances that the generated Java code will not be 100% Processing code, thus will not be converted to Javascript by the processing.js library.","Q_Score":4,"Tags":"javascript,python,processing","A_Id":49843328,"CreationDate":"2014-11-26T09:05:00.000","Title":"Is there a way to integrate a processing sketch written in Python in a webpage?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I reference a method, decorated with @property?\nFor simple methods, :py:meth: is working fine, but not for properties: it does not create a link to them.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6984,"Q_Id":27170958,"Users Score":0,"Answer":"I use :py:obj: instead. \n:py:attr: won't work for me when the property is in another page.","Q_Score":16,"Tags":"python,python-sphinx","A_Id":59568068,"CreationDate":"2014-11-27T12:34:00.000","Title":"Sphinx documentation: how to reference a Python property?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a tf-idf matrix already, with rows for terms and columns for documents. Now I want to train a LDA model with the given terms-documents matrix. The first step seems to be using gensim.matutils.Dense2Corpus to convert the matrix into the corpus format. But how to construct the id2word parameter? I have the list of the terms (#terms==#rows) but I don't know the format of the dictionary so I cannot construct the dictionary from functions like gensim.corpora.Dictionary.load_from_text. Any suggestions? Thank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":505,"Q_Id":27177721,"Users Score":1,"Answer":"id2word must map each id (integer) to term (string).\nIn other words, it must support id2word[123] == 'koala'.\nA plain Python dict is the easiest option.","Q_Score":3,"Tags":"python-3.x,tf-idf,lda,topic-modeling,gensim","A_Id":27378733,"CreationDate":"2014-11-27T19:37:00.000","Title":"Training a LDA model with gensim from some external tf-idf matrix and term list","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to generate a uniformly random coordinate that is inside a convex bounding box defined by its (at least) 4 vertices (for the case of a tetrahedron).\nCan someone suggest an algorithm that I can use?\nThanks!\n\nIf a point is generated in a bounding box, how do you detect whether or not it is outside the geometry but inside the box?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1463,"Q_Id":27192467,"Users Score":3,"Answer":"There's a lot that's unspecified in your question, such as what distribution you want to use. For the sake of this answer, I'll assume a uniform distribution.\nThe straightforward way to handle an arbitrary volume uniform distribution is to choose three uniformly random numbers as coordinates in the range of the bounding rectilinear solid enclosing your volume, then check to see if the chosen coordinate lies within the volume. If the coordinate is not within the volume, discard it and generate a new one.\nIf this is not sufficient, due to its non-constant performance or whatever other reason, you'll need to constrain your problem (say, to only tetrahedra) and do a bunch of calculus to compute the necessary random distributions and model the dependencies between the axes.\nFor example, you could start with the x axis and integrate the area of the intersecting shapes between the volume and the plane where x = t. This will give you a function p(x) which, when normalized, is the probability density function along the X axis. (If you want nonuniform distribution, you need to put that in the integrated function, too.)\nThen you need to do another set of integrals to determine p(y|x0), the probability distribution function on the Y axis given the chosen x coordinate. Finally, you'll need to determine p(z|x0,y0), the probability distribution function on the z axis.\nOnce you have all this, you need to use whatever random number algorithm you have to choose random numbers in these distributions: first choose x0 from p(x), then use that to choose y0 from p(y|x0), then use those to choose z0 from p(z|x0,y0), and you'll have your result (x0, y0, z0).\n\nThere are various algorithms to determine if a point is outside a volume, but a simple one could be:\n\nFor each polygon face:\n\nCompute its characteristic planes.\n\nUse cross product to compute plane normals.\nOne vertex of the face and the plane normal are sufficient to define the plane.\nRemember the right-hand rule and choose the points so that the plane normal consistently points into or out of the polyhedron.\n\nCheck that the random point lies on the \"inside\" half-space of that plane.\n\nA half-space is the set of all points on one side of the plane.\nCompute the vector from the plane vertex to the random point.\nCompute the dot product between the plane normal and this vector.\n\n\nIf you defined the plane normals to point out of the polyhedron, then all dot products must be negative.\nIf you defined the plane normals to point into the polyhedron, then all dot products must be positive.\n\nNote that you only have to recompute characteristic planes when the volume moves, not for each random point.\nThere are probably much better algorithms out there, and their discussion is outside the scope of this question and answer. This algorithm is what I could come up with with no research, and is probably as good as a bubble sort.","Q_Score":0,"Tags":"python,random,spatial,coordinate","A_Id":27192613,"CreationDate":"2014-11-28T16:11:00.000","Title":"Generate a random point in space (x, y, z) with a boundary","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible in an IPython-Notebook cell to get the previous (above) cell content ?\nI can see previous output with %capture magic function but I don't find how to get the previous cell content.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3415,"Q_Id":27192905,"Users Score":1,"Answer":"I didn't find how to get the previous content cell in a cell.\nBut I found another solution, creating a custom magic notebook function to capture the cell content and work with that.","Q_Score":5,"Tags":"ipython,ipython-notebook","A_Id":27229741,"CreationDate":"2014-11-28T16:39:00.000","Title":"IPython Notebook previous cell content","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With QPython on Kindle fire .. I use QEdit to write & save a .py file .. say bob.py ..\nBut when I switch to Console, I can't IMPORT from bob ..\nCan someone tell me how to do this?\nJohn (new to QPython)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":27193835,"Users Score":0,"Answer":"The comment from Yulia V got me thinking, maybe I just needed to append the location of \"Scripts\" to the sys.path,  and Yep, that worked fine!!\nThanks Yulia!","Q_Score":0,"Tags":"qpython","A_Id":27197253,"CreationDate":"2014-11-28T17:56:00.000","Title":"How to import from saved QPython file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With QPython on Kindle fire .. I use QEdit to write & save a .py file .. say bob.py ..\nBut when I switch to Console, I can't IMPORT from bob ..\nCan someone tell me how to do this?\nJohn (new to QPython)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":27193835,"Users Score":0,"Answer":"I think you can save the module file into the same directory which you script locates or  \/sdcard\/com.hipipal.qpyplus\/lib\/python2.7\/site-packages\/","Q_Score":0,"Tags":"qpython","A_Id":27209867,"CreationDate":"2014-11-28T17:56:00.000","Title":"How to import from saved QPython file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started with learning Python 3.4.x. \nI really want to keep learning and developing on all devices. That's why I'm using Codeanywhere. \nBut the problem is I don't know how to execute a .py file in Codeanywhere. \nIs there a method to do it?\nThanks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":9516,"Q_Id":27194932,"Users Score":2,"Answer":"You run your .py files just like you would if you were running the python commandline in windows. \nex. \npython myfile.py\nOpen a SSH terminal from your python devbox and type it in the cmd line and you're all set.","Q_Score":2,"Tags":"python","A_Id":30282342,"CreationDate":"2014-11-28T19:32:00.000","Title":"How do I run python in Codeanywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing a project on media (more like a video conferencing).\nThe problem is , although I am able to send text\/string data from one peer to another, I am still not sure about video files.\nUsing gstreamer, I am able to capture video stream from my webcam  and doing the encoding\/coding (H.264) , I am able to write the video stream into actual mp4 contanier directly using a file sink\nNow my problem is, I am not sure on reading the video files as it contains both audio and video streams, convert into transmission stream to transmit it using packets\n(I am able to send a very small jpeg file although).\nI am using socket module and implementing UDP","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":27198697,"Users Score":1,"Answer":"If you are to send a video(with audio) to a peer in the network, you would better use RTP(Real time Transfer Protocol) which works on top of UDP. RTP provides feature of timestamps and profile which help you syncronize the audio and video sent through two ports.","Q_Score":0,"Tags":"python,linux,sockets,video,udp","A_Id":27199731,"CreationDate":"2014-11-29T03:58:00.000","Title":"python - how to have video file(data) into list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a code where the pi gets a serial input from a usb-serial board(From the sparkfun RFID starter kit), how can I make this work?\n\nerror\nTraceback (most recent call last):\n   File \"main\", line 22, in \n    ser = s.Serial('ttyUSB0', 9600, timeout=10000)\n   File \"\/usr\/lib\/python2.7\/dist-packages\/serial\/serialutil.py\", line 260, in init\nself.open()\nFile \"\/usr\/lib\/python2.7\/dist-packages\/serial\/serialposix.py\", line 276, in open\n     raise SerialException(\"could not open port %s: %s\" % (self._port, msg))\n  serial.serialutil.SerialException: could not open port ttyUSB0: [Errno 2] No such file or >directory: 'ttyUSB0'\n\nThe RFID port is the ttyUSB0","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9230,"Q_Id":27204134,"Users Score":0,"Answer":"It's the cable. Check the USB cable. All of that yanking","Q_Score":1,"Tags":"python,serialization,raspberry-pi","A_Id":64522252,"CreationDate":"2014-11-29T15:58:00.000","Title":"ttyUSB0 not found on Raspberry Pi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to implement syntax highlighting for text in a Text widget. \nI use an external library to lexically analyse the text and give me the tokenised text. After that I go over all the words in the text and apply tag to their position in the text widget so that I can style each word. \nMy concern now is how do I deal with changes. Every time the user presses a key, do I tokenise the entire text again and add style tags to the text widget for the entire text. This is proving to be quite slow. \nI then transitioned to only doing the highlighting process for the line the insert character was to make it faster but this is giving faulty results and the highlighting is not perfect now. \nWhat would be an ideal compromise between fast and perfect? What is the best way to do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":228,"Q_Id":27207643,"Users Score":1,"Answer":"One possible answer is to do something like Idle does.  As a user hits each key, its custom incremental parser tags identifiers that are a keyword, builtin, or def\/class name*.  It also tags delimited char sequences that are a string or comment. I does what can be done quickly enough.\nFor example, if one types printer not in a string or comment, Idle checks if the word is a keyword or builtin name after each key.  After t is hit, print is tagged.  After e (or any other identifier char) is entered, printe is untagged. \nI believe some of the code is in idlelib\/Hyperparser.py and some in ColorDelegator.py.  You are free to copy and adapt code, but please do not use it directly, as the API may change.  I presume the parser does the minimum needed according to the current state (after def\/class, in an identifier, comment, string, etc.)\nIdle has an re-based function to retag the entire file.  I 'think' this is separate from the incremental colorizer, but I have not read all the relevant code. If one edits a long enough file, such as idlelib\/EditorWindow.py (about 3000 lines), and changes font size, Idle retags the file (I am not sure why).  There is a noticeable delay between the file turning all black and its being recolorized.  You definitely would not want that delay with each keystroke.\n\nClass\/functions names with non-ascii chars are not yet properly recognized in 3.x, but should be.  The patch is stuck on deciding the faster accurate method. Recognizing an ascii-only (2.x) indentifier is trivial by comparison.\n\nPS  I am correctly in guessing that you are interested in tagging something other than Python code?","Q_Score":0,"Tags":"python,performance,tkinter,syntax-highlighting,lexical-analysis","A_Id":27210959,"CreationDate":"2014-11-29T22:02:00.000","Title":"Efficiently applying text widget tags in tkinter text widgets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to debug separate pieces of my application in Visual Studio 2012.\nI have C# executable which works with Oracle.DataAccess dll. It works fine.\nWithin it IronPython runtime is invoked and it works fine too.\nWithin these IronPython modules object from main C# application is invoked and it works fine with Oracle dll.\nIf IronPython script is invoked standalone then it works fine and uses C# object fine as well. \nHowever in this case C# object doesn't see Oracle dll.\nTo debug IronPython scripts I have to create separate Python solution so I cannot configure my C# solution. So I do not have control of C# references. GAC has right Oracle dll but how to tell C# dll to use it?\nVise versa if I'm in C# solution where I can manage the references then I cannot add py files and debug them.\nIn what way can I configure VS to be able to run\/debug my application with dual entry C# or IronPython separately?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":390,"Q_Id":27208926,"Users Score":1,"Answer":"You can try replicating what \"works for me\". Create a solution containing:\n\npython project (ironpython)\nC# project\n\nAdd a reference to desired oracle library (Oracle.DataAccess.dll) to C# project using the standard VS mechanism. C# project should also contains a post build step to copy the resulting dll and pdb into the place where python script can find it. In my case root of the python project.\nYour python project is selected as Startup Project.\nI use Ctrl-F5 and F5 to start it. In both cases things work as expected.\nIn debug mode I am able to set and hit breakpoint in python and in referenced C# module. I can see the oracle library being loaded (Output window of debugger).\nHowever:\n\nThe stack traces are C# only.\nVisual Studio 2013 Update 4 together with PTVS 2.1 crashes on occasions when debugging.","Q_Score":0,"Tags":"c#,.net,dll,ironpython","A_Id":27233826,"CreationDate":"2014-11-30T01:01:00.000","Title":"DLL loading (C#\/IronPython\/C#) in VS2012","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have a particular task I need help with, but I was not sure how to do it. I have a model for the formation of ties between a fixed set of network nodes. So I want to set up a window or visualization that shows the set of all nodes on some sort of 2-dimensional or 3-dimensional grid. Then for each timestep, I want to update the visualization window with the latest set of ties between nodes. So I would start with a set of nodes positioned in space, and then with each timestep the visualization will gradually add the new edges. \nThe challenge here is that I know in something like networkx, redrawing the network at each timestep won't work. Many of the common network display algorithms randomly place nodes so that as to maximize the distance between thenm and better show the edges. So if I were to redraw the network at each timestep, the nodes would end up in different locations each time, and it would be hard to identify the pattern of network growth. That is why I want a set of static nodes, so I can see how the edges get added at each timestep.\nI am looking to visualize about 100 nodes at a time. So I will start with a small number of nodes like 20 or so, and gradually build up to 100 nodes. After the model is validated, then I would build up to 1000 or 2000 nodes. Of course it is hard to visualize 1000 or 2000 node network, that is why I just want to make sure I can visualize the network when I just have 100 nodes in the simulation.\nI was not sure if I could do this in webgl or something, or if there is a good way to do this in python. I can use Vispy for communication between python and webgl if needed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":308,"Q_Id":27217051,"Users Score":0,"Answer":"This looks like a good use-case for Vispy indeed. You'd need to use a PointVisual for the nodes, and a LineVisual for the edges. Then you can update the edges in real time as the simulation is executed.\nThe animation would also work in the IPython notebook with WebGL.\nNote that other graphics toolkits might also work for you (although you'd not necessarily have GPU acceleration through OpenGL) if you specify static positions for the nodes. I think you can fix the nodes positions with d3js or networkx instead of relying on an automatic layout algorithm.","Q_Score":0,"Tags":"python,opengl,webgl,ipython,vispy","A_Id":27259240,"CreationDate":"2014-11-30T19:08:00.000","Title":"network animation with static nodes in python or even webgl","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to automate a scenario in which, I have a terminal window open with multiple tabs open in it. I am able to migrate between the tabs, but my problem is how do i pass control to another terminal tab while i run my perl script in a different tab.\nExample: I have a terminal open with Tab1,Tab2,Tab3,Tab4 open in the same terminal, i run the perl script in Tab3 and i would want to pass some commands onto Tab1. Could you please tell me how can i do this ?? \nI use GUI tool to switch between tabs X11::GUITest and use keyboard shortcuts to switch between tabs, any alternative suggestion is welcome, my ultimate aim is to pass control on to a different tab.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":134,"Q_Id":27226551,"Users Score":1,"Answer":"The main thing to understand is that each tab has a different instance of terminal running, more importantly a different instance of shell (just thought I would mention as it didnt seem like you were clear about that from your choice of words). So \"passing control\" in such a scenario could most probably entail inter-process communication (IPC).\nNow that opens up a range of possibilities. You could, for example, have a python\/perl script running in the target shell (tab) to listen on a unix socket for commands in the form of text, which the script can then execute. In Python, you have modules subprocess (call, Popen) and os (exec*) for this. If you have to transfer control back to the calling process, then I would suggest using subprocess as you would be able to send back return codes too.\nSwitching between tabs is a different action and has no consequences on the calling\/called processes. And you have already mentioned how you intend on doing that.","Q_Score":0,"Tags":"python,perl,ubuntu,automation,perl-module","A_Id":27242918,"CreationDate":"2014-12-01T10:39:00.000","Title":"How do i pass on control on to different terminal tab using perl?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been trying to build a prediction model using a user\u2019s data. Model\u2019s input is documents\u2019 metadata (date published, title etc) and document label is that user\u2019s preference (like\/dislike). I would like to ask some questions that I have come across hoping for some answers:\n\nThere are way more liked documents than disliked. I read somewhere that if somebody train\u2019s a model using way more inputs of one label than the other this affects the performance in a bad way (model tends to classify everything to the label\/outcome that has the majority of inputs\nIs there possible to have input to a ML algorithm e.g logistic regression be hybrid in terms of numbers and words and how that could be done, sth like:\ninput = [18,23,1,0,\u2019cryptography\u2019] with  label = [\u2018Like\u2019]\nAlso can we use a vector ( that represents a word, using tfidf etc) as an input feature (e.g. 50-dimensions vector) ?\nIn order to construct a prediction model using textual data the only way to do so is by deriving a dictionary out of every word mentioned in our documents and then construct a binary input that will dictate if a term is mentioned or not? Using such a version though we lose the weight of the term in the collection right?\nCan we use something as a word2vec vector as a single input in a supervised learning model?\n\nThank you for your time.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":232,"Q_Id":27255560,"Users Score":1,"Answer":"You either need to under-sample the bigger class (take a small random sample to match the size of the smaller class), over-sample the smaller class (bootstrap sample), or use an algorithm that supports unbalanced data - and for that you'll need to read the documentation.\nYou need to turn your words into a word vector. Columns are all the unique words in your corpus. Rows are the documents. Cell values are one of: whether the word appears in the document, the number of times it appears, the relative frequency of its appearance, or its TFIDF score. You can then have these columns along with your other non-word columns.\n\nNow you probably have more columns than rows, meaning you'll get a singularity with matrix-based algorithms, in which case you need something like SVM or Naive Bayes.","Q_Score":2,"Tags":"python,machine-learning,language-features,feature-selection","A_Id":27256151,"CreationDate":"2014-12-02T17:36:00.000","Title":"Training a Machine Learning predictor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to delete cells from an Excel spreadsheet using openpyxl.  It seems like a pretty basic command, but I've looked around and can't find out how to do it.  I can set their values to None, but they still exist as empty cells.  worksheet.garbage_collect() throws an error saying that it's deprecated.  I'm using the most recent version of openpyxl.  Is there any way of just deleting an empty cell (as one would do in Excel), or do I have to manually shift all the cells up?  Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2658,"Q_Id":27259478,"Users Score":4,"Answer":"In openpyxl cells are stored individually in a dictionary. This makes aggregate actions like deleting or adding columns or rows difficult as code has to process lots of individual cells. However, even moving to a tabular or matrix implementation is tricky as the coordinates of each cell are stored on each cell meaning that you have process all cells to the right and below an inserted or deleted cell. This is why we have not yet added any convenience methods for this as they could be really, really slow and we don't want the responsibility for that.\nHoping to move towards a matrix implementation in a future version but there's still the problem of cell coordinates to deal with.","Q_Score":1,"Tags":"python,excel,openpyxl","A_Id":27280801,"CreationDate":"2014-12-02T21:38:00.000","Title":"Delete cells in Excel using Python 2.7 and openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am binding to ListBoxSelect and i want to implement a function which recognizes an alphabetical key-press and uses this to jump to the corresponding place in an alphabetically sorted list.\nIs there a way to tell what type of event is flagged by ListBoxSelect? I see something in the documentation about getting event \"keysym\" but i dont know how to access this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":27304973,"Users Score":0,"Answer":"No, there isn't a way to tell what type of event is flagged by <<ListboxSelect>>. Using <<ListboxSelect>> is useless for binding to a letter key, however. It only will fire for mouse clicks and using the arrow keys to navigate the listbox. \nYou can bind to <KeyPress>. That binding will tell you what key was pressed, and in that binding you can change the widget's selection. You can get that information from event.keysym","Q_Score":0,"Tags":"python,tkinter","A_Id":27305312,"CreationDate":"2014-12-04T22:01:00.000","Title":"How to determine the type of event flagged by <> in Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When installing a new python package with PIP, can I change the package name because there is another package with the same name?\nOr, how can I change the existing package's name?","AnswerCount":9,"Available Count":5,"Score":-0.0444152037,"is_accepted":false,"ViewCount":22776,"Q_Id":27308293,"Users Score":-2,"Answer":"This is not possible with the pip command line tool. All of the packages on PyPI have unique names. Packages often require and depend on each other, and assume the name will not change.","Q_Score":51,"Tags":"python,duplicates,package,pip","A_Id":27308401,"CreationDate":"2014-12-05T03:32:00.000","Title":"How to install python package with a different name using PIP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When installing a new python package with PIP, can I change the package name because there is another package with the same name?\nOr, how can I change the existing package's name?","AnswerCount":9,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":22776,"Q_Id":27308293,"Users Score":13,"Answer":"It's not possible to change \"import path\" (installed name) by specifying arguments to pip. All other options require some form of \"changes to the package\":\nA. Use pip install -e git+http:\/\/some_url#egg=some-name: that way even if both packages have the same import path, they will be saved under different directories (using some-name provided after #egg=). After this you can go to the source directories of packages (usually venv\/src\/some-name) and rename some folders to change import paths\nB-C. Fork the repository, make changes, then install the package from that repository. Or you can publish your package on PyPI using different name and install it by name\nD. use pip download to put one of the packages in your project, then rename folders as you like","Q_Score":51,"Tags":"python,duplicates,package,pip","A_Id":55817170,"CreationDate":"2014-12-05T03:32:00.000","Title":"How to install python package with a different name using PIP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When installing a new python package with PIP, can I change the package name because there is another package with the same name?\nOr, how can I change the existing package's name?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":22776,"Q_Id":27308293,"Users Score":0,"Answer":"I Don't think it is possible to change the name of package by using pip.\nBecause pip can install packages which are exist and gives error if there is no package name which you write for change the name of package.","Q_Score":51,"Tags":"python,duplicates,package,pip","A_Id":48315327,"CreationDate":"2014-12-05T03:32:00.000","Title":"How to install python package with a different name using PIP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When installing a new python package with PIP, can I change the package name because there is another package with the same name?\nOr, how can I change the existing package's name?","AnswerCount":9,"Available Count":5,"Score":0.0444152037,"is_accepted":false,"ViewCount":22776,"Q_Id":27308293,"Users Score":2,"Answer":"If you are struggling to install the correct package when using pip install 'module', you could always download its corresponding wheel file (.whl extension) and then install this directly using pip. This has worked for me in various situations in the past.","Q_Score":51,"Tags":"python,duplicates,package,pip","A_Id":49680767,"CreationDate":"2014-12-05T03:32:00.000","Title":"How to install python package with a different name using PIP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When installing a new python package with PIP, can I change the package name because there is another package with the same name?\nOr, how can I change the existing package's name?","AnswerCount":9,"Available Count":5,"Score":0.0886555158,"is_accepted":false,"ViewCount":22776,"Q_Id":27308293,"Users Score":4,"Answer":"Create a new virtualenv and then install the package on new virtualenv, with this you can have the different version of packages as well.","Q_Score":51,"Tags":"python,duplicates,package,pip","A_Id":50367038,"CreationDate":"2014-12-05T03:32:00.000","Title":"How to install python package with a different name using PIP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded and installed and also tested via a virtual machine online Odoo 8 and OpenErp 7. I have spent many hours tinkering with the apps and features of both. I am unable to find any way from hours I spend searching or tinkering for a method to change the approve timesheet functionality in the manner I will explain below.\nEach project will have an assigned manager. Any number employees can enter time for a project. Once employees send their timesheet to be be approved, each respective manager will only get that portion of the timesheet for which time was charged to the project they managed. They should be able to view each project and the employees in them.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":364,"Q_Id":27308836,"Users Score":1,"Answer":"You can manage this by grouping each employee according to their privilege. For example you have two groups Managerial and employee group so each of them might have different or some how common privilege on certain python objects from OpenERP so please identify those python objects and explore more in Setting >>  Users >> Groups","Q_Score":0,"Tags":"python,module,openerp-7,odoo,time-management","A_Id":27353088,"CreationDate":"2014-12-05T04:35:00.000","Title":"In using OpenErp 7 or Odoo 8, how do I modify it such that a manager assigned to a project is the one who will approve all timesheet entries for it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone tel me how to start a python script on boot, and then also load the GUI ? I am debian based Raspbian OS.\nThe reason I want to run the python script on boot is because I need to read key board input from a RFID reader. I am currently using raw_input() to read data from the RFID reader. The 11 character hex value is then compared against  a set of values in a txt file. This raw_input() did not work for me on autostarting python script using crontab and also  using with LXDE autostart.\nSo, I am thinking to run python script at boot, so that it reads keyboard input. If there are any other ways of reading keyboard input using crontab autostart and LXDE autostart, please let me know.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1590,"Q_Id":27337587,"Users Score":0,"Answer":"Try to use bootup option in crontab:\n@reboot   python \/path\/to\/pythonfile.py","Q_Score":0,"Tags":"python,linux,boot,raspbian,autostart","A_Id":27344131,"CreationDate":"2014-12-06T23:03:00.000","Title":"Starting a python script at boot and loading GUI after that","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In my app I need to know how big the canvas is in pixels.\nInstead calling canvas.size returns [100,100] no matter how many pixels the canvas is wide.\nCan you please tell me a way to get how many pixels the canvas is wide and high?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5156,"Q_Id":27358870,"Users Score":3,"Answer":"There is no position nor size in a Canvas. Canvas act just as a container for graphics instructions, like Fbo that draw within a Texture, so it have a size.\nIn Kivy, Canvas.size doesn't exists, but i guess you called your widget a canvas. By default, a Widget size is 100, 100. If you put it into a layout, the size will be changed, when the layout will known its own size. Mean, you need to listen to the changes of the Widget.size, or use a size you known, like Window.size.","Q_Score":2,"Tags":"python,kivy","A_Id":27380669,"CreationDate":"2014-12-08T13:15:00.000","Title":"Size of canvas in kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm so sorry for the vague question here, but I'm hoping an SPSS expert will be able to help me out here. We have some surveys that are done via SPSS, from which we extract data for an internal report. Right now the process is very cumbersome and requires going to the SPSS Data Collection Interviewer Server Administration page and manually exporting data from two different projects (which takes hours at a time!). We then take that data, massage it, and upload it to another database that drives the internal report.\nMy question is, does anyone out there know how to automate this process? Is there a SQL Server database behind the SPSS data? Where does the .mdd file come in to play? Can my team (who is well-versed in extracting data from various sources) tap into the SQL Server database behind SPSS to get our data? Or do we need some sort of Python script and plugin?\nIf I'm missing information that would be helpful in answering the question, please let me know. I'm happy to provide it; I just don't know what to provide.\nThanks so much.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1546,"Q_Id":27361967,"Users Score":-1,"Answer":"This isn't as clean as working directly with whatever database is holding the data, but you could do something with an exported data set:\nThere may or may not be a way for you to write and run an export script from inside your Admin panel or whatever. If not, you could write a simple Python script using Selenium WebDriver which logs into your admin panel and exports all data to a *.sav data file.\nThen you can use the Python SPSS extensions to write your analysis scripts. Note that these scripts have to run on a machine that has a copy of SPSS installed. \nOnce you have your data and analysis results accessible to Python, you should be able to easily write that to your other database.","Q_Score":1,"Tags":"python,sql-server,spss","A_Id":27362970,"CreationDate":"2014-12-08T16:06:00.000","Title":"Automating IBM SPSS Data Collection survey export?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm so sorry for the vague question here, but I'm hoping an SPSS expert will be able to help me out here. We have some surveys that are done via SPSS, from which we extract data for an internal report. Right now the process is very cumbersome and requires going to the SPSS Data Collection Interviewer Server Administration page and manually exporting data from two different projects (which takes hours at a time!). We then take that data, massage it, and upload it to another database that drives the internal report.\nMy question is, does anyone out there know how to automate this process? Is there a SQL Server database behind the SPSS data? Where does the .mdd file come in to play? Can my team (who is well-versed in extracting data from various sources) tap into the SQL Server database behind SPSS to get our data? Or do we need some sort of Python script and plugin?\nIf I'm missing information that would be helpful in answering the question, please let me know. I'm happy to provide it; I just don't know what to provide.\nThanks so much.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1546,"Q_Id":27361967,"Users Score":1,"Answer":"There are a number of different ways you can accomplish easing this task and even automate it completely. However, if you are not an IBM SPSS Data Collection expert and don't have access to somebody who is or have the time to become one, I'd suggest getting in touch with some of the consultants who offer services on the platform. Internally IBM doesn't have many skilled SPSS resources available, so they rely heavily on external partners to do services on a lot of their products. This goes for IBM SPSS Data Collection in particular, but is also largely true for SPSS Statistics.\nAs noted by previous contributors there is an approach using Python for data cleaning, merging and other transformations and then loading that output into your report database. For maintenance reasons I'd probably not suggest this approach. Though you are most likely able to automate the export of data from SPSS Data Collection to a sav file with a simple SPSS Syntax (and an SPSS add-on data component), it is extremely error prone when upgrading either SPSS Statistics or SPSS Data Collection.\nFrom a best practice standpoint, you ought to use the SPSS Data Collection Data Management module. It is very flexible and hardly requires any maintenance on upgrades, because you are working within the same data model framework (e.g. survey metadata, survey versions, labels etc. is handled implicitly) right until you load your transformed data into your reporting database.\nIdeally the approach would be to build the mentioned SPSS Data Collection Data Management script and trigger it at the end of each completed interview. In this way your reporting will be close to real-time (you can make it actual real-time by triggering the DM script during the interview using the interview script events - just a FYI).\nAll scripting on the SPSS Data Collection platform including Data Management scripting is very VB-like, so for most people knowing VB, it is very easy to get started and it is documented very well in the SPSS Data Collection DDL. There you'll also be able to find examples of extracting survey data from SPSS Data Collection surveys (as well as reading and writing data to\/from other databases, files etc.). There are also many examples of data manipulation and transformation.\nLastly, to answer your specific questions:\n\nYes, there is always an MS SQL Server behind SPSS Data Collection -\nno exceptions. However, generally speaking the data model is way to\ncomplex to read out data directly from it. If you have a look in it, \nyou'll quickly realize this.\nThe MDD file (short for Meta Data Document) is containing all survey meta\ndata including data source specifications, version history etc.\nWithout it you'll not be able to make anything of the survey data in\nthe database, which is the main reason I'd suggest to stay within the\nSPSS Data Collection platform for as large part of your data handling\nas possible. However, it is indeed just a readable XML file.\n\nNote that the SPSS Data Collection Data Management Module requires a separate license and if the scripting needed is large or complex, you'd probably want base professional too, if that's not what you already use for developing the questionnaires and handling the surveys.\nHope that helps.","Q_Score":1,"Tags":"python,sql-server,spss","A_Id":29892280,"CreationDate":"2014-12-08T16:06:00.000","Title":"Automating IBM SPSS Data Collection survey export?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm so sorry for the vague question here, but I'm hoping an SPSS expert will be able to help me out here. We have some surveys that are done via SPSS, from which we extract data for an internal report. Right now the process is very cumbersome and requires going to the SPSS Data Collection Interviewer Server Administration page and manually exporting data from two different projects (which takes hours at a time!). We then take that data, massage it, and upload it to another database that drives the internal report.\nMy question is, does anyone out there know how to automate this process? Is there a SQL Server database behind the SPSS data? Where does the .mdd file come in to play? Can my team (who is well-versed in extracting data from various sources) tap into the SQL Server database behind SPSS to get our data? Or do we need some sort of Python script and plugin?\nIf I'm missing information that would be helpful in answering the question, please let me know. I'm happy to provide it; I just don't know what to provide.\nThanks so much.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1546,"Q_Id":27361967,"Users Score":2,"Answer":"As mentioned by other contributors, there are a few ways to achieve this. The simplest I can suggest is using the DMS (data management script) and windows scheduler. Ideally you should follow below steps. \nPrerequisite: \n1. You should have access to the server running IBM Data collection\n2. Basic knowledge of windows task scheduler \n3. Knowledge of DMS scripting\nApproach:\n1. Create a new DMS script from the template\n2. If you want to perform only data extract \/ transformation, you only need input and output data source\n3. In the input data source, create\/build the connection string pointing to your survey on IBM Data collection server. Use the data source as SQL\n4. In the select query: use \"Select * from VDATA\" if you want to export all variables\n5. Set the output data connection string by selecting the output data format as SPSS (if you want to export it in SPSS)\n6. run the script manually and see if the SPSS export is what is expected\n7. Create batch file using text editor (save with .bat extension). Add below lines\ncd \"C:\\Program Files\\IBM\\SPSS\\DataCollection\\6\\DDL\\Scripts\\Data Management\\DMS\"\nCall DMSRun YOURDMSFILENAME.dms\nThen add a line to copy (using XCOPY) the data \/ files extracted to the location where you want to further process it.\n\nSave the file and open windows scheduler to schedule the execution of this batch file for data extraction. \n\nIf you want to do any further processing, you create an mrs or dms file and add to the batch file.\nHope this helps!","Q_Score":1,"Tags":"python,sql-server,spss","A_Id":30706866,"CreationDate":"2014-12-08T16:06:00.000","Title":"Automating IBM SPSS Data Collection survey export?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"my ultimate goal is to allow my raspberry pi detect when my iphone or pebble watch is nearby.  I am presently focusing on the pebble as I believe iphone randomizes the MAC address. I have the static MAC address of the pebble watch. \nMy question is how to detect the presence of the MAC address through bluetooth?\nI have tried hcitool rssi [mac address] or l2ping [mac address] however both needs a confirmation of connection on the watch before any response.  I want it to be automatic...\nI also tried hcitool scan, but it takes awhile, presumably it is going through all possibilities.  I simply want to search for a particular Mac Address.\nEDIT:  I just tried \"hcitool name [Mac Address]\" which return the name of the device and if not there it returns a \"null\" so this is the idea... is there a python equivalent of this?\nI am new to python, so hopefully someone can point to how I can simply ping the mac address and see how strong the RSSI value is?","AnswerCount":5,"Available Count":1,"Score":0.1586485043,"is_accepted":false,"ViewCount":15931,"Q_Id":27401918,"Users Score":4,"Answer":"Apple iDevices do use private resolvable addresses with Bluetooth Low Energy (BLE). They cycle to a different address every ~15 minutes. Only paired devices that have a so called Identity Resolving Key can \"decipher\" these seemingly random addresses and associate them back to the paired device.\nSo to do something like this with your iPhone, you need to pair it with your raspberry pi.\nThen what you can do is make a simple iOS app that advertises some data (what does not matter because when the app is backgrounded, only iOS itself gets to put data into the advertising packet). On the raspberry pi you can then use hcitool lescan to scan for the BLE advertisements. If the address of the advertisement can be resolved using the IRK, you know with high certainty that it's the iPhone. I'm not sure if hcitool does any IRK math out of the box, but the resolving algorithm is well specified by the Bluetooth spec.\nPebble currently does indeed use a fixed address. However, it is only advertising when it is disconnected from the phone it is supposed to be connected to. So, for your use case, using its BLE advertisements is not very useful. Currently, there is no API in the Pebble SDK to allow an app on the Pebble to advertise data.\n\nFWIW, the commands you mentioned are useful only for Bluetooth 2.1 (\"Classic\") and probably only useful if the other device is discoverable (basically never, unless it's in the Settings \/ Bluetooth menu).","Q_Score":3,"Tags":"python,bluetooth,pebble-watch","A_Id":27412126,"CreationDate":"2014-12-10T13:12:00.000","Title":"Detecting presence of particular bluetooth device with MAC address","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project and I did the following:\n\nAdded a table with some columns\nInsert some records into the db\nAdded a new column that I didn't realize I needed\nMade an update to populate that column \n\nWhen I did a migrate everything worked just fine. The new db column was created on the table and the values were populated. \nWhen I try to run my tests, however, I now bomb out at step 2 above. When I do insert, I believe it is expecting that field to be there, even though it hasn't been created at that point yet. \nWhat should I do?\nEDIT: More info\nI first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database.\nNow, I went to run my tests. It tried to create the test db and bombed out, saying \"1054 - Unknown column [my new column that I added to an existing table]\" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":8200,"Q_Id":27403050,"Users Score":0,"Answer":"I faced the same issue all what i do to get out this issue just drop all tables in my DB and then run: \n\npython manage.py makemigrations\n\nand :\n\npython manage.py migrate","Q_Score":4,"Tags":"python,mysql,django,database,data-migration","A_Id":60700719,"CreationDate":"2014-12-10T14:05:00.000","Title":"Django 1054 - Unknown Column in field list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project and I did the following:\n\nAdded a table with some columns\nInsert some records into the db\nAdded a new column that I didn't realize I needed\nMade an update to populate that column \n\nWhen I did a migrate everything worked just fine. The new db column was created on the table and the values were populated. \nWhen I try to run my tests, however, I now bomb out at step 2 above. When I do insert, I believe it is expecting that field to be there, even though it hasn't been created at that point yet. \nWhat should I do?\nEDIT: More info\nI first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database.\nNow, I went to run my tests. It tried to create the test db and bombed out, saying \"1054 - Unknown column [my new column that I added to an existing table]\" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":8200,"Q_Id":27403050,"Users Score":0,"Answer":"This happened to me because I faked one migration (m1), created another (m2), and then tried to migrate m2 before I had faked my initial migration (m1). \nSo in my case I had to migrate --fake <app name> m1 and then migrate <app name> m2.","Q_Score":4,"Tags":"python,mysql,django,database,data-migration","A_Id":40621929,"CreationDate":"2014-12-10T14:05:00.000","Title":"Django 1054 - Unknown Column in field list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project and I did the following:\n\nAdded a table with some columns\nInsert some records into the db\nAdded a new column that I didn't realize I needed\nMade an update to populate that column \n\nWhen I did a migrate everything worked just fine. The new db column was created on the table and the values were populated. \nWhen I try to run my tests, however, I now bomb out at step 2 above. When I do insert, I believe it is expecting that field to be there, even though it hasn't been created at that point yet. \nWhat should I do?\nEDIT: More info\nI first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database.\nNow, I went to run my tests. It tried to create the test db and bombed out, saying \"1054 - Unknown column [my new column that I added to an existing table]\" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":8200,"Q_Id":27403050,"Users Score":0,"Answer":"Unless the new column has a default value defined, the insert statement will expect to add data to that column. Can you move the data load to be after the second migration. (I would have commented, but do not yet have sufficient reputation.)","Q_Score":4,"Tags":"python,mysql,django,database,data-migration","A_Id":29351981,"CreationDate":"2014-12-10T14:05:00.000","Title":"Django 1054 - Unknown Column in field list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django project and I did the following:\n\nAdded a table with some columns\nInsert some records into the db\nAdded a new column that I didn't realize I needed\nMade an update to populate that column \n\nWhen I did a migrate everything worked just fine. The new db column was created on the table and the values were populated. \nWhen I try to run my tests, however, I now bomb out at step 2 above. When I do insert, I believe it is expecting that field to be there, even though it hasn't been created at that point yet. \nWhat should I do?\nEDIT: More info\nI first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database.\nNow, I went to run my tests. It tried to create the test db and bombed out, saying \"1054 - Unknown column [my new column that I added to an existing table]\" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":8200,"Q_Id":27403050,"Users Score":0,"Answer":"I believe this was because the migration scripts were getting called out of order, due to a problem I had setting them up. Everything is ok now.","Q_Score":4,"Tags":"python,mysql,django,database,data-migration","A_Id":31042146,"CreationDate":"2014-12-10T14:05:00.000","Title":"Django 1054 - Unknown Column in field list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to track django user details using zoho CRM?  \nI am new zoho CRM, I got the few information and details how ZOHO CRm will be.  \nNow I want to know one thing, I had implement the django project and also have a account in zoho CRM. Now I would like to Tacke all my user details from app database in zoho crm.  \nhow to export app database users to zoho CRM and how to track the user behaviour?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":812,"Q_Id":27416913,"Users Score":0,"Answer":"All you need is export django auth but if extender user model is there then you can also take extended user model too...\nPlease update your question what Database you are using ?","Q_Score":0,"Tags":"python,django,crm,zoho","A_Id":27498436,"CreationDate":"2014-12-11T06:46:00.000","Title":"How to track django user details using zoho CRM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've considered storing the high scores for my game as variables in the code itself rather than as a text file as I've done so far because it means less additional files are required to run it and that attributing 999999 points becomes harder.\nHowever, this would then require me to run self-modifying code to overwrite the global variables representing the scores permanently. I looked into that and considering that all I want to do is really just to change global variables, all the stuff I found was too advanced.\nI'd appreciate if someone could give me an explanation on how to write self-modifying Python code to do just that, preferably with an example too as it aids understanding.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":414,"Q_Id":27510077,"Users Score":2,"Answer":"My first inclination is to say \"don't do that\".  Self-modifying Python (really any language) makes it extremely difficult to maintain a versioned library.\n\nYou make a bug fix and need to redistribute - how do you merge data you stored via self-modification.\nVery hard to authenticate packaging using a hash - once the local version is modified it's hard to tell which version it originated because SHAs won't match.\nIt's unsafe - You could just save and load a Python class that's not stored with your package, however, if it's user writable, a foreign process could add any arbitrary Python code to that file to evaluate.  Kind of like SQL injection but Python style.\n\nPython makes is so trivial to load and dump JSON files, that for simple things, I wouldn't think of anything else.  Even CSV files are trivial and can be bound to maps but can be more easily manipulated as data using your favorite spreadsheet editor.\nMy suggestion - don't use self-modifiying Python unless you're just wanting to experiment; It's just not a practical solution in the real world, unless you're working in an embedded environment where disk and memory are a premium.","Q_Score":0,"Tags":"python,self-modifying","A_Id":27510374,"CreationDate":"2014-12-16T17:08:00.000","Title":"Self-modifying Python code to keep track of high scores","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I seem to have problem launching python from command line. I tried various things with no success.\nProblem: When trying to run python from the command line, there is no response i.e. I do not get message about 'command not found' and console does not launch. Only option to open python console is to run C:\\Python34\\python.exe directly. Running using python command does not work even when in the python directory but python.exe launches. Issue with the launching this way is that python console is launched in new window. This whole problem is present only on one machine while on my other machine I am able to run python correctly and console launches in the command prompt window from which the python command was executed. \nPATH is correctly set to \nC:\\Python34\\;C:\\Python34\\Scripts;...\nand where python correctly returns C:\\Python34\\python.exe. I verified that running other commands imported through PATH (such as javac) run correctly.\nThings I tried:\n\nCompletely re-installing python both with x86 and x64 python installations with no success.\nCopy installation from my second machine and manually set the path variables - again no success.\n\nCan anyone hint how to resolve this behavior?\n(Additional info: Win 8.1 x64, python 3.4.2)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":632,"Q_Id":27517255,"Users Score":0,"Answer":"Issue resolved. Since no feasible solution was found in 2 days, I decided to wipe all keys containing 'python' from registry as well as some files that were not parts of other programs. This resolved the issue after re-installing python.\nIf anyone finds the true cause of this misbehavior and other - less brutal - solution, please write it here for future reference.","Q_Score":1,"Tags":"python,windows,command-line,command","A_Id":27557706,"CreationDate":"2014-12-17T02:05:00.000","Title":"Python console not launching properly from command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Protobuf with pure python performance 3x slowly on pypy than CPython do.\nSo I try to use c++ implementation for pypy.\nThese are two error (PyFloatObject undefined and const char* to char*) when I compile protobuf(2.6.1 release) c++ implementation for pypy.\nI compile successfully after I modify python\/google\/protobuf\/pyext\/message.c,But I get 'Segmentation fault' error finally when I use protobuf with c++ implementation on pypy.\nI don't know how to fix it, help me please!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":567,"Q_Id":27517939,"Users Score":1,"Answer":"So this is a happy non-answer using my experience. The pure-python bindings for google protobuf are a terrible port of C\/C++ stuff. However, I had quite a bit of success wrapping C google protobuf generated bindings using cffi. Someone should go ahead and create a more generic binding, but that would just a short consulting stint.","Q_Score":2,"Tags":"python,c++,protocol-buffers","A_Id":27687619,"CreationDate":"2014-12-17T03:40:00.000","Title":"Is there any way to use Google Protobuf on pypy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In Python 2.7 how do I parse 'abc' into 'a b c' for a very long string (like 1000 chars)?\nOr how would I convert 'abccda' to '1 2 3 3 4 1'? (where each unique letter maps to a unique digit, 1-4)\nI imagine I could pop the chars off, one by one, but I'm new to Python and wonder if there is a simple function that does it.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":116,"Q_Id":27539852,"Users Score":1,"Answer":"Do you mean the list method?\ns='abccda'\nlist(s)   # ['a', 'b', 'c', 'c', 'd', 'a']","Q_Score":2,"Tags":"python,string,parsing,format,character","A_Id":27539969,"CreationDate":"2014-12-18T05:35:00.000","Title":"python parse string into individual chararcters","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python programming. While making an application, I ran into this problem. \nI am parsing URL using urllib library of python. I want to convert any relative url into its corresponding absolute url. I get relative and absolute URLs in random fashiion and they may not be from the same domain. Now how do I store the last known absolute url to extract the netloc from it and append it to relative url? Should I save the last known absolute URL in a text file? Or is there any better option to this problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":27553319,"Users Score":0,"Answer":"Now how do I store the last known absolute url to extract the netloc\n  from it and append it to relative url? Should I save the last known\n  absolute URL in a text file?\n\nWhat do you think is wrong with this? Seems to make sense to me... (depending on context, obviously)","Q_Score":0,"Tags":"python,python-3.x,urllib","A_Id":27556712,"CreationDate":"2014-12-18T18:30:00.000","Title":"URL parsing issue in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering if it would be a good idea to use different .py scripts for different parts of a Python program. Like one .py file for a calculator and another for class files and etc. If it is a good idea, is it possible?\nIf possible, where can I find how to do so? \nI am asking this because I find it confusing to have so much code in a single file, and have to find it anytime fixing is needed.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":545,"Q_Id":27555520,"Users Score":1,"Answer":"If your program starts assuming big dimensions, yes, you could split your classes or simply your functions according to what they do. Usually functions that do similar tasks or that work on the same data are put together.\nTo import a file containing a set of functions that you defined, if the file is in the same folder where your main script is, you can simply use this statement, if, for example, the name of the script containing your function that you want to imported is called functions.py, you can simply do import functions or from functions import *, or, better, from functions import function_1.\nLet's talk about the 3 ways of importing files that I have just mentioned:\nimport functions\nHere, in order to use one of your functions, for example foo, you have to put the name of the module in front of the name of the function followed by a .:\nfunctions.foo('this is a string')\nfrom functions import *\nIn this case, you can directly call foo just typing foo('this is a new method of importing files'). * means that you have just imported everything from the module functions.\nfrom functions import function_1\nIn this last case, you have imported a specific function function_1 from the module functions, and you can use just the function_1 from the same module:\nfunction_1('I cannot use the function \"foo\" here, because I did not imported it')","Q_Score":0,"Tags":"python,class","A_Id":27555893,"CreationDate":"2014-12-18T20:55:00.000","Title":"Is it a good idea to make use different Python scripts for programs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I sincerely apologize for the noobish dribble thats about to come out here:\nOkay so I am following along with a youtube tutorial using terminal\/django\/komodo edit to make a simple website.  This is my first time really using terminal, I am having issues.  I have read up on the terminal and searched this site for my question but to no avail. Im hoping someone will take the time to answer this for me as it is most infuriating.  This is my first time working with virtual env's as well. \nSo my question is, How do I uhmm, I suppose \"save\" my virtual env settings? \nSo I have set up a new virualenv.  Downloaded django and started up my server so I can see things such as the admin page, log in page, from the internet page. Things go as they should along with the tutorial until it comes time to eventually turn off my computer. \nWhen I reload the virtualenv I cannot run the server, it gives me: Import error, no module named django.core.management.\nI use pip freeze and it shows that django is no longer installed.\nIf trying to reinstall django it gives a long block of error messages. \nAll the work done within the virtualenv file is still visible for the komodo edit pages however, but it seems the terminal does not want to work properly. My only option thus far has been to completely remake a virualenv, re-set it all up with the proper imports, files, django and restart the project.  \nso my questions are:\nhow do I save my terminal and\/or virtualenv settings?\nWhat do I need to do before logging off to ensure I will be able to continue with my project?\nLets say I am going to continue with my project, How do I start up the project again via terminal? Is that where I am going wrong?  I've assumed up until now that I must go into terminal, start the server again and then from komodo edit continue with my project, but inside the terminal everything goes wrong.\nIm not even explicitly saying I cannot continue with my project, I am more saying the terminal is not recognizing I had django installed within my virtualenv, and it is not letting me start the server again.\nI have tried doing the research on my own, I am not one to sit back and wait for an answer but being completely new, this is baffling.  I am sorry for the noob questions, feel free to link another answered question or website that has the answer. \nThank you all!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":323,"Q_Id":27559330,"Users Score":1,"Answer":"Let's start from the beginning:\n\nYou are in your project folder eg \/home\/me\/myproject\nYou create a new virtualenv, eg virtualenv \/home\/me\/virtualenvs\/myprojectenv\nYou activate the new virtualenv:\nsource \/home\/me\/virtualenvs\/myprojectenv\/bin\/activate\n...this means that python and pip commands now point to the versions installed in your virtualenv\nYou install your project dependencies pip install django\nYou can .\/manage.py runserver successfully\n\nNow, the virtualenv has only been activated in your current terminal session. If you cd outside your project directory the virtualenv is still active. But if you open a new terminal window (or turn off the computer and come back later) the virtualenv is not activated.\nIf the virtualenv is not activated then the python and pip commands point to the system-installed copies (if they exist) and Django has not been installed there.\nAll you need to do when you open a new terminal is step 3. above:\nsource \/home\/me\/virtualenvs\/myprojectenv\/bin\/activate\nPossibly the tutorial you followed got you to install virtualenvwrapper which is an additional convenience layer around the virtualenv commands above. In that case the steps would look like this:\n\nYou are in your project folder eg \/home\/me\/myproject\nYou create a new virtualenv, eg mkvirtualenv myprojectenv\n...virtualenv has already been activated for you now!\nYou install your project dependencies pip install django\nYou can .\/manage.py runserver successfully\n\nand whenever you start a new shell session you need to:\nworkon myprojectenv\nin order to re-activate the virtualenv","Q_Score":0,"Tags":"python,django,terminal,komodoedit","A_Id":27559411,"CreationDate":"2014-12-19T03:32:00.000","Title":"Terminal\/django\/komodo edit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using amazon dynamodb and accessing it via the python boto query interface. I have a very simple requirement\n\nI want to get 1000 entries. But I don't know the primary keys beforehand. I just want to get 1000 entries. How can I do this? ...I know how to use the query_2 but that requires knowing primary keys beforehand.\nAnd maybe afterwards I want to get another different 1000 and go on like that. You can consider it as sampling without replacement.How can I do this?\n\nAny help is much appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1903,"Q_Id":27584321,"Users Score":2,"Answer":"Use Table.scan(max_page_size=1000)","Q_Score":2,"Tags":"python,amazon-dynamodb,boto,sample","A_Id":27599549,"CreationDate":"2014-12-20T21:05:00.000","Title":"python dynamodb get 1000 entries","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a small program in Python that involves tkinter, and I made it a pyw file because it has a shortcut on the desktop and I do not want the command prompt to get in the way. I used py2exe following the sentdex tutorial on youtube, and I got an output file, but the output file shows an error and exits before I can read it. The pyw file on its own works fine, but I don't know how to get the exe output file to work correctly.\nInformation:\nPython - 3.4.2;\nOS - Windows 8.1;\nFolder - Multiple items (photos and audio for the program);\nProgram - A simple animation in tkinter\nIf you need the program, tell me and I can upload the folder containing the program.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":27586108,"Users Score":0,"Answer":"As far as I understand there is not a version of py2exe for python3.x\nYou'd be best of going for cx_freeze (Sentdex also has a tutorial on that on that)","Q_Score":0,"Tags":"python-3.x,tkinter,exe,py2exe","A_Id":29677578,"CreationDate":"2014-12-21T02:02:00.000","Title":"Python py2exe with tkinter (pyw file)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I read an image (of unknown format, most frequent are PNGs or JPGs) from a buffer.\nI can decode it with cv2.imdecode, I can even check if it is valid (imdecode returns non-None).\nBut how can I reveal the image type (PNG, JPG, something else) of the buffer I've just read?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2355,"Q_Id":27608053,"Users Score":1,"Answer":"There is a standard Python functionimghdr.what. It rulez!\n^__^","Q_Score":1,"Tags":"python,opencv,image-processing","A_Id":27689079,"CreationDate":"2014-12-22T18:02:00.000","Title":"OpenCV: how to get image format if reading from buffer?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a simple python server that a client can connect to without the client having to know the exact portnumber. Is that even possible? The thought is to choose a random portnumber and using it for clients to connect. \nI know you could use bind(host, 0) to get a random port number and socket.getsockname()[1] within the server to get my portnumber. But how could my client get the portnumber?\nI have tried socket.getnameinfo() but I don't think I understand how that method really works.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":689,"Q_Id":27628753,"Users Score":1,"Answer":"In order to do that the server must listen on a certain port(s).\nThis means the client(s) will need to interact on these ports with it.\nSo... no it is impossible to do that on some random unknown port.","Q_Score":1,"Tags":"python,network-programming,client-server,port,server","A_Id":27628809,"CreationDate":"2014-12-23T22:10:00.000","Title":"How to give a python client a port number from a python server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a simple python server that a client can connect to without the client having to know the exact portnumber. Is that even possible? The thought is to choose a random portnumber and using it for clients to connect. \nI know you could use bind(host, 0) to get a random port number and socket.getsockname()[1] within the server to get my portnumber. But how could my client get the portnumber?\nI have tried socket.getnameinfo() but I don't think I understand how that method really works.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":689,"Q_Id":27628753,"Users Score":0,"Answer":"Take a look at Zeroconf, it seems to be the path to where you are trying to get to.","Q_Score":1,"Tags":"python,network-programming,client-server,port,server","A_Id":27630673,"CreationDate":"2014-12-23T22:10:00.000","Title":"How to give a python client a port number from a python server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a simple python server that a client can connect to without the client having to know the exact portnumber. Is that even possible? The thought is to choose a random portnumber and using it for clients to connect. \nI know you could use bind(host, 0) to get a random port number and socket.getsockname()[1] within the server to get my portnumber. But how could my client get the portnumber?\nI have tried socket.getnameinfo() but I don't think I understand how that method really works.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":689,"Q_Id":27628753,"Users Score":0,"Answer":"You need to advertise the port number somehow. Although DNS doesn't do that (well, you could probably cook up some resource record on the server object, but that's not really done) there are many network services that do. LDAP like active directory (you need write rights), DNS-SD dns service discovery, universal plug and play, service location protocol, all come to mind. You could even record the port number on some web page somewhere and have the client read it.","Q_Score":1,"Tags":"python,network-programming,client-server,port,server","A_Id":27628855,"CreationDate":"2014-12-23T22:10:00.000","Title":"How to give a python client a port number from a python server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm doing a Monte Carlo simulation in Python in which I obtain a set of intensities at certain 2D coordinates and then fit a 2D Gaussian to them. I'm using the scipy.optimize.leastsq function and it all seems to work well except for the following error:\nIntel MKL ERROR: Parameter 6 was incorrect on entry to DGELSD. \nThe problem occurs multiple times in a simulation. I have looked around and understand it is something to do with a bug in Intel's MKL library. I can't seem to find a solution to the problem and so I was looking at an alternative fitting function In could use. If someone does know how to get rid of the problem that would be good also.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":860,"Q_Id":27629227,"Users Score":-1,"Answer":"You could try Intel's python distribution. It includes a pre-built scipy optimized with MKL.","Q_Score":6,"Tags":"python,scipy,least-squares,intel-mkl","A_Id":45621086,"CreationDate":"2014-12-23T22:57:00.000","Title":"Intel MKL Error with Gaussian Fitting in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've accumulated a set of 500 or so files, each of which has an array and header that stores metadata.  Something like:\n\n2,.25,.9,26  #<-- header, which is actually cryptic metadata\n1.7331,0\n1.7163,0\n1.7042,0\n1.6951,0\n1.6881,0\n1.6825,0\n1.678,0\n1.6743,0\n1.6713,0\n\nI'd like to read these arrays into memory selectively.  We've built a GUI that lets users select one or multiple files from disk, then each are read in to the program.  If users want to read in all 500 files, the program is slow opening and closing each file.  Therefore, my question is: will it speed up my program to store all of these in a single structure?  Something like hdf5?  Ideally, this would have faster access than the individual files.  What is the best way to go about this?  I haven't ever dealt with these types of considerations.  What's the best way to speed up this bottleneck in Python?  The total data is only a few MegaBytes, I'd even be amenable to storing it in the program somewhere, not just on disk (but don't know how to do this)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":27641616,"Users Score":1,"Answer":"Reading 500 files in python should not take much time, as the overall file size is around few MB. Your data-structure is plain and simple in your file chunks, it ll not even take much time to parse I guess. \nIs the actual slowness is bcoz of opening and closing file, then there may be OS related issue (it may have very poor I\/O.)\nDid you timed it like how much time it is taking to read all the files.?\nYou can also try using small database structures like sqllite. Where you can store your file data and access the required data in a fly.","Q_Score":0,"Tags":"python,database,numpy,dataset,storage","A_Id":27641772,"CreationDate":"2014-12-24T19:51:00.000","Title":"Better way to store a set of files with arrays?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have an api with publishers + subscribers and I want to stop a publisher from uploading a lot of data if there are no subscribers. In an effort to avoid another RTT I want to parse the HTTP header, see if there are any subscribers and if not return an HTTP error before the publisher finishes sending all of the data. \nIs this possible? If so, how do I achieve it. I do not have post-buffering enabled in uwsgi and the data is being uploaded with a transfer encoding of chunked. Therefore, since uWSGi is giving me a content-length header, it must have buffered the whole thing somewhere previously. How do I get it to stop?\nP.S. uWSGi is being sent the data via nginx. Is there some configuration that I need to set there too perhaps?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":27645172,"Users Score":0,"Answer":"The limit here is nginx. It cannot avoid (unless when in websockets mode) buffering the input. You may have more luck with apache or the uWSGI http router (albeit i suppose they are not a viable choice)","Q_Score":0,"Tags":"python,nginx,uwsgi","A_Id":27646090,"CreationDate":"2014-12-25T07:32:00.000","Title":"Can uWSGI return a response before the POST data is uploaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to use python to scrape a website implemented with infinite scroll. Actually, the web is pinterest. I know how to use selenium webdriver to scrape a web with infinite scroll. However, the webdriver basically imitates the process of visiting the web and is slow, much slower than using BeautifulSoup and urllib for scraping. Do you know any time efficient ways to scrape a web with infinite scroll? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3050,"Q_Id":27682975,"Users Score":3,"Answer":"The infinite scroll is probably using an Ajax query to retrieve more data as you scroll. Use your browser's dev tools to inspect the request structure and try to hit the same endpoint directly. In this way you can get the data you need, often in json or xml format. \nIn chrome open the dev tools (Ctrl + shift + I  in windows) and switch to the network tab. Then begin to scroll, when more content is loaded you should see new network activity. Specifically a Ajax request, you can filter by \"xhr\". Click on the new network item and you will get detailed info on the request such as headers, the request body, the structure of the response, and the url (endpoint) the request is hitting. Scraping this url is the same as scraping a website except there will be no html to parse through just formatted data.\nSome websites will try to block this type of behavior. If that happens I suggest using phantomjs without selenium. It can be very fast (in comparison to selenium) for mimicking human interaction on websites.","Q_Score":0,"Tags":"python,web-scraping","A_Id":27683149,"CreationDate":"2014-12-29T03:17:00.000","Title":"Is there any fast ways to scrape a website with infinite scroll?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to activate this virtual environment:\n(G:\/virt_env\/virt1)\nI'm just following a virtualenv tutorial, I have created a virtual environment(look above), the next step Is activating It, but that tutorial was written for Unix, So how do I activate this virtual environment using Powershell 2? This is assuming basic knowledge of Powershell\nEdit: Question answered","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":522,"Q_Id":27690388,"Users Score":0,"Answer":"According to Lukas Graf:\nReplace source with . (a single dot) and the relative path after it with a full, absolute path","Q_Score":1,"Tags":"python,powershell","A_Id":27753819,"CreationDate":"2014-12-29T14:06:00.000","Title":"How do I activate a virtual environment in Powershell 2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an image and want to find the sum of a part of it and then compared to a threshold.\nI have a rectangle drawn on the image and this is the area I need to apply the sum.\nI know the cv2.integral function,  but this gives me a matrix as a result. Do you have any suggestion?","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":17785,"Q_Id":27714535,"Users Score":3,"Answer":"sumElems function in OpenCV will help you to find out the sum of the pixels of the whole of the image in python. If you want to find only the sum of a particular portion of an image, you will have to select the ROI of the image on the sum is to be calculated.\nAs a side note, if you had found out the integral image, the very last pixel represents the sum of all the pixels of the image.","Q_Score":2,"Tags":"python,opencv,pixel,integral","A_Id":27717883,"CreationDate":"2014-12-31T00:22:00.000","Title":"how to do the sum of pixels with Python and OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an image and want to find the sum of a part of it and then compared to a threshold.\nI have a rectangle drawn on the image and this is the area I need to apply the sum.\nI know the cv2.integral function,  but this gives me a matrix as a result. Do you have any suggestion?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":17785,"Q_Id":27714535,"Users Score":5,"Answer":"np.sum(img[y1:y2, x1:x2, c1:c2]) Where c1 and c2 are the channels.","Q_Score":2,"Tags":"python,opencv,pixel,integral","A_Id":27738842,"CreationDate":"2014-12-31T00:22:00.000","Title":"how to do the sum of pixels with Python and OpenCV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how to compare a string to a list. \nFor example \nI have string 'abcdab' and a list ['ab','bcd','da']. Is there any way to compare all possible list combinations to the string, and avoid overlaping elements. so that output will be a list of tuples like\n[('ab','da'),('bcd'),('bcd','ab'),('ab','ab'),('ab'),('da')].\nThe output should avoid combinations such as ('bcd', 'da') as the character 'd' is repeated in tuple while it appears only once in the string.\nAs pointed out in the answer. The characters in string and list elements, must not be rearranged.\nOne way I tried was to split string elements in to all possible combinations and compare. Which was 2^(n-1) n being number of characters. It was very time consuming. \nI am new to python programing.\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":567,"Q_Id":27716752,"Users Score":1,"Answer":"all possible list combinations to string, and avoiding overlaping\n  elements\n\nIs a combination one or more complete items in its exact, current order in the list that match a pattern or subpattern of the string?  I believe one of the requirements is to not rearrange the items in the list (ab doesn't get substituted for ba).  I believe one of the requirements is to not rearrange the characters in the string.  If the subpattern appears twice, then you want the combinations to reflect two individual copies of the subpattern by themselves as well as a list of with both items of the subpattern with other subpatterns that match too.  You want multiple permutations of the matches.","Q_Score":0,"Tags":"python,string,list,comparison,overlapping","A_Id":27716829,"CreationDate":"2014-12-31T05:50:00.000","Title":"Python: comparing list to a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a python program that can communicate with another python program running on another machine. They should communicate via network. For me, it's super simple using BasicHTTPServer. I just have to direct my message to http:\/\/ server2 : port \/my\/message and server2 can do whatever action needed based on that message \"\/my\/message\". It is also very time-efficient as I do not have to check a file every X seconds or something similar. (My other idea was to put text files via ssh to the remote server and then read that file..)\nThe downside is, that this is not password protected and not encrypted. I would like to have both, but still keep it that simple to transfer messages.\nThe machines that are communicating know each other and I can put key files on all those machines.\nI also stumbled upon twisted, but it looks rather complicated. Also gevent looks way too complicated with gevent.ssl.SSLsocket, because I have to check for byte length of messages and stuff..\nIs there a simple example on how to set something like this up?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":595,"Q_Id":27719695,"Users Score":0,"Answer":"if you have no problem rolling out a key file to all nodes ...\nsimply throw your messages into AES, and move the output like you moved the unencrypted messages ...\non the other side ... decrypt, and handle the plaintext like the messages you handled before ...","Q_Score":0,"Tags":"python,encryption,https","A_Id":27719872,"CreationDate":"2014-12-31T10:20:00.000","Title":"Python network communication with encryption and password protection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am testing a web application on both shared host and Apache localhost,  using Django and fastcgi. When I edited my code and refreshing the page, many times the new code does not take effect. I think this is a cache issue, but I don't know how from the application.\nFor example: adding new url pattern to mysite\/urls.py it does not take effect till I restart the Apache server on the localhost or waiting some time on the shared host.\nI did not find any entries in mysite\/settings.py that may allow any solution for that issue. I use Django 1.7 and Python 3.4.2.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":27724624,"Users Score":2,"Answer":"Thats the nature of using it in that format\/setup.  On development, running as 'manage.py runserver' it auto reloads on file changes.\nproduction\/proxy setups like you have, you need to reload\/restart the service to have changes take effect.","Q_Score":0,"Tags":"python,django,apache","A_Id":27725014,"CreationDate":"2014-12-31T17:57:00.000","Title":"How to cancel Django cache in fastcgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python client program (which will be available to a limited number of users) that fetches data from a remote MySQL-DB using the pymysql-Module.\nThe problem is that the login data for the DB is visible for everyone who takes a look at the code, so everyone could manipulate or delete data in the DB. Even if I would store the login data in an encrypted file, some still could edit the code and insert their own MySql queries (and again manipulate or delete data).\nSo how can I access the DB from my program and still SELECT, DELETE or UPDATE data in it, but make sure that no one can execute his own (evil) SQL Code (except the ones that are triggered by using the GUI)?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":934,"Q_Id":27743031,"Users Score":0,"Answer":"This happens to be one of the reasons desktop client-server architecture gave way to web architecture. Once a desktop user has access to a dbms, they don't have to use just the SQL in your application. They can do whatever their privileges allow.\nIn those bad old days, client-server apps only could change rows in the DBMS via stored procedures. They didn't have direct privileges to INSERT, UPDATE, or DELETE rows. The users of those apps had accounts that were GRANTed a limited set of privileges; they could SELECT rows and run procedures, and that was it. They certainly did not have any create \/ drop \/ table privilege.\n(This is why a typical DBMS has such granular privilege control.)\nYou should restrict the privileges of the account or accounts employed by the users of your desktop app. (The same is, of course, true for web app access accounts.) Ideally, each user should have her own account. It should only grant access to the particular database your application needs.\nThen, if you don't trust your users to avoid trashing your data, you can write, and test, and deploy, stored procedures to do every insert, update, or delete needed by your app. \nThis is a notoriously slow and bureaucratic way to get IT done; you may want to make good backups and trust your users, or switch to a web app.\nIf you do trust them tolerably well, then restrict them to the particular database employed by your app.","Q_Score":1,"Tags":"python,mysql,pymysql","A_Id":27743210,"CreationDate":"2015-01-02T13:31:00.000","Title":"Secure MySQL login data in a Python client program","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"-I'm using python and cocos2D\nI have the file loading a tmx-map but now I want to change a specific tile to display an image from another file, I have saved the specific tile that I want to change in a variable but changing it I don't know how.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":266,"Q_Id":27761448,"Users Score":1,"Answer":"All I had to do was\ncell.tile.image = image","Q_Score":0,"Tags":"python,tile,tmx,tiled,cocos2d-python","A_Id":27761506,"CreationDate":"2015-01-04T01:27:00.000","Title":"python cocos2d change tile's image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im trying to design a system that can periodic \"download\" a large amount of data from an outside api..\nThis user could have around 600,000 records of data that I need once, then to check back every hour or so to reconcile both datasets.\nIm thinking about doing this in python or ruby in background tasks eventually but I'm curious about how to store the data.\nWould it possible\/good idea to store everything in one record hashed as json vs copying each record individually?\nIt would be nice to be able to index or search the data without anything failing so I was wondering what would be the best implementation memory wise.\nFor example if the a user has 500,000 tweet records and I want to store all of them, which would be a better implementation?  \none record as JSON =>   user_1 = {id:1 twt:\"blah\"},{id:2 twt:\"blah\"},.....{id:600,000 twt:\"blah\"}\nvs \nmany records =>\nid:1 outside_id=1 twt:\"blah\"\nid:2 outside_id=1  twt:\"blah\"\nid:3 outside_id=1 twt:\"blah\"\nI'm curious how I would find out how memory intensive each method is or what is the best solution.\nThe records are alot more complex with maybe 40 attributes per record I wanted to store.\nAlso would MySQL or MongoDB be a better solution for fastest copy\/storage?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":149,"Q_Id":27761684,"Users Score":0,"Answer":"I think this all boils down to what the most important needs are for the project. These are some of the questions I would try to answer before selecting the technology:\n\nWill I need to access records individually after inserting into the database?\nWill I ever need to aggregate the data when reading it (for reporting, for instance)?\nIs it more important to the project goals to have the data written quickly or read quickly?\nHow large do I anticipate the data will grow and will the database technology I select scale easily, cheaply and reliably to support the data volume?\nWill the schema of the data change? Do I need a schemaless database solution like MongoDB?\nWhere are the trade offs between development time\/cost, maintenance time\/cost and time\/cost for running the program?\n\nWithout knowing much about the particulars or your project or its goals I would say it's generally not a good idea to store a single JSON object for the entirety of the data. This would likely make it more difficult to read the data and append to it in the future. You should probably apply some more thought on how to model your data and represent it in the database in a way that will make sense when you actually need to use it later.","Q_Score":0,"Tags":"python,mysql,ruby,json,mongodb","A_Id":27761882,"CreationDate":"2015-01-04T02:11:00.000","Title":"Best Way to Store Large Amount of Outside API Data... using Ruby or Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm working on a script to create epub from html files, but when I check my epub I have the following error : Mimetype entry missing or not the first in archive\nThe Mimetype is present, but it's not the first file in the epub. Any idea how to put it in first place in any case using Python ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1098,"Q_Id":27799692,"Users Score":0,"Answer":"The solution I've found:\n\ndelete the previous mimetype file\nwhen creating the new archive create an new mimetype file before adding anything else : zipFile.writestr(\"mimetype\", \"application\/epub+zip\")\n\nWhy does it work : the mimetype is the same for all epub : \"application\/epub+zip\", no need to use the original file.","Q_Score":0,"Tags":"python,zip,epub,epub3","A_Id":28436076,"CreationDate":"2015-01-06T13:28:00.000","Title":"epub3 : how to add the mimetype at first in archive","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am a beginner so I don't think I need to use anything complicated.\nBasically I have to print y=x^+3 for the rangex=0 to x=4 using formatted output and I don't know how.\nFrom what I have learned so far, I'm supposed to use formatted output, looping and variable width output to do this.\nDoes anyone know how to do it? Thank you very much.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":102,"Q_Id":27810571,"Users Score":1,"Answer":"Check out the module matplotlib, it was made to give plotting visuals in python. I hope this helps a little.","Q_Score":0,"Tags":"python,loops","A_Id":27810605,"CreationDate":"2015-01-07T02:30:00.000","Title":"How to formatted output a graph of an equation using python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"community!\nMy problem:\nI have an item, namely gi.repository.Gtk, marked as \"Unresolved reference: Gtk\".\nThe Gtk module did not exist at the moment of setting up Python SDK in Idea, however I've installed it little bit later.\nI can't get how do I force re-sync of classpath for python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":27813209,"Users Score":0,"Answer":"Normally the binary modules for a Python interpreter are rescanned on IntelliJ IDEA restart. Please try restarting the IDE.","Q_Score":0,"Tags":"python,intellij-idea","A_Id":27828457,"CreationDate":"2015-01-07T05:52:00.000","Title":"intellij: update classes in classpath for python plug-in","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Id like to have my secret keys loaded via environment vars that shall be check on startup of my Django app. Im using an AppConfig for that purpose, because that code will be executed on startup.\nFor now i wrote a little helper to get the vars and a list of vars to check. Which is working fine. \nThe problem:\nI also wrote a Django management command to help entering and storing the needed vars and save em to the users .profile, BUT when i have my checks in place the AppConfig will raise errors before i even have the chance to run my configuration command :(\nSo how do i enable that configuration management command whilst still having that env check run on startup?\nFor now im going to do a plain python script to not load Django at all (which i dont need for now anyways), but in case i might need to alter the database (and thus need Django for some setup task) how would i be able to sneak past my own startup check in my AppConf?\nWhere else might i be placing the checks?\nI tried the main urls.py, but this will only be loaded once the first url lookup is needs and thus one might start the server and not see any errors and still the app will not work once the first url is entered in the browser.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":170,"Q_Id":27834570,"Users Score":0,"Answer":"well, it turned out that the AppConfig is not the right spot for a task like that .. i realized my loading of secrets with a modification of the projects manage.py and im planning to release an app with all of the code in the near furture :)","Q_Score":0,"Tags":"python,django,environment-variables","A_Id":28414823,"CreationDate":"2015-01-08T06:57:00.000","Title":"How To check for environment vars during django startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"While installing pip and python I have ran into a that says:\n\nThe directory '\/Users\/Parthenon\/Library\/Logs\/pi' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.\n\nbecause I now have to install using sudo.\nI had python and a handful of libraries already installed on my Mac, I'm running Yosemite. I recently had to do a clean wipe and then reinstall of the OS. Now I'm getting this prompt and I'm having trouble figuring out how to change it\nBefore my command line was Parthenon$ now it's Philips-MBP:~ Parthenon$\nI am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":189575,"Q_Id":27870003,"Users Score":0,"Answer":"If you altered your $PATH variable that could also cause the problem. If you think that might be the issue, check your ~\/.bash_profile or ~\/.bashrc","Q_Score":156,"Tags":"python,pip,sudo,osx-yosemite","A_Id":57711516,"CreationDate":"2015-01-09T22:05:00.000","Title":"pip install: Please check the permissions and owner of that directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"While installing pip and python I have ran into a that says:\n\nThe directory '\/Users\/Parthenon\/Library\/Logs\/pi' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.\n\nbecause I now have to install using sudo.\nI had python and a handful of libraries already installed on my Mac, I'm running Yosemite. I recently had to do a clean wipe and then reinstall of the OS. Now I'm getting this prompt and I'm having trouble figuring out how to change it\nBefore my command line was Parthenon$ now it's Philips-MBP:~ Parthenon$\nI am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":189575,"Q_Id":27870003,"Users Score":61,"Answer":"pip install --user <package name> (no sudo needed) worked for me for a very similar problem.","Q_Score":156,"Tags":"python,pip,sudo,osx-yosemite","A_Id":39810683,"CreationDate":"2015-01-09T22:05:00.000","Title":"pip install: Please check the permissions and owner of that directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"using autoenv and virtualenvwrapper in python and trying to configure in it the specific python version. \nthe autoenv file (called .env) contains (simply)\necho 'my_env'\nis there a way to configure it's python version?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":572,"Q_Id":27885666,"Users Score":1,"Answer":"When creating virtual environment, you can specify which python to use.\nFor example,\nvirtualenv -p\/usr\/bin\/python2.7 env\nSame for mkvirtualenv","Q_Score":0,"Tags":"python,virtualenv,virtualenvwrapper","A_Id":27885868,"CreationDate":"2015-01-11T09:36:00.000","Title":"how to setup virtualenv to use a different python version in each virtual env","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a python program that converts text to one long binary string. The usual line of test and sentences are easy enough to convert into binary but I'm having trouble with the whitespace.\nHow do I put in a binary byte to represent the enter key?  \nDo I just put in the '\/' and an 'n' strings?  \nI would ideally want to be able to convert an entire text file into a binary string and be able to convert it back again. Obviously, if I were to do this with a python script, the tabbing would get messed up and the program would be broken.  \nWould a C language be better for doing this stuff?  \nObviously a C program would still function without its whitespace whereas python would not.\nIn short, I need to know how to represent the 'tab' and 'enter' keys in binary, and how to create a function to translate them into binary. would bin(ord('\\n')) be good?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":310,"Q_Id":27912757,"Users Score":0,"Answer":"The tab is represented in the ASCII chart as 0x08 0x09, or \"00001000\" \"00001001\" in a binary string.  \nThe Enter key is different because it could represent CR (carriage return), LF (Linefeed), or both.  \nThe CR is represented as 0x0d, or \"00001101\" as binary string.\nThe LF is represented as 0x0A, or \"00001010\" as binary string.\nA common convention is '\\t' for tab and '\\r' for CR, '\\n' for newline.","Q_Score":0,"Tags":"python,c++,c,binary","A_Id":27912842,"CreationDate":"2015-01-12T23:49:00.000","Title":"text - binary conversion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using urllib in python 2.7 to retrieve webpages from the internet. After parsing the data and storing it on the database, i get the following symbols \u00e2\u20ac\u201c and \u00e2\u20ac and \u00e2\u20ac\u201d and so on. I wanted to know how these symbols are generated and how to get rid of it? Is it an encoding issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":27929197,"Users Score":0,"Answer":"Yes it is an encoding issue, make sure sure when you parse your data it doesn't encrypt it or turn it into byte encoded format. Those characters means your computer can't read the data that is being stored, so it isn't being stored in a data type that we can read.","Q_Score":0,"Tags":"python,mysql,encoding,urllib","A_Id":27931174,"CreationDate":"2015-01-13T18:42:00.000","Title":"MySQL - Strange symbols while using urllib in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using PyCharm for a bit so I am not an expert. \nHow I normally ran my programs was with the terminal like so:\nprogram.py -t input1 -t1 input2\nI was wondering how can I debug this? \nFor other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":43698,"Q_Id":27952331,"Users Score":92,"Answer":"Menu: Run -> Edit configurations -> \"+\" (add new config) -> Python.\nScript name: program.py\nIf you need to debug a script from installed packages, such as tox, you can specify the full path too. For example:\nScript name: \/home\/your_user\/.envs\/env_name\/bin\/tox\nAbove \/home\/your_user\/.envs\/env_name is a path to virtual environment containing tox package.\nScript params: -t input1 -t1 input2","Q_Score":63,"Tags":"python,pycharm","A_Id":27952376,"CreationDate":"2015-01-14T20:59:00.000","Title":"Debugging with PyCharm terminal arguments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using PyCharm for a bit so I am not an expert. \nHow I normally ran my programs was with the terminal like so:\nprogram.py -t input1 -t1 input2\nI was wondering how can I debug this? \nFor other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":43698,"Q_Id":27952331,"Users Score":1,"Answer":"It was almost correct but just needed little correction with full script path.\nMenu: Run->Edit configurations->\"+\" (add new config)->Python.\nScript name: path + \/program.py\nScript params: -t input1 -t1 input2","Q_Score":63,"Tags":"python,pycharm","A_Id":51116540,"CreationDate":"2015-01-14T20:59:00.000","Title":"Debugging with PyCharm terminal arguments","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Good evening all,\nam running a python script inside java using processBuilder.\nthe python script returns a list and i dont know how to get it java and use it since all i can do for the moment with process builder is print errors or outputs.\nis it possible to get the list in java as well.\nMany thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":266,"Q_Id":27955622,"Users Score":0,"Answer":"From your scenario, you are looking for inter process communication.\nYou can achieve this using shared file. Your python script will write the output in text file, and your java program will read the same file.","Q_Score":1,"Tags":"java,python,processbuilder,inter-process-communicat","A_Id":27969431,"CreationDate":"2015-01-15T01:51:00.000","Title":"Java\/python using processBuilder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I have a billing agreement, which I just executed on the callback from the PayPal site:\n\nresource = BillingAgreement.execute(token)\n\nThe resource returned does not have any payer information (name, email, etc).  I can use the ID to load the full BillingAgreement:\n\nbilling_agreement = BillingAgreement.find(resource.id)\n\nThat returns successfully, but the resulting object also lacks an payer info.\nThis seems like a critical oversight in the REST API's design.  If I just got a user to sign up for a subscription, don't I need to know who they are?  How else will I send them a confirmation email, allow them to cancel later, etc?\nThanks for the help!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":555,"Q_Id":27972459,"Users Score":2,"Answer":"Got a reply from PayPal support.  Apparently you can take the same token you pass to BillingAgreement.execute() and pass it to GetExpressCheckoutDetails in their classic API.  I tried it and it works.  It means you have to use both APIs (which we weren't planning to do) and store both API auth info, which is annoying.  Hopefully they'll fix it someday, but if it's been high-priority for two months I'm not holding my breath.","Q_Score":1,"Tags":"python,rest,paypal","A_Id":27989541,"CreationDate":"2015-01-15T20:32:00.000","Title":"In the PayPal REST API, how can I get payer information from a newly executed BillingAgreement?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to use pyenv with another user?\nFor example, If I have installed pyenv in user test's environment, I could use pyenv when i login as test.   \nHowever, how could i use pyenv when I login as another user, such as root?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":3900,"Q_Id":27978383,"Users Score":5,"Answer":"Even if you did this, I'd strongly discourage it.  Root can access pretty much everyone's home directory, but the nuances of adding programs to the PATH that the root user doesn't technically own can be detrimental at best - might lead to a few root services not working properly, and actively insecure at worst.\nThere's literally nothing wrong with installing your own copy of pyenv as another user.  There's no pain involved and there's not much sense to do it any other way.","Q_Score":7,"Tags":"python","A_Id":27978545,"CreationDate":"2015-01-16T06:25:00.000","Title":"How to use pyenv with another user?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"please how can I randomly select 3 numbers whose sum is 356 and each of these 3 is more than 30?\nSo output should be for example [100, 34, 222]\n(but not [1,5,350])\nI would like to use random module to do this. thank you!","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":131,"Q_Id":28009390,"Users Score":6,"Answer":"This question is rather subjective to the definition of random, and the distribution you wish to replicate.\nThe simplest solution:\n\nChoose a one random number, rand1 : [30,296]\nChoose a second random number, rand2 : [30, (326-Rand1)]\nThen the third cannot be random due to the constraint so calc via 356-(rand1+rand2)","Q_Score":0,"Tags":"python,python-2.7","A_Id":28009442,"CreationDate":"2015-01-18T11:56:00.000","Title":"randomly select 3 numbers whose sum is 356 and each of these 3 is more than 30","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In python heapq if you are putting in objects, how can u use a lambda to specify its key? Like heapq.heappush(Q, v, key=lambda x: f(x)).\nThanks","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5551,"Q_Id":28017037,"Users Score":6,"Answer":"You can't. Or rather, you can't specify it as a lambda. You can however make a heap of tuples, heapq.heappush(Q, (key(v), v)) and heapq.heappop(Q)[1].","Q_Score":2,"Tags":"python,heap","A_Id":28017065,"CreationDate":"2015-01-19T02:11:00.000","Title":"How to use lambdas in python heapq?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to train a linear model on a very large dataset. \nThe feature space is small but there are too many samples to hold in memory. \nI'm calculating the Gram matrix on-the-fly and trying to pass it as an argument to sklearn Lasso (or other algorithms) but, when I call fit, it needs the actual X and y matrices. \nAny idea how to use the 'precompute' feature without storing the original matrices?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1183,"Q_Id":28024191,"Users Score":0,"Answer":"(My answer is based on the usage of svm.SVC, Lasso may be different.)\nI think that you are supposed pass the Gram matrix instead of X to the fit method.\nAlso, the Gram matrix has shape (n_samples, n_samples) so it should also be too large for memory in your case, right?","Q_Score":4,"Tags":"python,machine-learning,scikit-learn","A_Id":28024414,"CreationDate":"2015-01-19T12:00:00.000","Title":"Using precomputed Gram matrix in sklearn linear models (Lasso, Lars, etc)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im using the Django template login and want to navigate from the login to my own written index.html file.\nso if a user push the \"login\" button the result page is my index file. \nMy second question is how to use logos in django python and what structure i need in my project. \nbest regards","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":28024651,"Users Score":0,"Answer":"1: create your own view that the login button take the person to when clicked and load your index.html template.  you do not have to use the built in login.\n2: logo? you can use any logo\/format you want. Django doesn't come with a template that creates the look of the site (beside the admin one); so you need to create it.","Q_Score":0,"Tags":"python,django,login,navigation","A_Id":28024750,"CreationDate":"2015-01-19T12:26:00.000","Title":"Django Navigation from Template-Login to a self written index.html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im using the Django template login and want to navigate from the login to my own written index.html file.\nso if a user push the \"login\" button the result page is my index file. \nMy second question is how to use logos in django python and what structure i need in my project. \nbest regards","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":28024651,"Users Score":0,"Answer":"create custom log-in and registration in your project, and write the custom back-end if you have more user ,if request is came from user to log-in then redirect to index,html,","Q_Score":0,"Tags":"python,django,login,navigation","A_Id":28028387,"CreationDate":"2015-01-19T12:26:00.000","Title":"Django Navigation from Template-Login to a self written index.html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to learn how socket module works and I have a dumb question:\nWhere is socket.send()'s sent data stored before being cleared by socket.recv()?. \nI believe there must be a buffer somewhere in the middle awaiting for socket.recv() calls to pull this data out.\nI just made a test with a server which sent a lot of data at once, and then connected to a client that (intentionally) pulled data very slowly. The final result was that data was sent within a fraction of a second and, on the other side, it was entirely received in small chunks of 10 bytes .recv(10), which took 20 seconds long .\nWhere has this data been stored meanwhile??, what is the default size of this buffer?, how can it be accessed and modified? \nthanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":184,"Q_Id":28057552,"Users Score":0,"Answer":"Learn about OSI layers, and different connections such as TCP and UDP. socket.send implements a TCP transmission of data. If you look into the OSI layers, you will find out that the 4th layer (i.e. transport layer) will buffer the data to be transmitted. The default size of the buffer depends on the implementation.","Q_Score":0,"Tags":"python,sockets,buffer,recv","A_Id":28057641,"CreationDate":"2015-01-21T00:14:00.000","Title":"Trying to understand buffering in Python socket module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to learn how socket module works and I have a dumb question:\nWhere is socket.send()'s sent data stored before being cleared by socket.recv()?. \nI believe there must be a buffer somewhere in the middle awaiting for socket.recv() calls to pull this data out.\nI just made a test with a server which sent a lot of data at once, and then connected to a client that (intentionally) pulled data very slowly. The final result was that data was sent within a fraction of a second and, on the other side, it was entirely received in small chunks of 10 bytes .recv(10), which took 20 seconds long .\nWhere has this data been stored meanwhile??, what is the default size of this buffer?, how can it be accessed and modified? \nthanks.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":184,"Q_Id":28057552,"Users Score":0,"Answer":"The OS (kernel) buffers the data.\nOn Linux the buffer size parameters may be accessed through the \/proc interface. See man 7 socket for more details (towards the end.)","Q_Score":0,"Tags":"python,sockets,buffer,recv","A_Id":28057652,"CreationDate":"2015-01-21T00:14:00.000","Title":"Trying to understand buffering in Python socket module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am have just recently acquired a new Mac (Yosemite OSX 10.10) I am reconfiguring everything and I need to work with external configs and Python on some new projects. Which bring me to two additional question: \n\nhow to include an extra configuration with an external config file ? can I just include it to the httpd.conf of Apache from Ampps GUI? would I need to do additional settings in the Admin Panel ? \nhow do I set up the mod_wsgi in Ampps, is there a specific set of actions to trigger ? will I need some specific workflow to get it to  work with my external config (bunch of virtual hosts in which some application run on Python)\n\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":259,"Q_Id":28063378,"Users Score":1,"Answer":"As far as I can tell, AMPPS does not work on Yosemite at all (@ v2.8)","Q_Score":0,"Tags":"python,macos,apache,ampps","A_Id":28284966,"CreationDate":"2015-01-21T09:14:00.000","Title":"AMPPS Yosemite Python configuration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Odoo\/OpenERP 7, I have a nullable numeric column called balance\n\n'balance': fields.float(string='Balance',digits=(20,2))\n\nI am trying to use Python code to update None into the field\n\nself.write(cr, uid, [1], { 'balance':None })\n\nbut, rather frustratingly, Python treats None the same as 0 so I end up with 0 in the DB instead of the expected Null.\nAny pointers on how I can use the write command to store a null value?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4136,"Q_Id":28069439,"Users Score":7,"Answer":"You can't: the Odoo ORM does not support null numeric values.\nIf you really need to distinguish an \"empty\" value from a zero value, you need a workaround: either use a string field (simpler, but needs additional checks to allow only number and it's harder to perform calculations) or use a second boolean field to mark empty values.","Q_Score":8,"Tags":"python,mysql,openerp-7,odoo","A_Id":28069999,"CreationDate":"2015-01-21T14:19:00.000","Title":"Odoo - Write null to numeric column","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Some tuples in my database need to be erased after a given time. I need my django app to check if the rows have expired.\nWhile I can definitely write the function, how do I make Django run at everyday at a fixed time?\nI have heard about Task Queues like Celery. Are they too much powerful for this? Is their anything simpler? May be something build-in?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":140,"Q_Id":28076316,"Users Score":2,"Answer":"Use a simple cron job to trigger a custom Django management command.","Q_Score":0,"Tags":"python,django,scheduled-tasks,celery,django-celery","A_Id":28076369,"CreationDate":"2015-01-21T20:34:00.000","Title":"How do I make my django application perform a job at a fixed time everyday?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Some tuples in my database need to be erased after a given time. I need my django app to check if the rows have expired.\nWhile I can definitely write the function, how do I make Django run at everyday at a fixed time?\nI have heard about Task Queues like Celery. Are they too much powerful for this? Is their anything simpler? May be something build-in?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":140,"Q_Id":28076316,"Users Score":-1,"Answer":"Use a threading.Thread to schedule a continuous event loop. In your thread, use time.sleep to create a gap before the next occurrence of the event.","Q_Score":0,"Tags":"python,django,scheduled-tasks,celery,django-celery","A_Id":28076358,"CreationDate":"2015-01-21T20:34:00.000","Title":"How do I make my django application perform a job at a fixed time everyday?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have heard from several articles that Hadoop streaming with bash is significantly slower than a compiled code or python. Is this only true for sort commands and the like? My script needs to\n-copy file to node \n-on node execute a commercial program with file as argument\n-pass output back to folder\nMy intuition is telling me that this should be a similar speed to the compiled versions. Would it be?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":481,"Q_Id":28101995,"Users Score":2,"Answer":"The main idea why Hadoop Streaming is considered to be slow is that for both mapper and reducer you have to pass arguments via stdin, which means you have to serialize them as a text, and to get the output of both mapper and reducer you have to deserialize them from the text back to Java structures, which usually consumes much time.\nIf you have a third party compiled application that is capable of reading the input data from stdin and passing data to stdout you don't have much choice but to run it in Hadoop Streaming or in Spark pipe. But of course the native mapreduce application application would be faster as it would eliminate the need for data serialization\/deserialization on passing it to the application\nBut if your application just accepts the filename and reads the file by itself (from NFS, for instance), it would be the same speed as a native one, but of course you should consider that this type of use is not the case neither for Hadoop nor for Spark - these frameworks were developed to process the data with APIs they provide","Q_Score":0,"Tags":"python,bash,hadoop,mapreduce,apache-spark","A_Id":28112455,"CreationDate":"2015-01-23T02:12:00.000","Title":"Hadoop streaming with Bash - how slow?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So i'm using the request.session.set_expiry(NUMBER_OF_SECONDS) in order to check if the user of my webpage has been inactive for a number of seconds and clossing the session when it happens. The problem is that i want to call a function for doing some things jsut before the session expires and i don't know how can I do that.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":312,"Q_Id":28106854,"Users Score":2,"Answer":"You can't.\nThis question betrays a fundamental misunderstanding of how both sessions and web applications work. Web code is stateless; there is nothing \"running\" for any user in between the requests that user makes. If a user doesn't make any requests for longer than the session timeout, the only time the server code knows about it is the next time they actually do make a request: at which point the code will compare the last request time with the current time and either treat the session as valid or expired. If the user goes away and never comes back, there is simply no way the server will ever know.","Q_Score":0,"Tags":"python,django,function,session","A_Id":28107498,"CreationDate":"2015-01-23T09:36:00.000","Title":"Django: calling a function before session expires","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some doubts about how to do that, I hope anybody can point me in the correct direction.\nMy current situation is that I am working with the python package Python(x,y) 32 bits in a Windows machine with 64 bits. And, as many of you know, I am having some problems with the Memory error.\nSo that I am thinking about changing to 64-bits, let's say with Anaconda for example.\nMy concern is about what can happen with all the previous job done with python 2.7 with 32 bits. Will it work with Anaconda 64?.\nAnd, if finally I change to Anaconda 64, I really don't think I can still use QtDesigner anymore, if I am not wrong, it only works with python 32, right?.\nSorry If any question sound very basic, I really do not have any idea about that.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5321,"Q_Id":28108106,"Users Score":2,"Answer":"You'll need to reinstall everything for the 64-bit Python, but note that Anaconda and conda may already come with everything that you need.","Q_Score":2,"Tags":"python,64-bit,32-bit,anaconda,pythonxy","A_Id":28198803,"CreationDate":"2015-01-23T10:43:00.000","Title":"from python 32 bits to python 64 bits","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I am using an API that returns me articles in my language in determined categories. This API limits me in 100 calls for each interval of 60 minutes.\nI don't want to make 100 calls straight away and make my script wait until 60 minutes has passed.\nI could then shoot an API call every 36 seconds, but I also don't want the API calls to be shot evenly.\nWhat is a feasible way to make my script make 100 API calls at random intervals of time, as long as the 100 fits in 60 minutes?\nI thought of making a function that would generate 100 timestamps in this 60 minutes interval, and then at the right time of each timestamp, it would shoot an API call, but I think that'd be overkill, and I'm not sure how I could do that either.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":28124450,"Users Score":2,"Answer":"What you could do is choose a min\/max interval of how long you want to wait. Keep a note of how many requests have been made in the last 60 minutes and if you're still below the quota, download a document and wait for rand(min, max). This is not very fancy and doesn't distribute the wait times across the whole 60 minutes interval, but it's easy to implement.\nAnother way would be to randomly choose 100 numbers between 0 and 60*60. These are the seconds on which you make requests. Sort them and as you progress through the array, each time you wait for next - current seconds. (or even use the scheduler module to simplify it a bit)","Q_Score":0,"Tags":"python,python-2.7","A_Id":28124506,"CreationDate":"2015-01-24T10:20:00.000","Title":"How can I distribute 100 API calls randomly in a 60 minutes time interval?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a number guessing game and once you have guessed the number it will say well done but idle stays open, how do I get it to close?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":4071,"Q_Id":28127310,"Users Score":2,"Answer":"On windows, you can quit the interpreter with CTRL-z and on linux\/mac you can quit with CTRL-D.  If you type exit, it will tell you exactly what to do.\nIf you are not running interactively (i.e. by running python your_script.py) the code will just end when it's reached the bottom of the file.\nIf you actually do need to interact with the interpreter while you are running your code, you can use input (or raw_input, depending on the python version) for fetching information from simple prompts, or the code module for more complex interactions.","Q_Score":2,"Tags":"python,python-3.x","A_Id":28127456,"CreationDate":"2015-01-24T16:00:00.000","Title":"how do I get my program to close once finished in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have this little problem. When I try to install PyGame for Python 3.4 I download a .whl (wheel?) file and don't know how to use it. Some guys told me something about pip but don't know how to use\/install it.","AnswerCount":9,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":64844,"Q_Id":28127730,"Users Score":3,"Answer":"14 y\/o? Good for you! You can put the file into your python\/scripts folder and run pip install *file* (where *file* is your filename).","Q_Score":9,"Tags":"python,pygame,pip,python-3.4","A_Id":28127786,"CreationDate":"2015-01-24T16:40:00.000","Title":"How to install PyGame on Python 3.4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use bottle set\/get cookie mecanism to track my user_id (with 'secret' param when calling set\/get_cookie()\nDuring normal http(s) request everything is fine but when making a xhr request (same domain)user_id = request.get_cookie('user_id', secret='mysecret') returns None.\nWhen checking on client browser, cookie and key\/value are still available.\nHow to deal with it ?\n(I've always been told that xhr requests are http requests, so from same domain, cookies should be shared, no ? is problem arrising from Bottle 'secret' handling ?)","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":167,"Q_Id":28136063,"Users Score":1,"Answer":"I tried to set_cookies('test', 123, secret='mysecret') under AJAX request, it worked, but still couldn't find previous cookies.  \nThen I remarked that my previous cookies, called cook1 and cook2, written under 'normal' http request, if they had same domain, had different 'path' (under Chrome ressource explorer). They were set under path '\/XXX\/dev' and my AJAX request was just under path '\/XXX'\nSo I modified my AJAX request from \/XXX\/do_stuff to point to '\/XXX\/dev\/do_stuff', and then, surprise ! cook1 and cook2 could be read by my AJAX request.  \nNot sure if it's a Bottle bug or if such behaviour is designed on purpose (in this case, if someone can explain to me why...), but at least I have my solution.","Q_Score":1,"Tags":"ajax,python-3.x,cookies,xmlhttprequest,bottle","A_Id":28137747,"CreationDate":"2015-01-25T11:52:00.000","Title":"Bottle, how to get_cookie during AJAX request (same domain)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use vim with a couple of plugins as a python ide. Along with an open vim session, I run an ipython session in a split console. I've found their combination is a great productivity tool for programming data analysis scripts. \nWhat I'm missing is a way to show all current session history in a side panel, so that I could easily do some copy-pasting from there to the vim session to create a script. Something similar to 'tail -f' would do, if only I knew where ipython stores the current session history.\nI already know:\n\nipython has '%history' and 'hist' commands, BUT I'm looking for a way to display the history in a panel outside of the ipython session.\nhistory is stored in a sqlite file under .ipython\/(profile), BUT I don't know how to access that file.  \n\nI hope I've been clear about my question. \nThanks in advance for all your help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":851,"Q_Id":28139507,"Users Score":0,"Answer":"You can output your history with the commands\n\n%history -f filename\n\nhistory with lines and sessions\n\n%history -g -f filename","Q_Score":3,"Tags":"ipython","A_Id":34588036,"CreationDate":"2015-01-25T17:50:00.000","Title":"Where does ipython store the current session history?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed a django-secure into a virtualenv using pip.  The install was normal.  The module shows up in the virtualenv pip list and in virtualenvs\/dev\/lib\/python2.7\/site-packages.  I get the following error when running my code. \nImportError: No module named djangosecure\nThe folder is in there and there is an init. No install issues.  What am I doing wrong and how do I fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":28159111,"Users Score":0,"Answer":"Make sure your wsgi file points to the right virtualenv!","Q_Score":0,"Tags":"python,django","A_Id":28159200,"CreationDate":"2015-01-26T21:30:00.000","Title":"Virtualenv installed package not found","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am facing an issue while cloning a git repo.\nI am using function clone_from from GitPython library\n\nfrom git import Repo\nRepo.clone_from(\"git:\/\/github.com\/facebook\/buck.git\", \"D:\\sample\")\n\nI am getting error\n\nWindowsError: The system cannot find the file specified\n\nCan someone please tell me if this is how to clone a repo using the library?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1005,"Q_Id":28161508,"Users Score":0,"Answer":"You might not have git.ext in your PATH, but that can easily be tested by executing it yourself.\nIf you see an error, you can either add it to the PATH, or set the GIT_PYTHON_GIT_EXECUTABLEto the executable git-python should execute for git commandline services.","Q_Score":0,"Tags":"python,gitpython","A_Id":28179875,"CreationDate":"2015-01-27T00:53:00.000","Title":"GitPython - clone_from not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I know I can find multiple answers to this question but I have a problem with the result.\nI have a Windows PC with a script on it and a Linux PC that has to start the script using ssh.\nThe problem I am seeing is that for some reason it's using the Linux environment to run the script and not the Windows env. Is this expected and if yes how can I start a remote script (From Linux) and still use the Windows env?\nLinux: Python 2.7\nWindows: Python 3.4 \nMy example:\nI am running:ssh user@host \"WINDOWS_PYTHON_PATH Script.py arg1 arg2 arg3\" and it fails internally at a copy command  \nI can't run ssh user@host \"Script.py arg1 arg2 arg3\" because then it will fail to run the script because of the python version.\nThe way I run the command in Windows is using the same syntax \"Script.py arg1 arg2 arg3\" and it works.\nIt looks like it's using the Linux env to run the script. I would like to run the script on Windows no matter who triggers it. How can I achieve this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":865,"Q_Id":28162229,"Users Score":0,"Answer":"The solution to my problem is to use PATH=\/cygdrive\/c\/WINDOWS\/system32:\/bin cmd \/c in front of the script call, sth like: ssh user@host \"PATH=\/cygdrive\/c\/WINDOWS\/system32:\/bin cmd \/c script\" .This will run the script using in Windows env.\nIn my case the problem was that the script was run under cygwin env and I wanted to be run in a Windows env.","Q_Score":1,"Tags":"python,linux,bash,ssh","A_Id":28223316,"CreationDate":"2015-01-27T02:26:00.000","Title":"How to execute a remote script using ssh","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python threading to process multiple files and I want output of each of the files 0 through 100 being processed to be written in a file in orderly fashion \nCurrently I am saving output of all the thread as they get executed and hence the order is not maintained.\nHow can I achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":109,"Q_Id":28173716,"Users Score":0,"Answer":"How about you create a list of 101 elements, 0 through 100. Then store the output from processing file x into list element x. When all processing is complete, write the data in the list elements from 0 to 100 to the file.","Q_Score":0,"Tags":"python-multithreading","A_Id":28207425,"CreationDate":"2015-01-27T15:12:00.000","Title":"Python threading how get output of multiprocess in sequence","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an embedded system connected with an ethernet port to one of my 2 ethernet interfaces, but I have the problem that my python code for the socket connection does not know where to connect to the embedded.\nI mean, sometimes I get the connection and sometimes I just don't (and I have to change the cable to the other interface), because I don't know how the socket functionality is getting the right ethernet port in which it has to connect.\nis there anything I can do on my python code to know the correct ethernet port in which the embedded is connected? (in order to know every time I connect it without changing the cable to another interface)","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":172,"Q_Id":28174487,"Users Score":3,"Answer":"Unplug one and if it stops working - you found the right one.\nIf it does not stop working it is the other one.","Q_Score":1,"Tags":"python,sockets,ethernet","A_Id":28174528,"CreationDate":"2015-01-27T15:50:00.000","Title":"I have 2 ethernet interfaces on the same PC, how to know which interface is connected in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract mails from gmail using python. I noticed that I can get mails from \"[Gmail]\/All Mail\", \"[Gmail]\/Drafts\",\"[Gmail]\/Spam\" and so on. However, is there any method to retrieve mails that are labeled with \"Primary\", \"Social\", \"Promotions\" etc.? These tags are under the \"categories\" label, and I don't know how to access it.\nBy the way, I am using imaplib in python. Do I need to access the \"categories\" with some pop library?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":596,"Q_Id":28183527,"Users Score":0,"Answer":"Unfortunately the categories are not exposed to IMAP.  You can work around that by using filters in Gmail to apply normal user labels.  (Filter on, e.g., category:social.)","Q_Score":0,"Tags":"python,email,gmail","A_Id":28184142,"CreationDate":"2015-01-28T02:18:00.000","Title":"How to extract mail in \"categories\" label in gmail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract mails from gmail using python. I noticed that I can get mails from \"[Gmail]\/All Mail\", \"[Gmail]\/Drafts\",\"[Gmail]\/Spam\" and so on. However, is there any method to retrieve mails that are labeled with \"Primary\", \"Social\", \"Promotions\" etc.? These tags are under the \"categories\" label, and I don't know how to access it.\nBy the way, I am using imaplib in python. Do I need to access the \"categories\" with some pop library?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":596,"Q_Id":28183527,"Users Score":0,"Answer":"Yes, categories are not available in IMAP. However, rather than filters, I found that gmail api is more favorable for me to get mail by category.","Q_Score":0,"Tags":"python,email,gmail","A_Id":28218594,"CreationDate":"2015-01-28T02:18:00.000","Title":"How to extract mail in \"categories\" label in gmail?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a set of experimentally determined (x, y, z) points which correspond to a parabola. Unfortunately, the data is not aligned along any particular axis, and hence corresponds to a rotated parabola. \nI have the following general surface:\nAx^2 + By^2 + Cz^2 + Dxy + Gyz + Hzx + Ix + Jy + Kz + L = 0\nI need to produce a model that can represent the parabola accurately using (I'm assuming) least squares fitting. I cannot seem to figure out how this works. I have though of rotating the parabola until its central axis lines up with z-axis but I do not know what this axis is. Matlab's cftool only seems to fit equations of the form z = f(x, y) and I am not aware of anything in python that can solve this.\nI also tried solving for the parameters numerically. When I tried making this into a matrix equation and solving by least squares, the matrix turned out to be invertible and hence my parameters were just all zero. I also am stuck on this and any help would be appreciated. I don't really mind the method as I am familiar with matlab, python and linear algebra if need be. \nThanks","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1508,"Q_Id":28187233,"Users Score":2,"Answer":"Dont use any toolboxes, GUIs or special functions for this problem. Your problem is very common and the equation you provided may be solved in a very straight-forward manner. The solution to the linear least squares problem can be outlined as:\n\nThe basis of the vector space is x^2, y^2, z^2, xy, yz, zx, x, y, z, 1. Therefore your vector has 10 dimensions.\nYour problem may be expressed as Ap=b, where p = [A B C D E F G H I J K L]^T is the vector containing your parameters. The right hand side b should be all zeros, but will contain some residual due to model errors, uncertainty in the data or for numerical reasons. This residual has to be minimized.\nThe matrix A has a dimension of N by 10, where N denotes the number of known points on surface of the parabola.\n\nA = [x(1)^2 y(1)^2 ... y(1) z(1) 1\n...\nx(N)^2 y(N)^2 ... y(N) z(N) 1] \n\nSolve the overdetermined system of linear equations by computing p = A\\b.","Q_Score":0,"Tags":"python,matlab,curve-fitting,least-squares,surface","A_Id":28189659,"CreationDate":"2015-01-28T07:56:00.000","Title":"Rotated Paraboloid Surface Fitting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a set of experimentally determined (x, y, z) points which correspond to a parabola. Unfortunately, the data is not aligned along any particular axis, and hence corresponds to a rotated parabola. \nI have the following general surface:\nAx^2 + By^2 + Cz^2 + Dxy + Gyz + Hzx + Ix + Jy + Kz + L = 0\nI need to produce a model that can represent the parabola accurately using (I'm assuming) least squares fitting. I cannot seem to figure out how this works. I have though of rotating the parabola until its central axis lines up with z-axis but I do not know what this axis is. Matlab's cftool only seems to fit equations of the form z = f(x, y) and I am not aware of anything in python that can solve this.\nI also tried solving for the parameters numerically. When I tried making this into a matrix equation and solving by least squares, the matrix turned out to be invertible and hence my parameters were just all zero. I also am stuck on this and any help would be appreciated. I don't really mind the method as I am familiar with matlab, python and linear algebra if need be. \nThanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1508,"Q_Id":28187233,"Users Score":0,"Answer":"Do you have enough data points to fit all 10 parameters - you will need at least 10?\nI also suspect that 10 parameters are to many to describe a general paraboloid, meaning that some of the parameters are dependent. My fealing is that a translated and rotated paraboloid needs 7 parameters (although I'm not really sure)","Q_Score":0,"Tags":"python,matlab,curve-fitting,least-squares,surface","A_Id":28188683,"CreationDate":"2015-01-28T07:56:00.000","Title":"Rotated Paraboloid Surface Fitting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently writing a python script which needs to run a sed command to replace stuff from the svn:externals data.\nI tried to run sed on \"svn propedit svn:externals .\" but the outcome is not the one expected.\nDoes anyone know how to do this ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":153,"Q_Id":28215502,"Users Score":2,"Answer":"First of all, don't use sed. Use Python's string methods or the re module.\nSecond, I recommend to run svn propget ... first, to fetch the old value. Then, you manipulate it (within Python, no need to run sed). Finally, you run svn propset.\nAlternatively, you could run a second Python script as editor for svn propedit. Here, too, you don't need sed if you already have Python.","Q_Score":0,"Tags":"python,svn,externals","A_Id":28215771,"CreationDate":"2015-01-29T13:05:00.000","Title":"Run replace command on svn:externals (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For python applications that install with pip, how can you handle their C extension requirements automatically? \nFor example, the mysqlclient module requires development libs of MySQL installed on the system. When you initially install an application requiring that module it'll fail if the MySQL development libraries are not on the system. So the question is how do I solve this?\n\nIs there a way to solve this with setup.py already that I do not know about?\nIf not am I supposed to use a pure python module implementation?\n\nNote; I'm not looking for answers like \"just use py2exe\".","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":371,"Q_Id":28226283,"Users Score":-3,"Answer":"So the question is how do I solve this?\n\nYou have not solve this problem anyhow. There is no any method to describe external dependencies outside of python ecosystem in setup.py. Just provide it in a README.","Q_Score":7,"Tags":"python,deployment","A_Id":28262034,"CreationDate":"2015-01-29T22:58:00.000","Title":"How to handle C extensions for python apps with pip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a pygame program where there's a face in the center. What I want the program to do is have a bunch of objects on the screen, all irregular. Some would be circles, others would be cut-out pictures of objects like surf boards, chairs, bananas, etc. The user would be able to drag the objects around, and they'd collide with each other and the face in the center, and so be unable to pass through them. Could anyone show me how I would do this? Thanks!\n-EDIT- And by not be able to pass through, I mean they'd move along the edge of the object, trying to follow the mouse.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":28228431,"Users Score":0,"Answer":"What you are looking for is functionality usually provided by a so-called physics engine.  For very basic shapes, it is simple enough to code the basic functionality yourself.  (The simplest case for 2D shapes is the collision detection between circles). \nCollision detection gets pretty hard pretty quickly, especially if you want to do it at a reasonably fast rate (such as you would need for the sort of project you are describing) and also especially if you are dealing with arbitrary, non-regular shapes (which your description seems to indicate).  So, unless you are interested in learning how to code an optimized collision detection system, I suggest you google for python physics engines.  I have never used any, so I can't personally recommend one.  \nGood luck!","Q_Score":0,"Tags":"python,pygame,collision","A_Id":28228513,"CreationDate":"2015-01-30T02:48:00.000","Title":"Pygame image collision","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an apache server setup on a Pi, and i'm trying to learn Flask. I set it up so that The 'view' from the index '\/' returns \"hello world\". then i ran my main program. nothing happens from the browser on the PC i'm SSH'ing from,I just get an error saying , but when i used the Pi directly and went to http:localhost:5000\/ i got a response.I read about setting Host to '0.0.0.0' but that didnt help. how can i get my Flask to accept all connections? does it make a difference that I have an 'index.html' in '\/'?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":28253855,"Users Score":0,"Answer":"you need to configure your firewall on your server\/workstation to allow connections on port 5000.  setting the ip to 0.0.0.0 allows connections to your machine but only if you have the port open.  also, you will need to connect via the ip of your machine and not localhost since localhost will only work from the machine where the server is running.","Q_Score":0,"Tags":"python,flask","A_Id":28257714,"CreationDate":"2015-01-31T16:29:00.000","Title":"Flask isn't recognising connections from other clients","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I like Python and I like Spyder but I find debugging with Spyder terrible!\n\nEvery time I put a break point, I need to press two buttons: first\nthe debug and then the continue button (it pauses at first line\nautomatically) which is annoying.\nMoreover, rather than having the standard iPython console with auto completion etc I have a lousy ipdb>> console which is just garbage.\nThe worst thing is that this console freezes very frequently even if I write prints or simple evaluation to try to figure out what is the bug. This is much worse than MATLAB.\nLast but not least, if I call a function from within the\nipdb>> console, and put a breakpoint in it, it will not stop there.\nIt seems like I have to put the breakpoint there before I start the\ndebugging (Ctrl+F5).\n\nDo you have a solution or maybe can you tell me how you debug Python scripts and functions?\nI am using fresh install of Anaconda on a Windows 8.1 64bit.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":113747,"Q_Id":28280308,"Users Score":0,"Answer":"One minor extra regarding point 3:\nIt also seemed to me the debug console frequently froze, doing prints, evaluating, etc, but pressing the stop (Exit debug) button usually got it back to the bottom of the call stack and then I could go back up ('u') to the frame I was debugging in. Worth a try.  This might be for a later version of Spyder (2.3.5.2)","Q_Score":82,"Tags":"python,debugging,spyder","A_Id":36927378,"CreationDate":"2015-02-02T14:48:00.000","Title":"How do I debug efficiently with Spyder in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I like Python and I like Spyder but I find debugging with Spyder terrible!\n\nEvery time I put a break point, I need to press two buttons: first\nthe debug and then the continue button (it pauses at first line\nautomatically) which is annoying.\nMoreover, rather than having the standard iPython console with auto completion etc I have a lousy ipdb>> console which is just garbage.\nThe worst thing is that this console freezes very frequently even if I write prints or simple evaluation to try to figure out what is the bug. This is much worse than MATLAB.\nLast but not least, if I call a function from within the\nipdb>> console, and put a breakpoint in it, it will not stop there.\nIt seems like I have to put the breakpoint there before I start the\ndebugging (Ctrl+F5).\n\nDo you have a solution or maybe can you tell me how you debug Python scripts and functions?\nI am using fresh install of Anaconda on a Windows 8.1 64bit.","AnswerCount":7,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":113747,"Q_Id":28280308,"Users Score":0,"Answer":"You can use debug shortcut keys like:\nStep Over   F10\nStep Into   F11\nin tools>preferences>keyboard shortcuts","Q_Score":82,"Tags":"python,debugging,spyder","A_Id":49370618,"CreationDate":"2015-02-02T14:48:00.000","Title":"How do I debug efficiently with Spyder in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I like Python and I like Spyder but I find debugging with Spyder terrible!\n\nEvery time I put a break point, I need to press two buttons: first\nthe debug and then the continue button (it pauses at first line\nautomatically) which is annoying.\nMoreover, rather than having the standard iPython console with auto completion etc I have a lousy ipdb>> console which is just garbage.\nThe worst thing is that this console freezes very frequently even if I write prints or simple evaluation to try to figure out what is the bug. This is much worse than MATLAB.\nLast but not least, if I call a function from within the\nipdb>> console, and put a breakpoint in it, it will not stop there.\nIt seems like I have to put the breakpoint there before I start the\ndebugging (Ctrl+F5).\n\nDo you have a solution or maybe can you tell me how you debug Python scripts and functions?\nI am using fresh install of Anaconda on a Windows 8.1 64bit.","AnswerCount":7,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":113747,"Q_Id":28280308,"Users Score":61,"Answer":"(Spyder maintainer here) After our 4.2.0 version, released in November 2020, the debugging experience in Spyder is quite good. What we provide now is what people coming from Matlab would expect from a debugger, i.e. something that works like IPython and lets you inspect and plot variables at the current breakpoint or frame.\nNow about your points:\n\nIf there is a breakpoint present in the file you're trying to debug, then Spyder enters in debug mode and continues until the first breakpoint is met. If it's present in another file, then you still need to press first Debug and then Continue.\n\nIPdb is the IPython debugger console. In Spyder 4.2.0 or above it comes with code completion, syntax highlighting, history browsing of commands with the up\/down arrows (separate from the IPython history), multi-line evaluation of code, and inline and interactive plots with Matplotlib.\n\nThis is fixed now. Also, to avoid clashes between Python code and Pdb commands, if you have (for instance) a variable called n and write n in the prompt to see its value, we will show it instead of running the n Pdb command. To run that command instead, you have to prefix it with an exclamation mark, like this: !n\n\nThis is fixed too. You can set breakpoints in IPdb and they will be taken into account in your current session.","Q_Score":82,"Tags":"python,debugging,spyder","A_Id":28285708,"CreationDate":"2015-02-02T14:48:00.000","Title":"How do I debug efficiently with Spyder in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I like Python and I like Spyder but I find debugging with Spyder terrible!\n\nEvery time I put a break point, I need to press two buttons: first\nthe debug and then the continue button (it pauses at first line\nautomatically) which is annoying.\nMoreover, rather than having the standard iPython console with auto completion etc I have a lousy ipdb>> console which is just garbage.\nThe worst thing is that this console freezes very frequently even if I write prints or simple evaluation to try to figure out what is the bug. This is much worse than MATLAB.\nLast but not least, if I call a function from within the\nipdb>> console, and put a breakpoint in it, it will not stop there.\nIt seems like I have to put the breakpoint there before I start the\ndebugging (Ctrl+F5).\n\nDo you have a solution or maybe can you tell me how you debug Python scripts and functions?\nI am using fresh install of Anaconda on a Windows 8.1 64bit.","AnswerCount":7,"Available Count":4,"Score":0.0285636566,"is_accepted":false,"ViewCount":113747,"Q_Id":28280308,"Users Score":1,"Answer":"Here is how I debug in Spyder in order to avoid freezing the IDE. I do this if I alter the script while in debugging mode. \n\nI close out the current IPython (debugging) console [x]\nOpen a new one [Menu bar-> Consoles-> Open an IPython Console]\nEnter debug mode again [blue play pause button]. \n\nStill a bit annoying, but it has the added benefit of clearing (resetting) variable list.","Q_Score":82,"Tags":"python,debugging,spyder","A_Id":39023817,"CreationDate":"2015-02-02T14:48:00.000","Title":"How do I debug efficiently with Spyder in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Since my scaper is running so slow (one page at a time) so I'm trying to use thread to make it work faster. I have a function scrape(website) that take in a website to scrape, so easily I can create each thread and call start() on each of them.\nNow I want to implement a num_threads variable that is the number of threads that I want to run at the same time. What is the best way to handle those multiple threads?\nFor ex: supposed num_threads = 5 , my goal is to start 5 threads then grab the first 5 website in the list and scrape them, then if thread #3 finishes, it will grab the 6th website from the list to scrape immidiately, not wait until other threads end.\nAny recommendation for how to handle it? Thank you","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1243,"Q_Id":28308285,"Users Score":0,"Answer":"It depends.\nIf your code is spending most of its time waiting for network operations (likely, in a web scraping application), threading is appropriate.  The best way to implement a thread pool is to use concurrent.futures in 3.4.  Failing that, you can create a threading.Queue object and write each thread as an infinite loop that consumes work objects from the queue and processes them.\nIf your code is spending most of its time processing data after you've downloaded it, threading is useless due to the GIL.  concurrent.futures provides support for process concurrency, but again only works in 3.4+.  For older Pythons, use multiprocessing.  It provides a Pool type which simplifies the process of creating a process pool.\nYou should profile your code (using cProfile) to determine which of those two scenarios you are experiencing.","Q_Score":0,"Tags":"python,multithreading","A_Id":28308422,"CreationDate":"2015-02-03T20:38:00.000","Title":"Python what is the best way to handle multiple threads","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a client and server model. The server periodically sends its healthy condition to client. The client has a background thread to take care of it(main thread is doing something else). Once the client notices the server is in a bad status, it will do some clean up work and then kill itself(kill the client process).\nThe problem is this:\nAt the very beginning of the process, it does atexit.register(specific_cleanup_func). Once the client recognizes the server is in a bad status, the background thread will do general_cleanup_func() and os.kill(os.getpid(), signal.SIGTERM). I hope the os.kill() called by background thread will trigger the registered specific_cleanup_func but it is not the case. I also tried to call sys.exit() from the background thread but the process does not exit. I wonder how to trigger the registered function from the background thread while killing the process or how to let the background thread ask main thread to do all those cleanup stuff and sys.exit().","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":451,"Q_Id":28314822,"Users Score":0,"Answer":"A background task should never try to kill a foreground task - it might be doing something important.  The background task should pass a status of \"Restart Needed\" and the foreground task should exit when convenient or after prompting the user.  This would be an extension of your current status checking.\nIn your background thread you can have a status that is periodically fetched from the foreground and the foreground can take action based on the returned status.  You could also supply a callback to the background thread that it calls on there being a problem.","Q_Score":0,"Tags":"python,multithreading","A_Id":28314945,"CreationDate":"2015-02-04T06:27:00.000","Title":"python background thread cannot trigger function registered at atexit.register()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running apache with django and mod_wsgi enabled in 2 different processes.\nI read that the second process is a on-change listener for reloading code on change, but for some reason the ready() function of my AppConfig class is being executed twice. This function should only run once.\nI understood that running django runserver with the --noreload flag will resolve the problem on development mode, but I cannot find a solution for this in production mode on my apache webserver.\nI have two questions:\n\nHow can I run with only one process in production or at least make only one process run the ready() function ?\nIs there a way to make the ready() function run not in a lazy mode? By this, I mean execute only on on server startup, not on first request.\n\nFor further explanation, I am experiencing a scenario as follows:\nThe ready() function creates a folder listener such as pyinotify. That listener will listen on a folder on my server and enqueue a task on any changes.\nI am seeing this listener executed twice on any changes to a single file in the monitored directory. This leads me to believe that both processes are running my listener.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":28318105,"Users Score":0,"Answer":"You shouldn't prevent spawning multiple processes, because it's good thing, especially on production environment. You should consider using some external tool, separated from django or add check if folder listening is already running (for example monitor persistence of PID file and it's content).","Q_Score":1,"Tags":"django,python-2.7,apache2,mod-wsgi,pyinotify","A_Id":28320868,"CreationDate":"2015-02-04T09:42:00.000","Title":"how to run Apache with mod_wsgi and django in one process only?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running apache with django and mod_wsgi enabled in 2 different processes.\nI read that the second process is a on-change listener for reloading code on change, but for some reason the ready() function of my AppConfig class is being executed twice. This function should only run once.\nI understood that running django runserver with the --noreload flag will resolve the problem on development mode, but I cannot find a solution for this in production mode on my apache webserver.\nI have two questions:\n\nHow can I run with only one process in production or at least make only one process run the ready() function ?\nIs there a way to make the ready() function run not in a lazy mode? By this, I mean execute only on on server startup, not on first request.\n\nFor further explanation, I am experiencing a scenario as follows:\nThe ready() function creates a folder listener such as pyinotify. That listener will listen on a folder on my server and enqueue a task on any changes.\nI am seeing this listener executed twice on any changes to a single file in the monitored directory. This leads me to believe that both processes are running my listener.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":444,"Q_Id":28318105,"Users Score":2,"Answer":"No, the second process is not an onchange listener - I don't know where you read that. That happens with the dev server, not with mod_wsgi.\nYou should not try to prevent Apache from serving multiple processes. If you do, the speed of your site will be massively reduced: it will only be able to serve a single request at a time, with others queued until the first finishes. That's no good for anything other than a toy site.\nInstead, you should fix your AppConfig. Rather than blindly spawning a listener, you should check to see if it has already been created before starting a new one.","Q_Score":1,"Tags":"django,python-2.7,apache2,mod-wsgi,pyinotify","A_Id":28321203,"CreationDate":"2015-02-04T09:42:00.000","Title":"how to run Apache with mod_wsgi and django in one process only?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?\nI looked on Google and GitHub and I couldn't find anything promising.\nI am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4744,"Q_Id":28327779,"Users Score":0,"Answer":"Hit Ctrl + Space to bring up the control pane. Then start typing Set Syntax and select Set Syntax to Python. Start typing your Python then press Ctrl + Shift + Enter to build and run the program.","Q_Score":6,"Tags":"python,python-3.x,lighttable","A_Id":28327929,"CreationDate":"2015-02-04T17:36:00.000","Title":"Running Python 3 from Light Table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?\nI looked on Google and GitHub and I couldn't find anything promising.\nI am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4744,"Q_Id":28327779,"Users Score":0,"Answer":"I got the same problem. It worked for me after saving the file with a .py extension and then typing Cmd+Enter.","Q_Score":6,"Tags":"python,python-3.x,lighttable","A_Id":28331730,"CreationDate":"2015-02-04T17:36:00.000","Title":"Running Python 3 from Light Table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?\nI looked on Google and GitHub and I couldn't find anything promising.\nI am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":4744,"Q_Id":28327779,"Users Score":3,"Answer":"I had the same problem with using a syntax that was only valid on Python3.3.\n- Go to Settings:User Behaviour\n- add the line (find the real path of your python binary):\n      [:app :lt.plugins.python\/python-exe \"\/usr\/bin\/python3.4\"]\n- Save and test in your lighttable\nIt worked for me :) \nHope it helps","Q_Score":6,"Tags":"python,python-3.x,lighttable","A_Id":29534922,"CreationDate":"2015-02-04T17:36:00.000","Title":"Running Python 3 from Light Table","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The official website shows how weka-wrapper can install on ubuntu 64 bit. I want toknowhow it can be install on ubuntu 32 bit?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":359,"Q_Id":28340224,"Users Score":0,"Answer":"Before installing weka wrapper for python you are suppose to install the weka itself using sudo apt-get install weka or build from source code and add the path the enviroment variable using export wekahome=\"your weka path\" this will make sure you have the required weka jar file in the directory","Q_Score":0,"Tags":"python,weka","A_Id":35519213,"CreationDate":"2015-02-05T09:21:00.000","Title":"How to install python weka wrapper on ubuntu 32 bit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having trouble figuring out how to create a 10x1 numpy array with the number 5 in the first 3 elements and the other 7 elements with the number 0. Any thoughts on how to do this efficiently?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":5701,"Q_Id":28384481,"Users Score":1,"Answer":"Just do the following.\nimport numpy as np\narr = np.zeros(10)\narr[:3] = 5","Q_Score":1,"Tags":"python,arrays,numpy","A_Id":53429718,"CreationDate":"2015-02-07T16:26:00.000","Title":"Create a numpy array (10x1) with zeros and fives","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My python process run on different machines. It consists of a manager and many workers. The worker in each machine are multi threaded and needs to update some data such as its status  to the manager residing on another machine. I didn't want to use mysql because many other processes are already executing many queries on it and it will reach its max_connection\nI have two methods in mind:\n\nFor each worker thread, write the data to a local text file. A separate bash script will run a while-loop, check for file change and scp this file to all other machines.\nFor each worker thread, write the data to share memory and have it replicated to all other machines. I am not sure how to do this. In python how can i write to shared memory? How can i replicated shared memories?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":516,"Q_Id":28388896,"Users Score":1,"Answer":"Okay, first point is that you can't share memory among machines unless you're on a very specialized architecture. (Massively parallel machines, Beowulf clusters, and so on.)\nIf you mean to share code, then package your code into a real Python package and distribute it with a tool like Chef, Puppet or Docker.\nIf you mean to share data, use a database of some sort that all your workers can access. I'm fond of MongoDB because it's easy to match to an application, but there are a million others databases.  A lot of people use mysql or postgresql.","Q_Score":2,"Tags":"python","A_Id":28388912,"CreationDate":"2015-02-07T23:46:00.000","Title":"python - How to share files between many computers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i Launch cluster spark cassandra with datastax dse in aws cloud. So my dataset storage in S3. But i don't know how transfer data from S3 to my cluster cassandra. Please help me","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1657,"Q_Id":28417806,"Users Score":1,"Answer":"The details depend on your file format and C* data model but it might look something like this:\n\nRead the file from s3 into an RDD\nval rdd = sc.textFile(\"s3n:\/\/mybucket\/path\/filename.txt.gz\")\nManipulate the rdd\nWrite the rdd to a cassandra table:\nrdd.saveToCassandra(\"test\", \"kv\", SomeColumns(\"key\", \"value\"))","Q_Score":0,"Tags":"python,cassandra,datastax-enterprise","A_Id":28419293,"CreationDate":"2015-02-09T19:34:00.000","Title":"How import dataset from S3 to cassandra?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently installed Python 3.4 on my Mac and now want to install Django using pip. I tried running pip install Django==1.7.4 from the command line and received the following error:\nException:\n  Traceback (most recent call last):\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/basecommand.py\", line 232, in main\n      status = self.run(options, args)\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/commands\/install.py\", line 347, in run\n      root=options.root_path,\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/req\/req_set.py\", line 549, in install\n      **kwargs\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/req\/req_install.py\", line 754, in install\n      self.move_wheel_files(self.source_dir, root=root)\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/req\/req_install.py\", line 963, in move_wheel_files\n      isolated=self.isolated,\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/wheel.py\", line 234, in move_wheel_files\n      clobber(source, lib_dir, True)\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/wheel.py\", line 205, in clobber\n      os.makedirs(destdir)\n    File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/os.py\", line 157, in makedirs\n      mkdir(name, mode)\n  OSError: [Errno 13] Permission denied: '\/Library\/Python\/2.7\/site-packages\/django'\nObviously my path is pointing to the old version of Python that came preinstalled on my computer, but I don't know how to run the pip on the new version of Python. I am also worried that if I change my file path, it will mess up other programs on my computer. Is there a way to point to version 3.4 without changing the file path? If not how do I update my file path to 3.4?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":797,"Q_Id":28422520,"Users Score":0,"Answer":"Try adding sudo. sudo pip install Django","Q_Score":0,"Tags":"python,django,macos,pip","A_Id":35575253,"CreationDate":"2015-02-10T01:19:00.000","Title":"Mac OSX Trouble Running pip commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently installed Python 3.4 on my Mac and now want to install Django using pip. I tried running pip install Django==1.7.4 from the command line and received the following error:\nException:\n  Traceback (most recent call last):\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/basecommand.py\", line 232, in main\n      status = self.run(options, args)\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/commands\/install.py\", line 347, in run\n      root=options.root_path,\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/req\/req_set.py\", line 549, in install\n      **kwargs\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/req\/req_install.py\", line 754, in install\n      self.move_wheel_files(self.source_dir, root=root)\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/req\/req_install.py\", line 963, in move_wheel_files\n      isolated=self.isolated,\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/wheel.py\", line 234, in move_wheel_files\n      clobber(source, lib_dir, True)\n    File \"\/Library\/Python\/2.7\/site-packages\/pip-6.0.8-py2.7.egg\/pip\/wheel.py\", line 205, in clobber\n      os.makedirs(destdir)\n    File \"\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/os.py\", line 157, in makedirs\n      mkdir(name, mode)\n  OSError: [Errno 13] Permission denied: '\/Library\/Python\/2.7\/site-packages\/django'\nObviously my path is pointing to the old version of Python that came preinstalled on my computer, but I don't know how to run the pip on the new version of Python. I am also worried that if I change my file path, it will mess up other programs on my computer. Is there a way to point to version 3.4 without changing the file path? If not how do I update my file path to 3.4?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":797,"Q_Id":28422520,"Users Score":0,"Answer":"Try to create a virtual environment. This can be achieved by using python modules like venv or virtualenv. There you can change your python path without affecting any other programs on your machine. If then the error is is still that you do not have permission to read files, try sudo pip install. But only as a last resort since pip recommends not using it as root.","Q_Score":0,"Tags":"python,django,macos,pip","A_Id":70606374,"CreationDate":"2015-02-10T01:19:00.000","Title":"Mac OSX Trouble Running pip commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a csv file where a line of data might look like this:\n10,\"Apple, Banana\",20,...\nWhen I load the data in Python, the extra comma inside the quotes shifts all my column indices around, so my data is no longer a consistent structure. While I could probably write a complex algorithm that iterates through each row and fixes the issue, I was hoping there was an elegant way to just pass an extra parameter to loadtxt (or some other function) that will properly ignore commas inside quotes and treat the entire quote as one value.\nNote, when I load the CSV file into Excel, Excel correctly recognizes the string as one value.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5651,"Q_Id":28444272,"Users Score":0,"Answer":"While there is not such a parameter in numpy.loadtxt to ignore quoted or otherwise escaped commas, one alternative that has not been suggested yet would be the following...\nPerform a find and replace using some text editor to replace commas with tabs\nOR\nsave the file in Excel as tab delimited.\nWhen you use numpy.loadtxt, you will simply specify delimiter='\\t' instead of comma delimited.\nSimple solution that could save you some code...","Q_Score":7,"Tags":"python,csv,numpy","A_Id":64579432,"CreationDate":"2015-02-11T00:08:00.000","Title":"numpy.loadtxt: how to ignore comma delimiters that appear inside quotes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to cast in python code a gdb.value which is a complicated type variable to int (this is not general type, but defined in the our code - a kind of bitfield). \nWhen I promped in the gdb shell itself: \n\n\"p var\"\n\nit prints it as int, i.e. the gdb know how to cast that bitfield to int.\n(Strange thing, in addition, I got when I try this command:\n\nint(var.cast(i.type))\n\nWhen \"i\" is gdb.value that its type is int. The var indeed becomes int, but its value become same as the value of i).\nSo is someone know how to cast this gdb.value by use the knowledge of the gdb. (Or by other way..)\nThanks. This is my first question in StackOverFlow, sorry on the confusion and my weak English.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3058,"Q_Id":28451428,"Users Score":1,"Answer":"I had trouble with int(value) giving me a signed number even when the type was explicitly unsigned. I used this to solve the problem:\nint(value) & 0xffffffffffffffff","Q_Score":5,"Tags":"python,gdb","A_Id":34778855,"CreationDate":"2015-02-11T10:01:00.000","Title":"How to cast type of gdb.value to int","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two python packages A and B that I would like to merge together into A, i.e. all functionality of B is now reachable in A.B. Previously, A-1.0 depended on B-1.0. Now I want to avoid, that users of A-2.0 still have B-1.0 installed and I don't know how to handle this properly.\nDifferent solutions\/ideas I came up with:\n\nInclude some code in A-2.0 that tries to import B, if an ImportError is raised, catch the exception and go on, otherwise throw a RuntimeError that B is installed in parallel\nSomehow mark B as a blocker for A-2.0 (is this possible?)\nCreate a \"fake\" successor for B, so people who update their virtual environments or install the \"latest\" version of B get an empty package that throws an exception upon importing.\n\nI welcome your opinion, and experiences","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1572,"Q_Id":28456493,"Users Score":1,"Answer":"I think, you can't! (at least without using such tricks, as you described).\nThe Python package system has (to my knowledge) no such notion as \"allowed\" packages. There could be a person, that invents a different package C that he calls B, but with totally different functionality. Such a notion would prohibit users of your package A to use package C (alias B).\nSo I would communicate to users of A, that B is no longer needed and make sure, that your newer coding does not reference B at all. And when somebody installs B, it is like a third party library that has nothing to do with yours.\nOf course, when the functionality of A and B is intermingled very much and the other user code also has to deal with B directly and has (allowed) side effects on A, you could get in trouble when an old B is still installed. But than your initial design was not the best either.\nIn such a case (and when you really have to merge the packages -- see below) I would recommend, that you make a totally new package name like \"newA\" to underscore the fact, that something has fundamentally changed (and thus an intermingling between old A and B also would more likely be detected).\nBut of course, I would second the argument of msw, that you create your problem by yourself. Normally it is also better to have smaller packages (if they are of a reasonable size, of course) instead of bigger \"I manage the world\" packages. You just can combine smaller packages better for different applications.","Q_Score":4,"Tags":"python,pip,setuptools","A_Id":28460274,"CreationDate":"2015-02-11T14:13:00.000","Title":"Python dependencies: Merging two packages into one","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to deploy my GAE application - written with Python - on CapeDwarf  (WildFly_2.0.0.CR5).\nBut all the documentation talking only about Java Application.\nSo is CapeDwarf can deploy Python Application ?\nif it is, how to do it ?\nelse any other application that can ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":105,"Q_Id":28467558,"Users Score":1,"Answer":"Yes, as Alex posted - CapeDwarf is Java only.","Q_Score":1,"Tags":"python,google-app-engine,capedwarf","A_Id":28474564,"CreationDate":"2015-02-12T01:08:00.000","Title":"Is CapeDwarf compatible with Python GAE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In django model form, how to display blank for null values i.e prevent display of (None) on the form .Using postgresql, django 1.6.5. I do not wish to add space in the model instance for the allowed null values.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":432,"Q_Id":28494629,"Users Score":0,"Answer":"Instead I ended up using forms.HiddenInput() and did not display the field with null, which fits my case perfectly well!","Q_Score":0,"Tags":"python,django","A_Id":28510476,"CreationDate":"2015-02-13T07:36:00.000","Title":"django modelform display blank for null","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In C, I have to set proper type, such as int, float, long for a simple arithmetic for multiplying two numbers. Otherwise, it will give me an incorrect answer.\nBut in Python, basically it can automatically give me the correct answer.\nI have tried debug a simple 987*456 calculation to see the source code.\nI set a break point at that line in PyCharm, but I cannot step into the source code, it just finished right away.\nHow can I see the source code? Is it possible? Or how does Python do that multiplication?\nI mean, how does Python carry out the different of number type in the result of \n98*76 or 987654321*123457789, does Python detect some out of range error and try another number type?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":28512929,"Users Score":0,"Answer":"Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.\nBased on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals or characters in these variables.\nPython variables do not have to be explicitly declared to reserve memory space. The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.\nThe operand to the left of the = operator is the name of the variable and the operand to the right of the = operator is the value stored in the variable.","Q_Score":1,"Tags":"python,c,pycharm,python-2.x","A_Id":28513155,"CreationDate":"2015-02-14T06:00:00.000","Title":"How does Python know which number type to use in order to Multiply arbitrary two numbers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to read a dicom header tag in dicom file. \n Now, there are two ways to read this dicom header tag. \n1) Using pydicom package in python which apparently is not working well on my python installed version(python 3).\n2) or when i call AFNI function 'dicom_hinfo' through command line, i can get dicom tag value. The syntax to call afni function in terminal is as follows:\ndicom_hinfo -tag aaaa,bbbb filename.dcm\noutput:fgre\nNow how should i call this dicom-info -tag aaaa,bbbb filename.dcm in python script.\nI guess subprocess might work but not sure about how to use it in this case.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":411,"Q_Id":28533515,"Users Score":0,"Answer":"Oh this was due to syntax error using Pydicom. \nI wanted to access 0019, 109c tag. \nSyntax should be:\nds[0x0019,0x109c].value. \nnot ds[aaaa,bbbb].value","Q_Score":0,"Tags":"python,subprocess,dicom,pydicom","A_Id":28565218,"CreationDate":"2015-02-16T02:00:00.000","Title":"How to call command line command (AFNI command)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to create python wrapper for the library using SWIG and write unit tests for it. I don't know how to do this. My first take on this problem is to mock dynamic library with the same interface as those library that I'm writing wrapper for. This mock library can log every call or return some generated data. This logs and generated data can be checked by the unit tests.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":28543193,"Users Score":0,"Answer":"I'd absolutely recommend doing some basic testing of the wrapped code. Even some basic \"can I instantiate my objects\" test is super helpful; you can always write more tests as you find problem areas.\nBasically what you're testing is the accuracy of the SWIG interface file - which is code that you wrote in your project!\nIf your objects are at all interesting it is very possible to confuse SWIG. It's also easy to accidentally skip wrapping something, or for a wrapper to use a diferent typemap than you hoped.","Q_Score":4,"Tags":"python,swig,python-extensions","A_Id":60458804,"CreationDate":"2015-02-16T14:04:00.000","Title":"How should I unit-test python wrapper generated by SWIG","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am defining the models for my Django app, and I would like to have a field for a model consisting of a tuple of two (positive) integers.  How can I do this?  I'm looking at the Django Models API reference but I can't see any way of doing this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":339,"Q_Id":28551063,"Users Score":0,"Answer":"Depends on how you intend to use them after storing in the database; 2 methods I can think of are:\nOption 1)\nmodels.IntegerField(unique=True)\nnow the trick is loading data and parsing it: you would have to concatenate the numbers then have a way to split them back out.\nfast would be\nOption 2)\nmodels.CommaSeparatedIntegerField(max_length=1024, unique=True)\nnot sure how it handles unique values; likely '20,40' is not equal to '40,20', so those two sets would be unique.\nor just implement it yourself in a custom field\/functions in the model.","Q_Score":0,"Tags":"python,django","A_Id":28551333,"CreationDate":"2015-02-16T21:58:00.000","Title":"Django - how can I have a field in my model consisting of tuple of integers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im fairly new to python. I creating a game similar to asteroids, and so far I've gotten the spaceship to move around with the arrow keys. can someone explain what i would do to make the spaceship rotate in the direction its moving? thanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":774,"Q_Id":28553439,"Users Score":0,"Answer":"Each of your sprites should have velocity attributes. If your velocity is negative, turn one way. If your velocity is positive, turn the other. Because velocity indicates the direction of movement, this can be used to determine angular direction.","Q_Score":0,"Tags":"python,pygame","A_Id":28553503,"CreationDate":"2015-02-17T01:52:00.000","Title":"python\/pygame: how would i get my sprite to rotate in the direction it's moving?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I have a definite line segment and then am given two random different points, how would i be able to determine if they are on the same side of the line segment?\nI am wanting to use a function def same_side (line, p1, p2). I know based on geometry that cross products can be used but am unsure how to do so with python.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":2656,"Q_Id":28555246,"Users Score":3,"Answer":"If you can get the equation of the line in slope-intercept form, you should be able to set up an inequality.\nSay we have points (x1, y1), (x2, y2), and the line y = mx+b  \nYou should be able to plug in the x and y values for both points, and if both make the equation y < mx + b or both make it y > mx + b, they are on the same side.\nIf either point satisfies the equation (y = mx + b), that point is on the line.\nif (y1 > m * x1 + b and y2 > m * x2 + b) or (y1 < m * x1 + b and y2 < m *x2 + b):\n    return True #both on same side","Q_Score":1,"Tags":"python,python-3.x","A_Id":28555400,"CreationDate":"2015-02-17T05:25:00.000","Title":"Finding out if two points are on the same side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to score my students c programming homeworks. I want to write an autograder script which automatically score the homeworks. I plan to write this script in python language.\nMy question is, in the homework, in some parts students get some input from keyboard with scanf, how can i handle this problem if I try to write an autograder?  Is there any way to read from text file when the scanf line runs in homework ? \nAny idea is appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":160,"Q_Id":28594933,"Users Score":0,"Answer":"You can use the subprocess module in Python to spawn other programs, retrieve their output and feed them arbitrary input. The relevant pieces will most likely be the Popen.communicate() method and\/or the .stdin and .stdout file objects; ensure when you do this that you passed PIPE as the argument to the stdin and stdout keywords on creation.","Q_Score":0,"Tags":"python,c,automation,automated-tests","A_Id":28594984,"CreationDate":"2015-02-18T22:10:00.000","Title":"Autograder script - reading keyboard inputs from textfile","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Query results from some Postgres data types are converted to native types by  psycopg2.  Neither pgdb (PostgreSQL) and cx_Oracle seem to do this.\n\u2026so my attempt to switch pgdb out for psycopg2cffi is proving difficult, as there is a fair bit of code expecting strings, and I need to continue to support cx_Oracle.\nThe psycopg2 docs explain how to register additional types for conversion, but I'd actually like to remove that conversion if possible and get the strings as provided by Postgres.  Is that doable?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":274,"Q_Id":28597575,"Users Score":3,"Answer":"You can re-register a plain string type caster for every single PostgreSQL type (or at least for every type you expect a string for in your code): when you register a type caster for an already registered OID the new definition takes precedence. Just have a look at the source code of psycopg (both C and Python) to find the correct OIDs.\nYou can also compile your own version of psycopg disabling type casting. I don't have the source code here right now but probably is just a couple line changes.","Q_Score":2,"Tags":"postgresql,psycopg2,python-db-api","A_Id":28602221,"CreationDate":"2015-02-19T02:11:00.000","Title":"Can one disable conversion to native types when using psycopg2?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get the hostmask for a user, to allow some authentication in my IRCClient bot. However, it seems to be removed from all responses? I've tried 'whois', but it only gives me the username and the channels the user is in, not the hostmask.\nAny hint on how to do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":28606809,"Users Score":1,"Answer":"Found it, when I override RPL_WHOISUSER, I can get the information after issuing an IRCClient.whois.\n(And yes, did search for it before I posted my question, but had an epiphany right after I posted my question...)","Q_Score":1,"Tags":"python,twisted,irc,twisted.internet,twisted.words","A_Id":28607141,"CreationDate":"2015-02-19T12:46:00.000","Title":"How to get a user's hostmask with Twisted IRCClient","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have latest IronPython version built and running in Ubuntu 14.04 through Mono.\nBuilding Ironpython and running with Mono seems trivial but I am not convinced I have proper sys.paths or permissions for Ironpython to import modules, especially modules like fcntl. \nRunning ensurepip runs subprocess, and wants to import \"fcntl\". There are numerous posts already out there, but mostly regarding windows.\nAs I understand, fcntl is part of unix python2.7 standard library. To start the main problem seems to be that Ironpython has no idea where this is, but I also suspect that since fcntl seems to be perl or at least not pure python, that there is more to the story.\nSo my related sys.path questions are:\n\nIn Ubuntu, where should I install Ironpython (Ironlanguages folder)\nto? Are there any permissions I need to set?\nWhat paths should I add to the sys.path to get Ironpython's standard library found?'\nWhat paths should I add to the sys.path to get Ubuntu's python 2.7 installed modules?\nWhat paths should I add to the sys.path  or methods to get fcntl to import properly in Ironpython\nAny clues on how to workaround known issues installing pip through ensurepip using mono ipy.exe X:Frames ensurepip\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":456,"Q_Id":28648230,"Users Score":3,"Answer":"As far as I can see, the fcntl module of cPython is a builtin module (implemented in C) - those modules need to be explicitly implemented for most alternative Python interpreters like IronPython (in contrast to the modules implemented in plain Python), as they cannot natively load Python C extensions.\nAdditionally, it seems that there currently is no such fcntl implementation in IronPython.\nThere is a Fcntl.cs in IronRuby, however, maybe this could be used as a base for implementing one in IronPython.","Q_Score":1,"Tags":"python-2.7,ubuntu,mono,ironpython,fcntl","A_Id":28673847,"CreationDate":"2015-02-21T16:41:00.000","Title":"Ubuntu and Ironpython: What paths to add to sys.path AND how to import fcntl module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to import a text file and assign the key without a value? Im doing so to import other values from another text file to assign them as the values for the key. \nFor example, I would get a name from one text file and assign it as a key, then get their bank accnt number, amount of money, id number from another text file and assign those values to the key.\nI know how to import text files WITH the key and value from a single text file, but i dont know how to do it separately and assign it to one key value pair.\nThanks.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":74,"Q_Id":28665515,"Users Score":1,"Answer":"Every dict has a value for every key -- no such thing as \"no value\" for one or more keys.  However you can set the value to a placeholder, e.g None, and then simply reassign it once you know exactly what the value for each given key you want to be.","Q_Score":0,"Tags":"python","A_Id":28665549,"CreationDate":"2015-02-23T01:05:00.000","Title":"In Python I'm trying to import a text file into a dictionary but only assign the key, no value","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a huge txt data store on which I want to gather some stats.\nUsing Hadoop-streaming and Python I know how to implement a MapReduce for gathering stats on a single column, e.g. count how many records there are for each of a 100 categories. I create a simple mapper.py and reducer.py, and plug them into the hadoop-streaming command as -mapper and -reducer respectively.\nNow, I am at a bit of a loss at how to practically approach a more complex task: gathering various stats on various other columns in addition to categories above (e.g. geographies, types, dates, etc.). All that data is in the same txt files.\nDo I chain the mapper\/reducer tasks together? Do I pass key-value pairs initially long (with all data included) and \"strip\" them of interesting values one by one while processing? Or is this a wrong path? I need a practical advice on how people \"glue\" various MapReduce tasks for a single data source from within Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":107,"Q_Id":28668641,"Users Score":1,"Answer":"This question seems very generic to me.\nChain of many map-reduce jobs are the most common pattern for the production ready solutions. But as programmer, we should always try to use less number of MR jobs to get the best performance (You have to be smart in selecting your key-value pairs for the jobs in order to do this) but off course it is dependent on the use cases. Some people use different combinations of Hadoop Streaming, Pig, Hive, JAVA MR etc. MR jobs to solve one business problem. With the help of any workflow management tools like Oozie or bash scripts you can set the dependencies between the jobs. And for exporting\/importing data between RDBMS and HDFS, you can use Sqoop.\nThis is the very basic answer of your query. If you want to have further explanation for any point then let me know.","Q_Score":2,"Tags":"python,hadoop,mapreduce,hadoop-streaming","A_Id":28762585,"CreationDate":"2015-02-23T07:18:00.000","Title":"Python & MapReduce: beyond basics -- how to do more tasks on one database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to get data (json) in my html page, with help of Ajax. I have a Nodejs server serving requests. \nI have to get the json from server, which is python code to process and produce json as output. \n\nSo should i save json in db and access it? (seems complicated just for one single use)\nShould i run python server, to serve the requests with json as result (call it directy from html via ajax)\nShould i serve requests with nodejs alone, by calling python method from nodejs? if so how to call the python method.\nIf calling python requires it to run server ? which one to prefer (zeropc, or some kind of web framework?)\n\nWhich is the best solution? or Which is preferred over other in what scenario and what factors?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":932,"Q_Id":28679250,"Users Score":0,"Answer":"In your application, if you have some requirement of processing results of python server requests in your nodejs application, then you need to call the python server requests in nodejs app with request libray and then process the result. Otherwise, you should simply call python server resources through client side ajax requests.\nThanks","Q_Score":1,"Tags":"python,ajax,json,node.js","A_Id":28687176,"CreationDate":"2015-02-23T17:06:00.000","Title":"Nodejs Server, get JSON data from Python in html client with Ajax","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to run a python script on raspberry pi when it is turned on. how can i do this? my script contains \"Webkit\" and \n\"Gtk\" modules. I've tried many methods but still not working. the code works perfectly through the python IDEL","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":711,"Q_Id":28738062,"Users Score":1,"Answer":"If you run a DE, then use the DE's session manager.\nIf you want to run only your application in fullscreen mode use the ~\/.xinitrc to lauch it.","Q_Score":0,"Tags":"python,webkit,gtk,raspberry-pi,startup","A_Id":28744914,"CreationDate":"2015-02-26T08:57:00.000","Title":"how to run a python script automatically after startx on raspberrypi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a basic piano style program that uses functions with winsound.Beep to play different note. I am new to multi-processing, and was wondering how I would be able to play two notes at once. If that is not possible, perhaps there is a way to combine frequencies that I do not know. Thanks for reading\n~Jimnebob","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":142,"Q_Id":28756204,"Users Score":0,"Answer":"It seems like Beep function couldn't play several notes at the same time. You can record the sound of 'Beep' through sounddevice library, save the sound in wav files. Then, use subprocess.Popen to achieve multiprocess. The subprocess would play the wav files.","Q_Score":0,"Tags":"python,multiprocessing","A_Id":61904891,"CreationDate":"2015-02-27T01:50:00.000","Title":"How do I use the multiprocess library with winsound in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to fetch few data\/values from  a website. I have used beautifulsoup for this and the fields are blank when I try to fetch them from my Python script, whereas when I am inspecting elements of the webpage I can clearly see the values are available in the table row data.\nWhen i saw the HTML Source I noticed its blank there too.\nI came up with a reason, the website is using Javascript to populate the values in their corresponding fields from its own database. If so then how can i fetch them using Python?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":272,"Q_Id":28765398,"Users Score":1,"Answer":"The Python binding for Selenium and phantomjs (if you want to use a headless browser as backend) are the appropriate tools for this job.","Q_Score":0,"Tags":"javascript,python,html,web-scraping,beautifulsoup","A_Id":28852463,"CreationDate":"2015-02-27T12:42:00.000","Title":"How to fetch data from a website using Python that is being populated by Javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to fetch few data\/values from  a website. I have used beautifulsoup for this and the fields are blank when I try to fetch them from my Python script, whereas when I am inspecting elements of the webpage I can clearly see the values are available in the table row data.\nWhen i saw the HTML Source I noticed its blank there too.\nI came up with a reason, the website is using Javascript to populate the values in their corresponding fields from its own database. If so then how can i fetch them using Python?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":28765398,"Users Score":0,"Answer":"Yes, you can scrape JS data, it just takes a bit more hacking. Anything a browser can do, python can do.\nIf you're using firebug, look at the network tab to see from which particular request your data is coming from. In chrome element inspection, you can find this information in a tab named network, too. Just hit ctrl-F to search the response content of the requests.\nIf you found the right request, the data might be embedded in JS code, in which case you'll have some regex parsing to do. If you're lucky, the format is xml or json, in which case you can just use the associated builtin parser.","Q_Score":0,"Tags":"javascript,python,html,web-scraping,beautifulsoup","A_Id":28850142,"CreationDate":"2015-02-27T12:42:00.000","Title":"How to fetch data from a website using Python that is being populated by Javascript?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on making a GUI front end for a Python program using HTML and CSS (sort of similar to how a router is configured using a web browser). The program assigns values given by the user to variables and performs calculations with those variables, outputting the results. I have a few snags to work out:\n\nHow do I design the application so that the data is constantly updated, in real-time? I.e. the user does not need to hit a \"calculate\" button nor refresh the page to get the results. If the user changes the value in a field, all other are fields simultaneously updated, et cetera.\nHow can a value for a variable be fetched from an arbitrary location on the internet, and also constantly updated if\/when it is updated at the source? A few of the variables in the program are based on current market conditions (e.g. the current price of gold). I would like to make those values be automatically entered after retrieving them from certain sources that, let us assume, do not have APIs.\nHow do I build the application to display via HTML and CSS? Considering Python cannot be implemented like PHP, I am seeking a way to \"bridge the gap\" between HTML and Python, without such a \"heavy\" framework like Django, so that I can run Python code on the server-side for the webpage.\n\nI have been looking into this for a quite some time now, and have found a wide range of what seem to be solutions, or that are nearly solutions but not quite. I am having trouble picking what I need specifically for my application. These are my best findings:\nWerkzeug - I believe Werkzeug is the best lead I have found for putting the application together with HTML and Python. I would just like to be reassured that I am understanding what it is correctly and that is, in fact, a solution for what I am trying to do. \nWebSockets - For displaying the live data from an arbitrary website, I believe I could use this protocol. But I am not sure how I would implement this in practice. I.e. I do not understand how to target the value, and then continuously send it to my application. I believe this to be called scraping?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6330,"Q_Id":28786932,"Users Score":0,"Answer":"To achieve your goal, you need good knowledge of javascript, the language for dynamic web pages. You should be familiar with dynamic web techniques, AJAX, DOM, JSON. So the main part is on the browser side. Practically any python web server fits. To \"bridge the gap\" the keyword is templates. There are quite a few for python, so you can choose, which one suites you best. Some frameworks like django bring their own templating engine.\nAnd for your second question: when a web site doesn't offer an API, perhaps the owner of the site does not want, that his data is abused by others.","Q_Score":1,"Tags":"python,html,css,python-3.x","A_Id":28787299,"CreationDate":"2015-02-28T21:09:00.000","Title":"How to make a webpage display dynamic data in real time using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With GradientBoostingClassifier suppose I set n_estimators to 2000 and use GridSearchCV to search across learning_rate in [0.01, 0.05, 0.10] - how do I know the number of boosting iterations that produced the optimal result - is the model always going to fit 2000 trees for each value of learning_rate or is it going to use the optimal number of boosting iterations for each of these values? It wouldn't make sense to also include n_estimators in the grid search and search for all values in [1,2000].","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1119,"Q_Id":28790032,"Users Score":0,"Answer":"Currently there is no way to directly get the optimum number of estimators from GradientBoostingClassifier. If you also pass n_estimators in the parameter grid to GridSearchCV it will only try the exact values you give it, and return one of these.\nWe are looking to improve this, by searching over the number of estimators automatically.","Q_Score":0,"Tags":"python,scikit-learn","A_Id":28871022,"CreationDate":"2015-03-01T04:17:00.000","Title":"Obtain optimal number of boosting iterations in GradientBoostingClassifier using grid search","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Metaphorically speaking, I'm learning python in a community college for game programming; and our second assignment is to make a text based game. I'm stuck trying to figure out how to get the code to run if the player has something in their inventory, then display these options or print these options if they don't have that certain item in their inventory.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":117,"Q_Id":28791278,"Users Score":0,"Answer":"What you describe is what was a very popular type of game a long time ago. The most difficult portion of this type of game is interpreting user input. You can start with a list of possible commands, iterating through each token of the user's input. If I type\n\nlook left\n\nthe game can begin by calling a method or function which interprets the available visual data. You will want to look into your database implementation for what is left in relation to the current player's position. The game can respond with\n\nYou see a wooden box on the floor. It is locked.\n\nYou get the idea. As the user, I will probably want to check my inventory for a key. You can implement a subroutine in your parser for searching, categorizing, and using your inventory. The key to writing anything like the described program is spending at least twice as much time testing and debugging the game over how much time you spent coding the first working version. The second key is to make sure you are thinking ahead. Example: \"How can I modularize the navigation subroutine so that maps can be modified or expanded easily?\"\nComment if you have any questions. Good luck coding!","Q_Score":0,"Tags":"python-3.x","A_Id":28791357,"CreationDate":"2015-03-01T07:41:00.000","Title":"Key and lock code [game programming]?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program run_tests.py that executes test scripts (also written in python) one by one. Each test script may use threading.\nThe problem is that when a test script unexpectedly crashes, it may not have a chance to tidy up all open threads (if any), hence the test script cannot actually complete due to the threads that are left hanging open. When this occurs, run_tests.py gets stuck because it is waiting for the test script to finish, but it never does.\nOf course, we can do our best to catch all exceptions and ensure that all threads are tidied up within each test script so that this scenario never occurs, and we can also set all threads to daemon threads, etc, but what I am looking for is a \"catch-all\" mechanism at the run_tests.py level which ensures that we do not get stuck indefinitely due to unfinished threads within a test script. We can implement guidelines for how threading is to be used in each test script, but at the end of the day, we don't have full control over how each test script is written.\nIn short, what I need to do is to stop a test script in run_tests.py even when there are rogue threads open within the test script. One way is to execute the shell command killall -9 <test_script_name> or something similar, but this seems to be too forceful\/abrupt.\nIs there a better way?\nThanks for reading.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":238,"Q_Id":28799663,"Users Score":2,"Answer":"To me, this looks like a pristine application for the subprocess module.\nI.e. do not run the test-scripts from within the same python interpreter, rather spawn a new process for each test-script. Do you have any particular reason why you would not want to spawn a new process and run them in the same interpreter instead? Having a sub-process isolates the scripts from each other, like imports, and other global variables.\nIf you use the subprocess.Popen to start the sub-processes, then you have a .terminate() method to kill the process if need be.","Q_Score":0,"Tags":"python,multithreading","A_Id":28799878,"CreationDate":"2015-03-01T22:02:00.000","Title":"Best way to stop a Python script even if there are Threads running in the script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"maybe some of you can point me in the right direction.\nI've been playing around with OpenCV FaceRecognition for some time with Eigenfaces to let it learn to recognize faces. Now I would like to let it run during windows logon. \nPrecisely, I want to make Snapshots of Faces when I log into a user so after the software has learned the faces after x logins and to which user it belongs, it will log me in automatically when it recognises me during typing. \nAs a prototype it would be enough to somehow get a textfield and get textinput working to \"simulate\" login in. Im using python.\nI hope you understand what i want to achieve and can help me out.\nEdit: Another Question\/Idea: If i want to build an Application in Visual Studio, can I reuse my python Code or do I have to use c++? I could make a Windows Store app or something like that.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":211,"Q_Id":28850205,"Users Score":0,"Answer":"You can store the snapshots in an array, run your recognition on each image and see if the user is recognized as one of the users you have trained your model on.\nIf not then prompt the user for their name, if the name matches one of the users you trained your model on, add these snapshots to their training set and re-train, so the model is more up to date, if it does not match any names, then you assume this is a new user and create a new label and folder for them, and retrain your recognizer.\nBeware though that each time you add more snapshots the training time will increase, so perhaps limit each snapshot capture to 1 FPS or something.","Q_Score":0,"Tags":"python,windows,visual-studio,opencv,login","A_Id":28854271,"CreationDate":"2015-03-04T08:57:00.000","Title":"opencv FaceRecognition during login","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am pretty new to Python and pandas library, i just learned how to read a csv file using pandas. \nmy data is actually raw packets i captured from sensor networks, to analyze corrupt packets.\nwhat i have now is, thousands of rows and hundreds of columns, literally, and the values are all in Hex. i need to convert all the values to binary with trailing zeros.\ni am at lost on how to accomplish that once i have read the CSV file successfully using pandas.\nI'd appreciate every kind of help, even a simple direction.\nhere is my sample data:\n\n00 FF FF 00 00 29 00 89 29 41 88 44 22 00 FF FF 01 00 3F 06 55 55 55\n  55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55\n  55 55 0A \n00 FF FF 00 00 29 00 89 29 41 88 45 22 00 FF FF 01 00 3F 06 55 55 55\n  55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55\n  55 55 0A \n00 FF FF 00 00 29 00 89 29 41 88 46 22 00 FF FF 01 00 3F 06 55 55 55\n  55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55\n  55 55 0A \n00 FF FF 00 00 29 00 89 29 41 88 47 22 00 FF FF 01 00 3F 06 55 55 55\n  55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55\n  55 55 0A","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":778,"Q_Id":28854821,"Users Score":0,"Answer":"If I understood, in column 1 you have 00, column 2 : 55, ...\nIf I am right, you first need to concat three columns in a string value = str(col1)+str(col2)+str(col3) and then use the method to convert it in binary.","Q_Score":1,"Tags":"python,pandas,binary,hex","A_Id":28858326,"CreationDate":"2015-03-04T12:42:00.000","Title":"converting dataframe from Hex to binary in using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install and run successfully Bloomberg API Python 3.5.5 and I have also downloaded and unpacked C++ library 3.8.1.1., both for the Mac OS X.  I'm running Mac OS X 10.10.2.  I am using the Python native to Mac OS X, Python 2.7.6 and I had already installed, via Xcode, the Command line gcc compiler, GCC 4.2.1.\nI did, on an administrator account, sudo python setup.py install. I also had changed the setup.py ENVIRONMENT variable BLPAPI_ROOT to the directory for the C++ headers, blpapi_cpp_3.8.1.1. The setup was successful. \nI changed to another directory as suggested by the Python's README file, to avoid 'Import Error: No module named _internals'.  \nWhen I go to python and enter the command import blpapi, I obtain the following error:\n\n\n\nimport blpapi\n      Traceback (most recent call last):\n        File \"\", line 1, in \n        File \"\/Library\/Python\/2.7\/site-packages\/blpapi\/init.py\", line 5, in \n          from .internals import CorrelationId\n        File \"\/Library\/Python\/2.7\/site-packages\/blpapi\/internals.py\", line 50, in \n          _internals = swig_import_helper()\n        File \"\/Library\/Python\/2.7\/site-packages\/blpapi\/internals.py\", line 46, in swig_import_helper\n          _mod = imp.load_module('_internals', fp, pathname, description)\n      ImportError: dlopen(\/Library\/Python\/2.7\/site-packages\/blpapi\/_internals.so, 2): Library not loaded: libblpapi3_64.so\n        Referenced from: \/Library\/Python\/2.7\/site-packages\/blpapi\/_internals.so\n        Reason: image not found\n\n\n\nI check the directory for \/Library\/Python...\/blpapi\/ and there is no _internals.so only *.py files.  Is that the problem? I don't know how to proceed.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":3384,"Q_Id":28874356,"Users Score":7,"Answer":"There is a missing step in the Python SDK README file; it instructs you to set BLPAPI_ROOT in order to build the API wrapper, but this doesn't provide the information needed at runtime to be able to load it.\nIf you unpacked the C\/C++ SDK into '\/home\/foo\/blpapi-sdk' (for example), you will need to set DYLD_LIBRARY_PATH to allow the runtime dynamic linker to locate the BLPAPI library. This can be done as so:\n$ export DYLD_LIBRARY_PATH=\/home\/foo\/blpapi-sdk\/Darwin","Q_Score":3,"Tags":"python,c++,macos,installation,blpapi","A_Id":29039670,"CreationDate":"2015-03-05T09:32:00.000","Title":"Bloomberg API Python 3.5.5 with C++ 3.8.1.1. on Mac OS X import blpapi referencing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My code imports Paginator from django.core.paginator.  (Django 1.6.7)\nHowever, when run, somehow it is calling a custom paginator. I don't want it to do this, as the custom paginator template has been removed in an upgrade. I just want Django's Paginator to be used, but I can't find how to workout where it's overriding Django's Paginator with our broken one.\nThis may not be so much of a Django question and more of a generic Python question. All the usual things like grepping the code, inserting ipdb's, judicious use of find etc yield no help.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":28877499,"Users Score":0,"Answer":"You've all been really helpful. However the my confusion came from the fact that  paginator was being added to the context, yet there was a statement {% load paginator %} at the top of the template. I thought they were the same, but no. The paginator from the context was unused, and the load statement pulled in the bad paginator, which was registered with the templating engine. \nThe fix is obvious: remove the load statement, including the context paginator and use that one.","Q_Score":0,"Tags":"python,django,pagination","A_Id":28939075,"CreationDate":"2015-03-05T12:05:00.000","Title":"Django keeps calling another package to paginate -- how?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Is it possible to use Celery to run an already compiled (py2exe) python script, if yes, how I can invoke it ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":28877646,"Users Score":0,"Answer":"if __name__ == '__main__':\n    app.start()\nshould be added to the entry point of the script.","Q_Score":0,"Tags":"python,python-2.7,celery,py2exe","A_Id":28878537,"CreationDate":"2015-03-05T12:14:00.000","Title":"Is it possible to use Celery to run an already compiled (py2exe) python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a meta.yaml file for a python package to be used in conda packages in a way that works with CI systems. how can i specify external software requirements for the package? meaning software that is not a python library but is required for the package unit tests to pass? to clarify: the required module is not a python package, but the python package depends on it.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1203,"Q_Id":28892506,"Users Score":2,"Answer":"The requirements in the meta.yaml can be any conda package (which doesn't have to just be Python packages). If you have a conda package for your dependency, you can specify it.","Q_Score":3,"Tags":"python,travis-ci,anaconda,conda","A_Id":28909473,"CreationDate":"2015-03-06T04:47:00.000","Title":"how to specify external software requirements with conda\/meta.yaml in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to implement a REST backend for mobile applications.\nI will have to use Django REST Framework.\nAmong the features that I need to implement there will be the registration user and login.\nThrough the mobile application the user can create an account using ONLY the Facebook login. \nThen, the application will take the information from Facebook using the token-facebook and it will send this data to my server.\nI tried using python_social about Facebook authentication and user registration using the Facebook token. \nAt this point I have doubts:\nthink there could be two choices:\n1:\nThe mobile application use the Facebook-login to retrieve user data and will send a request to my server to create a new user with the Facebook data user and passing the Facebook-token.\nIn this case, in the server side, it will not be integrated python_social and facebook-token is a simple profile field.\nDoubts: how can you implement the next login (which password Is necessary to use?)\n2:\nThe second possibility is to use python_social. In this way there are no problems for subsequent logins. The token Facebook will be used to retrieve the data (and validate the user) by calling: do_auth\nBut in this case, for each user, the server will have to make a request to Facebbok (which actually is possible to avoid: the mobile application has already recovered all the data)\nWhat is the best case? What do you usually use for authentication backend rest with Facebook?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":779,"Q_Id":28903187,"Users Score":0,"Answer":"i didn't unerstand the first case, when you are using facebook login it does the authentication and we will register the user with the access token provided by facebook. When ever user log in we are not worried about the password, authentication is not done on our end. so when ever user tries to login it contacts facebook if everything goes good there, it will give you a token with that user can login.","Q_Score":1,"Tags":"django,facebook,rest,django-rest-framework,python-social-auth","A_Id":38586945,"CreationDate":"2015-03-06T16:28:00.000","Title":"Django REST Backend for mobile app with Facebook login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using DataNitro and would like to be able to copy output from the Excel Shell and paste into my editor. However, I can't find a way to do that. Any idea how I might do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":28909929,"Users Score":0,"Answer":"Right click in the shell, click \"mark\", highlight the region you want to copy, and press enter. It'll then be in your clipboard and you can paste it into an editor.\n(This is the way to copy things from a windows command prompt in general, which is where the shell is running.)","Q_Score":2,"Tags":"python,pandas,datanitro","A_Id":28910528,"CreationDate":"2015-03-07T00:27:00.000","Title":"DataNitro - copying from the shell into an editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I create a QMainWindow without explicitly specifying its dimensions, PyQt will give it a -let's say- \"standard size\" which is not the minimum that the window can get.\nCan I set this size at will in any way?\nMy goal is to get this \"standard size\" according to the currently visible widgets, when I set the visibility of some widgets on\/off.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1830,"Q_Id":28915681,"Users Score":1,"Answer":"QWidget.sizeHint holds the recommended size for the widget. It's default implementation returns the layout's preferred size if the widget has a layout. So if your dialog has a layout, just use sizeHint to get the recommended size which is the default one.","Q_Score":0,"Tags":"python,qt,pyqt","A_Id":28923741,"CreationDate":"2015-03-07T14:04:00.000","Title":"how to get the default size of a window in pyqt4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have this game which I have coded in python with pygame.\nWhen I launch my game through the renpy launcher, it works just fine. \nWhen I emulate my game through the renpy android emulator, it works just fine.\nWhen I go through each of the build steps (install sdk, configure, build package, install package) it completes successfully.\nThe package is installed on my connected android device. \nWhen I open the game on my android device, it says:\n\"ImportError: No module named renpygame.\"\nWhen I build the game and play it on my desktop I don't have this problem.\nI'm guessing somehow renpygame is not getting included in the package when I go through the build process in renpy for Android, but I don't know why or how to fix it. I'm not even getting an error message, I don't know where to start.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1556,"Q_Id":28921997,"Users Score":1,"Answer":"I e-mailed PyTom, the creator of Ren'py, and he responded back instantly:\n\"Edit the rapt\/blacklist.txt file, and delete the line that says **.py. \"\nIt worked! Thanks, PyTom.","Q_Score":0,"Tags":"python,android,pygame,renpy","A_Id":28922150,"CreationDate":"2015-03-08T01:11:00.000","Title":"Ren'Py with Renpygame for Android","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to monitor an audio streaming for silences. Any idea how I can do this ? it's a stream, not an audio file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6105,"Q_Id":28938162,"Users Score":5,"Answer":"Your best bet is to grab chunks from the stream (I'd advise 50 millisecond chunks since one complete wave form at 20Hz is 50ms), and construct an AudioSegment using this data.\nOnce you've done that you'll be able to use the AudioSegment().dBFS property to get a rough measure of the average loudness of that chunk. Once you get a sense for where the highs and lows are you can set a threshold below which will be considered silence.\nYou can of course determine the silence threshold automatically as well, but that'll probably require keeping track of loudest and quietest signal level in the last X seconds, and probably using some kind of decay as well.\nNote: The method I've described above is definitely not the fastest way to do this, but pydub does not natively handle streaming. That said, it's probably the simplest way to accomplish your goal with pydub.","Q_Score":3,"Tags":"python,pydub","A_Id":28943471,"CreationDate":"2015-03-09T08:59:00.000","Title":"How to detect silence in an audio stream with pydub?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering seriously about the effects of cv2.imwrite() function of OpenCV.\nI noticed that when I read pictures with cv2.imread() and save them again with cv2.imwrite() function, their quality is not the same any more for the human eyes.\nI ask you how can I keep the quality of the image the same as the original after saving it using cv2.imwrite() function.\nI ask this question because I have really a serious issue in a larger program and when I checked the quality of the pictures saved by this function, I guesses that my problem comes certainly from this function.\nFor example, I draw using the mouse movements small  red (Red=255) squares on picture . When I save the picture and count the number of pixels that have Red color equal to 255 I get very few of them only even if I draw a lot of them in pure red color. But when I check the image by my eyes, I notice the red pixels I drawed are not correctly saved in the correct red color I chosed (255).\nAny one does know how to resolve this problem ? I mean to save the pictures using OpenCV without degrading its quality.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2752,"Q_Id":28940711,"Users Score":5,"Answer":"JPEG is a lossy format, you need to save your images as PNG as it is a lossless format.","Q_Score":1,"Tags":"python,opencv,colors,python-2.x","A_Id":28940905,"CreationDate":"2015-03-09T11:18:00.000","Title":"Not losing the quality of pictures saved with cv2.imwrite()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have done a fair amount of googling about this question and most of the threads I've found are 2+ years old, so I am wondering if anything has changed, or if there is a new method to solve the issue pertaining to this topic.\nAs you might know when using IntelliJ (I use 14.0.2), it often autosaves files. For me, when making a change in Java or JavaScript files, its about 2 seconds before the changes are saved.  There are options that one would think should have an effect on this, such as Settings > Appearance & Behavior > System Settings > Synchronization > Save files automatically if application is idle for X sec.  These settings seem to have no effect for me though, and IntelliJ still autosaves, for example if I need to scroll up to remember how a method I am referencing does something.\nThis is really frustrating when I have auto-makes, which mess up TomCat, or watches on files via Grunt, Karma, etc when doing JS development.  Is there a magic setting that they've put in recently?  Has anyone figured out how to turn off auto-save, or actually delay it?","AnswerCount":8,"Available Count":2,"Score":0.024994793,"is_accepted":false,"ViewCount":59393,"Q_Id":28949290,"Users Score":1,"Answer":"If there are any file watchers active (Preferences>Tools>File Watchers), make sure to check their Advanced Options. Disable any Auto-save files to trigger the watcher toggles.\nThis option supersedes the Autosave options from Preferences>Appearance & Behaviour>System Settings.","Q_Score":78,"Tags":"java,python,intellij-idea,pycharm,ide","A_Id":66222468,"CreationDate":"2015-03-09T18:31:00.000","Title":"Turning off IntelliJ Auto-save","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have done a fair amount of googling about this question and most of the threads I've found are 2+ years old, so I am wondering if anything has changed, or if there is a new method to solve the issue pertaining to this topic.\nAs you might know when using IntelliJ (I use 14.0.2), it often autosaves files. For me, when making a change in Java or JavaScript files, its about 2 seconds before the changes are saved.  There are options that one would think should have an effect on this, such as Settings > Appearance & Behavior > System Settings > Synchronization > Save files automatically if application is idle for X sec.  These settings seem to have no effect for me though, and IntelliJ still autosaves, for example if I need to scroll up to remember how a method I am referencing does something.\nThis is really frustrating when I have auto-makes, which mess up TomCat, or watches on files via Grunt, Karma, etc when doing JS development.  Is there a magic setting that they've put in recently?  Has anyone figured out how to turn off auto-save, or actually delay it?","AnswerCount":8,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":59393,"Q_Id":28949290,"Users Score":8,"Answer":"I think the correct answer was given as a comment from ryanlutgen above: \nThe beaviour of \"auto-saving\" your file is not due to the auto-save options mentioned.\nIJ saves all changes to your build sources to automatically build the target.\nThis can be turned of in: \nPreferences -> Build,Execution,Deployment -> Compiler -> Make project automatically.\nNote: now have to initiate the project build manually (e.g. by using an appropriate key-shortcut)\n(All other \"auto-save\" options just fine-tune the build in auto-save behaviour.)","Q_Score":78,"Tags":"java,python,intellij-idea,pycharm,ide","A_Id":37813276,"CreationDate":"2015-03-09T18:31:00.000","Title":"Turning off IntelliJ Auto-save","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to carry out a padding oracle attack. I am aware that I have to modify the bytes from 00 to the point where it succeeds, to find the correct padding. But, how do I represent 00-FF in python? When I try representing it as a part of the string, 00 is taken as 2 bytes. \nP.S - This is a homework problem.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":289,"Q_Id":28960249,"Users Score":2,"Answer":"Doing '\\x00\\x00\\xff' or \"0000ff\".decode('hex') should work.","Q_Score":0,"Tags":"python,cryptography","A_Id":28960426,"CreationDate":"2015-03-10T09:37:00.000","Title":"padding oracle attack - how to represent hexadecimal as one byte in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a dynamic admin site, that based on if the field is blank or not will show that field.  So I have a model that has a set number of fields, but for each individual entry will not contain all of the fields in my model and I want to exclude based on if that field is blank.\nI  have a unique bridge identifier, that correlates to each bridge, and then all of the various different variables that describe the bridge.\nI have it set up now that the user will go to a url with the unique bridgekey and then this will create an entry of that bridge.  So (as i am testing on my local machine) it would be like localhost\/home\/brkey and that code in my views.py that corresponds to that url is \nHowever, not every bridge is the same and I have a lot more variables that I would like to include in my model but for now I am just testing on two : prestressed_concrete_deck and reinforced_concrete_coated_bars.  What I want is to dynamically create the admin site to not display the prestressed_concrete_deck variable if that field is blank.  So instead of displaying all of the variables on the admin site, I want to only display those variables if that bridge has that part, and to not display anything if the field is blank.  \nAnother possible solution to the problem would be to get that unique identifier over to my admins.py.  I cant figure out either how to get that individual key over as then I could query in the admins.py.  If i knew how to access the bridgekey, I could just query in my admins.py dynamically.  So how would I access the brkey for that entry in my admins.py (Something like BridgeModel.brkey ?)\nI have tried several different things in my admin.py and have tried the comments suggestion of overwriting the get_fields() method in my admin class, but I am probably syntactically wrong and I am kind of confused what the object it takes exactly is.  Is that the actual entry?  Or is that the individual field?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":84,"Q_Id":28967747,"Users Score":0,"Answer":"I was using Django 1.6 which did not support overriding the get_fields method.  Updated to 1.7 and this method worked perfectly.","Q_Score":1,"Tags":"python,django,django-models,django-admin","A_Id":29432774,"CreationDate":"2015-03-10T15:31:00.000","Title":"Create a dynamic admin site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a little script which picks the best machine out of a few dozen to connect to. It gets a users name and password, and then picks the best machine and gets a hostname. Right now all the script does is print the hostname. What I want is for the script to find a good machine, and open an ssh connection to it with the users provided credentials.\nSo my question is how do I get the script to open the connection when it exits, so that when the user runs the script, it ends with an open ssh connection.\nI am using sshpass.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1186,"Q_Id":28971180,"Users Score":0,"Answer":"If you want the python script to exit, I think your best bet would be to continue doing a similar thing to what you're doing; print the credentials in the form of arguments to the ssh command and run python myscript.py | xargs ssh.  As tdelaney pointed out, though, subprocess.call(['ssh', args]) will let you run the ssh shell as a child of your python process, causing python to exit when the connection is closed.","Q_Score":1,"Tags":"python,ssh","A_Id":28971821,"CreationDate":"2015-03-10T18:17:00.000","Title":"Open SSH connection on exit Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created Odoo v8 PyDev project in Aptana. When I run the openerp server from Aptana, and set a breakpoint in my file product_nk.py, the program does not stop at this break point although I navigated to the Odoo web pages where the functionality is linked to the code with breakpoint. \nWhat am I possibly missing in the setup and what I need to do to have the program stop at the set breakpoint in Python code?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":29017156,"Users Score":1,"Answer":"It could happen if you run your server in \"run\" mode and not \"debug\" mode.\nIf you are in \"run\" mode the breakpoints would be skipped. \nIn Aptana, go to the \"run\" -> \"debug\" to run it in debug mode.","Q_Score":0,"Tags":"python,openerp,aptana,odoo","A_Id":29017479,"CreationDate":"2015-03-12T18:05:00.000","Title":"OpenERP, Aptana - debugging Python code, breakpoint not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a very large dictionary of the following format {str: [0, 0, 1, 2.5, 0, 0, 0, ...], str: [0, 0, 0, 1.1, 0, 0, ...], ...}. The number of elements for each str key can be very big so I need an effective way to store and make calculations over this data. \nFor example right now my dict of str keys has 100 keys. Each key has one value which is a list of 7000 float elements. The length of str keys and values is constant. So, let's say str key is of length 5 and its value (which is a list) is 7000. \nAfter some reading I found that scipy.sparse module has a nice collection of various matrices to store sparse data but scipy documentation is so sparse that I can barely understand what's going on. \nCan you provide an example of how to convert the dictionary above to correct matrix type?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1646,"Q_Id":29018843,"Users Score":1,"Answer":"With standard dict methods you can get a list of the keys, and another list of the values.  Pass the 2nd to numpy.array and you should get a 100 x 7000 array.  The keys list could also be made into array, but it might not be any more useful than the list.  The values array could be turned into a sparse matrix.  But its size isn't exceptional, and arrays have more methods.\nTomorrow I can add sample code if needed.","Q_Score":1,"Tags":"python,numpy,matrix,scipy","A_Id":29026455,"CreationDate":"2015-03-12T19:40:00.000","Title":"How to convert a sparse dict to scipy.sparse matrix in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just installed iPython\/Jupyter and accidentally deleted pictures from a file that was living on my desktop. I don't know how to undo what I just deleted and can't seem to find any of the pictures in my trash. Is there anyway I can recover them? My instance of iPython\/Jupyter is still open.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3792,"Q_Id":29019387,"Users Score":0,"Answer":"Check in the hidden directory \".ipynb_checkpoints\" inside of the directory that used to hold the notebook.\nIf you had recently been running the notebook prior to deleting it, you may be able to find a recent copy of it saved at the last \"checkpoint\".","Q_Score":1,"Tags":"macos,python-3.x,ipython","A_Id":30279651,"CreationDate":"2015-03-12T20:15:00.000","Title":"Accidentally deleted a folder's contents in iPython\/Jupyter and I can recover it from trash on Mac OSX Yosemite. Is there anyway I can get it back?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just installed iPython\/Jupyter and accidentally deleted pictures from a file that was living on my desktop. I don't know how to undo what I just deleted and can't seem to find any of the pictures in my trash. Is there anyway I can recover them? My instance of iPython\/Jupyter is still open.\nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3792,"Q_Id":29019387,"Users Score":1,"Answer":"No, you can't easily recover the files. The files are gone. Your option is to restore from a backup, or use a data recovery tool of some sort.","Q_Score":1,"Tags":"macos,python-3.x,ipython","A_Id":29019518,"CreationDate":"2015-03-12T20:15:00.000","Title":"Accidentally deleted a folder's contents in iPython\/Jupyter and I can recover it from trash on Mac OSX Yosemite. Is there anyway I can get it back?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do the following:\n\nSave numeric data in a CSV-like formatting, with a \".foo\" extension;\nAssociate the \".foo\" file extension with some python script, which in turns opens the .foo file, reads its content, and plots something with a plotting library (matplotlib most probably).\n\nThe use-case would be: double-click the file, and its respective plot pops up right away.\nI wonder how I should write a python script in order to do that. \nBesides, the windows \"open with\" dialog only allows me to choose executables (*.exe). If I choose \"fooOpener.py\", it doesn't work.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":8512,"Q_Id":29041571,"Users Score":5,"Answer":"press the windows key\ntype cmd\nright click the result and choose \"run as administrator\"\nassoc .foo=foofile\nftype foofile=\"C:\\Users\\<user>\\AppData\\Local\\Programs\\Python\\PYTHON~1\\python.exe\" \"C:\\<whatever>\\fooOpener.py\" \"%1\" %*\n\nUse pythonw.exe if it's a .pyw file (to prevent a cmd window from spawning).\nIf you want to use an existing file type, you can find its alias by not assigning anything. For example, assoc .txt returns .txt=txtfile.","Q_Score":17,"Tags":"python,windows,file-extension,file-association","A_Id":63965668,"CreationDate":"2015-03-13T20:40:00.000","Title":"Associate file extension to python script, so that I can open the file by double click, in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I realize this is a fairly basic question, but I couldn't find what I'm looking for through searching (partly because I'm not sure how to summarize what I want). In any case:\nI have a dataframe that has the following columns:\n* ID (each one represents a specific college course)\n* Year\n* Term (0 = fall semester, 1 = spring semester)\n* Rating (from 0 to 5)  \nMy goal is to create another column for Previous Rating. This column would be equal to the course's rating the last time the course was held, and would be NaN for the first offering of the course. The goal is to use the course's rating from the last time the course was offered in order to predict the current semester's enrollment. I am struggling to figure out how to find the last offering of each course for a given row. \nI'd appreciate any help in performing this operation! I am working in Pandas but could move my data to R if that'd make it easier. Please let me know if I need to clarify my question.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1352,"Q_Id":29049985,"Users Score":1,"Answer":"Use this function to create the new column...\nDataFrame.shift(periods=1, freq=None, axis=0, **kwds)\nShift index by desired number of periods with an optional time freq","Q_Score":1,"Tags":"python,pandas,time-series","A_Id":29050296,"CreationDate":"2015-03-14T14:23:00.000","Title":"Pandas Time-Series: Find previous value for each ID based on year and semester","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an arff file as input. I read the arff file and put the element values in a numpy ndarray.Now my arff file contains some '?' as some of the elements. Basically these are property values of matrices calculated by anamod. Whichever values anamod cannot calculate it plugs in a '?' character for those. I want to do a Naive baiyes, Random Forest etc prediction for my data.  So to handle the '?' I want to use an imputer which is like : \nImputer(missing_values='NaN', strategy='mean', axis=0)\nThe  missing_values above is of type string of course. My question is that how to change the type of a few numpy ndarray elements to string from float. I used my_numpy_ndarray.astype('str') == 'NaN' to check for NaN values and I could do it successfully but I am not sure how to change the type of numpyndarray float element to string.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117,"Q_Id":29056302,"Users Score":0,"Answer":"You can't change the type of parts of an ordinary ndarray.  An ndarray requires all elements in the array to have the same numpy type (the dtype), so that mathematical operations can be done efficiently.  The only way to do this is to change the dtype to object, which allows you to store arbitrary types in each element.  However, this will drastically reduce the speed of most operations, and make some operations impossible or unreliable (such as adding two arrays).","Q_Score":1,"Tags":"python,numpy,casting","A_Id":29058672,"CreationDate":"2015-03-15T01:35:00.000","Title":"change the type of numpyndarray float element to string","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using numpy for reading an arff file and I'm getting the following error:\n\nValueError: Input contains NaN, infinity or a value too large for dtype('float64').\n\nI used np.isnan(X2.any()) and np.isfinite(X2.all())to check if it's a nan or infinite case. But it's none of these. This means it's the third case, which is infinity or a value too large for dtype('float64').\nI would appreciate if someone could tell me how to take care of this error.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":26758,"Q_Id":29060962,"Users Score":8,"Answer":"Ok I got it. After i used Imputer(missing_values='NaN', strategy='median', axis=1) imp.fit(X2). I also had to write : \nX2 = imp.fit_transform(X2). The reason being  sklearn.preprocessing.Imputer.fit_transform returns a new array, it doesn't alter the argument array","Q_Score":9,"Tags":"python,numpy,scikit-learn","A_Id":29061597,"CreationDate":"2015-03-15T13:11:00.000","Title":"a value too large for dtype('float64')","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to optimize a pyOpenCL program. For this reason I was wondering if there is a way to profile the program and see where most of the time is needed for.\nDo you have any idea how to approach this problem?\nThanks in advance\nAndi\nEDIT: For example nvidias nvprof for CUDA would do the trick for pyCuda, however, not for pyOpenCL.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2168,"Q_Id":29068229,"Users Score":0,"Answer":"CodeXL from AMD works very well.","Q_Score":5,"Tags":"python,opencl,pyopencl","A_Id":42962569,"CreationDate":"2015-03-16T01:12:00.000","Title":"Is there a way to profile an OpenCL or a pyOpenCL program?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to check that the given email id is really exists or not in smtp server. Is it possible to check or not.? If it possible please give me suggestion how can we do it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1440,"Q_Id":29073907,"Users Score":0,"Answer":"Short of sending an email and having someone respond to it is impossible to verify an email exists.\nYou can verify the SMTP server has a whois address, but thats it.","Q_Score":0,"Tags":"python,email,smtp","A_Id":29073968,"CreationDate":"2015-03-16T09:57:00.000","Title":"How to Check is email exists or not in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a specific requirement where I can use only Ansible in my host machine without vagrant.\nTwo questions associated with it:   \n\nIs it possible to spin up a VM over the host machine with libvirt\/KVM as hypervisor using ansible ? I know there is a module called virt in ansible which is capable of doing this. But I could'nt find any real example of how to use this. Appreciate if someone can point me to the example YAML through which I can spin up VM.   \nWith Ansible, is it possible to run my playbook from python code ? If I am not wrong there is a python API supported by Ansible. But is it possible to give YAML file as input to this API which executes tasks from YAML.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":561,"Q_Id":29079698,"Users Score":2,"Answer":"Of course - if you have SSH access to it.\nYes, you can run Ansible using its Python API or through command-line call. About passing YAML file - also - yes.","Q_Score":1,"Tags":"python,ansible,kvm,libvirt","A_Id":29079838,"CreationDate":"2015-03-16T14:45:00.000","Title":"Spin up VM using Ansible without Vagrant","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Matlab application that writes in to a .csv file and a Python script that reads from it. These operations happen concurrently and at their own respective periods (not necessarily the same). All of this runs on Windows 7.\nI wish to know :\n\nWould the OS inherently provide some sort of locking mechanism so that only one of the two applications - Matlab or Python - have access to the shared file?\nIn the Python application, how do I check if the file is already \"open\"ed by Matlab application? What's the loop structure for this so that the Python application is blocked until it gets access to read the file?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":212,"Q_Id":29085298,"Users Score":0,"Answer":"I am not sure about window's API for locking files\nHeres a possible solution:\n\nWhile matlab has the file open, you create an empty file called \"data.lock\" or something to that effect.\nWhen python tries to read the file, it will check for the lock file, and if it is there, then it will sleep for a given interval.\nWhen matlab is done with the file, it can delete the \"data.lock\" file.\n\nIts a programmatic solution, but it is simpler than digging through the windows api and finding the right calls in matlab and python.","Q_Score":2,"Tags":"python,windows,matlab,file,shared","A_Id":29085388,"CreationDate":"2015-03-16T19:24:00.000","Title":"Shared file access between Python and Matlab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am in the middle of my personal website development and I am using python to create a \"Comment section\" which my visitors could leave comments at there in public (which means, everybody can see it, so don't worry about the user name registration things). I already set up the sql database to store those data but only thing I haven't figured out yet was how to get the user input (their comments) from the browser. So, is there any modules in python could do that? (Like, the \"Charfield\" things in django, but unfortunately I don't use django)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":754,"Q_Id":29088344,"Users Score":0,"Answer":"For that you would need a web framework like Bottle or Flask. Bottle is a simple WSGI based web framework for Python. \nUsing either of these you may write simple REST based APIs, one for set and other for get. The \"set\" one could accept data from your client side and store it on your database where as your \"get\" api should return the data by reading it from your DB.\nHope it helps.","Q_Score":0,"Tags":"python,web-development-server","A_Id":37997045,"CreationDate":"2015-03-16T22:50:00.000","Title":"How I can get user input from browser using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to this so a silly question\nI am trying to make a demo website using Django for that I need a database.. Have downloaded and installed MySQL Workbench for the same. But I don't know how to setup this.\nThank you in advance :)\nI tried googling stuff but didn't find any exact solution for the same.\nPlease help","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1235,"Q_Id":29102422,"Users Score":1,"Answer":"I am a mac user. I have luckily overcome the issue with connecting Django to mysql workbench. I assume that you have already installed Django package created your project directory e.g. mysite.\n\nInitially after installation of MySQL workbench i have created a database : create database djo;\nGo to mysite\/settings.py and edit following piece of block.\nNOTE: Keep Engine name \"django.db.backends.mysql\" while using MySQL server. \nand STOP the other Django MySQL service which might be running.\n\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.\n        'NAME': 'djo',                      # Or path to database file if using sqlite3.\n        # The following settings are not used with sqlite3:\n        'USER': 'root',\n        'PASSWORD': '****',       # Replace **** with your set password.\n        'HOST': '127.0.0.1',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.\n        'PORT': '3306',                      # Set to empty string for default.\n    }\n}\n\nnow run manage.py to sync your database :\n$ python mysite\/manage.py syncdb\nbash-3.2$ python manage.py syncdb\nCreating tables ...\nCreating table auth_permission\nCreating table auth_group_permissions\nCreating table auth_group\nCreating table auth_user_groups\nCreating table auth_user_user_permissions\nCreating table auth_user\nCreating table django_content_type\nCreating table django_session\nCreating table django_site\n\nYou just installed Django's auth system, which means you don't have any superusers defined.\nWould you like to create one now? (yes\/no): yes\nUsername (leave blank to use 'ambershe'): root\nEmail address: ambershe@netapp.com\n\/Users\/ambershe\/Library\/Containers\/com.bitnami.django\/Data\/app\/python\/lib\/python2.7\/getpass.py:83: GetPassWarning: Can not control echo on the terminal.\n  passwd = fallback_getpass(prompt, stream)\nWarning: Password input may be echoed.\nPassword: ****\nWarning: Password input may be echoed.\nPassword (again): ****\nSuperuser created successfully.\nInstalling custom SQL ...\nInstalling indexes ...\nInstalled 0 object(s) from 0 fixture(s)","Q_Score":0,"Tags":"python,mysql,django,eclipse,pydev","A_Id":29493720,"CreationDate":"2015-03-17T14:56:00.000","Title":"Connect MySQL Workbench with Django in Eclipse in a mac","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I create a virtualenv name as ScrapyProject. when I use scrapy command or pip command it does not work but when I enter the python command it works. Here is how he shows me.\n\n(ScrapyProject) C:\\Users\\Jake\\ScrapyProject>scrapy\n(ScrapyProject) C:\\Users\\Jake\\ScrapyProject>pip\n(ScrapyProject) C:\\Users\\Jake\\ScrapyProject>python\npython2.7.6 etc.\n\nHere is how my paths are in virtualenv.\nC:\\Users\\Jake\\ScrapyProject\\Scripts;Then some windows paths then some python paths There is not extra spaces between them I am sure! and here is how my python paths look;C:\\python27;C:\\Python27\\Lib\\site-packages\nCan anybody help me If he needs some extra information, I will give you? I totally didnot understand it!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":29114480,"Users Score":0,"Answer":"You need to pip install all the set-up within the virtualenv.","Q_Score":0,"Tags":"python-2.7,scrapy,virtualenv,virtualenvwrapper","A_Id":29121164,"CreationDate":"2015-03-18T05:02:00.000","Title":"Commands not working in ScrapyProject","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Basically, what is a Futures on Tornado's approach?\nI've read on some stackoverflow threads that a tornado coroutine must return a Future, but returning a Future how do my db queries work?\nUsing Futures will my Tornado app be waiting for the query to return anything like a blocking i\/o or it will just dispatch the request and change the context until the query return?\nAnd this Motorengine solution? Do I need to use Futures or just make the queries?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":29124446,"Users Score":0,"Answer":"You need to understand how Tornado works asynchronously. Everytime you yield a Future object, Tornado suspends current coroutine and jumps to the next coroutine. Doing queries synchronous or asynchronous depends on the situation. If your query is fast enough, you can use synchronous driver. Also, keep in mind, jumping between coroutines has a cost, too. If it is not fast enough, you might consider doing asychronous calls.","Q_Score":0,"Tags":"python,mongodb,tornado","A_Id":29156089,"CreationDate":"2015-03-18T14:16:00.000","Title":"Do I need to use Tornado Futures with Motorengine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a text file of size 2.5 GB which contains hash values of some standard known files. My task is to find the hash of all files on my file system and compare it with the hashes stored in the text file. If a match is found I need to print Known on the screen and if no match is found then I need to print unknown on  the screen.\nThus the approach for the task is quite simple but the main issue is that the files involved in the process are very huge.\nCan somebody suggest how to accomplish this task in an optimized way.\nShould I import the text file containing hashes to a database. If yes, then please provide some link which could possibly help me accomplish it.\nSecondly what algorithm can I use for searching to speed up the process?\nMy preferred language is Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":62,"Q_Id":29137043,"Users Score":0,"Answer":"Search on StackOverflow for code to recursively list full file names in Python\nSearch on StackOverflow for code to return the hash checksum of a file\n\nThen list files using an iterator function. Inside the loop:\n\nGet the hash checksum of the current file in the loop\nIterate through every hash. Inside the loop:\n\nCompare with the current file's checksum\n\n\nAlgorithms? Don't worry about it. If you iterate through each line of the file, it will be fine. Just don't load it all at once, and don't load it into a data structure such as a list or dictionary because you might run out of memory.","Q_Score":0,"Tags":"python,hash","A_Id":29137224,"CreationDate":"2015-03-19T04:05:00.000","Title":"Perform searching on very large file programatically in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working with the Mean Shift clustering algorithm, which is based on the kernel density estimate of a dataset. I would like to generate a large, high dimensional dataset and I thought the Scikit-Learn function make_blobs would be suitable. But when I try to generate a 1 million point, 8 dimensional dataset, I end up with almost every point being treated as a separate cluster. \nI am generating the blobs with standard deviation 1, and then setting the bandwidth for the Mean Shift to the same value (I think this makes sense, right?). For two dimensional datasets this produced fine results, but for higher dimensions I think I'm running into the curse of dimensionality in that the distance between points becomes too big for meaningful clustering. \nDoes anyone have any tips\/tricks on how to get a good high-dimensional dataset that is suitable for (something like) Mean Shift clustering? (or am I doing something wrong? (which is of course a good possibility))","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":681,"Q_Id":29148746,"Users Score":1,"Answer":"The standard deviation of the clusters isn't 1.\nYou have 8 dimensions, each of which has a stddev of 1, so you have a total standard deviation of sqrt(8) or something like that.\nKernel density estimation does not work well in high-dimensional data because of bandwidth problems.","Q_Score":1,"Tags":"python,scikit-learn,cluster-analysis,mean-shift","A_Id":29149537,"CreationDate":"2015-03-19T15:32:00.000","Title":"Generating high dimensional datasets with Scikit-Learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm not sure what exactly the wording for the problem is so if I haven't been able to find any resource telling me how to do this, that's most likely why.\nThe basic problem is that I have a webcrawler, coded in Python, that has a 'Recipe' object that stores certain data about a specific recipe such as 'Name', 'Instructions', 'Ingredients', etc. with 'Instructions' and 'Ingredients' being a string array.\nNow, the problem I have comes when I want to store this data in a database for access from other sources.\nA basic example of the database looks as follows:\n(Recipes)\nr_id, name, ....\n(Ingredients)\ni_id, name, ....\n(RecipeIngredients)\nr_id, i_id.\nNow, specifically my problem is, how do I make sure I'm not duplicating ingredients and how do I insert the data so that the ingredient is linked to the id of the current Recipe object?\nI know my explanation is bad but I'm struggling to put it into words. Any help is appreciated, thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":29170268,"Users Score":0,"Answer":"For the first question (how do I make sure I'm not duplicating ingredients?), if I understand well, is basically put your primary key as (i_id, name) in the table ingredients. This way you guarantee that is impossible insert an ingredient with the same key (i_id, name).\nNow for the second question (how do I insert the data so that the ingredient is linked to the id of the current Recipe object?). I really don't understand this question very well. What I think you want is link the recipes with ingredients. This can be made with the table RecipeIngredients. When you want to do that, you simple insert a new row in that table with the id of the recipe and the id of the ingredient. If isn't this what you want sorry, but I really don't understand.","Q_Score":0,"Tags":"python,sql","A_Id":29170744,"CreationDate":"2015-03-20T15:33:00.000","Title":"Inserting data into SQL database that needs to be linked","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using a python program on 2 different computers.\n\nOn computer 1 some path (e.g., to an image or something), used by the program, is, say, a\/b\/\nOn computer 2, the equivalent path is different, say, b\/a\/ (the image, e.g., is in a different folder)\n\nWhen I want to run the script on computer 1 I pull the code and set the path to a\/b\/. Then I make changes and push.\nThen I go to computer 2 and pull. Now the path is a\/b\/ but actually I want the pull to not change the path (all the rest should change though of course).\nQ1:\nIs there a way to automatically do this (prevent the changes in the path)? Also I keep getting merge conflicts just due to the path being different.\nQ2: I might not even be doing this in an optimal way, how do people do this? My procedure could be wrong causing these issues.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":29178949,"Users Score":1,"Answer":"Absolute paths that depend on your specific computer do not belong in version control. A good solution would be to have your program read an environment variable and use it as the path. Make sure to set a sensible default if the environment variable is unset.","Q_Score":1,"Tags":"python,git","A_Id":29179099,"CreationDate":"2015-03-21T03:37:00.000","Title":"Ignore part of file in git when using on 2 different computers (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a simple script that uses audio files to talk a user through a process. When the user has finished the current step, it should stop trying to explain that step and move into the next. This is easy to do, except that it sounds very ugly and unnatural when the audio stops mid-word.\nI've noticed in Grand Theft Auto 5, when a character is talking and something unexpected happens, the audio pauses between words and then resumes at the beginning of the sentence a few seconds later -- which sounds very natural, because that's how people really speak.\nI'd like to find a way to do this with my script. It doesn't need to resume at the beginning of the sentence, because it's responding the the user being ready to move on, but I'd like it to somehow find the spaces between words and pause there. Is there a simple way to do this in Python, or maybe an easier way to do it in something else, assuming that it's not simple in Python?\nEdit: The audio has yet to be recorded, so if there's some way I should record it to make this happen, I can do that. I'm aware that GTA5 had a team of programmers, and I'm just one guy making a simple script -- but it seems like there should be a simple solution, like something that looks for silence in the audio, or maybe marking the spaces between words by hand?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":100,"Q_Id":29186447,"Users Score":0,"Answer":"I dont't know how you recorded your text but if you call every word in an other line you can type import time at line 1 and and then after every audio file you could set time.sleep(0.3) (0.3 stands for 0.3 seconds). but that may take a while. it would be useful to see your code. so can you send it maybe?","Q_Score":0,"Tags":"python,audio","A_Id":29192486,"CreationDate":"2015-03-21T18:30:00.000","Title":"python - stop audio between words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Okay, so I am brand new at this and I really need for this to be dumbed down for me. My python version is 2.7.9 and I downloaded pygame-1.9.1.win32-py2.7.msi and I am on a windows computer. I really need someone to explain why this is not working. I was reading on some of the other questions that you have to change the path of python and I have no idea how to do that. I am literally screwed because I have to turn something in for a major grade and I have literally been trying to figure this out for like about four weeks now.\nWhen I try to import pygame, I get this error message and I have absolutely no idea what I am doing wrong:\n\nTraceback (most recent call last):   File\n  \"C:\\Users\\Tiffany\\Documents\\NetBeansProjects\\NewPythonProject\\src\\newpythonproject.py\",\n  line 3, in \n      import pygame ImportError: No module named pygame","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3786,"Q_Id":29190350,"Users Score":0,"Answer":"There is only really only one way to do this:\n\nCreate a folder\nPut the Python Interpreter you are using in that folder\nPut the PyGame module you are using in that same folder\n\nAnd your problem is now solved. I hope this helps you!","Q_Score":0,"Tags":"python-2.7,pygame,importerror","A_Id":29221166,"CreationDate":"2015-03-22T02:39:00.000","Title":"ImportError: No module named pygame and how to change the path of pygame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Background\nI am working on a program that needs to find a list of open Metro apps. I originally tried using pure python with ctypes and using win32 api. Unfortunately, I couldn't get the names of Metro apps. So I moved on to IronPython thinking I could leverage a .net function or two to get what I want. No luck.\nWhere I am at\nI can easily get a list of running processes and their PID, but filtering the Metro apps from the non-metro apps is proving near impossible. Also, I need to get the HWND of that window so I can interact with it.\nWhat Won't Work\nEnumWindows doesn't seem to work. FindWindowEx seems promising, but I am not sure how to do this.\nThanks in advance.\nEDIT: I am now able to get what I want using IsImmersiveProcess, but the process list is doesn't include the Windows Apps.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":121,"Q_Id":29197996,"Users Score":0,"Answer":"I don't think MS  allows this functionality. As an alternative, you can have the user put their mouse over the window and press a keyboard shortcut (What I am doing). \nThat is the best one can do.","Q_Score":0,"Tags":"c#,python,windows-8,windows-store-apps,ironpython","A_Id":29978493,"CreationDate":"2015-03-22T18:11:00.000","Title":"IronPython-List Open Metro Apps only","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want my users to be able to login using all common OpenIds. But there seems to be a forest of clauses on how to use logos from google, facebook, yahoo and twitter.\nActually I'd prefer a wider button with the text on it, but it seems that all these buttons don't have the aspect ratio. And some of them I am not allowed to scale. \nAlso some pages switched to javascript buttons which seems incredibly stupid, because that causes the browser to download all the javascripts and the page looks like 1990 where you can watch individual elements loading.\nSo finally I surrendered and went for the stackoverflow approach of using square logos with the text \"login with\" next to them. But now I can't find an official source for a square yahoo icon.\nThe question: Can you recommend any articles or do you have any tipps on how to make OpenId look uniform?\nAnd: Have you seen an official source for a square Icon that I'm allowed to use?\nPS: I'm using python-social-auth for Django.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":29208955,"Users Score":0,"Answer":"You could simply use the yahoo site's favicon. It's already squared and gets as close to official as it can get.","Q_Score":0,"Tags":"oauth,openid,python-social-auth","A_Id":30144643,"CreationDate":"2015-03-23T11:20:00.000","Title":"How to make most common OpenID logins look the same?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hello i want to install these dependencies in OpenShift for my App\nyum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libffi-devel libxslt libxslt-devel libxml2 libxml2-devel openldap-devel libjpeg-turbo-devel openjpeg-devel libtiff-devel libyaml-devel python-virtualenv git libpng12 libXext xorg-x11-font-utils\nBut don't know how, is it through rhc? if so, how?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":461,"Q_Id":29221836,"Users Score":0,"Answer":"You can not use the \"yum\" command to install packages on OpenShift.  What specific issue are you having? I am sure that at least some of those packages are already installed in OpenShift online already (such as wget).  Have you tried running your project to see what specific errors you get about what is missing?","Q_Score":0,"Tags":"python,openshift","A_Id":29236634,"CreationDate":"2015-03-23T22:44:00.000","Title":"How to install dependencies in OpenShift?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After successful installation of Anaconda on Windows 7 I realized the default Python version is 2.7.8. However I need 2.7.9. So how do I upgrade?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6678,"Q_Id":29232101,"Users Score":0,"Answer":"Install newest version of Anaconda from their website. This will upgrade your Anaconda and python as well. Also, uninstall the previous version of Anaconda.","Q_Score":6,"Tags":"python,windows,anaconda","A_Id":43085233,"CreationDate":"2015-03-24T11:58:00.000","Title":"How do I upgrade python 2.7.8 to 2.7.9 in Anaconda without conflicting other components in its environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"the current code I have is category1[name]=(number) however if the same name comes up the value in the dictionary is replaced by the new number how would I make it so instead of the value being replaced the original value is kept and the new value is also added, giving the key two values now, thanks.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10467,"Q_Id":29246687,"Users Score":0,"Answer":"a key only has one value, you would need to make the value a tuple or list etc\nIf you know you are going to have multiple values for a key then i suggest you make the values capable of handling this when they are created","Q_Score":5,"Tags":"python,python-2.7,dictionary,key","A_Id":29246758,"CreationDate":"2015-03-25T02:58:00.000","Title":"How to add to python dictionary without replacing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create an asynchronous application using Python's asyncio module. However, all implementations I can find on the documentation is based on a single Event Loop.\nIs there any way to launch multiple Event Loops running the same application, so I can achieve high availability and fault tolerance? In other words, I want to scale-out my application by inserting new nodes that would share the execution of coroutines behind a load balancer.\nI understand there is an inherent issue between asynchronous programming and thread-safety, perhaps what I have in mind isn't even possible. If so, how to avoid this kind of SPOF on asynchronous architectures?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1433,"Q_Id":29252233,"Users Score":3,"Answer":"The standard way to deal with this is by starting multiple server processes (each with its own event loop), with a load balancer in front. Each such process typically cannot utilize more than one CPU core, so you might want to have as many processes as you have cores.","Q_Score":6,"Tags":"python,python-3.x,asynchronous,python-asyncio","A_Id":29729638,"CreationDate":"2015-03-25T09:47:00.000","Title":"High availability for Python's asyncio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how can we find out the number of calendar weeks in a year? \nI didn't find a function in the standard library. \nI then thought about date(year, 12, 31).isocalendar()[1], but\n\nFor example, 2004 begins on a Thursday, so the first week of ISO year 2004 begins on Monday, 29 Dec 2003 and ends on Sunday, 4 Jan 2004, so that date(2003, 12, 29).isocalendar() == (2004, 1, 1) and date(2004, 1, 4).isocalendar() == (2004, 1, 7).","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7322,"Q_Id":29262859,"Users Score":3,"Answer":"You're almost there, take the date of Dec. 28. If there is a monday after that, it will only have 3 days in the old year and hence be week 1 of the new year.","Q_Score":6,"Tags":"python,date","A_Id":29263021,"CreationDate":"2015-03-25T17:46:00.000","Title":"The number of calendar weeks in a year?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently tried to re-install numpy for python 3.4, since I got a new computer, and am struggling. I am on windows 8.1, and from what I remember I previously used a .exe file that did everything for me. However, this time I was given a .whl file (apparently this is a \"Wheel\" file), which I cannot figure out how to install.\nOther posts have explained that I have to use PIP, however the explanations of how to install these files that I have been able to find are dreadful. The command \"python install pip\" or \"pip install numpy\" or all the other various commands I have seen only return an error that \"python is not recognized as an internal or external command, operable program or batch file\", or \"pip is not recognised as an internal....\" ect.\nI have also tried \"python3.4\", \"python.exe\" and many others since it does not like python. The file name of the numpy file that I downloaded is \"numpy-1.9.2+mkl-cp34-none-win_amd64.whl\".\nSo can anybody give me a Detailed tutorial of how to use these, as by the looks of things all modules are using these now. Also, why did people stop using .exe files to install these? It was so much easier!","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":22006,"Q_Id":29284282,"Users Score":8,"Answer":"See the easiest solution is to unzip the .whl file using 7-zip. Then in the unzipped directory you will find the module which you can copy and paste in the directory C:\/Python34\/Lib\/site-packages\/ (or wherever else you have installed Python).","Q_Score":5,"Tags":"python,numpy,module","A_Id":33483629,"CreationDate":"2015-03-26T16:48:00.000","Title":"How to install in python 3.4 - .whl files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I recently tried to re-install numpy for python 3.4, since I got a new computer, and am struggling. I am on windows 8.1, and from what I remember I previously used a .exe file that did everything for me. However, this time I was given a .whl file (apparently this is a \"Wheel\" file), which I cannot figure out how to install.\nOther posts have explained that I have to use PIP, however the explanations of how to install these files that I have been able to find are dreadful. The command \"python install pip\" or \"pip install numpy\" or all the other various commands I have seen only return an error that \"python is not recognized as an internal or external command, operable program or batch file\", or \"pip is not recognised as an internal....\" ect.\nI have also tried \"python3.4\", \"python.exe\" and many others since it does not like python. The file name of the numpy file that I downloaded is \"numpy-1.9.2+mkl-cp34-none-win_amd64.whl\".\nSo can anybody give me a Detailed tutorial of how to use these, as by the looks of things all modules are using these now. Also, why did people stop using .exe files to install these? It was so much easier!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":22006,"Q_Id":29284282,"Users Score":6,"Answer":"Python 3.4 comes with PIP already included in the package, so you should be able to start using PIP immediately after installing Python 3.4. Commands like pip install <packagename> only work if the path to PIP is included in your path environment variable. If it's not, and you'd rather not edit your environment variables, you need to provide the full path. The default location for PIP in Python 3.4 is in C:\\Python34\\Scripts\\pip3.4.exe. If that file exists there (it should), enter the command C:\\Python34\\Scripts\\pip3.4.exe install <numpy_whl_path>, where <numpy_whl_path> is the full path to your numpy .whl file. For example: C:\\Python34\\Scripts\\pip3.4.exe install C:\\Users\\mwinfield\\Downloads\\numpy\u20111.9.2+mkl\u2011cp34\u2011none\u2011win_amd64.whl.","Q_Score":5,"Tags":"python,numpy,module","A_Id":29286276,"CreationDate":"2015-03-26T16:48:00.000","Title":"How to install in python 3.4 - .whl files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I just got my raspberry pi yesterday and have gone through all the setup and update steps required to enable the camera extension (which took me like 6 hrs; yes, I am a newbie). \nI need to create a focus point on the camera's output and use the arrow keys to move this point around the screen. \nMy question is how to access the pixel addresses in order to achieve this (if that is even how to do it). Please can one of you gurus out there point me in the right direction.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1081,"Q_Id":29290361,"Users Score":0,"Answer":"You do realise that the Pi Camera board has a fixed focus at 1m to infinity ?\n& If you want focus <1m you're gonna have to manually twist the lens, after removing the glue that fixates it in the housing.","Q_Score":0,"Tags":"python,camera,raspberry-pi","A_Id":29363197,"CreationDate":"2015-03-26T22:57:00.000","Title":"A focus point on the raspberry pi camera","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just got my raspberry pi yesterday and have gone through all the setup and update steps required to enable the camera extension (which took me like 6 hrs; yes, I am a newbie). \nI need to create a focus point on the camera's output and use the arrow keys to move this point around the screen. \nMy question is how to access the pixel addresses in order to achieve this (if that is even how to do it). Please can one of you gurus out there point me in the right direction.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1081,"Q_Id":29290361,"Users Score":0,"Answer":"If you need to take close-ups or if you are capturing image very close to camera lens then you need to manually set the focus.","Q_Score":0,"Tags":"python,camera,raspberry-pi","A_Id":38924580,"CreationDate":"2015-03-26T22:57:00.000","Title":"A focus point on the raspberry pi camera","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use a library which is available from python 2.7 onwards on a system with python 2.4. I cannot upgrade the system to python 2.7, as many other libraries and softwares are written in python 2.4.\nFor instance, i want to use the xml.eTree library in python 2.4.\nCan i take the source code of that library and do few changes and compile it on 2.4 ? If yes, could you please tell how to proceed?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":29298191,"Users Score":0,"Answer":"You don't need to upgrade the system Python. Install your own local version of 2.7 into your home directory, create a virtualenv using that version, and install your libraries there.","Q_Score":1,"Tags":"python,xml-parsing,python-2.4","A_Id":29298306,"CreationDate":"2015-03-27T10:14:00.000","Title":"how to use a library that's compiled for python 2.7 in python 2.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I have both Pycharm and Anaconda installed on my computer and I would like to upgrade the package Pandas to the latest version (i have the 0.14 version)\nUnfortunately my computer has strong firewall restrictions and I am not able to use the internet to update it. I can download the source files though.\nIs there a way to install the package manually? I use win 7 64 by the way\nMany thanks!!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1167,"Q_Id":29307829,"Users Score":1,"Answer":"If you are using conda, use the --offline flag when installing the conda package that you downloaded, like conda install --offline pandas-0.15.2-np19py27.tar.bz2.","Q_Score":1,"Tags":"python,python-2.7,pandas,pycharm,anaconda","A_Id":29353457,"CreationDate":"2015-03-27T18:34:00.000","Title":"how to update a Python package (Pandas) manually?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"An application wants to shell text out to vim and know what edits are being made, in real time.\nThe .swp file provides this information. Can anyone provide guidance on how to read this binary file, say, with Python?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2549,"Q_Id":29317107,"Users Score":0,"Answer":"Thanks everyone who replied.\nI hoped .swp would be documented, maybe even code available to access it, seems not.\nThe suggestion to write a plugin in Python probably makes the most sense, I bet it's possible to hook to something like 'on_keystroke' and maintain a mirror I can understand.\n'shell out' as in 'write this chunk of text to a temp file, open that file in vim, when vim exits, write the temp file contents to a replacement chunk of text'  \nPS: $100 is way too much to shell out for those tickets","Q_Score":3,"Tags":"python,vim","A_Id":29332655,"CreationDate":"2015-03-28T12:24:00.000","Title":"What is the structure of a vim .swp file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"An application wants to shell text out to vim and know what edits are being made, in real time.\nThe .swp file provides this information. Can anyone provide guidance on how to read this binary file, say, with Python?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":2549,"Q_Id":29317107,"Users Score":1,"Answer":"I wouldn't rely on the swapfile contents to get real-time updates. Its format is geared towards Vim's uses, and its format isn't documented other than by its implementation. You would have to duplicate large parts of the algorithm, and maintain that whenever the internal format changes (without prior notice).\nAlternatively, I would use one of the embedded languages (e.g. Python) to interface with the outside program that wants to get real-time updates. A Python function could periodically send along the entire buffer contents on a socket, for example.","Q_Score":3,"Tags":"python,vim","A_Id":29321744,"CreationDate":"2015-03-28T12:24:00.000","Title":"What is the structure of a vim .swp file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"In PTVS the default behavior is for the program to print to the Python console window and the Visual Studio Debug Output window.\nRealizing that it won't be able to accept user input, how do I suppress the Python console window?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":9244,"Q_Id":29319546,"Users Score":0,"Answer":"Use the Python Interactive Window (CTRL-ALT-F8 or Debug Menu). You will have the code output on the python interactive shell (where you can obviously interact). The win terminal will not appear anymore.","Q_Score":12,"Tags":"python,visual-studio,ptvs","A_Id":47253726,"CreationDate":"2015-03-28T16:27:00.000","Title":"How do I suppress the console window when debugging python code in Python Tools for Visual Studio (PTVS)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":0.0428309231,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":3,"Answer":"It looks that some files are still left and some registry keys are left. So you can run revocleaner tool to remove those entries as well. Do a reboot and install again it should be doing it now.\nI also faced issue and by complete cleaning I got Rid of it.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":50202529,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":1.0,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":18,"Answer":"If a clean re-install\/uninstall did not work, this is because the Anaconda install is still listed in the registry.\n\nStart -> Run -> Regedit\nNavigate to HKEY_CURRENT_USER -> Software -> Python\nYou may see 2 subfolders, Anaconda and PythonCore. Expand both and check the \"Install Location\" in the Install folder, it will be listed on the right.\nDelete either or both Anaconda and PythonCore folders, or the entire Python folder and the Registry path to install your Python Package to Anaconda will be gone.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":45360960,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":0.0428309231,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":3,"Answer":"For windows-\n\nIn the Control Panel, choose Add or Remove Programs or Uninstall a program, and then select Python 3.6 (Anaconda) or your version of Python.\nUse Windows Explorer to delete the envs and pkgs folders prior to Running the uninstall in the root of your installation.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":61464989,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":1.0,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":7,"Answer":"To use Uninstall-Anaconda.exe in C:\\Users\\username\\Anaconda3  is a good way.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":48980402,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":0.0142847425,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":1,"Answer":"Uninstall Anaconda from control Panel\nDelete related folders, cache data and configurations from Users\/user\nDelete from AppData folder from hidden list\nTo remove start menu entry -> Go to C:\/ProgramsData\/Microsoft\/Windows\/ and delete Anaconda folder or search for anaconda in start menu and right click on anaconda prompt -> Show in Folder option.\nThis will do almost cleaning of every anaconda file on your system.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":58889740,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":0.0428309231,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":3,"Answer":"there is a start item folder in C:\\ drive. Remove ur anaconda3 folder there, simple and you are good to go. In my case I found here \"C:\\Users\\pravu\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\"","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":63536711,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":0.0428309231,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":3,"Answer":"On my machine (Win10), the uninstaller was located at C:\\ProgramData\\Anaconda3\\Uninstall-Anaconda3.exe.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":56087895,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":0.0142847425,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":1,"Answer":"Go to C:\\Users\\username\\Anaconda3 and search for Uninstall-Anaconda3.exe which will remove all the components of Anaconda.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":54453907,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":1.0,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":19,"Answer":"In my computer there wasn't a uninstaller in the Start Menu as well. But it worked it the Control Panel > Programs > Uninstall a Program, and selecting Python(Anaconda64bits) in the menu.\n(Note that I'm using Win10)","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":37898464,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":1.0,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":184,"Answer":"In the folder where you installed Anaconda (Example: C:\\Users\\username\\Anaconda3) there should be an executable called Uninstall-Anaconda.exe. Double click on this file to start uninstall Anaconda.\nThat should do the trick as well.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":39490516,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":1.0,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":8,"Answer":"Anaconda comes with an uninstaller, which should have been installed in the Start menu.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":29377301,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":1.2,"is_accepted":true,"ViewCount":368077,"Q_Id":29337928,"Users Score":15,"Answer":"Since I didn't have the uninstaller listed - the solution turned out to be to reinstall Anaconda and then uninstall it.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":29377433,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7.\nI removed Anaconda and deleted all the directories and installed python 2.7.\nBut when I go to install PyGTK for Windows it says it will install it to the c:\/users\/...\/Anaconda directory - this doesn't even exist. I want to install it to the c:\/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","AnswerCount":14,"Available Count":13,"Score":0.057080742,"is_accepted":false,"ViewCount":368077,"Q_Id":29337928,"Users Score":4,"Answer":"Method1:\nTo uninstall Anaconda3 go to the Anaconda3 folder, there u will be able to find an executable called Uninstall-Anaconda3.exe, double click on it. This should uninstall ur application.\nThere are times when the shortcut of anaconda command prompt,jupyter notebook, spyder, etc exists, so delete those files too. \nMethod2 (Windows8):\nGo to control panel->Programs->Uninstall a Program and then select Anaconda3(Python3.1. 64-bit)in the menu.","Q_Score":102,"Tags":"python,windows,anaconda","A_Id":56794491,"CreationDate":"2015-03-30T03:25:00.000","Title":"How to remove anaconda from windows completely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Context\nMy app relies on external service for authentication, python API has function authentiate_request witch takes\nrequest instance as a param, and returns result dict:\n\nif auth was successful, dict contains 3 keys:\n\nsuccessful: true\nusername: alice\ncookies: [list of set-cookie headers required to remember user]\n\nif unsuccessful:\n\nsuccessful: false\nredirect: url where to redirect user for web based auth\n\n\nNow, call to this function is relatively expensive (is does HTTP POST underneath).\nQuestion\nI'm new to Pyramid security model, and I'm struggling how to use existing\/properly write AuthenticationPolicy for my app, so it uses my auth service, and does not call it's API more than once per session (In auth success scenario)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":29341688,"Users Score":0,"Answer":"There are two broad ways to do integrate custom auth with Pyramid:\n- write your own authentication policy for Pyramid (I haven't done this)\n- write your own middleware to deal with your auth issues, and use the RemoteUserAuthenticationPolicy in Pyramid (I have done this)\nFor the second, you write some standard wsgi middleware, sort out your custom authentication business in there, and then write to the wsgi env. Pyramid authorization will then work fine, with the Pyramid auth system getting the user value from the wsgi env's 'REMOTE_USER' setting. \nI personally like this approach because it's easy to wrap disparate apps in your middleware, and dead simple to turn it off or swap it out. While not really the answer to exactly what you asked, that might be a better approach than what you're trying.","Q_Score":1,"Tags":"python,authentication,pyramid","A_Id":32814226,"CreationDate":"2015-03-30T08:38:00.000","Title":"How to use external Auth system in Pyramid","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We need to get the count of each key (the keys are not known before executing), and do some computation dynamically in each Mapper. The key count could be global or only in each Mapper. What is the best way to implement that? In Hadoop this is similar to an aggregator function.\nThe accumulator in Spark needs to be defined before the Mapper jobs run. But we do not know what and how many keys are there.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":110,"Q_Id":29358494,"Users Score":0,"Answer":"You can use pairRDD.countByKey() function for counting the rows according their keys.","Q_Score":0,"Tags":"java,python,hadoop,mapreduce,apache-spark","A_Id":29516550,"CreationDate":"2015-03-31T00:14:00.000","Title":"Get the count of each key in each Mapper or globally in Spark MapReduce model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Please suggest me on the following.\nHow to find whether a particular day is weekday or weekend in Python?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":91511,"Q_Id":29384696,"Users Score":26,"Answer":"Use the date.weekday() method. Digits 0-6 represent the consecutive days of the week, starting from Monday.","Q_Score":56,"Tags":"python,python-2.7,python-3.x","A_Id":29384723,"CreationDate":"2015-04-01T06:58:00.000","Title":"how to find current day is weekday or weekends in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a very basic python script which uses boto to query the state of my EC2 instances. When I run it from console, it works fine and I'm happy. The problem is when I want to add some automation and run the script via crond. I notices that the script hangs and waits indefinitely for the connection. I saw that boto has this problem and that some people suggested to add some timeout value to boto config file. I couldn't understand how and where, I added manually \/etc\/boto.cfg file with the suggested timeout value (5) but it didn't help. With strace you can see that this configuration file is never being accessed. Any suggestions how to resolve this issue?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":774,"Q_Id":29395946,"Users Score":1,"Answer":"The entire issue appeared to be HTTP_PROXY environment variable. The variable was set in \/etc\/bashrc and all users got it this way but when cron jobs ran (as root) \/etc\/bashrc wasn't read and the variable wasn't set. By adding the variable to the configuration file of crond (via crontab -e) the issue was solved","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,cron,boto","A_Id":29407280,"CreationDate":"2015-04-01T16:23:00.000","Title":"Connection with boto to AWS hangs when running with crond","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am SSHed into a remote machine and I do not have rights to download python packages but I want to use 3rd party applications for my project. I found cx_freeze but I'm not sure if that is what I need.\nWhat I want to achieve is to be able to run different parts of my project (will mains everywhere) with command line arguments on the remote machine. My project will be filled with a few 3rd party python packages. Not sure how to get around this as I cannot pip install and am not a sudoer. I can SCP files to the remote machine","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":33,"Q_Id":29397839,"Users Score":1,"Answer":"It is basically useless if you don't have executable permission in the remote machine. You need to contact your administrator to obtain an executable permission.\nIn the case for the SCP files to the remote server, you may still be able to cp you files but you may not be able to execute it.","Q_Score":0,"Tags":"python","A_Id":29398092,"CreationDate":"2015-04-01T18:11:00.000","Title":"Using 3rd party packages on remote machine without download\/install rights","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got a problem in calculating permutations. The program needs to generate\npermutations(xrange(num), num)) and for each permutation I have to count the number of consecutive primes. i.e sum of every adjacent two digits in the number should be a prime.\nmax value 'num' would be 18\nprimes = permutations(xrange(1,num+1), num)\nfor val in primes:\n    for x in range(0,len(val-1)):\n        if (prime(val[x] + val[x+1])):\n             num_primes += 1\nif the 'num' range from 10 to 18, it is giving a response message of \n'killed' after a long waiting. please help me to solve this..","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":198,"Q_Id":29443218,"Users Score":1,"Answer":"There are 6402373705728000 permutations of 18 elements so it takes years to iterate over them. It should be better to think of an analytic solution for this problem.","Q_Score":0,"Tags":"algorithm,python-2.7","A_Id":29443892,"CreationDate":"2015-04-04T05:46:00.000","Title":"how to avoid memory error in generating and processing python permutations?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have 3 sets of comparison data(y axes) which needs to be plotted against a target source values. I'm comparing exports, gdp, standard of living values of different countries against a target countries values for different years. But values of each category are haphazard i.e exports in millions of dollars, gdp in percentage and standard of living scale of 1 to 10. Moreover I have years value for comparison as well.\nWhat I want to see is over the years how different parameters for each country over different years vary against the target country parameters. All of this plotted in one graph in plotly.\nI can plot multiple y axes in plotly, but the scale doesn't match.\nHas anyone any suggestions how to fit all the comparison in one layout. Maybe this is more of a graphing suggestion needed rather than help in plotly? Any ideas how to squeeze all in one graph?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":925,"Q_Id":29445943,"Users Score":1,"Answer":"Full disclosure, I work for Plotly.\nHere's my shot at summarizing your problem in general, you've got 4 dimensions for each country (year, exports, gdp, standard of living).\nYou might be able to use either or both of these solutions:\n\nvisualize this in two dimensions using x-value, y-value, marker-size, and marker-line-size (a bubble chart in 2d)\nvisualize this in three dimensions using x-value, y-value, z-value, and marker-size\n\nI'll leave a link to a notebook in the comments, but since it's not a very permanent link, I won't include it in the answer here.","Q_Score":0,"Tags":"python,graph,plotly","A_Id":29460131,"CreationDate":"2015-04-04T11:38:00.000","Title":"graph of multiple y axes in plotly","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an issue that I can't seem to find a solution within python.  \nFrom command line I can do this by:\nsed '1,\/COMMANDS\/d' \/var\/tmp\/newFile\nThis delete everything from line #1 till regex \"COMMANDS\".  Simple\nBut I can't do the same with Python that I can find.\nThe re.sub and multiline doesn't seem to work.\nSo I have a question how can I do this in a pythonic way?  I really rather not run sed from within python unless I have to.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1429,"Q_Id":29452879,"Users Score":0,"Answer":"Set a flag false.\nIterate over each line. \nFor each line,\n1) When you match your pattern, set a flag.\n2) If the flag is currently set set, print the line.","Q_Score":2,"Tags":"python,regex","A_Id":29452916,"CreationDate":"2015-04-05T00:28:00.000","Title":"Python delete lines of text line #1 till regex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing my bachelor's thesis where I wrote a program that is distributed over many servers and exchaning messages via IPv6 multicast and unicast. The network usage is relatively high but I think it is not too high when I have 15 servers in my test where there are 2 requests every second that are going like that:\nServer 1 requests information from server 3-15 via multicast. every of 3-15 must respond. if one response is missing after 0.5 sec, the multicast is resent, but only the missing servers must respond (so in most cases this is only one server)\nServer 2 does exactly the same. If there are missing results after 5 retries the missing servers are marked as dead and the change is synced with the other server (1\/2)\nSo there are 2 multicasts every second and 26 unicasts every second. I think this should not be too much?\nServer 1 and 2 are running python web servers which I use to do the request every second on each server (via a web client)\nThe whole szenario is running in a mininet environment which is running in a virtual box ubuntu that has 2 cores (max 2.8ghz) and 1GB RAM. While running the test, i see via htop that the CPUs are at 100% while the RAM is at 50%. So the CPU is the bottleneck here.\nI noticed that after 2-5 minutes (1 minute = 60 * (2+26) messages = 1680 messages) there are too many missing results causing too many sending repetitions while new requests are already coming in, so that the \"management server\" thinks the client servers (3-15) are down and deregisters them. After syncing this with the other management server, all client servers are marked as dead on both management servers which is not true...\nI am wondering if the problem could be my debug outputs? I am printing 3-5 messages for every message that is sent and received. So that are about (let's guess it are 5 messages per sent\/recvd msg) (26 + 2)*5 = 140 lines that are printed on the console.\nI use python 2.6 for the servers.\nSo the question here is: Can the console output slow down the whole system that simple requests take more than 0.5 seconds to complete 5 times in a row? The request processing is simple in my test. No complex calculations or something like that. basically it is something like \"return request_param in [\"bla\", \"blaaaa\", ...] (small list of 5 items)\"\nIf yes, how can I disable the output completely without having to comment out every print statement? Or is there even the possibility to output only lines that contain \"Error\" or \"Warning\"? (not via grep, because when grep becomes active all the prints already have finished... I mean directly in python)\nWhat else could cause my application to be that slow? I know this is a very generic question, but maybe someone already has some experience with mininet and network applications...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":29461480,"Users Score":0,"Answer":"I finally found the real problem. It was not because of the prints (removing them improved performance a bit, but not significantly) but because of a thread that was using a shared lock. This lock was shared over multiple CPU cores causing the whole thing being very slow.\nIt even got slower the more cores I added to the executing VM which was very strange...\nNow the new bottleneck seems to be the APScheduler... I always get messages like \"event missed\" because there is too much load on the scheduler. So that's the next thing to speed up... :)","Q_Score":0,"Tags":"python,performance,networking,cpu,mininet","A_Id":29502719,"CreationDate":"2015-04-05T19:44:00.000","Title":"Console output consuming much CPU? (about 140 lines per second)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The question I have as the title says is on the idea of setting up a graph in pygame that graphs sub-pixel coordinates. \nSomething a friend and I spoke of was how I could try to make a function graphing program for fun in python, and I thought about how I could use it, but I found a few issues. \nThe first one was the use of range, due to it using integers and not floats, but arange from numpy fixed that problem, but that brings me to the second issue. \nThe idea for the graph I thought about so that it would be simple, not making massive thick lines or odd shaped one, is that it uses display.set_at to make a single pixel a color. And for simple graphs, this works perfectly. But when I went into more complicated graphs, I ran into two main errors: \n\nThe first error is that the graph shows pixels without any line between them, the idea of the line was the illusion of having all of the pixels near each other. But I found that with a range step of one in range, it leaves this gap. In theory, using arange with a step of .01, the gaps would vanish all together, but this brings to the second problem.\nThe display.set_at does not work with sub-pixel coordinates. Would anyone be able to suggest a way to make this work? It would be most appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":312,"Q_Id":29484408,"Users Score":0,"Answer":"Instead of setting each individual pixel, use pygame's line drawing function to draw a line from the current coordinate to the next instead of using sub-pixel coordinates (pygame.draw.line or even pygame.draw.lines).\nThis way, the \"gaps\" between two points are filled; no need for sub-pixel coordinates.\nYou just have to draw the lines in the right order; just ensure the coordinates are sorted.\n\nOther than that, you could also simple convert your sub-pixel coordinates by casting the x\/y values to integers.","Q_Score":0,"Tags":"python,numpy,pygame","A_Id":29488142,"CreationDate":"2015-04-07T05:29:00.000","Title":"Pygame, sub-pixel coordinates.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to display graphs offered by the bokeh library in my web application via django framework but I don't want to use the bokeh-server executable because it's not the good way. so is that possible? if yes how to do that?","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":15838,"Q_Id":29508958,"Users Score":2,"Answer":"It must put {{the_script|safe}} inside the head tag","Q_Score":31,"Tags":"django,python-2.7,django-templates,bokeh","A_Id":32680856,"CreationDate":"2015-04-08T07:53:00.000","Title":"how to embed standalone bokeh graphs into django templates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When an exception is raised in the application that is not accounted for (an uncaught\/unhandled exception), it should be logged. I would like to test this behaviour in behave.\nThe logging is there to detect unhandled exceptions so developers can implement handling for these exceptions or fix them if needed.\nIn order to test this, I think I have to let the code under test raise an exception. The problem is that I cannot figure out how to do that without hard-coding the exception-raising in the production code. This is something I like to avoid as I do not think this test-code belongs in production.\nWhile unit-testing I can easily mock a function to raise the exception. In behave I cannot do this as the application is started in another process.\nHow can I cause an exception to be raised in behave testing, so it looks as if the production code has caused it, without hard-coding the exception in the production code?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":557,"Q_Id":29515509,"Users Score":0,"Answer":"Regadless to framework\/programming language exception is a state when something went wrong. This issue has to be handled somehow by the application, that's why a good programmer will write exception handling code in places where it needed at most.\nException handling can be everything. In your case you want to test that exception is logged. Therefore I see the an easy test sequence here:\n\nExecute the code\/sequence of actions which will rase the exception\nVerify that log file has an entry related to the exception raised in previous step with help of your test automation framework.","Q_Score":4,"Tags":"python-2.7,exception,testing,exception-handling,python-behave","A_Id":29516346,"CreationDate":"2015-04-08T13:06:00.000","Title":"How to test uncaught\/unhandled exceptions in behave?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a program that streams my screen to another computer(like TeamViewer), I'm using sockets, PIL ImageGrab, Tkinter.\nEverything is fine but the screenshot I get from ImageGrab.grab() is without the mouse cursor, which is very important for my program purpose.\nDo you know how can I take screenshot with the mouse cursor?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2661,"Q_Id":29524885,"Users Score":3,"Answer":"The cursor isn't on the same layer as the desktop or game your playing, so a screenshot won't capture it (try printscreen and paste into mspaint). A workaround is to get the position of the cursor and draw it on the image. you could use win32gui.GetCursorPos(point) for windows.","Q_Score":6,"Tags":"python,screenshot,python-imaging-library","A_Id":29624597,"CreationDate":"2015-04-08T20:37:00.000","Title":"Include mouse cursor in screenshot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am making a game for a presentation and I cannot seem to understand how to make a delay in Python.\nFor example, whenever I press the D key, my character not only moves but also changes pictures so it looks like it's running.\nI have the movement part down, I just need to slow down the changing of the sprite so that it doesn't look like he's running a million miles per hour. I have set the FPS.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":29526895,"Users Score":0,"Answer":"The command turtle.down() will work, I guess","Q_Score":1,"Tags":"python,pygame","A_Id":29527035,"CreationDate":"2015-04-08T23:09:00.000","Title":"How Do you make a delay in python without stoping the whole program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to write a script to access data on a website, such as:\n1) automatically searching a youtuber's profile for a new posting, and printing the title of it to stdout.\n2) automatically posting a new video, question, or comment to a website at a specified time. For a lot of sites, there is a required login, so that is something that would need to be automated as well.\nI would like to able to do all this stuff from the command line.\nWhat set of tools should I use for this? I was intending to use Bash, mostly because I am in the process of learning it, but if there are other options, like Python or Javascript, please let me know.\nIn a more general sense, it would be nice to know how to read and directly interact with a website's JS; I've tried looking at the browser console, but I can't make much sense of it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":29541619,"Users Score":1,"Answer":"Python or Node (JS) will probably be a lot easier for this task than Bash, primarily because you're going to have to do OAuth to get access to the social network.\nOr, if you're willing to get a bit \"hacky\", you could issue scripts to PhantomJS, and automate the interaction with the sites in question...","Q_Score":0,"Tags":"javascript,python,bash,youtube,command-line-interface","A_Id":29541704,"CreationDate":"2015-04-09T14:40:00.000","Title":"How to interact with social websites (auto youtube posting, finding titles of new videos etc.) from the command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a python script to get some basic system stats. I am using psutil for most of it and it is working fine except for one thing that I need. \nI'd like to log the average cpu wait time at the moment. \nfrom top output it would be in CPU section under %wa. \nI can't seem to find how to get that in psutil, does anyone know how to get it? I am about to go down a road I really don't want to go on.... \nThat entire CPU row is rather nice, since it totals to 100 and it is easy to log and plot. \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1680,"Q_Id":29548735,"Users Score":1,"Answer":"%wa is giving your the iowait of the CPU, and if you are using times = psutil.cpu_times() or times = psutil.cpu_times_percent() then it is under the times.iowait variable of the returned value (Assuming you are on a Linux system)","Q_Score":1,"Tags":"python,psutil,iowait","A_Id":29548863,"CreationDate":"2015-04-09T20:51:00.000","Title":"Get IO Wait time as % in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to program an application that runs a HTTP server as well as a GUI using Tornado and PyQt4 respectively.  I am confused about how to use these two event loops in parallel. Can this be done with the multiprocessing module? Should the HTTP server be run in a QtThread? Or is a bash script the best way to go to run both of these processes at the same time?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":757,"Q_Id":29551003,"Users Score":0,"Answer":"You won't need a bash script. Probably simplest to write a PyQt application and have the application launch the web server. The server may be in a separate thread or process depending on your requirements, but I'd start by having a single thread as a first draft and splitting it out later.\nHaving the PyQt app as your main thread makes sense as your GUI is going to be responsible for user inputs (start\/stop server, etc) and program outputs (server status, etc) and therefore it makes sense to make this the controlling thread with references to other objects or threads.","Q_Score":0,"Tags":"python,bash,qt,pyqt,tornado","A_Id":29551539,"CreationDate":"2015-04-09T23:49:00.000","Title":"How can I combine PyQt4 and Tornado's event loops into one application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am trying to build a GUI which will:\n\nLoad a file with parameters which describe certain type of problem.\nBased on the parameters of the file, show only certain tab in QTabwidget (of many predefined in Qt Designer .ui)\n\nI plan to make a QTabwidget with, say 10 tabs, but only one should be visible based on the parameters loaded. Enabling certain tab is not an option since it takes to many space and the disabled tabs are grey. I do not want to see disabled tabs.\nRemoving tab could be an option but the index is not related to a specific tab so I have to take care of the shift in the indices. And furthermore if user loads another file with different parameters, a good tab should be added and the current one removed.\nMy questions are:\n\nHow to do this effectively?\nIs it better to use any other type of widget?\nIn Qt designer, is it possible to define many widgets one over another and then just push the good one in front. If yes, how? And how to edit and change any of them?\nIf using RemoveTab, how to use pointers on tabs, rather than indices?\n\nI use PyQt4","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7611,"Q_Id":29560307,"Users Score":0,"Answer":"I see that this thread is kinda old. But I hope this will still help.\nYou can use the remove() method to \"hide\" the tab. There's no way to really hide them in pyqt4. when you remove it, it's gone from the ui. But in the back end, the tab object with all your settings still exist. I'm sure you can find a way to improvise it back. Give it a try!","Q_Score":1,"Tags":"python,pyqt,qt-designer,qtabwidget","A_Id":44781276,"CreationDate":"2015-04-10T11:28:00.000","Title":"PyQT Qtabwidget add, remove, hide, show certain tab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My google searching has failed me. I'd like to know how to make an executable Python file on OS X, that is, how to go about making an .exe file that can launch a Python script with a double click (not from the shell). For that matter I'd assume the solution for this would be similar between different scripting languages, is this the case?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":17211,"Q_Id":29584270,"Users Score":1,"Answer":"You can run python scripts through OS X Terminal. You just have to write a python script with an editor, open your Terminal and enter python path_to_my_script\/my_script.py","Q_Score":8,"Tags":"python,macos,exe","A_Id":29584289,"CreationDate":"2015-04-11T23:33:00.000","Title":"How do you make a Python executable file on Mac?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7. \nHow do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":29584840,"Users Score":0,"Answer":"I have found that making the 'python' alias replace the default version of python that the system comes with is a bad idea.\nWhen you install a new version of python (3.4 for instance), \nthese two new commands are installed, specifically for the version you installed:\npip3.4\npython3.4\nIf you're using an IDE that wants you to indicate which python version you are using the IDE will let you navigate to it in the Library folder\npip will still be for python2.7 after you download some other python version, as I think that's the current version osx comes installed with","Q_Score":0,"Tags":"macos,python-3.x","A_Id":37517408,"CreationDate":"2015-04-12T01:10:00.000","Title":"I don't know how to update my Python version to 3.4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7. \nHow do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":29584840,"Users Score":0,"Answer":"Try python3 or python3.4. It should print out the right version if correctly installed.\nPython 3.4 already has pip with it. You can use python3 -m pip to access pip. Or python3 -m ensurepip to make sure that it's correctly installed.","Q_Score":0,"Tags":"macos,python-3.x","A_Id":29584868,"CreationDate":"2015-04-12T01:10:00.000","Title":"I don't know how to update my Python version to 3.4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to make custom user models, my question is about style and best practices.\nWhat are the consequences of custom user model in Django? Is it really better to use auxiliary one-to-one model? \nAnd for example if I have a UserProfile models which is one-to-one to User, should I create friends relationship (which would be only specific to my app) between UserProfile or between User? \nAlso all 3rd-party packages rely on get_user_model(), so looks like if I don't use custom user model, all your relations should go to User, right? But I still can't add methods to User, so if User has friends relation, and I want to add recent_friends method, I should add this method to UserProfile. This looks a bit inconsistent for me.\nI'd be glad if someone experienced in Django could give a clear insight.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":138,"Q_Id":29595382,"Users Score":1,"Answer":"Also all 3rd-party packages rely on get_user_model(), so looks like if I don't use custom user model, all your relations should go to User, right? But I still can't add methods to User, so if User has friends relation, and I want to add recent_friends method, I should add this method to UserProfile.\n\nI have gone down the \"one-to-one\" route in the past and I ended up not liking the design of my app at all, it seems to me that it forces you away from SOLID. So if I was you I would rather subclass AbstractBaseUser or AbstractUser.\nWith AbstractBaseUser you are provided just the core implementation of User and then you can extend the model according to your requirements.\nDepending on what sort of 3rd-party packages you are using you might need more than just the core implementation: if that's the case just extend AbstractUser which lets you extend the complete implementation of User.","Q_Score":0,"Tags":"python,django,django-models,django-orm","A_Id":29596796,"CreationDate":"2015-04-12T22:27:00.000","Title":"Custom user model in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I know how to make custom user models, my question is about style and best practices.\nWhat are the consequences of custom user model in Django? Is it really better to use auxiliary one-to-one model? \nAnd for example if I have a UserProfile models which is one-to-one to User, should I create friends relationship (which would be only specific to my app) between UserProfile or between User? \nAlso all 3rd-party packages rely on get_user_model(), so looks like if I don't use custom user model, all your relations should go to User, right? But I still can't add methods to User, so if User has friends relation, and I want to add recent_friends method, I should add this method to UserProfile. This looks a bit inconsistent for me.\nI'd be glad if someone experienced in Django could give a clear insight.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":138,"Q_Id":29595382,"Users Score":1,"Answer":"I would definitely recommend using a custom user model - even if you use a one-to-one with a profile. It is incredibly hard to migrate to a custom user model if you've committed to the default user model, and there's almost always a point where you want to add at least some custom logic to the user model.\nWhether you use a profile or further extend the user model should then be based on all considerations that usually apply to your database structure. The right\u2122  decision depends on the exact details of your profile, which only you know.","Q_Score":0,"Tags":"python,django,django-models,django-orm","A_Id":29595803,"CreationDate":"2015-04-12T22:27:00.000","Title":"Custom user model in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am expecting the following code will return 0 but I get -3600, could someone explains why? and how to fix it? thanks \n\n  import datetime\n  import time\n  ts = time.mktime(time.gmtime(0))\n  print time.mktime(datetime.datetime.fromtimestamp(ts).timetuple())","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":709,"Q_Id":29596204,"Users Score":2,"Answer":"time.mktime converts a time tuple in local time to seconds since the Epoch.  Since time.gmtime(0) returns GMT time tuple, and the conversion assumes it was in your local time, you see this discrepancy.","Q_Score":2,"Tags":"python,datetime,epoch,mktime","A_Id":29596282,"CreationDate":"2015-04-13T00:21:00.000","Title":"how to make time.mktime work consistently with datetime.fromtimestamp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a PostgreSQL db. Pandas has a 'to_sql' function to write the records of a dataframe into a database. But I haven't found any documentation on how to update an existing database row using pandas when im finished with the dataframe.\nCurrently I am able to read a database table into a dataframe using pandas read_sql_table. I then work with the data as necessary. However I haven't been able to figure out how to write that dataframe back into the database to update the original rows.\nI dont want to have to overwrite the whole table. I just need to update the rows that were originally selected.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11070,"Q_Id":29607222,"Users Score":0,"Answer":"For sql alchemy case of read table as df, change df, then update table values based on df, I found the df.to_sql to work with name=<table_name> index=False if_exists='replace'\nThis should replace the old values in the table with the ones you changed in the df","Q_Score":25,"Tags":"python,postgresql,pandas","A_Id":68004057,"CreationDate":"2015-04-13T14:01:00.000","Title":"Update existing row in database from pandas df","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I can't figure out how to get \"any text\" from the string any text [monkey bars][fancy swing][1002](special)\nafter a lot of trying I've made (.*)[\\(*]|[\\[*] but it doesn't seem to work very well\nI'm using the python regex engine","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":29615953,"Users Score":0,"Answer":"Use the regexp ^[^[]* to match everything up to the first [.","Q_Score":0,"Tags":"python,regex","A_Id":29615982,"CreationDate":"2015-04-13T22:11:00.000","Title":"can't find substring in regex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to execute several shell scripts with python, some scripts would export environment parameters, so I need to execute them in the same process, otherwise, other scripts can't see the new environment parameters\nin one word, I want to let the shell script change the environment of the python process\nso I should not use subprocess, any idea how to realize it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1004,"Q_Id":29621193,"Users Score":1,"Answer":"What if you make a 'master' shell script that would execute all the others in sequence? This way you'll only have to create a single sub-process yourself, and the individual scripts will share the same environment. \nIf, however, you would like to interleave script executions with Python code, then you would probably have to make each of the scripts echo its environment to stdout before exiting, parse that, and then pass it into the next script (subprocess.Popen() accepts the env parameter, which is a map.)","Q_Score":0,"Tags":"python,shell","A_Id":29621377,"CreationDate":"2015-04-14T07:08:00.000","Title":"how to execute shell script in the same process in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to execute several shell scripts with python, some scripts would export environment parameters, so I need to execute them in the same process, otherwise, other scripts can't see the new environment parameters\nin one word, I want to let the shell script change the environment of the python process\nso I should not use subprocess, any idea how to realize it?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1004,"Q_Id":29621193,"Users Score":1,"Answer":"No, you cannot run more than one program (bash, python) in the same process at the same time.  \nBut you can run them in sequence using exec in bash or one of the exec commands in python, like os.execve.  Several things survive the \"exec boundary\", one  of which is the environment block.  So in each bash script you exec the next, and finally exec your python.\nYou might also consider using an IPC mechanism like a named pipe to pass data between processes.\nI respectfully suggest that you look at your design again.  Why are you mixing bash and python?  Is it just to reuse code?  Even if you managed this you will end with a real mess.  It is generally easier to stick with one language.","Q_Score":0,"Tags":"python,shell","A_Id":29621636,"CreationDate":"2015-04-14T07:08:00.000","Title":"how to execute shell script in the same process in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am attempting to create a program that can find the best solution for winning a game using NN and I was hoping to get some help from the wonderful community here.\nThe game is a strategy war game, you have your soldiers and a land you need to conquer. There is also the opponent's soldiers you need to be aware from them,\nfor every second you have a land in your possession you get a certain amount of points.\nyou have a lot of inputs that the engine writer created that you have access for example: where all the lands located on the map, where the other's opponent soldiers right now, if the land is already conquered or in the middle of conquering.\nI've already integrated the ANN in the game engine and set the fitness to be the points he collected but the fitness stays on nothing+1,\ni assume that the problem is that to capture a land you need to stay next to it for few seconds and i can't get him to learn how to do it the fitness stays on 1\nI've tried a big population and a lot of generations but its not conquering and i dont know what to do.\nsorry for my bad english.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":29647683,"Users Score":0,"Answer":"Since I can't comment yet I will just answer taking some assumptions.\n(I'm also starting to experiment with NN and GA in Python too (MultiNEAT), so not an expert either ;) )\n\nThe problem could be poor feedback to the genetic algorithm, so it can't select the best individuals. Try making your fitness score more fine grained, for example, making that every little movement towards an enemy soldier increases a little the fitness, instead of just scoring based on final points.\nWhat are your network outputs? Maybe the network's results are not being passed onto the game properly. I would make, for example, the output neurons targeting movement for soldiers and maybe some for reactions in case of proximity (I don't really know the game's mechanics). If you have a limited amount of possible answers from the network, it could be possible that those are just not enough to win the game, so no network can really score better.\nAre you waiting long enough? The bigger the problem, the more time it will take to find an answer, specially in slow computers. Try using the GPU to implement the Genetic algorithm to speed up the evaluations of networks, if speed proves to be an issue.\n\nGood luck.","Q_Score":0,"Tags":"python,neural-network,genetic-algorithm","A_Id":30931808,"CreationDate":"2015-04-15T10:21:00.000","Title":"Defining inputs and fitness in ANN with GA Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a codebase that includes both python2 and python3 code.  I want to make one script that will run pylint on all python2 and all python3 files, ideally from within a single virtualenv.\nI can figure out which version of pylint to run by annotating the directories (eg, adding a .pylint3 file to directories that need the python3 pylint to run or something like that).  However, I don't know how to install two separate versions of pylint side by side, either in the OS as a whole or in a virtualenv, without doing some manual annoying stuff.  \nIs there a good way to get two versions of pylint running side by side in the same virtualenv?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3773,"Q_Id":29662290,"Users Score":1,"Answer":"Usually python modules for different major versions don't interfer with each other. The only problem is utilities. So the recipe is as follows:\n\nCreate a virtual environment for a python2, then go to the bin\/ folder of the created environment and rename all created scripts\/wrappers\/binaries so that all of them would have suffix 2\nRepeat the creation of the virtual env. in the same directory but for python3. Again, go to the bin\/ subfolder of the created virtual environment and rename all newly created scripts to have suffix 3.\nMake sure that all hashbangs in the scripts call an apropriate python version.\nNow you should source <virtenv>\/bin\/activate as the docs suggest\nAnd now you may install pylint in the virtual env, you need to repeat the procedure for both python2 and python3, again separating the binaries in <virtualenv>\/bin\/. Use pip2 and pip3 or python2 -m pip...\/python3 -m pip... for that.\n\nI haven't installed pylint, but have an environment prepared for both python2 and python3 with a bunch of python utilities like bpython (called as bpython2 and bpython3 respectively, pygmentize etc). I don't think pylint is something different in this aspect.","Q_Score":2,"Tags":"python,virtualenv,pylint","A_Id":29663226,"CreationDate":"2015-04-15T22:49:00.000","Title":"How to install pylint for python2 and python3 side by side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm about to start working on a project where a Python script is able to remote into a Windows Server and read a bunch of text files in a certain directory. I was planning on using a module called WMI as that is the only way I have been able to successfully remotely access a windows server using Python, But upon further research I'm not sure i am going to be using this module.\nThe only problem is that, these text files are constantly updating about every 2 seconds and I'm afraid that the script will crash if it comes into an MutEx error where it tries to open the file while it is being rewritten. The only thing I can think of is creating a new directory, copying all the files (via script) into this directory in the state that they are in and reading them from there; and just constantly overwriting these ones with the new ones once it finishes checking all of the old ones. Unfortunately I don't know how to execute this correctly, or efficiently.\nHow can I go about doing this? Which python module would be best for this execution?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":693,"Q_Id":29704766,"Users Score":0,"Answer":"I've done some work with WMI before (though not from Python) and I would not try to use it for a project like this. As you said WMI tends to be obscure and my experience says such things are hard to support long-term.\nI would either work at the Windows API level, or possibly design a service that performs the desired actions access this service as needed. Of course, you will need to install this service on each machine you need to control. Both approaches have merit. The WinAPI approach pretty much guarantees you don't invent any new security holes and is simpler initially. The service approach should make the application faster and required less network traffic. I am sure you can think of others easily.\nYou still have to have the necessary permissions, network ports, etc. regardless of the approach. E.g., WMI is usually blocked by firewalls and you still run as some NT process.\nSorry, not really an answer as such -- meant as a long comment.\nADDED\nRe: API programming, though you have no Windows API experience, I expect you find it familiar for tasks such as you describe, i.e., reading and writing files, scanning directories are nothing unique to Windows. You only need to learn about the parts of the API that interest you.\nOnce you create the appropriate security contexts and start your client process, there is nothing service-oriented in the, i.e., your can simply open and close files, etc., ignoring that fact that the files are remote, other than server name being included in the UNC name of the file\/folder location.","Q_Score":1,"Tags":"python,windows,file,wmi,remote-access","A_Id":29705179,"CreationDate":"2015-04-17T16:30:00.000","Title":"python copying directory and reading text files Remotely","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"The generated HTML page works fine for text. But\n\ndoes not find the file and displays the alt text instead. I know the HTML works because \"view source\" in the browser can be copied into a file, which then works locally when the .jpg is in the same directory.\nOn the remote site, the .jpg file is in the same directory as the Python program that generated the HTML, and this is the directory where the Python process is running. Clearly this process is looking for the file (it shows the alt); how do I find where it is looking, so I can put the file there? I would rather have a local reference than an absolute one elsewhere on the Web, to improve performance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":29713533,"Users Score":0,"Answer":"No, your python process does not care about the JPG at all. It just generates html asking the browser to fetch the JPG. Then it's the browser, fetching the JPG by making another request to the webserver.\nTherefore it is very likely that your python script needs to live in a different directory than the JPG. Have a look on your web server log. You should see two requests. One for the HTML and one for the JPG.","Q_Score":0,"Tags":"python,html","A_Id":29713745,"CreationDate":"2015-04-18T03:10:00.000","Title":"My Python program generates an HTML page; how do I display a .jpg that's in the same directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to use some aggregate data in my django application that changes frequently and if I do the calculations on the fly some performance issues may happen. Because of that I need to save the aggregate results in a table and, when data changes, update them. Because I use django some options may be exist and some maybe not. For example I can use django signals and a table that, when post_save signal is emitted, updates the results. Another option is materialized views in postgresql or indexed views in MSSQL Server, that I do not know how to use in django or if django supports them or not. What is the best way to do this in django for improving performance and accuracy of results.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6549,"Q_Id":29716972,"Users Score":14,"Answer":"You can use Materialized view with postgres. It's very simple. \n\nYou have to create a view with query like CREATE MATERIALIZED VIEW\nmy_view as select * from my_table;\nCreate a model with two\noption managed=false and db_name=my_view in the model Meta like\nthis\nMyModel(models.Model):\n     class Meta:\n            managed = False\n            db_table='my_view'\nSimply use powers of ORM and treat MyModel as a regular model. e.g. MyModel.objects.count()","Q_Score":13,"Tags":"python,sql-server,django,database,postgresql","A_Id":55397481,"CreationDate":"2015-04-18T11:54:00.000","Title":"using materialized views or alternatives in django","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm working on creating a browser-based game in Django and Python, and I'm trying to come up with a solution to one of the problems I'm having.\nEssentially, every second, multiple user variables need to be updated. For example, there's a currency variable that should increase by some amount every second, progressively getting larger as you level-up and all of that jazz.\nI feel like it's a bad idea to do this with cronjobs (and from my research, other people think that too), so right now I'm thinking I should just create a thread that loops through all of the users in the database that performs these updates.\nAm I on the right track here, or is there a better solution? In Django, how can I start a thread the second the server starts? \nI appreciate the insight.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":782,"Q_Id":29721897,"Users Score":2,"Answer":"One of the possible solutions would be to use separate daemonized lightweight python script to perform all the in-game business logic and left django be just the frontend to your game. To bind them together you might pick any of high-performance asynchronous messaging library like ZeroMQ (for instance to pass player's actions to that script). This stack would also have a benefit of a frontend being separated and completely agnostic of a backend implementation.","Q_Score":3,"Tags":"python,django","A_Id":29722220,"CreationDate":"2015-04-18T19:35:00.000","Title":"Django\/Python - Updating the database every second","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm starting out with rethinkdb in python, and taking a look at the different approaches:\n\nBlocking approach with threads\nNon-blocking, callback-based approach with Tornado\nGreenlet-based approach with gevent\n\nIn the first case, the natural thing to do is to give each thread a connection object. In the second and third cases, however, I don't quite get it.\nWith tornado and gevent, how and when should I create connections? How many should I have around?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":373,"Q_Id":29723704,"Users Score":5,"Answer":"If you're using a non-blocking library, one connection should be sufficient in RethinkDB 2.0 (prior to 2.0 there was less per-connection parallelism).  Per-connection overhead is pretty low, though.  Some people open a connection per query and even that isn't too slow, so you should just do whatever's easiest.\nEDIT: This advice is now outdated.  For newer versions of RethinkDB using one connection per query is strongly discouraged.  One connection per thread is still fine.","Q_Score":3,"Tags":"python,tornado,gevent,rethinkdb","A_Id":29727792,"CreationDate":"2015-04-18T22:37:00.000","Title":"RethinkDB: how many connections?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use the Magento Custom Menu extension in a django project.\nI have modified the menucontent.phtml, but yet my menu items are not reflecting the appropriate captions.\nDoes anyone know how does the extension work to generate the menu?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":29726821,"Users Score":0,"Answer":"Ok. Great. I found the issue. I had not noticed another javascript line at the end of my html file's  tag. so I am home and dry.  Cheers.","Q_Score":0,"Tags":"php,python-2.7,magento-1.9","A_Id":29727058,"CreationDate":"2015-04-19T07:02:00.000","Title":"Magento 1.9 Custom Menu Extension Use in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My use case is this: I have 10 spiders and the AUTO_THROTTLE_ENABLED setting is set to True, globally. The problem is that for one of the spiders the runtime WITHOUT auto-throttling is 4 days, but the runtime WITH auto-throttling is 40 days... \nI would like to find a balance and make the spider run in 15 days (3x the original amount). I've been reading through the scrapy documentation this morning but the whole thing has confused me quite a bit. Can anyone tell me how to keep auto-throttle enabled globally, and just turn down the amount to which it throttles?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":5769,"Q_Id":29754112,"Users Score":1,"Answer":"set DOWNLOAD_DELAY = some_number where some_number is the delay (in seconds) you want for every request and RANDOMIZE_DOWNLOAD_DELAY = False so it can be static.","Q_Score":1,"Tags":"python,web-scraping,scrapy","A_Id":29783461,"CreationDate":"2015-04-20T17:08:00.000","Title":"How to Set Scrapy Auto_Throttle Settings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My use case is this: I have 10 spiders and the AUTO_THROTTLE_ENABLED setting is set to True, globally. The problem is that for one of the spiders the runtime WITHOUT auto-throttling is 4 days, but the runtime WITH auto-throttling is 40 days... \nI would like to find a balance and make the spider run in 15 days (3x the original amount). I've been reading through the scrapy documentation this morning but the whole thing has confused me quite a bit. Can anyone tell me how to keep auto-throttle enabled globally, and just turn down the amount to which it throttles?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":5769,"Q_Id":29754112,"Users Score":1,"Answer":"Auto_throttle is specifically designed so that you don't manually adjust DOWNLOAD_DELAY. Setting the DOWNLOAD_DELAY to some number will set an lower bound, meaning your AUTO_THROTTLE will not go faster than the number set in DOWNLOAD_DELAY. Since this is not what you want, your best bet would be to set AUTO_THROTTLE to all spiders except for the one you want to go faster, and manually set DOWNLOAD_DELAY for just that one spider without AUTO_THROTTLE to achieve whatever efficiency you desire.","Q_Score":1,"Tags":"python,web-scraping,scrapy","A_Id":33189665,"CreationDate":"2015-04-20T17:08:00.000","Title":"How to Set Scrapy Auto_Throttle Settings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running Scrapy 0.24.4, and have encountered quite a few sites that shut down the crawl very quickly, typically within 5 requests. The sites return 403 or 503 for every request, and Scrapy gives up. I'm running through a pool of 100 proxies, with the RotateUserAgentMiddleware enabled.\nDoes anybody know how a site could identify Scrapy that quickly, even with the proxies and user agents changing? Scrapy doesn't add anything to the request headers that gives it away, does it?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3256,"Q_Id":29758554,"Users Score":1,"Answer":"It appears that the primary problem was not having cookies enabled. Having enabled cookies, I'm having more success now. Thanks.","Q_Score":1,"Tags":"python,web-scraping,scrapy","A_Id":30086257,"CreationDate":"2015-04-20T21:15:00.000","Title":"Scrapy crawl blocked with 403\/503","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running Scrapy 0.24.4, and have encountered quite a few sites that shut down the crawl very quickly, typically within 5 requests. The sites return 403 or 503 for every request, and Scrapy gives up. I'm running through a pool of 100 proxies, with the RotateUserAgentMiddleware enabled.\nDoes anybody know how a site could identify Scrapy that quickly, even with the proxies and user agents changing? Scrapy doesn't add anything to the request headers that gives it away, does it?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3256,"Q_Id":29758554,"Users Score":0,"Answer":"I simply set AutoThrottle_ENABLED to True and my script was able to run.","Q_Score":1,"Tags":"python,web-scraping,scrapy","A_Id":72128238,"CreationDate":"2015-04-20T21:15:00.000","Title":"Scrapy crawl blocked with 403\/503","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed the Python IDE Spyder. For me it's a great development environment.\nSome how in this process I have managed to install three versions of Python on my system.These can be located as following:\n\nVersion 2.7.6 from the OS X Terminal;\nVersion 2.7.8 from the Spyder Console; and\nVersion 2.7.9rc1 from an IDL window.\n\nThe problem I have is (I think) that the multiple versions are preventing Spyder from working correctly.\nSo how do I confirm that 2.7.6 is the latest version supported by Apple and is there a simple way ('silver bullet') to remove other versions from my system.\nI hope this is the correct forum for this question. If not I would appreciate suggestions where I could go for help. \n\nI want to keep my life simple and to develop python software in the Spyder IDE. I am not an OS X guru and I really don't want to get into a heavy duty command line action. To that end I just want to delete\/uninstall the 'unofficial versions' of Python. Surely there must be an easy way to do this - perhaps 'pip uninstall Python-2.7.9rc1' or some such. The problem is that I am hesitant to try this due to the fear that it will crash my system.\nHelp on this would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":9789,"Q_Id":29761728,"Users Score":3,"Answer":"(Spyder dev here) There is no simple way to do what you ask for, at least for the Python version that comes with Spyder.\nI imagine you downloaded and installed our DMG package. That package comes with its own Python version as part of the application (along with several important scientific packages), so it can't be removed because that would imply to remove Spyder itself :-)\nI don't know how you installed IDL(E?), so I can't advise you on how to remove it.","Q_Score":4,"Tags":"python,spyder,osx-yosemite","A_Id":29841327,"CreationDate":"2015-04-21T02:17:00.000","Title":"How to uninstall and\/or manage multiple versions of python in OS X 10.10.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am trying to install a package called 'numpy'. \ni have python setup in eclipse luna with the help of pydev.\nhow do i install numpy in pydev. \ntried putting numpy in site-packages folder. doesnt seem to work","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16056,"Q_Id":29765250,"Users Score":0,"Answer":"Pandas can be installed after install python in to your pc. \nto install pandas go to command prompt and type \"pip install pandas\" this command collecting packages related to pandas. After if it asking to upgrade pip or if pip is not recognized by the command prompt use this command:\npython -m pip install --upgrade pip.","Q_Score":1,"Tags":"python,eclipse,numpy,pydev","A_Id":59991219,"CreationDate":"2015-04-21T07:08:00.000","Title":"Install Numpy in pydev(eclipse)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to execute a file after it gets downloaded on client side,File is a python script, User dont know how to change permission of a file, How to solve this issue??","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":48,"Q_Id":29778405,"Users Score":1,"Answer":"Change file permissions to make it executable: sudo chmod +x file.py","Q_Score":0,"Tags":"python,linux,apache,file-permissions","A_Id":29778427,"CreationDate":"2015-04-21T16:46:00.000","Title":"File permission gets changed after file gets downloaded on client machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to execute a file after it gets downloaded on client side,File is a python script, User dont know how to change permission of a file, How to solve this issue??","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":29778405,"Users Score":0,"Answer":"Maybe you can try teaching them how to use chmod +x command? Or actualy even more simple it would be to change it using GUI: right click -> properties -> permissions-> pick what is needed","Q_Score":0,"Tags":"python,linux,apache,file-permissions","A_Id":29778455,"CreationDate":"2015-04-21T16:46:00.000","Title":"File permission gets changed after file gets downloaded on client machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to set-up run configurations to pass parameters to a specific python script.  There are several entry points, I don't want a run configuration for each one do I?  What I want to do instead is launch a python script from a command line shell script and be able to attach the PyCharm debugger to the python script that is executed and have it stop at break points.  I've tried to use a pre-launch condition of a utility python script that will sleep for 10 seconds so I can attempt to \"attach to process\" of the python script.  That didn't work.  I tried to import pdb and settrace to see if that would stop it for attaching to the process, but that looks to be command line debugging specific only.  Any clues would be appreciated. \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1147,"Q_Id":29785534,"Users Score":1,"Answer":"You can attach the debugger to a python process launched from terminal: \nUse Menu Tools --> Attach to process then select python process to debug.\nIf you want to debug a file installed in site-packages you may need to open the file from its original location.\nYou can to pause the program manually from debugger and inspect the suspended Thread to find your source file.","Q_Score":4,"Tags":"python,bash,debugging,pycharm,pdb","A_Id":37883146,"CreationDate":"2015-04-22T00:24:00.000","Title":"How to attach to PyCharm debugger when executing python script from bash?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed photologue correctly in my project (blog) and I can add images in admin panel, but how to display them on my main page?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":29789325,"Users Score":0,"Answer":"In the admin panel, you also need to:\n\nCreate a gallery.\nChoose which photos are a part of which galleries.","Q_Score":0,"Tags":"python,django,photologue","A_Id":31057437,"CreationDate":"2015-04-22T06:23:00.000","Title":"How to add a gallery in photologue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline with:\n\nno module named cv2\n\nI assume that PyCharm is unable to locate my cv2.so file but I have the latest PyCharm version (4.0.6) and none of the forums I've looked at are helpful for this version. How do I get PyCharm to recognise my cv2 file? I went in Project Interpreter but there is no option for importing OpenCV from my own machine. Furthermore in Edit Configurations I defined an environment variable \n\nPYTHONPATH \n\nand set it to \n\n\/usr\/local\/lib\/python2.7\/site-packages:$PYTHONPATH \n\nbut this didn't help either.\nAny ideas?\nEDIT: I set up a\u00a0virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8253,"Q_Id":29797893,"Users Score":0,"Answer":"Do the following steps:\n\nDownload and install the OpenCV executable.\nAdd OpenCV in the system path(%OPENCV_DIR% = \/path\/of\/opencv\/directory)\nGo to C:\\opencv\\build\\python\\2.7\\x86 folder and copy cv2.pyd file.\nGo to C:\\Python27\\DLLs directory and paste the cv2.pyd file.\nGo to C:\\Python27\\Lib\\site-packages directory and paste the cv2.pyd file.\nGo to PyCharm IDE and go to DefaultSettings > PythonInterpreter.\nSelect the Python which you have installed.\nInstall the packages numpy, matplotlib and pip in pycharm.\nRestart your PyCharm.","Q_Score":7,"Tags":"python,opencv,pycharm","A_Id":56717998,"CreationDate":"2015-04-22T12:40:00.000","Title":"Cannot import cv2 in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline with:\n\nno module named cv2\n\nI assume that PyCharm is unable to locate my cv2.so file but I have the latest PyCharm version (4.0.6) and none of the forums I've looked at are helpful for this version. How do I get PyCharm to recognise my cv2 file? I went in Project Interpreter but there is no option for importing OpenCV from my own machine. Furthermore in Edit Configurations I defined an environment variable \n\nPYTHONPATH \n\nand set it to \n\n\/usr\/local\/lib\/python2.7\/site-packages:$PYTHONPATH \n\nbut this didn't help either.\nAny ideas?\nEDIT: I set up a\u00a0virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8253,"Q_Id":29797893,"Users Score":0,"Answer":"Have you selected the right version of python ? \nor rather, when you have installed opencv with brew, this last probably has installed a new version of python that you can find in Cellar's Directory. You can see this immediately; from the main window of PyCharm select:\n\n\nConfigure -> Preferences -> Project Interpreter\n\n\nclick on Project Interpreter Combobox and be careful if there is a instance of python in Cellar's Directory, if yes, select it and you can see the cv2 in the list below.","Q_Score":7,"Tags":"python,opencv,pycharm","A_Id":44804084,"CreationDate":"2015-04-22T12:40:00.000","Title":"Cannot import cv2 in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline with:\n\nno module named cv2\n\nI assume that PyCharm is unable to locate my cv2.so file but I have the latest PyCharm version (4.0.6) and none of the forums I've looked at are helpful for this version. How do I get PyCharm to recognise my cv2 file? I went in Project Interpreter but there is no option for importing OpenCV from my own machine. Furthermore in Edit Configurations I defined an environment variable \n\nPYTHONPATH \n\nand set it to \n\n\/usr\/local\/lib\/python2.7\/site-packages:$PYTHONPATH \n\nbut this didn't help either.\nAny ideas?\nEDIT: I set up a\u00a0virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":8253,"Q_Id":29797893,"Users Score":0,"Answer":"I got the same situation under win7x64 with pycharm version 2016.1.1, after a quick glimpse into the stack frame, I think it is a bug!\nPycharm ipython patches import action for loading QT, matplotlib, ..., and finally sys.path lost its way!\nanyway, there is a workaround, copy Lib\/site-packages\/cv2.pyd or cv2.so to $PYTHONROOT, problem solved!","Q_Score":7,"Tags":"python,opencv,pycharm","A_Id":39482840,"CreationDate":"2015-04-22T12:40:00.000","Title":"Cannot import cv2 in PyCharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"could you help me with that. I can't manage to install this plugin. I tried:\n1) install it through pip\n2) through setup.py in win console\n3) through anaconda3 but still no.\n4) I searched about it in web and here, but insructions are made to older versions.\n5) and also through the installation page of eyeD3. \nCould you guide me how should I do this? Maybe I'm doing something wrong. For first: should I use for this Python 2.7.9 or can it be Anaconda3","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":641,"Q_Id":29826237,"Users Score":0,"Answer":"The problem is that this file is only written for Python 2 but you are using Python 3. You should use Anaconda (vs. Anaconda3), or create a Python 2 environment with conda with conda create -n py2 anaconda python=2 and activate it with activate py2.","Q_Score":2,"Tags":"python,python-2.7,pip,anaconda,eyed3","A_Id":29851171,"CreationDate":"2015-04-23T14:19:00.000","Title":"I can't install eyeD3 0.7.5 into Python in windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to implement a Dynamic Programming algorithm to solve the Traveling Salesman problem in time that beats Brute Force Search for computing distances between points. For this I need to index subproblems by size and the value of each subproblem will be a float (the length of the tour). However holding the array in memory will take about 6GB RAM if I use python floats (which actually have double precision) and so to try and halve that amount (I only have 4GB RAM) I will need to use single precision floats. However I do not know how I can get single precision floats in Python (I am using Python 3). Could someone please tell me where I can find them (I was not able to find much on this on the internet). Thanks.\nEDIT: I notice that numpy also has a float16 type which will allow for even more memory savings. The distances between points are around 10000 and there are 25 unique points and my answer needs to be to the nearest integer. Will float16 provide enought accuracy or do I need to use float32?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4158,"Q_Id":29826523,"Users Score":2,"Answer":"You could try the c_float type from the ctypes standard library.  Alternatively, if you are capable of installing additional packages you might try the numpy package.  It includes the float32 type.","Q_Score":6,"Tags":"python,floating-point,double,precision","A_Id":29826612,"CreationDate":"2015-04-23T14:30:00.000","Title":"Python float precision float","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i noticed about to change the subject for django error reporting emails, \nis  it possible to change subject?\ncan we modify the subject for Django error reporting emails ?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1862,"Q_Id":29839766,"Users Score":3,"Answer":"If you need it only for reporting errors the best choice would be to inherit from the django.utils.log.AdminEmailHandler and override the def format_subject(self, subject): method. \nNote that changing EMAIL_SUBJECT_PREFIX will affect not only error emails but all emails send to admins including system information emails or so.","Q_Score":7,"Tags":"python,django","A_Id":42911596,"CreationDate":"2015-04-24T05:56:00.000","Title":"how to change the subject for Django error reporting emails?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm hosting my app on Google App Engine. Is there any posibility to get server IP of my app for current request?\nMore info:\nGAE has a specific IP addressing. All http requests go to my 3-level domain, and IP of this domain isn't fixed, it changes rather frequently and can be different on different computers at the same moment. Can I somehow find out, what IP address client is requesting now?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":157,"Q_Id":29845940,"Users Score":0,"Answer":"I'm not entirely clear on what you're looking for, but you can retrieve that type of information from the WSGI environmental variables.  The method of retrieving them varies with WSGI servers, and the number of variables made available to your application depends on the web server configuration.\nThat being said, getting client IP address is a common task and there is likely a method on the request object of the web framework you are using. \nWhat framework are you using?","Q_Score":0,"Tags":"python,google-app-engine","A_Id":29846170,"CreationDate":"2015-04-24T11:08:00.000","Title":"GAE: how to get current server IP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have django app which is backend for javascript application intended for multiple TV devices. Each device has different frontend but I don't think that creating multiple .po files is good idea for this goal, because most of translations are repetitive for these devices.\nIs this possible to add additional parameters for translations, for example in my case some function with parameter \"device\" would be very useful? If not, how to do in Django way?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":521,"Q_Id":29846606,"Users Score":-1,"Answer":"I assume that you are using Django to create an API, and you consume the API with javascript. You can check the user-agent string from the header and make the appropriate redirect according to the request.","Q_Score":3,"Tags":"python,django,internationalization,translation","A_Id":29846744,"CreationDate":"2015-04-24T11:41:00.000","Title":"Django way for multiple translations for one language or parametrize translations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've been using Scapy to craft packets and test my network, but the programmer inside me is itching to know how to do this without Scapy.\nFor example, how do I craft a DNS Query using sockets (I assume it's sockets that would be used).\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2153,"Q_Id":29852509,"Users Score":1,"Answer":"To open a UDP socket you'd use:\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_UDP\nTo send use:\nquery = craft_dns_query() # you do this part\ns.sendto(query,(socket.inet_aton(\"8.8.8.8\",53))\nTo receive the response use:\nresponse = s.recv(1024)\nYou'll have to refer to documentation on DNS for actually crafting the messages and handling the responses.","Q_Score":2,"Tags":"python,tcp,tcp-ip","A_Id":29898151,"CreationDate":"2015-04-24T16:14:00.000","Title":"Crafting a DNS Query Message in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Without having to convert it to datetime, how can I get the date from a Unix timestamps? In other words, I would like to remove hours, minutes and seconds from the time stamp and get the numbers that represent the date only.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3529,"Q_Id":29886501,"Users Score":1,"Answer":"If running the script in a UNIX like OS, you can use the date command -\n\n>>>import subprocess\n>>>process=subprocess.Popen(['date','-d','@1430106933', '+%Y%m%d'], stdout=subprocess.PIPE)\n>>>out,err = process.communicate()\n>>>print out\n20150426","Q_Score":2,"Tags":"python,datetime,time","A_Id":29886958,"CreationDate":"2015-04-27T03:03:00.000","Title":"How to remove hours, minutes, and seconds from a Unix timestamp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to draw a dynamic picture for a neural network to watch the weights changed and the activation of neurons during learning. How could I simulate the process in Python? \nMore precisely, if the network shape is: [1000, 300, 50], \nthen I wish to draw a three layer NN which contains 1000, 300 and 50 neurons respectively. \nFurther, I hope the picture could reflect the saturation of neurons on each layer during each epoch.\nI've no idea about how to do it. Can someone shed some light on me?","AnswerCount":9,"Available Count":1,"Score":0.022218565,"is_accepted":false,"ViewCount":35856,"Q_Id":29888233,"Users Score":1,"Answer":"Draw the network with nodes as circles connected with lines. The line widths must be proportional to the weights. Very small weights can be displayed even without a line.","Q_Score":29,"Tags":"python,image,neural-network","A_Id":29889993,"CreationDate":"2015-04-27T05:58:00.000","Title":"How to visualize a neural network","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the psycopg2 library with Python3 on a linux server to create some temporary tables on Redshift and querying these tables to get results and write to files on the server.\n\nSince my queries are long and takes about 15 minutes to create all these temp tables that I ultimate pull data from, how do I ensure that my connection persists and I don't lose the temp tables that I later query? Right now I just do a cursor() before the execute(), is there a default timeout for these?\nI have noticed that whenever I do a \n\n\nSelect a,b from #results_table\n\nor \n\nselect * from #results_table\n\nthe query just freezes\/hangs, but \n\nselect top 35 from #results_table\n\nreturns the results (select top 40 fails!). There are about a 100 rows in #results_table, and I am not able to get them all. I did a ps aux and the process just stays in the S+ state. If I manually run the query on Redshift it finishes in seconds.\nAny ideas?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":29893476,"Users Score":1,"Answer":"Re-declaring a cursor doesn't create new connection while using psycopg2.","Q_Score":0,"Tags":"linux,postgresql,python-3.x,psycopg2,amazon-redshift","A_Id":29915754,"CreationDate":"2015-04-27T10:42:00.000","Title":"Does redeclaring a cursor create new connection while using psycopg2?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set up a proxy server in Anaconda because my firewall does not allow me to run online commands such as\n\nconda update\n\nI see online that I should create a .condarc file that contains the proxy address. Unfortunately, \n\nI dont know how to create that file (is it a text file?)\nand where to put it?! (in which folder? in the Anaconda folder?)\n\nAny help appreciated\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":46665,"Q_Id":29896309,"Users Score":1,"Answer":"There are chances that the .condarc file is hidden as was in my case. I was using Linux Mint (Sarah) and couldn't find the file though later on I found that it was hidden in the home directory and hence when I opted to show hidden files I could find it.","Q_Score":10,"Tags":"python-3.x,python-2.7,proxy,anaconda,conda","A_Id":40988680,"CreationDate":"2015-04-27T12:50:00.000","Title":"how to create a .condarc file for Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set up a proxy server in Anaconda because my firewall does not allow me to run online commands such as\n\nconda update\n\nI see online that I should create a .condarc file that contains the proxy address. Unfortunately, \n\nI dont know how to create that file (is it a text file?)\nand where to put it?! (in which folder? in the Anaconda folder?)\n\nAny help appreciated\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":46665,"Q_Id":29896309,"Users Score":0,"Answer":"to create the .condarc file open Anaconda Prompt and type:\nconda config\nit will appear in your user's home directory","Q_Score":10,"Tags":"python-3.x,python-2.7,proxy,anaconda,conda","A_Id":69901282,"CreationDate":"2015-04-27T12:50:00.000","Title":"how to create a .condarc file for Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I currently have a small webapp on AWS based on the MEAN (Mongo, Express, Angular, Node) but have a python script I would like to execute on the front end.  Is there a way to incorporate this?  Basically, I have some data objects on my AngularJS frontend from a mongoDB that I would like to manipulate with python and don't know how to get them into a python scope, do something to them, and send them to a view.  \nIs this possible?  If so, how could it be done?  Or is this totally against framework conventions and should never be done?\nfrom","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1124,"Q_Id":29903381,"Users Score":1,"Answer":"To answer my own question about a year later, what I would do now is just run my python script in tiny web server that lived on the same server as my MEAN app. It wouldn't have any external ports exposed and the MEAN app would just ping it for information and get JSON back. Just in case anyone is looking at this question down the road...\nI find this way easier than trying to integrate the python script into the application itself.","Q_Score":1,"Tags":"python,angularjs,mongodb,frameworks,mean-stack","A_Id":36828297,"CreationDate":"2015-04-27T18:31:00.000","Title":"Webapp architecture: Putting python in a MEAN stack app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently experiencing an issue in my GAE app with sending requests to non-default modules. Every request throws an error in the logs saying:\n\nRequest attempted to contact a stopped backend.\n\nWhen I try to access the module directly through the browser, I get: \n\nThe requested URL \/ was not found on this server.\n\nI attempted to stop and start the \"backend\" modules a few times to no avail. I also tried changing the default version for the module to a previous working version, but the requests from my front-end are still hitting the \"new\", non-default version. When I try to access a previous version of the module through the browser, it does work however.\nOne final symptom: I am able to upload my non-default modules fine, but cannot upload my default front-end module. The process continually says \"Checking if deployment succeeded...Will check again in 60 seconds.\", even after rolling back the update.\nI Googled the error from the logs and found almost literally nothing. Anyone have any idea what's going on here, or how to fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":607,"Q_Id":29928477,"Users Score":0,"Answer":"Fixed by shutting down all instances (on all modules\/versions just to be safe).","Q_Score":2,"Tags":"python,google-app-engine","A_Id":29928760,"CreationDate":"2015-04-28T19:42:00.000","Title":"GAE module: \"Request attempted to contact a stopped backend.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done.\nAny hints links examples welcome.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1640,"Q_Id":29928485,"Users Score":0,"Answer":"Here is what I have sort of put together by pulling several threads online:\n\nRuby On Rails seems to be more popular than python at this moment.\nIf you go python, Flask and Django are good templates.\nbokeh seems to be a good way of plotting to a browser. \nAFAIK, there is no way to take an existing PyQt or pyqtgraph application and have it run on the web.\nI am not sure how Twisted (Tornado, Node.js and Friends) fits in to the web SaaS, but I see it referred to occasionally since it is asynchronous event-driven.\nPeople often suggest using Rest, but that seems slow to me. Not sure why...","Q_Score":4,"Tags":"python,django,pyqt,saas,pyqtgraph","A_Id":29947088,"CreationDate":"2015-04-28T19:43:00.000","Title":"Displaying pyqtgraph and pyqt widgets on web","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done.\nAny hints links examples welcome.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1640,"Q_Id":29928485,"Users Score":0,"Answer":"If all you need are static plots, then it should be straightforward to draw and export to an SVG file, then display the SVG in a webpage (or export to image, as svg rendering is not reliable in all browsers). If you need interactivity, then you're going to need a different solution and probably pyqtgraph is not the tool for this job. VisPy does have some early browser support but this has only been demonstrated with ipython notebook.","Q_Score":4,"Tags":"python,django,pyqt,saas,pyqtgraph","A_Id":29987875,"CreationDate":"2015-04-28T19:43:00.000","Title":"Displaying pyqtgraph and pyqt widgets on web","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question about REST design in general and specifically what the best way to implement a solution is in Django Rest Framework.  Here it the situation:\nSay I have an app for keeping track of albums that the user likes.  In the browser, the user sees a list of albums and each one has a check box next to it.  Checking the box means you like the album.  At the bottom of the page is a submit button.  \nI want the submit button to initiate an AJAX request that sends tp my API endpoint a list of the ids (as in, the Djano model ids) of the albums that are liked by the user.  \nMy question is, is this a standard approach for doing this sort of thing (I am new to web stuff and REST in particular).  In other words, is there a better way to handle the transmission of these data than to send an array of ids like this?  As a corollary, if this is an alright approach, how does one implement this in Django Rest Framework in a way which is consistent with its intended methodology.  \nI am keeping this question a little vague (not presenting any code for the album serializer, for example) intentionally because I am looking to learn some fundamentals, not to debug a particular piece of code.\nThanks a lot in advance!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":116,"Q_Id":29935200,"Users Score":2,"Answer":"Consider the upvote button to the left. When you click it, a request may be sent to stackoverflow.com\/question\/12345\/upvote. It creates an \"action resource\" on the db, so later you can go to your user profile and check out the list of actions you took.\nYou can consider doing the same thing for your application. It may be a better user experience to have immediate action taken like SO, or a \"batch\" request like with gmail's check boxes.","Q_Score":1,"Tags":"python,django,rest,django-rest-framework","A_Id":29935296,"CreationDate":"2015-04-29T05:38:00.000","Title":"Django rest framework: correctly handle incoming array of model ids","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have an angularjs app that uses Angular UI Router and the URL that are created have a # in them.. Eg. http:\/\/localhost:8081\/#\/login. I am using Python Simple HTTP server to run the app while developing. I need to remove the # from the URL. I know how to remove it by enabling HTML5 mode in angular. But that method has its problems and i want to remove the # from the server side.\nHow can i do this using Python Simple HTTP Server?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1156,"Q_Id":29939110,"Users Score":0,"Answer":"Well i had a similar problem but the difference is that i had Spring on the Server Side.\nYou can capture page not found exception at your server side implementation, and redirect to the default page [route] in your app. In Spring, we do have handlers for page not found exceptions, i guess they are available in python too.","Q_Score":0,"Tags":"python,angularjs,http,simplehttpserver","A_Id":29939768,"CreationDate":"2015-04-29T09:08:00.000","Title":"Remove # from the URL in Python Simple HTTP Server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently learned how to use virtualenv and virtualenvwrapper in my workflow but I've seen pyenv mentioned in a few guides but I can't seem to get an understanding of what pyenv is and how it is different\/similar to virtualenv. Is pyenv a better\/newer replacement for virtualenv or a complimentary tool? If the latter what does it do differently and how do the two (and virtualenvwrapper if applicable) work together?","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":58878,"Q_Id":29950300,"Users Score":33,"Answer":"Short version:\n\nvirtualenv allows you to create local (per-directory), independent python installations by cloning from existing ones\npyenv allows you to install (build from source) different versions of Python alongside each other; you can then clone them with virtualenv or use pyenv to select which one to run at any given time\n\nLonger version:\nVirtualenv allows you to create a custom Python installation e.g. in a subdirectory of your project. This is done by cloning from an existing Python installation somewhere on your system (some files are copied, some are reused\/shared to save space). Each of your projects can thus have their own python (or even several) under their respective virtualenv. It is perfectly fine for some\/all virtualenvs to even have the same version of python (e.g. 3.8.5) without conflict - they live separately and don't know about each other. If you want to use any of those pythons from shell, you have to activate it (by running a script which will temporarily modify your PATH to ensure that that virtualenv's bin\/ directory comes first). From that point, calling python (or pip etc.) will invoke that virtualenv's version until you deactivate it (which restores the PATH). It is also possible to call into a virtualenv Python using its absolute path - this can be useful e.g. when invoking Python from a script.\nPyenv operates on a wider scale than virtualenv. It is used to install (build from source) arbitrary versions of Python (it holds a register of available versions). By default, they're all installed alongside each other under ~\/.pyenv, so they're \"more global\" than virtualenv. Then, it allows you to configure which version of Python to run when you use the python command (without virtualenv). This can be done at a global level or, separately, per directory (by placing a .python-version file in a directory). It's done by prepending pyenv's shim python script to your PATH (permanently, unlike in virtualenv) which then decides which \"real\" python to invoke. You can even configure pyenv to call into one of your virtualenv pythons (by using the pyenv-virtualenv plugin). You can also duplicate Python versions (by giving them different names) and let them diverge.\nUsing pyenv can be a convenient way of installing Python for subsequent virtualenv use.","Q_Score":209,"Tags":"python,virtualenv,virtualenvwrapper,pyenv","A_Id":46344026,"CreationDate":"2015-04-29T17:13:00.000","Title":"What is the relationship between virtualenv and pyenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented?\nThe main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated.\nAny suggestions on how to circumvent this?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":2806,"Q_Id":29961898,"Users Score":4,"Answer":"You can use a AnonymousUserMixin subclass if you like, but you need to add some logic to it so that you can associate each anonymous user with a cart stored in your database.\nThis is what you can do:\n\nWhen a new user connects to your application you assign a randomly generated unique id. You can write this random id to the user session (if you want the cart to be dropped when the user closes the browser window) or to a long-lived cookie (if you want the cart to be remembered even after closing the browser). You can use Flask-Login for managing the session\/cookie actually, you don't have to treat unknown users as anonymous, as soon as you assign an id to them you can treat them as logged in users.\nHow do you know if an anonymous user is known or new? When the user connects you check if the session or cookie exist, and look for the id there. If an id is found, then you can locate the cart for the user. If you use a subclass of AnonymousUserMixin, then you can add the id as a member variable, so that you can do current_user.id even for anonymous users. You can have this logic in the Flask-Login user loader callback.\nWhen the user is ready to pay you convert the anonymous user to a registered user, preserving the id.\nIf you have a cron job that routinely cleans up old\/abandoned anonymous carts from the database, you may find that an old anonymous user connects and provides a user id that does not have a cart in the database (because the cart was deemed stale and deleted). You can handle this by creating a brand new cart for the same id, and you can even notify the user that the contents of the cart expired and were removed.\n\nHope this helps!","Q_Score":7,"Tags":"python,flask,flask-login,anonymous-users","A_Id":30008742,"CreationDate":"2015-04-30T07:44:00.000","Title":"How to track anonymous users with Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented?\nThe main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated.\nAny suggestions on how to circumvent this?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2806,"Q_Id":29961898,"Users Score":9,"Answer":"There is no need for a custom AnonymousUserMixin, you can keep the shopping cart data in session:\n\nanonymous user adds something to hist cart -> update his session with the cart data\nthe user wants to check out -> redirect him to login page\nlogged in user is back at the check out -> take his cart data out of the session and do whatever you would do if he was logged in the whole time","Q_Score":7,"Tags":"python,flask,flask-login,anonymous-users","A_Id":29962315,"CreationDate":"2015-04-30T07:44:00.000","Title":"How to track anonymous users with Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to understand how to use websockets correctly and seem to be missing some fundamental part of the puzzle.\nSay I have a website with 3 different pages:\n\nnewsfeed1.html \nnewsfeed2.html \nnewsfeed3.html\n\nWhen a user goes to one of those pages they get a feed specific to the page, ie newsfeed1.html = sport, newsfeed2.html = world news etc.\nThere is a CoreApplication.py that does all the handling of getting data and parsing etc.\nThen there is a WebSocketServer.py, using say Autobahn.\nAll the examples I have looked at, and that is alot, only seem to react to a message from the client (browser) within the WebSocketServer.py, think chat echo examples. So a client browser sends a chat message and it is echoed back or broadcast to all connected client browsers.\nWhat I am trying to figure out is given the following two components:\n\nCoreApplication.py\nWebSocketServer.py\n\nHow to best make CoreApplication.py communicate with WebSocketServer.py for the purpose of sending messages to connected users.\nNormally should CoreApplication.py simply send command messages to the WebSocketServer.py as a client. For example like this:\nCoreApplication.py -> Connects to WebServerSocket.py as a normal client -> sends a Json command message (like broadcast message X to all users || send message Y to specific remote client) -> WebSocketServer.py determines how to process the incoming message dependant on which client is connected to which feed and sends to according remote client browsers.\nOR, should CoreApplication.py connect programatically with WebSocketServer.py? As I cannot seem to find any examples of being able to do this for example with Autobahn or other simple web sockets as once the WebSocketServer is instantiated it seems to run in a loop and does not accept external sendMessage requests?\nSo to sum up the question: What is the best practice? To simply make CoreApplication.py interact with WebSocketServer.py as a client (with special command data) or for CoreApplication.py to use an already running instance of  WebSocketServer.py (both of which are on the same machine) through some more direct method to directly sendMessages without having to make a full websocket connection first to the WebSocketServer.py server?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":704,"Q_Id":29967612,"Users Score":0,"Answer":"It depends on your software design, if you decide the logic from WebSocketServer.px and CoreApplication.py belongs together, merge it. \nIf not, you need some kind of inter process communication (ipc). \nYou can use websockets for this ipc, but i would suggest, you use something simpler. For example, you can you json-rpc over tcp or unix domain to send control messages from CoreApplication.py to WebSocketServer.py","Q_Score":2,"Tags":"python,websocket","A_Id":29967827,"CreationDate":"2015-04-30T12:19:00.000","Title":"WebSockets best practice for connecting an external application to push data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I did setup an ipython server for other people (in my company department) to have a chance to learn and work with python.\nNow I wonder how people can load their own local data into the ipython notebook session on the remote server. Is there any way to do this?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52276,"Q_Id":29968829,"Users Score":0,"Answer":"If it is a text file, create a empty file, edit it and then copy\/paste the content..\nYou can do this to bypass the 25mb constraint","Q_Score":15,"Tags":"server,ipython","A_Id":42136317,"CreationDate":"2015-04-30T13:18:00.000","Title":"Load local data into IPython notebook server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm stumped on this one, please help me oh wise stack exchangers...\nI have a function that uses xlrd to read in an .xls file which is a file that my company puts out every few months.  The file is always in the same format, just with updated data.  I haven't had issues reading in the .xls files in the past but the newest release .xls file is not being read in and is producing this error: *** formula\/tFunc unknown FuncID:186\nThings I've tried:\n\nI compared the new .xls file with the old to see if I could spot any\ndifferences.  None that I could find.\nI deleted all of the macros that were contained in the file (older versions also had macros)\nUpdated xlrd to version 0.9.3 but get the same error\nThese files are originally .xlsm files.  I open them and save them as\n.xls files so that xlrd can read them in.  This worked just fine on previous releases of the file.  After upgrading to xlrd 0.9.3 which supposedly supports .xlsx, I tried saving the .xlsm file as.xlsx and tried to read it in but got an error with a blank error message\n\nUseful Info:\n\nPython 2.7\nxlrd 0.9.3\nWindows 7 (not sure if this matters but...)\n\nMy guess is that there is some sort of formula in the new file that xlrd doesn't know how to read.  Does anybody know what FuncID: 186 is?\nEdit: Still no clue on where to go with this.  Anybody out there run into this?  I tried searching up FuncID 186 to see if it's an excel function but to no avail...","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1917,"Q_Id":29971186,"Users Score":0,"Answer":"I had the same problem and I think we have to look at the cells excel that these are not picking up empty, that's how I solved it.","Q_Score":4,"Tags":"python,windows,excel,python-2.7,xlrd","A_Id":30945220,"CreationDate":"2015-04-30T15:01:00.000","Title":"Python XLRD Error : formula\/tFunc unknown FuncID:186","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Using Python 2.7, \nI am passing many large objects across processes using a manager derived from multiprocessing.managers. BaseManager and I would like to use cPickle as the serializer to save time; how can this be done? I see that the BaseManager initializer takes a serializer argument, but the only options appear to be pickle and xmlrpclib.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":330,"Q_Id":29972537,"Users Score":1,"Answer":"I'm the author of dill and pathos. Multiprocessing should use cPickle by default, so you should't have to do anything.\nIf your object doesn't searliize, you have two options: go to a fork of multiprocessing or some other parallel backend, or add methods to your class (i.e. reduce methods) that register how to serialize the object.","Q_Score":6,"Tags":"python,multiprocessing,pickle,serialization","A_Id":30238617,"CreationDate":"2015-04-30T16:01:00.000","Title":"How do I change the serializer that my multiprocessing.mangers.BaseManager subclass uses to cPickle?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using nosetests --with-coverage to test and see code coverage of my unit tests. The class that I test has many external dependencies and I mock all of them in my unit test.\nWhen I run nosetests --with-coverage, it shows a really long list of all the imports (including something I don't even know where it is being used). \nI learned that I can use .coveragerc for configuration purposes but it seems like I cannot find a helpful instruction on the web. \nMy questions are..\n1) In which directory do I need to add .coveragerc? How do I specify the directories in .coveragerc? My tests are in a folder called \"tests\"..\n\/project_folder\n\/project_folder\/tests \n2)It is going to be a pretty long list if I were to add each in omit= ...\nWhat is the best way to only show the class that I am testing with the unittest in the coverage report?\nIt would be nice if I could get some beginner level code examples for .coveragerc. Thanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1938,"Q_Id":29976769,"Users Score":1,"Answer":"The simplest way to direct coverage.py's focus is to use the source option, usually source=. to indicate that you only want to measure code in the current working tree.","Q_Score":2,"Tags":"python,unit-testing,nosetests,coverage.py","A_Id":29985334,"CreationDate":"2015-04-30T20:00:00.000","Title":"how to omit imports using .coveragerc in coverage.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using wxPython ObjectListView and it is very easy to use. Now I need to render a wx.Color as a column but I haven't found a way in the documentation. Basically I have list of items each of them have the following attributes: name, surname and hair color. Hair color is a RGB color and I would like to show it as a column in my ObjectListView.\nIs there a way to do it ?\nMany thanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":360,"Q_Id":29990202,"Users Score":0,"Answer":"For the future: what I did was to show the color as a background of the row of the list.","Q_Score":0,"Tags":"python,wxpython,objectlistview-python","A_Id":30030742,"CreationDate":"2015-05-01T15:46:00.000","Title":"ObjectListView wxPython: how to show a wx.Color","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My question is simple, apart from the three themes pre-installed in Tkinter are there any other themes I can get ? Something like 3rd party themes ? If not, how can I change the button or other widgets looks (manually changing the form,etc..)?\nAlso I would like to know if it is possible to change the outside window look, like the look of the \n\n[ _ ] [ [] ] [X] \n\nbuttons of the window, if not is there a way to remove them so I can put my own buttons in the frame?\nAny code example or link is welcome.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":30002869,"Users Score":2,"Answer":"You cannot change the window border, but you can remove it entirely and draw your own border. You'll also be responsible for adding the ability to move and resize the window. Search this site for \"overrideredirect\" for lots of questions and answers related to this feature.\nAs for third party themes: no, there aren't any.","Q_Score":1,"Tags":"python,python-2.7,tkinter","A_Id":30014871,"CreationDate":"2015-05-02T13:29:00.000","Title":"3rd party Tkinter themes and modifying outside window buttons","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset of a tennis game. This dataset contains the ball positions in each rally and the current score. I already 3d-visualized the game and ball positions in mayavi.\nNow I want to plot 2d line diagrams in mayavi that visualizes the score developement after specific events (such as after: a break, a set-win, set-loss,...). \nI came up with some ideas, but none of them are satisfying:\n\nI could use imshow and \"draw\" the diagram\nI could use points3d to plot the diagram\nMaybe I can somehow use pyplot to plot the diagram, then make a screenshot und then plot this screenshot in mayavi...  Any idea if this is possible?\n\nDo you have any other idea how I could plot a 2d line diagram in mayavi?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":783,"Q_Id":30035123,"Users Score":0,"Answer":"Mayavi is not really good at plotting 2d-diagramms, you can cheat a little by setting your camera position parallel to an 2d image. If you want to plot 2d-diagramms try using matplotlib.","Q_Score":0,"Tags":"python,matplotlib,mayavi","A_Id":30125166,"CreationDate":"2015-05-04T16:31:00.000","Title":"Plot 2d line diagram in mayavi","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering what is the difference between using pkt.time and pkt[IP].time since they both give different times for the same packet.\nI was also wondering how to interpret packet time such as 1430123453.564733 \nIf anyone has an idea or knows where I can find such information it would be very helpful.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":501,"Q_Id":30036175,"Users Score":0,"Answer":"pkt.time gives you the epoch time that is included in the FRAME layer of the packet in wireshark. \nJust after the notation pkt[IP].time gives you the time that is included in the IP layer of the packet in wireshark. But the IP layer has no time, so I don't think this command will work.","Q_Score":3,"Tags":"python-2.7,packet,scapy","A_Id":47197343,"CreationDate":"2015-05-04T17:26:00.000","Title":"Scapy packet time interpretation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Basically, I need to disable or turn off a GPIO pin whenever I execute a method in python.\nDoes anyone knows how to disable the pins?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4582,"Q_Id":30045659,"Users Score":0,"Answer":"There is a built-in function GPIO.cleanup() that clean up all the ports you've used.\nFor the power and ground pins, they are not under software control.","Q_Score":0,"Tags":"python,raspberry-pi,gpio","A_Id":30187490,"CreationDate":"2015-05-05T06:26:00.000","Title":"How to disable GPIO pins on the RaspberryPi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python and openCV to create face recognition with Eigenfaces. I stumbled on a problem, since I don't know how to create training set.\nDo I need multiple faces of people I want to recognize(myself for example), or do I need a lot of different faces to train my model?\nFirst I tried training my model with 10 pictures of my face and 10 pictures of ScarJo face, but my prediction was not working well.\nNow I'm trying to train my model with 20 different faces (mine is one of them). \nAm I doing it wrong and if so what am I doing wrong?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":247,"Q_Id":30049490,"Users Score":0,"Answer":"I later found the answer and would like to share it if someone will be facing the same challenges.\nYou need pictures only for the different people you are trying to recognise. I created my training set with 30 images of every person (6 persons) and figured out that histogram equalisation can play an important role when creating the training set and later when recognising faces. Using the histogram equalisation model accuracy was greatly increased. Another thing to consider is eye axis alignment so that all pictures have their eye axis aligned before they enter face recognition.","Q_Score":0,"Tags":"python,opencv,training-data","A_Id":32845800,"CreationDate":"2015-05-05T09:45:00.000","Title":"What does eigenfaces training set have to look like?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a python application and created a .msi installer for it to work and get installed on other machines.\nI would like to know how can the user change the language during the installation. ie the localization of msi.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":381,"Q_Id":30051770,"Users Score":0,"Answer":"A lot of this seems to be a question about how bdist_msi works, and it seems to be a tool that nobody here knows anything about. I would get some clarification from that tool somehow. The docs seem non-existent to me. \n\nIt might generate only one MSI in English. If so then you need to use a tool like Orca to translate the MSI text into each language and save each difference as a transform, an .mst file. Then you'd write a program that gets the language from the user and installs the MSI with a TRANSFORMS= command line that refers to the .mst file for the language. \nIt might work like Visual Studio, where each language has its own separate MSI file. Again, you'd need a setup program asks the user what language and you fire off the appropriate MSI. \n\nIn general, there's no need to ask the user what language to use. I have seen those dialogs but I don't know why they bother. I think it's better to assume the current user language rather than show a dialog that says \"Choose a language\". You'd need to localise that \"Choose a language\" text to the user's language anyway unless you assume that everyone already understands English. \nYou might be able to use something like WiX Burn to package your MSI and provide localisation, not sure.","Q_Score":0,"Tags":"python,localization,windows-installer,installation,multiple-languages","A_Id":30155408,"CreationDate":"2015-05-05T11:29:00.000","Title":"How to localize a msi setup installer file to support various languages?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need a list of all scikit-learn classifiers that support the predict_proba() method. Since the documentation provides no easy way of getting that information, how can get this programatically?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":8716,"Q_Id":30056331,"Users Score":3,"Answer":"AdaBoostClassifier\nBaggingClassifier\nBayesianGaussianMixture\nBernoulliNB\nCalibratedClassifierCV\nComplementNB\nDecisionTreeClassifier\nExtraTreeClassifier\nExtraTreesClassifier\nGaussianMixture\nGaussianNB\nGaussianProcessClassifier\nGradientBoostingClassifier\nKNeighborsClassifier\nLabelPropagation\nLabelSpreading\nLinearDiscriminantAnalysis\nLogisticRegression\nLogisticRegressionCV\nMLPClassifier\nMultinomialNB\nNuSVC\nQuadraticDiscriminantAnalysis\nRandomForestClassifier\nSGDClassifier\nSVC\n_BinaryGaussianProcessClassifierLaplace\n_ConstantPredictor","Q_Score":22,"Tags":"python,scikit-learn","A_Id":56863216,"CreationDate":"2015-05-05T14:50:00.000","Title":"How to list all scikit-learn classifiers that support predict_proba()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need a list of all scikit-learn classifiers that support the predict_proba() method. Since the documentation provides no easy way of getting that information, how can get this programatically?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8716,"Q_Id":30056331,"Users Score":0,"Answer":"If you are interested in a spesific type of estimator(say classifier), you could go with:\nimport sklearn\nestimators = sklearn.utils.all_estimators(type_filter=\"classifier\")\nfor name, class_ in estimators:\nif not hasattr(class_, 'predict_proba'):\nprint(name)","Q_Score":22,"Tags":"python,scikit-learn","A_Id":72497753,"CreationDate":"2015-05-05T14:50:00.000","Title":"How to list all scikit-learn classifiers that support predict_proba()","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I have got a black an white image, how do I convert the colour intensity at each point into a numerical value that represents its relativity intensity? \nI checked somewhere on the web and found the following:\n    Intensity = np.asarray(PIL.Image.open('test.jpg'))\nWhat's the difference between asarray and array?\nBesides, the shape of the array Intensity is '181L, 187L, 3L'. The size of the image test.jpg is 181x187, so what does the extra '3' represent?\nAnd are there any other better ways of extracting the colour intensity of an image?\nthank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":473,"Q_Id":30063430,"Users Score":1,"Answer":"The image is being opened as a color image, not as a black and white one. The shape is 181x187x3 because of that: the 3 is there because each pixel is an RGB value. Quite often images in black and white are actually stored in an RGB format. For an image image, if np.all(image[:,:,0]==image[:,:,1]) and so on, then you can just choose to use any of them (eg, image[:,:,0]). Alternatively, you could take the mean with np.mean(image,axis=2).\nNote too that the range of values will depend on the format, and so depending upon what you mean by color intensity, you may need to normalize them. In the case of a jpeg, they are probably uint8s, so you may want image[:,:,0].astype('float')\/255 or something similar.","Q_Score":0,"Tags":"python,arrays,image,image-processing,colors","A_Id":30063676,"CreationDate":"2015-05-05T21:21:00.000","Title":"how to extract the relative colour intensity in a black and white image in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Are there any ways to set the camera in raspberry pi to take black and white image?, like using some commands \/ code in picamera library?\nSince I need to compare the relative light intensity of a few different images, I'm worried that the camera will already so some adjustments itself when the object is under different illuminations, so even if I convert the image to black and white later on the object's 'true' black and white image will have been lost.\nthanks\nedit: basically what I need to do is to capture a few images of an object when the camera position is fixed, but the position of the light source is changed (and so the direction of illumination is changed as well). Then for each point on the image I will need to compare the relative light intensity of the different images. As long as the light intensity, or the 'brightness' of all the images are relative to the same scale, then it's ok, but I'm not sure if this is the case. I'm sure if the camera will adjust something like contrast automatically itself when an image is 'inherently' darker or brighter.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":16954,"Q_Id":30063974,"Users Score":3,"Answer":"What do you mean by \"black and white image,\" in this case? There is no \"true\" black and white image of anything. You have sensors that have some frequency response to light, and those give you the values in the image.\nIn the case of the Raspberry Pi camera, and almost all standard cameras, there are red, green and blue sensors that have some response centered around their respective frequencies. Those sensors are laid out in a certain pattern, as well. If it's particularly important to you, there are cameras that only have an array of a single sensor type that is sensitive to a wider range of frequencies, but those are likely going to be considerable more expensive.\nYou can get raw image data from the raspi camera with picamera. This is not the \"raw\" format described in the documentation and controlled by format, which is really just the processed data before encoding. The bayer option will return the actual raw data. However, that means you'll have to deal with processing by yourself. Each pixel in that data will be from a different color sensor, for example, and will need to be adjusted based on the sensor response.\nThe easiest thing to do is to just use the camera normally, as you're not going to get great accuracy measuring light intensity in this way. In order to get accurate results, you'd need calibration, and you'd need to be specific about what the data is for, how everything is going to be illuminated, and what data you're actually interested in.","Q_Score":2,"Tags":"python,camera,raspberry-pi,camera-calibration","A_Id":30064269,"CreationDate":"2015-05-05T21:58:00.000","Title":"how to set the camera in raspberry pi to take black and white image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Wondering how to write unreadable ^A into a file using Python. For unreadable ^A, I mean when we use command \"set list\" in vi, we can see unreadable character like ^I for '\\t', $ for '\\n'.\nthanks in advance,\nLin","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":243,"Q_Id":30089003,"Users Score":3,"Answer":"Another way to do it is '\\1'. Cheers!","Q_Score":2,"Tags":"python,file","A_Id":30089116,"CreationDate":"2015-05-06T22:48:00.000","Title":"how to write unreadable ^A into output file in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to run a python script which should always start when windows boot.\ni believe i can create an executable windows executable file from python by using py2exe... But how to make as a start up service which will be triggered while boot \nIs there any way ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":111,"Q_Id":30090942,"Users Score":1,"Answer":"You don't need to create a py2exe executable for this, you can simply run the Python executable itself (assuming it's installed of course), passing the name of your script as an argument.\nAnd one way to do that is to use the task scheduler, which can create tasks to be run at boot time, under any user account you have access to.","Q_Score":0,"Tags":"python,windows","A_Id":30090978,"CreationDate":"2015-05-07T02:30:00.000","Title":"is there any possible way to run a python script on boot in windows operating system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When defining a python function, I find it hard to debug if I had a typo in a variable name and that variable already exists in the outer scope. I usually use similar names for variables of the same type of data structure, so if that happens, the function still runs fine but just returns a wrong result. So is there a way to prevent python functions to read outer scope variables?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":841,"Q_Id":30108404,"Users Score":2,"Answer":"You're going against the point of having Scopes at all. We have local and global scopes for a reason. You can't prevent Python from seeing outer scope variables. Some other languages allow scope priority but Python's design principles enforce strong scoping. This was a language design choice and hence Python is the wrong language to try to prevent outer scope variable reading.\nJust use better naming methodologies to ensure no confusion, you change up variable names by using the Find-Replace function that most text editors provide.","Q_Score":4,"Tags":"python,scope","A_Id":30108596,"CreationDate":"2015-05-07T17:55:00.000","Title":"how to prevent python function to read outer scope variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I apologize I couldn't find a proper title, let me explain what I'm working on: \nI have a Python IRC bot, and I want to be able to keep track of how long users have been idle in the channel, and allow them to earn things (I have it tied to Skype\/Minecraft\/my website) each x amount of hours they're idle in the channel.\nI already have everything to keep track of each user and have them validated with the site and stuff, but I am not sure how I would keep track of the time they're idle.\nI have it capture on join\/leave\/part messages. How can I get a timer set up when they join, and keep that timer running, along with other times for all of the users who are in that channel, and each hour they've been idle (not all at same time) do something then restart the timer over for them?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":30118631,"Users Score":1,"Answer":"Two general ways:\n\nCreate a separate timer for each user when he joins, do something when the timer fires and destroy it when the user leaves.\nHave one timer set to fire, say, every second (or ten seconds) and iterate over all the users when it fires to see how long they have been idle.\n\nA more precise answer would require deeper insight into your architecture, I\u2019m afraid.","Q_Score":0,"Tags":"python,timer","A_Id":30118684,"CreationDate":"2015-05-08T07:52:00.000","Title":"Keep track of items in array with timer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having some Python code that heavily relies on numpy\/scipy and scikit-learn. What would be the best way to get it running on an Android device? I have read about a few ways to get Python code running on Android, mostly Pygame and Kivy but I am not sure how this would interact with numpy and scikit-learn.\nOr would it be better to consider letting the android application send data to some server where Python is running?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2766,"Q_Id":30119149,"Users Score":1,"Answer":"Depends on what you need....\nPython on a server using Flask\/ Django would allow you to build an http UI or even an API interface for your Android (or any) device.\nQpython is a brilliant way to run python on an Android but probably won't cope with the whole of scipy so depends on what libraries have already been ported across by the Qpython team. It's a great tool though and worth a look anyway.\nIMHO learning a bit of flask for server side running would be easier and more flexible than using Kivy.","Q_Score":1,"Tags":"android,python,numpy,scikit-learn","A_Id":30120067,"CreationDate":"2015-05-08T08:23:00.000","Title":"Port Python Code to Android","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I need to store a massive numpy vector to disk. Right now the vector that I am trying to store is ~2.4 billion elements long and the data is float64. This takes about 18GB of space when serialized out to disk.\nIf I use struct.pack() and use float32 (4 bytes) I can reduce it to ~9GB. I don't need anywhere near this amount of precision disk space is going to quickly becomes an issue as I expect the number of values I need to store could grow by an order of magnitude or two.\nI was thinking that if I could access the first 4 significant digits I could store those values in an int and only use 1 or 2 bytes of space. However, I have no idea how to do this efficiently. Does anyone have any idea or suggestions?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":934,"Q_Id":30130277,"Users Score":0,"Answer":"Use struct.pack() with the f type code to get them into 4-byte packets.","Q_Score":7,"Tags":"python,numpy,scipy","A_Id":30130970,"CreationDate":"2015-05-08T18:12:00.000","Title":"Binary storage of floating point values (between 0 and 1) using less than 4 bytes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run %qtconsole from within ipython3 I get ERROR: Line magic function%qtconsolenot found., but ipython3 qtconsole in terminal starts fine. According to this, how can I run qtconsole instance connected to ipython3 instance? And how to run it on a single core -- rc[0].execute(%qtconsole)?\nP.S. If someone know, tell me please how to escape `(backquote) symbol in code-mode.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":493,"Q_Id":30151258,"Users Score":1,"Answer":"Reposting as an answer:\nIf you just run ipython3 in a terminal, what you get is a pure terminal interface, it's not running a kernel that the Qt console can talk to.\nIf you run ipython3 console, you'll get a similar interface but it will be talking to a kernel, so you can start a Qt console to interact with it. You can either run %qtconsole from inside that interface, or run ipython qtconsole --existing in a shell to start a Qt console and connect to an existing kernel.","Q_Score":1,"Tags":"ipython,python-3.4,qtconsole","A_Id":30160102,"CreationDate":"2015-05-10T12:14:00.000","Title":"How to run qtconsole connected to ipython3 instance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Usually when outputting an object in Python, you define the string that is returned in __repr__, but what if you want it to return something else instead, like an integer or tuple?\nI'll give an example. My class is Users and there are member variables self.username and self.email. If I want to output an object of type Users, how do I get it to return (self.username,self.email) as a tuple?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":30172686,"Users Score":0,"Answer":"The __*__ attributes of an object are meant to implement internal functions standardized by the Python language. Like __add__ (which is used to provide a result of object + whatever, __repr__ is expected to behave in a defined way, which would include to return (a) certain datatype(s).\nWhile statically typed languages will report a compile-time error, for dynamically typed languages like Python, this might result in unexpected (yet not undefined!) runtime behaviour. This need not even result in an error message. Therefore, never change that behaviour to somethin unexpected.\nIf you want to return something custom, use a custom method like get_info(self) or similar. (Remember not to use __*__ names for that either)","Q_Score":0,"Tags":"python,class,oop,object","A_Id":30173088,"CreationDate":"2015-05-11T16:16:00.000","Title":"Returning a specific data type when referring to an object in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can find sum of all (non-zero) elements in scipy sparse matrix by mat.sum(), but how can I find their product? There's no mat.prod() method.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":30203785,"Users Score":0,"Answer":"If you are using any plugin that is named as \"infinite posts scroll\" or \"jetpack\" or any thing similar delete it.","Q_Score":0,"Tags":"python,scipy,sparse-matrix","A_Id":33983181,"CreationDate":"2015-05-13T00:42:00.000","Title":"Product of elements of scipy sparse matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try to make classification multiclass with SVM on OpenCV (I use openCV for python). Let's say if I have 5 class and training it well. I have been test it, and got good result.\nThe problem appear when object from 6th class come to this classification. Althought I haven't train this class before, why I got result this object (that come from 6th class) recognize as object from one of the class that I have been train before (It classified as member of 1st,or 2nd, ect class). While machine should say didn't know it from what class. SVM at OpenCV didn't return the probability, it just return the label of the class.\nI have an idea to make it 2 times classification. First with biner classification, with all of the sample as the training set. Second I classify it to multiclass.\nBut the problem, how should I find the negative sample for the first classification while I didn't know the other object (let's say that come from 6th or 7th class). Anybody can help me, what should I do? Which samples that should I use as Negative Sample? It is the great idea or stupid idea? Is there other way to solve this problem?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":87,"Q_Id":30204877,"Users Score":1,"Answer":"The classic SVM does part the n-dimensional feature space with planes. That means every point in space is in one of the partitions and therefore belongs to one of the trained classes. there is no outlier detection.\nHowever there is also the concept of a one-class SVM that tries to encapsulate the \"known\" space and classifies into \"known\" and \"unknown\". The libSVM package also has probabilities, you could try to analyse if that helps. You could also try other classification concepts to  detect outliers like nearest neighbour","Q_Score":0,"Tags":"python,opencv,svm","A_Id":30208490,"CreationDate":"2015-05-13T02:58:00.000","Title":"SVM find member of outside training set","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to web2py I have web2py application in my local system i want to upload this application into web2py environment throught admin interface option present in web2py Upload & install packed application and do some modifications and run the application but i am  unable to uploded the app please give the suggesations how to do this\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":724,"Q_Id":30208421,"Users Score":0,"Answer":"Just use the file system.\nGUI:\nCopy your application folder to your new instance of web2py (\/web2py\/applications).   \nCommand line:\nscp -r \/home\/username\/oldarea\/web2py\/application\/myApp \/home\/username\/newarea\/web2py\/applications","Q_Score":2,"Tags":"python,web2py","A_Id":30356551,"CreationDate":"2015-05-13T07:31:00.000","Title":"how to upload the existing app in to web2py environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using sqlalchemy to query memory logs off a MySql database. I am using:\nsession.query(Memory).filter(Memmory.timestamp.between(from_date, to_date))\nbut the results after using the time window are still too many. \nNow I want to query for results withing the time window, but filtered down by asking for entries logged every X minutes\/hours and skipping the ones between, but cannot find a simple way to do it.\nTo further elaborate, lets say the 'l's are all the results from a query in a given timewindow:\nlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll\nTo dilute them, I am looking for a query that will return only the 'l's every X minutes\/hours so that I am not overwhelmed:\nl......l......l.....l......l......l......l.....l.....l.....l.\nI could get everything and then write a function that does this, but that beats the purpose of avoiding choking with results in the first place.\nSidenote:\nWorse comes to worse, I can ask for a row after skipping a predifined number of rows, using mod on the row id column. But it would be great to avoid that since there is a timestamp (DateTime type of sqlalchemy).\nEdit:\nThere could be some value using group by on timestamp and then somehow selecting a row from every group, but still not sure how to do this in a useful manner with sqlalchemy.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":587,"Q_Id":30234706,"Users Score":0,"Answer":"If I understand correctly your from_date and to_date are just dates. If you set them to python datetime objects with the date\/times you want your results between, it should work.","Q_Score":0,"Tags":"python,mysql,flask,sqlalchemy","A_Id":30238066,"CreationDate":"2015-05-14T10:14:00.000","Title":"How to query rows with a minute\/hour step interval in SqlAlchemy?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file?\nI am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":30249063,"Users Score":0,"Answer":"If you just want to know how long a process takes to run the time command is pretty handy.  Just run time <command> and it will report how much time it took to run with it counted in a few categories, like wall clock time, system\/kernel time and user space time.  This won't tell you anything about which parts of the system are taking up the amount of time.  You can always look at a profiler if you want\/need that type of information.\nThat said, as Barmar said, if you aren't doing much processing of the sites you are grabbing, the laptop is probably not going to be a limiting factor.","Q_Score":0,"Tags":"python,linux,performance,ubuntu,analytics","A_Id":30249116,"CreationDate":"2015-05-14T23:22:00.000","Title":"Is it possible to see what a Python process is doing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file?\nI am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":30249063,"Users Score":0,"Answer":"You can always store the system time in a variable before a block of code that you want to test, do it again after then compare them.","Q_Score":0,"Tags":"python,linux,performance,ubuntu,analytics","A_Id":30249196,"CreationDate":"2015-05-14T23:22:00.000","Title":"Is it possible to see what a Python process is doing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a collection of python scripts that import from each other.  If I want to use these in a location where the scripts are not physically present, how can I do this. I tried adding the path of the dir with the scripts to my $PATH but got no joy.  Any help appreciated, thanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":52,"Q_Id":30261701,"Users Score":1,"Answer":"Python doesn't share its own path with the general $PATH, so to be able to do what you're looking for, you must add your scripts in the $PYTHONPATH instead.","Q_Score":0,"Tags":"python,unix,path","A_Id":30261822,"CreationDate":"2015-05-15T14:12:00.000","Title":"Calling python scripts from anywehre","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed zipline package via Enthought Cantopy. Now I try to run a script using it in command prompt, but get error ImportError: No module named zipline.\nI also tried to run the same code using IPython, with the same output.\nI think it is related to python virtual environments, but don't know how to fix that.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2894,"Q_Id":30264100,"Users Score":0,"Answer":"These are the Requirements\/ Steps to Make Zipline Work:\n\nInstall Microsoft Visual C++ 2010 Express\nDownload and install python 3.4\nDownload zipline from github and Extract in C:\/\nSet Anaconda as project interpreter\nSince zipline is compatible with Python 3.4, you need to create an environment with Python 3.4\nRun this command in console of IDE:\n$conda create -n python34 python=3.4 anaconda(replace py34 with the location of python34 folder)\nNow run this command in console:\n$activate python34 #Activates the python 3.4 environment\n$pip install -e C:\\GitHub\\zipline (Directory where you extracted zipline)\nIngest data from quandl with below command\n$zipline ingest\n\nHope this helps others who visit this page!","Q_Score":3,"Tags":"python,virtualenv,zipline","A_Id":45375832,"CreationDate":"2015-05-15T16:10:00.000","Title":"zipline error. No module named zipline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I installed zipline package via Enthought Cantopy. Now I try to run a script using it in command prompt, but get error ImportError: No module named zipline.\nI also tried to run the same code using IPython, with the same output.\nI think it is related to python virtual environments, but don't know how to fix that.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2894,"Q_Id":30264100,"Users Score":2,"Answer":"I figured it out. The problem was in the version of python I have. I have 32-bit python and Enthought Cantopy with 64 bit python, installed zipline package was under 64 bit python while command prompt was using 32 bit version. Installing 64 bit python fixed the issue.","Q_Score":3,"Tags":"python,virtualenv,zipline","A_Id":30345896,"CreationDate":"2015-05-15T16:10:00.000","Title":"zipline error. No module named zipline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to install matplotlib on my lab computer that does not have internet access. Since it requires six for its full implementation, I am unable to run the scripts that has matplotlib module.\nI know how to install six by using pip but am stuck when there is no internet access.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":237,"Q_Id":30265151,"Users Score":0,"Answer":"You can install the package by running pip install six-1.9.0.tar.gz which requires you to copy six-1.9.0.tar.gz to the machine somehow.","Q_Score":0,"Tags":"python,matplotlib,six","A_Id":30265202,"CreationDate":"2015-05-15T17:12:00.000","Title":"is there a way to install six if I do not have access to internet?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got my own drawing loaded on to the screen and scaled it to the size I want, but the background of the program I used to make the drawing is still on the image. I noticed that when I move the image, the background doesn't move with the picture, but it actually looks like it's stretching out and it will cover wherever I move the picture to. I think this is because I used the .blit feature when getting my picture on screen, but I can't find a clear enough answer on how to get the picture on screen any other way. Can someone point me in the right direction, please?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":30315466,"Users Score":0,"Answer":"Not sure if this is the problem, but the stretching might be caused by not redrawing the background. Blitting is like painting, you can't erase stuff. When you want to move something, you need to repaint all the places that have changed - also the background that is not visible after movement.\nThe quickest way to do this is to redraw the whole background.","Q_Score":0,"Tags":"python,pygame","A_Id":30315673,"CreationDate":"2015-05-19T01:47:00.000","Title":"Getting my drawing into pygame without .blit()","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We know the crontab command is used for scheduled tasks in Linux.\nI want to write a Python script. Its function is to receive some data (these data are related to crontab setting) and execute a 'crontab' command in order to reset the content of the user's crontab file.\nI know how to execute external Linux commands in Python. But when you execute the crontab command (e.g. crontab -u xxx -e), you need to interact with an editor to modify the user's crontab file. (Suppose I don't know where the file is. For new users, crontab will generate a new file anyway. And I don't execute the command as the root user).\nSo the question is, how can I just execute crontab in Python? Is there any way to avoid interacting with an editor to modify the user's crontab file in Python? \nMy OS is ubuntu 14.01.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6083,"Q_Id":30318168,"Users Score":0,"Answer":"If all you want to do is reset the content of user crontab file , then just remove the crontab file (or overwrite with your default) , and reload the cron service  .","Q_Score":2,"Tags":"python,linux,ubuntu,cron,crontab","A_Id":30319952,"CreationDate":"2015-05-19T06:24:00.000","Title":"Python: How to handle 'crontab' command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We know the crontab command is used for scheduled tasks in Linux.\nI want to write a Python script. Its function is to receive some data (these data are related to crontab setting) and execute a 'crontab' command in order to reset the content of the user's crontab file.\nI know how to execute external Linux commands in Python. But when you execute the crontab command (e.g. crontab -u xxx -e), you need to interact with an editor to modify the user's crontab file. (Suppose I don't know where the file is. For new users, crontab will generate a new file anyway. And I don't execute the command as the root user).\nSo the question is, how can I just execute crontab in Python? Is there any way to avoid interacting with an editor to modify the user's crontab file in Python? \nMy OS is ubuntu 14.01.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6083,"Q_Id":30318168,"Users Score":0,"Answer":"You could\/should first dump your current crontab with crontab -l, edit it the way you want (e. g. add some lines, or modify) and then install the new one.\nThis usually works with crontab <filename>, but should as well work with crontab - and then piping the new contents into the process's stdin.","Q_Score":2,"Tags":"python,linux,ubuntu,cron,crontab","A_Id":30319851,"CreationDate":"2015-05-19T06:24:00.000","Title":"Python: How to handle 'crontab' command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We run a site called inteokej.nu and I need to find out which version of Python it runs on. I have pulled all the files to my computer but I don't know if and how I can find out the version number from them? The site is hosted on Heroku and maybe there's a way to find out the version with some kind of Heroku command?\nAs for now I don't have any possibilities to change any code (e.g. add a code snippet to get the version).\nThanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1237,"Q_Id":30320265,"Users Score":0,"Answer":"If you didn't have access to source code, from headers I can see that server is using Gunicorn 0.17.2, which is compatible with Python 2.x >= 2.6, which rules out i.e. Python 3.","Q_Score":1,"Tags":"python,django,heroku,version","A_Id":30321377,"CreationDate":"2015-05-19T08:20:00.000","Title":"Find out Python version from source code (or Heroku)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering if there is a simple way to get to the penultimate line of an open file. f.seek is giving me no end of trouble. I can easily get to the final line, but I can't figure out how to get to the line above that.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":490,"Q_Id":30324638,"Users Score":3,"Answer":"Assuming the file isn't too big and memory isn't a concern\nopen('file.txt').readlines()[-2]","Q_Score":1,"Tags":"python,file,seek","A_Id":30324707,"CreationDate":"2015-05-19T11:41:00.000","Title":"Printing to the penultimate line of a file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently learning how to use Python\/Django. I have successfully installed and setup Django. I am experiencing problems creating a project using the django-admin startproject mysite command. I have executed the command from command prompt using the path: C:\\Python34\\Scripts\\django-admin startproject mysite I tried searching for it in the current directory but could not find the folder. I tried executing the command again and found out that the directory exists in: \n'C:\\Windows\\system32\\mysite'\nI tried searching for it in this directory, but could not find it. How can I make this directory visible and set it under the Python directory?\nHere is the exact error I am getting in Command Prompt:\nCommandError: 'C:\\Windows\\system32\\mysite' already exists\nI am currently running Windows 7 - 64 Bit","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1391,"Q_Id":30324761,"Users Score":0,"Answer":"To Summarize the comments:\nThis is because you're in c:\\Windows\\system32. By default when you open command prompt is in that system32 directory. you need to change it first. To change directory use cd <what path you want>. \nOnce you're in the correct directory, you can start the project with django-admin startproject command.\nFor example: cd c:\\ to change directory to your root directory. then type C:\\Python34\\Scripts\\django-admin startproject mysite. It will then create the directory under C:\\mysite\nLast but not least, you can also put C:\\Python34\\Scripts in your system environment variable PATH, so that you don't have to type the full address of django-admin. Instead you can then use the django-admin startproject mysite.","Q_Score":0,"Tags":"python,django,windows-7-x64","A_Id":30326360,"CreationDate":"2015-05-19T11:47:00.000","Title":"Django - Cannot find Directory 'mysite'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was wondering if there is a way to detect, from a python script, if the computer is connected to the internet using a tethered cell phone?\nI have a Python script which runs a bunch of network measurement tests. Ideally, depending on the type of network the client is using (ethernet, wifi, LTE, ...) the tests should change. The challenge is how to get this information from the python client, with out asking the user to provide it. Especially detect tethering.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":605,"Q_Id":30330543,"Users Score":1,"Answer":"Normally not - from the computer's prospective the tethered cell phone is simply just another wifi router\/provider.\nYou might be able to detect some of the phone carrier networks from the traceroute info to some known servers (DNS names or even IP address ranges of network nodes - they don't change that often).\nIf you have control over the phone tethering you could also theoretically use the phone's wifi SSID (or even IP address ranges) to identify tethering via individual\/specific phones (not 100% reliable either unless you know that you can't get those parameters from other sources).","Q_Score":1,"Tags":"python,wifi,tethering","A_Id":30333512,"CreationDate":"2015-05-19T15:58:00.000","Title":"Detect if connected to the internet using a tethered phone in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have been working on tornado web framework from sometime, but still i didnt understood the ioloop functionality  clearly, especially how to use it in multithreading.\nIs it possible to create separate instance of ioloop for multiple server ??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4428,"Q_Id":30357663,"Users Score":3,"Answer":"The vast majority of Tornado apps should have only one IOLoop, running in the main thread. You can run multiple HTTPServers (or other servers) on the same IOLoop.\nIt is possible to create multiple IOLoops and give each one its own thread, but this is rarely useful, because the GIL ensures that only one thread is running at a time. If you do use multiple IOLoops you must be careful to ensure that the different threads only communicate with each other through thread-safe methods (i.e. IOLoop.add_callback).","Q_Score":5,"Tags":"python,http,tornado,web-frameworks","A_Id":30362810,"CreationDate":"2015-05-20T18:28:00.000","Title":"Tornado ioloop + threading","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following Python distributions installed on my Windows computer:\n\nPython 2.7 (IDLE)\nPython 3.4 (IDLE)\nAnaconda (Python 3.4)\n\nObviously, they all store their libraries in different locations. \nSo, how can I easily make a targeted installation to (a different) one of them each time I need to do so?\nFor example, right now, I am trying to install pytz to Python 3.4 (IDLE), and pip install seems to be defaulting to Python 2.7 (IDLE), which is the first distribution of Python I had installed on my computer.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":16412,"Q_Id":30363813,"Users Score":0,"Answer":"(in command prompt)C:\\Python34\\scripts\\pip.exe install pytz\nthis assumes your path is similar to mine. I used the default install location for all my pythons(2.7,3.4).","Q_Score":11,"Tags":"python,python-2.7,python-3.x,pip,anaconda","A_Id":42434840,"CreationDate":"2015-05-21T03:00:00.000","Title":"How can I control which Python distribution to pip install a package to when I have Python 2, Python 3, and Anaconda on my computer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started to us Python and Pycharm today. I installed Python 3.4.3 and pycharm 4.5, and I'm using Windows 7 OS on a acer TravelMate 8471 laptop.\nWhen I try to print(\"hello\"), the error is:\n\n\"Fatal Python error: Py_Initialize: can't initialize sys standard streams\n  LookupError: unknown encoding: x-windows-950\"\n\nDoes anyone know how to fix this issue ?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":4364,"Q_Id":30367541,"Users Score":3,"Answer":"Just put the hello.py file in a subdirectory of your project directory.\nAll the files in the project directory essentially provides relevant \"system information\" of the project. One project may contains couple of applications. Each application should be put in one subdirectory.\nset:\n\"Settings\/Editor\/File Encodings\/Project Encoding\"\nto:\n\"UTF-8\"","Q_Score":0,"Tags":"python,pycharm","A_Id":30636214,"CreationDate":"2015-05-21T07:43:00.000","Title":"Issue with pycharm:(Pycharm:Py_Initialize: can't initialize sys standard streams)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was wondering how can I store sent emails\nI have a send_email() function in a pre_save() and now I want to store the emails that have been sent so that I can check when an email was sent and if it was sent at all.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":559,"Q_Id":30368271,"Users Score":2,"Answer":"Another way to look at it: send the mail to your backup email account ex: backup@yourdomain.com. So you can store the email, check if the email is sent or not.\nOther than that, having an extra model for logged emails is a way to go.","Q_Score":3,"Tags":"python,django","A_Id":30369384,"CreationDate":"2015-05-21T08:22:00.000","Title":"Python \/ Django | How to store sent emails?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how can I store sent emails\nI have a send_email() function in a pre_save() and now I want to store the emails that have been sent so that I can check when an email was sent and if it was sent at all.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":559,"Q_Id":30368271,"Users Score":5,"Answer":"I think the easiest way before messing up with middleware or whatever is to simply create a model for your logged emails and add a new record if send was successful.","Q_Score":3,"Tags":"python,django","A_Id":30368302,"CreationDate":"2015-05-21T08:22:00.000","Title":"Python \/ Django | How to store sent emails?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to do syncdb in django 1.4.2?\ni.e. having data in database, how to load the models again when the data schema is updated?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2775,"Q_Id":30387974,"Users Score":3,"Answer":"Thanks Amyth for the hints. \nbtw the commands is a bit different, i will post a 10x tested result here.\nUsing south \n1. setup the model\npython manage.py schemamigration models --initial\n\ndump data if you have to\n\npython manage.py dumpdata -e contenttypes -e auth.Permission --natural > data.json\n\nsyncdb \n\npython manage.py syncdb\npython manage.py migrate models\n\nload the data back into the db \n\npython manage.py loaddata data.json\n\nAfterwards, you may use \n\npython manage.py schemamigration models --auto\npython manage.py migrate models\nafter every change you made in the models schema\n\nA few notes \n1. Unloading the database and reload it is essential, because if not doing so the first migration will tell you already have those models. \n2. The -e contenttypes -e auth.Permission --natural parameter in dumpdata is essential otherwise exception will be thrown when doing loaddata.","Q_Score":1,"Tags":"python,django,django-models,django-syncdb","A_Id":30392918,"CreationDate":"2015-05-22T03:38:00.000","Title":"How to do django syncdb in version 1.4.2?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a turn-based strategy game using Libtcod and Python. The game map has variable terrain and each tile can be 1 of 5 types:\n\nPlains - Costs 1 to move over\nForest - Costs 2\nRiver - Costs 4\nHill - Costs 3\nMountain - Impassable\n\nEach type has its own movement cost, so that it costs less \"move points\" to move through plains than through a forest, for example. I want to display all the squares a unit can move to given its movement range\/starting move points. \nLibtcod has pathfinding functionality built for both A* and Dijtskra and it is trivial to display all the squares in a given range, without accounting for terrain. \nHowever, I cannot figure out how I can implement the terrain costs, without having to write my own pathfinding algorithm. Looking at the docs I know it has something to do with:\ndef path_func(xFrom,yFrom,xTo,yTo,userData) : ...\npath_new_using_function(width, height, path_func, user_data=0, diagonalCost=1.41)\ndijkstra_new_using_function(width, height, path_func, user_data=0,  diagonalCost=1.41)\nbut I cannot figure out what the custom function is supposed to do. According to the docs, it supposed to \n\n...return the walk cost from coordinates xFrom,yFrom to coordinates\n  xTo,yTo. The cost must be > 0.0f if the cell xTo,yTo is walkable. It\n  must be equal to 0.0f if it's not.\n\nbut, isn't that the point of the dijtskra algorithm to begin with? That is, the algorithm is supposed to take into account the variable costs of each tile and then build a path accordingly. \nThe map itself already has the terrain and move costs applied to it, I just need a way to bridge that data with the pathfinding.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":965,"Q_Id":30408098,"Users Score":0,"Answer":"As far as I understand, what you want to achieve is very well possible with tcod's built-in pathfinding function.\npath_new_using_function will call your path_func with adjacent cells, so you can simply have it return the values you listed above depending on the terrain below (xFrom, yFrom) and\/or (xTo, yTo).","Q_Score":2,"Tags":"python,algorithm,dijkstra,libtcod","A_Id":54982870,"CreationDate":"2015-05-23T01:50:00.000","Title":"Python Libtcod: How to do pathfinding with variable move cost terrain?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Windows 7, Python 2.7.9 plus latest version of IPython 3.1.\nI ran %python inside an IPython Notebook and ran the cell, instead of returning the Python version, it did not run and jumped to a new line and printed a In [*] instead of a line number. Now no line is running in ipython everything is ignored when I try to run a cell value.\nAnyone know what has happen?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":114689,"Q_Id":30421373,"Users Score":2,"Answer":"For me to resolve this issue, I had to stop my anti-virus program.","Q_Score":59,"Tags":"python,ipython,jupyter","A_Id":37065235,"CreationDate":"2015-05-24T08:12:00.000","Title":"What does In [*] in IPython Notebook mean and how to turn it off?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Windows 7, Python 2.7.9 plus latest version of IPython 3.1.\nI ran %python inside an IPython Notebook and ran the cell, instead of returning the Python version, it did not run and jumped to a new line and printed a In [*] instead of a line number. Now no line is running in ipython everything is ignored when I try to run a cell value.\nAnyone know what has happen?","AnswerCount":3,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":114689,"Q_Id":30421373,"Users Score":7,"Answer":"The issue causing your kernel to be busy can be a specific line of code.  If that is the case, your computer may just need time to work through that line.  \nTo find out which line or lines are taking so long, as mentioned by Mike Muller you need to restart the program or interrupt the kernel.  Then go through carefully running one line at a time until you reach the first one with the asterisk.  \nIf you do not restart or interrupt your busy program, you will not be able to tell which line is the problem line and which line is not, because it will just stay busy while it works on that problem line.  It will continue to give you the asterisk on every line until it finishes running that one line of code even if you start back at the beginning.  This is extremely confusing, because lines that have run and produced output suddenly lose their output when you run them on the second pass.  Also confusing is the fact that you can make changes to your code while the kernel is busy, but you just can't get any new output until it is free again.\nYour code does not have to be wrong to cause this.  You may just have included a time-consuming command.  Bootstrapping has caused this for me. \nIf your code is what it needs to be, it doesn't actually matter which line is the problem line, and you just need to give all of your code time to run.  The main reasons to find out which is the problem line would be if some lines were expendable, or in case you were getting the asterisk for some other reason and needed to rule this one out.\nIf you are writing code on an internet service that times out when you aren't giving it input, your code might not have enough time to finish running if you just wait on it.  Scrolling every few minutes is usually enough to keep those pages from timing out.","Q_Score":59,"Tags":"python,ipython,jupyter","A_Id":54258699,"CreationDate":"2015-05-24T08:12:00.000","Title":"What does In [*] in IPython Notebook mean and how to turn it off?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Windows 7, Python 2.7.9 plus latest version of IPython 3.1.\nI ran %python inside an IPython Notebook and ran the cell, instead of returning the Python version, it did not run and jumped to a new line and printed a In [*] instead of a line number. Now no line is running in ipython everything is ignored when I try to run a cell value.\nAnyone know what has happen?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":114689,"Q_Id":30421373,"Users Score":74,"Answer":"The kernel is busy. Go to the menu Kernel and click Interrupt. If this does not work click Restart. You need to go in a new cell and press Shift + Enter to see if it worked.","Q_Score":59,"Tags":"python,ipython,jupyter","A_Id":30421412,"CreationDate":"2015-05-24T08:12:00.000","Title":"What does In [*] in IPython Notebook mean and how to turn it off?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking into what it would take to add a feature to my site so this is a pretty naive question. \nI'd like to be able to connect buyers and sellers via an email message once the buyer clicks \"buy\". \nI can see how I could do this in java script, querying the user database and sending an email with both parties involved. What I'm wondering is if there's a better way I can do this, playing monkey in the middle so they only receive an email from my site, and the it's automatically forwarded to the other party. That way they don't have to remember to hit reply-all, just reply. Also their email addresses remain anonymous. \nAgain assuming I generate a unique subject line with the transaction ID I could apply some rules here to just automatically forward the email from one party to the other but is there an API or library which can already do this for you?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":74,"Q_Id":30427300,"Users Score":0,"Answer":"What you're describing would be handled largely by your backend.  If this were my project, I would choose the following simple route:\nStore the messages the buyers\/sellers send in your own database, then simply send notification emails when messages are sent. Have them reply to each other on your own site, like Facebook and eBay do.\nAn example flow would go like this:\n\n(Gather the user and buyer's email addresses via registration)\nBuyer enters a message and clicks 'Send Message' button on seller's page\nForm is posted (via AJAX or via POST) to a backend script\nYour backend code generates an email message\n\nSets the 'To' field to the seller\n\nYour seller gets an email alert of the potential buyer which shows the buyer's message\nThe Seller then logs on to your site (made easy by a URL in the email) to respond\nThe Seller enters a response message on your site and hits 'Reply'\nBuyer gets an email notification with the message body and a link to your site where they can compose a reply.\n\n...and so on.  So, replies would have to be authored on-site, rather than as an email 'reply.'  \nIf you choose to go this route, there are some simple 3rd party \"transactional email\" providers, which is the phrase you'd use to find them.  I've personally used SendGrid and found them easy to set up and use.  They have a simple plug in for every major framework.  There is also Mandrill, which is newer but gets good reviews as well.","Q_Score":0,"Tags":"javascript,php,python,email","A_Id":30427829,"CreationDate":"2015-05-24T19:12:00.000","Title":"Email API for connecting in a marketplace?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a plugin in sublime Text 3, and I've hit a snag that I can't figure out. This is my first using python, and the first time I've done even driven desktop development in over a decade, so hopefully this is just a lack of knowledge on my part.\nThe plugin I'm writing uses text commands to gather data and then uses that data to call another text command that starts a subprocess than can run for a significant period of time depending on the arguments passed.\nthe following is some simplified code.\n\n    class BlaOneCommand(sublime_plugin.TextCommand):\n        def run(self, edit):\n            commandArgs = []\n            self.view.run_command('run_command', {\"args\": commandArgs})\n\n    class BlaTwoCommand(sublime_plugin.TextCommand):\n        def run(self, edit):\n            commandArgs = []\n            self.view.run_command('run_command', {\"args\": commandArgs})\n\n    class BlaThreeCommand(sublime_plugin.TextCommand):\n        def run(self, edit):\n            commandArgs = []\n            self.view.run_command('run_command', {\"args\": commandArgs}) \n\n    class BlaRunCommand(sublime_plugin.TextCommand):\n        def run(self, edit, args):\n            self.commandArgs = args\n            sublime.set_timeout_async(self.runCommand, 0)\n\n        def runCommand(self):\n            proc = ''\n            if os.name == 'nt':\n                startupinfo = subprocess.STARTUPINFO()\n                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW\n                proc = subprocess.Popen(self.commandArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, startupinfo=startupinfo)\n            else:\n                proc = subprocess.Popen(self.commandArgs, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)\n\n            while proc.poll() is None:\n                try:\n                    data = proc.stdout.readline().decode(encoding='UTF-8')\n                    print(data, end=\"\")\n                except:\n                    return;\n\nBlaOne, BlaTwo, & BlaThree are set up in a context menue. and what I need to do is disable some or all of them while the subprocess is running. I know this can be done by overriding the is_enabled method. However I'm struggling with how to tie them all together.\nHow can I make all the objects aware of each other, so they can enable\/disable each other?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":65,"Q_Id":30428292,"Users Score":0,"Answer":"After another 5 hours of reading, I figured it out. As I assumed, it was a lack of Python knowledge on my part. \nAll I needed to do was create a module level variable to use as a flag.","Q_Score":0,"Tags":"python,sublimetext3,sublimetext,sublime-text-plugin","A_Id":30431423,"CreationDate":"2015-05-24T21:01:00.000","Title":"how do you disable a text command from another text command in Sublimetext","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to split a string on whitespaces (default behavior), but I want it to split it only once - I.e. I want it to return an array with 2 items at most.\nIf it is not possible - i.e. if for specifying the limit I have to also specify the pattern - could you please tell how to specify the default one?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":17995,"Q_Id":30437566,"Users Score":3,"Answer":"Split string on consecutive whitespace\u2020 at most maxsplit times\u2020\u2020\n\u2020 Resulting list will contain no leading or trailing empty strings (\"\") if the string has leading or trailing whitespace\n\u2020\u2020 Splits are made left to right. To split the other way (right to left), use the str.rsplit() method (requires Python 2.4+)\n\nPython 2\n\nstr.split(sep[, maxsplit]])\n  Use str.split(None, maxsplit)\nNote:\n  Specifying sep as None \u225d not specifying sep\nstr.split(None, -1) \u225d str.split() \u225d str.split(None) \n\n\nPython 3\n\nstr.split(sep=None, maxsplit=-1)\n  Option A: Stick with positional arguments (Python 2 option): str.split(None, maxsplit)\n>>> ' 4 2 0 '.split(None, 420)\n['4', '2', '0']\n\nOption B (personal preference, using keyword arguments): str.split(maxsplit=maxsplit)\n>>> ' 4 2 0 '.split(maxsplit=420)` \n['4', '2', '0']","Q_Score":14,"Tags":"python,string","A_Id":56108440,"CreationDate":"2015-05-25T11:41:00.000","Title":"Python: str.split() - is it possible to only specify the \"limit\" parameter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a large A.csv file (~5 Gb) with several columns. One of the columns is Model.\nThere is another large B.csv file (~15 Gb) with Vendor, Name and Model columns.\nTwo questions:\n1) How can I create result file that combines all columns from A.csv and corresponding Vendor and Name from B.csv (join on Model). The trick is - how to do it when my RAM is 4 Gb only, and I'm using python.\n2) How can I create a sample (say, 1 Gb) result file that combines random subsample from A.csv (all columns) joined with Vendor and Name from B.csv. The trick is, again, in 4 Gb of RAM.\nI know how to do it in pandas, but 4 Gb is limiting factor I can't overcome (","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":862,"Q_Id":30441107,"Users Score":0,"Answer":"As @Marc B said, reading one row at a time is the solution.\nAbout the join I would do the following (pseudocode: I don't know python).\n\n\"Select distinct Model from A\" on first file A.csv\n\nRead all rows, search for Model field and collect distinct values in a list\/array\/map\n\n\"Select distinct Model from B\" on second file B.csv\n\nSame operation as 1, but using another list\/array\/map\n\nFind matching models\n\nCompare the two lists\/arrays\/maps finding only matching models (they will be part of the join)\n\nDo the join\n\nReading rows of file A which match model, read all the rows of file B which match same model and write a file C with join result. To this for all models.\nNote: it's not particularly optimized.\nFor point 2 just choose a subset of matching models and\/or read a part of rows of file A and\/or B with maching models.","Q_Score":0,"Tags":"python,file,memory,merge","A_Id":30441330,"CreationDate":"2015-05-25T14:57:00.000","Title":"Concatenate large files in sql-like way with limited RAM","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"New to scrapy.There are something confused me:what's the relationship between spiders,pipelines and items?\n1.should one pipeline handle only one specific item or it can handle multiple items?\n2.how to use one spider to crawl multiple items or I should use one spider just to crawl one item?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":722,"Q_Id":30448027,"Users Score":1,"Answer":"Item refers to an item of data that it's scraped. You can also call it a record or an entry.\nSpider is the thing that does crawling (starting requests and following links) and scraping (extracting data items from responses). They can schedule whatever amount of requests and extract whatever amount of items as you want, there isn't any limit.\nItem pipelines are an abstraction to process the items that are extracted by a spider. The idea is that you can combine different \"pipes\" through which the data items will come through, and then you'll arrange them in a way that will accomplish whatever you need. Examples of use cases for pipelines are applying validation constraints, saving data into a database, doing some clean-up on the data (e.g., remove HTML tags), etc.\nSo, recapping:\nSpiders extract data items, which Scrapy send one by one to a configured item pipeline (if there is possible) to do post-processing on the items.","Q_Score":1,"Tags":"python,web,scrapy","A_Id":30448526,"CreationDate":"2015-05-26T01:20:00.000","Title":"can one spider handle multiple items and multiple pipelines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Functional depth first search is lovely in directed acyclic graphs.\nIn graphs with cycles however, how do we avoid infinite recursion? In a procedural language I would mark nodes as I hit them, but let's say I can't do that. \nA list of visited nodes is possible, but will be slow because using one will result in a linear search of that list before recurring. A better data structure than a list here would obviously help, but that's not the aim of the game, because I'm coding in ML - lists are king, and anything else I will have to write myself.\nIs there a clever way around this issue? Or will I have to make do with a visited list or, god forbid, mutable state?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":5901,"Q_Id":30464163,"Users Score":12,"Answer":"You have to keep track of the nodes you visit. Lists are not king in the ML family, they're just one of the oligarchs. You should just use a set (tree based) to track the visited nodes. This will add a log factor compared to mutating the node state, but is so much cleaner it's not funny. If you know more about your nodes you can possibly eliminate the log factor by using a set not based on a tree (a bit vector say).","Q_Score":26,"Tags":"python,haskell,functional-programming,ocaml,sml","A_Id":30464615,"CreationDate":"2015-05-26T16:32:00.000","Title":"Functional Breadth First Search","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Functional depth first search is lovely in directed acyclic graphs.\nIn graphs with cycles however, how do we avoid infinite recursion? In a procedural language I would mark nodes as I hit them, but let's say I can't do that. \nA list of visited nodes is possible, but will be slow because using one will result in a linear search of that list before recurring. A better data structure than a list here would obviously help, but that's not the aim of the game, because I'm coding in ML - lists are king, and anything else I will have to write myself.\nIs there a clever way around this issue? Or will I have to make do with a visited list or, god forbid, mutable state?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":5901,"Q_Id":30464163,"Users Score":3,"Answer":"It is pretty OK to have a mutable state hidden inside the function. If it is not visible, then it doesn't exist. I usually use hash sets for this. But in general, you should stick to this if your profiling pinpointed that. Otherwise, just use set data structure. OCaml has an excellent Set based on eagerly balanced AVL trees.","Q_Score":26,"Tags":"python,haskell,functional-programming,ocaml,sml","A_Id":30465604,"CreationDate":"2015-05-26T16:32:00.000","Title":"Functional Breadth First Search","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.","AnswerCount":12,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":184308,"Q_Id":30464980,"Users Score":4,"Answer":"As someone mentioned in a comment, you can use which python if it is supported by CentOS. Another command that could work is whereis python. In the event neither of these work, you can start the Python interpreter, and it will show you the version, or you could look in \/usr\/bin for the Python files (python, python3 etc).","Q_Score":75,"Tags":"python,linux,macos,centos,version","A_Id":30465953,"CreationDate":"2015-05-26T17:18:00.000","Title":"How to check all versions of python installed on osx and centos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.","AnswerCount":12,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":184308,"Q_Id":30464980,"Users Score":4,"Answer":"COMMAND: python --version && python3 --version\nOUTPUT:\n\nPython 2.7.10 \n  Python 3.7.1\n\nALIAS COMMAND: pyver\nOUTPUT:\n\nPython 2.7.10 \n  Python 3.7.1\n\nYou can make an alias like \"pyver\" in your .bashrc file or else using a text accelerator like AText maybe.","Q_Score":75,"Tags":"python,linux,macos,centos,version","A_Id":58172493,"CreationDate":"2015-05-26T17:18:00.000","Title":"How to check all versions of python installed on osx and centos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.","AnswerCount":12,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":184308,"Q_Id":30464980,"Users Score":20,"Answer":"we can directly use this to see all the pythons installed both by current user and the root by the following: \n                                 whereis python","Q_Score":75,"Tags":"python,linux,macos,centos,version","A_Id":56606519,"CreationDate":"2015-05-26T17:18:00.000","Title":"How to check all versions of python installed on osx and centos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.","AnswerCount":12,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":184308,"Q_Id":30464980,"Users Score":7,"Answer":"Use, yum list installed command to find the packages you installed.","Q_Score":75,"Tags":"python,linux,macos,centos,version","A_Id":30466232,"CreationDate":"2015-05-26T17:18:00.000","Title":"How to check all versions of python installed on osx and centos","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am about to begin work on a project that will use Django to create a system with three tiers of users. Each user will login into the dashboard type interface (each user will have different types of tools on the dashboard). There will be a few CRUD type interfaces for each user tier among other things. Only users with accounts will be able to interact with the system (anyone visiting is greeted with a login screen).\nIt seems that many people recommend to simply modify the default Admin app to fit the requirements. Is this an ideal solution and if so, how do I set so the admin interface is at the site's root (instead of admin\/). Also, any documentation on in-depth and secure modification of the admin interface (along with the addition of different user tiers) would be appreciated.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":165,"Q_Id":30493289,"Users Score":3,"Answer":"This seems like a bad idea.\nOut of the box, the information architecture presented by the admin interface is going to be very flat where views essentially mirror what's in the database 1:1. I can imagine a slim subset of users in internal IT apps or similar where that may be appropriate but the compromises in usability are serious, without modifying the admin interface so much that you'll probably wish you had done your app the traditional way by the time you were done.\nIf usability and information architecture are not serious concerns or requirements for your app, then you may proceed apace.","Q_Score":0,"Tags":"python,django","A_Id":30493396,"CreationDate":"2015-05-27T21:16:00.000","Title":"Django 1.8, Using Admin app as the main site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a Django site that will have 4 types of users;\n\nSuper Admin: Essentially manages all types of users\nUserTypeA:   Can login to site and basically will have a CRUD interface for some arbitrary model. Also has extra attributes (specific info that only pertains to TypeA users)\nUserTypeB:   Can login to site and has extra information that pertains specifically to TypeB users, also can create and manage TypeC user accounts\nUserTypeC:   Can login to site and has extra information that pertains only to TypeC users.\n\nNoting that I plan on creating a custom interface and not utilizing the built-in admin interface. What would be the best method for implementing this user structure? I would prefer to use Django's built-in authentication system (which manages password salting and hashing, along with session management etc), but I would be open to using some other authentication system if it is secure and production ready.\nEDIT: Also, my plan is to use 1 log-in screen to access the site and utilize the permissions and user type to determine what will be available on each user's dashboard.\nEDIT: Would it be possible to accomplish this by using an app for each user type, and if so how would this be done with a single log-in screen.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":14610,"Q_Id":30495979,"Users Score":0,"Answer":"You should need just use Groups Django mechanism - you need to create four groups like userA and let say common and check whether user is in first or second group - then show him appropriate view","Q_Score":22,"Tags":"python,django,authentication","A_Id":60831884,"CreationDate":"2015-05-28T01:59:00.000","Title":"Django 1.8, Multiple Custom User Types","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I convert \"YANG\" data model to \"JSON\"? \nAs there is many many docs available in web, in that they changed in YANG\nsynatx to JSON but how the value for the leaf or leaf list they are getting? from where and how it will get actual data in JSON from YANG?","AnswerCount":2,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":13938,"Q_Id":30503356,"Users Score":-4,"Answer":"Yang is a modeling language, not a data generation language.\nWhat you are asking for is a simulator that will contain the same or pseudo logic as your application to generate data.","Q_Score":5,"Tags":"python,json,python-2.7,data-modeling,ietf-netmod-yang","A_Id":30657742,"CreationDate":"2015-05-28T10:04:00.000","Title":"how to convert YANG data model to JSON data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"unittest.shortDescription() returns only the first line of the test method's docstring.\nIs there a way to change this behavior, e.g. to display the entirety of the docstring, or to display another message ?\nWould I need to override shortDescription() ?\nEDIT: I did know that shortDescription() takes no arguments (besides the implicit object reference), but I was very unclear in the wording of my question.  What I'm really looking for is pointers to how to override shortDescription() and get at, say, the entire contents of the docstring.  Thanks !","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":291,"Q_Id":30516510,"Users Score":0,"Answer":"unittest.shortDescription() takes no arguments. You would have to override it to get the entire docstring.","Q_Score":1,"Tags":"python,python-2.7,python-unittest","A_Id":30516764,"CreationDate":"2015-05-28T20:28:00.000","Title":"How to extend\/customize unittest's shortDescription()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First, the server setup:\n\nnginx frontend to the world\ngunicorn running a Flask app with gevent workers\nPostgres database, connection pooled in the app, running from Amazon RDS, connected with psycopg2 patched to work with gevent\n\nThe problem I'm encountering is inexplicably slow queries that are sometimes running on the order of 100ms or so (ideal), but which often spike to 10s or more.  While time is a parameter in the query, the difference between the fast and slow query happens much more frequently than a change in the result set. This doesn't seem to be tied to any meaningful spike in CPU usage, memory usage, read\/write I\/O, request frequency, etc.  It seems to be arbitrary.\nI've tried:\n\nOptimizing the query - definitely valid, but it runs quite well locally, as well as any time I've tried it directly on the server through psql.\nRunning on a larger\/better RDS instance - I'm currently working on an m3.medium instance with PIOPS and not coming close to that read rate, so I don't think that's the issue.\nTweaking the number of gunicorn workers - I thought this could be an issue, if the psycopg2 driver is having to context switch excessively, but this had no effect.\nMore - I've been working for a decent amount of time at this, so these were just a couple of the things I've tried.\n\nDoes anyone have ideas about how to debug this problem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1181,"Q_Id":30519299,"Users Score":0,"Answer":"You could try this from within psql to get more details on query timing\nEXPLAIN sql_statement\nAlso turn on more database logging. mysql has slow query analysis, maybe PostgreSQL has an equivalent.","Q_Score":0,"Tags":"python,postgresql,amazon-rds,gevent","A_Id":30519353,"CreationDate":"2015-05-29T00:34:00.000","Title":"Inconsistently slow queries in production (RDS)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose that I have tuples of the form\n[(('d',0),('g',0)),(('d',0),('d',1)),(('i',0),('g',0))]\n\nThen how do I increment the numbers inside the tuple that they are of the form:-\n[(('d',1),('g',1)),(('d',1),('d',2)),(('i',1),('g',1))]\n\n?\n\nI am able to do this in a single for loop. But I am looking for shorter methods.\nP.S. You are allowed to create new tuples","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":13989,"Q_Id":30519737,"Users Score":3,"Answer":"You can't change the values in tuples, tuples are immutable.  You would need to make them be lists or create a new tuple with the value you you want and store that.","Q_Score":11,"Tags":"python,python-3.x","A_Id":30519763,"CreationDate":"2015-05-29T01:34:00.000","Title":"how to increment inside tuple in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently switched to VIM using NERDTree and python-mode. As NERDTree seems to have a conflict with python-mode and breaks my layout if I close one out of multiple buffers, I decided to switch to netrw since it is shipped with VIM anyway.\nBut having a file opened, if I open netrw by typing :E and open another file by hitting <enter> VIM closes the old one and opens the new one in the same window. And if I hit <o> in the same situation VIM adds another buffer but adds a new window in a horizontal split.\nHow can I add multiple files\/buffers to the buffer list and only show the last added buffer in the active window (without new splits) using netrw? #edited#\nThanks in advance! I hope I haven't missed something trivial from the manual.. ;-)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3905,"Q_Id":30533263,"Users Score":3,"Answer":"But having a file opened, if I open netrw by typing :E and open another file by hitting <enter> VIM closes the old one and opens the new one in the same window.\n[...]\nHow can I open multiple files\/buffers in the same window using netrw?\n\nBuffers are added to a list, the buffer list, and facultatively displayed  in one or more window in one or more tab pages.\nSince a window can only display one buffer, the only way to see two separate buffers at the same time is to display them in two separate windows. That's what netrw's o and v allow you to do.\nWhen you use <CR>to edit a file, the previous buffer doesn't go away: it is still in the buffer list and can be accessed with :bp[revious].","Q_Score":2,"Tags":"python,vim,nerdtree,python-mode,netrw","A_Id":30533662,"CreationDate":"2015-05-29T15:18:00.000","Title":"VIM + netrw: open multiple files\/buffers in the same window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a python library with a 0 argument function that my custom Robot Framework keywords can call.  It needs to know the absolute path of the file where the keyword is defined, and the name of the keyword.  I know how to do something similar with test cases using the robot.libraries.BuiltIn library and the ${SUITE_SOURCE} and ${TEST NAME} variables, but I can't find anything similar for custom keywords.  I don't care how complicated the answer is, maybe I have to dig into the guts of Robot Framework's internal classes and access that data somehow.  Is there any way to do this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2627,"Q_Id":30538356,"Users Score":1,"Answer":"I took a relatively quick look through the sources, and it seems that the execution context does have any reference to currently executing keyword. So, the only way I can think of resolving this is:\n\nYour library needs also to be a listener, since listeners get events when a keyword is started\nYou need to go through robot.libraries.BuiltIn.EXECUTION_CONTEXT._kw_store.resources to find out which resource file contains the keyword currently executing.\n\nI did not do a POC, so I am not sure whether this actually doable, bu that's the solution that comes to my mind currently.","Q_Score":1,"Tags":"python,robotframework","A_Id":30659802,"CreationDate":"2015-05-29T20:17:00.000","Title":"Robot Framework location and name of keyword","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to computer programming!\nI want to learn python and write my program and run it on my mac OS X machine.\nHow can i setup python programming tools on OS X and how can i use that ?\nI before this never use any other programming language.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":30543041,"Users Score":1,"Answer":"python is installed on OSX by default\nand you just need to open terminal and write \u2018python\u2019 command, then you can start your python coding","Q_Score":1,"Tags":"python,macos","A_Id":30543046,"CreationDate":"2015-05-30T06:23:00.000","Title":"How can i install python on OSX?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed a RESTful API using the Django-rest-framework in python. I developed the required models, serialised them, set up token authentication and all the other due diligence that goes along with it.\nI also built a front-end using Angular, hosted on a different domain. I setup CORS modifications so I can access the API as required. Everything seems to be working fine.\nHere is the problem. The web app I am building is a financial application that should allow the user to run some complex calculations on the server and send the results to the front-end app so they can be rendered into charts and other formats. I do not know how or where to put these calculations.\nI chose Django for the back-end as I expected that python would help me run such calculations wherever required. Basically, when I call a particular api link on the server, I want to be able to retrieve data from my database, from multiple tables if required, and use the data to run some calculations using python or a library of python (pandas or numpy) and serve the results of the calculations as response to the API call.\nIf this is a daunting task, I at least want to be able to use the API to retrieve data from the tables to the front-end, process the data a little using JS, and send it to a python function located on the server with this processed data, and this function would run the necessary complex calculations and respond with results which would be rendered into charts \/ other formats.\nCan anyone point me to a direction to move from here? I looked for resources online but I think I am unable to find the correct keywords to search for them. I just want a shell code kind of a thing to integrate into my current backed using which I can call some python scripts that I write to run these calculations.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2516,"Q_Id":30547102,"Users Score":2,"Answer":"I assume your question is about \"how do I do these calculations in the restful framework for django?\", but I think in this case you need to move away from that idea.\nYou did everything correctly but RESTful APIs serve resources -- basically your model.\nA computation however is nothing like that. As I see it, you have two ways of achieving what you want:\n1) Write a model that represents the results of a computation and is served using the RESTful framework, thus your computation being a resource (can work nicely if you store the results in your database as a way of caching)\n2) Add a route\/endpoint to your api, that is meant to serve results of that computation. \nPath 1: Computation as Resource\nCreate a model, that handles the computation upon instantiation.\nYou could even set up an inheritance structure for computations and implement an interface for your computation models.\nThis way, when the resource is requested and the restful framework wants to serve this resource, the computational result will be served.\nPath 2: Custom Endpoint\nAdd a route for your computation endpoints like \/myapi\/v1\/taxes\/compute.\nIn the underlying controller of this endpoint, you will load up the models you need for your computation, perform the computation, and serve the result however you like it (probably a json response).\nYou can still implement computations with the above mentioned inheritance structure. That way, you can instantiate the Computation object based on a parameter (in the above case taxes).\nDoes this give you an idea?","Q_Score":1,"Tags":"python,django,python-2.7,numpy","A_Id":30549380,"CreationDate":"2015-05-30T14:02:00.000","Title":"Running complex calculations (using python\/pandas) in a Django server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand that the following is valid in Python: foo = {'a': 0, 1: 2, some_obj: 'c'}\nHowever, I wonder how the internal works. Does it treat everything (object, string, number, etc.) as object? Does it type check to determine how to compute the hash code given a key?","AnswerCount":5,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":16230,"Q_Id":30553766,"Users Score":11,"Answer":"Types aren't used the same way in Python as statically types languages. A hashable object is simply one with a valid hash method. The interpreter simply calls that method, no type checking or anything. From there on out, standard hash map principles apply: for an object to fulfill the contract, it must implement both hash and equals methods.","Q_Score":8,"Tags":"python","A_Id":30553899,"CreationDate":"2015-05-31T04:12:00.000","Title":"Python: how does a dict with mixed key type work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on developing a PyQt4 application that will require a lot of widgets and I have run into an issue. When you say where to move the widget to (such as: btn.move(100, 100) it moves it properly, but if you resize the window, you can't see it). I'm not sure how to fix this. I don't want to restrict resizing of the window from the user, but I can't have widgets not showing up on screen.\nSo if the user resizes the program window to 600x600, how can I have widgets automatically change their location?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":42,"Q_Id":30560147,"Users Score":0,"Answer":"Use a Qt layout (like a QVBoxLayout, QHBoxLayout, or a QGridLayout)","Q_Score":0,"Tags":"python,widget,pyqt,pyqt4","A_Id":30563200,"CreationDate":"2015-05-31T17:05:00.000","Title":"How to update PyQt4 widget locations based on window size?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering how i could generate random numbers that appear in a circular distribution.  \nI am able to generate random points in a rectangular distribution such that the points are generated within the square of (0 <= x < 1000, 0 <= y < 1000):  \nHow would i go upon to generate the points within a circle such that:\n(x\u2212500)^2 + (y\u2212500)^2 < 250000 ?","AnswerCount":7,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":31584,"Q_Id":30564015,"Users Score":8,"Answer":"FIRST ANSWER:\nAn easy solution would be to do a check to see if the result satisfies your equation before proceeding.\nGenerate x, y (there are ways to randomize into a select range)\nCheck if ((x\u2212500)^2 + (y\u2212500)^2 < 250000) is true\nif not, regenerate.\nThe only downside would be inefficiency.\nSECOND ANSWER:\nOR, you could do something similar to riemann sums like for approximating integrals. Approximate your circle by dividing it up into many rectangles. (the more rectangles, the more accurate), and use your rectangle algorithm for each rectangle within your circle.","Q_Score":14,"Tags":"python,distribution,point","A_Id":30564059,"CreationDate":"2015-06-01T00:10:00.000","Title":"How to generate random points in a circular distribution","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm deploying an python web server on AWS now and I have a some question about it. I'm using websocket to communicate between back end and front end.\n\nDo I have to use framework like django or flask?\nIf not, where should I put the index.html file? in other word, after deploying, how do AWS know the default page of my application?\n\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":30565431,"Users Score":2,"Answer":"AWS doesn't \"know\" anything about your content. The webserver that you install will be configured to point to the \"root\" directory in which index.html (or something equivalent) should be. \nSince it depends on which webserver (django, flask, Jinja etc) you install - you should lookup its documentation!","Q_Score":1,"Tags":"python,amazon-web-services,websocket,webserver,amazon-elastic-beanstalk","A_Id":30565453,"CreationDate":"2015-06-01T03:57:00.000","Title":"Deploy python web server on AWS Elastic Beanstalk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a queryset which I iterate through in a loop. I use data from the queryset to change data inside the queryset which might be needed in a lter step of the loop.\nNow the queryset is only loaded once at the beginning of the loop. How can I make django reload the data in every iteration?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":30575409,"Users Score":1,"Answer":"You can reload each object in the start of the loop body. Just use TheModel.objects.get(pk=curr_instance.pk) to do this.","Q_Score":0,"Tags":"python,django,django-queryset","A_Id":30579869,"CreationDate":"2015-06-01T13:53:00.000","Title":"Django how to not use cached queryset while iterating?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"this is a conceptual question. As part hobby, part art project I'm looking to build a Python script that allows two people to play battleships between their computers (across the net, without being on the same network).\nThe idea would be you could run the program something like:\npython battleships.py 192.168.1.1\nWhere the IP address would be the computer you wanted to do battle with.\nI have some modest Python coding abilities but I'm curious how hard it would be to build this and how one might go about it?\nOne key goal is that it must require almost zero set-up: I'm hoping anyone can download the python script, open the terminal and play battleships with someone else.\nThanks!","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":282,"Q_Id":30579494,"Users Score":-1,"Answer":"I think the simpliest way to do this is reading socket server in this battleship game. But here is a problem, in this case you will have a problem with connecting, in case when your ip is invisible from the internet.","Q_Score":0,"Tags":"python,p2p","A_Id":30579803,"CreationDate":"2015-06-01T17:23:00.000","Title":"Conceptual: how to code battleships between two computers in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how permissions\/groups\/user work together in a \"normal\" way.\nHowever, I feel incomfortable with this way to do in my case, let me explain why.\nIn my Django models, all my users are extended with models like \"Landlord\" or \"Tenant\".\nEvery landlord will have the same permissions, every tenant will have other same permissions.. So it seems to me there is not interest to handle permission in a \"user per user\" way.\nWhat I'd like to do is link the my Tenant and Landlord models (not the instances) to lists of permissions (or groups).\nIs there a way to do this? Am I missing something in my modelisation? How would you do that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":111,"Q_Id":30591965,"Users Score":1,"Answer":"django.contrib.auth has groups and group permissions, so all you have to do is to define landlords and tenants groups with the appropriate permissions then on your models's save() method (or using signals or else) add your Landlord and Tenant instances to their respective groups.","Q_Score":0,"Tags":"python,django,database-design","A_Id":30592097,"CreationDate":"2015-06-02T09:16:00.000","Title":"Can I link Django permissions to a model class instead of User instances?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently trying to right a python script that overnight turns off all of our EC2 instances then in the morning my QA team can go to a webpage and press a button to turn the instances back on.\nI have written my python script that turns the severs off using boto.  I also have a function which when ran turns them back on.\nI have an html doc with buttons on it.\nI'm just struggling to work out how to get these buttons to call the function.  I'm using bottle rather than flask and I have no Java SCript experience.  So I would like t avoid Ajax if possible.  I dont mind if the whole page has to reload after the button is pressed.  After the single press the webpage isnt needed anyway.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":617,"Q_Id":30592411,"Users Score":3,"Answer":"What I have ended up doing to fix this issue is used bottle to make a url which completes the needed function.  Then just made an html button that links to the relevant url.","Q_Score":1,"Tags":"python,html,boto,bottle","A_Id":30595791,"CreationDate":"2015-06-02T09:36:00.000","Title":"html buttons calling python functions using bottle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a Kivy UI for cmd line utility I have developed. Everything works fine, but some of the processes can take from a few seconds to a few minutes to process and I would like to provide some indication to the user that the process is running. Ideally, this would be in the form of a spinning wheel or loading bar or something, but even if I could update my display to show the user that a process is running, it would be better than what I have now.\nCurrently, the user presses a button in the main UI. This brings up a popup that verifies some key information with the user, and if they are happy with those options, they press a 'run' button. I have tried opening a new popup to tell them that the process is running, but because the display doesn't update until the process finishes, this doesn't work.\nI have a lot of coding experience, but mostly in the context of math and engineering, so I am very new to the designing of UIs and having to handle events and threads. A simple self-contained example would be greatly appreciated.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":12311,"Q_Id":30595908,"Users Score":1,"Answer":"I've dealt with similar problem and creating new thread didn't do the trick. I had to use Clock.schedule_once(new_func) function. It schedules function call to the next frame, so it is going to run almost immediately after callback ends.","Q_Score":9,"Tags":"python,user-interface,events,kivy","A_Id":56684592,"CreationDate":"2015-06-02T12:20:00.000","Title":"Building a simple progress bar or loading animation in Kivy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Someone gave me a python file to open and use as a resource. The only issue is I don't know anything about python, it's very different from my basic knowledge of coding. \nThe file is not a normal .py file, but rather a console-less .pyw file. I have imported the newest version of python and installed PySide, but I have had no successful attempts at opening the file.\nI was wondering if someone might know how to open this kind of file? Does it need to be somewhere specific?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3111,"Q_Id":30596353,"Users Score":1,"Answer":"Right-click the file, click properties, under general it says \"opens with:\"...\nClick the \"Change\" button to the right of that, and then click more options. On that menu there should be an option called \"pythonw\" click that. Then on the bottom-right click \"apply\", then \"OK\". Then just double-click on the file and it should run with no console window so you won't be able to see it running.","Q_Score":1,"Tags":"python,python-3.x,pyside","A_Id":38494564,"CreationDate":"2015-06-02T12:38:00.000","Title":"How to open PYW files in Windows 8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"My Python app needs web.py to run but I'm unable to figure out how to get it up to bluemix. I see no options using cf push. I tried to \"import web\" and added some additional code to my app without success.\nWhen I push my Python app to bluemix without web.py it fails (naturally) since it does not have what it needs to run.\nI'm sure I'm just missing an import mechanism. Any help?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1450,"Q_Id":30603407,"Users Score":4,"Answer":"The cause for this problem was that I was not correctly telling my Python app the needed configuration information when I pushed it out to Bluemix.\nWhat I ended up having to do was add a requirements.txt file and a Procfile file into the root directory of my Python application, to draw that connection between my Python app and the needed libraries\/packages.\nIn the requirements.txt file I specified the library packages needed by my Python app. These are the file contents:\n\nweb.py==0.37\n  wsgiref==0.1.2\n\nwhere web.py==0.37 is the version of the web.py library that will be downloaded, and wsgiref==0.1.2 is the version of the web server gateway interface that is needed by the version of web.py I am using.\nMy Procfile contains the following information:\n\nweb: python .py $PORT\n\nwhere myappname is the name of my Python app, and $PORT is the port number that my Python app uses to receive requests. \nI found out too that $PORT is optional because when I did not specify $PORT my app ran with the port number under the VCAP_APP_PORT environment variable for my app. \nFrom there it was just a matter of pushing my app out to Bluemix again only this time it ran fine.","Q_Score":2,"Tags":"python,ibm-cloud","A_Id":30603436,"CreationDate":"2015-06-02T18:05:00.000","Title":"How to import a 3rd party Python library into Bluemix?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a Python application that utilizes the Tumblr API and was wondering how I would go about hiding, or encrypting, the API key. \nGithub warns against pushing this information to a repo, so how would I make the application available to the public and still follow that policy?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":248,"Q_Id":30610892,"Users Score":5,"Answer":"Why do you need to post your API key? Why not post your app code to Github without your API key and have a configuration parameter for your users to add their own API key?","Q_Score":7,"Tags":"python,api,github","A_Id":30612182,"CreationDate":"2015-06-03T04:31:00.000","Title":"API key encryption for Github?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to create a random permutation of the numbers [1,2,...,N] where N is a big number. So I don't want to store all elements of the permutation in memory, but rather iterate over the elements of my particular permutation without holding former values in memory.\nAny idea how to do that in Python?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1933,"Q_Id":30615536,"Users Score":0,"Answer":"This is a generic issue and rather not a Python-specific. In most languages, even when iterators are used for using structures, the whole structure is kept in memory. So, iterators are mainly used as \"functional\" tools and not as \"memory-optimization\" tools. \nIn python, a lot of people end up using a lot of memory due to having really big structures (dictionaries etc.). However, all the variables-objects of the program will be stored in memory in any way. The only solution is the serialization of the data (save in filesystem, Database etc.).\nSo, in your case, you could create a customized function that would create the list of the permutations. But, instead of adding each element of the permutation to a list, it would save the element either in a file (or in a database with the corresponding structure). Then, you would be able to retrieve one-by-one each permutation from the file (or the database), without bringing the whole list in memory.\nHowever, as mentioned before, you will have to always know in which permutation you currently are. In order to avoid retrieving all the created permutations from Database (which would create the same bottleneck), you could have an index for each place holding the symbol used in the previously generated permutation (and create the permutations adding the symbols and a predefined sequence).","Q_Score":6,"Tags":"python,algorithm,iterator,permutation","A_Id":30615998,"CreationDate":"2015-06-03T09:06:00.000","Title":"Generate random permutation of huge list (in Python)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry in advance if there is an obvious answer to this, I'm still learning the ropes with Django.\nI'm creating a website which has 6 pre determined subjects (not stored in DB)\nenglish, civics, literature, language, history, bible\neach subject is going to be associated with a unique color.\nI've got a template for a subject.html page and a view that loads from the url appname\/subject\/subjectname\nwhat I need to do is apply particular css to style the page according to the subject accessed. for example if the user goes to appname\/subject\/english I want the page to be \"themed\" to english.\nI hope I've made myself clear, also I would like to know if there is a way I can add actual css code to the stylesheet and not have to change attributes one by one from the back-end.\nthanks very much!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":6764,"Q_Id":30631062,"Users Score":1,"Answer":"You can do this is many ways.\nIn general you need to return some variable from your view to the html and depending on this variable select a style sheet, if your variable name will match you style sheet's name you can do \"{{variable}}.css\", if not you can use JQuery.","Q_Score":4,"Tags":"python,html,css,django","A_Id":30631241,"CreationDate":"2015-06-03T21:25:00.000","Title":"Changing css styles from view in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Tips are there for dropping column and rows depending on some condition.\nBut I want to drop the whole dataframe created in pandas.\nlike in R : rm(dataframe) or in SQL: drop table \nThis will help to release the ram utilization.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":9398,"Q_Id":30642356,"Users Score":5,"Answer":"Generally creating a new object and binding it to a variable will allow the deletion of any object the variable previously referred to. del, mentioned in @EdChum's comment, removes both the variable and any object it referred to.\nThis is an over-simplification, but it will serve.","Q_Score":2,"Tags":"python,pandas,dataframe","A_Id":30648685,"CreationDate":"2015-06-04T11:12:00.000","Title":"how to drop dataframe in pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to call my index(request) function thats in views.py upon every page reload.  Currently index(request) only gets called when the app originally loads.  Every other page reload after that calls another function in views.py called filter_report(request).  The problem I am running into is that 85% of the code in filter_report(request) is also in index(request) and from my understanding you don't really want 2 functions that do a lot of the same stuff.  What I would like to do is take that 15% of code that isn't in index(request) but is in filter_report(request) and split it into different methods and just have index(request) call those other methods based on certain conditionals.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":519,"Q_Id":30649428,"Users Score":1,"Answer":"Well, that really is not how it works. Each view is separate and is only called from the URLs that map to it. If you have shared code, you probably want to either factor it out into separate functions that you can call from each view, or use something like a template tag or context processor to add the relevant information to the template automatically.","Q_Score":0,"Tags":"python,django,url-routing","A_Id":30649463,"CreationDate":"2015-06-04T16:35:00.000","Title":"Django: call index function on page reload","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question has potentially two parts but maybe only one if the first part can be encapsulated by the second. I am using python with numpy and netCDF4\nFirst:\nI have four lists of different variable values (hereafter referred to elevation values) each of which has a length of 28. These four lists are one set of 5 different latitude values of which are one set of the 24 different time values. \nSo 24 times...each time with 5 latitudes...each latitude with four lists...each list with 28 values.\nI want to create an array with the following dimensions (elevation, latitude, time, variable)\nIn words, I want to be able to specify which of the four lists I access,which index in the list, and specify a specific time and latitude. So an index into this array would look like this:\narray(0,1,2,3) where 0 specifies the first index of the the 4th list specified by the 3. 1 specifies the 2nd latitude, and 2 specifies the 3rd time and the output is the value at that point.\nI won't include my code for this part since literally the only things of mention are the lists\nlist1=[...]\nlist2=[...]\nlist3=[...]\nlist4=[...]\nHow can I do this, is there an easier structure of the array, or is there anything else I a missing?\nSecond:\nI have created a netCDF file with variables with these four dimensions. I need to set those variables to the array structure made above. I have no idea how to do this and the netCDF4 documentation does a 1-d array in a fairly cryptic way. If the arrays can be made directly into the netCDF file bypassing the need to use numpy first, by all means show me how. \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1886,"Q_Id":30655378,"Users Score":0,"Answer":"After talking to a few people where I work we came up with this solution:\nFirst we made an array of zeroes using the following argument:\narray1=np.zeros((28,5,24,4))\nThen appended this array by specifying where in the array we wanted to change:\narray1[:,0,0,0]=list1\nThis inserted the values of the list into the first entry in the array.\nNext to write the array to a netCDF file, I created a netCDF in the same program I made the array, made a single variable and gave it values like this:\nnetcdfvariable[:]=array1\nHope that helps anyone who finds this.","Q_Score":0,"Tags":"python,arrays,numpy,multidimensional-array,netcdf","A_Id":30713394,"CreationDate":"2015-06-04T22:35:00.000","Title":"Creating and Storing Multi-Dimensional Array in a netCDF File","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose you write a Django website and use git to manage the source code. Your website has various instances (one for each developer, at least).\nWhen you perform a change on the model in a commit, everybody needs to update its own database. In some cases it is enough to run python manage.py migrate, in some other cases you need to run a few custom SQL queries and\/or run some Python code to update values at various places.\nHow to automate this? Is there a clean way to bundle these \"model updates\" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":216,"Q_Id":30669568,"Users Score":1,"Answer":"You should track migrations. The only thing that you must keep an eye out for is at branch merge. If everyone uses a feature branch and develops on his branch then the changes are applied once the branch is integrated. At that point (pull request time or integration time) you need to make sure that the migrations make sense and if not fix them.","Q_Score":1,"Tags":"python,sql,django,git,workflow","A_Id":30669779,"CreationDate":"2015-06-05T14:51:00.000","Title":"How to track Django model changes with git?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose you write a Django website and use git to manage the source code. Your website has various instances (one for each developer, at least).\nWhen you perform a change on the model in a commit, everybody needs to update its own database. In some cases it is enough to run python manage.py migrate, in some other cases you need to run a few custom SQL queries and\/or run some Python code to update values at various places.\nHow to automate this? Is there a clean way to bundle these \"model updates\" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":30669568,"Users Score":4,"Answer":"All changes to models should be in migrations. If you \"need to run a few custom SQL queries and\/or run some Python code to update values\" then those are migrations too, and should be written in a migration file.","Q_Score":1,"Tags":"python,sql,django,git,workflow","A_Id":30669896,"CreationDate":"2015-06-05T14:51:00.000","Title":"How to track Django model changes with git?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After I make an exe file, there are many files such as .pyd that my exe depend on them..\nI want to make a program with only one exe file which will be handie..\nplease help me","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":280,"Q_Id":30699683,"Users Score":0,"Answer":"Py2exe is a tool provides an exe application which can be run without installing python interpreter, after packaging you find your exe and dlls of interpreter and all modules... In dist folder. It does nt provide all in one exe, use pyinstaller instead","Q_Score":0,"Tags":"python,exe,py2exe","A_Id":30699958,"CreationDate":"2015-06-07T23:56:00.000","Title":"PYTHON py2exe makes too many files.. how do I execute only one .EXE file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using iPython notebook build a online interactive teaching website, but I don't want users to run command line, any idea how to remove iPython notebook command line function? Is there any configuration or something? I have been stuck here for 3 days!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":750,"Q_Id":30713927,"Users Score":0,"Answer":"You can't make os.system or subprocess unavailable, and users could use these to build themselves terminals even if you disable the built in terminals. However, if you run the ipython instance in a sandbox then it won't matter that they have command line access.","Q_Score":0,"Tags":"python,terminal,ipython","A_Id":30714067,"CreationDate":"2015-06-08T15:58:00.000","Title":"How to stop the iPython notebook to run the command line, run only python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have tried import file csv using bulk insert but it is failed, is there another way in query to import csv file without using bulk insert ?\nso far this is my query but it use bulk insert :\nbulk insert [dbo].[TEMP] from \n\n'C:\\Inetpub\\vhosts\\topimerah.org\\httpdocs\\SNASPV0374280960.txt' with\n  (firstrow=2,fieldterminator = '~', rowterminator = ' ');","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":777,"Q_Id":30724143,"Users Score":0,"Answer":"My answer is to work with bulk-insert.\n1. Make sure you have bulk-admin permission in server.\n2. Use SQL authentication login (For me most of the time window authentication login haven't worked.) for bulk-insert operation.","Q_Score":0,"Tags":"python,mysql,sql,sql-server,csv","A_Id":30724975,"CreationDate":"2015-06-09T06:05:00.000","Title":"how to import file csv without using bulk insert query?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just installed a intel MKL optimized version of scipy and when running my benchmarks, I got remarkable speedup with it. I then looked closer and found out it was running on 20 cores ... how do I restrict it to single threaded mode? Is there a way I could have installed it to single threaded mode by default, while leaving the option open to run on a specified number of cores?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":225,"Q_Id":30736765,"Users Score":2,"Answer":"Upon further investigation it looks you are able to set the environment variable MKL_NUM_THREADS to achieve this.","Q_Score":2,"Tags":"python,multithreading,numpy,intel,intel-mkl","A_Id":30737140,"CreationDate":"2015-06-09T15:41:00.000","Title":"Restrict MKL optimized scipy to single thread","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm confused as to the difference between using a function in commands of tkinter items.  say I have  self.mb_BO.add_radiobutton(label= \"Red\",   variable=self.BO, value=2, command=self.red)\n\nwhat is the difference in how the add statement works from this:\nself.mb_BO.add_radiobutton(label= \"Red\",   variable=self.BO, value=2, command=self.red())\n\nwhere func red(self) changes the color to red.\nAnd self.mb_BO.add_radiobutton(label= \"Red\",   variable=self.BO, value=2, command=lambda:  self.red())\n\nEssentially I don't understand what these commands are doing and when to use the callback or function reference.  I've spent hours looking online for an easy to follow summary to no avail and I am still just as confused.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":881,"Q_Id":30769851,"Users Score":2,"Answer":"A good way to look at it is to imagine the button or binding asking you the question \"what command should I call when the button is clicked?\". If you give it something like self.red(), you aren't telling it what command to run, you're actually running the command. Instead, you have to give it the name (or more accurately, a reference) of a function. \nI recommend this rule of thumb: never use lambda. Like all good rules of thumb, it only applies for as long as you have to ask the question. Once you understand why you should avoid lambda, it's OK to use it whenever it makes sense.","Q_Score":1,"Tags":"python,lambda,tkinter,command","A_Id":30770368,"CreationDate":"2015-06-11T00:59:00.000","Title":"commands in tkinter when to use lambda and callbacks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know the difference between static and dynamic linking in C or C++. But what does it mean in Python? Since it's just an interpreter, and only having one style of import mechanism of modules, how does this make sense? \nIf I freeze my Python application with cx_freeze by excluding a specific library, is it a kind of dynamic linking? Because, users have to download and install that library by themselves in order to run my application.\nActually my problem is, I'm using the PySide library (with LGPL v2.1) to develop a Python GUI application. The library says I should dynamically link to the library to obey their legal terms (same as Qt). In this case, how do I link to PySide dynamically?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2509,"Q_Id":30770219,"Users Score":1,"Answer":"In python there's no static linking. All the imports requires the correct dependencies to be installed on our target machine. The choice of the version of such libraries are in our decision.\nNow let's come to the binary builders for python. In this case, we'll have to determine the linking type based on the GNU definitions. If the user can replace the dependency as he likes, it's dynamic. If the dependency is attached together with the binary itself, it's static linking. In case of cx_freeze or pyinstaller, if we build this as one file, it's static linking. If we build this in normal mode where all the dependencies are collected as separate files, it's dynamic linking. Idea is, whether we can replace the dependency in target machine or not.","Q_Score":12,"Tags":"python,qt,pyside,cx-freeze","A_Id":43317798,"CreationDate":"2015-06-11T01:45:00.000","Title":"What does it mean for statically linking and dynamically linking in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a sensor app in android and I've to store the accelerometer readings on a django server and then retrieve them on my device. I am new to django and I don't know how to communicate with Android's HttpClient and a django server.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":30786979,"Users Score":0,"Answer":"Django doesn't care what the client is, and Android's HttpClient don't care whether the url are served by Django, Tomcat, Rails, Apache or whatever. It's only HTTP. IOW:\n\nlearn to write a Django App (it's fully documented)\nlearn to use the Android's HttpClient (it's fully documented too IIRC)\nconnect the dots...","Q_Score":0,"Tags":"android,python,django,networking,android-networking","A_Id":30787714,"CreationDate":"2015-06-11T16:58:00.000","Title":"I want to write a django application that can respond to the HttpClient requests from an android device. Can I have an example code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm moving to pycharm from sublime text and can't get it working with kivy and virtualenv. I've created a virtualenv with a new project in pycharm but I can't figure out how to get kivy working. The kivy help shows using the kivy.bat as the python interpreter but I want to use the virtualenv. One possible option would be to add all the environmental variables from the kivy.bat, but this doesn't sound like fun to do with multiple virtualenvs. Any help or tips would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":295,"Q_Id":30787397,"Users Score":0,"Answer":"I found a way to set the environmental variables found in the kivy.bat. I simply created a new .bat that sets the environmental variables and then runs pycharm from the command line. This allows the variables to persist between projects.","Q_Score":1,"Tags":"python,pycharm,kivy","A_Id":30808862,"CreationDate":"2015-06-11T17:20:00.000","Title":"Pycharm, virtualenv and kivy setup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to do a schemamigration in Django with south using the following command where core is the app I would like to migrate.\n$ python manage.py schemamigration core --auto\n\nUnfortunately this throws the following KeyError:\nKeyError: u\"The model 'externaltoolstatus' from the app 'core' is not available in this migration.\"\n\nDoes anybody know a way to how figure out what went wrong or where\/when this error was thrown during the migration?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":30804783,"Users Score":0,"Answer":"I figured out the last migration files were accidentally corrupted and caused the KeyError.","Q_Score":0,"Tags":"python,django,django-south","A_Id":30805141,"CreationDate":"2015-06-12T13:50:00.000","Title":"Django south schemamigration KeyError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"How would the output of one script be passed as the input to another? For example if a.py outputs format.xml then how would a.py call b.py and pass it the argument format.xml? I think it's supposed to work like piping done on the command line.\nI've been hired by a bunch of scientists with domain specific knowledge but sometimes there computer programming requirements don't make sense. There's a long chain of \"modules\" and my boss is really adamant about 1 module being 1 python script, and the output of one module is the input of the next. I'm very new to Python, but if this design pattern rings a bell to anyone let me know.\nWorse yet the project is to be converted to executable format (using py2exe) and there still has to be the same number of executable files as .py files.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":360,"Q_Id":30838875,"Users Score":1,"Answer":"The pattern makes sense in some cases, but for me it's when you want to be able to run each module as a self sustained executeable.\nI.E. Should you want to use the script from within FORTRAN or similar language, it is the easiest way, to build the python module to an executeable, and then call it from FORTRAN.\nThat would not mean that one module is pr definition 1 python file, just that it only has one entry point, and is in fact executeable.\nThe one module pr script, could be to make it easier to locate the code. Or to mail it to someone for code inspection or peer review (done often in scientific communities)\nSo the requirements may be a mix of technical and social requirements.\nAnyway back to the problem.\nI would use the subprocess module to call the next module. (with close_fds set to true)\n\nIf close_fds is true, all file descriptors except 0, 1 and 2 will be\n  closed before the child process is executed. (Unix only). Or, on\n  Windows, if close_fds is true then no handles will be inherited by the\n  child process. Note that on Windows, you cannot set close_fds to true\n  and also redirect the standard handles by setting stdin, stdout or\n  stderr.","Q_Score":0,"Tags":"python,python-3.x,requirements","A_Id":30839105,"CreationDate":"2015-06-15T06:48:00.000","Title":"output of one file input to next","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python development using virtualenv. I have installed python 2.7, pip, virtualenv, virtualenvwrapper in windows and I am using windows PS. I have referred lots of tutorials for setting  this up. Most of them contained the same steps and almost all of them stopped short of explaining what to do after the virtualenv was created. \n\nHow do I actually work in a virtualenv? suppose I want to create a new flask application after installing that package in my new env virtualenv (eg; testenv).\nIf I already have an existing project and I want to put it inside a newly created virtual env, how do I do that? How should the folder structure be like?\nMy understanding of virtual env is that it provides a sandbox for your application by isolating it and keeping all its dependencies to itself in that particular env (and not sharing and it with others). Have I understood it wrong?\n\nPlease help me clear this.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":30856274,"Users Score":0,"Answer":"testenv\/bin\/pip and testenv\/bin\/python\nI'd check it in a local repository and check it out in the virtualenv. \nNo, you have not.","Q_Score":1,"Tags":"python,windows,directory,project,virtualenv","A_Id":30856299,"CreationDate":"2015-06-15T22:53:00.000","Title":"Run an existing python web application inside a virtalenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am using 2 python programs with rc.local for my raspberry, first program is my main program and the other is the second program. The second program is shutdown the raspberry, but when i do the second program my first program is still running and will stopped until raspberry truly shutdown. \nI want to make the second program kill the first program before raspberry truly shutdown, how can i do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":526,"Q_Id":30870391,"Users Score":0,"Answer":"Maybe an easier way would be to use the shell to kill the process in question? Each process in linux has a number assigned to it, which you can see by typing\npstree -p\nIn your terminal. You can then kill the process by typing in\nsudo kill process number\nDoes that help, or were you thinking of something a bit more complicated?","Q_Score":0,"Tags":"python,python-2.7,raspberry-pi","A_Id":30873178,"CreationDate":"2015-06-16T14:21:00.000","Title":"how to kill a python programs using another python program on raspberry?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was trying to implement a multiuser chat (group chat) with socket on python. \nIt basically works like this: Each messages that a user send is received by the server and the server sends it back to the rest of the users.\nThe problem is that if the server close the program, it crashes for everyone else. \nSo, how can you handle the departure of the server, should you change the server somehow, or there is other way around it?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":560,"Q_Id":30880392,"Users Score":0,"Answer":"could you make your server log for heartbeats? and also post heartbeats to the clients on the socket?\nif so, have a monitor check for the server heartbeats and restart the server application if the heartbeats exceed the threshold value. \nalso, check for heartbeats on the client and reestablish connection when you did not hear a heartbeat.","Q_Score":0,"Tags":"python,sockets","A_Id":30880515,"CreationDate":"2015-06-17T00:25:00.000","Title":"Creating Multi-user chat with sockets on python, how to handle the departure of the server?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was working with Apache Log File. And I created RDD with tuple (day,host) from each log line. Next step was to Group up host and then display the result.\nI used distinct() with mapping of first RDD into (day,host) tuple. When I don't use distinct I get different result as when I do. So how does a result change when using distinct() in spark??","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":30886340,"Users Score":0,"Answer":"I think when you only use map action on FIRST_RDD(logs) you will get SECOND_RDD count of new this SECOND_RDD will be equal to count of FIRST_RDD.But if you use distinct on SECOND_RDD, count will decrease to number of distinct tuples present in SECOND_RDD.","Q_Score":0,"Tags":"python,apache-spark","A_Id":30887058,"CreationDate":"2015-06-17T08:35:00.000","Title":"How does result changes by using .distinct() in spark?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install the GSSAPI module through pip but I receive this error that I don't know how to resolve.\n\nCould not find main GSSAPI shared library. Please try setting\nGSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to\n'false'\n\nI need this to work on Python 2.6 for LDAP3 authentication.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":20242,"Q_Id":30896343,"Users Score":0,"Answer":"For me, the issue got resolved after installing the package \"krb5-libs\" in Centos.\nBasically we need to have libgssapi_krb5.so file for installing gssapi.","Q_Score":16,"Tags":"python,installation,ldap,python-2.6,gssapi","A_Id":52655111,"CreationDate":"2015-06-17T15:44:00.000","Title":"How to install GSSAPI Python module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to install the GSSAPI module through pip but I receive this error that I don't know how to resolve.\n\nCould not find main GSSAPI shared library. Please try setting\nGSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to\n'false'\n\nI need this to work on Python 2.6 for LDAP3 authentication.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":20242,"Q_Id":30896343,"Users Score":14,"Answer":"sudo apt install libkrb5-dev\nactually installs \/usr\/bin\/krb5-config and \/usr\/lib\/libgssapi_krb5.so\nso none of the symlinking was needed, just install libkrb5-dev and you should be good.","Q_Score":16,"Tags":"python,installation,ldap,python-2.6,gssapi","A_Id":50410443,"CreationDate":"2015-06-17T15:44:00.000","Title":"How to install GSSAPI Python module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to implement Naive Bayes classifier in Python. My attributes are of different data types : Strings, Int, float, Boolean, Ordinal \nI could use Gaussian Naive Bayes classifier (Sklearn.naivebayes : Python package) , But I do not know how the different data types are to be handled. The classifier throws an error, stating cannot handle data types other than Int or float\nOne way I could possibly think of is encoding the strings to numerical values. But I also doubt , how good the classifier would perform if I do this.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3764,"Q_Id":30937667,"Users Score":3,"Answer":"Yes, you will need to convert the strings to numerical values\nThe naive Bayes classifier can not handle strings as there is not a way an string can enter in a mathematical equation.  \nIf your strings have some \"scalar value\" for example \"large, medium, small\" you might want to classify them as \"3,2,1\",\nHowever, if your strings are things without order such as colours or names, you can do this or assign binary variables with every variable referring to a colour or name, if they are not many.\nFor example if you are classifying cars an they can be red blue and green you can define the variables 'Red' 'Blue' 'Green' that take the values 0\/1, depending on the colour of your car.","Q_Score":1,"Tags":"python,scikit-learn,gaussian,naivebayes","A_Id":30938653,"CreationDate":"2015-06-19T12:01:00.000","Title":"NaiveBayes classifier handling different data types in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've installed Python 3.4 and am currently using Python 2.7. I want to create a Project in Python 3.4, but, when I go to Run-->Run Configurations and then look to make a new entry under Python Run , I see that C:\\Python34 doesn't show up. Also, when I try to create a new Project, the \"Grammar Version\" goes only up to 3.0. I don't know how to resolve this. \nEdit: Could this be because I haven't installed Python 3.4 correctly?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1700,"Q_Id":30947172,"Users Score":4,"Answer":"I'm assuming you're using PyDev. I don't know if there are other alternatives but that's what I use for Python in Eclipse.\n\nRight-click on your project folder in the Package Explorer view and select \"Properties\".\nSelect \"PyDev - Interpreter\/Grammar\"\nSelect the appropriate Grammar Version and Interpreter, if those options contain the Python version you want.\nIf not, click on \"Click here to configure an interpreter not listed.\"\nClick \"New\" and provide an interpreter name (e.g. python3.4) and path to the executable (C:\\Python34)\n\nOnce you've done that, you should see the option to select your Python 3.4 interpreter under Run Configurations > Interpreter. It'll be displayed using the interpreter name you provided in step 5.","Q_Score":4,"Tags":"python,eclipse","A_Id":30955933,"CreationDate":"2015-06-19T20:58:00.000","Title":"Trouble trying to run Python 2.7 and 3.4 in Eclipse","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to execute C++ code to acquire images to process in python.\nI need to use these commands from python:\n\nmake and\n.\/name_of_the_executable\n\nCould anybody please help know me how to do it?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":70,"Q_Id":30954589,"Users Score":2,"Answer":"Look For python.net which is cable of making a call to the interfaces written in .net supported languages.\nWhat all you need to do is\nSteps:\n\nDownload and put it two files Python.Runtime.dll and clr.pyd in your DLLs folder.\n\nFrom you >>>(triple greater than prompt )Python prompt Try\n>>>import clr\n\nif it doesn't gives any error you are good to go .\n\nNext You need to do is put Your C++ Dll inside Lib\/site-packages Folder .\n\n\n(This is not mandatory but good for beginners).\n\nNext to import clr try importing your Dll as a module import YourDllName\n\nIf step 5 doesn't gives you a error . Hola You are done That's All Folks :)","Q_Score":0,"Tags":"python,c++","A_Id":30954837,"CreationDate":"2015-06-20T13:36:00.000","Title":"Excuting cpp file from Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have code that runs basic TF-IDF vectorizer on a collection of documents, returning a sparse matrix of D X F where D is the number of documents and F is the number of terms. No problem.\nBut how do I find the TF-IDF score of a specific term in the document? i.e. is there some sort of dictionary between terms (in their textual representation) and their position in the resulting sparse matrix?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11861,"Q_Id":30976120,"Users Score":0,"Answer":"@kinkajou, No, TF and IDF are not same but they belong to the same algorithm- TF-IDF, i.e Term frequency Inverse document Frequency","Q_Score":7,"Tags":"python,scikit-learn,tf-idf","A_Id":56899773,"CreationDate":"2015-06-22T09:13:00.000","Title":"Find the tf-idf score of specific words in documents using sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building my first Django web application and I need a bit of advice on code layout. \nI need to integrate it with several other applications that are exposed through RESTful APIs and additionally Django's internal data. I need to develop the component that will pull data from various sources, django's DB, format it consistently for output and return it for rendering by the template. \nI am thinking of the best way to write this component. There are a couple of ways to proceed and I wanted to solicit some feedback from more experienced web developers on things I may have missed. \nWay #1\nDevelop a completely standalone objects for interacting with other applications via their APIs, etc... This would not have anything related with django and test independently. Then in django, import this module in the views that need it, run object methods to get required data, etc... \nIf I need to access any of this functionality via a GET request (like through JavaScript), I can have a dedicated view that imports the module and returns json. \nWay #2\nDevelop this completely as django view(s) expose as a series of GET\/POST calls that would all call each other to get the work done. This would be directly tied in the application. \nWay #3\nStart with Way #1, but instead of creating a view, package it as a django app. Develop unit tests on the app as well as the individual objects. \nI think that way 1 or 3 would be very much encapsulated and controlled.\nWay 2 would be more complicated, but facilitate higher component re-use. \nWhat is better from a performance standpoint? If I roll with Way #1 or 3, would an instance of the object be instantiated for each request? \nIf so this approach may be a bit too heavy for this. If I proceed with this, can they be singletons? \nAnyway, I hope this makes sense. \nthanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":765,"Q_Id":30985798,"Users Score":0,"Answer":"Definitely go for \"way #1\".  Keeping an independent layer for your service(s) API will help a lot later when you have to enhance that layer for reliability or extending the API.\nStay away from singletons, they're just global variables with a new name.  Use an appropriate life cycle for your interface objects.  The obvious \"instantiate for each request\" is not the worst idea, and it's easier to optimize that if needed (by caching and\/or memoization) than it's to unroll global vars everywhere.\nKeep in mind that web applications are supposed to be several processes on a \"shared nothing\" design; the only shared resources must be external to the app: database, queue managers, cache storage.\nFinally, try to avoid using this API directly from the view functions\/CBV.  Either use them from your models, or write a layer conceptually similar to the way models are used from the views.  No need of an ORM-like api, but keep any 'business process' away from the views, which should be concerned only with the presentation and high level operations.  Think \"thick model, thin views\" with your APIs as a new kind of models.","Q_Score":1,"Tags":"python,django","A_Id":30986554,"CreationDate":"2015-06-22T17:04:00.000","Title":"Python Module in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After creating a .ipynb file in the root directory \/, how can you move that .pynb file into a deeper directory ie: \/subdirectory using the web UI?","AnswerCount":8,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":23019,"Q_Id":30988075,"Users Score":2,"Answer":"If some stumbles here as of 2020, it's now possible to move .ipynb or other kind of files by simply checking it and clicking move.\nNevertheless, for .ipynb files you must be sure that the notebook isn't running (gray icon). If it's running it should be green and you must shut it down before moving.","Q_Score":14,"Tags":"python,ipython,ipython-notebook","A_Id":63175447,"CreationDate":"2015-06-22T19:17:00.000","Title":"Move .ipynb using the IPython Notebook Web Interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After creating a .ipynb file in the root directory \/, how can you move that .pynb file into a deeper directory ie: \/subdirectory using the web UI?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":23019,"Q_Id":30988075,"Users Score":0,"Answer":"Ran into this issue and solved it by :\n\nCreate a new folder in jupyter notebooks.\nGo to the folder\/directory and click the \"Upload \"button which is next to the \"New\" button. \nOnce you click \"Upload\", your pc file explorer window will pop-up, now simply find where you have your jupyter notebooks saved on your local machine and upload them to that desired file\/directory.\n\nAlthough this doesn't technically move your python files to your desired directory, it does however make a copy in that directory. So next time you can be more organized and just click on a certain directory that you want and create\/edit\/view the files you chose to be in there instead of looking for them through your home directory.","Q_Score":14,"Tags":"python,ipython,ipython-notebook","A_Id":40560790,"CreationDate":"2015-06-22T19:17:00.000","Title":"Move .ipynb using the IPython Notebook Web Interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After creating a .ipynb file in the root directory \/, how can you move that .pynb file into a deeper directory ie: \/subdirectory using the web UI?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":23019,"Q_Id":30988075,"Users Score":0,"Answer":"Duplicate the notebook and delete the original, was my workaround.","Q_Score":14,"Tags":"python,ipython,ipython-notebook","A_Id":43175463,"CreationDate":"2015-06-22T19:17:00.000","Title":"Move .ipynb using the IPython Notebook Web Interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After creating a .ipynb file in the root directory \/, how can you move that .pynb file into a deeper directory ie: \/subdirectory using the web UI?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":23019,"Q_Id":30988075,"Users Score":1,"Answer":"Ipython 5.1:\n1. Make new folder -- with IPython running, New, Folder, select 'Untitled folder' just created, rename (and remember the name!)\n2. Go to the file you want to move, Move, write new directory name at prompt\nNote: If the folder exists, skip 1.\nNote: If you want to leave a copy in the original directory, Duplicate and then move.","Q_Score":14,"Tags":"python,ipython,ipython-notebook","A_Id":46796512,"CreationDate":"2015-06-22T19:17:00.000","Title":"Move .ipynb using the IPython Notebook Web Interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to move the cursor in a Python matplotlib window by a (data) pixel at a time (I'm displaying a 2D image), using the keyboard arrow keys. I can trap the keyboard keypress events, but how do I reposition the cursor based on these events?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":533,"Q_Id":31003551,"Users Score":0,"Answer":"One solution is to make MatPlotLib react to key events immediately.\nAnother solution is print a 'Cursor' or marker line on the plot, and change its coordinates with the mouse events. Eg. draw a vertical line, and update its X coordinates with the left and right keys. You can then add a label with the X coordinate along the line, and other nice tricks.","Q_Score":1,"Tags":"python,matplotlib","A_Id":31004307,"CreationDate":"2015-06-23T13:02:00.000","Title":"move cursor in matplotlib window with keyboard stroke","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning TDD and am using Django and Selenium to do some functional testing. I wanted to make it so that a user selects a checkbox that essentially says \"add 1 to this number nightly\". Then, for all of the users that have this setting on, a nightly process will automatically increment the number on these accounts.\nI want to be able to test this functionality in my functional test in selenium, but I don't know how I would go about it. I obviously don't want to wait a day for the test to finish either. Can someone help me think about how I can get started?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":31009555,"Users Score":0,"Answer":"I've decided that I am just going to call the method of the nightly methods directly, instead of making a truly functional test.","Q_Score":0,"Tags":"python,django,selenium,functional-testing","A_Id":31042109,"CreationDate":"2015-06-23T17:30:00.000","Title":"Django Functional Test for Time Delayed Procedure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to save a dataframe to a .csv file with the name '123\/123', but it will split it in to two strings if I just type like df.to_csv('123\/123.csv'). \nAnyone knows how to keep the slash in the name of the file?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":31022379,"Users Score":0,"Answer":"You can not use any of these chars in the file name ;\n\/:*?\\\"|","Q_Score":0,"Tags":"python,pandas","A_Id":31022952,"CreationDate":"2015-06-24T09:09:00.000","Title":"How to save a dataframe as a csv file with '\/' in the file name","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python. I want to read JSON data from URL and if there is any change in JSON data on server, I want to update in my JSON file which is on client. How can I do that through python?\nActually i am ploting graph on django using JSON data which is on another server. That JSON data is updated frequently. So here i want to update my charts based on updated json data. For that i has to listen to URL link for change. So how can i do that.....i know with select() system call i can but need some another way","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":190,"Q_Id":31024852,"Users Score":0,"Answer":"There's no way to \"listen\" for changes other than repeatedly requesting that URL to check if something has changed; i.e. classic \"pull updates\". To get actual live notifications of changes, that other server needs to offer a way to push such a notification to you. If it's just hosting the file and is not offering any active notifications of any sort, then repeatedly asking is the best you can do. Try not to kill the server when doing so.","Q_Score":0,"Tags":"python","A_Id":31025251,"CreationDate":"2015-06-24T11:04:00.000","Title":"Asynchronous way to listen web service for data change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a scenario where some unknown exceptions may be raised during program execution and i can't except most of them and i want every time any exception will raise an email should send to me as exceptions cause program to terminate if not properly catch!\nso i have read about python provide atexit module but it did not work with exceptions so my question is , is there any way to make atexit work with exceptions?? so every any exception raised and programs terminates it should send me a mail?\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2151,"Q_Id":31060517,"Users Score":5,"Answer":"Look at sys.excepthook. As its name suggests, it's a hook into the exception. You can use it to send you an email when exceptions are raised.","Q_Score":5,"Tags":"python","A_Id":31061329,"CreationDate":"2015-06-25T20:48:00.000","Title":"how to use atexit when exception is raised","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on my first web application. I am doing it in Python with Flask, and I want to run a piece of Python code that takes an object, with Pickle, from a (binary) file of several MB which contains all the necessary data. I have been told that so using Pickle in a web app is not a good idea because of scalability; why?\nObviously, for a given purpose it's better to take just the necessary data. However, if I do this, with an Elasticsearch database and in the fastest way I can, the whole process takes about 100 times more time than if I take all the data at once from the binary; once the binary is unpickled, which will take at most one second, the computations are very fast, so I am wondering if I should use the binary file, and if so, how to do it in a scalable way.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1053,"Q_Id":31068690,"Users Score":0,"Answer":"Pickle files is good way to load data in python. By the way consider using the C implementation: cPickle.\nIf you want to scale, using pickle files. Ideally you want to look for a partition key, that fits for your data and your project needs.\nLet's say for example you have historical data, instead of having a single file with all historical data, you can create a pickle file per date.","Q_Score":2,"Tags":"python,flask,scalability,binaryfiles","A_Id":31069570,"CreationDate":"2015-06-26T08:43:00.000","Title":"Is it feasible to unpickle large amounts of data in a Python web app that needs to be scalable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I allow myself to write to you, due to a block on my part at Salt.\nI made a bash script that adds a host in my zabbix monitoring server. it works perfectly when I run .sh\nthe idea is that I want to automate this configuration through salt. I am when I do a highstate my state that contains the script runs in the master before minion because there's  my login authentication in my bash script.\nIs there's a special configuration for its? is what you have ideas how to do like this kind of setup? according to my research I found that to be used as the salt-runner but I do not know if this is good or not;\nIn anticipation of your return, I wish you a good weekend.","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":905,"Q_Id":31073993,"Users Score":0,"Answer":"If you need the highstate on the minion to cause something to occur on the master than you are going to want too look into using salt's Reactor (which is designed to do exactly this kind of multi-machine stuff).","Q_Score":0,"Tags":"python,git,salt-stack","A_Id":31254893,"CreationDate":"2015-06-26T13:07:00.000","Title":"Run script bash on saltstack master before minion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I allow myself to write to you, due to a block on my part at Salt.\nI made a bash script that adds a host in my zabbix monitoring server. it works perfectly when I run .sh\nthe idea is that I want to automate this configuration through salt. I am when I do a highstate my state that contains the script runs in the master before minion because there's  my login authentication in my bash script.\nIs there's a special configuration for its? is what you have ideas how to do like this kind of setup? according to my research I found that to be used as the salt-runner but I do not know if this is good or not;\nIn anticipation of your return, I wish you a good weekend.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":905,"Q_Id":31073993,"Users Score":0,"Answer":"Run a minion on the same box as your master, then you can run the script on your master's minion and then on the other server.","Q_Score":0,"Tags":"python,git,salt-stack","A_Id":31083687,"CreationDate":"2015-06-26T13:07:00.000","Title":"Run script bash on saltstack master before minion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been trying to determine how to detect point-anomalies given window-anomalies.\nIn more detail, I know for each 30-day window whether it contains an anomaly. For example, window 1 starts at 1\/1\/2009, window 2 at 1\/2\/2009, and so on.\nNow I'm trying to use this knowledge to determine which dates these anomalies lie. If I have an anomaly on dates 1\/5\/2009 to 1\/8\/2009, my window will raise a signal for windows from a window with a last day of 1\/8\/2009 to a window starting on 1\/5\/2009.\nI just don't see how I can find the exact intervals where there are anomalies using windows. Is there an approximation method that anyone can come up with? Feel free to include some code in Python if you'd like.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":31082231,"Users Score":0,"Answer":"I just don't see how I can find the exact intervals where there are anomalies using windows.\n\nYou can't. How do you know there aren't two anomalies?\n\nIs there an approximation method that anyone can come up with?\n\nFor each interval of windows where there is continuously an anomaly detected, assume that there is an anomaly lasting from the last day of the first window to the first day of the last window.","Q_Score":0,"Tags":"python,algorithm","A_Id":31084184,"CreationDate":"2015-06-26T21:12:00.000","Title":"how to determine point anomalies given window anomalies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to solve some system in the form of matrices using linalg, but the resulting solutions should sum up to 1. For example, suppose there are 3 unknowns, x, y, z. After solving the system their values should sum up to 1, like .3, .5, .2. Can anyone please tell me how I can do that? \nCurrently, I am using something like result = linalg.solve(A, B), where A and B are matrices. But this doesn't return solutions in the range [0, 1].","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":9737,"Q_Id":31098228,"Users Score":2,"Answer":"You could add a row consisting of ones to A and add one to B. After that use \nresult = linalg.lstsq(A, B)[0]\nOr you can replace one of A's rows to row consisting of ones, also replace value in B to one in the same row. Then use \nresult = linalg.solve(A, B)","Q_Score":7,"Tags":"python,numpy,matrix,equation-solving","A_Id":48433206,"CreationDate":"2015-06-28T09:40:00.000","Title":"Solving system using linalg with constraints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the program I'm writing, the user needs to be able to select a cell in the grid and edit its value. The program also shows what the value of the currently selected value is in hexadecimal (so (0,0) is 0x00, (1,3) is 0x19, etc.) I originally had this display be updated through a binding to the wx.grd.EVT_GRID_SELECT_CELL event. However, upon doing this, the GridCursor would no longer move, it would stay on (0,0). So, I added a SetGridCursor statement to the handler to have it move the cursor when the handler was called. However, this generated an infinite loop, as apparently SetGridCursor generates an EVT_GRID_SELECT_CELL command when called. \nMy question is, how do I have code that executes when a new cell is selected while still maintaining the old cell selection functionality?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":137,"Q_Id":31118668,"Users Score":0,"Answer":"Adding event.Skip() at the end of my custom handler passes the event to the default handler.","Q_Score":0,"Tags":"python,events,grid,wxpython,wxwidgets","A_Id":31124993,"CreationDate":"2015-06-29T14:44:00.000","Title":"In wxPython Grid, creating event handler for Cell Selection disables moving the GridCursor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There are several questions regarding this topic, but none of them seem to answer this question specifically.  \nIf I have the pattern p='([0-9]+)(,([0-9]+))*' and s='1,2,3,4,5' and I run m = re.match(p, s, 0) I get a match (as expected).  However, I would like to be able to print the list ('1', '2', '3', '4', '5').  I can't seem to do this with the re.match output.  It gives me ('1', ',5', '5').  \nAlso, how do I get the number of matches (in this case 5)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":507,"Q_Id":31145860,"Users Score":5,"Answer":"Don't use regexes for that. s.split(',') will do exactly what you want.","Q_Score":0,"Tags":"python,regex","A_Id":31145877,"CreationDate":"2015-06-30T18:35:00.000","Title":"How to match and print list of comma separated numbers in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question is distilled from the original application involving callback functions for Tkinter buttons.  This is one line that illustrates the behavior.\nlambdas = [lambda: i for i in range(3)]\nif you then try invoking the lambda functions generated:\nlambdas[0](), lambdas[1]() and lambdas[2]() all return 2.\nThe desired behavior was to have lambdas[0]() return 0, lambdas[1]() return 1, lambdas[2])() return 2.\nI see that the index variable is interpreted by reference.  The question is how to rephrase to have it treated by value.","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1153,"Q_Id":31186959,"Users Score":-2,"Answer":"Ahhh, further Googling found a solution (admittedly one I would not have stumbled upon myself). The desired behavior can be invoked by use of a default argument:\nlambdas = [lambda i=i: i for i in range(3)]","Q_Score":4,"Tags":"python,python-2.7,lambda,list-comprehension","A_Id":31187126,"CreationDate":"2015-07-02T14:13:00.000","Title":"How to generate a list of different lambda functions with list comprehension?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a command to step out of cycles (say, for or while) while debugging on ipdb without having to use breakpoints out of them?\nI use the until command to step out of list comprehensions, but don't know how could I do a similar thing, if possible, of entire loop blocks.","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":15509,"Q_Id":31196818,"Users Score":13,"Answer":"This could sound obvious: jump makes you jump. \nThis means that you don't execute the lines you jump: you should use this to skip code that you don\u2019t want to run. \nYou probably need tbreak (Temporary breakpoint, which is removed automatically when it is first hit. The arguments are the same as break) as I did when I found this page.","Q_Score":25,"Tags":"python,debugging,ipdb","A_Id":40893062,"CreationDate":"2015-07-03T00:40:00.000","Title":"ipdb debugger, step out of cycle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a command to step out of cycles (say, for or while) while debugging on ipdb without having to use breakpoints out of them?\nI use the until command to step out of list comprehensions, but don't know how could I do a similar thing, if possible, of entire loop blocks.","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":15509,"Q_Id":31196818,"Users Score":23,"Answer":"You can use j <line number> (jump) to go to another line.\nfor example, j 28 to go to line 28.","Q_Score":25,"Tags":"python,debugging,ipdb","A_Id":32097568,"CreationDate":"2015-07-03T00:40:00.000","Title":"ipdb debugger, step out of cycle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using anaconda python 2.7, and keep finding problems installing python libraries using pip that seem to rely on pkg-config. In particular, python-igraph (although the author of that library kindly added a patch to help conda users) and louvain (which I have yet to fix). \nWould installing pkg-config lead to conflicts with anaconda? Is there a way to set them up to play nice?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":365,"Q_Id":31225861,"Users Score":1,"Answer":"I faced some installation issues with Anaconda and my fix was to download manually the components of the Anaconda package.\n\nIf you use sudo apt-get python3-numpy\nfor example, it will download as well as all the dependencies.\n\nSo all you have to do is download the major libraries.\n\nAlthough I don't believe pkg-config causes conflicts with Anaconda. Give it a shot, should be easy to resolve issues if any at all.","Q_Score":1,"Tags":"python,igraph,anaconda,pkg-config","A_Id":31227686,"CreationDate":"2015-07-04T23:17:00.000","Title":"Anaconda and pkg-config on osx 10.10: how to prevent pip installation problems?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dedicated web server which runs CentOS 6.6\nI am running some script that uses Python SHA module and I think that this module is deprecated in the current Python version.\nI am consider downgrading my Python installation so that I can use this module. \nIs there a better option? If not, how should I do it?\nThese are my Python installation details:\n\nrpm-python-4.8.0-38.el6_6.x86_64\ndbus-python-0.83.0-6.1.el6.x86_64\ngnome-python2-2.28.0-3.el6.x86_64\ngnome-python2-canvas-2.28.0-3.el6.x86_64\nlibreport-python-2.0.9-21.el6.centos.x86_64\ngnome-python2-applet-2.28.0-5.el6.x86_64\ngnome-python2-gconf-2.28.0-3.el6.x86_64\ngnome-python2-bonobo-2.28.0-3.el6.x86_64\npython-urlgrabber-3.9.1-9.el6.noarch\npython-tools-2.6.6-52.el6.x86_64\nnewt-python-0.52.11-3.el6.x86_64\npython-ethtool-0.6-5.el6.x86_64\npython-pycurl-7.19.0-8.el6.x86_64\npython-docs-2.6.6-2.el6.noarch\ngnome-python2-libegg-2.25.3-20.el6.x86_64\npython-iwlib-0.1-1.2.el6.x86_64\nlibxml2-python-2.7.6-17.el6_6.1.x86_64\ngnome-python2-gnome-2.28.0-3.el6.x86_64\npython-iniparse-0.3.1-2.1.el6.noarch\ngnome-python2-libwnck-2.28.0-5.el6.x86_64\nlibproxy-python-0.3.0-10.el6.x86_64\npython-2.6.6-52.el6.x86_64\ngnome-python2-gnomevfs-2.28.0-3.el6.x86_64\ngnome-python2-desktop-2.28.0-5.el6.x86_64\ngnome-python2-extras-2.25.3-20.el6.x86_64\nabrt-addon-python-2.0.8-26.el6.centos.x86_64\nat-spi-python-1.28.1-2.el6.centos.x86_64\npython-libs-2.6.6-52.el6.x86_64\npython-devel-2.6.6-52.el6.x86_64","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8690,"Q_Id":31235059,"Users Score":-1,"Answer":"You can always install a different version of Python using the -altinstall argument, and then run it either in a virtual environment, or just run the commands with python(version) command.\nA considerable amount of CentOS is written in Python so changing the core version will most likely break some functions.","Q_Score":1,"Tags":"python,python-2.7,centos,sha","A_Id":31235259,"CreationDate":"2015-07-05T21:14:00.000","Title":"How to downgrade python version on CentOS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django 1.8 project that I would like to internationalize. I have added the code to do so in the application, and when I change the LANGUAGE_CODE tag, I can successfully see the other language used, but when I leave it on en-us, no other languages show up. I have changed my computer's language to the language in question (German), but calls to the site are still in English. What am I doing wrong?\nOther things: \n\nUSE_I18N = true \nLOCALE_PATHS works correctly (since changing the\nLANGUAGE_CODE works)\nI have also tried settings the LANGUAGES attribute although I don't think I have to anyway.\n\nEDIT: I have also confirmed that the GET call has the header: Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4, which contains de like I want. My locale folder has a folder de in it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":31263032,"Users Score":0,"Answer":"I just needed to add'django.middleware.locale.LocaleMiddleware' to my settings.py file in the MIDDLEWARE_CLASSES section. I figured if internationalization was already on that this wouldn't be necessary.","Q_Score":0,"Tags":"python,django,python-3.x,internationalization","A_Id":31278044,"CreationDate":"2015-07-07T08:04:00.000","Title":"Django i18n Problems","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to modify data through custom template tag in Django? More specifically, I have a model named Shift whose data I want to display in a calendar form. I figured using a custom inclusion tag is the best way to go about it, but I also want users to be able to click on a shift and buy\/sell the shift (thus modifying the database). My guess is that you can't do this with an inclusion tag, but if I were to write a different type of custom template tag from the ground up, would this be possible? If so, can you direct me to a few resources that address how to write such a tag?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":333,"Q_Id":31281119,"Users Score":0,"Answer":"This type of logic does not belong in a template tag. It belongs in a view that will respond to AJAX requests and return a JSONResponse. You'll need some javascript to handle making the request based on the input as well.","Q_Score":0,"Tags":"python,django,django-templates","A_Id":31282108,"CreationDate":"2015-07-07T23:29:00.000","Title":"Django: modifying data with user input through custom template tag?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've recently installed opencv3 on ubuntu 14.04. The tutorial I followed was for some reason using a virtualenv. Now I want to move opencv from the virtual to my global environment. The reason for this is that I can't seem to use the packages that are installed on my global environment which is getting on my nerves. So how can I do that?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":895,"Q_Id":31281539,"Users Score":4,"Answer":"I'm not sure I got your question right, but probably your virtualenv has been created without specifying the option --system-site-packages, which gives your virtualenv access to the packages you installed system-wise.\nIf you run virtualenv --system-site-packages tutorial_venv instead of just virtualenv tutorial_venv when creating your tutorial virtualenv, you might be fine.\nFyi, using a virtualenv with only local dependencies it's a fairly widespread practice, which:\n\ngives you isolation and reproducibility in production scenarios\nmakes possible for users without the privilege of installing packages system-wide to run and develop a python application\n\nThe last benefit might be the reason why your tutorial suggested a virtualenv based approach.","Q_Score":1,"Tags":"python,opencv,virtualenv","A_Id":31281670,"CreationDate":"2015-07-08T00:17:00.000","Title":"I want my already created virtualenv to have access to system packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"To convert a range of say the 1st to 5th page of a multipage pdf into single images is fairly straight forward using:\nconvert file.pdf[0-4] file.jpg\nBut how do i convert say the 5th to the last page when i dont know the number of pages in the pdf? \nIn ImageMagick \"-1\"represents the last page, so:\nconvert file.pdf[4--1] file.jpg works, great stuff,\nbut it doesnt work in GraphicsMagick.\nIs there a way of doing this easily or do i need to find the number of pages? \nPS: need to use graphicsmagick instead of imagemagick.\nThank you so much in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":191,"Q_Id":31283419,"Users Score":0,"Answer":"Future readers of this, if you're experiencing the same dilemma in GraphicsMagick. Here's the easy solution:\nSimply write a big number to represent the \"last page\".\nThat is: something like:\nconvert file.pdf[4-99999] +adjoin file%02d.jpg\nwill work to convert from the 5th pdf page to the last pdf page, into jpgs. \nNote: \"+adjoin\" & \"%02d\" have to do with getting all the images rather than just the last. You'll see what i mean if you try it.","Q_Score":1,"Tags":"python,pdf,graphicsmagick","A_Id":31310493,"CreationDate":"2015-07-08T04:14:00.000","Title":"Convert to PDF's Last Page using GraphicsMagick with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Working on a Flask application which will have separate classes of routes to be authenticated against: user routes and host routes(think Airbnb'esque where users and hosts differ substantially).\nCreating a single verify_password callback and login_required combo is extremely straightforward, however that isn't sufficient, since some routes will need host authentication and others routes will necessitate user authentication. Essentially I will need to have one verify_password\/login_required for user and one for host, but I can't seem to figure out how that would be done since it appears that the callback is global in respect to auth's scope.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":31284225,"Users Score":6,"Answer":"The way I intended that to be handled is by creating two HTTPAuth objects. Each gets its own verify_password callback, and then you can decorate each route with the decorator that is appropriate.","Q_Score":1,"Tags":"python,flask,flask-httpauth","A_Id":31305421,"CreationDate":"2015-07-08T05:31:00.000","Title":"Multiple verify_password callbacks on flask-httpauth","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making an application that will fetch data from a\/n (external) postgreSQL database with multiple tables.\nAny idea how I can use inspectdb only on a SINGLE table? (I only need that table)\nAlso, the data in the database would by changing continuously. How do I manage that? Do I have to continuously run inspectdb? But what will happen to junk values then?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":78,"Q_Id":31295352,"Users Score":0,"Answer":"I think you have misunderstood what inspectdb does. It creates a model for an existing database table. It doesn't copy or replicate that table; it simply allows Django to talk to that table, exactly as it talks to any other table. There's no copying or auto-fetching of data; the data stays where it is, and Django reads it as normal.","Q_Score":0,"Tags":"python,django,postgresql,python-2.7,django-1.8","A_Id":31309910,"CreationDate":"2015-07-08T14:15:00.000","Title":"Django 1.8 and Python 2.7 using PostgreSQL DB help in fetching","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am reading user input text with getstr(). Instead of waiting for the user to press enter, I would like to read the input each time it is changed and re-render other parts of the screen based on the input.\nIs this possible with getstr()? How? If not, what's the simplest\/easiest alternative?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":145,"Q_Id":31295836,"Users Score":0,"Answer":"Not with getstr(), but it's certainly possible with curses. You just have to read each keypress one at a time, via getch() -- and, if you want an editable buffer, you have to recreate something like the functionality of getstr() yourself. (I'd post an example, but what I have is in C rather than Python.)","Q_Score":0,"Tags":"python,ncurses,getstring,python-curses","A_Id":31301635,"CreationDate":"2015-07-08T14:34:00.000","Title":"Python ncurses - how to trigger actions while user is typing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how Python interactive mode works. Usually when you run Python script on CPython it will go trough the process of lexical analysis, parsing, gets compiled into .pyc file, and finally the .pyc file is interpreted. \nDoes this 4-step process happen while using interactive mode also, r is there a more efficient way of implementing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1991,"Q_Id":31331862,"Users Score":1,"Answer":"Python has two basic modes: normal and interactive. The normal mode is the mode where the scripted and finished .py files are run in the Python interpreter. Interactive mode is a command line shell which gives immediate feedback for each statement, while running previously fed statements in active memory. As new lines are fed into the interpreter, the fed program is evaluated both in part and in whole.\n\nThe same occurs with the .cpy files. Interactive mode basically doing the entire process for each line. I highly doubt that there's a more efficient way to do so.\n\nThe iPython notebook works in a similar way.","Q_Score":3,"Tags":"python,python-2.7,python-3.x,python-internals","A_Id":31334203,"CreationDate":"2015-07-10T03:15:00.000","Title":"How does Python's interactive mode work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'd like to know how to set breakpoints in IPython notebook on PyCharm. \nIf it's possible, please let me know.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":447,"Q_Id":31365093,"Users Score":0,"Answer":"You must start IPython Notebook from Pycharm's run \n\nFind the IPython path (ex which ipython on linux). Copy the resulting path, we will need it!\nOn PyCharm go to Run > Edit Configuration > + button on top left most corner (add configuration) > Choose Python. \nGive your configuration a name.\nOn the configuration tab, in the Script textbox, paste the path from step 1. On the script, parameters write notebook.\nApply then Ok.\n\nThis is essentially like calling ipython notebook from the terminal\nNow place your brakepoints and run the notebook from PyCarm (Shift+F10 or click the playbutton).","Q_Score":2,"Tags":"python,ipython,pycharm,ipython-notebook","A_Id":42631771,"CreationDate":"2015-07-12T06:36:00.000","Title":"Can PyCharm set breakpoints on ipython notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using requests to communicate with remote server over https. At the moment I'm not verifying SSL certificate and I'd like to fix that.\nWithin requests documentation, I've found that:\n\nYou can pass verify the path to a CA_BUNDLE file with certificates of\n  trusted CAs. This list of trusted CAs can also be specified through\n  the REQUESTS_CA_BUNDLE environment variable.\n\nI don't want to use system's certs, but to generate my own store.\nSo far I'm grabbing server certificate with ssl.get_server_certificate(addr), but I don't know how to create my own store and add it there.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":5838,"Q_Id":31369633,"Users Score":2,"Answer":"This is actually trivial... CA_BUNDLE can be any file that you append certificates to, so you can simply append the output of ssl.get_server_certificate() to that file and it works.","Q_Score":2,"Tags":"python,ssl,https,python-requests,client-certificates","A_Id":31370879,"CreationDate":"2015-07-12T15:49:00.000","Title":"Adding server certificates to CA_BUNDLE in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using django 1.8.3 and django-allauth 0.21.0 and I'd like the user to be able to log in using e.g. their Google account without leaving the page. The reason is that there's some valuable data from the page they're logging in from that needs to be posted after they've logged in. I've already got this working fine using local account creation, but I'm having trouble with social because many of the social networks direct the user away to a separate page to ask for permissions, etc. Ideally, I'd have all this happening in a modal on my page, which gets closed once authentication is successful.\nThe only possible (though not ideal) solution I can think of at the moment is to force the authentication page to open up in another tab (e.g. using target=\"_blank\" in the link), then prompting the user to click on something back in the original window once the authentication is completed in the other tab.\nHowever, the problem here is that I can't think of a way for the original page to know which account was just created by the previously-anonymous user without having them refresh the page, which would cause the important data that needs to be posted to be lost.\nDoes anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":610,"Q_Id":31370534,"Users Score":0,"Answer":"One option is that the primary form pops up social auth in a new window then uses AJAX to poll for whether the social auth has completed. As long as you are fine with the performance characteristics of this (it hammers your server slightly), then this is probably the simplest solution.","Q_Score":2,"Tags":"python,django,oauth-2.0,google-oauth,django-allauth","A_Id":31370619,"CreationDate":"2015-07-12T17:25:00.000","Title":"Social login in using django-allauth without leaving the page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using django 1.8.3 and django-allauth 0.21.0 and I'd like the user to be able to log in using e.g. their Google account without leaving the page. The reason is that there's some valuable data from the page they're logging in from that needs to be posted after they've logged in. I've already got this working fine using local account creation, but I'm having trouble with social because many of the social networks direct the user away to a separate page to ask for permissions, etc. Ideally, I'd have all this happening in a modal on my page, which gets closed once authentication is successful.\nThe only possible (though not ideal) solution I can think of at the moment is to force the authentication page to open up in another tab (e.g. using target=\"_blank\" in the link), then prompting the user to click on something back in the original window once the authentication is completed in the other tab.\nHowever, the problem here is that I can't think of a way for the original page to know which account was just created by the previously-anonymous user without having them refresh the page, which would cause the important data that needs to be posted to be lost.\nDoes anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":610,"Q_Id":31370534,"Users Score":1,"Answer":"I ended up resolving this by using Django's session framework. It turns out that the session ID is automatically passed through the oauth procedure by django-allauth, so anything that's stored in request.session is accessible on the other side after login is complete.","Q_Score":2,"Tags":"python,django,oauth-2.0,google-oauth,django-allauth","A_Id":32250705,"CreationDate":"2015-07-12T17:25:00.000","Title":"Social login in using django-allauth without leaving the page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"ERPNext + frappe need to change layout(footer & header) front-end. I tried to change base.html(frappe\/templates\/base.html) but nothing happened. Probably this is due to the fact that the html files need to somehow compile. Maybe someone have info how to do it?\nUPDATE:\nNo such command \"clear-cache\".\nCommands:\n  backup\n  backup-all-sites\n  config\n  get-app\n  init\n  migrate-3to4\n  new-app\n  new-site\n  patch\n  prime-wheel-cache\n  release\n  restart\n  set-default-site\n  set-mariadb-host\n  set-nginx-port\n  setup\n  shell\n  start\n  update","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1663,"Q_Id":31377196,"Users Score":0,"Answer":"bench clear-cache will clear the cache. After doing this, refresh and check.","Q_Score":0,"Tags":"python,frameworks,erpnext,frappe","A_Id":31379032,"CreationDate":"2015-07-13T07:01:00.000","Title":"Customize frappe framework html layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"ERPNext + frappe need to change layout(footer & header) front-end. I tried to change base.html(frappe\/templates\/base.html) but nothing happened. Probably this is due to the fact that the html files need to somehow compile. Maybe someone have info how to do it?\nUPDATE:\nNo such command \"clear-cache\".\nCommands:\n  backup\n  backup-all-sites\n  config\n  get-app\n  init\n  migrate-3to4\n  new-app\n  new-site\n  patch\n  prime-wheel-cache\n  release\n  restart\n  set-default-site\n  set-mariadb-host\n  set-nginx-port\n  setup\n  shell\n  start\n  update","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1663,"Q_Id":31377196,"Users Score":0,"Answer":"It seems you're not in your bench folder.\nWhen you create a new bench with, for example : bench init mybench it creates a new folder : mybench.\nAll bench commands must be run from this folder.\nCould you try to run bench --help in this folder ? You should see the clear-cache command.","Q_Score":0,"Tags":"python,frameworks,erpnext,frappe","A_Id":58808805,"CreationDate":"2015-07-13T07:01:00.000","Title":"Customize frappe framework html layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"ERPNext + frappe need to change layout(footer & header) front-end. I tried to change base.html(frappe\/templates\/base.html) but nothing happened. Probably this is due to the fact that the html files need to somehow compile. Maybe someone have info how to do it?\nUPDATE:\nNo such command \"clear-cache\".\nCommands:\n  backup\n  backup-all-sites\n  config\n  get-app\n  init\n  migrate-3to4\n  new-app\n  new-site\n  patch\n  prime-wheel-cache\n  release\n  restart\n  set-default-site\n  set-mariadb-host\n  set-nginx-port\n  setup\n  shell\n  start\n  update","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":1663,"Q_Id":31377196,"Users Score":0,"Answer":"If anyone stumbles on this.  The command needed is bench build.  That will compile any assets related to the build.json file in the public folder.  (NOTE: You usually have to create build.json yourself).","Q_Score":0,"Tags":"python,frameworks,erpnext,frappe","A_Id":68402268,"CreationDate":"2015-07-13T07:01:00.000","Title":"Customize frappe framework html layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to do that with javascript but I need a secure way to do it.\nAnybody can view page source, get the link and do not wait 5 seconds.\nIs there any solution? I'm working with javascript and django.\nThanks!","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1293,"Q_Id":31387762,"Users Score":0,"Answer":"The only secure way would be to put the logic on the server that checks the time. Make an Ajax call to the server. If the time is under 5 seconds, do not return the HTML, if it is greater than , than return the html to show. \nOther option is to have the link point to your server and if the time is less than five seconds it redirects them to a different page. If it is greater than 5, it will redirect them to the correct content.  \nEither way, it requires you to keep track of session time on the server and remove it from the client.","Q_Score":0,"Tags":"javascript,python,django,timer","A_Id":31387864,"CreationDate":"2015-07-13T15:44:00.000","Title":"Wait 5 seconds before download button appear","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to do that with javascript but I need a secure way to do it.\nAnybody can view page source, get the link and do not wait 5 seconds.\nIs there any solution? I'm working with javascript and django.\nThanks!","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1293,"Q_Id":31387762,"Users Score":0,"Answer":"Use server side timeout.. whenever there is (AJAX) request from client for download link with timestamp, compare the client sent timestamp with currenttime and derive how much time is required to halt the request at server side to make up ~5 seconds. So by comparing timestamp you can almost achieve accuracy of waiting time as the network delays would be taken into account automatically.","Q_Score":0,"Tags":"javascript,python,django,timer","A_Id":31388190,"CreationDate":"2015-07-13T15:44:00.000","Title":"Wait 5 seconds before download button appear","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Everything I found about this via searching was either wrong or incomplete in some way. So, how do I:\n\ndelete everything in my postgresql database\ndelete all my alembic revisions\nmake it so that my database is 100% like new","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7991,"Q_Id":31392285,"Users Score":3,"Answer":"This works for me:\n1) Access your session, in the same way you did session.create_all, do session.drop_all. \n2) Delete the migration files generated by alembic.\n3) Run session.create_all and initial migration generation again.","Q_Score":7,"Tags":"python,postgresql,sqlalchemy,alembic","A_Id":31392595,"CreationDate":"2015-07-13T19:56:00.000","Title":"Clear postgresql and alembic and start over from scratch","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a very large list that I want to write to file. My list is 2 dimensional, and each element of the list is a 1 dimensional list. Different elements of the 2 dimensional list has 1 dimensional lists of varying size. \nWhen my 2D list was small, pickle dump worked great. But now it just gives me memory error. \nAny suggestions on how to store and reload such arrays to disk?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1136,"Q_Id":31417091,"Users Score":0,"Answer":"If you really want to keep it simple and use something like pickle, the best thing is to use cPickle. This library is written in C and can handle bigger files and is faster than pickle.","Q_Score":0,"Tags":"python,list,pickle","A_Id":31429440,"CreationDate":"2015-07-14T20:51:00.000","Title":"Python pickle dump memory error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am learning the book Python for Data Analysis, after running the code from the book I got a pandas dataframe diversity like this:\n\nsex  F  M\nyear \n1880 [38] [14]\n1881 [38] [14]\n\nWhen I want to use diversity.plot() to draw some pictures, there is TypeError: \nEmpty 'DataFrame': no numeric data to plot \nSo, my question is how to deal with this dataframe to make it as numeric?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":352,"Q_Id":31420095,"Users Score":1,"Answer":"It seems that you have a list of int in your data frame. To convert it to you need to select the value inside and form data frame.\nI suggest you this code to convert\n\nfor col in df:\n     df[col] = df[col].apply(lambda x: x[0])","Q_Score":0,"Tags":"python,numpy,pandas","A_Id":31422570,"CreationDate":"2015-07-15T01:39:00.000","Title":"How to make dataframe in pandas as numeric?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to have advertisements in an android App I've written and built using PGS4A. I've done my research and all, but there doesn't seem to be any online resources that explains how to do that just yet. I haven't much knowledge on Java either, which is clearly why I've written that in Python. Has anyone found a way to achieve that? If not, how difficult would it be to convert the project files into an Android Studio (or even an Eclipse) project? (so then one can just implement the ads following the Java Admob documentation found everywhere)\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":199,"Q_Id":31441307,"Users Score":0,"Answer":"To access Java already implemented version you can use pyjnius. I tried to use it for something else and I didn't succeed. Well, I yielded pretty quickly  because it wasn't necessary for my project.\nOtherwise, I am afraid, you will have to implement it yourself from scratch.\nI never heard about a finished solution for your problem.\nIf you succeeded to use PGU, it wouldn't be so hard.\nIf not, well, I wish you luck, and put your solution online for others.\nThere is an Eclipse plug-in for Python. I think that Android studio does not support PGS4A. Never needed it. Console is the queen.","Q_Score":0,"Tags":"java,android,python,android-studio,admob","A_Id":31441510,"CreationDate":"2015-07-15T21:18:00.000","Title":"Admob Ads with Python Subset For Android (PGS4A)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm fairly new to python and want to start doing some more advanced programming in python 3. I installed some modules using pip on the terminal (I'm using a mac) only to find out that the modules only installed for python 2. I think that it's because I only installed it to the python 2 path, which I think is because my system is running python 2 by default.\nBut I have no idea how to get around this. Any ideas?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":33,"Q_Id":31443662,"Users Score":-1,"Answer":"When creating your virtual environment (you are using a virtual environment, right?) use pyvenv <foo> instead of virtualenv <foo>, and that will create a Python 3 virtual environment, free of Python 2. Then you are free to use pip and it will install the modules into that venv.","Q_Score":0,"Tags":"python,macos,python-2.7","A_Id":31443715,"CreationDate":"2015-07-16T00:51:00.000","Title":"Python Modules Only Installing For Python 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm fairly new to python and want to start doing some more advanced programming in python 3. I installed some modules using pip on the terminal (I'm using a mac) only to find out that the modules only installed for python 2. I think that it's because I only installed it to the python 2 path, which I think is because my system is running python 2 by default.\nBut I have no idea how to get around this. Any ideas?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":33,"Q_Id":31443662,"Users Score":0,"Answer":"You need to use pip3. OS X will default to Python 2 otherwise.","Q_Score":0,"Tags":"python,macos,python-2.7","A_Id":31443681,"CreationDate":"2015-07-16T00:51:00.000","Title":"Python Modules Only Installing For Python 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a python script that is designed to run forever. I load the script into a folder that I made on my remote server which is running debian wheezy 7.0. The code runs , but it will only run for 3 to 4 hours then it just stops, I do not have any log information on it stopping.I come back and check the running process and its not there. Is this a problem in where I am running the python file from? The script simply has a while loop and writes to an external csv file. The file runs from \/var\/pythonscript. The folder is a custom folder that I made. There is not error that I receive and the only way I know how long the code runs is by the time stamp on the csv file. I run the .py file by ssh to the server and sudo python scriptname.I also would like to know the best place in the linux debian directory to run python files from and limitations concerning that. Any help would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":31447971,"Users Score":0,"Answer":"Basically you're stuffed.\nYour problem is:\n\nYou have a script, which produces no error messages, no logging, and no other diagnostic information other than a single timestamp, on an output file.\nSomething has gone wrong.\n\nIn this case, you have no means of finding out what the issue was.  I suggest any of the following:\n\neither adding logging or diagnostic information to the script.\nContacting the developer of the script and getting them to find a way of determining the issue.\nDelete the evidently worthless script if you can't do either option 1, or 2, above, and consider an alternative way of doing your task.\n\nNow, if the script does have logging, or other diagnostic data, but you delete or throw them away, then that's your problem and you need to stop discarding this useful information.\nEDIT (following comment).\nAt a basic level, you should print to either stdout, or to stderr, that alone will give you a huge amount of information. Just things like, \"Discovered 314 records, we need to save 240 records\", \"Opened file name X.csv, Open file succeeded (or failed, as the case may be)\", \"Error: whatever\", \"Saved 2315 records to CSV\".  You should be able to determine if those numbers make sense. (There were 314 records, but it determined 240 of them should be saved, yet it saved 2315? What went wrong!? Time for more logging or investigation!)\nIdeally, though, you should take a look at the logging module in python as that will let you log stack traces effectively, show line numbers, the function you're logging in, and the like.   Using the logging module allows you to specify logging levels (eg, DEBUG, INFO, WARN, ERROR), and to filter them or redirect them to file or the console, as you may choose, without changing the logging statements themselves.\nWhen you have a problem (crash, or whatever), you'll be able to identify roughly where the error occured, giving you information to either increase the logging in that area, or to be able to reason what must have happened (though you should probably then add enough logging so that the logging will tell you what happened clearly and unambiguously).","Q_Score":0,"Tags":"python,debian,remote-server,directory-structure","A_Id":31448678,"CreationDate":"2015-07-16T07:30:00.000","Title":"Where to run python file on Remote Debian Sever","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Please bear with me as I have been reading and trying to understand HTTP and the different requests available in its protocol but there are still a few loose connections here and there.\nSpecifically, I have been using Apache's HttpClient to send requests, but I'm unsure of a few things. When we make a request to a URI, how can we know before hand how to properly format say a PUT request? You might be trying to transmit data to fill out a form, or send an image, etc. How would you know if the server is capable of receiving that format of request?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":25,"Q_Id":31466493,"Users Score":0,"Answer":"If you try to PUT without any knowledge of the server this request will \"fail\" (or not - depends on the implementation e.g. it can redirect you to main page). \nFailure is indicated by the server response code along with headers. E.g. 405 Method Not Allowed or 400 bad request etc. Or redirect you to main page: 302 Found\nYou, as a client, must adapt to the server's API.\nMoreover different requests to the same API may give you different specs e.g.\nOne response is gzipped & with ETag & cached, the other one is not.\nOr plain GET \/ will give you HTML and GET \/?format=json will give you JSON.","Q_Score":0,"Tags":"java,http,post,httpclient,python-requests","A_Id":31466587,"CreationDate":"2015-07-17T00:02:00.000","Title":"How to determine how to format an HTTP request to some server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a method name, how to determine which module(s) in the standard library contain this method?\nE.g. If I am told about a method called strip(), but told nothing about how it works or that it is part of str, how would I go and find out which module it belongs to? I obliviously mean using Python itself to find out, not Googling \"Python strip\" :)","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":71,"Q_Id":31481253,"Users Score":2,"Answer":"The trouble is, strip is not defined in any module. It is not a part of the standard library at all, but a method on str, which in turn is a built in class. So there isn't really any way of iterating through modules to find it.","Q_Score":1,"Tags":"python,python-2.7","A_Id":31481601,"CreationDate":"2015-07-17T17:14:00.000","Title":"How to determine which Python standard library module(s) contain a certain method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need a user input for my pygame program, but I need it on my GUI(pygame.display.set_mode etc.), not just like: var = input(\"input something\").  Does anybody have suggestions how to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":113,"Q_Id":31485636,"Users Score":0,"Answer":"There are some answers already here. Anyway, use PGU (Pygame GUI Utilities), it's available on pygame's site. It turns pygame into GUI toolkit. There is an explanation on how to combine it and your game.  Otherwise, program it yourself using key events. It's not hard but time consuming and boring.","Q_Score":0,"Tags":"python,pygame","A_Id":31485743,"CreationDate":"2015-07-17T22:30:00.000","Title":"Pygame, user input on a GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Whenever I google 'importing X package\/module' I always see a bunch of tutorials about using pip or the shell commands. But I've always just taken the downloaded file and put it in the site-packages folder, and when I just use 'import' in PyCharm it has worked just fine.\nThe reason I was wondering was because I was downloading NumPy today, and when I just copied the file the same way I'd been doing, PyCharm didn't show any errors. I was just wondering if I'm misunderstanding this whole concept of installing packages.\nEDIT: Thank you for your answers! I am off to learn how to use pip now.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":308,"Q_Id":31495357,"Users Score":2,"Answer":"Package manager solves things like dependencies and uninstalling.\nAdditionally, when using pip to install packages, packages are usually being built with setup.py script. While it might not be an issue for pure Python modules, if package contains any extension modules or some other custom stuff, copying files to site-packages just won't work (I'm actually not sure why it worked in your case with numpy, since it does contain C extensions modules).","Q_Score":2,"Tags":"python,packages","A_Id":31495419,"CreationDate":"2015-07-18T20:39:00.000","Title":"Installing Packages in Python - Pip\/cmd vs Putting File in Lib\/site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Whenever I google 'importing X package\/module' I always see a bunch of tutorials about using pip or the shell commands. But I've always just taken the downloaded file and put it in the site-packages folder, and when I just use 'import' in PyCharm it has worked just fine.\nThe reason I was wondering was because I was downloading NumPy today, and when I just copied the file the same way I'd been doing, PyCharm didn't show any errors. I was just wondering if I'm misunderstanding this whole concept of installing packages.\nEDIT: Thank you for your answers! I am off to learn how to use pip now.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":308,"Q_Id":31495357,"Users Score":2,"Answer":"One of the points of using a package manager (pip) is portability. With pip, you just include a requirements.txt in your project and you can work on it on any machine, be it Windows, Linux, or Mac. When moving to a new environment\/OS, pip will take care of installing the packages properly for you; note that packages can have OS-specific steps so your copy-pasted Windows set-up might now work when you move to another OS. \nMoreover, with your copy-paste method, you carry the bulk of your dependencies everywhere. I imagine that if you want to switch machines (not necessarily OS), you copy everything from project code to dependencies. With pip, you can keep your working directories leaner, all at the cost of a single requirements.txt.","Q_Score":2,"Tags":"python,packages","A_Id":31495433,"CreationDate":"2015-07-18T20:39:00.000","Title":"Installing Packages in Python - Pip\/cmd vs Putting File in Lib\/site-packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"There is a set of functions that I need to carry out during the start of my server. Regardless of path whether that be \"\/\", \"\/blog\/, \"\/blog\/post\". For developments purposes I'd love for this script to run every time I run python manage.py runserver and for production purposes I would love this script to run during deployment. Anyone know how this can be done? \nMy script is scraping data off and making a call to Facebook's Graph API with python and some of its libraries.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":835,"Q_Id":31506425,"Users Score":0,"Answer":"Sounds like the quickest (if not most elegant) solution would be to call 'python manage.py runserver' at the end of your script.","Q_Score":0,"Tags":"python,django,deployment,development-environment","A_Id":31506797,"CreationDate":"2015-07-19T22:06:00.000","Title":"Django app initialization process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed libffi on my Linux server as well as correctly set the PKG_CONFIG_PATH environment variable to the correct directory, as pip recognizes that it is installed; however, when trying to install pyOpenSSL, pip states that it cannot find file 'ffi.h'. I know both thatffi.h exists as well as its directory, so how do I go about closing this gap between ffi.h and pip?","AnswerCount":8,"Available Count":3,"Score":0.0748596907,"is_accepted":false,"ViewCount":93372,"Q_Id":31508612,"Users Score":3,"Answer":"You need to install the development package for libffi.\nOn RPM based systems (Fedora, Redhat, CentOS etc) the package is named libffi-devel.\nNot sure about Debian\/Ubuntu systems, I'm sure someone else will pipe up with that.","Q_Score":90,"Tags":"python,linux,pip","A_Id":31508671,"CreationDate":"2015-07-20T03:54:00.000","Title":"PIP install unable to find ffi.h even though it recognizes libffi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed libffi on my Linux server as well as correctly set the PKG_CONFIG_PATH environment variable to the correct directory, as pip recognizes that it is installed; however, when trying to install pyOpenSSL, pip states that it cannot find file 'ffi.h'. I know both thatffi.h exists as well as its directory, so how do I go about closing this gap between ffi.h and pip?","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":93372,"Q_Id":31508612,"Users Score":266,"Answer":"You need to install the development package as well.\nlibffi-dev on Debian\/Ubuntu, libffi-devel on Redhat\/Centos\/Fedora.","Q_Score":90,"Tags":"python,linux,pip","A_Id":31508663,"CreationDate":"2015-07-20T03:54:00.000","Title":"PIP install unable to find ffi.h even though it recognizes libffi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed libffi on my Linux server as well as correctly set the PKG_CONFIG_PATH environment variable to the correct directory, as pip recognizes that it is installed; however, when trying to install pyOpenSSL, pip states that it cannot find file 'ffi.h'. I know both thatffi.h exists as well as its directory, so how do I go about closing this gap between ffi.h and pip?","AnswerCount":8,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":93372,"Q_Id":31508612,"Users Score":24,"Answer":"To add to mhawke's answer, usually the Debian\/Ubuntu based systems are \"-dev\" rather than \"-devel\" for RPM based systems\nSo, for Ubuntu it will be apt-get install libffi libffi-dev\nRHEL, CentOS, Fedora (up to v22) yum install libffi libffi-devel\nFedora 23+ dnf install libffi libffi-devel\nOSX\/MacOS (assuming homebrew is installed) brew install libffi","Q_Score":90,"Tags":"python,linux,pip","A_Id":38077173,"CreationDate":"2015-07-20T03:54:00.000","Title":"PIP install unable to find ffi.h even though it recognizes libffi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I thought it was coming by default with the IDLE but I don't have it.\nBy the way, I installed Python 3.4.\nA few researches on the net revealed themselves unfruitful. Any idea about what's going on and how to fix this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2270,"Q_Id":31515583,"Users Score":4,"Answer":"You must be opening the code window not the shell window..\nTry opening the shell window..\nIt has a Debug menu(the shell window) but the code window does not have one..","Q_Score":0,"Tags":"python,debugging,python-3.4,python-idle","A_Id":31515714,"CreationDate":"2015-07-20T11:41:00.000","Title":"My Python IDLE is missing the Debugging menu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Python 2.x and Pygame to code games. Pygame has a built-in rect (Rectangle) class that only supports ints instead of floats. So I have made my own rect class (MyRect) which supports floats. Now my question is as follows:\nA 2D platformer char moves its position (x, y -> both floats). Now when I blit the char onto the screen, is the position rounded to an int (int(round(x))) or just converted into an int (int(x))? I know this might sound a bit stupid, but I've got an issue with this and I'd like to know how this is usually handled.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":68,"Q_Id":31520331,"Users Score":1,"Answer":"You should assume that when blitting a pygame.Surface, the position gets converted to an int via int()","Q_Score":3,"Tags":"python,animation,pygame,2d,sprite","A_Id":31527282,"CreationDate":"2015-07-20T15:21:00.000","Title":"Movement in 2D Games (round position when blitting?)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a WAV file which I would like to visualize in the frequency domain. Next, I would like to write a simple script that takes in a WAV file and outputs whether the energy at a certain frequency \"F\" exceeds a threshold \"Z\" (whether a certain tone has a strong presence in the WAV file). There are a bunch of code snippets online that show how to plot an FFT spectrum in Python, but I don't understand a lot of the steps.\n\nI know that wavfile.read(myfile) returns the sampling rate (fs) and the data array (data), but when I run an FFT on it (y = numpy.fft.fft(data)), what units is y in? \nTo get the array of frequencies for the x-axis, some posters do this where n = len(data): \nX = numpy.linspace(0.0, 1.0\/(2.0*T), n\/2)\nand others do this:\nX = numpy.fft.fftfreq(n) * fs)[range(n\/2)] \nIs there a difference between these two methods and is there a good online explanation for what these operations do conceptually?\nSome of the online tutorials about FFTs mention windowing, but not a lot of posters  use windowing in their code snippets. I see that numpy has a numpy.hamming(N), but what should I use as the input to that method and how do I \"apply\" the output window to my FFT arrays?\nFor my threshold computation, is it correct to find the frequency in X that's closest to my desired tone\/frequency and check if the corresponding element (same index) in Y has an amplitude greater than the threshold?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1122,"Q_Id":31527206,"Users Score":1,"Answer":"FFT data is in units of normalized frequency where the first point is 0 Hz and one past the last point is fs Hz. You can create the frequency axis yourself with linspace(0.0, (1.0 - 1.0\/n)*fs, n). You can also use fftfreq but the components will be negative.\nThese are the same if n is even. You can also use rfftfreq I think. Note that this is only the \"positive half\" of your frequencies, which is probably what you want for audio (which is real-valued). Note that you can use rfft to just produce the positive half of the spectrum, and then get the frequencies with rfftfreq(n,1.0\/fs).\nWindowing will decrease sidelobe levels, at the cost of widening the mainlobe of any frequencies that are there. N is the length of your signal and you multiply your signal by the window. However, if you are looking in a long signal you might want to \"chop\" it up into pieces, window them, and then add the absolute values of their spectra.\n\"is it correct\" is hard to answer. The simple approach is as you said, find the bin closest to your frequency and check its amplitude.","Q_Score":3,"Tags":"python,audio,signal-processing,fft","A_Id":31528542,"CreationDate":"2015-07-20T22:10:00.000","Title":"FFT in Python with Explanations","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Not sure this is the best title for this question but here goes.\nThrough python\/Qt I started multiple processes of an executable. Each process is writing a large file (~20GB) to disk in chunks. I am finding that the first process to start is always the last to finish and continues on much, much longer than the other processes (despite having the same amount of data to write). \nPerformance monitors show that the process is still using the expected amount of RAM (~1GB), but the disk activity from the process has slowed to a trickle. \nWhy would this happen? It is as though the first process started somehow gets its' disk access 'blocked' by the other processes and then doesnt recover after the other processes have finished...\nWould the OS (windows) be causing this? What can I do to alleviate this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1550,"Q_Id":31536863,"Users Score":0,"Answer":"There are no guarantees as to fairness of I\/O scheduling. What you're describing seems rather simple: the I\/O scheduler, whether intentionally or not, gives a boost to new processes. Since your disk is tapped out, the order in which the processes finish is not under your control. You're most likely wasting a lot of disk bandwidth on seeks, due to parallel access from multiple processes.\nTL;DR: Your expectation is unfounded. When I\/O, and specifically the virtual memory system, is saturated, anything can happen. And so it does.","Q_Score":1,"Tags":"python,qt,io,hard-drive,child-process","A_Id":31543489,"CreationDate":"2015-07-21T10:44:00.000","Title":"Why do multiple processes slow down?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used to use manage.py sqlall app to dump the database to sql statements. While, after upgrading to 1.8, it doesn't work any more.\nIt says:\n\nCommandError: App 'app' has migrations. Only the sqlmigrate and\n  sqlflush commands can be used when an app has migrations.\n\nIt seems there is not a way to solve this.\nI need to dump the database to sql file, so I can use it to clone the whole database else where, how can I accomplish this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":31545025,"Users Score":1,"Answer":"You can dump the db directly with mysqldump as allcaps suggested, or run manage.py migrate first and then it should work. It's telling you there are migrations that you have yet to apply to the DB.","Q_Score":1,"Tags":"python,django,django-models","A_Id":31545842,"CreationDate":"2015-07-21T16:49:00.000","Title":"Django: How to dump the database in 1.8?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with XLSX files with pivot tables and writing an automated script to parse and extract the data. I have multiple pivot tables per spreadsheet with cost categories, their totals, and their values for each month etc. Any ideas on how to use openpyxl to parse each pivot table?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1122,"Q_Id":31551135,"Users Score":0,"Answer":"This is currently not possible with openpyxl.","Q_Score":0,"Tags":"python,excel,pivot-table,xlsx,openpyxl","A_Id":31556316,"CreationDate":"2015-07-21T23:05:00.000","Title":"Extracting data from excel pivot tables using openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use a folder that is not in the base directory of my django project without adding it in to the base directory.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":83,"Q_Id":31553322,"Users Score":1,"Answer":"Open File > settings menu and then goto project: foo > Project Structure and press Add Content Root, then select destination directory.\nand after folder added in list, right click on the folder and set as source, in last step press OK...","Q_Score":1,"Tags":"python,django,directory,pycharm","A_Id":31554899,"CreationDate":"2015-07-22T03:27:00.000","Title":"PyCharm - how to use a folder that is not in the base directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I couldn't find any resources on this topic. There are a few questions with good answers describing solutions to problems which call for data stored on disk (pickle, shelve, databases in general), but I want to learn how to implement my own. \n1) If I were to create a disk based graph structure in Python, I'd have to implement the necessary methods by writing to disk. But how do I do that? \n2) One of the benefits on disk based structures is having the efficiency of the structure while working with data that might not all fit on memory. If the data does not fit in memory, only some parts of it are accessed at once. How does one access only part of the structure at once?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1607,"Q_Id":31580478,"Users Score":1,"Answer":"There's quite a number of problems you have to solve, some are quite straight forward and some are a little bit more elaborate, but since you want to do it yourself I don't think you minding about filling out details yourself (so I'll skip some parts).\nFirst simple step is to serialize and deserialize nodes (in order to be able to store on disk at all). That could be done in an ad hoc manner by having your nodes having an serialize\/deserialize method - in addition you might want to have the serialized data to have an type indicator so you can know which class' deserialize you should use to deserialize data. Note that on disk representation of a node must reference other nodes by file offset (either directly or indirectly).\nThe actual reading or writing of the data is done by ordinary (binary) file operations, but you have to seek to the right position in the file first.\nSecond step is to have the possibility to allocate space in the file. If you only want to have a write-once-behaviour it's quiete forward to just grow the file, but if you want to modify the data in the file (adding and removing nodes or even replacing them) you will have to cope with situation where regions in the file that are no longer in use and either reuse these or even pack the layout of the file.\nFurther steps could involve making the update atomic in some sense. One solution is to have a region where you write enough information so that the update can be completed (or abandoned) if it were terminated prematurely in it's most simple form it might just be a list of indempotent operations (operation that yields the same result if you repeat them, fx writing particular data to a particular place in the file).\nNote that while (some of) the builtin solutions does indeed handle writing and reading the entire graph to\/from disk they do not really handle the situation where you want to read only part of the graph or modifying the graph very efficient (you have to read mostly the whole graph and writing the complete graph in one go). Databases are the exception where you may read\/write smaller parts of your data in a random manner.","Q_Score":1,"Tags":"python,file,data-structures,disk","A_Id":31581102,"CreationDate":"2015-07-23T07:10:00.000","Title":"Creating a disk-based data structure","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using python 2.7, I need to convert the following curl command to execute in python. \ncurl -b \/tmp\/admin.cookie --cacert \/some\/cert\/location\/serverapache.crt --header \"X-Requested-With: XMLHttpRequest\" --request POST  \"https:\/\/www.test.com\"\nI am relatively new to Python and are not sure how to use the urllib library or if I should use the requests library.  The curl options are especially tricky for me to convert. Any help will be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":31582012,"Users Score":0,"Answer":"Can you stay under command line ? \nIf yes, try the python lib nammed \"pexpect\". It's pretty useful, and let you run commands like on a terminal, from a python program, and interact with the terminal !","Q_Score":1,"Tags":"python,curl","A_Id":31584263,"CreationDate":"2015-07-23T08:28:00.000","Title":"curl and curl options to python conversion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am generating some Python files in my setup.py as part of the build process. These files should be part of the installation. I have successfully added my code generator as a pre-build step (by implementing my own Command and overriding the default build to include this).\nHow do I copy my generated files from the temporary directory into the build output? Should I copy it myself using e.g. copy_file? If so, how do I get the path to the build output? Or should I declare it as part of the build somehow?\nI'd rather not clutter the source directory tree with my generated files, hence I prefer to avoid copying the files there and then declaring them as part of the package.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":67,"Q_Id":31585809,"Users Score":1,"Answer":"I solved this by subclassing build_py instead of build. It turns out build_py has a build_lib attribute that will be the path to the \"build\" directory.\nBy looking at the source code I think there is no better way.","Q_Score":2,"Tags":"python,code-generation,distutils","A_Id":31618879,"CreationDate":"2015-07-23T11:18:00.000","Title":"Add generated Python file as part of build","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a c-program which includes a make file that works fine on unix systems. Although I would like to compile the program for windows using this make file, how can i go around doing that?\nAdditionally I have python scripts that call this c-program using ctypes, I don't imagine I will have to much of an issue getting ctypes working on windows but i heard its possible to include all the python and c scripts in one .exe for windows, has anyone heard of that?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":69,"Q_Id":31606659,"Users Score":1,"Answer":"Answer to your first paragraph: Use MinGW for the compiler (google it, there is a -w64 version if you need that) and MSYS for a minimal environment including shell tools the Makefile could need.","Q_Score":0,"Tags":"python,c,unix,gcc","A_Id":31606702,"CreationDate":"2015-07-24T09:17:00.000","Title":"Compiling a unix make file for windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been studying KD Trees and KNN searching in 2D & 3D space. The thing I cannot seem to find a good explanation of is how to identify which objects are being referenced by each node of the tree. \nExample would be an image comparison database. If you generated descriptors for all the images, would you push all the descriptor data on to one tree? If so, how do you know which nodes are related to which original images? If not, would you generate a tree for each image, and then do some type of KD-Tree Random Forest nearest neighbor queries to determine which trees are closest to each other in 3-D space?\nThe image example might not be a good use case for KD-Trees since it's highly dimensional space, but I'm more using it to help explain the question I'm asking.\nAny guidance on practical applications of KD-Tree KNN queries for comparing objects is greatly appreciated. \nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":245,"Q_Id":31611089,"Users Score":0,"Answer":"A typical KD tree node contains a reference to the data point.\nA KD tree that only keeps the coordinates is much less useful.\nThis way, you can easily identify them.","Q_Score":1,"Tags":"python,tree,kdtree","A_Id":31646627,"CreationDate":"2015-07-24T12:54:00.000","Title":"How to identify objects related to KD Tree data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for some suggestions about how to do continue training in theano. For example, I have the following:\n\nclassifier = my_classifier()\n\ncost = ()\nupdates = []\ntrain_model = theano.function(...)\neval_model = theano.function(...)\n\nbest_accuracy = 0\nwhile (epoch < n_epochs):\n\n    train_model()\n\n    current_accuracy = eval_model()\n    if current_accuracy > best_accuracy:\n        save classifier or save theano functions?\n        best_accuracy = current_accuracy\n    else:\n        load saved classifier or save theano functions?\n        if we saved classifier previously, do we need to redefine train_model and eval_model functions?\n\n    epoch+=1\n\n#training is finished\nsave classifier\n\nI want to save the current trained model if it has higher accuracy than previously trained models, and load the saved model later if the current trained model accuracy is lower than the best accuracy. \nMy questions are:\nWhen saving, should I save the classifier, or theano functions? \nIf the classifier needs to be saved, do I need to redefine theano functions when loading it, since classifier is changed. \nThanks,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":246,"Q_Id":31612074,"Users Score":0,"Answer":"When pickling models, it is always better to save the parameters and when loading re-create the shared variable and rebuild the graph out of this. This allow to swap the device between CPU and GPU.\nBut you can pickle Theano functions. If you do that, pickle all associated function at the same time. Otherwise, they will have each of them a different copy of the shared variable. Each call to load() will create new shared variable if they where pickled. This is a limitation of pickle.","Q_Score":0,"Tags":"python,theano,deep-learning","A_Id":31778280,"CreationDate":"2015-07-24T13:39:00.000","Title":"Theano continue training","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to setup a remote kernel on my Raspberry Pi right now, using IPython as my remote kernel and try to connect to this kernel using Spyder.\nUsing Spyder to create local kernels and use them to interpret code is working perfectly fine. Starting a kernel on my Raspberry Pi also works well using ipython kernel.\nAs described by many other users before, the .JSON file for the connection details I have to hand to Spyder, is located at \/home\/<username>\/.ipython\/profile_default\/security\/kernel-<id>.json. Unfortunately I can't find this .JSON file on my Raspberry Pi, but if I try to connect an existing kernel on my local PC I can find all local kernels.\nWhat is the problem with the kernels on my Raspberry Pi? Why aren't they saved as .JSON files?\nAnother question: I accidently created another profile in IPython, how can I remove this profile?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":809,"Q_Id":31626044,"Users Score":0,"Answer":"On my Raspberry PI the .json are located in \/home\/<username>\/.config\/ipython\/profile_default\/security\/","Q_Score":1,"Tags":"raspberry-pi,ipython,ipython-notebook","A_Id":36211430,"CreationDate":"2015-07-25T11:34:00.000","Title":"Can't find IPython Kernel .JSON file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am debugging a test case. I use Python's OptionParser (from optparse) to do some testing and one of the options is a HTTP request.\nThe input in this specific case for the http request was 269KB in size.\nSo my python program fails with \"Argument list too long\" (I verified that there was no other arguments passed, just the request and one more argument as expected by the option parser. When I throw away some of the request and reduce its size, things work fine. So I have a strong reason to believe the size of the request is causing my problems here.)\nIs it possible for a HTTP request to be that big ?\nIf so how do I fix the OptionParser to handle this input?","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":82,"Q_Id":31630636,"Users Score":3,"Answer":"Is it possible for a HTTP request to be that big ?\n\nYes it's possible but it's not recommended and you could have compatibility issues depending on your web server configuration. If you need to pass large amounts of data you shouldn't use GET. \n\nIf so how do I fix the OptionParser to handle this input?\n\nIt appears that OptionParser has set its own limit well above what is considered a practical implementation. I think the only way to 'fix' this is to get the Python source code and modify it to meet your requirements. Alternatively write your own parser. \nUPDATE:  I possibly mis-interpreted the question and the comment from Padraic below may well be correct. If you have hit an OS limit for command line argument size then it is not an OptionParser issue but something much more fundamental to your system design that means you may have to rethink your solution. This also possibly explains why you are attempting to use GET in your application (so you can pass it on the command line?)","Q_Score":3,"Tags":"python,http","A_Id":31630829,"CreationDate":"2015-07-25T20:09:00.000","Title":"Is a HTTP Get request of size 269KB allowed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am debugging a test case. I use Python's OptionParser (from optparse) to do some testing and one of the options is a HTTP request.\nThe input in this specific case for the http request was 269KB in size.\nSo my python program fails with \"Argument list too long\" (I verified that there was no other arguments passed, just the request and one more argument as expected by the option parser. When I throw away some of the request and reduce its size, things work fine. So I have a strong reason to believe the size of the request is causing my problems here.)\nIs it possible for a HTTP request to be that big ?\nIf so how do I fix the OptionParser to handle this input?","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":31630636,"Users Score":0,"Answer":"Typical limit is 8KB, but it can vary (like, be even less).","Q_Score":3,"Tags":"python,http","A_Id":31630668,"CreationDate":"2015-07-25T20:09:00.000","Title":"Is a HTTP Get request of size 269KB allowed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am debugging a test case. I use Python's OptionParser (from optparse) to do some testing and one of the options is a HTTP request.\nThe input in this specific case for the http request was 269KB in size.\nSo my python program fails with \"Argument list too long\" (I verified that there was no other arguments passed, just the request and one more argument as expected by the option parser. When I throw away some of the request and reduce its size, things work fine. So I have a strong reason to believe the size of the request is causing my problems here.)\nIs it possible for a HTTP request to be that big ?\nIf so how do I fix the OptionParser to handle this input?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":82,"Q_Id":31630636,"Users Score":2,"Answer":"A GET request, unlike a POST request, contains all its information in the url itself. This means you have an URL of 269KB, which is extremely long. \nAlthough there is no theoretical limit on the size allowed, many servers don't allow urls of over a couple of KB long and should return a 414 response code in that case. A safe limit is 2KB, although most modern software will allow a bit more than that. \nBut still, for 269KB, use POST (or PUT if that is semantically more correct), which can contain larger chunks of data as the content of a request rather than the url.","Q_Score":3,"Tags":"python,http","A_Id":31630678,"CreationDate":"2015-07-25T20:09:00.000","Title":"Is a HTTP Get request of size 269KB allowed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having a Python application which offloads a number of processing work to a set of celery workers. The main application has to then wait for results from these workers. As and when result is available from a worker, the main application will process the results and will schedule more workers to be executed.\nI would like the main application to run in a non-blocking fashion. As of now, I am having a polling function to see whether results are available from any of the workers.\nI am looking at the possibility of using asyncio get notification about result availability so that I can avoid the polling. But, I could not find any information on how to do this.\nAny pointers on this will be highly appreciated.\nPS: I know with gevent, I can avoid the polling. However, I am on python3.4 and hence would prefer to avoid gevent and use asyncio.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2413,"Q_Id":31636454,"Users Score":2,"Answer":"I implement on_finish function of celery worker to publish a message to redis\nthen in the main app uses aioredis to subscribe the channel, once got notified, the result is ready","Q_Score":2,"Tags":"python,celery,python-asyncio","A_Id":43289761,"CreationDate":"2015-07-26T11:30:00.000","Title":"Collecting results from celery worker with asyncio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have been building a project on Ubuntu 15.04 with Python 3.4 and django 1.7. Now I want to use scrapy djangoitem, but that only runs on python 2.7. It's easy enough to have separate virtualenvs to do the developing in, but how can i put these different apps together in a single project, not only on my local machine, but later on heroku? \nIf it was just content, I could move the scrapy items over once the work was done, but the idea of djangoitem is that it uses the django model. Does that mean the django model has to be on python 2.7 also in order for djangoitem to access it? Even that is not insurmountable if I then port it to python 3, but it isn't very DRY, especially when i have to run scrapy for frequent updates. Is there a more direct solution, such as a way to have one app be 2.7 and another be 3.4 in the same project? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":67,"Q_Id":31639596,"Users Score":3,"Answer":"It's impossible for apps in the same project to be on different Python versions; the server has to run on one or the other. But it would be possible to have two projects, with your models in a shared app that is installed in both models, and the configuration pointing to the same database.","Q_Score":1,"Tags":"python,django,heroku,scrapy","A_Id":31639931,"CreationDate":"2015-07-26T16:59:00.000","Title":"multiple versions of django\/python in a single project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to find out if you strings are almost similar. For example, string like 'Mohan Mehta' should match 'Mohan Mehte' and vice versa. Another example, string like 'Umesh Gupta' should match 'Umash Gupte'. \nBasically one string is correct and other one is a mis-spelling of it. All my strings are names of people.\nAny suggestions on how to achieve this.\nSolution does not have to be 100 percent effective.","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":17280,"Q_Id":31642940,"Users Score":1,"Answer":"You could split the string and check to see if it contains at least one first\/last name that is correct.","Q_Score":22,"Tags":"python,regex,string","A_Id":53998316,"CreationDate":"2015-07-26T23:19:00.000","Title":"Finding if two strings are almost similar","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to import a module I have created if the script I am working on is in the same directory.  I would like to know how to set it up so I can import this module from anywhere.  For example, I would like to open up Python in the command line and type \"import my_module\" and have it work regardless of which directory I am in.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":31644834,"Users Score":0,"Answer":"To make this work consistently, you can put the module into the lib folder inside the python folder, then you can import it regardless of what directory you are in","Q_Score":0,"Tags":"python-2.7,module","A_Id":36118903,"CreationDate":"2015-07-27T04:08:00.000","Title":"Importing a python module I have created","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to import a module I have created if the script I am working on is in the same directory.  I would like to know how to set it up so I can import this module from anywhere.  For example, I would like to open up Python in the command line and type \"import my_module\" and have it work regardless of which directory I am in.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31,"Q_Id":31644834,"Users Score":0,"Answer":"You could create pth file with path to your module and put it into your Python site-packages directory.","Q_Score":0,"Tags":"python-2.7,module","A_Id":36118957,"CreationDate":"2015-07-27T04:08:00.000","Title":"Importing a python module I have created","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to do such thing, but I don't even know if it is possible to accomplish and if so, how to do this. \nI wrote an Django application which I would like to 'attach' to my wordpress blog. However, I need a permalink (but no page in wordpress pages section) which would point to Django application on the same server. Is that possible?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":138,"Q_Id":31649314,"Users Score":2,"Answer":"There are many ways to do this. You will have to provide more info about what you are trying to accomplish to give the right advise.\n\nmake a page with a redirect (this is an ugly solution in seo and user perspective)\nhandle this on server level.\nload your Django data with an ajax call","Q_Score":0,"Tags":"python,django,wordpress","A_Id":31649614,"CreationDate":"2015-07-27T09:21:00.000","Title":"How to create empty wordpress permalink and redirect it into django website?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have generated the spectrogram with GNU Radio and want to save the output graph but have no idea how to do it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":791,"Q_Id":31660214,"Users Score":1,"Answer":"The \"QT GUI Frequency Sink\" block will display the frequency domain representation of a signal.  You can save a static image of the spectrum by accessing the control panel using center-click and choosing \"Save\".","Q_Score":1,"Tags":"python,gnuradio,gnuradio-companion","A_Id":31667553,"CreationDate":"2015-07-27T18:07:00.000","Title":"How to save a graph that is generated by GNU Radio?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using wxPython to write an app.  I have a menu that pops up.  I would like to know how to keep it on the screen after the user clicks an item on the menu.  I only want it to go away after the click off it or if I tell it to in the programming.  Does anyone know how to do this?\nI am using RHEL 6 and wxPython 3.01.1","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":31661138,"Users Score":0,"Answer":"I don't think the regular wx.PopupMenu will work that way. However if you look at the wxPython demo, you will see a neat widget called wx.PopupWindow that claims it can be used as a menu and it appears to work the way you want. The wx.PopupTransientWindow might also work.","Q_Score":1,"Tags":"python,wxpython","A_Id":31680789,"CreationDate":"2015-07-27T18:58:00.000","Title":"Keep menu up after clicking in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am aware that you can get a reference to an existing model from within another model by using self.pool.get('my_model')\nMy question is, how can I get a reference to a model from a Python class that does NOT extend 'Model'?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":714,"Q_Id":31675839,"Users Score":0,"Answer":"It's pretty basic and simple any python class can be called from it's name space,  so call your class from namespace and instanciate the class.\nEven Model class or any class inherited from Model can be called and instanciated like this.\nSelf.pool is just orm cache to access framework persistent layer.\nBests","Q_Score":0,"Tags":"python,odoo","A_Id":31680404,"CreationDate":"2015-07-28T12:05:00.000","Title":"Access ORM models from different classes in Odoo\/OpenERP","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sometimes I download the python source code from github and don't know how to install all the dependencies. If there is no requirements.txt file I have to create it by hands.\nThe question is:\nGiven the python source code directory is it possible to create requirements.txt automatically from the import section?","AnswerCount":21,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":795098,"Q_Id":31684375,"Users Score":0,"Answer":"To help solve this problem, always run requirements.txt on only local packages. By local packages I mean packages that are only in your project folder. To do this do:\nPip freeze \u2014local > requirements.txt\nNot pip freeze > requirements.txt.\nNote that it\u2019s double underscore before local.\nHowever installing pipreqs helps too.\nPip install pipreqs.\nThe perfect solution though is to have a pipfile. The pipfile updates on its own whenever you install a new local package. It also has a pipfile.lock similar to package.json in JavaScript.\nTo do this always install your packages with pipenv not pip.\nSo we do pipenv","Q_Score":778,"Tags":"python,dependencies,python-import,requirements.txt","A_Id":72116250,"CreationDate":"2015-07-28T18:29:00.000","Title":"Automatically create requirements.txt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Web2Py and Python stack. I need to use a module in my Web2Py application which uses \"gensim\" and \"nltk\" libraries. I tried installing these into my Python 2.7 on a Windows 7 environment but came across several errors due to some issues with \"numpy\" and \"scipy\" installations on Windows 7. Then I ended up resolving those errors by uninstalling Python 2.7 and instead installing Anaconda Python which successfully installed the required \"gensim\" and \"nltk\" libraries. \nSo, at this stage I am able to see all these \"gensim\" and \"nltk\" libraries resolving properly without any error in \"Spyder\" and \"PyCharm\". However, when I run my application in Web2Py, it still complains about \"gensim\" and gives this error: <type 'exceptions.ImportError'> No module named gensim\nMy guess is if I can configure Web2Py to use the Anaconda Python then this issue would be resolved. \nI need to know if it's possible to configure Web2Py to use Anaconda Python and if it is then how do I do that? \nOtherwise, if someone knows of some other way resolve that \"gensim\" error in Web2Py kindly share your thoughts.\nAll your help would be highly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":712,"Q_Id":31685048,"Users Score":2,"Answer":"The Windows binary includes it's own Python interpreter and will therefore not see any packages you have in your local Python installation.\nIf you already have Python installed, you should instead run web2py from source.","Q_Score":0,"Tags":"python-2.7,web2py,anaconda,gensim","A_Id":31687769,"CreationDate":"2015-07-28T19:05:00.000","Title":"Configure Web2Py to use Anaconda Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Using the randomForest package in R, I was able to train a random forest that minimized overall error rate. However, what I want to do is train two random forests, one that first minimizes false positive rate (~ 0) and then overall error rate, and one that first maximizes sensitivity (~1), and then overall error. Another construction of the problem would be: given a false positive rate and sensitivity rate, train two different random forests that satisfy one of the rates respectively, and then minimize overall error rate. Does anyone know if theres an r package or python package, or any other software out there that does this and or how to do this? Thanks for the help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1366,"Q_Id":31711555,"Users Score":0,"Answer":"You can do a grid serarch over the 'regularazation' parameters to best match your target behavior.\nParameters of interest:\n\nmax depth\nnumber of features","Q_Score":1,"Tags":"python,r,machine-learning,random-forest","A_Id":31742947,"CreationDate":"2015-07-29T21:34:00.000","Title":"random forest with specified false positive and sensitivity","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to develop a online mobile app. I am thinking about using native languages to develop the front-ends, so Java for Android and Objective-C for iOS. However, for the back-end, can I use something like Django?\nI have used django for a while, but the tutorials are really lacking, so can anyone point me to something that will help me understand how to show data handled by Django models on a front-end developed by Java for an android device (that is, by using XML I suppose).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3574,"Q_Id":31760059,"Users Score":0,"Answer":"Sure. I've done this for my first app and others then. The backend technology is totally up to you, so feel free to take whatever you like.\nThe connection between backend and your apps should (but don't have to be) be something JSON-based. Standard REST works fine, Websockets also but have some issues on iOS.","Q_Score":1,"Tags":"android,python,ios,django","A_Id":31760094,"CreationDate":"2015-08-01T08:53:00.000","Title":"Is it possible to develop the back-end of a native mobile app using the python powered framework Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Overview\nAfter upgrading to 10.11 Yosemite, I discovered that vim (on the terminal) highlights a bunch of errors in my python scripts that are actually not errors.\ne.g.\nThis line:\nfrom django.conf.urls import patterns\ngets called out as an [import-error] Unable to import 'django.conf.urls'.\nThis error is not true because I can open up a python shell from the command line and import the supposedly missing module. I'm also getting a bunch of other errors all the way through my python file too: [bad-continuation] Wrong continued indentation, [invalid-name] Invalid constant name, etc.\nAll of these errors are not true.\nQuestion\nAnyway, how do I turn off these python error checks?\nvim Details\nvim --version:\nVIM - Vi IMproved 7.3 (2010 Aug 15, compiled Nov  5 2014 21:00:28)\nCompiled by root@apple.com\nNormal version without GUI.  Features included (+) or not (-):\n-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent\n-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments\n-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs\n-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path\n+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv\n+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent\n+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape\n-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse\n+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype\n+path_extra -perl +persistent_undo +postscript +printer -profile +python\/dyn\n-python3 +quickfix +reltime -rightleft +ruby\/dyn +scrollbind +signs\n+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary\n+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title\n -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo\n+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp\n -xterm_clipboard -xterm_save\n   system vimrc file: \"$VIM\/vimrc\"\n     user vimrc file: \"$HOME\/.vimrc\"\n      user exrc file: \"$HOME\/.exrc\"\n  fall-back for $VIM: \"\/usr\/share\/vim\"\nCompilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe\nLinking: gcc -arch i386 -arch x86_64 -o vim -lncurses","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":421,"Q_Id":31799087,"Users Score":2,"Answer":"Vim doesn't check Python syntax out of the box, so a plugin is probably causing this issue.\nNot sure why an OS upgrade would make a Vim plugin suddenly start being more zealous about things, of course, but your list of installed plugins (however you manage them) is probably the best place to start narrowing down your problem.","Q_Score":1,"Tags":"python,macos,vim,osx-yosemite","A_Id":31800107,"CreationDate":"2015-08-04T01:01:00.000","Title":"How Do I Turn Off Python Error Checking in vim? (vim terminal 7.3, OS X 10.11 Yosemite)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In Django grappelli, how can I add my own css files to all the admin pages? Or is there a way to extend admin's base.html template?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3792,"Q_Id":31849867,"Users Score":2,"Answer":"If you want to change the appearance of the admin in general you should override admin templates. This is covered in details here: Overriding admin templates. Sometimes you can just extend the original admin file and then overwrite a block like {% block extrastyle %}{% endblock %} in django\/contrib\/admin\/templates\/admin\/base.html as an example.\nIf your style is model specific you can add additional styles via the Media meta class in your admin.py. See an example here:\n\nclass MyModelAdmin(admin.ModelAdmin):\n        class Media:\n            js = ('js\/admin\/my_own_admin.js',)\n            css = {\n                 'all': ('css\/admin\/my_own_admin.css',)\n            }","Q_Score":1,"Tags":"python,django,django-admin,django-grappelli","A_Id":31850151,"CreationDate":"2015-08-06T07:50:00.000","Title":"Django (grappelli): how add my own css to all the pages or how to extend admin's base.html?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to wrap my head around what I can\/cannot do with Jupyter.\nI have a Jupyter server running on our internal server, accessible via VPN and password protected. \nI am the only one actually creating notebooks but I would like to make some notebooks visible to other team members in a read-only way. Ideally I could just share a URL with them that they would bookmark for when they want to see the notebook with refreshed data.\nI saw export options but cannot find any mention of \"publishing\" or \"making public\" local live notebooks. Is this impossible? Is it maybe just a wrong way to think about how Jupyter should be used?","AnswerCount":6,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":147878,"Q_Id":31855794,"Users Score":24,"Answer":"Michael's suggestion of running your own nbviewer instance is a good one I used in the past with an Enterprise Github server. \nAnother lightweight alternative is to have a cell at the end of your notebook that does a shell call to nbconvert so that it's automatically refreshed after running the whole thing: \n!ipython nbconvert <notebook name>.ipynb --to html\nEDIT: With Jupyter\/IPython's Big Split, you'll probably want to change this to !jupyter nbconvert <notebook name>.ipynb --to html now.","Q_Score":179,"Tags":"python,jupyter-notebook,jupyter","A_Id":33249008,"CreationDate":"2015-08-06T12:28:00.000","Title":"How can I share Jupyter notebooks with non-programmers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have some code that attempts to find a resource on HDFS...if it is not there it will calculate the contents of that file, then write it.  And next time it goes to be accessed the reader can just look at the file.  This is to prevent expensive recalculation of certain functions\nHowever...I have several processes running at the same time on different machines on the same cluster.  I SUSPECT that they are trying to access the same resource and I'm hitting a race condition that leads a lot of errors where I either can't open a file or a file exists but can't be read.\nHopefully this timeline will demonstrate what I believe my issue to be\n\nProcess A goes to access resource X\nProcess A finds resource X exists and begins writing\nProcess B goes to access resource X\nProcess A finishes writing resource X\n...and so on\n\nObviously I would want Process B to wait for Process A to be done with Resource X and simply read it when A is done.\nSomething like semaphores come to mind but I am unaware of how to use these across different python processes on separate processors looking at the same HDFS location.  Any help would be greatly appreciated\nUPDATE: To be clear..process A and process B will end up calculating the exact same output (i.e. the same filename, with the same contents, to the same location).  Ideally, B shouldn't have to calculate it.  B would wait for A to calculate it, then read the output once A is done.  Essentially this whole process is working like a \"long term cache\" using HDFS.  Where a given function will have an output signature.  Any process that wants the output of a function, will first determine the output signature (this is basically a hash of some function parameters, inputs, etc.).  It will then check the HDFS to see if it is there.  If it's not...it will write calculate it and write it to the HDFS so that other processes can also read it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":31860630,"Users Score":2,"Answer":"(Setting aside that it sounds like HDFS might not be the right solution for your use case, I'll assume you can't switch to something else. If you can, take a look at Redis, or memcached.)\nIt seems like this is the kind of thing where you should have a single service that's responsible for computing\/caching these results. That way all your processes will have to do is request that the resource be created if it's not already. If it's not already computed, the service will compute it; once it's been computed (or if it already was), either a signal saying the resource is available, or even just the resource itself, is returned to your process.\nIf for some reason you can't do that, you could try using HDFS for synchronization. For example, you could try creating the resource with a sentinel value inside which signals that process A is currently building this file. Meanwhile process A could be computing the value and writing it to a temporary resource; once it's finished, it could just move the temporary resource over the sentinel resource. It's clunky and hackish, and you should try to avoid it, but it's an option.\nYou say you want to avoid expensive recalculations, but if process B is waiting for process A to compute the resource, why can't process B (and C and D) be computing it as well for itself\/themselves? If this is okay with you, then in the event that a resource doesn't already exist, you could just have each process start computing and writing to a temporary file, then move the file to the resource location. Hopefully moves are atomic, so one of them will cleanly win; it doesn't matter which if they're all identical. Once it's there, it'll be available in the future. This does involve the possibility of multiple processes sending the same data to the HDFS cluster at the same time, so it's not the most efficient, but how bad it is depends on your use case. You can lessen the inefficiency by, for example, checking after computation and before upload to the HDFS whether someone else has created the resource since you last looked; if so, there's no need to even create the temporary resource.\nTLDR: You can do it with just HDFS, but it would be better to have a service that manages it for you, and it would probably be even better not to use HDFS for this (though you still would possibly want a service to handle it for you, even if you're using Redis or memcached; it depends, once again, on your particular use case).","Q_Score":5,"Tags":"python,hdfs,race-condition,ioerror","A_Id":31934576,"CreationDate":"2015-08-06T16:05:00.000","Title":"Sharing a resource (file) across different python processes using HDFS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's my problem,\nI have a shared hosting (GoDaddy Linux Hosting package) account and I'd like to create .py file to do some scraping for me. To do this I need the scrapy module (scrapy.org). Because of the shared account I can't install new modules so I installed VirtualEnv and created a new virtual env. that has pip, wheel, etc. preinstalled.\nRunning pip install scrapydoes NOT complete successfully because scrapy has lot of dependencies like libxml2 and it also needs python-dev tools. If I had access to 'sudo apt-get ...' this would be easy but I dont'. I can only use pip and easy_install.\nSo How do I install the python dev tool? And how do I install the dependencies? Is this even possible?\nCheers","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2964,"Q_Id":31866429,"Users Score":0,"Answer":"It's not possible to do what I wanted to do on the GoDaddy plan I had.","Q_Score":1,"Tags":"python,scrapy,virtualenv","A_Id":33439385,"CreationDate":"2015-08-06T21:51:00.000","Title":"Installing Scrapy on Python VirtualEnv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running a Python script that uses the requests library to get data from a service.\nThe script takes a while to finish and I am currently running it locally on my Windows 7 laptop. If I lock my screen and leave, will the script continue to run (for ~3 hours) without Windows disconnecting from the internet or halting any processes? The power settings are already set up to keep the laptop from sleeping.\nIf it will eventually halt anything, how do I keep this from happening? Thanks.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":27171,"Q_Id":31866507,"Users Score":13,"Answer":"As long as the computer doesn't get put to sleep, your process should continue to run.","Q_Score":14,"Tags":"python,windows","A_Id":31866538,"CreationDate":"2015-08-06T21:57:00.000","Title":"Keep Python script running after screen lock (Win. 7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running a Python script that uses the requests library to get data from a service.\nThe script takes a while to finish and I am currently running it locally on my Windows 7 laptop. If I lock my screen and leave, will the script continue to run (for ~3 hours) without Windows disconnecting from the internet or halting any processes? The power settings are already set up to keep the laptop from sleeping.\nIf it will eventually halt anything, how do I keep this from happening? Thanks.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":27171,"Q_Id":31866507,"Users Score":7,"Answer":"Check \"Power Options\" in the Control panel. You don't need to worry about the screen locking or turning off as these wont affect running processes. However, if your system is set to sleep after a set amount of time you may need to change this to Never. Keep in mind there are separate settings depending on whether or not the system is plugged in.","Q_Score":14,"Tags":"python,windows","A_Id":31866586,"CreationDate":"2015-08-06T21:57:00.000","Title":"Keep Python script running after screen lock (Win. 7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a python file that collect data. After collecting all the data, it will print out \"Done.\". Sometimes, it might take atleast 3 minutes to collect all the data.\nI would like to know how to print something like \"Please wait...\" for every 30 seconds, and it will stop after collecting all the data. \nCan anyone help me please?","AnswerCount":4,"Available Count":1,"Score":-0.1488850336,"is_accepted":false,"ViewCount":1834,"Q_Id":31870616,"Users Score":-3,"Answer":"If the program would know how much data it is getting, you could set it up to function like a progress bar..","Q_Score":1,"Tags":"python,python-2.7,time","A_Id":31870657,"CreationDate":"2015-08-07T05:52:00.000","Title":"Python Priting Out Something While Waiting For Long Output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am fairly new to unit testing. And at the moment I have trouble on trying to unit test a Google oAuth Picasa authentication. It involves major changes to the code if I would like to unit tested it (yeah, I develop unit test after the app works). \nI have read that Mock Object is probably the way to go. But if I use Mock, how do I know that the functionality (that is Google oAuth Picasa authentication), is really working?\nOr, aside that I develop unit testing after the app finished, did I made other mistakes in understanding Mock?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":31892531,"Users Score":1,"Answer":"When unit testing, you test a particular unit (function\/method...) in isolation, meaning that you don't care if other components that your function uses, work (since there are other unit test cases that cover those).\nSo to answer your question - it's out of the scope of your unit tests whether an external service like Google oAuth works. You just need to tests that you make a correct call to it, and here's where Mock comes in handy. It remembers the call for you to inspect and make some assertions about it, but it prevents the request for actually going out to the external service \/ component \/ library \/ whatever.\nEdit: If you find your code is too complex and difficult to test, that might be an indication that it should be refactored into smaller more manageable pieces.","Q_Score":0,"Tags":"python,unit-testing","A_Id":31892566,"CreationDate":"2015-08-08T11:17:00.000","Title":"How can mock object replace all system functionality being tested?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok the title explains it all. But just to clarify. \nI have Ubuntu and programed a GUI app with Qt Designer 4 and PyQt4. The program works fine running python main.py in terminal.\nLast week I made an update and now the program needs sudo privelages to start. So I type sudo python main.py.\nBut Oh my GODDDDDDD. What an ungly inteface came up. O.o\nAnd I don't know how to get the realy nice normal-mode interface in my programm and all of my others programs i'll make. Is there any way to set a vaiable to python? Do I need to execute any command line code? \nThe program is deployed only in Linux machines. \nP.S.\nI search a lot in the web and couldn't find a working solution.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1223,"Q_Id":31893477,"Users Score":0,"Answer":"This is a hacky solution.    \n\nInstall qt-qtconf. sudo apt-get install qt4-qtconfig\nRun sudo qtconfig or gksudo qtconfig.\nChange GUI Style to GTK+.\n\nEdited.","Q_Score":0,"Tags":"python,linux,qt,ubuntu,pyqt","A_Id":42756312,"CreationDate":"2015-08-08T13:11:00.000","Title":"How to run PyQt4 app with sudo privelages in Ubuntu and keep the normal user style","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter)","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":3088,"Q_Id":31906949,"Users Score":2,"Answer":"go to settings->input method select word-based","Q_Score":2,"Tags":"qpython","A_Id":41871252,"CreationDate":"2015-08-09T17:32:00.000","Title":"in qpython, how do I enter a \"return\" character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter)","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3088,"Q_Id":31906949,"Users Score":0,"Answer":"The console works just like a normally python console. You can use a function if you want to write a script in the console.","Q_Score":2,"Tags":"qpython","A_Id":32237684,"CreationDate":"2015-08-09T17:32:00.000","Title":"in qpython, how do I enter a \"return\" character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter)","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3088,"Q_Id":31906949,"Users Score":0,"Answer":"There is no way of doing it. \nThe console will automatically input a break line when the line of code ends so you can continue inputting in the screen without any scroll bars.\nFor complex code, you should use the editor.","Q_Score":2,"Tags":"qpython","A_Id":33434430,"CreationDate":"2015-08-09T17:32:00.000","Title":"in qpython, how do I enter a \"return\" character","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If there a data structures likes container\/queue, based on time , I could use it this way: add item(may duplicate) into it one by one, pop out those added time ealier then 60 minutes; count the queue; then I got top 10 most added items, in a dymatice period, said, 60min.\nHow to implement this time based container ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":347,"Q_Id":31907080,"Users Score":0,"Answer":"You can do something like this:\n\nStart timer 60 minutes\nGet the pages that people visits\nSave pages\nIf timer is not ended do step 2-3 again if timed is ended:\nCount wich one is the most visited\nCount wich one is the second most visited\nEtc","Q_Score":0,"Tags":"python,algorithm,data-structures,queue","A_Id":31908093,"CreationDate":"2015-08-09T17:43:00.000","Title":"python, data structures, algorithm: how to rank top 10 most visited pages in latest 60 minutes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some python code where gc.collect() seems to free a lot of memory. Given Python's reference counting nature, I am inclined to think that my program contains a lot of cyclical references. Since some data structures are rather big, I would like to introduce weak references. Now I need to find the circular references, having found a few of the obvious ones, I wonder if one can detect circular references and the objects that form the ring explicitly. So far I have only seen tutorials on how to call gc.collect et. al.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":909,"Q_Id":31914900,"Users Score":0,"Answer":"Unless you are overriding the __del__ methods, you should not worry about circular dependencies, as Python is able to properly cope with them.","Q_Score":8,"Tags":"python,garbage-collection","A_Id":35272896,"CreationDate":"2015-08-10T08:26:00.000","Title":"How to find out which specific circular references are present in code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can't open Spyder2 in Windows 10.0 (# 10240): the icon just appears briefly. Python 2.7.10 and Spyder 2.3.1 were loaded with Anaconda 2.3.0 (64-bit). The python console works fine - but I can't get my *.py or *.pyw files running. There is probably some message in the Python console when attemtping to open Spyder, but I don't know how to capture it.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1096,"Q_Id":31923606,"Users Score":1,"Answer":"First, one correction: the problem was with starting Spyder, not running .py or .pyw files. Anyway, things work all right now after de-installing Spyder and Python, and reinstalling the Python(x,y) package (instead of Anaconda's). Then, when starting Spyder from the Python(x,y)start window, it behaves normally.","Q_Score":0,"Tags":"python-2.7,windows-10,spyder","A_Id":32023483,"CreationDate":"2015-08-10T15:32:00.000","Title":"Can't run Spyder or .py(w) scripts with Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"System : SMEServer 8.1 (CentOS 5.10) 64bit, system python is 2.4.3\nThere is an alt python at \/usr\/local\/bin\/python2.7 (2.7.3) which was built some time ago.\nGoal : build python2.7.10, mod_wsgi, django. First step is python 2.7.10 to replace the (older and broken) 2.7.3\nWhat happens:\nWhen i build the latest 2.7 python as shared, the wrong executable is built.  \ncd \/tmp && rm -vrf Python-2.7.10 && tar -xzvf Python-2.7.10.tgz && cd Python-2.7.10 && .\/configure && make && .\/python -V\n2.7.10 <- as expected\n... but this wont work with mod_wsgi - we have to --enable-shared.\ncd \/tmp && rm -vrf Python-2.7.10 && tar -xzvf Python-2.7.10.tgz && cd Python-2.7.10 && .\/configure --enable-shared && make && .\/python -V\n2.7.3 <- Wrong version!\nI'm deleting the entire build directory each time to isolate things and ensure I'm not polluting the folder with each attempt. Somehow the (years old) install of 2.7.3 is being 'found' by configure but only when '--enable-shared' is on.\ncd \/tmp && rm -vrf Python-2.7.10 && tar -xzvf Python-2.7.10.tgz && cd Python-2.7.10 && .\/configure --prefix=\/usr\/local\/ && make && .\/python -V\n2.7.10\ncd \/tmp && rm -vrf Python-2.7.10 && tar -xzvf Python-2.7.10.tgz && cd Python-2.7.10 && .\/configure --enable-shared --prefix=\/usr\/local\/ && make && .\/python -V\n2.7.3 <- ???\nWhere do I look to find how make is finding old versions?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":364,"Q_Id":31931087,"Users Score":1,"Answer":"I'll document this here as the fix, also to hopefully get a comment from Graham as to why this might be needed;\nChanging\nmake\nto\nLD_RUN_PATH=\/usr\/local\/lib make \nwas the answer, but i had to use this for building both python2.7.10 and mod_wsgi. Without using LD_RUN_PATH on mod_wsgi I still got the dreaded;\n\n[warn] mod_wsgi: Compiled for Python\/2.7.10.\n[warn] mod_wsgi: Runtime using Python\/2.7.3.","Q_Score":2,"Tags":"linux,python-2.7,build,compilation,mod-wsgi","A_Id":31931647,"CreationDate":"2015-08-11T00:04:00.000","Title":"\"make\" builds wrong python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So in my django application, i'm running a task that will request from an api some data in the form of json. \nin order for me to get this data, i need to give the IP address of where the requests are going to come from (my heroku app)\nhow do i get the ip address in which my heroku application will request at","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":40929,"Q_Id":31932218,"Users Score":3,"Answer":"To my knowledge you can not get an ip for a heroku application. You could create a proxy with a known ip that serves as a middleman for the application. Otherwise you might want to look at whether heroku is still the correct solution for you","Q_Score":18,"Tags":"python,django,heroku","A_Id":31932292,"CreationDate":"2015-08-11T02:25:00.000","Title":"what is the IP address of my heroku application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've created a n new directory, a virtualenv and installed a django-toolbelt inside it. The django-version should be 1.8 but when I call 'django-admin.py version' it says 1.6. So when I start a new project it creates a 1.6. I thought virtualenv was supposed to prevent this. What am I doing wrong?\nEdit: I think it has to do with the PATH (?). Like it's calling the wrong django-admin version. I'm on Windows 7. Still don't know how to fix it.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1969,"Q_Id":31939714,"Users Score":0,"Answer":"I had the same problem. Could be related to your zsh\/bash settings.\nI realized that using zsh (my default) I would get django-admin version 1.11 despite the Django version was 2.1! When I tried the same thing with bash I would get django-admin version 2.1 (the correct version). Certainly a misconfiguration.\nSo, I strongly suggest you check your zsh or bash settings to check for paths you might have.","Q_Score":1,"Tags":"python,django,django-admin,virtualenv","A_Id":56271468,"CreationDate":"2015-08-11T10:48:00.000","Title":"Django-admin creates wrong django version inside virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've created a n new directory, a virtualenv and installed a django-toolbelt inside it. The django-version should be 1.8 but when I call 'django-admin.py version' it says 1.6. So when I start a new project it creates a 1.6. I thought virtualenv was supposed to prevent this. What am I doing wrong?\nEdit: I think it has to do with the PATH (?). Like it's calling the wrong django-admin version. I'm on Windows 7. Still don't know how to fix it.","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":1969,"Q_Id":31939714,"Users Score":3,"Answer":"I came across this problem too. In the official document, I found that, in a virtual environment, if you use the command 'django-admin', it would search from PATH usually in '\/usr\/local\/bin'(Linux) to find 'django-admin.py' which is a symlink to another version of django. This is the reason of what happened finally.  \nSo there are two methods to solve this problem:  \n\nre-symlink your current version django-admin(site-packages\/django\/bin\/django-admin.py) to 'usr\/local\/bin\/django-admin' or 'usr\/local\/bin\/django-admin.py'\nREMIND: This is a kind of global way so that it will effects your other django projects, so I recommend the second method  \ncd to your_virtual_env\/lib\/python3.x\/site-packages\/django\/bin\/(of course you should activate your virtual environment), and then use 'python  django-admin.py startproject project_name project_full_path' to create django project","Q_Score":1,"Tags":"python,django,django-admin,virtualenv","A_Id":47748881,"CreationDate":"2015-08-11T10:48:00.000","Title":"Django-admin creates wrong django version inside virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used ckanext-qa but its seems its not as per my requirement I am looking for extension by which Logged in user can be able to rate form 1 to 5 for each dataset over ckan.\nAnybody have an idea how to do like that","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":261,"Q_Id":31942911,"Users Score":1,"Answer":"I'm not aware of any extensions that do this.\nYou could write one to add this info in a dataset extra field. You may wish to store it as JSON and record the ratings given by each user.\nAlternatively you could try the rating_create API function - this is old functionality which has no UI, but it may just do what you want.","Q_Score":0,"Tags":"python,ckan","A_Id":32591030,"CreationDate":"2015-08-11T13:18:00.000","Title":"How to show star rating on ckan for datasets","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is really silly, but it's driving me nuts! \nNormally when I run ipython notebook through pycharm, the first time I click on the 'play' button to run a cell, PyCharm asks me if I want to start the kernel. When I say yes, it gives me a nice kernel window that shows me output from commands and errors. \nI really like this feature for debugging, but somehow it went away. PyCharm no longer asks if I would like to start the kernel, and I no longer can find the kernel window. My notebook is still running just fine, so the ipython kernel must be started somewhere. \nCan someone please tell me how to view the kernel window? \nThanks so much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":32015987,"Users Score":0,"Answer":"I spoke to JetBrains support. This is a known issue with Python 2.7.9 via Anaconda (maybe just with Anaconda in general, they did not specify). They said it will be fixed with the next release, which should be coming out in the next few days.","Q_Score":0,"Tags":"python,pycharm,ipython-notebook","A_Id":32101098,"CreationDate":"2015-08-14T17:52:00.000","Title":"PyCharm: lost ipython kernel window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on a python module that is a convenience wrapper for a c library. A python Simulation class is simply a ctypes structure with a few additional helper functions. Most parameters in Simulation can just be set using the _fields_ variable. I'm wondering how to document these properly. Should I just add it to the Simulation docstring? Or should I write getter\/setter methods just so I can document the variables?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":32027621,"Users Score":3,"Answer":"When I do similar things, if it is a small class I will put everything in the same class, but if it is bigger, I typically make a class that only contains the fields, and then a subclass of that with functions.  Then you can have a docstring for your fields class and a separate docstring for your simulation functions.\nYMMV, but I would never consider adding getters and setters for the sole purpose of making the documentation conform to some real or imaginary ideal.","Q_Score":1,"Tags":"python,documentation","A_Id":32031704,"CreationDate":"2015-08-15T17:57:00.000","Title":"Documenting ctypes fields","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There is one distance function I can pass to pdist use to create the distance matrix that is given to linkage. There is a second distance function that I can pass to linkage as the metric. \nWhy are there two possible distance functions? \nIf they are different, how are they used? For instance, does linkage use the distances in the distance matrix for its initial iterations, i.e. to see if any two original observations should be combined into a cluster, and then use the metric function for further combinations, i.e. of two clusters or of a cluster with an original observation?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":206,"Q_Id":32059711,"Users Score":0,"Answer":"The parameter 'method' is used to measure the similarities between clusters through the hierarchical clustering process. The parameter 'metric' is used to measure the distance between two objects in the dataset.\nThe 'metric' is closely related to the nature of the data (e.g., you could want to use 'euclidean' distance for objects with the same number of features, or Dynamic Time Warping for time series with different durations).\nThe thing is that there are two ways of using the linkage function. The first parameter is y, and it can be either the data itself or a distance matrix produced previously by a given measure.\nIf you choose to feed 'linkage' with a distance matrix, then you won't need the 'metric' parameter, because you have already calculated all the distance between all objects.","Q_Score":3,"Tags":"python,scipy,hierarchical-clustering","A_Id":70254029,"CreationDate":"2015-08-17T21:06:00.000","Title":"In scipy, what's the point of the two different distance functions used in hierarchical clustering?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to test if a float i.e(54.10) is divisible by 0.10.  54.10 % .10 returns .10 and not 0, why is that and how can I get it to do what I want it to do?","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":557,"Q_Id":32064356,"Users Score":5,"Answer":"The tried and true method here is to multiply your divisor and dividend by a power of 10. Effectively,  54.10 becomes 541 and 0.10 becomes 1. Then you can use standard modulo or ceiling and floor to achieve what you need.","Q_Score":1,"Tags":"python,decimal,division,modulus","A_Id":32065934,"CreationDate":"2015-08-18T05:41:00.000","Title":"how to test if a number is divisible by a decimal less than 1? (54.10 % .10)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a fpga board and I write a VHDL code that can get Images (in binary) from serial port and save them in a SDRAM on my board. then FPGA display images on a monitor via a VGA cable. my problem is filling the SDRAM take to long(about 10 minutes with 115200 baud rate).\non my computer I wrote a python code to send image(in binary) to FPGA via serial port. my code read binary file that saved in my hard disk and send them to FPGA.\nmy question is if I use buffer to save my images insted of binary file, do I get a better result? if so, can you help me how to do that, please? if not, can you suggest me a solution, please?\nthanks in advans,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":32100003,"Users Score":0,"Answer":"Unless you are significantly compressing before download, and decompressing the image after download, the problem is your 115,200 baud transfer rate, not the speed of reading from a file.\nAt the standard N\/8\/1 line encoding, each byte requires 10 bits to transfer, so you will be transferring 1150 bytes per second.\nIn 10 minutes, you will transfer 1150 * 60 * 10 = 6,912,000 bytes.  At 3 bytes per pixel (for R, G, and B), this is 2,304,600 pixels, which happens to be the number of pixels in a 1920 by 1200 image.\nThe answer is to (a) increase the baud rate; and\/or (b) compress your image (using something simple to decompress on the FPGA like RLE, if it is amenable to that sort of compression).","Q_Score":0,"Tags":"python-2.7","A_Id":32107551,"CreationDate":"2015-08-19T15:38:00.000","Title":"IS reading from buffer quicker than reading from a file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a simple neural network which uses the ReLU function. Can someone give me a clue of how can I implement the function using numpy.","AnswerCount":9,"Available Count":1,"Score":0.022218565,"is_accepted":false,"ViewCount":165706,"Q_Id":32109319,"Users Score":1,"Answer":"ReLU(x) also is equal to (x+abs(x))\/2","Q_Score":91,"Tags":"python,numpy,machine-learning,neural-network","A_Id":62125080,"CreationDate":"2015-08-20T03:58:00.000","Title":"How to implement the ReLU function in Numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have prepared a small program for retail shop, and have to print out receipt (using tvs msp star 240 dot matrix printer\/with paper roll) .\nwith wx.Printout() class for printing , as print preview is ok but actual printing is different and awkward :\n1. i m using paper roll n don't know how to call end printing\/OnEndPrinting()\/ cut paper  ?\n2. how to correct text shape or which font for actual printout ?\nI m new for programming .....\nPlease help and suggest appropriate code for this ...\nThanks in advance !!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1031,"Q_Id":32146943,"Users Score":0,"Answer":"Well i figure out some sort of solution :\nreceipt printing is impossible with wxPython , so, raw printing with escape sequences would be better option\nos.system(\"echo ' some text ' | lpr -o raw\" )\nfirst initialize printer\nos.system(\"echo ' \\x1B\\x40' | lpr -o raw\" )\nfor bold letters with ESC code :\nos.system(\"echo ' \\x1BE some text \\x1BF ' | lpr -o raw\" )\nfor double width :\nos.system(\"echo ' \\x1BW\\01 some text ' | lpr -o raw\" )\nfor underline\nos.system(\"echo ' \\x1B\\035 some text \\x1B\\034' | lpr -o raw\" )\nand many more options can be used with ESC code","Q_Score":0,"Tags":"python,printing,wxpython,receipt","A_Id":32464557,"CreationDate":"2015-08-21T18:19:00.000","Title":"Printout for receipt printer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to change some settings in Keil uVision project. I did not find how to disable\/enable project options through command line.\nSo I tried to do this by simple parsing .uvproj and .uvopt files with System.Xml in IronPython:\nimport clr\nclr.AddReference('System.Xml')\nxml_file = System.Xml.XmlDocument()\nxml_file.Load(PATH_TO_UVPROJ_FILE)\nxml_file.Save(PATH_TO_UVPROJ_FILE)\nThe problem is that I can't open parsed .uvproj file in uVision (get error \"Cannot read project file\").\nIf I copy all text from parsed .uvproj and past it to newly created file (New-Text Document in Windows Explorer -> rename extnsion to .uvproj -> past copied text -> save file) uVision opens it without error.\nWhy does this happen?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1224,"Q_Id":32172766,"Users Score":0,"Answer":"Could be problems with cr\/lf.\nHelpful would be a binary diff of the parsed and new created file. You could get more help if you post a few lines of a binary diff here.","Q_Score":0,"Tags":"c#,ironpython,keil","A_Id":32383582,"CreationDate":"2015-08-23T23:58:00.000","Title":"IronPython: Can't open Keil uVision .uvproj file edited with System.Xml","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am implementing a project using Django. It's a site where people can view different Art courses and register. I am having trouble implementing the app as reusable applications. I already have a standalone App which takes care of all the aspect of Arts. Now I want to create another application where an admin create various events for the Arts in the system. conceptually these two should be a standalone apps. Event scheduling is pretty general use case and I want to implement in a way where it can be used for scheduling any kind of Event. \nIn my case, those Events are Art related events. I don't want to put a foreign key to Art model in my Event model. how can I make it reusable so that it would work for scheduling Events related to any kind of objects.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":32188979,"Users Score":1,"Answer":"My sugestion is to create a third model, called ArtEvent and make this model points to Art and Event, this way you can create an especific app to manage events and then link everything. For example, when creating a new ArtEvent you redirects the user for the Event app, to enable him to create a new event. Then redirects again to the Art app with the created event, create a new ArtEvent and links those objects.\nIn future lets suppose that you want to add events to another model, like User, if you follow the same strategy you can separate what is UserEvent specific, and maintain what is common between ArtEvent and UserEvent.","Q_Score":0,"Tags":"python,django,django-apps","A_Id":32213209,"CreationDate":"2015-08-24T18:14:00.000","Title":"regarding Django philosphy of implementing project as reusable applications","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have uninstalled Python 2.7 and installed Python 3. But, when I type Python on my command prompt I get this :\n\"Enthought Canopy Python 2.7.9 .........\"\nHow can I run Python 3 from command line or how can I make it default on my computer? I asked Enthought Canopy help and I was told that I can \"have Canopy be your default Python only in a \"Canopy Command Prompt\". Not sure what it means.\nedit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4199,"Q_Id":32209554,"Users Score":0,"Answer":"After editing each path and creating a new variable for each python version, be sure to rename the python.exe to a unique one. i.e. \"python3x\" . then you can call it in the command line as \"python3x\". I am assuming that the original python installed (2X) retains the python.exe of which when you call \"python\" in the command line, it will show the 2x version","Q_Score":0,"Tags":"python,python-2.7,python-3.x,command-prompt,enthought","A_Id":43220221,"CreationDate":"2015-08-25T16:41:00.000","Title":"How to make Python 3 my default Python at command prompt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have uninstalled Python 2.7 and installed Python 3. But, when I type Python on my command prompt I get this :\n\"Enthought Canopy Python 2.7.9 .........\"\nHow can I run Python 3 from command line or how can I make it default on my computer? I asked Enthought Canopy help and I was told that I can \"have Canopy be your default Python only in a \"Canopy Command Prompt\". Not sure what it means.\nedit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4199,"Q_Id":32209554,"Users Score":0,"Answer":"You can copy python.exe to python3.exe. \nIf you are using Anaconda, then you will find it in the sub directory of your environment, for intance, c:\\Anaconda\\envs\\myenvironment.","Q_Score":0,"Tags":"python,python-2.7,python-3.x,command-prompt,enthought","A_Id":61764881,"CreationDate":"2015-08-25T16:41:00.000","Title":"How to make Python 3 my default Python at command prompt?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let say I'm creating an issue in Jira and write the summary and the description. Is it possible to call a python script after these are written that sets the value for another field, depending on the values of the summary and the description?\nI know how to create an issue and change fields from a python script using the jira-python module. But I have not find a solution for using a python script while editing\/creating the issue manually in Jira. Does anyone have an idea of how I manage that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1311,"Q_Id":32230294,"Users Score":1,"Answer":"Take a look at JIRA webhooks calling a small python based web server?","Q_Score":1,"Tags":"python,jira","A_Id":32234002,"CreationDate":"2015-08-26T15:07:00.000","Title":"Call python script from Jira while creating an issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running a Python Tornado server with a WebSocket handler.\nWe've noticed that if we abruptly disconnect the a client (disconnect a cable for example) the server has no indication the connection was broken. No on_close event is raised.\nIs there a workaround? \nI've read there's an option to send a ping, but didn't see anyone use it in the examples online and not sure how to use it and if it will address this issue.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1215,"Q_Id":32245227,"Users Score":0,"Answer":"The on_close event can only be triggered when the connection is closed.\nYou can send a ping and wait for an on_pong event.\nTimouts are typically hard to detect since you won't even get a message that the socket is closed.","Q_Score":0,"Tags":"python,websocket,tornado","A_Id":32245768,"CreationDate":"2015-08-27T09:13:00.000","Title":"Tornado websocket pings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to print Barcode on my Zebra Desktop label printer on CentOS 6.5 but I did not find any python drivers for that and did not found script so that i can use in my project.\nDoes anyone know how to print Barcode in Zebra printer?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":281,"Q_Id":32268889,"Users Score":2,"Answer":"If you are printing to a network printer open a TCP connection to port 9100. If you are printing to a USB printer look up a USB library for python.\nOnce you have a connection send a print string formatted in ZPL. Look on the Zebra site for the ZPL manual. There are examples in there on how to print a barcode.\nNormal Linux drivers will print graphics and text but do not have a barcode font.","Q_Score":1,"Tags":"python-2.7,centos6,zebra-printers,barcode-printing","A_Id":32270859,"CreationDate":"2015-08-28T10:28:00.000","Title":"How to print barcode in Centos 6 using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a JSP page called X.JSP (contains few radio button and submit button), when i hit the submit button in X.JSP, the next page is displayed Y.JSP?xxxx=1111&yyyy=2222&zzzz=3333\n\nhow to know what page or service or ajax call is being made when i hit the submit button in X.JSP page.\nxxxx=1111&yyyy=2222&zzzz=3333 these are generated after i click the submit button in X.JSP\n\nCurrently i am using python to script.\ni select a radio button and post the form. i am not able to get the desired O\/P.\nhow do I what page or service or ajax call is being made when i hit the submit button in X.JSP page, so that i can directly hit that page\nor is there any better way to solve this","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":32278459,"Users Score":0,"Answer":"The developers console ( F12 in Chrome and Firefox) is a wonderful thing. \nCheck the Network or Net tab. There you can see all the requests between your browser and your server.","Q_Score":1,"Tags":"javascript,python,ajax,jsp,jsp-tags","A_Id":32278473,"CreationDate":"2015-08-28T19:24:00.000","Title":"how to know what page or call is being when in a JSP page when submited","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows?\nThanks","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":91741,"Q_Id":32284938,"Users Score":7,"Answer":"3 steps to install wx-widgets and pygame in python IDLE\n\nInstall python 3xxx in your system opting (Add 3xxx to your path).\nopen python CLI to see whether python is working or not.\nthen open command prompt (CMD).\n\n\ntype PIP to see whether pip is installed or not.\n\nenter command : pip install wheel\nenter command : pip install pygame \nTo install wxpython \nenter command : pip install -U wxPython\n\nThats all !!","Q_Score":20,"Tags":"python,windows,download,wxpython","A_Id":48046623,"CreationDate":"2015-08-29T10:15:00.000","Title":"How to properly install wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows?\nThanks","AnswerCount":10,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":91741,"Q_Id":32284938,"Users Score":0,"Answer":"Check the version of wxpython and the version of python you have in your machine.\nFor python 2.7 use wxPython3.0-win32-3.0.2.0-py27 package","Q_Score":20,"Tags":"python,windows,download,wxpython","A_Id":54313732,"CreationDate":"2015-08-29T10:15:00.000","Title":"How to properly install wxPython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I don't know how many duplicates of this are out there but none of those I looked at solved my problem.\nTo practice writing and installing custom modules I've written a simple factorial module. I have made a factorial folder in my site-packages folder containing factorial.py and an empty __init__.py file.\nBut typing import factorial does not work. How can I solve this? I also tried pip install factorial but that didn't work either. \nDo I have to save my code intended to use factorial in the same folder inside site-packages or can I save it whereever I want?\nGreetings\nholofox\nEDIT: I solved it. Everything was correct as I did it. Had some problems at importing and using it properly in my code...","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":512,"Q_Id":32285041,"Users Score":0,"Answer":"I think there are several different things to take into consideration here.\nWhen you're importing a module, (doing import factorial), Python will look in the defined PATH and try to find the module you're trying to import. In the simplest case, if your module is in the same folder where your script is trying to import it, it will find it. If it's somewhere else, you will have to specify the path.\nNow, site-packages is where Python keep the installed libraries. So for example when you do pip install x, Python will put the module x in your site-packages destination and when you try to import it, it will look for it there. In order to manage site-packages better, try to read about virtualenv.\nIf you want your module to go there, first you need to create a package that you can install. For that look at distutils or all the different alternatives for packaging that involve some type of building process based on a setup file. \nI don't want to go into details in any of these points because all of them have been covered before. Just wanted to give you a general idea of where to look for.","Q_Score":1,"Tags":"python,macos,module,installation","A_Id":32285525,"CreationDate":"2015-08-29T10:32:00.000","Title":"Install a custom Python 2.7.10 module on Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My original purpose was to bulk insert into my db\nI tried pyodbc, sqlalchemy and ceodbc to do this with executemany function but my dba checked and they execute each row individually.\nhis solution was to run procedure that recieve table (user defined data type) as parameter and load it into the real table.\nThe problem is no library seem to support that (or at least no example on the internet).\nSo my question is anyone try bulk insert before or know how to pass user data defined type to stored procedure?\nEDIT\nI also tried bulk insert query but the problem it requires local path or share and it will not happend because organizition limits","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":826,"Q_Id":32297244,"Users Score":0,"Answer":"Sqlalchemy bulk operations doesn't really inserts a bulk. It's written in the docs.\nAnd we've checked it  with our dba.\nThank you we'll try the xml.","Q_Score":2,"Tags":"sql-server,python-2.7,sqlalchemy,pyodbc,pymssql","A_Id":32305711,"CreationDate":"2015-08-30T13:51:00.000","Title":"Python mssql passing procedure user defined data type as parameter","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know there are various ETL tools available to export data from oracle to MongoDB but i wish to use python as intermediate to perform this. Please can anyone guide me how to proceed with this?\nRequirement:\nInitially i want to add all the records from oracle to mongoDB and after that I want to insert only newly inserted records from Oracle into MongoDB.\nAppreciate any kind of help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":889,"Q_Id":32305131,"Users Score":0,"Answer":"To answer your question directly:\n 1. Connect to Oracle\n 2. Fetch all the delta data by timestamp or id (first time is all records)\n 3. Transform the data to json\n 4. Write the json to mongo with pymongo\n 5. Save the maximum timestamp \/ id for next iteration\nKeep in mind that you should think about the data model considerations and usually relational DB (like Oracle) and document DB (like mongo) will have different data model.","Q_Score":1,"Tags":"python,oracle,mongodb","A_Id":32305243,"CreationDate":"2015-08-31T06:29:00.000","Title":"Export from Oracle to MongoDB using python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We are migrating some data from our production database and would like to archive most of this data in the Cloud Datastore.\nEventually we would move all our data there, however initially focusing on the archived data as a test.\nOur language of choice is Python, and have been able to transfer data from mysql to the datastore row by row.  \nWe have approximately 120 million rows to transfer and at a one row at a time method will take a very long time.\nHas anyone found some documentation or examples on how to bulk insert data into cloud datastore using python?\nAny comments, suggestions is appreciated thank you in advanced.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3726,"Q_Id":32316088,"Users Score":7,"Answer":"There is no \"bulk-loading\" feature for Cloud Datastore that I know of today, so if you're expecting something like \"upload a file with all your data and it'll appear in Datastore\", I don't think you'll find anything.\nYou could always write a quick script using a local queue that parallelizes the work.\nThe basic gist would be:\n\nQueuing script pulls data out of your MySQL instance and puts it on a queue.\n(Many) Workers pull from this queue, and try to write the item to Datastore.\nOn failure, push the item back on the queue.\n\nDatastore is massively parallelizable, so if you can write a script that will send off thousands of writes per second, it should work just fine. Further, your big bottleneck here will be network IO (after you send a request, you have to wait a bit to get a response), so lots of threads should get a pretty good overall write rate. However, it'll be up to you to make sure you split the work up appropriately among those threads.\n\nNow, that said, you should investigate whether Cloud Datastore is the right fit for your data and durability\/availability needs. If you're taking 120m rows and loading it into Cloud Datastore for key-value style querying (aka, you have a key and an unindexed value property which is just JSON data), then this might make sense, but loading your data will cost you ~$70 in this case (120m * $0.06\/100k).\nIf you have properties (which will be indexed by default), this cost goes up substantially.\nThe cost of operations is $0.06 per 100k, but a single \"write\" may contain several \"operations\". For example, let's assume you have 120m rows in a table that has 5 columns (which equates to one Kind with 5 properties).\nA single \"new entity write\" is equivalent to:\n\n+ 2 (1 x 2 write ops fixed cost per new entity)\n+ 10 (5 x 2 write ops per indexed property)\n= 12 \"operations\" per entity.\n\nSo your actual cost to load this data is:\n120m entities * 12 ops\/entity * ($0.06\/100k ops) = $864.00","Q_Score":6,"Tags":"python,mysql,google-cloud-datastore","A_Id":33367328,"CreationDate":"2015-08-31T16:47:00.000","Title":"Is it possible to Bulk Insert using Google Cloud Datastore","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing a mini-project on Web-Crawler+Search-Engine. I already know how to scrape data using Scrapy framework. Now I want to do indexing. For that I figured out Python dictionary is the best option for me. I want mapping to be like name\/title of an object (a string) -> the object itself (a Python object).\nNow the problem is that I don't know how to store dynamic dict in MySQL database and I definitely want to store this dict as it is!\nSome commands on how to go about doing that would be very much appreciated!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":339,"Q_Id":32325390,"Users Score":1,"Answer":"If you want to store dynamic data in a database, here are a few options.  It really depends on what you need out of this.\nFirst, you could go with a NoSQL solution, like MongoDB.  NoSQL allows you to store unstructured data in a database without an explicit data schema.  It's a pretty big topic, with far better guides\/information than I could provide you.  NoSQL may not be suited to the rest of your project, though.\nSecond, if possible, you could switch to PostgreSQL, and use it's HSTORE column (unavailable in MySQL).  The HSTORE column is designed to store a bunch of Key\/Value pairs.  This column types supports BTREE, GIST, GIN, and HASH indexing.  You're going to need to ensure you're familiar with PostgreSQL, and how it differs from MySQL.  Some of your other SQL may no longer work as you'd expect.\nThird, you can serialize the data, then store the serialized entity.  Both json and pickle come to mind.  The viability and reliability of this will of course depend on how complicated your dictionaries are.  Serializing data, especially with pickle can be dangerous, so ensure you're familiar with how it works from a security perspective.  \nFourth, use an \"Entity-Attribute-Value\" table.  This mimics a dictionaries \"Key\/Value\" pairing.  You, essentially, create a new table with three columns of \"Related_Object_ID\", \"Attribute\", \"Value\".  You lose a lot of object metadata you'd normally get in a table, and SQL queries can become much more complicated. \nAny of these options can be a double edged sword.  Make sure you've read up on the downfalls of whatever option you want to go with, or, in looking into the options more, perhaps you'll find something that better suits you and your project.","Q_Score":1,"Tags":"python,mysql,dictionary,scrapy","A_Id":32334348,"CreationDate":"2015-09-01T06:58:00.000","Title":"How to store a dynamic python dictionary in MySQL database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new here and also a new Python learner. I was trying to install twilio package through the Windows command line interface, but I got a syntax error(please see below). I know there're related posts, however, I was still unable to make it work after trying those solutions. Perhaps I need to set the path in the command line, but I really have no idea how to do that...(I can see the easy_install and pip files in the Scripts folder under Python) Can anyone please help? Thanks in advance!\n\nMicrosoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation.\n  All rights reserved.\nC:\\WINDOWS\\system32>python Python 2.7.10 (default, May 23 2015,\n  09:44:00) [MSC v.1500 64 bit (AMD64)] on wi n32 Type \"help\",\n  \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\neasy_install twilio   File \"\", line 1\n            easy_install twilio\n                              ^ SyntaxError: invalid syntax","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":3665,"Q_Id":32343072,"Users Score":1,"Answer":"go to the command prompt \nit will say the account and all that jazz.\ntype cd .. \nthen hit enter\nit will say C:\\Users>\ntype cd .. again\nthen it will say C:>\ntype cd python27 (or the name of your python folder)\nit will say C:\\Python27>\ntype cd scripts\nit will say C:\\python27\/scripts>\ntype easy_install twilio\nthen wait for it to run the procceses and then you will have twilio installed to python.","Q_Score":2,"Tags":"python-2.7","A_Id":40198608,"CreationDate":"2015-09-02T00:53:00.000","Title":"getting \"SyntaxError\" when installing twilio in the Windows command line interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm new here and also a new Python learner. I was trying to install twilio package through the Windows command line interface, but I got a syntax error(please see below). I know there're related posts, however, I was still unable to make it work after trying those solutions. Perhaps I need to set the path in the command line, but I really have no idea how to do that...(I can see the easy_install and pip files in the Scripts folder under Python) Can anyone please help? Thanks in advance!\n\nMicrosoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation.\n  All rights reserved.\nC:\\WINDOWS\\system32>python Python 2.7.10 (default, May 23 2015,\n  09:44:00) [MSC v.1500 64 bit (AMD64)] on wi n32 Type \"help\",\n  \"copyright\", \"credits\" or \"license\" for more information.\n\n\n\neasy_install twilio   File \"\", line 1\n            easy_install twilio\n                              ^ SyntaxError: invalid syntax","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3665,"Q_Id":32343072,"Users Score":3,"Answer":"You should not type python first, then it becomes python command line.\nOpen a new command prompt and directly type: \neasy_install twilio","Q_Score":2,"Tags":"python-2.7","A_Id":40895682,"CreationDate":"2015-09-02T00:53:00.000","Title":"getting \"SyntaxError\" when installing twilio in the Windows command line interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"When developing a Django project, many third party authentication packages are available, for example:\n\nDjango OAuth Toolkit, OAuth 2.0 support.\nDjoser, provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation.\n\nCurrently, I just want to support basic actions registration, login and so on. So Djoser could be my best choice.\nBut if I want to support OAuth 2.0 later, I will have two tokens, one is from Djoser, and another is from Django OAuth Toolkit. I just got confused here, how to handler two tokens at the same time? \nOr should I just replace Djoser with Django OAuth Toolkit, if so, how to support basic actions such as registration?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":308,"Q_Id":32343180,"Users Score":0,"Answer":"djoser supports only Basic Auth and the token auth by Django Rest Framework. What you can do is to make use of login and logout from Django OAuth Toolkit and then djoser views such as like register, password reset.","Q_Score":0,"Tags":"python,django,django-rest-framework,django-rest-auth","A_Id":34567070,"CreationDate":"2015-09-02T01:10:00.000","Title":"Multiple authentication app support","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When memory issues are critical, do I save some memory when I do my python imports inside a function, so as to when the call finishes everything will be discarder from memory? Or this cumbers more my memory and CPU especially when I do a lot of calls of the specific function? (The user does the calls and I do not know in advance how many she will do). What are the memory implications of this difference?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":618,"Q_Id":32353887,"Users Score":2,"Answer":"When you import a module, any\/all module objects\/functions\/etc are cached so that importing the same module again is a no-op. Subsequently these objects\/functions\/etc will not be freed when the local names referring to them go out of scope. This only affects functions and objects defined globally within the module and it's very likely that there won't be a lot of those, so it's probably not something to worry about.\nTo specifically answer your question, there is effectively no difference in terms of performance unless the import is inside a function or branch which is never executed. In that rare case, having it inside the branch or function is slightly faster\/less resource intensive, but it won't gain you much.","Q_Score":0,"Tags":"python,python-2.7,python-import","A_Id":32359039,"CreationDate":"2015-09-02T12:59:00.000","Title":"Python import statement inside and outside a function. What is better for the memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Markdown, how do you highlight code <--- just like that. I don't know how to search for it because I'm not sure what it's called. I also don't know what the little dashes are called either. I tried doing what I would do in SO, but it just reads it as normal text\n\nUpdate:\nThis is what I have:\n\nfoo in SO it actually shows the hilighting\n\n\nbar whereas in iPython Notebook, it doesn't, it only changes the fontstyle","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3161,"Q_Id":32365141,"Users Score":1,"Answer":"Late answer but backtick ` is the way to go, just like here at SO.","Q_Score":3,"Tags":"syntax,markdown,ipython-notebook","A_Id":40813583,"CreationDate":"2015-09-03T00:15:00.000","Title":"Markdown in iPython Notebook: how to highlight code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When running model.update(args, kwargs) in python, if the data is not different it doesn't actually make any changes, correct? If so, does it update the TTL? If not, how can we make it so it will reset the TTL? \nUse case:\nWe have a model that stores out loop information for twisted and we have a TTL of 10 seconds on it. The program is set to automatically check that configuration every 2 seconds and if it does not then we want that data to be removed out of the active loops. Here is where it gets tricky, the data rarely changes once it has been set for a particular loop. \nI can post the model and other information if it would helpful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":473,"Q_Id":32381227,"Users Score":1,"Answer":"When you do an insert or update in Cassandra, the new value overrides the old value even if it is the same value.  This is because Cassandra does not do a read of the existing data before storing the new data.  Every write is just an append operation and Cassandra has no idea if the new value is the same as the old value.\nWhen you do a read, Cassandra will find the most recent write and that is the current value.  So if your insert or update sets a TTL, then that TTL will override any previous TTL for the columns you inserted\/updated.\nSo if you are writing data with a TTL of 10 seconds, then you need to write the same data again before the 10 seconds is up if you want it to stick around for another 10 seconds.","Q_Score":1,"Tags":"python,cassandra,cassandra-2.0","A_Id":32381556,"CreationDate":"2015-09-03T16:42:00.000","Title":"Updating only TTL in cassandra","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Iam new to Django Framework and just started learning django 1.8. In other framework Like Laravel,Rails there we can  make  different controller file. for example UserController.php,ContactController.php etc.\nI think in Django, views.py is similar to Controller  and In django ,in views.py i have a long line of code of more than 300 lines and i want to make my code clean by making seperate views.py for userRegistration,Contact,ArticleControl etc. My question is how can i achieve this ie:making many views.py like controller","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":602,"Q_Id":32390195,"Users Score":4,"Answer":"Instead of multiple views.py, You can divide your application into individual applications within your project. Like separate applications for userRegistration, Contact, ArticleControl. this way your code will look much cleaner. And in case of any bug you will be able to debug that specific application easily.","Q_Score":1,"Tags":"python,django","A_Id":32390343,"CreationDate":"2015-09-04T04:40:00.000","Title":"Can we make many views.py in Django as a Controller?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior.\nI have, however, done something wrong as this now includes things like Django in projects that have no business with Django.\nHow do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","AnswerCount":10,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":48165,"Q_Id":32390291,"Users Score":22,"Answer":"I have tried both pipreqs and pigar and found pigar is better because it also generates information about where it is used, it also has more options.","Q_Score":67,"Tags":"python,pip","A_Id":53797785,"CreationDate":"2015-09-04T04:49:00.000","Title":"Pip freeze for only project requirements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior.\nI have, however, done something wrong as this now includes things like Django in projects that have no business with Django.\nHow do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","AnswerCount":10,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":48165,"Q_Id":32390291,"Users Score":0,"Answer":"I just had the same issue, here's what I've found to solve the problem.\nFirst create the venv in the directory of your project, then activate it.\nFor Linux\/MacOS : python3 -m venv .\/venv source myvenv\/bin\/activate\nFor Windows :  python3 -m venv .\\venv env\\Scripts\\activate.bat\nNow pip freeze > requirements.txt should only takes the library used in the project.\nNB: If you have already begin your project you will have to reinstall all the library to have them in pip freeze.","Q_Score":67,"Tags":"python,pip","A_Id":70058507,"CreationDate":"2015-09-04T04:49:00.000","Title":"Pip freeze for only project requirements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior.\nI have, however, done something wrong as this now includes things like Django in projects that have no business with Django.\nHow do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","AnswerCount":10,"Available Count":3,"Score":0.0199973338,"is_accepted":false,"ViewCount":48165,"Q_Id":32390291,"Users Score":1,"Answer":"if you are using linux then do it with sed\npip freeze | sed 's\/==.*$\/''\/' > requirements.txt","Q_Score":67,"Tags":"python,pip","A_Id":65285557,"CreationDate":"2015-09-04T04:49:00.000","Title":"Pip freeze for only project requirements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a socket connection that will stay alive so that in event of connection loss. So basically I want to keep the server always open (also the client preferably) and restart the client after the connection is lost. But if one end shuts down both ends shut down. I simulated this by having both ends on the same computer \"localhost\" and just clicking the X button. Could this be the source of my problems?\nAnyway my connection code\nm.connect((\"localhost\", 5000))\nis in a if and try and while e.g.\nwhile True:\n    if tryconnection:\n        #Error handeling\n        try:\n            m.connect((\"localhost\", 5000))\n            init = True\n            tryconnection = False\n        except socket.error:\n            init = False\n            tryconnection = True\nAnd at the end of my code I just a m.send(\"example\") when I press a button and if that returns an error the code of trying to connect to \"localhost\" starts again. And the server is a pretty generic server setup with a while loop around the x.accept(). So how do keep them both alive when the connection closes so they can reconnect when it opens again. Or is my code alright and its just by simulating on the same computer is messing with it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1309,"Q_Id":32397089,"Users Score":0,"Answer":"The issue is not related to the programming language, in this case python. The oeprating system (Windows or linux), has the final word regarding the resilience degree of the socket.","Q_Score":0,"Tags":"python,sockets,networking,connection","A_Id":32403092,"CreationDate":"2015-09-04T11:33:00.000","Title":"Keeping python sockets alive in event of connection loss","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to make a socket connection that will stay alive so that in event of connection loss. So basically I want to keep the server always open (also the client preferably) and restart the client after the connection is lost. But if one end shuts down both ends shut down. I simulated this by having both ends on the same computer \"localhost\" and just clicking the X button. Could this be the source of my problems?\nAnyway my connection code\nm.connect((\"localhost\", 5000))\nis in a if and try and while e.g.\nwhile True:\n    if tryconnection:\n        #Error handeling\n        try:\n            m.connect((\"localhost\", 5000))\n            init = True\n            tryconnection = False\n        except socket.error:\n            init = False\n            tryconnection = True\nAnd at the end of my code I just a m.send(\"example\") when I press a button and if that returns an error the code of trying to connect to \"localhost\" starts again. And the server is a pretty generic server setup with a while loop around the x.accept(). So how do keep them both alive when the connection closes so they can reconnect when it opens again. Or is my code alright and its just by simulating on the same computer is messing with it?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1309,"Q_Id":32397089,"Users Score":1,"Answer":"I'm assuming we're dealing with TCP here since you use the word \"connection\".\nIt all depend by what you mean by \"connection loss\".\nIf by connection loss you mean that the data exchanges between the server and the client may be suspended\/irresponsive (important: I did not say \"closed\" here) for a long among of time, seconds or minutes, then there's not much you can do about it and it's fine like that because the TCP protocol have been carefully designed to handle such situations gracefully. The timeout before deciding one or the other side is definitely down, give up, and close the connection is veeeery long (minutes). Example of such situation: the client is your smartphone, connected to some server on the web, and you enter a long tunnel.\nBut when you say: \"But if one end shuts down both ends shut down. I simulated this by having both ends on the same computer localhost and just clicking the X button\", what you are doing is actually closing the connections.\n\nIf you abruptly terminate the server: the TCP\/IP implementation of your operating system will know that there's not any more a process listening on port 5000, and will cleanly close all connections to that port. In doing so a few TCP segments exchange will occur with the client(s) side (it's a TCP 4-way tear down or a reset), and all clients will be disconected. It is important to understand that this is done at the TCP\/IP implementation level, that's to say your operating system.\nIf you abruptly terminate a client, accordingly, the TCP\/IP implementation of your operating system will cleanly close the connection from it's port Y to your server port 5000.\nIn both cases\/side, at the network level, that would be the same as if you explicitly (not abruptly) closed the connection in your code.\n\n...and once closed, there's no way you can possibly re-establish those connections as they were before. You have to establish new connections.\nIf you want to establish these new connections and get the application logic to the state it was before, now that's another topic. TCP alone can't help you here. You need a higher level protocol, maybe your own, to implement stateful client\/server application.","Q_Score":0,"Tags":"python,sockets,networking,connection","A_Id":32399470,"CreationDate":"2015-09-04T11:33:00.000","Title":"Keeping python sockets alive in event of connection loss","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I use eclipse to write python codes using pydev. So far I have been using dropbox to synchronize my workspace. \nHowever, this is far from ideal. I would like to use github (or another SCM platform) to upload my code so I can work with it from different places. \nHowever, I have found many tutorials kind of daunting... Maybe because they are ready for projects shared between many programers\nWould anyone please share with me their experience on how to do this? Or any basic tutorial to do this effectively?\nThanks","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":32406765,"Users Score":0,"Answer":"I use mercurial. I picked it because it seemed easier. But is is only easiER.\nThere is mercurial eclipse plugin.\nSave a copy of your workspace and maybe your eclipse folder too before daring it :)","Q_Score":0,"Tags":"python,eclipse,version-control,synchronization,pydev","A_Id":32408606,"CreationDate":"2015-09-04T21:21:00.000","Title":"Using SCM to synchronize PyDev eclipse projects between different computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I use eclipse to write python codes using pydev. So far I have been using dropbox to synchronize my workspace. \nHowever, this is far from ideal. I would like to use github (or another SCM platform) to upload my code so I can work with it from different places. \nHowever, I have found many tutorials kind of daunting... Maybe because they are ready for projects shared between many programers\nWould anyone please share with me their experience on how to do this? Or any basic tutorial to do this effectively?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":86,"Q_Id":32406765,"Users Score":0,"Answer":"I use bitbucket coupled with mercurial. That is my repository is on bitbucket and i pull and psuh to it from mercurial within eclipse\nFor my backup i have an independent carbonite process going to net back all hard disk files. But I imagine there is a clever free programatic way to do so. If one knew how to write the appropriate scripts.\nGlad the first suggestion was helpful .you are wise to bite the bullet and get this in place now. ;)","Q_Score":0,"Tags":"python,eclipse,version-control,synchronization,pydev","A_Id":32466408,"CreationDate":"2015-09-04T21:21:00.000","Title":"Using SCM to synchronize PyDev eclipse projects between different computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"When I install OpenCV 3.0 with Homebrew, it gives me the following directions to link it to Python 2.7:\n\nIf you need Python to find bindings for this keg-only formula, run:\n  echo \/usr\/local\/opt\/opencv3\/lib\/python2.7\/site-packages >>\n  \/usr\/local\/lib\/python2.7\/site-packages\/opencv3.pth\n\nWhile I can find the python2.7 site packages in opencv3, no python34 site packages were generated. Does anyone know how I can link my OpenCV 3.0 install to Python 3?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":7461,"Q_Id":32420853,"Users Score":7,"Answer":"It's weird that there is no concise instruction for installing OpenCV 3 with Python3. So, here I make it clear step-by-step:\n\nInstall Homebrew Python 3.5: brew install python3\nTap homebrew\/science: brew tap homebrew\/science\nInstall any Python3 packages using pip3. This will create the site-packages folder for Python3 \nFor example:\npip3 install numpy\nThen install OpenCV3 brew install opencv3 --with-python3\nNow you can find the site-packages folder created in Step 2. Just run the following command to link Opencv3 to Python3:\necho \/usr\/local\/opt\/opencv3\/lib\/python3.5\/site-packages >> \/usr\/local\/lib\/python3.5\/site-packages\/opencv3.pth\n\nYou may have to change the above command correpondingly to your installed Homebrew Python version (e.g. 3.4).","Q_Score":4,"Tags":"python,macos,opencv,homebrew,opencv3.0","A_Id":37454424,"CreationDate":"2015-09-06T06:50:00.000","Title":"Homebrew installation of OpenCV 3.0 not linking to Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I install OpenCV 3.0 with Homebrew, it gives me the following directions to link it to Python 2.7:\n\nIf you need Python to find bindings for this keg-only formula, run:\n  echo \/usr\/local\/opt\/opencv3\/lib\/python2.7\/site-packages >>\n  \/usr\/local\/lib\/python2.7\/site-packages\/opencv3.pth\n\nWhile I can find the python2.7 site packages in opencv3, no python34 site packages were generated. Does anyone know how I can link my OpenCV 3.0 install to Python 3?","AnswerCount":2,"Available Count":2,"Score":0.3799489623,"is_accepted":false,"ViewCount":7461,"Q_Id":32420853,"Users Score":4,"Answer":"You need to install opencv like brew install opencv3 --with-python3. You can see a list of options for a package by running brew info opencv3.","Q_Score":4,"Tags":"python,macos,opencv,homebrew,opencv3.0","A_Id":32510430,"CreationDate":"2015-09-06T06:50:00.000","Title":"Homebrew installation of OpenCV 3.0 not linking to Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I implemented my first aiohttp based RESTlike service, which works quite fine as a toy example. Now I want to run it using gunicorn. All examples I found, specify some prepared application in some module, which is then hosted by gunicorn. This requires me to setup the application at import time, which I don't like. I would like to specify some config file (development.ini, production.ini) as I'm used from Pyramid and setup the application based on that ini file.\nThis is common to more or less all python web frameworks, but I don't get how to do it with aiohttp + gunicorn. What is the smartest way to switch between development and production settings using those tools?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":273,"Q_Id":32423519,"Users Score":1,"Answer":"At least for now aiohttp is a library without reading configuration from .ini or .yaml file.\nBut you can write code for reading config and setting up aiohttp server by hands easy.","Q_Score":1,"Tags":"python-3.x,gunicorn,aiohttp","A_Id":32440342,"CreationDate":"2015-09-06T12:23:00.000","Title":"Configuring an aiohttp app hosted by gunicorn","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"we have two client machines, how do we connect both of them using proxy server? As you said earlier:\n\"To start a RethinkDB proxy on the client:\nrethinkdb proxy -j -j ...\"\nonly of the clients can connect in this way, since the ports will already be in use.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":282,"Q_Id":32428052,"Users Score":1,"Answer":"As mentioned elsewhere, you can avoid the port conflict by passing in the -o 1 argument. This shifts the ports that the proxy uses by an offset of 1.","Q_Score":1,"Tags":"rethinkdb,rethinkdb-python,rethinkdb-javascript","A_Id":32465192,"CreationDate":"2015-09-06T20:35:00.000","Title":"How to setup rethinkdb proxy server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have something like 1500 mail messages in eml format and I want to parse them na get e-mail addresses that caused error and error message (or code).\nI would like to try to do it in python.\nSomeone have any idea how to do that except parsing line by line and searching for line and error code (or know software to do that)?\nI see nothing about errors in mail headers which is sad.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":165,"Q_Id":32438646,"Users Score":0,"Answer":"So you have 1500 .eml files and want to identify mails from mailer-daemons and which adress caused the mailer-daemon message?\nJust iterate over the files, then check the from: line and see if it is a mailer-daemon message, and then get the adress that caused the error out of the text.\nThere is no other way than iterating over them line by line.","Q_Score":0,"Tags":"python,email,parsing","A_Id":32442153,"CreationDate":"2015-09-07T12:20:00.000","Title":"Parse mailer daemons, failure notices","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is it possible to comment out whole cells in jupyter?\nI need it for this case:\nI have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them)\nThanks","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":42040,"Q_Id":32444840,"Users Score":2,"Answer":"You can switch the cell from 'Code to 'Raw NBConvert'","Q_Score":34,"Tags":"ipython,jupyter","A_Id":65136451,"CreationDate":"2015-09-07T19:16:00.000","Title":"jupyter - how to comment out cells?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to comment out whole cells in jupyter?\nI need it for this case:\nI have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them)\nThanks","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":42040,"Q_Id":32444840,"Users Score":39,"Answer":"Mark the content of the cell and press Ctrl+ \/. It will comment out all lines in that cell. Repeat the same steps to uncomment the lines of your cell.","Q_Score":34,"Tags":"ipython,jupyter","A_Id":52076374,"CreationDate":"2015-09-07T19:16:00.000","Title":"jupyter - how to comment out cells?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to comment out whole cells in jupyter?\nI need it for this case:\nI have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them)\nThanks","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":42040,"Q_Id":32444840,"Users Score":16,"Answer":"If you switch the cell to 'raw NBConvert' the code retains its formatting, while all text remains in a single font (important if you have any commented sections), so it remains readable. 'Markdown' will interpret the commented sections as headers and change the size and colour accordingly, making the cell rather messy.\nOn a side note I use this to interrupt the process if I want to stop it - it seems much more effective than 'Kernel --> Interrupt'.","Q_Score":34,"Tags":"ipython,jupyter","A_Id":38432841,"CreationDate":"2015-09-07T19:16:00.000","Title":"jupyter - how to comment out cells?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to comment out whole cells in jupyter?\nI need it for this case:\nI have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them)\nThanks","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":42040,"Q_Id":32444840,"Users Score":23,"Answer":"I think the easiest thing will be to change the cell type to 'Markdown' with M when you don't want to run it and change back to 'Code' with Y when you do.  In a short test I did, I did not lose my formatting when switching back and forth.\nI don't think you can select multiple cells at once.","Q_Score":34,"Tags":"ipython,jupyter","A_Id":32458871,"CreationDate":"2015-09-07T19:16:00.000","Title":"jupyter - how to comment out cells?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"if I start ipython in a terminal, when I type 'im' and press TAB, the terminal will auto-complete it with 'import', but when I click python console button in the bottom of pycharm IDE, when the ipython environment shows, type 'im', press TAB, it will not give autocompletion.\nIn PyCharm, it use pydevconsole.py to create the ipython environment, but I do not know how to change it to enable the autocompletion.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5218,"Q_Id":32458158,"Users Score":1,"Answer":"ctrl+space confuse with input language switching of Windows. need change setting of Keymap\nFile -> Setting -> Keymap ->\u3000Main menu -> Code -> Complete -> Basic","Q_Score":5,"Tags":"autocomplete,ipython,pycharm","A_Id":51340397,"CreationDate":"2015-09-08T12:42:00.000","Title":"pycharm python console autocompletion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I have a process where I push a button, and after a certain amount of time (from 1 to 30 minutes), an event occurs.  I then run a very large number of trials, and record how long it takes the event to occur for each trial.  This raw data is then reduced to a set of 30 data points where the x value is the number of minutes it took for the event to occur, and the y value is the percentage of trials which fell into that bucket.  I do not have access to the original data.\nHow can I use this set of 30 points to identify an appropriate probability distribution which I can then use to generate representative random samples?\nI feel like scipy.stats has all the tools I need built in, but for the life of me I can't figure out how to go about it. Any tips?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2122,"Q_Id":32488808,"Users Score":1,"Answer":"You can also use the histogram, piecewise uniform distribution directly, then you get exactly the corresponding random numbers instead of an approximation. \nThe inverse cdf, ppf, is piecewise linear and linear interpolation can be used to transform uniform random numbers appropriately.","Q_Score":3,"Tags":"python,statistics,scipy","A_Id":32510602,"CreationDate":"2015-09-09T20:41:00.000","Title":"Use Histogram data to generate random samples in scipy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a CSV file where the date is formatted as yy\/mm\/dd, but Excel is reading it wrongly as dd\/mm\/yyyy (e.g. 8th September 2015 is read as 15th of September 2008).  \nI know how to change the format that Excel outputs, but how can I change the format it uses to interpret the CSV data?  \nI'd like to keep it to Excel if possible, but I could work with a Python program.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1588,"Q_Id":32490561,"Users Score":4,"Answer":"Option 3. Import it properly\nUse DATA, Get External Data, From Text and when the wizard prompts you choose the appropriate DMY combination (Step 3 of 3, Under Column data format, and Date).","Q_Score":0,"Tags":"python,excel,date,csv,import-from-csv","A_Id":32490655,"CreationDate":"2015-09-09T23:12:00.000","Title":"Change date format when importing from CSV","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tend to write my API documentation in Markdown and generate a static site with MkDocs.  However, the site I'd like to host the documentation on is a Django site.  So my question is, and I can't seem to find an answer Googling around, is how would I go about hosting the MkDocs static generated site files at a location like \/api\/v1\/docs and have the static site viewable at that URL?\nUPDATE:\nI should point out I do serve all static files under Apache and do NOT use runserver or Debug mode to serve static files, that's just crazy. The site is completely built and working along with a REST API.\nMy question was simply how do I get Django (or should I say Apache) to serve the static site (for my API docs) generated by MkDocs under a certain URL. I understand how to serve media and static files for the site, but not necessarily how to serve what MkDocs generates.  It generates a completely static 'site' directory with HTML and assets files in it.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":1356,"Q_Id":32511575,"Users Score":4,"Answer":"Django is just a framework you need to host your static files and serve them with something like Nginx or Apache etc.","Q_Score":2,"Tags":"python,django,mkdocs","A_Id":32511724,"CreationDate":"2015-09-10T21:05:00.000","Title":"Hosting API docs generated with mkdocs at a URL within a Django project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to install pillow on my Mac.  I have python 2.7 and python 3.4, both installed with Homebrew.  I tried brew install pillow and it worked fine, but only for python 2.7.  I haven't been able to find a way to install it for python 3.  I tried brew install pillow3 but no luck.  I've found a post on SO that says to first install pip3 with Homebrew and then use pip3 install pillow.  As it happens, I have already installed pip3.\nI've never understood the difference, if any, between installing a python package  with pip and installing it with Homebrew.  Can you explain it to me?  Also, is it preferable to install with Homebrew if a formula is available?  If installing with Homebrew is indeed preferable, do you know how to install pillow for python 3 with Homebrew?\nThe first answers indicate that I haven't made myself plain.  If I had installed pillow with pip install pillow instead of brew install pillow would the installation on my system be any different?  Why would Homebrew make a formula that does something that pip already does?  Would it check for additional prerequisites or something?  Why is there a formula for pillow with python2, but not as far as I can tell for pillow with python3?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":38886,"Q_Id":32530506,"Users Score":4,"Answer":"Homebrew is a package manager, similar to apt on ubuntu or yum on some other linux distros. Pip is also a package manager, but is specific to python packages. Homebrew can be used to install a variety of things such as databases like MySQL and mongodb or webservers like apache or nginx.","Q_Score":48,"Tags":"python,macos,pip,homebrew","A_Id":32530618,"CreationDate":"2015-09-11T19:06:00.000","Title":"Is there a difference between \"brew install\" and \"pip install\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to do a quadratic equation solver. I searched on the web how people did their version, but all of them implied that the user entered the coefficients, which, although the easiest way, I really hate it.\nI want the user to introduce the whole equation, and let the program know which are the coefficients, and calculate the solution. I discovered the concept of regex, and automatically, the re module.\nI understand how to implement the quadratic formula to solve the problem, but the problem is that I don't know which function should I use, and how to get the coefficients from the input.\nI want the regex to be like:\n\\d(\\sx\\s\\(\\^)\\s2\/x\\^2)(\\s\\+\\s)\\dbx(\\s\\+\\s)\\d = 0\nTo find the coefficients in this:\nax^2 + bx + c = 0\nI am aware that the regex sucks, because I only started to understand it yesterday, so you can also tell me how to improve that.\n\nEDIT:\nLet's clarify what I exactly want. \n\nHow to improve the regex that I tried doing above?\nWhat Python function should I use so that I can only have the coefficients?\nHow can I take the groups and turn them into usable integers, assuming that it doesn't store those groups?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2333,"Q_Id":32531468,"Users Score":0,"Answer":"I'd recommend cleaning the input up a but first. Get rid of all the white space, or at least the spaces. Check for an equal sign and see if there's a 0 on one side or the other. If there is you can remove it. If not you have to decide how clever you want to be. \nGet it close to a format you want to deal with, in other words. Then you can check if they've entered a valid re. \nYou also need to decide if you can handle shuffling the order of the terms around and letters other than x. Also whether you want the ^ or ** or just x2.\nYou probably want to grab each term individually (all the terms between the + or -) and decide what kind of term it is. \nIn other words there's a lot to do before the re expression. \nIncidentally have you seen SymPy","Q_Score":0,"Tags":"python,regex","A_Id":32531657,"CreationDate":"2015-09-11T20:15:00.000","Title":"Python: Regular expression for quadratic equations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a collection X of documents, all of which are of class A (the only class in which I'm interested or know anything about). I also have a much larger collection Y of documents that I know nothing about. The documents in X and Y come from the same source and have similar formats and somewhat similar subject matters. I'd like to use the TF-IDF feature vectors of the documents in X to find the documents in Y that are most likely to be of class A.\nIn the past, I've used TF-IDF feature vectors to build naive Bayes classifiers, but in these situations, my training set X consisted of documents of many classes, and my objective was to classify each document in Y as one of the classes seen in X.\nThis seems like a different situation. Here, my entire training set has the same class (I have no documents that I know are not of class A), and I'm only interested in determining if documents in Y are or are not of that class.\nA classifier seems like the wrong route, but I'm not sure what the best next step is. Is there a different algorithm that can use that TF-IDF matrix to determine the likelihood that a document is of the same class?\nFYI, I'm using scikit-learn in Python 2.7, which obviously made computing the TF-IDF matrix of X (and Y) simple.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":264,"Q_Id":32553806,"Users Score":2,"Answer":"What I think you have is an unsupervised learning application.  Clustering.  Using the combined X & Y dataset, generate clusters.  Then overlay the X boundary; the boundary that contains all X samples.  All items from Y in the X boundary can be considered X.  And the X-ness of a given sample from Y is the distance from the X cluster centroid.  Something like that.","Q_Score":1,"Tags":"python,machine-learning,tf-idf,text-classification","A_Id":32555599,"CreationDate":"2015-09-13T19:39:00.000","Title":"If my entire training set of documents is class A, how can I use TF-IDF to find other documents of class A?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a collection X of documents, all of which are of class A (the only class in which I'm interested or know anything about). I also have a much larger collection Y of documents that I know nothing about. The documents in X and Y come from the same source and have similar formats and somewhat similar subject matters. I'd like to use the TF-IDF feature vectors of the documents in X to find the documents in Y that are most likely to be of class A.\nIn the past, I've used TF-IDF feature vectors to build naive Bayes classifiers, but in these situations, my training set X consisted of documents of many classes, and my objective was to classify each document in Y as one of the classes seen in X.\nThis seems like a different situation. Here, my entire training set has the same class (I have no documents that I know are not of class A), and I'm only interested in determining if documents in Y are or are not of that class.\nA classifier seems like the wrong route, but I'm not sure what the best next step is. Is there a different algorithm that can use that TF-IDF matrix to determine the likelihood that a document is of the same class?\nFYI, I'm using scikit-learn in Python 2.7, which obviously made computing the TF-IDF matrix of X (and Y) simple.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":264,"Q_Id":32553806,"Users Score":1,"Answer":"The easiest thing to do is what was already proposed - clustering. More specifically, you extract a single feature vector from set X and then apply K-means clustering to the whole X & Y set. \nps: Be careful not to confuse k-means with kNN (k-nearest neighbors). You are able to apply only unsupervised learning methods.","Q_Score":1,"Tags":"python,machine-learning,tf-idf,text-classification","A_Id":32604626,"CreationDate":"2015-09-13T19:39:00.000","Title":"If my entire training set of documents is class A, how can I use TF-IDF to find other documents of class A?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I use %include wchar.i in C# and it seems to work correctly for all wchar_t values and arrays mapping to C#'s string. Swig's library for Python also contains the typemaps for wchar_t in wchar.i file.\nJava's library doesn't have wchar.i. What's the reason for that? And also how I can achieve type mapping from wchar_t types in C++ to String in Java?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":32572114,"Users Score":0,"Answer":"As you are using c++, than you can try with std::wstring as it has typemaps for all: C#, Python and Java. It is in std_wstring.i","Q_Score":2,"Tags":"java,c#,python,c++,swig","A_Id":32615679,"CreationDate":"2015-09-14T19:07:00.000","Title":"SWIG: wchar_t support for Java","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently playing around with the Apache Spark Service in IBM Bluemix. There is a quick start composite application (Boilerplate) consisting of the Spark Service itself, an OpenStack Swift service for the data and an IPython\/Jupyter Notebook. \nI want to add some 3rd party libraries to the system and I'm wondering how this could be achieved. Using an python import statement doesn't really help since the libraries are then expected to be located on the SparkWorker nodes.\nIs there a ways of loading python libraries in Spark from an external source during job runtime (e.g. a Swift or ftp source)?\nthanks a lot!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":157,"Q_Id":32573995,"Users Score":1,"Answer":"You cannot add 3rd party libraries at this point in the beta. This will most certainly be coming later in the beta as it's a popular requirement ;-)","Q_Score":2,"Tags":"python,apache-spark,ipython,ibm-cloud,jupyter","A_Id":32574697,"CreationDate":"2015-09-14T21:09:00.000","Title":"How can I reference libraries for ApacheSpark using IPython Notebook only?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"brew and port does not provide python-devel. \nHow can I install it in Mac OS. \nIs there an equivalent in Mac OS?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":59901,"Q_Id":32578106,"Users Score":24,"Answer":"If you install Python using brew, the relevant headers are already installed for you.\nIn other words, you don't need python-devel.","Q_Score":27,"Tags":"macos,python-2.7","A_Id":32578175,"CreationDate":"2015-09-15T05:06:00.000","Title":"how to install python-devel in Mac OS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have a question; How does one get the files from a webpage and the urls attached to them. For example, Google.com\nso we go to google.com and open firebug (Mozilla\/chrome) and go to the \"network\"\nWe then see the location of every file attached, and extension of the file.\nHow do I do this in python?\nFor url stuff, I usually look into urllib\/mechanize\/selenium but none of these seem to support what I want or I don't know the code that would be associated with it.\nI'm using linux python 2.7 - Any help\/answers would be awesome. Thank you for anyone attempting to answer this.\nEdit: The things the back end servers generate, I don't know how but firebug in the \"net\" or \"network\" section show this information. I wondered if it could be implemented into python some how.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":32590327,"Users Score":0,"Answer":"It is not difficult to parse the webpage and find the links of all \"attached\" files such as (css, icon, js, images, etc.) which will be fetched by the browser that you can see them in the 'Network' panel.\nThe harder part is that some files are fetched by javascript using ajax. The only way to do that (completely and correctly) is to simulate a browser (parse html+css and run javascripts) which I don't think python can do.","Q_Score":0,"Tags":"python,url,networking,request","A_Id":32590563,"CreationDate":"2015-09-15T15:44:00.000","Title":"Get files attached to URL using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, uploading a gif to gfycat generates URLs in the form of Adjective-Adjective-Noun such as ForkedTestyRabbit.\nObviously going to this URL allows you to view the model instance that was uploaded.\nSo I'm thinking the post upload generates a unique random URL, e.g. \/uploads\/PurpleSmellyGiraffe. The model will have a column that is the custom URL part, i.e. PurpleSmellyGiraffe, and then in the urls.py we have anything \/uploads\/* will select the corresponding model with that URL. However, I'm not sure this is the best practice.\nCould I get some feedback\/suggestions on how to implement this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":508,"Q_Id":32601954,"Users Score":0,"Answer":"What I usually do is create a dir with uploaded date as name, e.g. 04042018\/ and then I rename the uploaded file with an uuid4, e.g. 550e8400-e29b-41d4-a716-446655440000.jpg\nSo the fullpath for the uploaded file will be something like this:\nsite_media\/media\/04042018\/550e8400-e29b-41d4-a716-446655440000.jpg\nPersonally I think is best this way than having something with site_media\/media\/username\/file.jpg because will be easier to figure out what images belong to who.","Q_Score":1,"Tags":"python,django,url","A_Id":49653008,"CreationDate":"2015-09-16T07:11:00.000","Title":"What is the right way in Django to generate random URLs for user uploaded items?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am now using anaconda pip after I installed pip by \"conda install pip\", if I want to use system pip again, how can I make it? Or how can I switch system pip to anaconda pip?","AnswerCount":2,"Available Count":2,"Score":0.4621171573,"is_accepted":false,"ViewCount":9104,"Q_Id":32611932,"Users Score":5,"Answer":"Odds are that anaconda automatically edited your .bashrc so that anaconda\/bin is in front of your \/usr\/bin folder in your $PATH variable.  To check this, type echo $PATH, and the command line will return a list of directory paths.  Your computer checks each of these places for pip when you type pip in the command line.  It executes the first one it finds in your PATH.  \nYou can open \/home\/username\/.bashrc with whatever text editor you choose.  Wherever it adds anaconda\/bin to the path, with something like export PATH=\/anaconda\/bin:$PATH , just replace it with export PATH=$PATH:\/anaconda\/bin\nNote though, this will change your OS to use your system python as well.  Instead of all of this, you can always just use the direct path to pip when calling it.  Or you can alias it using alias pip=\/path\/to\/system\/pip.  And you can put that line in your .bashrc file in order to apply it whenever you login to the pc.","Q_Score":8,"Tags":"python,pip,anaconda,conda","A_Id":32615498,"CreationDate":"2015-09-16T14:47:00.000","Title":"How can I switch using pip between system and anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am now using anaconda pip after I installed pip by \"conda install pip\", if I want to use system pip again, how can I make it? Or how can I switch system pip to anaconda pip?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":9104,"Q_Id":32611932,"Users Score":1,"Answer":"You don't need to change your path. Just use the full path to the system pip (generally \/usr\/bin\/pip or \/usr\/local\/bin\/pip) to use the system pip.","Q_Score":8,"Tags":"python,pip,anaconda,conda","A_Id":32617096,"CreationDate":"2015-09-16T14:47:00.000","Title":"How can I switch using pip between system and anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get my figures in just one pdf page, but I don't know how to do this. I found out that it's possible to save multiple figures in a pdf file with 'matplotlib.backends.backend_pdf', but it doesn't work for just one page.\nHas anyone any ideas ? Convert the figures to just one figure ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8551,"Q_Id":32652611,"Users Score":0,"Answer":"The PDF backend makes one page per figure. Use subplots to get multiple plots into one figure and they'll all show up together on one page of the PDF.","Q_Score":1,"Tags":"python,pdf,matplotlib","A_Id":32664477,"CreationDate":"2015-09-18T12:55:00.000","Title":"Save multiple figures in one pdf page, matplotlib","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've a read-only access to a database server dbserver1. I need to store the result set generated from my query running on dbserver1 into another server of mine dbserver2. How should I go about doing that? \nAlso can I setup a trigger which will automatically copy new entries that will come in to the dbserver1 to dbserver2? Source and destination are both using Microsoft SQL server.\nFollowing on that, I need to call a python script on a database trigger event. Any ideas on how could that be accomplished?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":449,"Q_Id":32659008,"Users Score":1,"Answer":"lad2015 answered the first part. The second part can be infinitely more dangerous as it involves calling outside the Sql Server process.\nIn the bad old days one would use the xp_cmdshell. These days it may be more worthwhile to create an Unsafe CLR stored procedure that'll call the python script.\nBut it is very dangerous and I cannot stress just how much you shouldn't do it unless you really have no other choices.\nI'd prefer to see a polling python script that runs 100% external to Sql that connects to a Status table populated by the trigger and performs work accordingly.","Q_Score":0,"Tags":"python,sql-server,database-design,triggers,database-cloning","A_Id":32659567,"CreationDate":"2015-09-18T18:45:00.000","Title":"Copy database from one server to another server + trigger python script on a database event","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a PHP script that is supposed to execute a python script as user \"apache\" but is returning the error:\n\/transform\/anaconda\/bin\/python: can't open file '\/transform\/python_code\/edit_doc_with_new_demo_info.py': [Errno 13] Permission denied\nPermissions for edit_doc_with_new_demo_info.py are ---xrwx--x. 1 apache PosixUsers 4077 Sep 18 12:14 edit_doc_with_new_demo_info.py. The line that is calling this python script is:\nshell_exec('\/transform\/anaconda\/bin\/python \/transform\/python_code\/edit_doc_with_new_demo_info.py ' . escapeshellarg($json_python_data) .' >> \/transform\/edit_subject_python.log 2>&1')\nIf apache is the owner of the python file and the owner has execute permission how can it be unable to open the file?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4074,"Q_Id":32660088,"Users Score":1,"Answer":"You need read permission to run the python script.","Q_Score":2,"Tags":"php,python,apache,permission-denied","A_Id":32660141,"CreationDate":"2015-09-18T19:58:00.000","Title":"Python can't open file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Good evening,\nI am working on some little website for fun and want users to be able to add items to their accounts. What I am struggling with is coming up with a proper solution how to implement this properly. \nI thought about adding the User Object itself to the item's model via ForeignKey but wouldn't it be necessary to filter through all entries in the end to find the elements attached to x user? While this would work, it seems quite inefficient, especially when the database has grown to some point. What would be a better solution?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1112,"Q_Id":32660496,"Users Score":0,"Answer":"You could create a model UserItems for each user with a ForeignKey pointing to the user and an item ID pointing to items. The UserItems model should store the unique item IDs of the items that belong to a user. This should scale better if items can be attached to multiple users or if items can exist that aren't attached to any user yet.","Q_Score":2,"Tags":"python,mysql,django","A_Id":32660678,"CreationDate":"2015-09-18T20:27:00.000","Title":"Add models to specific user (Django)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Beginner here.\nI\u2019m trying to use sklearn in pycharm. When importing sklearn I get an error that reads \u201cImport error: No module named sklearn\u201d\nThe project interpreter in pycharm is set to 2.7.10 (\/anaconda\/bin\/python.app), which should be the right one. \nUnder default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the \u201cImport error: No module named sklearn\u201d\nDoes anyone know how to solve this problem?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":67839,"Q_Id":32675024,"Users Score":1,"Answer":"SOLVED:\n\nreinstalled Python 3.7.9 (not the latet)\ninstalled numpy 1.17.5 (not the latest)\ninstalled scikit-learn (latest)\n\nsklearn works now!","Q_Score":24,"Tags":"python,scikit-learn,python-import,anaconda","A_Id":65357723,"CreationDate":"2015-09-20T02:07:00.000","Title":"Getting PyCharm to import sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Beginner here.\nI\u2019m trying to use sklearn in pycharm. When importing sklearn I get an error that reads \u201cImport error: No module named sklearn\u201d\nThe project interpreter in pycharm is set to 2.7.10 (\/anaconda\/bin\/python.app), which should be the right one. \nUnder default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the \u201cImport error: No module named sklearn\u201d\nDoes anyone know how to solve this problem?","AnswerCount":8,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":67839,"Q_Id":32675024,"Users Score":0,"Answer":"For Mac OS:\nPyCharm --> Preferences --> Project Interpreter --> Double Click on pip (a new window will open with search option) --> mention 'Scikit-learn' on the search bar --> Install Packages --> Once installed, close that new window --> OK on the existing window \nand you are done.","Q_Score":24,"Tags":"python,scikit-learn,python-import,anaconda","A_Id":53357368,"CreationDate":"2015-09-20T02:07:00.000","Title":"Getting PyCharm to import sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Beginner here.\nI\u2019m trying to use sklearn in pycharm. When importing sklearn I get an error that reads \u201cImport error: No module named sklearn\u201d\nThe project interpreter in pycharm is set to 2.7.10 (\/anaconda\/bin\/python.app), which should be the right one. \nUnder default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the \u201cImport error: No module named sklearn\u201d\nDoes anyone know how to solve this problem?","AnswerCount":8,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":67839,"Q_Id":32675024,"Users Score":8,"Answer":"please notice that, in the packages search 'Scikit-learn', instead 'sklearn'","Q_Score":24,"Tags":"python,scikit-learn,python-import,anaconda","A_Id":54702828,"CreationDate":"2015-09-20T02:07:00.000","Title":"Getting PyCharm to import sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Beginner here.\nI\u2019m trying to use sklearn in pycharm. When importing sklearn I get an error that reads \u201cImport error: No module named sklearn\u201d\nThe project interpreter in pycharm is set to 2.7.10 (\/anaconda\/bin\/python.app), which should be the right one. \nUnder default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the \u201cImport error: No module named sklearn\u201d\nDoes anyone know how to solve this problem?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":67839,"Q_Id":32675024,"Users Score":1,"Answer":"Same error occurs to me i have fixed by selecting File Menu-> Default Settings-> Project Interpreter -> Press + button and type 'sklearn' Press install button. Installation will be done in 10 to 20 seconds.\nIf issue not resolved please check you PyCharm Interpreter path. Sometimes your machine have Python 2.7 and Python 3.6 both installed and there may be some conflict by choosing one.","Q_Score":24,"Tags":"python,scikit-learn,python-import,anaconda","A_Id":50808255,"CreationDate":"2015-09-20T02:07:00.000","Title":"Getting PyCharm to import sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have successfully installed a library with pip install <library-name>. But when I try to import it, python raises ImportError: No module named <library-name>. Why do I get this error and how can I use the installed library?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67829,"Q_Id":32680081,"Users Score":2,"Answer":"A couple more points:\n\nCheck to see if you're installing the library into the virtualenv that you want to use.\nThere are some libraries whose package names are different from the library's name. You could take a look at their documentation online (google with keyword python <library> would usually bring up the information) to see if you're importing the package correctly.","Q_Score":38,"Tags":"python,pip","A_Id":32680295,"CreationDate":"2015-09-20T13:45:00.000","Title":"ImportError after successful pip installation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm facing a new problem.\nI'm writing a scraper for a website, usually for this kind of tasks I use selenium, but in this case I cannot use anything that simulate a web-browser.\nResearching on StackOverflow, I read the best solution is to undestand what javascript did and rebuild the request over HTTP.\nYeah, I understand well in theory, but don't know how to start, as I don't know well technologies involved. \nIn my specific case, some HTML is added to the page when the button is clicked. With developer tools I set a breakpoint on the 'click' event, but from here, I'm literally lost. \nAnyone can link some resource and examples I can study?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":84,"Q_Id":32680534,"Users Score":2,"Answer":"In most cases, it is enougth to analyze the \"network\" tab of the developer tools and see the requests that are fired when you hit that button you metioned.  \nAs you understand those requests, you will be able to implement your scraper to run similar requests and grab the relevant data.","Q_Score":0,"Tags":"javascript,python,browser,beautifulsoup,python-requests","A_Id":32680624,"CreationDate":"2015-09-20T14:35:00.000","Title":"Python - Rebuild Javascript generated code using Requests Module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a site, that performs some heavy calculations, using library for symbolic math.\nCurrently average calculation time is 5 seconds.\nI know, that ask too broad question, but nevertheless, what is the optimized configuration for this type of sites? What server is best for this?\nCurrently, I'm using Apache with mod_wsgi, but I don't know how to correctly configure it.\nOn average site is receiving 40 requests per second.\nHow many processes, threads, MaxClients etc. should I set? \nMaybe, it is better to use nginx\/uwsgi\/gunicorn (I'm using python as programming language)?\nAnyway, any info is highly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":32682065,"Users Score":1,"Answer":"Andrew,\nI believe that you can move some pieces of your deployment topology.\nMy suggestion is use nginx for delivering HTTP content, and expose your application using some web framework, i.e. tornadoweb (my preference, considering async core, and best documented if compared to twisted, even twisted being a really great framework)\nYou can communicate between nginx and tornado by proxy. It is simple to be configured.\nYou can replicate your service instance to distribute your calculation application inside the same machine and another hosts. It can be easily configured by nginx upstreams.\nIf you need more performance, you can break your application in small modules and integrate it using Async Messaging. You can choose using zeromq or rabbitmq, among other solutions.\nThen, you can have different topologies, gradually applied during the evolution of your application.\n1th Topology:\nnginx -> tornadoweb\n2th Topology:\nnginx with loadbalance (upstreams) -> tornadoweb replicated on [1..n] instances\n3rd Topology:\n[2nd topology] -> your app integrated by messaging (zeromq, amqp(rabbitmq), ...)\nMy favorite is 3rd, for begining. But, you should start, for this moment, by 1th and 2nd\nThere are a lot of options. But, these thre may be sufficient for a simple organization of your app.","Q_Score":1,"Tags":"python,nginx,apache2,server,uwsgi","A_Id":32682202,"CreationDate":"2015-09-20T17:10:00.000","Title":"Best server configuration for site with heavy calculations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have 5 different games written in python that run on a raspberry pi. Each game needs to pass data in and out to a controller using a serial connection. The games get called by some other code (written in nodeJS) that lets the user select any of the games.\nI'm thinking I don't want to open and close a serial port every time I start and finish a game. Is there anyway to make a serial object instance \"global\", open it once, and then access it from multiple game modules, all of which can open and close at will?\nI see that if I make a module which assigns a Serial object to a variable (using PySerial) I can access that variable from any module that goes on to import this first module, but I can see using the id() function that they are actually different objects - different instances - when they are imported by the various games.\nAny ideas about how to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":328,"Q_Id":32708630,"Users Score":0,"Answer":"Delegate the opening and management of the serial port to a separate daemon, and use a UNIX domain socket to transfer the file descriptor for the serial port to the client programs.","Q_Score":3,"Tags":"python,global","A_Id":32709121,"CreationDate":"2015-09-22T04:53:00.000","Title":"Python - global Serial obj instance accessible from multiple modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using pyenchant package for spell check in Python. I am able to do it successfully for languages English, French, German.\nAlso, I want to do it for languages Italian and Spanish. I looked into available dictionaries in enchant using enchant.list_languages() and I got only ['de_DE', 'en_AU', 'en_GB', 'en_US', 'fr_FR'].\nI am looking for how to do spell check for Italian and Spanish using enchant package or any other package\/techniques.\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4538,"Q_Id":32712557,"Users Score":0,"Answer":"You can use hunspell for italian it will replace it, and myspell for spanish\nsudo apt install hunspell-it Italian\nsudo apt install myspell-es Spanish","Q_Score":6,"Tags":"python,pyenchant","A_Id":58909625,"CreationDate":"2015-09-22T08:53:00.000","Title":"Pyenchant - Italian and Spanish Languages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had posted about this error some time back but need some more clarification on this.\nI'm currently building out a Django Web Application using Visual Studio 2013 on a Windows 10 machine (Running Python3.4). While starting out I was constantly dealing with the MySQL connectivity issue, for which I did a mysqlclient pip-install. I had created two projects that use MySQL as a backend and after installing the mysqlclient I was able to connect to the database through the current project I was working on. When I opened the second project and tried to connect to the database, I got the same 'No Module called MySqlDB' error.\nNow, the difference between both projects was that the first one was NOT created within a Virtual Environment whereas the second was.\nSo I have come to deduce that projects created within the Python virtual environment are not able to connect to the database. Can someone here please help me in getting this problem solved. I need to know how the mysqlclient module can be loaded onto a virtual environment so that a project can use it.\nThanks","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":660,"Q_Id":32715175,"Users Score":1,"Answer":"This approach worked ! I was able to install the mysqlclient inside the virtual environment through the following command:-\npython -m pip install mysqlclient\nThanks Much..!!!!!","Q_Score":0,"Tags":"python,mysql,django","A_Id":32723517,"CreationDate":"2015-09-22T11:02:00.000","Title":"No Module Named MySqlDb in Python Virtual Enviroment","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a very weird request. An executable I have has a system call to a python script which goes like py file1.py\nNow, in my system though py is shown as an unrecognized internal or external command. python file1.py works however.\nis there some way I can get my windows command prompt to recognize that py and python refer to the same thing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29688,"Q_Id":32742093,"Users Score":20,"Answer":"py command comes with Python3.x and allow to choose among multiple Python interpreters. For example if you have both Python 3.4 and 2.7 installed, py -2 will start python2.7 and py -3 will start python3.4 . If you just use py it will start the one that was defined as default.\nSo the official way would be to install Python 3.x, declare Python 2.7 as the default, and the py command will do its job.\nBut if you just want py to be an alias of python, doskey py=python.exe as proposed by @Nizil and @ergonaut will be much simpler... Or copying python.exe to py.exe in Python27 folder if you do not want to be bothered by the limitations of doskey.","Q_Score":6,"Tags":"python,windows,python-2.7,cmd","A_Id":32742619,"CreationDate":"2015-09-23T14:18:00.000","Title":"how to access python from command line using py instead of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just started exploring Flask. Earlier I tried to explore Django but found it a bit complicated. However, Installing Flask requires us to install virtualenv first which, As I can recall, is not required in the case of Django.\nIn case it is not required, how to go ahead without virtualenv?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2441,"Q_Id":32756711,"Users Score":12,"Answer":"No, there is no requirement to use a virtualenv. No project ever would require you to use one; it is just a method of insulating a collection of Python libraries from other projects.\nI personally do strongly recommend you use a virtualenv, because it makes it much, much easier to swap out versions of libraries and not affect other Python projects.\nWithout a virtualenv, you just continue with installing the dependencies, and they'll end up in your system libraries collection. Installing the Flask project with pip will pull in a few other packages, such as Werkzeug, Jinja2 and itsdangerous. These would all be installed 'globally'.","Q_Score":6,"Tags":"python,flask,virtualenv","A_Id":32756729,"CreationDate":"2015-09-24T08:25:00.000","Title":"Is it necessary to use virtualenv to use Flask framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently transforming a perl \/ bash tool into a salt module and I am wondering how I should sync the non-python parts of this module to my minions.\nI want to run salt agent-less and ideally the dependencies would by synced automatically alongside the module itself once its called via salt-ssh.\nBut it seems that only python scripts get synced. Any thoughts for a nice and clean solution?\nCopying the necessary files from the salt fileserver during module execution seems somehow wrong to me..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":284,"Q_Id":32762675,"Users Score":2,"Answer":"Only python extensions are supported, so your best bet is to do the following:\n1) Deploy your non-Python components via a file.managed \/ file.recurse state.\n2) Ensure your custom execution module has a __virtual__() function checking for the existence of the non-Python dependencies, and returning False if they are not present. This will keep the module from being loaded and used unless the deps are present.\n3) Sync your custom modules using saltutil.sync_modules. This function will also re-invoke the loader to update the available execution modules on the minion, so if you already had your custom module sync'ed and later deployed the non-Python depenencies, saltutil.sync_modules would re-load the custom modules and, provided your __virtual__() function returned either True or the desired module name, your execution module would then be available for use.","Q_Score":0,"Tags":"python,salt-stack","A_Id":32769491,"CreationDate":"2015-09-24T13:29:00.000","Title":"How to sync a salt execution module with non-python dependencies","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm just wondering (as im starting to make a game with pygame) is there a way to 1) Run a program that only opens a GUI and not the shell\nand \n2) Run the program without having to edit with idle (I'd like to do this so the game will look more professional.\nI would like to just have a desktop shortcut or something that when clicked, runs only the GUI and doesnt show my code or show the shell.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":87,"Q_Id":32771481,"Users Score":1,"Answer":"If you're on windows, a quick thing could be to make a one-line batch script.\nstart pythonw.exe <filename>\nThe start keyword causes the shell to not wait for the program to finish. \npythonw vs python prevents the python terminal from appearing. \nIf you're on linux\/mac, you could do the same with shell scripts.","Q_Score":0,"Tags":"python,pygame,python-idle","A_Id":32771570,"CreationDate":"2015-09-24T21:48:00.000","Title":"How to make the text shell not appear when running a program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Because I need to parse and then use the actual data in cells, I open an xlsm in openpyxl with data_only = True.\nThis has proved very useful. Now though, having the same need for an xlsm that contains formuale in cells, when I then save my changes, the formulae are missing from the saved version.\nAre data_only = True and formulae mutually exclusive? If not, how can I access the actual value in cells without losing the formulae when I save?\nWhen I say I lose the formulae, it seems that the results of the formulae (sums, concatenattions etc.) get preserved. But the actual formulaes themselves are no longer displayed when a cell is clicked.\nUPDATE:\nTo confirm whether or not the formulaes were being preserved or not, I've re-opened the saved xlsm, this time with data_only left as False. I've checked the value of a cell that had been constructed using a formula. Had formulae been preserved, opening the xlsm with data_only set to False should have return the formula. But it returns the actual text value (which is not what I want).","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6128,"Q_Id":32772954,"Users Score":2,"Answer":"If you want to preserve the integrity of the workbook, ie. retain the formulae, the you cannot use data_only=True. The documentation makes this very clear.","Q_Score":6,"Tags":"python,python-2.7,openpyxl","A_Id":32776318,"CreationDate":"2015-09-25T00:21:00.000","Title":"How to save in openpyxl without losing formulae?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"suppose i have three models, at my view I am showing all the item of these models, i want to give my user privilege to set which model's objects are to be shown at view at first, second and third.\nwhat is the best way to implement this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":32816966,"Users Score":0,"Answer":"it is not clear what you mean by \"my user\" .\nis this just the admin user who set this configuration globaly for the site .\nor do you mean evey user of the site has his\/her own preferences ?\nif the latter case then make a new model called Preferences which has one to one relation to the user model .\nthen in your query you should create three separate queries according to the preference values .","Q_Score":1,"Tags":"python,django,django-models","A_Id":32830790,"CreationDate":"2015-09-28T06:36:00.000","Title":"how to keep django models in database for users customized view?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"This is a python question, but also a linux\/BSD question.\nI have a python script with two threads, one downloading data from the web and the other sending data to a device over a serial port. Both of these threads print a lot of status information to stdout using python's logging module.\nWhat I would like is to have two terminal windows open, side by side, and have each terminal window show the output from one thread, rather than have the messages from both interleaved in a single window.\nAre there file descriptors other than stdin, stdout & stderr to write to and connect to other terminal windows? Perhaps this wish is better fulfilled with a GUI? \nI'm not sure how to get started with this.\nedit: I've tried writing status messages to two different files instead of printing them to stdout, and then monitoring these two files with tail -f in other terminal windows, but this doesn't work for live monitoring because the files aren't written to until you call close() on them.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":437,"Q_Id":32817302,"Users Score":0,"Answer":"File write operations are buffered by default so the file isn't effectiveley written until either the buffer is full, the file is closed or you explicitely call flush() on the file. \nBut anyway: dont use direct file access if you want to log to a file, use either a logging.StreamHandler with an opened file as stream or, better, a logging.FileHandler. Both will take care of flushing the file.","Q_Score":6,"Tags":"python,linux,macos,terminal,stdout","A_Id":32818127,"CreationDate":"2015-09-28T06:59:00.000","Title":"Is it possible to output to and monitor streams other than stdin, stdout & stderr? (python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I accidentally downloaded Python 3.4.2 a while back but I actually needed Python 2.7, so I deleted the 3.4.2 files and downloaded 2.7 instead. Now I need Python 3, so I tried to download it but I noticed that in the control panel in the Uninstall Programs section it tells me that the 3.4.2 from back then is still on my PC.\nEvery time I try to uninstall\/change\/repair\/download a newer version I can't and it tells me \n\nA program required to complete the installation can not be found...\n\nI can not find any remaining files connected to any sort of Python in my PC. My operating system is Windows 10. Does someone know how to solve this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":8420,"Q_Id":32820673,"Users Score":1,"Answer":"Did you try to reinstall the version you want to delete and then uninstall it afterwards ?","Q_Score":3,"Tags":"python,windows,uninstallation","A_Id":32821417,"CreationDate":"2015-09-28T10:21:00.000","Title":"Can't uninstall Python on Windows (3.4.2)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I accidentally closed the variable explorer on my Pythone(Spyder)...\nDoes anyone know how I can reopen it?\nIf I must reinstall the program, then I will but I just want to see if there is a way.\nThank you!","AnswerCount":4,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":51281,"Q_Id":32834722,"Users Score":6,"Answer":"Just use combination of shift+ctrl+v","Q_Score":21,"Tags":"python,spyder","A_Id":43390881,"CreationDate":"2015-09-29T02:28:00.000","Title":"spyder python how to re-open Variable Explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I accidentally closed the variable explorer on my Pythone(Spyder)...\nDoes anyone know how I can reopen it?\nIf I must reinstall the program, then I will but I just want to see if there is a way.\nThank you!","AnswerCount":4,"Available Count":4,"Score":0.0996679946,"is_accepted":false,"ViewCount":51281,"Q_Id":32834722,"Users Score":2,"Answer":"You can go to view then in view click on window layout then in that click on reset to spyder default which will give you the default layout of spyder.","Q_Score":21,"Tags":"python,spyder","A_Id":59318950,"CreationDate":"2015-09-29T02:28:00.000","Title":"spyder python how to re-open Variable Explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I accidentally closed the variable explorer on my Pythone(Spyder)...\nDoes anyone know how I can reopen it?\nIf I must reinstall the program, then I will but I just want to see if there is a way.\nThank you!","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":51281,"Q_Id":32834722,"Users Score":39,"Answer":"Go to View\/Panes and select Variable Explorer.","Q_Score":21,"Tags":"python,spyder","A_Id":32834969,"CreationDate":"2015-09-29T02:28:00.000","Title":"spyder python how to re-open Variable Explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I accidentally closed the variable explorer on my Pythone(Spyder)...\nDoes anyone know how I can reopen it?\nIf I must reinstall the program, then I will but I just want to see if there is a way.\nThank you!","AnswerCount":4,"Available Count":4,"Score":0.049958375,"is_accepted":false,"ViewCount":51281,"Q_Id":32834722,"Users Score":1,"Answer":"Just go to tools(look at the dashboard at top middle)\nand select reset spyder to factory dafaults and click ok\nYou will get your default spyder console.","Q_Score":21,"Tags":"python,spyder","A_Id":56264798,"CreationDate":"2015-09-29T02:28:00.000","Title":"spyder python how to re-open Variable Explorer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a Python script to fetch and update some data on a remote oracle database from a Linux server. I would like to know how can I connect to remote oracle database from the server.\nDo I necessarily need to have an oracle client installed on my server or any connector can be used for the same?\nAnd also if I use cx_Oracle module in Python, is there any dependency that has to be fulfilled for making it work?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6425,"Q_Id":32836510,"Users Score":0,"Answer":"Yes, you definitely need to install an Oracle Client, it even says so in cx_oracle readme.txt.\nAnother recommendation you can find there is installing an oracle instant client, which is the minimal installation needed to communicate with Oracle, and is the simplest to use.\nOther dependencies can usually be found in the readme.txt file, and should be the first place to look for these details.","Q_Score":1,"Tags":"python,oracle,database-connection,cx-oracle","A_Id":32836606,"CreationDate":"2015-09-29T05:47:00.000","Title":"Python connection to Oracle database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to edit the right click context sensitive menu from Maya. I have found how to add a menuItem but I would like to have this Item in the top of the list not at the bottom... I think in this case I need to deleteAllItems from the menu, add mine and then re-add the default Maya ones but I don't know how to re-add them. Where can I find it ?  Most of the topics say \"modify Maya's source code\" but that's not even an option.\nAny suggestions ? \nThx !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":955,"Q_Id":32849325,"Users Score":0,"Answer":"Okay i think I have found a solution, that's the best I have found but this is not very handy...\ncreate a copy of the buildobjectMenuItemsNow.mel and dagMenuProc.mel in your script folder so Maya will read those ones instead of the native ones. Once you have done that you can modify the dagMenuProc.mel without destructing anything as you re working on a copy.\nthe proc that needs modifications is the last one : dagMenuProc (line 2240)\nand you can start modifying inside the loop (line 2266)\nWhat I have done is make a call to a Python file that adds some more items in the menu and you can obviously remove some items by deleting few MEL lines.\nI hope this can help someone.\nAnd if there is an other way of doing that, I would love to hear about !","Q_Score":0,"Tags":"python,contextmenu,menuitem,maya,right-click","A_Id":32870983,"CreationDate":"2015-09-29T16:35:00.000","Title":"Maya right click context sensitive menu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working with multi-threading. There is a thread that periodically adds to a certain variable, say every 5 seconds. I want to make it so that, given a call to function f(), additions to that variable will have no effect.\nI can't find how to do this anywhere and I'm not sure where to start.\nIs there any syntax that makes certain operations not no effect no specific variables for a certain duration?\nOr is there any starting point someone could give me and I can figure out the rest?\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":32902615,"Users Score":2,"Answer":"I would suggest creating an addToVariable or setVariable method to take care of the actual adding  to the variable in question. This way you can just set a flag, and if the flag is set addToVariable returns immediately instead of actually adding to the variable in question.\nIf not, you should look into operator overloading. Basically what you want is to make your own number-class and write a new add function which contains some sort of flag that stops further additions to have any effect.","Q_Score":0,"Tags":"python,multithreading,python-2.7,python-3.x,python-multithreading","A_Id":32902789,"CreationDate":"2015-10-02T07:45:00.000","Title":"Make certain operators have no effect over a duration of time? (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a website with many pages, on each page is a sample essay. The homepage is a page with a search field. I'm attempting to design a system where a user can type in a word and when they click 'search', multiple paragaphs containing the searched word from the pages with a sample essays are loaded on to the page.\nI'm 14 and have been programming for about 2 years, can anyone please explain to me the programming languages\/technologies I'll need to accomplish this task and provide suggestions as to how I can achieve my task.\nAll I have so far are the web pages with articles and a custom search page I've made with PHP. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":32913859,"Users Score":1,"Answer":"The programing language does not realy matter for the way to solve the problem. You can implement it in the language which you are comfortable with.\nThere are two basic ways to solve the problem:\n\nUse a crawler which creates a index of words found on the different pages\nThe use that index to lookup the searched word\n\nor\n\nWhen the user has entered the search expression, you start crawling the pages and look if the search expression is found\n\nOf course both solutions will have different (dis)advantages\nFor example:\nIn 1) you need to do a inital crawl (and udate it later on when the pages change)\nIn 1) you need to store the crawl result in some sort of database\nIn 1) you will receive instanst search results\nIn 2) You don't need a database\/datastore\nIn 2) You will have to wait until all pages are searched before showing the final resultlist","Q_Score":0,"Tags":"java,php,python,html,mysql","A_Id":32915448,"CreationDate":"2015-10-02T18:46:00.000","Title":"Creating a webpage crawler that finds and maches user input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been searching the web for hours now, found several instances where someone had the same problem, but I seem to be too much of a newb with linux\/ubuntu to follow the instructions properly, as none of the given solutions worked.\nWhenever I try to run a panda3d sample file from the python shell, I would give me an error saying:\nTraceback (most recent call last):\n  File \"\/usr\/share\/panda3d\/samples\/asteroids\/main.py\", line 16, in \n    from direct.showbase.ShowBase import ShowBase\nImportError: No module named 'direct'\nWhat really bugs me is that when I try to execute the .py file directly (without opening it in the IDLE or pycharm) it works just fine.\nI know this has been asked before, but I would like to ask for a working step by step solution to be able to import panda3d from pycharm and the IDLE. I have no clue how to get it working, as none of the answers given to this question worked for me.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":501,"Q_Id":32937078,"Users Score":1,"Answer":"try to change your PYTHONPATH? \ni met a problem like this, and then i modify my PYTHONPATH, and it worked.","Q_Score":1,"Tags":"python,python-import,panda3d","A_Id":32937162,"CreationDate":"2015-10-04T18:48:00.000","Title":"panda3d python import error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm startint a project on my own and I'm having some troubles with importing datas from IMDb. Already downloaded everything that's necessary but I'm kinda newbie in this python and command lines stuff, and it's pissing me off because I'm doing my homework (trying to learn how to do these things) but I can't reach it :(\nSo, is there anybody who could create a step-by-step of how to do it? I mean, something like:\nYou'll need to download this and run this commands on 'x'.\nCreate a database and then run 'x'.\nIt would be amazing for me and other people who don't know how to do this as well and I would truly appreciate A LOT, really!. Oh, I'm using Windows.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1057,"Q_Id":32953669,"Users Score":3,"Answer":"Problem solved!\nFor those who are having the same problem, here it goes:\nDownload the java movie database. It works witch postrgres or mysql. You'll have to download java runtime. After that open the readme in the directory you installed the java movie database, there are all the instructions, but I'll help you.\nFollow the link off the *.list archives and download then. Move them into a new folder. After that, open JMDB (java movie database) and select the right folders of moviecollection, sound etc (they are in C:\/programs...). In IMDb-import select the folder you created which contains the *.files. Well, this is the end. Run the JMDB and you'll have your DB populated.","Q_Score":0,"Tags":"python,postgresql,imdb,imdbpy","A_Id":32972532,"CreationDate":"2015-10-05T16:44:00.000","Title":"How to run imdbpy2sql.py and import data from IMDb to postgres","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Last week I was given a requirement for an already crowded display\/input screen written in wxPython (data stored in MySQL database) to show the first 24 characters of two free format comment fields but to allow up to 255 characters to be displayed\/input. For instance on entry the screen might show \u201cRight hip and knee X-ra\u201d whilst the full entry continues \u201cys requested 24th September in both laying and standing positions with knee shown straighten and bent through 75 degrees\u201d. Whilst I can create a wxtextCtrl that holds more characters than displayed (scrolls) I cannot work out how to display\/enter the contents as a multiline box when selected. I have gone through our wxPython book and searched online with no joy.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":109,"Q_Id":32965937,"Users Score":1,"Answer":"The simplest way to do it I see would be to store only the abbreviated contents in wxTextCtrl itself normally and only replace it with the full contents when the user is about to start editing it (i.e. when you get wxEVT_SET_FOCUS) and then replace it with the abbreviated version again later (i.e. when you get wxEVT_KILL_FOCUS).","Q_Score":0,"Tags":"wxpython,wxwidgets","A_Id":32968457,"CreationDate":"2015-10-06T09:07:00.000","Title":"wxtextCtrl To Allow Input\/Display Of More Text Than Default Display","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Last week I was given a requirement for an already crowded display\/input screen written in wxPython (data stored in MySQL database) to show the first 24 characters of two free format comment fields but to allow up to 255 characters to be displayed\/input. For instance on entry the screen might show \u201cRight hip and knee X-ra\u201d whilst the full entry continues \u201cys requested 24th September in both laying and standing positions with knee shown straighten and bent through 75 degrees\u201d. Whilst I can create a wxtextCtrl that holds more characters than displayed (scrolls) I cannot work out how to display\/enter the contents as a multiline box when selected. I have gone through our wxPython book and searched online with no joy.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":109,"Q_Id":32965937,"Users Score":0,"Answer":"Have you considered using my.TextCtrl.SetToolTipString() and setting it to the same value as the textctrl contents. In this manner only the first 24 characters show in the textctrl but if you hover over it the entire string will be displayed as a tooltip.","Q_Score":0,"Tags":"wxpython,wxwidgets","A_Id":33018442,"CreationDate":"2015-10-06T09:07:00.000","Title":"wxtextCtrl To Allow Input\/Display Of More Text Than Default Display","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"where should my python files be stored so that I can run that using gdb. I have custom gdb located at \/usr\/local\/myproject\/bin. I start my gdb session by calling .\/arm-none-eabi-gdb from the above location.\nI don't know how this gdb and python are integrated into each other.\nCan anyone help.?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":886,"Q_Id":32978233,"Users Score":0,"Answer":"I was able to figure out. What I understood is\nGDB embeds the Python interpreter so it can use Python as an extension language.\nYou can't just import gdb from \/usr\/bin\/python like it's an ordinary Python library because GDB isn't structured as a library.\nWhat you can do is source MY-SCRIPT.py from within gdb (equivalent to running gdb -x MY-SCRIPT.py).","Q_Score":0,"Tags":"python,gdb","A_Id":32979189,"CreationDate":"2015-10-06T19:36:00.000","Title":"Invoke gdb from python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to read in a 4 column txt file and create a 5th column. Column 1 is a string and columns 2-4 are numbers, however they are being read as strings. I have two questions - my python script is currently unable to perform multiplication on two of the columns because it is reading columns 2-4 as strings. I want to know how to change columns 2-4 (which are numbers) to floating numbers and then create a 5th column that is two of the previous columns multiplied together.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":761,"Q_Id":32981331,"Users Score":0,"Answer":"Just cast them to float using float(x) method where x is the string that contains the float","Q_Score":0,"Tags":"python","A_Id":32981354,"CreationDate":"2015-10-06T23:18:00.000","Title":"Change data type in text file from string to float Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am implementing selenium and i have already included \"from selenium import webdriver\" but still getting this error \n\n\"ImportError: cannot import name webdriver\"\n\nAny idea how to resolve this error?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1185,"Q_Id":33009532,"Users Score":0,"Answer":"Cross check your language binding, check with older versions","Q_Score":0,"Tags":"python-2.7,selenium-webdriver","A_Id":33010025,"CreationDate":"2015-10-08T07:40:00.000","Title":"ImportError: cannot import name webdriver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Let's say I have a python module that has a lot of functions that rely on each other, processing each others results. There's lots of cohesion. \nThat means I'll be passing back and forth a lot of arguments. Either that, or I'd be using global variables.\nWhat are best practices to deal with such a situation if? Things that come to mind would be replacing those parameters with dictionaries. But I don't necessarily like how that changes the function signature to something less expressive. Or I can wrap everything into a class. But that feels like I'm cheating and using \"pseudo\"-global variables?\nI'm asking specifically for how to deal with this in Python but I understand that many of those things would apply to other languages as well. \nI don't have a specific code example right, it's just something that came to mind when I was thinking about this issue. \nExamples could be: You have a function that calculates something. In the process, a lot of auxiliary stuff is calculated. Your processing routines need access to this auxiliary stuff, and you don't want to just re-compute it.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":1672,"Q_Id":33023432,"Users Score":6,"Answer":"This is a very generic question so it is hard to be specific. What you seem to be describing is a bunch of inter-related functions that share data. That pattern is usually implemented as an Object.\nInstead of a bunch of functions, create a class with a lot of methods.  For the common data, use attributes.  Set the attributes, then call the methods. The methods can refer to the attributes without them being explicitly passed as parameters.","Q_Score":5,"Tags":"python,arguments,global-variables,parameter-passing","A_Id":33023611,"CreationDate":"2015-10-08T18:33:00.000","Title":"Avoiding global variables but also too many function arguments (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a working program written in Java (a 3d game) and some scripts in Python written with theano to process images. \nI am trying to capture the frames of the game as it is running and run these scripts on the frames.\nMy current implementation grabs the binary data from each pixel in the frame, saves the frame as a png image and calls the python script (using ProcessBuilder) which opens the image and does its thing.\nWriting an image to file and then opening it in python is pretty inefficient, so I would like to be able to pass the binary data from Java to Python directly.\nIf I am not mistaken, processBuilder only takes arguments as strings, so does anyone know how I can pass this binary data directly to my python script? Any ideas?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":250,"Q_Id":33029293,"Users Score":0,"Answer":"If there is no limit to the length of the string argument for launching the python script, you could simply encode the binary data from the image into a string, and pass that. The only problem you might encounter with this approach would be null characters and and negative numbers.","Q_Score":0,"Tags":"java,python,subprocess,jython,processbuilder","A_Id":38824000,"CreationDate":"2015-10-09T03:13:00.000","Title":"Passing binary data from java to python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want the program to wait like 5 seconds before exiting the console after finishing whatever it does, so the user can read the \"Good Bye\" message, how can one do this?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":33034687,"Users Score":0,"Answer":"If it's not a multithreaded program, then just let the program do whatever it needs and then: raw_input(\"Press Enter to stop the sharade.\\n\")\n\nMaybe it's not exactly what you're looking for but on the other hand you should not rely on a predefined sleep time.","Q_Score":0,"Tags":"python","A_Id":33034977,"CreationDate":"2015-10-09T09:29:00.000","Title":"How to stop console from exiting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded a subset of million song data set which is about 2GB. However, the data is broken down into folders and sub folders. In the sub-folder they are all in several 'H5 file' format. I understand it can be read using Python. But I do not know how to extract and load then into HDFS so I can run some data analysis in Pig. \nDo I extract them as CSV and load to Hbase or Hive ? It would help if someone can point me to right resource.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":726,"Q_Id":33043704,"Users Score":1,"Answer":"If it's already in the CSV or any format on the linux file system, that PIG can understand, just do a hadoop fs -copyFromLocal  to \nIf you want to read\/process the raw H5 File format using Python on HDFS, look at hadoop-streaming (map\/reduce)\nPython can handle 2GB on a decent linux system- not sure if you need hadoop for it.","Q_Score":0,"Tags":"python,hadoop,hive,hbase,bigdata","A_Id":33043867,"CreationDate":"2015-10-09T17:06:00.000","Title":"How to load big datasets like million song dataset into BigData HDFS or Hbase or Hive?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded a subset of million song data set which is about 2GB. However, the data is broken down into folders and sub folders. In the sub-folder they are all in several 'H5 file' format. I understand it can be read using Python. But I do not know how to extract and load then into HDFS so I can run some data analysis in Pig. \nDo I extract them as CSV and load to Hbase or Hive ? It would help if someone can point me to right resource.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":726,"Q_Id":33043704,"Users Score":0,"Answer":"Don't load such amount of small files into HDFS. Hadoop doesn't handle well lots of small files. Each small file will incur in overhead because the block size (usually 64MB) is much bigger.\nI want to do it myself, so I'm thinking of solutions. The million song dataset files don't have more than 1MB. My approach will be to aggregate data somehow before importing into HDFS. \nThe blog post \"The Small Files Problem\" from Cloudera may shed some light.","Q_Score":0,"Tags":"python,hadoop,hive,hbase,bigdata","A_Id":50411499,"CreationDate":"2015-10-09T17:06:00.000","Title":"How to load big datasets like million song dataset into BigData HDFS or Hbase or Hive?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to set a window's size, and then be able to resize it while the program is running. I've been able to make the window large, but I can't resize it smaller than the original set size. For a different project, I would also like to know how to make it so the window is not resizable at all.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":41,"Q_Id":33057049,"Users Score":3,"Answer":"For the first question: Gtk.Window.resize(width, height) should work. If you use set_size_request(width, height), you cannot resize your window smaller than these values.\nFor the second question: Gtk.Window.set_resizable(False)","Q_Score":1,"Tags":"python,resize,pygtk","A_Id":33057480,"CreationDate":"2015-10-10T17:42:00.000","Title":"PYGTK Resizing permissions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have read numerous articles about running code in the Atom code editor, however, I cannot seem to understand how this can be done. Could anyone explain it in simpler terms? \nI want to run my Python code in it and I have downloaded the 'python-tools-0.6.5' and 'atom-script-2.29.0' files from the Atom website and I just need to know how to get them working.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":17470,"Q_Id":33068445,"Users Score":0,"Answer":"From Atom > Preferences > Install:\nSearch for atom-runner package and install it.\nClose the atom editor and reopen. This helps the atom editor set the right path and will solve the issue.\nIf this doesnt help, manually copy the folder of the python installation directory and add the path to system PATH. This will solve the issue.","Q_Score":3,"Tags":"python,windows,atom-editor","A_Id":43814862,"CreationDate":"2015-10-11T18:15:00.000","Title":"Run Code In Atom Code Editor","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a very simple iOS and Android applications that download a txt file from a web server and preset it to the user. I'm looking for a way that only the application will be able to read the file so no one else can download and use it.\nI would like to take the file that is on my computer, encrypt it somehow, upload the result to the server and when the client will download the file it will know how to read it.\nWhat is the simplest way to to this kind of thing?\nThanks a lot!","AnswerCount":3,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1327,"Q_Id":33080063,"Users Score":-3,"Answer":"It's very wide question and the variety of ways to do that. \nFirst of all, you need to choose a method of the encryption and purpose why you encrypt the data. \nThere are 3 main encryption methods: \n1. Symmetric Encryption\nEncrypter and Decrypter have access to the same key. It's quite easy, but it has one big drawback - key needs to be shared, so if you put it to the client it can be stolen and abused. \nAs a solution, you would need to use some another method to send the key and encrypt it on the client. \n2. Asymmetric Encryption\nWith asymmetric encryption, the situation is different. To encrypt data you need to use public\/private key pair. \nThe public key is usually used to encrypt data, but decryption is possible only with a private key. So you can hand out public key to your clients, and they would be able to send some encrypted traffic back to you.  \nBut still you need to be sure that you are talking to the right public key to not abuse your encryption. \nUsually, it's used in TLS (SSL), SSH, signing updates, etc. \n3. Hashing (it's not really encryption)\nIt's the simplest. With hashing, you produce some spring that can't be reverted, but with a rule that same data will produce the same hash. \nSo you could just pick the most suitable method and try to find appropriate package in the language you use.","Q_Score":0,"Tags":"javascript,python,ios,swift,encryption","A_Id":33080475,"CreationDate":"2015-10-12T11:32:00.000","Title":"encrypting data on server and decrypting it on client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed iPython Notebook as a component of my Anaconda installation.  To become familiar with using iPython Notebook I started through an introductory tutorial and immediately ran into a discrepancy.  When I open the notebook the tutorial shows I should have three tabs across the top labelled 'Notebooks', 'Running' and 'Clusters'.  Instead I have 'Files', 'Running' and 'Clusters'.  I cannot figure out how to switch the Files tab to the Notebooks tab...or is the Files tab correct and is the tutorial out-of-date?  I would much prefer to just have the Notebooks view as listing all the file folders just gets in the way.  Can someone tell me how to swap out the Files tab for the Notebooks tab?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":33089288,"Users Score":0,"Answer":"The three tabs \"Files\", \"Running\" and \"Clusters\" should be correct. The \"Running\" tab has the active notebooks listed.\nYes, perhaps it was an older tutorial. Do you have a link?","Q_Score":0,"Tags":"ipython-notebook","A_Id":33089553,"CreationDate":"2015-10-12T20:02:00.000","Title":"Missing 'Notebooks' tab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed iPython Notebook as a component of my Anaconda installation.  To become familiar with using iPython Notebook I started through an introductory tutorial and immediately ran into a discrepancy.  When I open the notebook the tutorial shows I should have three tabs across the top labelled 'Notebooks', 'Running' and 'Clusters'.  Instead I have 'Files', 'Running' and 'Clusters'.  I cannot figure out how to switch the Files tab to the Notebooks tab...or is the Files tab correct and is the tutorial out-of-date?  I would much prefer to just have the Notebooks view as listing all the file folders just gets in the way.  Can someone tell me how to swap out the Files tab for the Notebooks tab?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":135,"Q_Id":33089288,"Users Score":0,"Answer":"To start the notebook in notebook server 4.2.1, go to file tab and on the top right side, you will see new drop down menu. Click on the python[root] and it should start the new notebook.","Q_Score":0,"Tags":"ipython-notebook","A_Id":39973387,"CreationDate":"2015-10-12T20:02:00.000","Title":"Missing 'Notebooks' tab","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to create multiple sockets between all users. \nSo how can i pass key and ID such as the server is divided in seprated windows.\nThank You.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":33126905,"Users Score":1,"Answer":"You do exactly that: you [can] pass around keys and make them show up in separate windows.\nFrom the way you've phrased your question, you appear new to streams\/sockets. I'd recommend you first start with one socket and make a chat application so you can get a feel for how to develop protocols which let you do that.","Q_Score":2,"Tags":"python,ios,objective-c,xcode,socketrocket","A_Id":33127431,"CreationDate":"2015-10-14T13:37:00.000","Title":"SocketRocket (iOS) : How to identify whom user are chatting with another?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program I want to open when I open Chrome. Instead of opening them separately, I want it to automatically start when Chrome starts. How would I write code to have the program attach itself to Chrome? I don't want the program to start on startup, just when Chrome starts. I know I can right click on the Chrome icon on my desktop and change the properties to open both programs but I want to know how to do the same thing with code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":33137569,"Users Score":0,"Answer":"Lots of options.  Which you should choose depends on lots of things.  Sorry for being so vague, but your question does not give any details besides the name Chrome.\n\nHow ever you start Chrome, e. g. by a button or menu of your window manager, maybe you can tweak that button or menu to start both programs.  This is probably the simplest solution, but of course it bears the risk that a different event starts Chrome (e. g. clicking a link in a mail program).  This would then pass-by your Program.\nYou can write a daemon process which you start via login-scripts at login time.  That daemon would try to figure out when you start Chrome (e. g. by polling the process table) and react by starting your accompanying program.\nYou can configure Chrome so that it starts your program upon starting time.  How to do this is a whole new question in itself with lots of answers; options include at least writing a plugin for Chrome which does what you want.\nYou can have your program up and running all the time (started via login scripts, i. e. too early) but stay invisible and passive until Chrome starts up.  This is basically the same as option 2, just that your program is itself that daemon.\n\nIn case you tell us more, we probably can give narrower and thus more fitting answers.","Q_Score":0,"Tags":"python","A_Id":33137802,"CreationDate":"2015-10-14T23:48:00.000","Title":"Python code to open with another program?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use a shared folder to share files in linux with a windows machine. However, after i have edited a python file using notepad++ in windows, changed the owner of the file to the user of ubuntu, and run the file, i wanted to edit the file again, when i save the file, I get the following error.\n\n'Please check whether if this file is opened in another program'\n\nis it concerned with the linux daemon?? If both machines are windows, i can edit it as administrator, but i am new to linux, i do not know how to deal with it?\nThanks for your help!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":33161725,"Users Score":0,"Answer":"Try to kill the process which is opening the python file\nor you can reboot your windows\nIt may resolve the problem","Q_Score":0,"Tags":"python,ubuntu","A_Id":33161926,"CreationDate":"2015-10-16T02:45:00.000","Title":"unable save file in a shared folder on a remote ubuntu machine using notepad++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've used Django ORM for one of my web-app and I'm very much comfortable with it. Now I've a new requirement which needs database but nothing else that Django offers. I don't want to invest more time in learning one more ORM like sqlalchemy.\nI think I can still do \nfrom django.db import models\nand create models, but then without manage.py how would I do migration and syncing?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15755,"Q_Id":33170016,"Users Score":0,"Answer":"I had to add import django, and then this worked.","Q_Score":26,"Tags":"python,django,orm","A_Id":67953078,"CreationDate":"2015-10-16T12:01:00.000","Title":"How to use Django 1.8.5 ORM without creating a django project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a code that makes Minimum Spanning Trees of many sets of points (about 25000 data sets containing 40-10000 points in each set) and this is obviously taking a while. I am using the MST algorithm from scipy.sparse.csgraph.\nI have been told that the MST is a subset of the Delaunay Triangulation, so it was suggested I speed up my code by finding the DT first and finding the MST from that.\nDoes anyone know how much difference this would make? Also, if this makes it quicker, why is it not part of the algorithm in the first place? If it is quicker to calculate the DT and then the MST, then why would scipy.sparse.csgraph.minimum_spanning_tree do something else instead?\nPlease note: I am not a computer whizz, some people may say I should be using a different language but Python is the only one I know well enough to do this sort of thing, and please use simple language in your answers, no jargon please!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":659,"Q_Id":33172090,"Users Score":1,"Answer":"NB: this assumes we're working in 2-d\nI suspect that what you are doing now is feeding all point to point distances to the MST library. There are on the order of N^2 of these distances and the asymptotic runtime of Kruskal's algorithm on such an input is N^2 * log N.\nMost algorithms for Delaunay triangulation take N log N time. Once the triangulation has been computed only the edges in the triangulation need to be considered (since an MST is always a subset of the triangulation). There are O(N) such edges so the runtime of Kruskal's algorithm in scipy.sparse.csgraph should be N log N. So this brings you to an asymptotic time complexity of N log N.  \nThe reason that scipy.sparse.csgraph doesn't incorporate Delaunay triangulation is that the algorithm works on arbitrary input, not only Euclidean inputs.\nI'm not quite sure how much this will help you in practice but that's what it looks like asymptotically.","Q_Score":0,"Tags":"python,algorithm,performance,minimum-spanning-tree,delaunay","A_Id":33175701,"CreationDate":"2015-10-16T13:45:00.000","Title":"Speed up Python MST calculation using Delaunay Triangulation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does Google App engine support multithreading? I am seeing conflicting reports on the web.\nBasically, I am working on a module that communicates with Apple Push Notification server (APNS).  It uses a worker thread that constantly looks for new messages that need to be pushed to client devices in a pull queue.\nAfter it gets a message and sends it to APNS, I want it to start another thread that checks if APNS sends any error response in return.  Basically, look for incoming bytes on same socket (it can only be error response per APNS spec). If nothing comes in 60s since the last message send time in the main thread, the error response thread terminates.\nWhile this \"error response handler\" thread is waiting for bytes from APNS (using a select on the socket), I want the main thread to continue looking at the pull queue and send any packets that come immediately.\nI tried starting a background thread to do the function of the error response handler.  But this does not work as expected since the threads are executed serially.  I.e control returns to the main thread only after the error response thread has finished its 60s wait.  So, if there are messages that arrive during this time they sit in the queue.\nI tried threadsafe: false in .yaml\nMy questions are:\n\nIs there any way to have true multithreading in GAE.  I.e the main thread and the error response thread execute in parallel in the above example instead of forcing one to wait while other executes?\nIf no, is there any solution to the problem I am trying to solve?  I tried kick-starting a new instance to handle the error response (basically use a push queue), but I don't know how to pass the socket object the error response thread will have to listen to as a parameter to this push queue task (since dill is not supported to serialize socket objects)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":921,"Q_Id":33183963,"Users Score":0,"Answer":"Found the issue.  I was calling start_background_thread with argument set to function().  When I fixed it to calling it as function it worked as expected.","Q_Score":0,"Tags":"multithreading,python-2.7,sockets,google-app-engine,apple-push-notifications","A_Id":33184298,"CreationDate":"2015-10-17T07:18:00.000","Title":"Multi-threading on Google app engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In Django, how does one give an attribute field name an alias that can be used to manipulate a queryset? \nBackground: I have a queryset where the underlying model has an auto-generating time field called \"submitted_on\". I want to use an alias for this time field (i.e. \"date\"). Why? Because I will concatenate this queryset with another one (with the same underlying model), and then order_by('-date'). Needless to say, this latter qset already has a 'date' attribute (attached via annotate()).  \nHow do I make a 'date' alias for the former queryset? Currently, I'm doing something I feel is an inefficient hack: qset1 = qset1.annotate(date=Max('submitted_on')) \nI'm using Django 1.5 and Python 2.7.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":452,"Q_Id":33187572,"Users Score":0,"Answer":"Even if you could do this, it wouldn't help solve your ultimate problem. You can't use order_by on concatenated querysets from different models; that can't possibly work, since it is a request for the database to do an ORDER BY on the query.","Q_Score":1,"Tags":"python,django","A_Id":33187887,"CreationDate":"2015-10-17T14:11:00.000","Title":"Making an alias for an attribute field, to be used in a django queryset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Django, how does one give an attribute field name an alias that can be used to manipulate a queryset? \nBackground: I have a queryset where the underlying model has an auto-generating time field called \"submitted_on\". I want to use an alias for this time field (i.e. \"date\"). Why? Because I will concatenate this queryset with another one (with the same underlying model), and then order_by('-date'). Needless to say, this latter qset already has a 'date' attribute (attached via annotate()).  \nHow do I make a 'date' alias for the former queryset? Currently, I'm doing something I feel is an inefficient hack: qset1 = qset1.annotate(date=Max('submitted_on')) \nI'm using Django 1.5 and Python 2.7.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":452,"Q_Id":33187572,"Users Score":0,"Answer":"It seems qset1 = qset1.annotate(date=Max('submitted_on')) is the closest I have right now. This, or using exclude(). I'll update if I get a better solution. Of course other experts from SO are welcome to chime in with their own answers.","Q_Score":1,"Tags":"python,django","A_Id":33192349,"CreationDate":"2015-10-17T14:11:00.000","Title":"Making an alias for an attribute field, to be used in a django queryset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm quite new to whole Selenim thing and I have a simple question.\nWhen I run tests (Django application) on my local machine, everything works great. But how this should be done on server? There is no X, so how can I start up webdriver there? What's the common way?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":33231156,"Users Score":0,"Answer":"I suggest you use a continuous integration solution like Jenkins to run your tests periodically.","Q_Score":0,"Tags":"python,django,selenium,selenium-webdriver","A_Id":33231191,"CreationDate":"2015-10-20T08:01:00.000","Title":"Selenium on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using OpenCV 3.0.0 on Python 2.7.9. I'm trying to track an object in a video with a still background, and estimate some of its properties. Since there can be multiple moving objects in an image, I want to be able to differentiate between them and track them individually throughout the remaining frames of the video.\nOne way I thought I could do that was by converting the image to binary, getting the contours of the blobs (tracked object, in this case) and get the coordinates of the object boundary. Then I can go to these boundary coordinates in the grayscale image, get the pixel intensities surrounded by that boundary, and track this color gradient\/pixel intensities in the other frames. This way, I could keep two objects separate from each other, so they won't be considered as new objects in the next frame.\nI have the contour boundary coordinates, but I don't know how to retrieve the pixel intensities within that boundary. Could someone please help me with that?\nThanks!","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":32084,"Q_Id":33234363,"Users Score":3,"Answer":"Answer from @rayryeng is excellent!\nOne small thing from my implementation is:\nThe np.where() returns a tuple, which contains an array of row indices and an array of column indices. So, pts[0] includes a list of row indices, which correspond to height of the image, pts[1] includes a list of column indices, which correspond to the width of the image. The img.shape returns (rows, cols, channels). So I think it should be img[pts[0], pts[1]] to slice the ndarray behind the img.","Q_Score":15,"Tags":"python,image,opencv,image-processing,opencv-contour","A_Id":42767296,"CreationDate":"2015-10-20T10:35:00.000","Title":"Access pixel values within a contour boundary using OpenCV in Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if I have really logged in to the website using correct credentials","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":33236054,"Users Score":0,"Answer":"HTTP status codes are usually meant for the browsers, or in case of APIs for the client talking to the server. For normal web sites, using status codes for semantical error information is not really useful. Overusing the status codes there could even cause the browser to not render responses correctly.\nSo for normal HTML responses, you would usually expect a code 200 for almost everything.\nIn order to check for errors, you will then have to check the\u2014application specific\u2014error output from the HTML response. A good way to find out about these signs is to just try logging in from the browser with invalid credentials and then check what output is rendered. Or as many sites also show some kind of user menu once you\u2019re logged in, check for its existence to figure out if you\u2019re logged in. And when it\u2019s not there, the login probably failed.","Q_Score":1,"Tags":"python,python-requests","A_Id":33236211,"CreationDate":"2015-10-20T11:58:00.000","Title":"How to verify that we have logged in correctly to a website using requests in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if I have really logged in to the website using correct credentials","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":33236054,"Users Score":0,"Answer":"What status code the site responds with depends entirely on their implementation; you're more likely to get a non-200 response if you're attempting to log in to a web service. If a login attempt yielded a non-200 response on a normal website, it'd require a special handler on their end, as opposed to a 200 response with a normal page prompting you (presumably a human user, not a script) with a visual cue indicating login failure.\nIf the site you're logging into returns a 200 regardless of success or failure, you may need to use something like lxml or BeautifulSoup to look for indications of success or failure (which presumably you'll be using already to process whatever it is you're logging in to access).","Q_Score":1,"Tags":"python,python-requests","A_Id":33236191,"CreationDate":"2015-10-20T11:58:00.000","Title":"How to verify that we have logged in correctly to a website using requests in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have problem with os.access(filename, os.R_OK) when file is an absolute path on a Linux system with space in the filename. I have tried many ways of quoting the space, from \"'\" + filename + \"'\" to filename.replace(' ', '\\\\ ') but it doesn't work.\nHow can I escape the filename so my shell knows how to access it? In terminal I would address it as '\/home\/abc\/LC\\ 1.a'","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4377,"Q_Id":33241211,"Users Score":6,"Answer":"You don't need to (and shouldn't) escape the space in the file name. When you are working with a command line shell, you need to escape the space because that's how the shell tokenizes the command and its arguments. Python, however, is expecting a file name, so if the file name has a space, you just include the space.","Q_Score":3,"Tags":"python,linux,file,space","A_Id":33241435,"CreationDate":"2015-10-20T15:52:00.000","Title":"Handling a literal space in a filename","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to list name of users who tweeted with given keyword along with count of tweets from them ?\nI am using python and tweepy.\nI used tweepy to list JSON result in a file  by filter(track[\"keyword\"])\nbut doesn't know how to list users who tweeted given keyword.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":578,"Q_Id":33273885,"Users Score":0,"Answer":"Once your data has been loaded into JSON format, you can access the username by calling tweet['user']['screen_name']. Where tweet is whatever varibale you have assigned that holds the JSON object for that specific tweet.","Q_Score":0,"Tags":"python,api,twitter,tweepy,twitter-streaming-api","A_Id":33290201,"CreationDate":"2015-10-22T05:22:00.000","Title":"how to list all users who tweeted a given keyword using twitter api and tweepy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed a Python\/Django application for a company. In this app all the employees of the company have a username and a password to login in. Now there is a need for a phone application that can do some functionality.\nIn some functions I have the decorator @login_required\nFor security reasons I would like to work with this decorator than against it, so how do I?\nI'm using PhoneGap (JavaScript\/JQuery) to make the phone app if that helps. I can do my own research but I just need a starting point. Do I get some sort of token and keep it in all my HTTP request headers?\nFirst Attempt:\nI was thinking that maybe I POST to the server and get some kind of Authentication Token or something. Maybe there is some Javascript code that hashes my password using the same algorithm so that I can compare it to the database.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":33294758,"Users Score":0,"Answer":"You would need to either expose the django token in the settings file so that it can be accessed via jquery, or that decorator wont be accessible via mobile. Alternatively, you can start using something like oauth","Q_Score":1,"Tags":"javascript,python,django,cordova,authentication","A_Id":33294839,"CreationDate":"2015-10-23T04:12:00.000","Title":"Login in from Phone App","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract the data from webpage after log in. To log in website, i can see the token (authenticity_token) in Form Data section. It seems, token   generating automatically.I am trying to get token values but no luck.Please anyone help me on this,how to get the token value while sending the post requests.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":33321076,"Users Score":0,"Answer":"You need to get the response from the page then regex match for token.","Q_Score":0,"Tags":"python,session,cookies,python-requests","A_Id":33321212,"CreationDate":"2015-10-24T17:19:00.000","Title":"How to get token value while sending post requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to extract the data from webpage after log in. To log in website, i can see the token (authenticity_token) in Form Data section. It seems, token   generating automatically.I am trying to get token values but no luck.Please anyone help me on this,how to get the token value while sending the post requests.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":33321076,"Users Score":0,"Answer":"token value is stored in the cookie file..check the cookie file and extract the value from it..\nfor example,a cookie file after login contain jsession ID=A01~xxxxxxx\nwhere 'xxxxxxx' is the token value..extract this value..and post this value","Q_Score":0,"Tags":"python,session,cookies,python-requests","A_Id":37413165,"CreationDate":"2015-10-24T17:19:00.000","Title":"How to get token value while sending post requests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently learning how to use Django. I want to make a web app where you as a user can join groups. These groups have content that just members of this group should be able to see. I learned about users, groups and a bit of authentication. \nMy first impression is, that this is more about the administration of the website itself and I cannot really believe that I can solve my idea with it.\nI just want to know if thats the way to go in Django. I probably have to create groups in Django that have the right to see the content of the group on the website. But that means that everytime a group is created, I have to create a django group. Is that an overkill or the right way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":33328730,"Users Score":0,"Answer":"Groups in django (django.contrib.auth) are used to specify certain rights of viewing content mainly in the admin to certain users. I think your group functionality might be more custom than this and that you're better of creating your own group models, and making your own user and group management structure that suits the way your website is used better.","Q_Score":0,"Tags":"python,django","A_Id":33329001,"CreationDate":"2015-10-25T10:41:00.000","Title":"How to organize groups in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going to write some HTTP (REST) client in Python. This will be a Command Line Interface tool with no gui. I won't use any business logic objects, no database, just using an API to communicate with the server (using Curl). Would you recommend me some architectual patterns for doing that, except for Model View Controller? \nNote: I am not asking for a design patterns like Command or Strategy. I just want to know how to segregate and decouple abstraction layers.\nI think using MVC is pointless regarding the fact of not having a business logic - please correct me if I'm wrong. Please give me your suggestions!\nDo you know any examples of CLI projects (in any language, not necessarily in Python) that are well maintained and with clean code?\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":355,"Q_Id":33353398,"Users Score":0,"Answer":"Since your app is not very complex, I see 2 layers here:\n\nServerClient: it provides API for remote calls and hides any details. It knows how to access HTTP server, provide auth, deal with errors etc. It has methods like do_something_good() which anyone may call and do not care if it remote method or not.\nCommandLine: it uses optparse (or argparse) to implement CLI, it may support history etc. This layer uses ServerClient to access remote service.\n\nBoth layers do not know anything about each other (only protocol like list of known methods). It will allow you to use somethign instead of HTTP Rest and CLI will still work. Or you may change CLI with batch files and HTTP should work.","Q_Score":0,"Tags":"python,design-patterns,command-line-interface,restful-architecture,n-tier-architecture","A_Id":33353621,"CreationDate":"2015-10-26T18:50:00.000","Title":"Architectual pattern for CLI tool","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've installed the azure SDK for Python (pip install azure).\nI've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook.\nI've replaced all the place holders in the script with actual values as noted in the scripts comments.\nWhen I run the script I get the error: \"NameError: global name 'BlobService' is not defined\" at the script line \"blob_service = BlobService(account_name=storage_account_name, account_key=storage_account_key)\".\nSince the \"from azure.storage import *\" line at the beginning of the script does not generate an error I'm unclear as to what the problem is and don't know how to fix it.  Can anyone point me to what I should correct?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3863,"Q_Id":33353968,"Users Score":0,"Answer":"BlobService is function you are trying to call, but it is not defined anywhere. It should be defined when you call from azure.storage import *. It is probably not being called, due to a difference in package versions.\nCalling from azure.storage.blob import * should work, as it is now invoked correctly.","Q_Score":0,"Tags":"python,azure","A_Id":42435442,"CreationDate":"2015-10-26T19:25:00.000","Title":"How do I fix the 'BlobService' is not defined' error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've installed the azure SDK for Python (pip install azure).\nI've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook.\nI've replaced all the place holders in the script with actual values as noted in the scripts comments.\nWhen I run the script I get the error: \"NameError: global name 'BlobService' is not defined\" at the script line \"blob_service = BlobService(account_name=storage_account_name, account_key=storage_account_key)\".\nSince the \"from azure.storage import *\" line at the beginning of the script does not generate an error I'm unclear as to what the problem is and don't know how to fix it.  Can anyone point me to what I should correct?","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3863,"Q_Id":33353968,"Users Score":0,"Answer":"It's been a long time since I did any Python, but BlobStorage is in the azure.storage.blob namespace I believe.\nSo I don't think your from azure.storage import * is pulling it in.\nIf you've got a code sample in a book which shows otherwise it may just be out of date.","Q_Score":0,"Tags":"python,azure","A_Id":33354366,"CreationDate":"2015-10-26T19:25:00.000","Title":"How do I fix the 'BlobService' is not defined' error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've installed the azure SDK for Python (pip install azure).\nI've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook.\nI've replaced all the place holders in the script with actual values as noted in the scripts comments.\nWhen I run the script I get the error: \"NameError: global name 'BlobService' is not defined\" at the script line \"blob_service = BlobService(account_name=storage_account_name, account_key=storage_account_key)\".\nSince the \"from azure.storage import *\" line at the beginning of the script does not generate an error I'm unclear as to what the problem is and don't know how to fix it.  Can anyone point me to what I should correct?","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3863,"Q_Id":33353968,"Users Score":1,"Answer":"James, I figured it out.  I just changed from azure.storage import * to azure.storage.blob import * and it seems to be working.","Q_Score":0,"Tags":"python,azure","A_Id":33355053,"CreationDate":"2015-10-26T19:25:00.000","Title":"How do I fix the 'BlobService' is not defined' error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In eclipse, I'm used to configuring the buildpath for versions of java installed on my computer. \nI recently added Python 3.5 to my computer and want to use it in place of the default 2.7 that Macs automatically include.\nHow can I configure my build path on PyDev, if there is such as concept to begin with, for the plugin? I've found that Python 3.5 is located at\/Library\/Frameworks\/Python.framework\/; how can I now change PyDev to use it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1264,"Q_Id":33405411,"Users Score":3,"Answer":"First check whether python3.5 is auto-configured in eclipse.\nGo to Window>Preferences \nOn the preferences window you will find PyDev configurations on left pan.\nPyDev>Interpreters>Python Interpreter\nIf python3.5 is not listed you can either add using \"Quick Auto-Config\" or if you want to add manually click \"New\" then add give the interpreter name (ex:Py3.5) and then browse to the path of python executable (In your case inside \/Library\/Frameworks\/Python.framework\/)\nOnce you have configured your interpreter in PyDev then you can change the interpreter of your project.\nRight click on your project>Properties\nOn the left pan click PyDev-Interpreter.In that select the name of the  PythonInterpreter(Py3.5) which you previously configured and you can also select the grammar version.","Q_Score":1,"Tags":"python,eclipse,pydev","A_Id":33405546,"CreationDate":"2015-10-29T03:21:00.000","Title":"How to change build path on PyDev","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if any of you could give me a walk through on how to remove an element from a linked list in python, I'm not asking for code but just kinda a pseudo algorithm in english. for example I have the linked list of \n1 -> 2 -> 2 -> 3 -> 4 and I want to remove one of the 2's how would i do that? I thought of traversing through the linked list, checking to see if the data of one of the nodes is equal to the data of the node after it, if it is remove it. But I'm having trouble on the removing part. Thanks!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3800,"Q_Id":33418316,"Users Score":0,"Answer":"You don't need to \"delete\" the node, just \"skip\" it.  That is, change Node1's next member to the second Node2.  \nEdit your question if you would like specific code examples (which are the norm for this site).","Q_Score":2,"Tags":"python,list","A_Id":33418551,"CreationDate":"2015-10-29T15:26:00.000","Title":"removing an element from a linked list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if any of you could give me a walk through on how to remove an element from a linked list in python, I'm not asking for code but just kinda a pseudo algorithm in english. for example I have the linked list of \n1 -> 2 -> 2 -> 3 -> 4 and I want to remove one of the 2's how would i do that? I thought of traversing through the linked list, checking to see if the data of one of the nodes is equal to the data of the node after it, if it is remove it. But I'm having trouble on the removing part. Thanks!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3800,"Q_Id":33418316,"Users Score":0,"Answer":"You can do something like:\nif element.next.value == element.value:\n    element.next = element.next.next \nJust be carefull to free the memory if you are programing this in C\/C++ or other language that does not have GC","Q_Score":2,"Tags":"python,list","A_Id":33418852,"CreationDate":"2015-10-29T15:26:00.000","Title":"removing an element from a linked list in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use \"tkinter\", \"opencv\" (cv2) and \"numpy\" in windows(8 - 64 bit and x64) with python2.7 - the same as I have running perfectly well in Linux (Elementary and DistroAstro) on other machines. I've downloaded the up to date Visual Studio and C++ compiler and installed these, as well as the latest version of PIP following error messages with the first attempts with PIP and numpy\n\nfirst I tried winpython, which already has numpy present but this comes without tkinter, although openCV would install. I don't want to use qt.\nso I tried vanilla Python, which installs to Python27. Numpy won't install with PIP or EasyInstall (unless it takes over an hour -same for SciPy), and the -.exe installation route for Numpy bombs becausee its looking for Python2.7 (not Python27). openCV won't install with PIP (\"no suitable version\")\nextensive searches haven't turned up an answer as to how to get a windows Python 2.7.x environment with all three of numpy, tkinter and cv2 working.\n\nAny help would be appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":33418678,"Users Score":0,"Answer":"Finally did it with .whl files. Download them, copy to C:\\python27\\Scripts and then open \"cmd\" and navigate to that folder with \"cd\\\" etc. Once there run:\npip install numpy-1.10.1+mkl-cp27-none-win_amd64.whl\nfor example.\nIn IDLE I then get:\nimport numpy\nnumpy.version\n'1.10.1'","Q_Score":0,"Tags":"python,windows,opencv,numpy,tkinter","A_Id":33434056,"CreationDate":"2015-10-29T15:41:00.000","Title":"tkinter opencv and numpy in windows with python2.7","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to use \"tkinter\", \"opencv\" (cv2) and \"numpy\" in windows(8 - 64 bit and x64) with python2.7 - the same as I have running perfectly well in Linux (Elementary and DistroAstro) on other machines. I've downloaded the up to date Visual Studio and C++ compiler and installed these, as well as the latest version of PIP following error messages with the first attempts with PIP and numpy\n\nfirst I tried winpython, which already has numpy present but this comes without tkinter, although openCV would install. I don't want to use qt.\nso I tried vanilla Python, which installs to Python27. Numpy won't install with PIP or EasyInstall (unless it takes over an hour -same for SciPy), and the -.exe installation route for Numpy bombs becausee its looking for Python2.7 (not Python27). openCV won't install with PIP (\"no suitable version\")\nextensive searches haven't turned up an answer as to how to get a windows Python 2.7.x environment with all three of numpy, tkinter and cv2 working.\n\nAny help would be appreciated!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":33418678,"Users Score":0,"Answer":"small remark: WinPython has tkinter, as it's included by Python Interpreter itself","Q_Score":0,"Tags":"python,windows,opencv,numpy,tkinter","A_Id":33441221,"CreationDate":"2015-10-29T15:41:00.000","Title":"tkinter opencv and numpy in windows with python2.7","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a pivot table which has an index of dates ranging from 01-01-2014 to 12-31-2015. I would like the index to range from 01-01-2013 to 12-31-2016 and do not know how without modifying the underlying dataset by inserting a row in my pandas dataframe with those dates in the column I want to use as my index for the pivot table.\nIs there a way to accomplish this wihtout modifying the underlying dataset?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":214,"Q_Id":33420633,"Users Score":0,"Answer":"I'm going to be general here, since there was no sample code or data provided. Let's say your original dataframe is called df and has columns Date and Sales.\nI would try creating a list that has all dates from 01-01-2014 to 12-31-2015. Let's call this list dates. I would also create an empty list called sales (i.e. sales = []). At the end of this workflow, sales should include data from dt['Sales'] AND placeholders for dates that are not within the data frame. In your case, these placeholders will be 0. In my answer, the names of the columns in the dataframe are capitalized; names of lists start with a lower case. \nNext, I would iterate through dates and check to see if each date is in dt['Date']. Each iteration through the list dates will be called date (i.e. date = dates[i]).\n\nIf date is in dt['Date'], I would append the Sales data for that date into sales. You can find the date in the dataframe through this command: df['Date']==date.  So, to append the corresponding Sales data into the list, I would use this command sales.append(df[df['Date']==date]['Sales'].\nIf date is NOT in dt['Date'], I would append a placeholder into sales (i.e. sales.append(0).\n\nOnce you iterate through all the dates in the list, I would create the final dataframe with dates and sales. The final dataframe should have both your original data and placeholders for dates that were not in the original data.","Q_Score":1,"Tags":"python,python-2.7,pandas,dataframe,pivot-table","A_Id":33421040,"CreationDate":"2015-10-29T17:14:00.000","Title":"Padding python pivot tables with 0","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Sublime Text Editor for Python development. If I create a new file by Ctrl + N, the default language setting for this file is Plain Text, so how to change the default language setting for the new file to be Python ?\nAnother question :If I write some code in the new file and have not save it to disk, it is impossible to run it and get the running result, is there a solution to remove this restriction so that we can run code in the new file without saving it to disk first?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2066,"Q_Id":33449969,"Users Score":1,"Answer":"The second question about running without saving to hard disk:\n1-press ctrl + shift + p \n2- write install package and install it\n3- write \"auto save\" and install it\n4- go to preferences> package settings> Auto-save> Settings Default and copy all the code\n5- go to preferences> package settings> Auto-save> Settings user and past it and change the first code from:\n\"auto_save_on_modified\": false,\nto\n\"auto_save_on_modified\": true,\ngood luck","Q_Score":5,"Tags":"python,sublimetext2,sublimetext3,sublimetext,sublime-text-plugin","A_Id":55436658,"CreationDate":"2015-10-31T09:20:00.000","Title":"Sublime Text: run code in a new file without saving to disk and the default language setting for a new file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been tasked with solving a sentiment classification problem using scikit-learn, python, and mapreduce. I need to use mapreduce to parallelize the project, thus creating multiple SVM classifiers. I am then supposed to \"average\" the classifiers together, but I am not sure how that works or if it is even possible. The result of the classification should be one classifier, the trained, averaged classifier. \nI have written the code using scikit-learn SVM Linear kernel, and it works, but now I need to bring it into a map-reduce, parallelized context, and I don't even know how to begin.\nAny advice?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":33450285,"Users Score":0,"Answer":"Make sure that all of the required libraries (scikit-learn, NumPy, pandas) are installed on every node in your cluster.\nYour mapper will process each line of input, i.e., your training row and emit a key that basically represents the fold for which you will be training your classifier.\nYour reducer will collect the lines for each fold and then run the sklearn classifier on all lines for that fold.\nYou can then average the results from each fold.","Q_Score":1,"Tags":"python,mapreduce,scikit-learn,svm","A_Id":35586970,"CreationDate":"2015-10-31T09:59:00.000","Title":"Combining SVM Classifiers in MapReduce","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a huge dataframe, and I index it like so:\ndf.ix[<integer>]\nDepending on the index, sometimes this will have only one row of values.  Pandas automatically converts this to a Series, which, quite frankly, is annoying because I can't operate on it the same way I can a df.  \nHow do I either:\n1)  Stop pandas from converting and keep it as a dataframe ?\nOR\n2)  easily convert the resulting series back to a dataframe ?\npd.DataFrame(df.ix[<integer>]) does not work because it doesn't keep the original columns.  It treats the <integer> as the column, and the columns as indices.  Much appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1239,"Q_Id":33458865,"Users Score":8,"Answer":"You can do df.ix[[n]] to get a one-row dataframe of row n.","Q_Score":5,"Tags":"python,pandas,dataframe,series","A_Id":33458868,"CreationDate":"2015-11-01T03:15:00.000","Title":"how to make 1 by n dataframe from series in pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This question is on Augmented Dickey\u2013Fuller test implementation in statsmodels.tsa.stattools python library - adfuller().\nIn principle, AIC and BIC are supposed to compute information criterion for a set of available models and pick up the best (the one with the lowest information loss).\nBut how do they operate in the context of Augmented Dickey\u2013Fuller?\nThe thing which I don't get: I've set maxlag=30, BIC chose lags=5 with some informational criterion. I've set maxlag=40 - BIC still chooses lags=5 but the information criterion have changed! Why in the world would information criterion for the same number of lags differ with maxlag changed?\nSometimes this leads to change of the choice of the model, when BIC switches from lags=5 to lags=4 when maxlag is changed from 20 to 30, which makes no sense as lag=4 was previously available.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1081,"Q_Id":33464294,"Users Score":2,"Answer":"When we request automatic lag selection in adfulller, then the function needs to compare all models up to the given maxlag lags. For this comparison we need to use the same observations for all models. Because lagged observations enter the regressor matrix we loose observations as initial conditions corresponding to the largest lag included.\nAs a consequence autolag uses nobs - maxlags observations for all models. For calculating the test statistic for adfuller itself, we don't need model comparison anymore and we can use all observations available for the chosen lag, i.e. nobs - best_lag.\nMore general, how to treat initial conditions and different number of initial conditions is not always clear cut, autocorrelation and partial autocorrelation are largely based on using all available observations, full MLE for AR and ARMA models uses the stationary model to include the initial conditions, while conditional MLE or least squares drops them as necessary.","Q_Score":3,"Tags":"python,statsmodels","A_Id":33479441,"CreationDate":"2015-11-01T16:16:00.000","Title":"How exactly BIC in Augmented Dickey\u2013Fuller test work in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just made a mess in my local Django project and realized that somehow I'm out of sync with my migrations. I tried to apply initial and realized that some of the tables already exist, so I tried --fake. This made the migration pass, but now I'm missing the one table I just wanted to add... how can I prepare migration just for one model or make Django re-discover what my database is missing and create that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":941,"Q_Id":33465153,"Users Score":0,"Answer":"I was using a models directory. Adding an import of the model to __init__.py allowed me to control whether it's visible to makemigrations or not. I found that using strace.","Q_Score":0,"Tags":"python,django,django-migrations","A_Id":33465379,"CreationDate":"2015-11-01T17:43:00.000","Title":"Django Migrations - how to insert just one model?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need several very similar plotting functions in python that share many arguments, but differ in some and of course also differ slightly in what they do. This is what I came up with so far:\n\nObviously just defining them one after the other and copying the code they share is a possibility, though not a very good one, I reckon.\nOne could also transfer the \"shared\" part of the code to helper functions and call these from inside the different plotting functions. This would make it tedious though, to later add features that all functions should have.\nAnd finally I've also thought of implementing one \"big\" function, making possibly not needed arguments optional and then deciding on what to do in the function body based on additional arguments. This, I believe, would make it difficult though, to find out what really happens in a specific case as one would face a forest of arguments.\n\nI can rule out the first option, but I'm hard pressed to decide between the second and third. So I started wondering: is there another, maybe object-oriented, way? And if not, how does one decide between option two and three?\nI hope this question is not too general and I guess it is not really python-specific, but since I am rather new to programming (I've never done OOP) and first thought about this now, I guess I will add the python tag.\nEDIT:\nAs pointed out by many, this question is quite general and it was intended to be so, but I understand that this makes answering it rather difficult. So here's some info on the problem that caused me to ask:\nI need to plot simulation data, so all the plotting problems have simulation parameters in common (location of files, physical parameters,...). I also want the figure design to be the same. But depending on the quantity, some plots will be 1D, some 2D, some should contain more than one figure, sometimes I need to normalize the data or take a logarithm before plotting it. The output format might also vary.\nI hope this helps a bit.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":444,"Q_Id":33465685,"Users Score":0,"Answer":"More information needs to be given to fully understand the context. But, in a general sense, I'd do a mix of all of them. Use helper functions for \"shared\" parts, and use conditional statements too. Honestly, a lot of it comes down to just what is easier for you to do?","Q_Score":1,"Tags":"python,oop","A_Id":33465756,"CreationDate":"2015-11-01T18:32:00.000","Title":"What is a good way to implement several very similar functions?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So first, I know there are some answers out there for similar questions, but...my problem has to do with speed and memory efficiency.\nI have a 60 GB text file that has 17 fields and 460,368,082 records. Column 3 has the ID of the individual and the same individual can have several records in this file. Lets call this file, File A.\nI have a second file, File B, that has the ID of 1,000,000 individuals and I want to extract the rows of File A that have an ID that is in File B.\nI have a windows PC and I'm open to doing this in C or Python, or whatever is faster... but not sure how to do it fast and efficiently. \nSo far every solution I have come up with takes over 1.5 years according to my calculations.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":33469625,"Users Score":0,"Answer":"It sounds like what you want to do is first read File B, collecting the IDs.  You can store the IDs in a set or a dict.\nThen read File A.  For each line in File A, extract the ID, then see if it was in File B by checking for membership in your set or dict.  If not, then skip that line and continue with the next line.  If it is, then process that line as desired.","Q_Score":1,"Tags":"python,c++,text,extract","A_Id":33469697,"CreationDate":"2015-11-02T02:00:00.000","Title":"Extracting certain rows from a file that match a condition from another file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Requirement - I want to execute a command that uses ls, grep, head etc using pipes (|). I am searching for some pattern and extracting some info which is part of the query my http server supports.\nThe final output should not be too big so m assuming stdout should be good to use (I read about deadlock issues somewhere)\nCurrently, I use popen from subprocess module but I have my doubts over it.\n\nhow many simultaneous popen calls can be fired.\ndoes the result immediately come in stdout? (for now it looks the case but how to ensure it if the commands take long time)\nhow to ensure that everything is async - keeping close to single thread model?\n\nI am new to Python and links to videos\/articles are also appreciated. Any other way than popen is also fine.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":302,"Q_Id":33503134,"Users Score":1,"Answer":"You could use os.listdir or os.walk instead of ls, and the re module instead of grep.\nWrap everything up in a function, and use e.g. the map method from a multiprocessing.Pool object to run several of those in parallel. This is a pattern that works very well.\nIn Python3 you can also use Executors from concurrent.futures in a similar way.","Q_Score":0,"Tags":"python,python-3.x,asynchronous,scalability,popen","A_Id":33503827,"CreationDate":"2015-11-03T15:37:00.000","Title":"Async execution of commands in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an large frame of a wide array of elements. Within this frame, there are basically two different sides to the frame. Consider a widget x on the left side, which is placed by .grid(row=4, column=0). Padding is added to this object x, so it is actually x.grid(row=4, column=0, pady=10) Well, the opposite object, object y, is placed on the same row by y.grid(row=4, column=4), or something along those lines. I have this setup, but the pady on x is adding padding to y as well. I want there to be padding on one widget in the row-- not the entire row. Therefore, my paraphrased question is, how does one add padding to only one widget in a row, without adding padding to every object in that respective row?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":767,"Q_Id":33506328,"Users Score":0,"Answer":"The very definition of a row is that is the same height all the way across. That's what makes it a row. The same can be said for columns.\nTherefore, the tallest item in a row (height plus padding) is what controls the overall height of the row. The only control you have over smaller widgets is which sides of their too-large cell they stick to. \nFor example, if you want all widgets to be aligned along their tops, use sticky=\"n\", which causes the top of the widgets to \"stick\" to the top (north) side of the space they have been allocated. If you want them aligned along their bottoms, use sticky=\"s\". Providing neither \"n\" or \"s\" means they will be aligned along their midpoints.","Q_Score":0,"Tags":"python,tkinter,widget","A_Id":33507438,"CreationDate":"2015-11-03T18:19:00.000","Title":"How to add padding to a widget, but not the entire row's widgets, in tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I use Selenium I can see the Browser GUI, is it somehow possible to do with scrapy or is scrapy strictly command line based?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1636,"Q_Id":33510814,"Users Score":1,"Answer":"Scrapy by itself does not control browsers. \nHowever, you could start a Selenium instance from a Scrapy crawler. Some people design their Scrapy crawler like this. They might process most pages only using Scrapy but fire Selenium to handle some of the pages they want to process.","Q_Score":1,"Tags":"python,selenium,scrapy","A_Id":33521521,"CreationDate":"2015-11-03T23:09:00.000","Title":"Can scrapy control and show a browser like Selenium does?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have searched for long time but I could not find how to disable cookies for phantomjs using selenium with python . I couldn't understand the documentation of phantomjs.Please someone help me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":730,"Q_Id":33514313,"Users Score":4,"Answer":"Documentation suggests this driver.cookies_enabled = False, you can use it.","Q_Score":0,"Tags":"python,selenium,cookies,phantomjs","A_Id":33516899,"CreationDate":"2015-11-04T05:26:00.000","Title":"disabling Cookies on phantomjs using selenium with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm using openpyxl to put data validation to all rows that have \"Default\" in them. But to do that, I need to know how many rows there are.\nI know there is a way to do that if I were using Iterable workbook mode, but I also add a new sheet to the workbook and in the iterable mode that is not possible.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":117258,"Q_Id":33541692,"Users Score":68,"Answer":"ws.max_row will give you the number of rows in a worksheet.\nSince version openpyxl 2.4 you can also access individual rows and columns and use their length to answer the question.\nlen(ws['A'])\nThough it's worth noting that for data validation for a single column Excel uses 1:1048576.","Q_Score":38,"Tags":"python,excel,openpyxl","A_Id":33543305,"CreationDate":"2015-11-05T10:06:00.000","Title":"How to find the last row in a column using openpyxl normal workbook?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got several MR-3020's that I have flashed with OpenWRT and mounted a 16GB ext4 USB drive on it. Upon boot, a daemon shell script is started which does two things:\n1) It constantly looks to see if my main program is running and if not starts up the python script\n2) It compares the lasts heartbeat timestamp generated by my main program and if it is older than 10 minutes in the past kills the python process. #1 is then supposed to restart it.\nOnce running, my main script goes into monitor mode and collects packet information. It periodically stops sniffing, connects to the internet and uploads the data to my server, saves the heartbeat timestamp and then goes back into monitor mode.\nThis will run for a couple hours, days, or even a few weeks but always seems to die at some point. I've been having this issue for nearly 6 months (not exclusively) I've run out of ideas. I've got files for error, info and debug level logging on pretty much every line in the python script. The amount of memory used by the python process seems to hold steady. All network calls are encapsulated in try\/catch statements. The daemon writes to logread. Even with all that logging, I can't seem to track down what the issue might be. There doesn't seem to be any endless loops entered into, none of the errors (usually HTTP request when not connected to internet yet) are ever the final log record - the device just seems to freeze up randomly.\nAny advice on how to further track this down?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":33550976,"Users Score":0,"Answer":"It could be related to many things: things that I had to fix also: check the external power supply of the router, needs to be  stable, the usb drives could drain too much current than the port can handle, a simple fix is to add a externally powered usbhub or the same port but with capacitors in parallel to the powerline and at the beginning of the usb port where the drive is, maybe 1000uF","Q_Score":0,"Tags":"python,linux","A_Id":36415642,"CreationDate":"2015-11-05T17:25:00.000","Title":"Crashing MR-3020","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have access to a S3 bucket. I do not own the bucket. I need to check if new files were added to the bucket, to monitor it.\nI saw that buckets can fire events and that it is possible to make use of Amazon's Lambda to monitor and respond to these events. However, I cannot modify the bucket's settings to allow this.\nMy first idea was to sift through all the files and get the latest one. However, there are a lot of files in that bucket and this approach proved highly inefficient.\nConcrete questions:\n\nIs there a way to efficiently get the newest file in a bucket?\nIs there a way to monitor uploads to a bucket using boto?\n\nLess concrete question:\n\nHow would you approach this problem? Say you had to get the newest file in a bucket and print it's name, how would you do it?\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4530,"Q_Id":33551143,"Users Score":1,"Answer":"You are correct that AWS Lambda can be triggered when objects are added to, or deleted from, an Amazon S3 bucket. It is also possible to send a message to Amazon SNS and Amazon SQS. These settings needs to be configured by somebody who has the necessary permissions on the bucket.\nIf you have no such permissions, but you have the ability to call GetBucket(), then you can retrieve a list of objects in the bucket. This returns up to 1000 objects per API call.\nThere is no API call available to \"get the newest files\".\nThere is no raw code to \"monitor\" uploads to a bucket. You would need to write code that lists the content of a bucket and then identifies new objects.\nHow would I approach this problem? I'd ask the owner of the bucket to add some functionality to trigger Lambda\/SNS\/SQS, or to provide a feed of files. If this wasn't possible, I'd write my own code that scans the entire bucket and have it execute on some regular schedule.","Q_Score":2,"Tags":"python,api,amazon-web-services,amazon-s3,boto","A_Id":33590521,"CreationDate":"2015-11-05T17:34:00.000","Title":"How to monitor a AWS S3 bucket with python using boto?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As I understand it (please do correct misunderstandings, obviously), the mentioned projects\/technologies are as follows:-\nCrossover.io - A router for WAMP. Cross-language.\nWAMP - An async message passing protocol, supporting (among other things) Pub\/Sub and RPC. Cross-language.\ntwisted - An asynchronous loop, primarily used for networking (low-level). Python specific. As far as I can tell, current crossover.io implementation in python is built on top of twisted.\nklein - Built on top of twisted, emulating flask but asynchronously (and without the plugins which make flask easier to use). Python specific.\ndjango\/flask\/bottle - Various stacks\/solutions for serving web content. All are synchronous because they implement the WSGI. Python specific.\nHow do they interact? I can see, for example, how twisted could be used for network connections between various python apps, and WAMP between apps of any language (crossover.io being an option for routing).\nFor networking though, some form of HTTP\/browser based connection is normally needed, and that's where in Python django and alternatives have historically been used. Yet I can't seem to find much in terms of interaction between them and crossover\/twisted.\nTo be clear, there's things like crochet (and klein), but none of these seem to solve what I would assume to be a basic problem, that of saying 'I'd like to have a reactive user interface to some underlying python code'. Or another basic problem of 'I'd like to have my python code update a webpage as it's currently being viewed'.\nTraditionally I guess its handled with AJAX and similar on the webpage served by django et. al., but that seems much less scalable on limited hardware than an asynchronous approach (which is totally doable in python because of twisted and tornado et. al.).\nSummary\nIs there a 'natural' interaction between underlying components like WAMP\/twisted and django\/flask\/bottle? If so, how does it work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":263,"Q_Id":33577252,"Users Score":0,"Answer":"With a Web app using WAMP, you have two separate mechanisms: Serving the Web assets and the Web app then communicating with the backend (or other WAMP components). \nYou can use Django, Flask or any other web framework for serving the assets - or the static Web server integrated into Crossbar.io.\nThe JavaScript you deliver as part of the assets then connects to Crossbar.io (or another WAMP router), as do the backend or other components. This is then used to e.g. send data to display to the Web frontend or to transmit user input.","Q_Score":0,"Tags":"python,django,twisted,wamp-protocol,crossbar","A_Id":34815287,"CreationDate":"2015-11-06T23:37:00.000","Title":"How do crossover.io, WAMP, twisted (+ klein), and django\/flask\/bottle interact?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to implement a blob detector based on LOG, the steps are:\n\ncreating an array of n levels of LOG filters\nuse each of the filters on the input image to create a 3d array of h*w*n where h = height, w = width and n = number of levels.\nfind a local maxima and circle the blob in the original image.\n\nI already created the filters and the 3d array (which is an array of 2d images).\nI used padding to make sure I don't have any problems around the borders (which includes creating a constant border for each image and create 2 extra empty images).\nNow I'm trying to figure out how to find the local maxima in the array.\nI need to compare each pixel to its 26 neighbours (8 in the same picture and the 9 pixels in each of the two adjacent scales)\nThe brute force way of checking the pixel value directly seems ugly and not very efficient.\nWhats the best way to find a local maxima point in python using openCV?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1030,"Q_Id":33587761,"Users Score":0,"Answer":"I'd take advantage of the fact that dilations are efficiently implemented in OpenCV. If a point is a local maximum in 3d, then it is also in any 2d slice, therefore:\n\nDilate each image in the array with a 3x3 kernel, keep as candidate maxima the points whose intensity is unchanged.\nBrute-force test the candidates against their upper and lower slices.","Q_Score":0,"Tags":"python,opencv,image-processing,computer-vision","A_Id":33596513,"CreationDate":"2015-11-07T21:04:00.000","Title":"finding a local maximum in a 3d array (array of images) in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here's what I'm trying to do:\nI have an image.\nI want to take a circular region in the image, and have it appear as normal. \nThe rest of the image should appear darker. \nThis way, it will be as if the circular region is \"highlighted\".\nI would much appreciate feedback on how to do it in Python. \nManually, in Gimp, I would create a new layer with a color of gray (less than middle gray). I would then create a circualr region on that layer, and make it middle gray. Then I would change the blending mode to soft light. Essentially, anything that is middle gray on the top layer will show up without modification, and anything darker than middle gray would show up darker.\n(Ideally, I'd also blur out the top layer so that the transition isn't abrupt). \nHow can I do this algorithmically in Python? I've considered using the Pillow library, but it doesn't have these kinds of blend modes. I also considered using the Blit library, but I couldn't import (not sure it's maintained any more). Am open to scikit-image as well. I just need pointers on the library and some relevant functions. \nIf there's no suitable library, I'm open to calling command line tools (e.g. imagemagick) from within the Python code.\nThanks!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":687,"Q_Id":33603304,"Users Score":1,"Answer":"I finally did it with ImageMagick, using Python to calculate the various coordinates, etc.\nThis command will create the desired circle (radius 400, centered at (600, 600):\nconvert -size 1024x1024 xc:none -stroke black -fill steelblue -strokewidth 1 -draw \"translate 600,600 circle 0,0 400,0\" drawn.png \nThis command will then convert it to B\/W to get a rudimentary mask:\nconvert drawn.png -alpha extract mask.png\nThis command will blur the mask (radius 180, sigma 16):\nconvert -channel RGBA  -blur 100x16 mask.png mask2.png\nThe above three commands gives me the mask I need.\nThis command will darken the whole image (without the mask):\nconvert image.jpg -level 0%,130%,0.7 dark.jpg\nAnd this command will put all 3 images together (original image, darkened image, and mask):\ncomposite image.jpg dark.jpg mask2.png out.jpg","Q_Score":1,"Tags":"python,image-processing","A_Id":33729058,"CreationDate":"2015-11-09T06:03:00.000","Title":"Create a \"spotlight\" in an image using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"sns.lmplot(x=\"size\", y=\"tip\", data=tips)\ngives a scatter plot. By default the markers have no edges. \nHow can I add markeredges? Sometimes I prefer to use edges transparent facecolor. Especially with dense data. However, \nNeither markeredgewidth nor mew nor linewidths are accepted as keywords.\nDoes anyone know how to add edges to the markers?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1371,"Q_Id":33614947,"Users Score":1,"Answer":"As per the comment from @S\u00f6ren, you can add the markeredges with the keyword scatter_kws. For example scatter_kws={'linewidths':1,'edgecolor':'k'}","Q_Score":1,"Tags":"python,seaborn,marker","A_Id":46858249,"CreationDate":"2015-11-09T17:42:00.000","Title":"Add markeredges in seaborn lmplot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've created a new group named accountant. If an user of this group opens the res.partner form for example, he must be able to read all, but only modify some specific fields (the ones inside the tab Accountancy, for example).\nSo I set the permissions create, write, unlink, read to 0, 1, 0, 1 in the res.partner model for the accountant group.\nThe problem: if I'm an user of the accountant group and I go to the form of res.partner, I will see the Edit button, if I click on it, I will be able to modify any field I want (and I should not, only the ones inside the tab).\nSo I thought to duplicate the menuitem (put the attribute groups=\"accountant\" to the copy) and the form (put all fields readonly except for the content of the tab).\nThe problem: if I'm an user of a group over accountant group (with accountant in its implied_ids list), I will see both menuitems (the one which takes to the normal form and the one which takes to the duplicated form with the readonly fields).\nIs it possible to create a menuitem which opens a specific set of views depending on the group of the user who is clicking on the mentioned menuitem? Any ideas of how can I succesfully implement this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2097,"Q_Id":33627789,"Users Score":1,"Answer":"You cannot make few or some of the fields as 'readonly' in odoo based on the groups. If you need to do it, you can use the custom module 'smile_model_access_extension'. \nFor loading appropriate view on menu click you can create record of 'ir.actions.act_window' (view_ids) field of 'ir.action', where you can specify the sequence and type of view to be loaded when the menu action is performed. In your case you can specify the specific 'form view' for your action.","Q_Score":1,"Tags":"python,xml,python-2.7,odoo-8,odoo","A_Id":33636388,"CreationDate":"2015-11-10T10:23:00.000","Title":"How to allow an user of a group to modify specific parts of a form in Odoo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to morphologically close a volume with a ball structuring element created by the function SE3 = skimage.morphology.ball(8).\nWhen using closing = cv2.morphologyEx(volume_start, cv2.MORPH_CLOSE, SE) it returns TypeError: src data type = 0 is not supported\nDo you know how to solve this issue? \nThank you","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":16369,"Q_Id":33628679,"Users Score":15,"Answer":"Make sure volume_start is dtype=uint8. You can convert it with volume_start = np.array(volume_start, dtype=np.uint8).\nOr nicer:\nvolume_start = volume_start.astype(np.uint8)","Q_Score":9,"Tags":"python,opencv,mathematical-morphology","A_Id":44216923,"CreationDate":"2015-11-10T11:13:00.000","Title":"Python Opencv morphological closing gives src data type = 0 is not supported","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I added a new template file from my project. Now I don't know how to make the languages update or get the new template file. I've read that 2.5 has update_against_templates but it's not in 2.7. How will update my languages?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":33630137,"Users Score":1,"Answer":"Template updates now happen outside of Pootle.  The old update_against_template had performance problems and could get Pootle into a bad state.  To achieve the same functionality as update_against_templates do the following.  Assuming your project is myproject and you are updating language af:\n\nsync_store --project=myproject --language=af\npot2po -t af template af\nupdate_store --project=myproject --language=af\n\nYou can automate that in a script to iterate through all languages.  Use list_languages --project=myproject to get a list of all the active languages for that project.","Q_Score":1,"Tags":"python,django,pootle,translate-toolkit","A_Id":38104213,"CreationDate":"2015-11-10T12:36:00.000","Title":"what is update_against_templates in pootle 2.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So recently I've thought about trying IronPython. I've got my GUI configured, I got my .py file. I click Start in Visual Studio, and that thing pops up: The environment \"Unknown Python 2.7 [...]\". I have the environment in Solution Explorer set to the Unknown Python 2.7 and I have no idea how to change it. Installed 2.7, 3.5, IronPyhon 2.7 and refreshed them in Python Environments tab","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7496,"Q_Id":33638010,"Users Score":1,"Answer":"Go to Project ->  Properties -> General -> Interpreter\nSet the Interpreter to IronPython 2.7 (you may need to install it).","Q_Score":2,"Tags":"python,visual-studio-2015,ironpython","A_Id":38080053,"CreationDate":"2015-11-10T19:29:00.000","Title":"Visual Studio 2015 IronPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So recently I've thought about trying IronPython. I've got my GUI configured, I got my .py file. I click Start in Visual Studio, and that thing pops up: The environment \"Unknown Python 2.7 [...]\". I have the environment in Solution Explorer set to the Unknown Python 2.7 and I have no idea how to change it. Installed 2.7, 3.5, IronPyhon 2.7 and refreshed them in Python Environments tab","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":7496,"Q_Id":33638010,"Users Score":3,"Answer":"Generally the best approach to handle this is to right click \"Python Environments\" in Solution Explorer, then select \"Add\/remove environments\" and change what you have added in there.","Q_Score":2,"Tags":"python,visual-studio-2015,ironpython","A_Id":34078923,"CreationDate":"2015-11-10T19:29:00.000","Title":"Visual Studio 2015 IronPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It might be that this question sounds pretty silly but I can not figure out how to do this I believe the simplest issue (because just start learning Django).\nWhat I know is I should create a middleware file and connect it to the settings. Than create a view and a *.html page that will show these requests and write it to the urls.\n\nhow can one store last (5\/10\/20 or any) http requests in the middleware and show them in a *.html page? The problem is I don't even know what exactly should I write into middlaware.py and views.py in the way it could be displayed in the *.html file. Ideally, this page should be also updated after the new requests occur. I read Django documentation, some other topics with middleware examples but it seems to be pretty sophisticated for me. \n\nI would be really thankful for any insights and elucidates.\nP.S. One more time sorry for a dummy question.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1698,"Q_Id":33645899,"Users Score":2,"Answer":"You can implement your own RequestMiddleware (which plugs in before the URL resolution) or ViewMiddleware (which plugs in after the view has been resolved for the URL).\nIn that middleware, it's standard python. You have access to the filesystem, database, cache server, ... the same you have anywhere else in your code.\nShowing the last N requests in a separate web page means you create a view which pulls the data from the place where your middleware is storing them.","Q_Score":1,"Tags":"python,django,middleware","A_Id":33646559,"CreationDate":"2015-11-11T07:23:00.000","Title":"Python, Django - how to store http requests in the middleware?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If so, how would this be done? If not, is there a conventional way to achieve the same effect?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":463,"Q_Id":33646840,"Users Score":0,"Answer":"Thank you, PM 2Ring. \nFor posterity, the answer is that you can bind multiple callbacks to a signal in GTK3. They will be called in the order they were bound in.","Q_Score":0,"Tags":"python,callback,gtk3","A_Id":33658899,"CreationDate":"2015-11-11T08:39:00.000","Title":"Is it possible to set multiple callback functions for a given event with GTK (Python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a beginner to both Python and to this forum, so please excuse any vague descriptions or mistakes.  \nI have a problem regarding reading\/writing to a file. What I'm trying to do is to read a text from a file and then find the words that occur more than one time, mark them as repeated_word and then write the original text to another file but with the repeated words marked with star signs around them.   \nI find it difficult to understand how I'm going to compare just the words (without punctuation etc) but still be able to write the words in its original context to the file.   \nI have been recommended to use regex by some, but I don't know how to use it. Another approach is to iterate through the textstring and tokenize and normalize, sort of by going through each character, and then make some kind av object or element out of each word.    \nI am thankful to anyone who might have ideas on how to solve this. The main problem is not how to find which words that are repeated but how to mark them and then write them to the file in their context. Some help with the coding would be much appreciated, thanks. \nEDIT\nI have updated the code with what I've come up with so far. If there is anything you would consider \"bad coding\", please comment on it. \nTo explain the Whitelist class, the assignment has two parts, one of where I am supposed to mark the words and one regarding a whitelist, containing words that are \"allowed repetitions\", and shall therefore not be marked. \nI have read heaps of stuff about regex but I still can't get my head around how to use it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":33672506,"Users Score":0,"Answer":"OK. I presume that this is a homework assignment, so I'm not going to give you a complete solution. But, you really need to do a number of things. \nThe first is to read the input file in to memory. Then split it in to its component words (tokenize it) probably contained in a list, suitably cleaned up to remove stray punctuation. You seem to be well on your way to doing that, but I would recommend you look at the split() and strip() methods available for strings. \nYou need to consider whether you want the count to be case sensitive or not, and so you might want to convert each word in the list to (say) lowercase to keep this consistent. So you could do this with a for loop and the string lower() method, but a list-comprehension is probably better. \nYou then need to go through the list of words and count how many times each one appears. If you check out collections.Counter you will find that this does the heavy lifting for your or, alternatively, you will need to build a dictionary which has the words as keys and the count of the words. (You might also want to check out the collections.defaultdict class here as well).\nFinally, you need to go through the text you've read from the file and for each word it contains which has more than one match (i.e. the count in the dictionary or counter is > 1) mark it appropriately. Regular expressions are designed to do exactly this sort of thing. So I recommend you look at the re library.\nHaving done that, you simply then write the result to a file, which is simple enough. \nFinally, with respect to your file operations (reading and writing) I would recommend you consider replacing the try ... except construct with a with ... as one.","Q_Score":1,"Tags":"python,regex,python-3.x,repeat","A_Id":33673417,"CreationDate":"2015-11-12T13:26:00.000","Title":"Reading text from a file, then writing to another file with repetitions in text marked","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a clustering of data performed by a human based solely on their knowledge of the system. I also have a feature vector for each element. I have no knowledge about the meaning of the features, nor do I know what the reasoning behind the human clustering was.\nI have complete information about which elements belong to which cluster. I can assume that the human was not stupid and there is a way to derive the clustering from the features.\nIs there an intelligent way to reverse-engineer the clustering? That is, how can I select the features and the clustering algorithm that will yield the same clustering most of the time (on this data set)?\nSo far I have tried the naive approach - going through the clustering algorithms provided by the sklearn library in python and comparing the obtained clusters to the source one. This approach does not yield good results.\nMy next approach would be to use some linear combinations of the features, or subsets of features. Here, again, my question is if there is a more intelligent way to do this than to go through as many combinations as possible.\nI can't shake the feeling that this is a standard problem and I'm just missing the right term to find the solution on Google.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":33677932,"Users Score":0,"Answer":"Are you sure it was done automatically?\nIt sounds to me as if you should be treating this as a classification problem: construct a classifier that does the same as the human did.","Q_Score":0,"Tags":"python,scikit-learn,cluster-analysis,feature-selection","A_Id":33683680,"CreationDate":"2015-11-12T17:46:00.000","Title":"Reverse-engineering a clustering algorithm from the clusters","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand the difference between a queue and stack. But if I spawn multiple processes and send messages between them put in multiprocessing.Queue how do I access the latest element put in the queue first?","AnswerCount":3,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":3099,"Q_Id":33691392,"Users Score":-5,"Answer":"The multiprocessing.Queue is not a data type. It is a mean to communicate between two processes. It is not comparable to Stack\nThat's why there is no API to pop the last item off the queue.\nI think what you have in mind is to make some messages to have a higher priority than others. When they are sent to the listening process, you want to dequeue them as soon as possible, bypassing existing messages in the queue.\nYou can actually achieve this effect by creating two multiprocessing.Queue: One for normal data payload and another for priority message. Then you do not need to worry about getting the last item. Simply segregate two different type of messages into two queues.","Q_Score":11,"Tags":"python,queue,python-multiprocessing,lifo","A_Id":33691733,"CreationDate":"2015-11-13T11:10:00.000","Title":"How to implement LIFO for multiprocessing.Queue in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"when using pdb to debug a python script, repeating l command will continue listing the source code right after the previous listing. \n\nl(ist) [\ufb01rst[, last]] List source code for the current \ufb01le. Without\n  arguments, list 11 lines around the current line or continue the\n  previous listing. With one argument, list 11 lines around at that\n  line. With two arguments, list the given range; if the second argument\n  is less than the \ufb01rst, it is interpreted as a count.\n\nHow can I repeatedly show the current line (i.e. the line where the program running is paused), instead of continuing after the previous listing? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":849,"Q_Id":33696300,"Users Score":2,"Answer":"The direct way, of course, is to pass the line as an argument to l.\nBut without having to go through the trouble of finding the current line and typing it, the non-optimal way I usually do it is to return to the same line by navigating up+down the call stack, then listing again. The sequence of commands for that is: u (up), d (down), l.","Q_Score":1,"Tags":"python,python-2.7,pdb","A_Id":33710178,"CreationDate":"2015-11-13T15:34:00.000","Title":"pdb: how to show the current line, instead of continuing after the previous listing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to SublimeText and Python3, so I don't really know how to turn Sublime autocomplete on. I installed Anaconda from Package Control, but I don't know how to use it. Some autocomplete shows up, but I don't think it's Anaconda's. That autocomplete keeps on poping up, then dissapearing. I can't read what it says and it hurts my eyes. How can i properly set up the autocomplete?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":374,"Q_Id":33697893,"Users Score":1,"Answer":"in case you are still looking for the answer, I had a similar problem. I had both SublimeJEDI autocompletion as well as Anaconda. \nThe flashing behavior is a result of you having two separate autocompletes fighting for the same space. \nTurning off SublimeJEDI solved this for me - I couldn't find a way to turn off Anaconda's.","Q_Score":0,"Tags":"python-3.x,autocomplete,sublimetext3","A_Id":36128676,"CreationDate":"2015-11-13T16:54:00.000","Title":"SublimeText 3 Anaconda autocomplete bug","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm curious, how a good automated workflow could look like for the process of automating issues\/touched file lists into a confluence page. I describe my current idea here:\n\nGet all issues matching my request from JIRA using REST (DONE)\nGet all touched files related to the matching Issues using Fisheye REST\nCreate a .adoc file with the content\nRender it using asciidoctor-confluence to a confluence page\n\nI'm implementing the this in python (using requests etc.) and I wonder how I could provide proper .adoc for the ruby-based asciidoctor. I'm planning to use asciidoctor for the reason it has an option to render directly to confluence using asciidocter-confluence. \nSo, is there anybody who can kindly elaborate on my idea?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":649,"Q_Id":33756512,"Users Score":1,"Answer":"I did something similar - getting info from Jira and updating confluence info.\nI did it in a bash script that ran on Jenkins. The script:\n\nGot Jira info using the Jira REST API\nParsed the JSON from Jira using jq (wonderful tool)\nCreated\/updated the confluence page using the Confluence REST API\n\nI have not used python but the combination of bash\/REST\/jq was very simple. Running the script from Jenkins allowed me to run this periodically, so confluence is updated automatically every 2 weeks with the new info from Jira.","Q_Score":1,"Tags":"python,automation,jira,confluence,asciidoctor","A_Id":33761564,"CreationDate":"2015-11-17T12:06:00.000","Title":"Programmatically create confluence content from jira and fisheye","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I already have a function that converts an image to a matrix, and back. But I was wondering how to manipulate the matrix so that the picture becomes blurry, or pixified?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":33756970,"Users Score":0,"Answer":"To make it blurry filter it using any low-pass filter (mean filter, gaussian filter etc.).","Q_Score":0,"Tags":"python,image-processing","A_Id":33757187,"CreationDate":"2015-11-17T12:29:00.000","Title":"How can I blur or pixify images in python by using matrixes?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a Python package that has multiple subpackages. Each of those subpackages contain files that import the same specific module that is quite large in size. \nSo as an example, file A.py from subpackage A will import a module that is supposedly named LargeSizedModule and file B.py from subpackage B will also import LargeSizedModule. Similarly with C.py from subpackage C.\nDoes anyone know how I can efficiently import the same exact module across multiple subpackages? I would like to reduce the 'loading' time that comes from those duplicate imports.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1283,"Q_Id":33761192,"Users Score":6,"Answer":"By doing import LargeSizedModule everywhere you need it. Python will only load it once.","Q_Score":4,"Tags":"python","A_Id":33761211,"CreationDate":"2015-11-17T15:47:00.000","Title":"How to efficiently import the same module into multiple sub-packages in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using sklearn's EllipticEnvelope to find outliers in dataset. But I am not sure about how to model my problem? Should I just use all the data (without dividing into training and test sets) and apply fit? Also how would I obtain the outlyingness of each datapoint? Should I use predict on the same dataset?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2901,"Q_Id":33778802,"Users Score":2,"Answer":"Right way to do this is:\n\nDivide data into normal and outliers.\nTake large sample from normal data as normal_train for fitting the novelty detection model.\nCreate a test set with a sample from normal that is not used in training (say normal_test) and a sample from outlier (say outlier_test) in a way such that the distribution of the test data (normal_test + outlier_test) retains population distribution.\nPredict on this test data to get usual metrics (accuracy, sensitivity, positive-predictive-value, etc.)\n\nWow. I have come a long way!","Q_Score":2,"Tags":"python,scikit-learn,outliers","A_Id":42991702,"CreationDate":"2015-11-18T11:24:00.000","Title":"How to apply sklearn's EllipticEnvelope to find out top outliers in the given dataset?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I know that you could use grequests create multiple requests and use map to process them at the same time. But how do you create some requests on the fly while some requests sent have not returned a response yet? I don't want to use multiprocessing or multithreading,is there a way to use grequests to realize it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":33800742,"Users Score":0,"Answer":"Just use the regular requests library for this. A call to res = requests.get(...) is asynchronous anyway, it will not block until you call something like \"res.content\". Is this what you are looking for?","Q_Score":0,"Tags":"python,asynchronous,grequests","A_Id":33801105,"CreationDate":"2015-11-19T10:07:00.000","Title":"create asynchronous requests on fly using greqeusts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to programming, in fact I take a class at school and I am not very good. My assignment is to write a quiz and with every question, the person has 60 seconds to answer the question and with every right answer their score doubles. \nPlease help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":33801334,"Users Score":0,"Answer":"When displaying a question \u2014 store current time to some variable. Then after user provided answer, calculate difference between current time and the time stored at previous step. Check if it exceeds 60 seconds limit or not.","Q_Score":0,"Tags":"python","A_Id":33801420,"CreationDate":"2015-11-19T10:30:00.000","Title":"Python: How to calculate scores and how to exercise a time limit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a process that will upload a file to GAE to interpret it's contents (most are PDFs, so we would use something like PDF Miner), and then store it in Google Cloud Storage.\nTo my understanding, the problem is that file uploads are limited to both 60 seconds for it to execute, as well as a size limit of I think 10MB.  Does anyone have any ideas of how to address this issue?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":33830715,"Users Score":0,"Answer":"your best bet could upload to blobstore or Cloud Storage, then use Task Queue to process the file which has no time limits.","Q_Score":0,"Tags":"python,file,google-app-engine","A_Id":33830880,"CreationDate":"2015-11-20T15:46:00.000","Title":"Google App Engine File Processing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use IDLE when I'm coding in Python and really enjoy it's simplicity.  One thing I don't like though is when you need to navigate to a certain line and have to scroll around the place, haphazardly guessing how far you have to go to reach it.  So, my question is is there a way to jump to a certain line number in IDLE for Windows?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1329,"Q_Id":33840926,"Users Score":0,"Answer":"Edit then go to line :D\nor Alt + G","Q_Score":2,"Tags":"python,python-idle","A_Id":33841418,"CreationDate":"2015-11-21T07:37:00.000","Title":"Jump to certain line in IDLE?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know if a key exists in boto3. I can loop the bucket contents and check the key if it matches.\nBut that seems longer and an overkill. Boto3 official docs explicitly state how to do this. \nMay be I am missing the obvious. Can anybody point me how I can achieve this.","AnswerCount":24,"Available Count":1,"Score":0.0083331404,"is_accepted":false,"ViewCount":266735,"Q_Id":33842944,"Users Score":1,"Answer":"Just following the thread, can someone conclude which one is the most efficient way to check if an object exists in S3? \nI think head_object might win as it just checks the metadata which is lighter than the actual object itself","Q_Score":283,"Tags":"python,amazon-s3,boto3","A_Id":59685923,"CreationDate":"2015-11-21T11:46:00.000","Title":"check if a key exists in a bucket in s3 using boto3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently learning how to use django. I have a standalone python script that I want to communicate with my django app. However, I have no clue how to go about doing this. My django app has a login function and a database with usernames and passwords. I want my python script to talk to my app and verify the persons user name and password and also get some account info like the person's name. How do I go about doing this? I am very new to web apps and I am not really sure where to begin.\nSome Clarifications: My standalone python program is so that the user can access some information about their account. I am not trying to use the script for login functionality. My django app already handles this. I am just trying to find a way to verify that they have said account.\nFor example: If you have a flashcards web app and you want the user to have a program locally on their computer to access their flashcards, they need to login and download the cards from the web app. So wouldn't the standalone program need to communicate with the app to get login information and access to the cards on that account somehow? That's what I am trying to accomplish.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":832,"Q_Id":33852035,"Users Score":3,"Answer":"If I understand you correctly, you're looking to have an external program communicate with your server.  To do this, the server needs to expose an API (Application Interface) that communicates with the external program. That interface will receive a message and return a response.  \nThe request will need to have two things: \n\nidentifying information for the user - usually a secret key - so that other people can't access the user's data. \na query of some sort indicating what kind of information to return.\n\nThe server will get the request, validate the user's secret key, process the query, and return the result. \nIt's pretty easy to do in Django.  Set up a url like \/api\/cards and a view.  Have the view process the request and return the response. Often, these days, these back and forth messages are encoded in JSON - an easy way to encapsulate and send data.  Google around with the terms django, api, and json and you'll find a lot of what you need.","Q_Score":2,"Tags":"python,django","A_Id":33852782,"CreationDate":"2015-11-22T05:45:00.000","Title":"How to get a standalone python script to get data from my django app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I define many modules in a file, and add from myFile import * to the first line of my ipython notebook so that I can use it as dependency for other parts in this notebook.\nCurrently my workflow is:\n\nmodify myFile\nrestart the Ipython kernel\nrerun all code in Ipython.\n\nDoes anyone know if there is a way to reload all modules in myFile without need to restart the Ipython kernel?  Thanks!","AnswerCount":3,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":19517,"Q_Id":33862420,"Users Score":-6,"Answer":"You should you start your workflow after restarting and opening a notebook again by running all cells. In the top menu, before you do anything else, first select \"Cell->Run all\"","Q_Score":29,"Tags":"python,ipython,ipython-notebook","A_Id":33862460,"CreationDate":"2015-11-23T01:25:00.000","Title":"IPython notebook: how to reload all modules in a specific Python file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try to run pip wheel azure-mgmt=0.20.1, but whenever I run it I get following pip wheel error, which is very clear:\nerror: [Error 183] Cannot create a file when that file already exists: 'build\\\\bdist.win32\\\\wheel\\\\azure_mgmt-0.20.0.data\\\\..'\nSo my question is where or how I can find that path? I want to delete that existing file. I have been searching my local computer, searched for default path in Google, but still didn't find any solution.\nAlso is it possible to tell pip wheel to output full log? As you can see that full error path is not displayed. I'm using virtualenv.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1089,"Q_Id":33867992,"Users Score":0,"Answer":"have you tried uninstalling and reinstalling? \nI tried pip wheel azure-mgmt and that installed -0.20.1 for me. \nThe directory for mine is \/Users\/me\/wheelhouse, so you could look there. I found that in the initial log of the build.","Q_Score":0,"Tags":"python,azure,pip,python-wheel","A_Id":33873874,"CreationDate":"2015-11-23T09:52:00.000","Title":"Pip Wheel Package Installation Fail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have 2 different python processes (running from 2 separate terminals) running separately at the same time accessing and updating mysql. It crashes when they are using same table at the same time. Any suggestions on how to fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":33909039,"Users Score":0,"Answer":"Are you using myisam or innodb?  I suggest using innodb since it has a better table\/record locking flexibility for multiple simultaneous updates.","Q_Score":0,"Tags":"python,mysql,python-2.7,mysql-python","A_Id":34680890,"CreationDate":"2015-11-25T05:26:00.000","Title":"python accessing and updating mysql from simultaneously running processes","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a set of 3D coordinates points: [lat,long,elevation] ([X,Y,Z]), derived from LIDAR data.\nThe points are not sorted and the steps size between the points is more or less random.\nMy goal is to build a function that converts this set of points to a 2D numpy matrix of a constant number of pixels where each (X,Y) cell hold the Z value, then plot it as elevations heatmap.\n\nscales must remain realistic, X and Y should have same step size.\nthe matrix doesn't have to catch the exact elevations picture, It will obviously need some kind of resolution reduction in order to have a constant number of pixels.\n\nThe solution I was thinking of is to build a bucket for each pixel, iterate over the points and put each in a bucket according to it's (X,Y) values. At last create a matrix where each sell holds the mean of the Z values in the corresponding bucket.\n\nSince I don't have lots of experience in this field I would love to hear some tips and specially if there are better ways to address this task.\n\nIs there a numpy function for converting my set of points to the desired matrix? (maybe meshgrid with steps of a constant value?)\n\nIf I build very sparse matrix, where the step size is\nmin[min{Xi,Xj} , min{Yk,Yl}] for all i,j,k,l\nis there a way to \"reduce\" the resolution and convert it to a matrix with the required size?\n\n\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2868,"Q_Id":33926704,"Users Score":0,"Answer":"I am aware that I am not answering half of your questions but this is how I would do it: \n\nCreate a 2D array of the desired resolution,\nThe \"leftmost\" values correspond to the smallest values of x and so forth\nFill the array with the elevation value of the closest match in terms of x and y values\nSmoothen the result.","Q_Score":3,"Tags":"python,numpy,matrix,matplotlib,lidar","A_Id":33926859,"CreationDate":"2015-11-25T21:28:00.000","Title":"Converting coordinates vector to numpy 2D matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Tornado as a coroutine engine for a periodic process, where the repeating coroutine calls ioloop.call_later() on itself at the end of each execution. I'm now trying to drive this with unit tests (using Tornado's gen.test) where I'm mocking the ioloop's time with a local variable t:\nDUT.ioloop.time = mock.Mock(side_effect= lambda: t)\n(DUT <==> Device Under Test)\nThen in the test, I manually increment t, and yield gen.moment to kick the ioloop. The idea is to trigger the repeating coroutine after various intervals so I can verify its behaviour.\nBut the coroutine doesn't always trigger - or perhaps it yields back to the testing code before completing execution, causing failures. \nI think should be using stop() and wait() to synchronise the test code, but I can't see concretely how to use them in this situation. And how does this whole testing strategy work if the DUT runs in its own ioloop?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":196,"Q_Id":33940518,"Users Score":0,"Answer":"In general, using yield gen.moment to trigger specific events is dicey; there are no guarantees about how many \"moments\" you must wait, or in what order the triggered events occur. It's better to make sure that the function being tested has some effect that can be asynchronously waited for (if it doesn't have such an effect naturally, you can use a tornado.locks.Condition).\nThere are also subtleties to patching IOLoop.time. I think it will work with the default Tornado IOLoops (where it is possible without the use of mock: pass a time_func argument when constructing the loop), but it won't have the desired effect with e.g. AsyncIOLoop. \nI don't think you want to use AsyncTestCase.stop and .wait, but it's not clear how your test is set up.","Q_Score":0,"Tags":"python,unit-testing,testing,asynchronous,tornado","A_Id":33975984,"CreationDate":"2015-11-26T13:56:00.000","Title":"Unit-testing a periodic coroutine with mock time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having trouble with a menu that allows the user to choose which function to call. Part of the problem is that when I run the program it starts from the beginning (instead of calling the menu function), and the other part is that I don't know how to pass the table and the number of rows and columns from the first function to the rest of them (when I tried it said they were not defined). The program is supposed to encrypt and decrypt text using a table.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":158,"Q_Id":33964851,"Users Score":0,"Answer":"In order to pass a variable from a function to another it needs to be \u2018\u2018global\u2019\u2019. One easy way to do that is to initialize the variable outside of all functions and just let all functions call it. This way it will be defined in all functions.","Q_Score":0,"Tags":"python,python-2.7,menu","A_Id":33965008,"CreationDate":"2015-11-27T21:13:00.000","Title":"Python: function menu not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So far I am using Tkinter to make textfields in Python. \nMy question is how do I make it so there are placeholders, preferably in the style of mathematica or something similar so that when a user starts a new line, a right and left place holder appear on that line and the user can only enter text in these placeholders? Eventually I would like to be able to make it so all the right placeholders are aligned as well, but that may be too complicated. I can't seem to find a way to do this in Tkinter. Is there possibly a better package for this?\nI'm not sure how to generate and format \"text placeholders\"\nEdit: I think this question is coming down to: how do I dynamically add text placeholders within already existing text fields based on certain key commands?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":33974018,"Users Score":0,"Answer":"tkinter doesn't have anything built-in to support this. Tkinter likely has all of the fundamental building blocks in order to build it yourself, but it will require a lot of work on your part.","Q_Score":0,"Tags":"python,tkinter,textfield","A_Id":34096603,"CreationDate":"2015-11-28T17:06:00.000","Title":"Adding dotted text placeholders within a textfield in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I spent couple days trying to solve this problem, but no luck so I turn to you. I have file for a photometry of a star with time and amplitude data. I'm supposed to use this data to find period changes. I used Lomb-Scargle from pysca library, but I have to use Fourier analysis. I tried fft (dft) from scipy and numpy but I couldn't get anything that would resemble frequency spectrum or Fourier coefficients. I even tried to use nfft from pynfft library because my data are not evenly sampled, but I did not get anywhere with this. So if any of you know how to get from Fourier analysis main frequency in periodical data, please let me know.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":33975835,"Users Score":0,"Answer":"Before doing the FFT, you will need to resample or interpolate the data until you get a set of amplitude values equally spaced in time.","Q_Score":0,"Tags":"python,fft,dft,period","A_Id":33980259,"CreationDate":"2015-11-28T20:01:00.000","Title":"Fourier series of time domain data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to connect my project from app engine with (googleSQL), but I get that error exceeded the maximum of 12 connections in python, I have a CLOUDSQL D8 1000 simultaneous connections\nhow can i change this number limit conexions, I'm using django and python\nthanks","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":223,"Q_Id":33977130,"Users Score":2,"Answer":"Each single app engine instance can have no more than 12 concurrent connections to Cloud SQL -- but then, by default, an instance cannot service more than 8 concurrent requests, unless you have deliberately pushed that up by setting the max_concurrent_requests in the automatic_scaling stanza to a higher value.\nIf you've done that, then presumably you're also using a hefty instance_class in that module (perhaps the default module), considering also that Django is not the lightest-weight or fastest of web frameworks;  an F4 class, I imagine. Even so, pushing max concurrent requests above 12 may result in latency spikes, especially if serving each and every request also requires other slow, heavy-weight operations such as MySQL ones.\nSo, consider instead using many more instances, each of a lower (cheaper) class, serving no more than 12 requests each (again, assuming that every request you serve will require its own private connection to Cloud SQL -- pooling those up might also be worth considering). For example, an F2 instance costs, per hour, half as much as an F4 one -- it's also about half the power, but, if serving half as many user requests, that should be OK.\nI presume, here, that all you're using those connections for is to serve user requests (if not, you could dispatch other, \"batch-like\" uses to separate modules, perhaps ones with manual or basic scheduling -- but, that's another architectural issue).","Q_Score":0,"Tags":"python,google-app-engine,google-cloud-sql","A_Id":33978178,"CreationDate":"2015-11-28T22:26:00.000","Title":"As codified the limit of 12 connections appengine to cloudsql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I trying to make an application with a pop-up menu - when I type SPACE-R_ALT on my keyboard, globally across the OS (Windows in my case). When that happens, I want to pop-up a window (I know how to do that), and it is crucial that I can happen to be using Chrome or Word, then tap Space-Right Alt, then be able to open up this little menu.\nTkinter event bindings have two problems:\n\nFirst, when I use an event binding for <Key> and then, in the\nfunction, use evt.keysym, I can see that the program can't register\nboth at the same time. I could use a timer and then see if it works,\nbut I would prefer one line that fixes it all.\nSecond, I find that tkinter event bindings only work when the binded widget's window (or window itself) is FOCUSED. I will hide my root and TopLevel at all times, and so is not focused.\n\nI would appreciate any help on this. If your suggestion uses another module, I don't really care, as long as it works on Windows 10 (not Mac OS X, not Linux, but Windows). I'm also using Python 3, but any version (aka 2) would also be okay, as I could either try to port YOUR suggestion to Py3, or port MY code to Py2. Thanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":33980603,"Users Score":0,"Answer":"I figured it out with Furas's help - with Pyhook I can wait for events globally, and then tie in the event with tkinter events.","Q_Score":0,"Tags":"python,tkinter","A_Id":33993563,"CreationDate":"2015-11-29T07:52:00.000","Title":"Check for tkinter events globally (across OS)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a super noob in python and oauth2 but still I've wasted days on this one, so if you guys could give me hand, I would be eternally grateful :')\nGoal: writing a script that download a file everything 5min from google drive\nAchieved: Get the credentials with tokens and download it once\nProblem: how do I refresh the token?\nI achieved to get my tokens once but I don't understand what to do so that I don't need to rebuild a refresh token eveytime...\nI don't really know if I'm getting oauth2 wrong, but I've read that it should be stored and (there is store method, right?)\nThanks :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":336,"Q_Id":34004281,"Users Score":0,"Answer":"Okay, found it myself.\nYou gotta refresh you token everytime it expires, using httplib2.\nQuick hint:\nimport httplib2\nhttp = httplib2.Http()\nhttp = credentials.authorize(http)\nwhere credentials contains what you got from your first authorization flow.\nCheers","Q_Score":0,"Tags":"python,oauth-2.0,token,google-api-python-client","A_Id":34023824,"CreationDate":"2015-11-30T17:19:00.000","Title":"Google API oauth2 - how to store credentials in order ot refresh token later","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to get the XPATH for Code Generator field form (Facebook) in order to fill it (of course before I need to put a code with \"numbers\").\nIn Chrome console when I get the XPATH I get:\n\n\/\/*[@id=\"approvals_code\"]\n\nAnd then in my test I put:\n\nelem = driver.find_element_by_xpath(\"\/\/*[@id='approvals_code']\")\nif elem: elem.send_keys(\"numbers\")\n        elem.send_keys(Keys.ENTER)\n\nWith those I get:\n\nStaleElementReferenceException: Message: stale element reference: element is not attached to the page document\n\nWhat means wrong field name. Does anyone know how to properly get a XPATH?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":34018450,"Users Score":0,"Answer":"This error usually comes if element is not present in the DOM. \nOr may be element is in iframe.","Q_Score":1,"Tags":"python,facebook,selenium,xpath","A_Id":34019477,"CreationDate":"2015-12-01T10:46:00.000","Title":"Python selenium test - Facebook code generator XPATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a program in Python that takes in several command line arguments and uses them in several functions. How can I use cProfile (within my code)to obtain the running time of each function? (I still want the program to run normally when it's done). Yet I can't figure out how, for example I cannot use\ncProfile.run('loadBMPImage(sys.argv[1])')\nto test the run time of the function loadBMPImage. I cannot use sys.argv[1] as an argument. Any idea how I can use cProfile to test the running time of each function and print to stdout, if each function depends on command line arguments? Also the cProfile must be integrated into the code itself. Thanks","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":2680,"Q_Id":34032055,"Users Score":3,"Answer":"I run the\npython program with -m cProfile\nexample:\npython -m cProfile <myprogram.py>\nThis will require zero changes to the myprogram.py","Q_Score":1,"Tags":"python,profiler,cprofile","A_Id":59113102,"CreationDate":"2015-12-01T23:17:00.000","Title":"How can I use the cProfile module to time each funtion in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The title says it all, really.   I am writing functions that deal with pygame.Surface objects from multiple sources. Among other operations, these functions will ensure that the Surface objects they return have been convert()ed at least once (or, according to user preference, convert_alpha()ed), as is required to optimize them for blitting in the current display mode. But I don't want to run the the convert() or convert_alpha() methods needlessly since they create copies of the surface and therefore take up time and memory.  How do I tell whether I need to do it? I have looked at the output of S.get_flags() before and after S = S.convert_alpha() but it doesn't seem to change.  The scalar value of S.get_alpha() does change (from 255 to 0) but I'm not convinced that's meaningful or reliable (and it doesn't solve the problem of knowing whether you have to .convert() in the case where alpha blending is not desired).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86,"Q_Id":34033149,"Users Score":1,"Answer":"I do not believe the existing API provides a way to do this.  I think the intended use is to convert all your surfaces (why wouldn't you?) so you never have to worry about it.\nPerhaps it is possible to subclass pygame.Surface and override the convert methods to set a flag in the way you wish.","Q_Score":1,"Tags":"python,pygame,pygame-surface","A_Id":34033205,"CreationDate":"2015-12-02T01:02:00.000","Title":"how can you tell whether convert()\/convert_alpha() has already been run on a pygame.Surface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"ImportError: DLL load failed: %1 is not a valid Win32 application\n\nDoes anyone know how to fix this? This problem occurs when i am trying to import cv2. My laptop is 64bit and installed 64bit python, i also put the cv2.pyd file in the site-packages folder of Python.\nMy PYTHONPATH value = C:\\Python35;C:\\Python35\\DLLs;C:\\Python35\\Lib;C:\\Python35\\libs;C:\\Users\\CV\\OpenCV\\opencv\\build\\python\\2.7\\x64;%OPENCV_DIR%\\bin;\nMy OPENCV_DIR value = C:\\Users\\CV\\OpenCV\\opencv\\build\\x64\\vc12\nI also put reference of my pythonpath and my opencv_dir to the PATH by putting **%PYTHONPATH%;%PYTHONPATH%\\Scripts\\;%OPENCV_DIR%;**\nI also installed opencv_python-3.0.0+contrib-cp35-none-win_amd64 through pip install and command line.\nNone of this solved my problem.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":10949,"Q_Id":34048431,"Users Score":-1,"Answer":"in this case, I just copy file 'python3.dll' from my python3 installation folder to my virtualenv lib folder, and then it works.","Q_Score":1,"Tags":"python,windows,opencv,dll,64-bit","A_Id":49609215,"CreationDate":"2015-12-02T16:53:00.000","Title":"Import CV2: DLL load failed (Python in Windows 64bit)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm going to write a web system to add and manage the position of driver and shops. GEO searching is not required, so it would be easier to use SQLite instead of PostgreSQL.\nThe core question here is that is there any easy way to manage GIS points using Django admin. I know Django have GeoModelAdmin to manage maps based on MapBox, but I could not find out how to use it just to save, delete, and update these points?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":119,"Q_Id":34061651,"Users Score":0,"Answer":"Yes, it is relatively easy to manage geometry data in the Django Admin, and it's all included. You can do any of the CRUD tasks relatively simply using the Geo Model manager in much the same way as any Django model or you can use the map interface you get in the admin.\nFrom time to time I find I want to investigate my data in more detail, and then I simply connect to my PostGIS database using QGIS and have a panoply of GIS tools at my disposal. \nI would strongly recommend using PostGIS from the start. If there is any 'mission creep' towards more geo-functionality in the future then it will save you oodles of time. It sounds like the sort of project where spatial queries might be very useful at some point.","Q_Score":0,"Tags":"python,django,gis,geodjango","A_Id":34397621,"CreationDate":"2015-12-03T09:01:00.000","Title":"How to use Django to manage GIS points easily?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Old habits being what they are, I would declare global variables, and probably use lists to store records. I appreciate this is not the best way of doing this these days, and that Python actively discourages you from doing this by having to constantly declare 'global' throughout.\nSo what should I be doing? I'm thinking I should maybe use instances, but I know of no way to create a unique instance name based on an identifier (all the records will have a unique ID) and then find out how many instances I have.\nI could use dictionaries maybe?\nThe most important thing is that the values are accessible anywhere in my code, and that I can list the number of records and easily refer to \/ change the values.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":34075288,"Users Score":0,"Answer":"It's tough to tell, without a bit more information about the problem that you are trying to solve, the scope of your code, and your code's architecture.\nGenerally speaking:\nIf you're writing a script that's reasonably small in scope, there really is nothing wrong with declaring variables in the global namespace of the script. \nIf you're writing a larger system - something that goes beyond one module or file, but is not running in a multi-process\/multi-thread environment, then you can create a module (as a separate file) that handles storage of your re-used data.  Anytime you need to read or write that data you can import that module.  The module could just expose simple variables, or it can wrap the data in classes and expose methods for creation\/reading\/updating\/deletion.  \nIf you are running in a multi-process\/multi-thread environment, then any sort of global in-memory variable storage is going to be problematic.  You'll need to use an external store of some sort - Redis or the like for temporary storage, or a database of some sort for permanent storage.","Q_Score":0,"Tags":"python","A_Id":34075641,"CreationDate":"2015-12-03T20:12:00.000","Title":"Best way of storing records and then iterating through them?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"When I build HTML output using sphinx, it is possible to display h1 and h2 on separate pages, however, h3 is always displayed on the same page as h2. Does anyone know how to make sphinx display the content of h3 on a separate page? The same way traditional online help systems do this.\nFor example:\n\nSection  \n\n\nSub-section\nSub-section\n\n\nSub-sub-section\nSub-sub-section \n\nSub-section\n\n\nSo, I want when I click on sub-sub-section see the content only under that sub-sub-section and not from Sub-section above or sub-sub-section below.\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":1308,"Q_Id":34098567,"Users Score":-3,"Answer":"So, we were able to make it work by adjusting the HTML template and the globaltoc setting.","Q_Score":1,"Tags":"python-sphinx","A_Id":39006565,"CreationDate":"2015-12-04T22:30:00.000","Title":"Display each section (h1, h2, h3) in a new page in Sphinx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My code\nb=[((1,1)),((1,2)),((2,1)),((2,2)),((1,3))] \nfor i in range(len(b)): \n    print b[i]\n\nObtained output:\n(1, 1)\n(1, 2)\n(2, 1)\n(2, 2)\n(1, 3)\nhow do i sort this list by the first element or\/and second element in each index value to get the output as:\n(1, 1)\n(1, 2)\n(1, 3)\n(2, 1)\n(2, 2)  \nOR\n(1, 1)\n(2, 1)\n(1, 2)\n(2, 2)\n(1, 3)\nIt would be nice if both columns are sorted as shown in the desired output, how ever if either of the output columns is sorted it will suffice.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":48,"Q_Id":34119746,"Users Score":1,"Answer":"Try this: b = sorted(b, key = lambda i: (i[0], i[1]))","Q_Score":1,"Tags":"python-2.7,sorting","A_Id":34119821,"CreationDate":"2015-12-06T16:25:00.000","Title":"how to sort list in python which has two numbers per index value?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python and Pycharm,\nI am trying to step over a line with list comprehension, \nbut instead of moving me to the next line, pycharm is incrementing the loop in 1 iteration. \nany ideas how to move to the next line without pushing F8 3000 times?\nthanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":941,"Q_Id":34135672,"Users Score":0,"Answer":"Set a breakpoint at the next line of code after the comprehension and then hit play again.","Q_Score":5,"Tags":"python,debugging,pycharm","A_Id":34135775,"CreationDate":"2015-12-07T14:14:00.000","Title":"how to step over list comprehension in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python and Pycharm,\nI am trying to step over a line with list comprehension, \nbut instead of moving me to the next line, pycharm is incrementing the loop in 1 iteration. \nany ideas how to move to the next line without pushing F8 3000 times?\nthanks!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":941,"Q_Id":34135672,"Users Score":2,"Answer":"PyCharm has 'Run to Cursor' option - just move your cursor one line down and hit it.","Q_Score":5,"Tags":"python,debugging,pycharm","A_Id":34135795,"CreationDate":"2015-12-07T14:14:00.000","Title":"how to step over list comprehension in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used xml-rpc in my Odoo ERP so whenever some user inputs data in external website that will come to my ERP. Everything working fine i.e. getting data which user inputs from website like personal details, But the problem is i've some onchange selection fields in custom model.for that data is not getting updated over here. Got my point?? I would like to know how to resolve this issue. At least i need to know someone's approach.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":257,"Q_Id":34135973,"Users Score":0,"Answer":"Chandu,\nWell you can call on_change method on through xml-rpc which will give you desire data and you can pass those data back to the server to store correct values.\nBests","Q_Score":0,"Tags":"python,xml,openerp,xml-rpc","A_Id":34148043,"CreationDate":"2015-12-07T14:30:00.000","Title":"Can't retrive data from webpage for onchange fields in odoo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to do sentiment analysis on a review dataset. Since I care more about identifying (extracting) negative sentiments in reviews (unlabeled now but I try to manually label a few hundreds or use Alchemy API), if the review is overall neutral or positive but a part has negative sentiment, I'd like my model to consider it more toward as a negative review. Could someone give me advices on how to do this? I'm thinking about using bag of words\/word2vect with supervised (random forest, SVM) \/unsupervised learning models (Kmeans).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":268,"Q_Id":34146996,"Users Score":0,"Answer":"When you annotate the sentiment, don't annotate 'Positive', 'Negative', and 'Neutral'. Instead, annotate them as either \"has negative\" or \"doesn't have negative\". Then your sentiment classification will only be concerned with how strongly the features indicate negative sentiment, which appears to be what you want.","Q_Score":0,"Tags":"python,machine-learning,nlp,sentiment-analysis","A_Id":34163258,"CreationDate":"2015-12-08T02:33:00.000","Title":"Review data sentiment analysis, focusing on extracting negative sentiment?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to study customers behavior. Basically, I have information on customer's loyalty points activities data (e.g. how many points they have earned, how many points they have used, how recent they have used\/earn points etc). I'm using R to conduct this analysis\nI'm just wondering how should I go about segmenting customers based on the above information? I'm trying to apply the RFM concept then use K-means to segment my customers(although I have a few more variables than just R,F,M , as i have recency,frequency and monetary on both points earn and use, as well as other ratios and metrics) . Is this a good way to do this?\nEssentially I have two objectives:\n1. To segment customers\n2. Via segmenting customers, identify customers behavior(e.g.customers who spend all of their points before churning), provided that segmentation is the right method for such task?\nClustering <- kmeans(RFM_Values4,centers = 10)\nPlease enlighten me, need some guidance on the best methods to tackle such problems.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":436,"Q_Id":34153844,"Users Score":0,"Answer":"Your attempts is always less then 5 because there is no variable increment. So your loop is infinite","Q_Score":0,"Tags":"python,loops,selenium","A_Id":34154600,"CreationDate":"2015-12-08T10:46:00.000","Title":"Python Selenium infinite loop","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am currently using the turtle.goto cords from a text file. I have the triangle drawn and everything but I don't know how to fill the triangle.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":812,"Q_Id":34160995,"Users Score":2,"Answer":"You are ending fill after every new coordinate. You need to call t.begin_fill() before your for loop and call t.end_fill() after the last coordinate, otherwise you are just filling in your single line with each iteration.","Q_Score":2,"Tags":"python,colors,turtle-graphics","A_Id":34161243,"CreationDate":"2015-12-08T16:26:00.000","Title":"Python Turtle fill the triangle with color?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an generator (a function that yields stuff), but when trying to pass it to gensim.Word2Vec I get the following error:\n\nTypeError: You can't pass a generator as the sentences argument. Try an iterator.\n\nIsn't a generator a kind of iterator? If not, how do I make an iterator from it?\nLooking at the library code, it seems to simply iterate over sentences like for x in enumerate(sentences), which works just fine with my generator. What is causing the error then?","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":6813,"Q_Id":34166369,"Users Score":3,"Answer":"It seems gensim throws a misleading error message.\nGensim wants to iterate over your data multiple times. Most libraries just build a list from the input, so the user doesn't have to care about supplying a multiple iterable sequence. Of course, generating an in-memory list can be very resource-consuming, while iterating over a file for example, can be done without storing the whole file in memory.\nIn your case, just changing the generator to a list comprehesion should solve the problem.","Q_Score":25,"Tags":"python,gensim,word2vec","A_Id":34166580,"CreationDate":"2015-12-08T21:28:00.000","Title":"Generator is not an iterator?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have to convert some of my python 3 files to 2 for class, but I can't figure out how to use 3to2. I did pip install 3to2 and it said it was successful. It install 2 folders  3to2-1.1.1.dist-info and lib3to2. I have tried doing python 3to2 file_name, `python lib3to2 file_name' I also tried changing the folder to 3to2.py like I saw on an answer on someone else question still didn't work. What is the correct way to use this?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":16706,"Q_Id":34168019,"Users Score":0,"Answer":"In MacOS, I have anaconda package manager installed, so after pip install 3to2 I found executable at \/Users\/<username>\/anaconda3\/bin\/3to2\nRun .\/3to2 to convert stdin (-), files or directories given as arguments. By default, the tool outputs a unified diff-formatted patch on standard output and a \u201cwhat was changed\u201d summary on standard error, but the -w option can be given to write back converted files, creating .bak-named backup files.\nIn Windows its in C:\\Python27\\Scripts\\ as a file 3to2\nRun by invoking python python 3to2 <filetoconvert> to display the diff on console or with -w option to write back the converted to same file.","Q_Score":9,"Tags":"python,python-3.x","A_Id":52257045,"CreationDate":"2015-12-08T23:23:00.000","Title":"How to use 3to2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to convert some of my python 3 files to 2 for class, but I can't figure out how to use 3to2. I did pip install 3to2 and it said it was successful. It install 2 folders  3to2-1.1.1.dist-info and lib3to2. I have tried doing python 3to2 file_name, `python lib3to2 file_name' I also tried changing the folder to 3to2.py like I saw on an answer on someone else question still didn't work. What is the correct way to use this?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":16706,"Q_Id":34168019,"Users Score":11,"Answer":"Had the same question and here's how I solved it:\n\npip install 3to2\nrename 3to2 to 3to2.py (found in the Scripts folder of the Python directory)\nOpen a terminal window and run 3to2.py -w [file]\n\nNB: You will either have to be in the same folder as 3to2.py or provide the full path to it when you try to run it. Same goes for the path to the file you want to convert. The easy way around this is to copy 3to2.py into the folder your py file is in and just run the command inside that folder. Use 3to2.py --help for info on how the script works.","Q_Score":9,"Tags":"python,python-3.x","A_Id":38457022,"CreationDate":"2015-12-08T23:23:00.000","Title":"How to use 3to2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The data was captured from LTE network.\n\nI don't know how to recognize count TCP retransmission of a single TCP flow, using\nPython. \nCould I recognize the type of retransmission? It's because of congestion or packet loss?\n\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1227,"Q_Id":34169111,"Users Score":1,"Answer":"I did it in C but the general ideas is, you need to keep track of TCP sequence numbers (there are two streams for each TCP session, one from client to server, the other is from server to client).  This is a little complex.\nFor each stream, you have a pointer to keep track of the consecutive sequence numbers sent so far and use a linked-list to keep track of the pairs ( sequence number + data length) that have a gap to the pointer. Each time you see a new data packet in the stream, you either update the pointer, or add to the linked-list. Note that after you update the pointer, you should check if the linked-list to see if some of the gaps are closed.  You can tell retransmitted data packets this way.\nHope it helps.  Good luck.","Q_Score":0,"Tags":"python,tcp,wireshark,pcap","A_Id":34496093,"CreationDate":"2015-12-09T01:16:00.000","Title":"How could I find TCP retransmission and packet loss from pcap file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place: \niPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7\nTherefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7. \nSo the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","AnswerCount":6,"Available Count":4,"Score":-0.0996679946,"is_accepted":false,"ViewCount":127783,"Q_Id":34198892,"Users Score":-3,"Answer":"Its simple\njust try:\nsudo apt-get remove python3.7 or the versions that you want to remove","Q_Score":13,"Tags":"python,ubuntu","A_Id":55326327,"CreationDate":"2015-12-10T10:04:00.000","Title":"Ubuntu, how do you remove all Python 3 but not 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place: \niPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7\nTherefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7. \nSo the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","AnswerCount":6,"Available Count":4,"Score":0.0665680765,"is_accepted":false,"ViewCount":127783,"Q_Id":34198892,"Users Score":2,"Answer":"neither try any above ways nor sudo apt autoremove python3 because it will remove all gnome based applications from your system including gnome-terminal. In case if you have done that mistake and left with kernal only than trysudo apt install gnome on kernal.\ntry to change your default python version instead removing it. you can do this through bashrc file or export path command.","Q_Score":13,"Tags":"python,ubuntu","A_Id":55406526,"CreationDate":"2015-12-10T10:04:00.000","Title":"Ubuntu, how do you remove all Python 3 but not 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place: \niPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7\nTherefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7. \nSo the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","AnswerCount":6,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":127783,"Q_Id":34198892,"Users Score":8,"Answer":"So I worked out at the end that you cannot uninstall 3.4 as it is default on Ubuntu.\nAll I did was simply remove Jupyter and then alias python=python2.7 and install all packages on Python 2.7 again.\nArguably, I can install virtualenv but me and my colleagues are only using 2.7. I am just going to be lazy in this case :)","Q_Score":13,"Tags":"python,ubuntu","A_Id":34220703,"CreationDate":"2015-12-10T10:04:00.000","Title":"Ubuntu, how do you remove all Python 3 but not 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place: \niPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7\nTherefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7. \nSo the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":127783,"Q_Id":34198892,"Users Score":9,"Answer":"EDIT: As pointed out in recent comments, this solution may BREAK your system.\nYou most likely don't want to remove python3.\nPlease refer to the other answers for possible solutions.\nOutdated answer (not recommended)\n\n     sudo apt-get remove 'python3.*'","Q_Score":13,"Tags":"python,ubuntu","A_Id":34198961,"CreationDate":"2015-12-10T10:04:00.000","Title":"Ubuntu, how do you remove all Python 3 but not 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python, Twistd and SO newbie.\nI am writing a program that organises seating across multiple rooms.  I have only included related columns from the tables below.\nBasic Mysql tables\nTable\n\nid \n\nSeat\n\nid\ntable_id\nname\n\nCard\n\nseat_id\n\nThe Seat and Table tables are pre-populated with the 'name' columns initially NULL.\nStage One \nI want to update a seat's name by finding the first available seat given a group of table ids.\nStage Two\nI want to be able to get the updated row id from Stage One (because I don't already know this) to add to the Card table.  Names can be assigned to more than one seat so I can't just find a seat that matches a name.\nI can do Stage One but have no idea how to do Stage Two because lastrowid only works for inserts not updates.\nAny help would be appreciated.\nUsing twisted.enterprise.adbapi if that helps.\nCheers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":311,"Q_Id":34213706,"Users Score":0,"Answer":"I think the best way to accomplish this is to first make a select for the id (or ids) of the row\/rows you want to update, then update the row with a WHERE condition matching the id of the item to update. That way you are certain that you only updated the specific item.\nAn UPDATE statement can update multiple rows that matches your criteria. That is why you cannot request the last updated id by using a built in function.","Q_Score":3,"Tags":"python,mysql,twisted","A_Id":35131551,"CreationDate":"2015-12-10T23:32:00.000","Title":"Python Twistd MySQL - Get Updated Row id (not inserting)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python code which needs to retrieve and store data to\/from a database on a LAMP server. The LAMP server and the device running the python code are never on the same internet network. The devices running the python code can be either a Linux, Windows or a MAC system. Any idea how could I implement this?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":155,"Q_Id":34242017,"Users Score":-1,"Answer":"are never on the same internet network.\n\nLet me clear the question, the problem is are never on the same internet network. firstly you need to fix the network issue, add router between the two sides which you want to communicate with. No relations with Python or LAMP.\n\nlet me assume your DB is mysql, if you can make you can access that DB from outside servers, you can just talk with that DB directly from another servers. \nbut for another solution, I recommend you to use API which would cover all request above the DB, then you can talk with that API to handle the data.","Q_Score":0,"Tags":"python,mysql,database,lamp,mysql-python","A_Id":34242082,"CreationDate":"2015-12-12T16:11:00.000","Title":"How to fetch or store data into a database on a LAMP server from devices over the internet?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how the contours levels are chosen in pyplot.contour. What I mean by this is, given a function f(x, y), the level curves are usually chosen by evaluating the points where f(x, y) = c, c=0,1,2,... etc. However if f(x, y) is an array A of nxn points, how do the level points get chosen? I don't mean how do the points get connected, just simply the points that correspond to A = c","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":976,"Q_Id":34275096,"Users Score":0,"Answer":"The function is evaluated at every grid node, and compared to the iso-level. When there is a change of sign along a cell edge, a point is computed by linear interpolation between the two nodes. Points are joined in pairs by line segments. This is an acceptable approximation when the grid is dense enough.","Q_Score":0,"Tags":"python,math,matplotlib","A_Id":34277060,"CreationDate":"2015-12-14T19:30:00.000","Title":"How are the points in a level curve chosen in pyplot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Kind all, I'm really new to python and I'm facing a task which I can't completely grasp.\nI've created an interface with Tkinter which should accomplish a couple of apparently easy feats.\nBy clicking a \"Start\" button two threads\/processes will be started (each calling multiple subfunctions) which mainly read data from a serial port (one port per process, of course) and write them to file. \nThe I\/O actions are looped within a while loop with a very high counter to allow them to go onward almost indefinitely.\nThe \"Stop\" button should stop the acquisition and essentially it should:\n\nKill the read\/write Thread\nClose the file\nClose the serial port\n\nUnfortunately I still do not understand how to accomplish point 1, i.e.: how to create killable threads without killing the whole GUI. Is there any way of doing this?\nThank you all!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1596,"Q_Id":34284335,"Users Score":0,"Answer":"First you can use subprocess.Popen() to spawn child processes, then later you can use Popen.terminate() to terminate them.\nNote that you could also do everything in a single Python thread, without subprocesses, if you want to.  It's perfectly possible to \"multiplex\" reading from multiple ports in a single event loop.","Q_Score":4,"Tags":"python,multithreading,kill-process","A_Id":34284612,"CreationDate":"2015-12-15T08:34:00.000","Title":"How to integrate killable processes\/thread in Python GUI?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"There are multiple questions about \"how to\" call C C++ code from Python. But I would like to understand what exactly happens when this is done and what are the performance concerns. What is the theory underneath? Some questions I hope to get answered by understanding the principle are:\nWhen considering data (especially large data) being processed (e.g. 2GB) which needs to be passed from python to C \/ C++ and then back. How are the data transferred from python to C when function is called? How is the result transferred back after function ends? Is everything done in memory or are UNIX\/TCP sockets or files used to transfer the data? Is there some translation and copying done (e.g. to convert data types), do I need 2GB memory for holding data in python and additional +-2GB memory to have a C version of the data that is passed to C function? Do the C code and Python code run in different processes?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":34284421,"Users Score":2,"Answer":"You can call between C, C++, Python, and a bunch of other languages without spawning a separate process or copying much of anything.\nIn Python basically everything is reference-counted, so if you want to use a Python object in C++ you can simply use the same reference count to manage its lifetime (e.g. to avoid copying it even if Python decides it doesn't need the object anymore).  If you want the reverse, you may need to use a C++ std::shared_ptr or similar to hold your objects in C++, so that Python can also reference them.\nIn some cases things are even simpler than this, such as if you have a pure function in C or C++ which takes some values from Python and returns a result with no side effects and no storing of the inputs.  In such a case, you certainly do not need to copy anything, because you can read the Python values directly and the Python interpreter will not be running while your C or C++ code is running (because they are all in a single thread).\nThere is an extensive Python (and NumPy, by the way) C API for this, plus the excellent Boost.Python for C++ integration including smart pointers.","Q_Score":2,"Tags":"python,c++,c,language-binding","A_Id":34284538,"CreationDate":"2015-12-15T08:39:00.000","Title":"How does calling C or C++ from python work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Modulo operator % on negative numbers is implemented in different way in python and in C. In C:\n-4 % 3 = -1, while in python:-4 % 3 = 2.\nI know how to implement python-like modulo in C. I wonder how to do the reverse, that is: easily implement a C-like modulo in python.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1018,"Q_Id":34291760,"Users Score":2,"Answer":"easily implement a C-like modulo in python.\n\nSince C does truncation toward zero when integers are divided, the sign of the remainder is always the sign of the first operand. There are several ways to implement that; pick one you like:\ndef mod(a, b):  return abs(a)%abs(b)*(1,-1)[a<0]\ndef mod(a, b):  return abs(a)%abs(b)*(1-2*(a<0))","Q_Score":2,"Tags":"python,c,modulo","A_Id":46969300,"CreationDate":"2015-12-15T14:28:00.000","Title":"How to easily implement C-like modulo (remainder) operation in python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Question:\nWhat are the most efficient approaches to multi-lingual data caching on a web server, given that clients want the same base set of data but in their locale format. So 1000 data items max to be cached and then rendered on demand in specific locale format.\nMy current approach is as follows:\nI have a multilingual python Google App Engine project. The multi-lingual part uses Babel and various language .po and .mo files for translation. This is all fine and dandy. Issues, start to arise when considering caching of data. For example, let's say I have 1000 product listings that I want clients to be able to access 100 at a time. I use memcache with a datastore backup entity if the memcache gets blasted. Again, all is fine and dandy, but not multilingual. Each product has to be mapped to match the key with the particular locale of any client, English, French, Turkish, whatever. The way I do it now is to map the products under a specific locale, say 'en_US', and render server side using jinja2 templates. Each bit of data that is multilingual specific is rendered using the locale settings for date, price formatting title etc. etc. in the 'en_US' format and placed into the datastore and memcache all nicely mapped out ready for rendering. However, I have an extra step to take for getting those multilingual data into the correct format for a clients locale, and that is by way of standard {{ }} translations and jinja2 filters, generally for stuff like price formatting and dates. Problem is this is slowing things up as this all has to be rendered on the server and then passed back to the client. The initial 100 products are always server side rendered, however, before caching I was rendering the rest client side from JSON data via ajax calls to the server. Now it's all server side rendering.\nI don't want to get into a marathon discussion regarding server vs client side rendering, but I would appreciate any insights into how others have successfully handled multi-lingual caching","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":47,"Q_Id":34310736,"Users Score":1,"Answer":"I assume the individual product rendering in a particular language accounts for the majority (or at least a big chunk) of the rendering effort for the entire page.\nYou could cache server-side the rendered product results for a particular language, prior to assembling them in a complete results page and sending them to the client, using a 2D product x language lookup scheme.\nYou could also render individual product info offline, on a task queue, whenever products are added\/modified, and store\/cache them on the server ahead of time. Maybe just for the most heavily used languages?\nThis way you avoid individual product rendering on the critical path - in response to the client requests, at the expense of added memcache\/storage.\nYou just need to:\n\nsplit your rendering in 2 stages (individual product info and complete results page assembly) \nadd logic for cleanup\/update of the stored\/cached rendered product info when products add\/change\/delete ops occur\n(maybe) add logic for on-demand product info rendering when pre-rendered info is not yet available when the client request comes in (if not acceptable to simply not display the info)\n\nYou might want to check if it's preferable to cache\/store the rendered product info compressed (html compresses well) - balancing memcache\/storage costs vs instance runtime costs vs response time performance (I have yet to do such experiment).","Q_Score":0,"Tags":"python,google-app-engine,caching,server-side,multilingual","A_Id":34314025,"CreationDate":"2015-12-16T11:23:00.000","Title":"Issues with Multi-lingual website data caching - Python - Google App Engine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand and like the idea of hierarchical structure of loggers with canonical module name as the name of the logger. But I don't know how to tie everything up at the top level.\nSupposing I have application using \npackage1.subpackage1.module1 and \npackage2.subpackage2.module2. \nAnd now I'd like to define one handler and one formatter for all. But I don't want to enumerate all module's loggers and setup them separately.\nIt seems that all module loggers should be automagically attached somewhere to \"master\" logger, where the only handler is defined. \nHow to achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15,"Q_Id":34322297,"Users Score":0,"Answer":"Ok I found the answer. The master parent for all loggers is root logger - no mater it's name doesn't appear in the canonical name.","Q_Score":0,"Tags":"python,logging","A_Id":34322394,"CreationDate":"2015-12-16T21:19:00.000","Title":"how to gather all module's loggers under one parent?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to set up a complete build environment with SCons and I came across this problem:\nMy project can be compiled with two different compilers (c or cpp compilers) and the resulting object files linked with the same linker.\nBecause of this, I need to know how to split the compilation part from the linking part.\nAlso, there are cases when I only need the .o files so I want to avoid linking. \nIs this possible using the same environment ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":657,"Q_Id":34333808,"Users Score":0,"Answer":"Create two Environments, one with each compiler, use where necessary.\nThen use whichever Environment you need for linking object from either Environment.","Q_Score":0,"Tags":"python,build,scons","A_Id":34335139,"CreationDate":"2015-12-17T11:45:00.000","Title":"How to compile with two different compilers using SCons?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed tensorflow on Windows using Docker, I want to go to the folder \"tensorflow\/models\/image\/imagenet\" that contains \"classify_image.py\" python file..\nCan someone please how to reach this mentioned path?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1104,"Q_Id":34337788,"Users Score":1,"Answer":"If you're using one of the devel tags (:latest-devel or :latest-devel-gpu), the file should be in \/tensorflow\/tensorflow\/models\/image\/imagenet\/classify_image.py.\nIf you're using the base container (b.gcr.io\/tensorflow\/tensorflow:latest), it's not included -- that image just has the binary installed, not a full source distribution, and classify_image.py isn't included in the binary distribution.","Q_Score":2,"Tags":"python,windows,docker,tensorflow","A_Id":34340617,"CreationDate":"2015-12-17T15:06:00.000","Title":"Location of tensorflow\/models.. in Windows","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"MySQLdb as I understand doesn't support Python 3. I've heard about PyMySQL as a replacement for this module. But how does it work in production environment?\nIs there a big difference in speed between these two? I asking because I will be managing a very active webapp that needs to create entries in the database very often.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":34341489,"Users Score":3,"Answer":"PyMySQL is a pure-python database connector for MySQL, and can be used as a drop-in replacement using the install_as_MySQLdb() function. As a pure-python implementation, it will have some more overhead than a connector that uses C code, but it is compatible with other versions of Python, such as Jython and PyPy. \nAt the time of writing, Django recommends to use the mysqlclient package on Python 3. This fork of MySQLdb is partially written in C for performance, and is compatible with Python 3.3+. You can install it using pip install mysqlclient. As a fork, it uses the same module name, so you only have to install it and Django will use it in its MySQL database engine.","Q_Score":0,"Tags":"python,django,python-3.x","A_Id":34341868,"CreationDate":"2015-12-17T18:13:00.000","Title":"MySQL module for Python 3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to extract text from pdf-files and later try to identify the references. I'm using pdfminer 20140328. With unencrypted files its running well, but I got now a file where i get:\n\nFile \"C:\\Tools\\Python27\\lib\\site-packages\\pdfminer\\pdfdocument.py\", line 348, in _initialize_password\nraise PDFEncryptionError('Unknown algorithm: param=%r' % param)\npdfminer.pdfdocument.PDFEncryptionError: Unknown algorithm: param={'CF': {'StdCF': {'Length': 16, 'CFM': \/AESV2, 'AuthEvent': \/DocOpen}}, 'O': '}\\xe2>\\xf1\\xf6\\xc6\\x8f\\xab\\x1f\"O\\x9bfc\\xcd\\x15\\xe09~2\\xc9\\\\x87\\x03\\xaf\\x17f>\\x13\\t^K\\x99', 'Filter': \/Standard, 'P': -1548, 'Length': 128, 'R': 4, 'U': 'Kk>\\x14\\xf7\\xac\\xe6\\x97\\xb35\\xaby!\\x04|\\x18(\\xbfN^Nu\\x8aAd\\x00NV\\xff\\xfa\\x01\\x08', 'V': 4, 'StmF': \/StdCF, 'StrF': \/StdCF}\n\nI checked with pdfinfo, that this file seemed to be AES encrypted, but i can open it without any problems.\nSo i have two questions:\n\nat first: how is it possible that a document is encrypted but i can open it without a password?\n\nand secondly: how do i make PDFMiner read that file properly? Somewhere i read to install pycrypto to get additional algorithms but it doesnt fixed my problem.\n\n\nMany thanks.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5581,"Q_Id":34357680,"Users Score":0,"Answer":"This is pdfminer's error, use pdfplumber.open(file_name, password=\"\".encode()) to skip this error or TypeError: can only concatenate str (not \"bytes\") to str.","Q_Score":11,"Tags":"python,pdf,encryption,pdfminer","A_Id":71596480,"CreationDate":"2015-12-18T14:19:00.000","Title":"PDF Miner PDFEncryptionError","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a creating a huge mesh object (some 900 megabytes in size).\nOnce I am done with analysing it, I would like to somehow delete it from the memory.\nI did a bit of search on stackoverflow.com, and I found out that del will only delete the reference to mentioned mesh. Not the mesh object itself.\nAnd that after some time, the mesh object will eventually get garbage collected.\nIs gc.collect() the only way by which I could instantly release the memory, and there for somehow remove the mentioned large mesh from the memory?\nI've found replies here on stackoverflow.com which state that gc.collect() should be avoided (at least when it comes to regular python, not specifically ironpython).\nI've also find comments here on stackoverflow which claim that in IronPython it is not even guaranteed the memory will be released if nothing else is holding a reference.\nAny comments on all these issues?\nI am using ironpython 2.7 version.\nThank you for the reply.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":499,"Q_Id":34376936,"Users Score":2,"Answer":"In general managed enviroments relase there memory, if no reference is existing to the object anymore (from connection from the root to the object itself). To force the .net framework to release memory, the garbage collector is your only choice. In general it is important to know, that GC.Collect does not free the memory, it only search for objects without references and put the in a queue of objects, which will be released. If you want to free memory synchron, you also need GC.WaitForPendingFinalizers. \nOne thing to know about large objects in the .net framework is, that they are stored seperatly, in the Large Object Heap (LOH). From my point of few, it is not bad to free those objects synchron, you only have to know, that this can cause some performance issues. That's why in general the GC decide on it's own, when to collect and free memory and when not to.\nBecause gc.collect is implemented in Python as well as in IronPython, you should be able to use it. If you take a look at the implementation in IronPython, gc.collect does exactly what you want, call GC.Collect() and GC.WaitForPendingFinalizer. So in your case, i would use it.\nHope this helps.","Q_Score":1,"Tags":"collections,ironpython,garbage","A_Id":34381901,"CreationDate":"2015-12-20T00:46:00.000","Title":"Delete the large object in ironpython, and instantly release the memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to 3d world. I would like to open 3ds files with python and visualize the objects.\nI could not find any easy and straight forward way to play with 3ds max files.\nCan you let me know how can I achieve this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":717,"Q_Id":34400788,"Users Score":0,"Answer":"According to my understanding, there are some advanced graphics libraries out there for advanced usage, however Blender, (an application developed in python) supports python scripting. There are even a simple drag and drop game engine for simpler tasks.","Q_Score":1,"Tags":"python,file,3d,3dsmax","A_Id":34401590,"CreationDate":"2015-12-21T16:59:00.000","Title":"how to open 3ds files with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a contract job for editing a Django application, and Django is not my main framework to use, so I have a question regarding models in it.\nThe application I am editing has a form that each user can submit, and every single model in the application is edited directly through the form.\nFrom this perspective, it seems every model is directly a form object, I do not see any model fields that I could use for custom variables. Meaning instead of a \"string\" that I could edit with JS, I only see a TextField where the only way it could be edited is by including it on a form directly.\nIf I wanted to have some models that were custom variables, meaning I controlled them entirely through JS rather than form submissions, how would I do that in Django?\nI know I could, for example, have some \"hidden\" form objects that I manipulated with JS. But this solution sounds kind of hacky. Is there an intended way that I could go about this?\nThanks!\n(Edit: It seems most responses do not know what I am referring to. Basically I want to allow the client to perform some special sorting functions etc, in which case I will need a few additional lists of data. But I do not want these to be visible to the user, and they will be altered exclusively by js.\nRegarding the response of SColvin, I understand that the models are a representation of the database, but from how the application I am working on is designed, it looks as if the only way the models are being used is strictly through forms.\nFor example, every \"string\" is a \"TextField\", and lets say we made a string called \"myField\", the exclusive use of this field would be to use it in templates with the syntax {{ form.myField|attr:\"rows:4\" }}.\nThere are absolutely no use of this model outside of the forms. Every place you see it in the application, there is a form object. This is why I was under the impression that is the primary way to edit the data found in the models.\nI did the Django tutorial prior to accepting this project but do not remember seeing any way to submit changes to models outside of the forms.\nSo more specifically what I would like to do in this case: Let's say I wanted to add a string to my models file, and this string will NOT be included\/edited on the form. It will be invisible to the user. It will be modified browser-side by some .js functions, and I would like it to be saved along when submitting the rest of the form. What would be the intended method for going about doing this?\nIf anyone could please guide me to documentation or examples on how to do this, it would be greatly appreciated! )\n(Edit2: No responses ever since the first edit? Not sure if this post is not appearing for anyone else. Still looking for an answer!)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":34400922,"Users Score":0,"Answer":"There is some terminology confusion here, as SColvin points out; it's really not clear what you mean by \"custom variables\", and how those relates to models.\nHowever your main confusion seems to be around forms. There is absolutely no requirement to use them: they are just one method of updating models. It is always possible to edit the models directly in code, and the data from that can of course come from Javascript if you want. The tutorial has good coverage of how to update a model from code without using a form.\nIf you're doing a lot of work via JS though, you probably want to look into the Django Rest Framework, which simplifies the process of converting Django model data to and from JSON to use in your client-side code. Again though DRF isn't doing anything you couldn't do manually in your own code, all without the use of forms.","Q_Score":0,"Tags":"javascript,python,django,forms","A_Id":34403444,"CreationDate":"2015-12-21T17:07:00.000","Title":"Django saving models by JS rather than form submissions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Maybe I'm overlooking something simple and obvious here, but here goes:\nSo one of the features of the Etag header in a HTTP request\/response it to enforce concurrency, namely so that multiple clients cannot override each other's edits of a resource (normally when doing a PUT request). I think that part is fairly well known.\nThe bit I'm not so sure about is how the backend\/API implementation can actually implement this without having a race condition; for example:\nSetup:\n\nRESTful API sits on top of a standard relational database, using an ORM for all interactions (SQL Alchemy or Postgres for example).\nEtag is based on 'last updated time' of the resource\nWeb framework (Flask) sits behind a multi threaded\/process webserver (nginx + gunicorn) so can process multiple requests concurrently.\n\nThe problem:\n\nClient 1 and 2 both request a resource (get request), both now have the same Etag.\nBoth Client 1 and 2 sends a PUT request to update the resource at the same time. The API receives the requests, proceeds to uses the ORM to fetch the required information from the database then compares the request Etag with the 'last updated time' from the database... they match so each is a valid request. Each request continues on and commits the update to the database.\nEach commit is a synchronous\/blocking transaction so one request will get in before the other and thus one will override the others changes.\nDoesn't this break the purpose of the Etag?\n\nThe only fool-proof solution I can think of is to also make the database perform the check, in the update query for example. Am I missing something?\nP.S Tagged as Python due to the frameworks used but this should be a language\/framework agnostic problem.","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":1416,"Q_Id":34428046,"Users Score":2,"Answer":"This is really a question about how to use ORMs to do updates, not about ETags.\nImagine 2 processes transferring money into a bank account at the same time -- they both read the old balance, add some, then write the new balance.  One of the transfers is lost.\nWhen you're writing with a relational DB, the solution to these problems is to put the read + write in the same transaction, and then use SELECT FOR UPDATE to read the data and\/or ensure you have an appropriate isolation level set.\nThe various ORM implementations all support transactions, so getting the read, check and write into the same transaction will be easy.  If you set the SERIALIZABLE isolation level, then that will be enough to fix race conditions, but you may have to deal with deadlocks.\nORMs also generally support SELECT FOR UPDATE in some way.  This will let you write safe code with the default READ COMMITTED isolation level.  If you google SELECT FOR UPDATE and your ORM, it will probably tell you how to do it.\nIn both cases (serializable isolation level or select for update), the database will fix the problem by getting a lock on the row for the entity when you read it.  If another request comes in and tries to read the entity before your transaction commits, it will be forced to wait.","Q_Score":6,"Tags":"python,database,rest,concurrency,etag","A_Id":34428792,"CreationDate":"2015-12-23T03:13:00.000","Title":"Etags used in RESTful APIs are still susceptible to race conditions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Maybe I'm overlooking something simple and obvious here, but here goes:\nSo one of the features of the Etag header in a HTTP request\/response it to enforce concurrency, namely so that multiple clients cannot override each other's edits of a resource (normally when doing a PUT request). I think that part is fairly well known.\nThe bit I'm not so sure about is how the backend\/API implementation can actually implement this without having a race condition; for example:\nSetup:\n\nRESTful API sits on top of a standard relational database, using an ORM for all interactions (SQL Alchemy or Postgres for example).\nEtag is based on 'last updated time' of the resource\nWeb framework (Flask) sits behind a multi threaded\/process webserver (nginx + gunicorn) so can process multiple requests concurrently.\n\nThe problem:\n\nClient 1 and 2 both request a resource (get request), both now have the same Etag.\nBoth Client 1 and 2 sends a PUT request to update the resource at the same time. The API receives the requests, proceeds to uses the ORM to fetch the required information from the database then compares the request Etag with the 'last updated time' from the database... they match so each is a valid request. Each request continues on and commits the update to the database.\nEach commit is a synchronous\/blocking transaction so one request will get in before the other and thus one will override the others changes.\nDoesn't this break the purpose of the Etag?\n\nThe only fool-proof solution I can think of is to also make the database perform the check, in the update query for example. Am I missing something?\nP.S Tagged as Python due to the frameworks used but this should be a language\/framework agnostic problem.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1416,"Q_Id":34428046,"Users Score":1,"Answer":"You are right that you can still get race conditions if the 'check last etag' and 'make the change' aren't in one atomic operation.\nIn essence, if your server itself has a race condition, sending etags to the client won't help with that.\nYou already mentioned a good way to achieve this atomicity:\n\nThe only fool-proof solution I can think of is to also make the database perform the check, in the update query for example.\n\nYou could do something else, like using a mutex lock. Or using an architecture where two threads cannot deal with the same data.\nBut the database check seems good to me. What you describe about ORM checks might be an addition for better error messages, but is not by itself sufficient as you found.","Q_Score":6,"Tags":"python,database,rest,concurrency,etag","A_Id":63120699,"CreationDate":"2015-12-23T03:13:00.000","Title":"Etags used in RESTful APIs are still susceptible to race conditions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Maybe I'm overlooking something simple and obvious here, but here goes:\nSo one of the features of the Etag header in a HTTP request\/response it to enforce concurrency, namely so that multiple clients cannot override each other's edits of a resource (normally when doing a PUT request). I think that part is fairly well known.\nThe bit I'm not so sure about is how the backend\/API implementation can actually implement this without having a race condition; for example:\nSetup:\n\nRESTful API sits on top of a standard relational database, using an ORM for all interactions (SQL Alchemy or Postgres for example).\nEtag is based on 'last updated time' of the resource\nWeb framework (Flask) sits behind a multi threaded\/process webserver (nginx + gunicorn) so can process multiple requests concurrently.\n\nThe problem:\n\nClient 1 and 2 both request a resource (get request), both now have the same Etag.\nBoth Client 1 and 2 sends a PUT request to update the resource at the same time. The API receives the requests, proceeds to uses the ORM to fetch the required information from the database then compares the request Etag with the 'last updated time' from the database... they match so each is a valid request. Each request continues on and commits the update to the database.\nEach commit is a synchronous\/blocking transaction so one request will get in before the other and thus one will override the others changes.\nDoesn't this break the purpose of the Etag?\n\nThe only fool-proof solution I can think of is to also make the database perform the check, in the update query for example. Am I missing something?\nP.S Tagged as Python due to the frameworks used but this should be a language\/framework agnostic problem.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":1416,"Q_Id":34428046,"Users Score":1,"Answer":"Etag can be implemented in many ways, not just last updated time.  If you choose to implement the Etag purely based on last updated time, then why not just use the Last-Modified header?\nIf you were to encode more information into the Etag about the underlying resource, you wouldn't be susceptible to the race condition that you've outlined above.  \n\nThe only fool proof solution I can think of is to also make the database perform the check, in the update query for example. Am I missing something?\n\nThat's your answer.\n\nAnother option would be to add a version to each of your resources which is incremented on each successful update.  When updating a resource, specify both the ID and the version in the WHERE.  Additionally, set version = version + 1.  If the resource had been updated since the last request then the update would fail as no record would be found.  This eliminates the need for locking.","Q_Score":6,"Tags":"python,database,rest,concurrency,etag","A_Id":34428187,"CreationDate":"2015-12-23T03:13:00.000","Title":"Etags used in RESTful APIs are still susceptible to race conditions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a python shell, if I type a = 2 nothing is printed. If I type a 2 gets printed automatically. Whereas, this doesn't happen if I run a script from idle.\nI'd like to emulate this shell-like behavior using  the python C api, how is it done?\nFor instance, executing this code PyRun_String(\"a=2 \\na\", Py_file_input, dic, dic); from C, will not print anything as the output. \nI'd like to simulate a shell-like behavior so that when I execute the previous command, the value \"2\" is stored in a string. Is it possible to do this easily, either via python commands or from the C api? Basically, how does the python shell do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":81,"Q_Id":34441206,"Users Score":1,"Answer":"To compile your code so expression statements invoke sys.displayhook, you need to pass Py_single_input as the start parameter, and you need to provide one statement at a time.","Q_Score":1,"Tags":"python,c","A_Id":34441467,"CreationDate":"2015-12-23T17:54:00.000","Title":"Simulate shell behavior (force eval of last command to be displayed)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django app with a postgres backend hosted on Heroku. I'm now migrating it to Azure. On Azure, the Django application code and postgres backend have been divided over two separate VMs. \nEverything's set up, I'm now at the stage where I'm transferring data from my live Heroku website to Azure. I downloaded a pg_dump to my local machine, transferred it to the correct Azure VM, ran syncdb and migrate, and then ran pg_restore --verbose --clean --no-acl --no-owner -U myuser -d mydb latest.dump. The data got restored (11 errors were ignored, pertaining to 2 tables that get restored, but which my code now doesn't use).\nWhen I try to access my website, I get the kind of error that usually comes in my website if I haven't run syncdb and migrate: \n\nException Type:   DatabaseError Exception Value:  \nrelation \"user_sessions_session\" does not exist LINE 1:\n  ...last_activity\", \"user_sessions_session\".\"ip\" FROM \"user_sess...\n                                                               ^\nException Location:\n    \/home\/myuser\/.virtualenvs\/myenv\/local\/lib\/python2.7\/site-packages\/django\/db\/backends\/postgresql_psycopg2\/base.py\n  in execute, line 54\n\nCan someone who has experienced this before tell me what I need to do here? It's acting as if the database doesn't exist and I had never run syncdb. When I use psql, I can actually see the tables and the data in them. What's going on? Please advise.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":119,"Q_Id":34472609,"Users Score":1,"Answer":"Try those same steps WITHOUT running syncdb and migrate\u00a0at all. So overall, your steps will be:\nheroku pg:backups capture\ncurl -o latest.dump heroku pg:backups public-url\n`scp -P  latest.dump myuser@example.cloudapp.net:\/home\/myuser\ndrop database mydb;\ncreate database mydb;\npg_restore --verbose --clean --no-acl --no-owner -U myuser -d mydb latest.dump","Q_Score":0,"Tags":"python,django,database,postgresql,database-migration","A_Id":34480125,"CreationDate":"2015-12-26T15:18:00.000","Title":"Unable to correctly restore postgres data: I get the same error I usually get if I haven't run syncdb and migrate","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was wondering how to make a 5D tensor in Theano.\nSpecifically, I tried dtensor = T.TensorType('float32', (False,)*5). However, the only issue is that dtensor.shapereturns: AttributeError: 'TensorType' object has no attribute 'shape'\nWhereas if I used a standard tensor type likedtensor = T.tensor3('float32'), I don't get this issue when I call dtensor.shape.\nIs there a way to have this not be an issue with a 5D tensor in Theano?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":506,"Q_Id":34483277,"Users Score":1,"Answer":"Theano variables do not have explicit shape information since they are symbolic variables, not numerical. Even dtensor3 = T.tensor3(T.config.floatX) does not have an explicit shape. When you type dtensor3.shape you'll get an object Shape.0 but when you do dtensor3.shape.eval() to get its value you'll get an error.\nFor both cases however, dtensor.ndim works and prints out 5 and 3 respectively.","Q_Score":1,"Tags":"python,theano,symbolic-computation","A_Id":34484383,"CreationDate":"2015-12-27T18:04:00.000","Title":"5D tensor in Theano","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how do I check that the user has entered a name instead of a number, when asking for user input as string? I want a string input in the form of their name, but I want to use error checking to make sure the user doesn't enter a number.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1176,"Q_Id":34486981,"Users Score":0,"Answer":"If you wanna check correct in english dictionary then you can use pyenchant ... use pip to install it ... its east to use and gives true if spelling of a word is correct and false if word doesn't exist in english dictionary.\npip install pyenchant","Q_Score":3,"Tags":"python-2.7","A_Id":34493500,"CreationDate":"2015-12-28T02:26:00.000","Title":"In Python, how do I check that the user has entered a name instead of a number?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have my own python script that manages the IP address on my computer. Mainly it executes the netsh command in the command line (windows 10) which for you must have administrator rights.\nIt is my own computer, I am the administrator and when running the script I am already logged in with my user (Adrian) which is of type administrator.\nI can`t use the right click and \"run as administrator\" solution because I am executing my netsh command from my python script.\nAnybody knows how to get \"run as administrator\" with a command from CMD ? \nThanks","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7654,"Q_Id":34500369,"Users Score":1,"Answer":"Try something like this: runas \/user:administrator regedit.","Q_Score":4,"Tags":"python,windows,cmd","A_Id":34500631,"CreationDate":"2015-12-28T20:33:00.000","Title":"open cmd with admin rights (Windows 10)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say that I have pandas DataFrame with a column called \"fruit\" that represents what fruit my classroom of kindergartners had for a morning snack. I have 20 students in my class. Breakdown would be something like this.\nOranges = 7, Grapes = 3, Blackberries = 4, Bananas = 6\nI used sort to group each of these fruit types, but it is grouping based on alphabetical order. I would like it to group based on the largest quantity of entries for that class of fruit. In this case, I would like Oranges to turn up  first so that I can easily see that Oranges is the most popular fruit.\nI'm thinking that sort is not the best way to go about this. I checked out groupby but could not figure out how to use that appropriately either.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":38,"Q_Id":34502840,"Users Score":2,"Answer":"To sort by name: df.fruit.value_counts().sort_index()\nTo sort by counts: df.fruit.value_counts().sort_values()","Q_Score":0,"Tags":"python,pandas","A_Id":34502877,"CreationDate":"2015-12-29T00:37:00.000","Title":"Python pandas: determining which \"group\" has the most entries","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7\/site-package directory.\nBut how do I install it into the python3 dir?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":73703,"Q_Id":34507744,"Users Score":1,"Answer":"I had some mismatch between Python version and Beautifulsoup. I was installing this project\nTh3Jock3R\/LinuxGSM-Arma3-Mod-Update\nto a linux centos8 dedicated Arma3 server. Python3 and Beautifulsoup4 seem to match.So I updated Python3, removed manually Beautifulsoup files and re-installed it with: sudo yum install python3-beautifulsoup4 (note the number 3). Works. Then pointing directories in Th3Jock3R:s script A3_SERVER_FOLDER = \"\" and A3_SERVER_DIR = \"\/home\/arma3server{}\".format(A3_SERVER_FOLDER) placing and running the script in same folder \/home\/arma3server with python3 update.py. In this folder is also located new folder called 'modlists' Now the lightness of mod loading blows my mind. -Bob-","Q_Score":27,"Tags":"python,python-3.x,beautifulsoup,pip","A_Id":70827357,"CreationDate":"2015-12-29T08:59:00.000","Title":"How to install beautifulsoup into python3, when default dir is python2.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7\/site-package directory.\nBut how do I install it into the python3 dir?","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":73703,"Q_Id":34507744,"Users Score":0,"Answer":"If you are on windows, this works for Python3 as well\npy -m pip install bs4","Q_Score":27,"Tags":"python,python-3.x,beautifulsoup,pip","A_Id":63598946,"CreationDate":"2015-12-29T08:59:00.000","Title":"How to install beautifulsoup into python3, when default dir is python2.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I create a menu that popups after a right on a tab. The menu contains three options: close, close other and close all. Right clicking on a tabs does not display its content (it not already displayed), it just show the menu that control the clicked tab. The issue is that right clicking on another tab popups the menu but the program does not know which tab was clicked.\nIs there any built-in methods to get the index of a tabs in AuiNotebook after a right click event?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":34514164,"Users Score":0,"Answer":"Use EVT_AUINOTEBOOK_TAB_RIGHT_DOWN to catch the event. The event.page will give you the clicked page.","Q_Score":1,"Tags":"wxpython","A_Id":44302082,"CreationDate":"2015-12-29T15:34:00.000","Title":"How to get the index of a tab in AuiNotebook after a right click on a non-active tab?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Working on a small app that takes a Spotify track URL submitted by a user in a messaging application and adds it to a public Spotify playlist. The app is running with the help of spotipy python on a Heroku site (so I have a valid \/callback) and listens for the user posting a track URL.\nWhen I run the app through command line, I use util.prompt_for_user_token. A browser opens, I move through the auth flow successfully, and I copy-paste the provided callback URL back into terminal.\nWhen I run this app and attempt to add a track on the messaging application, it does not open a browser for the user to authenticate, so the auth flow never completes.\nAny advice on how to handle this?  Can I auth once via terminal, capture the code\/token and then handle the refreshing process so that the end-user never has to authenticate?\nP.S. can't add the tag \"spotipy\" yet but surprised it was not already available","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1073,"Q_Id":34520233,"Users Score":2,"Answer":"I once ran into a similar issue with Google's Calendar API. The app was pretty low-importance so I botched a solution together by running through the auth locally in my browser, finding the response token, and manually copying it over into an environment variable on Heroku. The downside of course was that tokens are set to auto-expire (I believe Google Calendar's was set to 30 days), so periodically the app stopped working and I had to run through the auth flow and copy the key over again. There might be a way to automate that. \nGood luck!","Q_Score":6,"Tags":"python,api,heroku,oauth-2.0,spotify","A_Id":34520316,"CreationDate":"2015-12-29T22:40:00.000","Title":"Completing Spotify Authorization Code Flow via desktop application without using browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed caffe using Macports sudo port install caffe. However, Macports didn't use my anaconda python, which I would like to use for development. I can only import caffe in Macports' python2.7.\nIs there a way to show anaconda python where to look or do I have to reinstall for anaconda python? Either way, I would be grateful for a hint how to do it.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":132,"Q_Id":34547795,"Users Score":0,"Answer":"Install pyvenv ... it is easy to do on a Mac - then you can use whatever you want to.","Q_Score":0,"Tags":"python,anaconda,macports,caffe","A_Id":34549989,"CreationDate":"2015-12-31T14:30:00.000","Title":"Macports caffe wrong python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed caffe using Macports sudo port install caffe. However, Macports didn't use my anaconda python, which I would like to use for development. I can only import caffe in Macports' python2.7.\nIs there a way to show anaconda python where to look or do I have to reinstall for anaconda python? Either way, I would be grateful for a hint how to do it.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":132,"Q_Id":34547795,"Users Score":0,"Answer":"MacPorts never installs modules for use with other Python versions than MacPorts' own version. As a consequence, there is no switch to select the Python version to build against.\nYou'll have to install caffe for your Anaconda Python yourself, e.g. in a virtualenv, or use MacPorts Python.","Q_Score":0,"Tags":"python,anaconda,macports,caffe","A_Id":34557806,"CreationDate":"2015-12-31T14:30:00.000","Title":"Macports caffe wrong python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with Abstract Syntax Trees in Python 3. The ast library gives many ways to get children of the node (you can use iter_child_nodes() or walk()) but no ways to get parent of one. Also, every node has links to its children, but it hasn't links to its parent.\nHow I can get the parent of AST node if I don't want to write some plugin to ast library?\nWhat is the most correct way to do this?","AnswerCount":4,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4325,"Q_Id":34570992,"Users Score":1,"Answer":"You might create some hash table associating AST nodes to AST nodes and scan (recursively) your topmost AST tree to register in that hash table the parent of each node.","Q_Score":16,"Tags":"python,python-3.x,abstract-syntax-tree","A_Id":34571022,"CreationDate":"2016-01-02T21:38:00.000","Title":"Getting parent of AST node in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with Abstract Syntax Trees in Python 3. The ast library gives many ways to get children of the node (you can use iter_child_nodes() or walk()) but no ways to get parent of one. Also, every node has links to its children, but it hasn't links to its parent.\nHow I can get the parent of AST node if I don't want to write some plugin to ast library?\nWhat is the most correct way to do this?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4325,"Q_Id":34570992,"Users Score":0,"Answer":"It wouldn't be really be a plugin, but you can always write a function which adds a weakref to parent in every child.","Q_Score":16,"Tags":"python,python-3.x,abstract-syntax-tree","A_Id":34571024,"CreationDate":"2016-01-02T21:38:00.000","Title":"Getting parent of AST node in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Here is my question:\nI have a 3-d numpy array Data which in the shape of (1000, 100, 100).\nAnd I want to save it as a .txt or .csv file, how to achieve that?\nMy first attempt was to reshape it into a 1-d array which length 1000*100*100, and transfer it into pandas.Dataframe, and then, I save it as .csv file.    \nWhen I wanted to call it next time,I would reshape it back to 3-d array.    \nI think there must be some methods easier.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":34574396,"Users Score":1,"Answer":"If you need to re-read it quickly into numpy you could just use the cPickle module.\nThis is going to be much faster that parsing it back from an ASCII dump (but however only the program will be able to re-read it). As a bonus with just one instruction you could dump more than a single matrix (i.e. any data structure built with core python and numpy arrays).\nNote that parsing a floating point value from an ASCII string is a quite complex and slow operation (if implemented correctly down to ulp).","Q_Score":2,"Tags":"python,numpy","A_Id":34574445,"CreationDate":"2016-01-03T07:43:00.000","Title":"How to save the n-d numpy array data and read it quickly next time?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have a doubt, i need to create some svg files (in a sequence) and upload to data store. I know how to create the svg, but it save to filesystem, and i have understood that GAE cannot use it. \nSo, i don't know how to create and put it on the datastore.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":260,"Q_Id":34583385,"Users Score":4,"Answer":"Create your \"file\" in memory (use e.g io.BytesIO) and then use the getvalue method of the in-memory \"file\" to get the blob of bytes for the datastore. Do note that a datastore entity is limited to a megabyte or so, thus it's quite possible that some SVG file might not fit in that space -- in which case, you should look into Google Cloud Storage. But, that's a different issue.","Q_Score":3,"Tags":"python-2.7,google-app-engine,google-cloud-datastore","A_Id":34583572,"CreationDate":"2016-01-04T00:51:00.000","Title":"Create SVG and save it to datastore(GAE + Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a python pdf generator that can use an image directly from a given url? Right now I'm using ReportLab and I have to download and save the image to a file and then using filename I can add it to the PDF. Which is significatly slower I imagine, in comparison to directly downloading the image, storing it in memory somehow and write to the PDF.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":124,"Q_Id":34592010,"Users Score":0,"Answer":"I really cannot see how this is significantly slower.\nThe local disks bandwidth should be much larger than the internet bandwidth.\nSo the extra local save\/load times should be extremely low overhead.\nIf you really wan't to speed stuff up, check if the file already exists locally before downloading.\nunless of course if you are doing this download manually?","Q_Score":0,"Tags":"python,image,pdf,pdf-generation","A_Id":34592133,"CreationDate":"2016-01-04T13:13:00.000","Title":"Python PDF generation - image from internet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing ipython notebook in pycharm. But I don't know how to check the python doc of the library I use in the notebook with IDE support (like mouse over the code and python api doc display automatically). Does anyone know that ? Thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":58,"Q_Id":34593129,"Users Score":0,"Answer":"Simplest solution - print somewhere __doc__ or use LPM when clicking on method you want to check to go directly to the file, where method you need is declared. Then you should have docstring of it.","Q_Score":0,"Tags":"pycharm,ipython-notebook","A_Id":34593227,"CreationDate":"2016-01-04T14:15:00.000","Title":"how to see the python api doc in pycharm ipython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Given some coordinates in 3D (x-, y- and z-axes), what I would like to do is to get a polynomial (fifth order). I know how to do it in 2D (for example just in x- and y-direction) via numpy. So my question is: Is it possible to do it also with the third (z-) axes?\nSorry if I missed a question somewhere.\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":34597732,"Users Score":0,"Answer":"Numpy has functions for multi-variable polynomial evaluation in the polynomial package -- polyval2d, polyval3d -- the problem is getting the coefficients. For fitting, you need the polyvander2d, polyvander3d functions that create the design matrices for the least squares fit. The multi-variable polynomial coefficients thus determined can then be reshaped and used in the corresponding evaluation functions. See the documentation for those functions for more details.","Q_Score":0,"Tags":"python,numpy,curve-fitting,algebra","A_Id":38167204,"CreationDate":"2016-01-04T18:45:00.000","Title":"Create 3D- polynomial via numpy etc. from given coordinates","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use two installations of Spyder, one using my default python 2.7 and the other running in a python 3.4 virtualenv. However, the history of the IPython console is shared between the two. The cleanest way to have separate histories would be to define a new IPython profile for the python 3.4 installation. My question is: how to convince Spyder to run IPython with a non-default profile? I could not find any way to supply command line options.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":397,"Q_Id":34629913,"Users Score":3,"Answer":"(Spyder dev here) There is no way to start an IPython console inside Spyder with a different profile. We use the default profile to create all our consoles.","Q_Score":1,"Tags":"ipython,spyder","A_Id":34643480,"CreationDate":"2016-01-06T09:43:00.000","Title":"Non-default IPython profile in Spyder console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use two installations of Spyder, one using my default python 2.7 and the other running in a python 3.4 virtualenv. However, the history of the IPython console is shared between the two. The cleanest way to have separate histories would be to define a new IPython profile for the python 3.4 installation. My question is: how to convince Spyder to run IPython with a non-default profile? I could not find any way to supply command line options.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":397,"Q_Id":34629913,"Users Score":0,"Answer":"As mentioned by Carlos' answer, there is no way to start an IPython console inside Spyder with a different profile. A workaround is to duplicate the ~\/.ipython directory (I named mine ~\/.ipython3) and set the environment variable IPYTHONDIR to the new location before running the python 3 version of Spyder. It will then use the profile_default in the new directory.","Q_Score":1,"Tags":"ipython,spyder","A_Id":34657322,"CreationDate":"2016-01-06T09:43:00.000","Title":"Non-default IPython profile in Spyder console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In scikit-learn new  version ,there is a new function called apply() in Gradient boosting. I'm really confused about it .\nDoes it like the method:GBDT + LR that facebook has used?\nIf dose, how can we make it work like GBDT + LR?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1064,"Q_Id":34649751,"Users Score":3,"Answer":"From the Sci-Kit Documentation\n\napply(X)  Apply trees in the ensemble to X, return leaf indices\n\nThis function will take input data X and each data point (x) in it will be applied to each non-linear classifier tree. After application, data point x will have associated with it the leaf it end up at for each decision tree. This leaf will have its associated classes ( 1 if binary ). \napply(X) returns the above information, which is of the form [n_samples, n_estimators, n_classes].\nThus, the apply(X) function doesn't really have much to do with the Gradient Boosted Decision Tree + Logic Regression (GBDT+LR) classification and feature transform methods. It is a function for the application of data to an existing classification model.\nI'm sorry if I have misunderstood you in any way, though a few grammar\/syntax errors in your question made it harder to decipher.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":34653721,"CreationDate":"2016-01-07T07:41:00.000","Title":"What the function apply() in scikit-learn can do?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok, so I'm looking to switch to PyCharm from PyScripter for OS independent development. I also wanted to mention that I'm using Perforce for version control. \nSo what I currently do is double click a .py for editing in Perforce, and PyScripter opens up and I edit to my hearts desire. I can click on an imported function, and it'll open up the corresponding .py file and bring me right to the function. Awesome.\nSo I have yet to be able to achieve that on PyCharm. I'm using the community version which should be just fine for what I want, which is just an editor with some python checking & built in console.\nWhen I set the default .py program to use in Perforce to PyCharm, I click on the .py and PyCharm fires up. Good so far. But my problem arises when I try to \"ctrl + click\" a function or method. I get the \"Cannot find declaration to go to.\" I import the associated class & file.\n(Just an example, not actual code). So in Transportation.py I have \"import Cars\", which is a .py. I do Cars.NumberOfDoors() and I get the above error. My folder structure is:\n\nScripts (folder)\n\n\nPopulation.py (General support script)\nCitybudget.py (General support script)\nMassTransit (folder)\n\n\nTransportation.py\nCars.py\n\n\n\nSo question boils down to, is how do I properly setup the root to be the Scripts folder when I click on a file from Perforce? How do I set it up that it recognizes where it's at in the folder structure? So if I'm in the MassTransit it'll set the root as Scripts folder, and same for if I'm accessing the general support scripts like Population.py?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":207,"Q_Id":34661669,"Users Score":2,"Answer":"Go to \n\nFile --> Open\n\nin Pycharm and select your Scripts(folder) and open it. Then the Pycharm will treat it as a project and you will be able to ctrl + click a function.","Q_Score":1,"Tags":"python,pycharm,perforce,pyscripter","A_Id":34661837,"CreationDate":"2016-01-07T17:38:00.000","Title":"Directory issues within Pycharm (free version) & Perforce","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have activated a python virtualenv (dev) for one of my projects. However, don't know what happened, it looks like it has changed the path permanently. I cannot access my global packages. When I print sys.path it shows me paths related to virtualenv (dev) which is no more activated. When I run pip list, it shows me packages installed for virtualenv (dev) and not the ones install globally (c:\\python27\\Lib\\sitepackages). Any idea what must have gone wrong? And how do I reset sys.path? \nI checked out RegistryKey (HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\PythonPath) and Environment variables, everything looks okay. Any light on this issue would be helpful...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":156,"Q_Id":34668997,"Users Score":0,"Answer":"Your default environment variables may be wrong in path, since the default path must point to the python globally.\nTry this:\n\nStart menu > Run > 'sysdm.cpl' > Enter\nSearch for the tab 'Advanced'\nFinally 'Environment Variables'\n\nEdit the system variable 'Path'\nCarefully and search for the python path, just change it to the global paths instead.\nc:\\python27\\Lib\\site-packages\\PyQT4 (usually)\nc:\\python27\nc:\\python27\\scripts\nHope I could help.","Q_Score":0,"Tags":"python,virtualenv","A_Id":34669093,"CreationDate":"2016-01-08T03:24:00.000","Title":"Python virtualenv has changed sys.path permanently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm pretty new to Azure and I'm trying to get a Django WebApp up and running. I uploaded the files using FTP, But Azure doesn't run my requirements.txt.\n\n\nSo I searched for a bit and found out that you can install the requirements.txtwith pip.\n\n\nBack in Azure, PIP doesn't seem to work. Neither in the Console, The KUDU CMD or the KUDU powershell. Python does work.\n\nWhen I try to install PIP via Python, it first says that a older version is already installed. When Python tries to upgrade PIP, it doesn't have access to the folder that it needs to edit.\n\n\nI was wondering how I could use PIP in azure.\n\n(If you know a seperate way to install the requirements.txt please tell, because this was how I originally came to this point.)","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":7236,"Q_Id":34692370,"Users Score":2,"Answer":"You won't be able to upgrade the pip of your Django webapp because you will not have access to system files.\nInstead you can upgrade pip of your virtualenv, which you can do by adding a line in deploy.cmd file before install requirements.txt command.\nenv\\scripts\\python -m pip install --upgrade pip\nRemember not to upgrade pip with pip (env\/scripts\/pip) else it will uninstall global pip.","Q_Score":9,"Tags":"python,django,azure,pip,azure-web-app-service","A_Id":41843617,"CreationDate":"2016-01-09T10:31:00.000","Title":"Using PIP in a Azure WebApp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm pretty new to Azure and I'm trying to get a Django WebApp up and running. I uploaded the files using FTP, But Azure doesn't run my requirements.txt.\n\n\nSo I searched for a bit and found out that you can install the requirements.txtwith pip.\n\n\nBack in Azure, PIP doesn't seem to work. Neither in the Console, The KUDU CMD or the KUDU powershell. Python does work.\n\nWhen I try to install PIP via Python, it first says that a older version is already installed. When Python tries to upgrade PIP, it doesn't have access to the folder that it needs to edit.\n\n\nI was wondering how I could use PIP in azure.\n\n(If you know a seperate way to install the requirements.txt please tell, because this was how I originally came to this point.)","AnswerCount":5,"Available Count":2,"Score":0.0798297691,"is_accepted":false,"ViewCount":7236,"Q_Id":34692370,"Users Score":2,"Answer":"Have you tried upgrading pip with easy_install? The following worked for me in Azure kudu console:\npython -m easy_install --upgrade --user pip","Q_Score":9,"Tags":"python,django,azure,pip,azure-web-app-service","A_Id":38240151,"CreationDate":"2016-01-09T10:31:00.000","Title":"Using PIP in a Azure WebApp","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use pyquery with pypy but it depends on lxml2, which won't build under pypy. I know there's a lxml2 build that is meant to be used with pypy but I don't know how to make pyquery use that instead of the usual one.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":89,"Q_Id":34700577,"Users Score":1,"Answer":"Pypy 5.0 and lxml 3.6 are designed to work well with each other.","Q_Score":1,"Tags":"python,lxml,pypy,pyquery","A_Id":36188448,"CreationDate":"2016-01-10T00:22:00.000","Title":"How can I build pyquery for pypy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to develop an app to track people's Whatsapp last seen and other stuff, and found out that there are APIs out there to deal with it, but the thing is they are writen in python and are normally run in Linux I think\nI have Java and Android knowledge but not python, and wonder if there's a way to develop the most of the app in Java and get the info I want via calls using these python APIs, but without having to install a python interpreter or similar on the device, so the final user just has to download and run the Android app as he would do with any other \nI want to know if it would be very hard for someone inexperienced as me (this is the 2nd and final year of my developing grade), for it's what I have in mind for the final project, thx in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":34710059,"Users Score":0,"Answer":"Instead of running it as one app, what about running the python script as separate from the original script? I believe it would bee possible, as android is in fact a UNIX based OS. Any readers could give their input on this idea an if it would work.","Q_Score":0,"Tags":"java,android,python","A_Id":34710122,"CreationDate":"2016-01-10T19:50:00.000","Title":"how to write an Android app in Java which needs to use a Python library?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to insert 5 integers by simply typing 3 4 6 8 9 and hitting enter. I know how to insert strings in a list by using list=raw_input().split(\" \",99), but how can I insert integers using space?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6406,"Q_Id":34726376,"Users Score":0,"Answer":"map(int, \"1 2 3 4 5\".split())\n\n\n\nThis will take your string and convert to a list of ints.\nSplit defaults to splitting on a space, so you don't need an argument.\nFor raw_input(), you can do:\n\n\nmap(int, raw_input().split())","Q_Score":1,"Tags":"python-2.7","A_Id":34726494,"CreationDate":"2016-01-11T16:23:00.000","Title":"how to insert integers in list\/array separated by space in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to insert 5 integers by simply typing 3 4 6 8 9 and hitting enter. I know how to insert strings in a list by using list=raw_input().split(\" \",99), but how can I insert integers using space?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6406,"Q_Id":34726376,"Users Score":0,"Answer":"The above answer is perfect if you are looking to parse strings into a list. \nElse you can parse them into Integer List using the given way\nintegers = '22 33 11'\nintegers_list = []\ntry:\n    integers_list = [int(i) for i in integers.split(' ')]\nexcept:\n    print \"Error Parsing Integer\"\nprint integers_list","Q_Score":1,"Tags":"python-2.7","A_Id":34726835,"CreationDate":"2016-01-11T16:23:00.000","Title":"how to insert integers in list\/array separated by space in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I set up django using nginx and gunicorn. I am looking at the permission in my project folder and I see that the permission for the media folder is set to root (all others are set to debian): \n-rw-r--r-- 1 root   root    55K Dec  2 13:33 media\nI am executing all app relevant commands like makemigrations, migrate, collectstatic, from debian, therefore everything else is debian.\nBut the media folder doesn't exist when I start my app. I will be created once I upload stuff. \nBut who creates it and how do I change the permissions to debain?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":343,"Q_Id":34729149,"Users Score":0,"Answer":"Coulnd't find out who exactly is it created by, however, the permissions depend on the user (root or non root). \nThis means if you run the commands (for example: python manage.py runserver) with sudo or under root the folder gets root permissions which can't be edited from a non root user.","Q_Score":1,"Tags":"python,django,nginx,permissions,file-permissions","A_Id":36338260,"CreationDate":"2016-01-11T19:07:00.000","Title":"who creates the media folder in django and how to change permission rights?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can you upload entire folders in IPython Jupyter? If so, how? I know how to upload individual files, of course, but this can get tedious if there are a large number of files and\/or subdirectories.","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":61675,"Q_Id":34734714,"Users Score":12,"Answer":"Maybe it is easier to just use unix to just unzip the data.\nSteps:\n\nTransform the folder into a .zip file in your computer.\nUpload the .zip file to jupyter home.\nIn jupyter notebook run \n\n! unzip ~\/yourfolder.zip -d ~\/\nwhere \n! tells the jupyter notebook that you are going to give code directly to unix, not python code\nunzip is the unzip commmand\n~\/yourfolder.zip tells the command where your .zip folder is (at ~\/ if you uploaded to the home folder)\n-d ~\/ tells the command where you want to put the unzipped folder (this assumes you want to put it in the home folder, but you can also put it in any other subfolder with -d ~\/my_first_level_subfolder or -d ~\/my_first_level_subfolder\/my_second_level_subfolder, etc.)\n\nIf you want to delete the original .zip folder, delete it manually at jupyter home or use \n\n!rm ~\/yourfolder.zip\nHope if helps somebody","Q_Score":37,"Tags":"ipython,jupyter,jupyter-notebook","A_Id":59724231,"CreationDate":"2016-01-12T02:41:00.000","Title":"IPython Jupyter: uploading folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im developing an app using flask framework in python, i wanted to host it on my pc for a few people to be able to visit it, similar to wamps put online feature but for flask instead, i dont want to deploy it to the cloud just yet. how can i do it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2566,"Q_Id":34736964,"Users Score":0,"Answer":"Enable port forwarding on your router, start flask on the 0.0.0.0 address of your computer, set the forwarded port to be the one started on your laptop. This will now allow your LAN and calls to your ISP provided address to be directed to your laptop. \nTo clarify, LAN can do it without port forwarding in my experience.","Q_Score":0,"Tags":"python,web,flask,host","A_Id":34775584,"CreationDate":"2016-01-12T06:30:00.000","Title":"How to host a flask web app on my own pc?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have celery task with 100 input data in queue and need to execute using 5 workers.\n\nHow can I get which worker is executing which input?\nEach worker executed how many inputs and its status?\nIf any task is failed how can get failed input data in separately and re-execute with available worker?\n\nIs there any possible ways to customize celery based on worker specific.\nWe can combine celery worker limitation and flower\nI am not using any framework.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":834,"Q_Id":34737287,"Users Score":0,"Answer":"How can I get which worker is executing which input?\n\nThere are 2 options to use multiple workers:\n\nYou run each worker separately with separate run commands\nYou run in one command using command line option -c i.e. concurrency\n\nFirst method, flower will support it and will show you all the workers, all the tasks (you call inputs), which worker processed which task and other information too.\nWith second method, flower will show you all the tasks being processed by single worker. In this case you can only differentiate by viewing logs generated by celery worker as in logs it does store which worker THREAD executed which task. So, i think you will be better using first option given your requirements.\n\nEach worker executed how many inputs and its status?\n\nAs I mentioned, using first approach, flower will give you this information.\n\nIf any task is failed how can get failed input data in separately and\n  re-execute with available worker?\n\nFlower does provide the filters to filter the failed tasks and does provide what status tasks returned when exiting. Also you can set how many times celery should retry a failed task. But even after retries task fails, then you will have to relaunch the task yourself.","Q_Score":3,"Tags":"python,celery-task","A_Id":34738281,"CreationDate":"2016-01-12T06:54:00.000","Title":"Celery worker details","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to manage virtual machines (any flavor) using Python scripts. Example, create VM, start, stop and be able to access my guest OS's resources.\nMy host machine runs Windows. I have VirtualBox installed. Guest OS: Kali Linux. \nI just came across a software called libvirt. Do any of you think this would help me ? \nAny insights on how to do this? Thanks for your help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1117,"Q_Id":34757084,"Users Score":0,"Answer":"For aws use boto.\nFor GCE use Google API Python Client Library\nFor OpenStack use the python-openstackclient and import its methods directly.\nFor VMWare, google it.\nFor Opsware, abandon all hope as their API is undocumented and has like 12 years of accumulated abandoned methods to dig through and an equally insane datamodel back ending it.\nFor direct libvirt control there are python bindings for libvirt.  They work very well and closely mimic the c libraries.\nI could go on.","Q_Score":0,"Tags":"python,linux,scripting,virtual-machine","A_Id":34761507,"CreationDate":"2016-01-13T01:47:00.000","Title":"Controlling VMs using Python scripts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to run text processing Python scripts after submitting searchForms of my node.js application.\nI know how the scripts can be called with child_process and spawn within js, but what should I set up on the app (probably some package.json entries?) so that it will be able to run Python after deploying to Bluemix?\nThanks for any help!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":358,"Q_Id":34763600,"Users Score":1,"Answer":"I finally fixed this as adding an entry to dependencies in package.json of the project, which causes the call of npm install for the linked github repo. It is kinda straightforward but I found no explanation for that on Bluemix resources.","Q_Score":1,"Tags":"python,node.js,ibm-cloud","A_Id":34790983,"CreationDate":"2016-01-13T10:01:00.000","Title":"How to invoke python scripts in node.js app on Bluemix?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know a tool to implement a Python SMPP server and some tips on how to proceed?\nI found Pythomnic3k framework, but did not find material needed for me to use it as SMPP server ...","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":491,"Q_Id":34771013,"Users Score":2,"Answer":"Take a look at jasmin sms gateway, it's pythonic and has smpp server implementation.","Q_Score":1,"Tags":"python,smpp","A_Id":34810025,"CreationDate":"2016-01-13T15:47:00.000","Title":"Implementing an SMPP Server in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a Flask-admin application and I have a class with a \"Department\" and a \"Subdepartment\" fields.\nIn the create form, I want that when a Department is selected, the Subdepartment select automatically loads all the corresponding subdepartments.\nIn the database, I have a \"department\" table and a \"sub_department\" table that was a foreign key \"department_id\".\nAny clues on how I could achieve that?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":34786665,"Users Score":0,"Answer":"You have to follow this steps\nJavascript\n\nBind a on change event to your Department select . \nIf the select changes you get the value selected.\nWhen you get the value, you have to send it to the server through an AJAX request.\n\nFlask\n\nImplement a method that reads the value and loads the associated Subdepartments.\nSend a JSON response to the view with your Subdepartments\n\nJavascript\n\nIn your AJAX request implement a success function. This function by default has as first parameter the data received from the server. Loop over them and append them to the wished select.","Q_Score":0,"Tags":"python,flask,flask-admin","A_Id":34786896,"CreationDate":"2016-01-14T10:05:00.000","Title":"Load a select list when selecting another select","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In tensorflow, I would like to rotate an image from a random angle, for data augmentation. But I don't find this transformation in the tf.image module.","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28208,"Q_Id":34801342,"Users Score":0,"Answer":"For rotating an image or a batch of images counter-clockwise by multiples of 90 degrees, you can use tf.image.rot90(image,k=1,name=None).\nk denotes the number of 90 degrees rotations you want to make.\nIn case of a single image, image is a 3-D Tensor of shape [height, width, channels] and in case of a batch of images, image is a 4-D Tensor of shape [batch, height, width, channels]","Q_Score":15,"Tags":"python,tensorflow","A_Id":53392066,"CreationDate":"2016-01-14T22:56:00.000","Title":"tensorflow: how to rotate an image for data augmentation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After installing unison from \/usr\/ports\/net\/unison with X11 disabled via make config, running the command unison -repeat watch \/dir\/mirror\/1 \/dir\/mirror\/2\nYields the message:\n\nFatal error: No file monitoring helper program found\n\nFrom here I decided to try using pkg to install unison-nox11 and this yields the same error message.\nI've also tried copying the fsmonitor.py file from unison-2.48.3.tar.gz to \/usr\/bin\/unison-fsmonitor and I got the following error:\n\nFatal error: Unexpected response 'Usage: unison-fsmonitor [options] root [path] [path]...' from the filesystem watcher (expected VERSION)\n\nRunning the command unison-fsmonitor version shows the message\n\nunsupported platform freebsd10\n\nAnyone have any ideas on how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":847,"Q_Id":34825214,"Users Score":1,"Answer":"I think the message is pretty clear: unison-fsmonitor can't be run on freebsd10 because it's not supported, so you can't use Unison with the -repeat option.\nSince it's just written in Python, though, I don't see why it shouldn't be supported. Maybe message the developer.","Q_Score":1,"Tags":"python,freebsd,ports,unison","A_Id":36164028,"CreationDate":"2016-01-16T08:56:00.000","Title":"Using Unison \"-repeat watch\" in FreeBSD (10.2) after installing from ports yields error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I can't use normal tools and technics to measure the performance of a coroutine because the time it takes at await should not be taken in consideration (or it should just consider the overhead of reading from the awaitable but not the IO latency).\nSo how do measure the time a coroutine takes ? How do I compare 2 implementations and find the more efficent ? What tools do I use ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5793,"Q_Id":34826533,"Users Score":0,"Answer":"If you only want to measure performance of \"your\" code, you could used approach similar to unit testing - just monkey-patch (even patch + Mock) the nearest IO coroutine with Future of expected result. \nThe main drawback is that e.g. http client is fairly simple, but let's say momoko (pg client)... it could be hard to do without knowing its internals, it won't include library overhead. \nThe pro are just like in ordinary testing:\n\nit's easy to implement, \nit measures something ;), mostly one's implementation without overhead of third party libraries,\nperformance tests are isolated, easy to re-run,\nit's to run with many payloads","Q_Score":16,"Tags":"python,performance-testing,trace,python-asyncio","A_Id":34839535,"CreationDate":"2016-01-16T11:41:00.000","Title":"How to measure Python's asyncio code performance?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a program that simulates governments and families in the medieval ages. People (represented by objects of the class Actor) are born, grow old, have kids, and die.\nThis means I need to track quite a few objects, and figure out some to e.g. call update_age() for every tracked person every year\/month\/week.\nThis brings up several problems. I need to find some way to iterate over the set of all tracked Actors. I also need to be able to dynamically add to that set, to account for births.\nMy first idea was to make an object Timekeeper with a method that calls update_age() for every object in the set of tracked objects. Then, in the main program loop, I would call the Timekeeper's method. However, this makes Timekeeper a singleton, a concept which is not always a good idea. Since I am only a novice programmer, I'd like to learn good design patterns now, rather than learn wrong.\nIt still leaves me with the problem of how to get a set\/list\/dictionary of all the tracked people to update.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":57,"Q_Id":34835172,"Users Score":2,"Answer":"If you're running a simulation, it is certainly reasonable design to have a single \"simulation engine\", with various components. As long as you don't implement these as application-wide singletons, you will be fine. This is actually a great example of what the advice to avoid singletons is actually all about! Not having these as singletons will allow, for example, running several simulations at once within the same process.\nOne of the common designs for a system such as yours is an event-based design. With such a design, you'll have a single event manager component for the simulation. It will support registering functions to be called given certain conditions, e.g. a given amount of simulation time has passed. You can then register your update_age() events to be fired off at intervals for each of the Actors in your simulation.\nIf you go this route, remember that you will need to be able to remove registered event handlers for Actors that are no longer relevant, e.g. if they die in the simulation. This can be done by creating a unique ID for each registered event, which can be used to remove it later.","Q_Score":2,"Tags":"python,oop,simulation","A_Id":34835543,"CreationDate":"2016-01-17T04:40:00.000","Title":"How to track and update a great many values efficiently?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"This is a beginner question. I am using \"import pandas as pd\" in IDLE,\nbut got the following error message \"ImportError: No module named 'pandas\", \nI don't know how to install the the pandas in IDLE. I run the same code in MAC linux command window, it worked. Not sure why not working in IDLE.\nThanks for the help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":716,"Q_Id":34845704,"Users Score":0,"Answer":"May be you are using different Python versions in IDLE and the command line, if this is the case, you should install Pandas for the Python version that you are using in IDLE","Q_Score":0,"Tags":"python,pandas,module","A_Id":34845928,"CreationDate":"2016-01-18T00:51:00.000","Title":"import pandas using IDLE error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have installation of python 2.7 and 3.3 side by side (C:\\Python27 and C:\\Python33). I am now trying to install virtualenv. \nPython2.7 is my default interpreter. Whenever I open a command prompt and type 'python' it brings up \"Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32\" for me. But when I am firing \"pip install virtualenv\", it is installing virtualenv inside python3.3 folder.\nI am quite surprised that my active interpreter is python2.7, but virtualenv installation is somehow getting inside python3.3 folder instead of expected python2.7 folder. Can anyone please explain this anomaly and suggest me how to install virtualenv inside python 2.7 ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1818,"Q_Id":34864038,"Users Score":1,"Answer":"I'd imagine your environment variables are set up to use the python2.7 environment variable for python and the path to the python3.3 pip for that, you either need to adjust those or use the full paths when using the tool as you require.","Q_Score":0,"Tags":"python,django,python-2.7,python-3.x","A_Id":34864106,"CreationDate":"2016-01-18T21:03:00.000","Title":"Installing virtualenv for Python2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to write a program using Python in Jupiter. To make things easy, it'd be better off writing a few subroutines (functions) and probably some user-defined classes first before writing the main script. How do I arrange them in Jupiter? Just each sub function\/class for a new line and write sequentially and then write main script below to call subroutines? I just wonder if this is the right way to use Jupyter.\nI am new to Jupyter and Python, but in Matlab, for instance, I would create a folder which contains all sub functions to be used. And I will also write a script inside the same folder to call these functions to accomplish the task. However, how do I achieve this in Python using Jupyter?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4032,"Q_Id":34864672,"Users Score":-1,"Answer":"The best thing to do for repeated code you want all your notebook to access is to add it to the profile directory. The notebook will load all scripts from that directory in order, so it's recommended you name files 01-<projname>.py if you want them to load in a certain order. All files in that directory will be loaded via exec which executes the file as though it were in your context, it's not a module load so globals will squash each other and all of the model context will be in your local namespace afterwards (similar to an import * effect).\nTo find your profile directory the docs recommend you use ipython locate profile <my_profile_name>. This will tell you where you can place the script.","Q_Score":3,"Tags":"python,ipython,ipython-notebook,jupyter,jupyter-notebook","A_Id":34864812,"CreationDate":"2016-01-18T21:48:00.000","Title":"In Jupyter notebook, how do I arrange subroutines in order to write a project efficiently?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am on ubuntu 15.10. I notice that i have many python versions installed. Is it safe now to remove 2.7 completely? And how to make 3.5 the default one? I ask this because i think it messes up my django installation because django gets intsalled in share directory.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":57,"Q_Id":34872610,"Users Score":2,"Answer":"A lot of application still require Python 2.7 and are not yet compatible with Python3. So it really depends on what you do on the server (Only running Django?).\nOne solution would be to use virtualenv so that you do not depend on which python version is installed in your server, and you totally control all the packages.\nLook for django + virtualenv, you will find a lot of tutorials.","Q_Score":0,"Tags":"python,django,ubuntu","A_Id":34872786,"CreationDate":"2016-01-19T09:09:00.000","Title":"can python 2.7 be removed completely now?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For running python2 all I do is activate the required conda environment and just type idle. It automatically opens IDLE for python 2.7. But I can't figure out how to do this for Python 3. I have python 3.5 installed in my environment.\nI used conda create -n py35 anaconda for install installing python 3.5 .","AnswerCount":3,"Available Count":1,"Score":0.3215127375,"is_accepted":false,"ViewCount":14423,"Q_Id":34881105,"Users Score":5,"Answer":"Type idle3 instead of idle from your conda env.","Q_Score":6,"Tags":"python-3.x,anaconda,python-idle,conda","A_Id":47986798,"CreationDate":"2016-01-19T15:49:00.000","Title":"How to run IDLE for python 3 in a conda environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I am trying to add RDKit to my project in PyCharm. I have found that if you are using interpreter \/usr\/bin\/python2.7 PyCharm will try to install stuff using the pip. While, RDKit requires conda. I have tried to change the interpreter to conda, but RDKit is either not on the list or it can't open the URL with the repo. Does anyone know how to fix that?\nBy the way, is it possible while keeping the interpreter \/usr\/bin\/python2.7 to make it use anything else (not pip), while installing stuff?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3938,"Q_Id":34898422,"Users Score":0,"Answer":"Another option is to select the existing virtual environment when you create a new project in PyCharm. Once you go through the steps that Anna laid out above, the \"Previously configured interpreter\" section of the \"Create Project\" screen should show the ~\/anaconda\/envs\/my-rdkit-env\/bin\/python as an option.","Q_Score":5,"Tags":"python,pycharm,rdkit","A_Id":68302546,"CreationDate":"2016-01-20T11:10:00.000","Title":"How to add RDKit to project in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django website running on an Amazon EC2 instance. I want to add an EBS. In order to do that, I need to change the location of my PGDATA directory if I understand well. The new PGDATA path should be something like \/vol\/mydir\/blabla.\nI absolutely need to keep the data safe (some kind of dump could be useful). \nDo you have any clues on how I can do that ? I can't seem to find anything relevant on the internet.\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":34905744,"Users Score":0,"Answer":"Ok, thanks for your answers, I used : \nfind . -name \"postgresql.conf\" to find the configuration find, which was located into the \"\/etc\/postgresql\/9.3\/main\" folder. There is also pg_lsclusters if you want to show the directory data.\nThen I edited that file putting the new path, restarted postgres and imported my old DB.","Q_Score":1,"Tags":"python,django,postgresql,amazon-ec2","A_Id":34922249,"CreationDate":"2016-01-20T16:46:00.000","Title":"Django PostgreSQL : migrating database to a different directory","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run sudo pip install --upgrade six I run into the issue below:\n2016-01-20 18:29:48|optim $ sudo pip install --upgrade six\n    Collecting six\n      Downloading six-1.10.0-py2.py3-none-any.whl\n    Installing collected packages: six\n      Found existing installation: six 1.4.1\n    Detected a distutils installed project ('six') which we cannot uninstall. The metadata provided by distutils does not contain a list of files which have been installed, so pip does not know which files to uninstall.\n\nI have Python 2.7, and I'm on Mac OS X 10.11.1.\nHow can I make this upgrade successful?\n(There are other kind of related posts, but they do not actually have a solution to this same error.)\nEDIT:\nI am told I can remove six manually by removing things from site-packages. These are the files in site-packages that begin with six:\nsix-1.10.0.dist-info, six-1.9.0.dist-info, six.py, six.py.\nAre they all correct\/safe to remove?\nEDIT2:\nI decided to remove those from site-packages, but it turns out the existing six that cannot be installed is actually in\n\/System\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/Extras\/lib\/python.\nThere I see the files:\nsix-1.4.1-py2.7.egg-info, six.py, six.pyc\nbut doing rm on them (with sudo, even) gives Operation not permitted.\nSo now the question is, how can I remove those files, given where they are?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6127,"Q_Id":34912784,"Users Score":1,"Answer":"I, too, have had some issues with installing modules, and I sometimes find that it helps just to start over. In this case, it looks like you already have some of the 'six' module, but isn't properly set up, so if sudo pip uninstall six yields the same thing, go into your directory and manually delete anything related to six, and then try installing it. You may have to do some digging where you have your modules are stored (or have been stored, as pip can find them in different locations).","Q_Score":5,"Tags":"python,installation,pip,upgrade,six","A_Id":34912892,"CreationDate":"2016-01-20T23:40:00.000","Title":"Python - Cannot upgrade six, issue uninstalling previous version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm currently creating a Snake game on Python using the TKinter library.\nSo right now, I've implemented the movements, the food system, and the score system. I still need some help on how I can make the snake grow when it eats the food.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1681,"Q_Id":34914142,"Users Score":0,"Answer":"I do not see the associated code that actually displays the current position of the snake on the screen and remove it after movement, but this is where you can change the size if you make the length of the snake variable and have it drawn and removed in an iterate fashion. When food is eaten, you can simply increase the size of the snake length variable and pause the erasing of the snake movement as it proceeds along its vector until the desired growth has occurred, at which time removal can proceed at the new length rate. Please clarify the part of the code that actually renders the snakes position.","Q_Score":1,"Tags":"python,tkinter","A_Id":34914501,"CreationDate":"2016-01-21T02:03:00.000","Title":"Need help for a Python Snake game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on a machine learning project, and I would like to save my IPython files with the rest of my scripts. However, I have been unable to find any information on how to change the path that IPython files are saved to. \"ipython locate\" only gives me the location they are saved to, and does not appear to give me a way to change it, and the iPython editor does not have a file selector that I can use to change the save path. I am using Windows 10. Any help would be appreciated.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1705,"Q_Id":34939193,"Users Score":0,"Answer":"By default ipython and jupyter set the top of the working tree to the current directory at the time of launching the notebook server.  You can change this by setting c.NotebookApp.notebook_dir in the either the .ipython\/profile_XXX\/ipython_notebook_config.py or .jupyter\/jupyter_notebook_config.py (*nix\/Mac - not sure where these are located on Windows).\nAs long as the top of working tree includes the subdirectory with your scripts then you can just use the cmd\/explorer to move the .ipynb to your scripts directory and then browse http:\/\/localhost:XXXX\/tree to open the ipython notebook.","Q_Score":0,"Tags":"python,ipython","A_Id":34939512,"CreationDate":"2016-01-22T04:46:00.000","Title":"Save IPython file to a particular directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have an HTTP server created by the Tornado framework. I need to update\/reload this server without any connection lost and shutdown. \nI have no idea how to do it.\nCould you get me any clue?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":583,"Q_Id":34949364,"Users Score":1,"Answer":"Easy way, do it with nginx.\n\nStart a latest tornado server.\nRedirect all new connections to the new tornado server.(Change nginx configure file and reload with nginx -s reload)\nTell the old tornado server shutdown itself if all connections are closed.\n\nHard way\nIf you want to change your server on the fly, maybe you could find a way by reading nginx's source code, figure out how nginx -s reload works, but I think you need to do lots of work.","Q_Score":0,"Tags":"python,tornado,upgrade","A_Id":34960704,"CreationDate":"2016-01-22T14:44:00.000","Title":"Graceful reload of python tornado server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When it comes to normal ANNs, or any of the standard machine learning techniques, I understand what the training, testing, and validation sets should be (both conceptually, and the rule-of-thumb ratios). However, for a bidirectional LSTM (BLSTM) net, how to split the data is confusing me.\nI am trying to improve prediction on individual subject data that consists of monitored health values. In the simplest case, for each subject, there is one long time series of values (>20k values), and contiguous parts of that time series are labeled from a set of categories, depending on the current health of the subject. For a BLSTM, the net is trained on all of the data going forwards and backwards simultaneously. The problem then is, how does one split a time series for one subject? \n\nI can't just take the last 2,000 values (for example), because they might all fall into a single category.\nAnd I can't chop the time series up randomly, because then both the learning and testing phases would be made of disjointed chunks.\n\nFinally, each of the subjects (as far as I can tell) has slightly different (but similar) characteristics. So, maybe, since I have thousands of subjects, do I train on some, test on some, and validate on others? However, since there are inter-subject differences, how would I set up the tests if I was only considering one subject to start?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1028,"Q_Id":34970818,"Users Score":0,"Answer":"I think this has more to do with your particular dataset than Bi-LSTMs in general.\nYou're confusing splitting a dataset for training\/testing vs. splitting a sequence in a particular sample. It seems like you have many different subjects, which constitute a different sample. For a standard training\/testing split, you would split your dataset between subjects, as you suggested in the last paragraph.\nFor any sort of RNN application, you do NOT split along your temporal sequence; you input your entire sequence as a single sample to your Bi-LSTM. So the question really becomes whether such a model is well-suited to your problem, which has multiple labels at specific points in the sequence. You can use a sequence-to-sequence variant of the LSTM model to predict which label each time point in the sequence belongs to, but again you would NOT be splitting the sequence into multiple parts.","Q_Score":1,"Tags":"python,neural-network,time-series,keras,recurrent-neural-network","A_Id":45060104,"CreationDate":"2016-01-24T00:34:00.000","Title":"Training, testing, and validation sets for bidirectional LSTM (BLSTM)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do I remove all traces of legacy projects from PyCharm?\nBackground: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today.\nReason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'. \nI deleted the legacy project folders.\nI then opened the Pro Edition and went through the steps of creating a Django project called 'deals' with  a python3.4 interpreter in a virtualenv.\nIt didn't work, I got an error message saying something about a missing file, and in the PyCharm project explorer, all I could see was\n\ndeals\n.ideas \n\nSo I deleted it (ie. deleted the folders in both ~\/.virtualenvs\/deals and ~\/Projects\/deals).\nI tried again, although this time I got an interpreter with a number suffix, ie. python3.4 (1). \nI continued, and got the same empty file structure.\nI deleted both folders again, went and cleaned out the intepreters in Settings > Project Interpreters .\nI then tried again, getting 'new' interpreters,until I finally had python3.4 (5) \nPlus, along the way I also invalidated the caches and restarted.\n(ie. File > Invalidate Caches\/Restart)\nThen to prove if it works at all, I tried a brand new name 'junk'.\nThis time it worked fine, and I could see the Django folders in the PyCharm explorer. Great.\nBut I really want to work on a project called 'deals'.\nSo I deleted all the 'deal's folders again, and tried to create a deals Django project again.\nSame result.\nAfter googling, I went to the Settings > Project Structure > + Content Root, and pointed it to the folder at ~\/.virtual\/deals.\nOk, so now I could see the files in the virtual env, but there's no Django files, and plus, the project folder was separate to the virtualenv folder, eg\n\ndeals\n\ndeals (~\/project\/deals)       <- separate\ndeals (~\/.virtualenvs\/deals) <- separate\n\ndeals\ninit.py\nsettings.py\nurls.py\nwsgi.py\n\nmanage.py\n\n\nReally stuck now.\nAny advice on how to get this working please?\nEg. how do I\n(i) get it back to 'cleanskin' so that I can start up a Django project and get the proper folders in the project space.\n(ii) get it working with virtualenv, and ensure that the interpreter doesn't have a number suffix, such as python3.4(6)  \nMany thanks in advance,\nChris","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":16475,"Q_Id":34979145,"Users Score":9,"Answer":"You can clean out old PyCharm interpreters that are no longer associated with a project via Settings -> Project Interpreter, click on the gear in the top right, then click \"More\". This gives you a listing where you can get rid of old virtualenvs that PyCharm thinks are still around. This will prevent the \"(1)\", \"(2)\" part.\nYou don't want to make the virtualenv into the content root. Your project's code is the content root.\nAs a suggestion:\n\nClear out all the registered virtual envs\nMake a virtualenv, outside of PyCharm\nCreate a new project using PyCharm's Django template\n\nYou should then have a working example.","Q_Score":3,"Tags":"python,django,pycharm","A_Id":34993725,"CreationDate":"2016-01-24T17:42:00.000","Title":"PyCharm & VirtualEnvs - How To Remove Legacy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"How do I remove all traces of legacy projects from PyCharm?\nBackground: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today.\nReason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'. \nI deleted the legacy project folders.\nI then opened the Pro Edition and went through the steps of creating a Django project called 'deals' with  a python3.4 interpreter in a virtualenv.\nIt didn't work, I got an error message saying something about a missing file, and in the PyCharm project explorer, all I could see was\n\ndeals\n.ideas \n\nSo I deleted it (ie. deleted the folders in both ~\/.virtualenvs\/deals and ~\/Projects\/deals).\nI tried again, although this time I got an interpreter with a number suffix, ie. python3.4 (1). \nI continued, and got the same empty file structure.\nI deleted both folders again, went and cleaned out the intepreters in Settings > Project Interpreters .\nI then tried again, getting 'new' interpreters,until I finally had python3.4 (5) \nPlus, along the way I also invalidated the caches and restarted.\n(ie. File > Invalidate Caches\/Restart)\nThen to prove if it works at all, I tried a brand new name 'junk'.\nThis time it worked fine, and I could see the Django folders in the PyCharm explorer. Great.\nBut I really want to work on a project called 'deals'.\nSo I deleted all the 'deal's folders again, and tried to create a deals Django project again.\nSame result.\nAfter googling, I went to the Settings > Project Structure > + Content Root, and pointed it to the folder at ~\/.virtual\/deals.\nOk, so now I could see the files in the virtual env, but there's no Django files, and plus, the project folder was separate to the virtualenv folder, eg\n\ndeals\n\ndeals (~\/project\/deals)       <- separate\ndeals (~\/.virtualenvs\/deals) <- separate\n\ndeals\ninit.py\nsettings.py\nurls.py\nwsgi.py\n\nmanage.py\n\n\nReally stuck now.\nAny advice on how to get this working please?\nEg. how do I\n(i) get it back to 'cleanskin' so that I can start up a Django project and get the proper folders in the project space.\n(ii) get it working with virtualenv, and ensure that the interpreter doesn't have a number suffix, such as python3.4(6)  \nMany thanks in advance,\nChris","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":16475,"Q_Id":34979145,"Users Score":0,"Answer":"In addition to the answer above, which removed the Venv from the Pycharm list, I also had to go into my ~\/venvs directory and delete the associated directory folder in there.\nThat did the trick.","Q_Score":3,"Tags":"python,django,pycharm","A_Id":60949461,"CreationDate":"2016-01-24T17:42:00.000","Title":"PyCharm & VirtualEnvs - How To Remove Legacy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"How do I remove all traces of legacy projects from PyCharm?\nBackground: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today.\nReason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'. \nI deleted the legacy project folders.\nI then opened the Pro Edition and went through the steps of creating a Django project called 'deals' with  a python3.4 interpreter in a virtualenv.\nIt didn't work, I got an error message saying something about a missing file, and in the PyCharm project explorer, all I could see was\n\ndeals\n.ideas \n\nSo I deleted it (ie. deleted the folders in both ~\/.virtualenvs\/deals and ~\/Projects\/deals).\nI tried again, although this time I got an interpreter with a number suffix, ie. python3.4 (1). \nI continued, and got the same empty file structure.\nI deleted both folders again, went and cleaned out the intepreters in Settings > Project Interpreters .\nI then tried again, getting 'new' interpreters,until I finally had python3.4 (5) \nPlus, along the way I also invalidated the caches and restarted.\n(ie. File > Invalidate Caches\/Restart)\nThen to prove if it works at all, I tried a brand new name 'junk'.\nThis time it worked fine, and I could see the Django folders in the PyCharm explorer. Great.\nBut I really want to work on a project called 'deals'.\nSo I deleted all the 'deal's folders again, and tried to create a deals Django project again.\nSame result.\nAfter googling, I went to the Settings > Project Structure > + Content Root, and pointed it to the folder at ~\/.virtual\/deals.\nOk, so now I could see the files in the virtual env, but there's no Django files, and plus, the project folder was separate to the virtualenv folder, eg\n\ndeals\n\ndeals (~\/project\/deals)       <- separate\ndeals (~\/.virtualenvs\/deals) <- separate\n\ndeals\ninit.py\nsettings.py\nurls.py\nwsgi.py\n\nmanage.py\n\n\nReally stuck now.\nAny advice on how to get this working please?\nEg. how do I\n(i) get it back to 'cleanskin' so that I can start up a Django project and get the proper folders in the project space.\n(ii) get it working with virtualenv, and ensure that the interpreter doesn't have a number suffix, such as python3.4(6)  \nMany thanks in advance,\nChris","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":16475,"Q_Id":34979145,"Users Score":0,"Answer":"When virtual env is enabled, there will be a 'V' symbol active in the bottom part of pycharm in the same line with terminal and TODO. When you click on the 'V' , the first one will be enabled with a tick mark. Just click on it again. Then it will get disabled. As simple as that.","Q_Score":3,"Tags":"python,django,pycharm","A_Id":63129392,"CreationDate":"2016-01-24T17:42:00.000","Title":"PyCharm & VirtualEnvs - How To Remove Legacy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In my program, A serve-forever daemon is restarted in a subprocess.\nThe program itself is a web service, using port 5000 by default.\nI don't know the detail of the start script of that daemon, but it seems to inherit the socket listening on port 5000.\nSo if I were to restart my program, I'll find that the port is already occupied by the daemon process.\nNow I am considering to fine tune the subprocess function to close the inherited socket FD, but I don't know how to get the FD in the first place.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":429,"Q_Id":34988678,"Users Score":1,"Answer":"It seems like a permission issue. The subprocess is probably running as an other user and therefore you will not have access to the process. Use sudo ps xauw |grep [processname] to figure as under what user the daemon process is running.","Q_Score":0,"Tags":"python,linux,sockets,subprocess","A_Id":34989073,"CreationDate":"2016-01-25T09:08:00.000","Title":"How to get a socket FD according to the port occupied in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have multiple api which we have provided to android developers.\nLike :\n1) Creating  Business card API\n2) Creating Contacts API\nSo these api working fine when app is online. So our requirement is to handle to create business card and contacts when app is offline.\nWe are following steps but not sure:-\n1) Android developer store the business card when app offline and send this data to server using separate offline business card api when app comes online.\n2) Same we do for creating contacts offline using offline contact api.\nMy problem is I want do in one api call to send all data to server and do operation.\nIs this approach will right?? Also please suggest what is the best approach to handle offline data. Also how to handle syncing data when app would come online??\nPlease let me know if I could provide more information.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1524,"Q_Id":34992856,"Users Score":0,"Answer":"I'm confused as to how you're approaching this.  My understanding is that when the app is offline you want to \"queue up\" any API requests that are sent.\nYour process seems fine however without knowing the terms around the app being \"offline\" it's hard to understand if this best.\nAssuming you're meaning the server(s) holding the application are offline you're correct you want a process in the android app that will store the request until the application becomes online.  However, this can be dangerous for end users.  They should be receiving a message on the application being offline and to \"try again later\" as it were.  The fear being they submit a request for x new contacts to be queued and then re-submit not realizing the application was offline.\nI would suggest you have the android app built to either notify the user of the app being down or provide some very visible notification that requests are queued locally on their phone until the application becomes available and for them to view\/modify\/delete said locally cached requests until the application becomes available.  When the API becomes available a notification can be set for users to release their queue on their device.","Q_Score":3,"Tags":"python,django,django-rest-framework,offlineapps","A_Id":34996085,"CreationDate":"2016-01-25T12:39:00.000","Title":"how to design rest api which handle offline data","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"In Pyspark, I am trying to broadcast a large numpy array of size around 8GB. But it fails with the error \"OverflowError: cannot serialize a string larger than 4GiB\". I have 15g in executor memory and 25g driver memory. I have tried using default and kyro serializer. Both didnot work and show same error. \nCan anyone suggest how to get rid of this error and the most efficient way to tackle large broadcast variables?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3217,"Q_Id":34998280,"Users Score":1,"Answer":"This is not the problem of PySpark, this is a limit of Spark implement. \nSpark use a scala array to store the broadcast elements, since the max Integer of Scala is 2*10^9, so the total string bytes is 2*2*10^9 = 4GB, you can view the Spark code.","Q_Score":1,"Tags":"python,apache-spark,python-3.4,pyspark","A_Id":35013791,"CreationDate":"2016-01-25T17:10:00.000","Title":"Broadcast large array in pyspark (~ 8GB)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am a new user of the Django Framework. I am currently building a REST API with the django_rest_framework. When starting my server I am getting deprecation warnings that I have no idea how to fix.\n\nRemovedInDjango110Warning: 'get_all_related_objects is an unofficial API that has been deprecated. You may be able to replace it with 'get_fields()'\n    for relation in opts.get_all_related_objects()\n\nThe above is the first of these. Does anyone know how to fix this issue. All I have in my API at the minute is standard rest calls using the built in ModelViewSet and I have also overwritten the default authentication & user system with my own so I have no idea why I'm getting these warnings as I have been using Django 1.9 from the start. \nI also got this:\n\nRemovedInDjango110Warning: render() must be called with a dict, not a RequestContext\n\nFrom my initial research this is related to templates. I am not using any templates so I don't know why this is coming up.\nCan anyone help me to fix these issues?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2418,"Q_Id":35002061,"Users Score":3,"Answer":"You don't have to \"fix\" Deprecation Warnings as they are, well, only warnings and things still work. However, if you'll decide to update they might break your app. So usually it's a good idea to rewrite the parts with warnings to new interfaces, that are hinted in those warnings if it's in your code. If it's in some side library you use, then you might want to wait if the library creator will update his\/her library in the next release.\nRegarding your particular warnings, unless you'll decide to update to Django 1.10, your code should work well.","Q_Score":4,"Tags":"python,django,rest,django-views,django-rest-framework","A_Id":35009997,"CreationDate":"2016-01-25T20:48:00.000","Title":"How to fix a Deprecation Warning in Django 1.9","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am not quite sure about how file-queue works. I am trying to use a large dataset like imagenet as input. So preloading data is not the case, so I am wondering how to use the file-queue. According to the tutorial, we can convert data to TFRecords file as input. Now we have a single big TFRecords file. So when we specify a FIFO queue for the reader, does it mean the program would fetch a batch of data each time and feed the graph instead of loading the whole file of data?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2670,"Q_Id":35004619,"Users Score":2,"Answer":"The amount of pre-fetching depends on your queue capacity. If you use string_input_producer for your filenames and batch for batching, you will have 2 queues - filename queue, and prefetching queue created by batch. Queue created by batch has default capacity of 32, controlled by batch(...,capacity=) argument, therefore it can prefetch up to 32 images. If you follow outline in TensorFlow official howto's, processing examples (everything after batch) will happen in main Python thread, whereas filling up the queue will happen in threads created\/started by batch\/start_queue_runners, so prefetching new data and running prefetched data through the network will occur concurrently, blocking when the queue gets full or empty.","Q_Score":3,"Tags":"python,deep-learning,tensorflow","A_Id":35004791,"CreationDate":"2016-01-25T23:46:00.000","Title":"reading a large dataset in tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"For a coding exercise I'm working on, I'm trying to compare two numbers and choose the one that has the larger number of significant digits. \nFor example: compare 2.37e+07 and 2.38279e+07, select 2.38279e+07 because it has more significant digits. \nI don't know how to implement this in Python. I considered counting the length of each number using len(str(NUMBER)), but this method returns \"10\" for both of the numbers above because it doesn't differentiate between zero and non-zero digits. \nHow can I compare the number of significant digits in Python?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1713,"Q_Id":35020609,"Users Score":2,"Answer":"A quick and dirty approach might be len(str(NUMBER).strip('0')) which will trim off any trailing zeros and count the remaining digits.\nTo discount the decimal point then you'd need len(str(NUMBER).replace('.','').strip('0'))\nHowever you need to bear in mind that in many cases converting a python float to a string can give you some odd behaviour, due to the way floating point numbers are handled.","Q_Score":4,"Tags":"python","A_Id":35020764,"CreationDate":"2016-01-26T17:57:00.000","Title":"Compare the number of significant digits in two numbers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed pytest into a virtual environment (using virtualenv) and am running it from that virtual environment, but it is not using the packages that I installed in that virtual environment. Instead, it is using the main system packages. (Using python -m unittest discover, I can actually run my tests with the right python and packages, but I want to use the py.test framework.)\nIs it possible that py.test is actually not running the pytest inside the virtual environment and I have to specify which pytest to run?\nHow to I get py.test to use only the python and packages that are in my virtualenv?\nAlso, since I have several version of Python on my system, how do I tell which Python that Pytest is using? Will it automatically use the Python within my virtual environment, or do I have to specify somehow?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":32064,"Q_Id":35045038,"Users Score":3,"Answer":"In my case I was obliged to leave the venv (deactivate), remove pytest (pip uninstall pytest), enter the venv (source \/my\/path\/to\/venv), and then reinstall pytest (pip install pytest). I don't known exacttly why pip refuse to install pytest in venv (it says it already present).\nI hope this helps","Q_Score":75,"Tags":"python,virtualenv,pytest","A_Id":39231653,"CreationDate":"2016-01-27T18:16:00.000","Title":"How do I use pytest with virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed pytest into a virtual environment (using virtualenv) and am running it from that virtual environment, but it is not using the packages that I installed in that virtual environment. Instead, it is using the main system packages. (Using python -m unittest discover, I can actually run my tests with the right python and packages, but I want to use the py.test framework.)\nIs it possible that py.test is actually not running the pytest inside the virtual environment and I have to specify which pytest to run?\nHow to I get py.test to use only the python and packages that are in my virtualenv?\nAlso, since I have several version of Python on my system, how do I tell which Python that Pytest is using? Will it automatically use the Python within my virtual environment, or do I have to specify somehow?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":32064,"Q_Id":35045038,"Users Score":95,"Answer":"There is a bit of a dance to get this to work:\n\nactivate your venv : source venv\/bin\/activate\ninstall pytest : pip install pytest\nre-activate your venv: deactivate && source venv\/bin\/activate\n\nThe reason is that the path to pytest is set by the sourceing the activate file only after pytest is actually installed in the venv. You can't set the path to something before it is installed.\nRe-activateing is required for any console entry points installed within your virtual environment.","Q_Score":75,"Tags":"python,virtualenv,pytest","A_Id":54597424,"CreationDate":"2016-01-27T18:16:00.000","Title":"How do I use pytest with virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The version of Linux I am working on has python 2.6 by default, and we installed 2.7 on it in a separate folder. \nIf I want to run a .py script, how do I tell it to use 2.7 instead of the default?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":7476,"Q_Id":35047691,"Users Score":2,"Answer":"Use update-alternatives --config python and shoose python2.7 from choices.\nIf you need to remove it use update-alternatives --remove python \/usr\/bin\/python2.7.","Q_Score":3,"Tags":"python,linux","A_Id":35047953,"CreationDate":"2016-01-27T20:48:00.000","Title":"How to select which version of python I am running on Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded a python program from git.\nThis program is python 3. \nOn my laptop i have both python 2.7 and python 3.4. Python 2.7 is default version.\nwhen i want run this program in terminal it gives some module errors because of it used the wrong version.\nhow can i force an name.py file to open in an (non) default version of python.\nI have tried so search on google but this without any result because of lack of search tags.\nalso just trying things like .\/name.py python3 but with same result(error)","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7570,"Q_Id":35048996,"Users Score":0,"Answer":"When you type \"python\", your path is searched to run this version. But, if you specify the absolute path of the other python, you run it the way you want it.\nHere, in my laptop, I have \/home\/user\/python3_4 and \/home\/user\/python2_7. If I type python, the 3.4 version is executed, because this directory is set in my path variable. When I want to test some scripts from the 2.7 version, I type in the command line: \/home\/user\/python2_7\/bin\/python script.py. (Both directory were chosen by me. It's not the default for python, of course).\nI hope it can help you.","Q_Score":1,"Tags":"python,terminal","A_Id":35049070,"CreationDate":"2016-01-27T22:06:00.000","Title":"Run python program from terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have downloaded a python program from git.\nThis program is python 3. \nOn my laptop i have both python 2.7 and python 3.4. Python 2.7 is default version.\nwhen i want run this program in terminal it gives some module errors because of it used the wrong version.\nhow can i force an name.py file to open in an (non) default version of python.\nI have tried so search on google but this without any result because of lack of search tags.\nalso just trying things like .\/name.py python3 but with same result(error)","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":7570,"Q_Id":35048996,"Users Score":0,"Answer":"The Method of @Tom Dalton and @n1c9 work for me!\npython3 name.py","Q_Score":1,"Tags":"python,terminal","A_Id":35964107,"CreationDate":"2016-01-27T22:06:00.000","Title":"Run python program from terminal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a .csv file on disk, formatted so that I can read it into a pandas DataFrame easily, to which I periodically write rows. I need this database to have a row index, so every time I write a new row to it I need to know the index of the last row written. \nThere are plenty of ways to do this: \n\nI could read the entire file into a DataFrame, append my row, and then print the entire DataFrame to memory again. This might get a bit slow as the database grows.\nI could read the entire index column into memory, and pick the largest value off, then append my row to the .csv file. This might be a little better, depending on how column-reading is implemented.\n\nI am curious if there is a way to just get that one cell directly, without having to read a whole bunch of extra information into memory. Any suggestions?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":511,"Q_Id":35063946,"Users Score":1,"Answer":"Reading the entire index column will still need to read and parse the whole file.\nIf no fields in the file are multiline, you could scan the file backwards to find the first newline (but with a check if there is a newline past the data). The value following that newline will be your last index.\nStoring the last index in another file would also be a possibility, but you would have to make sure both files stay consistent.\nAnother way would be to reserve some (fixed amount of) bytes at the beginning of the file and write (in place) the last index value there as a comment. But your parser would have to support comments, or be able to skip rows.","Q_Score":2,"Tags":"python-2.7,csv,pandas,pandasql","A_Id":35064268,"CreationDate":"2016-01-28T14:17:00.000","Title":"reading the last index from a csv file using pandas in python2.7","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been using iPython (aka Jupyter) quite a bit lately for data analysis and some machine learning. But one big headache is copying results from the notebook app (browser) into either Excel or Google Sheets so I can manipulate results or share them with people who don't use iPython.\nI know how to convert results to csv and save. But then I have to dig through my computer, open the results and paste them into Excel or Google Sheets. That takes too much time.\nAnd just highlighting a resulting dataframe and copy\/pasting usually completely messes up the formatting, with columns overflowing. (Not to mention the issue of long resulting dataframes being truncated when printed in iPython.)\nHow can I easily copy\/paste an iPython result into a spreadsheet?","AnswerCount":6,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":17289,"Q_Id":35074209,"Users Score":37,"Answer":"Try using the to_clipboard() method. E.g., for a dataframe, df: df.to_clipboard() will copy said dataframe to your clipboard. You can then paste it into Excel or Google Docs.","Q_Score":19,"Tags":"python,excel,google-sheets,ipython,ipython-notebook","A_Id":35090610,"CreationDate":"2016-01-28T23:33:00.000","Title":"How to copy\/paste a dataframe from iPython into Google Sheets or Excel?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been using iPython (aka Jupyter) quite a bit lately for data analysis and some machine learning. But one big headache is copying results from the notebook app (browser) into either Excel or Google Sheets so I can manipulate results or share them with people who don't use iPython.\nI know how to convert results to csv and save. But then I have to dig through my computer, open the results and paste them into Excel or Google Sheets. That takes too much time.\nAnd just highlighting a resulting dataframe and copy\/pasting usually completely messes up the formatting, with columns overflowing. (Not to mention the issue of long resulting dataframes being truncated when printed in iPython.)\nHow can I easily copy\/paste an iPython result into a spreadsheet?","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":17289,"Q_Id":35074209,"Users Score":1,"Answer":"Paste the output to an IDE like Atom and then paste in Google Sheets\/Excel","Q_Score":19,"Tags":"python,excel,google-sheets,ipython,ipython-notebook","A_Id":66239699,"CreationDate":"2016-01-28T23:33:00.000","Title":"How to copy\/paste a dataframe from iPython into Google Sheets or Excel?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having some trouble tracking down where my pip modules are going, and I finally found what seems to be the root of the issue when I did a \"pip list\" command in two separate cmd windows.\nOne window was running as admin, and the other not.  They showed two completely different lists of modules installed.  When I ran \"python\" in each window, one started python 3.4.3, and the other python 3.5.0a2.\nThe reason I'm doing this in two separate types of windows is because I'm running into \"access is denied\" errors when trying to install modules with pip.  (For example, requests.)\nWhen I check my PATH variable, it points to C:\\Program Files\\Python 3.5.  Is there an admin PATH variable somewhere that I can modify so that I can run python3.5 as admin?\nCan someone help me understand how I can get around access is denied without using admin cmd, or how I can change admin Path variable, or something?\nI'm running Windows 7, 64 bit, with several versions of python installed. 2.7, 3.3, 3.4.3, 3.5.0a2.  I can get more refined details if I need to.\nEdit Addition:  I'd like to use virtualenv with python3.5, but when I try to install it with pip install virtualenv, I get Permission denied error.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":35079670,"Users Score":0,"Answer":"I couldn't find a solution anywhere to this, so I just deleted every trace of Python from my computer and installed Anaconda.\nI don't feel this was a very informed or optimal solution, but I now have consistent behavior in various places.  Also, the Anaconda installer seems much more smooth than the pip installer.","Q_Score":0,"Tags":"python,windows","A_Id":35080840,"CreationDate":"2016-01-29T08:10:00.000","Title":"Different versions of python when running cmd as admin, how do I alter admin version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm having some trouble tracking down where my pip modules are going, and I finally found what seems to be the root of the issue when I did a \"pip list\" command in two separate cmd windows.\nOne window was running as admin, and the other not.  They showed two completely different lists of modules installed.  When I ran \"python\" in each window, one started python 3.4.3, and the other python 3.5.0a2.\nThe reason I'm doing this in two separate types of windows is because I'm running into \"access is denied\" errors when trying to install modules with pip.  (For example, requests.)\nWhen I check my PATH variable, it points to C:\\Program Files\\Python 3.5.  Is there an admin PATH variable somewhere that I can modify so that I can run python3.5 as admin?\nCan someone help me understand how I can get around access is denied without using admin cmd, or how I can change admin Path variable, or something?\nI'm running Windows 7, 64 bit, with several versions of python installed. 2.7, 3.3, 3.4.3, 3.5.0a2.  I can get more refined details if I need to.\nEdit Addition:  I'd like to use virtualenv with python3.5, but when I try to install it with pip install virtualenv, I get Permission denied error.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":226,"Q_Id":35079670,"Users Score":1,"Answer":"Although you are running Python on a Windows Machine - I am assuming a Client i.e. Desktop. You should go and look at Virtual Python Environments - there are lots of resources documenting how this is accomplished... \nYou are directly manipulating the System copy of the Python Environment and 1 mistake will screw the whole lot up. Much better (and safer) for either project\/Projects(s) to share a Virtual Env - which you can then either upgrade using pip requirements.","Q_Score":0,"Tags":"python,windows","A_Id":35079769,"CreationDate":"2016-01-29T08:10:00.000","Title":"Different versions of python when running cmd as admin, how do I alter admin version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to measure execution time for some queries and add this data to responses, like: {\"meta\": {\"execution_time_in_ms\": 500 ...}} I know how to add fields to tastypie's responses, but I haven't idea how to measure time in it, where I should initialize the timer and where I should stop it. Any ideas?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":107,"Q_Id":35105825,"Users Score":1,"Answer":"That'll only work for list endpoints though. My advice is to use a middleware to add X- headers, it's a cleaner, more generalized solution.","Q_Score":1,"Tags":"python,django,tastypie","A_Id":35167054,"CreationDate":"2016-01-30T19:03:00.000","Title":"Tastypie. How to add time of execution to responses?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For the moment I've created an Python web application running on uwsgi with a frontend created in EmberJS. There is also a small python script running that is controlling I\/O and serial ports connected to the beaglebone black.\nThe system is running on debian, packages are managed and installed via ansible, the applications are updated also via some ansible scripts. With other words, updates are for the moment done by manual work launching the ansible scripts over ssh.\nI'm searching now a strategy\/method to update my python applications in an easy way and that can also be done by our clients (ex: via webinterface). A good example is the update of a router firmware. I'm wondering how I can use a similar strategy for my python applications.\nI checked Yocto where I can build my own linux with but I don't see how to include my applications in those builds, and I don't wont to build a complete image in case of hotfixes.\nAnyone who has a similar project and that would like to share with me some useful information to handle some upgrade strategies\/methods?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":141,"Q_Id":35136140,"Users Score":0,"Answer":"A natural strategy would be to make use of the package manager also used for the rest of the system. The various package managers of Linux distributions are not closed systems. You can create your own package repository containing just your application\/scripts and add it as a package source on your target. Your \"updater\" would work on top of that.\nThis is also a route you can go when using yocto.","Q_Score":1,"Tags":"python,deployment,updates,beagleboneblack,yocto","A_Id":35147597,"CreationDate":"2016-02-01T17:02:00.000","Title":"Update strategy Python application + Ember frontend on BeagleBone","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using atom IDE for my python projects.\nthere are auto-complete suggestions in some cases but I'd like to know if it's possible to have a list of all possible functions that a imported module has, for instance if i import \nimport urllib\nwhen I type urlib. and press (ctrl+tab) would like to see a list with the possible functions\/methods to use.\nIs that possible?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.3215127375,"is_accepted":false,"ViewCount":23531,"Q_Id":35150683,"Users Score":5,"Answer":"Atom is getting various modifications. Autocomplete-python package is a handy package which helps code faster. The way to install it has changed.\nIn all new Atom editor go to File->Settings->install\nsearch for autocomplete-python\nand click on install. Voila its done, restart Atom is not required and you will see the difference with next time you edit python code.\nDeb","Q_Score":10,"Tags":"python,autocomplete,ide,atom-editor","A_Id":41311935,"CreationDate":"2016-02-02T10:19:00.000","Title":"python - atom IDE how to enable auto-complete code to see all functions from a module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using atom IDE for my python projects.\nthere are auto-complete suggestions in some cases but I'd like to know if it's possible to have a list of all possible functions that a imported module has, for instance if i import \nimport urllib\nwhen I type urlib. and press (ctrl+tab) would like to see a list with the possible functions\/methods to use.\nIs that possible?\nThanks","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":23531,"Q_Id":35150683,"Users Score":14,"Answer":"I found the solution for my own question.\nActually I had the wrong plugin installed!\nSo, in the IDE, edit->preferences, and in the packages section just typed autocomplete-python and press install button.\nAfter restart Atom, it should start work :)","Q_Score":10,"Tags":"python,autocomplete,ide,atom-editor","A_Id":35151184,"CreationDate":"2016-02-02T10:19:00.000","Title":"python - atom IDE how to enable auto-complete code to see all functions from a module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"New to python and PyCharm, but trying to use if for an online course.\nAfter opening an assignment .py document (attached image), I get an error message if I open the python console:\n\nError:Cannot start process, the working directory '\\c:...\\python_lab.py' is not a directory.\n\nObviously, it is not - it is a python file, but I don't know how to address the problem.\nHow can I assign a working directory that is functional from within PyCharm, or in general, what is the meaning of the error message?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":882,"Q_Id":35158809,"Users Score":1,"Answer":"Create new project\nCreate new py file in your project or copy your file to under the project directory\n\nSecond option would be import existing project by selecting a directory where you have your python file.","Q_Score":3,"Tags":"python,python-2.7,pycharm,python-2.x","A_Id":35158959,"CreationDate":"2016-02-02T16:31:00.000","Title":"How to assign a directory to PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"New to python and PyCharm, but trying to use if for an online course.\nAfter opening an assignment .py document (attached image), I get an error message if I open the python console:\n\nError:Cannot start process, the working directory '\\c:...\\python_lab.py' is not a directory.\n\nObviously, it is not - it is a python file, but I don't know how to address the problem.\nHow can I assign a working directory that is functional from within PyCharm, or in general, what is the meaning of the error message?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":882,"Q_Id":35158809,"Users Score":1,"Answer":"Looks like your default working directory is a .tmp folder. Best way to fix this is to create a new project, just make sure it's not pointing to a .tmp directory.","Q_Score":3,"Tags":"python,python-2.7,pycharm,python-2.x","A_Id":35158965,"CreationDate":"2016-02-02T16:31:00.000","Title":"How to assign a directory to PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to release a subset of my code for external use. Only certain functions or methods should be used (or even seen) by the external customer. Is there a way to do this in Python? \nI thought about wrapping the code I want removed in an if __debug__: and then creating a .pyc file with py_compile or compileall and then recreate source code from the new byte-code using uncompyle2. The __debug__ simply creates an if False condition which gets stripped out by the \"compiler\". I couldn't figure out how to use those \"compiler modules\" with the -O option.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":35163501,"Users Score":1,"Answer":"I don't know if there are any standard tools for doing this, but it shouldn't be too difficult to mark the sections with appropriately coded remarks and then run all your files through a script that outputs a new set of files omitting the lines between those remarks.","Q_Score":3,"Tags":"python,python-2.7","A_Id":35163645,"CreationDate":"2016-02-02T20:47:00.000","Title":"How to remove code from external release","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have seen that transpose and reshape together can help but I don't know how to use.\nEg. dimshuffle(0, 'x')\nWhat is its equivalent by using transpose and reshape? or is there a better way?\nThank you.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4682,"Q_Id":35163789,"Users Score":0,"Answer":"tf.transpose is probably what you are looking for.   it takes an arbitrary permutation.","Q_Score":7,"Tags":"python,numpy,theano,tensorflow","A_Id":50763868,"CreationDate":"2016-02-02T21:04:00.000","Title":"Theano Dimshuffle equivalent in Google's TensorFlow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to verify the style of an element i.e. the color of the text shown in a textview. Whether it is black or blue ex. textColor or textSize. This information is not listed in the uiautomatorviewer. \nI can get the text using elem.get_attribute(\"text\") as the text value is seen in the Node Detail.  Is there a way to check for the style attributes?( I can do this fairly easy with straight selenium.)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1771,"Q_Id":35164413,"Users Score":1,"Answer":"Update. As it turns out that cannot be done with appium webdriver.\nFor those of you who are wondering this is the answer I rec'd from the appium support group:\nThis cannot be done by appium as underlying UIAutomator framework does not allow us to do so.\nIn app's native context this cannot be done\nIn app's webview's context this will be same as below because webview is nothing but a chromeless browser session inside and app\n print searchBtn.value_of_css_property(\"background-color\").\nSummary \nfor element inside NATIVE CONTEXT ==>> NO\nfor element inside WEBVIEW CONTEXT ==>> YES\nHope this helps.","Q_Score":1,"Tags":"android,python,appium,python-appium","A_Id":35277434,"CreationDate":"2016-02-02T21:48:00.000","Title":"Appium Android UI testing - how to verify the style attribute of an element?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a file that is all strings and I want to loop through the file and check its contents against another file. Both files are too big to place in the code so I have to open each file with open method and then turn each into a loop that iterates over the file word for word (in each file) and compare every word for every word in other file. Any ideas how to do this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":69,"Q_Id":35168823,"Users Score":1,"Answer":"If the files are both sorted, or if you can produce sorted versions of the files, then this is relatively easy. Your simplest approach (conceptually speaking) would be to take one word from file A, call it a, and then read a word from file B, calling it b. Either b is alphabetically prior to a, or it is after a, or they are the same. If they are the same, add the word to a list you're maintaining. If b is prior to a, read b from file B until b >= a. If equal, collect that word. If a < b, obviously, read a from A until a >= b, and collect if equal. \nSince file size is a problem, you might need to write your collected words out to a results file to avoid running out of memory. I'll let you worry about that detail. \nIf they are not sorted and you can't sort them, then it's a harder problem. The naive approach would be to take a word from A, and then scan through B looking for that word. Since you say the files are large, this is not an attractive option. You could probably do better than this by reading in chunks from A and B and working with set intersections, but this is a little more complex.\nPutting it as simply as I can, I would read in a reasonably-sized chunks of file A, and convert it to a set of words, call that a1. I would then read similarly-sized chunks of B as sets b1, b2, ... bn. The union of the intersections of (a1, b1), (a1, b2), ..., (a1, bn) is the set of words appearing in a1 and B. Then repeat for chunk a2, a3, ... an. \nI hope this makes sense. If you haven't played with sets, it might not, but then I guess there's a cool thing for you to learn about.","Q_Score":0,"Tags":"python-3.x","A_Id":35169115,"CreationDate":"2016-02-03T04:59:00.000","Title":"Python: how to open a file and loop through word for word and compare to a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a file that is all strings and I want to loop through the file and check its contents against another file. Both files are too big to place in the code so I have to open each file with open method and then turn each into a loop that iterates over the file word for word (in each file) and compare every word for every word in other file. Any ideas how to do this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":35168823,"Users Score":0,"Answer":"I found the answer. There is a pointer when reading files . The problem is that when using a nested loop it doesn't redirect back to the next statement in the outer loop for Python.","Q_Score":0,"Tags":"python-3.x","A_Id":35211196,"CreationDate":"2016-02-03T04:59:00.000","Title":"Python: how to open a file and loop through word for word and compare to a list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working on a server + client combo on python and I'm using TCP sockets. From networking classes I know, that TCP connection should be closed step by step, first one side sends the signal, that it wants to close the connection and waits for confirmation, then the other side does the same. After that, socket can be safely closed.\nI've seen in python documentation function socket.shutdown(flag), but I don't see how it could be used in this standard method, theoretical of closing TCP socket. As far as I know, it just blocks either reading, writing or both.\nWhat is the best, most correct way to close TCP socket in python? Are there standard functions for closing signals or do I need to implement them myself?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5767,"Q_Id":35174394,"Users Score":2,"Answer":"shutdown is useful when you have to signal the remote client that no more data is being sent. You can specify in the shutdown() parameter which half-channel you want to close.\nMost commonly, you want to close the TX half-channel, by calling shutdown(1). In TCP level, it sends a FIN packet, and the remote end will receive 0 bytes if blocking on read(), but the remote end can still send data back, because the RX half-channel is still open.\nSome application protocols use this to signal the end of the message. Some other protocols find the EOM based on data itself. For example, in an interactive protocol (where messages are exchanged many times) there may be no opportunity, or need, to close a half-channel.\nIn HTTP, shutdown(1) is one method that a client can use to signal that a HTTP request is complete. But the HTTP protocol itself embeds data that allows to detect where a request ends, so multiple-request HTTP connections are still possible.\nI don't think that calling shutdown() before close() is always necessary, unless you need to explicitly close a half-channel. If you want to cease all communication, close() does that too. Calling shutdown() and forgetting to call close() is worse because the file descriptor resources are not freed.\nFrom Wikipedia: \"On SVR4 systems use of close() may discard data. The use of shutdown() or SO_LINGER may be required on these systems to guarantee delivery of all data.\" This means that, if you have outstanding data in the output buffer, a close() could discard this data immediately on a SVR4 system. Linux, BSD and BSD-based systems like Apple are not SVR4 and will try to send the output buffer in full after close(). I am not sure if any major commercial UNIX is still SVR4 these days.\nAgain using HTTP as an example, an HTTP client running on SVR4 would not lose data using close() because it will keep the connection open after request to get the response. An HTTP server under SVR would have to be more careful, calling shutdown(2) before close() after sending the whole response, because the response would be partly in the output buffer.","Q_Score":2,"Tags":"python,sockets,tcp","A_Id":35206533,"CreationDate":"2016-02-03T10:25:00.000","Title":"Proper way to close tcp sockets in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I often work with csv files that are 100s of GB in size.  Is there any way to tell read_csv to only read a fixed number of MB from a csv file?\nUpdate:\nIt looks like chunks and chunksize can be used for this, but the documentation looks a bit slim here. What would be an example of how to do this with a real csv file? (e.g. say a 100GB file, read only rows up to approximately ~10MB)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":779,"Q_Id":35184894,"Users Score":1,"Answer":"You can pass nrows=number_of_rows_to_read to your read_csv function to limit the lines that are read.","Q_Score":1,"Tags":"python-3.x,pandas","A_Id":35184973,"CreationDate":"2016-02-03T18:31:00.000","Title":"Limiting the number of GB to read in read_csv in Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm really sorry if this question sounds really simple but I couldn't figure out the solution yet...\nI'm using wxPython in order to create a GUI. I've used wx.Notebook, and created some tabs, all default configuration are located in the last tab.\nMy question is, how can I get these default values from the last tab and use it?!? I tried \"pub\" (wx.lib.pubsub), but I only get these default values after an event (e.g. button click). Also there is\/are any magic to get these values after user modification without a button click?\nThanks all,\nRegards,","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":35188282,"Users Score":0,"Answer":"When you create the UI, you can keep the default config in a variable. A dictionary would probably work. Then when you create the tabs, you can pass them a dictionary. Alternatively, you could just save the defaults to a config file and then use Python to read it and load it into the UI. Python can parse csv, json, xml and whatnot right out of the box after all.","Q_Score":0,"Tags":"python,user-interface,wxpython","A_Id":35229531,"CreationDate":"2016-02-03T21:40:00.000","Title":"Default values from wxPython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed a python web application using flask microframework.  I have some interactive plots generated by Bokeh and some HTML5 tables.  My question is how I can update my table and graph data on fly? \nShould I use threading class and set the timer and then re run my code every couple of seconds and feed updated data entries to the table and graphs? \nI also investigated flask-socketIO, but all I found is for sending and receiving Messages, Is there a way to use flask-socketIO for this purpose?\nI also worked a little bit with Bokeh-server, should I go that direction? does it mean I need to run two servers? my flask web server and bokeh-server?\nI am new to this kind of work. I appreciate if you can explain in detail what I need to do.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1747,"Q_Id":35188305,"Users Score":2,"Answer":"You really are asking two questions in one. Really, you have two problems here. First, you need a mechanism to periodically give the client access to updated data for your tables and charts. Second, you need the client to incorporate those updates into the page.\nFor the first problem, you have basically two options. The most traditional one is to send Ajax requests (i.e. requests that run in the background of the page) to the server on a regular interval. The alternative is to enhance your server with WebSocket, then the client can establish a permanent connection and whenever the server has new data it can push it to the client. Which option to use largely depends on your needs. If the frequency of updates is not too high, I would probably use background HTTP requests and not worry about adding Socket.IO to the mix, which has its own challenges. On the other side, if you need sort of a live, constantly updating page, then maybe WebSocket is a good idea.\nOnce the client has new data, you have to deal with the second problem. The way you deal with that is specific to the tables and charts that you are using. You basically need to write Javascript code that passes these new values that were received from the server into these components, so that the page is updated. Unfortunately there is no automatic way to cause an update. You can obviously throw the current page away and rebuild it from scratch with the new data, but that is not going to look nice, so you should probably find what kind of Javascript APIs these components expose to receive updates.\nI hope this helps!","Q_Score":0,"Tags":"python,html,flask,bokeh,flask-socketio","A_Id":35204805,"CreationDate":"2016-02-03T21:42:00.000","Title":"Streaming live data in HTML5 graphs and tables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have read lots about python threading and the various means to 'talk' across thread boundaries.  My case seems a little different, so I would like to get advice on the best option:\nInstead of having many identical worker threads waiting for items in a shared queue, I have a handful of mostly autonomous, non-daemonic threads with unique identifiers going about their business. These threads do not block and normally do not care about each other. They sleep most of the time and wake up periodically. Occasionally, based on certain conditions, one thread needs to 'tell' another thread to do something specific - an action -, meaningful to the receiving thread. There are many different combinations of actions and recipients, so using Events for every combination seems unwieldly. The queue object seems to be the recommended way to achieve this. However, if I have a shared queue and post an item on the queue having just one recipient thread, then every other thread needs monitor the queue, pull every item, check if it is addressed to it, and put it back in the queue if it was addressed to another thread.  That seems a lot of getting and putting items from the queue for nothing. Alternatively, I could employ a 'router' thread: one shared-by-all queue plus one queue for every 'normal' thread, shared with the router thread. Normal threads only ever put items in the shared queue, the router pulls every item, inspects it and puts it on the addressee's queue. Still, a lot of putting and getting items from queues....\nAre there any other ways to achieve what I need to do ?  It seems a pub-sub class is the right approach, but there is no such thread-safe module in standard python, at least to my knowledge.\nMany thanks for your suggestions.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1923,"Q_Id":35195348,"Users Score":0,"Answer":"Thanks for the response.  After some thoughts, I have decided to use the approach of many queues and a router-thread (hub-and-spoke). Every 'normal' thread has its private queue to the router, enabling separate send and receive queues or 'channels'. The router's queue is shared by all threads (as a property) and used by 'normal' threads as a send-only-channel, ie they only post items to this queue, and only the router listens to it, ie pulls items.  Additionally, each 'normal' thread uses its own queue as a 'receive-only-channel' on which it listens and which is shared only with the router. Threads register themselves with the router on the router queue\/channel, the router maintains a list of registered threads including their queues, so it can send an item to a specific thread after its registration.\nThis means that peer to peer communication is not possible, all communication is sent via the router.  \nThere are several reasons I did it this way:\n1. There is no logic in the thread for checking if an item is addressed to 'me', making the code simpler and no constant pulling, checking and re-putting of items on one shared queue. Threads only listen on their queue, when a message arrives the thread can be sure that the message is addressed to it, including the router itself.\n2. The router can act as a message bus, do vocabulary translation and has the possibility to address messages to external programs or hosts.\n3. Threads don't need to know anything about other threads capabilities, ie they just speak the language of the router.  In a peer-to-peer world, all peers must be able to understand each other, and since my threads are of many different classes, I would have to teach each class all other classes' vocabulary.\nHope this helps someone some day when faced with a similar challenge.","Q_Score":3,"Tags":"python,multithreading","A_Id":35222210,"CreationDate":"2016-02-04T07:51:00.000","Title":"Recommended way to send messages between threads in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to all these methods and am trying to get a simple answer to that or perhaps if someone could direct me to a high level explanation somewhere on the web. My googling only returned kaggle sample codes.\nAre the extratree and randomforrest essentially the same? And xgboost uses boosting when it chooses the features for any particular tree i.e. sampling the features. But then how do the other two algorithms select the features?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":2360,"Q_Id":35237044,"Users Score":9,"Answer":"Extra-trees(ET) aka. extremely randomized trees is quite similar to random forest (RF). Both methods are bagging methods aggregating some fully grow decision trees. RF will only try to split by e.g. a third of features, but evaluate any possible break point within these features and pick the best. However, ET will only evaluate a random few break points and pick the best of these. ET can bootstrap samples to each tree or use all samples. RF must use bootstrap to work well.\nxgboost is an implementation of gradient boosting and can work with decision trees, typical smaller trees. Each tree is trained to correct the residuals of previous trained trees. Gradient boosting can be more difficult to train, but can achieve a lower model bias than RF. For noisy data bagging is likely to be most promising. For low noise and complex data structures boosting is likely to be most promising.","Q_Score":8,"Tags":"python,random-forest,xgboost,kaggle","A_Id":35248119,"CreationDate":"2016-02-06T03:34:00.000","Title":"What is the difference between xgboost, extratreeclassifier, and randomforrestclasiffier?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on some problem where i have to take 15th power of numbers, when I do it in python console i get the correct output, however when put these numbers in pandas data frame and then try to take the 15th power, i get a negative number. \nExample, \n1456 ** 15 = 280169351358921184433812095498240410552501272576L, however when similar operation is performed in pandas i get negative values. Is there a limit on the size of number which pandas can hold and how can we change this limit.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":35237874,"Users Score":0,"Answer":"If the operations are done in the pydata stack (numpy\/pandas), you're limited to \nfixed precision numbers, up to 64bit.\nArbitrary precision numbers as string, perhaps?","Q_Score":0,"Tags":"python-2.7,pandas","A_Id":35237949,"CreationDate":"2016-02-06T05:53:00.000","Title":"Python Pandas largest number","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on some problem where i have to take 15th power of numbers, when I do it in python console i get the correct output, however when put these numbers in pandas data frame and then try to take the 15th power, i get a negative number. \nExample, \n1456 ** 15 = 280169351358921184433812095498240410552501272576L, however when similar operation is performed in pandas i get negative values. Is there a limit on the size of number which pandas can hold and how can we change this limit.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":112,"Q_Id":35237874,"Users Score":0,"Answer":"I was able to overcome by changing the data type from int to float, as doing this gives the answer to 290 ** 15 = 8.629189e+36, which is good enough for my exercise.","Q_Score":0,"Tags":"python-2.7,pandas","A_Id":35237988,"CreationDate":"2016-02-06T05:53:00.000","Title":"Python Pandas largest number","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to run jupyter notebook from a terminal on Xfce Ubuntu machine. \nI typed in the command:\njupyter notebook --browser=firefox\nThe firefox browser opens, but it is empty and with the following error:\n\"IPython Notebook requires JavaScript. Please enable it to proceed.\"\nI searched the web on how to enable JavaScript on Ipython NoteBook but didn't find an answer. I would appreciate a lot any help. Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3643,"Q_Id":35266360,"Users Score":1,"Answer":"In the address bar, type \"about:config\" (with no quotes), and press Enter.\nClick \"I'll be careful, I promise\".\nIn the search bar, search for \"javascript.enabled\" (with no quotes).\nRight click the result named \"javascript.enabled\" and click \"Toggle\". JavaScript is now enabled.\nTo Re-disable JavaScript, repeat these steps.","Q_Score":1,"Tags":"javascript,firefox,ipython-notebook,jupyter-notebook","A_Id":35270287,"CreationDate":"2016-02-08T09:40:00.000","Title":"ipython notebook requires javascript - on firefox web browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to run jupyter notebook from a terminal on Xfce Ubuntu machine. \nI typed in the command:\njupyter notebook --browser=firefox\nThe firefox browser opens, but it is empty and with the following error:\n\"IPython Notebook requires JavaScript. Please enable it to proceed.\"\nI searched the web on how to enable JavaScript on Ipython NoteBook but didn't find an answer. I would appreciate a lot any help. Thanks!","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3643,"Q_Id":35266360,"Users Score":1,"Answer":"javascript has to be enabled in firefox browser it is turned off. to turn it on do this\n\nTo enable JavaScript for Mozilla Firefox: Click the Tools drop-down menu and select Options. Check the boxes next to Block pop-up windows, Load images automatically, and Enable JavaScript. Refresh your browser by right-clicking anywhere on the page and selecting Reload, or by using the Reload button in the toolbar.","Q_Score":1,"Tags":"javascript,firefox,ipython-notebook,jupyter-notebook","A_Id":35266458,"CreationDate":"2016-02-08T09:40:00.000","Title":"ipython notebook requires javascript - on firefox web browser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having some trouble understanding how Python uses the PYTHONPATH environment variable. According to the documentation, the import search path (sys.path) is \"Initialized from the environment variable PYTHONPATH, plus an installation-dependent default.\"\nIn a Windows command box, I started Python (v.2.7.6) and printed the value of sys.path. I got a list of pathnames, the \"installation-dependent default.\"\nThen I quit Python, set PYTHONPATH to .;.\/lib;, restarted Python, and printed os.environ['PYTHONPATH']. I got .;.\/lib; as expected. Then I printed sys.path. I think it should have been the installation-dependent default with .;.\/lib; added to the start or the end. Instead it was the installation-dependent default alone, as if PYTHONPATH were empty. What am I missing here?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":35276844,"Users Score":0,"Answer":"It always uses PYTHONPATH. What happened is probably that you quit python, but didn't quit your console\/command shell. For that shell, the environment that was set when the shell was started still applies, and hence, there's no PYTHONPATH set.","Q_Score":2,"Tags":"python,pythonpath,sys.path","A_Id":35276882,"CreationDate":"2016-02-08T18:36:00.000","Title":"When\/how does Python use PYTHONPATH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a simple chat program in python that uses tkinter and mysql db. It connects to db first, gets the messages and shows them to user. But when another user send a message to the user, the user can not see the new messages. So, I made a refresh button. But, everybody knows, people don't want to use a chat program that you always should press a button to see messages. The question is, how can I make a instant message app without clicking any buttons?\n\nIt doesn't require to use tkinter for gui. It can be run with other gui libs.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":294,"Q_Id":35294239,"Users Score":0,"Answer":"in order to periodically refresh the user messages, just make an infinite while loop and set it to update every 5 seconds or so. this way every 5 seconds you check to see if database has new messages. alternatively you can make the while loop update if the database has been updated at any point but this is more complex.","Q_Score":0,"Tags":"python,mysql,tkinter","A_Id":35295077,"CreationDate":"2016-02-09T14:12:00.000","Title":"Python3 - Tkinter - Instant messaging","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working with Python Tools for Visual Studio.  (Note, not IronPython.)\nI need to work with arguments passed to the module from the command line.  I see how to start the module in Debug by right-clicking in the code window and selecting \"Start with Debugging\".  But this approach never prompts me for command line arguments, and len(sys.argv) always == 1.\nHow do I start my module in debug mode and also pass arguments to it so sys.argv has more than 1 member?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21881,"Q_Id":35302508,"Users Score":0,"Answer":"You want to select \"Execute Project with Python Interactive\" from the debug dropdown menu. The keyboard shortcut for this is Shift+Alt+F5. When you do that, you will have a window open at the bottom of the screen called Python Interactive and you will see your printed statements and any prompts for inputs from your program.\nThis does not allow you to also enter debug mode though. It is either one or the other.","Q_Score":17,"Tags":"python,python-2.7,debugging,command-line,visual-studio-2015","A_Id":35303799,"CreationDate":"2016-02-09T21:27:00.000","Title":"How do I pass command line arguments to Python from VS in Debug mode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to give my users the possibility to store unstructured data in JSON-Format, alongside the structured data, via an API generated with Ramses.\nSince the data is made available via Elasticsearch, I try to achieve that this data is indexed and searchable, too.\nI can't find any mentioning in the docs or searching.\nWould this be possible and how would one do it?\nCheers \/Carsten","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":35318866,"Users Score":0,"Answer":"This is Chrisses answer, copied from gitter.im:\nYou can use the dict field type for \"unstructured data\", as it takes arbitrary json. If the db engine is postgres, it uses jsonfield under the hood, and if the db engine is mongo, it's converted to a bson document as usual. Either way it should index automatically as expected in ES and will be queryable through the Ramses API.\nThe following ES queries are supported on documents\/fields: nefertari-readthedocs-org\/en\/stable\/making_requests.html#query-syntax-for-elasticsearch\nSee the docs for field types here, start at the high level (ramses) and it should \"just work\", but you can see what the code is mapped to at each level below down to the db if desired:\n\nramses: ramses-readthedocs-org\/en\/stable\/fields.html\nnefertari (underlying web framework): nefertari-readthedocs-org\/en\/stable\/models.html#wrapper-api\nnefertari-sqla (postgres-specific engine): nefertari-sqla-readthedocs-org\/en\/stable\/fields.html\nnefertari-mongodb (mongo-specific engine): nefertari-mongodb-readthedocs-org\/en\/stable\/fields.html\n\nLet us know how that works out, sounds like it could be a useful thing. So far we've just used that field type to hold data like user settings that the frontend wants to persist but for which the API isn't concerned.","Q_Score":1,"Tags":"python,json,elasticsearch","A_Id":35405127,"CreationDate":"2016-02-10T15:13:00.000","Title":"Storing unstructured data with ramses to be searched with Ramses-API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using apache with mod_wsgi in windows platform to deploy my flask application. I am using sqlalchemy to connect redshift database with connection pool(size 10).\nAfter few days suddenly I am getting follwoing error.\n(psycopg2.OperationalError) SSL SYSCALL error: Software caused connection abort  \nCan anybody suggest why I am getting this error and how to fix?  \nIf I do the apache restart then this error gone. But after few days it again comeback.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3963,"Q_Id":35322629,"Users Score":1,"Answer":"I solved this error by turning DEBUG=False in my config file [and\/or in the run.py]. Hope it helps someone.","Q_Score":4,"Tags":"python,apache,flask,amazon-redshift","A_Id":44923869,"CreationDate":"2016-02-10T18:00:00.000","Title":"(psycopg2.OperationalError) SSL SYSCALL error: Software caused connection abort","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Deploying to a live server for an existing Django application. It's a very old site that has not been updated in 3+ years. \nI was hired on contract to bring it up to date, which included upgrading the Django version to be current. This broke many things on the site that had to be repaired.\nI did a test deployment and it went fine. Now it is time for deployment to live and I am having some issues....\nFirst thing I was going to do is keep a log of the current Django version on server, incase of any issues we can roll back. I tried logging in Python command prompt and importing Django to find version number, and it said Django not found.\nI was looking further and found the version in a pip requirements.txt file. \nThen I decided to update the actual django version on the server. Update went through smoothly. Then I checked the live site, and everything was unchanged (with the old files still in place). Most of the site should have been broken. It was not recognizing any changes in Django.\nI am assuming the reason for this might be that the last contractor used virtualenv? And that's why it is not recognizing Django, or the Django update are not doing anything to the live site?\nThat is the only reason I could come up with to explain this issue, as since there is a pip requirements.txt file, he likely installed Django with pip, which means Python should recognize the path to Django. \nSo then I was going to try to find the source path for the virtualenv with command \"lsvirtualenv\". But when I do that, even that gives me a \"command not found\" error.\nMy only guess is that this was an older version of virtualenv that does not have this command? If that is not the case, I'm not sure what is going on.\nAny advice for how I find the information I need to  update the package versions on this server with the tools I have access to?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":5340,"Q_Id":35326476,"Users Score":2,"Answer":"Create your own virtualenv\nIf all fails, just recreate the virtualenv from the requirements.txt and go from there\nFind out how the old app was being launched\nIf you insist on finding the old one, IMO the most direct way is to find how is the production Django app being ran. Look for bash scripts that start it, some supervisor entries etc\nIf you find how it starts, then you can pinpoint the environment it is launched in (e.g. which virtualenv)\nFind the virtualenv by searching for common files\nOther than that you can use find or locate command to search for files we know to exist in a virtualenv like lib\/pythonX.Y\/site-packages, bin\/activate or bin\/python etc","Q_Score":2,"Tags":"python,django","A_Id":35326564,"CreationDate":"2016-02-10T21:39:00.000","Title":"How to locate a virtualenv install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Deploying to a live server for an existing Django application. It's a very old site that has not been updated in 3+ years. \nI was hired on contract to bring it up to date, which included upgrading the Django version to be current. This broke many things on the site that had to be repaired.\nI did a test deployment and it went fine. Now it is time for deployment to live and I am having some issues....\nFirst thing I was going to do is keep a log of the current Django version on server, incase of any issues we can roll back. I tried logging in Python command prompt and importing Django to find version number, and it said Django not found.\nI was looking further and found the version in a pip requirements.txt file. \nThen I decided to update the actual django version on the server. Update went through smoothly. Then I checked the live site, and everything was unchanged (with the old files still in place). Most of the site should have been broken. It was not recognizing any changes in Django.\nI am assuming the reason for this might be that the last contractor used virtualenv? And that's why it is not recognizing Django, or the Django update are not doing anything to the live site?\nThat is the only reason I could come up with to explain this issue, as since there is a pip requirements.txt file, he likely installed Django with pip, which means Python should recognize the path to Django. \nSo then I was going to try to find the source path for the virtualenv with command \"lsvirtualenv\". But when I do that, even that gives me a \"command not found\" error.\nMy only guess is that this was an older version of virtualenv that does not have this command? If that is not the case, I'm not sure what is going on.\nAny advice for how I find the information I need to  update the package versions on this server with the tools I have access to?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5340,"Q_Id":35326476,"Users Score":0,"Answer":"Why not start checking what processes are actually running, and with what commandline, using ps auxf or something of the sort. Then you know if its nginx+uwsgi or django-devserver or what, and maybe even see the virtualenv path, if it's being launched very manually. Then, look at the config file of the server you find.\nAlternatively, look around, using netstat -taupen, for example, which processes are listening to which ports. Makes even more sense, if there's a reverse proxy like nginx or whatever running, and you know that it's proxying to.\nThe requirements.txt I'd ignore completely. You'll get the same, but correct information from the virtualenv once you activate it and run pip freeze. The file's superfluous at best, and misleading at worst.\nBtw, if this old contractor compiled and installed a custom Python, (s)he might not even have used a virtualenv, while still avoiding the system libraries and PYTHONPATH. Unlikely, but possible.","Q_Score":2,"Tags":"python,django","A_Id":35345062,"CreationDate":"2016-02-10T21:39:00.000","Title":"How to locate a virtualenv install","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am looking for some real help. I want to web scraping using Python, I need it because i want to import some database, How can we do that in Python. What libraries do we need ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":35328278,"Users Score":0,"Answer":"You can use \n1) Beautiful Soup\n2) Python Requests\n3) Scrapy\n4) Mechanize\n... and many more. These are the most popular tools, and easy to learn for the beginner. \nFrom there, you can branch out to more complex stuff such as UserAgentSpoofing, HTML Load balancing, Regex, XPATH and CSS Selectors. You will need these to scrape more difficult sites that has protection or login fields. \nHope that helps. \nCheers","Q_Score":0,"Tags":"python-2.7","A_Id":35330126,"CreationDate":"2016-02-10T23:50:00.000","Title":"Python Web scraping- Required Libraries and how to do it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for some real help. I want to web scraping using Python, I need it because i want to import some database, How can we do that in Python. What libraries do we need ?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":35328278,"Users Score":0,"Answer":"As others have suggested I too would use Beautiful Soup and Python Requests, but if you get problems with websites which have to load some data with Javascript after the page has loaded and you only get the incomplete html with Request, try using Selenium and PhantomJs for the scraping.","Q_Score":0,"Tags":"python-2.7","A_Id":44280408,"CreationDate":"2016-02-10T23:50:00.000","Title":"Python Web scraping- Required Libraries and how to do it","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a chrome extension that injects a content script into every page the user goes to. What i want to do is to get the output of a python function for some use in the content script (can't write it in javascript, since it requires raw sockets to connect to my remote SSL server).\nI've read that one might use CGI and Ajax or the like, to get output from the python code into the javascript code, but i ran into 3 problems:\n\nI cannot allow hosting the python code on a local server, since it is security sensitive data that only the local computer should be able to know. \nChrome demands that HTTP and HTTPS can not mix- if the user goes to an HTTPS website, i can't host the python code on a HTTP server.\nI don't think Chrome even supports CGI on extensions-when i try to access a local file, all it does is print out the text (the python code itself) instead of what i defined to be its output (I tried to do so using Flask). As I said in 1, I shouldn't even try this anyway, but this is just a side note.\n\nSo my question is, how do i get the output of my python functions inside a Content Script, built with javascript?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7214,"Q_Id":35346456,"Users Score":0,"Answer":"The only way to get the output of a Python script inside a content script built with Javascript is to call the file with XMLHttpRequest. As you noted, you will have to use an HTTPS connection if the page is served over HTTPS. A workaround for this is to make a call to your background script, which can then fetch the data in whichever protocol it likes, and return it to your content script.","Q_Score":6,"Tags":"javascript,python,google-chrome-extension","A_Id":35349167,"CreationDate":"2016-02-11T17:46:00.000","Title":"Combining Python and Javascript in a chrome plugin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to \"pseudo\"-randomly select an element from a list that wasn't chosen before? I know about the choice function, which returns a random item from the list, but without taking into account previous chosen items. I could keep track of which elements were already picked, and keep randomly choose another not yet selected item, but this might include nested loops, etc.\nI could also for example remove the element chose from the list at each iteration, but this does not seem a good solution, too.\nMy question is: is there a \"aware\" choice function that selects only items that weren't chosen before? Note that I'm not asking how to implement such a function, but possible solutions are of course well-accepted too.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":953,"Q_Id":35371372,"Users Score":0,"Answer":"Shuffle the list and pop elements from the top. That will only produce each list element once.","Q_Score":0,"Tags":"python,python-3.x,random,choice","A_Id":35371559,"CreationDate":"2016-02-12T20:10:00.000","Title":"Pseudo-randomly pick an element from a list only if it was not chosen yet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a small project for my android phone using kivy. I am trying to get the android back key to do a make Toast saying 'press back again to exit', and then exit when the back key is pressed twice. I checked online and saw a tutorial on how to do this. I had to useimport android \nbut the problem is that it just doesn't work on my phone. Not on kivy launcher when i tested it. I even compiled to an android apk using buildozer, but it still doesn't work. Please im still very new to kivy and android api. Help me get this right. Or if there is another way to do this i also appreciate it. Please include an example in your response.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":614,"Q_Id":35376747,"Users Score":2,"Answer":"Hello  guys I finally found the problem. The import android actually works.\nThe problem was that I used it wrongly . I was trying to do a makeToast  like dis 'android.makeToast'. Evidently dat was wrong. Found out there was another way to do it with pyjnius. \nThanks so ooo much for your assistance","Q_Score":1,"Tags":"android,python,kivy,buildozer","A_Id":35383918,"CreationDate":"2016-02-13T06:11:00.000","Title":"kivy import android doesnt work","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Flask app that uses SQLAlchemy (Flask-SQLAlchemy) and Alembic (Flask-Migrate).  The app runs on Google App Engine. I want to use Google Cloud SQL.\nOn my machine, I run python manage.py db upgrade to run my migrations against my local database.  Since GAE does not allow arbitrary shell commands to be run, how do I run the migrations on it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1816,"Q_Id":35391120,"Users Score":1,"Answer":"You can whitelist the ip of your local machine for the Google Cloud SQL instance, then you run the script on your local machine.","Q_Score":8,"Tags":"python,google-app-engine,flask,google-cloud-sql,alembic","A_Id":35395267,"CreationDate":"2016-02-14T11:17:00.000","Title":"Run Alembic migrations on Google App Engine","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I trained a linear regression model(using sklearn with python3),\nmy train set was with 94 features and the class of them was 0 or 1..\nthan i went to check my linear regression model on the test set and it gave me those results:\n1.[ 0.04988957] its real value is 0 on the test set\n2.[ 0.00740425] its real value is 0 on the test set\n3.[ 0.01907946] its real value is 0 on the test set\n4.[ 0.07518938] its real value is 0 on the test set\n5.[ 0.15202335] its real value is 0 on the test set\n6.[ 0.04531345] its real value is 0 on the test set\n7.[ 0.13394644] its real value is 0 on the test set\n8.[ 0.16460608] its real value is 1 on the test set\n9.[ 0.14846777] its real value is 0 on the test set\n10.[ 0.04979875] its real value is 0 on the test set\nas you can see that at row 8 it gave the highest value but the thing is that i want to use my_model.predict(testData) and it will give only 0 or 1 as results, how can i possibly do it? the model got any threshold or auto cutoff that i can use?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2479,"Q_Id":35436599,"Users Score":1,"Answer":"There is a linear classifier sklearn.linear_model.RidgeClassifer(alpha=0.) that you can use for this. Setting the Ridge penalty to 0. makes it do exactly the linear regression you want and set the threshold to divide between classes.","Q_Score":1,"Tags":"python,scikit-learn,linear-regression","A_Id":35438322,"CreationDate":"2016-02-16T15:32:00.000","Title":"can i make linear regression predict like a classification?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can I combine an executable with another executable (Windows Service Program) and run this program as a logical service?\n\nBy combining, I mean to form a single executable.\nI want to write a Windows Service, and I've followed some tutorials that show how to do it using C++, i.e. writing the Service Program (in Windows) and using ServiceMain() functions as logical services.\nHowever, I prefer not to write the ServiceMain() functions in C++. Instead, I wonder whether I could write these logical services using Python and compile to binary using py2exe.\nIs this possible? - could I substitute the ServiceMain() functions for py2exe compiled modules? If so, please provide the details on how to do it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":35484772,"Users Score":0,"Answer":"You could have your python executable call the c++ executable and have the executable take in command line arguments.  So basically in python have the service main code and a few basic cases that will call into a normal c++ executable.  Not extremely efficient, but it works","Q_Score":0,"Tags":"python,c++,windows","A_Id":35495227,"CreationDate":"2016-02-18T14:54:00.000","Title":"Can I combine an executable with another executable (Windows Service Program) and run this program as a logical service?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using pandas to input a list of names and phone numbers, clean that list, then export it. When I export the list, all of the phone numbers have '.0' tacked on to the end. I tried two solutions:\nA: round()\nB: converting to integer then converting to text (which has worked in the past)\nFor some reason when I tried A, the decimal still comes out when I export to a text file and when I tried B, I got an unexpected negative ten digit number\nAny ideas about what's happening here and\/or how to fix it?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":35485629,"Users Score":0,"Answer":"figured it out. specified the data type on import with dtype = {\"phone\" : str, \"other_phone\" : str})","Q_Score":0,"Tags":"python,pandas","A_Id":35486318,"CreationDate":"2016-02-18T15:29:00.000","Title":"Removing decimals on export python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a simple software with GUI. It has several source files. I can run the project in my editor. I think it is ready for the 1.0 release. But I don't know how to create a setup\/installer for my software.\nThe source is in python. Environment is Linux(Ubuntu). I used an external library which does not come with standard Python library. How can I create the installer, so that I just distribute the source code in the tar file. And the user installs the software on his machine(Linux) by running a setup\/installer file?\nPlease note: When the setup is run, it should automatically take care of the dependencies.(Also, I don't want to build an executable for distribution.)\nSomething similar to what happens when I type:\nsudo apt-get install XXXX","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":137,"Q_Id":35509019,"Users Score":1,"Answer":"Look at \n\nsetuptools\ndistutils\n\nThese are classical tools for python packaging","Q_Score":3,"Tags":"python,linux","A_Id":35509182,"CreationDate":"2016-02-19T15:35:00.000","Title":"How to create setup\/installer for my Python project which has dependencies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a django 1.9 project deployed using gunicorn with a view contains a line \n\nsubprocess.call([\"xvfb-run .\/stored\/all_crawlers.sh \"+outputfile+\" \" + url], shell=True, cwd= path_to_sh_file)\n\nwhich runs fine with .\/manage.py runserver \nbut fails on deployment and (deployed with gunicorn and wsgi).\nAny Suggestion how to fix it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":35524022,"Users Score":4,"Answer":"1) User who runs gunicorn has no permissions to run .sh files\n2) Your .sh file has no rights to be runned\n3) Try to user full path to the file\nAlso, which error do you get when trying to run it on the production?","Q_Score":1,"Tags":"python,django,shell,subprocess,gunicorn","A_Id":35524148,"CreationDate":"2016-02-20T13:37:00.000","Title":"Django deployed project not running subprocess shell command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm generating a summary report from a data set. I used .describe() to do the heavy work but it doesn't generate everything I need i.e. the second most common thing in the data set.\nI noticed that if I use .mode() it returns the most common value, is there an easy way to get the second most common?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":2825,"Q_Id":35531367,"Users Score":1,"Answer":"Try this method:\n\nCreate a duplicate data set.\nUse .mode() to find the most common value.\nPop all items with that value from the set.\nRun .mode() again on the modified data set.","Q_Score":0,"Tags":"python,pandas","A_Id":35531393,"CreationDate":"2016-02-21T01:51:00.000","Title":"In pandas, how to get 2nd mode","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a file that has a column with names, and another with comma separated US licenses, for example, AZ,CA,CO,DC,HI,IA,ID; but any combination of 50 states is possible. I have another file that has a certain value attached to each state, for example AZ=4, CA=30, DC=23, and so on for all 50. \nI need to add up the amount that each person is holding via their combination of licenses. Say, someone with just CA, would have 30, while some one with AZ, CA and DC, would end up with 30+4+23=57; and any combination of 50 licenses is possible. \nI know a bit of Python, but not enough to know how to even get started, what packages to use, what the architecture should be..\nAny guidance is appreciated. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":52,"Q_Id":35544800,"Users Score":1,"Answer":"I am told to use Pandas to get at each of the individual states in your excel file. \nI then use a dictionary structure to store state values and look up sates from the above to these.","Q_Score":0,"Tags":"python,excel,combinations","A_Id":35557793,"CreationDate":"2016-02-22T02:18:00.000","Title":"How do I parse out all US states from comma separated strings in Python from an excel file.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working with WinPython and Spyder, and somehow spyder wouldn't start. It would briefly flash an error message of which the relevant line is: ConfigParser.ParsingError: File contains parsing errors: D:\\progs\\WinPython-64bit-2.7.10.3\\settings\\.spyder\\spyder.ini  [line 431]: u'_\/switch to'.\nThen delving into that file it seems to be clipped. It abruptly ends on line 431 with _\/switch to in the [shortcuts] section of the file.\nCan anyone link me to a complete spyder.ini file, I can't find it in the spyder github? Or if it's the last line (or one of the last few lines), provide me with the bit I'm missing?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1152,"Q_Id":35555798,"Users Score":3,"Answer":"Simply removing the line which was an issue and starting Spyder did the trick. Spyder rebuilt the spyder.ini file upon running spyder.exe.","Q_Score":1,"Tags":"python,spyder","A_Id":35555927,"CreationDate":"2016-02-22T14:11:00.000","Title":"Replace corrupted spyder.ini file (with winpython 64)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So we just started learning about loops and got this assignment\ndef    factorial_cap(num): For    positive    integer n,  the factorial   of  n   (denoted    as  n!),    is  the product \nof  all positive    integers    from    1   to  n   inclusive.      Implement   the function    that    returns the smallest\npositive    n   such    that    n!  is  greater than    or  equal   to  argument    num.\nExamples:\nfactorial_cap(20) \u2192 4 #3!<20 but 4!>20\nfactorial_cap(24) \u2192 4 #4!=24\nCan anyone give me a direction as to where to start? I am quite lost at how to even begin to start this. I fully understand what my program should do, just not how to start it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":124,"Q_Id":35561072,"Users Score":0,"Answer":"In a recursive function there are two main components:\n\nThe recursive call\nThe base case\n\nThe recursive call is when you call the function from within itself, and the base case is where the function returns\/stops calling itself.\nFor your recursive call, you want nfactorial(n-1), because this is essentially the definition of a factorial (n(n-1)(n-2)...*2). Following this logic, the base case should be when n == 2. \nGood luck, hope I was able to point you in the right direction.","Q_Score":2,"Tags":"python,loops,python-3.x,functional-programming","A_Id":35561218,"CreationDate":"2016-02-22T18:26:00.000","Title":"Starting loops with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used the \"import existing project\" option to import an existing project into workspace. However, eclipse actually makes copies of the original files and create a new project.\nSo, if I made a change on a file. It only affect on the copied file in workspace. The original file is untouched.\nMy question is how do I make my modification affected on the original files?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":35570376,"Users Score":1,"Answer":"The 'Import Existing Projects into Workspace' wizard has a 'Copy projects into workspace' check box on the first page. Unchecking this option will make Eclipse work on the original files.","Q_Score":0,"Tags":"python,eclipse,ide","A_Id":35571869,"CreationDate":"2016-02-23T06:28:00.000","Title":"eclipse modify imported project files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use Django REST framework for my new project but I am not sure if I can do it efficiently. I would like to be able to integrate easily classical Django app in my API. However I don't know how I can proceed to make them respect the REST framework philosophy. Will I have to rewrite all the views or is there a more suitable solution?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":422,"Q_Id":35574857,"Users Score":2,"Answer":"\"Normal\" Django views (usually) return HTML pages. \nDjango-Rest-Framework views (usually) return JSON.\nI am assuming you are looking for something more like a Single page application. \nIn this case you will have a main view that will be the bulk of the HTML page. This will be served from  \"standard\" Django view returning HTML (which will likely include a fair bit of JavaScript). \nOnce the page is loaded the JavaScript code will makes requests to the DRF views. So when you interact with the page, JavaScript will request Json, and update (not reload) the page based on the contents of the JSON. \nDoes that make sense?","Q_Score":0,"Tags":"python,django,rest,django-rest-framework","A_Id":35583466,"CreationDate":"2016-02-23T10:26:00.000","Title":"How to use classic Django app with Django REST framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building an app with a Django backend, Angular frontend, and a REST API using Django REST Framework for Angular to consume. When I was still working out backend stuff with a vanilla frontend, I used the provided Django authentication to handle user auth- but now that I'm creating a REST based app, I'm not sure how to approach authentication.\nSince all user data will be either retrieved or submitted via the API, should API authentication be enough? If so, do I need to remove the existing Django authentication middleware?\nRight now, when I try to hit API endpoints on an early version of the app, I'm directed to what looks like the normal Django login form. If I enter a valid username and password, it doesn't work- just prompts to login again. Would removing the basic Django authentication prevent this? I want to be prompted to login, however I'm not sure how to handle that with these technologies.\nThe package django-rest-auth seems useful, and the same group makes an Angular module- but the docs don't go much past installation and the provided endpoints. Ultimately, I think the core of this question is: how do I entirely switch authentication away from what's provided by Django to something like django-rest-auth or one of the other 3rd party packages recommended by DRF?\nedit: I made this comment below, but I realized that I need to figure out how combined auth will work. I'm not building a single page app, so individual basic pages will be served from Django, but each page will hit various API endpoints to retrieve the data it needs. Is there a way to have something like django-rest-auth handle all authentication?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":698,"Q_Id":35607753,"Users Score":0,"Answer":"To anyone that stumbles onto this question, I couldn't figure out how to make the hybrid approach work. Having Django serve pages that each contained API calls seemed OK, but I never saw any requests made to the API- I believe due to some other security issues. I'm sure it's possible, but I decided to go for the single page app implementation after all to make things simpler.","Q_Score":5,"Tags":"python,django,django-rest-framework,django-rest-auth","A_Id":35726205,"CreationDate":"2016-02-24T16:32:00.000","Title":"Django, Angular, & DRF: Authentication to Django backend vs. API","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using PyCharm IDE with Anaconda distribution. \nwhen I run:Tools > Python Console... PyCharm uses ipython console which is part of Anaconda distribution.\nBut it using a default profile.\nI already tried add option --profile=myProfileName in Environment variables and in Interpreter options in Settings > Build, Execution, Deployment > Console > Python Console\nBut it keeps using default profile.\nMy question is how to set different ipython profile in PyCharm?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1263,"Q_Id":35612338,"Users Score":0,"Answer":"Short answer:\nGo to File > Default settings > Build, Execution, Deployment > Console and select Use Ipython if available\nGo to Run > Edit Configurations and select Show command line afterwards\nTip: Run selected parts of your code with ALT + SHIFT + E\nThe details:\nIf you've selected Anaconda as the project interpreter, IPython will most likely be the selected console even though it neither looks nor behaves like the IPython console you are used to in Spyder.\nI guess you are used to seeing this in Spyder: enter image description here\nI'm also guessing that the following is what you're seeing in PyCharm in the Console Window:\nenter image description here\nUnlike Spyder, PyCharm has no graphical indicator showing that this is an IPython console. So, to make sure it's an IPython console and make it behave more or less like the IPython console you are used to from Spyder, you should try to follow these two steps:\nGo to File > Default Settings >  Build, Execution, Deployment > Console and make sure to select Use IPython if available. enter image description here\nGo to Run > Edit Configurations and select Show command line afterwards enter image description here\nNow you can run selected parts of your code with ALT+SHIFT+E more or less exactly like in Spyder.\nIf this doesn't do the trick, you should check out these other posts on SO:\nInteracting with program after execution\nDisable ipython console in pycharm","Q_Score":10,"Tags":"python,ipython,pycharm,anaconda","A_Id":52747634,"CreationDate":"2016-02-24T20:23:00.000","Title":"How to set ipython profile in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I am wondering how I can have the python console pop up automatically after I run a script in Pycharm. Currently it opens in the background and I have to either command-tab to it, or click manually. Maybe there is a way to edit the configuration to allow it to pop up, I haven't found one. \nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":35624808,"Users Score":0,"Answer":"It's in the same window know so much easier to go to it.","Q_Score":3,"Tags":"python,macos,console,pycharm,jetbrains-ide","A_Id":54680604,"CreationDate":"2016-02-25T10:34:00.000","Title":"How to automatically switch focus to python console when running script in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As the question says, I'm using django-registration-redux and I've made templates for the registration emails and pages but can't figure out how to make the template for the password reset email. \nI'm using django 1.9","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":606,"Q_Id":35647221,"Users Score":4,"Answer":"Based on itzmeontv's answer:\nTo override original templates in registration application.\n\ncreate folder templates inside your base app if it doesn't exist\ncreate folder registration inside it. So folder looks like <yourapp>\/templates\/registration\nInside yourapp\/templates\/registration , create htmls with same name as in registration app. For ex : password_change_form.html. So it will look like <yourapp>\/templates\/registration\/password_change_form.html.\n\nMake sure that your base app comes before registration in INSTALLED_APPS.","Q_Score":0,"Tags":"python,django","A_Id":35650368,"CreationDate":"2016-02-26T08:49:00.000","Title":"How do I make a custom email template for django-registration-redux password reset?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In flask programming, people usually use 'url_for' such as {{url_for = 'some url'}}\nThis way have to make URL(@app.route), template(HTML) and map each other.\nBut, I just want to send email when I click submit button in HTML modal.\nFor this, There is no page reloading. To do this, I think I have to connect between button and python function without URL, return(response)\nI wonder that how to make it, help me please, I'm beginner in flask programming.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1304,"Q_Id":35647516,"Users Score":2,"Answer":"You can't trigger anything on the server without making a request to a URL. \nIf you don't want the page to reload, you can either redirect back to the original page after your action is finished, or you can use Ajax to make the request without changing the page; but the request itself is always to a URL.","Q_Score":0,"Tags":"python,html,flask","A_Id":35647647,"CreationDate":"2016-02-26T09:06:00.000","Title":"How to connect between HTML button and python(or flask) function?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python 2.7.0 and pygame 1.9.1, on OS X 10.10.5. The user guide for PyInstaller dictates that Mac users should use Homebrew, and I have it installed. I used it to install both Python and Pygame. But 'brew install PyInstaller' produces no formulae at all when typed into Terminal! So how can I use homebrew to install PyInstaller? This seems like it should be simple, and I'm sorry to bother you, but I have searched high and low with no result.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3559,"Q_Id":35658436,"Users Score":9,"Answer":"The pyinstaller docs are poorly worded and you may be misunderstanding their meaning.\n\nPyInstaller works with the default Python 2.7 provided with current\n  Mac OS X installations. However, if you plan to use a later version of\n  Python, or if you use any of the major packages such as PyQt, Numpy,\n  Matplotlib, Scipy, and the like, we strongly recommend that you\n  install THESE using either MacPorts or Homebrew.\n\nIt means to say \"install later versions of Python as well as python packages with Homebrew\", and not to say \"install pyinstaller itself with homebrew\". In that respect you are correct, there is no formula for pyinstaller on homebrew.\nYou can install pyinstaller with pip though: pip install pyinstaller or pip3 install pyinstaller. Then confirm the install with pyinstaller --version.","Q_Score":1,"Tags":"python,python-2.7,homebrew,pyinstaller","A_Id":36139384,"CreationDate":"2016-02-26T17:48:00.000","Title":"Using homebrew to install pyinstaller","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a video consisting of different objects such as square, rectangle , triangle. I somehow need to detect and show only square objects. So in each frame, if there is a square, it is fine but if there is a triangle or rectangle then it should display it. I am using background subtraction and I am able to detect all the three objects and create a bounding box around them. But I am not able to figure out how to display only square object.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":948,"Q_Id":35661419,"Users Score":1,"Answer":"How are your objects filled or just an outline?\nIn either case the approach I would take is to detect the vertices by finding the maximum gradient or just by the bounding box. The vertices will be on the bounding box. Once you have the vertices, you can say whether the object is a square or a rectangle just by finding the distances between the consecutive vertices.","Q_Score":0,"Tags":"python,opencv,frames","A_Id":35663902,"CreationDate":"2016-02-26T20:46:00.000","Title":"How to detect objects in a video opencv with Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a video consisting of different objects such as square, rectangle , triangle. I somehow need to detect and show only square objects. So in each frame, if there is a square, it is fine but if there is a triangle or rectangle then it should display it. I am using background subtraction and I am able to detect all the three objects and create a bounding box around them. But I am not able to figure out how to display only square object.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":948,"Q_Id":35661419,"Users Score":3,"Answer":"You can use the following algorithm:\n-Perform Background subtraction, as you're doing currently\n-enclose foreground in contours (using findContours(,,,) then drawContours(,,,) function)\n-enclose obtained contours in bounding boxes (using boundingRect(,,,) function)\n-if area of bounding box is approximately equal to that of enclosed contour, then the shape is a square or rectangle, not a triangle. \n(A large part of the box enclosing a triangle will lie outside the triangle)\n-if boundingBox height is approximately equal to its width, then it is a square. (access height and width by Rect.height and Rect.width)","Q_Score":0,"Tags":"python,opencv,frames","A_Id":35788514,"CreationDate":"2016-02-26T20:46:00.000","Title":"How to detect objects in a video opencv with Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a df in pandas\nimport pandas as pd\nimport pandas as pd\ndf = pd.DataFrame(['AA', 'BB', 'CC'], columns = ['value'])\nI want to iterate over rows in df. For each row i want rows value and next rows value.\nHere is the desired result.\n0 1 AA BB\n1 2 BB CC\nI have tried a pairwise() function with itertools.\nfrom itertools import tee, izip\ndef pairwise(iterable):\n    \"s -> (s0,s1), (s1,s2), (s2, s3), ...\"\n    a, b = tee(iterable)\n    next(b, None)\n    return izip(a, b)\n\nimport pandas as pd\ndf = pd.DataFrame(['AA', 'BB', 'CC'], columns = ['value'])\n\nfor (i1, row1), (i2, row2) in pairwise(df.iterrows()):\n    print i1, i2, row1[\"value\"], row2[\"value\"]\nBut, its too slow. Any idea how to achieve the output with iterrows ? I would like to try pd.apply for a large dataset.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":908,"Q_Id":35670348,"Users Score":0,"Answer":"While it's not the most \"fancy\" way - I would just use a numeric iterator and access lines i and i+1","Q_Score":1,"Tags":"python,pandas,apply,next","A_Id":35670515,"CreationDate":"2016-02-27T13:24:00.000","Title":"python pandas ... alternatives to iterrows in pandas to get next rows value (NEW)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm not really new to matplotlib and I'm deeply ashamed to admit I have always used it as a tool for getting a solution as quick and easy as possible. So I know how to get basic plots, subplots and stuff and have quite a few code which gets reused from time to time...but I have no \"deep(er) knowledge\" of matplotlib.\nRecently I thought I should change this and work myself through some tutorials. However, I am still confused about matplotlibs plt, fig(ure) and ax(arr). What is really the difference?\nIn most cases, for some \"quick'n'dirty' plotting I see people using just pyplot as plt and directly plot with plt.plot. Since I am having multiple stuff to plot quite often, I frequently use f, axarr = plt.subplots()...but most times you see only code putting data into the axarr and ignoring the figure f.\nSo, my question is: what is a clean way to work with matplotlib? When to use plt only, what is or what should a figure be used for? Should subplots just containing data? Or is it valid and good practice to everything like styling, clearing a plot, ..., inside of subplots?\nI hope this is not to wide-ranging. Basically I am asking for some advice for the true purposes of plt <-> fig <-> ax(arr) (and when\/how to use them properly).\nTutorials would also be welcome. The matplotlib documentation is rather confusing to me. When one searches something really specific, like rescaling a legend, different plot markers and colors and so on the official documentation is really precise but rather general information is not that good in my opinion. Too much different examples, no real explanations of the purposes...looks more or less like a big listing of all possible API methods and arguments.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8825,"Q_Id":35677767,"Users Score":0,"Answer":"pyplot is matlab like API for those who are familiar with matlab and want to make quick and dirty plots\nfigure is object-oriented API for those who doesn't care about matlab style plotting\n\nSo you can use either one but perhaps not both together.","Q_Score":39,"Tags":"python,matplotlib,plot,figure","A_Id":35677835,"CreationDate":"2016-02-28T01:47:00.000","Title":"Understanding matplotlib: plt, figure, ax(arr)?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So recently I made a script, and I also finished gui and managed to merge those two together. Now i wish when I start the exe file that cmd doesn't appear but instead only GUI? Any idea on how to manage this? So far my searching didn't yield any satisfying results. Some more info is: Python 3.5, using pyinstaller to convert to exe, Tkinter Gui, pycharm 5.0.1. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":35685734,"Users Score":0,"Answer":"Since your question mentions .exe executables, I'wll assume you work in the Windows environment.  Try using a .pywextension instead of a .py extension for the python program.","Q_Score":0,"Tags":"python,user-interface,python-3.x","A_Id":35685792,"CreationDate":"2016-02-28T17:23:00.000","Title":"How do I stop cmd from appearing when i run exe file (python 3, gui)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an archive which I do not want to extract but check for each of its contents whether it is a file or a directory.\nos.path.isdir and os.path.isfile do not work because I am working on archive. The archive can be anyone of tar,bz2,zip or tar.gz(so I cannot use their specific libraries). Plus, the code should work on any platform like linux or windows. Can anybody help me how to do it?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20515,"Q_Id":35690072,"Users Score":0,"Answer":"I got the answer. It is that we can use two commands: archive.getall_members() and archive.getfile_members(). \nWe iterate over each of them and store the file\/folder names in two arrays a1(contains file\/folder names) and a2(contains file names only). If both the arrays contain that element, then it is a file otherwise it is a folder.","Q_Score":7,"Tags":"python,zip,archive","A_Id":35690298,"CreationDate":"2016-02-29T00:19:00.000","Title":"How to check if it is a file or folder for an archive in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a framework for executing tasks on top of Celery framework.\nI would like to see the list of recently executed tasks (for the recent 2-7 days).\nLooking on the API I can find app.backend object, but cannot figure out how to make a query to fetch tasks.\nFor example I can use backends like Redis or database. I do not want to explicitly write SQL queries to database.\nIs there a way to work with task history\/results with API?\nI tried to use Flower, but it can only handle events and cannot get history before its start.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":4109,"Q_Id":35726948,"Users Score":5,"Answer":"You can use the persisent option\uff0ceg: flower -A ctq.celery --persistent=True","Q_Score":5,"Tags":"python,celery,flower","A_Id":38764411,"CreationDate":"2016-03-01T15:32:00.000","Title":"Celery task history","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm build a Django app with a number of models (5-10). There would be an admin side, where an end-user manages the data, and then a user side, where other end-users can only read the data. I understand the point of a Django app is to encourage modularity, but I'm unsure as to \"where the line is drawn\" so-to-speak. \nIn \"best practices terms\": Should each model (or very related groups of models) have their own app? Should there be an 'admin' app and then a 'frontend' app? \nIn either case, how do the other apps retrieve and use models\/data inside other apps?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":100,"Q_Id":35731438,"Users Score":1,"Answer":"Python\\Django is modular.\n\nApp should include just those models which usually solve 1 concrete task.\nIf some of models from p.1 can be usefull in other tasks, then probably would be better to create a new apps for those models. Ie if some models are shared between multiple tasks then there is a logic to make a new apps with those models. \n\nFor example you have a forum app. This forum has such features like, polls, registrations, PM, etc. Logically everything seems to be combined together. However, if your site is just a forum - ok, but if there are other content, for example blogs with comments, then \"registration model\" can be made as a separate app and can be shared between parts of site such as \"blogs with comments\" and \"forum\". \nRegarding admin\\frontend. Ive seen apps\\projects with more than 10 models together. Based on the forum example above, if the admin part does not do any task out of scope of your app, then I would make admin and front-end inside of one app. Otherwise, if admin has any relation to another task, which is out of scope of your main app - admin should be as a seperate app.","Q_Score":2,"Tags":"python,django","A_Id":35732320,"CreationDate":"2016-03-01T19:13:00.000","Title":"Django - What constitutes an app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using CRF POS Tagger in Python, training English PTB sample corpus and the result is quite good.\nNow I want to use CRF to train on a large Vietnamese corpus. I need to add some Vietnamese features into this tagger like proper name, date-time, number,... I tried for days but cannot figure out how to do that. I already knew the format of data so it is not problem.\nI am quite new to Python. So any detailed answer can be helpful. Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":293,"Q_Id":35737093,"Users Score":0,"Answer":"i recommend use CRF tagger, it's very easy.","Q_Score":0,"Tags":"python,function,language-features,pos-tagger,crf","A_Id":38946931,"CreationDate":"2016-03-02T02:03:00.000","Title":"How to add specific features to CRF POS Tagger in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to find total length(perimeter),area of a spline from dxf file.\nIs there any function in dxfgrabber or ezdxf to find total length of an entity from dxf file ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3245,"Q_Id":35741698,"Users Score":1,"Answer":"dxfgrabber and ezdxf are just interfaces to the DXF format and do not provide any kind of CAD or calculation functions, and the geometrical length of DXF entities are not available attributes in the DXF format.","Q_Score":3,"Tags":"python,dxf","A_Id":36529617,"CreationDate":"2016-03-02T08:14:00.000","Title":"how to find length of entity from dxf file using dxfgrabber or ezdxf packages","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to interact with an API that uses a timestamp that starts at a different time than UNIX epoch. It appears to start counting on 2000-01-01, but I'm not sure exactly how to do the conversion or what the name of this datetime format is.\nWhen I send a message at 1456979510 I get a response back saying it was received at 510294713.\nThe difference between the two is 946684796 (sometimes 946684797) seconds, which is approximately 30 years.\nCan anyone let me know the proper way to convert between the two? Or whether I can generate them outright in Python?\nThanks\nEdit\nAn additional detail I should have mentioned is that this is an API to a Zigbee device. I found the following datatype entry in their documentation:  \n\n1.3.2.7 Absolute time\n  This is an unsigned 32-bit integer representation for absolute time. Absolute time is measured in seconds\n  from midnight, 1st January 2000.  \n\nI'm still not sure the easiest way to convert between the two","AnswerCount":5,"Available Count":1,"Score":0.1194272985,"is_accepted":false,"ViewCount":13703,"Q_Id":35763357,"Users Score":3,"Answer":"Well, there are 946684800 seconds between 2000-01-01T00:00:00Z and 1970-01-01T00:00:00Z.   So, you can just set a constant for 946684800 and add or subtract from your Unix timestamps.\nThe variation you are seeing in your numbers has to do with the delay in sending and receiving the data, and could also be due to clock synchronization, or lack thereof.  Since these are whole seconds, and your numbers are 3 to 4 seconds off, then I would guess that the clocks between your computer and your device are also 3 to 4 seconds out of sync.","Q_Score":9,"Tags":"python,datetime,unix,timestamp,epoch","A_Id":35763677,"CreationDate":"2016-03-03T04:42:00.000","Title":"Conversion from UNIX time to timestamp starting in January 1, 2000","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After spending 2 hours of research to no avail, I decided to pose my question here. What is the code to find CI of mean response in python? \nI know how to do it in R, but I just don't know what I need to do for Python. I assume statsmodel has a function for that. If so, what is it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":40,"Q_Id":35809944,"Users Score":0,"Answer":"Check wls_prediction_std from statsmodels.sandbox.regression.predstd.","Q_Score":0,"Tags":"python,statistics","A_Id":35810321,"CreationDate":"2016-03-05T04:18:00.000","Title":"How do I find CI of Mean Response using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"New to Theano when I tried to use the package I keep getting the following error: \nImportError: ('The following error happened while compiling the node', Dot22(, ), '\\n', 'dlopen(\/Userdir\/.theano\/compiledir_Darwin-14.3.0-x86_64-i386-64bit-i386-2.7.11-64\/tmpEBdQ_0\/eb163660e6e45b373cd7909e14efd44a.so, 2): Library not loaded: libmkl_intel_lp64.dylib\\n  Referenced from: \/Userdir\/.theano\/compiledir_Darwin-14.3.0-x86_64-i386-64bit-i386-2.7.11-64\/tmpEBdQ_0\/eb163660e6e45b373cd7909e14efd44a.so\\n  Reason: image not found', '[Dot22(, )]')\nCan someone tell me how to fix this issue?  Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":35811941,"Users Score":0,"Answer":"get rid of theano and reinstall. If that doesn't work, reinstall all of python","Q_Score":0,"Tags":"python-2.7,anaconda,theano","A_Id":42725755,"CreationDate":"2016-03-05T08:34:00.000","Title":"Running Theano on Python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a django app that requires Python (3.4) lxml package. I had a fair amount of trouble building the c shared libraries libxslt and libxml2 that lxml depends on in my red hat server environment. However, pip install lxml now completes successfully and I can import and use lxml in the command line interpreter.\nWhen I restart apache, importing lxml within my django app causes the error:\nImportError: \/usr\/local\/lib\/python3.4\/site-packages\/lxml\/etree.cpython-34m.so: undefined symbol: exsltMathXpathCtxtRegister\nI have checked that my LD_LIBRARY_PATH is set the same in both environments (\/usr\/lib).\nI notice that when I reinstall lxml through pip, pip tells me that it is building against libxml2\/libxslt found at \/usr\/lib64. I have removed all libxml2.so and libxslt.so files found at \/usr\/lib64\/ and been confounded to find that pip continues to tell me that it is building against lib64, that the install completes successfully, and that lxml still works correctly at command line but not through apache. \npip also says that the detected version of libxslt that it's using in the install is 1.1.23. However, I've used strace to see that when I import using the interpreter, the library that is loaded is \/usr\/lib\/libxslt.so.1.1.28. I don't know of any tool or technique to find out what library is being loaded through apache..\nDoes anyone have any theories as to what is going on or how to debug the issue? Thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":35820328,"Users Score":0,"Answer":"Fixed by removing libexslt.so files from usr\/lib64\/.","Q_Score":0,"Tags":"python,django,apache,lxml,libxslt","A_Id":35821295,"CreationDate":"2016-03-05T21:48:00.000","Title":"lxml runs in interpreter but not through apache\/mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how to detect if two substrings match a main string in a specific order. For example if we're looking for \"hours\" and then \"minutes\" anywhere at all in a string, and the string is \"what is 5 hours in minutes\", it would return true. If the string was \"what is 5 minutes in hours\", it would return false.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":35851862,"Users Score":0,"Answer":"You could use a regular expression such as \"hours.*minutes\", or you could use a simple string search that looks for \"hours\", notes the location where it is found, then does another search for \"minutes\" starting at that location.","Q_Score":2,"Tags":"python","A_Id":35851962,"CreationDate":"2016-03-07T19:04:00.000","Title":"If multiple substrings match string in specific order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"To change the logging level of a dependent package that properly names its logger log = logging.getLogger(__name__) is easy: logging.getLogger(\"name.of.package\").setLevel(logging.WARNING).\nBut if the 3rd party package doesn't name their logger and just logs messages using logging.info(\"A super loud annoying message!\"), how do I change that level?  Adding the getLogger(...).setLevel(..) doesn't seem to work because the logger isn't named.  Is it possible to change the logging level output of just one package without changing the level for the entire logging module?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":133,"Q_Id":35869666,"Users Score":0,"Answer":"If the logger is not named, it just means it is the default logger. You can get it by calling logging.getLogger()\nSo to set the log level, do this:\nlogging.getLogger.setLevel(logging.INFO)","Q_Score":1,"Tags":"python,logging","A_Id":35869928,"CreationDate":"2016-03-08T14:12:00.000","Title":"How to change python log level for unnamed logger?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed anconda with python 3.5, but i am curious to know how conda is managing between system python(2.7.6) and python3.5(installed with anaconda).\nParticularly If I make a new environment with conda help containing python 3.5 and don't switch to my root env in conda while restarting the system. Does system start with python3 as default or python 2.7.6?\nI am in need of answer to this as one of my friend installed Anaconda with python3.5 as default to system which broke the system dependencies and It did not start.\nI am using Ubuntu 14.04.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":642,"Q_Id":35871850,"Users Score":0,"Answer":"if you already used pip and virtual env, conda is like both at the same time. It's a package manager and also creates virtual environments. \nTo answer your question, conda creates a new environement, exporting python paths for this environment and installing all packages here. You can always switch between environments, but after reboot, all your virtual environments would be desactivated and you'll have your default system python path (2.7).","Q_Score":2,"Tags":"python,python-3.x,anaconda,conda","A_Id":35872466,"CreationDate":"2016-03-08T15:49:00.000","Title":"How conda manages the environment with system python and python installed with this","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the newest version of python (2.7.11) installed on my home director. To compile the YouCompleteMe plugin, I need the python-dev to be installed. However, the global python of my environment is 2.7.11, which means that if I install python-dev via apt-get, it would incompatible with python 2.7.11, because it is used for python 2.6.\nI re-compiled python 2.7.11 with --enable-shared flag, but failed to know how to add its lib and header files to system's default search path (if there exist such a path environment variable). \nSo, my question is, how to manually install the locally compiled python library to system?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":170,"Q_Id":35872623,"Users Score":0,"Answer":"Try installing the 2.7 version : apt-get install python2.7-dev","Q_Score":0,"Tags":"python,linux,ubuntu,installation,environment-variables","A_Id":35872702,"CreationDate":"2016-03-08T16:24:00.000","Title":"how to manually install the locally compiled python library (shared python library) to system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a situation where I've got finer time granularity than I do position granularity. Let's say that I'm measuring position at 10 Hz, but am making other measurements at 100 Hz. I'm wondering if anyone is aware of a clever\/efficient way of associating a position with a time interval? That is, given a time that falls within that interval the lookup would return an appropriate position. It may just be that a straightforward implementation involving a list of tuples (start_time, end_time, position) and looping won't be disastrous, but I'm curious to know how other people have dealt with this kind of problem.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":17,"Q_Id":35879103,"Users Score":1,"Answer":"You could have a data structure that maps interval start or end points to positions. In order to compute the interval you need to look up, either do some appropriate rounding on the time value in question (if the intervals can be considered regular enough for that), or use the bisect module to look up the closest start or end point in the list of all occurring intervals.","Q_Score":0,"Tags":"python,collections","A_Id":35879173,"CreationDate":"2016-03-08T22:15:00.000","Title":"Efficiently associating a single value with an interval","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python 2.7, how do I most efficiently produce a unique, random string of len=3 - formed only of digits - where values contained in a list (called exclude_me) are not considered while the random string is being calculated? \nE.g. exclude_me=['312','534','434','999',...........,'123']","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":344,"Q_Id":35879106,"Users Score":0,"Answer":"You could declare a fixed list of approximately 1000 strings (i.e. ['000', '001', ..., '999'], omitting whatever values you like, then call random.choice() on that list.\nIf you don't want to type 1000 strings, you could programatically generate the list using something like range() and then .remove() your banned values.","Q_Score":0,"Tags":"python,python-2.7,random","A_Id":35879315,"CreationDate":"2016-03-08T22:15:00.000","Title":"Generating a random string of fixed length where certain values are prohibited","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to show live webcam video stream on webpage and I have a working draft. However, I am not satisfied with the performance and looking for a better way to do the job.\nI have a webcam connected to Raspberry PI and a web server which is a simple python-Flask server. Webcam images are captured by using OpenCV and formatted as JPEG. Later, those JPEGs are sent to one of the server's UDP ports. What I did up to this point is something like a homemade MJPEG(motion-jpeg) streaming. \nAt the server-side I have a simple python script that continuously reads UDP port and put JPEG image in the HTML5 canvas. That is fast enough to create a perception of a live stream. \nProblems:\n\nThis compress the video very little. Actually it does not compress the video. It only decreases the size of a frame by formatting as JPEG.\nFPS is low and also quality of the stream is not that good.\nIt is not a major point for now but UDP is not a secure way to stream video.\nServer is busy with image picking from UDP. Needs threaded server design.\n\nAlternatives:\n\nI have used FFMPEG before to convert video formats and also stream pre-recorded video. I guess, it is possible to encode(let say H.264) and stream WebCam live video using ffmpeg or avconv. (Encoding)\n\n\nIs this applicable on Raspberry PI ?\n\n\nVLC is able to play live videos streamed on network.  (Stream)\n\n\nIs there any Media Player to embed on HTML\/Javascript to handle\n  network stream like the VLC does ?\n\n\nI have read about HLS (HTTP Live Stream) and MPEG-DASH. \n\n\nDoes these apply for this case ? If it does,how should I use them ?\nIs there any other way to show live stream on webpage ?\n\n\nRTSP is a secure protocol.\n\n\nWhat is the best practice for transport layer protocol in video\n  streaming ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":8409,"Q_Id":35880417,"Users Score":0,"Answer":"You could use FFmpeg to mux the video stream in to H.264 in a mp4 container and then that can be directly used in a HTML5 video element.","Q_Score":6,"Tags":"python,video,ffmpeg,video-streaming,http-live-streaming","A_Id":35886856,"CreationDate":"2016-03-08T23:56:00.000","Title":"Live Video Encoding and Streaming on a Webpage","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in text mining\/classification when a vectorizer is used to transform a text into numerical features, in the training TfidfVectorizer(...).fit_transform(text) or TfidfVectorizer(...).fit(text) is used. In testing it supposes to utilize former training info and just transform the data following the training fit. \nIn general case the test run(s) is completely separate from train run. But it needs some info regarding the fit obtained during the training stage otherwise the transformation fails with error sklearn.utils.validation.NotFittedError: idf vector is not fitted . It's not just a dictionary, it's something else. \nWhat should be saved after the training is done, to make the test stage passing smoothly?\nIn other words train and test are separated in time and space, how to make test working, utilizing training results?\nDeeper question would be what 'fit' means in scikit-learn context, but it's probably out of scope","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":35882062,"Users Score":0,"Answer":"In the test phase you should use the same model names as you used in the trainings phase. In this way you will be able to use the model parameters which are derived in the training phase. Here is an example below;\n\nFirst give a name to your vectorizer and to your predictive algoritym (It is NB in this case)\n\n\nvectorizer = TfidVectorizer()\nclassifier = MultinomialNB()\n\n\nThen, use these names to vectorize and predict your data\n\n\ntrainingdata_counts = vectorizer.fit_transform(trainingdata.values)\nclassifier.fit(trainingdata_counts, trainingdatalabels)\ntestdata_counts = vectorizer.transform(testdata.values)\npredictions=classifier.predict(testdata_counts)\n\nBy this way, your code will be able to process training and the test phases continuously.","Q_Score":0,"Tags":"python,scikit-learn","A_Id":35889624,"CreationDate":"2016-03-09T02:58:00.000","Title":"Vectorizer where or how fit information is stored?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Windows 7 Task Scheduler is running my Python script every 15 minutes. Command line is something like c:\\Python\\python.exe c:\\mypath\\myscript.py. It all works well, script is called every 15 minues, etc. \nHowever, the task scheduler pops up a huge console window titled taskeng.exe every time, blocking the view for a few seconds until the script exits. \nIs there a way to prevent the pop-up?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3605,"Q_Id":35900622,"Users Score":5,"Answer":"Simply save your script with .pyw extension.\nAs far as I know, .pyw extension is the same as .py, only difference is that .pyw was implemented for GUI programs and therefore console window is not opened.\nIf there is more to it than this I wouldn't know, perhaps somebody more informed can edit this post or provide their own answer.","Q_Score":3,"Tags":"python,windows,scheduled-tasks","A_Id":35901175,"CreationDate":"2016-03-09T19:15:00.000","Title":"Windows Task Scheduler running Python script: how to prevent taskeng.exe pop-up?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have python 2.7 under windows x64, I have been trying to make a simple GUI using PyQt4, like this:\nfrom PyQt4 import *\nfrom ui_mainwindow import Ui_MainWindow\nclass MainWindow(QtGui.QMainWindow, Ui_MainWindow):\nwhen I run the program I have this error:  \" No module named ui_mainWindow\"\n-I have pyqt4 installed\n- I have tried to replace um_mainwindow with ui_simple and clientGUI but the same error resulted.\nWhat am I doing wrong and how to fix this?\nthank you","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":831,"Q_Id":35914596,"Users Score":0,"Answer":"As far as I know, ui_mainWindow is a python file generated by some Qt Tool, that transforms .ui file from QtDesigner to Python class.\nI have no real experience with PyQT, but I know both C++\/Qt and python. In C++\/Qt QtCreator does the job of transforming .ui file to C++ class, but probably in python You need to do this Yourself.","Q_Score":0,"Tags":"python,python-2.7,pyqt4","A_Id":35914964,"CreationDate":"2016-03-10T11:02:00.000","Title":"python 2.7 under windows: cannot import ui_mainwindow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I run python in my Android Terminal and want to run a .py file with:\npython \/sdcard\/myScript.py\nThe problem is that python is called in my Android enviroment indirect with a shell in my \/system\/bin\/ path (to get it direct accessable via Terminal emulator). \nMy exact question, how the title tells how to pass parameter through multiple Shell scripts to Python?\nMy direct called file \"python\" in \/System\/bin\/ contains only a redirection like:\nsh data\/data\/com.hipipal.qpyplus\/files\/bin\/qpython-android5.sh\nand so on to call python binary.\nEdit:\nI simply add the $1 parameter after every shell, Python is called through like:\nsh data\/data\/com.hipipal.qpyplus\/files\/bin\/qpython-android5.sh $1\nso is possible to call \npython \/sdcard\/myScript.py arg1\nand in myScript.py as usual fetch with sys.argv\nthanks","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":373,"Q_Id":35928155,"Users Score":0,"Answer":"I don't have experience in Android programming, so I can only give a general recommendation:\nOf course the naive solution would be to explicitly pass the arguments from script to script, but I guess you can't or don't want to modify the scripts in between, otherwise you would not have asked.\nAnother approach, which I sometimes use, is to define an environment variable in the outermost scripts, stuff all my parameters into it, and parse it from Python. \nFinally, you could write a \"configuration file\" from the outermost script, and read it from your Python program. If you create this file in Python syntax, you even spare yourself from parsing the code.","Q_Score":0,"Tags":"android,python,shell,qpython","A_Id":35935344,"CreationDate":"2016-03-10T21:58:00.000","Title":"Pass parameter through shell to python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I run python in my Android Terminal and want to run a .py file with:\npython \/sdcard\/myScript.py\nThe problem is that python is called in my Android enviroment indirect with a shell in my \/system\/bin\/ path (to get it direct accessable via Terminal emulator). \nMy exact question, how the title tells how to pass parameter through multiple Shell scripts to Python?\nMy direct called file \"python\" in \/System\/bin\/ contains only a redirection like:\nsh data\/data\/com.hipipal.qpyplus\/files\/bin\/qpython-android5.sh\nand so on to call python binary.\nEdit:\nI simply add the $1 parameter after every shell, Python is called through like:\nsh data\/data\/com.hipipal.qpyplus\/files\/bin\/qpython-android5.sh $1\nso is possible to call \npython \/sdcard\/myScript.py arg1\nand in myScript.py as usual fetch with sys.argv\nthanks","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":373,"Q_Id":35928155,"Users Score":0,"Answer":"I have similar problem. Runing my script from Python console \n\/storage\/emulator\/0\/Download\/.last_tmp.py -s && exit \n I am getting \"Permission denied\". No matter if i am calling last_tmp or edited script itself. \nIs there perhaps any way to pass the params in editor?","Q_Score":0,"Tags":"android,python,shell,qpython","A_Id":36178959,"CreationDate":"2016-03-10T21:58:00.000","Title":"Pass parameter through shell to python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm taking an online MIT programming course that suggested I use the enthought programming environment.  I installed it and now my idle keyboard shortcuts have all changed.  It seems to be directly caused by the installation of enthought, as my other computer (without enthought) still retained the old keyboard shortcuts.  Anyone know how to get my old keyboard shortcuts back?","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":21,"Q_Id":35928317,"Users Score":-2,"Answer":"if i were you, try to continue and use your old shortcuts but if they still dont work, try to use \"control\" for \"option\" shortcuts and vice-versa. thanks to the the websites online for everything!","Q_Score":0,"Tags":"keyboard,python-idle,enthought,shortcut","A_Id":52823738,"CreationDate":"2016-03-10T22:07:00.000","Title":"idle keyboard shortcuts have changed after installing enthought","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using the whitegrid style and it's fine except for the vertical lines in the background.\nI just want to retain the horizontal lines.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":35938891,"Users Score":0,"Answer":"Passing arguments into ax.yaxis.grid() and ax.xaxis.grid() will include or omit grids in the graphs","Q_Score":0,"Tags":"python,matplotlib,seaborn","A_Id":35939091,"CreationDate":"2016-03-11T11:18:00.000","Title":"matplotlib & seaborn: how to get rid of lines?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can run my python scripts on the terminal and get the print results on the stdout e.g. \npython myprog.py \nor simply redirect it to a file:\npython myprog.py > out.txt\nMy question is how could I do both solutions at the same time.\nMy linux experience will tell me something like:\npython myprog.py |& tee out.txt \nThis is not having the behaviour I expected, print on the fly and not all at once when the program ends.\nSo what I wanted (preferred without changing python code) is the same behavior as python myprog.py (print on the fly) but also redirecting output to a file.\nWhat is the simplest way to accomplish this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":838,"Q_Id":35941506,"Users Score":0,"Answer":"You want to use 'tee'. stdbuf -oL python mycode.py | tee out.txt","Q_Score":2,"Tags":"python,redirect,stdout","A_Id":35941617,"CreationDate":"2016-03-11T13:28:00.000","Title":"python - print to stdout and redirect output to file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use virtualenv in my new mainly Python project. The code files are located at ~\/Documents\/Project, and I installed a virtual environment in there, located at ~\/Documents\/Project\/env. I have all my packages and libraries I wanted in the env\/bin folder.\nThe question is, how do I actually run my Python scripts, using this virtual environment? I activate it in Terminal, then open idle as a test, and try \n\n\"import django\"\n\nbut it doesn't work. Basically, how can I use the libraries install in the virtual environment with my project when I run it, instead of it using the standard directories for installed Python libraries?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2126,"Q_Id":35952511,"Users Score":0,"Answer":"It's also good practice to make a requires.txt file for all your dependencies.  If for example your project requires Flask and pymongo, create a file with:\nFlask==<version number you want here>\npymongo==<version number you want here>\n\nThen you can install all the necessary libraries by doing:\npip install -r requires.txt\nGreat if you want to share your project or don't want to remember every library you need in your virtualenv.","Q_Score":0,"Tags":"python,django,virtualenv","A_Id":35952928,"CreationDate":"2016-03-12T01:06:00.000","Title":"How to use virtualenv in Python project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python in the MSYS2 environment. The MSYS2 has its own built MINGW python version. Also I can install the official python from the www.python.org.\nHere is the problem: If I want to write a python code need to know the python version is MINGW or the official one, how can I do it?\nHere are some ways I can image.\n\nUse the \"sys.prefix\" object. It tells the installation directory. the MSYS2 usually installed in the directory X:\\msys2\\.... and the official one install in the X:\\Python27\\ as default. But users may change the installation directory. So this is not a good way.\nUse the \"sys.version\" object can get the version strings show with the compiler name. It shows the MINGW python compiled by GCC, the official one compiled by MSC. But there may have some possibility that there is an other version's python also built by GCC or MSC.\n\nIs there any more elegant way can do this?","AnswerCount":3,"Available Count":1,"Score":-0.0665680765,"is_accepted":false,"ViewCount":2041,"Q_Id":35956180,"Users Score":-1,"Answer":"sys.platform gives msys when in msys-Python.","Q_Score":2,"Tags":"python,windows,gcc,mingw,msys2","A_Id":41492215,"CreationDate":"2016-03-12T09:58:00.000","Title":"How to determine the python is mingw or official build?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This might be a very dumb question, so please bear with me (there's also no code included either).\nRecently, I switched from PHP to Python and fell in love with Django. Locally, everything works well.\nHowever, how are these files accessed when on a real server?\nIs the manage.py runserver supposed to be used in a server environment?\nDo I need to use mod_python ?\nComing from PHP, one would simply use Apache or Nginx but how does the deployment work with Python\/Django?  \nThis is all very confusing to me, admittedly. Any help is more than welcome.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":35962581,"Users Score":1,"Answer":"manage.py runserver is only used to speed your development process, it shouldn't be run on your server. It's similar to the newly introduced php's built-in server php -S host:port.\nSince you're coming from PHP you can use apache with mod_wsgi in order to serve your django application, there are a lot of tutorials online on how to configure it properly. You might want to read what wsgi is and why it's important.","Q_Score":0,"Tags":"python,django,server","A_Id":35962887,"CreationDate":"2016-03-12T19:55:00.000","Title":"Python development: Server Handling","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"when I try to import pandas using the data nitro shell, I get the error that there is no module named pandas. \nI have pandas through the canopy distribution, but somehow the data nitro shell isn't \"finding\" it. \nI suspect this has to do with the directory in which pandas is stored, but I don't know how to \"extract\" pandas from that directory and put it into the appropriate directory for data nitro. \nAny ideas would be super appreciated. Thank you!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":193,"Q_Id":35963580,"Users Score":0,"Answer":"DataNitro is probably using a different copy of Python on your machine. Go to Settings in the DataNitro ribbon, uncheck \"use default Python\", and select the Canopy python directory manually. Then, restart Excel and see if importing works.","Q_Score":1,"Tags":"python,pandas,datanitro","A_Id":35964006,"CreationDate":"2016-03-12T21:34:00.000","Title":"Can't find pandas in data nitro","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using the python cassandra-driver to execute queries on a cassandra database and I am wondering how to re-insert a ResultSet returned from a SELECT query on table A to a table B knowing that A and B have the same columns but a different primary keys.\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":294,"Q_Id":35964324,"Users Score":0,"Answer":"There is no magic, you'll need to:\n\ncreate a prepare statement for INSERT ... INTO tableB ...\non each ResultSet from table A, extract the values and create a\nbound statement for table B, then execute the bound statement for\ninsertion into B\n\nYou can use asynchronous queries to accelerate the migration a little bit but be careful to throttle the async.","Q_Score":0,"Tags":"python,cassandra,resultset","A_Id":35969262,"CreationDate":"2016-03-12T22:52:00.000","Title":"Cassandra python driver - how to re-insert a ResultSet","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Windows 7 64 Bit. By mistake I installed Python 3.5 32 bit. I want to uninstall it (for installing 64 Bit version) but dont know how to do it (It does not get uninstalled from Control Panel -> Uninstall a Program). I googled it and found some links but could not understand \/ was not able to do it.\nPlease help.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":9697,"Q_Id":35965427,"Users Score":3,"Answer":"Find the uninstall shortcut link in the python folder on win start menu Or in Python's install folder, then uninstall it. \nIf you can not find either, I think you should just delete the python install folder, then everything should be ok after you install the python x64. \nBecause for many program just the files in install folder are x86\/x64 dependent, other files in the user folder is not.\nP.S.\nInstallation folder maybe locate in c:\\\\programs\/python35\/or in something like c:\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python35","Q_Score":3,"Tags":"python,uninstallation","A_Id":35965537,"CreationDate":"2016-03-13T01:29:00.000","Title":"Python 3.5 uninstall Windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a program in Python which draws parts of the Mandelbrot set using pygame. However, when I leave it running to generate for a long time and then save the file I get this error: \n\npygame.error: SavePNG: could not open for writing \n\nI'm not sure why this would happen and saving works fine usually. Perhaps when the computer goes to sleep something stops working? But more importantly does anyone know how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1146,"Q_Id":35968464,"Users Score":0,"Answer":"Are you on windows or on mac? If you're on windows look if you wrote the location like this\n\"\\folder\\thing.png\", that's an error because you put the starting \"\\\". Remove that and try again.","Q_Score":1,"Tags":"python,image,crash,save,pygame","A_Id":51588818,"CreationDate":"2016-03-13T09:08:00.000","Title":"pygame.error: SavePNG: could not open for writing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am currently writing a time consuming python program and decided to rewrite part of the program in fortran. However, the performance is still not good. For profiling purpose, I want to know how much time is spent in f2py wrappers and how much time is actual spent in fortran subroutines. Is there a convenient way to achieve this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":35968682,"Users Score":1,"Answer":"At last I found out -DF2PY_REPORT_ATEXIT option can report wrapper performance.","Q_Score":0,"Tags":"python,fortran,profiling,f2py","A_Id":35970843,"CreationDate":"2016-03-13T09:35:00.000","Title":"How to obtain how much time is spent in f2py wrappers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?","AnswerCount":6,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":40994,"Q_Id":35999344,"Users Score":4,"Answer":"Run Tkinter.TclVersion or Tkinter.TkVersion and if both are not working, try Tkinter.__version__","Q_Score":27,"Tags":"python-3.x,tkinter","A_Id":35999383,"CreationDate":"2016-03-14T22:30:00.000","Title":"How to determine what version of python3 tkinter is installed on my linux machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?","AnswerCount":6,"Available Count":2,"Score":0.1651404129,"is_accepted":false,"ViewCount":40994,"Q_Id":35999344,"Users Score":5,"Answer":"Type this command on the Terminal and run it.\n\npython -m tkinter\n\nA small window will appear with the heading tk and two buttons: Click Me! and QUIT. There will be a text that goes like This is Tcl\/Tk version ___. The version number will be displayed in the place of the underscores.","Q_Score":27,"Tags":"python-3.x,tkinter","A_Id":63566647,"CreationDate":"2016-03-14T22:30:00.000","Title":"How to determine what version of python3 tkinter is installed on my linux machine?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on mac OS X and I have both Python 2.7 and 3.3 on it. I want to install pykml module and i successfully installed it on python 3.3, but how do I do the same for Python 2.7?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":66,"Q_Id":36007774,"Users Score":1,"Answer":"You can do this if pip version >=1.5\n$ pip2.6 install package\n $ pip3.3 install package\nif pip version is between 0.8 and 1.5 this will work\n$ pip-2.7 install package\n $ pip-3.3 install package","Q_Score":0,"Tags":"python,macos,module,installation","A_Id":36007983,"CreationDate":"2016-03-15T09:51:00.000","Title":"Install module in Python 2.7 and not in Python 3.3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"we are trying to come up with a solution to have AWS S3 to host and distribute our Python packages.\nBasically what we want to do is using python3 setup.py bdist_wheel to create a wheel. Upload it to S3. Then any server or any machine can do pip install $http:\/\/path\/on\/s3. (including a virtualenv in AWS lambda)\n(We've looked into Pypicloud and thought it's an overkill.)\nCreating package and installing from S3 work fine. There is only one issue here: we will release new code and give them different versions. If we host our code on Pypi, you can upgrade some packages to their newest version by calling pip install package --upgrade.\nBut if you host your packages on S3, how do you let pip know there's a newer version exists? How do you roll back to an older version by simply giving pip the version number? Is there a way to let pip know where to look for different version of wheels on S3?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13564,"Q_Id":36022867,"Users Score":0,"Answer":"What about wrapping up the whl file (e.g. yourpkg-1.0-py3-none-any.whl) inside another zip file (e.g. yourpkg.zip) with a deterministic name. Then you can set up some cron scripts to check locally whether the deterministic key has a new s3 file, and if so then unzip the whl and install it.","Q_Score":21,"Tags":"python,amazon-s3,pip","A_Id":62367203,"CreationDate":"2016-03-15T21:48:00.000","Title":"If we want use S3 to host Python packages, how can we tell pip where to find the newest version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I launch an EMR using spot block (AWS) using boto ? I am trying to launch it using boto but I cannot find any parameter --block-duration-minutes in boto, I am unable to find how to do this using boto3.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":454,"Q_Id":36029866,"Users Score":1,"Answer":"According to the boto3 documentation, yes it does support spot blocks. \n\nBlockDurationMinutes (integer) --\n  The defined duration for Spot instances (also known as Spot blocks) in minutes. When specified, the Spot instance does not terminate before the defined duration expires, and defined duration pricing for Spot instances applies. Valid values are 60, 120, 180, 240, 300, or 360. The duration period starts as soon as a Spot instance receives its instance ID. At the end of the duration, Amazon EC2 marks the Spot instance for termination and provides a Spot instance termination notice, which gives the instance a two-minute warning before it terminates.\n\nIniside the LaunchSpecifications dictionary, you need to assign a value to BlockDurationMinutes.  However, the maximum value is 360 (6 hours) for a spot block.","Q_Score":4,"Tags":"python-2.7,boto,emr,boto3","A_Id":46980003,"CreationDate":"2016-03-16T08:02:00.000","Title":"How can I launch an EMR using SPOT Block using boto?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have machine with multiple NICs that can be connected to one net, to different nets or every other possible way. Python script that uses requests module to send POST\/GET requests to the server is ran on that machine.\nSo, the question is next: how can I know in python script from which interface requests will be sent?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":204,"Q_Id":36054602,"Users Score":0,"Answer":"Here there are two different answers. The one is for the case where you want to specify the NIC to send the request and the other is for what you're asking: find the correct NIC. \nFor the second answer, I can only say that it depends. Are these NICs on the same network \/ subnet? Are they bonded? \nIf they are on a different network then you can know the host IP Address and use the computer's routing table to see which NIC the packet will go through. If they are bonded on the same network then the request will leave from the bond interface since it is (normally) the one with an IP Address. If they are on the same network and have a different IP on the same subnet then it depends. Can you provide some more information in that case?","Q_Score":1,"Tags":"python,python-3.x,post,network-programming,python-requests","A_Id":36056276,"CreationDate":"2016-03-17T07:58:00.000","Title":"Python 3: how to get nic from which will be sent packets to certain ip?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Question 1 \nYou have an abstract stack with n entries and an empty abstract queue (to help). Approximately how many calls are needed to determine n? The stack needs to be unchanged afterwards. \nQuestion 2\nSame question, but you start with an abstrack queue and have an empty abstrack stack. \nMy reasoning\nPop from stack -> push onto queue -> get from queue -> put on stack -> pop from stack -> push onto queue -> get from queue -> put on stack. Somewhere we throw in a counter and that makes it 8*n calls (9*n if the counter calls count). I don't see how else I can pop the items from the stack and then get them back in the right order. Is there a better way?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":234,"Q_Id":36059066,"Users Score":0,"Answer":"Q1. A better solution could be:\n\npop \nenqueue \ndequeue\npush\n\nBy do this, you get 4*n operations.\nFor instance, let be stack:  1, 2, 3 (with 1 as the top)\nLet be s the stack and q the queue.\nq.enqueue(s.pop()), so now s = [2, 3] and q = [1]\nq.enqueue(s.pop()), so now s = [3] and q = [1, 2]\nq.enqueue(s.pop()), so now s = [] and q = [1, 2, 3]\ns.push(q.dequeue()), so now s = [1] and q = [2, 3]\ns.push(q.dequeue()), so now s = [2, 1] and q = [3]\ns.push(q.dequeue()), so now s = [3, 2, 1] and q = []\nq.enqueue(s.pop()), so now s = [2, 1] and q = [3]\nq.enqueue(s.pop()), so now s = [1] and q = [3, 2]\nq.enqueue(s.pop()), so now s = [] and q = [3, 2, 1]\ns.push(q.dequeue()), so now s = [3] and q = [2, 1]\ns.push(q.dequeue()), so now s = [2, 3] and q = [1]\ns.push(q.dequeue()), so now s = [1, 2, 3] and q = []\nI don't think this could be the best solution, but is a better solution (9*n vs 4*n, always O(n))\nQ2. I think that the same (not optimal) algorithm of previous case could be used now...\nThe main idea is that when you get an item from stack, this would be the last of the queue, cause the two data stuctures have a different way for input.\nHope this helps you :-)","Q_Score":0,"Tags":"python,python-3.x","A_Id":36060129,"CreationDate":"2016-03-17T11:22:00.000","Title":"Number of calls to determine size of stack\/queue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First of all I'm new to python and using 3.5 version when trying to install pandas usingpip install pandasit is showing error as pip is not recognized as an internal or external command by using other command to install some packages,py -3.5 -m pip install SomePackageit shows me error could not find a version that satisfies the requirement SomePackage also ask's me update the pip version from 7.1.2 to 8.1.0 and when updating the pip python -m pip install --upgrade pip it shows me error python is not recognized as an internal or external command\nNow how to install Pandas on my python 3.5?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":479,"Q_Id":36062523,"Users Score":0,"Answer":"You should try typing in python3 instead of python because, you are running v3.x on Python and the command python runs v2.7 according to me.","Q_Score":0,"Tags":"python,pandas,python-3.5","A_Id":36587035,"CreationDate":"2016-03-17T13:50:00.000","Title":"error for pandas installation and update of pip in python 3.5 windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'd like to know how to generate a controlled CPU load on Linux using shell or python script. By controlled load I mean creating a process that consumes a specified amount of CPU cycles (e.g., 20% of available CPU cycles). \nI wrote a python script that does some dummy computation like generating N random integers and sort them using the built-in sort function. I used \"time\" utility in Linux to compute the User and Kernel time consumed by the process. But I am not sure how to compute the CPU utilization of the specific process from CPU time.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":151,"Q_Id":36087488,"Users Score":0,"Answer":"Maybe try to to use time.sleep() and play around with how long to sleep in between calculations?","Q_Score":1,"Tags":"python,linux,cpu","A_Id":36087597,"CreationDate":"2016-03-18T14:53:00.000","Title":"How to create controlled CPU load on Linux?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a web app using my own framework that I created using mod_wsgi.\nI want to avoid using dependencies such as Django or Flask, just to have a short script, It actually won't be doing much.\nI have managed to authenticate user using LDAP, from a login page, the problem is that I don't want the user to authenticate every time a action requires authorization, but I don't know how to keep user logged in.\nShould I use the cookies? If so, what would be the best method to keep identification in cookies? What are my options?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":127,"Q_Id":36095800,"Users Score":1,"Answer":"The best (read: easiest) way to go about this is with session variables. That said, in lieu of session variable functionality you would get with a framework, you can implement your own basic system.\n1) Generate a random Session id\n2) send a cookie to browser\n3) Json or pickle encode your variables\n4a) save encoded string to key-value storage system like redis or memcached with session if as the key, or\n4b) save it to a file on the server preferably in \/tmp\/","Q_Score":0,"Tags":"python,apache,cookies,mod-wsgi,sign","A_Id":36096173,"CreationDate":"2016-03-18T23:14:00.000","Title":"Keep user signed in using mod_wsgi","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Hello dear programmers Python language.\nI have a question about importing modules in another module with Python 2.7.\nI want to know how to import a .py module in the form of a variable.\nIn fact, I would like to import a module based on the needs of my main module to limit the memory usage of the computer.\nFor example, suppose I have 25 modules: 1.py, 2.py ... 25.py\nSuppose my main module P.y needs, at some point, the modules 2, 7, 15 and 24.py but not the others.\nBecause, I don't know which modules the main module needs, I currently import all modules with the import function: import 1 2 3 ... 25\nIs there a python function to import only the modules 2, 7,15 and 24 with a variable ? (for example: somethink_like_import (variable)\n where variable contains the module name to import.)\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":80,"Q_Id":36104410,"Users Score":0,"Answer":"I found this and it's working !\nvariable = \"mymodule\"\nmodule = __ import__(variable,globals(),locals(),[],-1)\n...\nmodule.myfunction() # where function is the name of the function inside mymodule.py","Q_Score":0,"Tags":"python-2.7","A_Id":36119138,"CreationDate":"2016-03-19T16:49:00.000","Title":"import a module with a variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try to use pip install psycopg2 on windows10 and python3.5, but it show me below error message. how can i fix it ?\n\nCommand\n  \"d:\\desktop\\learn\\python\\webcatch\\appserver\\webcatch\\scripts\\python.exe\n  -u -c \"import setuptools, tokenize;file='C:\\Users\\16022001\\AppData\\Local\\Temp\\pip-build-rsorislh\\psycopg2\\setup.py';exec(compile(getattr(tokenize,\n  'open', open)(file).read().replace('\\r\\n', '\\n'), file,\n  'exec'))\" install --record\n  C:\\Users\\16022001\\AppData\\Local\\Temp\\pip-kzsbvzx9-record\\install-record.txt\n  --single-version-externally-managed --compile --install-headers d:\\desktop\\learn\\python\\webcatch\\appserver\\webcatch\\include\\site\\python3.5\\psycopg2\"\n  failed with error code 1 in\n  C:\\Users\\16022001\\AppData\\Local\\Temp\\pip-build-rsorislh\\psycopg2\\","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":329,"Q_Id":36115491,"Users Score":0,"Answer":"pip install psycopg this worked for me, don't mention version i.e (pip install psycopg2)","Q_Score":0,"Tags":"python,windows,psycopg2","A_Id":69657488,"CreationDate":"2016-03-20T15:11:00.000","Title":"pip install psycopg2 error","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to find, do I follow someone or not. I realized that although it is written in official Tweepy document, I cannot use API.exists_friendship anymore. Therefore, I tried to use API.show_friendship(source_id\/source_screen_name, target_id\/target_screen_name) and as the document said it returns me friendship object. (<tweepy.models.Friendship object at 0x105cd0890>, <tweepy.models.Friendship object at 0x105cd0ed0>) \nWhen I write screen_names = [user.screen_name for user in connection.show_friendship(target_id=someone_id)] it returns my_username and username for someone_id.\nCan anyone tell me how can I use it properly? or is there any other method that simply returns me True\/False because I just want to know do I follow him\/her or not.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3016,"Q_Id":36118490,"Users Score":0,"Answer":"i am using below code this works fine  ..\n     if(api.show_friendship(source_screen_name='venky6amesh', target_screen_name='vag')):\n            print(\"the user is not a friend of \")\n            try:\n                api.create_friendship(j)\n                print('success')\n            except tweepy.TweepError as e:\n                print('error')\n                print(e.message[0]['code']) \n            else:\n                print(\"user is a friend of \",j)","Q_Score":0,"Tags":"python,tweepy","A_Id":55508308,"CreationDate":"2016-03-20T19:31:00.000","Title":"Checking friendship in Tweepy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"As title, python use virtualenv to isolate pip libraries for each python application. Ruby has gem, how does it prevent library version conflicts without a virtual environment.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":299,"Q_Id":36122612,"Users Score":2,"Answer":"bundler is generally used to lock dependency versions for a project (e.g. the gem versions). rbenv and rvm (there are several others too) are two common approaches to managing multiple versions of Ruby. A feature these provide (at least rvm does) is gemsets: these are a way to isolate your gem directories (so you may have a default gemset and a edge gemset or something; I don't find these very useful so I apologize for the bad examples).\nIn general bundler is usually seen as the \"good enough\" solution to isolating dependencies and gemsets don't seem to be used all that often anymore.","Q_Score":1,"Tags":"python,ruby,rubygems,pip,virtualenv","A_Id":36122740,"CreationDate":"2016-03-21T03:19:00.000","Title":"Python use virtualenv to prevent library version conflicts. How ruby does it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been learning how to make GUIs with Tkinter and a question has occurred to me. As I'm testing the program, I often end up building the code while an instance of it already exists in the background. Are these two independent of each other in terms of performing their functions? I've always read that when I create the instance of the Tk() and then run its mainloop(), that is what takes care of everything. Can I have two or more loops running if each pertains to a different Tk() instance?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":291,"Q_Id":36141010,"Users Score":1,"Answer":"Each instance of Tk is separate from any other instance of Tk. It gets its own copy of an underlying tcl interpreter. Two instance of Tk in the same process means you have two active tcl interpreters. \nAs a general rule you should only ever have exactly one instance of Tk, but I suppose if you fully understand how they work, it should be possible to have two or more. \nI think this falls into the category of things you shouldn't do until you understand why you shouldn't do them. And once you understand, you won't want to do it.","Q_Score":1,"Tags":"python,python-2.7,tkinter","A_Id":36141286,"CreationDate":"2016-03-21T20:32:00.000","Title":"Is each instance of Tk() class running independent of each other?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have lots of forms that aren't attached to models, like a search form. I don't want people to be able to access these without first verifying their account through an email. How is the best way to limit their ability to do this? Is it through custom permissions? If so, how do I go about this? Thank you so much!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":36144018,"Users Score":0,"Answer":"You have several ways to do it:\n\nUI level: when the search field is focused you can say through an alert or other mechanism to notify users you are not allowed to search.\nServer level: assuming your user is logged in or has an account you can verify the user in the search request and return a response where you state you cannot search without confirming your email.\nDon't let them use the site after registering unless they confirm their email. You can see doing searches as data display and if you don't block that either you confuse users. Why can I see all articles but can't search? \n\nI would go for 3. and let them use the site. They can confirm it afterwards when they try to do something which modifies the DB (aka they try to post something, then from a psychological standpoint there is a block between them and their objective and they will be more willing to confirm in order to achieve their objective)","Q_Score":0,"Tags":"python,django,forms,permissions,verify","A_Id":36146532,"CreationDate":"2016-03-22T00:12:00.000","Title":"Django: Making custom permissions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"In Django database username is used as schema name.\nIn DB2 there is no database level users. OS users will be used for login into the database.\nIn my database I have two different names for database user and database schema.\nSo in django with db2 as backend how can I use different schema name to access the tables?\nEDIT:\nClarifying that I'm trying to access via the ORM and not raw SQLs. The ORM implicitly is using the username as the schema name. How do I avoid that ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":688,"Q_Id":36159706,"Users Score":0,"Answer":"DB2 uses so-called two part names, schemaname.objectname. Each object, including tables, can be referenced by the entire name. Within a session there is the current schema which by default is set to the username. It can be changed by the SET SCHEMA myschema statement. \nFor your question there are two options:\n1) Reference the tables with their full name: schemaname.tablename\n2) Use set schema to set the common schemaname and reference just the table.","Q_Score":2,"Tags":"django,python-2.7,django-models,db2","A_Id":36159818,"CreationDate":"2016-03-22T16:15:00.000","Title":"django-db2 use different schema name than database username","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a program in python that can find a specific word in a .docx file and return page number that it occurred on.  So far, in looking through the python-docx documentation I have been unable to find how do access the page number or even the footer where the number would be located.  Is there a way to do this using python-docx or even just python? Or if not, what would be the best way to do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":14423,"Q_Id":36193159,"Users Score":13,"Answer":"Short answer is no, because the page breaks are inserted by the rendering engine, not determined by the .docx file itself.\nHowever, certain clients place a <w:lastRenderedPageBreak> element in the saved XML to indicate where they broke the page last time it was rendered.\nI don't know which do this (although I expect Word itself does) and how reliable it is, but that's the direction I would recommend if you wanted to work in Python. You could potentially use python-docx to get a reference to the lxml element you want (like w:document\/w:body) and then use XPath commands or something to iterate through to a specific page, but just thinking it through a bit it's going to be some detailed development there to get that working.\nIf you work in the native Windows MS Office API you might be able to get something better since it actually runs the Word application.\nIf you're generating the documents in python-docx, those elements won't be placed because it makes no attempt to render the document (nor is it ever likely to). We're also not likely to add support for w:lastRenderedPageBreak anytime soon; I'm not even quite sure what that would look like.\nIf you search on 'lastRenderedPageBreak' and\/or 'python-docx page break' you'll see other questions\/answers here that may give a little more.","Q_Score":10,"Tags":"python,docx,python-docx","A_Id":36194547,"CreationDate":"2016-03-24T04:11:00.000","Title":"Page number python-docx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":1},{"Question":"I am using the sklearn.cluster KMeans package. Once I finish the clustering if I need to know which values were grouped together how can I do it?\nSay I had 100 data points and KMeans gave me 5 cluster. Now I want to know which data points are in cluster 5. How can I do that.\nIs there a function to give the cluster id and it will list out all the data points in that cluster?","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62619,"Q_Id":36195457,"Users Score":0,"Answer":"You can Simply store the labels in an array. Convert the array to a data frame. Then Merge the data that you used to create K means with the new data frame with clusters. \nDisplay the dataframe. Now you should see the row with corresponding cluster. If you want to list all the data with specific cluster, use something like data.loc[data['cluster_label_name'] == 2], assuming 2 your cluster for now.","Q_Score":40,"Tags":"python,scikit-learn,cluster-analysis,k-means","A_Id":50800687,"CreationDate":"2016-03-24T07:56:00.000","Title":"How to get the samples in each cluster?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am setting up a system where one user will be posting images to a Django server and N users will each be viewing a subset of the posted images in parallel. I can't seem to find a queuing mechanism in Django to accomplish this task. The closest thing is using latest with filter(), but that will just keep sending the latest image over and over again until a new one comes. The task queue doesn't help since this isn't a periodic task, it only occurs when a user asks for the next picture. I have one Viewset for uploading the images  and another for fetching. I thought about using the python thread-safe Queue. The unloader will enqueue the uploaded image pk, and when multiple users request a new image, the sending Viewset will dequeue an image pk and send it to the most recent user requesting an image and then the next one dequeued to the second most recent user and so on...\nHowever, I still feel like there are some race conditions possible here. I read that Django is thread-safe, but that the app can become un-thread-safe. In addition, the Queue would need to be global to be shared among the Viewsets, which feels like bad practice. Is there a better and safer way of going about this?\nEdit\nHere is more detail on what I'm trying to accomplish and to give it some context. The user posting the pictures is a Smart-phone attached to a Drone. It will be posting pictures from the sky at a constant interval to the Django server. Since there will be a lot of pictures coming in. I would like to be able to have multiple users splitting up the workload of looking at all the pics (i.e. no two user's should see the same picture). So when a user will contact the Django server, saying \"send me the next pic you have or send me the next 3 pics you have or etc...\". However, multiple users might say this at the same time. So Django needs to keep some sort of ordering to the pictures,that's why I said Queue and figure out how to pass it to users if more than one of them asks at a time. So one Viewset is for the smart phone to post the pics and the other is for the users to ask for the pics. I am looking for a thread-safe way to do this. The only idea I have so far is to use Python's thread-safe queue and make it a global queue to the Viewsets. However, I feel like that is bad practice, and I'm not sure if it is thread-safe with Django.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":394,"Q_Id":36202899,"Users Score":1,"Answer":"Django itself doesn't have a queue, but you can easily simulate it. Personally, I would probably use an external service, like rabbitMQ, but it can be done in pure Django if you want. Add a separate ImageQueue model to hold references to incoming images and use transaction management to make sure simultaneous requests don't return the same image. Maybe something like this (this is purely proof of concept code, of course).\n\nclass ImageQueue(models.Model):\n    image = models.OneToOne(Image)\n    added = models.DateTimeField(auto_now_add=True)\n    processed = models.DateTimeField(null=True, default=None)\n    processed_by = models.ForeignKey(User, null=True, default=None)\n\n    class Meta:\n        order_by=('added')\n\n...\n# in the incoming image API that drone uses\ndef post_an_image(request):\n    image = Image()\n    ... whatever you do to post an image ...\n    image.save()\n    queue = ImageQueue.objects.create(image=image)\n    ... whatever else you need to do ...\n\n# in the API your users will use\nfrom django.db import transaction\n\n@transaction.atomic\ndef request_images(request):\n    user = request.user\n    num = request.POST['num'] # number of images requested\n    queue_slice = ImageQueue.objects.filter(processed__isnull=True)[:num]\n    for q in queue_slice:\n        q.processed = datetime.datetime.now()\n        q.processed_by = user\n        q.save()\n    return [q.image for q in queue_slice]","Q_Score":1,"Tags":"python,django,multithreading,django-rest-framework,django-1.9","A_Id":36209892,"CreationDate":"2016-03-24T14:41:00.000","Title":"Queuing pictures to be requested in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to using python to open two files at the same time, read one line from each of them then do some operations. Then read the next line from each of then and do some operation,then the next next line...I want to know how can I do this. It seems that for loop cannot do this job.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":36212431,"Users Score":0,"Answer":"Why not read each file into a list each element in the list holds 1 line.\nOnce you have both files loaded to your lists you can work line by line (index by index) through your list doing whatever comparisons\/operations you require.","Q_Score":0,"Tags":"python","A_Id":36212457,"CreationDate":"2016-03-25T00:50:00.000","Title":"how to use python to deal with two file at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently bought a Windows 10 machine and now I want to run a server locally for testing a webpage I am developing.\nOn Windows 7 it was always very simple to start a HTTP Server via python and the command prompt. Fx writing the below code would fire up a HTTP server and I could watch the website through localhost.\n\nC:\\pathToIndexfile\\python -m SimpleHTTPServer\n\nThis does however not seems to work on Windows 10...\nDoes anyone know how to do this on Windows 10?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25052,"Q_Id":36223345,"Users Score":10,"Answer":"Ok, so different commands is apparently needed. \nThis works:\n\nC:\\pathToIndexfile\\py -m http.server\n\nAs pointed out in a comment, the change to \"http.server\" is not because of windows, but because I changed from python 2 to python 3.","Q_Score":5,"Tags":"python,windows-10,simplehttpserver","A_Id":36223473,"CreationDate":"2016-03-25T15:55:00.000","Title":"How to start python simpleHTTPServer on Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using NameCheap to host my domain, and I use their privateemail.com to host my email. I'm looking to create a python program to retrieve specific\/all emails from my inbox and to read the HTML from them (html instead of .body because there is a button that has a hyperlink which I need an is only accessible via html). I had a couple questions for everyone.\n\nWould the best way to do this be via IMAPlib? If it is, how do I find out the imap server for privateemail.com?\nI could do this via selenium, but it would be heavy and I would prefer a lighter weight and faster solution. Any ideas on other possible technologies to use?\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":411,"Q_Id":36234690,"Users Score":1,"Answer":"Well, just a little bit of testing with telnet will give you the answer to the question 'how do I find the imap server for privateemail.com'.  \nmail.privateemail.com is their IMAP server.","Q_Score":0,"Tags":"python,email","A_Id":36242008,"CreationDate":"2016-03-26T11:24:00.000","Title":"Retrieving emails from NameCheap Private Email","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have one huge data matrix X, of which subsets of rows correspond to different tasks that are related but also have different idiosyncratic properties.\nThus I want to train a Multi-Task model with some regularization and chose sklearn's linear_model MultiTaskElasticNet function. \nI am confused with the inputs of fitting the model. It says that both the X and the Y matrix are 2-dimensional. The 2nd dimension in Y corresponds to the number of tasks. That makes sense, but in my understanding the X matrix should be 3-dimensional right? In that way I have selected which subsets of my data correspond to different tasks as I know that in advance (obviously).\nDoes someone know how to enter my data correctly for this scikit-learn module?\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":511,"Q_Id":36288578,"Users Score":0,"Answer":"I don't see why you'd want X to vary for each task: the point of multitask learning is that the same feature space is used to represent instances for multiple tasks which can be mutually informative. I get that you may not have ground truth y for all instances for all tasks, though this is currently assumed in the scikit-learn implementation.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":36298305,"CreationDate":"2016-03-29T15:25:00.000","Title":"Sklearn multi-task: Input data not 3-dimensional?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Apparently it is not possible and the best advice I found so far is to use dict but this is not what I want. Is there still a way to store a set \/ list in MongoDB?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2869,"Q_Id":36288794,"Users Score":2,"Answer":"With mongo you have to pass a json (which in python we can essentially think of as a dict) in order to do anything really, so say you want to add a list or set of numbers to the hamburgers field in your collection, you would prepare it as follows:\ndb.your_collection.update({'$push': {'hamburgers': {$each: [1, 2, 3, 4]}}})\nif it's a set, you cant convert it to a list\ndb.your_collection.update({'$push': {'hamburgers': {$each: list({1, 2, 3, 4})}}})","Q_Score":1,"Tags":"python,mongodb,pymongo","A_Id":36289062,"CreationDate":"2016-03-29T15:35:00.000","Title":"MongoDB & PyMongo: how to store a set \/ list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm relatively new to Python. \nWhen I did C\/C++ programming, I used the internal classes quite often. For example, in some_file.cc, we may implement a class in the anonymous namespace to prevent it from being used outside. This is useful as a helper class specific to that file.\nThen, how we can do a similar thing in Python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":751,"Q_Id":36295569,"Users Score":1,"Answer":"Python code doesn't have any such equivalent for an anonymous namespace, or static linkage for functions. There are a few ways you can get what you're looking for\n\nPrefix with _. Names beginning with an underscore are understood\nto be for internal use to that python file and are not exported by\nfrom * imports. it's as simple as class _MyClass.\nUse __all__: If a python file contains a list a list of strings\nnamed __all__, the functions and classes named within are\nunderstood to be local to that python file and are not exported by\nfrom *.\nUse local classes\/functions. This would be done the same way you've\ndone so with C++ classes.\n\nNone these gets exactly what you want, but privacy and restricting in this way are just not part of the language (much like how there's no private data member equivalent). Pydoc is also well aware of these conventions and will provide informative documentation for the intended-to-be-public functions and classes.","Q_Score":1,"Tags":"python,class,internal","A_Id":36295771,"CreationDate":"2016-03-29T21:38:00.000","Title":"How to make a python class not exposed to the outside?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python algorithm that access a huge database in my laptop. I want to create a web server to work with it. can I use django with the folder paths I have used ? like how do I communicate with it ? I want to get an image from web application and get it sent to my laptop and run algorithm on it then send result back to the webserver. would that still be possible without me changing my algorithm paths? like I use os.path to access my database folder, would I still be able to do what with django or shall I learn something else? I wanted to try django as it runs in python and I can learn it easy.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":36297179,"Users Score":1,"Answer":"I have found out that django works fine with os.path and no problems. actually if you are programming with python then django is a great choice for server work.","Q_Score":0,"Tags":"python,django,web-applications","A_Id":36440307,"CreationDate":"2016-03-29T23:51:00.000","Title":"can i use django to access folders on my pc using same os.path for windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi i noticed that whenever you have the focus property of a textinput widget set to True,\nthe hint_text is not displayed when the textinput is actually in focus.\nPlease is there a way to combine them both, i.e the hint_text gets displayed even when the text input is in focus?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":443,"Q_Id":36314303,"Users Score":4,"Answer":"This is an issue with Kivy 1.9.1, where the hint text disappears as soon as the TextInput is focused. It has been fixed in the development branch, and now only disappears when there is content in the field.","Q_Score":4,"Tags":"python,kivy","A_Id":36314717,"CreationDate":"2016-03-30T16:14:00.000","Title":"Kivy TextInput how to combine hint_text and focus","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python (2.7) console application that I have written on Windows (8.1). I have used argparse.ArgumentParser() for handling the parameters when executing the program. \nThe application has quite a few parameters, so when the --help parameter is used the documentation greatly exceeds the size of the console window. Even with the console window maximized. Which is fine, but the issue I'm encountering is that the user is unable to scroll up to view the rest of the help documentation. I have configured my windows console properties appropriately, such as the \"Window Size\" and \"Screen Buffer Size\". And I have verified that those changes are working, but they only work outside of the Python environment. As soon as I execute a Python script or run a --help command for a script, the console properties no longer apply. The scroll bar will disappear from the window and I can no longer scroll to the top to see the previous content.\nSo basically, I need to figure out how to enable scrolling for my Python console programs. I need scrolling enabled both when executing a script and when viewing the --help documentation. I'm not sure how to go about doing that. I have been searching online for any info on the subject and I have yet to find anything even remotely helpful.\nAt this point, I am completely stuck. So if someone knows how to get scrolling to work, I would greatly appreciate your help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4402,"Q_Id":36341867,"Users Score":0,"Answer":"You can not do it from you python script (OK, it is possible, but most probably you don't want to do it). Scrolling depends on environment (Windows or Linux terminal, doesn't matter). So it is up to users to set it up in a way that is good for them.  \nOn Linux you can use less or more:\npython script.py | less\nit will buffers output from the script and will let user ability to scroll up and down without losing any information.","Q_Score":1,"Tags":"python,python-2.7,scroll,console-application,windows-console","A_Id":36342079,"CreationDate":"2016-03-31T19:18:00.000","Title":"How to Enable Scrolling for Python Console Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to develop a script that will connect to our switch and do some tasks.\nIn this script I have a main function that calls a second function. In the second function I pass a list of switches that Python will start to connect one by one.\nThe second function will call a third function. In the third function the script makes some tests. If one of these tests fail I want to close the entire script.\nThe problem is that I tried to put return, exit, raise System, os.exit but what happens is that the script doesn't stop, it just jumps to another switch and goes on.\nAnyone knows how can I close my entire script from a function?\nBest regards.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":5270,"Q_Id":36343431,"Users Score":1,"Answer":"Thanks for your reply.\nI already tried use sys.exit, raise and others into the third funcion but nothing works. What I did, I put a return with stantement pass or fail. On the secund function I test the return and if fail the script execute sys.exit(). When I do this on the secund function the script stop like we want. Now it's working fine. Probably this is the worst way to do this but worked.\nBest regards.","Q_Score":1,"Tags":"python,break","A_Id":36359087,"CreationDate":"2016-03-31T20:46:00.000","Title":"Python exit from all function and stop the execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been experimenting with IBPy for a while; however, the two following things have been eluding me:\na) How does one the name of the actual portfolios that positions belong to? I know how to find positions, their costs, values etc. (using message.UpdatePortfolio), but out trading simulation will likely have many portfolios and it helps to know which portfolio each position belongs to. Is it even possible to send information to IB in multiple portfolios?\nb) How does one find out the existing orders using IBPy? So when I run the code, I want it to display all positions, along with their order types and limits (e.g. if its a limit order for AAPL, I want to find the limit price etc.)\nMany thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":549,"Q_Id":36352167,"Users Score":0,"Answer":"a) As far as I know, IB API has no concept of 'Portfolio'. You probably need to keep a list of orders put in for which portfolio and then resolve the order data supplied by IB against your portfolio vs order data.\nb) IB does keep track of the client (i.e. your client that is calling the API code - normally defaulted to 0) that has put in the orders.  \nIf you want to know what orders are open that were input via your client then: client.reqOpenOrders();\nIf you want to know all open orders i.e. orders put in via your client plus other clients or TWS, then: client.reqAllOpenOrders();","Q_Score":0,"Tags":"python,interactive-brokers,ibpy","A_Id":37589275,"CreationDate":"2016-04-01T09:04:00.000","Title":"Getting portfolio names and existing orders using Interactive Brokers IBPy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"total noob question. I have a file that contains a number on each line, there are approximately 5 millions rows, each row has a different number, how do i find the top 5 values in the file using spark and python.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":54,"Q_Id":36363502,"Users Score":1,"Answer":"You distribute the data you read among nodes.\nEvery node finds it's 5 local maximums.\nYou combine all the local maximums and you keep the 5 max of them,\nwhich is the answer.","Q_Score":0,"Tags":"python,apache-spark","A_Id":36363565,"CreationDate":"2016-04-01T18:34:00.000","Title":"spark python product top 5 numbers from a file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Okay, I'm really new to Python and have no idea how to do this:\nI need to take a string, say 'ABAB__AB', convert it to a list, and then take the leading index of the pair I want to move and swap that pair with the __. I think the output should look something like this:\nmove_chars('ABAB__AB', 0)\n'__ABABAB'\nand another example:\nmove_chars('__ABABAB', 3)\n'BAA__BAB'\nHonestly have no idea how to do it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":7193,"Q_Id":36381523,"Users Score":0,"Answer":"I think this should go to the comment section, but I can't comment because of lack of reputation, so...\nYou'll probably want to stick with list index swapping, rather than using .pop() and .append(). .pop() can remove elements from arbitrary index, but only one at once, and .append() can only add to the end of the list. So they're quite limited, and it would complicate your code to use them in this kind of problems.\nSo, well, better stick with swapping with index.","Q_Score":0,"Tags":"python,string,list,python-3.x,swap","A_Id":36381647,"CreationDate":"2016-04-03T04:10:00.000","Title":"Swapping pairs of characters in a string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the old (non-Ajax) Google Appengine's Developer Console Dashboard - showed estimated cost for the last 'n' hours. This was useful to quickly tell how the App engine is doing vis-a-vis the daily budget.\nThis field seems to be missing in the new Appengine Developer Console. I have tried to search various tabs on the Console and looked for documentation, but without success.\nLooking for any pointers as to how do I get to this information in the new Console and any help\/pointers are highly appreciated !","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":18,"Q_Id":36386528,"Users Score":1,"Answer":"App Engine > Dashboard\nThis view shows how much you are charged so far during the current billing day, and how many hours you still have until the reset of the day. This is equivalent to what the old console was showing, except there is no \"total\" line under all charges.\nApp Engine > Quotas\nThis view shows how much of each daily quota have been used.\nApp Engine > Quotas > View Usage History\nThis view gives you a summary of costs for each of the past 90 days. Clicking on a day gives you a detailed break-down of all charges for that day.","Q_Score":0,"Tags":"google-app-engine,google-app-engine-python","A_Id":36388402,"CreationDate":"2016-04-03T14:16:00.000","Title":"Estimated Cost field is missing in Appengine's new Developer Console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone tell me, whether there is a way to find which class a member variable belongs to, using the variable.\nI am trying to create a decorator that will allow only member method and variables of certain classes be used as method parameter.\nlike\n\n@acceptmemberofclass(class1,class2)\n  def method(memberfunc, membervar):\n     #do something\n\nI have figured out how to do this with methods (using inspect.getmro(meth.im_class)) but I am unable to find a way for variables","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":36388952,"Users Score":0,"Answer":"To my knowledge, there's no \"cheap trick\" you'll have to have all your class elements and compare their variable values with what you have . (Couldn't comment, sry) At least from what I understand you're trying to achieve, the question isn't very well constructed.","Q_Score":0,"Tags":"python-2.7","A_Id":36389003,"CreationDate":"2016-04-03T17:51:00.000","Title":"Python how to find which class owns a variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm evaluating orange as a potential solution to helping new entrants into data science to get started. I would like to have them save out model objects created from different algorithms as pkl files similar to how it is done in scikit-learn with joblib or pickle.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":61,"Q_Id":36415572,"Users Score":0,"Answer":"I don't understand what \"exported with joblib\" refers to, but you can save trained Orange models by pickling them, or with Save Classifier widget if you are using the GUI.","Q_Score":0,"Tags":"python,orange","A_Id":36516264,"CreationDate":"2016-04-04T19:00:00.000","Title":"Can the model object for a learner be exported with joblib?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python 2 script that is run as root. I want to use os.system(\"some bash command\") without root privileges, how do I go about this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1614,"Q_Id":36445861,"Users Score":4,"Answer":"Try to use os.seteuid(some_user_id) before os.system(\"some bash command\").","Q_Score":2,"Tags":"python,root,python-2.x","A_Id":36445985,"CreationDate":"2016-04-06T08:42:00.000","Title":"using os.system() to run a command without root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python 2 script that is run as root. I want to use os.system(\"some bash command\") without root privileges, how do I go about this?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1614,"Q_Id":36445861,"Users Score":-1,"Answer":"I have test on my PC. If you run the python script like 'sudo test.py' and the question is resolved.","Q_Score":2,"Tags":"python,root,python-2.x","A_Id":47768790,"CreationDate":"2016-04-06T08:42:00.000","Title":"using os.system() to run a command without root","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running El Capitan, when I type python --version the terminal prints Python 2.7.10, I have successfully downloaded pygame for Python 2.7.10 but I want to develop in python 3.5.1, I know I can do this by entering python3 in the terminal, but how do I properly set up pygame for this version of python?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":36456584,"Users Score":1,"Answer":"Use python3.5 -mpip install pygame.","Q_Score":0,"Tags":"python,pygame","A_Id":36456629,"CreationDate":"2016-04-06T16:10:00.000","Title":"How to download pygame for non default version of python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a test file with tests in it which will not be called with the regular \nmanage.py test\ncommand, only when I specifically tell django to do so. \nSo my file lives in the same folder as tests.py and its name is test_blub.py\nI tried it with \nmanage.py test --pattern=\"test_*.py\"\nAny idea?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":528,"Q_Id":36462875,"Users Score":0,"Answer":"Ok, so the key is quite simple, the file is not supposed to start with test. \nI named it blub_test.py and then called it with \n.\/manage.py test --pattern=\"blub_test.py\"","Q_Score":0,"Tags":"python,django,testing,automated-tests","A_Id":36485158,"CreationDate":"2016-04-06T21:41:00.000","Title":"how to use --patterns for tests in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can somebody let me know how to install python \"parse\" module for python2.7 version?\nServer details :\nCloudLinux Server release 5.11\ncPanel 54.0 (build 21)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3954,"Q_Id":36473334,"Users Score":1,"Answer":"If you have pip installed, try to run pip install parse as root.","Q_Score":0,"Tags":"python,python-2.7","A_Id":36473657,"CreationDate":"2016-04-07T10:23:00.000","Title":"Parse python module installtion for python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to experiment with Beaker Notebooks, but I can not figure out how to launch from a specified directory. I've downloaded the .zip file (I'm on Windows 10), and can launch from that directory using the beaker.command batch file, but cannot figure out where to configure or set a separate launch directory for a specific notebook. With Jupyter notebooks, launching from the saved .ipynb file serves from that directory, but I cannot figure out how to do the same for Beaker notebooks.\nDoes anyone know the correct method to serve a Beaker Notebook from various parent directories?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":178,"Q_Id":36485392,"Users Score":0,"Answer":"If you want to change the current working directory, I don't think that's possible.\nBut if you want to serve files as in make them available to the web server that creates the page, use ~\/.beaker\/v1\/web as described in the \"Generating and accessing web content\" tutorial.","Q_Score":2,"Tags":"ipython,beaker-notebook","A_Id":37124128,"CreationDate":"2016-04-07T19:25:00.000","Title":"How to serve Beaker Notebook from different directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am starting to make a python program to get user locations, I've never worked with the twitter API and I've looked at the documentation but I don't understand much. I'm using tweepy, can anyone tell me how I can do this? I've got the basics down, I found a project on github on how to download a user's tweets and I understand most of it.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":13479,"Q_Id":36490085,"Users Score":2,"Answer":"Once you have a tweet, the tweet includes a user, which belongs to the user model. To call the location just do the following\n\ntweet.user.location","Q_Score":5,"Tags":"python,python-2.7,twitter,tweepy","A_Id":42499529,"CreationDate":"2016-04-08T01:40:00.000","Title":"How to get twitter user's location with tweepy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Pygal (with Python \/ Flask) relatively successfully in regards to loading data, formatting colors, min\/max, etc., but can't figure out how to format a number in Pygal using dollar signs and commas.  \nI'm getting 265763.557372895 and instead want $265,763.\nThis goes for both the pop-up boxes when hovering over a data point, as well as the y-axes.  \nI've looked through pygal.org's documentation to no avail.  Does anyone know how to properly format those numbers?\nUPDATE:\nI'm not quite ready to mark this question \"answered\" as I still can't get the separating commas.  However, I did find the following native formatting option in pygal.  This eliminates trailing decimals (without using Python's int()) and adds a dollar sign:\ngraph.value_formatter = lambda y: \"$%.0f\" % y\nChange the 0f to 2f if you prefer two decimals, etc.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":784,"Q_Id":36552029,"Users Score":3,"Answer":"graph.value_formatter = lambda y: \"{:,}\".format(y) will get you the commas.\ngraph.value_formatter = lambda y: \"${:,}\".format(y) will get you the commas and the dollar sign.\nNote that this formatting seems to be valid for Python 2.7 but would not work on 2.6.","Q_Score":2,"Tags":"python,flask,formatting,pygal","A_Id":36914709,"CreationDate":"2016-04-11T14:48:00.000","Title":"Properly formatting numbers in pygal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a script that uses paramiko to ssh onto several remote hosts and run a few checks. Some hosts are setup as fail-overs for others and I can't determine which is in use until I try to connect. Upon connecting to one of these 'inactive' hosts the host will inform me that you need to connect to another 'active' IP and then close the connection after n seconds. This appears to be written to the stdout of the SSH connection\/session (i.e. it is not an SSH banner). \nI've used paramiko quite a bit, but I'm at a loss as to how to get this output from the connection, exec_command will obviously give me stdout and stderr, but the host is outputting this immediately upon connection, and it doesn't accept any other incoming requests\/messages. It just closes after n seconds. \nI don't want to have to wait until the timeout to move onto the next host and I'd also like to verify that that's the reason for not being able to connect and run the checks, otherwise my script works as intended.\nAny suggestions as to how I can capture this output, with or without paramiko, is greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":36576158,"Users Score":0,"Answer":"I figured out a way to get the data, it was pretty straight forward to be honest, albeit a little hackish. This might not work in other cases, especially if there is latency, but I could also be misunderstanding what's happening:\nWhen the connection opens, the server spits out two messages, one saying it can't chdir to a particular directory, then a few milliseconds later it spits out another message stating that you need to connect to the other IP. If I send a command immediately after connecting (doesn't matter what command), exec_command will interpret this second message as the response. So for now I have a solution to my problem as I can check this string for a known message and change the flow of execution.\nHowever, if what I describe is accurate, then this may not work in situations where there is too much latency and the 'test' command isn't sent before the server response has been received.\nAs far as I can tell (and I may be very wrong), there is currently no proper way to get the stdout stream immediately after opening the connection with paramiko. If someone knows a way, please let me know.","Q_Score":1,"Tags":"python,ssh,paramiko","A_Id":36601638,"CreationDate":"2016-04-12T14:23:00.000","Title":"Paramiko get stdout from connection object (not exec_command)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The parent process launches a few tens of threads that receive data (up to few KB, 10 requests per second), which has to be collected in a list in the parent process. What is the recommended way to achieve this, which is efficient, asynchronous, non-blocking, and simpler to implement with least overhead?\nThe ZeroMQ guide recommends using a PAIR socket archetype for coordinating threads, but how to scale that with a few hundred threads?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":214,"Q_Id":36593464,"Users Score":1,"Answer":"There is no dinner for free\neven if some marketing blable offers that, do not take it for granted.\nEfficient means usually a complex resources handling.\nSimplest to implement usually fights with overheads & efficient resources handling.\n\nSimplest?\nUsing sir Henry FORD's point of view, a component, that is not present in one's design simply cannot fail.\nIn this very sense, we strive here not to programmatically control anything beyond the simplest possible use of elementary components of an otherwise smart ZeroMQ library:\nScenario SIMPLEST:\n\nRule a)\n\nThe central HQ-unit ( be it just a thread or a fully isolated process ) .bind()-s it's receiving port ( pre-set as a ZMQ_SUBSCRIBE behaviour-archetype ) and \"subscribes\" it's topic-filter to \"everything\" .setsockopt( ZMQ_SUBSCRIBE, \"\" ) before it spawns the first DAQ-{ thread | process }, further ref'd as DAQ-unit.\n\nRule b)\n\nEach DAQ-unit simply .connect()-s to an already setup & ready port on the HQ-unit with a unit-local socket access-port, pre-set as a ZMQ_PUBLISH behaviour-archetype.\n\nRule c)\n\nAny DAQ-unit simply .send( ..., ZMQ_NOBLOCK )-s as needed it's local-data via a message, which is being delivered in the background by the ZeroMQ-layer to the hands of the HQ-unit, being there queued & available for a further processing at the HQ-unit's will.\n\nRule d)\n\nThe HQ-unit regularly loops and .poll( 1 )-s for a presence of a collected message from any DAQ-unit + .recv( ZMQ_NOBLOCK ) in case any such was present.\nThat's all\nAsynchronous: yes.\nNon-blocking: yes.\nSimplest: yes.\nScaleable: yes. Almost linearly, until I\/O-bound  ( still some tweaking possible to handle stressed-I\/O-operations )  as a bonus-point...","Q_Score":1,"Tags":"python,multithreading,zeromq,pyzmq","A_Id":36602302,"CreationDate":"2016-04-13T09:02:00.000","Title":"How to collect data from multiple threads in the parent process with ZeroMQ while keeping the solution both as simple & as scaleable as possible?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to add a simple password check to a Python\/wxPython\/MySQL application to confirm that the user wants to carry out a particular action. So far I have a DialogBox with a textCtrl for password input and Buttons for Submit or Cancel. At the moment the password appears in the textCtrl. I would prefer this to appear as asterisks whilst the user input is captured but cannot figure out how to do this. How could I implement this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":493,"Q_Id":36643784,"Users Score":2,"Answer":"Set the style on the text ctrl as\nTE_PASSWORD: The text will be echoed as asterisks.","Q_Score":0,"Tags":"python-2.7,wxpython","A_Id":36649037,"CreationDate":"2016-04-15T09:49:00.000","Title":"Creating Simple Password Check In wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to deploy a django app on hostgator shared hosting. I followed the hostgator django installation wiki and i deployed my app. The issue is that i am getting a 500 error internal page when entering the site url in the browser. I contacted the support team but could not provide enough info on troubleshooting the error Premature end of script headers: fcgi.This was the error found on the server error log.\nI am installed django 1.9.5 on the server and from the django documentation it does not support fastcgi. \nSo my question 500 error be caused by the reason that i am running django 1.9.5 on the server and it does not support fastcgi. if so do i need to install lower version of django to support the fastcgi supported by hostgator shared hosting\nFirst i thought the error was caused by my .htaccess file but it has no issue from the what i heard from support team.\nAny Leads to how i can get the app up and running will be appreciated. This is my first time with django app deployment. Thank you in advance","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":6154,"Q_Id":36645076,"Users Score":3,"Answer":"I know this is a while as to when i asked the question. I finally fixed this by changing the hosts. I went for Digital Oceans (created a new droplet) which supports wsgi. I deployed the app using gunicorn (application server) and nginx (proxy server).\nIt is not a good idea to deploy a Django app on shared hosting as you will be limited especially installing the required packages.","Q_Score":5,"Tags":"python,django","A_Id":52244829,"CreationDate":"2016-04-15T10:46:00.000","Title":"Django app deployment on shared hosting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to deploy a django app on hostgator shared hosting. I followed the hostgator django installation wiki and i deployed my app. The issue is that i am getting a 500 error internal page when entering the site url in the browser. I contacted the support team but could not provide enough info on troubleshooting the error Premature end of script headers: fcgi.This was the error found on the server error log.\nI am installed django 1.9.5 on the server and from the django documentation it does not support fastcgi. \nSo my question 500 error be caused by the reason that i am running django 1.9.5 on the server and it does not support fastcgi. if so do i need to install lower version of django to support the fastcgi supported by hostgator shared hosting\nFirst i thought the error was caused by my .htaccess file but it has no issue from the what i heard from support team.\nAny Leads to how i can get the app up and running will be appreciated. This is my first time with django app deployment. Thank you in advance","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":6154,"Q_Id":36645076,"Users Score":0,"Answer":"As you say, Django 1.9 does not support FastCGI.\nYou could try using Django 1.8, which is a long term support release and does still support FastCGI.\nOr you could switch to a different host that supports deploying Django 1.9 with wsgi.","Q_Score":5,"Tags":"python,django","A_Id":36646426,"CreationDate":"2016-04-15T10:46:00.000","Title":"Django app deployment on shared hosting","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App.\nI don't know how to proceed to link the WebJob to the web app.\nAny ideas ?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":36669500,"Users Score":0,"Answer":"You would need to provide some more information about what kind of interface your web app exposes. Does it only handle normal HTTP1 requests or does it have a web socket or HTTP2 type interface? If it has only HTTP1 requests that it can handle then you just need to make multiple requests or try and do long polling. Otherwise you need to connect with a web socket and stream the data over a normal socket connection.","Q_Score":0,"Tags":"python,azure,web-applications,azure-webjobs","A_Id":36669596,"CreationDate":"2016-04-16T20:42:00.000","Title":"Streaming values in a python script to a wep app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App.\nI don't know how to proceed to link the WebJob to the web app.\nAny ideas ?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":36669500,"Users Score":1,"Answer":"You have two main options:\nYou can have the WebJobs write the values to a database or to Azure Storage (e.g. a queue), and have the Web App read them from there.\nOr if the WebJob and App are in the same Web App, you can use the file system. e.g. have the WebJob write things into %home%\\data\\SomeFolderYouChoose, and have the Web App read from the same place.","Q_Score":0,"Tags":"python,azure,web-applications,azure-webjobs","A_Id":36671291,"CreationDate":"2016-04-16T20:42:00.000","Title":"Streaming values in a python script to a wep app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing some work in document classification with scikit-learn. For this purpose, I represent my documents in a tf-idf matrix and feed a Random Forest classifier with this information, works perfectly well. I was just wondering which similarity measure is used by the classifier (cosine, euclidean, etc.) and how I can change it. Haven't found any parameters or informatin in the documentation.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":350,"Q_Id":36687929,"Users Score":0,"Answer":"As with most supervised learning algorithms, Random Forest Classifiers do not use a similarity measure, they work directly on the feature supplied to them. So decision trees are built based on the terms in your tf-idf vectors.\nIf you want to use similarity then you will have to compute a similarity matrix for your documents and use this as your features.","Q_Score":1,"Tags":"python-2.7,scikit-learn,text-classification","A_Id":36693072,"CreationDate":"2016-04-18T07:35:00.000","Title":"similarity measure scikit-learn document classification","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to connect a burlap java server with a python client but I can't find any detail whatsoever regarding how to use burlap with python or if it even is implemented for python. Any ideas? Can I build burlap python clients? Any resources? Would using a hessian python client work with a java burlap server?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":205,"Q_Id":36694973,"Users Score":0,"Answer":"Burlap and Hessian are 2 different (but related) RPC protocols, with Burlap being XML based and Hessian being binary.\nThey're both also pretty ancient, so if you have an opportunity to use something else, I'd highly recommend it. If not, then you're going to have to find a Burlap lib for Python.\nSince it seems that a Burlap lib for Python simply doesn't exist (at least anymore), your best choice is probably to make a small Java proxy that communicates with a more recent protocol with the Python side and in Burlap with the Java server.","Q_Score":0,"Tags":"java,python,server,client,hessian","A_Id":36695144,"CreationDate":"2016-04-18T13:10:00.000","Title":"Burlap java server to work with python client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a lambdas function that resizes and image, stores it back into S3. However I want to pass this image to my API to be returned to the client. \nIs there a way to return a png image to the API gateway, and if so how can this be done?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":835,"Q_Id":36717654,"Users Score":0,"Answer":"You could return it base64-encoded...","Q_Score":0,"Tags":"python,aws-lambda,aws-api-gateway","A_Id":36757815,"CreationDate":"2016-04-19T11:56:00.000","Title":"Passing an image from Lambda to API Gateway","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a lambdas function that resizes and image, stores it back into S3. However I want to pass this image to my API to be returned to the client. \nIs there a way to return a png image to the API gateway, and if so how can this be done?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":835,"Q_Id":36717654,"Users Score":0,"Answer":"API Gateway does not currently support passing through binary data either as part of a request nor as part of a response.  This feature request is on our backlog and is prioritized fairly high.","Q_Score":0,"Tags":"python,aws-lambda,aws-api-gateway","A_Id":36727013,"CreationDate":"2016-04-19T11:56:00.000","Title":"Passing an image from Lambda to API Gateway","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed theano but when I try to use it I got this error:\n\nWARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute \n   optimized C-implementations (for both CPU and GPU) and will default to Python \n   implementations. Performance will be severely degraded.\n\nI installed g++, and put the correct path in the environment variables, so it is like theano does not detect it.\nDoes anyone know how to solve the problem or which may be the cause?","AnswerCount":6,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":31119,"Q_Id":36722975,"Users Score":3,"Answer":"This is the error that I experienced in my mac running jupyter notebook with a python 3.5 kernal hope this helps someone, i am sure rggir is well sorted at this stage :) \nError\nUsing Theano backend.\nWARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.\nCause\nupdate of XCode (g++ compiler) without accepting terms and conditions, this was pointed out above thanks Emiel\nResolution:\n\ntype g++ --version in the mac terminal\n\"Agreeing to the Xcode\/iOS license requires admin privileges, please re-run as root via sudo.\" is output as an error\nlaunch Xcode and accept terms and conditions\nreturn g++ --version in the terminal\nSomething similar to the following will be returned to show that Xcode has been fully installed and g++ is now available to keras\n\n\nConfigured with: --prefix=\/Applications\/Xcode.app\/Contents\/Developer\/usr --with-gxx-include-dir=\/usr\/include\/c++\/4.2.1\nApple LLVM version 8.0.0 (clang-800.0.42.1)\nTarget: x86_64-apple-darwin15.6.0\nThread model: posix\nInstalledDir: \/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\n\nRestart you machine\u2026 I am sure there are some more complicated steps that someone smarter than me can add here to make this faster\nRun the model.fit function of the keras application which should run faster now \u2026 win!","Q_Score":18,"Tags":"python,g++,theano","A_Id":40705647,"CreationDate":"2016-04-19T15:31:00.000","Title":"theano g++ not detected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I installed theano but when I try to use it I got this error:\n\nWARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute \n   optimized C-implementations (for both CPU and GPU) and will default to Python \n   implementations. Performance will be severely degraded.\n\nI installed g++, and put the correct path in the environment variables, so it is like theano does not detect it.\nDoes anyone know how to solve the problem or which may be the cause?","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":31119,"Q_Id":36722975,"Users Score":7,"Answer":"I had this occur on OS X after I updated XCode (through the App Store). Everything worked before the update, but after the update I had to start XCode and accept the license agreement. Then everything worked again.","Q_Score":18,"Tags":"python,g++,theano","A_Id":39568992,"CreationDate":"2016-04-19T15:31:00.000","Title":"theano g++ not detected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I installed theano but when I try to use it I got this error:\n\nWARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute \n   optimized C-implementations (for both CPU and GPU) and will default to Python \n   implementations. Performance will be severely degraded.\n\nI installed g++, and put the correct path in the environment variables, so it is like theano does not detect it.\nDoes anyone know how to solve the problem or which may be the cause?","AnswerCount":6,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":31119,"Q_Id":36722975,"Users Score":6,"Answer":"On Windows, you need to install mingw to support g++. Usually, it is advisable to use Anaconda distribution to install Python. Theano works with Python3.4 or older versions. You can use conda install command to install mingw.","Q_Score":18,"Tags":"python,g++,theano","A_Id":37846308,"CreationDate":"2016-04-19T15:31:00.000","Title":"theano g++ not detected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was using Tensorflow sequence to sequence example code. for some reason, I don't want to add softmax to output. instead, I want to get the raw output of decoder without softmax. I was wondering if anyone know how to do it based on sequence to sequence example code? Or I need to create it from scratch or modify the the seq2seq.py (under the \/tensorflow\/tensorflow\/python\/ops\/seq2seq.py)?\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":389,"Q_Id":36759037,"Users Score":1,"Answer":"The model_with_buckets() function in seq2seq.py returns 2 tensors: the output and the losses. The outputs variable contains the raw output of the decoder that you're looking for (that would normally be fed to the softmax).","Q_Score":0,"Tags":"python,tensorflow","A_Id":36870610,"CreationDate":"2016-04-21T03:24:00.000","Title":"tensorflow sequence to sequence without softmax","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a ~220 million row, 7 column csv file. I need to remove row 2636759.\nThis file is 7.7GB, more than will fit in memory. I'm most familiar with R, but could also do this in python or bash.\nI can't read or write this file in one operation. What is the best way to build this file incrementally on disk, instead of trying to do this all in memory?\nI've tried to find this on SO but have only been able to find how to do this with files that are small enough to read\/write in memory, or with rows that are at the beginning of the file.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1468,"Q_Id":36779522,"Users Score":2,"Answer":"use sed '2636759d' file.csv > fixedfile.csv\nAs a test for a 40,001 line 1.3G csv, removing line 40,000 this way takes 0m35.710s. The guts of the python solution from @en_Knight (just stripping the line and writing to a temp file) is ~ 2 seconds faster for this same file.\nedit OK sed (or some implementations) may not work (based on feedback from questioner)\nYou could, in plain bash, to remove row n from a file of N rows, file.csv, you can do head -[n-1] file.csv > file_fixed.csv and tail -[N-n] file.csv >> file_fixed.csv (in both of these the expression in brackets is replaced by a plain number). \nTo do this, though you need to know N. The python solution is better...","Q_Score":6,"Tags":"python,r,csv","A_Id":36780531,"CreationDate":"2016-04-21T20:12:00.000","Title":"remove known exact row in huge csv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am trying to run a python program\n\nimport random\n  random.random()\n\nWritten in notepad in two different lines,I want to run it in cmd.how to do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":36824269,"Users Score":1,"Answer":"Save the program with a .py extention. For example: hello.py\nThen run it with python <script_name>.py. For example: python hello.py","Q_Score":0,"Tags":"python,python-3.x,cmd,python-import","A_Id":36824295,"CreationDate":"2016-04-24T14:17:00.000","Title":"Running python from notepad in cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I know I can make Python executable using pyinstaller.\nHowever, every time it raises an error, it will instantly end the program, so I can't find what is the error.\nI know I probably can use time.sleep(30000) to stop it.\nBut if the code raises error before it meets time.sleep(30000), it will just shut down.\nTo sum up, how to make it keep not shutting down, so I can see where is the mistake?","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5599,"Q_Id":36831877,"Users Score":0,"Answer":"Instead of just double-clicking the file, run it from the command line. A terminal window that your program automatically created will also be automatically closed when the program ends, but if you open a terminal yourself and run the program from the command line, it won't touch the open terminal and you can read the error.","Q_Score":3,"Tags":"python","A_Id":36831904,"CreationDate":"2016-04-25T04:08:00.000","Title":"How to make Python executable pause when it raises an error?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"please I am working on a site where I would scrap another website's html table source code and append it to my template before rendering my page. \nI have written the script which stores the html code in a variable but don't know how to appendix it.\nKindly suggest.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":36836101,"Users Score":0,"Answer":"If you're using jinja, try this:\n<div class=\"html-content\">{{scraped_html|safe}}<\/div>","Q_Score":0,"Tags":"python-2.7,web-applications,pyramid","A_Id":36873321,"CreationDate":"2016-04-25T09:04:00.000","Title":"How to modify a pyramid template on the fly before rendering","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that for fft.fft, I can use fft.fftfreq. But there seems to be no such thing as fft.fftfreq2. Can I somehow use fft.fftfreq to calculate the frequencies in 2 dimensions, possibly with meshgrid? Or is there some other way?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":343,"Q_Id":36859840,"Users Score":0,"Answer":"Yes. Apply fftfreq to each spatial vector (x and y) separately. Then create a meshgrid from those frequency vectors. \nNote that you need to use fftshift if you want the typical representation (zero frequencies in center of spatial spectrum) to both the output and your new spatial frequencies (before using meshgrid).","Q_Score":0,"Tags":"python,numpy,fft","A_Id":36976133,"CreationDate":"2016-04-26T08:49:00.000","Title":"How to extract the frequencies associated with fft2 values in numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Scenario : \nI have an OTP generation API. As of now , if I do POST with contact number in body, it will be generating OTP code irrespective of how many times, it gets invoked by same ip. There is no security at code level and nginx level. \nSuggestions are accepted whether blocking IP should be done at code level or Nginx. I want to restrict  access to api 5 times in a day from same IP .","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":219,"Q_Id":36861358,"Users Score":0,"Answer":"You really should move away from using the IP as the restriction. Not only can the IP be changed allowing for an intermediary to replay the OTP.\nA combination of the visiting IP along with additional unique vectors would serve as a better method of identifying the visitor and associating the OTP with their access.\nBecause of this the throttling you wish to implement would be better served at the code or application level vs. your web server. You should also be doing that anyways in order to better protect the OTP and the best practices associated with them; expiring, only using them once etc. etc.","Q_Score":2,"Tags":"python,node.js,django,nginx","A_Id":36862095,"CreationDate":"2016-04-26T09:51:00.000","Title":"Securing OTP API at code level or Nginx level?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am attempting to use Graphviz from Spyder (via an Anaconda install). I am having trouble understanding what is needed to do this and how to go about loading packages, setting variables, etc.\nI straight forward approach for a new Python and Graphviz and Spyder user would be great!\nAlso, apart from just creating and running Graphviz, how can one run Graphviz from python with a pre-generated .gv file?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":36755,"Q_Id":36869258,"Users Score":3,"Answer":"Open Anaconda Prompt\nRun-> \"conda install python-graphviz\" in anaconda prompt.\nAfter install graphviz then copy the directory:\nC:\\Users\\Admin\\anaconda3\\Library\\bin\\graphviz\nOpen Control Panel\\System\\Advanced system settings\nEnviornment variables\\path\\Edit\\New\nPaste that copied directory and then click Ok","Q_Score":9,"Tags":"python-3.x,anaconda,graphviz,spyder","A_Id":64227029,"CreationDate":"2016-04-26T15:23:00.000","Title":"How to use Graphviz with Anaconda\/Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create a big array in python from Sqlite database. It's size is 1000_000_000*1000_000_000 and each item is one or zero. Actually, my computer can't store in RAM this volume of information. Maybe someone have idea how to work in this situation?  Maybe store these vectors in database or there is some framework for similar needs? If i am able to do this, then i need to build clusters, that problem frighten me not less, with this information size.\nThanks in advance\/","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":36883631,"Users Score":0,"Answer":"I also work with really big datasets (complete genomes or all possible gene combinations) and i store these in a zipped database with pickle. this way it is ram efficient and uses a lot less hard disk memory.\nI suggest you try that.","Q_Score":1,"Tags":"python,arrays,cluster-computing","A_Id":36883848,"CreationDate":"2016-04-27T07:53:00.000","Title":"How do you work with big array in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Two items may be unequal in many ways. Can python tell what is the reason?\nFor example: 5 is not 6, int(5) is not float(5), \"5\" is not \"5 \", ...\n\nEdit: I did not ask what kinds of equality test there are, but why and how those are not equal. I think my question is not duplicate.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":99,"Q_Id":36884019,"Users Score":0,"Answer":"is checks if the two items are the exact same object. This check identity\n== checks if the two objects are equal values\nYou use is not None to make sure that the object the \"real\" none and not just false-y.","Q_Score":0,"Tags":"python,equality","A_Id":36884102,"CreationDate":"2016-04-27T08:12:00.000","Title":"If \"a is not b\" how to know what is the difference?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In machine learning task. We should get a group of random w.r.t normal distribution with bound. We can get a normal distribution number with np.random.normal() but it does't offer any bound parameter. I want to know how to do that?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43386,"Q_Id":36894191,"Users Score":0,"Answer":"You can subdivide your targeted range (by convention) to equal partitions and then calculate the integration of each and all area, then call uniform method on each partition according to the surface.\nIt's implemented in python:\nquad_vec(eval('scipy.stats.norm.pdf'), 1, 4,points=[0.5,2.5,3,4],full_output=True)","Q_Score":44,"Tags":"python,numpy,random,machine-learning,normal-distribution","A_Id":60298484,"CreationDate":"2016-04-27T15:24:00.000","Title":"How to get a normal distribution within a range in numpy?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am 'kind of' new to programming and must have searched a large chunk of the web in connection with this question. I am sure the answer is somewhere out there but I am probably simply not using the right terminology to find it. Nevertheless, I did my best and I am totally stuck. I hope people here understand the feeling and won't mind helping. \nI am currently working on a data driven web app that I am building together with an outsourced developer while also learning more about programming. I've got some rusty knowledge of it but I've been working in business-oriented non-technical roles for a few years now and the technical knowledge gathered some dust. \nThe said web app uses MySql database to store information. In this MySql database there is currently a table containing 200,000 variables (Company Names). I want to run those Company Names through a third-party json RESTful API to return some additional data regarding those Companies.\nThere are 2 questions here and I don't expect straight answers. Pointing me in the right learning direction would be sufficient:\n1. How would I go about taking those 200,000 variables and executing a script that would automatically make 200,000 calls to the API to obtain the data I am after. How do I then save this data to a json or csv file to import to MySql? I know how to make single API requests, using curl but making automated large volume requests like that is a mystery to me. I don't know whether I should create a json file out of it or somehow queue the requests, I am lost.\n2. The API mentioned above is limited to 600 calls per 5 minutes perios, how do I introduce some sort of control system so that when the maximum volume of API calls is reached the script pauses and only returns to working when the specified amount of time goes by? What language is best to interact with the json RESTful API and to write the script described in question no1?\nThank you for your help.\nKam","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":392,"Q_Id":36901709,"Users Score":0,"Answer":"You don't mention what server side language you're using, but the concepts would be the same for all - make your query to get your 200K variables, loop through the result set, making the curl call to the API for each, store the results in an array, json encode the array at the end of the loop, and then dump the result to a file. As for the limit to requests per time period, most languages have some sort of pause function, in PHP it's sleep(). If all else fails, you could put a loop that does nothing (except take time) into each call to put a delay in the process.","Q_Score":0,"Tags":"jquery,python,mysql,api,scripting","A_Id":36901878,"CreationDate":"2016-04-27T22:01:00.000","Title":"Most effective way to run execute API calls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know writing print \"website url\" does not provide a clickable url. So is it possible to get a clickable URL in python, which would take you directly to that website? And if so, how can it be done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":36905809,"Users Score":0,"Answer":"This is typically a function of the terminal that you're using.\nIn iterm2, you can click links by pressing cmd+alt+left click.\nIn gnome-terminal, you can click links by pressting ctrl+left click or right clicking and open link.","Q_Score":0,"Tags":"python,python-2.7,url","A_Id":36947097,"CreationDate":"2016-04-28T05:16:00.000","Title":"Clickable website URL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I do not see too how I could set this:\nI must code a small IA for asymmetric board game for 2 players. Each turn each player has a number of action points to use to move their pieces on the board (10x10).\nFor now I know how to generate the list of possible moves for each pawn based on the number of given action point but I block to the next step, selecting the best move. How could I code the fact that for example 5 action points it is best to move one pawn 3 cells and another 2 cells that move one pawn 5 cells. Do I have to use a particular algorithm or apply a programming concept ...? Well, I'm lost.\nHope you can help me :)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":839,"Q_Id":36911785,"Users Score":0,"Answer":"You need to assign score (evaluation) to each move based on the rules of the game. When you choose appropriate scoring method you can evaluate which out of 5 possible actions is the best one.\nAs an example let's assume simple game where you must take all opponents pawns by placing your pawn on top of theirs (checkers with simplified\/relaxed rules). When you move pawn to the next free cell without exposing your pawn to the danger you can assign score +1 and when you take opponent's pawn +3. If opponent takes your pawn in next move you subtract your score -3. You can define other scoring rules. When you apply scoring to all possible moves you can then select best move either using MinMax algorithm for 2 players game or some greedy search algorithm which just maximizes the score selecting action which yields highest score on next move without predicting opponent's move.","Q_Score":0,"Tags":"python,artificial-intelligence","A_Id":37138718,"CreationDate":"2016-04-28T10:21:00.000","Title":"define the best possible move (AI - game)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a project that uses Python OpenCV. My image processing is a bit slow, so I thought I can made the code faster by creating a .pyd file (I read that somewhere).\nI am able to create a .c file using Cython, but how to make a .pyd? While they are a kind of .dll, should I make a .dll first and convert it? And I think they're not platform-independent, what are equivalents on Unix?\nThanks for any help!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28584,"Q_Id":36921961,"Users Score":0,"Answer":"If you try to find your answer using cython with Visual Studio to convert python code into pyd( Python Dynamic Module ) then, you will have a blurry answer. As, visual code that you expect to work might not due to compatibility issue with later versions. For instance, 1900, 1929 of msvc.\nYou will need to edit cygwin-compiler in disutils to get things done. If you want to use MingW then also you need to include the configuration of compiler used in disutils.\nA very simple way is that we can use Nuitka, it is very simplifed and reliable to convert python code into C and Python Dynamic Library. No configuration, no support addition required.\n\nLet's grab basics\n\n1). Install nuitka, pip install nuitka\n2). Install MingW, from Sourceforge\n3). Add mingW to path\nAnd everything is good to go now.\n4).Open cmd as admin, type python -m nuitka --module file.py\nNuitka will create file.c, file.pyi(For imports) and file.cp39_architecture.pyd in current directory. From file.pyd you can import the module directly into your main.py and it will be lightning fast.\nBut, it you want to create standalone application then try,\npython -m nuitkafile.py","Q_Score":10,"Tags":"python,performance,opencv,compilation,cython","A_Id":68894961,"CreationDate":"2016-04-28T17:46:00.000","Title":"How to create a .pyd file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"(I am new to Python and programming) I am using raw_input() so I can make a program that talks to the user. For example:\nProgram: How are you?\nUser: I am doing great!\/I feel terrible.\nI need my program to respond accordingly, as in \"YAY!\" or \"Aw man... I hope you feel better soon.\" so can you please give me ways to scan for words such as \"good\" or \"bad\" in the user's raw input so my program knows how to respond? \nI know a few ways to do this, but the problem is, I want multiple words for it to look for, like great, amazing, and awesome can all be classified into the \"good\" group. AND, I need it where it doesn't have to be exact. I keep on running into problems where the user has to exactly type, \"I am good.\" instead of all the different variations that they could possibly say it. THANK YOU IN ADVANCE!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":36924296,"Users Score":0,"Answer":"Well I'm not sure of having a program understand the english language. It will only take a string literal as a string literal. \"Good\" does not mean Good or Bad to the Interpreter in Python. \nWhat I'd suggest is making a dictionary of all of the good phrases you want, such as I'm good, Feelin' great, I'm A OK. You can store all of these good feeling string literals to your \"Good Feels\" dictionary and vice versa for your Bad feels string literals. \nI'm not too sure how you'd work around spelling with <100% accuracy and the interpreter still picking it up \nI'm a bit inexperienced myself, but I'd say a predefined dictionary is your best bet, maybe throw in an else statement that prompts the user to spell correctly if he can't get one of the saying right.","Q_Score":0,"Tags":"python,raw-input","A_Id":36924497,"CreationDate":"2016-04-28T19:54:00.000","Title":"Python: If Raw_Input Contains...BLAH","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to implement a fairly standard entity-attribute-value hierarchy. There are devices of multiple types, each type has a bunch of settings it can have, each individual device has a set of particular values for each setting. It seems that both django-eav and eav-django packages are no longer maintained, so I guess I need to roll my own. But how do I architect this? So far, I am thinking something like this (skipping a lot of detail)\n\nclass DeviceType(Model):\n    name = CharField()\n\nclass Device(Model):\n    name = CharField()\n    type = ForeignKey(DeviceType)\n\nclass Setting(Model):\n    name = CharField()\n    type = CharField(choices=(('Number', 'int'), ('String', 'str'), ('Boolean', 'bool')))\n    device_type = ForeignKey(DeviceType)\n\nclass Value(Model):\n    device = ForeignKey(Device)\n    setting = ForeignKey(Setting)\n    value = CharField()\n\n    def __setattr__(self, name, value):\n        if name == 'value':\n            ... do validation based on the setting type ...\n\n    def __getattr__(self, name):\n        if name == 'value':\n            ... convert string to whatever is the correct value for the type ...\n\nAm I missing something? Is there a better way of doing this? Will this work?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2167,"Q_Id":36941823,"Users Score":-1,"Answer":"I am trying to answer,let me know, wheather we are on a same plane. I think, you need to formulate EAV database scema first. For that identify what are the entities,attributes, and the associated values. Here, in the example mentioned by you, entity maybe device and it's attribute maybe setting. If we take other example, say in case of car sales, entity is sales recipt, attribute is product purchased by the customer(car), and values are price, car model, car colour etc.\nMake master tables and tables that stores mappings if any.\nThis schema implementation in models.py will make your models, and insert values in those models through shell, or insert script.","Q_Score":6,"Tags":"python,django,entity-attribute-value","A_Id":40278064,"CreationDate":"2016-04-29T15:08:00.000","Title":"How to implement EAV in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"TL;DR\nI would like to be able to check if a git repo (located on a shared network) was updated without using a git command. I was thinking checking one of the files located in the .git folder to do so, but I can't find the best file to check. Anyone have a suggestion on how to achieve this?\nWhy:\nThe reason why I need to do this is because I have many git repos located on a shared drive. From a python application I built, I synchronize the content of some of these git repo on a local drive on a lot of workstation and render nodes.\nI don't want to use git because the git server is not powerful enough to support the amount of requests of all the computers in the studio would need to perform constantly.\nThis is why I ended up with the solution of putting the repos on the network server and syncing the repo content on a local cache on each computer using rsync\nThat works fine, but the as time goes by, the repos are getting larger and the rsync is taking too much time to perform. So I would like to be have to (ideally) check one file that would tell me if the local copy is out of sync with the network copy and perform the rsync only when they are out of sync.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":36946288,"Users Score":1,"Answer":"Check the .git\/FETCH_HEAD for the time stamp and the content.\nEvery time you fetch content its updating the content and the modification time of the file.","Q_Score":0,"Tags":"python,git","A_Id":36946689,"CreationDate":"2016-04-29T19:40:00.000","Title":"How to check if a git repo was updated without using a git command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a BLE device which has a bunch of GATT services running on it. My goal is to access and read data from the service characteristics on this device from a Linux computer (BlueZ version is 5.37). I have enabled experimental mode - therefore, full GATT support should be available. BlueZ's DBUS API, however, only provides the org.bluez.GattManager1 interface for the connected device, and not the org.bluez.GattCharacteristic1 or org.bluez.GattService1 interfaces which I need. Is there something I'm doing wrong? The device is connected and paired, and really I've just run out of ideas as how to make this work, or what may be wrong.\nIf it helps, I'm using Python and the DBUS module to interface with BlueZ.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1158,"Q_Id":36956477,"Users Score":1,"Answer":"A system update resolved this problem.","Q_Score":1,"Tags":"python,linux,python-3.x,dbus,bluez","A_Id":36988374,"CreationDate":"2016-04-30T15:03:00.000","Title":"BlueZ DBUS API - GATT interfaces unavailable for BLE device","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the $PYTHONPATH variable, and what's the significance in setting it?\nAlso, if I want to know the content of my current pythonpath, how do I find that out?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":464,"Q_Id":36957843,"Users Score":0,"Answer":"PYTHONPATH is the default search path for importing modules. If you use bash, you could type echo $PYTHONPATH to look at it.","Q_Score":3,"Tags":"python,shell,path,environment-variables","A_Id":36957901,"CreationDate":"2016-04-30T17:14:00.000","Title":"Trying to understand the pythonpath variable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a list of objects that each contain a datetime.date() and a datetime.time() element. I know how to sort the array based on a single element using insertion sort, or any other sorting algorithm. However, how would I sort this list in chronological order using date AND time?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":797,"Q_Id":36960576,"Users Score":2,"Answer":"Use a tuple of (my_date, my_time) as the \"single element\" you're sorting on. You could build a datetime.datetime object from the two, but that seems unnecessary just to sort them.\nThis applies in general to any situation where you want a lexicographical comparison between multiple quantities. \"Lexicographical\" meaning, most-significant first with less-significant quantities as tie-breakers, which is exactly what the standard comparisons do for tuple.","Q_Score":0,"Tags":"python,sorting","A_Id":36960631,"CreationDate":"2016-04-30T21:42:00.000","Title":"Python: sort by date and time?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to scale an export system that works in the following steps:\n\nFetch a large number of records from a MySQL database. Each record is a person with an address and a product they want.\nMake an external API call to verify address information for each of them.\nMake an internal API call to get store and price information about the product on each record.\nAssign identifiers to each record in a specific format, which is different for each export.\nDump all the data into a file, zip it and email it.\n\nAs of now all of this happens in one monolithic python script which is starting to show its age. As the number of records being exported at a time has grown by about 10x, the script takes a lot of memory and whole export process is slow because all the steps are blocking and sequential.\nIn order to speed up the process and make it scalable I want to distribute the work into a chain of SQS queues. This is quite straightforward for the first 4 steps:\n\nSelector queue - takes a request, decides which records will be exported. Creates a msg for each of them in the verifier queue with export_id and record_id.\nVerifier queue - takes the id of the record, makes the API call to verify its address. Creates a msg in the price queue with export_id and record_id.\nPrice queue - takes the id of a record, makes the API call to get prices and attaches it to the record. Creates a msg in the assigner queue with export_id and record_id.\nAssigner queue - takes the id of a record, assigns it the sequential export ID. Creates a msg in the dumper queue with export_id and record_id.\nDumper queue - ???\n\nThis is all fine and dandy till now. Work is parallelized and we can add more workers to whichever step needs them the most. \nI'm stumped by how to add the last step in the process?\nTill now all the queues have been (suitably) dumb. They get a msg, perform an action and pass it on. In the current script, by the time we reach the last step, the program can be certain that all previous steps are complete for all the records and it is time to dump the information. How should I replicate this in the distributed case?\nHere are the options I could think of:\n\nThe dumper queue just saves it's incoming msgs in a DB table till it gets a msg flagged \"FINAL\" and then it dumps all msgs of that export_id. This makes the final msg a single point of failure. If multiple exports are being processed at the same time, order of msgs is not guaranteed so deciding which msg is final is prone to failure.\nPass an expected_total and count in each step and the dumper queue waits till it gets enough msgs. This would cause the dumper queue to get blocked and other exports will have to wait till all msgs of a previously started export are received. Will also have to deal with possibly infinite wait time in some way if msgs get lost.\n\nNone of the above options seem good enough. What other options do I have?\nAt a high level, consistency is more important than availability in this problem. So the exported files can arrive late, but they should be correct.\nMsg Delay Reasons\nAs asked in the comments:\n\nInternal\/External API response times may vary. Hard to quantify.\nIf multiple exports are being processed at the same time, msgs from one export may get lagged behind or be received in a mixed sequence in queues down the line.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":36972296,"Users Score":0,"Answer":"It looks like you can do the following:\n\nAssigner \n\nReads from the assigner queue and assigns the proper ids\nPacks the data in bulks and uploads them to S3.\nSends the path to S3  to the Dumper queue\n\nDumper reads the bulks and dumps them to DB in bulks","Q_Score":1,"Tags":"python,amazon-sqs","A_Id":36972378,"CreationDate":"2016-05-01T21:40:00.000","Title":"Scaling a sequential program into chain of queues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to scale an export system that works in the following steps:\n\nFetch a large number of records from a MySQL database. Each record is a person with an address and a product they want.\nMake an external API call to verify address information for each of them.\nMake an internal API call to get store and price information about the product on each record.\nAssign identifiers to each record in a specific format, which is different for each export.\nDump all the data into a file, zip it and email it.\n\nAs of now all of this happens in one monolithic python script which is starting to show its age. As the number of records being exported at a time has grown by about 10x, the script takes a lot of memory and whole export process is slow because all the steps are blocking and sequential.\nIn order to speed up the process and make it scalable I want to distribute the work into a chain of SQS queues. This is quite straightforward for the first 4 steps:\n\nSelector queue - takes a request, decides which records will be exported. Creates a msg for each of them in the verifier queue with export_id and record_id.\nVerifier queue - takes the id of the record, makes the API call to verify its address. Creates a msg in the price queue with export_id and record_id.\nPrice queue - takes the id of a record, makes the API call to get prices and attaches it to the record. Creates a msg in the assigner queue with export_id and record_id.\nAssigner queue - takes the id of a record, assigns it the sequential export ID. Creates a msg in the dumper queue with export_id and record_id.\nDumper queue - ???\n\nThis is all fine and dandy till now. Work is parallelized and we can add more workers to whichever step needs them the most. \nI'm stumped by how to add the last step in the process?\nTill now all the queues have been (suitably) dumb. They get a msg, perform an action and pass it on. In the current script, by the time we reach the last step, the program can be certain that all previous steps are complete for all the records and it is time to dump the information. How should I replicate this in the distributed case?\nHere are the options I could think of:\n\nThe dumper queue just saves it's incoming msgs in a DB table till it gets a msg flagged \"FINAL\" and then it dumps all msgs of that export_id. This makes the final msg a single point of failure. If multiple exports are being processed at the same time, order of msgs is not guaranteed so deciding which msg is final is prone to failure.\nPass an expected_total and count in each step and the dumper queue waits till it gets enough msgs. This would cause the dumper queue to get blocked and other exports will have to wait till all msgs of a previously started export are received. Will also have to deal with possibly infinite wait time in some way if msgs get lost.\n\nNone of the above options seem good enough. What other options do I have?\nAt a high level, consistency is more important than availability in this problem. So the exported files can arrive late, but they should be correct.\nMsg Delay Reasons\nAs asked in the comments:\n\nInternal\/External API response times may vary. Hard to quantify.\nIf multiple exports are being processed at the same time, msgs from one export may get lagged behind or be received in a mixed sequence in queues down the line.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":121,"Q_Id":36972296,"Users Score":0,"Answer":"You should probably use a cache instead of a queue.","Q_Score":1,"Tags":"python,amazon-sqs","A_Id":61071601,"CreationDate":"2016-05-01T21:40:00.000","Title":"Scaling a sequential program into chain of queues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My main Question:\nHow do I switch pages? \nI did some things on a page and than switch to another one,\nhow do I update the driver to be the current page?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":108,"Q_Id":36978007,"Users Score":2,"Answer":"With .get(url), just like you got to the first page.","Q_Score":0,"Tags":"python,selenium,switch-statement","A_Id":36978124,"CreationDate":"2016-05-02T08:19:00.000","Title":"Selenium Python, New Page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to write documentation and want and have multiply files used by multiple toc trees. Previously I used an empty file with .. include:: <isonum.txt> however, this does not work for multiply files in a directory with sub directories. Another solution I have used was to use a relative file path to the index file I am linking to. However this messes up the sphinx nav tree. So my question is how to include a directory of files with RST and Sphinx?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5575,"Q_Id":36993230,"Users Score":0,"Answer":"Perhaps indicate the start and end of the section where the files should go with a comment (.. START_GLOB_INCLUDE etc), and then have a build pre-process step that finds the files you want and rewrites that section of the master file.","Q_Score":7,"Tags":"python-sphinx,restructuredtext","A_Id":66927504,"CreationDate":"2016-05-02T23:30:00.000","Title":"How to include a directory of files with RST and Sphinx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to use ctypes to call a function from a C++ .dll in Python by creating a \"wrapper\" function that casts the Python input types to C. I think of this as essentially recreating the function signatures in Python, where the function body contains the type cast to C and a corresponding .dll function call.\nI currently have a set of C++ .dll files. Each library contains many functions, some of which are overloaded. I am tasked with writing a Python interface for each of these .dll files. My current way forward is to \"use the hammer I have\" and go through each function, lovingly crafting a corresponding Python wrapper for each... this will involve my looking at the API documentation for each of the functions within the .dlls and coding them up one by one. My instinct tells me, though, that there may be a much more efficient way to go about this.\nMy question is: Is there a programmatic way of interfacing with a Windows C++ .dll that does not require crafting corresponding wrappers for each of the functions? Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1193,"Q_Id":37002150,"Users Score":2,"Answer":"I would recommend using Cython to do your wrapping. Cython allows you to use C\/C++ code directly with very little changes (in addition to some boilerplate). For wrapping large libraries, it's often straightforward to get something up and running very quickly with minimal extra wrapping work (such as in Ctypes). It's also been my experience that Cython scales better... although it takes more front end work to stand Cython up rather than Ctypes, it is in my opinion more maintainable and lends itself well to the programmatic generation of wrapping code to which you allude.","Q_Score":2,"Tags":"python-3.x,dll,ctypes","A_Id":38547145,"CreationDate":"2016-05-03T10:51:00.000","Title":"How to programmatically wrap a C++ dll with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I installed Jupyter notebooks in Ubuntu 14.04 via Anaconda earlier, and just now I installed TensorFlow. I would like TensorFlow to work regardless of whether I am working in a notebook or simply scripting. In my attempt to achieve this, I ended up installing TensorFlow twice, once using Anaconda, and once using pip. The Anaconda install works, but I need to preface any call to python with \"source activate tensorflow\". And the pip install works nicely, if start python the standard way (in the terminal) then tensorflow loads just fine. \nMy question is: how can I also have it work in the Jupyter notebooks? \nThis leads me to a more general question: it seems that my python kernel in Jupyter\/Anaconda is separate from the python kernel (or environment? not sure about the terminology here) used system wide. It would be nice if these coincided, so that if I install a new python library, it becomes accessible to all the varied ways I have of running python.","AnswerCount":14,"Available Count":2,"Score":0.057080742,"is_accepted":false,"ViewCount":87389,"Q_Id":37061089,"Users Score":4,"Answer":"Here is what I did to enable tensorflow in Anaconda -> Jupyter. \n\nInstall Tensorflow using the instructions provided at \nGo to \/Users\/username\/anaconda\/env and ensure Tensorflow is installed\nOpen the Anaconda navigator and go to \"Environments\" (located in the left navigation)\nSelect \"All\" in teh first drop down and search for Tensorflow\nIf its not enabled, enabled it in the checkbox and confirm the process that follows. \nNow open a new Jupyter notebook and tensorflow should work","Q_Score":34,"Tags":"python,tensorflow,jupyter","A_Id":46785026,"CreationDate":"2016-05-05T22:08:00.000","Title":"Trouble with TensorFlow in Jupyter Notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Jupyter notebooks in Ubuntu 14.04 via Anaconda earlier, and just now I installed TensorFlow. I would like TensorFlow to work regardless of whether I am working in a notebook or simply scripting. In my attempt to achieve this, I ended up installing TensorFlow twice, once using Anaconda, and once using pip. The Anaconda install works, but I need to preface any call to python with \"source activate tensorflow\". And the pip install works nicely, if start python the standard way (in the terminal) then tensorflow loads just fine. \nMy question is: how can I also have it work in the Jupyter notebooks? \nThis leads me to a more general question: it seems that my python kernel in Jupyter\/Anaconda is separate from the python kernel (or environment? not sure about the terminology here) used system wide. It would be nice if these coincided, so that if I install a new python library, it becomes accessible to all the varied ways I have of running python.","AnswerCount":14,"Available Count":2,"Score":-0.0142847425,"is_accepted":false,"ViewCount":87389,"Q_Id":37061089,"Users Score":-1,"Answer":"Open an Anaconda Prompt screen:   (base) C:\\Users\\YOU>conda create -n tf tensorflow\nAfter the environment is created type: conda activate tf\nPrompt moves to (tf) environment, that is: (tf) C:\\Users\\YOU>\nthen install Jupyter Notebook in this (tf) environment:\nconda install -c conda-forge jupyterlab - jupyter notebook\nStill in (tf) environment, that is type\n(tf) C:\\Users\\YOU>jupyter notebook\nThe notebook screen starts!!\nA New notebook then can import tensorflow \nFROM THEN ON\nTo open a session\nclick Anaconda prompt,\ntype conda activate tf\nthe prompt moves to tf environment\n(tf) C:\\Users\\YOU>\nthen type (tf) C:\\Users\\YOU>jupyter notebook","Q_Score":34,"Tags":"python,tensorflow,jupyter","A_Id":67094115,"CreationDate":"2016-05-05T22:08:00.000","Title":"Trouble with TensorFlow in Jupyter Notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a GridView inside of a ScrollView. I am trying to create and display approximately ~12,000 items in the GridView (which clearly will not display appropriately on screen), but the number of items could feasible be ~40,000. Currently ~18 seconds are spent constructing all of the items (Labels), and any resizing of the window results in another significant delay.\nHow can I speed up the construction and rendering of the items? I don't know how to do paging or delayed, on-demand loading on a ScrollView.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":525,"Q_Id":37064168,"Users Score":0,"Answer":"How can you imagine a user scrolling through 40000 labels? You should rethink your app design.\nConsider adding a text input, and based on the given string, fetch filtered data from the database you have.","Q_Score":0,"Tags":"python,kivy","A_Id":37085902,"CreationDate":"2016-05-06T04:19:00.000","Title":"Kivy ScrollView (with Gridview) Suffering Performance Issues","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As far as I know, Variable is the default operation for making a variable, and get_variable is mainly used for weight sharing.\nOn the one hand, there are some people suggesting using get_variable instead of the primitive Variable operation whenever you need a variable. On the other hand, I merely see any use of get_variable in TensorFlow's official documents and demos.\nThus I want to know some rules of thumb on how to correctly use these two mechanisms. Are there any \"standard\" principles?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43849,"Q_Id":37098546,"Users Score":92,"Answer":"I'd recommend to always use tf.get_variable(...) -- it will make it way easier to refactor your code if you need to share variables at any time, e.g. in a multi-gpu setting (see the multi-gpu CIFAR example). There is no downside to it. \nPure tf.Variable is lower-level; at some point tf.get_variable() did not exist so some code still uses the low-level way.","Q_Score":134,"Tags":"python,tensorflow","A_Id":37102908,"CreationDate":"2016-05-08T09:57:00.000","Title":"Difference between Variable and get_variable in TensorFlow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Good afternoon. I have been learning Virtualenv and Virtualenvwrapper. I then decided I wanted to install Anaconda Python again so I could continue learning how to do data analysis. Then I saw where you can use conda to make a virtual environment for Anaconda. I installed it and told it not to add the path to my bashrc file but then conda was  not recognized. So then I reinstalled and said yes. But now my global python is set to anaconda 3.5 which I do not want. How can I use conda to set up a virtual environment without affecting my global python of 2.7? Thank you.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":255,"Q_Id":37123971,"Users Score":0,"Answer":"fix your PATH environment variable so it has the global python directory declared before the anacaonda directory.","Q_Score":0,"Tags":"python,python-3.x","A_Id":37124089,"CreationDate":"2016-05-09T19:31:00.000","Title":"Installing Anaconda Python in a virtual world without changing global Python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used IDLE for some time, then for a class they told us to download Anaconda, which I ended up not using, but still downloaded it anyway. \nI uninstalled anaconda and deleted all the files from my CPU and started using IDLE again. I now can't import a module to IDLE because it can't find it. I think anaconda messed up the python path, but I don't know how to change it so I can import modules back to python.\nHow can I determine what the python path is and how can I change it so when I download modules I can import them to IDLE again?\nI am running OsX 10.10.5 and Python 2.7.10.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3476,"Q_Id":37127292,"Users Score":0,"Answer":"To add the python path for anaconda if you are on windows:\n\nRight click my computer \nGo to advanced settings\nClick on environment variables\nFind the PATH variable and click edit\nAdd the path where your python.exe file is located\n\nExample:\nC:\\Anaconda3 - might not work\nC:\\Anaconda3 - then this should work\nSame thing for those, who have other installations.","Q_Score":1,"Tags":"python,python-2.7,import,module,anaconda","A_Id":45157942,"CreationDate":"2016-05-10T00:05:00.000","Title":"Reset python path after Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have zmq version 4.1.3 and pyzmq version 15.2.0 installed on my machine (I assume through pip but I dont remember now).  I have a need to connect to a UDP epgm socket but get the error \"protocol not supported\".  I have searched the vast expanses of the internet and have found the answer: \"build zero mq with --with-pgm option\".  \nDoes anyone know how to do that? \nI searched around the harddrive and found the zeromq library in pkgs in my python directory and found some .so files but I dont see any setup.py or anything to recompile with the mysterious --with-pgm option.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1035,"Q_Id":37177322,"Users Score":1,"Answer":"Here is the general procedure which works for me:\n1. download zeromq package (using zeromq-4.1.5.tar.gz as example)\n2. tar zxvf zeromq-4.1.5.tar.gz\n3. cd zeromq-4.1.5\n4. apt-get install libpgm-dev\n5. .\/configure --with-pgm && make && make install\n6. pip install --no-binary :all: pyzmq\nThen you can use pgm\/epgm as you want.","Q_Score":1,"Tags":"python,zeromq,multicast,pyzmq","A_Id":45479765,"CreationDate":"2016-05-12T04:31:00.000","Title":"How to install pyzmq \"--with-pgm\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I made a flask app following flask's tutorial. After python flaskApp.py, how can I stop the app? I pressed ctrl + c in the terminal but I can still access the app through the browser. I'm wondering how to stop the app? Thanks.\nI even rebooted the vps. After the vps is restated, the app still is running!","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":13550,"Q_Id":37178582,"Users Score":2,"Answer":"CTRL+C is the right way to quit the app, I do not think that you can visit the url after CTRL+C. In my environment it works well. \nWhat is the terminal output after CTRL+C? Maybe you can add some details. \nYou can try to visit the url by curl to test if browser cache or anything related with browser cause this problem.","Q_Score":2,"Tags":"python,flask","A_Id":37179018,"CreationDate":"2016-05-12T06:10:00.000","Title":"How to stop flask app.run()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a flask app following flask's tutorial. After python flaskApp.py, how can I stop the app? I pressed ctrl + c in the terminal but I can still access the app through the browser. I'm wondering how to stop the app? Thanks.\nI even rebooted the vps. After the vps is restated, the app still is running!","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":13550,"Q_Id":37178582,"Users Score":1,"Answer":"Have you tried pkill python?\nWARNING: do not do so before consulting your system admin if are sharing a server with others.","Q_Score":2,"Tags":"python,flask","A_Id":43197195,"CreationDate":"2016-05-12T06:10:00.000","Title":"How to stop flask app.run()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use numpy and scipy in different environments (MacOS, Ubuntu, RedHat).\nUsually I install numpy by using the package manager that is available (e.g., mac ports, apt, yum).\nHowever, if you don't compile Numpy manually, how can you be sure that it uses a BLAS library? Using mac ports, ATLAS is installed as a dependency. However, I am not sure if it is really used. When I perform a simple benchmark, the numpy.dot() function requires approx. 2 times the time than a dot product that is computed using the Eigen C++ library. I am not sure if this is a reasonable result.","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":28680,"Q_Id":37184618,"Users Score":4,"Answer":"numpy.show_config() just tells that info is not available on my Debian Linux. \nHowever \/usr\/lib\/python3\/dist-packages\/scipy\/lib has a subdirectory for blas which may tell you what you want. There are a couple of test programs for BLAS in subdirectory tests.\nHope this helps.","Q_Score":33,"Tags":"python,c++,macos,numpy,blas","A_Id":37185292,"CreationDate":"2016-05-12T10:44:00.000","Title":"Find out if\/which BLAS library is used by Numpy","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to install OpenCV for python3 in ubuntu 16.04.  Fist I tried running sudo apt-get install python3-opencv which is how I pretty much install all of my python software.  This could not find a repository.  The install does work however if I do sudo apt-get install python-opencv this issue with this is that by not adding the three to python it installs for python 2 which I do not use.  I would really perfer not to have to build and install from source so is there a way I can get a repository?  I also tried installing it with pip3 and it could not find it either.","AnswerCount":9,"Available Count":1,"Score":0.022218565,"is_accepted":false,"ViewCount":54785,"Q_Id":37188623,"Users Score":1,"Answer":"This is because you have multiple installations of python in your machine.You should make python3 the default, because by default is the python2.7","Q_Score":27,"Tags":"python,opencv,ubuntu","A_Id":37188746,"CreationDate":"2016-05-12T13:37:00.000","Title":"Ubuntu, how to install OpenCV for python3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm interested in tips for my algorithm that I use to find out the divisors of a very large number, more specifically \"n over k\" or C(n, k). The number itself can range very high, so it really needs to take time complexity into the 'equation' so to say. \nThe formula for n over k is n! \/ (k!(n-k)!) and I understand that I must try to exploit the fact that factorials are kind of 'recursive' somehow - but I havent yet read too much discrete mathematics so the problem is both of a mathematical and a programming nature. \nI guess what I'm really looking for are just some tips heading me in the right direction - I'm really stuck.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":846,"Q_Id":37207589,"Users Score":2,"Answer":"First you could start with the fact that : C(n,k) = (n\/k) C(n-1,k-1).\nYou can prouve that C(n,k) is divisible by n\/gcd(n,k).\nIf n is prime then n divides C(n,k).\nCheck Kummer's theorem: if p is a prime number, n a positive number, and k a positive number with 0< k < n then the greatest exponent r for which p^r divides C(n,k) is the number of carries needed in the subtraction n-k in base p.\nLet us suppose that n>4 :\n\nif p>n then p cannot divide C(n,k) because in base p, n and k are only one digit wide \u2192 no carry in the subtraction\n\nso we have to check for prime divisors in [2;n]. As C(n,k)=C(n,n-k) we can suppose k\u2264n\/2 and n\/2\u2264n-k\u2264n\n\nfor the prime divisors in the range [n\/2;n] we have n\/2 < p\u2264n, or equivalently p\u2264n<2p. We have p\u22652 so p\u2264n < p\u00b2 which implies that n has exactly 2 digits when written in base p and the first digit has to be 1. As k\u2264n\/2 < p, k can only be one digit wide. Either the subtraction as one carry and one only when n-k< p \u21d2 p divides C(n,k); either the subtraction has no carry and p does not divide C(n,k).\nThe first result is :\nevery prime number in [n-k;n] is a prime divisor of C(n,k) with exponent 1.\nno prime number in [n\/2;n-k] is a prime divisor of C(n,k).\n\nin [sqrt(n); n\/2] we have 2p\u2264n< p\u00b2, n is exactly 2 digits wide in base p, k< n implies k has at most 2 digits. Two cases: only one carry on no carry at all. A carry exists only if the last digit of n is greater than the last digit of p iif n modulo p < k modulo p\nThe second result is :\nFor every prime number p in [sqrt(n);n\/2]\np divides C(n;k) with exponent 1 iff n mod p < k mod p\np does not divide C(n;k) iff n mod p \u2265 k mod p\n\nin the range [2; sqrt(n)] we have to check all the prime numbers. It's only in this range that a prime divisor will have an exponent greater than 1","Q_Score":3,"Tags":"algorithm,python-3.x,discrete-mathematics,binomial-coefficients","A_Id":37212468,"CreationDate":"2016-05-13T10:25:00.000","Title":"Smart algorithm for finding the divisors of a binomial coefficient","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script I run using Cygwin and I'd like to create a clickable icon on the windows desktop that could run this script without opening Cygwin and entering in the commands by hand. how can I do this?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":33470,"Q_Id":37219045,"Users Score":1,"Answer":"A better way (in my opinion):\nCreate a shortcut:\nSet the target to\n%systemroot%\\System32\\cmd.exe \/c \"python C:\\Users\\MyUsername\\Documents\\MyScript.py\"\nStart In:\nC:\\Users\\MyUsername\\Documents\\\nObviously change the path to the location of your script. May need to add escaped quotes if there is a space in it.","Q_Score":8,"Tags":"python,windows,bash,cygwin","A_Id":68331346,"CreationDate":"2016-05-13T20:43:00.000","Title":"Windows: run python command from clickable icon","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a Deep Learning application I am building, I have a dataset of about 50k grayscale images, ranging from about 300*2k to 300*10k pixels. Loading all this data into memory is not possible, so I am looking for a proper way to handle reading in random batches of data. One extra complication with this is, I need to know the width of each image before building my Deep Learning model, to define different size-buckets within the data (for example: [2k-4k, 4k-6k, 6k-8k, 8k-10k].\nCurrently, I am working with a smaller dataset and just load each image from a png file, bucket them by size and start learning. When I want to scale up this is no longer possible. \nTo train the model, each batch of the data should be (ideally) fully random from a random bucket. A naive way of doing this would be saving the sizes of the images beforehand, and just loading each random batch when it is needed. However, this would result in a lot of extra loading of data and not very efficient memory management.\nDoes anyone have a suggestion how to handle this problem efficiently?\nCheers!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":811,"Q_Id":37227938,"Users Score":0,"Answer":"Why not add a preprocessing step, where you would either (a) physically move the images to folders associated with bucket and\/or rename them, or (b) first scan through all images (headers only) to build the in-memory table of image filenames and their sizes\/buckets, and then the random sampling step would be quite simple to implement.","Q_Score":0,"Tags":"python,deep-learning","A_Id":37228094,"CreationDate":"2016-05-14T14:37:00.000","Title":"Proper way of loading large amounts of image data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to debug a scrapy project , built in Python 2.7.1 \nin visual studio 2013. \nI am able to reach breakpoints, but when I do step into\/ step over\nthe debugger seems to continue the exceution as if I did resume (F5).\nI am working with standard python launcher.\nAny idea how to make the step into\/over functionality work?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2148,"Q_Id":37240431,"Users Score":1,"Answer":"workaround rather than full answer.\nI encountered this problem while importing my own module which ran code (which was erroring) on import.\nBy setting the imported module to the startup script, I was able to step through the startup code in the module and  debug.\nMy best guess is that visual studio 2015 decided the imported module was a python standard library, but it really isn't viable to turn on the 'debug standard library option' as many standard library modules generate errors on import themselves.","Q_Score":2,"Tags":"python,visual-studio,ptvs","A_Id":49196161,"CreationDate":"2016-05-15T15:55:00.000","Title":"python tools visual studio - step into not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Once logging is started in INFO level I keep getting bunch of py4j.java_gateway:Received command c on object id p0 on your logs. How can I hide it?","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":6581,"Q_Id":37252527,"Users Score":36,"Answer":"using the logging module run:\nlogging.getLogger(\"py4j\").setLevel(logging.ERROR)","Q_Score":22,"Tags":"python,pyspark,py4j","A_Id":37252533,"CreationDate":"2016-05-16T11:11:00.000","Title":"how to hide \"py4j.java_gateway:Received command c on object id p0\"?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How does Visual Studio switch between python and C# expressions when debugging a process that mixes both C# an Python by embedding and invoking python interpreter?\nFor background: My Visual Studio 2015 with PTVS 2.2.2 did not allow me to specify any python expressions in the watch window (on at least two machines), until something switched, and now it only allows using Python expressions in the same watch window (but not C#).\nI am not sure what I did, is there a proper way to switch between the two languages?\nOnce Python expressions started working, the C# expressions now all fall back on 'internal error in expression evaluator' both in watch and immediate window. The whole thing might have been related to me playing around with Python Debug Interactive window, but it feels very ad hoc and I am wondering how to properly configure this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":37289244,"Users Score":1,"Answer":"There seems to be a bug\/issue in PTVS and\/or Visual Studio in that the watch window does not realize that the context has switched to Python, unless there is at least one call to a python method in the call stack.\nso if embedded script does:\nprint ('foo')\n, the watch window thinks it's still in c# context.\nIf the embedded window has this instead - the watch window switches to Python\ndef Test():\nprint ('foo')\nTest()","Q_Score":1,"Tags":"c#,python,debugging,visual-studio-2015,ptvs","A_Id":37337168,"CreationDate":"2016-05-18T02:29:00.000","Title":"How to specify language for watch window expressions in a multi-language debugging environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"Using the form i create several strings that looks like xml data. One part of this strings i need to send on several servers using urllib and another part, on soap server, then i use suds library. When i receive the respond, i need to compare all of this data and show it to user. The sum of these server is nine and quantity of servers can grow. When i make this requests successively, it takes lot of time. According to this i have a question, is there some python library that can make different requests at the same time? Thank you for answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":37311172,"Users Score":3,"Answer":"You might want to consider using PycURL or Twisted. These should have the asynchronous capabilities you're looking for.","Q_Score":1,"Tags":"python,xml,django","A_Id":37311205,"CreationDate":"2016-05-18T22:33:00.000","Title":"Django sending xml requests at the same time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am playing around with some audio processing in python.  Right now I have the audio as a 2x(Large Number) numpy array.  I want to combine the channels since I only want to try some simple stuff.  I am just unsure how I should do this mathematically.  At first I thought this is kind of like converting an RGB image to gray-scale where you would average each of the color channels to create a gray pixel.  Then I thought that maybe I should add them due to the superposition principal of waves (then again average is just adding and dividing by two.)  Does anyone know the best way to do this?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3971,"Q_Id":37313320,"Users Score":1,"Answer":"i handle this by using Matlab.python can do the same. (left-channel+right-channel)\/2.0","Q_Score":1,"Tags":"python,audio","A_Id":37313404,"CreationDate":"2016-05-19T03:10:00.000","Title":"How to convert two channel audio into one channel audio","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am playing around with some audio processing in python.  Right now I have the audio as a 2x(Large Number) numpy array.  I want to combine the channels since I only want to try some simple stuff.  I am just unsure how I should do this mathematically.  At first I thought this is kind of like converting an RGB image to gray-scale where you would average each of the color channels to create a gray pixel.  Then I thought that maybe I should add them due to the superposition principal of waves (then again average is just adding and dividing by two.)  Does anyone know the best way to do this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3971,"Q_Id":37313320,"Users Score":1,"Answer":"To convert any stereo audio to mono, what I have always seen is the following:\nFor each pair of left and right samples:\n\nAdd the values of the samples together in a way that will not overflow\nDivide the resulting value by two\nUse this resulting value as the sample in the mono track -  make sure to round it properly if you are converting it to an integer value from a floating point value","Q_Score":1,"Tags":"python,audio","A_Id":37313414,"CreationDate":"2016-05-19T03:10:00.000","Title":"How to convert two channel audio into one channel audio","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The Jenkins ShiningPanda plugin provides a Managers Jenkins - Configure System setting for Python installations... which includes the ability to Install automatically. This should allow me to automatically setup Python on my slaves. \nBut I'm having trouble figuring out how to use it. When I use the Add Installer drop down it gives me the ability to\n\nExtract .zip\/.tar.gz\nRun Batch Command\nRun Shell Command\n\nBut I can't figure out how people us these options to install Python. Especially as I need to install Python on Windows, Mac, & Linux.\nOther Plugins like Ant provide an Ant installations... which installs Ant automatically. Is this possible with Python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4515,"Q_Id":37328773,"Users Score":3,"Answer":"As far as my experiments for jenkins and python goes, shining panda plug-in doesn't install python in slave machines in fact it uses the existing python library set in the jenkins configuration to run python commands.\nIn order to install python on slaves, I would recommend to use python virtual environment which comes along with shining panda and allows to run the python commands and then close the virtual environment.","Q_Score":7,"Tags":"python,plugins,jenkins","A_Id":37616786,"CreationDate":"2016-05-19T16:12:00.000","Title":"How to configure the Jenkins ShiningPanda plugin Python Installations","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm using a Raspberry Pi 2 with a rfid scanner and wrote a script in python that logs people in and out of our attendance system, connects to our postgresql database and returns some data like how much overtime they have and whether their action was a login or logout.\nThis data is meant to be displayed on a very basic webpage (that is not even on a server or anything) that just serves as a graphical interface to display said data.\nMy problem is that I cannot figure out how to dynamically display that data that my python script returns on the webpage without having to refresh it. I'd like it to simply fade in the information, keep it there for a few seconds and then have it fade out again (at which point the system becomes available again to have someone else login or logout).\nCurrently I'm using BeautifulSoup4 to edit the Html File and Chrome with the extension \"LivePage\" to then automatically update the page which is obviously a horrible solution.\nI'm hoping someone here can point me in the right direction as to how I can accoumplish this in a comprehensible and reasonably elegant way.\nTL;DR: I want to display the results of my python script on my web page without having to refresh it.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1371,"Q_Id":37340848,"Users Score":0,"Answer":"To update page data without delay you need to use websockets. \nThere is no need in using heavy frameworks.\n\nOnce page is loaded first time you open websocket with js and listen to it.\nEvery time you read a tag you post all necessary data to this open socket and it instantly appear on client side.","Q_Score":0,"Tags":"javascript,jquery,python,raspberry-pi,rfid","A_Id":37479489,"CreationDate":"2016-05-20T07:43:00.000","Title":"Dynamically update static webpage with python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok so I am very bad at sprites and I just don't get how to use sprites with blitted images. So I was wondering, if I make the image and just make a rectangle around that object that follows that image around, would that be a good replacement for sprites, the rectangle would be the one that's colliding for instances... Or should I try learning sprites. If I should is there any tutorial that could help me with using blitted images to make sprite characters that use python 3.4? \nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":37381061,"Users Score":0,"Answer":"In my experience, most uses for sprites can work with rectangular collision boxes. Only if you had an instance where a ball needed to be collided with then you would have to use an actual sprite. In the long run, I would recommend learning sprites, but if you need help with sprites, the pygame documentation has loads of information!","Q_Score":2,"Tags":"python-3.x,pygame","A_Id":37381094,"CreationDate":"2016-05-23T00:28:00.000","Title":"Replacing sprites idea","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Introduction\nI'd like to know what other topic modellers consider to be an optimal topic-modelling workflow all the way from pre-processing to maintenance. While this question consists of a number of sub-questions (which I will specify below), I believe this thread would be useful for myself and others who are interested to learn about best practices of end-to-end process.\nProposed Solution Specifications\nI'd like the proposed solution to preferably rely on R for text processing (but Python is fine also) and topic-modelling itself to be done in MALLET (although if you believe other solutions work better, please let us know). I tend to use the topicmodels package in R, however I would like to switch to MALLET as it offers many benefits over topicmodels. It can handle a lot of data, it does not rely on specific text pre-processing tools and it appears to be widely used for this purpose. However some of the issues outline below are also relevant for topicmodels too. I'd like to know how others approach topic modelling and which of the below steps could be improved. Any useful piece of advice is welcome.\nOutline\nHere is how it's going to work: I'm going to go through the workflow which in my opinion works reasonably well, and I'm going to outline problems at each step.\nProposed Workflow\n1. Clean text\nThis involves removing punctuation marks, digits, stop words, stemming words and other text-processing tasks. Many of these can be done either as part of term-document matrix decomposition through functions such as for example TermDocumentMatrix from R's package tm.\nProblem: This however may need to be performed on the text strings directly, using functions such as gsub in order for MALLET to consume these strings. Performing in on the strings directly is not as efficient as it involves repetition (e.g. the same word would have to be stemmed several times)\n2. Construct features\nIn this step we construct a term-document matrix (TDM), followed by the filtering of terms based on frequency, and TF-IDF values. It is preferable to limit your bag of features to about 1000 or so. Next go through the terms and identify what requires to be (1) dropped (some stop words will make it through), (2) renamed or (3) merged with existing entries. While I'm familiar with the concept of stem-completion, I find that it rarely works well. \nProblem: (1) Unfortunately MALLET does not work with TDM constructs and to make use of your TDM, you would need to find the difference between the original TDM -- with no features removed -- and the TDM that you are happy with. This difference would become stop words for MALLET. (2) On that note I'd also like to point out that feature selection does require a substantial amount of manual work and if anyone has ideas on how to minimise it, please share your thoughts.\nSide note: If you decide to stick with R alone, then I can recommend the quanteda package which has a function dfm that accepts a thesaurus as one of the parameters. This thesaurus allows to to capture patterns (usually regex) as opposed to words themselves, so for example you could have a pattern \\\\bsign\\\\w*.?ups? that would match sign-up, signed up and so on. \n3. Find optimal parameters\nThis is a hard one. I tend to break data into test-train sets and run cross-validation fitting a model of k topics and testing the fit using held-out data. Log likelihood is recorded and compared for different resolutions of topics.\nProblem: Log likelihood does help to understand how good is the fit, but (1) it often tends to suggest that I need more topics than it is practically sensible and (2) given how long it generally takes to fit a model, it is virtually impossible to find or test a grid of optimal values such as iterations, alpha, burn-in and so on.\nSide note: When selecting the optimal number of topics, I generally select a range of topics incrementing by 5 or so as incrementing a range by 1 generally takes too long to compute.\n4. Maintenance\nIt is easy to classify new data into a set existing topics. However if you are running it over time, you would naturally expect that some of your topics may cease to be relevant, while new topics may appear. Furthermore, it might be of interest to study the lifecycle of topics. This is difficult to account for as you are dealing with a problem that requires an unsupervised solution and yet for it to be tracked over time, you need to approach it in a supervised way.\nProblem: To overcome the above issue, you would need to (1) fit new data into an old set of topics, (2) construct a new topic model based on new data (3) monitor log likelihood values over time and devise a threshold when to switch from old to new; and (4) merge old and new solutions somehow so that the evolution of topics would be revealed to a lay observer.\nRecap of Problems\n\nString cleaning for MALLET to consume the data is inefficient.\nFeature selection requires manual work.\nOptimal number of topics selection based on LL does not account for what is practically sensible\nComputational complexity does not give the opportunity to find an optimal grid of parameters (other than the number of topics)\nMaintenance of topics over time poses challenging issues as you have to retain history but also reflect what is currently relevant.\n\nIf you've read that far, I'd like to thank you, this is a rather long post. If you are interested in the suggest, feel free to either add more questions in the comments that you think are relevant or offer your thoughts on how to overcome some of these problems.\nCheers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1478,"Q_Id":37386595,"Users Score":4,"Answer":"Thank you for this thorough summary!\nAs an alternative to topicmodels try the package mallet in R. It runs Mallet in a JVM directly from R and allows you to pull out results as R tables. I expect to release a new version soon, and compatibility with tm constructs is something others have requested.\nTo clarify, it's a good idea for documents to be at most around 1000 tokens long (not vocabulary). Any more and you start to lose useful information. The assumption of the model is that the position of a token within a given document doesn't tell you anything about that token's topic. That's rarely true for longer documents, so it helps to break them up.\nAnother point I would add is that documents that are too short can also be a problem. Tweets, for example, don't seem to provide enough contextual information about word co-occurrence, so the model often devolves into a one-topic-per-doc clustering algorithm. Combining multiple related short documents can make a big difference.\nVocabulary curation is in practice the most challenging part of a topic modeling workflow. Replacing selected multi-word terms with single tokens (for example by swapping spaces for underscores) before tokenizing is a very good idea. Stemming is almost never useful, at least for English. Automated methods can help vocabulary curation, but this step has a profound impact on results (much more than the number of topics) and I am reluctant to encourage people to fully trust any system.\nParameters: I do not believe that there is a right number of topics. I recommend using a number of topics that provides the granularity that suits your application. Likelihood can often detect when you have too few topics, but after a threshold it doesn't provide much useful information. Using hyperparameter optimization makes models much less sensitive to this setting as well, which might reduce the number of parameters that you need to search over.\nTopic drift: This is not a well understood problem. More examples of real-world corpus change would be useful. Looking for changes in vocabulary (e.g. proportion of out-of-vocabulary words) is a quick proxy for how well a model will fit.","Q_Score":4,"Tags":"python,r,text-mining,lda,mallet","A_Id":37416493,"CreationDate":"2016-05-23T08:52:00.000","Title":"What is the optimal topic-modelling workflow with MALLET?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"HI i want to install the polyglot on python version 3.5. it requires to have numpy installed which i already have and also libicu-dev. My OS is windows X86. I went through cmd, pip and wrote \"pip install libicu-dev\" but it gives me an error that could not find a version to satisfy the requirements.\nhow can i install libicu-dev?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2805,"Q_Id":37402110,"Users Score":0,"Answer":"This will work by typing it on Anaconda Prompt:\n pip install polyglot==14.11","Q_Score":0,"Tags":"windows,python-3.x,polyglot","A_Id":61607500,"CreationDate":"2016-05-23T23:29:00.000","Title":"Getting error on installing polyglot for python 3.5?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using cross_val_score from scikit-learn (package sklearn.cross_validation) to evaluate my classifiers.\nIf I use f1 for the scoring parameter, the function will return the f1-score for one class. To get the average I can use f1_weighted but I can't find out how to get the f1-score of the other class. (precision and recall analogous)\nThe functions in sklearn.metrics have a labels parameter which does this, but I can't find anything like this in the documentation.\nIs there a way to get the f1-score for all classes at once or at least specify the class which should be considered with cross_val_score?","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":13883,"Q_Id":37413302,"Users Score":-1,"Answer":"For individual scores of each class, use this : \nf1 = f1_score(y_test, y_pred, average= None)\nprint(\"f1 list non intent: \", f1)","Q_Score":5,"Tags":"python,scikit-learn,cross-validation","A_Id":53760310,"CreationDate":"2016-05-24T12:15:00.000","Title":"f1 score of all classes from scikits cross_val_score","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"EDIT:  When I say function in the title, I mean mathematical function not programming function.  Sorry for any confusion caused.\nI'm trying to create a function from randomly generated integers and operators.  The approach I am currently taking is as follows:\nSTEP 1:  Generate random list of operators and integers as a list.\nSTEP 2:  Apply a set of rules to the list so I always end up with an integer, operator, integer, operator... etc list.\nSTEP 3:  Use the modified list to create a single answer once the operations have been applied to the integers.\nFor example:\nSTEP 1 RESULT: [1,2,+,-,2,\/,3,8,*]\nSTEP 2 RESULT: [1,+,2,-,2,\/,3,*,8] - Note that I am using the operator command to generate the operators within the list.\nSTEP 3 RESULT: The output is intended to be a left to right read function rather than applying BODMAS, so in this case I'd expect the output to be 8\/3 (the output doesn't have to be an integer).\nSo my question is:  What function (and within what module) is available to help me combine the list as defined above.  OR should I be combining the list in a different way to allow me to use a particular function?\nI am considering changing the way I generate the list in the first place so that I do the sort on the fly, but I think I'll end up in the same situation that I wouldn't know how to combine the integers and operators after going through the sort process.\nI feel like there is a simple solution here and I am tying myself up in knots unnecessarily!\nAny help is greatly appreciated,\nDom","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":37414515,"Users Score":0,"Answer":"Why not create one list for the ints and one for the operators and them append from each list step by step?\nedit: you can first convert your ints to strings then, create a string by using string=''.joint(list) after that you can just eval(string)\nedit2: you can also take a look at the Sympy module that allows you to use symbolic math in python","Q_Score":0,"Tags":"python,list,operators","A_Id":37414636,"CreationDate":"2016-05-24T13:04:00.000","Title":"creating a simple function using lists of operators and integers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"EDIT:  When I say function in the title, I mean mathematical function not programming function.  Sorry for any confusion caused.\nI'm trying to create a function from randomly generated integers and operators.  The approach I am currently taking is as follows:\nSTEP 1:  Generate random list of operators and integers as a list.\nSTEP 2:  Apply a set of rules to the list so I always end up with an integer, operator, integer, operator... etc list.\nSTEP 3:  Use the modified list to create a single answer once the operations have been applied to the integers.\nFor example:\nSTEP 1 RESULT: [1,2,+,-,2,\/,3,8,*]\nSTEP 2 RESULT: [1,+,2,-,2,\/,3,*,8] - Note that I am using the operator command to generate the operators within the list.\nSTEP 3 RESULT: The output is intended to be a left to right read function rather than applying BODMAS, so in this case I'd expect the output to be 8\/3 (the output doesn't have to be an integer).\nSo my question is:  What function (and within what module) is available to help me combine the list as defined above.  OR should I be combining the list in a different way to allow me to use a particular function?\nI am considering changing the way I generate the list in the first place so that I do the sort on the fly, but I think I'll end up in the same situation that I wouldn't know how to combine the integers and operators after going through the sort process.\nI feel like there is a simple solution here and I am tying myself up in knots unnecessarily!\nAny help is greatly appreciated,\nDom","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":37414515,"Users Score":0,"Answer":"So, for those that are interested.  I achieved what I was after by using the eval() function.  Although not the most robust, within the particular loop I have written the inputs are closely controlled so I am happy with this approach for now.","Q_Score":0,"Tags":"python,list,operators","A_Id":37438697,"CreationDate":"2016-05-24T13:04:00.000","Title":"creating a simple function using lists of operators and integers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I searched the web and SO but did not find an aswer.\nUsing Python, I would like to know how (if possible) can I stop the screen from updating its changes to the user.\nIn other words, I would like to buid a function in Python that, when called, would freeze the whole screen, preventing the user from viewing its changes. And, when called again, would set back the screen to normal. Something like the Application.ScreenUpdating Property of Excel VBA, but applied directly to the whole screen.\nSomething like:\nFreezeScreen(On)\nFreenScreen(Off)\nIs it possible?\nThanks for the help!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1178,"Q_Id":37419778,"Users Score":1,"Answer":"If by \"the screen\" you're talking about the terminal then I highly recommend checking out the curses library. It comes with the standard version of Python. It gives control of many different aspects of the terminal window including the functionality you described.","Q_Score":0,"Tags":"python,screen,freeze,display","A_Id":37421436,"CreationDate":"2016-05-24T17:03:00.000","Title":"Using Python, how to stop the screen from updating its content?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using proxmoxer to manipulate machines on ProxMox (create, delete etc).\nEvery time I am creating a machine, I provide a description which is being written in ProxMox UI in section \"Notes\".\nI am wondering how can I retrieve that information?\nBest would be if it can be done with ProxMox, but if there is not a way to do it with that Python module, I will also be satisfied to do it with plain ProxMox API call.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":256,"Q_Id":37463782,"Users Score":0,"Answer":"The description parameter is only a message to show in proxmox UI, and it's not related to any function","Q_Score":1,"Tags":"python,virtual-machine,virtualization,proxmox","A_Id":37565566,"CreationDate":"2016-05-26T14:29:00.000","Title":"How can I retrieve Proxmox node notes?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Django and PythonAnywhere, and I want to make the DEBUG to False. But when I set it to False and make ALLOWED_HOSTS = ['*'], it works fine. But the problem is the media (or the images) is not displaying. Anyone encounter this and know how to resolve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1288,"Q_Id":37480048,"Users Score":4,"Answer":"I Figured it out, thanks for the hint Mr. Raja Simon.\nIn my PythonAnywhere Dashboard on Web Tab. I set something like this..\nURL             \/media\/     \nDirectory   \/home\/\/media_cdn\n*media_cdn is where my images located.","Q_Score":2,"Tags":"django,pythonanywhere","A_Id":37480695,"CreationDate":"2016-05-27T09:38:00.000","Title":"Django + Pythonanywhere: How to disable Debug Mode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose that i have multiple .csv files with columns of same kind . If i wanted to access data of a particular column from a specified .csv file , how is it possible?\nAll .csv files have been stored in list.data\nfor ex:\nSuppose that here , list.data[1] gives me the first .csv file.\nHow will i access a column of this file?\nI have tried list.data[1]$nameofthecolumn.\nBut this is giving me null values.\nI am not much familiar with R.\n\nlist.data[1]$name1\n  NULL\nlist.data[1]$name1\n  NULL\nlist.data[1]\n  $\n  NULL","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":51,"Q_Id":37480728,"Users Score":0,"Answer":"you can use list.data[[1]]$name1","Q_Score":0,"Tags":"python,r,csv","A_Id":37480887,"CreationDate":"2016-05-27T10:10:00.000","Title":"how to access a particular column of a particular csv file from many imported csv files","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am starting to learn Tkinter and have been creating new windows with new instances of Tk every time. I just read that that wasn't a good practice. If so, why? And how could this be done better? I have seen others create windows with Toplevel and Frame instances. What are the benefits\/drawbacks of using these instead?\nIn case this makes a difference: The application that I am writing code for starts off with a login window and then proceeds to a second window is the entered password is correct.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1757,"Q_Id":37502942,"Users Score":3,"Answer":"Every tkinter program needs exactly one instance of Tk. Tkinter is a wrapper around an embedded tcl interpreter. Each instance of Tk gets its own copy of the interpreter, so two Tk instances have two different namespaces. \nIf you need multiple windows, create one instance of Tk and then additional windows should be instances of Toplevel. \nWhile you can create, destroy, and recreate a root window, there's really no point. Instead, create the root window for the login screen, and then just delete the login screen widgets and replace them with your second window.\nThis becomes trivial if you make each of your \"windows\" a separate class that inherits from tk.Frame. Because tkinter will destroy all child widgets when a frame is destroyed, it's easy to switch from one \"window\" to another. Create an instance of LoginFrame and pack it in the root window. When they've input a correct password, destroy that instance, create an instance of MainWindow and pack that.","Q_Score":0,"Tags":"python,python-2.7,user-interface,tkinter","A_Id":37503535,"CreationDate":"2016-05-28T19:17:00.000","Title":"Tkinter Creating Multiple Windows - Use new Tk instance or Toplevel or Frame?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to set my QGroupBox's title with HTML expressions in python program, \ne.g. :\n ABC. (subscript)\nDoes anybody have an idea how to do this?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":372,"Q_Id":37527124,"Users Score":1,"Answer":"QGroupBox's title property does not support HTML. The only customization you can do through the title string (besides the text itself) is the addition of an ampersand (&) for keyboard accelerators.\nIn short, unlike QLabel, you can't use HTML with QGroupBox.","Q_Score":1,"Tags":"python,html,qt,groupbox","A_Id":37535825,"CreationDate":"2016-05-30T13:38:00.000","Title":"How can I set QGroupBox's title with HTML expressions? (Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering if it's possible to populate sys.argv (or some other structure) with command line arguments in a jupyter\/ipython notebook, similar to how it's done through a python script. \nFor instance, if I were to run a python script as follows:\npython test.py False\nThen sys.argv would contain the argument False. But if I run a jupyter notebook in a similar manner:\njupyter notebook test.ipynb False\nThen the command line argument gets lost. Is there any way to access this argument from within the notebook itself?","AnswerCount":11,"Available Count":1,"Score":0.0181798149,"is_accepted":false,"ViewCount":117203,"Q_Id":37534440,"Users Score":1,"Answer":"A workaround is to make the jupyter notebook read the arguments from a file. \nFrom the command line, modify the file and run the notebook.","Q_Score":67,"Tags":"python,jupyter-notebook,command-line-arguments,papermill","A_Id":60984594,"CreationDate":"2016-05-30T22:39:00.000","Title":"Passing command line arguments to argv in jupyter\/ipython notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I 'm using svm to predict the label from the title of a book. However I want to give more weight to some features pre defined. For example, if the title of the book contains words like fairy, Alice I want to label them as children's books. I'm using word n-gram svm. Please suggest how to achieve this using sklearn.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":156,"Q_Id":37538068,"Users Score":0,"Answer":"You can create one more feature vector in your training data, if the name of the book contains your predefined words then make it one otherwise zero.","Q_Score":1,"Tags":"python,svm","A_Id":37538260,"CreationDate":"2016-05-31T06:11:00.000","Title":"giving more weight to a feature using sklearn svm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to make message boxes, and I know how to create textboxes. However, I don't know how to make a message box WITH a textbox in it. I've looked through the tkinter documentation and it seems message boxes are kind of limited.\nIs there a way to make a message box that contains a text entry field, or would I have to create a new pop up window from scratch?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":392,"Q_Id":37556808,"Users Score":0,"Answer":"simpledialog.askstring() was exactly what I needed.","Q_Score":1,"Tags":"user-interface,python-3.x,tkinter,textbox,messagebox","A_Id":37559356,"CreationDate":"2016-05-31T22:40:00.000","Title":"Python: Create a message box with a text entry field using tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I know \"adb push\" command could be used to push files to android device. But in Python how do i push single file for example file.txt(size of about 50 KB) into android sdcard with different names(for ex. file1.txt, file2.txt etc) until the device storage is full. Any idea much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":37559502,"Users Score":0,"Answer":"I found an alternative solution to this problem. In a python while loop push a single file into SD Card and use \"adb mv\" to rename the file in the SD Card after pushing the file, continue this until the device memory is full.","Q_Score":1,"Tags":"python","A_Id":37658540,"CreationDate":"2016-06-01T04:34:00.000","Title":"Python push single file into android device with different names until the device runs out of memory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm having a bit of a problem figuring out how to generate user friendly links to products for sharing.\nI'm currently using \/product\/{uuid4_of_said_product}\nWhich is working quite fine - but it's a bit user unfriendly - it's kind of long and ugly.\nAnd I do not wish to use and id as it would allow users to \"guess\" products. Not that that is too much of an issue - I would like to avoid it.\nDo you have any hints on how to generate unique, user friendly, short sharing urls based on the unique item id or uuid?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":491,"Q_Id":37568811,"Users Score":1,"Answer":"As Seluck suggested I decided to go with base64 encoding and decoding:\nIn the model my \"link\" property is now built from the standard url + base64.urlsafe_b64encode(str(media_id))\nThe url pattern I use to match the base64 pattern:\nbase64_pattern = r'(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$'\nAnd finally in the view we decode the id to load the proper data:\nmedia_id = base64.urlsafe_b64decode(str(media_id))\nmedia = Media.objects.get(pk=media_id)","Q_Score":0,"Tags":"python,django,url,sharing","A_Id":37651587,"CreationDate":"2016-06-01T12:36:00.000","Title":"Sharing URL generation from uuid4?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a single-threaded python3 program that I'm trying to convert to use many threads.  I have a tree-like data structure that gets read from and written to.  Potentially many threads will want to read and write at the same time.\nOne obvious way about this is to have a single lock for the entire data structure: no one can read while a write is happening, no more than one write can happen at a time, and no write can happen when there are pending reads.\nHowever, I'd like to make the locking more fine-grained for greater performance.  It's a full 16-ary tree, and when fully populated has about 5 to 6 million leafs (mostly well-balanced in practice, but no guarantee).  If I wanted the finest-grained locking, I could lock the parents of the leafs.  That would mean over 100 thousand locks.\nI must admit, I haven't tried this yet.  But I thought I'd ask first: are there any hardware limitations or performance reasons that should stop me from creating so many lock objects?  That is, should I consider just locking down to, say, depth 2 from the root (256 locks)?\nThanks for any insights.\nEDIT:\nMore details: \nI don't know how many cores yet as we're still experimenting as to just how much computing power we'll need, but I'd hazard a guess that just a handful of cores will be used.\nI'm aiming for around 50,000 threads.  There's async I\/O, and one thread per socket.  During a bootstrapping phase of the code, as many threads as possible will be running simultaneously (as limited by hardware), but that's a one-time cost.  The one we're more interested in is once things are up and running.  At that point, I'd hazard a guess that only several thousand per second are running.  I need to measure the response time, but I'd guess it's around 10ms per wake period.  That's a few 10s of threads active at a time (on average).\nNow that I write that out, maybe that's the answer to my question.  If I only need a few 10s of threads reading or writing at a time, then I don't really need that fine-grained locking on the tree.","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":643,"Q_Id":37603610,"Users Score":4,"Answer":"Premature Optimization\nThis is a classic example of premature optimization.  Without knowing how much time your threads spend blocking, presumably waiting for other writes to happen, it's unclear what you have to gain from creating the added complexity of managing thousands of locks.  \nThe Global Interpreter Lock\nThreading itself can be a premature optimization.  Is your task easily threadable?  Can many threads safely work in parallel?  Tasks that require a large amount of shared state (i.e. many and frequent locks) are typically poor candidates for high thread counts.  In python, you're likely to see even less benefit because of the GIL.  Are your threads doing a lot of IO, or calling out to external applications, or using python modules written in C that properly releases the GIL?  If not, threading might not actually give you any benefit.  You can sidestep the GIL by using the multiprocessing module, but there's an overhead to passing locks and writes across process boundaries, and ironically, it might make your application much slower\nQueues\nAnother option is to use a write queue.  If threads don't actually need to share state, but they all need to write to the same object (i.e. very little reading from that object), you can simply add the writes to a queue and have a single thread process the writes, with no need for any locks.","Q_Score":7,"Tags":"python,multithreading","A_Id":37603825,"CreationDate":"2016-06-02T23:18:00.000","Title":"are there any limitations on the number of locks a python program can create?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"what is the proper way to close tensorboard with jupyter notebook? \nI'm coding tensorflow on my jupyter notebook.                                        To launch, I'm doing:                                                                     1.  \n\n!tensorboard --logdir = logs\/\nopen a new browser tab and type in localhost:6006\n\nto close, I just do:\n\nclose the tensorflow tab on my browser\non jupyter notebook, I click on interrupt kernel \n\nJust wondering if this is the proper way....\nBTW, in my code I set my log file as '.\/log\/log1'. \nwhen starting tensorboard, should I use --logdir = .\/log  or --logdir = .\/log\/log1?   \nthank you very much.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2652,"Q_Id":37632393,"Users Score":1,"Answer":"The jupyter stuff seems fine. In general, if you don't close TensorBoard properly, you'll find out as soon as you try to turn on TensorBoard again and it fails because port 6006 is taken. If that isn't happening, then your method is fine.\nAs regards the logdir, passing in the top level logdir is generally best because that way you will get support for comparing multiple \"runs\" of the same code in TensorBoard. However, for this to work, it's important that each \"run\" be in its own subdirectory, e.g.:\nlogs\/run1\/..tfevents..\nlogs\/run2\/..tfevents..\ntensorboard --logdir=logs","Q_Score":1,"Tags":"python,tensorflow,jupyter-notebook,tensorboard","A_Id":37682991,"CreationDate":"2016-06-04T16:13:00.000","Title":"how to close tensorboard server with jupyter notebook","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I had anaconda2 installed, and manually added the python3 kernel, so I could chose between python2 and python3. The problem was that I added my system's python3 binary, not anaconda's, so I was missing all the libraries that anaconda brings. Specifically I couldnt import 'from scipy.misc import imread'.\nSo I deleted anaconda2, installed anaconda3, but my jupyter notebook still uses my system's old python3 kernel. When I run sys.version inside the jupyter notebook I get python 3.4, but when I run it inside ipython in console I get python 3.5, with all the modules I need good to go.\nSo how do I tell jupyter notebook specifically what bin to use as a kernel?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":519,"Q_Id":37642502,"Users Score":1,"Answer":"Ended up solving it with:\npip install -U ipython\nipython3 kernelspec install-self","Q_Score":1,"Tags":"python,ipython,jupyter","A_Id":37645847,"CreationDate":"2016-06-05T13:31:00.000","Title":"Jupyter Notebook uses my system's python3.4 instead of anaconda's python3.5 as a kernel","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a beginner in python programming and I am working on a project that I want to send files to the recycle bin using python. I heard of this \"add-on\" called Send2Trash which is what I wanted but I don't really know how to install it. I tried on the python website, other websites and from the author and it really didn't made any sense about the python setup.py install and  about \"Distutils\". Can someone help give a clear instruction on installing this type of \"add-on\" very clearly. And also I apologize if I ask something like this because I'm still a beginner in python but it is really a big help if someone can solve this problem.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1242,"Q_Id":37694804,"Users Score":0,"Answer":"Answer\nIf you are getting the error while using Python 3 on Mac OS X, try these commands in Terminal: pip3 install Send2Trash or pip3 install send2trash\nI am on Mac OS X using Python 3, and this worked for me.\n\nExplanation\nI have read that most Mac OS X users have both Python 2 and Python 3 installed. Using pip3 (instead of pip) installs the module on Python 3 (instead of Python 2). (Disclaimer: I don't know if this explanation is correct.)","Q_Score":1,"Tags":"python","A_Id":55979236,"CreationDate":"2016-06-08T06:29:00.000","Title":"How to install an \"add-on\" like Send2Trash to be used in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would expect a return of 0. Is -1 simply the equivalent of false? For a moment I thought it was because 0 is a position (index?) in the string, but so is -1. While I know it is enough to simply memorize that this is how the find operation works, I was wondering if there was a deeper explanation or if this is something common that I will continue to encounter as I study.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4891,"Q_Id":37707616,"Users Score":1,"Answer":"The objective of the find method is to return the index value, which (for all practical purposes) programmers want as positive. In this case, any negative value means that the function could not find the particular element.\nThe reason why True or False is NOT used is just to avoid thousands of TypeErrors","Q_Score":1,"Tags":"python,find","A_Id":37708306,"CreationDate":"2016-06-08T16:07:00.000","Title":"Why does the find function return -1 in python when searching a string and failing to find a match?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would expect a return of 0. Is -1 simply the equivalent of false? For a moment I thought it was because 0 is a position (index?) in the string, but so is -1. While I know it is enough to simply memorize that this is how the find operation works, I was wondering if there was a deeper explanation or if this is something common that I will continue to encounter as I study.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4891,"Q_Id":37707616,"Users Score":0,"Answer":"@jonrsharpe I believe your comment answered my question best. While -1 is an index, the find function always returns a non-negative index when successful and -1 otherwise.","Q_Score":1,"Tags":"python,find","A_Id":37708679,"CreationDate":"2016-06-08T16:07:00.000","Title":"Why does the find function return -1 in python when searching a string and failing to find a match?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"round(1.4 999 999 999 999 999) (without the spaces) gets rounded to 2\nbut\nround(1.4  99 999 999 999 999) (without the spaces) gets rounded to 1.\nI suppose this has to do with imprecise floating point representations, but fail to understand how does it come that the first representation is interpreted as closer to 2 than to 1.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":312,"Q_Id":37720228,"Users Score":5,"Answer":"Because 1.4 999 999 999 999 999 when parsed is exactly 1.5, the difference between them is too small to represent at that magnitude.\nBut 1.4  99 999 999 999 999 is low enough to parse to \"less than 1.5\", actually 1.4999999999999988897769753748434595763683319091796875, which is clearly less than 1.5","Q_Score":3,"Tags":"python-3.x,floating-point,rounding","A_Id":37720389,"CreationDate":"2016-06-09T08:07:00.000","Title":"Rounding in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any shortcut key in Spyder python IDE to indent the code block?\nFor example, Like ctr+[ in Matlab, I want to indent the code block together.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":69522,"Q_Id":37721263,"Users Score":0,"Answer":"Spyder 4 select the lines and then press TAB or CTRL+] For indent and shift+TAB or CTRL+] for un-indent","Q_Score":16,"Tags":"python,ipython,spyder","A_Id":61645817,"CreationDate":"2016-06-09T08:56:00.000","Title":"how to indent the code block in Python IDE: Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any shortcut key in Spyder python IDE to indent the code block?\nFor example, Like ctr+[ in Matlab, I want to indent the code block together.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":69522,"Q_Id":37721263,"Users Score":40,"Answer":"Select your code and press Tab for indent and Shift+Tab to un-indent.\nor go to Edit -> Indent\/Unindent\nEdit section also contains some other tools for editing your code.","Q_Score":16,"Tags":"python,ipython,spyder","A_Id":37721501,"CreationDate":"2016-06-09T08:56:00.000","Title":"how to indent the code block in Python IDE: Spyder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed Win10, Visual Studio 2015, Python 2.7, Python 3.5 and PTVS 2.2.3.\nUnfortunately PTVS does not work at all. I can not load any Python projects that were loading previously in Visual Studio. It worked before I installed Python 3.5. I tried to uninstall Python 2.7 and get an error saying that the uninstall didn't success. After several tries, the problem appears to be around pip which is somehow blocking both install and uninstall of Python 2.7.\nWhen trying to open Python Tools from Tools menu, nothing happens. Neither window opens nor any error message is displayed. Python Environments window does not open even with the shortcut.\nIn Tools > Options > Python Tools, the only text shown is: \"An error occurred loading this property page\".\nWhen I try to load\/reload the Python project, the message is: \"error  : Expected 1 export(s) with contract name \"Microsoft.PythonTools.Interpreter.IInterpreterOptionsService\" but found 0 after applying applicable constraints.\" This has already been posted for 11 days ago, but no one has answered.\nTo solve this, I would like to know how to make the Python Environment window appearing in Visual Studio.\nThanks for any help.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4337,"Q_Id":37721461,"Users Score":0,"Answer":"I`m also having similar issues, first installation path:\n\nVisual Studio 2015 Pro with Update 1\nInstalled PTVS using the VS2015 installation setup later on\nEverything work fine\n\nThe issues started:\n\nInstalled a DEV version of PTVS from their github page\nMy pyproj stopped loading saying a migration needed\nNoticed that after new PTVS installation, I`ve installed VS2015 Update 2\n\nNot being able to reload my project after trying to debug the issue, I`ve decided to: \n\nUninstall PTVS and \nReinstall PTVS through VS2015 setup\n\nNow the issue was different, while trying to load my previous pyproj or even creating different Python projects using multiple templates. I was getting this error:\n\n\"There is a missing project subtype. Subtype: '{1b580a1a-fdb3-4b32-83e1-6407eb2722e6}' is unsupported by this installation.\"\n\nNot finding anything around this, I`ve:\n\nUninstalled Visual Studio 2015 (having Update 2)\nReinstalled Visual Studio 2015 with Update 1 (without checking PTVS, who requires VS 2015 Update 2 to be installed as well, I suspected it has something to do with it)\nInstalled PTVS latest stable version from their Github\n\nNow Visual Studio is crashing while trying to load the past mentioned pyproj, with the same error as OP:\n\nSetSite failed for package [Python Tools Package][Expected 1 export(s) with contract name \"Microsoft.PythonTools.Interpreter.IInterpreterOptionsService\" but found 0 after applying applicable constraints.]\n\nStill trying to fix it at the moment.\nMaybe these steps will help debugging the issue.\nUpdate \/ Fixed\nAfter installing VS 2015 with Update 1 and PTVS 2.2 for VS 2015, I was still having issues opening the pyproj causing VS to just crash (unfortunately nothing in ActivityLog.xml).\nI've tried repairing Visual Studio through it's setup, still the same issue.\nFinally, I've decided to re-update Visual Studio 2015 to Update 2, causing also to update PTVS to March release, all through VS setup utility.\nAnd now my pyproj correctly opens. Probably some versions miss match during the initial steps where I've installed a DEV version of PTVS. Not sure which step actually corrected my issue but it did.\nHope this will help somehow other people with similar issues.","Q_Score":1,"Tags":"visual-studio,python-2.7,python-3.x,ptvs","A_Id":37955825,"CreationDate":"2016-06-09T09:06:00.000","Title":"Visual Studio Python Environments window does not display","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have installed Win10, Visual Studio 2015, Python 2.7, Python 3.5 and PTVS 2.2.3.\nUnfortunately PTVS does not work at all. I can not load any Python projects that were loading previously in Visual Studio. It worked before I installed Python 3.5. I tried to uninstall Python 2.7 and get an error saying that the uninstall didn't success. After several tries, the problem appears to be around pip which is somehow blocking both install and uninstall of Python 2.7.\nWhen trying to open Python Tools from Tools menu, nothing happens. Neither window opens nor any error message is displayed. Python Environments window does not open even with the shortcut.\nIn Tools > Options > Python Tools, the only text shown is: \"An error occurred loading this property page\".\nWhen I try to load\/reload the Python project, the message is: \"error  : Expected 1 export(s) with contract name \"Microsoft.PythonTools.Interpreter.IInterpreterOptionsService\" but found 0 after applying applicable constraints.\" This has already been posted for 11 days ago, but no one has answered.\nTo solve this, I would like to know how to make the Python Environment window appearing in Visual Studio.\nThanks for any help.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4337,"Q_Id":37721461,"Users Score":0,"Answer":"Thanks for your posts.\nMy problem was fixed after I installed VS 2015 update 3 which included a new release of PTVS (June 2.2.40623).","Q_Score":1,"Tags":"visual-studio,python-2.7,python-3.x,ptvs","A_Id":38182070,"CreationDate":"2016-06-09T09:06:00.000","Title":"Visual Studio Python Environments window does not display","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have installed Win10, Visual Studio 2015, Python 2.7, Python 3.5 and PTVS 2.2.3.\nUnfortunately PTVS does not work at all. I can not load any Python projects that were loading previously in Visual Studio. It worked before I installed Python 3.5. I tried to uninstall Python 2.7 and get an error saying that the uninstall didn't success. After several tries, the problem appears to be around pip which is somehow blocking both install and uninstall of Python 2.7.\nWhen trying to open Python Tools from Tools menu, nothing happens. Neither window opens nor any error message is displayed. Python Environments window does not open even with the shortcut.\nIn Tools > Options > Python Tools, the only text shown is: \"An error occurred loading this property page\".\nWhen I try to load\/reload the Python project, the message is: \"error  : Expected 1 export(s) with contract name \"Microsoft.PythonTools.Interpreter.IInterpreterOptionsService\" but found 0 after applying applicable constraints.\" This has already been posted for 11 days ago, but no one has answered.\nTo solve this, I would like to know how to make the Python Environment window appearing in Visual Studio.\nThanks for any help.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":4337,"Q_Id":37721461,"Users Score":0,"Answer":"You'll need to open the ActivityLog.xml (%APPDATA%\\Microsoft\\VisualStudio\\14.0\\ActivityLog.xml) and see if there's any exceptions there related to PTVS.  \nIt sounds like you have a pretty messed up configuration at this point.  You could try uninstalling PTVS and re-installing it, but my guess is your messed up Python installs are somehow throwing PTVS off and causing it to crash somewhere.","Q_Score":1,"Tags":"visual-studio,python-2.7,python-3.x,ptvs","A_Id":37890917,"CreationDate":"2016-06-09T09:06:00.000","Title":"Visual Studio Python Environments window does not display","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've been using IDLE with my raspberry for a while, it's nice at the beginning, but Pycharm provides lots more of features and I'm used to them since I've been also using Android Studio.\nThe problem is I couldn't figure out how to install the RPi module to control the pins of my Raspberry. Does anyone know how to do this?\nIn case it matters, it's python3 on a raspberry 2B.","AnswerCount":2,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":18522,"Q_Id":37732918,"Users Score":-2,"Answer":"You can run Pycharm directly on your Raspberry Pi:\n- Using your Raspberry Pi, download the installation file directly from the Pycharm website (JetBrains).  It will be a tarball, i.e., a file ending in \".tar.gz\".\n- Extract the file to a folder of your choice.\n- Browsing through the extracted files and folders, you will find a folder named \"bin\". Inside \"bin\" you will find a file named Pycharm.sh\n- Using your terminal window, go to the \"bin\" folder and launch the Pycharm application by typing:  sudo .\/Pycharm.sh\nAfter several seconds (it's a little slow to load on my RPi3), Pycharm will load.  Have fun!","Q_Score":3,"Tags":"python,raspberry-pi,pycharm","A_Id":40196547,"CreationDate":"2016-06-09T17:48:00.000","Title":"Install RPi module on Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having problem of installing python package language-check to my python 2.7 environment.\nI tried the pip install language-check --upgrade command but it was no avail. It gave my error saying \"Command \"python setup.py egg_info\" failed with error code 1 in \/private\/var\/folders\/fn\/g0nd0gb54d5c__5fjhb7rp0w0000gn\/T\/pip-build-zMuFbc\/language-check\/\". I have problem of understanding what it is saying. If you know what it is saying, please give me a hint on how to fix it.\nI also tried to download the laguage-check tar.gz to my mac, gunzip it, ran tar -xwf command on it, went to language-check directory and ran setup install but it did not work either . It gave me an error saying \"error in language-check setup command: package_data must be a dictionary mapping package names to lists of wildcard patterns\". So if you know how to fix the problem, please let me know.\nThank you so much in advance,\nTom","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":387,"Q_Id":37750405,"Users Score":1,"Answer":"I found alternative: pip install --user --upgrade grammar-check","Q_Score":1,"Tags":"python-2.7","A_Id":40962470,"CreationDate":"2016-06-10T14:10:00.000","Title":"error on installing language-check packages to python 2.7 environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am creating a code where I need to take a string of words, convert it into numbers where hi bye hi hello would turn into 0 1 0 2.  I have used dictionary's to do this and this is why I am having trouble on the next part. I then need to compress this into a text file, to then decompress and reconstruct it into a string again.  This is the bit I am stumped on.\nThe way I would like to do it is by compressing the indexes of the numbers, so the 0 1 0 2 bit into the text file with the dictionary contents, so in the text file it would have 0 1 0 2 and {hi:0, bye:1, hello:3}.  \nNow what I would like to do to decompress or read this into the python file, to use the indexes(this is how I will refer to the 0 1 0 2 from now on) to then take each word out of the dictionary and reconstruct the sentence, so if a 0 came up, it would look into the dictionary and then find what has a 0 definition, then pull that out to put into the string, so it would find hi and take that.\nI hope that this is understandable and that at least one person knows how to do it, because I am sure it is possible, however I have been unable to find anything here or on the internet mentioning this subject.","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":37753680,"Users Score":0,"Answer":"TheLazyScripter gave a nice workaround solution for the problem, but the runtime characteristics are not good because for each reconstructed word you have to loop through the whole dict. \nI would say you chose the wrong dict design: To be efficient, lookup should be done in one step, so you should have the numbers as keys and the words as items. \nSince your problem looks like a great computer science homework (I'll consider it for my students ;-) ), I'll just give you a sketch for the solution:\n\nuse word in my_dict.values() #(adapt for py2\/py3) to test whether the word is already in the dictionary. \nIf no, insert the next available index as key and the word as value.   \nyou are done. \nFor reconstructing the sentence, just \n\n\nloop through your list of numbers\nuse the number as key in your dict and print(my_dict[key])\n\nPrepare exception handling for the case a key is not in the dict (which should not happen if you are controlling the whole process, but it's good practice).\n\nThis solution is much more efficient then your approach (and easier to implement).","Q_Score":0,"Tags":"python,dictionary","A_Id":37771544,"CreationDate":"2016-06-10T17:05:00.000","Title":"How to take a word from a dictionary by its definition","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get \n\nRequirement already satisfied (use --upgrade to upgrade): scrapy in \/system\/linux\/lib\/python2.7\/dist-packages\n\nWhen I try to run scrapy from the command, with scrapy crawl ... for example, I get. \n\nThe program 'scrapy' is currently not installed.\n\nWhat's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":24069,"Q_Id":37757233,"Users Score":0,"Answer":"make sure you activate command that is\n\"Scripts\\activate.bat\"","Q_Score":6,"Tags":"python,scrapy","A_Id":63207972,"CreationDate":"2016-06-10T21:12:00.000","Title":"Scrapy installed, but won't run from the command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get \n\nRequirement already satisfied (use --upgrade to upgrade): scrapy in \/system\/linux\/lib\/python2.7\/dist-packages\n\nWhen I try to run scrapy from the command, with scrapy crawl ... for example, I get. \n\nThe program 'scrapy' is currently not installed.\n\nWhat's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","AnswerCount":9,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":24069,"Q_Id":37757233,"Users Score":7,"Answer":"I tried the following sudo pip install scrapy , however was promtly advised by Ubuntu 16.04 that it was already installed.\nI had to first use sudo pip uninstall scrapy, then sudo pip install scrapy for it to successfully install.\nNow you should successfully be able to run scrapy.","Q_Score":6,"Tags":"python,scrapy","A_Id":40753182,"CreationDate":"2016-06-10T21:12:00.000","Title":"Scrapy installed, but won't run from the command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get \n\nRequirement already satisfied (use --upgrade to upgrade): scrapy in \/system\/linux\/lib\/python2.7\/dist-packages\n\nWhen I try to run scrapy from the command, with scrapy crawl ... for example, I get. \n\nThe program 'scrapy' is currently not installed.\n\nWhat's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","AnswerCount":9,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":24069,"Q_Id":37757233,"Users Score":3,"Answer":"I faced the same problem and solved using following method. I think scrapy is not usable by the current user.\n\nUninstall scrapy.\nsudo pip uninstall scrapy\nInstall scrapy again using -H.\nsudo -H pip install scrapy\nShould work properly.","Q_Score":6,"Tags":"python,scrapy","A_Id":60684096,"CreationDate":"2016-06-10T21:12:00.000","Title":"Scrapy installed, but won't run from the command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get \n\nRequirement already satisfied (use --upgrade to upgrade): scrapy in \/system\/linux\/lib\/python2.7\/dist-packages\n\nWhen I try to run scrapy from the command, with scrapy crawl ... for example, I get. \n\nThe program 'scrapy' is currently not installed.\n\nWhat's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","AnswerCount":9,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":24069,"Q_Id":37757233,"Users Score":16,"Answer":"I had the same error. Running scrapy in a virtual environment solved it.\n\nCreate a virtual env : python3 -m venv env\nActivate your env : source env\/bin\/activate\nInstall Scrapy with pip : pip install scrapy\nStart your crawler : scrapy crawl your_project_name_here\n\nFor example my project name was kitten, I just did the following in step 4\nscrapy crawl kitten\nNOTE: I did this on Mac OS running Python 3+","Q_Score":6,"Tags":"python,scrapy","A_Id":55285170,"CreationDate":"2016-06-10T21:12:00.000","Title":"Scrapy installed, but won't run from the command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get \n\nRequirement already satisfied (use --upgrade to upgrade): scrapy in \/system\/linux\/lib\/python2.7\/dist-packages\n\nWhen I try to run scrapy from the command, with scrapy crawl ... for example, I get. \n\nThe program 'scrapy' is currently not installed.\n\nWhat's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","AnswerCount":9,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":24069,"Q_Id":37757233,"Users Score":0,"Answer":"I had the same issue. sudo pip install scrapy fixed my problem, although I don't know why must use sudo.","Q_Score":6,"Tags":"python,scrapy","A_Id":37914201,"CreationDate":"2016-06-10T21:12:00.000","Title":"Scrapy installed, but won't run from the command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been working on machine learning KNN (K Nearest Neighbors) algorithm with Python and Python's Scikit-learn machine learning API.\nI have created sample code with toy dataset simply using python and Scikit-learn and my KNN is working fine. But As we know Scikit-learn API is build to work on single machine and hence once I will replace my toy data with millions of dataset it will decrease my output performance.\nI have searched for many options, help and code examples, which will distribute my machine learning processing parallel using spark with Scikit-learn API, but I was not found any proper solution and examples.\nCan you please let me know how can I achieve and increase my performance with Apache Spark and Scikit-learn API's K Nearest Neighbors?    \nThanks in advance!!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5059,"Q_Id":37767790,"Users Score":1,"Answer":"Well according to discussions https:\/\/issues.apache.org\/jira\/browse\/SPARK-2336 here MLLib (Machine Learning Library for Apache Spark) does not have an implementation of KNN. \nYou could try https:\/\/github.com\/saurfang\/spark-knn.","Q_Score":1,"Tags":"python,scala,apache-spark,machine-learning,scikit-learn","A_Id":37768933,"CreationDate":"2016-06-11T19:33:00.000","Title":"Scikit-learn KNN(K Nearest Neighbors ) parallelize using Apache Spark","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Wizard of Oz experiment using Choregraphe to make a NAO perform certain tasks running on machine A. The participant interacting with the NAO also interacts with a machine B. When I start the experiment (in Choregraphe on machine A) I want a certain MATLAB script to start on machine B. I.e. Choregraphe will initiate the MATLAB script.\nDo you have any suggestions of how to do this? My programming are limited to that of MATLAB and R, while Choregraphe is well integrated with Python and C++ hence my question here on Stack.\nKind Regards,\nKD","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":37785380,"Users Score":0,"Answer":"Using NAO C++ SDK, it may be possible to make a MEX-FILE in Matlab that \"listens\" to NAO. Then NAO just has to raise an event in its memory (ALMemory) that Matlab would catch to start running the script.","Q_Score":0,"Tags":"python,c++,matlab,nao-robot","A_Id":37796440,"CreationDate":"2016-06-13T08:50:00.000","Title":"Sync Choregraphe and Matlab","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to download the package xlwt to my Python 3.5.1 but typing 'pip install xlwt' isn't working and gives me an error at the word install that says invalid syntax, though all the websites I've checked told me to do exactly this.\nI mostly have a theoretical knowledge of Python and can code pretty decently, but don't really know how to set the technology up in order to do the actual coding. \nAny help would be appreciated!!!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1235,"Q_Id":37798552,"Users Score":0,"Answer":"Sounds like you are typing pip install ... into a Python prompt and not a shell command prompt. This is not a Python statement but a shell command that has to be executed at the command-line prompt.","Q_Score":0,"Tags":"python,python-3.5,xlwt","A_Id":37798884,"CreationDate":"2016-06-13T20:27:00.000","Title":"Downloading xlwt to Python 3.5.1","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am looking to ingest and write Avro files in GCS with the Python SDK. Is this currently possible with Avro leveraging the Python SDK? If so how would I do this? I see TODO comments in the source regarding this so I am not too optimistic.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":761,"Q_Id":37799065,"Users Score":0,"Answer":"You are correct: the Python SDK does not yet support this, but it will soon.","Q_Score":1,"Tags":"python,avro,google-cloud-dataflow","A_Id":37866731,"CreationDate":"2016-06-13T21:03:00.000","Title":"Dataflow Python SDK Avro Source\/Sync","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I load and execute a cmm script inside trace32 application using bmm commands.\nwhen the execution is over i need to close the entire t32 application window itself (similar to File -> Exit) using cmm command ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":993,"Q_Id":37830836,"Users Score":3,"Answer":"To close the PowerView main window use TRACE32 command QUIT","Q_Score":2,"Tags":"python,command,exit,trace32","A_Id":37845692,"CreationDate":"2016-06-15T09:03:00.000","Title":"how to close trace 32 application itself through cmm command?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"does anybody knows how to open a filedialog on Odoo? I've add a button on a custom view, now I would like to browse for a file on THE CLIENT when this button is clicked.\nAny ideas?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":108,"Q_Id":37836077,"Users Score":1,"Answer":"You can define binary fields in Odoo, like other fields. Look into ir.attachment model definition and its view definitions to get a good hint, how do it for such fields.","Q_Score":1,"Tags":"python,openerp,fileopendialog","A_Id":37839268,"CreationDate":"2016-06-15T12:53:00.000","Title":"Odoo python fileopendialog","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a queryset from Picture.objects.filter(user_ID=user). The Picture model has \"contest_ID\" as a foreign key. \nI'm looking to get a queryset of Contests which have Pictures, so from the queryset I already have, how do I pull a list of Contest objects?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":37845389,"Users Score":0,"Answer":"I assume that your models look something like this\n\nclass Contest(Model):\n    ... something ...\n\nclass Picture(Model):\n    user = ForeignKey(User)\n    contest = ForeignKey(Contest)\n    ... something ...\n\nSo, Picture.objects.filter(user=user) gives you pictures by a particular user (don't have to specify _id, filters operate on model objects just fine). And to get contests with pictures by a particular user you can do \n\npics_by_user = Picture.objects.filter(user=user)\ncontests_by_user = Contest.objects.filter(id__in=pics_by_user.values_list('contest', flat=True))\n\nThere might be an easier way though","Q_Score":1,"Tags":"python,django,python-3.x","A_Id":37845897,"CreationDate":"2016-06-15T20:42:00.000","Title":"Get a queryset from a queryset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I create a signup page in odoo website. The auth_signup module seems to do the job (according to their description). I don't know how to utilize it.\n\nIn the signup page there shouldn't be database selector\nWhere should I store the user data(including password); res.users or res.partner","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1173,"Q_Id":37850154,"Users Score":1,"Answer":"User Signup is a standard feature provided by Odoo, and it seems that you already found it.\nThe database selector shows because you have several PostgresSSQL databases.\nThe easiest way is to set a filter that limits it to the one you want:\nstart the server with the option --dbfilter=^MYDB$, where MYDBis the database name.\nUser data is stored both in res.userand res.partner: the user specific data, such as login and password, are stored in res.user. Other data, such as the Name is stored in a related res.partner record.","Q_Score":0,"Tags":"python-2.7,openerp,odoo-9","A_Id":37852231,"CreationDate":"2016-06-16T04:55:00.000","Title":"Odoo website, Creating a signup page for external users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I create a signup page in odoo website. The auth_signup module seems to do the job (according to their description). I don't know how to utilize it.\n\nIn the signup page there shouldn't be database selector\nWhere should I store the user data(including password); res.users or res.partner","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1173,"Q_Id":37850154,"Users Score":2,"Answer":"you can turn off db listing w\/ some params in in odoo.cfg conf\n\ndb_name = mydb\nlist_db = False\ndbfilter = mydb\n\nauth_signup takes care of the registration, you don't need to do anything. A res.user will be created as well as a partner related to it.\nThe pwd is stored in the user.","Q_Score":0,"Tags":"python-2.7,openerp,odoo-9","A_Id":37852264,"CreationDate":"2016-06-16T04:55:00.000","Title":"Odoo website, Creating a signup page for external users","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"These two look like they should be very much equivalent and therefore what works for one should work for the other? So why does accumulate only work for maximum but not argmax?\nEDIT: A natural follow-up question is then how does one go about creating an efficient argmax accumulate in the most pythonic\/numpy-esque way?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1719,"Q_Id":37855059,"Users Score":4,"Answer":"Because max is associative, but argmax is not:\n\nmax(a, max(b, c)) == max(max(a, b), c)\nargmax(a, argmax(b, c)) != argmax(argmax(a, b), c)","Q_Score":3,"Tags":"python,numpy,numpy-ufunc","A_Id":37855371,"CreationDate":"2016-06-16T09:24:00.000","Title":"Why does accumulate work for numpy.maximum but not numpy.argmax","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I setuup Project Interpreter pointing virtualenv on vagrant virtual machine (Settings \/ Project Interpreter \/ Add Remote), but when I click ctrl+B or use 'go to definition' I always end up in location like this: \/home\/<my_user_name>\/.PyCharm50\/system\/remote_sources\/1174787026\/154306353\/django\/...\nhow to avoid such pycharm behaviour? How to force it to use virtualenvs code when go to declaration?\nUsing Pycharm 5.0 on Ubuntu 14.04\nUPDATE: with pycharm 2017.2.* it works now good!","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":458,"Q_Id":37877325,"Users Score":5,"Answer":"I also had this issue setting up a remote interpreter with Vagrant.\nIt appears that for a remote interpreter you need to mark Python source root folders as \"Source Folders\" under Project Structure in Preferences. They should then show up as blue in your Project browser. You don't need to mark all the sub folders, just the root folder for each python project\/package.\nWithout doing this it seems like Pycharm can't find the source files and takes you to the readonly cached code derived from the remote interpreter environment.","Q_Score":6,"Tags":"python,ubuntu,vagrant,pycharm,virtualenv","A_Id":39578272,"CreationDate":"2016-06-17T09:00:00.000","Title":"pycharm not using virtualenv from vagrant box when 'go to declaration' instead uses some outdated stuff from its remote_sources","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question, I have been given x,y,z coordinate values at cell centers of a grid. I would like to create structured grid using these cell center coordinates. \nAny ideas how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":425,"Q_Id":37879558,"Users Score":1,"Answer":"If you grid is regular:\n\nYou have calculate dx = x[i+1]-x[i], dy = y[i+1]-y[i], dz = z[i+1]-z[i].\nThen calculate new arrays of points:\nx1[i] = x[i]-dx\/2, y1[i] = y[i]-dy\/2, z1[i] = z[i]-dz\/2.\n\nIf mesh is irregular you have to do the same but dx,dy,dz you have to define for every grid cell.","Q_Score":1,"Tags":"python,numpy,scipy","A_Id":37879801,"CreationDate":"2016-06-17T10:42:00.000","Title":"Creating a 3D grid using X,Y,Z coordinates at cell centers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I've been doing a lot of work with Tweepy and Twitter data mining, and one of the things I want to do is to be able to get all Tweets that are replies to a particular Tweet. I've seen the Search api, but I'm not sure how to use it nor how to search specifically for Tweets in reply to a specific Tweet. Anyone have any ideas? Thanks all.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3634,"Q_Id":37897064,"Users Score":0,"Answer":"I've created a workaround that kind of works. The best way to do it is to search for mentions of a user, then filter those mentions by in_reply_to_id .","Q_Score":2,"Tags":"python,search,twitter,tweepy","A_Id":37902045,"CreationDate":"2016-06-18T12:39:00.000","Title":"Tweepy Get Tweets in reply to a particular tweet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just installed Anaconda on my computer because I need to use Numpy.\nWell, when I use python I for some reason have to be in the same folder as python.exe and, of course, now that I want to use Anaconda I have to be in the Anaconda3\\Scripts folder where python.exe isn't. This is a nightmare, how can I use anaconda with python on a windows computer? Why does it have to be so complicated?","AnswerCount":3,"Available Count":1,"Score":0.2605204458,"is_accepted":false,"ViewCount":35921,"Q_Id":37918215,"Users Score":4,"Answer":"I think you are referring to the command-line use of python?\nIf you have admin priviliges on your machine you can add python to your environment variables, making it available in the console anywhere. (Sorry for different spellings, I am not on an english machine)\n\nPress Shift+Pause (\"System\")\nClick \"Advanced System Options\"\nClick \"Environment variables\"\nIn the lower field with \"System variables\" there is a variable called PATH. Append the complete path to your python.exe  without the file to that by adding a ; behind the last path in the variable and then adding your path. Do not add any spaces!\n\nExample: C:\\examplepath\\;C:\\Python27\\","Q_Score":9,"Tags":"python,windows,numpy,cmd,anaconda","A_Id":37918313,"CreationDate":"2016-06-20T08:51:00.000","Title":"Using python with Anaconda in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Not sure how to describe this but I am running a Scrapy spider on a Digital Ocean server ($5 server), the Scrapy project is deployed as a Dokku app.\nHowever, it runs very slowly compared to the speed on my local computer and on a Heroku free tier dyno. On Dokku it crawls at a speed of 30 pages per minute while locally and on Heroku the speed is 200+ pages per minutes.\nI do not know how to debug, analyze or where to start in order to fix the problem. Any help, clues or tips on how to solve this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":430,"Q_Id":37925504,"Users Score":1,"Answer":"I 'fixed' this issue by not using a Digital Ocean server. The website that I am trying to crawl, which is craigslist.org, just did not respond well to a DO server. It takes a long time to respond to a request. Other websites like Google or Amazon work just fine with DO.\nMy scraper works just fine on craigslist when using a VPS from another provider.","Q_Score":0,"Tags":"python,heroku,scrapy,digital-ocean,dokku","A_Id":37969257,"CreationDate":"2016-06-20T14:48:00.000","Title":"Running Scrapy on Dokku using a Digital Ocean server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do I update an inverted index efficiently if documents are inserted, deleted or updated ? also should i use index file to store index or should I store index in a database table ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":551,"Q_Id":37937313,"Users Score":1,"Answer":"Python does allow you to constrcut classes that implement dictionary-like interface and thatc ould maintain any inverted indexes you would wish - \nBut you are too broad on your question. The \"extradict\" Python package (pip install extradict), for example have a \"BijectiveDict\" that just exposes any values as keys and vice-versa, and keep everything synchronize - but it is a simple symmetric key, value store.\nIf you want complex, nested documents, and persistence you should use an existing NoSQL database like MongoDB, Codernity,  ElasticSearch, ZODB, rather than try to implement one yourself.","Q_Score":0,"Tags":"python-3.x,inverted-index","A_Id":37945993,"CreationDate":"2016-06-21T06:47:00.000","Title":"how to make inverted index?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Ive been using Jedit for programming for a few days and I wonder how I can change the tab indent in Jedit. Or can I change the Indent for whole Linux? My second question: I use Python and I would like to have an Indent in the next line after colons. where are the settings for this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":137,"Q_Id":37954211,"Users Score":0,"Answer":"Indentation can be configured by navigating to Utilities > Global Options > Editing > Tab width. You said you are coding in python so I strongly recommend that you leave the indentation as it is as python only accepts indentation with standard tabs (4 spaces long).\nObs: I see no reason why you would use Jedit, you'd better use a decent editor like Atom or Sublime Text.","Q_Score":0,"Tags":"python,linux,python-3.x","A_Id":37954337,"CreationDate":"2016-06-21T20:42:00.000","Title":"Tab indent in Linux and Jedit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning Python 3 (my first language since BASIC), and I have a general question:\nIf I want to iterate over something, how do I determine if the best way is to use a For loop or a generator? They appear to be closely related.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":128,"Q_Id":37955249,"Users Score":2,"Answer":"Use a for-loop if you can. It's simple, and it uses iterators behind the scenes. One of the great things about python's iterator system is that you don't need to think about them most of the time. It is quite rare that you'll need to explicitly call next() on something.\nThis is kind of general, but so is your question. If you have a particular use case in mind, edit your question to add it and you'll get more detailed responses.","Q_Score":0,"Tags":"python","A_Id":37955310,"CreationDate":"2016-06-21T21:55:00.000","Title":"Python 3 For loop vs next() iterator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a script using Python that will access all students' Google calendars using their Google accounts and then add their school schedule into their calendar. I have figured out adding and deleting events and calendars using the API, but my question is how do I add a specific event to a specific calendar under a domain. I am a domain admin.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":71,"Q_Id":37977358,"Users Score":0,"Answer":"Solved:\nThe issue was that my client_secrets.json file for oauth 2.0 was set to my personal google account and not the admin account. I cleared the storage.json file where credentials were stored, re ran the program with the admin account logged in, and it worked! Hoped this helps.","Q_Score":0,"Tags":"python,calendar,google-api,google-admin-sdk","A_Id":38876630,"CreationDate":"2016-06-22T20:09:00.000","Title":"Google API Domain Admin Access","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In IDLE Python if I do print \"a\\tb\"  I get an output that looks like: a[TAB]b.\nIf I do the same in IPython in Spyder, then I get an output that looks like: a[7 spaces]b\nI like to output tables of data as tab delimited text to make it easier to copy from the console and paste it to Excel. If the tabs get converted to spaces it becomes more difficult. \nIs there any setting within IPython or Spyder which controls how TAB characters are displayed? I am using Spyder+IPython on a Windows 10 desktop. I realized I could just write the data to a file, but in this case it is more convenient to just use the console and the clipboard.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":793,"Q_Id":37980943,"Users Score":0,"Answer":"(Spyder maintainer here) For the record, this problem was solved in our 4.1.0 version, released in March 2020.","Q_Score":4,"Tags":"python,excel,ipython,spyder,copy-paste","A_Id":70369693,"CreationDate":"2016-06-23T01:41:00.000","Title":"How to prevent tab characters from being converted to spaces in console output when using IPython in Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Ubuntu 14.04 LTS. I guess different versions of python are pre-installed in Ubuntu 14.04. Right now when I type 'python' in terminal it opens python 2.7.11, but I guess the default version of Ubuntu 14.04 is 2.7.6. When I type \/usr\/bin\/python it opens the default version. I know this can be done with making aliases. The real problem is, I have installed pygame, cv2 (that is for image processing) using apt-get. These are installed for default version of python i.e python 2.7.6. Also I have installed anaconda with python 2.7.11 using pip, but again 'pip' and anaconda are installed for 2.7.11. I know python 3 is also pre-installed there but I don't use it. Also I have no python version installed in user\/local\/bin.Now I want to know why this problem is occurring? How can I fix this now? Also how to import all the libraries for one python version(either default or another) and how to use it? How to configure my settings so that I would not have any problem in future?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":38018045,"Users Score":0,"Answer":"First of all I want to thanks Bennet for responding to my question so that I was able to figure out what the problem was. Actually the problem was with aliasing. When I installed cv2 or pygame using apt-get, they were installed for default version but when I installed any package by downloading the installer first (like I installed anaconda), it was installed for python 2.7.11 because 'python' was aliased for this version(that is 2.7.11). So, basically make sure that the default version for which you want to install everything is the one which is aliased as 'python', and everything goes fine. I aliased 'python' for the default version and then installed anaconda via installer and now it has been installed default version.","Q_Score":0,"Tags":"python,pygame,ubuntu-14.04","A_Id":38035454,"CreationDate":"2016-06-24T16:26:00.000","Title":"How to install pygame, cv2, anaconda, pip etc to any one version of python in ubuntu 14.04","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use AWS Lambda to transfer data from my S3 bucket to Couchbase server, and I'm writing in Python. So I need to import couchbase module in my Python script. Usually if there are external modules used in the script, I need to pip install those modules locally and zip the modules and script together, then upload to Lambda. But this doesn't work this time. The reason is the Python client of couchbase works with the c client of couchbase: libcouchbase. So I'm not clear what I should do. When I simply add in the c client package (with that said, I have 6 package folders in my deployment package, the first 5 are the ones installed when I run \"pip install couchbase\": couchbase, acouchbase, gcouchbase, txcouchbase, couchbase-2.1.0.dist-info; and the last one is the c client of Couchbase I installed: libcouchbase), lambda doesn't work and said:\n\"Unable to import module 'lambda_function': libcouchbase.so.2: cannot open shared object file: No such file or directory\" \nAny idea on how I can get the this work? With a lot of thanks.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":348,"Q_Id":38031729,"Users Score":3,"Answer":"Following two things worked for me:\n\nManually copy \/usr\/lib64\/libcouchbase.so.2 into ur project folder\nand zip it with your code before uploading to AWS Lambda.\nUse Python 2.7 as runtime on the AWS Lambda console  to connect to couchbase.\n\nThanks !","Q_Score":6,"Tags":"python,couchbase,aws-lambda","A_Id":54285148,"CreationDate":"2016-06-25T18:34:00.000","Title":"How to create AWS Lambda deployment package that uses Couchbase Python client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using REPL extension for Sublime text 3 for my python projects. Currently when I want to interrupt a running script I have to close to close the REPL window to stop execution and all computations are so far are lost. \nI was wondering if anybody knows how to interrupt an execution and have a short cut or key bindings for that","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1773,"Q_Id":38043336,"Users Score":0,"Answer":"As mentioned above (a long time ago) the key bindings aren't present for Windows. However, one can Mouse Right Click to open a context menu. From here there are menu options for Kill and Restart. You can also open a sub-menu which allows you send those and other signals including SIGINT.","Q_Score":3,"Tags":"python,sublimetext3,sublimerepl","A_Id":53070278,"CreationDate":"2016-06-26T21:25:00.000","Title":"Key bindings for interrupt execution in Python Sublime REPL","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to pythonanywhere. I wonder how to load data from local csv files (there are many of them, over 1,000) into a mysql table. Let's say the path for the folder of the csv files is d:\/data. How can I write let pythonanywhere visit the local files? Thank you very much!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1111,"Q_Id":38045616,"Users Score":2,"Answer":"You cannot get PythonAnywhere to read the files directly off your machine. At the very least, you need to upload the file to PythonAnywhere first. You can do that from the Files tab. Then the link that Rptk99 provided will show you how to import the file into MySQL.","Q_Score":2,"Tags":"database,python-2.7,pythonanywhere","A_Id":38056627,"CreationDate":"2016-06-27T03:46:00.000","Title":"Pythonanywhere Loading data from local files","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I've been trying to iterate through a bytearray, add up all the bytes and then append the result back into the same bytearray. The bytearray looks like this: \nkey = bytearray([0x12, 0x10, 0x32])\nHowever, when I call sum(key) I get the decimal representation of 84. Any idea how I can change the decimal representation and put it back into a hexadecimal format while keeping it of type int. Thank You","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1227,"Q_Id":38056711,"Users Score":1,"Answer":"A bytearray is always a list of integers. How they are displayed is only their representation. The same applies to the way you entered them. Python understand the 0x?? (hexadicimal) and 0?? (octal) notation for integers but it will display the decimal notation.\nTo convert an integer to a string in the 0x?? format use hex(value).","Q_Score":1,"Tags":"python,binary,hex,byte,bytearray","A_Id":38056839,"CreationDate":"2016-06-27T14:34:00.000","Title":"Adding bytes in python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have found a number of answers in pulling information from HIDs in Linux, but not many in Windows.\nI have created a system where a person can scan an ID badge when entering a briefing that logs their attendance into a database.  It utilizes a Python 3.4 front end which queries and then updates a MongoDB database.\nCurrently, I have a USB Barcode Scanner which, when scanning, acts as a keyboard and \"types\" what the barcode says, followed by a CR.  I also have a window which takes the text input and then closes the window and executes a database query and update when the CR is received.\nThe current issue is speed.  I have been asked to expand the system so that one computer with a USB hub can take 4-8 of these Barcode Scanners at the same time, attempting to increase scanning rate to 1000 people every 5 minutes.\nWhat I am afraid will happen is that if two scans happen at almost the same time, then their inputs will overlap, generating an invalid query and resulting in both individuals not being logged.\nAs far as I can understand, I need to place each Scanner in its own thread to prevent overlapping data, and I do not want to \"lock\" input from the other scanners when the system detects a scan beginning as this system is all about speed.  However, I am unsure of how to differentiate the devices and how to implement the system.\nAny solutions would be appreciated!  Please take note that I am unfamiliar with HID use in this sense, and only have a basic background in multi-threading.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":180,"Q_Id":38066526,"Users Score":0,"Answer":"In this scenario I will suggest using scanners\/readers that can emulate serial (COM) port. As HID device writes to same bus then there is a huge probability that output from two or more devices could by mixed-up.\nMore over I will add a device id string to a prefix like dev01. Binding to a com port can be used by pySerial module.\nAny comments welcome!","Q_Score":0,"Tags":"python,mongodb,windows-7,barcode-scanner,hid","A_Id":38120429,"CreationDate":"2016-06-28T03:21:00.000","Title":"Sorting Input from Multiple HIDs in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been trying\/looking to solve this problem for a long while.\nI have read the documentation for gspread and I cannot find that there is a way to rename a worksheet.\nAny of you know how to? I would massively appreciate it!\nThere is indeed worksheet.title which gives the name of the worksheet, but I cannot find a way to rename the actual sheet.\nThank you in advance!","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":13927,"Q_Id":38074069,"Users Score":0,"Answer":"For those whose solving this renaming using NodeJS. Just use the batchRequest API. Indicate in the sheetID the sheet id youre editing and the title field the new title. Then indicate \"title\" in the fields.","Q_Score":30,"Tags":"python,google-sheets,google-api,google-sheets-api,google-api-python-client","A_Id":61849385,"CreationDate":"2016-06-28T10:45:00.000","Title":"How do I rename a (work)sheet in a Google Sheets spreadsheet using the API in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running Python 3.5.1 on a Windows 7 machine. I've been using Anaconda without issue for several months now. This morning, I updated my packages (conda update --all) and now I can't import numpy (version 1.11.0) or pandas(version 0.18.1).\nThe error I get from Python is:\nSyntax Error: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \\UXXXXXXXX escape. This error occurs when the import statement is executed.\nI'm able to import other packages, some from anaconda's bundle and some from other sources without issue.\nAny thoughts on how to resolve this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":604,"Q_Id":38083176,"Users Score":0,"Answer":"I was able to resolve this issue using conda to remove and reinstall the packages that were failing to import. I will leave the question marked unanswered to see if anyone else has a better solution, or guidance on how to prevent this in the future.","Q_Score":2,"Tags":"python,numpy,pandas,anaconda","A_Id":38084884,"CreationDate":"2016-06-28T17:58:00.000","Title":"Python 3.5.1 Unable to import numpy after update","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"As title,\nBuild successful, but the exe can't run. can not found msvcr100.dll.\nI can put msvcr100.dll with exe in the same dir, the exe can run.\nBut I just want only one exe file.\nAnyone know how to do?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1132,"Q_Id":38089277,"Users Score":2,"Answer":"Has solved.  This is a bug of pyinstaller3.2, the new in the git has solved this bug. Down the newest source in the github, erverything works fine.","Q_Score":1,"Tags":"python-2.7,pyqt4,pyinstaller","A_Id":38112580,"CreationDate":"2016-06-29T02:19:00.000","Title":"pyinstaller 3.2 build pyqt4\/python2.7 to onefile exe, can not run missing msvcr100.dll?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As title,\nBuild successful, but the exe can't run. can not found msvcr100.dll.\nI can put msvcr100.dll with exe in the same dir, the exe can run.\nBut I just want only one exe file.\nAnyone know how to do?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1132,"Q_Id":38089277,"Users Score":2,"Answer":"Has solved. This is a bug of pyinstaller3.2, the new one in the git has solved this bug. Down the newest source in the GitHub, everything works fine.\n\nThis is correct, I cant tell you how much that answer helped me out. I have been trying to build a single exe Exploit to execute on Windows XP with-out it crashing for my OSCP Labs\/Exam. I followed so many tutorials and nothing seems to work. I was able to build the EXE but could not get it to run under a single EXE.\nIf anyone who reads this is getting \"This Program cannot be run in DOS mode\" try running it from another machine with the same build (Windows XP). There is not much info out there on how to solve that from a Reverse Shell on a End Of Life Operating System using an EXE exploit built with Pyinstaller. (Lots of Trial and Error and determination)\n\nMicrosoft Visual C++ 2008 Redistributable Package (or some other version depending on python version) is needed in any case, python27.dll requires it\n\nI was also receiving an error about msvcr100.dll when ran from the GUI on my build machine(WinXP SP2). This is corrected in the 3.3 Dev version on GitHub.\nI installed the C++ 2008 Package but this didn't solve my problem when I re-built the EXE, the 3.3 Dev Pyinstaller was the solution.\nWhat I did was:\nZip down the Dev version of Pyinstaller 3.3 Dev(GitHub) is the newest for 11\/14\/16 that I could tell. Make sure you have Python 2.7.x (I used 2.7.11) and pywin32 installed that matches (Python 2.7.x) version. (And it does matter if its 64-bit or 32-bit) Use the setup.py to install Pyinstaller, make sure you do not have a previous version already installed, if so use pip or etc. to remove. I installed with pip first and this was my whole issue.\nI was able to get all of my 32-bit Single EXE Exploits to run on 64-bit\/32-bit Windows machines up to Windows 10.\nOnce that is completed, make sure Pyinstaller is in your $PATH and follow the standard tutorials on creating a --onefile EXE. Copy to your Windows Target machine and it should work with-out error. I did not need to pull any dependencies over but you may have to include some with the --hidden command. Its greatly detailed in the Pyinstaller documentation on how to include hidden .dlls\nIf this still doesn't work for you try using py2exe. Its a little more complicated but it your determined you will figure it out.\nIf you have code written in python 2.x.x and 3.x.x you can have multiple environments of Python and have Pyinstaller installed in each. This is in the documentation as well.\nThank you jim ying. Your 2 sentence answer was exactly what I needed.","Q_Score":1,"Tags":"python-2.7,pyqt4,pyinstaller","A_Id":40601355,"CreationDate":"2016-06-29T02:19:00.000","Title":"pyinstaller 3.2 build pyqt4\/python2.7 to onefile exe, can not run missing msvcr100.dll?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm now practicing with Gtk by developing a file manager application similar to Thunar, and I simply can't figure out how to make the IconView items flow vertically instead of horizontally, like in Thunar or Nautilus' Compact View mode, as well as in Windows Explorer's List View Mode. Should I use TreeView istead?\nI'm practicing in Haskell bindings, the Gtk2Hs, but I'm also familiar with native C library and Python bindings (PyGtk), so explanations using these languages are also acceptable.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":113,"Q_Id":38103354,"Users Score":0,"Answer":"It finally seems that IconView has not such a feature right now, as Thunar uses its own control from libexo, while Caja\/Nautilus use their own controls from other libraries.","Q_Score":1,"Tags":"python,listview,gtk,pygtk,gtk2hs","A_Id":40487030,"CreationDate":"2016-06-29T15:01:00.000","Title":"How to make GtkListView items flow from top to bottom, like in Thunar or Nautilus Compact View Mode?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to make a browser with Python GTK and Webkit for education purposes. I have GTK and it works, but I can't find how to get webkit for Mac OS X. I tried brew, pip3, easy_install. And I'm not sure if PyQT webkit port is the same as webkit.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2977,"Q_Id":38120223,"Users Score":0,"Answer":"For GTK3\nbrew install pygobject3\nOtherwise\nbrew install pygobject","Q_Score":3,"Tags":"linux,macos,python-3.x,webkit,gtk","A_Id":48846011,"CreationDate":"2016-06-30T10:17:00.000","Title":"How to get Webkit for Mac OS X","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was trying to install Airflow in windows through command prompt using pip. \nThe python is 3.4.2, pip included. I am getting the below error.\ndistutils.errors.DistutilsError: Setup script exited with error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).\nI have installed Visual studio 2012 but Python 3.4 looks for VS10 by default. I tried to trick Python to use the newer visual studio by \n\nExecuting the command set VS100COMNTOOLS=%VS110COMNTOOLS%. \nAdding new system variable VS100COMNTOOLS as variable name and gave the value as VS110COMNTOOLS.\n\nBoth tricks did not work. I am still getting the same old error. \nThe file vcvarsall.bat is present in C:\\Program Files\\Microsoft Visual Studio 11.0\\VC\nwhat is missing here? how can I get rid of this error?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":689,"Q_Id":38130483,"Users Score":0,"Answer":"Instead of setting VS100COMNTOOLS=%VS110COMNTOOLS% in cmd, i did\nSET VS100COMNTOOLS=C:\\Program Files\\Microsoft Visual Studio 11.0\\Common7\\Tools\\ and it was picking correctly but again thrown another pile of errors as VS11 compiler is different and cannot compile Python 3.4 code properly.\nI uninstalled VS11, Installed VS10 and it worked.","Q_Score":0,"Tags":"python,visual-studio,visual-c++,pip,setup.py","A_Id":38182957,"CreationDate":"2016-06-30T18:12:00.000","Title":"Error while installing Airflow using pip in windows- Unable to find vcvarsall.bat","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a diameter packet capture pcap file (using tcpdump) containing some AVPs. I'd like to parse the pcap file and access\/retrieve the AVPs.\nI'm using python3.5.1. The dpkt library apparently supports diameter well but it's not yet available for python3. I tried converting it via 2to3-3.5 script but the conversion isn't full-proof and I'm hitting unicode errors while parsing the pcap.\nI am trying to use scapy now. I need some help\/examples in how to use scapy to:\n\nparse a pcap file\nretrieve\/parse AVPs from the pcap.\n\nAny help would be appreciated.\nRegards\nSharad","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1867,"Q_Id":38143219,"Users Score":0,"Answer":"I would suggest you to use tshark. Using tshark you can convert the pcap files to text files containing the AVPs that you are interested in. Once you have the text file, I believe it would be easy to extract the information using python.","Q_Score":2,"Tags":"python,python-3.x,scapy,diameter-protocol,dpkt","A_Id":40066101,"CreationDate":"2016-07-01T10:35:00.000","Title":"How to parse and retrieve diameter AVPs in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have been trying to connect to SQL Server (I have SQL Server 2014 installed on my machine and SQL Native Client 11.0 32bit as driver) using Python and specifically pyodbc but i did not manage to establish any connection. \nThis is the connection string i am using:\nconn = pyodbc.connect('''DRIVER={SQL Server Native Client 11.0}; SERVER=\/\/123.45.678.910; DATABASE=name_database;UID=blabla;PWD=password''') \nThe error message i am getting is this:\nError: ('08001', '[08001] [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [161].  (161) (SQLDriverConnect)')\nNow, is this caused by the fact that both Python (i have version 3.5.1) and pyodbc are 64bit while the SQL Driver is 32bit? \nIf yes, how do i go about solving this problem?\nHow do i adapt pyodbc to query a 32bit database?\nI am experiencing the same problem with Oracle database  OraCLient11g32_home1 \nFor your information, my machine runs Anaconda 2.5.0 (64-bit).\nAny help would be greatly appreciated.Thank you very much in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":228,"Q_Id":38145048,"Users Score":0,"Answer":"I may be missing something here.  Why don't you connect to your Oracle database as a SQL Server linked server (or the other way around) ?","Q_Score":0,"Tags":"python,sql-server,database,oracle,python-3.x","A_Id":38146099,"CreationDate":"2016-07-01T12:08:00.000","Title":"Database Connection SQL Server \/ Oracle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using a custom Django runserver command that is supposed to run a bunch of cleanup functions upon termination. This works fine as long as I don't use the autoreloader: by server catches the KeyboardInterrupt exception properly and exits gracefully.\nHowever, if I use Django's autoreloader, the reloader seems to simply kill the server thread without properly terminating it (as far as I can tell, it doesn't have any means to do this). \nThis seems inherently unsafe, so I can't really believe that there's not a better way of handling this. \nCan I somehow use the autoreloader functionality without having my server thread be killed uncleanly?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":150,"Q_Id":38160577,"Users Score":1,"Answer":"Try using the atexit module to catch the termination. It should work for everything which acts like SIGINT or SIGTERM, SIGKILL cannot be interrupted (but should not be sent by any auto-restart script without sending SIGTERM before).","Q_Score":0,"Tags":"python,django","A_Id":38171865,"CreationDate":"2016-07-02T13:15:00.000","Title":"Graceful exit server when using Django's autoreloader","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using Knime 3.1.2 on OSX and Linux for OPENMS analysis (Mass Spectrometry).\nCurrently, it uses static filename.mzML files manually put in a directory. It usually has more than one file pressed in at a time ('Input FileS' module not 'Input File' module) using a ZipLoopStart.\nI want these files to be downloaded dynamically and then pressed into the workflow...but I'm not sure the best way to do that. \nCurrently, I have a Python script that downloads .gz files (from AWS S3) and then unzips them. I already have variations that can unzip the files into memory using StringIO (and maybe pass them into the workflow from there as data??). \nIt can also download them to a directory...which maybe can them be used as the source? But I don't know how to tell the ZipLoop to wait and check the directory after the python script is run. \nI also could have the python script run as a separate entity (outside of knime) and then, once the directory is populated, call knime...HOWEVER there will always be a different number of files (maybe 1, maybe three)...and I don't know how to make the 'Input Files' knime node to handle an unknown number of input files. \nI hope this makes sense. \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1032,"Q_Id":38160597,"Users Score":1,"Answer":"There are multiple options to let things work:\n\nConvert the files in-memory to a Binary Object cells using Python, later you can use that in KNIME. (This one, I am not sure is supported, but as I remember it was demoed in one of the last KNIME gatherings.)\nSave the files to a temporary folder (Create Temp Dir) using Python and connect the Pyhon node using a flow variable connection to a file reader node in KNIME (which should work in a loop: List Files, check the Iterate List of Files metanode).\nMaybe there is already S3 Remote File Handling support in KNIME, so you can do the downloading, unzipping within KNIME. (Not that I know of, but it would be nice.)\n\nI would go with option 2, but I am not so familiar with Python, so for you, probably option 1 is the best. (In case option 3 is supported, that is the best in my opinion.)","Q_Score":1,"Tags":"python-2.7,file-io,knime","A_Id":38161395,"CreationDate":"2016-07-02T13:17:00.000","Title":"Python in Knime: Downloading files and dynamically pressing them into workflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a media player using vlc and python but it throws an Error which is No module named vlc. how to fix this?","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":30496,"Q_Id":38265773,"Users Score":4,"Answer":"I had a same issue. You should try sudo pip install python-vlc","Q_Score":7,"Tags":"python,vlc","A_Id":38265916,"CreationDate":"2016-07-08T11:43:00.000","Title":"Import Vlc module in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a media player using vlc and python but it throws an Error which is No module named vlc. how to fix this?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":30496,"Q_Id":38265773,"Users Score":0,"Answer":"The answer didn't work for me, using Mu 1.0.2 on a Raspberry Pi, this did however:\nsudo pip3 install vlc","Q_Score":7,"Tags":"python,vlc","A_Id":60589679,"CreationDate":"2016-07-08T11:43:00.000","Title":"Import Vlc module in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Qpython3 on my Android tablet. I have a Python script for a talking alarm clock that I would like to run in the background and then go off at the time the user sets. The problem is, once I set the console running in the background, I can't figure out how to get back to it to stop the script (i.e. get the message to stop repeating).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1123,"Q_Id":38278626,"Users Score":1,"Answer":"Open the \"qpython3\" app then touch \"Console\" and in the top left corner touch \"No. 1\" or \"No. 2\" or ... then select your background running scripts and by touching \"X\" sing you can kill them.","Q_Score":0,"Tags":"android,qpython,qpython3","A_Id":38304956,"CreationDate":"2016-07-09T05:16:00.000","Title":"How do I stop a script that is running in the background in Qpython3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any way I can use Django forms inside a ReactJS script, like include {{ form }} in the JSX file? \nI have a view which displays a from and it is rendered using React. When I load this page from one page the data in these fields should be empty, but when I hit this view from another page I want date to be prefilled in this form. I know how to do this using Django forms and form views, but I am clueless where to bring in React.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1649,"Q_Id":38280859,"Users Score":2,"Answer":"The {{ form }} statement is relative to Django template. Django templates responsible for rendering HTML and so do React, so you don't have to mix the two together.\nWhat you probably want to do is to use the Django form validation mechanism server side, let React render the form client-side. In your Django view, simply return a JSON object that you can use in your React code to initialize your form component.","Q_Score":4,"Tags":"python,reactjs,django-forms","A_Id":38281765,"CreationDate":"2016-07-09T10:30:00.000","Title":"Django forms in ReactJs","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make my stylesheets dynamic with django (jinja2) and I want to do something like this:\n <link rel=\"stylesheet\" href=\"{% static 'home\/css\/{{ block css }}{{ endblock }}.css' %}\">\nApparently, I can't use Jinja in Jinja :), and I don't know how to make this work another way.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1671,"Q_Id":38291388,"Users Score":2,"Answer":"I found a solution that works out pretty well.\nI use\n<link rel=\"stylesheet\" href=\"{% block css %}{% endblock %}\"> in the template\n and then: {% block css%}{% static 'home\/css\/file.css' %}{% endblock % in each page","Q_Score":2,"Tags":"python,html,django,dynamic,jinja2","A_Id":38301898,"CreationDate":"2016-07-10T11:29:00.000","Title":"Dynamic css import with Jinja2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After the installation of Kivy 1.9.1 on Windows using the commands of Kivy installation tutorials, I can't run the program using \"kivy ***.py\". I don't know how to set up the environment variables, and I can't find it on the official websites.\n\nKivy: 1.9.1\nPython: 3.4.4\nWindows 10\n\nPlease HELP!\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":662,"Q_Id":38301047,"Users Score":1,"Answer":"Make sure you're running the command from the folder where the *.py file is located, \"kivy *.py\" should run from there.","Q_Score":0,"Tags":"python,environment-variables,kivy","A_Id":38301272,"CreationDate":"2016-07-11T07:09:00.000","Title":"How to run kivy after 1.9.1 on windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I wanted to get some help with an application... Currently I have a script that saves certain information to a database table, well call this table \"x\". I have another script that gets and saves other info to a different database table, well call this one \"y\". I also have a script that runs formulas on the information found in table y and I have another script that opens the link found in table x and saves certain information into table \"z\".\nThe problem I have is that the first script doesn't end, and neither does the third script. So I know now that I need to have either threads or multiple processes running but which one do I choose? \nScript 1 accesses table W & X\nScript 2 accesses table X & Y\nScript 3 accesses table Y\nScript 4 accesses table Z\nCan you please give me some guidance on how to proceed?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":38317462,"Users Score":0,"Answer":"Based on Harp's second comment to his original post (which was posted after your answer), I suspect that you would now agree with me that processes are probably called-for here, based on this newly-supplied information.\nHowever, I find myself questioning just how much \"truly effective concurrency\" is likely to be found here. This sounds like a job to me: a \"script 1\" (with its sub-scripts 1.1, 1.2 etc.), which prepares a file of inputs that is then delivered to \"script 2.\" Especially since \"script 2\" is utterly beholden to an external web-site for what it does, I'm just not yet persuaded that the added complexity of \"multi-threading\" is genuinely justifiable here.","Q_Score":0,"Tags":"python,multithreading,multiprocessing","A_Id":38317881,"CreationDate":"2016-07-11T22:55:00.000","Title":"Should I use Threads or multiple processess?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to apply tanh(dot(x,y));\nx and y are batch data of my RNN.  \nx,y have shape (n_batch, n_length, n_dim) like (2,3,4) ; 2 samples with 3 sequences, each is 4 dimensions.\nI want to do inner or dot production to last dimension.  Then tanh(dot(x,y)) should have shape of (n_batch, n_length) = (2, 3)\nWhich function should I use?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":291,"Q_Id":38321248,"Users Score":1,"Answer":"This expression should do the trick:\n\ntheano.tensor.tanh((x * y).sum(2))\n\nThe dot product is computed 'manually' by doing element-wise multiplication, then summing over the last dimension.","Q_Score":0,"Tags":"python,numpy,theano,deep-learning,keras","A_Id":38353930,"CreationDate":"2016-07-12T06:15:00.000","Title":"how to use dot production on batch data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a SSH server with Twisted Conch. When I execute \"ssh username@xx.xx.xx.xx\" command on the client side. My twisted SSH server will return a prompt requesting password that like \"username@xx.xx.xx.xx's password: \".\n   But now I want to change this password prompt that like \"your codes is:\". Dose anyone know how to do it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":38321820,"Users Score":0,"Answer":"The password prompt is part of keyboard-authentication which is part of the ssh protocol and thus cannot be changed. Technically, the prompt is actually client side. However, you can bypass security (very bad idea) and then output \"your codes is\"[sic] via the channel","Q_Score":0,"Tags":"python,ssh,twisted.conch,password-prompt","A_Id":38324034,"CreationDate":"2016-07-12T06:49:00.000","Title":"Python SSH Server(twisted.conch) change the password prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how you exit the multiple row layout on Sublime Text. I switched to a 3 row layout when editing one of my Django projects, but how do I exit from it (remove the extra rows I have added).\nThanks,\nHenry","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":38330752,"Users Score":2,"Answer":"In the menu bar: View > Layout > Single\nOr from the keyboard (on Windows): Alt + Shift + 1\nTo find your default shortcuts, Preferences > Key Bindings - Default, and search for \"set_layout\".","Q_Score":0,"Tags":"python,sublimetext2,sublimetext3,sublimetext,text-editor","A_Id":38330853,"CreationDate":"2016-07-12T13:47:00.000","Title":"Sublime Text: How do you exit the multiple row layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how you exit the multiple row layout on Sublime Text. I switched to a 3 row layout when editing one of my Django projects, but how do I exit from it (remove the extra rows I have added).\nThanks,\nHenry","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":38330752,"Users Score":2,"Answer":"Use View -> Layout menu. If you choose View -> Layout -> Single, other rows will be removed. Short keys depends on OS.","Q_Score":0,"Tags":"python,sublimetext2,sublimetext3,sublimetext,text-editor","A_Id":38330833,"CreationDate":"2016-07-12T13:47:00.000","Title":"Sublime Text: How do you exit the multiple row layout","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I switched to PyCharm a couple of months ago, but I can't figure out how to get rid of the welcome screen when I open files.\nMore specifically, I've set up my mac to open all .py files using PyCharm. However, when I double click on a .py file, it's the Welcome screen that opens up and not the .py file.\nHow do I get PyCharm to just open the python script in the editor, without showing me a welcome screen?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":393,"Q_Id":38331175,"Users Score":0,"Answer":"PyCharm displays the Welcome screen when no project is open. From this screen, you can quickly access the major starting points of PyCharm. The Welcome screen appears when you close the current project in the only instance of PyCharm. If you are working with multiple projects, usually closing a project results in closing the PyCharm window in which it was running, except for the last project, closing this will show the Welcome screen.","Q_Score":1,"Tags":"python,ide,pycharm","A_Id":38331228,"CreationDate":"2016-07-12T14:04:00.000","Title":"PyCharm Directly Open Python File","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a GUI for an application, modeled off of one I have seen. This other application uses diamond-shaped radiobutton indicators from Python Tkinter, and I can't seem to find out how to use a diamond-shaped radiobutton in my program. All of my attempts at creating a radiobutton result in a circular shaped radioubtton. And thoughts? I'm running my GUI on Redhat and Windows, same problem for both.","AnswerCount":2,"Available Count":1,"Score":-0.2913126125,"is_accepted":false,"ViewCount":494,"Q_Id":38356263,"Users Score":-3,"Answer":"The forms toolkit offers precisely the components that it offers.  If you are not happy with round radio buttons, then code in OSF\/Motif, which offers diamond-shaped radio buttons.  Either that, or you could hack the internals of the widget (sorry, \"control\": I am so accustomed to professional [= UNIX] terminology).  The round button is probably represented as a pixmap somewhere: just overwrite that in place, lickety-split, with your own two-tone pixmap that effects a rough diamond shape.","Q_Score":0,"Tags":"python,tkinter","A_Id":38357614,"CreationDate":"2016-07-13T15:44:00.000","Title":"Diamond Shaped Radiobuttons in Python Tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I'm in ipython and try to import keras, I get the error No space left on device: \/home\/username\/.keras. How can I change this so that Keras does not use my HOME directory, and instead use \/data\/username\/? I did the same for the directory ~\/.ipython. I moved it to the desired location and then did export IPYTHONDIR=\/data\/username\/.ipython, can I do something similar with Keras? More generally, how can I do this for any app that wants to use HOME?\nNote: Please don't give answers like \"you can clean your home\" etc. I am asking this for a reason. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":680,"Q_Id":38357398,"Users Score":2,"Answer":"I don't think keras is the only problem. If you are using theano as a backend, it will create $HOME\/.theano\/ as well.\nOne dirty trick is to export HOME=\/data\/username\/, but other program than keras or ipython will also treat \/data\/username\/ as $HONE. To avoid that, you can do this locally by calling HOME=\/data\/username\/ ipython or HOME=\/data\/username\/ python kerasProgram.py.","Q_Score":2,"Tags":"ipython,keras","A_Id":38408813,"CreationDate":"2016-07-13T16:44:00.000","Title":"Move .keras directory in Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am writing some code in Python with all the data available in SAS datasets both on Local hard drive and SAS server. The problem is how to access \/ import these datasets directly in my python program and then write back? Can anybody help. I have seen recommendation for python package \"Sas7bdat\" but not sure about it. is there anyway other way to get connected especially to the datasets available on the local derive (not on server)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":958,"Q_Id":38363949,"Users Score":1,"Answer":"With the help of sas7bdat package you can access all sas datasets normally in local drive, and to use datasets from server use FTP or SFTP connections to read the file as a object and it's easy to access.","Q_Score":0,"Tags":"python,sas,dataset","A_Id":53167909,"CreationDate":"2016-07-14T00:59:00.000","Title":"How to access SAS dataset (available both n local derive and SAS server) from Python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"especially when there are so many parameters (10+ 20+).  \nWhat are good ways of enforcing required\/optional parameters to a function?\nWhat are some good books that deal with this kind of questions for python?\n(like effective c++ for c++)\n** EDIT **\nI think it's very unpractical to list def foo(self, arg1, arg2, arg3,  .. arg20, .....): when there are so many required parameters.","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":19827,"Q_Id":38364162,"Users Score":2,"Answer":"One way is to have your required parameters be named like func(a, b, c=1) and this would denote required because the code will error out at runtime if missing any. Then for the optional parameters you would then use Python's args and kwargs.\nOf course anytime you use Python's args and kwargs means additional code to pull the parameter from the args and kwargs.\nAdditionally for each combination of optional parameters you then would need to code a bunch of conditional control flow. \nIn addition you don't want too many optional assignments because it makes the code's API to complex to describe... and the control flow have to many lines of code because the number of possible combinations grows very quickly for each additional optional parameter.\nAND your test code grows EVEN faster...","Q_Score":9,"Tags":"python,function","A_Id":38364393,"CreationDate":"2016-07-14T01:31:00.000","Title":"in python, how do you denote required parameters and optional parameters in code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running multiple scenarios and would like to incorporate some sort of dynamic scenario dispatcher which would allow me to have specific steps to execute after a test is done based on the scenario executed. When I was using PHPUnit, I used to be able to subclass the TestCase class and add my own setup and teardown methods. For behave, what I have been doing is adding an extra \"Then\" step at the end of the scenario which would be executed once the scenario finishes to clean up everything - clean up the configuration changes made by scenario, etc. But since every scenario is different, the configuration changes I need to make are specific to a scenario so I can't use the after_scenario hook that I have in my environment.py file. Any ideas on how to implement something similar?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":697,"Q_Id":38364568,"Users Score":0,"Answer":"What I've been doing might give you an idea:\nIn the before_all specify a list in the context (eg context.teardown_items =[]).\nThen in the various steps of various scenarios add to that list (accounts, orders or whatever)\nThen in the after_all I login as a superuser and clean everything up I specified in that list.\nCould something like that work for you ?","Q_Score":0,"Tags":"python,bdd,scenarios,python-behave","A_Id":38643609,"CreationDate":"2016-07-14T02:30:00.000","Title":"Dynamic scenario dispatcher for Python Behave","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry if I messed up the title, I didn't know how to phrase this. Anyways, I have a tensor of a set of values, but I want to make sure that every element in the tensor has a range from 0 - 255, (or 0 - 1 works too). However, I don't want to make all the values add up to 1 or 255 like softmax, I just want to down scale the values.\nIs there any way to do this?\nThanks!","AnswerCount":6,"Available Count":1,"Score":0.1651404129,"is_accepted":false,"ViewCount":25931,"Q_Id":38376478,"Users Score":5,"Answer":"sigmoid(tensor) * 255 should do it.","Q_Score":22,"Tags":"python,tensorflow,conv-neural-network","A_Id":38376532,"CreationDate":"2016-07-14T14:08:00.000","Title":"Changing the scale of a tensor in tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"While Mac OSX 10.11.5 (El Capitan) has the \"say\" command to speak in a system generated voice, or so to say, is there any command that is similar for Python that can be used in Python? If Subprocess is utilized, please explain on how to use that.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":449,"Q_Id":38387676,"Users Score":0,"Answer":"Thank you everyone for the quick replies. I have been playing with the subprocess module, and I have gotten this to work:import subprocess\nm=subprocess.Popen([\"say\",\"hello\"])\nprint(m)\n\nThe .Popen command is also a quick way to get this to work. However, this is only working on my Mac and I need it to work on my Raspberry Pi for an interactive feature in my code. (I am using Pi Cam and Infrared Sensors for a robot that wheels around and when it senses people in front of it, says \"Hey! Please move out of my way please!\"","Q_Score":0,"Tags":"python,macos,subprocess,osx-elcapitan","A_Id":38387870,"CreationDate":"2016-07-15T04:03:00.000","Title":"While Mac OSX has the say command to speak, or so to say, is there any command that is similar for Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Overview: I have data something like this (each row is a string):\n\n81:0A:D7:19:25:7B, 2016-07-14 14:29:13, 2016-07-14 14:29:15, -69, 22:22:22:22:22:23,null,^M\n3B:3F:B9:0A:83:E6, 2016-07-14 01:28:59, 2016-07-14 01:29:01, -36, 33:33:33:33:33:31,null,^M\nB3:C0:6E:77:E5:31, 2016-07-14 08:26:45, 2016-07-14 08:26:47, -65, 33:33:33:33:33:32,null,^M\n61:01:55:16:B5:52, 2016-07-14 06:25:32, 2016-07-14 06:25:34, -56, 33:33:33:33:33:33,null,^M\n\nAnd I want to sort each row based on the first timestamp that is present in the each String, which for these four records is:\n\n2016-07-14 01:28:59\n2016-07-14 06:25:32\n2016-07-14 08:26:45\n2016-07-14 14:29:13\n\nNow I know the sort() method but I don't understand how can I use here to sort all the rows based on this (timestamp) quantity, and I do need to keep the final sorted data in the same format as some other service is going to use it.\nI also understand I can make the key() but I am not clear how that can be made to sort on the timestamp field.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":358,"Q_Id":38388799,"Users Score":1,"Answer":"you can use string.split()\uff0cstring.split(',')[1]","Q_Score":5,"Tags":"python,list,python-2.7,sorting","A_Id":38389853,"CreationDate":"2016-07-15T05:57:00.000","Title":"Sort A list of Strings Based on certain field","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My background in programming is mostly Java. It was the first language I learned, and the language I spent the most amount of time with (I then moved on to C# for a little, and eventually C in school). A while back I tried dabbling with Python, and it seemed so different to me (based on my experience with Java). Anyways, now I'm doing much more Python stuff, and I've learned that Python is considered an OOP language with classes and such. I was just curious as to whether these attributes of Python function similarly to their Java counterparts.\nPlease understand, that I'm asking this at a very rudimentary level. I'm still a \"new\" programmer in the sense that I just know how to write code, but don't know much about the various intricacies and subtleties with various languages and types of programming.\nThanks\nEDIT\nSorry, I realize that this was incredibly broad, but I really wasn't looking for specifics. I guess the root of my question stems from my curiosity about the purpose\/role of classes in Python to begin with. From my experience, and what I've seen (and this is by no means extensive or considered to be an accurate representation of the actual uses of Python), most of the time, Python is used without classes or any sort of OOP. As to how that relates to Java, I merely wanted to know if there was a special use or scenario for classes in Python. Essentially, since classes are required in Java, and I was brought up on Java, classes seemed like a norm to me. However, when I got to Python, I noticed that a lack of classes was the norm. This led me to wonder whether classes in Python had some sort of special significance.\nI apologize if this is no more clear than my original post, or if any of this sounds confusing\/inaccurate.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":57,"Q_Id":38400918,"Users Score":2,"Answer":"The short answer is yes and no.\nOne of the key differences I see in Python compared to Java and C# is that in Python, functions don't have to be in a class. In fact, operations don't even have to be in a function.\nJava and C# both have two main rules:\n\nAll code must be in a class.\nOperations are generally required to be in functions.\n\nThis isn't true in Python. In fact, you can write a very basic Python script that's not even in a function. Java does not offer that flexibility - sometimes, that can be very positive because those strict rules help keep the code organized.\nClasses in Python operate in a manner that's very similar to Java and C#, but they aren't necessarily applied in the same way because of the rules above.","Q_Score":0,"Tags":"java,python,oop","A_Id":38400988,"CreationDate":"2016-07-15T16:23:00.000","Title":"Do classes in Python work the same way as classes in Java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've got a Jupyter Notebook with a couple hundred lines of code in it, spread across about 30 cells.  If I want to loop through 10 cells in the middle (e.g. using a For Loop), how do you do that?  Is it even possible, or do you need to merge all the code in your loop into one cell?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":18735,"Q_Id":38405345,"Users Score":7,"Answer":"The only way I can see to do it would be to join the cells, and then put the entire thing in a for\/while loop.","Q_Score":10,"Tags":"python,jupyter-notebook","A_Id":38405533,"CreationDate":"2016-07-15T21:36:00.000","Title":"How to loop through multiple cells in Jupyter \/ iPython Notebook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just installed the new Intel Distribution for Python because I need some performance improvements with my Skull Canyon NUC, but I don't understand how to use all the packages\/modules modified by Intel.\nI usually use Anaconda Spyder as my main IDE, how can I \"tell\" to Spyder to not use the Anaconda standard\/included packages\/modules instead of the new Intel ones?\nThank you for your answers!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":892,"Q_Id":38405454,"Users Score":1,"Answer":"In Spyder menu choose Preferences then click console and click to Advanced settings tab. From there choose the Python interpreter, which came with Intel Distribution.","Q_Score":0,"Tags":"python,performance,intel,python-multiprocessing,intel-mkl","A_Id":38405541,"CreationDate":"2016-07-15T21:48:00.000","Title":"Intel Distribution for Python and Spyder IDE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a simple way to get a PDF from a xml with an xsl-fo?\nI would like to do it in python.\nI know how to do an html from an xml&xsl, but I haven't find a code example to get a PDF.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1430,"Q_Id":38412298,"Users Score":1,"Answer":"XSL FO requires a formatting engine to create print output like PDF from XSL FO input. Freely available one is Apache FOP. There are several other commercial products also. I know of no XSL FO engines written in Python though some have Python interfaces.","Q_Score":1,"Tags":"xml,python-2.7,xslt,pdf-generation,xsl-fo","A_Id":38413882,"CreationDate":"2016-07-16T14:45:00.000","Title":"xml + xslfo to PDF python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a college project I'm tasked with getting a Raspberry Pi to control an RC car over WiFi, the best way to do this would be through a web interface for the sake of accessibility (one of the key reqs for the module). However I keep hitting walls, I can make a python script control the car, however doing this through a web interface has proven to be dificult to say the least. \nI'm using an Adafruit PWM Pi Hat to control the servo and ESC within the RC car and it only has python libraries as far as I'm aware so it has to be witihn python. If there is some method of passing variables from javascript to python that may work, but in a live environment I don't know how reliable it would be.\nAny help on the matter would prove most valuable, thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":229,"Q_Id":38418140,"Users Score":0,"Answer":"I can suggest a way to handle that situation but I'm not sure how much will it suit for your scenario.\nSince you are trying to use a wifi network, I think it would be better if you can use a sql server to store commands you need to give to the vehicle to follow from the web interface sequentially. Make the vehicle to read the database to check whether there are new commands to be executed, if there are, execute sequentially.\nFrom that way you can divide the work into two parts and handle the project easily. Handling user inputs via web interface to control vehicle. Then make the vehicle read the requests and execute them.\nHope this will help you in someway. Cheers!","Q_Score":0,"Tags":"javascript,python,html,raspberry-pi2","A_Id":38418381,"CreationDate":"2016-07-17T05:18:00.000","Title":"How do I control a python script through a web interface?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently writing a web application using Flask in python that generates the linux\/nix performances(CPU, Disk Usage, Memory Usage). I already implemented the python library psutil.\nMy question is how can I get the values of each util with date ranges. For example: Last 3 hours of CPU, Disk Usage, Memory usage.\nSorry for the question I'm a beginner in programming.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":172,"Q_Id":38429271,"Users Score":0,"Answer":"For future need, I found a way to this. Using ElasticSearch and Psutil.\nI indexed the psutil values to elasticsearch then used the date-range and date-histogram aggs.\nThanks!","Q_Score":0,"Tags":"python,flask,psutil","A_Id":38521678,"CreationDate":"2016-07-18T05:38:00.000","Title":"Python\/Flask : psutil date ranges","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is openmdao GUI available on 1.7.0 version? And if yes, how to run it? I have found, how to run the GUI on the 0.10.7 version, but it doesn't work on the 1.7.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":287,"Q_Id":38431782,"Users Score":0,"Answer":"Worked for me after updating to 1.7.1 via pip on Fedora v20. The command with conventional naming is: \n\n\nview_tree(top)","Q_Score":1,"Tags":"python,python-3.x,openmdao","A_Id":38446190,"CreationDate":"2016-07-18T08:20:00.000","Title":"Running openmdao 1.7.0 GUI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a curve of some data that I am plotting using matplotlib.  The small value x-range of the data consists entirely of NaN values, so that my curve starts abruptly at some value of x>>0 (which is not necessarily the same value for different data sets I have).  I would like to place a vertical dashed line where the curve begins, extending from the curve, to the x axis.  Can anyone advise how I could do this? Thanks","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4256,"Q_Id":38433584,"Users Score":3,"Answer":"Assuming you know where the curve begins, you can just use:\nplt.plot((x1, x2), (y1, y2), 'r-') to draw the line from the point (x1, y1) to the point (x2, y2) \nHere in your case, x1 and x2 will be same, only y1 and y2 should change, as it is a straight vertical line that you want.","Q_Score":1,"Tags":"python,matplotlib","A_Id":38433637,"CreationDate":"2016-07-18T09:49:00.000","Title":"Python - Plotting vertical line","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python with Conda to manage my environment and libraries. Does anyone know how to get IntelliJ (with the Python plugin) or PyCharm to add the libraries in my Conda environment to my project?\nIt only pulls in site packages even when I select ~\/anaconda\/bin\/python as my Python Interpreter.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":563,"Q_Id":38476379,"Users Score":2,"Answer":"You ned to change your Project Interpreter to point to $CONDA_PREFIX\/bin\/python where $CONDA_PREFIX is the location of your conda env.  The $CONDA_PREFIX environment location you're looking for should be in the second column of the output from conda info --envs.","Q_Score":1,"Tags":"python,intellij-idea,pycharm,conda","A_Id":38732023,"CreationDate":"2016-07-20T08:41:00.000","Title":"How can I get IntelliJ to index libraries in my Python Conda environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Basically I am writing a script that can be stopped and resumed at any time. So if the user uses, say PyCharm console to execute the program, he can just click on the stop button whenever he wants. \nNow, I need to save some variables and let an ongoing function finish before terminating. What functions do I use for this?\nI have already tried atexit.register() to no avail. \nAlso, how do I make sure that an ongoing function is completed before the program can exit?\nThanks in advance","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":639,"Q_Id":38480595,"Users Score":1,"Answer":"Solved it using a really bad workaround. I used all functions that are related to exit in Python, including SIG* functions, but uniquely, I did not find a way to catch the exit signal when Python program is being stopped by pressing the \"Stop\" button in PyCharm application. Finally got a workaround by using tkinter to open an empty window, with my program running in a background thread, and used that to close\/stop program execution. Works wonderfully, and catches the SIG* signal as well as executing atexit . Anyways massive thanks to @scrineym as the link really gave a lot of useful information that did help me in development of the final version.","Q_Score":1,"Tags":"python,pycharm,exit","A_Id":38529814,"CreationDate":"2016-07-20T11:54:00.000","Title":"Wait and complete processes when Python script is stopped from PyCharm console?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running errbot in a docker container, we did the !backup and we have the backup.py, but when i start the docker container it just run \/app\/venv\/bin\/run.sh\nbut i cannot pass -r \/srv\/backup.py to have all my data restored.\nany ideas?\nall the data is safe since the \/srv is a mounted volume","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":75,"Q_Id":38488977,"Users Score":1,"Answer":"I think the best if you run Errbot in a container is to run it with a real database for the persistence (redis for example).\nThen you can simply run backup.py from anywhere (including your dev machine).\nEven better, you can just do a backup of your redis directly.","Q_Score":2,"Tags":"python,docker,errbot","A_Id":38557886,"CreationDate":"2016-07-20T19:12:00.000","Title":"how can i restore the backup.py plugin data of errbot running in a docker container","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been having some really odd issues with trying to install and use the Python \"Pip\" module. Firstly, I've installed the pip module by downloading the getpip.py file and running it which has replaced my pre existing pip which seemed to work fine. However whenever I try to use pip it always comes up with \"pip is not recognized as an internal or external command\" etc. I've set the path for python by using setx PATH \"%PATH%;C:\\Python27\\python\" and then using C:\\Python27\\Scripts\\pip the second time to try and set the path for pip. But one of these seem to work. I can't use pip in cmd neither can I now use python.\nDoes anyone know how to make this work? I'm trying to run this command \"pip install -r requirements.txt \" even in the right folder but pip is not recognized. Any suggestions? Thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":38493144,"Users Score":0,"Answer":"You're using the wrong path, Pip should reside in the Scripts  sub directory, set PATH to C:\\Python27\\Scripts then you should restart cmd.","Q_Score":0,"Tags":"python,windows,python-2.7","A_Id":38493199,"CreationDate":"2016-07-21T00:53:00.000","Title":"Python 2.7 Pip module not installing or setting paths via cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been on it for several days + researching the internet on how to get specific information from a pdf file.\nEventually I was able to fetch all information using Python from a text file(which I created by going to the PDF file -----> File ------> Save as Text).\nThe question is how do I get Python to accomplish those tasks(Going to the PDF file(opening it - is quite easy open(\"file path\"), clicking on File in the menu, and then saving the file as a text file in the same directory).\nJust to be clear, I do not require the pdfminer or pypdf libraries as I have already extracted the information with the same file(after converting it manually to txt)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3865,"Q_Id":38496026,"Users Score":0,"Answer":"You can use \"tabula\" python library. which basically uses Java though so you have to install Java SDK and JDK.\n\"pip install tabula\"\nand import it to the python script then you can convert pdf to txt file as:\ntabula.convert_into(\"path_or_name_of_pdf.pdf\", \"output.txt\", output_format=\"csv\", pages='all')\nYou can see other functions on google. It worked for me.\nCheers!!!","Q_Score":3,"Tags":"python,python-2.7,pdf,text,converter","A_Id":70157888,"CreationDate":"2016-07-21T06:01:00.000","Title":"Converting a PDF file to a Text file in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have imported a SAS dataset in python dataframe using Pandas read_sas(path) \nfunction. REPORT_MONTH is a column in sas dataset defined and saved as DATE9. format. This field is imported as float64 datatype in dataframe and having numbers which is basically a sas internal numbers for storing a date in a sas dataset. Now wondering how can I convert this originally a date field into a date field in dataframe?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":398,"Q_Id":38518000,"Users Score":0,"Answer":"I don't know how python stores dates, but SAS stores dates as numbers, counting the number of days from Jan 1, 1960. Using that you should be able to convert it in python to a date variable somehow.\nI'm fairly certain that when data is imported to python the formats aren't honoured so in this case it's easy to work around this, in others it may not be.\nThere's probably some sort of function in python to create a date of Jan 1, 1960 and then increment by the number of days you get from the imported dataset to get the correct date.","Q_Score":0,"Tags":"python,pandas,dataframe,import,sas","A_Id":38518356,"CreationDate":"2016-07-22T04:09:00.000","Title":"Date field in SAS imported in Python pandas Dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to create a dashboard based upon an excel table and I know excel has a feature for creating dashboards. I have seen tutorials on how to do it and have done my research, but in my case, the excel table on which the dashboard would be based is updated every 2 minutes by a python script. My question is, does the dashboard display automatically if a value in the table has modified, or does it need to be reopened, reloaded, etc..?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1488,"Q_Id":38518227,"Users Score":1,"Answer":"If the \"dashboard\" is in Excel and if it contains charts that refer to data in the current workbook's worksheets, then the charts will update automatically when the data is refreshed, unless the workbook calculation mode is set to \"manual\". By default calculation mode is set to \"automatic\", so changes in data will immediately reflect in charts based on that data.\nIf the \"dashboard\" lives in some other application that looks at the Excel workbook for the source data, you may need to refresh the data connections in the dashboard application after the Excel source data has been refreshed.","Q_Score":0,"Tags":"python,excel,dashboard","A_Id":38520493,"CreationDate":"2016-07-22T04:33:00.000","Title":"Can Excel Dashboards update automatically?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to have easily the percentage of sales orders \/ quotes per users?\nThe objective it is to know what the percentage of quote that become a sale order per user.\nI have not a clue how I can do it.\nI am using OpenERP 7","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":118,"Q_Id":38521380,"Users Score":0,"Answer":"Yes it is possible by using status bar.\nIn order for you to compute the percentage of sales order, you should determine how much is the quota for each sale order.","Q_Score":0,"Tags":"python,openerp,openerp-7","A_Id":38689879,"CreationDate":"2016-07-22T08:09:00.000","Title":"OpenERP - Odoo - How to have the percentage of quote that become a sale orders","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently using a Jenkins build to run a bash command that activates a Python script. The build is parametrised, and i need to be able to set environment variables containing those parameters on the Windows slave to be used by the Python script.\nSo, my question is: How do i set temporary env. variables for the current build and secondly, how do i use Python to retreive them while running a script?\nAn explanation of the process would be great since i couldn't make any solution work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":766,"Q_Id":38527505,"Users Score":0,"Answer":"What I usually do is going on the build output, on the left you will find \"Build environment Variables\" or something similar and check if you can see them there, but the solution cited on the other SO post works usually for me as well","Q_Score":0,"Tags":"python,jenkins,jenkins-plugins","A_Id":38527694,"CreationDate":"2016-07-22T13:18:00.000","Title":"Jenkins with Windows slave with Python - Setting environment variables while building and using them when running a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My Jupyter\/IPython notebooks reside in various directories all over my file system. I don't enjoy navigating hierarchies of directories in the Jupyter notebook browser every time I have to open a notebook. In absence of the (still) missing feature allowing to bookmark directories within Jupyter, I want to explore if I can open a notebook from the command line such that it is opened by the Jupyter instance that is already running. I don't know how to do this....","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1220,"Q_Id":38531685,"Users Score":2,"Answer":"Option 1: Run multiple jupyter notebook servers from your project directory root(s).  This avoids navigating deeply nested structures using the browser ui.  I often run many notebook servers simultaneously without issue.\n$ cd path\/to\/project\/; jupyter notebook;\nOption 2: If you know the path you could use webbrowser module\n$ python -m webbrowser http:\/\/localhost:port\/path\/to\/notebook\/notebook-name.ipynb\nOf course you could alias frequently accessed notebooks to something nice as well.","Q_Score":2,"Tags":"python,ipython-notebook,jupyter-notebook","A_Id":38531985,"CreationDate":"2016-07-22T16:51:00.000","Title":"Open a Jupyter notebook within running server from command line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set group volume in soco (python) for my Sonos speakers. It is straightforward to set individual speaker volume but I have not found any way to set volume on group level (without iterating through each speaker setting the volume individually). Any idea to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":442,"Q_Id":38540517,"Users Score":1,"Answer":"you can easily iterate over the group, and change all their volumes, for example to increate the volume on all speakers by 5:\nfor each_speaker in my_zone.group:\n  each_speaker.volume += 5\n(assuming my_zone is you speaker object)","Q_Score":1,"Tags":"python,sonos","A_Id":38955622,"CreationDate":"2016-07-23T10:04:00.000","Title":"Anyone know how to set group volume in soco (python)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use Flask and for some reason it is rendering with a byte-order mark that's a quirk of something using UTF8 (the mark is \u00ef\u00bb\u00bf in particular for people googling the same issue).\nI do not know how to get rid of it or if it is a source of some of my problems. I am using Flask on Windows 10.\nI wish I knew how to reproduce this issue.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":142,"Q_Id":38558368,"Users Score":2,"Answer":"The string (BOM) is most likely included in your template file. Open\/save it in some editor which doesn't include unnecessary symbols in UTF-8 files. For example Notepad++.","Q_Score":0,"Tags":"python-3.x,utf-8,flask","A_Id":38558411,"CreationDate":"2016-07-25T00:59:00.000","Title":"flask serving byte-order-mark \u00ef\u00bb\u00bf","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am currently working on a project that involves the google maps API. In order to display data on this, the file needs to be in a geojson format. So far in order to accomplish this, I have been using two programs, 1 in javascript that converts a .json to a CSV, and another that converts a CSV to a geojson file, which can then be dropped on the map. However, I need to make both processes seamless, therefore I am trying to write a python script that checks the format of the file, and then converts it using the above programs and outputs the file. I tried to use many javascript to python converters to convert the javascript file to a python file, and even though the files were converted, I kept getting multiple errors for the past week that show the converted program not working at all and have not been able to find a way around it. I have only seen articles that discuss how to call a javascript function from within a python script, which I understand, but this program has a lot of functions and therefore I was wondering how to call the entire javascript program from within python and pass it the filename in order to achieve the end result. Any help is greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":196,"Q_Id":38586396,"Users Score":0,"Answer":"I was able to write a conversion script, and it's working now, thanks!","Q_Score":0,"Tags":"javascript,python,json,csv,geojson","A_Id":38633221,"CreationDate":"2016-07-26T09:43:00.000","Title":"How to execute an entire Javascript program from within a Python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need to trace the status for the tasks. i could get the 'state', 'info' attribute from the AsyncResult obj. however, it looks there's no way to get the 'done_date'. I use MySQL as result backend so i could find the date_done column in the taskmeta table, but how could i get the task done date directly from AysncResult obj? thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":696,"Q_Id":38586767,"Users Score":1,"Answer":"You can get it from the _cache object of the AsyncResult after you have called res.result\nfor example\nres._cache['date_done']","Q_Score":1,"Tags":"python,celery","A_Id":38587766,"CreationDate":"2016-07-26T09:59:00.000","Title":"Celery: How to get the task completed time from AsyncResult","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to read from a Google sheet say every 2 hours.  I have looked at both the API for Google sheets and also the Google Apps Script.\nI'm using Python\/Flask, and what I'm specifically confused about is how to add the time trigger. I can use the Google Sheets API to read from the actual file,but I'm unsure of how to run this process every x hours. From my understanding,  it seems like Google Apps Script, is for adding triggers to doc, sheets, etc, which is not really what I want to do.\nI'm pretty sure I'm looking in the wrong area for this x hour read. Should I be looking into using the sched module or Advanced Python Scheduler?Any advice on how to proceed would be very appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":38596793,"Users Score":1,"Answer":"If you want to do this with only manipulating your Python program, you would have to run it all day. This would waste CPU resources.\nIt's best to use cron to schedule your unix system to run a command for you every 2 hours. In this case, it'd be your python program.","Q_Score":0,"Tags":"python,google-spreadsheet-api","A_Id":38600670,"CreationDate":"2016-07-26T17:56:00.000","Title":"Reading From Google Sheets Periodically","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using tkinter and pyinstaller\/py2exe (either one would be fine), to create an executable as a single file from my python script. I can create the executable, and it runs as desired when not using the bundle option with py2exe or -F option with pyinstaller. I'm running third party python scripts within my code with os.system(), and can simply place these scripts in the 'dist' dir after it is created in order for it to work. The command has several parameters: input file, output file, number of threads..etc, so I'm unsure how to add this into my code using import. Unfortunately, this is on Windows, so some colleagues can use the GUI, and would like to have the single executable to distribute. \n**EDIT:**I can get it to bundle into a single executable, and provide the scripts along with the exe. The issue still however, is with os.system(\"python script.py -1 inputfile -n numbthreads -o outputfile..\") when running the third party scripts within my code. I had a colleague test the executable with the scripts provided with it, however at this point they need to have python installed, which is unacceptable since there will be multiple users.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1346,"Q_Id":38603480,"Users Score":2,"Answer":"After a couple of days of some tests, I was able to figure out how to work around this problem. Instead of os.system, I am using subprocess.call(\"script.py arg1 arg2 ..., shell=True) for each script I need to run. Also, I used chmod +x (in linux) before transferring the scripts to windows to ensure they're an executable (someone can hopefully tell me if this was really necessary). Then without having to install python a colleague was able to run the program, after I compiled it as a single file with pyInstaller. I was also able to do the same thing with blast executables (where the user did not have to install blast locally - if the exe also accompanied the distribution of the script). This avoided having to call bipython ncbiblastncommandline and the install.","Q_Score":2,"Tags":"python,import,py2exe,pyinstaller,os.system","A_Id":38665906,"CreationDate":"2016-07-27T03:59:00.000","Title":"PyInstaller\/Py2exe - include os.system call with third party scripts in single file compilation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to speed up my website. So at the moment, controller fetches data from database, do calculation on data and display on view. \nwhat I plan to do is, controller\/action fetches half the data and display to the view. Than come back to different controller\/action and do calculation on data and display data on screen.\nBut what I want to know is once I fetch data and display on screen, how do I go back to controller automatically(without any click by user) to do calculations on same data.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":51,"Q_Id":38612836,"Users Score":2,"Answer":"Why don't you use ajax function , post data to the server and when proccess to the server is done display the result to the html page","Q_Score":0,"Tags":"python,performance,model-view-controller,pyramid","A_Id":38612965,"CreationDate":"2016-07-27T12:21:00.000","Title":"Suggestions to make website fast by breaking a request in two parts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to analyze a text which is given by lines, and I wish to vectorize the lines using sckit-learn package's TF-IDF-vectorization in python.\nThe problem is that the vectorization can be done either by words or n-grams but I want them to be done for lines, and I already ruled out a work around that just vectorize each line as a single word (since in that way the words and their meaning wont be considered).\nLooking through the documentation I didnt find how to do that, so is there any such option?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":791,"Q_Id":38615088,"Users Score":1,"Answer":"You seem to be misunderstanding what the TF-IDF vectorization is doing. For each word (or N-gram), it assigns a weight to the word which is a function of both the frequency of the term (TF) and of its inverse frequency of the other terms in the document (IDF). It makes sense to use it for words (e.g. knowing how often  the word \"pizza\" comes up) or for N-grams (e.g. \"Cheese pizza\" for a 2-gram)\nNow, if you do it on lines, what will happen? Unless you happen to have a corpus in which lines are repeated exactly (e.g. \"I need help in Python\"), your TF-IDF transformation will be garbage, as each sentence will appear exactly once in the document. And if your sentences are indeed always similar to the punctuation mark, then for all intents and purposes they are not sentences in your corpus, but words. This is why there is no option to do TF-IDF with sentences: it makes zero practical or theoretical sense.","Q_Score":2,"Tags":"python,scikit-learn,vectorization,tf-idf,text-analysis","A_Id":38615418,"CreationDate":"2016-07-27T13:58:00.000","Title":"Tf-Idf vectorizer analyze vectors from lines instead of words","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I keep trying to install Pip using get-pip.py and only get the wheel file in the scripts folder. Try running \"pip\" in the command prompt and it just comes out with an error. Running windows 8 incase you need.\nedit error is 'pip' is not recognized as an internal or external command...","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":17163,"Q_Id":38626409,"Users Score":0,"Answer":"Try navigating to ~\/Python[version]\/Scripts in cmd, then use pip[version] [command] [module] (ie. pip3 install themodulename or pip2 install themodulename)","Q_Score":0,"Tags":"python,python-2.7,pip","A_Id":38627143,"CreationDate":"2016-07-28T03:00:00.000","Title":"Python pip installation not working how to do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I keep trying to install Pip using get-pip.py and only get the wheel file in the scripts folder. Try running \"pip\" in the command prompt and it just comes out with an error. Running windows 8 incase you need.\nedit error is 'pip' is not recognized as an internal or external command...","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":17163,"Q_Id":38626409,"Users Score":1,"Answer":"If you are using latest version of Python.\nIn computer properties, Go to Advanced System Settings -> Advanced tab -> Environmental Variables\nIn System variables section, there is variable called PATH. Append c:\\Python27\\Scripts (Note append, not replace)\nThen open a new command prompt, try \"pip\"","Q_Score":0,"Tags":"python,python-2.7,pip","A_Id":38627346,"CreationDate":"2016-07-28T03:00:00.000","Title":"Python pip installation not working how to do?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am doing some data science analysis on jupyter and I wonder how to get all the output of my cell saved into a pdf file ?\nthanks","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":19046,"Q_Id":38657054,"Users Score":3,"Answer":"When I want to save a Jupyter Notebook I right click the mouse, select print, then change Destination to Save as PDF. This does not save the analysis outputs though. So if I want to save a regression output, for example, I highlight the output in Jupyter Notebook, right click, print, Save as PDF. This process creates fairly nice looking documents with code, interpretation and graphics all-in-one. There are programs that allow you to save more directly but I haven't been able to get them to work.","Q_Score":6,"Tags":"python-2.7,pdf,jupyter-notebook","A_Id":41493134,"CreationDate":"2016-07-29T10:55:00.000","Title":"how to save jupyter output into a pdf file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've recently tried to install seaborn on ipython, which the latter was installed using anaconda. However, when I ran  conda install seaborn, i was returned with a syntax error. I tried again with conda install -c anaconda seaborn=0.7.0 this time but syntax error was returned again. Apologies for my limited programming knowledge, but could anyone provide advice on how to resolve this issue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":494,"Q_Id":38672768,"Users Score":2,"Answer":"conda is a command line tool, not a Python function. You should be typing these commands in a bash (or tcsh, etc.) shell, not in the IPython interpreter.","Q_Score":1,"Tags":"ipython,anaconda,seaborn,conda","A_Id":38698060,"CreationDate":"2016-07-30T10:15:00.000","Title":"Syntax error while installing seaborn using conda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to run Python scripts inside virtualenv from Sublime Text 3. When I activate the virtualenv in ST3 and choose the .py, ST3 creates a Scripts folder inside the preexisting Scripts folder (for a new `.py'). What is causing this problem and how I do stop this from happening?\nFollowing are the detailed steps I follow:\n\nCreate `virtualenx Somevenv' from CMD\nNavigate to 'Someenv\\Scripts`\nactivate\npip install somePackage\nSelect Virtualenv:New (Virtualenv: Activate does nothing)\nPaste \\path\\to\\Someenv\\Scripts under Virtualenv Path\nSelect c:\\Python27\nST3 does it's thing and produces this message:\nNew python executable in C:\\Users\\Gandalf\\Documents\\Python_Virtual_Env\\Legolas\\Scripts\\Scripts\\python.exe\nInstalling setuptools, pip, wheel...done.\n\nAs you see, ST3 creates a Scripts inside the previous Scripts folder. As a result, the packages installed in step 4 are not used. I want to stop the creation of this second Scripts folder.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":38688707,"Users Score":0,"Answer":"Solved. In ST3, use Virtualenv: Add Directory instead of Virtualenv: New. The latter creates a new virtualenv (hence the new Scripts folder).","Q_Score":0,"Tags":"python,python-2.7,sublimetext3,virtualenv","A_Id":38689463,"CreationDate":"2016-07-31T21:54:00.000","Title":"Sublime Text3 creates Scripts inside Scripts folder inside virtualenv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know python is a high level language and manages the memory allocation etc. on its own user\/developer doesn't need to worry much unlike other languages like c, c++ etc.\nbut is there a way through will we can write some value in a particular memory address in python\ni know about id() which if hex type casted can give hexadecimal location but how can we write at a location.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":5817,"Q_Id":38696575,"Users Score":1,"Answer":"Python itself does not include any facilities to allow the programmer direct access to memory. This means that sadly (or happily, depending on your outlook) the answer to your question is \"no\".","Q_Score":8,"Tags":"python,python-2.7","A_Id":38696887,"CreationDate":"2016-08-01T10:30:00.000","Title":"Writing to particular address in memory in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know python is a high level language and manages the memory allocation etc. on its own user\/developer doesn't need to worry much unlike other languages like c, c++ etc.\nbut is there a way through will we can write some value in a particular memory address in python\ni know about id() which if hex type casted can give hexadecimal location but how can we write at a location.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5817,"Q_Id":38696575,"Users Score":0,"Answer":"I can't advise how but I do know (one) why.  Direct writing to registers allows one to set up a particular microcontroller.  For example, configuring ports or peripherals.  This is normally done in C (closer to hardware) but it would be a nice feature if you wanted to use Python for other reasons.","Q_Score":8,"Tags":"python,python-2.7","A_Id":51573628,"CreationDate":"2016-08-01T10:30:00.000","Title":"Writing to particular address in memory in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a web project where I take in Form data and write to a SQL database.\nThe forms will be a questionnaire with logic branching. Due to the nature of the form, and the fact that this is an MVP project, I've opted to use an existing form service (e.g Google Forms\/Typeform). \nI was wondering if it's feasible to have form data submitted to multiple different tables (e.g CustomerInfo, FormDataA, FormDataB, etc.). While this might be possible with a custom form application, I do not think it's possible with Google Forms and\/or Typeform. \nDoes anyone have any suggestions on how to parse user submitted Form data into multiple tables when using Google Forms or Typeform?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":638,"Q_Id":38703892,"Users Score":0,"Answer":"You can add a script in the Google spreadsheet with an onsubmit trigger. Then you can do whatever you want with the submitted data.","Q_Score":0,"Tags":"python,sql,google-forms","A_Id":39074108,"CreationDate":"2016-08-01T16:37:00.000","Title":"Using Google Forms to write to multiple tables?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a python script run in the background, and listen to commands. For example if I run my script:\npython my_script.py it will start running (and wait for commands).\nThen I wish to run:\npython my_script.py --do_something, open a different python process, and it will run a function do_something() in the previous process.\nI've seen this works on programs like PDPlayer where the flag --play causes the player to start playing a video. Can this also be done in python?\nI know how to handle the command line arguments using argparse. I need help regarding the communication between the two python processes.\nAlso, I plan to cx_freeze the app, so the PID of the app can be found using psutil by searching the executable name.\nThanks.\nbtw, I'm using Windows...","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1144,"Q_Id":38707350,"Users Score":1,"Answer":"There are two things this needs to do: you need to handle command-line flags, and you need to send signals to another process. For the flags, you could use the argparse library, or simply sys.argv.\nFor sending signals, you will need the Process ID (pid) of the already running process. Under Linux you can call ps, and check to see if there is another instance of the script running. If there is, send it a signal.\nAnother alternative to signal handling is DBus. This is less cross-platform capable, though.","Q_Score":0,"Tags":"python,subprocess,command-line-arguments","A_Id":38707485,"CreationDate":"2016-08-01T20:14:00.000","Title":"Send commands to running script by running it with flags","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got two questions when I was plotting graph in ipython.\n\nonce, i implement %matplotlib inline, I don't know how to switch back to use floating windows. \nwhen I search for the method to switch back, people told me to implement \n%matplotlib osx or %matplotlib, however, I finally get an error, which is \n\nGtk* backend requires pygtk to be installed.\n\n\nCan anyone help me, giving me some idea?\np.s. I am using windows 10 and python 2.7","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":336,"Q_Id":38727035,"Users Score":0,"Answer":"You need to install pyGTK. How to do so depends on what you're using to run Python. You could also not use '%matplotlib inline' and then it'll default to whatever is installed on your system.","Q_Score":0,"Tags":"python,matplotlib,ipython","A_Id":38729045,"CreationDate":"2016-08-02T17:35:00.000","Title":"How to turn off matplotlib inline function and install pygtk?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've deployed a new version which contains just one image replacement. After migrating traffic (100%) to the new version I can see that only this version now has active instances. However 2 days later and App engine is still intermittently serving the old image. So I assume the previous version. When I ping the domain I can see that the latest version has one IP address and the old version has another.\nMy question is how do I force App Engine to only server the new version? I'm not using traffic splitting either.\nAny help would be much appreciated\nRegards,\nDanny","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":190,"Q_Id":38741327,"Users Score":1,"Answer":"You have multiple layers of caches beyond memcache, \nGoogles edge cache will definitely cache static content especially if you app is referenced by your domain and not appspot.com .  \nYou will probably need to use some cache busting techniques.  \nYou can test this by requesting the url that is presenting old content with the same url but appending something like ?x=1 to the url.  \nIf you then get current content then the edge cache is your problem and therefore the need to use cache busting techniques.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":38788820,"CreationDate":"2016-08-03T10:43:00.000","Title":"App Engine serving old version intermittently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In neural network theory - setting up the size of hidden layers seems to be a really important issue. Is there any criteria how to choose the number of neurons in a hidden layer?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":638,"Q_Id":38759647,"Users Score":2,"Answer":"Yes - this is a really important issue. Basically there are two ways to do that:\n\nTry different topologies and choose best: due to the fact that number of neurons and layers are a discrete parameters you cannot differentiate your loss function with respect to this parameters in order to use a gradient descent methods. So the easiest way is to simply set up different topologies and compare them using either cross-validation or division of your training set to - training \/ testing \/ validating parts. You can also use a grid \/ random search schemas to do that. Libraries like scikit-learn have appropriate modules for that.\nDropout: the training framework called dropout could also help. In this case you are setting up relatively big number of nodes in your layers and trying to adjust a dropout parameter for each layer. In this scenario - e.g. assuming that you will have a two-layer network with 100 nodes in your hidden layer with dropout_parameter = 0.6 you are learning the mixture of models - where every model is a neural network with size 40 (approximately 60 nodes are turned off). This might be also considered as figuring out the best topology for your task.","Q_Score":0,"Tags":"python-2.7,machine-learning,neural-network","A_Id":38763173,"CreationDate":"2016-08-04T06:08:00.000","Title":"How should we set the number of the neurons in the hidden layer in neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In neural network theory - setting up the size of hidden layers seems to be a really important issue. Is there any criteria how to choose the number of neurons in a hidden layer?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":638,"Q_Id":38759647,"Users Score":1,"Answer":"You have to set the number of neurons in hidden layer in such a way that it shouldn't be more than # of your training example. There are no thumb rule for number of neurons.\nEx: If you are using MINIST Dataset then you might have ~ 78K training example. So make sure that combination of Neural Network (784-30-10) = 784*30 + 30*10 which are less than training examples. but if you use like (784-100-10) then it exceeds the # of training example and highly probable to over-fit.\nIn short, make sure you are not over-fitting and hence you have good chances to get good result.","Q_Score":0,"Tags":"python-2.7,machine-learning,neural-network","A_Id":38776068,"CreationDate":"2016-08-04T06:08:00.000","Title":"How should we set the number of the neurons in the hidden layer in neural network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a post-commit script in Python and calling git commands using subprocess.\nIn my script I want to stash all changes before I run some commands and then pop them back. The problem is that if there was nothing to stash, stash pop returns a none-zero error code resulting in an exception in subprocess.check_output(). I know how I can ignore the error return code, but I don't want to do it this way.\nSo I have been thinking. Is there any way to get the number of items currently in stash? I know there is a command 'git stash list', but is there something more suited for my needs or some easy and safe way to parse the output of git stash list?\nAlso appreciate other approaches to solve this problem.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":441,"Q_Id":38776447,"Users Score":5,"Answer":"Don't do that!\nSuppose that git stash save saves nothing, but there are already some items in the stash.  Then, when you're all done, you pop the most recent stash, which is not one you created.\nWhat did you just do to the user?\nOne way to do this in shell script code is to check the result of git rev-parse refs\/stash before and after git stash save.  If it changes (from failure to something, or something to something-else), you have created a new stash, which you can then pop when you are done.\nMore recent versions of Git have git stash create, which creates the commit-pair as usual but does not put them into the refs\/stash reference.  If there is nothing to save, git stash create does nothing and outputs nothing.  This is a better way to deal with the problem, but is Git-version-dependent.","Q_Score":2,"Tags":"python,git","A_Id":38776587,"CreationDate":"2016-08-04T20:02:00.000","Title":"Only call 'git stash pop' if there is anything to pop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am creating a post-commit script in Python and calling git commands using subprocess.\nIn my script I want to stash all changes before I run some commands and then pop them back. The problem is that if there was nothing to stash, stash pop returns a none-zero error code resulting in an exception in subprocess.check_output(). I know how I can ignore the error return code, but I don't want to do it this way.\nSo I have been thinking. Is there any way to get the number of items currently in stash? I know there is a command 'git stash list', but is there something more suited for my needs or some easy and safe way to parse the output of git stash list?\nAlso appreciate other approaches to solve this problem.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":441,"Q_Id":38776447,"Users Score":2,"Answer":"You can simply try calling git stash show stash@{0}.  If this returns successfully, there is something stashed.","Q_Score":2,"Tags":"python,git","A_Id":38776533,"CreationDate":"2016-08-04T20:02:00.000","Title":"Only call 'git stash pop' if there is anything to pop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm using Wing IDE, how do I install hypothesis Python package to my computer?\nI have already download the zip file, do I use command prompt to install it or there is an option in Wing IDE to do it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1175,"Q_Id":38796441,"Users Score":1,"Answer":"pip install hypothesis\nAssuming you have pip.\nIf you want to install it from the downloaded package just open command prompt and  cd to the directory where you downloaded it and do\npython setup.py install","Q_Score":0,"Tags":"python,wing-ide,python-packaging","A_Id":38796484,"CreationDate":"2016-08-05T19:20:00.000","Title":"how to install hypothesis Python package?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I will compile form designed by qt designer in eric6, but show \"Could not start pyuic5, Ensure that it is in the search path.\" But actually the PATH of  pyuic5.exe has been in the system PATH, and also the pyuic5.exe can be run by typing pyuic5 in the cmd of window7 .\nThe envirement is python3.5+qt5.7+pyqt5.7+eric6.\nWhy I could not compile form in eric6? How can fix the error?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":974,"Q_Id":38807068,"Users Score":0,"Answer":"Had the exact same issue. Looks like Eric wants pyuic5.bat (somewhere in the path)\nI created such a batch file with the following contents, and it worked\n\n@\"pyuic5.exe\" %1 %2 %3 %4 %5 %6 %7 %8 %9\n\nPS: In my setup these files are both located in a folder:\n\nC:\\Python35-32\\Scripts","Q_Score":0,"Tags":"python,qt,python-3.x,pyqt5","A_Id":40221119,"CreationDate":"2016-08-06T17:41:00.000","Title":"Compile form in eric6, but show \"Could not start pyuic5, Ensure that it is in the search path.\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash).\nDoes anyone know how I can recover the notebook? I am using Mac OS X.\nThanks!","AnswerCount":12,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":68420,"Q_Id":38819322,"Users Score":28,"Answer":"This is bit of additional info on the answer by Thuener,\nI did the following to recover my deleted .ipynb file. \n\nThe cache is in ~\/.cache\/chromium\/Default\/Cache\/ (I use chromium)\nused grep in binary search mode, grep -a 'import math' (replace search string by a keyword specific in your code)\nEdit the  binary file in vim (it doesn't open in gedit)\n\n\nThe python ipynb should file start with  '{ \"cells\":' and\nends with  '\"nbformat\": 4, \"nbformat_minor\": 2}'\nremove everything outside these start and end points\n\nRename the file as .ipynb, open it in your jupyter-notebook, it works.","Q_Score":23,"Tags":"ipython-notebook,jupyter-notebook,recovery","A_Id":44044643,"CreationDate":"2016-08-07T22:58:00.000","Title":"How to recover deleted iPython Notebooks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash).\nDoes anyone know how I can recover the notebook? I am using Mac OS X.\nThanks!","AnswerCount":12,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":68420,"Q_Id":38819322,"Users Score":11,"Answer":"On linux:\nI did the same error and I finally found the deleted file in the trash\n\/home\/$USER\/.local\/share\/Trash\/files","Q_Score":23,"Tags":"ipython-notebook,jupyter-notebook,recovery","A_Id":59777233,"CreationDate":"2016-08-07T22:58:00.000","Title":"How to recover deleted iPython Notebooks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash).\nDoes anyone know how I can recover the notebook? I am using Mac OS X.\nThanks!","AnswerCount":12,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":68420,"Q_Id":38819322,"Users Score":0,"Answer":"Sadly my file was neither in the checkpoints directory, nor chromium's cache.  Fortunately, I had an ext4 formatted file system and was able to recover my file using extundelete:\n\nFigure out the drive your missing deleted file was stored on:\ndf \/your\/deleted\/file\/diretory\/\nSwitch to a folder located on another you have write access to:\ncd \/your\/alternate\/location\/\nIt is proffered to run extundlete on an unmounted partition. Thus, if your deleted file wasn't stored on the same drive as your operating system, it's recommended you unmount the partition of the deleted file (though you may want to ensure extundlete is already installed before proceeding):\nsudo umount \/dev\/sdax\nwhere sdax is the partition returned by your df command earlier\nUse extundelete to restore your file:\nsudo extundelete --restore-file  \/your\/deleted\/file\/diretory\/delted.file \/dev\/sdax\nIf successful your recovered file will be located at: \n\/your\/alternate\/location\/your\/deleted\/file\/diretory\/delted.file","Q_Score":23,"Tags":"ipython-notebook,jupyter-notebook,recovery","A_Id":52046886,"CreationDate":"2016-08-07T22:58:00.000","Title":"How to recover deleted iPython Notebooks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash).\nDoes anyone know how I can recover the notebook? I am using Mac OS X.\nThanks!","AnswerCount":12,"Available Count":4,"Score":0.0166651236,"is_accepted":false,"ViewCount":68420,"Q_Id":38819322,"Users Score":1,"Answer":"If you're using windows, it sends it to the recycle bin, thankfully.  Clearly, it's a good idea to make checkpoints.","Q_Score":23,"Tags":"ipython-notebook,jupyter-notebook,recovery","A_Id":53780758,"CreationDate":"2016-08-07T22:58:00.000","Title":"How to recover deleted iPython Notebooks","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Ubuntu 16.04 . I tried to install Tensorflow using Anaconda 2 . But it installed a Environment inside ubuntu . So i had to create a virtual environment and then use Tensorflow . Now how can i use both Tensorflow and Sci-kit learn together in a single environment .","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2492,"Q_Id":38828829,"Users Score":1,"Answer":"Anaconda defaults doesn't provide tensorflow yet, but conda-forge do, conda install -c conda-forge tensorflow should see you right, though (for others reading!) the installed tensorflow will not work on CentOS < 7 (or other Linux Distros of a similar vintage).","Q_Score":2,"Tags":"python,pycharm,tensorflow,anaconda,ubuntu-16.04","A_Id":39021770,"CreationDate":"2016-08-08T12:08:00.000","Title":"How to use Tensorflow and Sci-Kit Learn together in one environment in PyCharm?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"To python experts:\nI put lots of print() to check the value of my variables.\nOnce I'm done, I need to delete the print(). It quite time-consuming and prompt to human errors.\nWould like to learn how do you guys deal with print(). Do you delete it while coding or delete it at the end? Or there is a method to delete it automatically or you don't use print()to check the variable value?","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":306,"Q_Id":38841865,"Users Score":2,"Answer":"You can use logging with debug level and once the debugging is completed, change the level to info. So any statements with logger.debug() will not be printed.","Q_Score":2,"Tags":"python","A_Id":38842389,"CreationDate":"2016-08-09T04:07:00.000","Title":"How do you deal with print() once you done with debugging\/coding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"To python experts:\nI put lots of print() to check the value of my variables.\nOnce I'm done, I need to delete the print(). It quite time-consuming and prompt to human errors.\nWould like to learn how do you guys deal with print(). Do you delete it while coding or delete it at the end? Or there is a method to delete it automatically or you don't use print()to check the variable value?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":306,"Q_Id":38841865,"Users Score":0,"Answer":"What I do is put print statements in with with a special text marker in the string. I usually use print(\"XXX\", thething). Then I just search for and delete the line with that string. It's also easier to spot in the output.","Q_Score":2,"Tags":"python","A_Id":38843280,"CreationDate":"2016-08-09T04:07:00.000","Title":"How do you deal with print() once you done with debugging\/coding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently trying to run an R script from the command line (my end goal is to execute it as the last line of a python script).  I'm not sure what a batch file is, or how to make my R script 'executable'. Currently it is saved as a .R file.  It works when I run it from R.\nHow do I execute this from the windows command prompt line? Do i need to download something called Rscript.exe? Do I just save my R script as an .exe file? Please advise on the easiest way to achieve this.\nR: version 3.3   python: version 3.x  os: windows","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":3887,"Q_Id":38856271,"Users Score":1,"Answer":"You probably already have R, since you can already run your script.\nAll you have to do is find its binaries (the Rscript.exe file).\nThen open windows command line ([cmd] + [R] > type in : \"cmd\" > [enter])\nEnter the full path to R.exe, followed by the full path to your script.","Q_Score":4,"Tags":"python,r,shell,command-line","A_Id":38856331,"CreationDate":"2016-08-09T16:42:00.000","Title":"Running an R script from command line (to execute from python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently trying to run an R script from the command line (my end goal is to execute it as the last line of a python script).  I'm not sure what a batch file is, or how to make my R script 'executable'. Currently it is saved as a .R file.  It works when I run it from R.\nHow do I execute this from the windows command prompt line? Do i need to download something called Rscript.exe? Do I just save my R script as an .exe file? Please advise on the easiest way to achieve this.\nR: version 3.3   python: version 3.x  os: windows","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":3887,"Q_Id":38856271,"Users Score":3,"Answer":"You already have Rscript, it came with your version of R. If R.exe, Rgui.exe, ... are in your path, then so is Rscript.exe.\nYour call from Python could just be Rscript myFile.R.  Rscript is much better than R BATCH CMD ... and other very old and outdated usage patterns.","Q_Score":4,"Tags":"python,r,shell,command-line","A_Id":38856393,"CreationDate":"2016-08-09T16:42:00.000","Title":"Running an R script from command line (to execute from python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wish to add more python modules to my yocto\/openembedded project but I am unsure how to?  I wish to add flask and its dependencies.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":20667,"Q_Id":38862088,"Users Score":3,"Answer":"The OE layer index at layers.openembedded.org lists all known layers and the recipes they contain, so searching that should bring up the meta-python layer that you can add to your build and use recipes from.","Q_Score":13,"Tags":"python,linux,yocto,bitbake,openembedded","A_Id":38865576,"CreationDate":"2016-08-09T23:38:00.000","Title":"How do I add more python modules to my yocto\/openembedded project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new in embedded programming, and would like to understand what I need to do to run python scikit-learn on a capable embedded processor.\nSee Raspberry Pi as an example.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":18641,"Q_Id":38865708,"Users Score":0,"Answer":"scikit-learn will run on a Raspberry Pi just as well as any other Linux machine.\nTo install it, make sure you have pip3 (sudo apt-get install python3-pip), and use sudo pip3 install scikit-learn.\nAll Python scripts utilizing scikit-learn will now run as normal.","Q_Score":0,"Tags":"python,raspberry-pi,scikit-learn","A_Id":38866597,"CreationDate":"2016-08-10T06:23:00.000","Title":"How can I run python scikit-learn on Raspberry Pi?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Anaconda for python 3.5 and python 2.7 seems to install just as a drop in folder inside my home folder on Ubuntu.  Is there an installed version of Anaconda for Ubuntu 16?  I'm not sure how to ask this but do I need python 3.5 that comes by default if I am also using Anaconda 3.5?  \nIt seems like the best solution is docker these days.  I mean I understand virtualenv and virtualenvwrapper.  However, sometimes I try to indicate in my .bashrc that I want to use python 3.5 and yet I'll use the command mkvirtualenv and it will start installing the python 2.7 versions of python.  \nShould I choose either Anaconda or the version of python installed with my OS from python.org or is there an easy way to manage many different versions of Python?\nThanks,\nBruce","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3184,"Q_Id":38882845,"Users Score":0,"Answer":"Use anaconda version Anaconda3-4.2.0-Linux-x86_64.sh from the anaconda installer archive.This comes with python 3.5. This worked for me.","Q_Score":1,"Tags":"python,python-2.7,python-3.x,ubuntu,anaconda","A_Id":46602056,"CreationDate":"2016-08-10T20:22:00.000","Title":"How to get Python 3.5 and Anaconda 3.5 running on ubuntu 16.04?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the \"service simulator\" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors?\nHere's my situation:\nI have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid.\nI copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not).\nHow can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch\/logs related to this particular lambda or for the skill.\nNot sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3387,"Q_Id":38887061,"Users Score":0,"Answer":"My guess would be that you missed a step on setup. There's one where you have to set the \"event source\". IF you don't do that, I think you get that message.\nBut the debug options are limited. I wrote EchoSim (the original one on GitHub) before the service simulator was written and, although it is a bit out of date, it does a better job of giving diagnostics.\nLacking debug options, the best is to do what you've done. Partition and re-test. Do static replies until you can work out where the problem is.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-dynamodb,aws-lambda,alexa-skills-kit","A_Id":38895935,"CreationDate":"2016-08-11T04:02:00.000","Title":"Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the \"service simulator\" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors?\nHere's my situation:\nI have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid.\nI copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not).\nHow can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch\/logs related to this particular lambda or for the skill.\nNot sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3387,"Q_Id":38887061,"Users Score":3,"Answer":"tl;dr: The remote endpoint could not be called, or the response it returned was invalid. also means there may have been a timeout waiting for the endpoint. \nI was able to narrow it down to a timeout. \nSeems like the Alexa service simulator (and the Alexa itself) is less tolerant to long responses than the lambda testing console. During development I had increased the timeout of ARN:1 to 30 seconds (whereas I believe the default is 3 seconds). The DynamoDB table used by ARN:1 has more data and it takes slightly longer to process than ARN:3 which has an almost empty table. As soon as I commented out some of the data loading stuff it was running slightly faster and the Alexa service simulator was working again. I can't find the time budget documented anywhere, I'm guessing 3 seconds? I most likely need to move to another backend, DynamoDB+Python on lambda is too slow for very trivial requests.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-dynamodb,aws-lambda,alexa-skills-kit","A_Id":38902127,"CreationDate":"2016-08-11T04:02:00.000","Title":"Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the \"service simulator\" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors?\nHere's my situation:\nI have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid.\nI copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not).\nHow can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch\/logs related to this particular lambda or for the skill.\nNot sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":3387,"Q_Id":38887061,"Users Score":1,"Answer":"I think the problem you having for ARN:1 is you probably didn't set a trigger to alexa skill in your lambda function.\nOr it can be the alexa session timeout which is by default set to 8 seconds.","Q_Score":2,"Tags":"python,amazon-web-services,amazon-dynamodb,aws-lambda,alexa-skills-kit","A_Id":39245816,"CreationDate":"2016-08-11T04:02:00.000","Title":"Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Purpose:\nI'm making a program that will set up a dedicated server (software made by game devs) for a game with minimal effort. One common step in making the server functional is port forwarding by making a port forward rule on a router.\nMe and my friends have been port forwarding through conventional means for many years with mixed results. As such I am hoping to build a function that will forward a port on a router when given the internal ip of the router, the internal ip of the current computer,the port and the protocol. I have looked for solutions for similar problems, but I found the solutions difficult to understand since i'm not really familiar with the socket module. I would prefer not to use any programs that are not generally installed on windows since I plan to have this function work on systems other than my own.\nApproaches I have explored:\nCreating a bat file that issues commands by means of netsh, then running the bat.\nMaking additions to the settings in a router found under Network -> Network Infrastructure (I do not know how to access these settings programmaticly).\n(I'm aware programs such as GameRanger do this)\nUsing the Socket Module.\nIf anyone can shed some light how I can accomplish any of the above approaches or give me some insight on how I can approach this problem another way I would greatly appreciate it.\nThank you.\nEdit: Purpose","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":707,"Q_Id":38931064,"Users Score":0,"Answer":"I'm not sure if that's possible, as much as I know, ports aren't actually a thing their just some abstraction convention made by protocols today and supported by your operating system that allows you to have multiple connections per one machine,\nnow sockets are basically some object provided to you by the operating system that implements some protocol stack and allows you to communicate with other systems, the API provides you some very nice API called the socket API which allows you use it's functionality in order to communicate with other computers, Port forwarding is not an actual thing, it just means that when the operating system of the router when receiving incoming packets that are destined to some port it will drop them if the port is not open, think of your router as some bouncer or doorman, standing in the entrance of a building, the building is your LAN, your apartment is your machine and rooms within your apartment are ports, some package or mail arrives to your doorman under the port X, a port rule means on IP Y and Port X of the router -> forward to IP Z and port A of some computer within the LAN ( provides and implements the NAT\/PAT ) so what happens if we'll go back to my analogy is something such as this: doorman receives mail destined to some port, and checks if that port is open, if not it drops the mail if it is it allows it to go to some room within some apartment.. (sounds complex I know apologize) my point is, every router chooses to implement port rules or port blocking a little bit different and there is no standard protocol for doing, socket is some object that allows you program to communicate with others, you could create some server - client with sockets but that means that you'll need to create or program your router, and I'm not sure if that's possible,\nwhat you COULD do is:\nevery router provides some http client ( web client ) that is used to create and forward ports, maybe if you read about your router you could get access to that client and write some python http script that forwards ports automatically\nanother point I've forgot is that you need to make sure you're own firewall isn't blocking ports, but there's no need for sockets \/ python to do so, just manually config it","Q_Score":3,"Tags":"python,sockets,batch-file,portforwarding","A_Id":38932875,"CreationDate":"2016-08-13T09:00:00.000","Title":"How to make a port forward rule in Python 3 in windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Purpose:\nI'm making a program that will set up a dedicated server (software made by game devs) for a game with minimal effort. One common step in making the server functional is port forwarding by making a port forward rule on a router.\nMe and my friends have been port forwarding through conventional means for many years with mixed results. As such I am hoping to build a function that will forward a port on a router when given the internal ip of the router, the internal ip of the current computer,the port and the protocol. I have looked for solutions for similar problems, but I found the solutions difficult to understand since i'm not really familiar with the socket module. I would prefer not to use any programs that are not generally installed on windows since I plan to have this function work on systems other than my own.\nApproaches I have explored:\nCreating a bat file that issues commands by means of netsh, then running the bat.\nMaking additions to the settings in a router found under Network -> Network Infrastructure (I do not know how to access these settings programmaticly).\n(I'm aware programs such as GameRanger do this)\nUsing the Socket Module.\nIf anyone can shed some light how I can accomplish any of the above approaches or give me some insight on how I can approach this problem another way I would greatly appreciate it.\nThank you.\nEdit: Purpose","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":707,"Q_Id":38931064,"Users Score":0,"Answer":"You should read first some sort of informations about UPnP (Router Port-Forwarding) and that it's normally disabled.  \nDependent of your needs, you could also try a look at ssh reverse tunnels and at ssh at all, as it can solve many problems.\nBut you will see that working with windows and things like adavanced network things is a bad idea.\nAt least you should use cygwin.  \nAnd when you really interessted in network traffic at all, wireshark should be installed.","Q_Score":3,"Tags":"python,sockets,batch-file,portforwarding","A_Id":38932807,"CreationDate":"2016-08-13T09:00:00.000","Title":"How to make a port forward rule in Python 3 in windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can't seem to find a good explanation of how to use Python modules. Take for example the urllib module. It has commands such as\nreq = urllib.request.Request().\nHow would I find out what specific commands, like this one, are in certain Python modules?\nFor all the examples I've seen of people using specific Python modules, they just know what to type, and how to use them. \nAny suggestions will be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":138,"Q_Id":38936584,"Users Score":1,"Answer":"My flow chart looks something like this:\n\nReading the published documentation (or use help(moduleName) which gives you the same information without an internet connection in a harder to read format). This can be overly verbose if you're only looking for one tidbit of information, in which case I move on to...\nFinding tutorials or similar stack overflow posts using specific keywords in your favorite search engine. This is generally the approach you will use 99% of the time.\nJust recursively poking around with dir() and __doc__ if you think the answer for what you're looking for is going to be relatively obvious (usually if the module has relatively simple functions such as math that are obvious by the name)\nLooking at the source of the module if you really want to see how things works.","Q_Score":1,"Tags":"python,python-3.x,python-module","A_Id":38937103,"CreationDate":"2016-08-13T20:12:00.000","Title":"How to find good documentation for Python modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"By mistake, I updated this file to customize css.\nD:\\Continuum\\Anaconda2\\Lib\\site-packages\\notebook\\static\\custom\\custom.css\nTo rollback the above change, \n1) I put back the original file that I saved before. still the new css shows up in jupyter.\n2) I removed all .ipython and .jupyter dir and it didn't work either.\n3) I even uninstalled anaconda and still that css shows up.\nI'm really stuck here. Does anyone know how to go back to the default css of jupyter ?","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":770,"Q_Id":38944204,"Users Score":5,"Answer":"Reposting as an answer:\nWhen your changes don't seem to be taking effect in an HTML interface, browser caching is often a culprit. The browser saves time by not asking for files again. You can:\n\nTry force-refreshing with Ctrl-F5. It may get some things from the cache anyway, though sometimes mashing it several times is effective.\nUse a different browser profile, or private browsing mode, to load the page.\nThere may be a setting to disable caching under developer options. I think Chrome has this. May only apply while developer tools are open.\nIf all else fails, load the page using a different browser. If it still doesn't change, it's likely the problem is not (just) browser caching.","Q_Score":2,"Tags":"ipython,jupyter,jupyter-notebook","A_Id":38944682,"CreationDate":"2016-08-14T16:27:00.000","Title":"jupyter custom.css removal","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Let's say I want to write a 16bit linear feedback shift register LFSR in Python using its native shift operator.\n\nDoes the operator itself have a feature to specify the bit to shifted into the new MSB position? \nDoes the operator have a carry flag or the like to catch the LSB falling out of the register?\nHas to setup the register to 16bit size? Not sure how to do this in Python where variables are not clearly typed.\nWhat's the smartest way to compute the multi-bit XOR function for the feedback. Actual bit extraction or lookup table?\n\nThanks,\nGert","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":384,"Q_Id":38948430,"Users Score":1,"Answer":"Python does not have registers and you cannot declare the type of anything. \nThe shift operators operate on unlimited-precision integers. If you shift left, the number will continue to get larger indefinitely (or until out of memory). If you shift right, the least-significant bit is dropped as you would expect. There is no \"carry flag\", that's the kind of thing you see in assembly language and Python is not assembly. Since the integers have unlimited precision, logical and arithmetic shifts are equivalent, in a sense (if you imagine that the sign bit repeats indefinitely).\nAny time you want fixed width operations you will just have to mask the results of the unlimited-precision operations. \nAs for the \"smartest\" way to do something, that's not really an appropriate question for Stack Overflow.","Q_Score":0,"Tags":"python,bit-shift","A_Id":38948543,"CreationDate":"2016-08-15T02:12:00.000","Title":"Using shift operator for LFSR in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a website built with Django.\nWhen I'm doing updates on the static files, the users have to hard refresh the website to get the latest version.\nI'm using a CDN server to deliver my static files so using the built-in static storage from Django.\nI don't know about the best practices but my idea is to generate a random string when I redeploy the website and have something like style.css?my_random_string.\nI don't know how to handle such a global variable through the project (Using Gunicorn in production).\nI have a RedisDB running, I can store the random string in it and clear it on redeployment.\nI was thinking to have this variable globally available in templates with a context_processors.  \nWhat are your thoughts on this ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":865,"Q_Id":38954505,"Users Score":0,"Answer":"Here's my work around : \nOn deployment (from a bash script), I get the shasum of my css style.\nI put this variable inside the environment.  \nI have a context processor for the template engine that will read from the environment.","Q_Score":1,"Tags":"python,django,caching,static,cdn","A_Id":38956967,"CreationDate":"2016-08-15T11:48:00.000","Title":"Cache busting with Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"First time posting, let me know how I can improve my questions.\nI have installed PyCharm Edu 3.0 and Anaconda 3 on an older laptop. I am attempting to access the embedded terminal in the IDE and I am unable to launch it.\nI have searched through similar questions here and the JetBrains docs, and the common knowledge seems to be installing the \"Terminal\" Plugin. My version of PyCharm does not have this plugin, and I am unable to find it in the JetBrains plugin list or community repositories.\nIf anyone has experienced this before or knows where I am going wrong attempting to launch the terminal I would appreciate the feedback.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":628,"Q_Id":38966114,"Users Score":0,"Answer":"Go to File > Settings > Plugins > Browse repositories > Search and Install Native Terminal\nThis will install a terminal which will use the Windows Native terminal.\nA small black button will appear on the tool bar.\nIf you did not enable the tool bar, here is the trick: View | toolbar\ncheck this toolbar option and the cmd button will be shown on the bar","Q_Score":1,"Tags":"python,django,intellij-idea,ide,pycharm","A_Id":53610811,"CreationDate":"2016-08-16T03:16:00.000","Title":"Pycharm edu terminal plugin missing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"First time posting, let me know how I can improve my questions.\nI have installed PyCharm Edu 3.0 and Anaconda 3 on an older laptop. I am attempting to access the embedded terminal in the IDE and I am unable to launch it.\nI have searched through similar questions here and the JetBrains docs, and the common knowledge seems to be installing the \"Terminal\" Plugin. My version of PyCharm does not have this plugin, and I am unable to find it in the JetBrains plugin list or community repositories.\nIf anyone has experienced this before or knows where I am going wrong attempting to launch the terminal I would appreciate the feedback.","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":628,"Q_Id":38966114,"Users Score":-1,"Answer":"Click preferences and choose plugin. Next click install Jetbrains plugin and choose Command line Tool Support. I hope this will help you","Q_Score":1,"Tags":"python,django,intellij-idea,ide,pycharm","A_Id":43782480,"CreationDate":"2016-08-16T03:16:00.000","Title":"Pycharm edu terminal plugin missing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a program that spawns multiple child processes, how would I make the program only call atexit.register(function) on the main process and not on the child processes as well?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":38966528,"Users Score":0,"Answer":"The functions registered via atexit are inherited by the children processes.\nThe simplest way to prevent that, is via calling atexit after you have spawned the children processes.","Q_Score":0,"Tags":"python-3.x,process,multiprocessing,parent-child,atexit","A_Id":38981627,"CreationDate":"2016-08-16T04:09:00.000","Title":"Python3 Running atexit only on the main process","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Background: I have a sequence of images. In each image, I map a single pixel to a number. Then I want to create a pandas dataframe where each pixel is in its own column and images are rows. The reason I want to do that is so that I can use things like forward fill.\nChallenge: I have transformed each image into a one dimensional array of numbers, each of which is about 2 million entries and I have thousands of images. Simply doing pd.DataFrame(array) is very slow (testing it on a smaller number of images). Is there a faster solution for this? Other ideas how to do this efficiently are also welcome, but using non-core different libraries may be a challenge (corporate environment).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":310,"Q_Id":38976431,"Users Score":0,"Answer":"Out of curiosity, is there a reason you want to use Pandas for this?  Image analysis is typically handled in matrices making NumPy a clear favorite.  If I'm not mistaken, both sk-learn and PIL\/IMAGE use NumPy arrays to do their analysis and operations.\nAnother option:  avoid the in-memory step!  Do you need to access all 1K+ images at the same time?  If not, and you're operating on each one individually, you can iterate over the files and perform your operations there.  For an even more efficient step, break your files into lists of 200 or so images, then use Python's MultiProcessing capabilities to analyze in parallel.\nJIC, do you have PIL or IMAGE installed, or sk-learn?  Those packages have some nice image analysis algorithms already packaged in which may save you some time in not having to re-invent the wheel.","Q_Score":1,"Tags":"python,pandas,numpy,large-data","A_Id":38976616,"CreationDate":"2016-08-16T13:35:00.000","Title":"Initializing a very large pandas dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I built my random forest model using scikit learn in python, I set a condition (where clause in sql query) so that the training data only contain values whose value is greater than 0.\nI am curious to know how random forest handles test data whose value is less than 0, which the random forest model has never seen before in the training data.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":709,"Q_Id":38980544,"Users Score":0,"Answer":"They will be treated in the same manner as the minimal value already encountered in the training set. RF is just a bunch of voting decision trees, and (basic) DTs can only form decisions in form of \"if feature X is > then T go left, otherwise go right\". Consequently, if you fit it to data which, for a given feature, has only values in [0, inf], it will either not use this feature at all or use it in a form given above (as decision of form \"if X is > than T\", where T has to be from (0, inf) to make any sense for the training data). Consequently if you simply take your new data and change negative values to \"0\", the result will be identical.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,random-forest","A_Id":38980686,"CreationDate":"2016-08-16T16:57:00.000","Title":"What does Random Forest do with unseen data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to use nltk in python, but am receiving a pop up error (windows) describing that I am missing a drive at the moment I call import nltk\nDoes anyone know why or how to fix this?\nThe error is below:\n\"There is no disk in the drive. Please insert a disk into drive \\Device\\Harddisk4\\DR4.\"","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":895,"Q_Id":38984387,"Users Score":1,"Answer":"While i am not sure exactly where the problem arises, I had this same error happen to me (it started 'overnight' - the code had been working, i hand not re-installed nltk, so i have no idea what caused it to start happening). I still had the problem after upgrading to the latest version of nltk (3.2.1), and re-downloading the nltk data. \nshiratori's answer helped me solve my problem, although at least for me it was slightly more complicated. Specifically, my nltk data was stored in C:\\Users\\USERNAME\\AppData\\Roaming\\nltk_data (i think this is a default location). This is where it had always been stored, and always had worked fine, however suddenly nltk did not seem to be recognizing this location, and hence looked in the next drive. To solve it, I copied and pasted all the data in that folder to C:\\nltk_data and now it is running fine again.\nAnyway, not sure if this is Windows induced problem, or what exactly changed to cause code that was working to stop working, but this solved it.","Q_Score":4,"Tags":"python,nltk","A_Id":40272424,"CreationDate":"2016-08-16T20:59:00.000","Title":"Drive issue with python NLTK","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I know how to install external modules using the pip command but for Scikit-learn I need to install NumPy and Matplotlib as well.\nHow can I install these modules using the pip command?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2435,"Q_Id":38989896,"Users Score":0,"Answer":"Old post, but right answer is,\n'sudo pip install -U numpy matplotlib --upgrade' for python2 or 'sudo pip3 install -U numpy matplotlib --upgrade' for python3","Q_Score":1,"Tags":"python,windows,scikit-learn","A_Id":46249521,"CreationDate":"2016-08-17T06:49:00.000","Title":"How to install scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to install external modules using the pip command but for Scikit-learn I need to install NumPy and Matplotlib as well.\nHow can I install these modules using the pip command?","AnswerCount":2,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2435,"Q_Id":38989896,"Users Score":-1,"Answer":"Using Python 3.4, I run the following from the command line:\nc:\\python34\\python.exe -m pip install package_name\nSo you would substitute \"numpy\" and \"matplotlib\" for 'package_name'","Q_Score":1,"Tags":"python,windows,scikit-learn","A_Id":38990089,"CreationDate":"2016-08-17T06:49:00.000","Title":"How to install scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I get a message that says my GPU Device is ignored because its multiprocessor count is lower than the minimum set. However, it gives me the environment variable TF_MIN_GPU_MULTIPROCESSOR_COUNT but it doesn't seem to exist because I keep getting command not found. When I look at the environment variables using set or printenv and grep for the variable name, it doesn't exist. Does anyone know where I can find it or how I can change its set value?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2221,"Q_Id":39003909,"Users Score":3,"Answer":"Do something like this before running your main script\nexport TF_MIN_GPU_MULTIPROCESSOR_COUNT=4 \nNote though that the default is set for a reason -- if you enable slower GPU by changing that variable, your program may run slower than it would without any GPU available, because TensorFlow will try to put run everything on that GPU","Q_Score":0,"Tags":"python,tensorflow,gpu","A_Id":39004702,"CreationDate":"2016-08-17T18:30:00.000","Title":"Can't find TF_MIN_GPU_MULTIPROCESSOR_COUNT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I get a message that says my GPU Device is ignored because its multiprocessor count is lower than the minimum set. However, it gives me the environment variable TF_MIN_GPU_MULTIPROCESSOR_COUNT but it doesn't seem to exist because I keep getting command not found. When I look at the environment variables using set or printenv and grep for the variable name, it doesn't exist. Does anyone know where I can find it or how I can change its set value?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2221,"Q_Id":39003909,"Users Score":0,"Answer":"In windows, create a new environmental variable with this name and assign its value.  \nYou can do that by right clicking on the This PC  in File Explorer, select Properties at bottom, then select Advanced system settings on left.  That will get you to the System Properties dialog.  Also you can type \"environmental properties\" in Cortana Search.  \nFrom there you click the Environmental Variables button.  Once in the Environmental Variables dialog, select new to create the variable and assign the value, then back out.  You may have to restart your IDE or open a new DOS window for that environmental variable to be visible.","Q_Score":0,"Tags":"python,tensorflow,gpu","A_Id":56837569,"CreationDate":"2016-08-17T18:30:00.000","Title":"Can't find TF_MIN_GPU_MULTIPROCESSOR_COUNT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Any idea how this can be done? ie, if we have a variable defined in java as below\npublic Class Foo {\n   String pass = \"foo\";\n}\nhow can I access this via jpype since pass is a reserved keyword? I tried\ngetattr(Jpype.JClass(Foo)(), \"pass\") but it fails to find the attribute named pass","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":358,"Q_Id":39007823,"Users Score":1,"Answer":"Figured out that jpype appends an \"_\" at the end for those methods\/fields in its source code. So you can access it by Jpype.JClass(\"Foo\").pass_\nWish it's documented somewhere","Q_Score":1,"Tags":"java,python,type-conversion,reserved-words,jpype","A_Id":39027662,"CreationDate":"2016-08-17T23:37:00.000","Title":"jpype accessing java mehtod\/variable whose name is reserved name in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Any idea how this can be done? ie, if we have a variable defined in java as below\npublic Class Foo {\n   String pass = \"foo\";\n}\nhow can I access this via jpype since pass is a reserved keyword? I tried\ngetattr(Jpype.JClass(Foo)(), \"pass\") but it fails to find the attribute named pass","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":358,"Q_Id":39007823,"Users Score":0,"Answer":"unfortunally Fields or methods conflicting with a python keyword can\u2019t be accessed","Q_Score":1,"Tags":"java,python,type-conversion,reserved-words,jpype","A_Id":39007952,"CreationDate":"2016-08-17T23:37:00.000","Title":"jpype accessing java mehtod\/variable whose name is reserved name in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a django project where I am using celery with rabbitmq to perform a set of async. tasks. So the setup i have planned goes like this.\n\nDjango app running on one server.\nCelery workers and rabbitmq running from another server.\n\nMy initial issue being, how to do i access django models from the celery tasks resting on another server?\nand assuming I am not able to access the Django models, is there a way once the tasks gets completed, i can send a callback to the Django application passing values, so that i get to update the Django's database based on the values passed?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1298,"Q_Id":39017678,"Users Score":0,"Answer":"I've used the following set up on my application:\n\nTask is initiated from Django - information is extracted from the model instance and passed to the task as a dictionary. NB - this will be more future proof as Celery 4 will default to JSON encoding\nRemote server runs task and creates a dictionary of results\nRemote server then calls an update task that is only listened for by a worker on the Django server.\nDjango worker read results dictionary and updates model.\n\nThe Django worker listens to a separate queue, those this isn't strictly necessary. Results backend isn't used - data needed is just passed to the task","Q_Score":5,"Tags":"python,django,asynchronous,rabbitmq,celery","A_Id":39065804,"CreationDate":"2016-08-18T11:59:00.000","Title":"Django and celery on different servers and celery being able to send a callback to django once a task gets completed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm thinking of something like\npython3 my_script.py --pythonpath \/path\/to\/some\/necessary\/modules\nIs there something like this? I know (I think) that Pycharm temporarily modifies PYTHONPATH when you use it to execute scripts; how does Pycharm do it?\nReasons I want to do this (you don't really need to read the following)\nThe reason I want to do this is that I have some code that usually needs to run on my own machine (which is fine because I use Pycharm to run it) but sometimes needs to run on a remote server (on the commandline), and it doesn't work because the remote server doesn't have the PYTHONPATHs that Pycharm automatically temporarily adds. I don't want to export PYTHONPATH=[...] because it's a big hassle to change it often (and suppose it really does need to change often).","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3666,"Q_Id":39022629,"Users Score":0,"Answer":"Not sure how much effort you want to put into this temporary python path thing but you could always use a python virtual environment for running scripts or whatever you need.","Q_Score":8,"Tags":"python,pycharm,pythonpath","A_Id":39022921,"CreationDate":"2016-08-18T15:53:00.000","Title":"Provide temporary PYTHONPATH on the commandline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded from github a package (scikit-lean) and put the code source in repository folder (Windows 7 64-bit).\nAfter modifying the code source, how can I load the package into the IPython notebook for testing ?\n\nShould I copy paste the modified in sites-packages folder ?\n(what about the current original scikit-lean package)\nCan I add the modified folder to the Python path ?\nHow to manage versioning when loading package in Python since both are same names ?\n  (ie: the original package vs the package I modified)\n\nSorry, it looks like beginner questions, but could not find anything how to start with","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":85,"Q_Id":39023270,"Users Score":0,"Answer":"If the code is in a file called file.py, you should just be able to do import file (if you're not in the right folder, just run cd folder  in IPython first.)","Q_Score":0,"Tags":"python,scikit-learn,ipython","A_Id":39031052,"CreationDate":"2016-08-18T16:30:00.000","Title":"How to load a code source modified package in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django application where I use django-storages and amazon s3 to store images.\nI need to move those images to a different account: different user different bucket.\nI wanted to know how do I migrate those pictures?\nmy main concern is the links in my database to all those images, how do I update it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":39062605,"Users Score":0,"Answer":"The URL is relative to the amazon storage address you provide in your settings. so you only need to move the images to a new bucket and update your settings.","Q_Score":0,"Tags":"django,amazon-s3,python-django-storages","A_Id":39062626,"CreationDate":"2016-08-21T09:08:00.000","Title":"changing s3 storages with django-storages","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a code to read serial input. Once the serial input has been read, I have to add a time stamp below it and then the output from a certain software. To get the output from the software, I want python to write a certain command to the terminal, and then read the output that comes on the terminal. Could you suggest how do I go about doing the last step: namely, writing to the terminal then reading the output? I'm a beginner in python, so please excuse me if this sounds trivial.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":338,"Q_Id":39064796,"Users Score":0,"Answer":"You would need to have python implemented into the software. \nAlso, I believe this is a task for GCSE Computing this year as I was privileged enough to choose what test we are doing and there was a question about serial numbers.","Q_Score":0,"Tags":"python,python-2.7,terminal","A_Id":39064972,"CreationDate":"2016-08-21T13:36:00.000","Title":"Giving input to terminal in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an application (spark based service), which when starts..works like following.\nAt localhost:9000\nif I do nc -lk localhost 9000 \nand then start entering the text.. it takes the text entered in terminal as an input and do a simple wordcount computation on it.\nhow do i use the requests library to programmatically send the text, instead of manually writing them in the terminal.\nNot sure if my question is making sense..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":32,"Q_Id":39086420,"Users Score":1,"Answer":"requests is a HTTP request library, while Spark's wordcount example provides a raw socket server, so no, requests is not the right package to communicate with your Spark app.","Q_Score":0,"Tags":"python,python-requests","A_Id":39086692,"CreationDate":"2016-08-22T18:32:00.000","Title":"Using requests package to make request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For my app, I am using Flask, however the question I am asking is more general and can be applied to any Python web framework.\nI am building a comparison website where I can update details about products in the database. I want to structure my app so that 99% of users who visit my website will never need to query the database, where information is instead retrieved from the cache (memcached or Redis).\nI require my app to be realtime, so any update I make to the database must be instantly available to any visitor to the site. Therefore I do not want to cache views\/routes\/html.\nI want to cache the entire database. However, because there are so many different variables when it comes to querying, I am not sure how to structure this. For example, if I were to cache every query and then later need to update a product in the database, I would basically need to flush the entire cache, which isn't ideal for a large web app.\nI would prefer is to cache individual rows within the database. The problem is, how do I structure this so I can flush the cache appropriately when an update is made to the database? Also, how can I map all of this together from the cache?\nI hope this makes sense.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":488,"Q_Id":39128100,"Users Score":0,"Answer":"I had this exact question myself, with a PHP project, though. My solution was to use ElasticSearch as an intermediate cache between the application and database.\nThe trick to this is the ORM. I designed it so that when Entity.save() is called it is first stored in the database, then the complete object (with all references) is pushed to ElasticSearch and only then the transaction is committed and the flow is returned back to the caller.\nThis way I maintained full functionality of a relational database (atomic changes, transactions, constraints, triggers, etc.) and still have all entities cached with all their references (parent and child relations) together with the ability to invalidate individual cached objects.\nHope this helps.","Q_Score":2,"Tags":"python,database,caching,redis,memcached","A_Id":39128415,"CreationDate":"2016-08-24T16:03:00.000","Title":"How do I structure a database cache (memcached\/Redis) for a Python web app with many different variables for querying?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can i write x.append(1-e^(-value1^2\/2*value2^2)) in python 2.7?\nI don't know how to use power operator and e.","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":248925,"Q_Id":39154611,"Users Score":0,"Answer":"Just to add, numpy also has np.e","Q_Score":48,"Tags":"python,python-2.7,math,equation,exp","A_Id":71583338,"CreationDate":"2016-08-25T20:57:00.000","Title":"How can I use \"e\" (Euler's number) and power operation in python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new in odoo, I want to know how we get the current flag\/state of every operation.\nFor example: when we create a new record how do we know the current flag\/state is \"add\"? or when we view a record how do we know the current flag\/state is \"view\"? \nIt something like current user id that stored in session named \"uid\", is there something similar to get the current flag\/state in every operation?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":107,"Q_Id":39160816,"Users Score":0,"Answer":"There is no such thing as 'flag\/state'. \nWhat you are probably trying to say is that you want to know which operations are taking place on a record. The easiest method is to take a look at your log. There will be statements there in the form \/web\/dataset\/call_kw\/model\/operation where model is your ORM model and operation could be a search, read, unlink etc. RPC calls are logged in there as well. The format of the log output is a little bit different between different versions of odoo. You can go to a lower level by monitoring sql transactions on postgresql but I do not think that this is what you want.","Q_Score":1,"Tags":"python,web,openerp","A_Id":39180410,"CreationDate":"2016-08-26T07:34:00.000","Title":"How to get the flag\/state of current operation in Odoo 9?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the LSTM model that comes by default in tensorflow. I would like to check or to know how to save or show the values of the forget gate in each step, has anyone done this before or at least something similar to this?\nTill now I have tried with tf.print but many values appear (even more than the ones I was expecting) I would try plotting something with tensorboard but I think those gates are just variables and not extra layers that I can print (also cause they are inside the TF script)\nAny help will be well received","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1695,"Q_Id":39168025,"Users Score":2,"Answer":"If you are using tf.rnn_cell.BasicLSTMCell , the variable you are looking for will have the following suffix in its name : <parent_variable_scope>\/BasicLSTMCell\/Linear\/Matrix . This is a concatenated matrix for all the four gates. Its first dimension matches the sum of the second dimensions of the input matrix and the state matrix (or output of the cell to be exact). The second dimension is 4 times the number of cell size.\nThe other complementary variable is <parent_variable_scope>\/BasicLSTMCell\/Linear\/Bias that is a vector of the same size as the second dimension of the abovementioned tensor (for obvious reasons).\nYou can retrieve the parameters for the four gates by using tf.split() along dimension 1. The split matrices would be in the order [input], [new input], [forget], [output]. I am referring to the code here form rnn_cell.py.\nKeep in mind that the variable represents the parameters of the Cell and not the output of the respective gates. But with the above info, I am sure you can get that too, if you so desire.\nEdit:\nAdded more specific information about the actual tensors Matrix and Bias","Q_Score":5,"Tags":"python,neural-network,tensorflow,lstm","A_Id":39177157,"CreationDate":"2016-08-26T13:54:00.000","Title":"Tensorflow: show or save forget gate values in LSTM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a number of data sets, each containing x, y, and y_error values, and I'm simply trying to calculate the average value of y at each x across these data sets. However the data sets are not quite the same length. I thought the best way to get them to an equal length would be to use scipy's interoplate.interp1d for each data set. However, I still need to be able to calculate the error on each of these averaged values, and I'm quite lost on how to accomplish that after doing an interpolation.\nI'm pretty new to Python and coding in general, so I appreciate your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":403,"Q_Id":39172559,"Users Score":0,"Answer":"As long as you can assume that your errors represent one-sigma intervals of normal distributions, you can always generate synthetic datasets, resample and interpolate those, and compute the 1-sigma errors of the results.\nOr just interpolate values+err and values-err, if all you need is a quick and dirty rough estimate.","Q_Score":0,"Tags":"python,scipy,interpolation","A_Id":39174418,"CreationDate":"2016-08-26T18:23:00.000","Title":"Python: How to interpolate errors using scipy interpolate.interp1d","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to deploy a new version of my Python\/Django application using eb deploy.\nIt unfortunately fails due to unexpected version of the application. The problem is that somehow eb deploy screwed up the version and I don't know how to override it. The application I upload is working fine, only the version number is not correct, hence, Elastic Beanstalk marks it as Degraded. \nWhen executing eb deploy, I get this error:\n\n\"Incorrect application version \"app-cca6-160820_155843\" (deployment\n  161). Expected version \"app-598b-160820_152351\" (deployment 159). \"\n\nThe same says in the health status at AWS Console.\nSo, my question is the following: How can I force Elastic Beanstalk to make the uploaded application version the current one so it doesn't complain?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":10464,"Q_Id":39185570,"Users Score":11,"Answer":"I've realised that the problem was that Elastic Beanstalk, for some reasons, kept the unsuccessfully deployed versions under .elasticbeanstalk. The solution, at least in my case, was to remove those temporal (or whatever you call them) versions of the application.","Q_Score":18,"Tags":"python,django,amazon-web-services,amazon-ec2,amazon-elastic-beanstalk","A_Id":42735371,"CreationDate":"2016-08-27T20:42:00.000","Title":"How to force application version on AWS Elastic Beanstalk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"For example,\nhow to convert [1, 5, 7] into [1,2,5,6,7,8] into python?\n[x, x+1 for x in [1,5,7]] can't work for sure...","AnswerCount":7,"Available Count":2,"Score":0.0285636566,"is_accepted":false,"ViewCount":93,"Q_Id":39217639,"Users Score":1,"Answer":"You can do your list comprehension logic with tuples and then flatten the resulting list:\n[n for pair in [(x, x+1) for x in [1,5,7]] for n in pair]","Q_Score":5,"Tags":"python","A_Id":39217670,"CreationDate":"2016-08-30T01:50:00.000","Title":"How to convert a list by mapping an element into multiple elements in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example,\nhow to convert [1, 5, 7] into [1,2,5,6,7,8] into python?\n[x, x+1 for x in [1,5,7]] can't work for sure...","AnswerCount":7,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":39217639,"Users Score":0,"Answer":"If you just want to fill the list with the numbers between the min and max+1 values you can use [i for i in range (min(x),max(x)+2)] assuming x is your list.","Q_Score":5,"Tags":"python","A_Id":39217679,"CreationDate":"2016-08-30T01:50:00.000","Title":"How to convert a list by mapping an element into multiple elements in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use h5py which needs libhdf5-dev to be installed. I installed hdf5 from the source, and thought that any options with compiling that one would offer me the developer headers, but doesn't look like it.\nAnyone know how I can do this? Is there some other source i need to download? (I cant find any though)\nI am on amazon linux, yum search libhdf5-dev doesn't give me any result and I cant use rpm nor apt-get there, hence I wanted to compile it myself.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":20706,"Q_Id":39236025,"Users Score":0,"Answer":"For Centos 8, I got the below warning message :\n\nWarning: Couldn't find any HDF5 C++ libraries. Disabling HDF5 support.\n\nand I solved it using the command :\n\nsudo yum -y install hdf5-devel","Q_Score":6,"Tags":"python,linux,installation,hdf5","A_Id":67224754,"CreationDate":"2016-08-30T19:53:00.000","Title":"how to install libhdf5-dev? (without yum, rpm nor apt-get)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to execute script(probably written in python), when update query is executed on MySQL database. The query is going to be executed from external system written in PHP to which I don't have access, so I can't edit the source code. The MySQL server is installed on our machine. Any ideas how I can accomplish this, or is it even possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":39243626,"Users Score":0,"Answer":"No, it is not possible to call external scripts from MySQL.\nThe only thing you can do is adding an ON UPDATE trigger that will write into some queue. Then you will have the python script POLLING the queue and doing whatever it's supposed to do with the rows it finds.","Q_Score":1,"Tags":"php,python,mysql,database","A_Id":39244221,"CreationDate":"2016-08-31T07:45:00.000","Title":"Executing script when SQL query is executed","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I could not get a working example of importing a compiled library (pyd file) in Python.\nI compiled the blender source code, result is a bpy.pyd file.\nThis file is placed in the python\\lib folder.\nIn the source code I have \nimport bpy\nThe file is found at runtime, but I get a runtime error that the module could not be imported\nDoes someone have a good documentation on importing compiled python modules? \nI searched ~100 entries, but only general definitions on how to do this. I trued all suggestions without success.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":703,"Q_Id":39256378,"Users Score":0,"Answer":"Found the error:\nthe pyd file was compiled with a 32 bit Python, was called with a 64 bit Python","Q_Score":0,"Tags":"python,python-3.x,bpy","A_Id":39298240,"CreationDate":"2016-08-31T18:13:00.000","Title":"How to Import compiled libs (pyd) in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need to match things that format something along the lines of \n657432-76,   54678-01,   54364A-12\nI got (r'^\\d{6}-\\d{2}$')\nand   (r'^\\d{5}-\\d{2}$')\nbut how do you get the letter?\nthanks!!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":39257759,"Users Score":0,"Answer":"For the letter use [a-zA-Z], and if it's only upper case then [A-Z] is sufficient.","Q_Score":2,"Tags":"python,regex,format,expression","A_Id":39257814,"CreationDate":"2016-08-31T19:42:00.000","Title":"Regular Expression with letter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to match things that format something along the lines of \n657432-76,   54678-01,   54364A-12\nI got (r'^\\d{6}-\\d{2}$')\nand   (r'^\\d{5}-\\d{2}$')\nbut how do you get the letter?\nthanks!!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":39257759,"Users Score":0,"Answer":"it seems the pattern generically is 6 characters with possible letter or number at last char max then - then 2 numbers? so then you'd use this pattern\npattern = r'^d{5}.+-\\d{2}$'","Q_Score":2,"Tags":"python,regex,format,expression","A_Id":39257845,"CreationDate":"2016-08-31T19:42:00.000","Title":"Regular Expression with letter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently learning building a SOAP web services with django and spyne. I have successfully tested my model using unit test. However, when I tried to test all those @rpc functions, I have no luck there at all.\nWhat I have tried in testing those @rpc functions:\n1. Get dummy data in model database\n2. Start a server at localhost:8000\n3. Create a suds.Client object that can communicate with localhost:8000\n4. Try to invoke @rpc functions from the suds.Client object, and test if the output matches what I expected.\nHowever, when I run the test, I believe the test got blocked by the running server at localhost:8000 thus no test code can be run while the server is running.\nI tried to make the server run on a different thread, but that messed up my test even more.\nI have searched as much as I could online and found no materials that can answer this question.\nTL;DR: how do you test @rpc functions using unit test?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":458,"Q_Id":39274850,"Users Score":1,"Answer":"I believe if you are using a service inside a test, that test should not be a unit test.\nyou might want to consider use factory_boy or mock, both of them are python modules to mock or fake a object, for instance, to fake a object to give a response to your rpc call.","Q_Score":1,"Tags":"python,django,testing,rpc,spyne","A_Id":39275854,"CreationDate":"2016-09-01T14:54:00.000","Title":"How to test RPC of SOAP web services?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to remove spaces, apostrophes, and double quote in each column data using this for loop\nfor c in data.columns:\n    data[c] = data[c].str.strip().replace(',', '').replace('\\'', '').replace('\\\"', '').strip()\nbut I keep getting this error:\nAttributeError: 'Series' object has no attribute 'strip'\ndata is the data frame and was obtained from an excel file\nxl = pd.ExcelFile('test.xlsx');\ndata = xl.parse(sheetname='Sheet1')\nAm I missing something?  I added the str but that didn't help.  Is there a better way to do this.\nI don't want to use the column labels, like so data['column label'], because the text can be different.  I would like to iterate each column and remove the characters mentioned above.\nincoming data:\nid        city      country\n1       Ontario       Canada\n2     Calgary '        Canada'\n3   'Vancouver        Canada\ndesired output:\nid  city      country\n1   Ontario     Canada\n2   Calgary     Canada\n3   Vancouver   Canada","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5363,"Q_Id":39280278,"Users Score":0,"Answer":"data[c] does not return a value, it returns a series (a whole column of data).  \nYou can apply the strip operation to an entire column df.apply.  You can apply the strip function this way.","Q_Score":0,"Tags":"python,pandas","A_Id":39280341,"CreationDate":"2016-09-01T20:21:00.000","Title":"Pandas - how to remove spaces in each column in a dataframe?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I got the following error while executing a python script on appium \nImportError: No module named appium\nI am running appium in one terminal and tried executing the test on another terminal. Does anyone know what is the reason for this error? and how to resolve it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":571,"Q_Id":39303681,"Users Score":1,"Answer":"Try to use nosetest.\nInstall:\npip install nose\nRun:\nnosetests (name of the file containing test)","Q_Score":0,"Tags":"ubuntu,python-appium","A_Id":41982234,"CreationDate":"2016-09-03T05:48:00.000","Title":"Python and Appium","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am writing tests for a program I intend to write that checks for certain lines in configuration files.\nFor example, the program might check that the line: AllowConnections- \nis contained in the file SomeFile.conf.\nMy function stub does not take any arguments because I know the file that I am going to be checking.\nI am trying to write a tests for this function that check the behavior for different SomeFile.conf files, but I don't see how I could do this. It is possible to change SomeFile.conf in the setup and teardown test functions, but this seems like a bad way to test. Should I change the function so that it can accept a file argument just for the sake of testing?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":39316449,"Users Score":1,"Answer":"The code you test, and the code you run should be same.\nI do not recommend using a filename, because now you are dealing with (in one function) opening the file - and the errors associated with that part, and then confirming the file format (the actual purpose of the function).\nIt sounds to me that your function's job is to check if the file's contents contain a specific string. So, this function should take any type of content element (an iterable) and then as long as the key string is not found, the function should return None\/False\/Fail condition - and your test should check for that.","Q_Score":0,"Tags":"python,testing","A_Id":39316539,"CreationDate":"2016-09-04T11:31:00.000","Title":"Should functions take extra arguments for the sake of testing?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building am application to process user's photo on server. Basically, user upload a photo to the server and do some filtering processing using deep learning model. Once it's done filter, user can download the new photo. The filter program is based on the deep learning algorithm, using torch framework, it runs on python\/lua. I currently run this filter code on my local ubuntu machine. Just wonder how to turn this into a web service. I have 0 server side knowledge, I did some research, maybe I should use flask or tornado, or other architecture?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":906,"Q_Id":39319275,"Users Score":0,"Answer":"It does make sense to look at the whole task and how it fits to your actual server, Nginx or Lighttpd or Apache since you are serving static content.  If you are going to call a library to create the static content, the integration of your library to your web framework would be simpler if you use Flask but it might be a fit for AWS S3 and Lambda services.\nIt may be worth it to roughly design the whole site and match your content to the tools at hand.","Q_Score":0,"Tags":"python,amazon-web-services,lua,server,torch","A_Id":48819337,"CreationDate":"2016-09-04T16:49:00.000","Title":"how to build an deep learning image processing server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building an application in Python using cx_Oracle (v5) and Pyinstaller to package up and distribute the application.  When I built and packaged the application, I had the Oracle 12c client installed.  However, when I deployed it to a machine with the 11g client installed, it seems not to work.  I get the message \"Unable to acquire Oracle environment handle\".  I assume this is as the result of the application being packaged with Pyinstaller while my ORACLE_HOME was pointed to a 12c client.  I know that the cx_Oracle I have was built against both 11g and 12 libraries.  So, I'm wondering how I deploy an application using Pyinstaller so it can run with either 11 or 12c client libraries installed?\nBy the way, I am building this on Linux (debian\/Mint 17.2), and deploying to Linux (CentOS 7).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":738,"Q_Id":39324217,"Users Score":1,"Answer":"The error \"Unable to acquire Oracle environment handle\" means there is something wrong with your Oracle configuration. Check to see what libclntsh.so file you are using. The simplest way to do that is by using the ldd command on the cx_Oracle module that PyInstaller has bundled with the executable. Then check to see if there is a conflict due to setting the environment variable ORACLE_HOME to a different client!\nIf PyInstaller picked up the libclntsh.so file during its packaging you will need to tell it to stop doing that. There must be an Oracle client (either full client or the much simpler instant client) on the target machine, not just the one file (libclntsh.so).\nYou can also verify that your configuration is ok by using the cx_Oracle.so module on the target machine to establish a connection -- independently of your application. If that doesn't work or you don't have a Python installation there for some reason, you can also use SQL*Plus to verify that your configuration is ok as well.","Q_Score":0,"Tags":"python,oracle,pyinstaller,cx-oracle","A_Id":39349805,"CreationDate":"2016-09-05T05:04:00.000","Title":"How do I build a cx_oracle app using pyinstaller to use multiple Oracle client versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use scikit-learn's neural network module in iPython... running Python 3.5 on a Win10, 64-bit machine.\nWhen I try to import from sknn.mlp import Classifier, Layer , I get back the following AttributeError: module 'theano' has no attribute 'gof' ...\nThe command line highlighted for the error is class DisconnectedType(theano.gof.type.Type), within theano\\gradient.py\nTheano version is 0.8.2, everything installed via pip.\nAny lights on what may be causing this and how to fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":331,"Q_Id":39332901,"Users Score":0,"Answer":"Apparently it was caused by some issue with Visual Studio. The import worked when I reinstalled VS and restarted the computer.\nThanks @super_cr7 for the prompt reply!","Q_Score":0,"Tags":"python,installation,attributes,scikit-learn,theano","A_Id":39334690,"CreationDate":"2016-09-05T14:36:00.000","Title":"Failure to import sknn.mlp \/ Theano","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have added 2 LinearRegionItems to a pyqtgraph plot. When I move the boundary of 1 over the other, the boundary never overlaps the other.\nI would like to know how to allow overlapping. This is a functionality that I need, where I am selecting different regions of the data plot to be used later on.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":39337545,"Users Score":0,"Answer":"Sorry, there was a bug in my code which was handling the case where a part of one LinearRegionItem overlapped with another LinearRegionItem.\nNow I see that one linearRegionItem can lie on top of another one.\nConsider this solved","Q_Score":1,"Tags":"python,pyqtgraph","A_Id":39413892,"CreationDate":"2016-09-05T20:48:00.000","Title":"How to get 2 or more LinearRegionItem to overlap each other","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a 32 bit installation of the Anaconda Python distribution.\nI know how to create environments for different python versions.\nWhat I need is to have a 64 bit version of python.\nIs it possible to create a conda env with the 64 bit version?\nOr do I have to reinstall anaconda or install a different version of anaconda and then switch the values of the PATH when I need the different versions?\nI looked and searched the documentation, and the conda create -h help page did not find any mention of this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4169,"Q_Id":39345313,"Users Score":1,"Answer":"As I understand, Anaconda installs into a self-contained directory (<pwd>\/anaconda3). Since 64-bit and 32-bit builds of Python can not be mixed or converted into each other (in terms of the compiled Python binaries and libraries in site-packages or other PYTHONPATH location), you have to go with a second (64-bit) Anaconda installation in another directory.\nIf you have 32-bit code that needs to call 64-bit code, you have to rely subprocesses and pipes (or other IPC mechanisms). You probably have to be careful about your environment variables, e.g. PATH and PYTHONPATH when doing so.","Q_Score":2,"Tags":"python,anaconda,32bit-64bit,development-environment,conda","A_Id":39345619,"CreationDate":"2016-09-06T09:22:00.000","Title":"How to create python conda 64 bit environment in existing 32bit install?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Anyone know how I can find the character in the center that is surrounded by spaces?\n1 + 1\nI'd like to be able to separate the + in the middle to use in a if\/else statement.\nSorry if I'm not too clear, I'm a Python beginner.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":2051,"Q_Id":39361214,"Users Score":1,"Answer":"This regular expression will detect a single character surrounded by spaces, if the character is a plus or minus or mult or div sign: r' ([+-*\/]) '. Note the spaces inside the apostrophes. The parentheses \"capture\" the character in the middle. If you need to recognize a different set of characters, change the set inside the brackets.\nIf you haven't dealt with regular expressions before, read up on the re module. They are very useful for simple text processing. The two relevant features here are \"character classes\" (the square brackets in my example) and \"capturing parentheses\" (the round parens).","Q_Score":0,"Tags":"python,python-3.x","A_Id":39361292,"CreationDate":"2016-09-07T04:29:00.000","Title":"Python detect character surrounded by spaces","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, we have project Foo with dependency Bar (that in private Git repo) and we want install Bar into Foo directory via pip from requirements.txt. \nWe can manually install Bar with console command:\npip install --target=. git+ssh:\/\/git.repo\/some_pkg.git#egg=SomePackage\nBut how to install Bar into current directory from requirements.txt?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1394,"Q_Id":39368789,"Users Score":0,"Answer":"The best way to do this would be to clone the repository, or just donwload the requirements.txt file, and then run pip install -r requirements.txt to install all the modules dependencies.","Q_Score":2,"Tags":"python,git,pip","A_Id":39369148,"CreationDate":"2016-09-07T11:33:00.000","Title":"How to install package via pip requirements.txt from VCS into current directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying reproduce the game \"Snake\" in pygame, using the pygame.blit function, instead of pygame.draw. My question is how to make an image follow another image. I mean, make the snake's body photo follow your head. In the current state of my program the head moves on its own.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":39380527,"Users Score":0,"Answer":"Keep positions of snake segments on list (first segment is head).\nLater new position of head insert before first segment (and remove last segment). \nUse this list to blit snake segments.","Q_Score":0,"Tags":"python","A_Id":39380622,"CreationDate":"2016-09-07T23:40:00.000","Title":"Pygame: how to blit an image that follows another image","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a list of Sparsetensors in Tensorflow. I want to access them in later sessions of my program. I've read online that you can store Python lists as json files but how do I save a list of Sparsetensors to a json file and then use that later on?\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":70,"Q_Id":39382725,"Users Score":1,"Answer":"A Tensor in TensorFlow is a node in the graph which, when run, will produce a tensor. So you can't save the SparseTensor directly because it's not a value (you can serialize the graph). If you do evaluate the sparsetensor, you get a SparseTensorValue object back which can be serialized as it's just a tuple.","Q_Score":0,"Tags":"python,json,tensorflow","A_Id":39395872,"CreationDate":"2016-09-08T04:42:00.000","Title":"Saving Python list containing Tensorflow Sparsetensors to file for later access?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With pyspark dataframe, how do you do the equivalent of Pandas df['col'].unique().\nI want to list out all the unique values in a pyspark dataframe column.\nNot the SQL type way (registertemplate then SQL query for distinct values).\nAlso I don't need groupby then countDistinct, instead I want to check distinct VALUES in that column.","AnswerCount":10,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":344799,"Q_Id":39383557,"Users Score":21,"Answer":"You can use df.dropDuplicates(['col1','col2']) to get only distinct rows based on colX in the array.","Q_Score":149,"Tags":"python,apache-spark,pyspark,apache-spark-sql","A_Id":44253561,"CreationDate":"2016-09-08T06:03:00.000","Title":"Show distinct column values in pyspark dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With pyspark dataframe, how do you do the equivalent of Pandas df['col'].unique().\nI want to list out all the unique values in a pyspark dataframe column.\nNot the SQL type way (registertemplate then SQL query for distinct values).\nAlso I don't need groupby then countDistinct, instead I want to check distinct VALUES in that column.","AnswerCount":10,"Available Count":2,"Score":0.0199973338,"is_accepted":false,"ViewCount":344799,"Q_Id":39383557,"Users Score":1,"Answer":"If you want to select ALL(columns) data as distinct frrom a DataFrame (df), then\ndf.select('*').distinct().show(10,truncate=False)","Q_Score":149,"Tags":"python,apache-spark,pyspark,apache-spark-sql","A_Id":60578769,"CreationDate":"2016-09-08T06:03:00.000","Title":"Show distinct column values in pyspark dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to debug a Pootle (pootle is build on django) installation which fails with a django transaction error whenever I try to add a template to an existing language. Using the python debugger I can see that it fails when pootle tries to save a model as well as all the queries that have been made in that session.\nWhat I can't see is what specifically causes the save to fail. I figure pootle\/django must have added some database database constraint, how do I figure out which one? MySql (the database being used) apparently can't log just failed transactions.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":223,"Q_Id":39387983,"Users Score":1,"Answer":"Install django debug toolbar, you can easily check all of the queries that have been executed","Q_Score":0,"Tags":"python,mysql,django,pootle","A_Id":39447127,"CreationDate":"2016-09-08T10:01:00.000","Title":"How do I get Django to log why an sql transaction failed?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need to compare two files of differing formats quickly and I'm not sure how to do it. I would very much appreciate it if someone could point me in the right direction.\nI am working on CentOS 6 and I am most comfortable with Python (both Python 2 and Python 3 are available).\n\nThe problem\nI am looking to compare the contents two large files (quickly). The files, unfortunately, differ in content; I will need to modify the contents of one before I can compare them. They are not particularly well-organized, so I can't move linearly down each and compare line-by-line.\nHere's an example of the files:\n\nFile 1                    File 2\nJob,Time                  Job,Start,End\n0123,3-00:00:00           0123,2016-01-01T00:00:00,2016-01-04T00:00:00\n1111,05:30:00             1111,2016-01-01T00:00:00,2016-01-01T05:30:00\n0000,00:00:05             9090.abc,2016-01-01T12:00:00,2016-01-01T22:00:00\n9090.abc,10:00:00         0000,2015-06-01T00:00:00,2015-06-01T00:00:05\n...                       ...\n\nI would like to compare the contents of lines with the same \"Job\" field, like so:\n\nJob        File 1 Content   File 2 Content\n0123       3-00:00:00       2016-01-01T00:00:00,2016-01-04T00:00:00\n1111       05:30:00         2016-01-01T00:00:00,2016-01-01T05:30:00\n0000       00:00:05         2015-06-01T00:00:00,2015-06-01T00:00:05\n9090.abc   10:00:00         2016-01-01T12:00:00,2016-01-01T22:00:00\n...        ...              ...\n\nI will be performing calculations on the File 1 Content and File 2 Content and comparing the two (for each line).\nWhat is the most efficient way of doing this (matching lines)?\n\nThe system currently in place loops through one file in its entirety for each line in the other (until a match is found). This process may take hours to complete, and the files are always growing. I am looking to make the process of comparing them as efficient as possible, but even marginal improvements in performance can have a drastic effect.\nI appreciate any and all help.\nThank you!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1140,"Q_Id":39394328,"Users Score":1,"Answer":"If you can find a way to take advantage of hash tables your task will change from O(N^2) to O(N). The implementation will depend on exactly how large your files are and whether or not you have duplicate job IDs in file 2. I'll assume you don't have any duplicates. If you can fit file 2 in memory, just load the thing into pandas with job as the index. If you can't fit file 2 in memory, you can at least build a dictionary of {Job #: row # in file 2}. Either way, finding a match should be substantially faster.","Q_Score":0,"Tags":"python,performance,file,io","A_Id":39395013,"CreationDate":"2016-09-08T15:02:00.000","Title":"Comparing the contents of very large files efficiently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to compare two files of differing formats quickly and I'm not sure how to do it. I would very much appreciate it if someone could point me in the right direction.\nI am working on CentOS 6 and I am most comfortable with Python (both Python 2 and Python 3 are available).\n\nThe problem\nI am looking to compare the contents two large files (quickly). The files, unfortunately, differ in content; I will need to modify the contents of one before I can compare them. They are not particularly well-organized, so I can't move linearly down each and compare line-by-line.\nHere's an example of the files:\n\nFile 1                    File 2\nJob,Time                  Job,Start,End\n0123,3-00:00:00           0123,2016-01-01T00:00:00,2016-01-04T00:00:00\n1111,05:30:00             1111,2016-01-01T00:00:00,2016-01-01T05:30:00\n0000,00:00:05             9090.abc,2016-01-01T12:00:00,2016-01-01T22:00:00\n9090.abc,10:00:00         0000,2015-06-01T00:00:00,2015-06-01T00:00:05\n...                       ...\n\nI would like to compare the contents of lines with the same \"Job\" field, like so:\n\nJob        File 1 Content   File 2 Content\n0123       3-00:00:00       2016-01-01T00:00:00,2016-01-04T00:00:00\n1111       05:30:00         2016-01-01T00:00:00,2016-01-01T05:30:00\n0000       00:00:05         2015-06-01T00:00:00,2015-06-01T00:00:05\n9090.abc   10:00:00         2016-01-01T12:00:00,2016-01-01T22:00:00\n...        ...              ...\n\nI will be performing calculations on the File 1 Content and File 2 Content and comparing the two (for each line).\nWhat is the most efficient way of doing this (matching lines)?\n\nThe system currently in place loops through one file in its entirety for each line in the other (until a match is found). This process may take hours to complete, and the files are always growing. I am looking to make the process of comparing them as efficient as possible, but even marginal improvements in performance can have a drastic effect.\nI appreciate any and all help.\nThank you!","AnswerCount":5,"Available Count":2,"Score":0.0399786803,"is_accepted":false,"ViewCount":1140,"Q_Id":39394328,"Users Score":1,"Answer":"I was trying to develop something where you'd split one of the files into smaller files (say 100,000 records each) and keep a pickled dictionary of each file that contains all Job_id as a key and its line as a value. In a sense, an index for each database and you could use a hash lookup on each subfile to determine whether you wanted to read its contents.\nHowever, you say that the file grows continually and each Job_id is unique. So, I would bite the bullet and run your current analysis once. Have a line counter that records how many lines you analysed for each file and write to a file somewhere. Then in future, you can use linecache to know what line you want to start at for your next analysis in both file1 and file2; all previous lines have been processed so there's absolutely no point in scanning the whole content of that file again, just start where you ended in the previous analysis. \nIf you run the analysis at sufficiently frequent intervals, who cares if it's O(n^2) since you're processing, say, 10 records at a time and appending it to your combined database. In other words, the first analysis takes a long time but each subsequent analysis gets quicker and eventually n should converge on 1 so it becomes irrelevant.","Q_Score":0,"Tags":"python,performance,file,io","A_Id":39396201,"CreationDate":"2016-09-08T15:02:00.000","Title":"Comparing the contents of very large files efficiently","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to globally provide a custom instance of User class instead of AnonymousUser?\nIt is not possible to assign AnonymousUser instances when User is expected (for example in forms, there is need to check for authentication and so on), and therefore having an ordinary User class with name 'anonymous' (so that we could search for it in the DB) would be globally returned when a non-authenticated user visits the page. Somehow implementing a custom authentication mechanism would do the trick? And I also want to ask if such an idea is a standard approach before diving into this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":39410656,"Users Score":1,"Answer":"You could create a custom middleware (called after AuthenticationMiddleware), that checks if the user if logged in or not, and if not, replaces the current user object attached to request, with the the user of your choice.","Q_Score":1,"Tags":"python,django","A_Id":39411527,"CreationDate":"2016-09-09T11:34:00.000","Title":"Providing 'default' User when not logged in instead of AnonymousUser","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Alright, so I managed to use PyInstaller to build a homework assignment I made with Pygame. Cool. The executable works fine and everything.\nProblem is, alongside the executable, there is so much clutter. So many files, like pyds and dlls accompany the exe in the same directory, making it look so ugly.\nNow, I know that these files are important; the modules I used, such as Pygame, need them to work. Still, how do I make PyInstaller build my game, so that it puts the clutter into its own folder? I could just manually make a folder and move the files in there, but it stops the exe from working.\nIf this info would help any, I used Python 3.4.3 and am on Windows.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4472,"Q_Id":39419108,"Users Score":2,"Answer":"Not trying to dig up this old question, but this was at the top of my Google search so it may be for others as well.\nIf you intend to distribute the program in some kind of folder, you can always just mark everything unnecessary as hidden in Windows, and it will remain hidden even if you compress or extract it.\nFor a program that I designed to be very user friendly, I just selected each file and folder that was not necessary to the user and hid them. If the user has show hidden files on (rarely default), they aren't likely to be intimidated by the mess of files that pyinstaller creates.","Q_Score":2,"Tags":"python,build,pygame,pyinstaller","A_Id":68652885,"CreationDate":"2016-09-09T20:15:00.000","Title":"How to remove clutter from PyInstaller one-folder build?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im trying to find out the number of where X is in the list e.g:\nif i had a list like: ['a','b','c','d'] and i have 'c' how would i find where it is in the list, so that it would print '2' (as thats where it is in the list)\nthanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":39436020,"Users Score":1,"Answer":"Use the built-in method list.index\nIf you wanna know where is 'c':\n\nl = ['a','b','c']\nl.index('c')","Q_Score":0,"Tags":"python-3.4","A_Id":39436077,"CreationDate":"2016-09-11T12:20:00.000","Title":"How to find in a list what thats number python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"More in detail, would like to know:\n\nwhat is the default SYN_RECEIVED timer,\nhow do i get to change it,\nare SYN cookies or SYN caches implemented.\n\nI'm about to create a simple special-purpose publically accessible server. i must choose whether using built-in TCP sockets or RAW sockets and re-implement the TCP handshake if these security mechanisms are not present.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":216,"Q_Id":39438003,"Users Score":1,"Answer":"What you describe are internals of the TCP stack of the operating system. Python just uses this stack via the socket interface. I doubt that any of these settings can be changed specific to the application at all, i.e. these are system wide settings which can only be changed with administrator privileges.","Q_Score":1,"Tags":"python,sockets,tcp,ddos,python-sockets","A_Id":39438366,"CreationDate":"2016-09-11T16:01:00.000","Title":"what anti-ddos security systems python use for socket TCP connections?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been reading the documentation but can't find what I'm looking for. \nI'm simply trying to match foo inside foobar but can't seem to see how to do it. Any guidance would be helpful!","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":162,"Q_Id":39438843,"Users Score":1,"Answer":"Use parenthesis \nLike \nre.findall(\"(foo)bar\",\"foobar foogy woogy\")","Q_Score":0,"Tags":"python,regex","A_Id":39438883,"CreationDate":"2016-09-11T17:36:00.000","Title":"Python Regex matching word inside words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a python application that uses cx_Oracle and then generates a pyinstaller bundle (folder\/single executable).  I should note it is on 64 bit linux.  I have a custom spec file that includes the Oracle client libraries so everything that is needed is in the bundle.  \nWhen I run the bundled executable on a freshly installed CentOS 7.1 VM, (no Oracle software installed), the program connects to the database successfully and runs without error.  However, when I install the bundled executable on another system that contains RHEL 7.2, and I try to run it, I get\n\nUnable to acquire Oracle environment handle. \n\nMy understanding is this is due to an Oracle client installation that has some sort of conflict.  I tried unsetting ORACLE_HOME on the machine giving me errors.  It's almost as though the program is looking for the Oracle client libraries in a location other than in the location where I bundled the client files.  \nIt seems like it should work on both machines or neither machine.  I guess I'm not clear on how the Python application\/cx_Oracle finds the Oracle client libraries.  Again, it seems to have found them fine on a machine with a fresh operating system installation.  Any ideas on why this is happening?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":306,"Q_Id":39482504,"Users Score":1,"Answer":"One thing that you may be running into is the fact that if you used the instant client RPMs when you built cx_Oracle an RPATH would have been burned into the shared library. You can examine its contents and change it using the chrpath command. You can use the special path $ORIGIN in the modified RPATH to specify a path relative to the shared library.\nIf an RPATH isn't the culprit, then you'll want to examine the output from the ldd command and see where it is looking and then adjust things to make it behave itself!","Q_Score":0,"Tags":"python,pyinstaller,cx-oracle","A_Id":39503038,"CreationDate":"2016-09-14T04:30:00.000","Title":"Why does pyinstaller generated cx_oracle application work on fresh CentOS machine but not on one with Oracle client installed?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am developing a small web application using Django and Elasticbeanstalk.\nI created a EB application with two environments (staging and production), created a RDS instance and assigned it to my EB environments. \nFor development I use a local database, because deploying to AWS takes quite some time.\nHowever, I am having troubles with the migrations. Because I develop and test locally every couple of minutes, I tend to have different migrations locally and on the two environments.\nSo once I deploy the current version of the app to a certain environment, the \"manage.py migrate\" fails most of the times because tables already exist or do not exist even though they should (because another environment already created the tables).\nSo I was wondering how to handle the migration process when using multiple environments for development, staging and production with some common and some exclusive database instances that might not reflect the same structure all the time?\nShould I exclude the migration files from the code repository and the eb deployment and run makemigrations & migrate after every deployment? Should I not run migrations automatically using the .ebextensions and apply all the migrations manually through one of the instances?\nWhat's the recommended way of using the same Django application with different database instances on different environments?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":795,"Q_Id":39500513,"Users Score":1,"Answer":"Seems that you might have deleted the table or migrations at some point of time.\nWhen you run makemigrations, django create migratins and when you run migrate, it creates database whichever is specified in settings file.\nOne thing is if you keep on creating migrations and do not run it in a particular database, it will be absolutely fine. Whenever you switch to databsse and run migrations, it will handle it as every  database will store the point upto which migrations have been run until now in django-migrations table and will start running next migrations only.\nTo solve your problem, you can delete all databases and migration files and start afresh as you are perhaps testing right now. Things will go fine untill you delete a migration or a database in any of the server.\nIf you have precious data, you should get into migration files and tables to analyse and manage things.","Q_Score":1,"Tags":"python,django,amazon-web-services,amazon-elastic-beanstalk,django-migrations","A_Id":39500763,"CreationDate":"2016-09-14T22:18:00.000","Title":"Django Migration Process for Elasticbeanstalk \/ Multiple Databases","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to send some applications in python to a Apache Spark cluster. There is given a Clustermanager and some worker nodes with the addresses to send the Application to.\nMy question is, how to setup and to configure Spark on my local computer to send those requests with the data to be worked out to the cluster?\nI am working on Ubuntu 16.xx and already installed java and scala. I have searched the inet but the most find is how to build the cluster or some old advices how to do it, which are out of date.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":39525214,"Users Score":0,"Answer":"your question is unclear. If the data are on your local machine, you should first copy your data to the cluster on HDFS filesystem. Spark can works in 3 modes with YARN (are u using YARN or MESOS ?): cluster, client and standalone. What you are looking for is client-mode or cluster mode. But if you want to start the application from your local machine, use client-mode. If you have an SSH access, you are free to use both.\nThe simplest way is to copy your code directly on the cluster if it is properly configured then start the application with the .\/spark-submit script, providing the class to use as an argument. It works with python script and java\/scala classes (I only use python so I don't really know)","Q_Score":0,"Tags":"java,python,scala,apache-spark,pyspark","A_Id":39530209,"CreationDate":"2016-09-16T06:41:00.000","Title":"Configurate Spark by given Cluster","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Exception in XML-RPC listener loop (java.net.SocketException: Socket closed).\n\nWhen I run PyCharm from bash , I get this error..As result: I cant't use python-console in pycharm Anybody know how to fix it ? \nOS: ubuntu 16.04","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":602,"Q_Id":39537700,"Users Score":-1,"Answer":"Hi I had the same problem as you. I solved the problem by making the line 127.0.0.1 localhost as the first line in \/etc\/hosts. The reason python console does not run is that python console tries to connect to localhost:pycharm-port, but localhost was resolved to the IPv6 addess of ::1, and the connection is refused.","Q_Score":4,"Tags":"python,pycharm,xml-rpc","A_Id":44059972,"CreationDate":"2016-09-16T18:10:00.000","Title":"How to fix python console error in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to post data from html to another html\nI know how to post data html->python and python-> html\nI have dictionary in the html (I get it from python - return render_to_response('page.html', locals())\nhow can I use with the dictionary in the second html file?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":39571659,"Users Score":0,"Answer":"If you are not gonna use any sensitive data like password you can use localStorage or Url Hash .","Q_Score":0,"Tags":"javascript,python,html","A_Id":69865240,"CreationDate":"2016-09-19T11:05:00.000","Title":"Post data from html to another html","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I acquire samples (integers) at a very high rate (several kilo samples per seconds) in a thread and put() them in a threading.Queue. The main thread get()s the samples one by one into a list of length 4096, then msgpacks them and finally sends them via ZeroMQ to a client. The client shows the chunks on the screen (print or plot). In short the original idea is, fill the queue with single samples, but empty it in large chunks.\nEverything works 100% as expected. But the latter part i.e. accessing the queue is very very slow. Queue gets larger and the output always lags behind by several to tens of seconds.\nMy question is: how can I do something to make queue access faster? Is there a better approach?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3388,"Q_Id":39598572,"Users Score":1,"Answer":"Q : \"Is there a better approach?\"\n\nA :\nWell, my ultimate performance-candidate would be this :\n\nthe sampler will operate two or more, separate, statically preallocated \"circular\"-buffers, one for storing in phase one, the other thus free-to get sent and vice-verse\nonce the sampler's filling reaches the end of the first buffer, it starts filling the other, sending the first one and vice versa\nZeroMQ zero-copy, zero-blocking .send( zmq.NOBLOCK ) over an inproc:\/\/ transport-class uses just memory-pointer mapping, without moving data in-RAM ( or we can even further reduce the complexity, if moving the filled-up buffer right from here directly to the client, w\/o any mediating party ( if not needed otherwise ) for doing so, if using a pre-allocated, static storage,like a numpy.array( ( bufferSize, nBuffersInRoundRobinCYCLE ), dtype = np.int32 ), we can just send an already packed-block of { int32 | int64 }-s or other dtype-mapped data using .data-buffer, round-robin cycling along the set of nBuffersInRoundRobinCYCLE-separate inplace storage buffers (used for sufficient latency-masking, filling them one after another in cycle and letting them get efficiently .send( zmq.NOBLOCK )-sent in the \"background\" ( behind the back of the Python-GIL-lock blocker tyrant ) in the meantime as needed ).\n\nTweaking Python-interpreter, disabling gc.disable() at all and tuning the default GIL-lock smooth processing \"meat-chopper\" from 100[ms] somewhere reasonably above, as no threading is needed anymore, by sys.settimeinterval() and moving several acquired samples in lump multiples of CPU-words ~up~to~ CPU-cache-line lengths ( aligned for reducing the fast-cache-to-slow-RAM-memory cache-consistency management mem-I\/O updates ) are left for the next LoD of bleeding performance boosting candidates","Q_Score":7,"Tags":"python,multithreading,queue,python-multithreading,pyzmq","A_Id":70651650,"CreationDate":"2016-09-20T15:49:00.000","Title":"Python threading queue is very slow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed Anaconda, but I do not know how to open a .py file..\nIf it is possible, please explain plainly, I browsed several threads, but I understood none of them..\nThanks a lot for your helps..\nBest,","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":8545,"Q_Id":39646077,"Users Score":0,"Answer":"You can use any text editor to open a .py file, e.g. TextMate, TextWrangler, TextEdit, PyCharm, AquaMacs, etc.","Q_Score":1,"Tags":"python,anaconda","A_Id":39646217,"CreationDate":"2016-09-22T18:11:00.000","Title":"How to read a .py file after I install Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed Anaconda, but I do not know how to open a .py file..\nIf it is possible, please explain plainly, I browsed several threads, but I understood none of them..\nThanks a lot for your helps..\nBest,","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":8545,"Q_Id":39646077,"Users Score":3,"Answer":"In the menu structure of your operating system, you should see a folder for Anaconda. In that folder is an icon for Spyder. Click that icon.\nAfter a while (Spyder loads slowly) you will see the Spyder integrated environment. You can choose File then Open from the menu, or just click the Open icon that looks like an open folder. In the resulting Open dialog box, navigate to the relevant folder and open the relevant .py file. The Open dialog box will see .py, .pyw, and .ipy files by default, but clicking the relevant list box will enable you to see and load many other kinds of files. Opening that file will load the contents into the editor section of Spyder. You can view or edit the file there, or use other parts of Spyder to run, debug, and do other things with the file.\nAs of now, there is no in-built way to load a .py file in Spyder directly from the operating system. You can set that up in Windows by double-clicking a .py file, then choosing the spyder.exe file, and telling Windows to always use that application to load the file. The Anaconda developers have said that a soon-to-come version of Anaconda will modify the operating system so that .py and other files will load in Spyder with a double-click. But what I said above works for Windows.\nThis answer was a bit condensed, since I do not know your level of understanding. Ask if you need more details.","Q_Score":1,"Tags":"python,anaconda","A_Id":39646328,"CreationDate":"2016-09-22T18:11:00.000","Title":"How to read a .py file after I install Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I changed the interpreter for my python projects from 2.x to 3.5 recently. The code interpretes correctly with the 3.5 version.\nI noticed that the autocompletion function of Eclipse still autocompletes as if I am using 2.x Python version. For example: print gets autocompleted without parenthesis as a statement and not as a function. Any idea how to notify the Eclipse that it need to use 3.5 autocompletion?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":82,"Q_Id":39659748,"Users Score":1,"Answer":"If you are using PyDev, make sure that interpreter grammar is set to 3.0 (right click project -> Properties -> PyDev - Interpreter\/Grammar)","Q_Score":0,"Tags":"python,eclipse,python-3.x,autocomplete","A_Id":39773761,"CreationDate":"2016-09-23T11:32:00.000","Title":"force eclipse to use Python 3.5 autocompletion","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am very new to Python. I am curious to how I would be able to copy some files from my directory to another Users directory on my computer using python script? And would I be correct in saying I need to check the permissions of the users and files? So my question is how do I send files and also check the permissions at the same time","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":639,"Q_Id":39665029,"Users Score":1,"Answer":"shutil is a very usefull thing to use when copying files.\nI once needed to have a python script that moved all .mp3 files from a directory to a backup, deleted the original directory, created a new once, and moved the .mp3 files back in. shutil was perfect for thise.\nThe formatting for the command is how @Kieran has stated earlier.\nIf you're looking to keep file metadata, then use shutil.copy2(src, dest), as that is the equivalent of running copy() and copystat() one after another.","Q_Score":1,"Tags":"python","A_Id":39665400,"CreationDate":"2016-09-23T15:59:00.000","Title":"Python sending files from a user directory to another user directory","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been having trouble using django. Right now, I have a messagebox class that is suppose to hold messages, and a message class that extends it. How do I make it so messagebox will hold messages?\nSomething else that I cannot figure out is how classes are to interact. Like, I have a user that can send messages. Should I call its method to call a method in messagebox to send a msg or can I have a method in user to make a msg directly. \nMy teacher tries to accentuate cohesion and coupling, but he never even talks about how to implement this in django or implement django period. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":121,"Q_Id":39679167,"Users Score":3,"Answer":"You're confusing two different things here. A class can easily have an attribute that is a list which contains instances of another class, there is nothing difficult about that. \n(But note that there is no way in which a Message should extend MessageBox; this should be composition, not inheritance.)\nHowever then you go on to talk about Django models. But Django models, although they are Python classes, also represent tables in the database. And the way you represent one table containing a list of entries in another table is via a foreign key field. So in this case your Message model would have a ForeignKey to MessageBox.\nWhere you put the send method depends entirely on your logic. A message should probably know how to send itself, so it sounds like the method would go there.","Q_Score":0,"Tags":"python,django","A_Id":39679214,"CreationDate":"2016-09-24T17:38:00.000","Title":"How can a class hold an array of classes in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a model called widgetManager and 2 widget models called emailWidget and TextWidget. Now a single instance of widgetManager can have multiple instances of emailWidget and TextWidget. How can this be achieved with the following in mind\n\nTill now i only have two but there can be more in future\nThe order of widget is very important\n\nI have tried with adding two many-many relations in widgetManager but that seems impractical and not the best way to go around because if first condition.\nWhat i have in mind is maybe i can somehow make a base widget class and extend all the widgets from that class but i am not sure about that. Would be super helpful if someone can point me in the right direction. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":39691679,"Users Score":1,"Answer":"If I understood your description correctly, you want a relationship where there can be many emailWidget or TextWidget for one instance of widgetManager. \nWhat you can do in this case is add a ForeignKey field for widgetManager to emailWidget and TextWidget. This way, you can have many instances of the widgets while they refer to the same manager.\nI think you may have confused inheritance with model relationships when you said you want to extend widgets from a base class. Perhaps I'm wrong? \nNot sure what you mean't about order of the widget being important either..","Q_Score":0,"Tags":"python,django,django-models","A_Id":39692799,"CreationDate":"2016-09-25T20:46:00.000","Title":"Proper model defination in django for a widget manager","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using macOS Sierra 10.12 and after I upgraded my OS I can no longer install packages for python 3 using pip. Before I used to use pip for python2 and pip3 for python 3 as I have both versions of Python. But now I can no longer use pip to install libraries for python2. \nCan anyone help me how can I change my default pip installer to python2? So that I can just use pip install in order to install for python 2.\nFor your information - when I only type python on terminal it says my default is python 2.7.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4506,"Q_Id":39691860,"Users Score":1,"Answer":"install pip for Python2.7 with easy_install:\nsudo easy_install-2.7 pip\nnow you can use pip for the same specific version of Python:\nsudo pip2.7 install BeautifulSoup","Q_Score":2,"Tags":"python-2.7,pip","A_Id":43962413,"CreationDate":"2016-09-25T21:08:00.000","Title":"pip command by default using python 3...how to change it to python 2?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python 2.7 project that has thus far been using gfortran and MinGW to build extensions. I use MinGW because it seems to support write statements and allocatable arrays in the Fortran code while MSVC does not.\nThere is another project I would like to incorporate into my own (Netgen) but it is currently set up for Python 3.5 using Boost.Python. I first tried to transfer my own program to Python 3.5 but that is where I was reminded of the MSVC issues and apparently MinGW is not supported. For that reason, I've been trying to think of a way to compile Netgen + Boost.Python for deployment in Python 2.7.\nI think the Boost part is straightforward, but it seems I need Visual C++ 2008 to get it integrated with Python 2.7. I have the Visual C++ Compiler for Python 2.7 from Microsoft, but I haven't gotten it to work inside the CMake build system. I point it to the cl.exe compilers in the VC for Python folders and CMake always tells me that building a simple test program fails. Since I don't actually have (and can't find) Visual Studio 2008, not sure how far I'd get anyway.\nThere's a lot of places that could have issues here, but I'm just looking for a go\/no-go answer if that's what it is. Any solutions would obviously be welcomed.\nI am running Windows 10 64-bit.\nI'm not a C\/C++ expert, but it seems like I have all the tools I need to compile Netgen using the VC for Python tools (cl, link, etc). I just don't have\/not sure how to put it all together into a project or something like that.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":168,"Q_Id":39694646,"Users Score":0,"Answer":"I built Boost.Python libraries 1.61.0 from source for Python 2.7 using VC 14.0. Then used those in the build process for Netgen (again using VC 14.0) and pointed to the Python 2.7 library and include directories (as opposed to Python 3.5). This has thus far worked in Python 2.7 with my existing code.","Q_Score":2,"Tags":"python,c++,boost,fortran,gfortran","A_Id":39716307,"CreationDate":"2016-09-26T04:15:00.000","Title":"Building Fortran extension for Python 3.5 or C extension for 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Has anyone come across a way to emulate kbhit() in the Spyder environment on Windows? Somehow the development environment gets between the Python program and the keyboard, so any simple way of doing it (i.e. msvcrt.kbhit()) does not work.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":478,"Q_Id":39713433,"Users Score":1,"Answer":"Set this configuration in Spyder:  \nRun > Run Configuration Per File > Execute In An External System Terminal\nIn my experience \"msvcrt.kbhit\" only works in CMD.","Q_Score":2,"Tags":"python,keyboard,spyder","A_Id":60240641,"CreationDate":"2016-09-26T22:34:00.000","Title":"How to make kbhit() work in the Spyder environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to read and write custom data to TCP options field using Scapy. I know how to use TCP options field in Scapy in \"normal\" way as dictionary, but is it possible to write to it byte per byte?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":402,"Q_Id":39713540,"Users Score":1,"Answer":"You can not directly write the TCP options field byte per byte, however you can either:\n\nwrite your entire TCP segment byte per byte: TCP(\"\\x01...\\x0n\")\nadd an option to Scapy's code manually in scapy\/layers\/inet.py TCPOptions structure\n\nThese are workarounds and a definitive solution to this would be to implement a byte per byte TCP options field and commit on Scapy's github of course.","Q_Score":0,"Tags":"python,tcp,scapy","A_Id":40023525,"CreationDate":"2016-09-26T22:46:00.000","Title":"Read\/Write TCP options field","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working in Python and using OpenCV's videocapture and cv.imshow to show a video. I am trying to put an overlay on this video so I can draw on it using cv.line, cv.rectangle, etc. Each time the frame changes it clears the image that was drawn so I am hoping if I was to put an overlay of some sort on top of this that it would allow me to draw multiple images on the video without clearing. Any advice? Thanks ahead!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1160,"Q_Id":39715472,"Users Score":0,"Answer":"What you need are 2 Mat objects- one to stream the camera (say Mat_cam), and the other to hold the overlay (Mat_overlay).\nWhen you draw on your main window, save the line and Rect objects on Mat_overlay, and make sure that it is not affected by the streaming video\nWhen the next frame is received, Mat_cam will be updated and it'll have the next video frame, but Mat_overlay will be the same, since it will not be cleared\/refreshed with every 'for' loop iteration. Adding Mat_overlay and Mat_cam using Weighted addition will give you the desired result.","Q_Score":1,"Tags":"python,opencv,video,overlay","A_Id":39716115,"CreationDate":"2016-09-27T03:22:00.000","Title":"How to put an overlay on a video","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently working in Python and using OpenCV's videocapture and cv.imshow to show a video. I am trying to put an overlay on this video so I can draw on it using cv.line, cv.rectangle, etc. Each time the frame changes it clears the image that was drawn so I am hoping if I was to put an overlay of some sort on top of this that it would allow me to draw multiple images on the video without clearing. Any advice? Thanks ahead!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1160,"Q_Id":39715472,"Users Score":0,"Answer":"I am not sure that I have understood your question properly.What I got from your question is that you want the overlay to remain on your frame, streamed from Videocapture,  for that one simple solution is to declare your \"Mat_cam\"(camera streaming variable) outside the loop that is used to capture frames so that \"Mat_cam\" variable will not be freed every time you loop through it.","Q_Score":1,"Tags":"python,opencv,video,overlay","A_Id":39721387,"CreationDate":"2016-09-27T03:22:00.000","Title":"How to put an overlay on a video","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to understand whether python libraries are compiled because I want to know if the interpreted code I write will perform the same or worse.\ne.g. I saw it mentioned somewhere that numpy and scipy are efficient because they are compiled. I don't think this means byte code compiled so how was this done? Was it compiled to c using something like cython? Or was it written using a language like c and compiled in a compatible way?\nDoes this apply to all modules or is it on a case-by-case basis?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2959,"Q_Id":39722984,"Users Score":1,"Answer":"Python can execute functions written in Python (interpreted) and compiled functions.  There are whole API docs about writing code for integration with Python.  cython is one of the easier tools for doing this. \nLibraries can be any combination - pure Python, Python plus interfaces to compiled code, or all compiled.  The interpreted files end with .py, the compiled stuff usually is .so or .dll (depending on the operating system).  It's easy to install pure Python code - just load, unzip if needed, and put the right directory.  Mixed code requires a compilation step (and hence a c compiler, etc), or downloading a version with binaries.\nTypically developers get the code working in Python, and then rewrite speed sensitive portions in c.  Or they find some external library of working c or Fortran code, and link to that.\nnumpy and scipy are mixed.  They have lots of Python code, core compiled portions, and use external libraries.  And the c code can be extraordinarily hard to read.\nAs a numpy user, you should first try to get as much clarity and performance with Python code.  Most of the optimization SO questions discuss ways of making use of the compiled functionality of numpy - all the operations that work on whole arrays.  It's only when you can't express your operations in efficient numpy code that you need to resort to using a tool like cython or numba.\nIn general if you have to iterate extensively then you are using low level operations.  Either replace the loops with array operations, or rewrite the loop in cython.","Q_Score":4,"Tags":"python,numpy,compilation","A_Id":39728900,"CreationDate":"2016-09-27T11:02:00.000","Title":"Are Python modules compiled?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I have a data file of size 5GB in the disk, and I want to append another set of data of size 100MB at the end of the file -- Just simply append, I don't want to modify nor move the original data in the file. I know I can read the hole file into memory as a long long list and append my small new data to it, but it's too slow. How I can do this more efficiently?\nI mean, without reading the hole file into memory?\nI have a script that generates a large stream of data, say 5GB, as a long long list, and I need to save these data into a file. I tried to generate the list first and then output them all in once, but as the list increased, the computer got slow down very very severely. So I decided to output them by several times: each time I have a list of 100MB, then output them and clear the list. (this is why I have the first problem)\nI have no idea how to do this.Is there any lib or function that can do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1079,"Q_Id":39726921,"Users Score":0,"Answer":"Let's start from the second point: if the list you store in memory is larger than the available ram, the computer starts using the hd as ram and this severely slow down everything. The optimal way of outputting in your situation is fill the ram as much as possible (always keeping enough space for the rest of the software running on your pc) and then writing on a file all in once.\nThe fastest way to store a list in a file would be using pickle so that you store binary data that take much less space than formatted ones (so even the read\/write process is much much faster). \nWhen you write to a file, you should keep the file always open, using something like with open('namefile', 'w') as f. In this way, you save the time to open\/close the file and the cursor will always be at the end. If you decide to do that, use f.flush() once you have written the file to avoid loosing data if something bad happen. The append method is good alternative anyway.\nIf you provide some code it would be easier to help you...","Q_Score":0,"Tags":"python","A_Id":39727471,"CreationDate":"2016-09-27T14:09:00.000","Title":"modify and write large file in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Many would want to measure code similarity to catch plagiarisms, however my intention is to cluster a set of python code blocks (say answers to the same programming question) into different categories and distinguish different approaches taken by students. \nIf you have any idea how this could be achieved, I would appreciate it if you share it here.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":960,"Q_Id":39738872,"Users Score":2,"Answer":"One approach would be to count then number of functions, objects, keywords possibly grouped into categories such as branching, creating, manipulating, etc., and number variables of each type.  Without relying on the methods and variables being called the same name(s).\nFor a given problem the similar approaches will tend to come out with similar scores for these, e.g.: A students who used decision tree would have a high number of branch statements while one who used a decision table would have much lower.\nThis approach would be much quicker to implement than parsing the code structure and comparing the results.","Q_Score":2,"Tags":"python,compilation,comparison,abstract-syntax-tree","A_Id":39738985,"CreationDate":"2016-09-28T05:42:00.000","Title":"How to measure similarity between two python code blocks?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My system is SLES 11.4 having python 2.6.9.\nI know little about python and have not found where to download rpm's that give me needed python packages.\nI acquired numpy 1.4 and 1.11 and I believe did a successful python setup.py build followed by python setup.py install on numpy.\nGoing from memory I think this installed under \/usr\/local\/lib64\/python2.6\/...\nNext I tried building & installing matplotlib (which requires numpy) and when I do python setup.py build it politely responds with cannot find numpy.  So my questions are\ndo i need to set some kind of python related environment variable, something along the lines of LD_LIBRARY_PATH or PATH ?\nAs I get more involved with using python installing packages that I have to build from source I need to understand where things currently are per the default install of python, where new things should go, and where the core settings for python are to know how and where to recognize new packages.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":44,"Q_Id":39759680,"Users Score":0,"Answer":"think i figured it out.  Apparently SLES 11.4 does not include the development headers in the default install from their SDK for numpy 1.8.\nAnd of course they don't offer matplotlib along with a bunch of common python packages.\nThe python packages per the SLES SDK are the system default are located under\/usr\/lib64\/python2.6\/site-packages\/ and it is under here I see numpy version 1.8.  So using the YAST software manager if you choose various python packages this is where they are located.\nTo this point without having the PYTHONPATH environment variable set I can launch python, type import numpy, and for the most part use it.  But if I try to build matplotlib 0.99.1 it responds that it cannot find the header files for numpy version 1.8, so it knows numpy 1.8 is installed but the development package needs to be installed.\nAssuming by development headers they mean .h files,\nIf I search under \/usr\/lib64\/python2.6\/site-packages I have no .h files for anything!\nI just downloaded the source for numpy-1.8.0.tar.gz  and easily did a python setup.py.build followed by python setup.py install and noticed it installed under \/usr\/local\/lib64\/python2.6\/site-packages\/\nWithout the PYTHONPATH environment variable set, if i try to build matplotlib I still get the error about header files not found.\nbut in my bash shell, as root, after I do export PYTHONPATH=\/usr\/local\/lib64\/python2.6\/site-packages I can successfully do the build and install of matplotlib 0.99.1 which also installs \/usr\/local\/lib64\/python2.6\/site-packages\nNotes:\nI also just did a successful build & install of numpy-1.11 and that got thrown in under \/usr\/local\/lib64\/python2.6\/site-packages however when i try to then build matplotlib 0.99.1 with PYTHONPATH set it reports outright that numpy is not installed that version 1.1 or greater is needed.  So here it seems this older version of matplotlib needs to use a certain version range of numpy, that the latest numpy 1.11 is not compatible.\nAnd the only other environment variable i have which is set by the system is PYTHONSTARTUP which points to the file \/etc\/pythonstart.","Q_Score":0,"Tags":"python","A_Id":39778818,"CreationDate":"2016-09-29T00:44:00.000","Title":"manually building installing python packages in linux so they are recognized","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a program on the Raspberry Pi with a touchscreen display. \nI'm using Python Tkinter that has two entry widgets and one on screen keypad. I want to use the same keypad for entering data on both entry widgets. \nCan anyone tell me how can i check if an entry is selected? Similar like clicking on the Entry using the mouse and the cursor appears. How can I know that in Python Tkinter?\nThank you.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1831,"Q_Id":39768925,"Users Score":2,"Answer":"There is always a widget with the keyboard focus. You can query that with the focus_get method of the root window. It will return whatever widget has keyboard focus. That is the window that should receive input from your keypad.","Q_Score":1,"Tags":"python,tkinter,raspberry-pi,touchscreen,raspberry-pi3","A_Id":39770561,"CreationDate":"2016-09-29T11:23:00.000","Title":"Check if Entry widget is selected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I haven't been able to find anything and I am not sure if this is the place I should be asking... \nBut I want to include the path to my interpreter in every new project I create.  The reason being is that I develop locally and sync my files to a linux server.  It is annoying having to manually type #! \/users\/w\/x\/y\/z\/bin\/python every time I create a new project. Also would be nice to include certain imports I use 90% of the time.  \nI got to thinking, in the program I produce music with you can set a default project file.  Meaning, when you click new project it is set up how you have configured (include certain virtual instruments, effects, etc).\nIs it possible to do this or something similar with IDE, and more specifically, Pycharm?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":39771998,"Users Score":0,"Answer":"Click on the top-right tab with your project name, then go Edit Configurations and there you can change the interpreter.","Q_Score":0,"Tags":"python,linux,pycharm","A_Id":39772172,"CreationDate":"2016-09-29T13:42:00.000","Title":"Is it possible to include interpreter path (or set any default code) when I create new python file in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I haven't been able to find anything and I am not sure if this is the place I should be asking... \nBut I want to include the path to my interpreter in every new project I create.  The reason being is that I develop locally and sync my files to a linux server.  It is annoying having to manually type #! \/users\/w\/x\/y\/z\/bin\/python every time I create a new project. Also would be nice to include certain imports I use 90% of the time.  \nI got to thinking, in the program I produce music with you can set a default project file.  Meaning, when you click new project it is set up how you have configured (include certain virtual instruments, effects, etc).\nIs it possible to do this or something similar with IDE, and more specifically, Pycharm?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":39771998,"Users Score":1,"Answer":"You should open File in the main menu and click Default Settings, collapse the Editor then click File and Code Templates, in the Files tab click on the + sign and create a new Template, give the new template a name and extension, in the editor box put your template content, in your case #! \/users\/w\/x\/y\/z\/bin\/python apply and OK. After that everytime you open a project, select that template to include default lines you want. You could make number of templates.","Q_Score":0,"Tags":"python,linux,pycharm","A_Id":39772630,"CreationDate":"2016-09-29T13:42:00.000","Title":"Is it possible to include interpreter path (or set any default code) when I create new python file in Pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to add a text box to a chart I've generated with openpyxl, but can't find documentation or examples showing how to do so. Does openpyxl support it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3047,"Q_Id":39773544,"Users Score":0,"Answer":"I'm not sure what you mean by \"text box\". In theory you can add pretty much anything covered by the DrawingML specification to a chart but the practice may be slightly different.\nHowever, there is definitely no built-in API for this so you'd have to start by creating a sample file and working backwards from it.","Q_Score":2,"Tags":"python,openpyxl","A_Id":39774351,"CreationDate":"2016-09-29T14:49:00.000","Title":"Adding a text box to an excel chart using openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to write the file to my company's project folder which is unix system and the location is \/department\/projects\/data\/. So I used the following code\ndf.to_csv(\"\/department\/projects\/data\/Test.txt\", sep='\\t', header = 0)\nThe error message shows it cannot find the locations. how to specify the file location in Unix using python?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":39779412,"Users Score":0,"Answer":"I have find the solution. It might because I am using Spyder from anaconda. As long as I use \"\\\" instead of \"\\\", python can recognize the location.","Q_Score":0,"Tags":"python,unix","A_Id":39813792,"CreationDate":"2016-09-29T20:27:00.000","Title":"how to export data to unix system location using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"how to generate a responsive PDF with Django?.\nI want to generate a PDF with Django but i need that is responsive, that is to say, the text of the PDF has that adapted to don't allow space empty.\nfor example to a agreement this change in the text, then, i need to adapt the to space of paper leaf.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":252,"Q_Id":39780715,"Users Score":2,"Answer":"PDF is not built to be responsive, it is built to display the same no matter where it is viewed.\nAs @alxs pointed out in a comment, there are a few features that PDF viewing applications have added to simulate PDFs being responsive. Acrobat's Reflow feature is the best example of this that I am aware of and even it struggles with most PDFs that users come across in the wild.\nOne of the components (if not the only one) that matters, is that in order for a PDF to be useful in Acrobat's Reflow mode is to make sure that the PDFs you are creating contain structure information, this would be a Tagged PDF. Tagged PDF contains content that has been marked, similar to HTML tags, where text that makes up a paragraph is tagged in the PDF as being a paragraph. A number of PDF tools (creation or viewing) do not interpret the structure of a PDF though.","Q_Score":1,"Tags":"python,html,django,pdf-generation,weasyprint","A_Id":39792862,"CreationDate":"2016-09-29T22:02:00.000","Title":"how to generate a responsive PDF with Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I have a text that I've read into memory by using open('myfile.txt').read(), and if I know a certain location in this file, say, at character 10524, how can I find the line number of that location?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":156,"Q_Id":39801748,"Users Score":2,"Answer":"Examine the text preceding your desired position and count the number of \\n characters.","Q_Score":0,"Tags":"python","A_Id":39801759,"CreationDate":"2016-10-01T00:19:00.000","Title":"In Python, how can I get a line number corresponding to a given character location?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to scrape a lot (a few hundred) of sites, which are basically like bulletin boards. Some of these are very large (up to 1.5 million) and also growing very quickly. What I want to achieve is:\n\nscrape all the existing entries\nscrape all the new entries near real-time (ideally around 1 hour intervals or less)\n\nFor this we are using scrapy and save the items in a postresql database. The problem right now is, how can I make sure I got all the records without scraping the complete site every time? (Which would not be very agressive traffic-wise, but also not possible to complete within 1 hour.)\nFor example: I have a site with 100 pages and 10 records each. So I scrape page 1, and then go to page 2. But on fast growing sites, at the time I do the request for page 2, there might be 10 new records, so I would get the same items again. Nevertheless I would get all items in the end. BUT next time scraping this site, how would I know where to stop? I can't stop at the first record I already have in my database, because this might be suddenly on the first page, because there a new reply was made.\nI am not sure if I got my point accross, but tl;dr: How to fetch fast growing BBS in an incremental way? So with getting all the records, but only fetching new records each time. I looked at scrapy's resume function and also at scrapinghubs deltafetch middleware, but I don't know if (and how) they can help to overcome this problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":265,"Q_Id":39805237,"Users Score":1,"Answer":"For example: I have a site with 100 pages and 10 records each. So I scrape page 1, and then go to page 2. But on fast growing sites, at the time I do the request for page 2, there might be 10 new records, so I would get the same items again. Nevertheless I would get all items in the end. BUT next time scraping this site, how would I know where to stop? I can't stop at the first record I already have in my database, because this might be suddenly on the first page, because there a new reply was made.\n\nUsually each record has a unique link (permalink) e.g. the above question can be accessed by just entering https:\/\/stackoverflow.com\/questions\/39805237\/ & ignoring the text beyond that. You'll have to store the unique URL for each record and when you scrape next time, ignore the ones that you already have. \nIf you take the example of tag python on Stackoverflow, you can view the  questions here : https:\/\/stackoverflow.com\/questions\/tagged\/python but the sorting order can't be relied upon for ensuring unique entries. One way to scrape would be to sort by newest questions and keep ignoring duplicate ones by their URL. \nYou can have an algorithm that scrapes first 'n' pages every 'x' minutes until it hits an existing record. The whole flow is a bit site specific, but as you scrape more sites, your algorithm will become more generic and robust to handle edge cases and new sites.\nAnother approach is to not run scrapy yourself, but use a distributed spider service. They generally have multiple IPs and can spider large sites within minutes. Just make sure you respect the site's robots.txt file and don't accidentally DDoS them.","Q_Score":0,"Tags":"python,postgresql,web-scraping,scrapy","A_Id":39805342,"CreationDate":"2016-10-01T09:56:00.000","Title":"How to go about incremental scraping large sites near-realtime","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have problem on import nltk.\nI configured apache and run some sample python code, it worked well on the browser.\nThe URL is : \/localhost\/cgi-bin\/test.py.\nWhen I import the nltk in test.py its not running. The execution not continue after the \"import nltk\" line.And it gives me that error ValueError: Could not find a default download directory \nBut when I run in the command prompt its working perfect.\nhow to remove this error?","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1011,"Q_Id":39805675,"Users Score":-1,"Answer":"The Problem is raised probably because you don't have a default directory created for your ntlk downloads. If you are on a Windows Platform, All you need to do is to create a directory named \"nltk_data\" in any of your root directory and grant write permissions to that directory. The Natural Language Tool Kit initially searches for the destination named \"nltk_data\" in all of the root directories.\nFor Instance: Create a folder in your C:\\ drive named \"nltk_data\"\nAfter Making sure everything is done fine, execute your script to get rid of this error.\nHope this helps. \nRegards.","Q_Score":1,"Tags":"python,nltk","A_Id":39810288,"CreationDate":"2016-10-01T10:46:00.000","Title":"ValueError: Could not find a default download directory of nltk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a .csv file with a list of URLs I need to extract data from. I need to automate the following process: (1) Go to a URL in the file. (2) Click the chrome extension that will redirect me to another page which displays some of the URL's stats. (3) Click the link in the stats page that enables me to download the data as a .csv file. (4) Save the .csv. (5) Repeat for the next n URLs.\nAny idea how to do this? Any help greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":282,"Q_Id":39836893,"Users Score":0,"Answer":"There is a python package called mechanize. It helps you automate the processes that can be done on a browser. So check it out.I think mechanize should give you all the tools required to solve the problem.","Q_Score":0,"Tags":"python,automation,imacros","A_Id":39837450,"CreationDate":"2016-10-03T17:11:00.000","Title":"Automate file downloading using a chrome extension","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","AnswerCount":8,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":31750,"Q_Id":39851566,"Users Score":12,"Answer":"You will have to use the absolute path of pip.\nE.g: if I installed python 3 to C:\\python35, I would use:\nC:\\> python35\\Scripts\\pip.exe install packagename\nOr if you're on linux, use pip3 install packagename\nIf you don't specify a full path, it will use whichever pip is in your path.","Q_Score":15,"Tags":"python,python-2.7,python-3.x,pip","A_Id":39852126,"CreationDate":"2016-10-04T11:51:00.000","Title":"Using pip on Windows installed with both python 2.7 and 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","AnswerCount":8,"Available Count":4,"Score":0.024994793,"is_accepted":false,"ViewCount":31750,"Q_Id":39851566,"Users Score":1,"Answer":"The answer from Farhan.K will work. However, I think a more convenient way would be to rename python35\\Scripts\\pip.exe to python35\\Scripts\\pip3.exe assuming python 3 is installed in C:\\python35.\nAfter renaming, you can use pip3 when installing packages to python v3 and pip when installing packages to python v2. Without the renaming, your computer will use whichever pip is in your path.","Q_Score":15,"Tags":"python,python-2.7,python-3.x,pip","A_Id":39852599,"CreationDate":"2016-10-04T11:51:00.000","Title":"Using pip on Windows installed with both python 2.7 and 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","AnswerCount":8,"Available Count":4,"Score":-0.024994793,"is_accepted":false,"ViewCount":31750,"Q_Id":39851566,"Users Score":-1,"Answer":"I tried many things , then finally \npip3 install --upgrade pip worked for me as i was facing this issue since i  had both python3 and python2.7 installed on my system. \nmind the pip3 in the beginning and pip in the end.\nAnd yes you do have to run in admin mode the command prompt and make sure if the path is set properly.","Q_Score":15,"Tags":"python,python-2.7,python-3.x,pip","A_Id":48870834,"CreationDate":"2016-10-04T11:51:00.000","Title":"Using pip on Windows installed with both python 2.7 and 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","AnswerCount":8,"Available Count":4,"Score":-0.024994793,"is_accepted":false,"ViewCount":31750,"Q_Id":39851566,"Users Score":-1,"Answer":"1-open command prompt and change direction using the command cd C:\\Python35\\Scripts\n2- write the command pip3 install --upgrade pip\n3- close the command prompt and reopen it again to return to the default direction and use the command pip3.exe install package_name to install any package you want","Q_Score":15,"Tags":"python,python-2.7,python-3.x,pip","A_Id":53885123,"CreationDate":"2016-10-04T11:51:00.000","Title":"Using pip on Windows installed with both python 2.7 and 3.5","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Well, I know I can use %matplotlib inline to plot inline.\nHowever, how to disable it? \nSometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure.","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":9341,"Q_Id":39861106,"Users Score":3,"Answer":"%matplotlib auto should switch to the default backend.","Q_Score":7,"Tags":"python,matplotlib,ipython,jupyter","A_Id":50086042,"CreationDate":"2016-10-04T20:22:00.000","Title":"How to DISABLE Jupyter notebook matplotlib plot inline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Well, I know I can use %matplotlib inline to plot inline.\nHowever, how to disable it? \nSometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":9341,"Q_Id":39861106,"Users Score":1,"Answer":"Use %matplotlib notebook to change to a zoom-able display.","Q_Score":7,"Tags":"python,matplotlib,ipython,jupyter","A_Id":39861256,"CreationDate":"2016-10-04T20:22:00.000","Title":"How to DISABLE Jupyter notebook matplotlib plot inline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a python package for in-house use which relies upon some environmental variables (namely, the user and password to enter an online database). for my company, the convenience of installing a package rather than having it in every  project is significant as the functions inside are used in completely separate projects and maintainability is a primary issue. \nso, how do I \"link\" the package with the environmental variables?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23,"Q_Id":39880906,"Users Score":0,"Answer":"I think I'll just detail in the readme file what to insert and where. I tried to find a difficult solution when it was really simple and straightforward","Q_Score":0,"Tags":"python,package,environment-variables","A_Id":39918729,"CreationDate":"2016-10-05T18:06:00.000","Title":"In-house made package and environmental variables link","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"im using django-tables2 in order to show values from a database query. And everythings works fine. Im now using Django-dabug-toolbar and was looking through my pages with it. More out of curiosity than performance needs. When a lokked at the page with the table i saw that the debug toolbar registerd over 300 queries for a table with a little over 300 entries. I dont think flooding the DB with so many queries is a good idea even if there is no performance impact (at least not now). All the data should be coming from only one query.\nWhy is this happening and how can i reduce the number of queries?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":348,"Q_Id":39882504,"Users Score":2,"Answer":"Im posting this as a future reference for myself and other who might have the same problem. \nAfter searching for a bit I found out that django-tables2 was sending a single query for each row. The query was something like SELECT * FROM \"table\"  LIMIT 1 OFFSET 1 with increasing offset. \nI reduced the number of sql calls by calling query = list(query) before i create the table and pass the query. By evaluating the query in the python view code the table now seems to work with the evaulated data instead and there is only one database call instead of hundreds.","Q_Score":3,"Tags":"python,django,django-tables2","A_Id":39882505,"CreationDate":"2016-10-05T19:49:00.000","Title":"django-tables2 flooding database with queries","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So i'm programming python program that uses wxPython for UI, with wx.TreeCtrl widget for selecting pictures(.png) on selected directory. I would like to add hover on treectrl item that works like tooltip, but instead of text it shows bitmap picture.\nIs there something that already allows this, or would i have to create something with wxWidgets? \nI am not too familiar with wxWidgets, so if i have to create something like that how hard would it be, lot of code is already using the treectrl, so it needs to be able to work same way.\nSo how would i have to go about doing this? And if there might be something i might be missing id be happy to know.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":160,"Q_Id":39891681,"Users Score":1,"Answer":"Take a look at the wx.lib.agw.supertooltip module. It should help you to create a tooltip-like window that displays custom rich content.\nAs for triggering the display of the tooltip, you can catch mouse events for the tree widget (be sure to call Skip so the tree widget can see the events too) and reset a timer each time the mouse moves.  If the timer expires because the mouse hasn't been moved in that long then you can use tree.HitTest to find the item that the cursor is on and then show the appropriate image for that item.","Q_Score":0,"Tags":"python,bitmap,wxpython","A_Id":39901257,"CreationDate":"2016-10-06T08:54:00.000","Title":"wxpython treectrl show bitmap picture on hover","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Java process which interacts with its REST API called from my program's UI. When I receive the API call, I end up calling the (non-REST based) Python script(s) which do a bunch of work and return me back the results which are returned back as API response.\n- I wanted to convert this interaction of UI API -> JAVA -> calling python scripts to become end to end a REST one, so that in coming times it becomes immaterial which language I am using instead of Python.\n- Any inputs on whats the best way of making the call end-to-end a REST based ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2327,"Q_Id":39906167,"Users Score":0,"Answer":"Furthermore, in the future you might want to separate them from the same machine and use network to communicate.\nYou can use http requests.\nMake a contract in java of which output you will provide to your python script (or any other language you will use) send the output as a json to your python script, so in that way you can easily change the language as long as you send the same json.","Q_Score":1,"Tags":"java,python,rest,api","A_Id":39906371,"CreationDate":"2016-10-06T21:51:00.000","Title":"Inputs on how to achieve REST based interaction between Java and Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've tried to do this using the 'r+b',  'w+b', and 'a+b' modes for open(). I'm using with seek() and write() to move to and write to an arbitrary location in the file, but all I can get it to do is either 1) write new info at the end of the file or 2) overwrite existing data in the file. \nDoes anyone know of some other way to do this or where I'm going wrong here?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":56,"Q_Id":39906620,"Users Score":1,"Answer":"What you're doing wrong is assuming that it can be done.  :-)\nYou don't get to insert and shove the existing data over; it's already in that position on disk, and overwrite is all you get.\nWhat you need to do is to mark the insert position, read the remainder of the file, write your insertion, and then write that remainder after the insertion.","Q_Score":0,"Tags":"python,file,binaryfiles,file-writing","A_Id":39906690,"CreationDate":"2016-10-06T22:31:00.000","Title":"how do I insert data to an arbitrary location in a binary file without overwriting existing file data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a python console exe. It cannot work on windows2008 R2 server.\nI copy MSVCR100.dll and MSVCP100.dll from another computer onto the dir containing the exe file. It has been working correctly a long time.\nToday, when start it show that \"Failed to write all bytes for MSVCR100.dll\"\nI don't know what caused it and how to deal with it.\nThanks for any suggestions.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2132,"Q_Id":39940303,"Users Score":0,"Answer":"The \"Failed to write all bytes for (random DLL name)\" error generally indicates that the disk is full. Would be nice if Microsoft had bothered to add an extra sentence indicating such, but this is usually the problem.\nIf your disk isn't full, then it may be a permissions issue -- make sure the user you're running the program as has write access to wherever it's trying to write to.","Q_Score":0,"Tags":"python,windows-server-2008-r2,msvcr100.dll","A_Id":54189960,"CreationDate":"2016-10-09T05:21:00.000","Title":"Failed to write all bytes for MSVCR100.dll","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple \"Hello World\" script and I'm receiving this error: \n\nFailed to launch the Python Process, please validate the path 'python'\n\nfollowed by this in the debug console:\n\nError: spawn python ENOENT\n\nCould someone please help me out and tell me how to fix this?\nI'm running on windows 10.\nThanks!","AnswerCount":6,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":27825,"Q_Id":39949845,"Users Score":0,"Answer":"Figured it out, if you just started python then you probably did not add python to your path. \nTo do so uninstall python and then reinstall it. This time click \"add python to path\" at the bottom of the install screen.","Q_Score":4,"Tags":"python-3.x","A_Id":39950009,"CreationDate":"2016-10-10T00:18:00.000","Title":"Visual Studio Python \"Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple \"Hello World\" script and I'm receiving this error: \n\nFailed to launch the Python Process, please validate the path 'python'\n\nfollowed by this in the debug console:\n\nError: spawn python ENOENT\n\nCould someone please help me out and tell me how to fix this?\nI'm running on windows 10.\nThanks!","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":27825,"Q_Id":39949845,"Users Score":1,"Answer":"Simply restart your VB studio code. Those show that some packages have been downloaded but not yet installed until reboot it.","Q_Score":4,"Tags":"python-3.x","A_Id":43901308,"CreationDate":"2016-10-10T00:18:00.000","Title":"Visual Studio Python \"Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple \"Hello World\" script and I'm receiving this error: \n\nFailed to launch the Python Process, please validate the path 'python'\n\nfollowed by this in the debug console:\n\nError: spawn python ENOENT\n\nCould someone please help me out and tell me how to fix this?\nI'm running on windows 10.\nThanks!","AnswerCount":6,"Available Count":5,"Score":0.0333209931,"is_accepted":false,"ViewCount":27825,"Q_Id":39949845,"Users Score":1,"Answer":"Add python path by following these steps.\n1. Go to uninstall a program.\n2. Go to Python 3.6.1 (this is my python version). Select and click on Uninstall\/change.\n3.Click on Modify.\n4. Click next > In advanced options > tick add Python to environment variable. Click install. Restart VS code.","Q_Score":4,"Tags":"python-3.x","A_Id":43998477,"CreationDate":"2016-10-10T00:18:00.000","Title":"Visual Studio Python \"Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple \"Hello World\" script and I'm receiving this error: \n\nFailed to launch the Python Process, please validate the path 'python'\n\nfollowed by this in the debug console:\n\nError: spawn python ENOENT\n\nCould someone please help me out and tell me how to fix this?\nI'm running on windows 10.\nThanks!","AnswerCount":6,"Available Count":5,"Score":0.0665680765,"is_accepted":false,"ViewCount":27825,"Q_Id":39949845,"Users Score":2,"Answer":"For those who are having this error after the recent (May-June of 2017) update of Visual Studio Code.\nYour old launch.json file might be causing this issue, due to the recent updates of launch.json file format and structure.\nTry to delete launch.json file in the .vscode folder. The .vscode folder exists in your workspace where your source code exists, not to be confused with the one in your user home folder (C:\\Users\\{username}\\.vscode).\nThis workaround worked fine for me with Windows10 + Visual Studio Code + Python extension. Just delete the existing launch.json and restart Visual Studio Code, and then start your debugging. The launch.json file might be regenerated again, but this time it should be in the correct shape.","Q_Score":4,"Tags":"python-3.x","A_Id":44814591,"CreationDate":"2016-10-10T00:18:00.000","Title":"Visual Studio Python \"Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple \"Hello World\" script and I'm receiving this error: \n\nFailed to launch the Python Process, please validate the path 'python'\n\nfollowed by this in the debug console:\n\nError: spawn python ENOENT\n\nCould someone please help me out and tell me how to fix this?\nI'm running on windows 10.\nThanks!","AnswerCount":6,"Available Count":5,"Score":1.0,"is_accepted":false,"ViewCount":27825,"Q_Id":39949845,"Users Score":7,"Answer":"Do not uninstall!\n1) Go to location that you installed the program.\n*example: C:\\Program Files (x86)\\Microsoft VS Code \ncopy the location.\n2) right click on computer> properties >Advanced System Settings> Environment variables > under user variables find \"path\" click> edit> under variable value: go to the end of the line add ; then paste your location>ok > then go under system variables find \"path\"> do the same thing.... add ; then paste your location.\n FOR EXAMPLE\"        ;C:\\Program Files (x86)\\Microsoft VS Code\n3) Restart your Visual Studio Code","Q_Score":4,"Tags":"python-3.x","A_Id":41195399,"CreationDate":"2016-10-10T00:18:00.000","Title":"Visual Studio Python \"Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem with console app with threading. In first thread i have a function, which write symbol \"x\" into output. In second thread i have function, which waiting for users input. (Symbol \"x\" is just random choice for this question).\nFor ex.\nThread 1:\n\n\n    while True:\n        print \"x\"\n        time.sleep(1)\n\n\nThread 2:\n\n\n    input = null\n    while input != \"EXIT\":\n        input = raw_input()\n        print input\n\n\nBut when i write text for thread 2 to console, my input text (for ex. HELLO) is rewroted. \n\n\n    x\n    x\n    HELx\n    LOx\n    x\n    x[enter pressed here]\n\n    HELLO\n    x\n    x\n\n\nIs any way how can i prevent rewriting my input text by symbol \"x\"?\nThanks for answers.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":201,"Q_Id":39958650,"Users Score":0,"Answer":"In a console, standard output (produced by the running program(s)) and standard input (produced by your keypresses) are both sent to screen, so they may end up all mixed.\nHere your thread 1 writes 1 x by line every second, so if your take more than 1 second to type HELLO then that will produce the in-console output that you submitted.\nIf you want to avoid that, a few non-exhaustive suggestions:\n\ntemporarily interrupt thread1 output when a keypress is detected\nuse a library such as ncurses to create separates zones for your program output and the user input\njust suppress thread1 input, or send it to a file instead.","Q_Score":0,"Tags":"python,multithreading,console-application","A_Id":39958943,"CreationDate":"2016-10-10T12:46:00.000","Title":"One of threads rewrites console input in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently building a recommender engine in python and I faced the following problem.\nI want to incorporate collaborative filtering approach, its user-user variant. To recap, its idea is that we have an information on different users and which items they liked (if applicable - which ratings these users assigned to items). When we have new user who liked couple of things we just find users who liked same items and recommend to this new user items which were liked by users similar to new user.\nBut I want to add some twist to it. I will be recommending places to users, namely 'where to go tonight'. I know user preferences, but I want to also incorporate the distance to each item I could recommend. The father the place I am going to recommend to the user - the least attractive it should be.\nSo in general I want to incorporate a penalty into recommendation engine and the amount of penalty for each place will be based on the distance from user to the place.\nI tried to googleif anyone did something similar but wasn't able to find anything. Any advice on how to properly add such penalty?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":39969168,"Users Score":2,"Answer":"I would keep it simple and separate:\nYour focus is collaborative filtering, so your recommender should generate scores for the top N recommendations regardless of location.\nThen you can re-score using distance among those top-N.  For a simple MVP, you could start with an inverse distance decay (e.g. final-score = cf-score * 1\/distance), and adjust the decay function based on behavioral evidence if necessary.","Q_Score":0,"Tags":"python,machine-learning,recommendation-engine,data-science","A_Id":40001529,"CreationDate":"2016-10-11T01:29:00.000","Title":"Recommender engine in python - incorporate custom similarity metrics","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a sparse matrix X, shape (6000, 300). I'd like something like a scatterplot which has a dot where the X(i, j) != 0, and blank space otherwise. I don't know how many nonzero entries there are in each row of X. X[0] has 15 nonzero entries, X[1] has 3, etc. The maximum number of nonzero entries in a row is 16.\nAttempts:\n\nplt.imshow(X) results in a tall, skinny graph because of the shape of X. Using plt.imshow(X, aspect='auto) will stretch out the graph horizontally, but the dots get stretched out to become ellipses, and the plot becomes hard to read.\nax.spy suffers from the same problem. \nbokeh seems promising, but really taxes my jupyter kernel. \n\nBonus:\n\nThe nonzero entries of X are positive real numbers. If there was some way to reflect their magnitude, that would be great as well (e.g. colour intensity, transparency, or across a colour bar).\nEvery 500 rows of X belong to the same class. That's 12 classes * 500 observations (rows) per class = 6000 rows. E.g. X[:500] are from class A, X[500:1000] are from class B, etc. Would be nice to colour-code the dots by class. For the moment I'll settle for manually including horizontal lines every 500 rows to delineate between classes.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2877,"Q_Id":39970515,"Users Score":0,"Answer":"It seems to me heatmap is the best candidate for this type of plot. imshow() will return u a colored matrix with color scale legend. \nI don't get ur stretched ellipses problem, shouldnt it be a colored squred for each data point? \nu can try log color scale if it is sparse. also plot the 12 classes separately to analyze if theres any inter-class differences.","Q_Score":1,"Tags":"python,matplotlib","A_Id":39971118,"CreationDate":"2016-10-11T04:29:00.000","Title":"Python: Plot a sparse matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a sparse matrix X, shape (6000, 300). I'd like something like a scatterplot which has a dot where the X(i, j) != 0, and blank space otherwise. I don't know how many nonzero entries there are in each row of X. X[0] has 15 nonzero entries, X[1] has 3, etc. The maximum number of nonzero entries in a row is 16.\nAttempts:\n\nplt.imshow(X) results in a tall, skinny graph because of the shape of X. Using plt.imshow(X, aspect='auto) will stretch out the graph horizontally, but the dots get stretched out to become ellipses, and the plot becomes hard to read.\nax.spy suffers from the same problem. \nbokeh seems promising, but really taxes my jupyter kernel. \n\nBonus:\n\nThe nonzero entries of X are positive real numbers. If there was some way to reflect their magnitude, that would be great as well (e.g. colour intensity, transparency, or across a colour bar).\nEvery 500 rows of X belong to the same class. That's 12 classes * 500 observations (rows) per class = 6000 rows. E.g. X[:500] are from class A, X[500:1000] are from class B, etc. Would be nice to colour-code the dots by class. For the moment I'll settle for manually including horizontal lines every 500 rows to delineate between classes.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2877,"Q_Id":39970515,"Users Score":0,"Answer":"plt.matshow also turned out to be a feasible solution. I could also plot a heatmap with colorbars and all that.","Q_Score":1,"Tags":"python,matplotlib","A_Id":40127976,"CreationDate":"2016-10-11T04:29:00.000","Title":"Python: Plot a sparse matrix","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently installed ArcGIS10.4 and now when I run python 2.7 programs using Idle (for purposes unrelated to ArcGIS) it uses the version of python attached to ArcGIS.\nOne of the programs I wrote needs an updated version of the pandas module. When I try to update the pandas module in this verion of python (by opening command prompt as an administrator, moving to C:\\Python27\\ArcGIS10.4\\Scripts and using the command pip install --upgrade pandas) the files download ok but there is an access error message when PIP tries to upgrade. I have tried restarting the computer in case something was open.  The error message is quite long and I can't cut and paste from command prompt but it finishes with \n\" Permission denied:  'C:\\Python27\\ArcGIS10.4\\Lib\\site-packages\\numpy\\core\\multiarray.pyd'  \"\nI've tried the command to reinstall pandas completely which also gave an error message.  I've tried installing miniconda in the hope that I could get a second version of python working and then use that version instead of the version attached to ArcMap. However I don't know how to direct Idle to choose the newly installed version. \nSo overall I don't mind having 2 versions of python if someone could tell me how to choose which one runs or if there's some way to update the ArcMap version that would be even better. I don't really want to uninstall ArcMap at the moment.\nAny help is appreciated! Thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":212,"Q_Id":39972261,"Users Score":0,"Answer":"I reinstalled python again directly from python.org and then installed pandas which seems to work.  \nI guess this might stop the ArcMap version of python working properly but since I'm not using python with ArcMap at the moment it's not a big problem.","Q_Score":0,"Tags":"python,pandas,upgrade,arcmap","A_Id":39972738,"CreationDate":"2016-10-11T07:25:00.000","Title":"How to update pandas when python is installed as part of ArcGIS10.4, or another solution","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am now trying the python module google which only return the url from the search result. And I want to have the snippets as information as well, how could I do that?(Since the google web search API is deprecated)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":167,"Q_Id":39989680,"Users Score":0,"Answer":"I think you're going to have to extract your own snippets by opening and reading the url in the search result.","Q_Score":1,"Tags":"python","A_Id":39989752,"CreationDate":"2016-10-12T02:41:00.000","Title":"How can I get the google search snippets using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The past few months, I've been working on a project using Spyder2 IDE with Python 2.7. However, now I'm being instructed to look into ways of translating the program from Python 2.7 to Python 3.5, which means I'm using Anaconda3 now instead of Anaconda2, and that means I'm using Spyder3 as the default IDE instead of Spyder2. I want to be able to import the entire project, but Spyder3 does not recognize it as such. So how to I import a Spyder2 Project into the Spyder3 IDE?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":505,"Q_Id":40001836,"Users Score":1,"Answer":"There is an easy solution to this, at least for simple cases and as of May 2017 (Spyder 3.1.2): Create a new empty project in Spyder 3.  The new project directory will then have a subdirectory named \".spyproject\" with these files in it: codestyle.ini, encoding.ini, vcs.ini, workspace.ini.  Copy the entire .spyproject subdirectory to the old Spyder 2 project directory. \nThis allows Spyder 3 to at least see the source files in the old project directory, even if all the settings don't track.\nI only have dumb use cases (e.g. no \"related projects\") in my Spyder 2 projects.  But this way I don't have to generate 75 new projects and manually import the old files.","Q_Score":1,"Tags":"python,python-3.5,projects-and-solutions,spyder","A_Id":44144280,"CreationDate":"2016-10-12T14:55:00.000","Title":"Import Project from Spyder2 to Spyder3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running a website where user can send in-site message (no instantaneity required) to other user, and the receiver will get a notification about the message.\nNow I am using a simple system to implement that, detail below.\nTable Message:\n\nid\ncontent\nreceiver\nsender\n\nTable User:\n\nsome info\nnotification\nsome info\n\nWhen a User A send message to User B, a record will be add to Message and the B.notification will increase by 1. When B open the message box the notification will decrease to 0.\nIt's simple but does well.\nI wonder how you\/company implement message system like that.\nNo need to care about UE(like confirm which message is read by user), just the struct implement.\nThank a lot :D","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":123,"Q_Id":40013849,"Users Score":0,"Answer":"I think you will need to read about pub\/sub for messaging services. For php, you can use libraries such as redis.\nSo for e.g, user1 subscribe to topic1, any user which publish to topic1, user1 will be notified, and you can implement what will happen to the user1.","Q_Score":0,"Tags":"php,python,web,messagebox","A_Id":40015293,"CreationDate":"2016-10-13T06:34:00.000","Title":"How to implement a message system?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"1) I have Spark on Bluemix platform, how do I add a library there ?\nI can see the preloaded libraries but cant add a library that I want.\nAny command line argument that will install a library?\n\npip install --package is not working there\n\n2)  I have Spark and Mongo DB running, but I am not able to connect both of them.\n\ncon ='mongodb:\/\/admin:ITCW....ssl=true'\n  ssl1 =\"LS0tLS .....\"\n  client = MongoClient(con,ssl=True)\n  db = client.mongo11 \n  collection = db.mongo11 \n  ff=db.sammy.find() \n\n Error I am getting is : \nSSL handshake failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":106,"Q_Id":40020767,"Users Score":2,"Answer":"In a Python notebook:\n!pip install <package>\nand then\nimport <package>","Q_Score":0,"Tags":"python,apache-spark,ibm-cloud,ibm-cloud-plugin","A_Id":40021035,"CreationDate":"2016-10-13T12:17:00.000","Title":"Add a library in Spark in Bluemix & connect MongoDB , Spark together","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been learning Python for a project required for work.  We are starting up a new server that will be running linux, and need a python script to run that will monitor a folder and handle files when they are placed in the folder.\nI have the python \"app\" working, but I'm having a hard time finding how to make this script run when the server is started.  I know it's something simple, but my linux knowledge falls short here.\nSecondary question:  As I understand it I don't need to compile or install this application, basically just call the start script to run it.  Is that correct?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":40033066,"Users Score":2,"Answer":"You can set up the script to run via cron, configuring time as @reboot\nWith python scripts, you will not need to compile it. You might need to install it, depending on what assumptions your script makes about its environment.","Q_Score":2,"Tags":"python,linux","A_Id":40033097,"CreationDate":"2016-10-14T00:21:00.000","Title":"Run a python application\/script on startup using Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I run a script on several CentOS machines that compiles Python 2.7.6 from source and installs it. I would now like to update the script so that it updates Python to 2.7.12, and don't really know how to tackle this.\nShould I do this exactly the same way, just with source code of higher version, and it will overwrite the old Python version?\nShould I first uninstall the old Python version? If so, then how?\nSorry if this is trivial - I tried Googleing and searching through Stack, but did not found anyone with a similar problem.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":240,"Q_Id":40046656,"Users Score":1,"Answer":"Replacing 2.7.6 with 2.7.12 would be fine using the procedure you linked.\nThere should be no real problems with libraries installed with pip easy_install as the version updates are minor. \nWorst comes to worst and there is a library conflict it would be because the python library used for compiling may be different and you can always reinstall the library which would recompile against the correct python library if required. This is only problematic if the library being installed is actually compiled against the python library. Pure python packages would not be affected.\nIf you were doing a major version change this would be okay as well as on CentOS you have to call python with python2.7 and not python, so a new version would call with python2.8","Q_Score":0,"Tags":"python,python-2.7,centos","A_Id":40047015,"CreationDate":"2016-10-14T15:18:00.000","Title":"Updating Python version that's compiled from source","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My system is Archlinux.\nMy project will use NumPy, and my project is in a virtual environment created by virtualenv.\nAs it is difficult to install NumPy by pip, I install it by Pacman:\nsudo pacman -S python-scikit-learn\nBut how can I use it in virtualenv?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":492,"Q_Id":40071987,"Users Score":1,"Answer":"You can create the virtualenv with the --system-site-packages switch to use system-wide packages in addition to the ones installed in the stdlib.","Q_Score":0,"Tags":"python,linux,virtualenv,archlinux-arm,pacman-package-manager","A_Id":40072017,"CreationDate":"2016-10-16T15:27:00.000","Title":"How to use the NumPy installed by Pacman in virtualenv?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am reading other's pickle file that may have data type based on xarray. Now I cannot read in the pickle file with the error \"No module named core.dataset\".\nI guess this maybe a xarray issue. My collaborator asked me to change my version to his version and try again.\nMy version is 0.8.2, and his version 0.8.0. So how can I change back to his version?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":999,"Q_Id":40099001,"Users Score":1,"Answer":"Use \"conda install xarray==0.8.0\" if you're using anaconda, or \"pip install xarray==0.8.0\" otherwise.","Q_Score":1,"Tags":"python-xarray","A_Id":40099554,"CreationDate":"2016-10-18T03:26:00.000","Title":"how to install previous version of xarray","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In accounting -> Customer Invoices, there is a filter called Overdue. Now I want to calculate the overdue payments per user and then display it onto the customer form view.\nI just want to know how can we apply the condition of filter in python code. I have already defined a smart button to display it with a (total invoice value) by inheriting account.invoice.\n\"Overdue\" filter in invoice search view:\n['&', ('date_due', '<', time.strftime('%Y-%m-%d')), ('state', '=', 'open')]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":270,"Q_Id":40109065,"Users Score":1,"Answer":"Your smart button on partners should use a new action, like the button for customer or vendor bills. This button definition should include context=\"{'default_partner_id': active_id} which will allow to change the partner filter later on, or the upcoming action definition should include the partner in its domain.\nThe action should be for model account.invoice and have to have the following domain:\n[('date_due', '<', time.strftime('%Y-%m-%d')), ('state', '=', 'open')]\nIf you want to filter only outgoing (customer invoices) add a filter tuple for field type.","Q_Score":2,"Tags":"python,openerp,odoo-9","A_Id":40124695,"CreationDate":"2016-10-18T13:02:00.000","Title":"Display Sum of overdue payments in Customer Form view for each customer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to figure out the best way to structure a Django app that uses Celery to handle async and scheduled tasks in an autoscaling AWS ElasticBeanstalk environment.\nSo far I have used only a single instance Elastic Beanstalk environment with Celery + Celerybeat and this worked perfectly fine. However, I want to have multiple instances running in my environment, because every now and then an instance crashes and it takes a lot of time until the instance is back up, but I can't scale my current architecture to more than one instance because Celerybeat is supposed to be running only once across all instances as otherwise every task scheduled by Celerybeat will be submitted multiple times (once for every EC2 instance in the environment).\nI have read about multiple solutions, but all of them seem to have issues that don't make it work for me:\n\nUsing django cache + locking: This approach is more like a quick fix than a real solution. This can't be the solution if you have a lot of scheduled tasks and you need to add code to check the cache for every task. Also tasks are still submitted multiple times, this approach only makes sure that execution of the duplicates stops.\nUsing leader_only option with ebextensions: Works fine initially, but if an EC2 instance in the enviroment crashes or is replaced, this would lead to a situation where no Celerybeat is running at all, because the leader is only defined once at the creation of the environment.\nCreating a new Django app just for async tasks in the Elastic Beanstalk worker tier: Nice, because web servers and workers can be scaled independently and the web server performance is not affected by huge async work loads performed by the workers. However, this approach does not work with Celery because the worker tier SQS daemon removes messages and posts the message bodies to a predefined urls. Additionally, I don't like the idea of having a complete additional Django app that needs to import the models from the main app and needs to be separately updated and deployed if the tasks are modified in the main app.\n\nHow to I use Celery with scheduled tasks in a distributed Elastic Beanstalk environment without task duplication? E.g. how can I make sure that exactly one instance is running across all instances all the time in the Elastic Beanstalk environment (even if the current instance with Celerybeat crashes)?\nAre there any other ways to achieve this? What's the best way to use Elastic Beanstalk's Worker Tier Environment with Django?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1251,"Q_Id":40120312,"Users Score":-3,"Answer":"In case someone experience similar issues: I ended up switching to a different Queue \/ Task framework for django. It is called django-q and was set up and working in less than an hour. It has all the features that I needed and also better Django integration than Celery (since djcelery is no longer active).\nDjango-q is super easy to use and also lighter than the huge Celery framework. I can only recommend it!","Q_Score":13,"Tags":"python,django,celery,amazon-elastic-beanstalk,celerybeat","A_Id":40166437,"CreationDate":"2016-10-19T00:48:00.000","Title":"Multiple instances of celerybeat for autoscaled django app on elasticbeanstalk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to figure out the best way to structure a Django app that uses Celery to handle async and scheduled tasks in an autoscaling AWS ElasticBeanstalk environment.\nSo far I have used only a single instance Elastic Beanstalk environment with Celery + Celerybeat and this worked perfectly fine. However, I want to have multiple instances running in my environment, because every now and then an instance crashes and it takes a lot of time until the instance is back up, but I can't scale my current architecture to more than one instance because Celerybeat is supposed to be running only once across all instances as otherwise every task scheduled by Celerybeat will be submitted multiple times (once for every EC2 instance in the environment).\nI have read about multiple solutions, but all of them seem to have issues that don't make it work for me:\n\nUsing django cache + locking: This approach is more like a quick fix than a real solution. This can't be the solution if you have a lot of scheduled tasks and you need to add code to check the cache for every task. Also tasks are still submitted multiple times, this approach only makes sure that execution of the duplicates stops.\nUsing leader_only option with ebextensions: Works fine initially, but if an EC2 instance in the enviroment crashes or is replaced, this would lead to a situation where no Celerybeat is running at all, because the leader is only defined once at the creation of the environment.\nCreating a new Django app just for async tasks in the Elastic Beanstalk worker tier: Nice, because web servers and workers can be scaled independently and the web server performance is not affected by huge async work loads performed by the workers. However, this approach does not work with Celery because the worker tier SQS daemon removes messages and posts the message bodies to a predefined urls. Additionally, I don't like the idea of having a complete additional Django app that needs to import the models from the main app and needs to be separately updated and deployed if the tasks are modified in the main app.\n\nHow to I use Celery with scheduled tasks in a distributed Elastic Beanstalk environment without task duplication? E.g. how can I make sure that exactly one instance is running across all instances all the time in the Elastic Beanstalk environment (even if the current instance with Celerybeat crashes)?\nAre there any other ways to achieve this? What's the best way to use Elastic Beanstalk's Worker Tier Environment with Django?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1251,"Q_Id":40120312,"Users Score":1,"Answer":"I guess you could single out celery beat to different group. \nYour auto scaling group runs multiple django instances, but celery is not included in the ec2 config of the scaling group.  \nYou should have different set (or just one) of instance for celery beat","Q_Score":13,"Tags":"python,django,celery,amazon-elastic-beanstalk,celerybeat","A_Id":54745929,"CreationDate":"2016-10-19T00:48:00.000","Title":"Multiple instances of celerybeat for autoscaled django app on elasticbeanstalk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I'm trying to do is recreating what is commonly called an \"RGB shift\" effect, which is very easy to achieve with image manipulation programs. \nI imagine I can \"split\" the channels of the image by either opening the image as a matrix of triples or opening the image three times and every time operate just on one channel, but I wouldn't know how to \"offset\" the channels when merging them back together (possibly by creating a new image and position each channel's [0,0] pixel in an offsetted position?) and reduce each channel's opacity as to not show just the last channel inserted into the image. \nHas anyone tried to do this? Do you know if it is possible? If so, how did you do it?\nThanks everyone in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1180,"Q_Id":40126407,"Users Score":2,"Answer":"Per color plane, replace the pixel at (X, Y) by the pixel at (X-1, Y+3), for example. (Of course your shifts will be different.)\nYou can do that in-place, taking care to loop by increasing or decreasing coordinate to avoid overwriting.\nThere is no need to worry about transparency.","Q_Score":1,"Tags":"python,image,image-processing,rgb","A_Id":40127791,"CreationDate":"2016-10-19T08:47:00.000","Title":"Split and shift RGB channels in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am Publishing data from Raspberry Pi to AWS IoT and I can see the updates there. \nNow, I need to get that data into AWS Lambda and connect it to AWS SNS to send a message above a threshold. I know about working with SNS and IoT.\nI just want to know that how I can get the data from AWS IoT to AWS Lambda ?? \nPlease Help !!\nThanks :)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":471,"Q_Id":40141313,"Users Score":0,"Answer":"In IoT Code, Create a rule for invoking a Lambda to accept JSON data. Then you can do anything with that data.","Q_Score":0,"Tags":"python,amazon-web-services,aws-lambda","A_Id":56790848,"CreationDate":"2016-10-19T20:51:00.000","Title":"Stream data from AWS IoT to AWS Lambda using Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I plotted some points on google maps using gmplot's scatter method (python). I want to add some text to the points so when someone clicks on those points they can see the text.\nI am unable to find any documentation or example that shows how to do this. \nAny pointers are appreciated.","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":8147,"Q_Id":40142959,"Users Score":5,"Answer":"Just looking for the answer to this myself. gmplot was updated to June  2016 to include a hovertext functionality for the marker method, but unfortunately this isn't available for the scatter method. The enthusiastic user will find that the scatter method simply calls the marker method over and over, and could modify the scatter method itself to accept a title or range of titles.\nIf like myself you are using an older version, make sure to run \npip install --upgrade gmplot\nand to place a marker with hovertext (mouse hovering over pin without clicking)\n\ngmap=gmplot.GoogleMapPlotter(\"Seattle\")\ngmap.marker(47.61028142523736, -122.34147349538826, title=\"A street corner in Seattle\")\nst=\"testmap.html\"\ngmap.draw(st)","Q_Score":3,"Tags":"python","A_Id":41708567,"CreationDate":"2016-10-19T23:10:00.000","Title":"Add text to scatter point using python gmplot","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. How can I switch between python 2 and 3 when starting jupyter? Basic \"jupyter notebook\" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook after start but how can I do this in this situation?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1469,"Q_Id":40148265,"Users Score":0,"Answer":"Did you install python by Anaconda?\nTry to install under Anaconda2\/envs when choosing destination folder,\nlike this: \nD:\/Anaconda2\/envs\/py3\nthen\"activate py3\" by cmd, py3 must be then same name of installation folder","Q_Score":0,"Tags":"python,jupyter,jupyter-notebook","A_Id":42150227,"CreationDate":"2016-10-20T07:39:00.000","Title":"jupyter notebook select python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. How can I switch between python 2 and 3 when starting jupyter? Basic \"jupyter notebook\" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook after start but how can I do this in this situation?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1469,"Q_Id":40148265,"Users Score":1,"Answer":"There's important points to consider:\n\nyou have to have jupyter notebook installed in each environment you want to run it from\nif jupyter is only installed in one environment, your notebook will default to that environment no matter from which environment your start it, and you will have no option to change the notebook kernel (i.e. the conda package, and therefore which python version to use for your notebook)\n\nYou can list the packages in your environment with conda list. You can also check what environments exist with conda info --envs to make sure there's indeed one with python 3 (and use conda list to check it has jupyter installed).\nFrom what you write, since your notebook defaults to python2, conda list should show you python 2 related packages.\nSo, as has been pointed, first activate the anaconda environment for python3 with the command activate your_python3_environment then restart your Notebook.\nYou don't need internet for this but you do need to be able to swap between anaconda2 and 3 (which you say are both installed) and both should have jupyter installed.","Q_Score":0,"Tags":"python,jupyter,jupyter-notebook","A_Id":42550420,"CreationDate":"2016-10-20T07:39:00.000","Title":"jupyter notebook select python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a CSV file and I want to check if the first row has only strings in it (ie a header). I'm trying to avoid using any extras like pandas etc. I'm thinking I'll use an if statement like if row[0] is a string print this is a CSV but I don't really know how to do that :-S any suggestions?","AnswerCount":8,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24553,"Q_Id":40193388,"Users Score":0,"Answer":"I think the best way to check this is -> simply reading 1st line from file and then match your string instead of any library.","Q_Score":11,"Tags":"python,python-2.7,csv","A_Id":65651852,"CreationDate":"2016-10-22T14:38:00.000","Title":"How to check if a CSV has a header using Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After installing Winpython on windows 7 64 bits, when I launch Spyder I face this:\nImportError: No module named encodings\nPython 2.7.12 Shell works well but Spyder don't.\nDo you know how to solve this problem?\nI really appreciate any help you can provide","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":609,"Q_Id":40194021,"Users Score":0,"Answer":"You Could try to uninstall that version of spyder and download Anaconda, a free package manager that comes pre-installed with spyder and should work fine, as it did for me as I have windows 7 x64","Q_Score":0,"Tags":"python-2.7,spyder","A_Id":41088731,"CreationDate":"2016-10-22T15:47:00.000","Title":"Can't launch Spyder on windows 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just discovered the amazing Raspberry Pi 3 and I am trying to learn how to use it in one of my projects.\nSetup:\n\nASP.NET app on Azure.\nRPi: \n\n\nsoftware: Raspbian, PHP, Apache 2, and MariaDB.\nhas internet access and a web server a configured.\n\n3G dongle for SMS sending, connected to the RPi.\n\nDesired scenario:\n\nwhen a specific button within the ASP app is clicked:\n\n\nthrough jQuery $.ajax() the RPi's ip is called with the parameters phoneNumber and smsType.\n\nthen the RPi:\n\n\nfetches the SMS text from a MariaDB database based on the smsType parameter.\ninvokes a Python script using the PHP exec(\"python sendSms.py -p phoneNumber -m fetchedText\", $output) (i.e. with the phone number and the fetched text):\n\n\nscript will send the AT command(s) to the dongle.\nscript will return true or false based on the action of the dongle.  \n\n\necho the $output to tell the ASP what is the status.\nfinally, the ASP will launch a JavaScript alert() saying if it worked or not.\n\nThis is what I need to accomplish. For most of the parts I found resources and explanations. However, before starting on this path I want to understand few things:\n\nGeneral questions (if you think they are not appropriate, please ignore this category):\n\nWhat are the (logical) pitfalls of this scenario?\nWhat would be a simpler way to approach this?\n\nSpecific questions:\n\nIs there a size limit to consider when passing parameters through the url?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":98,"Q_Id":40195188,"Users Score":0,"Answer":"What are the (logical) pitfalls of this scenario?\nMy opion would be to pass the data and the two fields (phoneNumber and SmsType) through a POST request rather then an GET request because you can send more data in an post request and encapsulate it with JSON making it easier to handle the data.\nWhat would be a simpler approch ?\nMaybe not simple but more elegant, extend the python script with something like flask and build the webserver right into the python script, saves you running a webserver with php!","Q_Score":0,"Tags":"php,python,asp.net,raspberry-pi,sms","A_Id":40195564,"CreationDate":"2016-10-22T17:45:00.000","Title":"Calling Raspberry Pi from ASP.NET to send a SMS remotely","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a program to search a txt file for a certain line based only on part of the string. If the string isn't found, it should print not found once, but it is printing it multiple times. Even after indenting and using a correct code it still prints:","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":41,"Q_Id":40200840,"Users Score":1,"Answer":"the else suite is executed after the for terminates normally (not by a break).\nso it will definitely execute the else statement in your code, because you don't break in the for loop.","Q_Score":1,"Tags":"python","A_Id":40201438,"CreationDate":"2016-10-23T08:04:00.000","Title":"how do i stop the invalid code message repeating while also occuring at the right time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"python2.7\nwhen I import Tkinter, it prompt no module named _tkinter, I don't have the limits of administrator, so I install tcl and tk, then recompile python with --with-tcltk-includes and --with-tcltk-libs parameter, but when running 'make', the error \"\"\"*** WARNING: renaming \"_tkinter\" since importing it failed: build\/lib.linux-x86_64-2.7\/_tkinter.so: undefined symbol: Tk_Init\"\"\" occurred, I really don't know how to deal with it\ncan somebody help me?\nthanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":648,"Q_Id":40214784,"Users Score":0,"Answer":"I had the same exact issue with Python-3.4.3. I followed Brice's solution and got halfway there. Not only did I require the -l flags after the -L flag as he suggested, but I discovered my LD_LIBRARY_PATH was inadequate when performing the 'make altinstall'. Be sure to include the same directory in LD_LIBRARY_PATH as used in your -L flag entry.","Q_Score":0,"Tags":"python-2.7,tkinter","A_Id":50161426,"CreationDate":"2016-10-24T09:19:00.000","Title":"undefined symbol: Tk_Init","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"When trying to install cPickle using pycharm I get this:\n\nCommand \"python setup.py egg_info\" failed with error code 1 in C:\\Users\\Edwin\\AppData\\Local\\Temp\\pycharm-packaging\\cpickle \n  You are using pip version 7.1.2, however version 8.1.2 is available.\n  You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n\nSo then when I go command prompt to type in:\n\npython -m pip install --upgrade pip\n\nI get this:\n\n'python' is not recognized as an internal or external command, operable program or batch file.\n\nSo how do I install cPickle?\nBTW: I am using windows & python 3.5.1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4792,"Q_Id":40223807,"Users Score":2,"Answer":"As suggested in the comments, this is most likely because Python is not added to your environment variables. If you do not want to touch your environment variables, and assuming your Python is installed in C:\\Python35\\, \n\nNavigate tp C:\\Python35\\ in Windows Explorer\nGo to the address bar and type cmd to shoot up a command prompt in that directory\n\nAlternatively to steps 1 and 2, directly shoot up a command prompt, and cd to your Python installation Directory (default: C:\\Python35)\n\nType python -m pip install pip --upgrade there","Q_Score":0,"Tags":"python,pycharm,pickle","A_Id":40224304,"CreationDate":"2016-10-24T17:07:00.000","Title":"Why can't I install cPickle | Pip needs upgrading?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've created tool, that runs as a server, and allow clients to connect to it through TCP, and run some commands. It's written on python 3\nNow I'm going to build package and upload it to Pypi, and have conceptual problem.\nThis tool have python client library inside, so, after installation of the package, it'll be possible to just import library into python script, and use for connection to the daemon without dealing with raw TCP\/IP.\nAlso, I have PHP library, for connection to me server, and the problem is - I don't know how to include it into my python package the right way.\nVariants, that I found and can't choose the right one:\n\nJust include library.php file into package, and after running \"pip install my_package\", I would write \"require('\/usr\/lib\/python3\/dist-packages\/my_package\/library.php')\" into my php file. This way allows to distribute library with the server, and update it synchronously, but add long ugly paths to php require instruction.\nAs library.php in placed on github repository, I could just publish it's url in the docs, and it'll be possible to just clone repository. It makes possible to clone repo, and update library by git pull. \nCreate separate package with my library.php, upload it into packagist, and use composer to download it when it's needed. Good for all composer users, and allow manual update, but doens't update with server's package.\n\nMaybe I've missed some other variants.\nI want to know what would be true python'ic and php'ic way to do this. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":605,"Q_Id":40236281,"Users Score":0,"Answer":"I've decided to create separate PHP package for my PHP library, and upload it to a packagist.org, so, user could get it using php composer, but not forced to, as it would be in case of including library.php into python package.","Q_Score":0,"Tags":"php,python,python-3.x,pip,composer-php","A_Id":40252615,"CreationDate":"2016-10-25T09:29:00.000","Title":"How to include PHP library in Python package (on not do it)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a virtual console, which would use the systems builtin commands and then do the action and display output results on next line in console. This is all working, but how do I get the contents of the last line, and only the last line in the tkinter text widget? Thanks in advance. I am working in python 3.\nI have treed using text.get(text.linestart, text.lineend) To no avail. Have these been deprecated? It spits out an error saying that AttributeError: 'Text' object has no attribute 'linestart'","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2994,"Q_Id":40251259,"Users Score":1,"Answer":"You can apply modifiers to the text widget indicies, such as linestart and lineend as well as adding and subtracting characters. The index after the last character is \"end\".\nPutting that all together, you can get the start of the last line with \"end-1c linestart\".","Q_Score":3,"Tags":"python,python-3.x,tkinter,console","A_Id":40251792,"CreationDate":"2016-10-25T23:19:00.000","Title":"How to get the contents of last line in tkinter text widget (Python 3)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on a virtual console, which would use the systems builtin commands and then do the action and display output results on next line in console. This is all working, but how do I get the contents of the last line, and only the last line in the tkinter text widget? Thanks in advance. I am working in python 3.\nI have treed using text.get(text.linestart, text.lineend) To no avail. Have these been deprecated? It spits out an error saying that AttributeError: 'Text' object has no attribute 'linestart'","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2994,"Q_Id":40251259,"Users Score":0,"Answer":"Test widget has a see(index) method.\ntext.see(END) will scroll the text to the last line.","Q_Score":3,"Tags":"python,python-3.x,tkinter,console","A_Id":56634803,"CreationDate":"2016-10-25T23:19:00.000","Title":"How to get the contents of last line in tkinter text widget (Python 3)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using a proxy (from proxymesh) to run a spider written in scrapy python, the script is running normally when I don't use the proxy, but when I use it, I am having the following error message:\nCould not open CONNECT tunnel with proxy fr.proxymesh.com:31280 [{'status': 408, 'reason': 'request timeout'}]\nAny clue about how to figure out?\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":497,"Q_Id":40266219,"Users Score":1,"Answer":"Thanks.. I figure out here.. the problem is that some proxy location doesn't work with https.. so I just changed it and now it is working.","Q_Score":0,"Tags":"python,proxy,web-scraping,scrapy,web-crawler","A_Id":40296417,"CreationDate":"2016-10-26T15:24:00.000","Title":"Proxy Error 408 when running a script written in Scrapy Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I am making a hand controlled media player application in Python and through OpenCV.I want to embed gesture window of OpenCV in Tkinter frame so I can add further attributes to it.\nCan someone tell how to embed OpenCV camera window into Tkinter frame?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":747,"Q_Id":40269957,"Users Score":0,"Answer":"OpenCV window in Tkinter window is not good idea. Both windows use own mainloop (event loop) which can't work at the same time (or you have to use threading) and don't have contact one with other. \nProbably it is easier to get video frame and display in Tkinter window on Label or Canvas. You can use tk.after(miliseconds, function_name) to run periodically function which will update video frame in Tkinter window.","Q_Score":0,"Tags":"python,opencv,tkinter","A_Id":40271580,"CreationDate":"2016-10-26T18:46:00.000","Title":"opencv window in tkinter frame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a python function using flask framework to process some data submitted via a web form.  However I don't want to re-render the template, I really just want to process the data and the leave the web form, it the state it was in, when the POST request was created.  Not sure how to do this ... any suggestions ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":795,"Q_Id":40277199,"Users Score":0,"Answer":"If you want the user to stay in place, you should send the form using JavaScript asynchronously. That way, the browser won't try to fetch and render a new page.\nYou won't be able to get this behavior from the Flask end only. You can return effectively nothing but the browser will still try to get it and render that nothing for the client.","Q_Score":0,"Tags":"python,flask","A_Id":40277255,"CreationDate":"2016-10-27T06:01:00.000","Title":"Flask return nothing, instead of having the re-render template","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Imagine I have a numpy array in python that has complex numbers as its elements.\nI would like to know if it is possible to split any matrix of this kind into a hermitian and anti-hermitian part? My intuition says that this is possible, similar to the fact that any function can be split into an even and an uneven part.\nIf this is indeed possible, how would you do this in python? So, I'm looking for a function that takes as input any matrix with complex elements and gives a hermitian and non-hermitian matrix as output such that the sum of the two outputs is the input.\n(I'm working with python 3 in Jupyter Notebook).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":309,"Q_Id":40284296,"Users Score":4,"Answer":"The Hermitian part is (A + A.T.conj())\/2, the anti-hermitian part is (A - A.T.conj())\/2 (it is quite easy to prove).\nIf A = B + C with B Hermitian and C anti-Hermitian, you can take the conjugate (I'll denote it *) on both sides, uses its linearity and obtain A* = B - C, from which the values of B and C follow easily.","Q_Score":0,"Tags":"python,numpy,matrix","A_Id":40284356,"CreationDate":"2016-10-27T12:12:00.000","Title":"python: split matrix in hermitian and anti-hermitian part","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I think I have a pretty reasonable idea on how to do go about accomplishing this, but I'm not 100% sure on all of the steps. This question is mostly intended as a sanity check to ensure that I'm doing this in the most efficient way, and that my math is actually sound (since my statistics knowledge is not completely perfect).\nAnyways, some explanation about what I'm trying to do:\nI have a lot of time series data that I would like to perform some linear regressions on. In particular, I have roughly 2000 observations on 500 different variables. For each variable, I need to perform a regression using two explanatory variables (two additional vectors of roughly 2000 observations). So for each of 500 different Y's, I would need to find a and b in the following regression Y = aX_1 + bX_2 + e.\nUp until this point, I have been using the OLS function in the statsmodels package to perform my regressions. However, as far as I can tell, if I wanted to use the statsmodels package to accomplish my problem, I would have to call it hundreds of times, which just seems generally inefficient.\nSo instead, I decided to revisit some statistics that I haven't really touched in a long time. If my knowledge is still correct, I can put all of my observations into one large Y matrix that is roughly 2000 x 500. I can then stick my explanatory variables into an X matrix that is roughly 2000 x 2, and get the results of all 500 of my regressions by calculating (X'Y)\/(X'X). If I do this using basic numpy stuff (matrix multiplication using * and inverses using matrix.I), I'm guessing it will be much faster than doing hundreds of statsmodel OLS calls.\nHere are the questions that I have:\n\nIs the numpy stuff that I am doing faster than the earlier method of calling statsmodels many times? If so, is it the fastest\/most efficient way to accomplish what I want? I'm assuming that it is, but if you know of a better way then I would be happy to hear it. (Surely I'm not the first person to need to calculate many regressions in this way.)\nHow do I deal with missing data in my matrices? My time series data is not going to be nice and complete, and will be missing values occasionally. If I just try to do regular matrix multiplication in numpy, the NA values will propagate and I'll end up with a matrix of mostly NAs as my end result. If I do each regression independently, I can just drop the rows containing NAs before I perform my regression, but if I do this on the large 2000 x 500 matrix I will end up dropping actual, non-NA data from some of my other variables, and I obviously don't want that to happen.\nWhat is the most efficient way to ensure that my time series data actually lines up correctly before I put it into the matrices in the first place? The start and end dates for my observations are not necessarily the same, and some series might have days that others do not. If I were to pick a method for doing this, I would put all the observations into a pandas data frame indexed by the date. Then pandas will end up doing all of the work aligning everything for me and I can extract the underlying ndarray after it is done. Is this the best method, or does pandas have some sort of overhead that I can avoid by doing the matrix construction in a different way?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":3105,"Q_Id":40287113,"Users Score":4,"Answer":"some brief answers\n1) Calling statsmodels repeatedly is not the fastest way. If we just need parameters, prediction and residual and we have identical explanatory variables, then I usually just use params = pinv(x).dot(y) where y is 2 dimensional and calculate the rest from there. The problem is that inference, confidence intervals and similar require work, so unless speed is crucial and only a restricted set of results is required, statsmodels OLS is still more convenient.\nThis only works if all y and x have the same observations indices, no missing values and no gaps.\nAside: The setup is a Multivariate Linear Model which will be supported by statsmodels in, hopefully not very far, future.\n2) and 3) The fast simple linear algebra of case 1) does not work if there are missing cells or no complete overlap of observation (indices). In the analog to panel data, the first case requires \"balanced\" panels, the other cases imply \"unbalanced\" data. The standard way is to stack the data with the explanatory variables in a block-diagonal form. Since this increases the memory by a large amount, using sparse matrices and sparse linear algebra is better. It depends on the specific cases whether building and solving the sparse problem is faster than looping over individual OLS regressions. \nSpecialized code: (Just a thought):\nIn case 2) with not fully overlapping or cellwise missing values, we would still need to calculate all x'x, and x'y matrices for all y, i.e. 500 of those. Given that you only have two regressors 500 x 2 x 2 would still not require a large memory. So it might be possible to calculate params, prediction and residuals by using the non-missing mask as weights in the cross-product calculations.\nnumpy has vectorized linalg.inv, as far as I know. So, I think, this could be done with a few vectorized calculations.","Q_Score":4,"Tags":"python,python-3.x,numpy,linear-regression","A_Id":40293068,"CreationDate":"2016-10-27T14:20:00.000","Title":"Fastest way to calculate many regressions in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am preparing a Doc2Vec model using tweets. Each tweet's word array is considered as a separate document and is labeled as \"SENT_1\", SENT_2\" etc.\n\ntaggeddocs = []\nfor index,i in enumerate(cleaned_tweets):\n    if len(i) > 2: # Non empty tweets\n        sentence = TaggedDocument(words=gensim.utils.to_unicode(i).split(), tags=[u'SENT_{:d}'.format(index)])\n        taggeddocs.append(sentence)\n\n# build the model\nmodel = gensim.models.Doc2Vec(taggeddocs, dm=0, alpha=0.025, size=20, min_alpha=0.025, min_count=0)\n\nfor epoch in range(200):\n    if epoch % 20 == 0:\n        print('Now training epoch %s' % epoch)\n    model.train(taggeddocs)\n    model.alpha -= 0.002  # decrease the learning rate\n    model.min_alpha = model.alpha  # fix the learning rate, no decay\n\nI wish to find tweets similar to a given tweet, say \"SENT_2\". How?\nI get labels for similar tweets as:\n\nsims = model.docvecs.most_similar('SENT_2')\nfor label, score in sims:\n    print(label)\n\nIt prints as:\n\nSENT_4372\nSENT_1143\nSENT_4024\nSENT_4759\nSENT_3497\nSENT_5749\nSENT_3189\nSENT_1581\nSENT_5127\nSENT_3798\n\nBut given a label, how do I get original tweet words\/sentence? E.g. what are the tweet words of, say, \"SENT_3497\". Can I query this to Doc2Vec model?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1260,"Q_Id":40296765,"Users Score":1,"Answer":"Gensim's Word2Vec\/Doc2Vec models don't store the corpus data \u2013 they only examine it, in multiple passes, to train up the model. If you need to retrieve the original texts, you should populate your own lookup-by-key data structure, such as a Python dict (if all your examples fit in memory). \nSeparately, in recent versions of gensim, your code will actually be doing 1,005 training passes over your taggeddocs, including many with a nonsensically\/destructively negative alpha value. \n\nBy passing it into the constructor, you're telling the model to train itself, using your parameters and defaults, which include a default number of iter=5 passes. \nYou then do 200 more loops. Each call to train() will do the default 5 passes. And by decrementing alpha from 0.025 by 0.002 199 times, the last loop will use an effective alpha of 0.025-(200*0.002)=-0.375 - a negative value essentially telling the model to make a large correction in the opposite direction of improvement each training-example. \n\nJust use the iter parameter to choose the desired number of passes. Let the class manage the alpha changes itself. If supplying the corpus when instantiating the model, no further steps are necessary. But if you don't supply the corpus at instantiation, you'll need to do model.build_vocab(tagged_docs) once, then model.train(tagged_docs) once.","Q_Score":1,"Tags":"python,nlp,gensim,doc2vec","A_Id":41733461,"CreationDate":"2016-10-28T01:49:00.000","Title":"How to extract words used for Doc2Vec","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can find the number of rows in a column in a pandas dataframe that do NOT follow a pattern but not the number of rows that follow the very same pattern!\nThis works:\ndf.report_date.apply(lambda x: (not re.match(r'[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}', x))).sum()\nThis does not: removing 'not' does not tell me how many rows match but raises a TypeError. Any idea why that would be the case?\n\ndf.report_date.apply(lambda x: (re.match(r'[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}', x))).sum()","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":883,"Q_Id":40309777,"Users Score":2,"Answer":"The problem is that the match function does not return True when it matches, it returns a match object. Pandas cannot add this match object because it is not an integer value. The reason you get a sum when you are using 'not' is because it returns a boolean value of True, which pandas can sum the True value and return a number.","Q_Score":3,"Tags":"python,regex,pandas","A_Id":40310470,"CreationDate":"2016-10-28T16:55:00.000","Title":"cannot sum rows that match a regular expression in pandas \/ python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I have been playing around with requests and bs4 for a project I'm working on and have managed to return the following in a variable: \n\"----------\nCrossways Inn\nWithy Road\nWest Huntspill\nSomerset\nTA93RA\n01278783756\nwww.crosswaysinn.com\n----------\"\nThis was scraped from a site, using .text function within the bs4 module.\nIs there any way I can format this within my program to look like the following:\n\"----------\\n\nCrossways Inn\\n\nWithy Road\\n\nWest Huntspill\\n\nSomerset\\n\nTA93RA\\n\n01278783756\\n\nwww.crosswaysinn.com\\n\n----------\\n\"\nSorry for the vague explanation of what I want to do, but do not know how to explain it better. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":45,"Q_Id":40321096,"Users Score":1,"Answer":"Just use repr()\nLike:\nprint(repr(<variable with string>))","Q_Score":0,"Tags":"python,string,format,python-requests,bs4","A_Id":40321224,"CreationDate":"2016-10-29T16:16:00.000","Title":"How do I format the contents of the following variable in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have searched the internet for hours at this point. Does anyone know how to parse a namedtuple returned from a python function into a struct or just into separate variables. The part I am having trouble with is getting the data out of the returned pointer. I am calling a python function embedded in C++ using the PyObject_CallFunction() call and I don't know what to do once I have the PyObject* to the returned data.\nI am using Python 2.7 for reference.\nEDIT: I ended up moving all of the functionality I was trying to do in both Python and C++ to just Python for now. I will update in the near future about attempting the strategy suggested in the comments of this question.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1655,"Q_Id":40321668,"Users Score":1,"Answer":"namedtuple is implemented purely in Python.  You can see its full source in collections.py.  It's very short.  The thing to keep in mind is that namedtuple itself is a function which creates a class in the frame in which it is called and then returns this class (not an instance of this class).  And it is this returned class that is then used to create instances.  So the object which you get is not what you want to pass into C++ if you want to pass individual instances.  \nC++ creates struct definitions at compile time.  namedtuple creates namedtuple classes at run time.  If you want to bind them to C++ structs, either use the PyObject to create your newly minted class' instances inside of C++ and assign them to struct elements at compile time.  Or create the newly minted class' instances in Python and pass them to C++.\nOr you can use _asdict method (provided by namedtuple factory method for all classes it builds) and pass that to C++ to then do the binding of run-time defined data to compile-time defined data.\nIf you really want to do the bulk of the work in C++, you may also use the Struct module instead of using namedtuple.  \nnamedtuple is really the swiss-army knife of Python for data which stays in Python.  It gives positional access, named access, and all the elements are also \"properties\" (so they have fget accessor method which can be used in maps, filters, etc. instead of having to write your own lambdas).  \nIt's there for things like DB binding (when you don't know which columns will be there at run time). It's less clunky than OrderedDict for converting data from one format into another.  When it's used that way, the overhead of processing strings is nothing compared to actual access of the db (even embedded).  But I wouldn't use namedtuple for large arrays of structs which are meant to be used in calculations.","Q_Score":1,"Tags":"c++,python-2.7,struct,namedtuple","A_Id":40336177,"CreationDate":"2016-10-29T17:23:00.000","Title":"Python NamedTuple to C++ Struct","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem understanding some description of functions in Python.\nI understand simply functions like os.putenv(varname, value) but I have no idea how to use this: os.getenv(varname[, value]). How to pass arguments to that function, what does those square brackets mean?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":161,"Q_Id":40323573,"Users Score":0,"Answer":"Square brackets typically mean that the value is optional. Here, varname refers to the environment variable you want to get and value is an optional value that is return if the environment variable doesn't exist.","Q_Score":0,"Tags":"python,python-2.7","A_Id":40323605,"CreationDate":"2016-10-29T20:54:00.000","Title":"How to read Python function documentation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to implement a multiscale CNN in python. My aim is to use three different CNNs for three different scales and concatenate the final outputs of the final layers and feed them to a FC layer to take the output predictions.\nBut I don't understand how can I implement this. I know how to implement a single scale CNN. \nCould anyone help me in this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1527,"Q_Id":40329307,"Users Score":0,"Answer":"I do not understand why to have 3 CNNs because you would mostly have the same results than on a single CNN. Maybe you could train faster.\nPerhaps you could also do pooling and some resnet operation (I guess this could prove similar to what you want).\nNevertheless, for each CNN you need a cost function in order to optimize the \"heuristic\" you use (eg: to improve recognition). Also, you could do something as in the NN Style Transfer in which you compare results between several \"targets\" (the content and the style matrices); or simply train 3 CNNs then cutoff the last layers (or freeze them) and train again with the already trained weights but now with your target FN layer...","Q_Score":4,"Tags":"python,neural-network,concatenation,convolution,keras","A_Id":52020891,"CreationDate":"2016-10-30T12:52:00.000","Title":"Multiscale CNN - Keras Implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a message scheduler that generates a hash-key from the message attributes before placing it on a Kafka topic queue with the key.\nThis is done for de-duplication purposes. However, I am not sure how I could possibly test this deduplication without actually setting up a local cluster and checking that it is performing as expected.\nSearching online for tools for mocking a Kafka topic queue has not helped, and I am concerned that I am perhaps thinking about this the wrong way.\nUltimately, whatever is used to mock the Kafka queue, should behave the same way as a local cluster - i.e. provide de-deuplication with Key inserts to a topic queue.\nAre there any such tools?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":11023,"Q_Id":40340100,"Users Score":4,"Answer":"If you need to verify a Kafka specific feature, or implementation with a Kafka-specific feature, then the only way to do it is by using Kafka!\nDoes Kafka have any tests around its deduplication logic?  If so, the combination of the following may be enough to mitigate your organization's perceived risks of failure:\n\nunit tests of your hash logic (make sure that the same object does indeed generate the same hash)\nKafka topic deduplication tests (internal to Kafka project)\npre-flight smoke tests verifying your app's integration with Kafka\n\n\nIf Kafka does NOT have any sort of tests around its topic deduplication, or you are concerned about breaking changes, then it is important to have automated checks around Kafka-specific functionality. This can be done through integration tests.  I have had much success recently with Docker-based integration test pipelines.  After the initial legwork of creating a Kafka docker image (one is probably already available from the community), it becomes trivial to set up integration test pipelines.  A pipeline could look like:\n\napplication-based unit tests are executed (hash logic)\nonce those pass, your CI server starts up Kafka\nintegration tests are executed, verifying that duplicate writes only emit a single message to a topic.\n\n\nI think the important thing is to make sure Kafka integration tests are minimized to ONLY include tests that absolutely rely on Kafka-specific functionality.  Even using docker-compose, they may be orders of magnitude slower than unit tests, ~1ms vs 1 second?  Another thing to consider is the overhead of maintaining an integration pipeline may be worth the risk of trusting that Kakfa will provide the topic deduplication that it claims to.","Q_Score":11,"Tags":"python,unit-testing,apache-kafka,kafka-python","A_Id":40342318,"CreationDate":"2016-10-31T10:09:00.000","Title":"Python: how to mock a kafka topic for unit tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have to double an image using python, \nSo i think i can replace each pixel of the image with a square formed by 4 pixels \nhow do i can do that and assign to each pixel of the little square different colors?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1504,"Q_Id":40341471,"Users Score":0,"Answer":"Is that a homework ? Working with a new target image, as suggested in the comments, is the easiest.\nBut theoretically, assuming your original image is represented as some 2 dimension table of pixels, you could do it without creating a new image:\nFirst double both dimensions of the original image (with the original image staying on \"upper left\" and occupying 1\/4 of the new image, and filling the other 3\/4 with blank or any value). \nThen take the lower right pixel from the original image, and write 4 identical pixels in the lower right of the resized image. \nThen take the original pixel directly at the the left of the previous original pixel, copy it on the 4 pixels directly at the left of the 4 previous new pixels. Repeat until you reach the left end of the line, then start the process again on the line above. \nAt some point you will overwrite pixels from the original image, but that doesn't matter since you will already have duplicated those in the new image. \nThat's pure theory, assuming you are not allowed to use external libraries such as Pillow.","Q_Score":1,"Tags":"python,image,python-3.x,python-3.5","A_Id":40343522,"CreationDate":"2016-10-31T11:41:00.000","Title":"Double an image using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question about tensorflow tensor.\nIf I have a NeuralNet like y=xw+b as an example.\nthen x is placeholder([7,7] dims), w is Variable([7,1]) and b is Variable([1,1])\nSo, y is tensorflow tensor with [7,1] dims.\nthen, in this case. can I make a new tensor like\nnew_y = [tf.reduce_sum(y[0:3]), tf.reduce_sum(y[3:5]), tf.reduce_sum(y[5:])] \nand use it for training step?\nIf possible, how can I make it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":40370004,"Users Score":0,"Answer":"You should just make your label (y) in your reduced sum format (i.e. 3 bits), and train to that label.  The neural net should be smart enough to adjust the weights to imitate your reduce_sum logic.","Q_Score":0,"Tags":"python-2.7,tensorflow","A_Id":40370096,"CreationDate":"2016-11-01T23:07:00.000","Title":"Generate new tensorflow tensor according to the element index of original tensor","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suddenly, my pip install commands stopped installing binaries into \/usr\/local\/bin. I tried to upgrade pip to see if that might be the problem, it was up to date and a forced re-install deleted my \/usr\/local\/pip3 and didn't install it back, so now I have to use python3 -m pip to do any pip operations. I am running OS X Sierra with the latest update (that is the main thing that changed, so I think the OS X upgrade might have caused this) with python3 installed by homebrew. How do I fix this?\nEdit: I am still trying to work this out. python3 -m pip show -f uwsgi actually shows the uwsgi binary as being installed to what amounts to \/usr\/local\/bin (it uses relative paths). Yet the binary is not there and reinstalling doesn't put it there and doesn't produce any errors. So either pip records the file in its manifest, but doesn't actually put it there or the OS X transparently fakes the file creation (did Apple introduce some new weird security measures?)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1216,"Q_Id":40384700,"Users Score":1,"Answer":"Resolved the problem. Turns out that this is Homebrew's behavior. I must have recently ran brew upgrade and it installed a newer version of python3. It seems that something got weird with re-linking the new python3, so all binaries for the new installs ended up somewhere deep in \/usr\/local\/Cellar\/python3.\nI expect that re-linking python3 would solve this, but I ended up removing all versions of python3 and reinstalling. After that all I had to do was re-install any and all packages that had binary files in them.\nNot sure if this is the intended behavior or a bug in python3 package.","Q_Score":1,"Tags":"python,macos,pip","A_Id":40386891,"CreationDate":"2016-11-02T16:14:00.000","Title":"pip3 stopped installing executables into \/usr\/local\/bin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a file called train.dat which has three fields - userID, movieID and rating. \nI need to predict the rating in the test.dat file based on this.\nI want to know how I can use scikit-learn's KMeans to group similar users given that I have only feature - rating. \nDoes this even make sense to do? After the clustering step, I could do a regression step to get the ratings for each user-movie pair in test.dat\nEdit: I have some extra files which contain the actors in each movie, the directors and also the genres that the movie falls into. I'm unsure how to use these to start with and I'm asking this question because I was wondering whether it's possible to get a simple model working with just rating and then enhance it with the other data. I read that this is called content based recommendation. I'm sorry, I should've written about the other data files as well.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":733,"Q_Id":40389402,"Users Score":-1,"Answer":"Clustering users makes sense. But if your only feature is the rating, I don't think it could produce a useful model for prediction. Below are my assumptions to make this justification:\n\nThe quality of movie should be distributed with a gaussion distribution.\nIf we look at the rating distribution of a common user, it should be something like gaussian.\nI don't exclude the possibility that a few users only give ratings when they see a bad movie (thus all low ratings); and vice versa. But on a large scale of users, this should be unusual behavior. \n\nThus I can imagine that after clustering, you get small groups of users in the two extreme cases; and most users are in the middle (because they share the gaussian-like rating behavior). Using this model, you probably get good results for users in the two small (extreme) groups; however for the majority of users, you cannot expect good predictions.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,k-means","A_Id":40390555,"CreationDate":"2016-11-02T20:39:00.000","Title":"Clustering before regression - recommender system","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two Bokeh apps (on Ubuntu \\ Supervisor \\ Nginx), one that's a dashboard containing a Google map and another that's an account search tool.  I'd like to be able to click a point in the Google map (representing a customer) and have the account search tool open with info from the the point.\nMy problem is that I don't know how to get the data from A to B in the current framework.  My ideas at the moment:\n\nHave an event handler for the click and have it both save a cookie and open the account web page.  Then, have some sort of js that can read the cookie and load the account.\nThrow my hands up, try to put both apps together and just find a way to pass it in the back end.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":157,"Q_Id":40425856,"Users Score":1,"Answer":"The cookies idea might work fine. There are a few other possibilities for sharing data: \n\na database (e.g. redis or something else, that can trigger async events that the app can respond to)\ndirect communication between the apps (e.g. with zeromq or similiar) The Dask dashboard uses this kind of communication between remote workers and a bokeh server.\nfiles and timestamp monitoring if there is a shared filesystem (not great, but sometimes workable in very simple cases) \n\nAlternatively if you can run both apps on the same single server (even though they are separate apps) then you could probably communicate by updating some mutable object in a module that both apps import. But this would not work in a scale-out scenario with more than one Bokeh server running. \nAny\/all of these somewhat advanced usages, an working example would make a great contribution for the docs so that others can use them to learn from.","Q_Score":0,"Tags":"javascript,python,cookies,bokeh","A_Id":40429660,"CreationDate":"2016-11-04T15:03:00.000","Title":"Transfer Data from Click Event Between Bokeh Apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can run my python file with imported functionalities from GraphLab from the Terminal (first use the source activate gl-env and then run the file). So the file and installations are alright in that sense. \nHowever, I can't figure out how to run the file directly in Spyder IDE. I only get ImportError: No module named 'graphlab'. The Spyder runs with python3.5 and I've tried to change to 2.7 as the GraphLap seems to, but it doesn't work either (I redirected to the same python2.7 'scientific_startup.py' used in GraphLab lib ). \nI wonder if anyone knows how to run the file directly from Spyder??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":391,"Q_Id":40430960,"Users Score":2,"Answer":"Following method will solve this: \nOpen Spyder --> tools --> preferences --> python interpreter --> change from default to custom and select the python executable under gl-env environment. \nRestart spyder. It will work.","Q_Score":2,"Tags":"python-2.7,python-3.x,spyder,graphlab","A_Id":40952297,"CreationDate":"2016-11-04T20:07:00.000","Title":"run graphlab from Spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wanted to know how does python hashlib library treat sparse files. If the file has a lot of zero blocks then instead of wasting CPU and memory on reading zero blocks does it do any optimization like scanning the inode block map and reading only allocated blocks to compute the hash?\nIf it does not do it already, what would be the best way to do it myself.\nPS: Not sure it would be appropriate to post this question in StackOverflow Meta.\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":40431073,"Users Score":1,"Answer":"The hashlib module doesn't even work with files. You have to read the data in and pass blocks to the hashing object, so I have no idea why you think it would handle sparse files at all.\nThe I\/O layer doesn't do anything special for sparse files, but that's the OS's job; if it knows the file is sparse, the \"read\" operation doesn't need to do I\/O, it just fills in your buffer with zeroes with no I\/O.","Q_Score":0,"Tags":"python,hashlib,sparse-file","A_Id":40431152,"CreationDate":"2016-11-04T20:16:00.000","Title":"Python hashlib and sparse files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a second laptop running kali linux which is not used at all, meaning it can be running anytime as a server for my application. So what I actually want to do is connect from my application to my server and send some data, on the server run a python program that uses this code and return some data back. I never tried to work with servers, can I even turn my computer into a server for my application? does this cost any money? can I run a python code on the server and return the results?\nI know I haven't published any code but I actually don't know how to start this project and I can use some help so can someone refer me to something to start with? Thanks..","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":40438629,"Users Score":0,"Answer":"Your problem is not Android-related definitely.\nYou simply need to educated yourself about networking. Yes, it will cost you some money - you spend them buying few books and some hardware for building home network.\nAfter about 3-6-12 months of playing with your home network you will find your question rather simple to answer.","Q_Score":0,"Tags":"android,python","A_Id":40438672,"CreationDate":"2016-11-05T13:10:00.000","Title":"Using a server in android to run code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python ( CPython) we can import module:\nimport module and module can be just *.py file ( with a python code) or module can be a module written in C\/C++ ( be extending python). So, a such module is just compiled object file ( like *.so\/*.o on the Unix). \nI would like to know how is it executed by the interpreter exactly.\nI think that python module is compiled to a bytecode and then it will be interpreted. In the case of C\/C++ module functions from a such module are just executed. So, jump to the address and start execution. \nPlease correct me if I am wrong\/ Please say more.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":191,"Q_Id":40442688,"Users Score":4,"Answer":"When you import a C extension, python uses the platform's shared library loader to load the library and then, as you say, jumps to a function in the library. But you can't load just any library or jump to any function this way. It only works for libs specifically implemented to support python and to functions that are exported by the library as a python object. The lib must understand python objects and use those objects to communicate.\nAlternately, instead of importing, you can use a foreign-function library like ctypes to load the library and convert data to the C view of data to make calls.","Q_Score":1,"Tags":"python","A_Id":40442773,"CreationDate":"2016-11-05T20:07:00.000","Title":"C\/C++ module vs python module.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project.  Before I will at least will have 10 to 100 apps per project.  Now my project is just a website that presents information about a company with no use database, meaning it's really static, with only 10 to 20 pages. Now how do you start, do you create an app for such project.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":318,"Q_Id":40452529,"Users Score":3,"Answer":"meaning it's really static\n\nUse nginx to serve static files. Do not use django. You will setup project structure when it will be required.","Q_Score":1,"Tags":"python,django","A_Id":40452589,"CreationDate":"2016-11-06T17:50:00.000","Title":"How to structure a very small Django Project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project.  Before I will at least will have 10 to 100 apps per project.  Now my project is just a website that presents information about a company with no use database, meaning it's really static, with only 10 to 20 pages. Now how do you start, do you create an app for such project.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":318,"Q_Id":40452529,"Users Score":1,"Answer":"Frankly I won't use Django in that case, I would use Flask for such small projects. it's easy to learn and setup a small website.\nPS: I use Flask in small and large apps!","Q_Score":1,"Tags":"python,django","A_Id":40452810,"CreationDate":"2016-11-06T17:50:00.000","Title":"How to structure a very small Django Project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could suggest a better algorithm or just some tips to help me. Thank you.\n\nWrite a function called answer(src, dest) which takes in two parameters: the source square, on which you start, and the destination square, which is where you need to land to solve the puzzle.  The function should return an integer representing the smallest number of moves it will take for you to travel from the source square to the destination square using a chess knight's moves (that is, two squares in any direction immediately followed by one square perpendicular to that direction, or vice versa, in an \"L\" shape).  Both the source and destination squares will be an integer between 0 and 63, inclusive, and are numbered like the example chessboard below:\n\n\n-------------------------\n| 0| 1| 2| 3| 4| 5| 6| 7|\n-------------------------\n| 8| 9|10|11|12|13|14|15|\n-------------------------\n|16|17|18|19|20|21|22|23|\n-------------------------\n|24|25|26|27|28|29|30|31|\n-------------------------\n|32|33|34|35|36|37|38|39|\n-------------------------\n|40|41|42|43|44|45|46|47|\n-------------------------\n|48|49|50|51|52|53|54|55|\n-------------------------\n|56|57|58|59|60|61|62|63|\n-------------------------","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1507,"Q_Id":40454897,"Users Score":1,"Answer":"For this problem, simply doing a breadth-first search is enough (Dijkstra and BFS work in same way for unweighted graphs). To ensure that only the chess knight's moves are used, you'll have to define the moves in a proper way.\nNotice that a chess knight moves two squares to any direction, then one square perpendicular to that. This means it can move two squares left of right then one square up or down, or two squares up or down then one square left or right.\nThe calculation will be much easier if you identify the cells by rows (0 - 7) and columns (0 - 7) instead of 0 - 63. This can be done easily by dividing the cell index by 8 and using the quotient and remainder as row and column indices. So, if the knight is at position (x, y) now, its next possible positions can be any of (x - 2, y - 1), (x - 2, y + 1), (x + 2, y - 1), (x + 2, y + 1), (x - 1, y - 2), (x - 1, y + 2), (x + 1, y - 2), (x + 1, y + 2). Be careful that all of these 8 cells may not be inside the grid, so discard the locations that falls out of the board.","Q_Score":1,"Tags":"python,algorithm,path-finding","A_Id":40458170,"CreationDate":"2016-11-06T21:47:00.000","Title":"Simple algorithm to move from one tile to another using only a chess knight's moves","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could suggest a better algorithm or just some tips to help me. Thank you.\n\nWrite a function called answer(src, dest) which takes in two parameters: the source square, on which you start, and the destination square, which is where you need to land to solve the puzzle.  The function should return an integer representing the smallest number of moves it will take for you to travel from the source square to the destination square using a chess knight's moves (that is, two squares in any direction immediately followed by one square perpendicular to that direction, or vice versa, in an \"L\" shape).  Both the source and destination squares will be an integer between 0 and 63, inclusive, and are numbered like the example chessboard below:\n\n\n-------------------------\n| 0| 1| 2| 3| 4| 5| 6| 7|\n-------------------------\n| 8| 9|10|11|12|13|14|15|\n-------------------------\n|16|17|18|19|20|21|22|23|\n-------------------------\n|24|25|26|27|28|29|30|31|\n-------------------------\n|32|33|34|35|36|37|38|39|\n-------------------------\n|40|41|42|43|44|45|46|47|\n-------------------------\n|48|49|50|51|52|53|54|55|\n-------------------------\n|56|57|58|59|60|61|62|63|\n-------------------------","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":1507,"Q_Id":40454897,"Users Score":2,"Answer":"Approach the problem in the following way:\nStep 1: Construct a graph where each square of the chess board is a vertex.\nStep 2: Place an edge between vertices exactly when there is a single knight-move from one square to another.\nStep 3: Apply Dijkstra's algorithm. Dijkstra's algorithm is an algorithm to find the length of a path between two vertices (squares).","Q_Score":1,"Tags":"python,algorithm,path-finding","A_Id":40458703,"CreationDate":"2016-11-06T21:47:00.000","Title":"Simple algorithm to move from one tile to another using only a chess knight's moves","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could suggest a better algorithm or just some tips to help me. Thank you.\n\nWrite a function called answer(src, dest) which takes in two parameters: the source square, on which you start, and the destination square, which is where you need to land to solve the puzzle.  The function should return an integer representing the smallest number of moves it will take for you to travel from the source square to the destination square using a chess knight's moves (that is, two squares in any direction immediately followed by one square perpendicular to that direction, or vice versa, in an \"L\" shape).  Both the source and destination squares will be an integer between 0 and 63, inclusive, and are numbered like the example chessboard below:\n\n\n-------------------------\n| 0| 1| 2| 3| 4| 5| 6| 7|\n-------------------------\n| 8| 9|10|11|12|13|14|15|\n-------------------------\n|16|17|18|19|20|21|22|23|\n-------------------------\n|24|25|26|27|28|29|30|31|\n-------------------------\n|32|33|34|35|36|37|38|39|\n-------------------------\n|40|41|42|43|44|45|46|47|\n-------------------------\n|48|49|50|51|52|53|54|55|\n-------------------------\n|56|57|58|59|60|61|62|63|\n-------------------------","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":1507,"Q_Id":40454897,"Users Score":1,"Answer":"While User_Targaryen's answer is the best because it directly answers your question, I would recommend an algebraic solution, if your goal is computing is the delivery of an answer in the shortest amount of time.\nTo shorten the algorithm, use reflections about the x, y, and xy axes, so as to consider only positive (x, y) where x >= y, and place the starting move at the origin, coordinate (0, 0).  This is one octant (one eighth) of the possible directions.\nA hint to discovering the solution is to use graph-paper or Dijkstra's algorithm with the restriction of reaching all points in the first octant up to 5 moves, and display this as a grid.  Each cell of the grid should be labeled with a digit representing the minimum number of moves.\nLet me know if you would like to broaden your question and would like additional information.","Q_Score":1,"Tags":"python,algorithm,path-finding","A_Id":41089879,"CreationDate":"2016-11-06T21:47:00.000","Title":"Simple algorithm to move from one tile to another using only a chess knight's moves","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i wrote one program to do the information retrieval and extraction. user enter the query in the search bar, the program can show the relevant txt result such as the relevant sentence and the article which consists the sentence.\nI did some research for how to evaluate the result. I might need to calculate the precision, recall, AP, MAP....\nHowever, I am new to that. How to calculate the result. Since my dataset is not labeled and i did not do the classification. The dataset I used was the article from BBC news. there were 200 articles. i named it as 001.txt, 002.txt ...... 200.txt \nIt would be good if u have any ideas how to do the evaluation in python. Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":6407,"Q_Id":40457331,"Users Score":1,"Answer":"Evaluation has two essentials. First one is a test resource with the ranking of documents or their relevancy tag (relevant or not-relevant) for specific queries, which is made with an experiment (like user click, etc. and is mostly used when you have a running IR system), or made through crowd-sourcing. The second essential part of evaluation is which formula to use for evaluating an IR system with the test collection. \nSo based on what you said, if you don't have a labeled test collection you cant evaluate your system.","Q_Score":3,"Tags":"python,information-retrieval,information-extraction","A_Id":40603239,"CreationDate":"2016-11-07T03:20:00.000","Title":"information retrieval evaluation python precision, recall, f score, AP,MAP","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on my first django project which is also my first backend project. In the tutorials\/reading I have completed, I haven't come across passing information back to django without a modelform.\nMy intention is to calculate a value on a page using javascript and pass it to django when a user hits a submit button on that page. The submit button will also be a link to another page. I know I could process the information in a view via the url if I knew how to pass the information back to django.\nI'm aware that django uses MVC and as I have my models and views in place, I am lead to believe that this has something to do with controllers. \nBasically, I would like to know how to pass information from a page to django as a user follows a link to another page. I understand that this isn't the place for long step by step tutorials on specific topics but I would appreciate any links to resources on this subject. I don't know what this process is even called so I can't search documentation for it.\nEDIT:\nFrom further reading, I think that I want to be using the submit button to GET or POST the value. In this particular case, POST is probably better. Could someone confirm that this is true?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":47,"Q_Id":40471132,"Users Score":2,"Answer":"Yes, generally POST is a better way of submitting data than GET. There is a bit of a confusion about terminology in Django. While Django is, indeed MVC, models are models, but views are in fact controllers and views are templates. Since you are going to use AJAX to submit and retrieve the data, you don't care about templates. So what you most likely want is something like this\nin your urls.py as part of your urlpatterns variable\n\nurl(r'mything\/$', MyView.as_view())\n\nin your views.py\n\nfrom django.views import View\nfrom django.http import HttpResponse\n\nclass MyView(View):\n    def post(self, request):\n        data = request.POST\n        ... do your thing ...\n        return HttpResponse(results)\n\nand in your javascript\n\njQuery.post('\/mything\/', data, function() { whatever you do here })","Q_Score":2,"Tags":"python,django","A_Id":40474452,"CreationDate":"2016-11-07T17:33:00.000","Title":"Django - beginner- what is the process for passing information to a view via a url?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have two forms, when I submit form#1 I get some corresponding file, but when I submit form#2 thenafter, the corresponding file gets shown but form#1 goes empty. So basically I want some thing like a SPA(e.g angular) but I am taking form#1 and form#2 as separate requests routes and each render my index.html every time, so form#2 is wiped off when I submit form#1 and vice-versa.\nI dont want a working code but any ideas on how I do that with Tornado (not angular, or say Tornado + Angular ? ) \nI think one way for example is to handle these requests via a controller and do an AJAX post to corresponding Tornado Handler, which after the file is rendered, displays \/ serves the very file back again. But this uses AngularJS as a SPA. Any other solution possible?\nThanks in Advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":40482242,"Users Score":0,"Answer":"This is not really a Tornado question, as this is simply how Web works.\nOne possible solution is to have only one form, but display its fields so that they look like two forms; in addition, have two separate submit buttons, each with its own name and value. Now, when you click on either button the whole form will be submitted, but in the handler you can process only the fields associated with the clicked button, while still displaying values in all the fields.","Q_Score":0,"Tags":"python,angularjs,templates,tornado","A_Id":40517136,"CreationDate":"2016-11-08T08:31:00.000","Title":"ways to avoid previous reload tornado","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have coded a python app to manage file copies on linux, I want to know how can I get it to process copy\/paste calls, like those launched by pressing ctrl + c\/ ctrl + v  or right click \/ Copy..., or drag and drop, instead of using system copier.\nCan I do this for all deb based linux dist. or its on different ways for Ubuntu, Mint, Debian, and so on????\nForgive my English and thanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":205,"Q_Id":40492606,"Users Score":2,"Answer":"Short answer: no, you can't.\nLong answer: the component that does \"copy&paste\" is not alone defined by the distribution. This is a function of the desktop system \/ window manager. In other words: there is no such thing as the \"default system file\" copier for \"Linux\".\nThere are file mangers like dolphin for KDE; or nautilus on gnome that all come with their own implementation of file copy. Some good, some not so much (try copying a whole directory with thousands of files with nautilus). \nBut the real question here: why do you want to do that? What makes you think that your file-copy implementation that requires an interpreter to run ... is suited to replace the defaults that come with Linux? Why do you think that your re-invention of an existing wheel will be better at doing anything?!\nEdit: if your reason to \"manage\" system copy is some attempt to prevent the user from doing certain things ... you should better look into file permissions and such ideas. Within a Linux environment, you simply can't manage what the user is doing in the first place by manipulating some tools. Instead: understand the management capabilities that the OS offers to you, and use those!","Q_Score":0,"Tags":"python,linux,copy-paste","A_Id":40493312,"CreationDate":"2016-11-08T17:05:00.000","Title":"Change default system file copier in Linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have started using djangorestframework-jwt package instead of PyJWT , I just could not know how to decode the incoming token (I know there is verify token methode).... All I need to know is how to decode the token and get back info encoded......","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":11026,"Q_Id":40522177,"Users Score":1,"Answer":"Do this jwt.decode(token,settings.SECRET_KEY, algorithms=['HS256'])","Q_Score":7,"Tags":"django,python-2.7,django-rest-framework,jwt","A_Id":70026089,"CreationDate":"2016-11-10T07:33:00.000","Title":"How to decode token and get back information for djangorestframework-jwt packagefor Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was using Zodb for large data storage which was in form of typical dictionary format (key,value). \nBut while storing in ZODB i got following warning message:\n\nC:\\python-3.5.2.amd64\\lib\\site-packages\\ZODB\\Connection. py:550:\n  UserWarning: The  object\n  you're saving is large. (510241658 bytes.)\nPerhaps you're storing media which should be stored in blobs.\nPerhaps you're using a non-scalable data structure, such as a\n  PersistentMapping or PersistentList.\nPerhaps you're storing data in objects that aren't persistent at all.\n  In cases like that, the data is stored in the record of the containing\n  persistent object.\nIn any case, storing records this big is probably a bad idea.\nIf you insist and want to get rid of this warning, use the\n  large_record_size option of the ZODB.DB constructor (or the\n  large-record-size option in a configuration file) to specify a larger\n  size.\nwarnings.warn(large_object_message % (obj.class, len(p)))\n\nplease suggest how can i store large data in ZODB or suggest any other library for this purpose","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":901,"Q_Id":40548608,"Users Score":1,"Answer":"You must store the object on the filesystem and add reference to it in the zodb like using a regular database.","Q_Score":2,"Tags":"python,database,dataset,zodb,object-oriented-database","A_Id":40549472,"CreationDate":"2016-11-11T13:01:00.000","Title":"ZODB or other database for large data storage in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed both 32-bit conda and 64-bit conda for different projects. I created a new environment and specified python 3 in \nconda create -name ..name.. python=3\nThe command picked up Python 3.5.2 but in 64-bit, rather than 32. But when I changed the command to\nconda create -name ..name.. python=3.4\nit picked up the 32-bit python correctly. My question is how to force conda to pickup 32-bit python 3.5.2? so I can use some of the packages that only support python 3.5.\nHere's what I did and none of them work:\n\ninstalled both 32-bit and 64-bit pythons\ninstalled both 32-bit and 64-bit condas\nset 32-bit Miniconda to come before 64-bit Miniconda in PATH\nlaunched 32-bit conda prompt\nset CONDA_FORCE_32BIT=1\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1344,"Q_Id":40550207,"Users Score":0,"Answer":"I found that I have to delete the package caches first. Or force conda to install Python with -f option.","Q_Score":0,"Tags":"python,32bit-64bit,conda","A_Id":40661895,"CreationDate":"2016-11-11T14:34:00.000","Title":"conda 32-bit keep installing 64-bit python 3.5.2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Without root access, how do I change the default Python from 3.5 to 2.7 for my specific user? Would like to know how to run Python scripts with Python 2 as well.\nIf I start up Python by running simply python then it runs 3.5.2. I have to specifically run python2 at the terminal prompt to get a version of python2 up.\nIf I run which python, then \/data\/apps\/anaconda3\/bin\/python gets returned and I believe Python 2.7 is under \/usr\/bin\/python.\nThis is on CentOS if that helps clarify anything","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6310,"Q_Id":40555625,"Users Score":0,"Answer":"If you are looking to change the python interpreter in anaconda from 3.5 to 2.7 for the user, try the command conda install python=2.7","Q_Score":3,"Tags":"python,python-2.7,python-3.x,centos,anaconda","A_Id":48596296,"CreationDate":"2016-11-11T20:22:00.000","Title":"How do I change default Python version from 3.5 to 2.7 in Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've gotten use to using print in my python code to show contents of variable and checking the shell output.\nBut i have now migrated all my work onto a online server. Pythonanywhere \nI don't have the foggiest idea how to do the same now?\nCan someone point me in the right direction?\nPrint to web console? To a file? Or even to the shell session?\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1138,"Q_Id":40560439,"Users Score":3,"Answer":"On production server your print statements will output log to your webserver log files\nIn case of pythonanywhere there are three log files\n\nAccess log:yourusername.pythonanywhere.com.access.log\n  Error log:yourusername.pythonanywhere.com.error.log\n  Server log:yourusername.pythonanywhere.com.server.log\n\nthose logs are accessible in your web tab page.\nThe logs you are looking for will be in server.log","Q_Score":3,"Tags":"python,django,pythonanywhere","A_Id":40560572,"CreationDate":"2016-11-12T07:04:00.000","Title":"Django print in prod' server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a python project, how do I setup a project-wide \"data\" folder, accessible from every module? I don't have a single entry point in my program, so I cannot do something like global (dataFolderPath). I would like for every module to know where the data folder is (without hardcoding the path in every module!), so it can load and write the data it needs. I'm using python 3.5 on a mac. \nThanks!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":710,"Q_Id":40562116,"Users Score":0,"Answer":"This is not python specific, but if you want to share a config globally among your programs you could set up a environment variable like MYPROJECT_DATA_PATH and all your scripts check this variable before loading the data. Or you could write a config file which all your programs know the location. Or both, a environment variable with the path of the config file, where you can fine-tune it for your needs.","Q_Score":1,"Tags":"python,macos,python-3.x,path,global-variables","A_Id":40562461,"CreationDate":"2016-11-12T10:57:00.000","Title":"How to set up data folder to be accessible from everywhere in a python project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to read an existing SVG file, traverse all elements and remove them if they match certain conditions (e.g. remove all objects with red border).\nThere is the svgwrite library for Python2\/3 but the tutorials\/documentation I found only show how to add some lines and save the file.\nCan I also manipulate\/remove existing elements inside an SVG document with svgwrite? If not - is there an alternative for Python?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":414,"Q_Id":40574548,"Users Score":0,"Answer":"The svgwrite package only creates svg. It does not read a svg file. I have not tried any packages to read and process svg files.","Q_Score":1,"Tags":"python,svg","A_Id":41472508,"CreationDate":"2016-11-13T13:49:00.000","Title":"manipulating SVGs with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":1.2,"is_accepted":true,"ViewCount":309596,"Q_Id":40595961,"Users Score":209,"Answer":"If you're using Spyder 3, please go to\nTools > Preferences > Syntax Coloring\nand select there the dark theme you want to use.\nIn Spyder 4, a dark theme is used by default. But if you want to select a different theme you can go to\nTools > Preferences > Appearance > Syntax highlighting theme","Q_Score":106,"Tags":"python,themes,spyder","A_Id":40684400,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":0,"Answer":"1.Click Tools\n2.Click Preferences\n3.Select Syntax Coloring","Q_Score":106,"Tags":"python,themes,spyder","A_Id":56964742,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":-1.0,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":-5,"Answer":"Yes, that's the intuitive answer. Nothing in Spyder is intuitive. Go to Preferences\/Editor and select the scheme you want. Then go to Preferences\/Syntax Coloring and adjust the colors if you want to. \ntcebob","Q_Score":106,"Tags":"python,themes,spyder","A_Id":41008022,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":0.022218565,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":2,"Answer":"I tried the option: Tools > Preferences > Syntax coloring > dark spyder\nis not working.\nYou should rather use the path:\nTools > Preferences > Syntax coloring > spyder \nthen begin modifications as you want your editor to appear","Q_Score":106,"Tags":"python,themes,spyder","A_Id":46890965,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":0.0111106539,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":1,"Answer":"On mine it's Tools --> Preferences --> Editor and \"Syntax Color Scheme\" dropdown is at the very bottom of the list.","Q_Score":106,"Tags":"python,themes,spyder","A_Id":50761910,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":0.022218565,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":2,"Answer":"I think some of the people answering this question don\u2019t actually try to do what they recommend, because there is something wrong with way the Mac OS version handles the windows.\nWhen you choose the new color scheme and click OK, the preferences window looks like it closed, but it is still there behind the main spyder window.  You need to switch windows with command ~ or move the main spyder window to expose the preferences window.  Then you need to click Apply to get the new color scheme.","Q_Score":106,"Tags":"python,themes,spyder","A_Id":52020233,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":0,"Answer":"At First click on  preferences(Ctrl+Shift+alt+p) then click the option of syntax coloring and change the scheme to \"Monokai\".Now apply it and you will get the dark scheme.","Q_Score":106,"Tags":"python,themes,spyder","A_Id":56276123,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":0.0111106539,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":1,"Answer":"I've seen some people recommending installing aditional software but in my opinion the best way is by using the built-in skins, you can find them at:\nTools > Preferences > Syntax Coloring","Q_Score":106,"Tags":"python,themes,spyder","A_Id":58119453,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?","AnswerCount":18,"Available Count":9,"Score":0.0,"is_accepted":false,"ViewCount":309596,"Q_Id":40595961,"Users Score":0,"Answer":"In Spyder 4.1, you can change background color from:\nTools > Preferences > Appearance > Syntax highlighting scheme","Q_Score":106,"Tags":"python,themes,spyder","A_Id":60023463,"CreationDate":"2016-11-14T19:03:00.000","Title":"How to change the Spyder editor background to dark?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Simple question - but any steps on how to remove pylint from a Windows 10 machine with Python 3.5.2 installed.\nI got an old version of pylint installed that's spellchecking on old Python 2 semantics and it's bugging the heck out of me when the squigglies show up in Visual Studio Code.","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":42819,"Q_Id":40626429,"Users Score":31,"Answer":"If you just want to disable pylint then the updated VSCode makes it much more easier.\n\nJust hit CTRL + SHIFT + P > Select linter > Disabled Linter.\n\nHope this helps future readers.","Q_Score":32,"Tags":"python,visual-studio-code,vscode-settings,pylint","A_Id":56183059,"CreationDate":"2016-11-16T07:37:00.000","Title":"Visual Studio Code - removing pylint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Simple question - but any steps on how to remove pylint from a Windows 10 machine with Python 3.5.2 installed.\nI got an old version of pylint installed that's spellchecking on old Python 2 semantics and it's bugging the heck out of me when the squigglies show up in Visual Studio Code.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":42819,"Q_Id":40626429,"Users Score":0,"Answer":"i had this problem but it was fixed with this solution CTRL + SHIFT + P > Selecionar linter > Linter desabilitado.","Q_Score":32,"Tags":"python,visual-studio-code,vscode-settings,pylint","A_Id":72494136,"CreationDate":"2016-11-16T07:37:00.000","Title":"Visual Studio Code - removing pylint","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an s3 bucket which is used for users to upload zipped directories, often 1GB in size. The zipped directory holdes images in subfolders and more. \nI need to create a lambda function, that will get triggered upon new uploads, unzip the file, and upload the unzipped content back to an s3 bucket, so I can access the individual files via http - but I'm pretty clueless as to how I can write such a function?\nMy concerns are:\n\nPyphon or Java is probably better performance over nodejs?\nAvoid running out of memory, when unzipping files of a GB or more (can I stream the content back to s3?)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1257,"Q_Id":40627395,"Users Score":0,"Answer":"Lambda would not be a good fit for the actual processing of the files for the reasons mentioned by other posters. However, since it integrates with S3 events it could be used as a trigger for something else. It could send a message to SQS where another process that runs on EC2 (ECS, ElasticBeanstalk, ECS) could handle the messages in the queue and then process the files from S3.","Q_Score":0,"Tags":"java,python,amazon-web-services,amazon-s3,aws-lambda","A_Id":40632303,"CreationDate":"2016-11-16T08:38:00.000","Title":"AWS lambda function to retrieve any uploaded files from s3 and upload the unzipped folder back to s3 again","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to apply NLP to an OCR document. To extract named entities, how can I use features like position of the word in the document?\nFor example, I have a health report I need to extract the chemical terms in the report in a particular area and avoid their occurrence elsewhere. Can I define a position feature for this in terms of {top:x , left:y} values?\nAre there any sklearn libraries?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":393,"Q_Id":40631040,"Users Score":0,"Answer":"You could build extraction zones to fetch this content.\nIn other words, group documents that have the required content within a given area in the image and then fetch the contents from that area for all images.","Q_Score":1,"Tags":"python,machine-learning,nlp,ocr","A_Id":42022673,"CreationDate":"2016-11-16T11:31:00.000","Title":"NLP: Position feature of a word in an OCR of a document","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I am running a Python script in C:\\temp\\templates\\graphics. I can get the current directory using currDir = os.getcwd(), but how can I use relative path to move up in directories and execute something in C:\\temp\\config (note: this folder will not always be in C:\\)?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":930,"Q_Id":40666853,"Users Score":0,"Answer":"Try this one:\nos.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), \"config\")","Q_Score":1,"Tags":"python,file,directory,relative-path","A_Id":40666955,"CreationDate":"2016-11-17T23:24:00.000","Title":"Move up in directory structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I built a simple statement to run a load data local infile on a MySQL table. I'm using Python to generate the string and also run the query. So I'm using the Python package pymysql.\nThis is the line to build the string. Assume metadata_filename is a proper string:\n\nload_data_statement = \"\"\"load data local infile \"\"\" + metadata_filename + \"\"\"INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\"\n\nI originally had string substitution, and wanted to see if that was the issue, but it isn't. If I edit the statement above and commend out the ENCLOSED BY part, it is able to run, but not properly load data since I need the enclosed character\nIf I print(load_data_statement), I get what appears to be proper SQL code, but it doesn't seem to be read by the SQL connector. This is what's printed: \n\nload data local infile 'filename.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY ''';\n\nThat all appears to be correct, but the Mysql engine is not taking it. What should I edit in Python to escape the single quote or just write it properly?\nEdit:\nI've been running the string substitution alternative, but still getting issues: load_data_statement = \"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nAlso tried raw strings:load_data_statement = r\"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nAlso tried raw strings:load_data_statement = r\"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nAnd tried adding extra escapes: Also tried raw strings:load_data_statement = r\"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\\'';\"\"\" % metadata_filename\nAlso tried raw strings:load_data_statement = r\"\"\"load data local infile \\'tgt_metadata_%s.txt\\' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nThe execute line is simple `cur.execute(load_data_statement)\nAnd the error I'm getting is odd: `pymysql.err.ProgrammingError: (1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tgt_metadta_mal.txt'.txt' INTO table tgt_metadata FIELDS TERMINATED BY ','; ENC' at line 1\")\nI don't understand why the message starts at 'tgt_metadata_mal.txt and shows only the first 3 letters of ENCLOSED BY...","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":4539,"Q_Id":40672551,"Users Score":0,"Answer":"I think the problem is with the SQL statement you print. The single quote in ''' should be escaped: '\\''. Your backslash escapes the quote at Python level, and not the MySQL level. Thus the Python string should end with ENCLOSED BY '\\\\'';\nYou may also use the raw string literal notation:\nr\"\"\"INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\"","Q_Score":1,"Tags":"python,mysql,escaping,load-data-infile,pymysql","A_Id":40672954,"CreationDate":"2016-11-18T08:36:00.000","Title":"In Python how do I escape a single quote within a string that will be used as a SQL statement?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I built a simple statement to run a load data local infile on a MySQL table. I'm using Python to generate the string and also run the query. So I'm using the Python package pymysql.\nThis is the line to build the string. Assume metadata_filename is a proper string:\n\nload_data_statement = \"\"\"load data local infile \"\"\" + metadata_filename + \"\"\"INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\"\n\nI originally had string substitution, and wanted to see if that was the issue, but it isn't. If I edit the statement above and commend out the ENCLOSED BY part, it is able to run, but not properly load data since I need the enclosed character\nIf I print(load_data_statement), I get what appears to be proper SQL code, but it doesn't seem to be read by the SQL connector. This is what's printed: \n\nload data local infile 'filename.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY ''';\n\nThat all appears to be correct, but the Mysql engine is not taking it. What should I edit in Python to escape the single quote or just write it properly?\nEdit:\nI've been running the string substitution alternative, but still getting issues: load_data_statement = \"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nAlso tried raw strings:load_data_statement = r\"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nAlso tried raw strings:load_data_statement = r\"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nAnd tried adding extra escapes: Also tried raw strings:load_data_statement = r\"\"\"load data local infile 'tgt_metadata_%s.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\\'';\"\"\" % metadata_filename\nAlso tried raw strings:load_data_statement = r\"\"\"load data local infile \\'tgt_metadata_%s.txt\\' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\'';\"\"\" % metadata_filename\nThe execute line is simple `cur.execute(load_data_statement)\nAnd the error I'm getting is odd: `pymysql.err.ProgrammingError: (1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tgt_metadta_mal.txt'.txt' INTO table tgt_metadata FIELDS TERMINATED BY ','; ENC' at line 1\")\nI don't understand why the message starts at 'tgt_metadata_mal.txt and shows only the first 3 letters of ENCLOSED BY...","AnswerCount":2,"Available Count":2,"Score":0.2913126125,"is_accepted":false,"ViewCount":4539,"Q_Id":40672551,"Users Score":3,"Answer":"No need for escaping that string.\ncursor.execute(\"SELECT * FROM Codes WHERE ShortCode = %s\", text) \nYou should use %s instead of your strings and then (in this case text) would be your string. This is the most secure way of protecting from SQL Injection","Q_Score":1,"Tags":"python,mysql,escaping,load-data-infile,pymysql","A_Id":40672606,"CreationDate":"2016-11-18T08:36:00.000","Title":"In Python how do I escape a single quote within a string that will be used as a SQL statement?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a classifier that has been trained using a given set of input training data vectors. There are missing values in the training data which is filled as numpy.Nan values and Using imputers to fill in the missing values.\nHowever, In case of my input vector for prediction, how do I pass in the input where the value is missing? should I pass the value as nan? Does imputer play a role in this.?\nIf I have to fill in the value manually, How do I fill in the value for such case will I need to calculate the mean\/median\/frequency from the existing data.\nNote : I am using sklearn.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":787,"Q_Id":40673629,"Users Score":0,"Answer":"You cannot use NaN values because the input vector will, for instance, be multiplied with a weight matrix. The result of such operations needs to be defined.\nWhat you typically do if you have gaps in your input data is, depending on the specific type and structure of the data, fill the gaps with \"artificial\" values. For instance, you can use the mean or median of the same column in the remaining training data instances.","Q_Score":0,"Tags":"python,numpy,machine-learning,scikit-learn","A_Id":40673779,"CreationDate":"2016-11-18T09:36:00.000","Title":"Pass a NAN in input vector for prediction","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to run automated test on my python script using Hudson and testlink. I configured Hudson with my testlink server but the test results are always \"not run\". Do you know how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":299,"Q_Id":40680022,"Users Score":0,"Answer":"I found how to do it : \nI used testLink-API-Python-client.","Q_Score":0,"Tags":"python,automated-tests,hudson,testlink","A_Id":40722012,"CreationDate":"2016-11-18T14:53:00.000","Title":"Automate python test with testlink and hudson","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have built a flask web application that makes use of Google's authenticated login to authenticate users. I currently have it running on localhost 127.0.0.1:5000 however I would like to point a custom domain name to it that I would like to purchase.\nI have used custom domains with Flask applications before, I'm just not sure how to do it with this. I'm confused as to what I would do with my oauth callback.\nMy callback is set to http:\/\/127.0.0.1:5000\/authorized in my Google oauth client credentials. I don't think it would just be as easy as running the app on 0.0.0.0.\nI would need to be able to match the flask routes to the domain. i.e be able to access www.mydomain.com\/authorized.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":447,"Q_Id":40685275,"Users Score":0,"Answer":"I was able to solve this just now!\nI went through my DNS settings of my domain and pointed the DNS A record to the IP address that my flask application is running on.\nPreviously, I was using a redirect on the domain, which was not working.","Q_Score":0,"Tags":"python","A_Id":40699877,"CreationDate":"2016-11-18T20:15:00.000","Title":"Use custom domain for flask app with Google authenticated login","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get started with xlwings, but am recieving a few errors when I go to import it.\nI pulled up my OSX terminal, ran \n\npip install xlwings\n\nno problem there. Fired up python\n\n$ python\n\nthen ran\n\nimport xlwings as xw\n\nAnd it gave me this:\n\n\/users\/Joshua\/anaconda\/lib\/python3.5\/site-packages\/numexpr\/cpuinfo.py:53: UserWarning: [Errno 2] No such file or directory: 'arch'\n    stacklevel=stacklevel + 1)\n  \/users\/Joshua\/anaconda\/lib\/python3.5\/site-packages\/numexpr\/cpuinfo.py:53: UserWarning: [Errno 2] No such file or directory: 'machine'\n    stacklevel=stacklevel + 1)\n  \/users\/Joshua\/anaconda\/lib\/python3.5\/site-packages\/numexpr\/cpuinfo.py:76: UserWarning: [Errno 2] No such file or directory: 'sysctl'\n    stacklevel=stacklevel + 1):\n\nI tried uninstalling and reinstalling the numexpr package\n\npip uninstall numexpr\n  pip install numexpr\n\nand doing the same with xlwings, but still recieving this error. :\/\nAny ideas on how to get the missing files?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":179,"Q_Id":40689085,"Users Score":0,"Answer":"xlwings imports pandas, if it is installed. Pandas again is importing numexpr if it's available. This seems to be not correctly installed. I would reinstall numexpr using conda (as you are using anaconda) and if that doesn't help pandas and xlwings. You could also create a new conda environment and conda install xlwings to try it out in a fresh environment.","Q_Score":0,"Tags":"python,terminal,pip,xlwings,numexpr","A_Id":40692275,"CreationDate":"2016-11-19T03:59:00.000","Title":"import xlwings, missing files from numexpr package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making an AI for a card game in Python and was wondering how I can keep players' decision functions from accessing the information given to them by the game that they shouldn't be able to access (for example, other players' hands). Currently, the game object itself is being passed into the players' decision functions.\nI can only see two avenues of improvement: to either carefully choose what you pass in (although even things like one's own deck shouldn't be able to be manipulated by oneself, sadly, so this might not work), or to somehow filter using some obfuscation method, but I can't really think of one. Can you think of a better way to design this?\nThanks!\nAndrew","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":31,"Q_Id":40690016,"Users Score":1,"Answer":"Treat them like human players; don't give them the internal guts, just give them an interface to use.\nE.g. give them an object that contains only the information they're allowed to access, and have the AI return a choice of which action they wish to perform.","Q_Score":0,"Tags":"python,artificial-intelligence","A_Id":40690032,"CreationDate":"2016-11-19T06:45:00.000","Title":"Obfuscating\/Hiding Information from other players when writing an AI for a game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I understand how to index a word in a given list, but if given a set list and a word not in the list, how do I find the index position of the new word without appending or inserting the new word to the sorted list?\nFor example:\ndef find_insert_position: \n    a_list = ['Bird', 'Dog', 'Alligator']\n    new_animal = 'Cow'\nWithout altering the list, how would I determine where the new word would be inserted within a sorted list?  So that if you entered the new word, the list would stat in alphabetical order.  Keep in mind this is a given list and word, so I would not know any of the words before hand. I am using Python3.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":40693141,"Users Score":0,"Answer":"Set a variable counter to 0\nLoop through each item inthe wordlist and compare each word in the list with the given list\nIf the given word is greater than the item in list then increment the counter\nSo when you are out of the loop, counter value is the index you are looking for.\nYou can convert this to code.","Q_Score":0,"Tags":"list,python-3.x,loops,iteration","A_Id":40693343,"CreationDate":"2016-11-19T12:54:00.000","Title":"How to iterate a list without inserting the new word to list?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use python's epoll but it can't use event.data.ptr like in c++.\nSometimes I will register class A.fd and sometimes I will register class B.fd.\nSo, when epoll.poll() returned, how can I know whether fd belongs to class A or B?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":171,"Q_Id":40703762,"Users Score":0,"Answer":"You can always maintain a separate map from fd to A or B. Then when an event gets triggered, lookup based on fd.\nDoesn't look like epoll has a richer interface, even in Python 3+","Q_Score":0,"Tags":"python,c++,epoll","A_Id":40704285,"CreationDate":"2016-11-20T11:58:00.000","Title":"python,epoll.register(fd, eventmask) only has two parameters, how could I to use event.data_ptr like c++?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've seen other IDEs have the option to right click and reinitialize the environment. Does anyone know if this is possible in PyCharm, and if so, how it's done?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31725,"Q_Id":40712203,"Users Score":0,"Answer":"Please note that this button does not reset all the variables. But then you can enter in the command prompt: reset.","Q_Score":32,"Tags":"python,pycharm","A_Id":58099676,"CreationDate":"2016-11-21T03:12:00.000","Title":"How to reinitialize the Python console in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've seen other IDEs have the option to right click and reinitialize the environment. Does anyone know if this is possible in PyCharm, and if so, how it's done?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":31725,"Q_Id":40712203,"Users Score":0,"Answer":"I had tried \"rerun\" and found that it didn't reload the new environment.\nI suggest that \"new console\" button could help you to reload the environment that it had installed the new packages.","Q_Score":32,"Tags":"python,pycharm","A_Id":71106939,"CreationDate":"2016-11-21T03:12:00.000","Title":"How to reinitialize the Python console in PyCharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python program that read Linux kernel system calls (use Lttng), So with this program I could read all kernel calls. I have some operations and then with python program going to analyses system calls, in the operations I have some IO works, then with python program I need to know how many bytes that read from cache and how many read from disk. which system calls show me the bytes read from cache and disk?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":130,"Q_Id":40729919,"Users Score":0,"Answer":"Handling read, write, pread, pwrite, readv, writev should be enough.\nYou just have to check whether the FD refers to the cache or disk. I think it would be easier in kernelspace, by writing a module, but...","Q_Score":0,"Tags":"python,linux,lttng","A_Id":40730003,"CreationDate":"2016-11-21T21:42:00.000","Title":"Which linux kernel system calls shows bytes read from disk","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to build an app for making UML diagrams. For visibility problems, I wish I could move classes using the mouse.\nSo here is my problem :\nDo you know how can I drag and drop a widget in a canvas using wxPython ?\nFound some things about ogl, but sound strange to me ... \nThx guys","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":84,"Q_Id":40762810,"Users Score":0,"Answer":"Take a look at the FloatCanvas sample in the wxPython demo.  There is also a sample for the OGL package there.  Either, or both of those would likely be suitable for diagrams depending on your needs.","Q_Score":0,"Tags":"wxpython","A_Id":40940273,"CreationDate":"2016-11-23T11:08:00.000","Title":"wxpython self made widget and drag and drop it in a canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anybody have a suggestion on what's the best way to present overlapping lines on a plot? I have a lot of them, and I had the idea of having full lines of different colors where they don't overlap, and having dashed lines where they do overlap so that all colors are visible and overlapping colors are seen.\nBut still, how do I that.","AnswerCount":4,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35477,"Q_Id":40766909,"Users Score":33,"Answer":"Just decrease the opacity of the lines so that they are see-through. You can achieve that using the alpha variable. Example:\nplt.plot(x, y, alpha=0.7)\nWhere alpha ranging from 0-1, with 0 being invisible.","Q_Score":28,"Tags":"python,matplotlib","A_Id":40767005,"CreationDate":"2016-11-23T14:18:00.000","Title":"Suggestions to plot overlapping lines in matplotlib?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Every time I open up Chrome driver in my python script, it says \"chromedriver.exe has stopped working\" and crashes my script with the error: [Errno 10054] An existing connection was forcibly closed by the remote host.\nI read the other forum posts on this error, but I'm very new to this and a lot of it was jargon that I didn't understand.  One said something about graceful termination, and one guy said \"running the request again\" solved his issue, but I have no idea how to do that.  Can someone explain to me in more detail how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":298,"Q_Id":40782641,"Users Score":0,"Answer":"Fixed.  It was a compatibility error.  Just needed to downloaded the latest chrome driver version and it worked.","Q_Score":0,"Tags":"python-2.7,selenium-webdriver,selenium-chromedriver","A_Id":40795935,"CreationDate":"2016-11-24T09:36:00.000","Title":"[Errno 10054], selenium chromedriver crashing each time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a use case where i want to invoke my lambda function whenever a object has been pushed in S3 and then push this notification to slack. \nI know this is vague but how can i start doing so ? How can i basically achieve this ? I need to see the structure","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1589,"Q_Id":40800757,"Users Score":0,"Answer":"You can use S3 Event Notifications to trigger the lambda function.\nIn bucket's properties, create a new event notification for an event type of s3:ObjectCreated:Put and set the destination to a Lambda function.\nThen for the lambda function, write a code either in Python or NodeJS (or whatever you like) and parse the received event and send it to Slack webhook URL.","Q_Score":3,"Tags":"python,amazon-web-services,lambda","A_Id":65574478,"CreationDate":"2016-11-25T08:40:00.000","Title":"How to write a AWS lambda function with S3 and Slack integration","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any automated way to test that code is compatible with both Python 2 and 3? I've seen plenty of documentation on how to write code that is compatible with both, but nothing on automatically checking. Basically a kind of linting for compatibility between versions rather than syntax\/style.\nI have thought of either running tests with both interpreters or running a tool like six or 2to3 and checking that nothing is output; unfortunately, the former requires that you have 100% coverage with your tests and I would assume the latter requires that you have valid Python 2 code and would only pick up issues in compatibility with Python 3.\nIs there anything out there that will accomplish this task?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4817,"Q_Id":40815079,"Users Score":1,"Answer":"Could you not look at the output from 2to3 to see if any code changes may be necessary ?","Q_Score":4,"Tags":"python,python-2.7,python-3.x,version","A_Id":40815167,"CreationDate":"2016-11-26T04:57:00.000","Title":"Checking code for compatibility with Python 2 and 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there any automated way to test that code is compatible with both Python 2 and 3? I've seen plenty of documentation on how to write code that is compatible with both, but nothing on automatically checking. Basically a kind of linting for compatibility between versions rather than syntax\/style.\nI have thought of either running tests with both interpreters or running a tool like six or 2to3 and checking that nothing is output; unfortunately, the former requires that you have 100% coverage with your tests and I would assume the latter requires that you have valid Python 2 code and would only pick up issues in compatibility with Python 3.\nIs there anything out there that will accomplish this task?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":4817,"Q_Id":40815079,"Users Score":4,"Answer":"There is no \"fool-proof\" way of doing this other than running the code on both versions and finding inconsistencies.  With that said, CPython2.7 has a -3 flag which (according to the man page) says:\n\nWarn about Python 3.x incompatibilities that 2to3 cannot trivially fix.\n\nAs for the case where you have valid python3 code and you want to backport it to python2.x -- You likely don't actually want to do this.  python3.x is the future.  This is likely to be a very painful problem in the general case.  A lot of the reason to start using python3.x is because then you gain access to all sorts of cool new features.  Trying to re-write code that is already relying on cool new features is frequently going to be very difficult.  Your much better off trying to upgrade python2.x packages to work on python3.x than doing things the other way around.","Q_Score":4,"Tags":"python,python-2.7,python-3.x,version","A_Id":40815143,"CreationDate":"2016-11-26T04:57:00.000","Title":"Checking code for compatibility with Python 2 and 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Python 3.6 and Windows 7. \nI am able to successfully start the python interpreter in interactive mode, which I have confirmed by going to cmd, and typing in python, so my computer knows how to find the interpreter.\nI am confused however, as to how to access files from the interpreter. For example, I have a file called test.py (yes, I made sure the correct file extension was used). \nHowever, I do not know how to access test.py from the interpreter. Let us say for the sake of argument that the test.py file has been stored in C:\\ How then would I access test.py from the interpreter?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1359,"Q_Id":40829181,"Users Score":0,"Answer":"The simplest way would be to  just do the following in cmd:\nC:\\path\\to\\file\\test.py\nWindows recognizes the file extension and runs it with Python.\nOr you can change the directory to where the Python program\/script is by using the cd command in the command prompt:\ncd C:\\path\\to\\file\nStart Python in the terminal and import the script using the import function:\nimport test\nYou do not have to specify the .py file extension. The script will only run once per process so you'll need to use the reload function to run it after it's first import.\nYou can make python run the script from a specific directory:\npython C:\\path\\to\\file\\test.py","Q_Score":0,"Tags":"python,cmd,interpreter","A_Id":40829247,"CreationDate":"2016-11-27T12:54:00.000","Title":"Running a python program in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Python 3.6 and Windows 7. \nI am able to successfully start the python interpreter in interactive mode, which I have confirmed by going to cmd, and typing in python, so my computer knows how to find the interpreter.\nI am confused however, as to how to access files from the interpreter. For example, I have a file called test.py (yes, I made sure the correct file extension was used). \nHowever, I do not know how to access test.py from the interpreter. Let us say for the sake of argument that the test.py file has been stored in C:\\ How then would I access test.py from the interpreter?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1359,"Q_Id":40829181,"Users Score":0,"Answer":"In command prompt you need to navigate to the file location. In your case it is in C:\\ drive, so type:\n\ncd C:\\\n\nand then proceed to run your program:\n\npython test.py\n\nor you could do it in one line:\n\npython C:\\test.py","Q_Score":0,"Tags":"python,cmd,interpreter","A_Id":40829271,"CreationDate":"2016-11-27T12:54:00.000","Title":"Running a python program in Windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When running my kivy app on Android Kivy Launcher it crashes instantly. I've looked everywhere for the logs, but couldn't find them. No .kivy folder is created, apps that view android logcat require root access and I couldn't get working adb logcat. Can someone explain to me how to use adb logcat to catch the error, or state another solution to my problem?\nPS: The app uses kivy 1.9.1 and py 3.4.4, runs fine on windows and my cellphone is a Xperia Z5 running Android Marshmallow 6.0.1","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1259,"Q_Id":40830517,"Users Score":2,"Answer":"Finally figured out how to use adb logcat. Install android studio 2.2. Connect your device to the PC via USB and enable debugging mode in the developer options. cd in command prompt to C:\\Users[user]\\AppData\\Local\\Android\\sdk\\platform-tools, and run adb devices. If the serial number of your android device appears, you're good to go. Then run adb logcat while executing the kivy app in your phone, and you'll get the realtime logs.","Q_Score":1,"Tags":"android,python,kivy,crash-reports","A_Id":40833444,"CreationDate":"2016-11-27T15:21:00.000","Title":"Cant find kivy logs when running with Kivy Launcher","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm trying to get the items (and their count) that were inserted in the last 24 hours using happybase. All I can think of is to use the timestamp to do that, but I couldn't figure out how to do that.\nI can connect to hbase","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":862,"Q_Id":40837982,"Users Score":0,"Answer":"the hbase data model does not offer that efficiently without encoding the timestamp as a prefix of the row key, or using a second table as a secondary index. read up on hbase schema design, your use case is likely covered in sections on time series data.","Q_Score":0,"Tags":"python,hbase,happybase","A_Id":41020057,"CreationDate":"2016-11-28T05:59:00.000","Title":"How to scan between two timestamps range using happybase?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to install my own package in my local dir (I do not have the root privilege). How to install python3-dev locally?\nI am using ubuntu 16.04.","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":2282,"Q_Id":40840480,"Users Score":-1,"Answer":"I think you have to build it yourself from source... You can easily find a guide for that if you google it.","Q_Score":2,"Tags":"python,python-3.x,ubuntu","A_Id":40840607,"CreationDate":"2016-11-28T09:03:00.000","Title":"python3: how to install python3-dev locally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":933,"Q_Id":40851318,"Users Score":0,"Answer":"You could do any of these: 1) read the string from a file, 2) read the string from a database, 3) pass the string as a command line argument","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":40851410,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":933,"Q_Id":40851318,"Users Score":0,"Answer":"One option is to use asymmetric encryption, you can request the private string from a server using it (see SSL\/TLS).\nIf you want to do it locally you should write\/read to a file (OS should take care of authorization, by means of user access)","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":40851444,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":933,"Q_Id":40851318,"Users Score":0,"Answer":"If you want to hide it, Encrypt it, you see this alot on github where people accidently post their aws keys or what not to github because they didnt use it as a \"secret\".\nalways encrypt important data, never use hardcoded values like ip as this can easily be changed, some sort of dns resolver can help to keep you on route.\nin this specific case you mentioned using a DNS to point to a proxy will help to mask the endpoint ip.","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":43877881,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software.\nI heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him.\nSo, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","AnswerCount":4,"Available Count":4,"Score":1.2,"is_accepted":true,"ViewCount":933,"Q_Id":40851318,"Users Score":1,"Answer":"There are several ways to obscure a hard-coded string. One of the simplest is to XOR the bits with another string or a repeated constant. Thus you could have two hardcoded short arrays that, when XORed together, produce the string you want to obscure.","Q_Score":0,"Tags":"python,string,hardcoded","A_Id":40852193,"CreationDate":"2016-11-28T18:44:00.000","Title":"How to not hardcode a String in a software?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I have some comp html files designer gave me and I want to just use it right away in a web2py website running on 127.0.0.1, with web2py MVC structure, how can I achieve that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":110,"Q_Id":40856714,"Users Score":2,"Answer":"web2py serves static files from the application's \/static folder, so just put the files in there. If you need to generate links to them, you can use the URL helper: URL('static', 'path\/to\/static_file.html') (where the second argument represents the path within the \/static folder).","Q_Score":0,"Tags":"python,web,web2py","A_Id":40870054,"CreationDate":"2016-11-29T02:14:00.000","Title":"How to visit html static site inside web2py project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a new module that save history of a record when someone edit it but doesn't find out any documents regards how to catch an edit action. Does anyone know how to do it ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":299,"Q_Id":40864539,"Users Score":1,"Answer":"if you don't want to use the models in the addons store, You can create a new class inherit from models.Model and overrid the create and write method to save audit in another model and create new Model that inherit the new model not the models.Model class this when ever a create or write is happen it will call the create and write of the parent class not the create","Q_Score":1,"Tags":"python,openerp,odoo-9","A_Id":40881979,"CreationDate":"2016-11-29T11:16:00.000","Title":"How can I \"catch\" action edit in odoo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Right, i have a bot that has 2 shards, each on their own server. I need a way to share data between the two, preferably as files, but im unsure how to achieve this.\n\nThe bot is completely python3.5 based\nThe servers are both running Headless Debian Jessie\nThe two servers arent connected via LAN, so this has to be sharing data over the internet\nThe data dosent need to be encrypted, as no sensitive data is shared","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":40898087,"Users Score":0,"Answer":"Probably the easiest to achive, that is also secure is to use sshfs between the servers.","Q_Score":0,"Tags":"debian,python-3.5,file-sharing","A_Id":40911268,"CreationDate":"2016-11-30T20:58:00.000","Title":"Share data between two scripts on different servers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need some orientation for a problem I\u2019m trying to solve. Anything would be appreciated, a keyword to Google or some indication !\nSo I have a list of 5 items. All items share the same features, let\u2019s say each item has 3 features for the example.\nI pass the list to a ranking function which takes into account the features of every item in the list and returns an arbitrary ordered list of these items.\nFor example,  if I give the following list of items (a, b, c, d, e) to the ranking function, I get (e, a, b, d, c).\nHere is the thing, I don\u2019t know how the ranking function works. The only things I have is the list of 5 items (5 is for the example, it could be any number greater than 1), the features of every item and the result of the ranking function.\nThe goal is to train a model which outputs an ordered list of 5 items the same way the ranking function would have done it.\nWhat ML model can I use to support this notion of ranking ? Also, I can\u2019t determine if it is a classification or a regression problem. I\u2019m not trying to determine a continuous value or classify the items, I want to determine how they rank compared to each other by the ranking function.\nI have to my disposition an infinite number of items since I generate them myself. The ranking function could be anything but let\u2019s say it is :\nattribute a score = 1\/3 * ( x1 + x2 + x3 ) to each item and sort by descending score\nThe goal for the model is to guess as close as possible what the ranking function is by outputting similar results for the same batch of 5 items.\nThanks in advance !","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":1288,"Q_Id":40942391,"Users Score":2,"Answer":"Since there's an unknown function that generates the output, it's a regression problem. Neural network with 2 hidden layers and e.g. sigmoid can learn any arbitrary function.","Q_Score":2,"Tags":"python,machine-learning","A_Id":40942885,"CreationDate":"2016-12-02T23:25:00.000","Title":"ML model to predict rankings (arbitrary ordering of a list)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need some orientation for a problem I\u2019m trying to solve. Anything would be appreciated, a keyword to Google or some indication !\nSo I have a list of 5 items. All items share the same features, let\u2019s say each item has 3 features for the example.\nI pass the list to a ranking function which takes into account the features of every item in the list and returns an arbitrary ordered list of these items.\nFor example,  if I give the following list of items (a, b, c, d, e) to the ranking function, I get (e, a, b, d, c).\nHere is the thing, I don\u2019t know how the ranking function works. The only things I have is the list of 5 items (5 is for the example, it could be any number greater than 1), the features of every item and the result of the ranking function.\nThe goal is to train a model which outputs an ordered list of 5 items the same way the ranking function would have done it.\nWhat ML model can I use to support this notion of ranking ? Also, I can\u2019t determine if it is a classification or a regression problem. I\u2019m not trying to determine a continuous value or classify the items, I want to determine how they rank compared to each other by the ranking function.\nI have to my disposition an infinite number of items since I generate them myself. The ranking function could be anything but let\u2019s say it is :\nattribute a score = 1\/3 * ( x1 + x2 + x3 ) to each item and sort by descending score\nThe goal for the model is to guess as close as possible what the ranking function is by outputting similar results for the same batch of 5 items.\nThanks in advance !","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1288,"Q_Id":40942391,"Users Score":1,"Answer":"It could be treated as a regression problem with the following trick: You are given 5 items with 5 feature vectors and the \"black box\" function outputs 5 distinct scores as [1, 2, 3, 4, 5]. Treat these as continuous values. So, you can think of your function as operating by taking five distinct input vectors x1, x2, x3, x4, x5 and outputting five scalar target variables t1, t2, t3, t4, t5 where the target variables for your training set are the scores the items get. For example, if the ranking for a single sample is (x1,4), (x2,5), (x3,3), (x4,1), (x5,2) then set t1=4, t2=5, t3=3, t4=1 and t5=2. MLPs have the \"universal approximation\" capability and given a black box function, they can approximate it arbitrarily close, dependent on the hidden unit count. So, build a 2 layer MLP with the inputs as the five feature vectors and the outputs as the five ranking scores. You are going to minimize a sum of squares error function, the classical regression error function. And don't use any regularization term, since you are going to try to mimic a deterministic black fox function, there is no random noise inherent in the outputs of that function, so you shouldn't be afraid of any overfitting issues.","Q_Score":2,"Tags":"python,machine-learning","A_Id":40947117,"CreationDate":"2016-12-02T23:25:00.000","Title":"ML model to predict rankings (arbitrary ordering of a list)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running python program using Linux operating system and i want to know how much total memory used for this process. Is there any way to determine the total memory usage  ?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":494,"Q_Id":40947387,"Users Score":0,"Answer":"You can just open task manager and look how much ram does it take. I use Ubuntu and it came preinstalled.","Q_Score":0,"Tags":"python,memory,memory-management","A_Id":40947523,"CreationDate":"2016-12-03T11:46:00.000","Title":"total memory used by running python code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to write a semi transparent click trough program to use like onion skin over my 3d application.\nthe one thing I couldn't find googling is how to make the window click trough. is there an attribute or something for it in tkinter? or maybe some way around it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":40957941,"Users Score":0,"Answer":"You can use PyAutoGUI and Tkinter to:\n\nGet current mouse position relative to desktop coordinates.\nMinimize tkinter window or drag it out of the screen.\nSimulate click event when the window will be hidden.\nReturn back tkinter window.\n\nIt should work but I'm not sure how fast would it be.","Q_Score":0,"Tags":"python-3.x,tkinter","A_Id":54459365,"CreationDate":"2016-12-04T11:06:00.000","Title":"python 3.4 tkinter, click trough window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In tensorflow,we may see these codes.\nembeddings=tf.Variable(tf.random_uniform([vocabulary_size,embedding_size],-1.0,1.0))\nembed=tf.nn.embedding_lookup(embeddings,train_inputs)\nWhen tensorflow is training,does embedding matrix remain unchanged?\nIn a blog,it is said that embedding matrix can update.I wonder how does it work.Thanks a lot !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":40959177,"Users Score":0,"Answer":"Embedding matrix is similar to any other variable. If you set the trainable flag to True it will train it (see tf.Variable)","Q_Score":0,"Tags":"python,tensorflow,deep-learning","A_Id":40960903,"CreationDate":"2016-12-04T13:34:00.000","Title":"In tensorflow,does embedding matrix remain unchanged?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way to find all the roots of a function using something on the lines of the bisection algorithm?\nI thought of checking on both sides of the midpoint in a certain range but it still doesn't seem to guarantee how deep I would have to go to be able to know if there is a root in the newly generated range; also how would I know how many roots are there in a given range even when I know that the corresponding values on applying the function are of opposite sign?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1208,"Q_Id":40960079,"Users Score":1,"Answer":"The bisection algorithm can be used to find a root in a range where the function is monotonic. You can find such segments by studying the derivative function, but in the general case, no assumptions can be made as to the monotonicity of a given function over any range.\nFor example, the function f(x) = sin(1\/x) has an infinite number of roots between -1 and 1.  To enumerate these roots, you must first determine the ranges where it is monotonic and these ranges become vanishingly small as x comes closer to 0.","Q_Score":0,"Tags":"python,c++,c,algorithm","A_Id":40960224,"CreationDate":"2016-12-04T15:15:00.000","Title":"Bisection algorithm to find multiple roots","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python script, that needs to load a large file from disk to a variable. This takes a while. The script will be called many times from another application (still unknown), with different options and the stdout will be used. Is there any possibility to avoid reading the large file for each single call of the script?\nI guess i could have one large script running in the background that holds the variable. But then, how can I call the script with different options and read the stdout from another application?","AnswerCount":4,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2241,"Q_Id":40969733,"Users Score":4,"Answer":"Make it a (web) microservice: formalize all different CLI arguments as HTTP endpoints and send requests to it from main application.","Q_Score":1,"Tags":"python,variables,memory,ipc,ram","A_Id":40969773,"CreationDate":"2016-12-05T08:09:00.000","Title":"Keeping Python Variables between Script Calls","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am now studying and developing a CANopen client with a python stack and i'm struggling to find out how to communicate with a slave Modbus through a gateway.\nSince the gateway address is the one present in the Object Dictionary of the CANopen, and the Gateway has addresses of modbus Slaves I\/O, how to specify the address of the modbus input ?\nAs i can see it CANopen uses the node-ID to select the server and an address to select the property to read\/write, but in this case i need to go farther than that and point an input.\njust to be clear i'm in the \"studying\" phase i have no CANopen\/Modbus gateway in mind. \nRegards.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":339,"Q_Id":40974077,"Users Score":0,"Answer":"This will be the gateway's business to fix. There is no general answer, nor is there a standard for how such gateways work. Gateways have some manner of software that allows you to map data between the two field buses. In this case I suppose it would be either a specific CANopen PDO or a specific CAN id that you map to a Modbus address. \nIn case you are just writing a CANopen client, neither you or the firmware  should need to worry about Modbus. Just make a CANopen node that is standard compliant and let the gateway deal with the actual protocol conversion. \nYou may however have to do the PDO mapping in order to let your client and the gateway know how to speak with each other, but that should preferably be a user-level configuration of the finished product, rather than some hard-coded mapping.","Q_Score":0,"Tags":"python,modbus,can-bus,canopen","A_Id":41042839,"CreationDate":"2016-12-05T12:15:00.000","Title":"How does CANopen client communicate with Modbus slave through CANopen\/Modbus gateway ?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been researching the past few days on how to achieve this, to no avail.\nI have a JSON file with a large array of json objects like so:\n[{\n    \"tweet\": \"@SHendersonFreep @realDonaldTrump watch your portfolios go to the Caribbean banks and on to Switzerland. Speculation without regulation\",\n    \"user\": \"DGregsonRN\"\n},{\n    \"tweet\": \"RT @CodeAud: James Mattis Vs Iran.\\n\\\"The appointment of Mattis by @realDonaldTrump got the Iranian military leaders' more attention\\\". https:\\u2026\",\n    \"user\": \"American1765\"\n},{\n    \"tweet\": \"@realDonaldTrump the oyou seem to be only fraud I see is you, and seem scared since you want to block the recount???hmm cheater\",\n    \"user\": \"tgg216\"\n},{\n    \"tweet\": \"RT @realDonaldTrump: @Lord_Sugar Dopey Sugar--because it was open all season long--you can't play golf in the snow, you stupid ass.\",\n    \"user\": \"grepsalot\"\n},{\n    \"tweet\": \"RT @Prayer4Chandler: @realDonaldTrump Hello Mr. President, would you be willing to meet Chairman #ManHeeLee of #HWPL to discuss the #PeaceT\\u2026\",\n    \"user\": \"harrymalpoy1\"\n},{\n    \"tweet\": \"RT @realDonaldTrump: Thank you Ohio! Together, we made history \\u2013 and now, the real work begins. America will start winning again! #AmericaF\\u2026\",\n    \"user\": \"trumpemall\"\n}]\nAnd I am trying to access each key and value, and write them to a csv file. I believe using json.loads(json.dumps(file)) should work in normal json format, but because there is an array of objects, I can't seem to be able to access each individual one.\nconverter.py:\n\n\n    import json\n    import csv\n\n    f = open(\"tweets_load.json\",'r')\n    y = json.loads(json.dumps(f.read(), separators=(',',':')))\n    t = csv.writer(open(\"test.csv\", \"wb+\"))\n\n    # Write CSV Header, If you dont need that, remove this line\n    t.writerow([\"tweet\", \"user\"])\n\n    for x in y:\n       t.writerow([x[0],x[0]])\n\n\ngrab_tweets.py:\n\n\n    import tweepy\n    import json\n\n    def get_api(cfg):\n      auth = tweepy.OAuthHandler(cfg['consumer_key'], cfg['consumer_secret'])\n      auth.set_access_token(cfg['access_token'], cfg['access_token_secret'])\n      return tweepy.API(auth)\n\n    def main():\n\n      cfg = {\n        \"consumer_key\"        : \"xxx\",\n        \"consumer_secret\"     : \"xxx\",\n        \"access_token\"        : \"xxx\",\n        \"access_token_secret\" : \"xxx\"\n        }\n      api = get_api(cfg)\n      json_ret = tweepy.Cursor(api.search, q=\"@realDonaldTrump\",count=\"100\").items(100)\n      restapi =\"\"\n      for tweet in json_ret:\n          rest = json.dumps({'tweet' : tweet.text,'user' :str(tweet.user.screen_name)},sort_keys=True,indent=4,separators=(',',': '))\n          restapi = restapi+str(rest)+\",\"\n      f = open(\"tweets.json\",'a')\n      f.write(str(restapi))\n      f.close()\n\n    if __name__ == \"__main__\":\n      main()\n\n\nThe output so far is looking like: \ntweet,user^M\n{,{^M\n\"\n\",\"\n\"^M\n , ^M\n , ^M\n , ^M\n , ^M\n\"\"\"\",\"\"\"\"^M\nt,t^M\nw,w^M\ne,e^M\ne,e^M\nt,t^M\n\"\"\"\",\"\"\"\"^M\n:,:^M\n , ^M\n\"\"\"\",\"\"\"\"^M\nR,R^M\nT,T^M\n , ^M\n@,@^M\nr,r^M\ne,e^M\na,a^M\nl,l^M\nD,D^M\no,o^M\nn,n^M\na,a^M\nl,l^M\n\n\nWhat exactly am I doing wrong?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1675,"Q_Id":40976901,"Users Score":0,"Answer":"turns out it was the json.dumps(), should've read more into what it does! Thanks.","Q_Score":0,"Tags":"python,json,csv","A_Id":40977897,"CreationDate":"2016-12-05T14:46:00.000","Title":"Access key value from JSON array of objects Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering about this, so I did quite a bit of google searches, and came up with the SetWrapMode(self, mode) function. However, it was never really detailed, and there was nothing that really said how to use it. I ended up figuring it out, so I thought I'd post a thread here and answer my own question for anyone else who is wondering how to make an stc.StyledTextCtrl() have word wrap.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":265,"Q_Id":40980163,"Users Score":0,"Answer":"It would be more maintainable to use the constants stc.WRAP_NONE, stc.WRAP_WORD, stc.WRAP_CHAR and stc.WRAP_WHITESPACE instead of their numerical values.","Q_Score":1,"Tags":"python-2.7,wxpython,word-wrap","A_Id":64083696,"CreationDate":"2016-12-05T17:42:00.000","Title":"How to set up word wrap for an stc.StyledTextCtrl() in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering about this, so I did quite a bit of google searches, and came up with the SetWrapMode(self, mode) function. However, it was never really detailed, and there was nothing that really said how to use it. I ended up figuring it out, so I thought I'd post a thread here and answer my own question for anyone else who is wondering how to make an stc.StyledTextCtrl() have word wrap.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":265,"Q_Id":40980163,"Users Score":0,"Answer":"I see you answered your own question, and you are right in every way except for one small detail. There are actually several different wrap modes. The types and values corresponding to them are as follows:\n\n0: None\n1: Word Wrap\n2: Character Wrap\n3: White Space Wrap\n\nSo you cannot enter any value above 0 to get word wrap. In fact if you enter a value outside of the 0-3 you should just end up getting no wrap as the value shouldn't be recognized by Scintilla, which is what the stc library is.","Q_Score":1,"Tags":"python-2.7,wxpython,word-wrap","A_Id":40986021,"CreationDate":"2016-12-05T17:42:00.000","Title":"How to set up word wrap for an stc.StyledTextCtrl() in wxPython","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Currently, I am doing a project about Nao Robot. I am having problem with importing the python class file into choregraphe. So anyone knows how to do this? \nError message\n\n[ERROR] behavior.box :init:8 _Behavior__lastUploadedChoregrapheBehaviorbehavior_127183361\u200c\u200b6__root__RecordSound\u200c\u200b_3__RecSoundFile_4: ALProxy::ALProxy Can't find service:","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":272,"Q_Id":40989958,"Users Score":0,"Answer":"You can add any path to the PYTHONPATH environment variable from within your behavior. However, this has bad side effects, like:\n\nIf you forget to remove the path from the environment right after importing your module, you won't know anymore where you are importing modules from, since there is only one Python context for the whole NAOqi and all the behaviors.\nFor the same reason (a single Python context), you'll need to restart NAOqi if you change the module you are trying to import.","Q_Score":0,"Tags":"python,ibm-cloud,nao-robot","A_Id":41919816,"CreationDate":"2016-12-06T07:26:00.000","Title":"How to import IBM Bluemix Watson speech-to-text in Choregraphe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just got started with pycharm and was wondering how can I simply copy a file in pycharm for editing purposes? For instance, I have a file opened, want to edit the code but want to make sure that I do not accidentally \"over-save\" the original file. \nIn other environments, I can simply right click the file, and copy it to a new file. I do not see a 'copy to new file' option in pycharm, but instead I do have to manually open a new file (File>New>Python..), and then manually copy all the code from the original file and paste it in the empty new file.\nAm I missing something or is that not possible in pycharm?","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":2801,"Q_Id":41005047,"Users Score":6,"Answer":"Select the file in the Project or Project Files pane and then hit File>Save as... The save-as dialog that pops up has an option (checked by default) to \"open copy in editor\". Not exactly what you asked for but it's the easiest way I could find.","Q_Score":9,"Tags":"python,pycharm","A_Id":41005483,"CreationDate":"2016-12-06T21:15:00.000","Title":"Pycharm - how can I copy a file (tab) in pycharm (to a new tab)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just got started with pycharm and was wondering how can I simply copy a file in pycharm for editing purposes? For instance, I have a file opened, want to edit the code but want to make sure that I do not accidentally \"over-save\" the original file. \nIn other environments, I can simply right click the file, and copy it to a new file. I do not see a 'copy to new file' option in pycharm, but instead I do have to manually open a new file (File>New>Python..), and then manually copy all the code from the original file and paste it in the empty new file.\nAm I missing something or is that not possible in pycharm?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2801,"Q_Id":41005047,"Users Score":7,"Answer":"If I understood well, you are looking for to a something similar duplicate functionality.\nSo to do this, you can simply go to the project structure (the panel to the left) and copy the file in this way:\n\nsimply Ctrl + c\nRight click on choosen file > Copy\n\nAfter this, paste your file in the directory that you want in this way:\n\nsimply Ctrl + v\nRight click on choosen directory  > Paste\n\nIn this way you have the possibility to duplicate the choosen file with another name.","Q_Score":9,"Tags":"python,pycharm","A_Id":41005579,"CreationDate":"2016-12-06T21:15:00.000","Title":"Pycharm - how can I copy a file (tab) in pycharm (to a new tab)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get pySerial to communicate with a microcontroller over an FTDI lead at a baud rate of 500,000. I know my microcontroller and FTDI lead can both handle it as can my laptop itself, as I can send to a putty terminal at that baud no problem. However I don't get anything when I try to send stuff to my python script with pySerial, although the same python code works with a lower baud rate.\nThe pySerial documentation says:\n\"The parameter baudrate can be one of the standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200. These are well supported on all platforms.\nStandard values above 115200, such as: 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000 also work on many platforms and devices.\"\nSo, I'm assuming why it's not working is because my system doesn't support it, but how do I check what values my system supports\/is there anything I can do to make it work? I unfortunately do need to transmit at least 250,000 and at a nice round number like 250,000 or 500000 (to do with clock error on the microcontroller).\nThanks in advance for your help!","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":3411,"Q_Id":41022923,"Users Score":2,"Answer":"So I found that the rounded numbers didn't work i.e. 100000, 200000, 250000 but the multiples of 115200 do. i.e. 230400, 460800\nI tried to use 230400 at first but the baud rate my microcontroller can produce is either 235294 or 222222. 235294 yields an error of -2.1% and 222222 yields an error of 3.55%. I naturally picked the one with the lower error however it didn't work and didn't bother trying 222222. For some reason 222222 works when 235294 though. So I don't actually have to use the 250000 baud rate I initially thought I'd have to.\nI still don't know why pyserial doesn't work with those baud rates when putty does, so clearly my laptop can physically do it. Anyway will know in future to try more standard baud rates as well as when using microcontrollers which can't produce the exact baud rate required to try frequencies both above and below.","Q_Score":3,"Tags":"python,pic,pyserial,ftdi","A_Id":41058265,"CreationDate":"2016-12-07T16:45:00.000","Title":"PySerial - Max baud rate for platform (windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I currently have a Python program which reads a local file (containing a pickled database object) and saves to that file when it's done. I'd like to branch out and use this program on multiple computers accessing the same database, but I don't want to worry about synchronizing the local database files with each other, so I've been considering cloud storage options. Does anyone know how I might store a single data file in the cloud and interact with it using Python? \nI've considered something like Google Cloud Platform and similar services, but those seem to be more server-oriented whereas I just need to access a single file on my own machines.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":41031326,"Users Score":0,"Answer":"You could install gsutil and the boto library and use that.","Q_Score":0,"Tags":"python,database,file,cloud,storage","A_Id":41031479,"CreationDate":"2016-12-08T03:33:00.000","Title":"Access a Cloud-stored File using Python 3?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote an optimization function in Julia 0.4 and I want to call it from Python. I'm storing the function in a .jl file in the same working directory as the Python code. The data to be transferred is numeric, and I think of using Numpy arrays and Julia arrays for calls. Is there a tutorial on how to make this work?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":569,"Q_Id":41041998,"Users Score":2,"Answer":"In my experience, calling Julia using the Python pyjulia package is difficult and not a robust solution outside HelloWorld usage.  \n1) pyjulia is very neglected. \nThere is practically no documentation aside the source code. For example, the only old tutorials I've found still use julia.run() that was replaced by julia.eval(). pyjulia is not registered on PyPI, the Python Package Index. Many old issues have few or no responses. And buggy, particularly with heavy memory usage and you could run into mysterious segfaults. Maybe, garbage collector conflicts...\n2) You should limit pyjulia use to Julia functions that return simple type\nJulia objects imported to python using pyjulia are difficult to use. pyjulia doesn't import any type constructors. For example, pyjulia seems to convert complex Julia types into plain python matrix.\n3) If you can isolate the software modules and manage the I\/O, you should consider the shell facility, particularly in Linux \/ Unix environment.","Q_Score":1,"Tags":"python,julia","A_Id":45740595,"CreationDate":"2016-12-08T14:37:00.000","Title":"Calling a Julia 0.4 function from Python. How i can make it work?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to find a way that I can have a program step through Python code line by line and do something with the results of each line.  In effect a debugger that could be controlled programmatically rather than manually.  pdb would be exactly what I am looking for if it returned its output after each step as a string and I could then call pdb again to pickup where I left off.  However, instead it outputs to stdout and I have to manually input \"step\" via the keyboard.\nThings I have tried:\n\nI am able to redirect pdb's stdout.  I could redirect it to a second\nPython program which would then process it.  However, I cannot\nfigure out how to have the second Python program tell pdb to\nstep.\nRelated to the previous one, if I could get pdb to step all the way\nthrough to the end (perhaps I could figure out something to spoof a\nkeyboard repeatedly entering \"step\"?) and redirect the output to a\nfile, I could then write another program that acted like it was\nstepping through the program when it was actually just reading the\nfile line by line.\nI could use exec to manually run lines of Python code.  However,\nsince I would be looking at one line at a time, I would need to\nmanually detect and handle things like conditionals, loops, and\nfunction calls which quickly gets very complicated.\nI read some posts that say that pdb is implemented using\nsys.settrace.  If nothing else works I should be able to recreate\nthe behavior I need using this.\n\nIs there any established\/straight forward way to implement the behavior that I am looking for?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1492,"Q_Id":41067947,"Users Score":1,"Answer":"I read some posts that say that pdb is implemented using sys.settrace.\n  If nothing else works I should be able to recreate the behavior I need\n  using this.\n\nDon't view this as a last resort. I think it's the best approach for what you want to accomplish.","Q_Score":2,"Tags":"python,interpreter,pdb","A_Id":41201288,"CreationDate":"2016-12-09T19:59:00.000","Title":"How to programmatically execute\/step through Python code line by line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to find a way that I can have a program step through Python code line by line and do something with the results of each line.  In effect a debugger that could be controlled programmatically rather than manually.  pdb would be exactly what I am looking for if it returned its output after each step as a string and I could then call pdb again to pickup where I left off.  However, instead it outputs to stdout and I have to manually input \"step\" via the keyboard.\nThings I have tried:\n\nI am able to redirect pdb's stdout.  I could redirect it to a second\nPython program which would then process it.  However, I cannot\nfigure out how to have the second Python program tell pdb to\nstep.\nRelated to the previous one, if I could get pdb to step all the way\nthrough to the end (perhaps I could figure out something to spoof a\nkeyboard repeatedly entering \"step\"?) and redirect the output to a\nfile, I could then write another program that acted like it was\nstepping through the program when it was actually just reading the\nfile line by line.\nI could use exec to manually run lines of Python code.  However,\nsince I would be looking at one line at a time, I would need to\nmanually detect and handle things like conditionals, loops, and\nfunction calls which quickly gets very complicated.\nI read some posts that say that pdb is implemented using\nsys.settrace.  If nothing else works I should be able to recreate\nthe behavior I need using this.\n\nIs there any established\/straight forward way to implement the behavior that I am looking for?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1492,"Q_Id":41067947,"Users Score":2,"Answer":"sys.settrace() is the fundamental building block for stepping through Python code.  pdb is implemented entirely in Python, so you can just look at the module to see how it does things.  It also has various public functions\/methods for stepping under program control, read the library reference for your version of Python for details.","Q_Score":2,"Tags":"python,interpreter,pdb","A_Id":41069302,"CreationDate":"2016-12-09T19:59:00.000","Title":"How to programmatically execute\/step through Python code line by line","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataframe in which one of the row is filled with string \"Error\"\nI am trying to add rows of 2 different dataframe. However, since I have the string in one of the row, it is concatenating the 2 strings. \nSo, I am having the dataframe filled with a row \"ErrorError\". I would prefer leaving this row empty than concatenating the strings.\nAny idea how to do it ? \nThanks\nkiran","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":41082675,"Users Score":1,"Answer":"You can fix resulting DataFrame using df.replace({'FieldName': {'ErrorError': ''}})","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":41082749,"CreationDate":"2016-12-11T03:25:00.000","Title":"Throw an exception while doing dataframe sum in Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I know how to actually install flask, via pip install Flask\nBut, I'm running a virtualenv with python3.4. The problem is, Flask is in fact installed. The problem is though, it is installed for python2.7 and not python3.4 .\nI did run this command with the virtualenv activated via source bin\/activate , but it seems to install it for python2.7 even though a virtualenv running python3.4 is activated.\nHow do I fix this? im pulling my hair out over this.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1368,"Q_Id":41091357,"Users Score":0,"Answer":"If you are using Pycharm just switch to python 3, and there is a list of packages installed. Hit add(+), and look for flask\nYou can switch to python 3 by hitting file-> setting -> Project:Projectname -> Project Interpreter","Q_Score":0,"Tags":"python,flask,dependencies,virtualenv","A_Id":41091835,"CreationDate":"2016-12-11T21:31:00.000","Title":"Install Flask in Python 3.4+ NOT for python2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I get this error \n\n\"ProgrammingError at \/admin\/\n  relation \"django_admin_log\" does not exist\n  LINE 1: ...\".\"app_label\", \"django_content_type\".\"model\" FROM \"django_ad...\"\n\ndjango_admin_log table does not exist in the database. Does anyone know how I can create it? I am not worried about deleting the data for my app.\nwhen i try '.\/manage.py sqlmigrate admin 0001' or '.\/manage.py sqlmigrate admin 0001'\ni get \n\"\nBEGIN;\n-- Create model LogEntry\nCREATE TABLE \"django_admin_log\" (\"id\" serial NOT NULL PRIMARY KEY, \"action_time\" timestamp with time zone NOT NULL, \"object_id\" text NULL, \"object_repr\" varchar(200) NOT NULL, \"action_flag\" smallint NOT NULL CHECK (\"action_flag\" >= 0), \"change_message\" text NOT NULL, \"content_type_id\" integer NULL, \"user_id\" integer NOT NULL);\nALTER TABLE \"django_admin_log\" ADD CONSTRAINT \"django_admin_content_type_id_c4bce8eb_fk_django_content_type_id\" FOREIGN KEY (\"content_type_id\") REFERENCES \"django_content_type\" (\"id\") DEFERRABLE INITIALLY DEFERRED;\nALTER TABLE \"django_admin_log\" ADD CONSTRAINT \"django_admin_log_user_id_c564eba6_fk_auth_user_id\" FOREIGN KEY (\"user_id\") REFERENCES \"auth_user\" (\"id\") DEFERRABLE INITIALLY DEFERRED;\nCREATE INDEX \"django_admin_log_417f1b1c\" ON \"django_admin_log\" (\"content_type_id\");\nCREATE INDEX \"django_admin_log_e8701ad4\" ON \"django_admin_log\" (\"user_id\");\nCOMMIT;\"\nbut i still get the same error? i use postgresql if anyone cares.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2274,"Q_Id":41094926,"Users Score":0,"Answer":"After .\/manage.py sqlmigrate admin 0001, please run python manage.py migrate.","Q_Score":1,"Tags":"python,django,django-admin","A_Id":47960936,"CreationDate":"2016-12-12T05:56:00.000","Title":"I accidentally deleted django_admin_log and now i can not use the django admin","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I get this error \n\n\"ProgrammingError at \/admin\/\n  relation \"django_admin_log\" does not exist\n  LINE 1: ...\".\"app_label\", \"django_content_type\".\"model\" FROM \"django_ad...\"\n\ndjango_admin_log table does not exist in the database. Does anyone know how I can create it? I am not worried about deleting the data for my app.\nwhen i try '.\/manage.py sqlmigrate admin 0001' or '.\/manage.py sqlmigrate admin 0001'\ni get \n\"\nBEGIN;\n-- Create model LogEntry\nCREATE TABLE \"django_admin_log\" (\"id\" serial NOT NULL PRIMARY KEY, \"action_time\" timestamp with time zone NOT NULL, \"object_id\" text NULL, \"object_repr\" varchar(200) NOT NULL, \"action_flag\" smallint NOT NULL CHECK (\"action_flag\" >= 0), \"change_message\" text NOT NULL, \"content_type_id\" integer NULL, \"user_id\" integer NOT NULL);\nALTER TABLE \"django_admin_log\" ADD CONSTRAINT \"django_admin_content_type_id_c4bce8eb_fk_django_content_type_id\" FOREIGN KEY (\"content_type_id\") REFERENCES \"django_content_type\" (\"id\") DEFERRABLE INITIALLY DEFERRED;\nALTER TABLE \"django_admin_log\" ADD CONSTRAINT \"django_admin_log_user_id_c564eba6_fk_auth_user_id\" FOREIGN KEY (\"user_id\") REFERENCES \"auth_user\" (\"id\") DEFERRABLE INITIALLY DEFERRED;\nCREATE INDEX \"django_admin_log_417f1b1c\" ON \"django_admin_log\" (\"content_type_id\");\nCREATE INDEX \"django_admin_log_e8701ad4\" ON \"django_admin_log\" (\"user_id\");\nCOMMIT;\"\nbut i still get the same error? i use postgresql if anyone cares.","AnswerCount":3,"Available Count":2,"Score":0.1325487884,"is_accepted":false,"ViewCount":2274,"Q_Id":41094926,"Users Score":2,"Answer":"experienced the same issue, the best way is to copy the CREATE TABLE log, login to your database .\/manage.py dbshell and Paste the content over there without adding the last line (COMMIT ) it will solve the problem and manually create the table for you.","Q_Score":1,"Tags":"python,django,django-admin","A_Id":60692503,"CreationDate":"2016-12-12T05:56:00.000","Title":"I accidentally deleted django_admin_log and now i can not use the django admin","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I know how to send email through Outlook\/Gmail using the Python SMTP library. However, I was wondering if it was possible to receive replys from those automated emails sent from Python.\nFor example, if I sent an automated email from Python (Outlook\/Gmail) and I wanted the user to be able to reply \"ok\" or \"quit\" to the automated email to either continue the script or kick off another job or something, how would I go about doing that in Python?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":308,"Q_Id":41107643,"Users Score":0,"Answer":"SMTP is only for sending. To receive (read) emails, you will need to use other protocols, such as POP3, IMAP4, etc.","Q_Score":0,"Tags":"python,email,outlook","A_Id":41108481,"CreationDate":"2016-12-12T18:57:00.000","Title":"Python SMTP Send Email and Receive Reply","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a usable tests for my package, but using Flask.test_client is so different from the requests API that I found it hard to use.\nI have tried to make requests.adapters.HTTPAdapter wrap the response, but it looks like werkzeug doesn't use httplib (or urllib for that matter) to build it own Response object.\nAny idea how it can be done? Reference to existing code will be the best (googling werkzeug + requests doesn't give any useful results)\nMany thanks!!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1360,"Q_Id":41108551,"Users Score":1,"Answer":"A PyPI package now exists for this so you can use pip install requests-flask-adapter.","Q_Score":11,"Tags":"python,python-requests,werkzeug","A_Id":59821311,"CreationDate":"2016-12-12T19:57:00.000","Title":"requests-like wrapper for flask's test_client","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to write a basic Flask app that limits the number of active logins a user can have, a la Netflix. I'm using the following strategy for now:\n\nUsing Flask_Security\nstore a active_login_count field for my User class.\nevery time a successful login request is completed, the app increases the active_login_count by 1. If doing so makes the count greater than the limit, it calls logout_user() instead.\n\nThis is a bad solution, because if the user loses her session (closed the incognito mode without logging out), the app hasn't been able to decrement her login count, and so, future logins are blocked.\nOne solution is to store the sessions on the server, but I don't know how I would go about authenticating valid sessions. Flask_Sessions is something I'm looking into, but I have no idea how to limit the number of active sessions.\nAs per my understanding, in the default configuration, Flask generates new session cookies on every request to prevent CSRF attacks. How would I go about doing that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1075,"Q_Id":41124843,"Users Score":0,"Answer":"There could be several ways off the top of my head you approach this, none of them striking a nice balance between simplicity and effectiveness:\nOne way could be to add a last_seen field to your User. Pick some arbitrary number(s) that could serve as a heuristic to determine whether someone is \"active\". Any sufficiently long gap in activity could trigger a reset of the active_login_count. This obviously has many apparent loopholes, the biggest I see at the moment being, users could simply coordinate logins and potentially rack up an unlimited number of active sessions without your application being any the wiser. It's a shame humans in general tend to use similar \"logical\" mechanisms to run their entire lives; but I digress...\nYou could make this approach more sophisticated by trying to track the user's active ip addresses. Add an active_ips field and populate a list of (n) ips, perhaps with some browser information etc to try and fingerprint users' devices and manage it that way.\nAnother way is to use an external service, such as a Redis instance or even a database. Create up to (n) session ids that are passed around in the http headers and which are checked every time the api is hit. No active session id, or if the next session id would constitute a breach of contract, no access to the app. Then you simply clear out those session ids at regular intervals to keep them fresh.\nHopefully that gives you some useful ideas.","Q_Score":3,"Tags":"python,authentication,flask,flask-security","A_Id":59997976,"CreationDate":"2016-12-13T15:32:00.000","Title":"How to limit number of active logins in Flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like some advice on how to best design a class and it's instance variables. I initialize the class with self.name. However, the main purpose of this class it to retrieve data from an API passing self.name as a parameter, and then parsing the data accordingly. I have a class method called fetch_data(self.name) that makes the API request and returns ALL data. I want to store this data into a class instance variable, and then call other methods on that variable. For example, get_emotions(json), get_personality_traits(json), and get_handle(json), all take the same dictionary as a parameter, assign it to their own local variables, and then manipulate it accordingly. \nI know I can make fetch_data(self.name) return data, and then call fetch_data(self.name) within the other methods, assign the return value to a local variable, and manipulate that. The problem is then I will need to call the API 5 times rather than 1, which I can't do for time and money reasons. \nSo, how do I make the result of fetch_data(self.name) global so that all methods within the class have access to the main data object? I know this is traditionally done in an instance variable, but in this scenario I can't initiliaze the data since I don't have it until after I call fetch_data(). \nThank you in advance!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1302,"Q_Id":41126100,"Users Score":0,"Answer":"Try to do it with self.data=None , or make an instance variable and call whenever you need. writing algorithm will make this thing more complex try to solve issue with inbuilt functions or with algorithm program vulnerability will affect alot.","Q_Score":0,"Tags":"python,class","A_Id":41126396,"CreationDate":"2016-12-13T16:35:00.000","Title":"How do I best store API data into a Python class instance variable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently in the process of learning how to use Python, and i'm trying to build a Monopoly simulator (for starters, I just want to simulate how one player moves about on the board). \nHow do i iteratively go through the list of board positions: eg. range(0, 39)? So, if the player is currently in position 35, and rolls a 6, he ends up in position 1. \nHopefully you're able to help! All the best :)","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":49,"Q_Id":41155765,"Users Score":1,"Answer":"You can just subtract the number rolled from distance from the player to the end of the board.\nif the difference is less than 0, send the player back to the start of the board and add the absolute value of the difference to the player's position.","Q_Score":2,"Tags":"python,arrays,list,loops,iteration","A_Id":41155912,"CreationDate":"2016-12-15T03:05:00.000","Title":"Iteratively searching through a looped list","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running Android Studio 2.2.3\nI need to run Python scripts during my development to process some data files. The final apk does not need to run Python in the device.\nAt the moment I run the scripts from a terminal or from PyDev for Eclipse, but I was looking for a way of doing it from Android Studio.\nThere seems to be a way to do this, as when I right-click on a .py file and select the 'Run' option, an 'Edit configuration' dialog opens where I can configure several options. The problem is that I cannot specify the Python interpreter, having to select it from a combo box of already configured Python SDKs. While there is no interpreter selected, there is an error message stating \"Error: Please select a module with a valid Python SDK\". \nI managed to create Java modules for my project, but not Python ones (I do have the Python Community Edition plugin installed).Does anybody know how to achieve this?.\nTIA.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25025,"Q_Id":41166406,"Users Score":6,"Answer":"If you only need to run the scripts and not to edit them, the easiest way to do so is to configure an external tool through Settings | Tools | External Tools. This doesn't require the Python plugin or any Python-specific configuration; you can simply specify the command line to execute. External tools appear as items in the Tools menu, and you can also assign keyboard shortcuts to them using Settings | Keymap.","Q_Score":9,"Tags":"python,android-studio","A_Id":41166600,"CreationDate":"2016-12-15T14:19:00.000","Title":"Running Python scripts inside Android Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So the issue is that apparently Django uses the sqlite3 that is included with python, I have sqlite3 on my computer and it works fine on its own. I have tried many things to fix this and have not found a solution yet.\nPlease let me know how I can fix this issue so that I can use Django on my computer.\n:~$ python\nPython 3.5.2 (default, Nov 6 2016, 14:10:16)\n[GCC 6.2.0 20161005] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\n>>> import sqlite3\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\n  File \"\/usr\/local\/lib\/python3.5\/sqlite3\/__init__.py\", line 23, in <module>\n    from sqlite3.dbapi2 import *\n  File \"\/usr\/local\/lib\/python3.5\/sqlite3\/dbapi2.py\", line 27, in <module>\n    from _sqlite3 import *\nImportError: No module named '_sqlite3'\n\n>>> exit()","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":197,"Q_Id":41177692,"Users Score":1,"Answer":"I figured out that this error was caused by me changing my python path to 3.5 from the default of 2.7.","Q_Score":0,"Tags":"linux,django,python-3.x,ubuntu,sqlite","A_Id":41196939,"CreationDate":"2016-12-16T05:17:00.000","Title":"How do I configure the sqlite3 module to work with Django 1.10?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The spider is to crawl info on a certain B2B website, and I want it to be a webserver, where user sumbit a url then the spider starts crawl.\nThe url seems like: apple.b2bxxx.com, which is a minisite on a B2B website, where all the products are listed. The \"apple\" might be different because different companies use different names for there minisite, and duplication is not allowed.\nOn the backend, it's MongoDB to store the data scraped.\nWhat I have done, is that, I can collect info on the given url, but all data are stored in the same db.collection.\nI know I can get parameters using \"-a\" for running scrapy, but how should I use it?\nShould I change the pipelines.py or the spider python file?\nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":79,"Q_Id":41179622,"Users Score":0,"Answer":"I've got an answer.\nfor example:\nusing -s collection_name=abc for scrapy crawl command, then get the parameter in pipelines.py using param = settings.get('collection_name').\nThis is also found in stackoverflow, but can't remember which ticket.\nHope this would help some one facing same problem.","Q_Score":0,"Tags":"python,mongodb,scrapy","A_Id":41194752,"CreationDate":"2016-12-16T07:52:00.000","Title":"Usa parameter as collection name in a scrapy project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using df= df.replace('No data', np.nan) on a csv file containing \u2018No data\u2019 instead of blank\/null entries where there is no numeric data. Using the head() method I see that the replace method does replace the \u2018No data\u2019 entries with NaN. When I use df.info() it says that the datatypes for each of the series is an object. \nWhen I open the csv file in Excel and manually edit the data using find and replace to change \u2018No data\u2019 to blank\/null entries, although the dataframes look exactly the same when I use df.head(), when I use df.info() it says that the datatypes are floats.\nI was wondering why this was and how can I make it so that the datatypes for my series are floats, without having to manually edit the csv files.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1782,"Q_Id":41198719,"Users Score":2,"Answer":"If the rest of the data in your columns is numeric then you should use pd.to_numeric(df, errors='coerce')","Q_Score":0,"Tags":"python,pandas,dataframe","A_Id":41200368,"CreationDate":"2016-12-17T12:47:00.000","Title":"Pandas replace method and object datatypes","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using Python Spacy, how to extract entity from simple passive voice sentence? In the follow sentence, my intention is to extract both \"John\u201d  from the sentence as nsubjpass and .ent_.\nsentence =  \"John was accused of crimes by David\"","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1693,"Q_Id":41200785,"Users Score":-1,"Answer":"Go through the spacy 2.0 nightly build. It should have the solution you're looking for.","Q_Score":2,"Tags":"python,nlp,nltk,spacy","A_Id":44993090,"CreationDate":"2016-12-17T16:40:00.000","Title":"Extract entities from Simple passive voice sentence by Python Spacy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When generating content using Pelican, everything is Ok except that I see in the footer \"Proudly powered by Pelican ...\"\nI want to get rid of it. I know I can remove it from the generated files manually, but that is tedious. \nIs there a way to prevent the generation of the above phrase by asking Pelican to do that for me? Some magic Pelican command or settings, maybe?","AnswerCount":4,"Available Count":2,"Score":-0.049958375,"is_accepted":false,"ViewCount":1230,"Q_Id":41221779,"Users Score":-1,"Answer":"Probably is not the answer you are looking for, but if you are already customizing the CSS, think about usgin CSS to hide the section.","Q_Score":1,"Tags":"python,pelican","A_Id":41222267,"CreationDate":"2016-12-19T11:39:00.000","Title":"how to automatically remove \"Powered by ...\" in Pelican CMS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When generating content using Pelican, everything is Ok except that I see in the footer \"Proudly powered by Pelican ...\"\nI want to get rid of it. I know I can remove it from the generated files manually, but that is tedious. \nIs there a way to prevent the generation of the above phrase by asking Pelican to do that for me? Some magic Pelican command or settings, maybe?","AnswerCount":4,"Available Count":2,"Score":0.1488850336,"is_accepted":false,"ViewCount":1230,"Q_Id":41221779,"Users Score":3,"Answer":"In your theme template, there will be a line like,\n{% extends \"!simple\/base.html\" %}\nThis base.html is used as the foundation for creating the theme. This file is available in : %PYTHON%\\Lib\\site-packages\\pelican\\themes\\simple\\templates\nYou can edit this file to remove the \"Powered By..\"","Q_Score":1,"Tags":"python,pelican","A_Id":47449423,"CreationDate":"2016-12-19T11:39:00.000","Title":"how to automatically remove \"Powered by ...\" in Pelican CMS?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to generate excel spreadsheets by python, the first few tabs are exactly same, all are refer to the last page, so how to insert the last page by openpyxl? because the first few tabs are too complex so load_workbook is always failed, is there have any other way to insert tabs without loading?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":41252907,"Users Score":0,"Answer":"As far as i know, openpyxl does not allow you to access only one cell, or a limited number of cells for that matter. In order to access any information in a given worksheet, openpyxl will create one in the memory. This is the reason for which you will be unable to add a Sheet without opening the entire document in memory and overwriting it at the end.","Q_Score":0,"Tags":"python,excel,openpyxl","A_Id":43180932,"CreationDate":"2016-12-20T23:33:00.000","Title":"How to use openpyxl to insert one sheet to a template?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am a noob to web and mqtt programming, I am working on a python application that uses mqtt (via hivemq or rabbitmq broker) and also needs to implement http rest api for clients.\nI realized using python bottle framework is pretty easy to provide a simple http server, however both bottle and mqtt have their event loop, how do I combine these 2 event loop, I want to have a single threaded app to avoid complexity.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":544,"Q_Id":41254715,"Users Score":1,"Answer":"I'm not familiar with bottle but a quick look at the docs it doesn't look like there is any other way to start it's event loop apart from with the run() function.\nPaho provides a loop_start() which will kick off it's own background thread to run the MQTT network event loop.\nGiven there looks to be no way to run the bottle loop manually I would suggest calling loop_start() before run() and letting the app run on 2 separate threads as there is no way to combine them and you probably wouldn't want to anyway.\nThe only thing to be careful of will be if MQTT subscriptions update data that the REST service is sending out, but as long as are not streaming large volumes of data that is unlikely to be an issue.","Q_Score":1,"Tags":"python,rabbitmq,mqtt,bottle,hivemq","A_Id":41259154,"CreationDate":"2016-12-21T03:40:00.000","Title":"Using http and mqtt together in a single threaded python app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to change my models in django\nwhen I execute python manage.py makemigrations ,it asks a question: \n\nDid you rename the demoapp.Myblog model to Blog? [y\/N] y^M^M^M\n\nthat I input y and press Enter,but it adds ^M to the line\nI've looked around and apparently but I've got no choices \ncan anybody tell me how to fix it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":786,"Q_Id":41254869,"Users Score":6,"Answer":"Better to reset the console frequently.\nThis is not a big problem but due to multiple terminals being not reset for long durations, such problem occurs.","Q_Score":9,"Tags":"python,django","A_Id":41256129,"CreationDate":"2016-12-21T04:00:00.000","Title":"django press Enter and it show ^M","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is closing a cursor needed when the shortcut conn.execute is used in place of an explicitly named cursor in SQLite?  If so how is this done?  Also, is closing a cursor only need for SELECT, when a recordset is returned, or is it also needed for UPDATE, etc.?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":41263383,"Users Score":0,"Answer":"The close() method allows you to close a cursor object before it is garbage collected.\nThe connection's execute() method is exactly the same as conn.cursor().execute(...), so the return value is the only reference to the temporary cursor object. When you just ignore it, CPython will garbage-collect the object immediately (other Python implementations might work differently).","Q_Score":1,"Tags":"python,sqlite,cursor","A_Id":41485462,"CreationDate":"2016-12-21T12:59:00.000","Title":"How does closing SQLite cursor apply when conn.execute is used in place of named cursor","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I researched up and down and I'm not seeing any answers that I'm quite understanding so I thought to post my own question.\nI building a web application (specifically in web2py but that shouldn't matter I don't believe) on Python 2.7 to be hosted on Windows.\nI have a list of about 2000 items in a database table.\nThe user will be opening the application which will initially select all 2000 items into Python and return the list to the user's browser.  After that the user will be filtering the list based on one-to-many values of one-to-many attributes of the items.\nI'm wanting Python to hold the unadulterated list of 2000 items in-memory between the user's changes of filtering options.\n\nEvery time the user changes their filter options,  \ntrip the change back to Python,\napply the filter to the in-memory list and\nreturn the subset to the user's browser.\n\nThis is to avoid hitting the database with every change of filter options.  And to avoid passing the list in session over and over.\nMost of this I'm just fine with.  What I'm seeking you advise on is how to get Python to hold the list in-memory.  In c# you would just make it a static object.\nHow do you do a static (or whatever other scheme that applies) in Python?\nThanks for your remarks.\n\nWhile proofreading this I see I'm still probably passing at least big portions of the list back and forth anyway so I will probably manage the whole list in the browser.\nBut I still like to hear you suggestions.  Maybe something you say will help.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35,"Q_Id":41266569,"Users Score":1,"Answer":"As you seem to conclude, there isn't much reason to be sending requests back and forth to the server given that the server isn't generating any new data that isn't already held in the browser. Just do all the filtering directly in the browser.\nIf you did need to do some manipulation on the server, though, don't necessarily assume it would be more efficient to search\/filter a large dataset in Python rather than querying the database. You should do some testing to figure out which is more efficient (and whether any efficiency gains are worth the hassle of adding complexity to your code).","Q_Score":0,"Tags":"python-2.7,web2py","A_Id":41273813,"CreationDate":"2016-12-21T15:38:00.000","Title":"Python 2.7 list of dictionaries in memory between page trips","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"when I use this code for extracting the date\ndateutil.parser.parse('today is 21 jan 2016')\nIt throws an error -> ValueError: unknown string format\nis there any way to extract dates and time from a sentence???","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1640,"Q_Id":41310316,"Users Score":1,"Answer":"There is! (Python is amazing)\ndateutil.parser.parse(\"today is 21 jan 2016\", fuzzy=True)","Q_Score":1,"Tags":"python,date,nlp","A_Id":41347322,"CreationDate":"2016-12-24T04:26:00.000","Title":"how to find unstructured date and time from a sentence in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using scikit-learn's linear_model.LogisticRegression to perform multinomial logistic regress. I would like to initialize the solver's seed value, i.e. I want to give the solver its initial guess as the coefficients' values.\nDoes anyone know how to do that?  I have looked online and sifted through the code too, but haven't found an answer.\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":493,"Q_Id":41346055,"Users Score":0,"Answer":"You can use the warm_start option (with solver not liblinear), and manually set coef_ and intercept_ prior to fitting.\n\nwarm_start : bool, default=False\nWhen set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. Useless for liblinear solver.","Q_Score":4,"Tags":"python,machine-learning,scikit-learn,logistic-regression","A_Id":66783030,"CreationDate":"2016-12-27T13:25:00.000","Title":"Feeding a seed value to solver in Python Logistic Regression","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to shuffle to inputted strings, and to mix together to jumble the two strings up.\nFor example \"hello\" and \"world\" shuffle together to become \"wherd llohe\"","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1312,"Q_Id":41347484,"Users Score":0,"Answer":"the hard way, \n\nget the ascii equivalent of each letter  \ngenerate a random letter between the range of highest and lowest ascii value  \njoin the random characters together","Q_Score":0,"Tags":"python","A_Id":41347592,"CreationDate":"2016-12-27T15:02:00.000","Title":"Anybody know how to shuffle two strings together?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Usually the main reason I'm using jupyter notebook with python is the possibility to initialize once (and only once) objects (or generally \"data\") that tend to have long (lets say more than 30 seconds) loading times. When my work is iterative, i.e. I run minimally changed version of some algorithm multiple times, the accumulated cost of repeated initialization can get large at end of a day.\nI'm seeking an alternative approach (allowing to avoid the cost of repeated initialization without using a notebook) for the following reasons:\n\nNo \"out of the box\" version control when using notebook.\nOccasional problems of \"I forgot to rename variable in a single place\". Everything keeps working OK until the notebook is restarted.\nUsually I want to have usable python module at the end anyway.\nSomehow when using a notebook I tend to get code that if far from \"clean\" (I guess this is more self discipline problem...).\n\nIdeal workflow should allow to perform whole development inside IDE (e.g. pyCharm; BTW linux is the only option). Any ideas?\nI'm thinking of implementing a simple (local) execution server that keeps the problematic objects pre-initialized as global variables and runs the code on demand (that uses those globals instead of performing initialization) by spawning a new process each time (this way those objects are protected from modification, at the same time thanks to those variables being global there is no pickle\/unpickle penalty when spawning new process). \nBut before I start implementing this - maybe there is some working solution or workflow already known?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":849,"Q_Id":41364326,"Users Score":1,"Answer":"Visual Studio Code + Python extension works fine (both Windows and Mac, not sure about Linux). Very fast and lightweight, Git integration, debugging refactorings, etc.\nAlso there is an IDE called Spyder that is more Python-specific. Also works fine but is more heavy-weight.","Q_Score":0,"Tags":"python,initialization,delay,jupyter-notebook","A_Id":41364412,"CreationDate":"2016-12-28T14:44:00.000","Title":"Alternative workflow to using jupyter notebook (aka how to avoid repetitive initialization delay)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have changed my application running with flask and python2.7 from a standalone solution to flask with apache and mod_wsgi.\nMy Flask app (app.py) includes some classes which are in the directory below my app dir (..\/).\nHere is my app.wsgi:\n\n\n    #!\/usr\/bin\/python\n    import sys\n    import logging\n    logging.basicConfig(stream=sys.stderr)\n    sys.stdout = sys.stderr\n    \n    \n    project_home = '\/opt\/appdir\/Application\/myapp'\n    project_web  = '\/opt\/appdir\/Application\/myapp\/web'\n    \n    \n    if project_home not in sys.path:\n        sys.path = [project_home] + sys.path\n    \n    if project_web not in sys.path:\n        sys.path = [project_web] + sys.path\n    \n    from app import app\n    application = app\n    \nBefore my configuration to mod_wsgi my main call in the app.py looks like that:\n\n\n    # Main\n    if __name__ == '__main__' :\n        from os import sys, path\n        sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))\n        from logger import Logger\n        from main import Main\n        from configReader import ConfigReader\n        print \"Calling flask\"\n        from threadhandler import ThreadHandler\n        ca = ConfigReader()\n        app.run(host=\"0.0.0.0\", threaded=True)\n\n\nI was perfectly able to load my classes in the directory below.\nAfter running the app with mod_wsgi I get the following error:\nglobal name \\'Main\\' is not defined\nSo how do I have to change my app that this here would work:\n\n\n    @app.route(\"\/\")\n    def test():\n       main = Main(\"test\")\n       return main.responseMessage()","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1008,"Q_Id":41381705,"Users Score":0,"Answer":"No main function call with mod_wsgi was the right answer. I do not implemented my required modules in the wsgi file,\nbut on top of the flask app.","Q_Score":0,"Tags":"python,flask,undefined,global,mod-wsgi","A_Id":41394185,"CreationDate":"2016-12-29T14:32:00.000","Title":"Flask with mod_wsgi - Cannot call my modules","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Situation:\nMy gimp python plug-in shows the user a drop down box with two options [\".jpg\", \".png\"].\nQuestion:\nHow to show a second input window with conditional content based on first input?\n\n.jpg --> \"Quality\" range slider [0 - 100]\n.png --> \"Compression\" range slider [0 - 9]\n\n\nIn different words:\nHow to trigger a (registered) plug-in WITH user-input-window from within the main function of a plug-in?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":404,"Q_Id":41409731,"Users Score":2,"Answer":"Either you build a full GUI with PyGTK (or perhaps tkinter) or you find another way. Typically for this if you stick to the auto-generated dialogs you have the choice between: \n\na somewhat clumsy dialog that asks for both parameters and will ignore one or the other depending of the image format, \ntwo menu entries for two different dialogs, one for PNG and one for JPG.\n\nOn the other hand, I have always use compression level 9 in my PNGs (AFAIK the only benefit of other levels is CPU time, but this is moot in modern machines) so your dialog could only ask for the JPEG quality which would mak it less clumsy.\nHowever... JPEG quality isn't all there is to it and there are actually many options (chroma sub-sampling being IMHO at least as important as quality), and to satisfy all needs you could end up with a rather complex dialog. So you could either:\n\nJust save with the current user's default settings (gimp_file_save())\nGet these settings from some .ini file (they are less likely to change than other parameters of your script)\nNot save the image and let the user Save\/Export to his\/her liking (if this isn't a batch processing script)","Q_Score":2,"Tags":"python,plugins,gimp,python-fu","A_Id":41410753,"CreationDate":"2016-12-31T15:43:00.000","Title":"gimp python plug in: how to trigger another user input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The django app running on localhost in a virtualenv uses the default python version 2.7.3 that is under \/usr\/bin\/ but I installed Python 2.7.9 under ~\/.opt\/bin\/python2.7. I updated the $PATH but I want the django app to use the locally installed python version by default.\nPlease help me understand how to make that happen. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":96,"Q_Id":41432445,"Users Score":1,"Answer":"Create a new virtualenv using Python 2.7.  Use the -p flag to point to the python installation you want for that virtual environment, and then pip install django within that virtual environment.","Q_Score":0,"Tags":"django,python-2.7","A_Id":41433294,"CreationDate":"2017-01-02T19:40:00.000","Title":"Updating which python my django app uses","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using the mysql.connector module with Python 2.7 and testing locally using XAMPP.  Whenever I upload my script to the server, I am getting an import error for the mysql.connector module.  I am assuming this is because, unlike my local machine, I have not installed the mysql.connector module on the server.  \nMy question is: can I somehow use the mysql.connector module on the server or is this something only for local development?  I have looked into it, and apparently do not have SSH access for my server, only for the database.  As well, if I cannot use the mysql.connector module, how do I connect to my MySQL database from my Python script on the server?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":41454355,"Users Score":0,"Answer":"You can use mysql.connector on the server. However, you will have to install it first. Do you have root (admin) access? If no, you might need help from the server admin.","Q_Score":0,"Tags":"python,mysql","A_Id":41454481,"CreationDate":"2017-01-04T00:17:00.000","Title":"Can you use Python mysql.connector on actual Server?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to  transform the string 'one two three' into one_two_three.\nI've tried \"_\".join('one two three'), but that gives me o_n_e_ _t_w_o_ _t_h_r_e_e_...\nhow do I insert the \"_\" only at spaces between words in a string?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":10301,"Q_Id":41476490,"Users Score":0,"Answer":"And if you want to use join only , so you can do like thistest=\"test string\".split() \n\"_\".join(test)\nThis will give you output as \"test_string\".","Q_Score":1,"Tags":"python,string","A_Id":41476538,"CreationDate":"2017-01-05T02:34:00.000","Title":"How to join() words from a string?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a micro-services architecture of let say 9 services, each one running in its own container.\nThe services use a mix of technologies, but mainly Django, Celery (with a Redis Queue), a shared PostgreSQL database (in its own container), and some more specific services\/libraries.\nThe micro-services talk to each other through REST API.\nThe problem is that, sometimes in a random way, some containers API doesn't respond anymore and get stuck. \nWhen I issue a curl request on their interface I get a timeout.\nAt that moment, all the other containers answer well.\nThere is two stucking containers. \nWhat I noticed is that both of the blocking containers use:\n\nDjango\ndjango-rest-framework\nCelery\ndjango-celery\nAn embedded Redis as a Celery broker\nAn access to a PostgreSQL DB that stands in another container\n\nI can't figure out how to troubleshoot the problem since no relevant information is visible in the Services or Docker logs.\nThe problem is that these API's are stuck only at random moments. To make it work again, I need to stop the blocking container, and start it again.\nI was wondering if it could be a python GIL problem, but I don't know how to check this hypothesis...\nAny idea about how to troubleshot this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":472,"Q_Id":41485251,"Users Score":0,"Answer":"You can shell into the running container and check things out. Is the celery process still running, etc...\ndocker exec -ti my-container-name \/bin\/bash\nIf you are using django, for example, you could go to your django directory and do manage.py shell and start poking around there.\nI have a similar setup where I run multiple web services using django\/celery\/celerybeat\/nginx\/...\nHowever, as a rule I run one process per container (kind of exception is django and gunicorn run in same container). I then share things by using --volumes-from. \nFor example, the gunicorn app writes to a .sock file, and the container has its own nginx config; the nginx container does a --volumes-from the django container to get this info. That way, I can use a stock nginx container for all of my web services.\nAnother handy thing for debugging is to log to stdout and use docker's log driver (splunk, logstash, etc.) for production, but have it log to the container when debugging. That way you can get a lot of information from 'docker logs' when you've got it under test. One of the great things about docker is you can take the exact code that is failing in production and run it under the microscope to debug it.","Q_Score":1,"Tags":"python,django,docker,containers,celery","A_Id":41668121,"CreationDate":"2017-01-05T12:33:00.000","Title":"Troubleshooting API timeout from Django+Celery in Docker Container","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I want to achieve is :\ntasks = [call(url) for url in urls]\ncall is an async method \/ coroutine in Python3.5 to perform GET requests , let's say aiohttp.\nSo basically all calls to call are async. Now I can run asyncio.wait(tasks) and later access the result in futures one by one.\nBUT, what I want is, lets assume there are 2 url only, then :\na, b = call(url1), call(url2)\nSomething like how you do it in Koa by yielding an array. Any help how to do this if it can be done ??","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":73,"Q_Id":41485507,"Users Score":1,"Answer":"var1, var2 = loop.run_until_complete(asyncio.gather(task1, task2))\nAccording to the docs, gather retains the order of the sequence it was passed","Q_Score":2,"Tags":"python,python-3.x,asynchronous,concurrency,python-asyncio","A_Id":41502152,"CreationDate":"2017-01-05T12:46:00.000","Title":"Set result of 2 or more Async HTTP calls into named variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used some of the codes such as\nclear cls clc but none of them gave me the desired result.\nIs there any command that can clear the screen of the idle?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":560,"Q_Id":41519202,"Users Score":-1,"Answer":"Press the key\nCtrl+F6\nthen you can restart the powershell.\nJust like the 'clear' used in terminal, it clears the all variables you've assigned values for.","Q_Score":0,"Tags":"python,python-3.4","A_Id":49356344,"CreationDate":"2017-01-07T07:56:00.000","Title":"how to clear the screen of the idle3(python3 shell)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Ok,  so I've looked around on how to do this and haven't really found an answer that showed me examples that I could work from. \nWhat I'm trying to do is have a script that can do things like:\n-Log into website\n-Fill out forms or boxes etc.\nSomething simple that might help me in that I though of would be for example if I could write a script that would let me log into one if those text message websites like textnow or something like that,  and then fill out a text message and send it to myself.  \nIf anyone knows a good place that explains how to do something like this,  or if anyone would be kind enough to give some guidance of their own then that would be greatly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":58,"Q_Id":41528141,"Users Score":1,"Answer":"So after some good answers and further research,  I have found that selenium is the thing that best suits my needs.  It works not only with python,  but supports other languages as well. If anyone else is looking for something that I had been when I asked the my question, a quick Google search for \"selenium\" should give them all the information they need about the tool that I found best for what I needed.","Q_Score":0,"Tags":"python,html,python-3.x,web","A_Id":44302397,"CreationDate":"2017-01-08T00:26:00.000","Title":"How to have python interact automatically with a web site","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python.\nI use putty to manage some servers. I want to use Python to create a Excel file on each server, for that I think if I can use some orders like ssh ip \"python abc.py\" to create the file. It is possible to write a bash script to manage all servers. This is the trouble I meet:\n\nThe servers can't use internet. \n\nAnd it is not allowed to use any third party libraries. When a linux(redhat 6.5) was installed, is there any library in python that can be used to create Excel immediately?\nPlease help me, thanks.","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":15636,"Q_Id":41550060,"Users Score":0,"Answer":"I am not sure if this is what the OP was looking for,but if you have to manipulate data in python without installing any modules (just standard library), you can try the sqlite3 module, which of course allows you to interact with sqlite files (a Relational Database Management System).\nThese databases are conceptually similar to an Excel file. If an excel file is basically a collection of sheets, with each sheet being a matrix where you can put data, sqlite databases are the same (but each \"matrix\" is called a table instead).\nThis format is scripting friendly, as you can read and write data using SQL, but it does not follow the client-server model other DBMS are based on. The whole database is contained in a single file that you can email to a colleague, and you can also install a GUI that gives you a spreadsheet like interface to make it more user-friendly (DB browser for SQLite is avaible for Windows, Linux and Mac).\nThis allows you to include SQL code in your python scripts, which adds a lot of data processing capabilities, and it is an excellent way to achieve data persistence for simple programs.","Q_Score":4,"Tags":"python,excel","A_Id":60421964,"CreationDate":"2017-01-09T14:21:00.000","Title":"how to create a excel file only with python standard library?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have recently started using a program which has command line interfaces accessed through the Mac Terminal. \nI am trying to automate the process whereby a series of commands are passed through the terminal using Python.\nSo far I have found a way to open the Terminal using the subprocess.Popen command but how do I then \"write\" in the terminal once it's open ?\nFor example what I am looking to do is;\n1. Open the Terminal App.\n2. Select a directory in the App.\n3. Run a command. In this instance the file I wish to run is called \"RunUX\" and what I want to type is \".\/RunUX ...\" followed by command line arguments. \nI'm fairly new to Python and programming and appreciate all help !!\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":379,"Q_Id":41568395,"Users Score":1,"Answer":"Thanks for the comments guys but I managed to figure it out. \nIn the end I used a combination of subprocess.Popen() and os.chdir() and it seems to work using Jupyter Notebook.","Q_Score":0,"Tags":"macos,python-3.x,terminal,subprocess","A_Id":41615003,"CreationDate":"2017-01-10T12:01:00.000","Title":"Manipulating the Terminal Using a Python Script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Python 3.3 includes in its standard library the new package venv. What does it do, and how does it differ from all the other packages that seem to match the regex (py)?(v|virtual|pip)?env?","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":438843,"Q_Id":41573587,"Users Score":56,"Answer":"Let's start with the problems these tools want to solve:\nMy system package manager don't have the Python versions I wanted or I want to install multiple Python versions side by side, Python 3.9.0 and Python 3.9.1, Python 3.5.3, etc\nThen use pyenv.\nI want to install and run multiple applications with different, conflicting dependencies.\nThen use virtualenv or venv. These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.\nI'm developing an \/application\/ and need to manage my dependencies, and manage the dependency resolution of the dependencies of my project.\nThen use pipenv or poetry.\nI'm developing a \/library\/ or a \/package\/ and want to specify the dependencies that my library users need to install\nThen use setuptools.\nI used virtualenv, but I don't like virtualenv folders being scattered around various project folders. I want a centralised management of the environments and some simple project management\nThen use virtualenvwrapper. Variant: pyenv-virtualenvwrapper if you also use pyenv.\n\nNot recommended\n\npyvenv. This is deprecated, use venv or virtualenv instead. Not to be confused with pipenv or pyenv.","Q_Score":1722,"Tags":"python,virtualenv,virtualenvwrapper,pyenv,python-venv","A_Id":65854168,"CreationDate":"2017-01-10T16:27:00.000","Title":"What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a project that involves a RandomWalk on a large graph(too big to fit in memory). I coded it in Python using networkx but soon, the graph became too big to fit in memory, and so I realised that I needed to switch to a distributed system. So, I understand the following:\n\nI will need to use a graph database as such(Titan, neo4j, etc)\nA graph processing framework such as Apache Giraph on hadoop\/ graphx on spark.\n\nFirstly, are there enough APIs to allow me to continue to code in Python, or should I switch to Java?\nSecondly, I couldn't find exact documentation on how I can write my custom function of traversal(in either Giraph or graphx) in order to implement the Random Walk algorithm.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":480,"Q_Id":41575620,"Users Score":0,"Answer":"My understanding is, you need to process large graphs which are stored on file systems. There are various distributed graph processing frameworks like Pregel, Pregel+, GraphX, GPS(Stanford), Mizan, PowerGraph etc. \nIt is worth taking a look at these frameworks. I will suggest coding in C, C++ using openMPI like which can help achieve better efficiency. \nFrameworks in Java are not very memory efficient. I am not sure of API of these frameworks in Python.\nIt is worth taking a look at blogs and papers which give a comparative analysis of these frameworks before deciding on implementing them.","Q_Score":0,"Tags":"python,hadoop,graph,random-walk,bigdata","A_Id":44357542,"CreationDate":"2017-01-10T18:15:00.000","Title":"Large graph processing on Hadoop","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a Cloud based data analysis tool, and I am using Django(1.10) for that.\nI have to add columns to the existing tables, create new tables, change data-type of columns(part of data-cleaning activity) at the run time and can't figure out a way to update\/reflect those changes, in run time, in the Django model, because those changes will be required in further analysis process.\nI have looked into 'inspectdb' and 'syncdb', but all of these options would require taking the portal offline and then making those changes, which I don't want.\nPlease can you suggest a solution or a work-around of how to achieve this.\nAlso, is there a way in which I can select what database I want to work from the list of databases on my MySQL server, after running Django.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":43,"Q_Id":41591079,"Users Score":0,"Answer":"Django's ORM might not be the right tool for you if you need to change your schema (or db) online - the schema is defined in python modules and loaded once when Django's web server starts.\nYou can still use Django's templates, forms and other libraries and write your own custom DB access layer that manipulates a DB dynamically using python.","Q_Score":0,"Tags":"python,django,django-1.10","A_Id":41592978,"CreationDate":"2017-01-11T12:32:00.000","Title":"Changing Database in run time and making the changes reflect in Django in run time","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using ipython notebook by connecting to a server\nI don't know how to download a thing (data frame, .csv file,... for example) programatically to my local computer. Because I can't specific declare the path like C:\/\/user\/\/... It will be downloaded to their machine not mine","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":45980,"Q_Id":41627247,"Users Score":7,"Answer":"The download option did not appear for me.\nThe solution was to open the file (which could not be correctly read as it was a binary file), and to download it from the notebook's notepad.","Q_Score":24,"Tags":"python,download,ipython,jupyter-notebook,jupyter","A_Id":46266094,"CreationDate":"2017-01-13T04:08:00.000","Title":"Download data from a jupyter server","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a program in python (2.7) and I want to protect it from reverse engineering.\nI compiled it using cx_freeze (supplies basic security-  obfuscation and anti-debugging)\nHow can I add more protections such as obfuscation, packing, anti-debugging, encrypt the code recognize VM.\nI thought maybe to encrypt to payload and decrypt it on run time, but I have no clue how to do it.","AnswerCount":3,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":12365,"Q_Id":41633039,"Users Score":6,"Answer":"There's no way to make anything digital safe nowadays.\nWhat you CAN do is making it hard to a point where it's frustrating to do it, but I admit I don't know python specific ways to achieve that. The amount of security of your program is not actually a function of programsecurity, but of psychology.\nYes, psychology.\nGiven the fact that it's an arms race between crackers and anti-crackers, where both continuously attempt to top each other, the only thing one can do is trying to make it as frustrating as possible. How do we achieve that?\nBy being a pain in the rear!\nEvery additional step you take to make sure your code is hard to decipher is a good one.\nFor example could you turn your program into a single compiled block of bytecode, which you call from inside your program. Use an external library to encrypt it beforehand and decrypt it afterwards. Do the same with extra steps for codeblocks of functions. Or, have functions in precompiled blocks ready, but broken. At runtime, utilizing byteplay, repair the bytecode with bytes depending on other bytes of different functions, which would then stop your program from working when modified.\nThere are lots of ways of messing with people's heads and while I can't tell you any python specific ways, if you think in context of \"How to be difficult\", you'll find the weirdest ways of making it a mess to deal with your code.\nFunnily enough this is much easier in assembly, than python, so maybe you should look into executing foreign code via ctypes or whatever.\nSummon your inner Troll!","Q_Score":4,"Tags":"python,debugging,assembly,reverse-engineering,obfuscation","A_Id":41637182,"CreationDate":"2017-01-13T10:59:00.000","Title":"protect python code from reverse engineering","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a program in python (2.7) and I want to protect it from reverse engineering.\nI compiled it using cx_freeze (supplies basic security-  obfuscation and anti-debugging)\nHow can I add more protections such as obfuscation, packing, anti-debugging, encrypt the code recognize VM.\nI thought maybe to encrypt to payload and decrypt it on run time, but I have no clue how to do it.","AnswerCount":3,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":12365,"Q_Id":41633039,"Users Score":3,"Answer":"Story time: I was a Python programmer for a long time. Recently I joined in a company as a Python programmer. My manager was a Java programmer for a decade I guess. He gave me a project and at the initial review, he asked me that are we obfuscating the code? and I said, we don't do that kind of thing in Python. He said we do that kind of things in Java and we want the same thing to be implemented in python. Eventually I managed to obfuscate code just removing comments and spaces and renaming local variables) but entire python debugging process got messed up.\nThen he asked me, Can we use ProGuard? I didn't know what the hell it was. After some googling I said it is for Java and cannot be used in Python. I also said whatever we are building we deploy in our own servers, so we don't need to actually protect the code. But he was reluctant and said, we have a set of procedures and they must be followed before deploying.\nEventually I quit my job after a year tired of fighting to convince them Python is not Java. I also had no interest in making them to think differently at that point of time.\nTLDR; Because of the open source nature of the Python, there are no viable tools available to obfuscate or encrypt your code. I also don't think it is not a problem as long as you deploy the code in your own server (providing software as a service). But if you actually provide the product to the customer, there are some tools available to wrap up your code or byte code and give it like a executable file. But it is always possible to view your code if they want to. Or you choose some other language that provides better protection if it is absolutely necessary to protect your code. Again keep in mind that it is always possible to do reverse engineering on the code.","Q_Score":4,"Tags":"python,debugging,assembly,reverse-engineering,obfuscation","A_Id":41635003,"CreationDate":"2017-01-13T10:59:00.000","Title":"protect python code from reverse engineering","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I read the following on python-requests website: \n\nNote that connections are only released back to the pool for reuse once all body data has been read; be sure to either set stream to False or read the content property of the Response object.\n\nBut as I use the object returned by req.json() and doesn't use req thereafter. I wonder when is the connection released? I don't really know how to check that for sure too.\nMany thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":59,"Q_Id":41634436,"Users Score":0,"Answer":"You could answer your question quite simpply by reading the source code. But anyway: response.json() does read the response's content, obviously - it's just a convenient shortcut for json.loads(response.content).","Q_Score":0,"Tags":"python,json,python-requests","A_Id":41634715,"CreationDate":"2017-01-13T12:14:00.000","Title":"In requests-python, when is connection released when using req_json = req.json()?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I usually create a canvas, the (0, 0) coord is place on the top left corner of it. Now I want to set it on the bottom left corner. I think I have to set the \"scrollbarregion\" but I can't understand how to do it.\nCan someone explain?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4720,"Q_Id":41652978,"Users Score":0,"Answer":"You could create a couple of variables that hold the size of the screen. then replace (0,0) with (self.screenWidth-0, self.sceenHeight-0)","Q_Score":3,"Tags":"python,tkinter","A_Id":41653041,"CreationDate":"2017-01-14T17:38:00.000","Title":"Tkinter: Set 0, 0 coords on the bottom of a canvas","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to make a Python script run as a service.\nIt need to work and run automatically after a reboot.\nI have tried to copy it inside the init.d folder, But without any luck.\nCan anyone help?(if it demands a cronjob, i haven't configured one before, so i would be glad if you could write how to do it)\n(Running Centos)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6891,"Q_Id":41662821,"Users Score":0,"Answer":"There is no intrinsic reason why Python should be different from any other scripting language here.\nHere is someone else using python in init.d: blog.scphillips.com\/posts\/2013\/07\/\u2026 In fact, that deals with a lot that I don't deal with here, so I recommend just following that post.","Q_Score":2,"Tags":"python,linux,centos","A_Id":41662958,"CreationDate":"2017-01-15T15:27:00.000","Title":"How to run python script at startup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been breaking my head for the pass 2 weeks, and I still can't figure it out.\nI'm trying to build a Server-Client based streaming player on Python (Ironpython for the wpf GUI) that streams video files. My problem is when the client requests to seek on a part that he did not load yet. When I try to send him just the middle of the .mp4 file, he cant seem to be able to play it.\nNow I know such thing exists because every online player has it, and it uses the HTTP 206 Partial Content request, where the client just requests the byte range that he desires and the server sends it to him.\nMy question is - how is the client able to play the video with a gap in bytes in his .mp4 file - how can he start watching for the middle of the file? When i seem to try it the player just wont open the file.\nAnd more importantly: how can I implement this on my Server-Client program to enable free seeking?\nI really tried to look for a simple explanation for this all over the internet...\nPlease explain it thoroughly and in simple terms for a novice such as me, I would highly appreciate it.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1969,"Q_Id":41666809,"Users Score":2,"Answer":"Before playing an MP4 file the client (e.g. browser) needs to read the header part of the file. An MP4 is broken into 'Atoms' and the Moov atom is the header or index atom for the file.\nFor MP4 files that will be streamed, a common optimisation is to move this Moov atom to the front of the file.\nThis allows the client to get the moov at the start and it will then have the information it needs to allow you jump to the offset you want in your case.\nIf you don't have the moov atom at the start the client needs to either download the whole file, or if it is a bit more sophisticated, jump around the file with range requests until it finds it.","Q_Score":1,"Tags":"python,video,video-streaming,httprequest,buffering","A_Id":41672032,"CreationDate":"2017-01-15T22:01:00.000","Title":"How does HTTP 206 Partial Content Request works","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning TensorFlow (as well as general deep learning). I am wondering when do we need to break the input training data into batches? And how do we determine the batch size? Is there a rule of thumb? Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":211,"Q_Id":41668158,"Users Score":1,"Answer":"Generally Deep Learning algorithms are ran on GPUs which has limited memory and thus a limited number of input data samples (in the algorithm commonly defined as batch size) could be loaded at a time.\nIn general larger batch size reduces the overall computation time (as the internal matrix multiplications are done in a parallel manner in GPU, thus with large batch sizes the time gets saved in reading\/writing gradients and possibly some other operations output).\nAnother probable benefit of large batch size is: \nIn multi-class classification problems, if the number of classes are large, a \nlarger batch size makes algorithm generalize better(technically avoids over-fitting) over the different classes (while doing this a standard technique is to keep uniform distribution of classes in a batch).\nWhile deciding batch size there are some other factors which comes into play are: learning rate and the type of Optimization method.\nI hope this answers your question to certain extent!","Q_Score":0,"Tags":"python,python-3.x,tensorflow,deep-learning,data-science","A_Id":41763164,"CreationDate":"2017-01-16T01:09:00.000","Title":"TensorFlow: how to determine if we want to break the training dataset into batches","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python to develop SDN\nI also wrote a virtual network function just like DHCP,NAT,Firewall,QoS\nBut I want to get computer's hostname from IP like 192.168.2.XXX\nI try to use arp but it only can find IP and MAC address in packets.\nSo how should I get hostname from specific IP?\nShould I try this in DHCP or NAT?\nThanks a lot !!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1035,"Q_Id":41671972,"Users Score":0,"Answer":"Try socket.gethostbyaddr() from the module socket","Q_Score":1,"Tags":"python,hostname,nat,dhcp,sdn","A_Id":41672160,"CreationDate":"2017-01-16T08:15:00.000","Title":"How to get hostname from IP?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to build a python program that will display various headlines from certain news sites. I used pip to install the module newspaper, but when I run the program, I get the error:\n\nImportError: No module named newspaper\n\nAny ideas on how to fix this?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":8074,"Q_Id":41680636,"Users Score":1,"Answer":"You can type at the terminal \npip install newspaper3k","Q_Score":4,"Tags":"python,python-newspaper","A_Id":46494795,"CreationDate":"2017-01-16T16:17:00.000","Title":"ImportError: No module named newspaper","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I, as it will soon be obvious, am a total newb when it comes to Python.\nI am running python version 3.5 on Windows 10, 64 bit.\nI installed the PyAutoGui module for a small project I am working on. At first, everything worked perfectly. But now it appears that PyAutoGui is crashing when it clicks. I suspect that it's because PyAutoGui is only intended for use up to Python 3.4.\nIn order to rectify this, I downloaded Python 3.4. Unfortunately, however, when I try to install PyAutoGui (using pip install pyautogui), it tells me that it's already been installed because it sees it in the Python 3.5 folder.\nMy question is this: How do I install PyAutoGui in Python 3.4 with it already installed in Python 3.5?\nAssume that I know virtually nothing about how to install a module manually without using pip\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1047,"Q_Id":41710540,"Users Score":0,"Answer":"If you have multiple versions of Python installed you need to find your versions and rename them and their Pips. \nIn windows the path is, C:\\\\Users\\USERNAME\\AppData\\Local\\Programs\\Python\\Python3x-32. The x should be replaced with the Python version and USERNAME with your username. On Mac it's located in \/usr\/local\/bin\/python. On Linux it should be in \/usr\/bin\/python. The location might vary depending on OS and Python version. \nRename the files python.exe\/python and pip.exe\/pip so that each file is different. I named mine python35.exe, python2.exe and python.exe(for 3.5, 2.7 and 3.6). \nNow when you execute your pip command use, pip34 install pyautogui or whatever you named the file. \nOr if you really want to you can go the painful way of renaming all the path variables, but I won't explain that here.","Q_Score":1,"Tags":"python,python-3.x,pip,pyautogui","A_Id":41710713,"CreationDate":"2017-01-18T02:43:00.000","Title":"Installing PyAutoGui on multiple versions of Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am interested to find sentence vectors using word vectors.I  read that by multiplying each word's tf-idf weights with their vectors and finding their average we can get whole sentence vector.\nNow I want to know that how these tf-idf weights helps us to get sentence vectors i.e how these tf-idf and sentence vector are related?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":878,"Q_Id":41725993,"Users Score":0,"Answer":"Any aggregative operation on the word vectors can give you a sentence vector.\nYou should consider what do you want your representation to mean and choose the operation accordingly.\nPossible operations are summing the vectors, averaging them, concatenating, etc.","Q_Score":0,"Tags":"python,machine-learning","A_Id":41740148,"CreationDate":"2017-01-18T17:40:00.000","Title":"How tf-idf is relevant in calculating sentence vectors","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having trouble logging in my Microsoft account using python mechanize utility. user-name and password are working fine. Problem comes when submitting the form, I get an interim response page with title: \"continue\" . and URL: some interim_URL. \nQuestion is how do I move to my intended URL? br.open(\"intended_URL\") doesn\u2019t work at all.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":41732616,"Users Score":0,"Answer":"First verify if the login is being done by checking the redirected link with \nprint br.geturl()\nIf it is logging in and you're have an http error in your console use exceptions for the http error which will redirect you to your page","Q_Score":0,"Tags":"python-2.7,python-3.x","A_Id":45281197,"CreationDate":"2017-01-19T02:12:00.000","Title":"python mechanize Http error 100","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have some weird problem with python int function.\nI read some file with numeric values and convert these to integers.\nWhen I do this locally it's goes fine, but when I upload it to Google App Engine the conversion fails with error: \ninvalid literal for int() with base 10: ''\nI tried to print the value it's trying to convert and it is 2210.\nThen I tried to output whole splitted line from file and got this:\n['\\x00B\\x00a\\x00u\\x00w\\x00e\\x00n\\x00s\\x00', '\\x002\\x002\\x001\\x000\\x00', '\\x005\\x004\\x003\\x001\\x00', '\\x005\\x003\\x007\\x002\\x00', '\\x005\\x002\\x006\\x005\\x00', '\\x005\\x006\\x001\\x008\\x00', '\\x005\\x003\\x002\\x008\\x00\\r\\x00']\nI use that code to convert: int(splitted_line[j])\nAnd I am very new to python. Could someone say what I need to do?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":325,"Q_Id":41742720,"Users Score":1,"Answer":"It seems like an encoding issue, but a quick workaround would be to remove '\\x00' from each string before converting it. So try int(splitted_line[j].replace('\\x00',''))","Q_Score":0,"Tags":"python,google-app-engine,int,type-conversion","A_Id":41743702,"CreationDate":"2017-01-19T13:15:00.000","Title":"How solve conversion thing in python that int() can't convert '\\x002\\x002\\x001\\x000\\x00' into integer?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the inception v3 model to retrain my own dataset. I have few folder which represent the classes which contain images for each class. What i would like to do is to 'attach' some text ids to these images so when they are retrained and used to run classification\/similarity-detection those ids are retrieved too. (basically its image similarity detection)\nFor instance, Image X is of class 'Teachers' and it belongs to John. When i retrain the model, and run a classification on the new model, i would like to get the Teachers class, but in addition to this i would like to know who is teacher (John).\nAny ideas how to go for it?\nRegards","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":596,"Q_Id":41745022,"Users Score":1,"Answer":"You have 3 main options - multiply your classes, multi-label learning or training several models.\nThe first option is the most straight forward - instead of having  teachers who belong to John and teachers who belong to Jane you can have teachers whose class is Teachers_John and class whose class is Teachers_John and learn to classify to those categories as you would learn any other set of categories, or use something like hierarchical softmax.\nThe second option is to have a set of categories that includes Teachers as well as John and Jane - now your target is not to correctly predict the one most accurate class (Teachers) but several (Teachers and John).\nYour last option is to create a hierarchy of models where the first learns to differentiate between John and Jane and others to classify the inner classes for each of them.","Q_Score":0,"Tags":"python,machine-learning,tensorflow,neural-network,deep-learning","A_Id":41792826,"CreationDate":"2017-01-19T15:02:00.000","Title":"Tensorflow Inception v3 retraining - attach text\/labels to individual images","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know it is frowned upon to post questions without code, but I have been stuck for days thinking of how to handle this issue and cant think of a solution. \nMy setup is this:\n\n\nArduino Mega w\/ 4G + GPS Shield from Cooking Hacks\nDjango Server set up with Python\nPostgresql Database\n\n\nBecause the 4G + GPS shield has the capability for http commands, I want to use http POST to send gps data to my Django Server and store that information in my Postgresql database. Another thing to keep in mind is I am running a Django test server on my Localhost, so I need to POST to that local host. \nBecause I am not posting through a form and it is not synchronous I am really confused as to how the Django server is supposed to handle this asynchronous POST. It will look like this (I imagine):\nArduino (POST) --> Django Server (Localhost) --> Postgresql Database\nSo I have 2 questions:\n1) In order to successfully send a POST to my local Django Server, should my host be my public router IP and the Port be the same as that which I am running my server on? Is there something else I am missing?\n2) Do I need to use Django REST Framework to handle the POST request? if not, how would I implement this in my views.py?\nI am trying to get a reference point on the problem in order to visualize how to do it. I DONT need coded solutions. Any help on this would be greatly appreciated, and if you have any other questions I will be quick to answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1484,"Q_Id":41748325,"Users Score":0,"Answer":"1)Depends, if your arduino is on the same local network than your Django Server then you don't need a public IP, otherwise you would have to forward your Django Server IP & port so its accesible from internet.\n2) Not really, you can do a traditional POST request to a normal view on Django.","Q_Score":1,"Tags":"django,postgresql,python-3.x,post,arduino","A_Id":41748434,"CreationDate":"2017-01-19T17:43:00.000","Title":"HTTP POST Data from Arduino to Django Database","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Jenkins with python code as follows.\nAfter detecting a change to the GIT dev branch:\n\nCheckout GIT repository dev branch code\nPerform Unit tests \/ code coverage\nIf build passes, check code into the production branch of the same repo\n\nWhat I want to add, is the ability to keep track of the previous code version (the python code package stores the version number in the setup.py file ) and if the version in the latest build job is incremented compared to the saved version, only then check the passed code into the production branch.\nAny thoughts on how best to achieve this?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":140,"Q_Id":41751050,"Users Score":0,"Answer":"I've made use of the following plugins to achieve this:\n\nFlexible Publish Plugin\nRun Condition Plugin","Q_Score":0,"Tags":"python,git,jenkins","A_Id":41751932,"CreationDate":"2017-01-19T20:25:00.000","Title":"Jenkins - Store code previous version number, and take actions if version number changes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used python scripting to do a series of complex queries from 3 different RDS's, and then exported the data into a CSV file. I am now trying to find a way to automate publishing a dashboard that uses this data into Tableau server on a weekly basis, such that when I run my python code, it will generate new data, and subsequently, the dashboard on Tableau server will be updated as well. \nI already tried several options, including using the full UNC path to the csv file as the live connection, but Tableau server had trouble reading this path. Now I'm thinking about just creating a powershell script that can be run weekly that calls the python script to create the dataset and then refreshes tableau desktop, then finally re-publishes\/overwrites the dashboard to tableau server. \nAny ideas on how to proceed with this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1415,"Q_Id":41754825,"Users Score":0,"Answer":"Getting data from excel to Tableau Server:\n\nSetup the UNC path so it is accessible from your server.  If you do this, you can then set up an extract refresh to read in the UNC path at the frequency desired.\nCreate an extract with the Tableau SDK.\nUse the Tableau SDK to read in the CSV file and generate a file.\n\nIn our experience, #2 is not very fast.  The Tableau SDK seems very slow when generating the extract, and then the extract has to be pushed to the server. I would recommend transferring the file to a location accessible to the server.  Even a daily file copy to a shared drive on the server could be used if you're struggling with UNC paths. (Tableau does support UNC paths; you just have to be sure to use them rather than a mapped drive in your setup.)\nIt can be transferred as a file and then pushed (which may be fastest) or it can be pushed remotely.\nAs far as scheduling two steps (python and data extract refresh), I use a poor man's solution myself, where I update a csv file at one point (task scheduler or cron are some of the tools which could be used) and then setup the extract schedule at a slightly later point in time.  While it does not have the linkage of running the python script and then causing the extract refresh (surely there is a tabcmd for this), it works just fine for my purposes to put 30 minutes in between as my processes are reliable and the app is not mission critical.","Q_Score":2,"Tags":"python,powershell,scripting,server,tableau-api","A_Id":47515380,"CreationDate":"2017-01-20T01:52:00.000","Title":"Tableau: How to automate publishing dashboard to Tableau server","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Don't have much expertise in programming. Only picked up Python last summer.\nI have installed both Atom and Conda on my computer. Recently, I've used Atom to edit my scripts in Python, then run the scripts via Command Line. As per standard practice, I created Virtual Environments where I installed packages I needed to run different Python scripts. \nI now want to use Atom as an IDE, and so have installed the Script package on Atom so I can run my scripts in Atom itself. However, when I tried running a Python script that required the Python numpy package, I got this:\nImportError: No module named 'numpy'\nThis error is obviously going to appear for other packages that haven't already been installed in the root environment (I think?).\nSo now, my question is how do I activate the needed Virtual Environment in Atom? In other applications like Jupyter and Spyder, I would activate the Virtual Environment I needed then open the Application via Command Line, but I can't do that with Atom.\n(If possible, is there a way to use Virtual Environments created by Conda)\nThanks","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":10521,"Q_Id":41771459,"Users Score":4,"Answer":"One way is to start atom from the activated virtual environment. In this case, executing programs\/scripts uses the configured python interpreter and imports the installed in the virtual environment.\nEDIT:\nIt's been long though, it might be useful for people redirected to this question.\nBy installing atom-python-virtualenv you can create, change or deactivate virtual environments with atom editor.","Q_Score":12,"Tags":"python,package,atom-editor,conda,virtual-environment","A_Id":47923174,"CreationDate":"2017-01-20T20:02:00.000","Title":"Activating Python Virtual Environment in Atom","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Case: \nThere is a large zip file in an S3 bucket which contains a large number of images. Is there a way without downloading the whole file to read the metadata or something to know how many files are inside the zip file?\nWhen the file is local, in python i can just open it as a zipfile() and then I call the namelist() method which returns a list of all the files inside, and I can count that. However not sure how to do this when the file resides in S3 without having to download it. Also if this is possible with Lambda would be best.","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":3417,"Q_Id":41789176,"Users Score":-1,"Answer":"As of now, you cannot get such information without downloading the zip file. You can store the required information as the metadata for a zip file when uploading to s3. \nAs you have mentioned in your question, using the python functions we are able to get the file list without extracting. You can use the same approach to get the file counts and add as metadata to a particular file and then upload it to S3.\nHope this helps, Thanks","Q_Score":7,"Tags":"python,amazon-web-services,amazon-s3,boto","A_Id":41790354,"CreationDate":"2017-01-22T09:10:00.000","Title":"How to count files inside zip in AWS S3 without downloading it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a checkbutton inside of a menu widget in python with tkinter. (Using python 3.5.2). I know that with normal checkbuttons you can select or deselect the checkbuttons using checkbutton.select() and checkbutton.deselect(). I need to know how to do this with the checkbuttons that I have in the menu object.\nI have tried the menu.entrybutton.configure(id, coption) method but there is no coption for selecting and deselecting checkbuttons within the menu. \nAny help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2380,"Q_Id":41793953,"Users Score":2,"Answer":"You should assign an IntVar (or possibly StringVar) to the checkbutton when you create it, via its variable= configuration option.  You call .get() on this var to check the button's state, and .set() to change its state.","Q_Score":0,"Tags":"python,tkinter","A_Id":41794262,"CreationDate":"2017-01-22T17:26:00.000","Title":"Selecting and deselecting tkinter Menu Checkbutton widgets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how scikit-learn put more emphasis on a class when we use the parameter class_weight. Is it an oversampling of the minority sampling ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":420,"Q_Id":41850349,"Users Score":0,"Answer":"I'm not sure if there is a single method of treating class_weight for all the algorithms.\nThe way Decision Trees (and Forests) deals with this is by modifying the weights of each sample according to its class.\nYou can consider weighting samples as a more general case of oversampling all the minority class samples (using weights you can \"oversample\" fractions of samples).","Q_Score":0,"Tags":"python,scikit-learn","A_Id":41851421,"CreationDate":"2017-01-25T11:22:00.000","Title":"How class_weight emphasis a class in in scikit-learn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For this question simplictly , I'm having two types of computers: type A and B.\nThere is one computer of type A, and many of type B.  \nB are type of hosts which can write and read from ftp.\nA is a computer which can just read from ftp.\nAs you might already guess, ftp is the shared area which need to be protected by readers-writers lock solution.  \nDoes anybody knowns of an already existing python package which handle this scenario, if not, do anybody has an example how can it be implemented for such need?  \nI guess that some locks should be implemented as files on ftp, since we are dealing with processes from different hosts.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":460,"Q_Id":41856832,"Users Score":0,"Answer":"Writer:\n\nUpload a file W.  If this fails, wait and try again.\nUpload a file R.  If this fails, wait and try again.\nDo as many writes as desired.\nRemove W.\nRemove R.\n\nReader:\n\nUpload a file R.  If this fails, wait and try again.\nCheck for the existence of a file W.  If it exists, remove R and return to step 1.\nDo one read.  If multiple reads are needed, return to step 2.\nRemove R.\n\nYou can use the Python module ftplib (or for SFTP, paramiko) to implement the above operations.","Q_Score":0,"Tags":"python,python-2.7,operating-system,locks,readerwriterlock","A_Id":41869149,"CreationDate":"2017-01-25T16:34:00.000","Title":"Reader writer lock with preference to writers","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"when i tried to check the bear results for a python file by using\n\ncoala --bears AnnotationBear -f add.py --save\n\nand when it asked for setting language- give \"python\", then on checking .coafile i didn't find any result that AnnotationBear has to give\nso, how to check result?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":49,"Q_Id":41867109,"Users Score":0,"Answer":"Hey the AnnotationBear yields, HiddenResult which are results meant to be used by other bears, and not be directly viewed by the user. If you are trying to test coala, you should check bears which actually give results, for eg: PyFlakesBear","Q_Score":0,"Tags":"python,coala,coala-bears","A_Id":45793120,"CreationDate":"2017-01-26T04:52:00.000","Title":"Checking result by applying bear on file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi I know this is a pretty basic design question. But I don't realy get it....\nI write it in Python with PySide, but I think this is more a language unrelated question.\nA simplified example what I want to do:\nI Have a Gui with a button that opens a file dialog. \nIn this one I choose a folder.\nThe code scans the suffixes of the files in the folder and returns the 3 needed one. lets say .mp3, .txt and .mov and shows them in the gui.\nTo this point the seperation should be no problem I would have a Gui class that runs the code of the core class, gets the three files as return values and sets up the gui.\nWhat I am wondering about is what happens when there are more then one files matching the .mp3 suffix. I would want to have a pop up with a combobox to select the one I want to use. But I don't realy get how to implement it without adding gui code to the core class.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":41889588,"Users Score":1,"Answer":"Well maybe have the function in the Core module return some specifier that such a thing has happened (found multiple) along with the given names, then display the choice to the user and call a function in the Core module that returns relevant information about that file.\nBear in mind you do not have to be dogmatic regarding such restrictions, there are some situations where having code in the GUI is much less of a hassle than having to integrate some way of it to work in between modules.\nThis is where you make a decision how to go about writing the code, bearing in mind how important this feature is to you, how testable\/maintainable you need it to be.","Q_Score":0,"Tags":"python,user-interface,model-view-controller,interface","A_Id":41889758,"CreationDate":"2017-01-27T08:24:00.000","Title":"clean divide Code and Gui","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a beginner and have 2 issues, which may be related to each other.\n1. I am using PyCharm, and when I put\n    \"from PyQt4 import QtCore, QtGui, uic\"\nI get a red line under each word (except from & import) saying \"unresolved reference\".\n\nI have PyQ4\/Designer installed (I know it is because I have made a GUI), but when I click 'view code' for the GUI, it says \"unable to launch C:\/Python34\/Lib\/site-packages\/PyQt4\\uic\"\n\nMaybe a path issue???  Like I said, I am very new to Python\/Qt and really do not know how to check the path and\/or change it if it is wrong.  I downloaded Python 3.6.0, PyChamr2016.3.2, Qt4.8.7","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1774,"Q_Id":41912691,"Users Score":0,"Answer":"Since you do seem to have PyQt installed my guess is that you have multiple Python versions installed (version 3.4 and version 3.6) and that PyQt is only installed under 3.6, but that PyCharm and the Designer are configured to use 3.4.\nI don't know how to change the Python interpreter in the Qt Designer as I never use it. However in PyCharm open the settings and look for the \"Project Interpeter\" tab. There you can configure the default Python interpreter that is used for your project. It even shows the installed packages for that interpreter. \nWhen you run a Python program from PyCharm, the first line in the output shows which Python interpreter was used. This way you can check if it is as expected. If it is still not correct, it can be that you have overridden it in your Run Configuration. Select \"Edit Configuration\" from the \"Run\" menu. This will open a dialog with Run Configuration settings for the Python script that you last executed. Check the \"Python Interpreter\" there and change it if needed.","Q_Score":1,"Tags":"python,python-3.x,pyqt,pycharm","A_Id":41919317,"CreationDate":"2017-01-28T17:29:00.000","Title":"PyCharm not recognizing PyQT4 and PyQt4 not allowing me to 'view code'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning about the ZeroMQ patterns, and I need to implement the following:\nNodeJS will send messages to many python threads, but it doesn't need to wait for the answers synchronously, they can come in any order. I know that the publish\/subscribe pattern solves it in one way: it can send to many, but how do the python workers send the reply back?\nAlso, in order for the python threads to receive the message, which is the better design: the python process receives the message and sends to the appropriate thread (don't know how to do it), or each thread is responsible to receive its own messages?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":41925527,"Users Score":0,"Answer":"There's no obligation to use a single socket for the two way comms. Two is perfectly fine.\nThis means you can have PUB\/SUB to broadcast from your NodeJS to your Python code. That's the easy part. Then have a separate PUSH\/PULL socket back the other way - the Python does the pushing, the NodeJS does the pulling. One PUSH socket per Python thread, and just one PULL socket in the NodeJS (it will pull from any of the push sockets). Thus whenever one of the Python threads wants to send something to the NodeJS, it simply sends it through the PUSH socket.\nAFAIK the NodeJS can 'bind' it's PULL socket, and the Python can 'connect' it's PUSH socket, which is something you can do if one wants to feel that the NodeJS is the 'server'. Though this is unecessary - either end can bind, so long as the other end connects. Remember though that ZeroMQ is Actor model programming; there is no clients or servers, there's just actors. 'Bind' and 'connect' are only mentioned at all because it's all implemented on top of tcp (or similar), and it's the tcp transport that has to be told who's binding and connecting.\nHave each thread responsible for its own socket. Though given that Python threads aren't real threads you're not going to get a speed-up through having them (unless they've gone and got rid of the global interpretter lock since I last looked). The ZeroMQ context itself sets up a thread(s) which marshalls all the actual message transfers in the background, so the IO is already significantly overlapped.","Q_Score":0,"Tags":"python,node.js,multithreading,sockets,zeromq","A_Id":42099793,"CreationDate":"2017-01-29T20:21:00.000","Title":"ZeroMQ: publish to many, receive replys in any order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to implement a book structure in Django in the model. \nThe structure is as follows \nBook Class:\ntitle\npages (this is an array of page objects)\nbibliography (a dictionary of titles and links)\nPage Class:\ntitle\nsections (an array of section objects)\nimages (array of image urls)\nSection Class:\ntitle: \ntext:\nimages (array of image urls)\nvideos (array of video urls)\nI am pretty new to Django and SQL structuring. What my question specifically is, what would be the best method in order to make a db with books where each entry has the components listed above? I understand that the best method would be to have a table of books where each entry has a one to many relationship to pages which in turn has a one to many relationship with sections. But I am unclear on connecting Django models together and how I can enable lists of objects (importantly these lists have to be dynamic).","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":296,"Q_Id":41927996,"Users Score":-1,"Answer":"Each Django model is a class which you import in your app to be able to work with them. To connect models together you can use foreign keys to define relationships, i.e. your Page class will have a foreign key from Book. To store lists in a field, one of the ways of doing it is to convert a list to string using json module and define the field as a text field. json.dumps converts the list to a string, json.loads converts the string back to a list. Or, if you are talking about other \"lists\" in your question, then maybe all you need is just django's basic queryset that you get with model.objects.get(). Queryset is a list of rows from a table.","Q_Score":1,"Tags":"python,django,sqlite","A_Id":41928825,"CreationDate":"2017-01-30T01:45:00.000","Title":"Book Structure in Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm making a program that uses PyMySql and I'd like people to be able to run my program without going through the manual installation of PyMySql, is there a way I can achieve that?\nI've already tried compiling to .pyc but that doesn't seem to work, in fact when I uninstall PyMySql it doesn't work anymore.\nPS: There probably are better languages to do that but it's a homework assignment for school and can't use anything but python, also sorry for my bad english","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":41964500,"Users Score":0,"Answer":"Use cx_freeze, pyinstaller or virtualenv.\nOr copy code and put in your. Read python import","Q_Score":1,"Tags":"python,pip,python-3.5,pymysql,pyc","A_Id":41965456,"CreationDate":"2017-01-31T18:05:00.000","Title":"If I install modules with pip, how can I make sure other people can run my program without having that module installed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After installing anaconda 4.3 64-bit (python 3.6) on windows, and choosing \"install for current user only\" and \"add to path\":\nI noticed that the anaconda program shortcuts don't work on my start menu--they are cut off at the end.  Does anyone know how the correct entries should read?  (or instead, how to repair the links?) thanks.   \nUPDATE: I reproduced the problem on two other machines, Windows 10 (x64) and windows 8.1 (x64), that were \"clean\" (neither one had a prior installation of python).\nThis is what they are after a fresh install (under \"Target\" in \"Properties\" in the \"Shortcut\" tab for each shortcut item):\nJUPYTER NOTEBOOK:\nC:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\python.exe C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\cwp.py C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3 \"C:\/Users\/user_name\/AppData\/Local\/Continuum\/Anaconda3\/python.exe\" \"C:\/Users\/user_name\/AppData\/Loc\nJUPYTER QTCONSOLE:\nC:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\pythonw.exe C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\cwp.py C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3 \"C:\/Users\/user_name\/AppData\/Local\/Continuum\/Anaconda3\/pythonw.exe\" \"C:\/Users\/user_name\/AppData\/L\nSPYDER:\nC:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\pythonw.exe C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\cwp.py C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3 \"C:\/Users\/user_name\/AppData\/Local\/Continuum\/Anaconda3\/pythonw.exe\" \"C:\/Users\/user_name\/AppData\/L\nRESET SPYDER:\nC:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\python.exe C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\cwp.py C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3 \"C:\/Users\/user_name\/AppData\/Local\/Continuum\/Anaconda3\/python.exe\" \"C:\/Users\/user_name\/AppData\/Loc\nNAVIGATOR:\nC:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\pythonw.exe C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\cwp.py C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3 \"C:\/Users\/user_name\/AppData\/Local\/Continuum\/Anaconda3\/pythonw.exe\" \"C:\/Users\/user_name\/AppData\/L\nIPYTHON:\nC:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\python.exe C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3\\cwp.py C:\\Users\\user_name\\AppData\\Local\\Continuum\\Anaconda3 \"C:\/Users\/user_name\/AppData\/Local\/Continuum\/Anaconda3\/python.exe\" \"C:\/Users\/user_name\/AppData\/Loc","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1261,"Q_Id":41970630,"Users Score":2,"Answer":"Looks like this was fixed in the newest build of anaconda (4.3.0 .1).  Unfortunately looks like it requires uninstall and reinstall as the locations seems to have changed drastically (from some subsubsub folder off of AppData to something higher up, under user directory). \n(But that might be the effect of testing 4.3.0.1 on a different machine.)\nFor example, ipython is now:\nC:\\Users\\user_name\\Anaconda3\\python.exe C:\\Users\\user_name\\Anaconda3\\cwp.py C:\\Users\\user_name\\Anaconda3 \"C:\/Users\/user_name\/Anaconda3\/python.exe\" \"C:\/Users\/user_name\/Anaconda3\/Scripts\/ipython-script.py\"\nHere is changelog for 4.3.0.1:\nIn this \u201cmicro\u201d patch release, we fixed a problem with the Windows installers which was causing problems with Qt applications when the install prefix exceeds 30 characters. No new Anaconda meta-packages correspond to this release (only new Windows installers).","Q_Score":3,"Tags":"python-3.x,anaconda,jupyter-notebook","A_Id":42047557,"CreationDate":"2017-02-01T01:46:00.000","Title":"Anaconda 4.3, 64-bit (python 3.6), leaves incorrect truncated paths in windows Start menu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently deployed a Django site on a DigitalOcean droplet through Apache. I did python manage.py runserver through ssh and now the Django site is running. However, it stayed on even after the ssh session expired (understandable because it's still running on the remote server) but how do I shut it down if I need to?\nAlso, due to this, I don't get error messages on the terminal if something goes wrong like I do when I develop locally. What would be a fix for this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":48,"Q_Id":41974959,"Users Score":1,"Answer":"Your question is confusing. If you deployed it with Apache, it's running through Apache and not through runserver. You might have additionally started runserver, but that is not what is serving your site.","Q_Score":0,"Tags":"python,django,apache,ssh","A_Id":41976000,"CreationDate":"2017-02-01T08:21:00.000","Title":"Is it normal that the Django site I recently deployed on Apache is always on?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"On Linux, specifically Debian Jessie, should I use \/usr\/bin\/python or should I install another copy in \/usr\/local\/bin?\nI understand that the former is the system version and that it can change when the operating system is updated. This would mean that I can update the version in the latter independently of the OS. As I am already using python 3, I don't see what significant practical difference that would make.\nAre there other reasons to use a local version?\n(I know there are ~42 SO questions about how to change between version, but I can't find any about why)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6843,"Q_Id":41992104,"Users Score":0,"Answer":"1) You should not modify the system's binaries yourself directly \n2) If your $PATH variable doesn't contain \/usr\/local\/bin, the naming of that secondary directory isn't really important. You can install \/ upgrade independently wherever you have installed your extra binaries.\n3) For Python specifically, you could also just use conda \/ virtualenv invoked by your system's python to manage your versions & projects.","Q_Score":7,"Tags":"python,linux","A_Id":41992148,"CreationDate":"2017-02-02T00:00:00.000","Title":"\/usr\/bin\/python vs \/usr\/local\/bin\/python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do I upload an image (from the web) using Bigcommerce's Python API?\nI've got this so far:\ncustom = api.Products.create(name='Test', type='physical', price=8.33, categories=[85], availability='available', weight=0)\nThank you! I've tried almost everything!","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":438,"Q_Id":42003461,"Users Score":-2,"Answer":"This will create the product on the BigCommerce website. You create the image after creating the product, by entering the following line. The image_file tag should be a fully qualified URL pointing to an image that is accessible to the BigCommerce website, being found either on another website or on your own webserver.\napi.ProductImages.create(parentid=custom.id, image_file='http:\/\/www.evenmore.co.uk\/images\/emgrab_s.jpg', description='My image description')","Q_Score":3,"Tags":"python,e-commerce,bigcommerce","A_Id":48835159,"CreationDate":"2017-02-02T13:27:00.000","Title":"Bigcommerce Python API, how do I create a product with an image?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Having read many stack overflow questions, tutorials etc on all-auth I keep getting the impression that it only supports the registration of one type of user per project.\nI have two usecases\n\nA business user authenticates and registers his business in one step.\nA developer user authenticates and just fills in the name of his employer (software company).\n\nI do not want the developer to see the business fields when he signs up. i.e his signup form is different.\nIf, in fact signup should be common and the user specific details should be left to a redirect, how to accomplish this from social auth depending on user type?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":376,"Q_Id":42006246,"Users Score":1,"Answer":"@pennersr was kind enough to answer this on the allauth github page:\n\nThis truly all depends on how you model things, there is nothing in\n  allauth that blocks you from implementing the above.\nOne way of looking at things is that the signup form is not different\n  at all. It merely contains an additional switch that indicates the\n  type of user account that is to be created. Then, it is merely a\n  matter of visualizing things properly, if you select type=employer,\n  then show a different set of fields compared to signing up using\n  type=developer.\nIf you don't want such a switch in your form, then you can store the\n  type of account being created somewhere in the session, and refer to\n  that when populating the account.","Q_Score":0,"Tags":"python,django,django-allauth","A_Id":42011936,"CreationDate":"2017-02-02T15:34:00.000","Title":"Django All-Auth Role Based Signup","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Why doesn\u2019t the array class have a .sort()? I don't know how to sort an array directly.\nThe class array.array is a packed list which looks like a C array.\nI want to use it because only numbers are needed in my case, but I need to be able to sort it. Is there some way to do that efficiently?","AnswerCount":2,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":144,"Q_Id":42040813,"Users Score":-7,"Answer":"A list is a data structure that has characteristics which make it easy to do some things. An array is a very well understood standard data structure and isn't optimized for sorting. An array is basically a standard way of storing the product of sets of data. There hasn't ever been a notion of sorting it.","Q_Score":1,"Tags":"python,arrays,python-3.x,sorting","A_Id":42040862,"CreationDate":"2017-02-04T13:15:00.000","Title":"Why doesn\u2019t 'array' have an in-place sort like list does?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was writing my code, then I pressed Ctrl+S. It then started not responding. I closed it and came back on to find the file was now empty!\nAnyone know how I can retrieve it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":431,"Q_Id":42053240,"Users Score":0,"Answer":"In the end, I just retyped my code. Luckily, I'd done a backup the previous night, so didn't lose too much.\nI am now making sure to do daily backups.","Q_Score":1,"Tags":"python-3.x,crash,python-idle","A_Id":42232624,"CreationDate":"2017-02-05T14:31:00.000","Title":"Python IDLE crashed when saving and all my code disappeared","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to find the accuracy of one class in MMNIST dataset .So how can i split it on the basis of classes?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":567,"Q_Id":42057667,"Users Score":1,"Answer":"Not sure exactly what you are asking. I will answer about what I understood. In case you want to predict only one class for example digit 5 and rest of the digits. Then first you need to label your vectors in such a way that maybe label all those vectors as 'one' which has ground truth 5 and 'zero' to those vectors whose ground truth is not 5. \nThen design your network with only two nodes in output, where first node will show the probability that the input vector belongs to class 'one' (or digit 5) and second node will show the probability of belonging to class 'zero'. Then just train your network. \nTo find accuracy, you can simple techniques like just count how many times you predict right i.e. if probability is higher than 0.5 for right class classify it as that class. \nI hope that helps, if not maybe it would be better if you could explain your question more precisely.","Q_Score":1,"Tags":"python,tensorflow","A_Id":42057766,"CreationDate":"2017-02-05T21:42:00.000","Title":"How can we use MNIST dataset one class as an input using tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to keep a record of all pip commands that were executed in a given virtual environment and of the package versions that got installed\/updated\/removed. Is there an easy way to do that?\nAlternatively, how do I get requirements.txt (including --install-option, etc.) out of my virtual environment state, if that's possible? Presumably, only the immediate dependencies need to be there.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":337,"Q_Id":42058677,"Users Score":0,"Answer":"You can use the history command to view the history of all your commands and then grep for pip with out put to a file.\nSimilar to the comment above.","Q_Score":1,"Tags":"python,pip,virtualenv","A_Id":42059013,"CreationDate":"2017-02-05T23:51:00.000","Title":"log all pip commands in a given virtual environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In case you want to predict only one class. Then first you need to label your vectors in such a way that maybe label all those vectors as 'one' which has ground truth 5 and 'zero' to those vectors whose ground truth is not 5. \nhow can I implement this in tensorflow using puthon","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":164,"Q_Id":42059103,"Users Score":0,"Answer":"while preparing the data you can use numpy to set all the data points in class 5 as 1 and the others will be set to as 0 using .\narr = np.where(arr!=5,arr,0)\narr = np.where(arr=5,arr,1) \nand then you can create a binary classifier using Tensorflow to classifiy them while using a binary_crossentropy loss to optimize the classifier","Q_Score":2,"Tags":"python,tensorflow,one-hot-encoding","A_Id":59105698,"CreationDate":"2017-02-06T01:03:00.000","Title":"how to predict only one class in tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do I get the key of the workbook if I know only the name of the workbook? I can use open by title, but once i'm in I didn't find a get.key type method in the documents. Is there a way to get the key by only knowing the title?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":140,"Q_Id":42060186,"Users Score":2,"Answer":"You can access a spreadsheet key with mySpreadSheet.id after you have opened it by title.","Q_Score":2,"Tags":"python,gspread","A_Id":42066652,"CreationDate":"2017-02-06T04:08:00.000","Title":"gspread get key once opened by title","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Python docx 0.8.5\nI can't seem to be able to figure out how to get a list of  typeface and sizes used in a document\nThere is a Font object, accessible on Run.font but I can't handle this problem. \nCan somebody please point me to an example?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":51,"Q_Id":42072399,"Users Score":0,"Answer":"There is no \"centralized authority\" in a Word document of what Fonts have been used. You'll need to parse through the full document and detect them yourself. Runs are the right place to look, but you'll also need to check styles, both paragraph and character styles. Also, to be thorough, you'll need to check the document default font.","Q_Score":0,"Tags":"python,python-docx","A_Id":42074715,"CreationDate":"2017-02-06T16:16:00.000","Title":"get a list of typeface and sizes used in a docx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was recently trying to make my own module when I realised a copy of my module had been made but instead of ending in .py like the origional, it ended in .pyc. When I opened it, I could not understand a thing. I was using the import to make a game from pygame and the fact that the .pyc file had a bunch of question marks and weird symbols seemed to be helpful for hackers if I ever make a game good enough for release which probably wont happen. I just want to know a few things about these files:\n\nCan other computers that download the game still read the module if I delete the original and only leave the weirder .pyc file?\nAre they readable by humans and can they actually prevent hacks on downloaded game? (its not online I just don't want a easy game for people who know python)\nShould I get rid of them for what I am doing? (I saw other questions asking how to do that but the answers said it was helpful)\nLast but not least, will it work for .txt files (will they not just be read as a bunch of symbols)?\n\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":42079675,"Users Score":0,"Answer":"The .pyc files are not readable by humans - the python interpreter compiles the source code to these files, and they are used by the python virtual machine. You can delete these files, and when you run the .py file again, you will see a new .pyc file created.","Q_Score":0,"Tags":"python-2.7","A_Id":42079696,"CreationDate":"2017-02-07T00:23:00.000","Title":"are there limitations on .pyc files?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Sorry about the vague title, but I didn't know how to word it. \nSo I have a pandas dataframe with 3 columns and any amount of rows. The first column is a person's name, the second column is their major (six possible majors, always written the same), and the third column is their gender (always 'Male' or 'Female'). \nI was told to print out the number of people in each major, which I was able to accomplish by saying table.Qmajor.value_counts() (table being my dataframe variable name). Now I am being asked to print the amount of males and females in each major, and I have no idea where to start. Any help is appreciated.\nThe column names are Qnames, Qmajor, and Qgender.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":5858,"Q_Id":42081790,"Users Score":2,"Answer":"altering @VaishaliGarg's answer a little, \nyou can use\ndf.groupby(['Qgender','Qmajor']).count()\nAlso if needed a dataframe out of it, we need to add .reset_index()\nsince it would be a groupbyObject.\ndf.groupby(['Qgender','Qmajor']).count().reset_index()","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":42081957,"CreationDate":"2017-02-07T04:33:00.000","Title":"Pandas dataframe: Listing amount of people per gender in each major","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently using Spyder and have been for a long time, however I downloaded anaconda recently and started using Spyder for Python 3.5 which gives me several problems.\nWhenever I run a script in the Python Console, I have to run it twice and then when I am finished running it and want to run a new I have to kill the current process and reload it. \nI am currently using some scripts with threading, but that never used to be a problem before I upgraded, anyone have similar experiences and know how to fix it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":502,"Q_Id":42087789,"Users Score":1,"Answer":"(Spyder developer here) We're aware of these problems in the Python console, but unfortunately we don't know how to fix them.\nPlease use the IPython console instead because the Python console is going to be removed in Spyder 3.2.","Q_Score":0,"Tags":"python,spyder","A_Id":42121732,"CreationDate":"2017-02-07T10:46:00.000","Title":"Spyder IDE environment in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to cache a computationally expensive property in a class defined with the __slots__ attribute.\nAny idea, how to store the cache for later use? Of course the usual way to store a dictionary in instance._cache would not work without __dict__ being defined. For several reasons i do not want to add a '_cache' string to __slots__.\nI was thinking whether this is one of the rare use cases for global. Any thoughts or examples on this matter?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":992,"Q_Id":42089856,"Users Score":2,"Answer":"There is no magic possible there - ou want to store a value, so you need a place to store your value.\nYou can't just decide \"I won't have an extra entry on my __slots__ because it is not elegant\" - you don't need to call it _cached: \ngive it whatever name you want, but these cached values are something you want to exist in each of the object's instances, and therefore you need an attribute. \nYou can cache in a global (module level) dictionary, in which the keys are id(self) - but that would be a major headache to keep synchronized when instances are deleted.  (The same thing is true for a class-level dictionary, with the further downside of it still be visible on the instance).\nTL;DR: the \"one and obvious way to do it\"  is to have a shadow attribute, starting with \"_\" to keep the values you want cached, and declare these in __slots__.  (If you use a _cached dictionary per instance, you loose the main advantage from __slots__, that is exactly not needing one dictionary per instance).","Q_Score":2,"Tags":"python,caching","A_Id":42091305,"CreationDate":"2017-02-07T12:23:00.000","Title":"Python caching attributes in object with __slots__","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to cache a computationally expensive property in a class defined with the __slots__ attribute.\nAny idea, how to store the cache for later use? Of course the usual way to store a dictionary in instance._cache would not work without __dict__ being defined. For several reasons i do not want to add a '_cache' string to __slots__.\nI was thinking whether this is one of the rare use cases for global. Any thoughts or examples on this matter?","AnswerCount":3,"Available Count":2,"Score":-0.1325487884,"is_accepted":false,"ViewCount":992,"Q_Id":42089856,"Users Score":-2,"Answer":"Something like Borg pattern can help.\nYou can alterate the status of your instance in the    __init__ or   __new__     methods.","Q_Score":2,"Tags":"python,caching","A_Id":42089927,"CreationDate":"2017-02-07T12:23:00.000","Title":"Python caching attributes in object with __slots__","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My django app displays the objects from database in table view. The problem is that these objects (models) are pretty complex: the have 50+ fields. Nearly for each field I have to do some formatting:\n\nconver phone numbers from int 71234567689 to \"+7 (123) 456789\"\ndisplay long prices with spaces: \"7 000 000\" instead of \"7000000\"\nconstruct full address from several fields like \"street\", \"house\" and so on (logic if pretty complex with several if-else-s)\nand so on\n\nDjango templating language has several useful tags for simple cases but I guess is not suitable in general case (like mine) for serious formatting.\nCreate the @property-s in model class is also not an option because the question is about rendering and is not related to model.\nSo I guess I should do my conversions in view: create dict for each obj, fill with converted data and pass to template. \nBut! The model has a lot of fields and I don't want to copy them all :) Moreover, it would be great to preserve model structure to use it in django template (say, regroup) and query set laziness.\nSo the greatest way would be to instruct django \"how to render\". Is it possible?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":392,"Q_Id":42089967,"Users Score":1,"Answer":"If you are using Django Rest Framework, then you can simply use serializers. But I don't think that is a case. What you want to accomplish seems very similar to the role of django forms, but as such they are only used (conventionally) for saving\/updating models i.e. POST requests. Now either you can define a new class for filtering\/rendering and use that in your view or just go ahead and use django forms which would automatically provide basic cleaning for different fields.","Q_Score":2,"Tags":"python,django","A_Id":42090129,"CreationDate":"2017-02-07T12:30:00.000","Title":"Django: best way to convert data from model to view","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to setup a salt-master\/salt-cloud on Centos 7. The issue that I am having is that I need Python 2.7.13 to use salt-cloud to clone vm in vmware vcenter (uses pyvmomi). CentOS comes with Python 2.7.5 which salt has a known issue with (SSL doesn't work).\nI have tried to find a configuration file on the machine to change which python version it should use with no luck.\nI see two possible fixes here,\nsomehow overwrite the python 2.7.5 with 2.7.13 so that it is the only python available. \nOR \nIf possible change the python path salt uses.\nAny Ideas on how to do either of these would be appreciated? \n(Or another solution that I haven't mentioned above?)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1084,"Q_Id":42103374,"Users Score":1,"Answer":"The salt packages are built using the system python and system site-packages directory.  If something doesn't work right, file a bug with salt.  You should avoid overwriting the stock python, as that will result in a broken system in many ways.","Q_Score":1,"Tags":"python,python-2.7,salt,salt-stack,salt-cloud","A_Id":42263855,"CreationDate":"2017-02-08T01:58:00.000","Title":"How to change Default Python for Salt in CentOS 7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how to create a communication for each services. I am using API Gateway for the outside of the system to communicate with the services within. Is it necessary for a service to call another service through API Gateway or just directly into the service itself ?\nThank You","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3274,"Q_Id":42105805,"Users Score":0,"Answer":"Api gateway is not needed for Internal service to service communication\nBut, you need a service registry or some kind of dynamic  load balancing mechanism to reach the services","Q_Score":0,"Tags":"python,api,microservices","A_Id":42114560,"CreationDate":"2017-02-08T06:03:00.000","Title":"Microservices Communication Design","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have trained my model on a data set and i used decision trees to train my model and it has 3 output classes - Yes,Done and No , and I got to know the feature that are most decisive in making a decision by checking feature importance of the classifier. I am using python and sklearn as my ML library. Now that I have found the feature that is most decisive I would like to know how that feature contributes, in the sense that if the relation is positive such that if the feature value increases the it leads to Yes and if it is negative It leads to No and so on and I would also want to know the magnitude for the same.\nI would like to know if there a solution to this and also would to know a solution that is independent of the algorithm of choice, Please try to provide solutions that are not specific to decision tree but rather general solution for all the algorithms. \nIf there is some way that would tell me like:\nfor feature x1 the relation is 0.8*x1^2\nfor feature x2 the relation is -0.4*x2 \njust so that I would be able to analyse the output depends based on input feature x1 ,x2  and so on\nIs it possible to find out the whether a high value for particular feature to a certain class, or a low value for the feature.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":998,"Q_Id":42108324,"Users Score":0,"Answer":"In general - no. Decision trees work differently that that. For example it could have a rule under the hood that if feature X > 100 OR X < 10 and Y = 'some value' than answer is Yes, if 50 < X < 70 - answer is No etc. In the instance of decision tree you may want to visualize its results and analyse the rules. With RF model it is not possible, as far as I know, since you have a lot of trees working under the hood, each has independent decision rules.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn,decision-tree","A_Id":42115789,"CreationDate":"2017-02-08T08:40:00.000","Title":"How to know the factor by which a feature affects a model's prediction","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I don't shuffle my files, I can get the file names with generator.filenames. But when the generator shuffles the images, filenames isn't shuffled, so I don't know how to get the file names back.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1974,"Q_Id":42118850,"Users Score":0,"Answer":"I think the only option here is to NOT shuffle the files. I have been wondering this myself and this is the only thing I could find in the docs. Seems odd and not correct...","Q_Score":7,"Tags":"python,machine-learning,neural-network,generator,keras","A_Id":46009804,"CreationDate":"2017-02-08T16:42:00.000","Title":"How to retrieve the filename of an image with keras flow_from_directory shuffled method?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know I am using the wrong search terms and that's why I haven't been able to suss out the answer myself. However, I cannot seem to figure out how to use the CGI module to pull what I think counts as a query string from the url.\ngiven a url www.mysite.com\/~usr\/html\/cgi.py\/desired\/path\/info how would one get the desired\/path\/info out of the url? I understand GET and POST requests and know I can use CGI's FieldStorage class to get at that data to fill my Jinja2 templates out and such. But now I want to start routing from a landing page with different templates to select before proceeding deeper into the site. I'm hoping the context is enough to see what I'm asking because I am lost in a sea of terms that I don't know.\nEven if it's just the right search term, I need something to help me out here.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":33,"Q_Id":42121512,"Users Score":0,"Answer":"Thanks for all the help on what was actually not to complicated a question. What I was looking for was a router\/dispatcher that is usually handled by a framework fairly simply though an @route or something similar. Opting for a more efficient approach all I had to do was import os and then look at os.environ.get('PATH_INFO', '') for all the data I could possibly need. For anyone else following the path I was, that is how I found my way.","Q_Score":0,"Tags":"python-2.7,url,cgi,query-string","A_Id":42122277,"CreationDate":"2017-02-08T19:02:00.000","Title":"Getting what I think is a part of the query string using python 2.7\/CGI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I meant by the title is that I have two different programs and I want to plot data on one figure. In Matlab there is this definition for figure handle which eventually points to a specific plot. Let's say if I call figure(1) the first time, I get a figure named ''1'' created. The second I call figure(1), instead of creating a new one, Matlab simply just plot on the previous figure named ''1''. I wondered how I can go about and do that in Spyder. \nI am using Matplotlib in sypder. I would imagine this could be easily achieved. But I simply don't know much about this package to figure my problem out. :(\nAny suggestions are appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":42149777,"Users Score":0,"Answer":"One way that I have figured out is to define a dictionary and then record the results you want individually. Apparently, this is not the most efficient way, but it works.","Q_Score":2,"Tags":"ipython,spyder","A_Id":50688040,"CreationDate":"2017-02-10T00:59:00.000","Title":"How to plot data from different runs on one figure in Spyder","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This may be a dumb question, but I want to add a line at the very start of the code like\n\nprint 'previous runtime' time.time()-tic\n\nIs there a way to do it? Or can I somehow get the previous runtime other than keeping a logfile?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":37,"Q_Id":42151236,"Users Score":1,"Answer":"No. It wouldn't be possible unless written somewhere. Simple reason is that once the python process ends, GC cleans up everything.","Q_Score":0,"Tags":"python","A_Id":42151338,"CreationDate":"2017-02-10T03:54:00.000","Title":"Is there a way to write over the python code after the interpretation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using TensorFlow to build a deep learning model. And new to TensorFlow.\nDue to some reason, my model has limited batch size, then this limited batch-size will make the model has a high variance.\nSo, I want to use some trick to make the batch size larger. My idea is to store the gradients of each mini-batch, for example 64 mini-batches, and then sum the gradients together, use the mean gradients of this 64 mini batches of training data to update the model's parameters.\nThis means that for the first 63 mini-batches, do not update the parameters, and after the 64 mini batch, update the model's parameters only once.\nBut as TensorFlow is graph based, do anyone know how to implement this wanted feature?\nThanks very much.","AnswerCount":6,"Available Count":1,"Score":-0.0333209931,"is_accepted":false,"ViewCount":8795,"Q_Id":42156957,"Users Score":-1,"Answer":"You can use Pytorch instead of Tensorflow as it allows the user to accumulate gradients during training","Q_Score":18,"Tags":"python,tensorflow,gradient","A_Id":56578297,"CreationDate":"2017-02-10T10:23:00.000","Title":"How to update model parameters with accumulated gradients?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have deployed a small application to Heroku. The slug contains, among other things, a list in a textfile. I've set a scheduled job to, once an hour, run a python script that select an item from that list, and does something with that item.\nThe trouble is that I don't want to select the same item twice in sequence. So I need to be able to store the last-selected item somewhere. It turns out that Heroku apparently has a read-only filesystem, so I can't save this information to a temporary or permanent file.\nHow can I solve this problem? Can I use os.environ in python to set a configuration variable that stores the last-selected element from the list?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":42171188,"Users Score":1,"Answer":"Have to agree with @KlausD, doing what you are suggesting is actually a bit more complex trying to work with a filesystem that won't change and tracking state information (last selected) that you may need to persist. Even if you were able to store the last item in some environmental variable, a restart of the server would lose that information.\nAdding a db, and connecting it to python would literally take minutes on Heroku. There are plenty of well documented libraries and ORMs available to create a simple model for you to store your list and your cursor. I normally recommend against storing pointers to information in preference to making the correct item obvious due to the architecture, but that may not be possible in your case.","Q_Score":0,"Tags":"python,heroku","A_Id":42213846,"CreationDate":"2017-02-11T01:28:00.000","Title":"Heroku: how to store a variable that mutates?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python and took on a small project for the firehouse.\nI am looking to make a \"Calls YTD\" Sign.\nThe initial thought was a raspberry Pi connected to the a touch screen.\nAfter some playing around and learning how to use python a little I realized one very important fact... I am way over my head.\nLooking for some direction.\nIn order for this to display on the touch screen I will need to build it into a GUI.  Should I stop right there and instead get a 12x12 LED and keep it more simple?  \nOtherwise the goal would be to display the current call number \"61\" for example, with an up and down arrow to simply advance or retract a number .\nAdding the ability to display last years call volume would be cool but not necessary.\nWhat I am looking for ultimately, is some direction if python and raspberry pi is the way to go or should I head in another direction.\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":42179424,"Users Score":0,"Answer":"For a gui you could always take a look into Tkinter.\nYou could test the gui without having the actual raspberry pi.\nSwitching to leds would require an LED matrix, which is more demanding in terms of electrical engineering. Raspberry pi would be my recommendation.","Q_Score":0,"Tags":"python,raspberry-pi,touch","A_Id":42180008,"CreationDate":"2017-02-11T18:11:00.000","Title":"Counter Display Design","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a table in MySQL command line and I'm able to interact with it using python really well. However, I wanted to be able to change values in the table more easily so I installed MySQL workbench to do so. \nI have been able to connect to my server but when I try to change any values after selecting a table, it doesn't let me edit it. I tried making a new table within MySQL Workbench and I could edit it then. \nSo, I started to use that table. However, trying to edit the table python stopped working, so I made another table with command line again and it works! \nDoes anyone know how to fix either of these problems? It seems MySQL Workbench can only edit tables that have been created with Workbench, and not with Command Line. There must be a configuration option somewhere that is limiting this. \nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":94,"Q_Id":42211463,"Users Score":0,"Answer":"Editing a table means to be able to write back data in a way that reliably addresses the records that have changed. In MySQL Workbench there are certain conditions which must be met to make this possible. A result set:\n\nmust have a primary key\nmust not have any aggregates or unions\nmust not contain subselects\n\nWhen you do updates in a script you have usually more freedom by writing a WHERE clause that limits changes to a concrete record.","Q_Score":0,"Tags":"python,mysql,mysql-workbench","A_Id":42220939,"CreationDate":"2017-02-13T18:55:00.000","Title":"MySQL Workbench can't edit a table that was created using Command Line","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a meteor project that includes python scripts in our private folder of our project. We can easily run them from meteor using exec, we just don't know how to install python modules on our galaxy server that is hosting our app. It works fine running the scripts on our localhost since the modules are installed on our computers, but it appears galaxy doesn't offer a command line or anything to install these modules. We tried creating our own command line by calling exec commands on the meteor server, but it was unable to find any modules. For example when we tried to install pip, the server logged \"Unable to find pip\".\nBasically we can run the python scripts, but since they rely on modules, galaxy throws errors and we aren't sure how to install those modules. Any ideas?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":192,"Q_Id":42216640,"Users Score":0,"Answer":"It really depends on how horrible you want to be :)\nNo matter what, you'll need a well-specified requirements.txt or setup.py. Once you can confirm your scripts can run on something other than a development machine, perhaps by using a virtualenv, you have a few options:\n\nI would recommend hosting your Python scripts as their own independent app. This sounds horrible, but in reality, with Flask, you can basically make them executable over the Internet with very, very little IT. Indeed, Flask is supported as a first-class citizen in Google App Engine.\nAlternatively, you can poke at what version of Linux the Meteor containers are running and ship a binary built with PyInstaller in your private directory.","Q_Score":1,"Tags":"python,node.js,meteor,meteor-galaxy","A_Id":42284125,"CreationDate":"2017-02-14T02:02:00.000","Title":"Installing python modules in production meteor app hosted with galaxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a python script (on my local machine) that queries Postgres database and updates a Google sheet via sheets API. I want the python script to run on opening the sheet. I am aware of Google Apps Script, but not quite sure how can I use it, to achieve what I want.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6619,"Q_Id":42218932,"Users Score":2,"Answer":"you will need several changes. first you need to move the script to the cloud (see google compute engine) and be able to access your databases from there.\nthen, from apps script look at the onOpen trigger. from there you can urlFetchApp to your python server to start the work.\nyou could also add a custom \"refresh\" menu to the sheet to call your server which is nicer than having to reload the sheet.\nnote that onOpen runs server side on google thus its impossible for it to access your local machine files.","Q_Score":0,"Tags":"python,google-apps-script,google-sheets,google-spreadsheet-api","A_Id":42327384,"CreationDate":"2017-02-14T06:00:00.000","Title":"Running python script from Google Apps script","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a conda environment named old_name, how can I change its name to new_name without breaking references?","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":242754,"Q_Id":42231764,"Users Score":8,"Answer":"As the answer from @pkowalczyk mentioned some drawbacks: In my humble opinion, the painless and risk-free (workaround) way is following these steps instead:\n\nActivate & Export your current environment conda env export > environment.yml\nDeactivate current conda environment. Modify the environment.yml file and change the name of the environment as you desire (usually it is on the first line of the yaml file)\nCreate a new conda environment by executing this conda env create -f environment.yml\n\nThis process takes a couple of minutes, and now you can safely delete the old environment.\nP.S. nearly 5 years and conda still does not have its \"rename\" functionality.","Q_Score":469,"Tags":"python,anaconda,conda","A_Id":68422861,"CreationDate":"2017-02-14T16:51:00.000","Title":"How can I rename a conda environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the most efficient way to list all dependencies required to deploy a working project elsewhere (on a different OS, say)? \nPython 2.7, Windows dev environment, not using a virtualenv per project, but a global dev environment, installing libraries as needed, happily hopping from one project to the next. \nI've kept track of most (not sure all) libraries I had to install for a given project. I have not kept track of any sub-dependencies that came auto-installed with them. Doing pip freeze lists both, plus all the other libraries that were ever installed. \nIs there a way to list what you need to install, no more, no less, to deploy the project? \nEDIT In view of the answers below, some clarification. My project consists of a bunch of modules (that I wrote), each with a bunch of imports. Should I just copy-paste all the imports from all modules into a single file, sort eliminating duplicates, and throw out all from the standard library (and how do I know they are)? Or is there a better way? That's the question.","AnswerCount":10,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":86884,"Q_Id":42237072,"Users Score":26,"Answer":"Scan your import statements. Chances are you only import things you explicitly wanted to import, and not the dependencies.\nMake a list like the one pip freeze does, then create and activate a virtualenv. \nDo pip install -r your_list, and try to run your code in that virtualenv. Heed any ImportError exceptions, match them to packages, and add to your list. Repeat until your code runs without problems. \nNow you have a list to feed to pip install on your deployment site.\nThis is extremely manual, but requires no external tools, and forces you to make sure that your code runs. (Running your test suite as a check is great but not sufficient.)","Q_Score":71,"Tags":"python","A_Id":42237193,"CreationDate":"2017-02-14T22:01:00.000","Title":"List dependencies in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to run an existing django app. The app has been built in django-1.10. I set up a new virtualenv and installed the requirements and everything. However, I get errors like the following:\nfrom django.utils import importlib\nImportError: cannot import name importlib\nNow, the above is from the following source - .virtualenvs\/crowd\/lib\/python2.7\/site-packages\/account\/conf.py\nWhen I manually fix the conf.py file, I still keep getting errors to fix either deprecated or removed features from older django versions.\nAny idea as to how to fix this? I thought the purpose of working in virtualenvs was to avoid such errors. \nAny suggestions would be much appreciated. Thanks in advance!\nThis is how the question is different: Even after I fix the importlib import statement, it keeps giving me errors like that of the usage of SubFieldBase and so on.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":42239173,"Users Score":1,"Answer":"The problem was not with the Django-core but with django-user-accounts app that was included with pinax. Upgrading the django-user-accounts app fixed the issue.\nThanks to @Selcuk for the solution.","Q_Score":0,"Tags":"python,django,python-2.7,virtualenv","A_Id":42239415,"CreationDate":"2017-02-15T01:20:00.000","Title":"django-1.10 still contains deprecated and removed features","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"How do you truncate a PyHandle returned by win32file.CreateFile. I know you can open it with the TRUNCATE_EXISTING flag, but how do you truncate it to a specific size after reading\/writing? Note: The reason I cannot use the standard library is because I'm using win32file to restrict simultaneous reading\/writing to a file.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":63,"Q_Id":42264022,"Users Score":1,"Answer":"Call win32file.SetEndOfFile(handle) after positioning the file handle to the offset that you want to be the new end of file.  This is similar to the ftruncate POSIX system call, or writing 0 bytes in DOS.","Q_Score":0,"Tags":"python,python-2.7","A_Id":42289440,"CreationDate":"2017-02-16T03:00:00.000","Title":"Truncate PyHandle (win32file)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed OpenStack swift python client (pip install python-swiftclient). However \/usr\/bin has swift executable (which I can not remove as it is owned by root) and is overriding python swift.\nRequirement already satisfied: python-swiftclient in \/Library\/Python\/2.7\/site-packages\nRequirement already satisfied: requests>=1.1 in \/Library\/Python\/2.7\/site-packages (from python-swiftclient)\nRequirement already satisfied: six>=1.5.2 in \/Library\/Python\/2.7\/site-packages\/six-1.10.0-py2.7.egg (from python-swiftclient)\nRequirement already satisfied: futures>=3.0; python_version == \"2.7\" or python_version == \"2.6\" in \/Library\/Python\/2.7\/site-packages (from python-swiftclient)\nHowever, I am unable to find python swift anywhere. Please let me know how to resolve this.\nMany Thanks\nChen","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":416,"Q_Id":42264307,"Users Score":1,"Answer":"For me, Apple Swift is under \/usr\/bin\/swift and python-swiftclient is under \/usr\/bin\/local\/swift. Explicitly invoking it as \/usr\/bin\/local\/swift works.","Q_Score":0,"Tags":"swift,python-2.7","A_Id":56529866,"CreationDate":"2017-02-16T03:28:00.000","Title":"Apple Swift is overriding Openstack swift package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to import and use dataset package of python at AWS Lambda. The dataset package is about MySQL connection and executing queries. But, when I try to import it, there is an error.\n\"libmysqlclient.so.18: cannot open shared object file: No such file or directory\"\nI think that the problem is because MySQL client package is necessary. But, there is no MySQL package in the machine of AWS Lambda.\nHow to add the third party program and how to link that?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":131,"Q_Id":42267553,"Users Score":0,"Answer":"You should install your packages in your lambda folder :\n$ pip install YOUR_MODULE -t YOUR_LAMBDA_FOLDER \nAnd then, compress your whole directory in a zip to upload in you lambda.","Q_Score":1,"Tags":"mysql,python-2.7,amazon-web-services,aws-lambda","A_Id":42268813,"CreationDate":"2017-02-16T07:30:00.000","Title":"How to use the package written by another language in AWS Lambda?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have python script that checks if the server is up or down, and if it's down it sends out an email along with few system logs. \nWhat I want is to keep checking for the server every 5 minutes, so I put the cronjob as follows:\n*\/5 * * * * \/python\/uptime.sh\nSo whenever the server's down, it sends an email. But I want the script to stop executing (sending more emails) after the first one. \nCan anyone help me out with how to do this? \nThanks.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":227,"Q_Id":42271330,"Users Score":0,"Answer":"Simple solution is, you can set some Bash env variable MONITORING=true and let your python script to check that variable using os.environ[\"MONITORING\"]. If that variable is true then check if the server is up or down else don't check anything. Once server down is found, set that variable to false from script like os.environ[\"MONITORING\"] = false. So it won't send emails until you set that env variable again true.","Q_Score":0,"Tags":"python,cron,crontab","A_Id":42271741,"CreationDate":"2017-02-16T10:32:00.000","Title":"Running cronjob every 5 minutes but stopped after first execution?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have python script that checks if the server is up or down, and if it's down it sends out an email along with few system logs. \nWhat I want is to keep checking for the server every 5 minutes, so I put the cronjob as follows:\n*\/5 * * * * \/python\/uptime.sh\nSo whenever the server's down, it sends an email. But I want the script to stop executing (sending more emails) after the first one. \nCan anyone help me out with how to do this? \nThanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":227,"Q_Id":42271330,"Users Score":0,"Answer":"write an empty While True script that runs forever (ex: \"mailtrigger.py\")\nrun it with -nohup mailtrigger.py from shell in infinite loop\nonce the server is down check if mailtrigger.py is running, if its\nnot then terminate mailtrigger.py (kill process id)\n\nyour next iterations will not send mails since mailtrigger.py is not running.","Q_Score":0,"Tags":"python,cron,crontab","A_Id":42295869,"CreationDate":"2017-02-16T10:32:00.000","Title":"Running cronjob every 5 minutes but stopped after first execution?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try to write an script in python for analyse an .stl data file(3d geometry) and say which model is convex or concave and watertight and tell other properties...\nI would like to use and TensorFlow, scikit-learn or other machine learning library. Create some database with examples of objects with tags and in future add some more examples and just re-train model for better results.\nBut my problem is: I don\u00b4t know how to recalculate or restructure 3d data for working in ML libraries. I have no idea.\nThank you for your help.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1021,"Q_Id":42274756,"Users Score":2,"Answer":"You have to first extract \"features\" out of your dataset. These are fixed-dimension vectors. Then you have to define labels which define the prediction. Then, you have to define a loss function and a neural network. Put that all together and you can train a classifier.\nIn your example, you would first need to extract a fixed dimension vector out of an object. For instance, you could extract the object and project it on a fixed support on the x, y, and z dimensions. That defines the features.\nFor each object, you'll need to label whether it's convex or concave. You can do that by hand, analytically, or by creating objects analytically that are known to be concave or convex. Now you have a dataset with a lot of sample pairs (object, is-concave).\nFor the loss function, you can simply use the negative log-probability.\nFinally, a feed-forward network with some convoluational layers at the bottom is probably a good idea.","Q_Score":1,"Tags":"python,machine-learning,3d,tensorflow,scikit-learn","A_Id":42284733,"CreationDate":"2017-02-16T13:02:00.000","Title":"How to analyse 3d mesh data(in .stl) by TensorFlow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My intention is to add a vertical bar to IDLE to indicate preferred line length at column 80.\nI have tried to find a configuration option for the Text tkinter widget that would allow this but have found nothing.\nI was hoping it would be a simple configuration option so I could just add a another item the text_options dictionary within EditorWindow.py found within Python\\Lib\\idlelib.\nI am not sure how styles\/themes work but do they have the capability to change the background colour of only 1 column in a Text widget?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":395,"Q_Id":42309798,"Users Score":0,"Answer":"Outline of possible solution:\n\nCreate a 1-pixel wide Frame, with a contrasting background color, as a child of the Text.\nUse .place() to position the Frame at an appropriate horizontal coordinate.\n\nPossible issues:\n\nI don't see any easy way to get the coordinate for a particular column.  Text.bbox(\"1.80\") looks promising, but doesn't work unless there actually are 80 characters in the line already.  You may have to insert a dummy 80-character line at first, call update_idletasks to get the Text to calculate positions, call bbox to get the coordinates, then delete the dummy text.  Repeat whenever the display font is changed.\nThe line would necessarily appear on top of any text or selection region, which isn't quite the visual appearance I'd expect for a feature like this.","Q_Score":0,"Tags":"python,tkinter,python-idle","A_Id":42333708,"CreationDate":"2017-02-18T00:48:00.000","Title":"Adding a vertical bar or other marker to tkinter Text widgets at a particular column","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"does anyone know how to create or use 2 minibatch sources or inputs a sorted way? My problem is the following:\nI have images named from 0 to 5000 and images named 0_mask to 5000_mask. For each image x the coressponding image x_mask is the regression image for a deconvolution output. So i need a way to tell cntk that each x corresponds to x_match and that there is no regression done between x and y_mask.\nI'm well aware of the cntk convolution sample. I've seen it. The problem are the two input streams with x and x_mask. \nCan i combine them and make the reference, i need it in an easy way?\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":65,"Q_Id":42339941,"Users Score":1,"Answer":"You can create two minibatch sources, one for x and one for x_mask, both with randomize=False. Then the examples will be read in the order in which they are listed in the two map files. So as long as the map files are correct and the minibatch sizes are the same for both sources you will get the images and the masks in the order you want.","Q_Score":1,"Tags":"python,cntk","A_Id":42521000,"CreationDate":"2017-02-20T08:47:00.000","Title":"CNTK 2 sorted minibatch sources","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to draw a rectangle in opencv.\nBut can I choose the length and breadth to be in centi meters?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":408,"Q_Id":42357801,"Users Score":0,"Answer":"Its dependent on the pixel-distance ratio. You can measure this by taking an image of a meter-stick and and measuring its pixel width (for this example say its 1000px). The ratio of pixels to distance is 1000px\/100cm, or 10. You can now use this constant as a multiplier, so for a given length and width in cm., you will just multiply by the ratio, and can get a pixel height and width, which can be passed into opencv's draw rectangle function.","Q_Score":0,"Tags":"python,opencv","A_Id":42357893,"CreationDate":"2017-02-21T02:51:00.000","Title":"Draw rectangle in opencv with length and breadth in cms?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a Project with python and openpyxl.\nIn a Excel file are some cells with conditional formatting. These change the infillcolor, when the value changes. I need to extract the color from the cell. \nThe \"normal\" methode\nworksheet[\"F11\"].fill.start_color.index\ndoesn't work. Excel doesn't interpret the infillcolor from the conditional formatting as infillcolor so i get a '00000000' back for no infill.\nAnyone knows how to get the infillcolor?\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":496,"Q_Id":42372121,"Users Score":1,"Answer":"This isn't possible without you writing some of your own code.\nTo do this you will have to write code that can evaluate conditional formatting because openpyxl is a library for the file format and not a replacement for an application like Excel.","Q_Score":2,"Tags":"python-3.x,spyder,openpyxl","A_Id":42372863,"CreationDate":"2017-02-21T15:58:00.000","Title":"Python\/openpyxl get conditional format","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a \"wargame\" like the ones on overthewire.org or smashthestack.org. When you finish the game, the user should get a python program that has extra permissions to edit a file in \/var\/www\/html so that they     can sign their name. I want to have a program like this so that they can add text to the html file without removing the text of other users and so that it filters offensive words. \nHow can I make a file editable by a specific program in Linux? And how can I make the program edit the file in python? Do I just use os.system?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":42446403,"Users Score":0,"Answer":"I'm going to answer your question but also beg you to consider another approach.\nThe functionality you are looking for is usually handled by a database. If you don't want to use anything more complex, SQLite is often all you need. You would then need a simple web application that connects to the database, grabs the fields, and then injects them into HTML.\nI'd use Flask for this as it comes with Jinja and that's a pretty simple stack to get started with.\nIf you really want to edit the HTML file directly in Python, you will need write permissions for whatever user is running the Python script. On Ubuntu, that folder is typically owned by www-data if you are running Apache.\nThen you'd open the file in Python, perform file operations on it, and then close it.\nwith open(\"\/var\/www\/html\/somefile.txt\", \"a\") as myfile:\n    myfile.write(\"l33t h4x0r has completed the challenge!\\n\")\nThat's an example of how you'd do a simple append operation in Python.","Q_Score":0,"Tags":"python,html,linux,ubuntu","A_Id":42446617,"CreationDate":"2017-02-24T19:04:00.000","Title":"Allow a python file to add to a different file linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I found this error [Error 193] %1 is not a valid Win32 application when i run this python command windll.LoadLibrary(\"C:\\Windows\\System32\\plcommpro.dll\")\nFor this error i found my plcommpro.dll file is not executable file.But I don't know how to make it as a executable file.If someone knows please share me.\nThanks and Best.","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4749,"Q_Id":42477956,"Users Score":6,"Answer":"If you are using a 32 bit Python and the DLL is a 64 bit DLL you will get this error, likewise if the DLL is 32 bit and your Python is 64 bit.\nYou can check this using the dumpbin \/HEADERS <dll filepath> command from a visual studio command prompt.","Q_Score":3,"Tags":"python,dll","A_Id":42478265,"CreationDate":"2017-02-27T04:42:00.000","Title":"Error 193 %1 is not a valid Win32 application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to implement Gaussian Mixture Model using keras with tensorflow backend. Is there any guide or example on how to implement it?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2619,"Q_Id":42479954,"Users Score":3,"Answer":"Are you sure that it is what you want? you want to integrate a GMM into a neural network? \nTensorflow and Keras are libraries to create, train and use neural networks models. The Gaussian Mixture Model is not a neural network.","Q_Score":4,"Tags":"python-3.x,tensorflow,keras,gmm","A_Id":42481143,"CreationDate":"2017-02-27T07:24:00.000","Title":"Implement Gaussian Mixture Model using keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a script with python-pyautogui to automate mouse and keyboard actions. Mouse and keyboard commands are working as per script when keyboard and mouse are connected. I wondered, it still works even when they are not connected. if so it is as per design, may i know how to set the condition to execute the script only if keyboard and mouse are connected??\nKindly share your ideas.\nThanks in advance..","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":371,"Q_Id":42483272,"Users Score":0,"Answer":"PyAutoGUI will still work if there's no keyboard or mouse connected. However, PyAutoGUI does not have any way to detect if a keyboard or mouse are connected to your machine.","Q_Score":0,"Tags":"python-2.7,python-3.x,keyboard,mouse,pyautogui","A_Id":42882714,"CreationDate":"2017-02-27T10:25:00.000","Title":"Pyautogui commands are working even when no mouse or keyboard is connected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know that superusers and regular users are both just django's User objects, but how can I write a custom user class that requires some fields for plain users and doesn't require those fields for superusers?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":535,"Q_Id":42493384,"Users Score":1,"Answer":"You can have a profile class (say UserProfile) with foreign key to the user that is to be created only when user signs up using the website's registration form. That way, superuser which is created on admin site or through command line wouldn't need an extra profile instance attached to it.","Q_Score":2,"Tags":"python,django,python-2.7,django-models","A_Id":42494571,"CreationDate":"2017-02-27T18:40:00.000","Title":"In Django, is it possible for superusers to have different required fields than non-superusers?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Could someone give me an example of using whoosh for a sqlite3 database, I want to index my database. Just a simple connect and searching through the database would be great. I searched online and was not able to find an examples for sqlite3.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":466,"Q_Id":42493984,"Users Score":0,"Answer":"You need to add a post-save function index_data to your database writers. This post-save should get the data to be written in database, normalize it and index it.\nThe searcher could be an independent script given an index and queries to be searched for.","Q_Score":3,"Tags":"python,python-2.7,indexing,sqlite,whoosh","A_Id":51001220,"CreationDate":"2017-02-27T19:16:00.000","Title":"Using Whoosh with a SQLITE3.db (Python)","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After I get the pysvn client, how can I set the working folder to a specific local working folder belonging to a specific repo?\nI'd like to set the working folder so i can then commit changes from there.\nI have tried passing in the path to the client but that doesn't work.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":353,"Q_Id":42497824,"Users Score":0,"Answer":"The simplest way to call pysvn.Client().checkin() is with the absolute path to the working copy top folder. You should then see from svn log that all the changed files where committed.\nBy using an absolute path you avoid issues with the current working directory and relative paths.\nIf this does not help post details of the error message you receive, the version of python, the version of pysvn and your operating system.","Q_Score":0,"Tags":"python,pysvn","A_Id":42912443,"CreationDate":"2017-02-27T23:42:00.000","Title":"PYSVN: how to set local working folder so I can commit a file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently using linux. I have a python script which I want to run as a background service such as the script should start to run when I start my machine. \nCurrently I am using python 2.7 and the command 'python myscripy.py' to run the script.\nCan anyone give an idea about how to do this.\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1140,"Q_Id":42500030,"Users Score":0,"Answer":"You can create init script in \/etc\/init\/ directory\nExample:\n\n\n\n    start on runlevel [2345]\n    stop on runlevel [!2345]\n    kill timeout 5\n    respawn\n\n    script\n       exec \/usr\/bin\/python \/path\/to\/script.py\n    end script\n\n\n\nSave with .conf extension","Q_Score":0,"Tags":"python","A_Id":42500440,"CreationDate":"2017-02-28T04:06:00.000","Title":"Run a python script as a background service in linux","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how traffic flows in SoftLayer between the servers, In course of traffic flow how to detect unusual traffic and how to detect ports that are prone to unusual\/malicious traffic. Can we retrieve this information using any SoftLayer python API's ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":42506643,"Users Score":0,"Answer":"that is not possbile using the Softlayer's API even using the Softlayer's control portal that information is not avaiable.\nregards","Q_Score":0,"Tags":"python-2.7,ibm-cloud-infrastructure","A_Id":42534904,"CreationDate":"2017-02-28T10:47:00.000","Title":"how to get unusual traffic or traffic information in SoftLayer using python API's","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to remove and add completly new db.sqlite3 database to django project written in pycharm?\nI did something wrong and I need completelty new database. The 'flush' command just removes data from databse but it't dosent remove tables schema. So the question is how to get get back my databse to begin point(no data, no sql table)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1356,"Q_Id":42514902,"Users Score":4,"Answer":"A SQLite database is just a file. To drop the database, simply remove the file.\nWhen using SQLite, python manage.py migrate will automatically create the database if it doesn't exist.","Q_Score":1,"Tags":"python,sql,django","A_Id":42515036,"CreationDate":"2017-02-28T17:14:00.000","Title":"How to remove and add completly new db.sqlite3 to django project written in pycharm?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"does anyone of you know how to find \/ click the YT-Like button in Python using selenium since it doesn't have a real Id, etc...\nThanks for the answers","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":378,"Q_Id":42515611,"Users Score":0,"Answer":"you can select with CSS Selector like this:\nif you want to like:\n#watch8-sentiment-actions > span > span:nth-child(1) > button\nif you want cancel like:\n#watch8-sentiment-actions > span > span:nth-child(2) > button","Q_Score":0,"Tags":"python,selenium,button,youtube","A_Id":42515710,"CreationDate":"2017-02-28T17:54:00.000","Title":"Python - Selenium: Find \/ Click YT-Like Button","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently self-learning Spark programming and trying to recode an existing Python application in PySpark. However, I am still confused about how we use regular Python objects in PySpark. \nI understand the distributed data structure in Spark such as the RDD, DataFrame, Datasets, vector, etc. Spark has its own transformation operations and action operations such as .map(), .reduceByKey() to manipulate those objects. However, what if I create traditional Python data objects such as array, list, tuple, or dictionary in PySpark? They will be only stored in the memory of my driver program node, right? If I transform them into RDD, can i still do operations with typical Python function?\nIf I have a huge dataset, can I use regular Python libraries like pandas or numpy to process it in PySpark? Will Spark only use the driver node to run the data if I directly execute Python function on a Python object in PySpark? Or I have to create it in RDD and use Spark's operations?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":854,"Q_Id":42522654,"Users Score":0,"Answer":"You can create traditional Python data objects such as array, list, tuple, or dictionary in PySpark.\nYou can perform most of the operations using python functions in Pyspark.\nYou can import Python libraries in Pyspark and use them to process data in Pyspark\nYou can create a RDD and apply spark operations on them","Q_Score":1,"Tags":"python,python-2.7,apache-spark,pyspark","A_Id":42522820,"CreationDate":"2017-03-01T03:30:00.000","Title":"How Python data structure implemented in Spark when using PySpark?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am trying to intall webdriver and in order to open firefox i need the geckodriver to be installed and in the correct path.\nFirstly the download link to install geckodriver only allows you to install a file that is not an executable. So is there a way to make it an executable?\nsecondly I have tried to change my path variables in commmand prompt, but of course it didn't work. I then changed the user variable not the system path variables because there is not Path in system. there is a Path in user variables so I edited that to change where the file is located. \nI have extracted the geckodriver rar file and have received a file with no extension. I don't know how you can have a file with no extension, but they did it. The icon is like a blank sheet of paper with a fold at the top left. \nIf anyone has a solution for this including maybe another package that is like webdriver and will allow me to open a browser and then refresh the page after a given amount of time. this is all I want to do.","AnswerCount":5,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":66774,"Q_Id":42524114,"Users Score":7,"Answer":"For one make sure you are downloading the one for your OS. Windows is at the bottom of the list it will say win32. Download that file or 64 doesn't matter.\nAfter that you are going to want to extract the file. If you get an error that says there is no file in the Winrar file, this may be because in your Winrar settings you have Winrar set to not extract any files that have the extension .exe. If you go to Winrar options then settings then security you can delete this it will say *.exe, and after you delete that you can extract the file. After that is done, search how to update the path so that gecko driver can be accessed. Then you will most likely need to restart.","Q_Score":8,"Tags":"python,webdriver,geckodriver","A_Id":42542815,"CreationDate":"2017-03-01T05:46:00.000","Title":"how to install geckodriver on a windows system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to intall webdriver and in order to open firefox i need the geckodriver to be installed and in the correct path.\nFirstly the download link to install geckodriver only allows you to install a file that is not an executable. So is there a way to make it an executable?\nsecondly I have tried to change my path variables in commmand prompt, but of course it didn't work. I then changed the user variable not the system path variables because there is not Path in system. there is a Path in user variables so I edited that to change where the file is located. \nI have extracted the geckodriver rar file and have received a file with no extension. I don't know how you can have a file with no extension, but they did it. The icon is like a blank sheet of paper with a fold at the top left. \nIf anyone has a solution for this including maybe another package that is like webdriver and will allow me to open a browser and then refresh the page after a given amount of time. this is all I want to do.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":66774,"Q_Id":42524114,"Users Score":0,"Answer":"I've wrestled with the same question for last hour.\n\nMake sure you have the latest version of Firefox installed.  I had Firefox 36, which, when checking for updates, said it was the latest version.  Mozilla's website had version 54 as latest.  So download Firefox from website, and reinstall.\n\nMake sure you have the latest gecko driver downloaded.\n\nIf you're getting the path error - use the code below to figure out which path python is looking at. Add the geckodriver.exe to the working directory.\n\n\nimport os\nos.getcwd()","Q_Score":8,"Tags":"python,webdriver,geckodriver","A_Id":46927125,"CreationDate":"2017-03-01T05:46:00.000","Title":"how to install geckodriver on a windows system","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Spyder Variable explore only show variables when i run a python script. But while debugging, there is nothing in Spyder Variable explore.\nhow to set?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1166,"Q_Id":42546031,"Users Score":1,"Answer":"This was fixed in Spyder 3.2, which was released in July of 2017.","Q_Score":1,"Tags":"python,anaconda,spyder","A_Id":42579694,"CreationDate":"2017-03-02T02:58:00.000","Title":"how to show variable in Spyder Variable explore while debugging?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going to build an online photo editor using python, but I don't know how to start. My plan is to create a platform online. Users can upload their photos and the system can transform their photos into a style like Ukioyoe from Japan, the ancient wood printing, so the photo outcomes are similar to that. Is there any similar works that have already done or any libraries that can help to do this work? \nThanks for answering.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2065,"Q_Id":42582938,"Users Score":0,"Answer":"Online photo editor means that most of the processing will be done on the client side (i.e. in browser). Python is mostly a server-side language, so I would suggest using some other, more browser-friendly, language (perhaps, JavaScrip?)","Q_Score":0,"Tags":"python,image,photo,editing","A_Id":42583042,"CreationDate":"2017-03-03T15:39:00.000","Title":"Creating a online photo editor in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":10377,"Q_Id":42583082,"Users Score":0,"Answer":"In my case, \/usr\/bin\/python is a symlink that points to \/usr\/bin\/python2.7.\nUsusally, there is a relevant symlink for python2 and python3.\nSo, if you type python2 you get a python-2 interpreter and if you type python3 you get a python-3 one.","Q_Score":0,"Tags":"python,python-2.7,python-3.x","A_Id":42583156,"CreationDate":"2017-03-03T15:46:00.000","Title":"how to switch python interpreter in cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":10377,"Q_Id":42583082,"Users Score":0,"Answer":"It depends on OS (and the way Python has been installed).\nFor most current installations:\n\non Windows, Python 3.x installs a py command in the path that can be used that way:\n\npy -2 launches Python2\npy -3 launches Python3\n\nOn Unix-likes, the most common way is to have different names for the executables of different versions (or to have different symlinks do them). So you can normally call directly python2.7 or python2 to start that version (and python3 or python3.5 for the alternate one). By default only a part of all those symlinks can have been installed but at least one per version. Search you path to find them","Q_Score":0,"Tags":"python,python-2.7,python-3.x","A_Id":42583347,"CreationDate":"2017-03-03T15:46:00.000","Title":"how to switch python interpreter in cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":10377,"Q_Id":42583082,"Users Score":0,"Answer":"As has been mentioned in other answers to this and similar questions, if you're using Windows, cmd reads down the PATH variable from the top down. On my system I have Python 3.8 and 3.10 installed. I wanted my cmd to solely use 3.8, so I moved it to the top of the PATH variable and the next time I opened cmd and used python --version it returned 3.8.\nHopefully this is useful for future devs researching this specific question.","Q_Score":0,"Tags":"python,python-2.7,python-3.x","A_Id":71958209,"CreationDate":"2017-03-03T15:46:00.000","Title":"how to switch python interpreter in cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":10377,"Q_Id":42583082,"Users Score":0,"Answer":"Usually on all major operating systems the commands python2 and python3 run the correct version of Python respectively. If you have several versions of e.g. Python 3 installed, python32 or python35 would start Python 3.2 or Python 3.5. python usually starts the lowest version installed I think.\nHope this helps!","Q_Score":0,"Tags":"python,python-2.7,python-3.x","A_Id":42583188,"CreationDate":"2017-03-03T15:46:00.000","Title":"how to switch python interpreter in cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","AnswerCount":7,"Available Count":5,"Score":0.0,"is_accepted":false,"ViewCount":10377,"Q_Id":42583082,"Users Score":0,"Answer":"If you use Windows OS:\npy -2.7 for python 2.7\npy -3 for python 3.x\nBut first you need to check your PATH","Q_Score":0,"Tags":"python,python-2.7,python-3.x","A_Id":42583177,"CreationDate":"2017-03-03T15:46:00.000","Title":"how to switch python interpreter in cmd?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how to get a progress-bar\/seeker for the QMediaPlayer module on PyQt5... So on my music player application I can have a progress bar for the songs. Thank You in Advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1095,"Q_Id":42602039,"Users Score":2,"Answer":"Your question is a bit broad, bit in general this is what you should do:\n\nCreate a QProgressBar\nCreate your QMediaPlayer\nListen to the currentMediaChanged() signal of your QMediaPlayer module; in your handler fetch the duration of the current media, divide by 1000 to get the length in seconds, set this as the maximum value of your QProgressBar; reset the progressbar.\nListen to the positionChanged() signal of your QMediaPlayer; in the handler fetch the current position; again divide by 1000 and set the value in your QProgressBar with setValue.\n\nThis should give you a progressbar that is automatically updated by the QMediaPlayer.\nYou may wish to disable the text in the progressbar as a percentage isn't really useful for a song playback. Unfortunately there doesn't seem to be an easy way to print the time in the progressbar.","Q_Score":1,"Tags":"qt,python-3.x,user-interface,pyqt5,qmediaplayer","A_Id":42602957,"CreationDate":"2017-03-04T22:17:00.000","Title":"Connect QProgressBar or QSlider to QMediaPlayer for song progress","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a web server using NodeJS - Express and I have a Scikit-Learn (machine learning) model pickled (dumped) in the same machine.\nWhat I need is to demonstrate the model by sending\/receiving data from it to the server. I want to load the model on startup of the web server and keep \"listening\" for data inputs. When receive data, executes a prediction and send it back.\nI am relatively new to Python. From what I've seen I could use a \"Child Process\" to execute that. I also saw some modules that run Python script from Node. \nThe problem is I want to load the model once and let it be for as long as the server is on. I don't want to keep loading the model every time due to it's size. How is the best way to perform that?\nThe idea is running everything in a AWS machine.\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3643,"Q_Id":42610590,"Users Score":6,"Answer":"My recommendation: write a simple python web service (personally recommend flask) and deploy your ML model. Then you can easily send requests to your python web service from your node back-end. You wouldn't have a problem with the initial model loading. it is done once in the app startup, and then you're good to go\nDO NOT GO FOR SCRIPT EXECUTIONS AND CHILD PROCESSES!!! I just wrote it in bold-italic all caps so to be sure you wouldn't do that. Believe me... it potentially go very very south, with all that zombie processes upon job termination and other stuff. let's just simply say it's not the standard way to do that.\nYou need to think about multi-request handling. I think flask now has it by default\nI am just giving you general hints because your problem has been generally introduced.","Q_Score":11,"Tags":"python,node.js,scikit-learn,child-process","A_Id":62075227,"CreationDate":"2017-03-05T16:02:00.000","Title":"Sklearn Model (Python) with NodeJS (Express): how to connect both?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I want to write a decorator that does persistent memoization (memoizing to disk). Since I want to use this decorator for many functions, I have to decide where to save memoizing data for these functions. I googled around and found two solutions:\n\nlet the functions decide where to store the memoizing data\nautomatically determine where to store the data by function names\n\nHowever, in these two solutions, it is necessary for every function to \"know\" each other in case of colliding of names (or destinations), which is a smell of bad design. \nThus, my question is, how to avoid such collidings?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":74,"Q_Id":42616958,"Users Score":1,"Answer":"Save it in something next to or related to __file__, which is the path to the file the module was loaded from.  I believe in some cases it can be a relative path, so you might want to store the memos in that path directly, or turn it into an absolute path or something.","Q_Score":0,"Tags":"python","A_Id":42618800,"CreationDate":"2017-03-06T03:13:00.000","Title":"destination of python persistent memoization","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using MXNet on IRIS dataset which has 4 features and it classifies the flowers as -'setosa', 'versicolor', 'virginica'. My training data has 89 rows. My label data is a row vector of 89 columns. I encoded the flower names into number -0,1,2 as it seems mx.io.NDArrayIter does not accept numpy ndarray with string values. Then I tried to predict using\nre = mod.predict(test_iter) \nI get a result which has the shape 14 * 10.\nWhy am I getting 10 columns when I have only 3 labels and how do I map these results to my labels. The result of predict is shown below:\n\n[[ 0.11760861 0.12082944 0.1207106 0.09154381 0.09155304 0.09155869\n  0.09154817 0.09155204 0.09154914 0.09154641] [ 0.1176083 0.12082954 0.12071151 0.09154379 0.09155323 0.09155825\n  0.0915481 0.09155164 0.09154923 0.09154641] [ 0.11760829 0.1208293 0.12071083 0.09154385 0.09155313 0.09155875\n  0.09154838 0.09155186 0.09154932 0.09154625] [ 0.11760861 0.12082901 0.12071037 0.09154388 0.09155303 0.09155875\n  0.09154829 0.09155209 0.09154959 0.09154641] [ 0.11760896 0.12082863 0.12070955 0.09154405 0.09155299 0.09155875\n  0.09154839 0.09155225 0.09154996 0.09154646] [ 0.1176089 0.1208287 0.1207095 0.09154407 0.09155297 0.09155882\n  0.09154844 0.09155232 0.09154989 0.0915464 ] [ 0.11760896 0.12082864 0.12070941 0.09154408 0.09155297 0.09155882\n  0.09154844 0.09155234 0.09154993 0.09154642] [ 0.1176088 0.12082874 0.12070983 0.09154399 0.09155302 0.09155872\n  0.09154837 0.09155215 0.09154984 0.09154641] [ 0.11760852 0.12082904 0.12071032 0.09154394 0.09155304 0.09155876\n  0.09154835 0.09155209 0.09154959 0.09154631] [ 0.11760963 0.12082832 0.12070873 0.09154428 0.09155257 0.09155893\n  0.09154856 0.09155177 0.09155051 0.09154671] [ 0.11760966 0.12082829 0.12070868 0.09154429 0.09155258 0.09155892\n  0.09154858 0.0915518 0.09155052 0.09154672] [ 0.11760949 0.1208282 0.12070852 0.09154446 0.09155259 0.09155893\n  0.09154854 0.09155205 0.0915506 0.09154666] [ 0.11760952 0.12082817 0.12070853 0.0915444 0.09155261 0.09155891\n  0.09154853 0.09155206 0.09155057 0.09154668] [ 0.1176096 0.1208283 0.12070892 0.09154423 0.09155267 0.09155882\n  0.09154859 0.09155172 0.09155044 0.09154676]]","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":158,"Q_Id":42641657,"Users Score":1,"Answer":"Using \"y = mod.predict(val_iter,num_batch=1)\" instead of \"y = mod.predict(val_iter)\", then you can get only one batch labels. For example,if you batch_size is 10, then you will only  get the 10 labels.","Q_Score":1,"Tags":"python,mxnet","A_Id":43152282,"CreationDate":"2017-03-07T06:29:00.000","Title":"mod.predict gives more columns than expected","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to start a python script that will parse a csv file uploaded from the UI by the user.  On the client side, how do I make a call to start the python script (I've read AJAX http requests work)?  And then secondly, how do I take the user input (just a simple user upload with the  HTML tag) which will be read by the python script?\nThe back end python script works perfectly through the command line, I just need to create a front end for easier use.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":899,"Q_Id":42660299,"Users Score":0,"Answer":"Many (if not all) server side technology can solve your problem: CGI, Java Servlet, NodeJS, Python, PHP etc. \nThe steps are: \n\nIn browser, upload file via AJAX request.\nIn server, receive file sent from browser, save it somewhere in server disk.\nAfter file is saved, invoke your python script to handle the file.\n\nAs your current script is written by Python, I guess Python is the best choice for server side technology.","Q_Score":0,"Tags":"javascript,jquery,python,ajax,http","A_Id":42662740,"CreationDate":"2017-03-07T23:29:00.000","Title":"Start python script from client side","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to construct clusters out of a set of data using the Kmeans algorithm from SkLearn. I want to know how one can determine whether the algorithm actually converged to a solution for one's data. \nWe feed in the tol parameter to define the tolerance for convergence but there is also a max_iter parameter that defines the number of iterations the algorithm will do for each run. I get that the algorithm may not always converge within the max_iter times of iterations. So is there any attribute or a function that I can access to know if the algorithm converged before the max_iter iterations ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2975,"Q_Id":42666255,"Users Score":4,"Answer":"You have access to the n_iter_ field of the KMeans class, it gets set after you call fit (or other routines that internally call fit.\nNot your fault for overlooking that, it's not part of the documentation, I just found it by checking the source code ;)","Q_Score":2,"Tags":"python,scikit-learn,k-means","A_Id":42684721,"CreationDate":"2017-03-08T08:20:00.000","Title":"Sklearn K means Clustering convergence","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I  use nosetests and allure framework for reporting purposes. In order to make the report look like I want, I have to add @nose.allure.feature('some feature') decorator to each test. The problem is that I have over 1000 test. Is there any way to modify tests before execution? \nI was thinking about custom nose plugin, but not sure how can it be implemented.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":42667584,"Users Score":0,"Answer":"How about adding the decorator to the test classes instead?\nNot sure if it will work, but sometimes works nicely for @patch.","Q_Score":0,"Tags":"python,nose,allure","A_Id":42684514,"CreationDate":"2017-03-08T09:32:00.000","Title":"Nosetest: add decorator for tests before execution","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using jupyter notebook with anaconda3 package but I want to use jupyter with anaconda2 and the package I have already installed! how can I add anaconda2 to jupyter kernel?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":668,"Q_Id":42678845,"Users Score":-1,"Answer":"try changing the file directory from the python 3.5 to python 2.7.e.g C:\\Users\\python36 to  C:\\Users\\python27 in ipython settings or preferences","Q_Score":0,"Tags":"python-2.7,python-3.x,ipython,anaconda,jupyter-notebook","A_Id":42682359,"CreationDate":"2017-03-08T18:13:00.000","Title":"how can I change ipython kernel to python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a mac running OS X.  Although it has Python 2.7 preinstalled, I used home-brew to install Python 3.5, which works great.  Now I'm looking to add modules using pip.  Trouble is, when I used pip in the terminal, it looks like the module was installed, however, my Python 3.5 doesn't see it.  After a bit of digging, I suspect the problem is that my pip is pointed at the the Apple 2.7 Python version and I realize the answer is I need to change the config on pip to point at the 3.5 version of python, but I can't make any sense of the brew file structure in order to know where to point it at.  And, as I dig through the Cellar, I see multiple versions of pip, so I'm not even sure I'm using the right one, but not sure how to call the right one from the terminal.  I'm sure this is very straightforward to experienced users, but I'm lost.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":152,"Q_Id":42682326,"Users Score":0,"Answer":"I found the answer in the documentation for homebrew.  For Homebrew python, you must use \"pip3 install \" instead of \"python -m pip install \"\nThere were two other issues that complicated this.\n1. I had previously manually installed python 3.5.  The bash profile was configured to point to this before \/usr\/local\/bin.\n2. In the documentation of pip, it mentions that the CLI command \"pip\" points to the last version of python that used it.  So using \"pip\" alone was causing pip to load the modules into the 2.7 version of the python.\nTo fix this, I deleted the manually installed version, I removed the garbage from the bash profile, then it everything seemed to work.","Q_Score":1,"Tags":"python,pip,homebrew","A_Id":42702937,"CreationDate":"2017-03-08T21:34:00.000","Title":"Understanding pip and home-brew file structure","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I used celery + requests first in python2.7,and it works fine,but I heard celery + aiohttp is faster,so I test it in python3, and it really fast,but then I found I can't use celery to start my program write in python2.7,because there are changes between them ,I use command line to start celery only get errors\nI guess I should just uninstall the celery of python3?\nIs there a better way to do this?\nIn fact,I guess since there are many package works for both p2,p3,and use commandline to start,there must have a good solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":60,"Q_Id":42686125,"Users Score":1,"Answer":"What you need is a virtual environment. A virtual environment encapsulates a Python install, along with all the pip packages And executable files such as celery. check out the virtualenv and virtualenvwrapper Python packages.","Q_Score":0,"Tags":"python,celery","A_Id":42686288,"CreationDate":"2017-03-09T03:29:00.000","Title":"how to use command line to start celery when I install it both in python2,python3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I currently have a flask application that uses Flask-Security to handle user login and registration. I'm trying to test a chatroom I made so I want to login to two different accounts in different windows to check if it works. However I can't do that because when I login to account2 it simply logs out account1 in my other browser. I'm certain this has something to do with Flask-Login and user sessions but I'm not sure how to fix this issue. If anyone could point me in the right direction that'd be awesome.\nI tried looking at the LoginManger docs on Flask-Login's site but can't figure out how to disable cookies.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1395,"Q_Id":42710628,"Users Score":0,"Answer":"I was using the same type of browser to try and log into different accounts. Such as two firefox browsers and I tried two firefox incognito browsers. Which in both cases I think they shared the same cookies. After trying with one Chrome and one Firefox it worked correctly.","Q_Score":3,"Tags":"python,flask,flask-login,flask-security","A_Id":42752122,"CreationDate":"2017-03-10T05:05:00.000","Title":"Flask multiple login from same computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I have a diagonal matrix with diagonal 100Kx1 and how can I to get its pseudo inverse?\nI won't be able to diagonalise the matrix and then get the inverse like I would do for small matrix so this won't work\nnp.linalg.pinv(np.diag(D))","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":945,"Q_Id":42711310,"Users Score":2,"Answer":"Just take the reciprocals of the nonzero elements. You can check with a smaller diagonal matrix that this is what pinv does.","Q_Score":1,"Tags":"python,numpy,matrix","A_Id":42711798,"CreationDate":"2017-03-10T06:00:00.000","Title":"How to get the pseudo inverse of a huge diagonal matrix in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, I'm trying to deploy a Django Web App to production, but I want to change the secret key before doing so.\nI've attempted to generate a new key using a randomizing function and insert that new key in place of the old one. When I do so, I get an error that says the following:\n\nAttributeError 'module' object has no attribute 'JSONEncoder' ...\n  Exception Location ...\/django\/contrib\/messages\/storage\/cookie.py in\n  , line 9\n\nI've deleted the browser cache and restarted the server, but the error persists.\nI've also attempted to change the key back, after deleting the browser cache and restarting, the error still persists.\nAny idea how to resolve this issue?\nEdit: Python version is 2.6.6 and Django version is 1.3.1","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":4502,"Q_Id":42726719,"Users Score":7,"Answer":"So, to answer my own question, changing the assigned key is done the same way you'd change any other variable. Just create a 50 character (ideally random) string and set SECRET_KEY equal to it.\nSECRET_KEY = \"#$%&N(ASFGAD^*(%326n26835625BEWSRTSER&^@T#%$Bwertb\"\nThen restart the web application.\nMy problem was completely unrelated. It occurred because I set the path python uses to locate packages to a weird location. Sorry about that guys.","Q_Score":8,"Tags":"python,django,secret-key","A_Id":42772208,"CreationDate":"2017-03-10T19:57:00.000","Title":"How can i properly change the assigned secret key in a Django Web Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Lets say we have \n{'Pop': 5}\nand we have a variable\na = 'store'\nhow could I get the output:\n{'store': {'pop': 5}} \nIs there a easy way?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":553,"Q_Id":42730894,"Users Score":0,"Answer":"You can put a dictionary inside a dictionary.\nTry it:\nprint({a:{'pop':5}})","Q_Score":0,"Tags":"python,dictionary","A_Id":42730914,"CreationDate":"2017-03-11T03:09:00.000","Title":"Putting a dictionary inside a dictionary?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Many people here tell you to use threading but how do you have the rest of the program running while that thread sleeps, and reruns, and sleeps again.. etc. \nI have tried normal threading with things like a while loop but that didn't work for me\nedit: so the question is: how do you sleep a thread without pausing the whole program in python, if possible could you give me a example of how to do it?\nedit 2: and if possible without tkinter\nedit 3: fixed it, it already worked but i didn't see it because printing doesn't work across threads... Silly me.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1227,"Q_Id":42738434,"Users Score":0,"Answer":"Silly me, threading works but printing doesn't work across threads. Thanks for all the help!","Q_Score":1,"Tags":"python,multithreading,python-2.7,loops,sleep","A_Id":42745207,"CreationDate":"2017-03-11T17:38:00.000","Title":"python how to loop a function with wait without pausing the whole program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have question that I am having a hard time understanding what the code might look like so I will explain the best I can. I am trying to view and search a NUL byte and replace it with with another NUL type byte, but the computer needs to be able to tell the difference between the different NUL bytes. an Example would be Hex code 00 would equal NUL and hex code 01 equals SOH. lets say I wanted to create code to replace those with each other. code example\n\nTextFile1 = Line.Replace('NUL','SOH')\nTextFile2.write(TextFile1)\n\nYes I have read a LOT of different posts just trying to understand to put it into working code. first problem is I can't just copy and paste the output of hex 00 into the python module it just won't paste. reading on that shows 0x00 type formats are used to represent that but I'm having issues finding the correct representation for python 3.x\n\nPrint (\\x00)\noutput = nothing shows   #I'm trying to get output of 'NUL' or as hex would show '.' either works fine --Edited\n\nso how to get the module to understand that I'm trying to represent HEX 00 or 'NUL' and represent as '.' and do the same for SOH, Not just limited to those types of NUL characters but just using those as exmple because I want to use all 256 HEX characters. but beable to tell the difference when pasting into another program just like a hex editor would do. maybe I need to get the two programs on the same encoding type not really sure. I just need a very simple example text as how I would search and replace none representable Hexadecimal characters and find and replace them in notepad or notepad++, from what I have read, only notepad++ has the ability to do so.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4065,"Q_Id":42740284,"Users Score":0,"Answer":"another equivalent way to get the value of \\x00 in python is chr(0) i like that way a little better over the literal versions","Q_Score":1,"Tags":"python,python-3.x,nul","A_Id":58441607,"CreationDate":"2017-03-11T20:31:00.000","Title":"Nul byte representation in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a script where I used a few command-line tools are utilised. However I've hit an issue where I am trying to convert two videos into one video (which I can do) however this is meant to be an idle process and when I run this command with subprocess.call() it prompted me with a 'A file with this name already exists, would you like to overwrite it [y\/n]?' and now I am stuck on how to emulate a users input of 'y' + Enter.\nIt could be a case of running it as admin (somehow) or using pipes or this Stdout stuff I read about but didn't really understand. How would you guys approach this? What do you think the best technique? \nCheers guys, any help is immensely appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":42766823,"Users Score":1,"Answer":"Often, tools you are calling have a -y flag to automatically answer surch questions with yes.","Q_Score":0,"Tags":"python,command-line,subprocess","A_Id":42767271,"CreationDate":"2017-03-13T15:00:00.000","Title":"Subprocess emulate user input after command","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have tried to run the Holoviews examples from the Holoviews website.\nI have:\n\nbokeh 0.12.4.\nholoviews 1.6.2 py27_0 conda-forge\n\nHowever, following any of the tutorials I get an error such as the following and am unable to debug:\nAttributeError: 'Image' object has no attribute 'set'.\nIs anyone able to guide me as to how to fix this?\nCheers\nEd","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":997,"Q_Id":42771938,"Users Score":0,"Answer":"There are some changes in bokeh 0.12.4, which are incompatible with HoloViews 1.6.2. We will be releasing holoviews 1.7.0 later this month, until then you have the option to downgrading to bokeh 0.12.3 or upgrading to the latest holoviews dev release with:\nconda install -c ioam\/label\/dev holoviews\nor \npip install https:\/\/github.com\/ioam\/holoviews\/archive\/v1.7dev7.zip","Q_Score":0,"Tags":"python,bokeh,holoviews","A_Id":42772141,"CreationDate":"2017-03-13T19:31:00.000","Title":"Holoviews: AttributeError: 'Image' object has no attribute 'set'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I'm working with sqlalchemy and oracle, but I don't want to store the database password directly in the connection string, how to store a encrypted password instead?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3865,"Q_Id":42776941,"Users Score":0,"Answer":"Encrypting the password isn't necessarily very useful, since your code will have to contains the means to decrypt.  Usually what you want to do is to store the credentials separately from the codebase, and have the application read them at runtime.  For example*:\n\nread them from a file\nread them from command line arguments or environment variables (note there are operating system commands that can retrieve these values from a running process, or they may be logged)\nuse a password-less connection mechanism, for example Unix domain sockets, if available\nfetch them from a dedicated secrets management system\n\nYou may also wish to consider encrypting the connections to the database, so that the password isn't exposed in transit across the network.\n\n* I'm not a security engineer: these examples are not exhaustive and may have other vulnerabilities in addition to those mentioned.","Q_Score":2,"Tags":"python,oracle,sqlalchemy","A_Id":70789442,"CreationDate":"2017-03-14T02:53:00.000","Title":"How to use encrypted password in connection string of sqlalchemy?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a web python application with tornado framework on a raspberry pi.\nWhat i actually do is to connect to my raspberry with ssh. I am writing my source code with vi, on the raspberry.\nWhat i want to do is to write source code on my development computer but i do not know how to synchronize (transfer) this source code to raspberry.\nIt is possible to do that with ftp for example but i will have to do something manual.\nI am looking for a system where i can press F5 on my IDE and this IDE will transfer modified source files. Do you know how can i do that ?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":42787560,"Users Score":0,"Answer":"Following a couple of bad experiences where I lost code which was only on my Pi's SD card, I now run WinSCP on my laptop, and edit files from Pi on my laptop, they open in Notepad++ and WinSCP automatically saves edits to Pi. And also I can use WinSCP folder sync feature to copy contents of SD card folder to my latop. Not perfect, but better what I was doing before","Q_Score":0,"Tags":"python,version-control,raspberry-pi","A_Id":42787653,"CreationDate":"2017-03-14T13:38:00.000","Title":"Synchronize python files between my development computer and my raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a web python application with tornado framework on a raspberry pi.\nWhat i actually do is to connect to my raspberry with ssh. I am writing my source code with vi, on the raspberry.\nWhat i want to do is to write source code on my development computer but i do not know how to synchronize (transfer) this source code to raspberry.\nIt is possible to do that with ftp for example but i will have to do something manual.\nI am looking for a system where i can press F5 on my IDE and this IDE will transfer modified source files. Do you know how can i do that ?\nThanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":334,"Q_Id":42787560,"Users Score":0,"Answer":"I have done this before using bitbucket as a standard repository and it is not too bad. If you set up cron scripts to git pull it's almost like continuous integration.","Q_Score":0,"Tags":"python,version-control,raspberry-pi","A_Id":54502688,"CreationDate":"2017-03-14T13:38:00.000","Title":"Synchronize python files between my development computer and my raspberry","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I have done:\n1- Created a web form using HTML and javascript to create a SSL certificate that can create dynamic certificates.\n2- Successfully parsed through an existing certificate and passed the required values to the web form.\n3- I am using the HTML+javascript inside the python script itself and appending the parsed certificate values to the javascript before displaying it.\nWhat I need to do:\n1-Take values from the web form, assign those to particular variables and pass those variables to a python script, that can create a CSR using those and sign it using a dummy key.\nSo, basically, I want to call a python script on a click of a button that can take web form values and create a certificate.\nP.S. PHP isn't an option for me, as the server I am working on doesn't support it.\nCan someone guide me in the right direction as for how to proceed? Any examples or study material? Or should I start working with Flask?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":134,"Q_Id":42801569,"Users Score":1,"Answer":"Django is a good option to create applications using python. You can start an application, and embed your code in template and write a view to handle requests and responses.","Q_Score":0,"Tags":"javascript,python,ssl,x509certificate","A_Id":42801616,"CreationDate":"2017-03-15T05:13:00.000","Title":"Using javascript to pass web forms values to python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to send an image from node js script to python script using python-shell. From what I know, I should use binary format. \nI know that in python side I can use this 2 functions:\nimport sys\nsys.stdout.write() and sys.stdin.read()\nBut I am not sure how the node js side gonna be? (Which functions can I use and how can I use them?)","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":631,"Q_Id":42804006,"Users Score":0,"Answer":"I tried to encode the image and send it but It did not work. So I used Socket programming instead and It worked wonderfully.","Q_Score":1,"Tags":"javascript,python,node.js","A_Id":42963477,"CreationDate":"2017-03-15T08:00:00.000","Title":"Sending Images from nodejs to Python script via standard input\/output","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a code which outputs an N-length Numpy array at every iteration. \nEg. -- theta = [ 0, 1, 2, 3, 4 ]\nI want to be able to save the arrays to a text file or .csv file dynamically such that I can load the data file later and extract appropriately which array corresponds to which iteration. Basically, it should be saved in an ordered fashion.\nI am assuming the data file would look something like this:-\n0 1 2 3 4\n1 2 3 4 5\n2 3 4 5 6 ... (Random output)\nI thought of using np.c_ but I don't want to overwrite the file at every iteration and if I simply save the terminal output as > output.txt, it saves as arrays including the brackets. I don't know how to read such a text file.\nIs there a proper method to do this, i.e. write and read the data?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":741,"Q_Id":42817337,"Users Score":0,"Answer":"How about ndarray's .tofile() method? To read use numpy.fromfile().","Q_Score":0,"Tags":"python,arrays,numpy,save","A_Id":42817461,"CreationDate":"2017-03-15T17:59:00.000","Title":"How do I save numpy arrays such that they can be loaded later appropriately?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python's XGBRegressor and R's xgb.train with the same parameters on the same dataset and I'm getting different predictions. \nI know that XGBRegressor uses 'gbtree' and I've made the appropriate comparison in R, however, I'm still getting different results. \nCan anyone lead me in the right direction on how to differentiate the 2 and\/or find R's equivalence to python's XGBRegressor?\nSorry if this is a stupid question, thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1321,"Q_Id":42819987,"Users Score":1,"Answer":"Since XGBoost uses decision trees under the hood it can give you slightly different results between fits if you do not fix random seed so the fitting procedure becomes deterministic.\nYou can do this via set.seed in R and numpy.random.seed in Python.\nNoting Gregor's comment you might want to set nthread parameter to 1 to achieve full determinism.","Q_Score":1,"Tags":"python,r,machine-learning,scikit-learn,xgboost","A_Id":42821370,"CreationDate":"2017-03-15T20:24:00.000","Title":"Python's XGBRegressor vs R's XGBoost","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project where i do need to do a communication in 3 parts. Let me explain:\n1.- The user fills a form, which is used to create a set of objects from the models. This objects are not saved in the database on this moment. All the objects are related between them.\n2.- This objects must be saved in some way for an admin user to check the data and decide if proceed to save it, or if any element is invalid and reject the form.\n3.- If the admin decide that the data is correct, select an option to send a .save() to add the data to the database.\nAt least that's the idea i have on how should work. I decided to create the objects before send it to the admin because it sounded easier to show that if i sended the request.POST and the request.FILES. My problem is that i don't know where could save the objects to show it to the admin when he connects(There are 2 types of users, Normal and Admin, the normal are the ones that fill the forms, the admins only check it, the two of them has their own views). So, does anyone how could i send the data and storage it until the admin connects? I'm open to any idea if this is not possible, the only thing that is necesary is the flow of: User fills the form, admin check it, data is saved or rejected.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":38,"Q_Id":42823336,"Users Score":1,"Answer":"You will want to save() them when the user submits the form at the start. Add a BooleanField to your model that says whether the row has been moderated and accepted. Then in your application, filter out all non-moderated rows, and on the admin side, filter out only rows that need moderation.","Q_Score":1,"Tags":"python,django","A_Id":42823497,"CreationDate":"2017-03-16T00:43:00.000","Title":"How to storage objects for communication without the database in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a receipt creator where you \"buy\" products then go to the checkout to confirm you want to \"buy\" your items.(this is just a python program, you don't spend money). \nHowever, i feel like this could become extremely easy for me if i could put the names of all of the items in one array, the GTIN 8 number into another and the price into a final array. \nMy problem is that I MUST use some sort of text document to store the items with their GTIN 8 number and their price. Is it possible to do this, and if so, how?\nHere is an example of a document that i would use:\nGTIN 8 NO.  NAME. PRICE.\n66728009, NET, 10.00\n74632558, OATMEAL, 5.00\n05103492, FISHING ROD, 20.00\n45040122, FISH BAIT, 5.00\n20415112, MILK, 2.00\n37106560, SHOES, 25.00\n51364755, T-SHIRT, 10.00\n64704739, TROUSERS, 15.00\n47550544, CEREAL, 2.00 \n29783656, TOY, 10.00","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":42830209,"Users Score":0,"Answer":"Just read your text document, pick up rights informations, then put in in 3 differents arrays for name, GTIN, and price. Maybe you can show what your document looks like.","Q_Score":0,"Tags":"python,arrays","A_Id":42830903,"CreationDate":"2017-03-16T09:37:00.000","Title":"Python: how to add different part of a text document to different arrays","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I go to \"tools\" and select \"python console\", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks!","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":41595,"Q_Id":42846803,"Users Score":2,"Answer":"If you use Win 10, 64Bits. Run your codes using Ctrl + Shift + F10 or simply right click on the workspace and click Run from the options.","Q_Score":5,"Tags":"python,pycharm","A_Id":47140011,"CreationDate":"2017-03-16T23:48:00.000","Title":"How to run code in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I go to \"tools\" and select \"python console\", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks!","AnswerCount":4,"Available Count":3,"Score":0.049958375,"is_accepted":false,"ViewCount":41595,"Q_Id":42846803,"Users Score":1,"Answer":"in mac.\nyou can use fn+shift+f10 and happy coding with python","Q_Score":5,"Tags":"python,pycharm","A_Id":49919793,"CreationDate":"2017-03-16T23:48:00.000","Title":"How to run code in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I go to \"tools\" and select \"python console\", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks!","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":41595,"Q_Id":42846803,"Users Score":0,"Answer":"Right click on project name \/ select New \/ select Python File\nPycharm needs to know you're running a Python file before option to run is available","Q_Score":5,"Tags":"python,pycharm","A_Id":52305481,"CreationDate":"2017-03-16T23:48:00.000","Title":"How to run code in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python file named abc.py. I can run it in mongodb with the help of robomongo but i couldnt run it in cmd. Can anyone tell me how to run a .py file in mongodb using cmd ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":82,"Q_Id":42853347,"Users Score":0,"Answer":"First you need to ensure that your directory is in the correct folder.\nfor example you can write cd name_of_folder\nthen to run it you need to typepython your_filen_name.py","Q_Score":0,"Tags":"python,mongodb,pymongo","A_Id":65763003,"CreationDate":"2017-03-17T09:13:00.000","Title":"how to run python file in mongodb using cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a worker application written in python for a distributed system. There is a situation when I need to start multiple instances of this worker on a single server. Logging should be written into file I suspect that I cannot write to the same file from different instances. So what should I do, pass log-file name as command line argument to each instance? Is there a standard approach for such situation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":303,"Q_Id":42859075,"Users Score":0,"Answer":"I will use MySQL. This way I will have a standard tool for log analysis (MySQL Workbench), will solve the problem with multiple instance logging serialization. The best way would be probably to write a handler to standard logging module but at the moment I'll sent all messages through rabbitmq to service that stores them.","Q_Score":0,"Tags":"python,logging,distributed-computing,multiple-instances","A_Id":42872180,"CreationDate":"2017-03-17T13:40:00.000","Title":"If I have multiple instance of the same python application running how to perform logging into file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am planning to automate a process of cleaning file systems in Linux using a set of scripts in Shell, Python and I'll create a simple dashboard using Node.js to allow a more visual approach.\nI have a script in Shell which already cleans a file system in a specific server - but I have to login and then issue this command. Now I am proceeding with a dashboard in HTML\/CSS\/JS to visualize all servers which are having space problems.\nMy idea is: create a Python scrip to login and get a list of filesystems and its usage and update a single JSON file, then, my dashboard uses this JSON to feed the screen.\nMy question is how to get the list of file system in Linux and its usage?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":1490,"Q_Id":42873222,"Users Score":-1,"Answer":"You can use command \ndf\nProvides an option to display sizes in Human Readable formats  (e.g., 1K 1M 1G) by using \u2018-h\u2019.This is the most common command but\nyou can also check du and di. di in fact provides even more info than df.","Q_Score":2,"Tags":"python,json,linux,shell,automation","A_Id":42874372,"CreationDate":"2017-03-18T10:34:00.000","Title":"Get a list of all mounted file systems in Linux with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Followings are the result  after profiling using %time in ipython-\nsingle-thread:\n  CPU time: user 6m44s sys 1.78s total 6m46s\n  Wall time: 5m19s\n4-thread:\n  CPU time: user 10m12s sys 2.83s total 10m15s\n  Wall time: 4m14s\nShouldn't CPU time be lesser for multi-threaded code ?\nAlso, how can be CPU time be more than wall time, as wall time is total elapsed time. Could you please clarify these terminology.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":141,"Q_Id":42881071,"Users Score":2,"Answer":"No CPU time is the time spent by all cpus on the task. So if cpu1 spent 2 minutes on a task and cpu2 spent 3 minutes on the same task the cpu time will be 1 + 3 = 4.\nSo in multithreaded programs we would expect that cpu time will usually be more than the wall time.\nNow you might ask why does the same hold for your single-threaded program. The answer will probably be that even if your code does not explicitly use parallelism, there is probably a library you use that does.","Q_Score":1,"Tags":"python,multithreading,performance,time,benchmarking","A_Id":42881144,"CreationDate":"2017-03-18T23:24:00.000","Title":"how to analyze cpu time while benchmarking in python (multiprocessing)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone tell me commands to get contrib module for anaconda\nI need that module for \n matches = flann.knnMatch(des1,des2,k=2)\nto run correctly\nerror thrown is \ncv2.error: ......\\modules\\python\\src2\\cv2.cpp:163: error: (-215) The data should normally be NULL! in function NumpyAllocator::allocate\nAlso I am using Anaconda openCV version 3, and strictly dont want to switch to lower versions \nP.S. as suggested at many places to edit file cv2.cpp option is not available with anaconda.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":29093,"Q_Id":42886286,"Users Score":1,"Answer":"The question is old but I thought to update the answer with the latest information. My Anaconda version is 2019.10 and build channel is py_37_0 . I  used pip install opencv-python==3.4.2.17 and pip install opencv-contrib-python==3.4.2.17. Now they are also visible as installed packages in Anaconda navigator and I am able to use patented methods like SIFT etc.","Q_Score":10,"Tags":"python,opencv,anaconda,conda","A_Id":62689216,"CreationDate":"2017-03-19T11:56:00.000","Title":"how to get opencv_contrib module in anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Can anyone tell me commands to get contrib module for anaconda\nI need that module for \n matches = flann.knnMatch(des1,des2,k=2)\nto run correctly\nerror thrown is \ncv2.error: ......\\modules\\python\\src2\\cv2.cpp:163: error: (-215) The data should normally be NULL! in function NumpyAllocator::allocate\nAlso I am using Anaconda openCV version 3, and strictly dont want to switch to lower versions \nP.S. as suggested at many places to edit file cv2.cpp option is not available with anaconda.","AnswerCount":6,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":29093,"Q_Id":42886286,"Users Score":14,"Answer":"I would recommend installing pip in your anaconda environment then just doing: pip install opencv-contrib-python. This comes will opencv and opencv-contrib.","Q_Score":10,"Tags":"python,opencv,anaconda,conda","A_Id":44329928,"CreationDate":"2017-03-19T11:56:00.000","Title":"how to get opencv_contrib module in anaconda","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was trying to download a Python wrapper called rawpy on my Windows machine. I used the command \"pip install rawpy\". I have already looked at many other SO threads but could find no solution. The exact error is :\n\nIO Error: [Errno 2] No such file or directory:\n  'external\/LibRawcmake\/CMakeLists.txt'\n\nThe only dependency for the wrapper is numpy, which I successfully installed. I would like to know how to fix this. Quite new to Python, so any information would help.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1408,"Q_Id":42916551,"Users Score":0,"Answer":"User letmaik was able to help me with this. It turned out that the error was caused by my version of pip being too old. The command \"python -m pip install -U pip\" did not work to upgrade pip; \"easy_install -U pip\" was required. This allowed rawpy to be installed successfully.","Q_Score":1,"Tags":"python,file,windows-7","A_Id":42988360,"CreationDate":"2017-03-21T00:49:00.000","Title":"python - IO Error [Errno 2] No such file or directory when downloading package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"When thinking of the why a interpeter work:\nparse code -> producer machine byte code -> allocate exec mem -> run\nhow can it be done in wasm?\nthanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":763,"Q_Id":42919339,"Users Score":4,"Answer":"If you are actually implementing an interpreter then you don't need to generate machine code at runtime, so everything can stay within Wasm.\nWhat you actually seem to have in mind is a just-in-time compiler. For that, you indeed have to call back into the embedder (i.e., JavaScript in the browser) and create and compile new Wasm modules there on the fly, and link them into the running program -- e.g., by adding new functions to an existing table. The synchronous compilation\/instantiation interface exists for this use case.\nIn future versions it may be possible to invoke the compilation API directly from within Wasm, but for now going through JavaScript is the intended approach.","Q_Score":3,"Tags":"javascript,python,c,webassembly","A_Id":42920349,"CreationDate":"2017-03-21T05:50:00.000","Title":"Compile a JIT based lang to Webassembly","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to create a hive udf with transform and using, but I can't use sklearn because not all the node in hive cluster has sklearn.\nI have an anaconda2.tar.gz with sklearn, What should I do ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":314,"Q_Id":42927141,"Users Score":0,"Answer":"I recently started looking into this approach and I feel like the problem is not about to get all the 'hive nodes' having sklearn on them (as you mentioned above), I feel like it is rather a compatibility issue than 'sklearn node availability' one. I think sklearn is not (yet) designed to run as a parallel algorithm such that large amount of data can be processed in a short time.\n\nWhat I'm trying to do, as an approach, is to communicate python to 'hive' through 'pyhive' (for example) and implement the necessary sklearn libraries\/calls within that code. The rough assumption here that this 'sklearn-hive-python' code will run in each node and deal with the data at the 'map-reduce' level. \nI cannot say this is the right solution or correct approach (yet) but this is what I can conclude after searching for sometime.","Q_Score":0,"Tags":"python,hive,package,udf","A_Id":43289954,"CreationDate":"2017-03-21T12:26:00.000","Title":"How to create an udf for hive using python with 3rd party package like sklearn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"so I am trying to install kivy on my mac.From their instructions page, I am on step 2, and have to enter the command $ USE_OSX_FRAMEWORKS=0 pip install kivy. However, when I put this in terminal, I get the error error: command '\/usr\/bin\/clang' failed with exit status 1, and as a result Failed building wheel for kivy. Does anyone know how to address this issue?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1854,"Q_Id":42940941,"Users Score":1,"Answer":"Just had this issue, and was able to fix it following the directions on the kivy mac OS X install page, with one modification as follows:\n$ brew install pkg-config sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer\n$ pip3 install Cython==0.25.2\n$ pip3 install kivy\npip3 is my reference to pip for Python 3.6 as I have two different versions of python on my system. May just be pip install for you.\nHope this helps!","Q_Score":1,"Tags":"macos,kivy,python-3.4","A_Id":46702178,"CreationDate":"2017-03-22T01:04:00.000","Title":"Trying to install kivy for python on mac os 10.12","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"In a Python\/Django website I maintain, users keep unique usernames at sign up. While registering, if a username isn't available, they have to guess another one.\nSometimes users have to contend with multiple \"username already exists\" messages before they're able to sign up.\nI want to ameliorate this issue via suggesting a username based upon the already used username they currently put in. Can someone illustrate a neat Python solution for this?\n\nI haven't tried anything yet. But I was thinking what would work is taking the current nickname the user wants, and then somehow doing an ordinal based diff with 4-5 neighboring nicknames from the DB (these I can easily query). \nThe diffs that are found can then somehow be used to guess an available nickname for the user, which is also sufficiently based on the one they already wanted. Something like that. Being a neophyte, I'm still trying to wrap my head around a viable solution.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":87,"Q_Id":42958619,"Users Score":0,"Answer":"If you want to have 5 suggestions and the user only provides a username he likes to use you could do the following.\nJust start a counter from 1 to 100, append that number to the username and check if it is in the database. If not then save that suggestion in a list.\nIf that list has 5 entries, show them to your user to choose from.","Q_Score":1,"Tags":"python,python-2.7","A_Id":42960513,"CreationDate":"2017-03-22T17:21:00.000","Title":"Using diff of two strings to suggest a unique string (Python 2.7)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm fairly new to programming and thought I'd try writing a piecewise linear interpolation function. (perhaps which is done with numpy.interp or scipy.interpolate.interp1d)\nSay I am given data as follows: x= [1, 2.5, 3.4, 5.8, 6] y=[2, 4, 5.8, 4.3, 4]\nI want to design a piecewise interpolation function that will give the coefficents of all the Linear polynomial pieces between 1 and 2.5, 2.5 to 3.4 and so on using Python. \nof course matlab has the interp1 function which do this but im using python and i want to do exactly the same job as matlab but python only gives the valuse but not linear polynomials coefficient ! (in matlab we could get this with pp.coefs) .\nbut how to get pp.coefs in python numpy.interp ?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4195,"Q_Id":42995027,"Users Score":1,"Answer":"If you're doing linear interpolation you can just use the formula that the line from point (x0, y0) to (x1, y1) the line that interpolates them is given by y - y0 = ((y0 - y1)\/(x0 - x1)) * (x - x0). You can take 2 element slices of your list using the slice syntax; for example to get [2.5, 3.4] you would use x[1:3].\nUsing the slice syntax you can then implement the linear interpolation formula to calculate the coefficients of the linear polynomial interpolations.","Q_Score":3,"Tags":"python,interpolation,coefficients","A_Id":42995646,"CreationDate":"2017-03-24T08:49:00.000","Title":"piecewise linear interpolation function in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Obviously the rfft2 function simply computes the discrete fft of the input matrix. However how do I interpret a given index of the output? Given an index of the output, which Fourier coefficient am I looking at?\nI am especially confused by the sizes of the output. For an n by n matrix, the output seems to be an n by (n\/2)+1 matrix (for even n). Why does a square matrix ends up with a non-square fourier transform?","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":5101,"Q_Id":43001729,"Users Score":2,"Answer":"Also note the ordering of the coefficients in the fft output:\nAccording to the doc: by default the 1st element is the coefficient for 0 frequency component (effectively the sum or mean of the array), and starting from the 2nd we have coeffcients for the postive frequencies in increasing order, and starts from n\/2+1 they are for negative frequencies in decreasing order. To have a view of the frequencies for a length-10 array:\n\nnp.fft.fftfreq(10)\n\nthe output is:\n\narray([ 0. ,  0.1,  0.2,  0.3,  0.4, -0.5, -0.4, -0.3, -0.2, -0.1])\n\nUse np.fft.fftshift(cf), where cf=np.fft.fft(array), the output is shifted so that it corresponds to this frequency ordering:\n\narray([-0.5, -0.4, -0.3, -0.2, -0.1,  0. ,  0.1,  0.2,  0.3,  0.4])\n\nwhich makes for sense for plotting.\nIn the 2D case it is the same. And the fft2 and rfft2 difference is as explained by others.","Q_Score":11,"Tags":"python,numpy,fft","A_Id":43012808,"CreationDate":"2017-03-24T14:12:00.000","Title":"How should I interpret the output of numpy.fft.rfft2?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am sending some emails from Python using smtplib MIMEtext; and have the often noted problem that Outlook will \"sometimes\" remove what it considers \"extra line breaks\".\nIt is odd, because I print several headers and they all break find, but the text fields in a table are all smooshed - unless the recipient manually clicks Outlook's \"restore line breaks\".\nBecause some come through alright, I wonder what is Outlook's criteria for \"extra\", and thus how to avoid it?\nDo I need to format the message as HTML?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":795,"Q_Id":43005000,"Users Score":0,"Answer":"You won't be able to fix this.  Outlook does it no matter how many line breaks you put in there in my experience.  You might be able to trick it by adding spaces on each line, or non-breaksping space characters.  It's a dumb feature of outlook....","Q_Score":0,"Tags":"python,email,outlook","A_Id":43005956,"CreationDate":"2017-03-24T16:49:00.000","Title":"python sending email - line breaks removed by Outlook","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to stackoverflow, very new to Python and trying to learn Django.\nI am on Windows 10 and running commands from powershell (as administrator). \nI am in a virtual environment.  I am trying to set up Django. \nI have run the following commands\n\"pip install Django\"\n\"django-admin.py startproject learning_log .\"\n\"python manage.py migrate\"\nAll of the above seemed to work okay, however, when I then try to run the command\n\"python manage.py runserver\"\nI get a popup error box that says:\nPython has stopped working\nA problem caused the program to stop working correctly.\nWindows will close the program and notify you if a solution is available.\nCan someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2081,"Q_Id":43024066,"Users Score":0,"Answer":"I finally got the \"python manage.py runserver\" command to work. The only thing different I did was before setting up the virtual env and installing Django was set my executionpolicy to Unrestricted. Previously it had been set to RemoteSigned. I hadn't been gettiing any warning or errors but thought I would try it and it worked.","Q_Score":0,"Tags":"python,django","A_Id":43051626,"CreationDate":"2017-03-26T01:47:00.000","Title":"Python stops working on manage.py runserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am new to stackoverflow, very new to Python and trying to learn Django.\nI am on Windows 10 and running commands from powershell (as administrator). \nI am in a virtual environment.  I am trying to set up Django. \nI have run the following commands\n\"pip install Django\"\n\"django-admin.py startproject learning_log .\"\n\"python manage.py migrate\"\nAll of the above seemed to work okay, however, when I then try to run the command\n\"python manage.py runserver\"\nI get a popup error box that says:\nPython has stopped working\nA problem caused the program to stop working correctly.\nWindows will close the program and notify you if a solution is available.\nCan someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2081,"Q_Id":43024066,"Users Score":0,"Answer":"I encountered the same problem. After trying everything, I switched from PS to cmd, cd to the same directory and run python manage.py runserver. Then it worked. Then I ctrl+C quit the server, switched back to PS, ran the command, it still threw the same dialog window (Python stopped working). Then I went back to cmd, typed the command and the server started fine.\nConclusion: Use cmd to run the command, not PS.","Q_Score":0,"Tags":"python,django","A_Id":49569047,"CreationDate":"2017-03-26T01:47:00.000","Title":"Python stops working on manage.py runserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"There are already some question on this but most of their answers are using models based workflow which is not a recommended way anymore according to django-registration. I am just frustrated from last week, trying to figure out how to add first and last name fields in registration form in HMAC Workflow.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":174,"Q_Id":43026801,"Users Score":1,"Answer":"I am not intimately familiar with django, but an easy solution would be to follow the default registration workflow to let your user register. Then when your user tries to login for the first time you present them with a form to fill with all the extra information you might need.\nIn this way you also decouple the actual account creation from asking the user for more information, creating for them an extra incentive to actually go through with this process (\"Oh man why do I need to provide my name, let's not sign up\" vs \"Oh well, I have already registered and given them an email might as well go through with it\")\n\nIf you would prefer to have them in one step, then providing what code you have already would help us provide better feedback","Q_Score":0,"Tags":"python,django,django-registration","A_Id":43152421,"CreationDate":"2017-03-26T08:47:00.000","Title":"How to add custom-fields (First and Last Name) in django-registration 2.2 (HMAC activation Workflow)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am using Python 3 and I am not sure if this is a possible query because I've searching it up and I couldn't find a solution. My question is, I want to learn how to change colour and size of my output.\nHow to make the size bigger or smaller?\n\n\n\nAble to make the font size big\n\n\n\nHow to change the background colour of shell?\n\n\n\nAble to make the background colour, for example, right now, it's all white but I want it black.\n\n\n\nHow to change the output colour of shell?\n\n\n\nI would love to see colourful fonts operating in black background shell\n\n\n\nI hope there is a solution to this! Thanks in advance","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3009,"Q_Id":43033174,"Users Score":1,"Answer":"I know about the color part, but I came for the size.\nTo start off with, to close the color, use \\u001b[0m. If you don't use  this, all text will become the color that you started with until you close it. \nGreen is\\u001b[32m\nBlack is\\u001b[30m\nPink is \\u001b[35m\nThere are much more, but is you experiment with different numbers, you can highlight and do different colors.\nTo make a sentence with color, format it like this:\nprint(\"\\u001b[35mHi, coders. This is pink output.\\u001b[0m\")\nTest that code. it will come out in pink.","Q_Score":1,"Tags":"python,python-3.x,fonts,colors,size","A_Id":49737636,"CreationDate":"2017-03-26T18:57:00.000","Title":"How to change font colour and size of Python Shell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am loading Spark dataframes into H2O (using Python) for building machine learning models. It has been recommended to me that I should allocate an H2O cluster with RAM 2-4x as big as the frame I will be training on, so that the analysis fits comfortably within memory. But I don't know how to precisely estimate the size of an H2O frame.\nSo supposing I have an H2O frame already loaded into Python, how do I actually determine its size in bytes? An approximation within 10-20% is fine.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":699,"Q_Id":43048126,"Users Score":0,"Answer":"This refers to 2-4 times the size of the file on disk, so rather than looking at the memory in Python, look at the original file size.  Also, the 2-4x recommendation varies by algorithm (GLM & DL will requires less memory than tree-based models).","Q_Score":0,"Tags":"python,h2o","A_Id":43051434,"CreationDate":"2017-03-27T13:42:00.000","Title":"How to determine size in bytes of H2O frame in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use keras 1.0 and keras 2.0 at the same time, I tried to create two environments in anaconda: keras1 and keras2. \nI install keras1.0 in keras1, when I change the environment to keras2, I found the keras' version is 1.0, and I upgrade the keras to 2.0, then the keras' version became 2.0 in environment keras1.\nWhat should I do to use the two versions at the same time?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":433,"Q_Id":43070180,"Users Score":1,"Answer":"I have had similar issues with Anaconda environments - pip will install to the environment in which you're 'logged in', so you need to be very careful about which environment you're in when you use pip. \nIf I were you, I would pip uninstall the packages in both environments, and methodically install keras in each, as having two different versions in two different environments will not be an issue.","Q_Score":1,"Tags":"python,anaconda","A_Id":43070556,"CreationDate":"2017-03-28T12:55:00.000","Title":"how to install two python package versions in different anaconda environments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created two classes. The first class takes an image from the working directory and then covert the image from pdf to jpg using wand. The second class takes the created jpg image and then do further manipulations with the image. \nNow When I try to run the first class and then the second class right after that; python crashes because the second class is trying to look for the image but it wont find it until it is created. \nMy question is how can you run the second class but just after the first class is executed.\nclass1 = imagecreation('image.jpg')\nclass2 = transformimage()","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":22,"Q_Id":43084539,"Users Score":0,"Answer":"I found the answer to my question. When you reference classes and you import as a module in a different one; the module will get call when is defined if you do not use if __name__=='__main__':. By putting this code at the end of the code will only execute the module once it is intended to be executed but not when you import the module. This way you can use the modules by themselves and also to import from other modules.","Q_Score":0,"Tags":"python-3.x","A_Id":43140722,"CreationDate":"2017-03-29T04:44:00.000","Title":"Open a file after it was created in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I want to add new nodes to on of my tensorflow layers on the fly, how can I do that?\nFor example if I want to change the amount of hidden nodes from 10 to 11 after the model has been training for a while. Also, assume I know what value I want the weights coming in and out of this node\/neuron to be.\nI can create a whole new graph, but is there a different\/better way?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2690,"Q_Id":43092454,"Users Score":5,"Answer":"Instead of creating a whole new graph you might be better off creating a graph which has initially more neurons than you need and mask it off by multiplying by a non-trainable variable which has ones and zeros. You can then change the value of this mask variable to allow effectively new neurons to act for the first time.","Q_Score":3,"Tags":"python,machine-learning,tensorflow,neural-network,artificial-intelligence","A_Id":43098199,"CreationDate":"2017-03-29T11:40:00.000","Title":"How to add new nodes \/ neurons dynamically in tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a tcsh shell script that sets up all the necessary environment including PYTHONPATH, which then run an executable at the end of it. I also have a python script that gets sent to the shell script as an input. So the following works perfectly fine when it is ran from Terminal:\npath to shell script path to python script\nNow, the problem occurs when I want to do the same thing from a subprocess. The python script fails to be ran since it cannot find many of the modules that's already supposed to be set via the shell script. And clearly, the PYTHONPATH ends up having many missing paths compared to the parent environment the subprocess was ran from or the shell script itself! It seems like the subprocess does not respect the environment the shell script sets up.\nI've tried all sorts of things already but none help! \ncmd = [shell_script_path, py_script_path]\nprocess = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=os.environ.copy())\n\nIt makes no difference if env is not given either!\nAny idea how to fix this?!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":882,"Q_Id":43096197,"Users Score":0,"Answer":"Knowing the subprocess inherits all the parent process environment and they are supposed to be ran under same environment, making the shell script to not setup any environment, fixed it. \nThis solves the environment being retained, but now the problem is, the process just hangs! (it does not happen when it is ran directly from shell)","Q_Score":0,"Tags":"python,shell,subprocess,tcsh","A_Id":43118394,"CreationDate":"2017-03-29T14:18:00.000","Title":"Subprocess not retaining all environment variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If you make two concurrent calls to the same session, sess.run(...), how are variables concurrently accessed in tensorflow? \nWill each call see a snapshot of the variables as of the moment run was called, consistent throughout the call? Or will they see dynamic updates to the variables and only guarantee atomic updates to each variable?\nI'm considering running test set evaluation on a separate CPU thread and want to verify that it's as trivial as running the inference op on a CPU device in parallel. \nI'm having troubles figuring out exactly what guarantees are provided that make sessions \"thread safe\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":646,"Q_Id":43105148,"Users Score":3,"Answer":"After doing some experimentation it appears that each call to sess.run(...) does indeed see a consistent point-in-time snapshot of the variables. \nTo test this I performed 2 big matrix multiply operations (taking about 10 sec each to complete), and updated a single, dependent, variable before, between, and after. In another thread I grabbed and printed that variable every 1\/10th second to see if it picked up the change that occurred between operations while the first thread was still running. It did not, I only saw it's initial and final values. Therefore I conclude that variable changes are only visible outside of a specific call to sess.run(...) at the end of that run.","Q_Score":1,"Tags":"python,multithreading,tensorflow","A_Id":43107623,"CreationDate":"2017-03-29T22:15:00.000","Title":"How are variables shared between concurrent `session.run(...)` calls in tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to test my django app in my WAMP server. The idea is that i want to create a web app for aaa.com and aaa.co.uk, if the user enter the domain aaa.co.uk, my django app will serve the UK version, if the user go to aaa.com, the same django app will serve the US version (different frontend). Basically i will be detecting the host of the user and serve the correct templates.\nHow do i setup my WAMP so i can test this? right now i am using pyCharm default server which is 127.0.0.1:8000","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3505,"Q_Id":43107173,"Users Score":2,"Answer":"Ok the answer is basically  ericeastwood.com\/blog\/3\/django-setup-for-wamp  combined with httpd.apache.org\/docs\/2.4\/vhosts\/name-based.html \u2013 shadow","Q_Score":0,"Tags":"python,django,wamp","A_Id":43772665,"CreationDate":"2017-03-30T01:57:00.000","Title":"how do i setup django in wamp?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going to create search api for Android and iOS developers.\nOur client have setup a lambda function in AWS. \nNow we need to fetch data using jwplatform Api based on search keyword passed as parameter. For this, I have to install jwplatform module in Lambda function or upload zip file of code with dependencies. So that i want to run python script locally and after getting appropriate result i will upload zip in AWS Lambda.\nI want to use the videos\/list (jwplatform Api) class to search the video library using python but i don't know much about Python. So i want to know how to run python script? and where should i put the pyhton script ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":514,"Q_Id":43111193,"Users Score":1,"Answer":"I am succeed to install jwplatform module locally.\nSteps are as follows:\n1. Open command line\n2. Type 'python' on command line\n3. Type command 'pip install jwplatform'\n4. Now, you can use jwplatform api. \nAbove command added module jwplatform in python locally\nBut my another challenge is to install jwplatform in AWS Lambda. \nAfter research i am succeed to install module in AWS Lambda. I have bundled module and code in a directory then create zip of bundle and upload it in AWS Lambda. This will install module(jwplatform) in AWS Lambda.","Q_Score":0,"Tags":"python,python-2.7,amazon-web-services,aws-lambda,jwplayer","A_Id":43133422,"CreationDate":"2017-03-30T07:26:00.000","Title":"how to use jwplatform api using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have PhpMyAdmin to view and edit a database and a Flask + SQLAlchemy app that uses a table from this database. Everything is working fine and I can read\/write to the database from the flask app. However, If I make a change through phpmyadmin, this change is not detected by SQLAlchmey. The only to get those changes is by manually refreshing SQLAlchmey connection \nMy Question is how to tell SQLAlchemy to reload\/refresh its Database connection?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":665,"Q_Id":43149092,"Users Score":0,"Answer":"I suggest you to look at Server Sent Events(SSE). I am looking for code of SSE for postgres,mysql,etc. It is available for reddis.","Q_Score":0,"Tags":"python,flask,sqlalchemy,flask-sqlalchemy","A_Id":43703427,"CreationDate":"2017-03-31T20:22:00.000","Title":"Flask App using SQLAlcehmy: How to detect external changes committed to the database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have made a program where there is are many values that are accessed and changed in many classes and functions. I want to know is how to use and change a variable without using global or only using it once. I used global around 20 times all throughout my code and it looks ugly and is annoying.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":31,"Q_Id":43151776,"Users Score":1,"Answer":"Two ideas that I have is either to pass a reference of all these variables through functions. The other idea is to define classes containing the variables. The all the functions of the class have access to the values defined in the class and you don't need to pass them. Or you are passing pack of variables.","Q_Score":0,"Tags":"python,python-2.7,function,global-variables","A_Id":43151811,"CreationDate":"2017-04-01T01:22:00.000","Title":"Python Globalling to use and change in many functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to install third party package in python online coding environments. Could you please tell me how we can achieve this?\nThe below line needs to execute\nfrom watson_developer_cloud import SpeechToTestV1 as STT\nwhen I run the above line, I am getting the following error,\nError:\nTraceback (most recent call last): \n  File \"..\\Playground\\\", line 1, in  \n    \\ufefffrom watson_developer_cloud import SpeechToTestV1 as STT \nImportError: No module named 'watson_developer_cloud'\nEven tried the below command in CODE Playground but it throwing incorrect syntax.\npip install watson_developer_cloud\nThanks in advance,","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":806,"Q_Id":43154781,"Users Score":1,"Answer":"You can install packages when using SoloLearn. You need to ask SoloLearn's administrators to install the package for you.\nThe python playground includes some of the most popular packages but it's very limited in terms of what you can do if the package you want to use is not there.","Q_Score":1,"Tags":"python-3.x,ibm-cloud,speech-to-text,watson","A_Id":43174919,"CreationDate":"2017-04-01T08:53:00.000","Title":"How to install new module\/package in python coding online environment?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"How do I select an interpreter on my IDE which is Python IDLE? I can't find the options to do that.\nI managed to install Tensorflow but it only works when I import it in the terminal, not in my current IDE\nWhat I want: Make my current IDE use the Python.exe that has been provided when I installed Tensorflow on my computer\nWhat I tried: Using PYCHARM, it works (like a charm!) but I can't do that stuff like import module then have \" >>> \" then issue my commands etc...","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":264,"Q_Id":43167500,"Users Score":1,"Answer":"IDLE does NOT provide such functionality - it works through idlelib, a package from stdlib so it's executed using pythonw -m idlelib. To change interprenter in IDLE, call it using a different interprenter - \"C:\\path\\to\\your\\python\\interprenter\\pythonw.exe\" -m idlelib (make sure idlelib is installed for target interprenter).","Q_Score":1,"Tags":"python,tensorflow,python-idle","A_Id":47119800,"CreationDate":"2017-04-02T10:58:00.000","Title":"how do i select an interpreter on my IDE which is Python IDLE","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say you have b'\\x04' and b'\\x00' how can you combine them as b'\\x0400'?","AnswerCount":5,"Available Count":2,"Score":-0.0399786803,"is_accepted":false,"ViewCount":26609,"Q_Id":43168123,"Users Score":-1,"Answer":"It has a simple solution like this:\n0x0400 = 0x04 \u00d7 256 + 0x00","Q_Score":3,"Tags":"python,byte","A_Id":51676604,"CreationDate":"2017-04-02T12:08:00.000","Title":"How to append two bytes in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say you have b'\\x04' and b'\\x00' how can you combine them as b'\\x0400'?","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":26609,"Q_Id":43168123,"Users Score":0,"Answer":"In my application I am receiving a stream of bytes from a sensor. I need to combine two of the bytes to create the integer value.\nHossein's answer is the correct solution.\nThe solution is the same as when one needs to bit shift binary numbers to combine them for instance if we have two words which make a byte, high word 0010 and low word 0100. We can't just add them together but if we bit shift the high word to the left four spaces we can then or the bits together to create 00100100. By bit shifting the high word we have essencially multiplied it by 16 or 10000.\nIn hex example above we need to shift the high byte over two digits which in hex 0x100 is equal to 256. Therefore, we can multiple the high byte by 256 and add the low byte.","Q_Score":3,"Tags":"python,byte","A_Id":51753927,"CreationDate":"2017-04-02T12:08:00.000","Title":"How to append two bytes in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a slight problem. I have a project that I'm working on and that requires two programs to read\/write into some .txt files.  \nPython writes into one .txt file, C++ reads from it. C++ does what it needs to do and then writes its own information into another .txt file that Python has to read.  \nWhat I want to know is how can I check with C++ if Python has closed the .txt file before opening the same file, as Python may still be writing stuff into it and vice versa?  \nIf you need any extra information about this conundrum, feel free to contact me.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":43169118,"Users Score":0,"Answer":"You might consider having each \"writer\" process write its output to a temporary file, close the file, then rename it to the filename that the \"reader\" process is looking for.\nIf the file is present, then the respective reader process knows that it can read from it.","Q_Score":0,"Tags":"python,c++","A_Id":43173531,"CreationDate":"2017-04-02T13:50:00.000","Title":"Has .txt file been closed?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I already know how to make a neural network using the mnist dataset. I have been searching for tutorials on how to train a neural network on your own dataset for 3 months now but I'm just not getting it. If someone can suggest any good tutorials or explain how all of this works, please help.\nPS. I won't install NLTK. It seems like a lot of people are training their neural network on text but I won't do that. If I would install NLTK, I would only use it once.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1168,"Q_Id":43169766,"Users Score":2,"Answer":"I suggest you use OpenCV library. Whatever you uses your MNIST data or PIL, when it's loaded, they're all just NumPy arrays. If you want to make MNIST datasets fit with your trained model, here's how I did it:\n1.Use cv2.imread to load all the images you want them to act as training datasets.\n2.Use cv2.cvtColor to convert all the images into grayscale images and resize them into 28x28.\n3.Divide each pixel in all the datasets by 255.\n4.Do the training as usual!\nI haven't tried to make it your own format, but theoratically it's the same.","Q_Score":4,"Tags":"python,tensorflow,neural-network,dataset","A_Id":43170260,"CreationDate":"2017-04-02T14:54:00.000","Title":"Using your own Data in Tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I have two placeholder quantities in tensorflow: placeholder_1 and placeholder_2. Essentially I would like the following computational functionality: \"if placeholder_1 is defined (ie is given a value in the feed_dict of sess.run()), compute X as f(placeholder_1), otherwise, compute X as g(placeholder_2).\" Think of X as being a hidden layer in a neural network that can optionally be computed in these two different ways. Eventually I would use X to produce an output, and I'd like to backpropagate error to the parameters of f or g depending on which placeholder I used. \nOne could accomplish this using the tf.where(condition, x, y) function if there was a way to make the condition \"placeholder_1 has a value\", but after looking through the tensorflow documentation on booleans and asserts I couldn't find anything that looked applicable.\nAny ideas? I have a vague idea of how I could accomplish this basically by copying part of the network, sharing parameters and syncing the networks after updates, but I'm hoping for a cleaner way to do it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1190,"Q_Id":43175272,"Users Score":3,"Answer":"You can create a third placeholder variable of type boolean to select which branch to use and feed that in at run time.\nThe logic behind it is that since you are feeding in the placholders at runtime anyways you can determine outside of tensorflow which placeholders will be fed.","Q_Score":3,"Tags":"python,tensorflow,deep-learning","A_Id":43214452,"CreationDate":"2017-04-03T01:21:00.000","Title":"check if tensorflow placeholder is filled","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"Django documentation says:\n\nget_absolute_url() method to tell Django how to calculate the canonical URL for an object.\n\nWhat is canonical URL mean in this is context?\nI know from an SEO perspective that canonical URL means picking the best URL from the similar looking URLs (example.com , example.com\/index.html). But this meaning doesn't fit in this context.\nI know this method provides some additional functionality in Django admin, redirection etc. And I am fully aware of how to use this method.\nBut what is the philosophy behind it? I have never actually used it in my projects. Does it serve any special purpose?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":37142,"Q_Id":43179875,"Users Score":10,"Answer":"You create models for your website. When a new instance is made for a model, django must know where to go when a new post is created or a new instance is created.\nHere get_absolute_url comes in picture. It tells the django where to go when new post is created.","Q_Score":43,"Tags":"python,django","A_Id":54591055,"CreationDate":"2017-04-03T08:29:00.000","Title":"When to use Django get_absolute_url() method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"The sparse matrix has only 0 and 1 at each entry (i,j) (1 stands for sample i has feature j). How can I estimate the co-occurrence matrix for each feature given this sparse representation of data points? Especially, I want to find pairs of features that co-occur in at least 50 samples. I realize it might be hard to produce the exact result, is there any approximated algorithm in data mining that allows me to do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":101,"Q_Id":43209135,"Users Score":0,"Answer":"This can be solved reasonably easily if you go to a transposed matrix.\nOf any two features (now rows, originally columns) you compute the intersection. If it's larger than 50, you have a frequent cooccurrence.\nIf you use an appropriate sparse encoding (now of rows, but originally of columns - so you probably need not only to transpose the matrix, but also to reencode it) this operation using O(n+m), where n and m are the number of nonzero values.\nIf you have an extremely high number of features this make take a while. But 100000 should be feasible.","Q_Score":0,"Tags":"python,machine-learning,data-mining","A_Id":43216616,"CreationDate":"2017-04-04T13:48:00.000","Title":"Given a sparse matrix with shape (num_samples, num_features), how do I estimate the co-occurrence matrix?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm quite green on Python and have been looking around for an answer to my particular question. Though I'm not sure if it's a Python specific question, or if I'm simply getting my OOP \/ design patterns confused.\nI've got three files: main.py, board.py and player.py. Board and player each only hold a class Player and Board, main simply starts the game. \nHowever I'm struggling with validating player positions when they are added to the board. What I want is to instantiate the board and consecutively new player object(s) in main.py, but check the board size in player.py when a new player is added to the board, to ensure the player is not outside of bounds upon creation.\nAs it is now I'm getting a TypeError (getX() missing 1 required positional argument: 'self') when attempting to access the board's size inside of player.py. \nMost likely because the board isn't instantiated in that scope. But if I instantiate it in the scope that will be counted as a new object, won't it? And if I pass the board to the player as a variable that would surely be counted as bad practice, wouldn't it? \nSo how do I go about accessing the instance variables of one class from another class?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":305,"Q_Id":43213086,"Users Score":0,"Answer":"Your question is asking about a concept called \"dependency injection.\"  You should take some time to read up on it.  It details the ways of making one object available to another object that wants to interact with it.  While that's too broad to write up here, here are some of the basics:\n\nYou could have all objects you care about be global, or contained in a global container.  They can all see each other and interact with each other as necessary.  This isn't very object-oriented, and is not the best practice.  It's brittle (all the objects are tightly bound together, and it's hard to change or replace one), and it's not a good design for testing.  But, it is a valid option, if not a good one.\nYou could have objects that care about each other be passed to each other.  This would be the responsibility of something outside of all of the objects (in your case, basically your main function).  You can pass the objects in every method that cares (e.g. board.verify_player_position(player1)).  This works well, but you may find yourself passing the same parameter into almost every function.  Or you could set the parameter either through a set call (e.g. board.set_player1(player1)), or in the constructor (e.g. board = Board(player1, player2)).  Any of these are functionally pretty much the same, it's just a question of what seems to flow best for you.  You still have the objects pretty tightly bound.  That may be unavoidable.  But at least testing is easier.  You can make stub classes and pass them in to the appropriate places.  (Remember that python works well with duck typing: \"If it walks like a duck and quacks like a duck, then it's a duck.\"  You can make testing code that has the same functions as your board and player class, and use that to test your functions.)\nA frequent pattern is to have these objects be fairly dumb, and to have a \"game_logic\" or some other kind of controller.  This would be given the instances of the board and the two players, and take care of maintaining all of the rules of the game.  Then your main function would basically create the board and players, and simply pass them into your controller instance.  If you went in this direction, I'm not sure how much code you would need your players or board to have, so you may not like this style.\n\nThere are other patterns that will do this, as well, but these are some of the more basic.\nTo answer your direct questions: yes, the error you're seeing is because you're trying to invoke the class function, and you need it to be on an object.  And yes, instantiating in that case would be bad.  But no, passing an instance of one class to another is not a bad thing.  There's no use in having objects if they don't interact with something; most objects will need to interact with some other object at some point.\nYou mentioned that you have code available, but it's a good thing to think out your object interactions a little bit before getting too into the coding.  So that's the question for you:  do you want player1.check_valid_position(board), or board.check_player(player1), or rules.validate_move(player, some_kind_of_position_variable)`.  They're all valid, and they all have the objects inter-relate; it's just a question of which makes the most sense to you to write.","Q_Score":1,"Tags":"python,python-3.x,oop","A_Id":43213652,"CreationDate":"2017-04-04T16:43:00.000","Title":"Accessing variable of class-object instantiated in other file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm reading from a \"bookazine\" which I purchased from WHSmiths today and its said\nduring the setup I need to type in these commands into the terminal (or the Command Prompt in my case) in order to make a script without needing to do it manually. One of these commands is chmod +x (file name) but because this is based of Linux or Mac and I am on Windows I am not sure how to make my script executable, how do I?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":492,"Q_Id":43219217,"Users Score":0,"Answer":"You don't have shell scripts on Windows, you have batch or powershell. \nIf your reading is teaching Unix things, get a virtual machine running (insert popular Linux distribution here). \nRegarding python, you just execute python script.py","Q_Score":0,"Tags":"python,windows,executable","A_Id":43219241,"CreationDate":"2017-04-04T23:10:00.000","Title":"How would I go about making a Python script into an executable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset consisting of multiple columns and I want to calculate the average by using the groupby function in Python. However, since some of the values are NAN I get that the mean of that particular group is NAN when a NAN value is present. I would like to omit this value, not set it to zero or fill it with any statistical variable, just omit.\nAny idea how I can achieve this?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":266,"Q_Id":43219641,"Users Score":0,"Answer":"I get that the mean of that particular group is NAN when a NAN value\n  is present\n\nFALSE! :)\nthe mean will only consider non null values. You are safe my man.","Q_Score":0,"Tags":"python,pandas","A_Id":43219694,"CreationDate":"2017-04-04T23:54:00.000","Title":"How to Omit NaN values when applying groupyby in Pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a telegram bot for a home project and i wish the bot only talk to 3 people, how can I do this?\nI thought to create a file with the chat id of each of us and check it before responding to any command, I think it will work. the bot will send the correct info if it's one of us and \"goodbye\" to any other\nBut is there any other way to block any other conversation with my bot?\nPd: I'm using python-telegram-bot","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":986,"Q_Id":43240152,"Users Score":1,"Answer":"For the first part of your question you can make a private group and add your bot as one of its administrators. Then it can talk to the members and answer to their commands. \nEven if you don't want to do so, it is possible by checking the chatID of each update that the bot receives. If the chatID exists in the file, DataBase or even in a simple array the bot answers the command and if not it just ignores or sends a simple text like what you said good-bye.\n\nNote that bots cannot block people they can only ignore their\n  messages.","Q_Score":3,"Tags":"telegram,telegram-bot,python-telegram-bot","A_Id":43241747,"CreationDate":"2017-04-05T19:37:00.000","Title":"Telegram-bot user control","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Hi I have two process \n\nDjango and MYSQL \nnode\/express and mongo db.\n\n1.\nHow can I configure this two process to point to different url\nlike. Django point to api.abc.com\/v1 and node point to api.abc.com\/v2 ?\n2.\nall my user login is inside Django and MYSQL with OAuth. I can authenticate user in Django.\nBut how can authenticate user in nodejs app with the token send by Django REST OAuth ?\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1050,"Q_Id":43253823,"Users Score":1,"Answer":"Scenario A\nYou create a url in django ^v2\/.*$ and then make a request from django view to node.js process. this way django can handle user auth and permissions and node can be standalone and not know anything about user auth. If you need user data (id or something) you can inject it in the request as a header or a cookie. \nScenario B\nYou dig into django REST OAuth implementation, find where tokens are stored in db, and on each request you take the oauth token from the header\/cookie and compare it to the one in DB. You would have to setup nginx as a reverse proxy and route all traffic that goes on url \/v1\/.*$ to django app, and all traffic that goes to \/v2\/.*\/ to node app.\nEither options are doable but I would suggest Scenario A. It's easier, quicker and far less error prone.","Q_Score":1,"Tags":"node.js,django,python-2.7,oauth-2.0,nodes","A_Id":43254420,"CreationDate":"2017-04-06T11:26:00.000","Title":"Django and Node processes for the same domain","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to coding and decided to install Anaconda because I heard it was the most practical platform for beginners. \nThe problem is, every time I try opening it, it literally takes at least 15 minutes to boot up while showing me \"Updating metadata...\" and subsequently showing me \"Updating repodata...\" statements.\nWould any of you know how to fix or go around this issue?\nI'm using a macbook air that has 8gb of RAM and an i5 processor, if that helps.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7621,"Q_Id":43270149,"Users Score":0,"Answer":"Some time restart works. I was also facing same issue, when I restarted my system it works like charm.","Q_Score":2,"Tags":"python,ios,arrays,anaconda,conda","A_Id":49812547,"CreationDate":"2017-04-07T05:12:00.000","Title":"The Anaconda launcher takes long time to load","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to coding and decided to install Anaconda because I heard it was the most practical platform for beginners. \nThe problem is, every time I try opening it, it literally takes at least 15 minutes to boot up while showing me \"Updating metadata...\" and subsequently showing me \"Updating repodata...\" statements.\nWould any of you know how to fix or go around this issue?\nI'm using a macbook air that has 8gb of RAM and an i5 processor, if that helps.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7621,"Q_Id":43270149,"Users Score":0,"Answer":"I started Anaconda Navigator with \"Run as Administrator\" privileges on my Windows machine, and it worked like a charm. Though it did ask me for Admin credentials for a couple of times while loading different scripts, but the response was <1 min, compared to 6 - 8 mins. earlier.\nSearch for Anaconda through desktop search or go to Cortana tool on the desktop toolbar and type Anaconda\nOn the Anaconda icon that shows up, right-click and choose \"Run as Administrator\"\nProvide Admin credentials when prompted\nThis should hopefully work for Windows 10 users.","Q_Score":2,"Tags":"python,ios,arrays,anaconda,conda","A_Id":59691347,"CreationDate":"2017-04-07T05:12:00.000","Title":"The Anaconda launcher takes long time to load","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using a LocalExecutor and my dag has 3 tasks where task(C) is dependant on task(A). Task(B) and task(A) can run in parallel something like below\nA-->C\nB\nSo task(A) has failed and but task(B) ran fine. Task(C) is yet to run as task(A) has failed.\nMy question is how do i re run Task(A) alone so Task(C) runs once Task(A) completes and Airflow UI marks them as success.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":35603,"Q_Id":43270820,"Users Score":98,"Answer":"In the UI:\n\nGo to the dag, and dag run of the run you want to change\nClick on GraphView \nClick on task A\nClick \"Clear\"\n\nThis will let task A run again, and if it succeeds, task C should run.\nThis works because when you clear a task's status, the scheduler will treat it as if it hadn't run before for this dag run.","Q_Score":54,"Tags":"python,hadoop,airflow","A_Id":43330451,"CreationDate":"2017-04-07T06:08:00.000","Title":"How to restart a failed task on Airflow","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python 2.7, with the module threading. Now I am having a countdown of 24 hours which is one thread, the other thread is taking user input using raw input.\nWhen my program run, the countdown thread is waiting for the user input to be inserted, and only then the countdown continues. At the first place my reason of using threading is to achieve both the threads run at the same time. I just can't understand why would one thread wait for the input of another one? And how to fix that?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":410,"Q_Id":43306222,"Users Score":0,"Answer":"OK so i figured out that threading module is not actually apply parallel running of threads because of some mechanism called GIL. My solution is using multi processing instead. It works fine. Hope it helped someone.","Q_Score":0,"Tags":"python-2.7,python-multithreading,raw-input","A_Id":43306536,"CreationDate":"2017-04-09T11:35:00.000","Title":"Python thread stuck while another thread waiting for user input","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have huge data stored in cassandra and I wanted to process it using spark through python.\nI just wanted to know how to interconnect spark and cassandra through python.\nI have seen people using sc.cassandraTable but it isnt working and fetching all the data at once from cassandra and then feeding to spark doesnt make sense.\nAny suggestions?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1860,"Q_Id":43310597,"Users Score":0,"Answer":"I'll just give my \"short\" 2 cents. The official docs are totally fine for you to get started. You might want to specify why this isn't working, i.e. did you run out of memory (perhaps you just need to increase the \"driver\" memory) or is there some specific error that is causing your example not to work. Also it would be nice if you provided that example.\nHere are some of my opinions\/experiences that I had. Usually, not always, but most of the time you have multiple columns in partitions. You don't always have to load all the data in a table and more or less you can keep the processing (most of the time) within a single partition. Since the data is sorted within a partition this usually goes pretty fast. And didn't present any significant problem.\nIf you don't want the whole store in casssandra fetch to spark cycle to do your processing you have really a lot of the solutions out there. Basically that would be quora material. Here are some of the more common one:\n\nDo the processing in your application right away - might require some sort of inter instance communication framework like hazelcast of even better akka cluster this is really a wide topic \nspark streaming - just do your processing right away in micro batching and flush results for reading to some persistence layer - might be cassandra\napache flink - use proper streaming solution and periodically flush state of the process to i.e. cassandra\nStore data into cassandra the way it's supposed to be read - this approach is the most adviseable (just hard to say with the info you provided)\nThe list could go on and on ... User defined function in cassandra, aggregate functions if your task is something simpler.\n\nIt might be also a good idea that you provide some details about your use case. More or less what I said here is pretty general and vague, but then again putting this all into a comment just wouldn't make sense.","Q_Score":3,"Tags":"python,apache-spark,cassandra,pyspark","A_Id":43311283,"CreationDate":"2017-04-09T18:51:00.000","Title":"Spark and Cassandra through Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to install *.whl files through cmd (the code is simply python -m pip install *so-and-so-.whl). But since I accidentally deleted my OS and had no backups I found myself in the predicament to reinstall all of my whl files for my work. \nThis comes up to around 50 files. I can do this manually which is pretty simple, but I was wondering how to do this in a single line. I can't seem to find anything that would allow me to simply type in python -m pip install *so-and-so.whl to find all of the whl files in the directory and install them.\nAny ideas?","AnswerCount":5,"Available Count":1,"Score":-0.1194272985,"is_accepted":false,"ViewCount":9927,"Q_Id":43314517,"Users Score":-3,"Answer":"For installing multiple packages on the command line, just pass them as a space-delimited list, e.g.:\npip install numpy pandas","Q_Score":6,"Tags":"python,cmd","A_Id":43314666,"CreationDate":"2017-04-10T03:23:00.000","Title":"How to install multiple whl files in cmd","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working for the first time towards the implementation of a very simple GUI in PyQt5, which embeds a matplotlib plot and few buttons for interaction.\nI do not really know how to work with classes so I'm making a lot of mistakes, i.e. even if the functionality is simple, I have to iterate a lot between small corrections and verification.\nFor some reason I would like to debug, however, the whole process is made much, much slower by the fact that at any other try, the python kernel dies and it needs restarting (all done automatically) several times.\nThat is, every time I try something that should last maybe 5 secs, I end up spending a minute.\nAnybody know where to look to spot what is causing these constant death\/rebirth circles?\nI have been using spyder for some time now and I never experienced this behaviour before, so I'm drawn to think it might have to do with PyQt, but that's about how far I can go.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":14340,"Q_Id":43328064,"Users Score":1,"Answer":"I had a similar problem and found that my application only worked when the graphics settings inside Spyder are set to inline. This can be done at Tools -> Preferences -> IPython console -> Graphics, now change the Backends to inline. \nHope this helps.","Q_Score":3,"Tags":"python,pyqt,spyder","A_Id":54673251,"CreationDate":"2017-04-10T16:09:00.000","Title":"Spyder + Python 3.5 - how to debug kernel died, restarting?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?","AnswerCount":15,"Available Count":3,"Score":1.0,"is_accepted":false,"ViewCount":175026,"Q_Id":43351596,"Users Score":6,"Answer":"Unfortunately, this does not work on macOS. Despite the fact that I have export CONDA_DEFAULT_ENV='$HOME\/anaconda3\/envs\/dev' in my .zshrc and \"python.pythonPath\": \"${env.CONDA_DEFAULT_ENV}\/bin\/python\",\n in my VSCode prefs, the built-in terminal does not use that environment's Python, even if I have started VSCode from the command line where that variable is set.","Q_Score":92,"Tags":"python,visual-studio-code,anaconda","A_Id":46554629,"CreationDate":"2017-04-11T16:33:00.000","Title":"Activating Anaconda Environment in VsCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?","AnswerCount":15,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":175026,"Q_Id":43351596,"Users Score":5,"Answer":"Just launch the VS Code from the Anaconda Navigator. It works for me.","Q_Score":92,"Tags":"python,visual-studio-code,anaconda","A_Id":60607499,"CreationDate":"2017-04-11T16:33:00.000","Title":"Activating Anaconda Environment in VsCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?","AnswerCount":15,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":175026,"Q_Id":43351596,"Users Score":0,"Answer":"As I was not able to solve my problem by suggested ways, I will share how I fixed it.\nFirst of all, even if I was able to activate an environment, the corresponding environment folder was not present in C:\\ProgramData\\Anaconda3\\envs directory.\nSo I created a new anaconda environment using Anaconda prompt,\na new folder named same as your given environment name will be created in the envs folder.\nNext, I activated that environment in Anaconda prompt.\nInstalled python with conda install python command.\nThen on anaconda navigator, selected the newly created environment in the 'Applications on' menu.\nLaunched vscode through Anaconda navigator.\nNow as suggested by other answers, in vscode, opened command palette with Ctrl + Shift + P keyboard shortcut.\nSearched and selected Python: Select Interpreter\nIf the interpreter with newly created environment isn't listed out there, select Enter Interpreter Path and choose the newly created python.exe which is located similar to C:\\ProgramData\\Anaconda3\\envs\\<your-new-env>\\ .\nSo the total path will look like C:\\ProgramData\\Anaconda3\\envs\\<your-nev-env>\\python.exe\nNext time onwards the interpreter will be automatically listed among other interpreters.\nNow you might see your selected conda environment at bottom left side in vscode.","Q_Score":92,"Tags":"python,visual-studio-code,anaconda","A_Id":66031427,"CreationDate":"2017-04-11T16:33:00.000","Title":"Activating Anaconda Environment in VsCode","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm doing a project that require cv2 and numpy in one of the scripts using choregraphe, but I get an error :\nNo module named cv2\/numpy.\nI think it is because choregraphe has its own python interpreter but I do not know how to install cv2 and numpy into the python of choregraphe.\nHow can I do it?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1416,"Q_Id":43351742,"Users Score":2,"Answer":"It depends if you're using a real NAO or a simulated one.\n\nSimulated one: choregraphe use its own embedded python interpreter, even if you add library to your system it won't change anything\nReal NAO: the system python interpreter is used, you need to install those library to your robot (and not to the computer running choregraphe). As pip ofthen doesn't work fine in NAO, you'll have to manually copy library to \/home\/nao\/.local\/lib\/python2.7\/site-packages","Q_Score":1,"Tags":"python,opencv,numpy,nao-robot,choregraphe","A_Id":43369916,"CreationDate":"2017-04-11T16:42:00.000","Title":"how to import cv2 and numpy in Choregraphe for NAO robot?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a simple (and maybe silly) question about binary data files. If a simple type is used (int\/float\/..) it is easy to imagine the structure of the binary file (a sequence of floats, with each float written using a fixed number of bytes). But what about structures, objects and functions ? Is there some kind of convension for each language with regards to the order in which the variables names \/ attributes \/ methods are written, and if so, can this order be changed and cusotomized ? otherwise, is there some kind of header that describes the format used in each file ?\nI'm mostly interested in python and C\/C++. When I use a pickled (or gzipped) file for example, python \"knows\" whether the original object has a certain method or attribute without me casting the unpickled object or indicating its type and I've always wondered how is that implemented. I didn't know how to look this up on Google because it may have something to do with how these languages are designed in the first place. Any pointers would be much appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":62,"Q_Id":43352671,"Users Score":1,"Answer":"Binary files contain data.  \nThere are a plethora of data layouts of binary files.  Some examples are JPEG, Executables, Word Processor, Raw Text and archive files.  \nA file may have an extension that may indicate the layout.  For example, a \".png\" would would most likely follow the PNG format.  A \"bin\" or \"dat\" extension is to generic.  One could zip up files and name the archive with a \"png\" extension.  \nIf there is no file extension or the OS doesn't store the type of a file, then the format of the file is based on discovery (or trying random formats).  Some file formats have integrity values in them to help verify correctness.  Knowing the integrity value and how it was calculated, can assist in classify the format type.  Again, there is no guarantee.\nBTW, file formats are independent of the language to used to read them.  One could read a gzipped file using FORTRAN or BASIC.","Q_Score":0,"Tags":"python,c++,binaryfiles","A_Id":43355184,"CreationDate":"2017-04-11T17:33:00.000","Title":"Binary files structure for objects and structs in C++\/Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am making a game using the Pygame development module. When a user for my game presses the left key, I would like my character to \"face\" left and when the user presses the right key, I would like my character to be flipped and \"face\" the right. The character is one I drew and imported in. I am aware of the flip function in Pygame, but I think there will be errors. If the character starts off facing the left, and the user presses the right key, the character will be flipped and will move to the right. However, if he\/she lets go of the right key and then presses it again, the character will flip and face the left, but will continue to move to the right. Is there any way to solve this problem? I already know how to move the character; I am having problems with flipping it. Also, another idea I have considered is the diplay blitting one image when the key is pressed, and then blitting another when the other key is presses. But I do not knoww how to make the original image disappear. Any thoughts on this as well? Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":346,"Q_Id":43377434,"Users Score":1,"Answer":"You have to remember the face direction ( self.face_direction = RIGHT ) on click flip only if direction is wrong. \nAlternatively, save the flipped image in face_flipped_right. Then either show original image or flipped ( flipping is nondestructive)","Q_Score":0,"Tags":"python,pygame","A_Id":43377665,"CreationDate":"2017-04-12T18:50:00.000","Title":"Trying to flip a character in Pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python \"^A\" is represented by chr(1). This is what I use as a separator in myfiles. What is the equivalent in Scala.I am reading the file using scala. I want to know how to represent ^A in order to split the data i read from my files.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":237,"Q_Id":43379578,"Users Score":5,"Answer":"^A is usually used to represent the Start Of Header Character (SOH). It's ascii value is x01.\nYou can create this in code with val c: Char = 1, if it's more clear to you, or if you need it in a string literal you can use the unicode notation '\\u0001'","Q_Score":2,"Tags":"python,scala","A_Id":43379784,"CreationDate":"2017-04-12T21:00:00.000","Title":"Control A Representation in Python\/Scala","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am interacting with svg elements in a web page.\nI am able to locate the svg elements by xpath, but not able to click it, The error mentions that the methods like click(), onclick() are not available.\nAny suggestions of how can we make it clickable ? please advice ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":106,"Q_Id":43412779,"Users Score":0,"Answer":"Try to make use of Actions  or Robot class","Q_Score":0,"Tags":"python,selenium,svg,webdriver","A_Id":43422726,"CreationDate":"2017-04-14T13:42:00.000","Title":"SVG Elements: Able to locate elements using xpath but not able to click","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.\nAny leads would be helpful thanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":884,"Q_Id":43416606,"Users Score":0,"Answer":"Call the python script with \/usr\/bin\/time script. This allows you to track CPU and wall-clock time of the script.","Q_Score":0,"Tags":"python,bash,shell","A_Id":43416717,"CreationDate":"2017-04-14T17:49:00.000","Title":"Capture run time of python script executed inside shell script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using sys.argv on python -c \"some code\" I only get ['-c'], how can I reliably access the code being passed to -c as a string?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":43430790,"Users Score":0,"Answer":"The option list starts after the code (which was passed as a string literal) according to the manual:\n\nSpecify  the command to execute (see next section).\n  This terminates the option list (following options are passed as arguments\n  to the command).\n\nIt means that the name of the script will be replaced by -c. The\npython -c \"import sys; print(sys.argv)\" 1 2 3\nresults\n['-c', '1', '2', '3']\nA possible solution is the usage of inspect module, for example\npython3 -c \"import sys; import inspect; inspect.getsource(sys.modules[__name__])\"\nbut it causes TypeError because the __main__ module is a built-in one.","Q_Score":1,"Tags":"python","A_Id":43431194,"CreationDate":"2017-04-15T20:11:00.000","Title":"Capture the value of python -c \"some code\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When using sys.argv on python -c \"some code\" I only get ['-c'], how can I reliably access the code being passed to -c as a string?","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":43430790,"Users Score":0,"Answer":"This works\npython -c \"import sys; exec(sys.argv[1])\" \"print 'hello'\"\nhello","Q_Score":1,"Tags":"python","A_Id":43437447,"CreationDate":"2017-04-15T20:11:00.000","Title":"Capture the value of python -c \"some code\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Not sure what's up, but I just noticed my anaconda based jupyter totally fails to render latex.  I don't get an error, but if I put $x$ in a markdown cell, I get back $x$.  Any suggestions on how to diagnose\/fix?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":2129,"Q_Id":43433329,"Users Score":3,"Answer":"Well, I shutdown the server and restarted it, and now it works.  Wish I knew what happened.","Q_Score":3,"Tags":"python,jupyter-notebook,jupyter","A_Id":43436983,"CreationDate":"2017-04-16T03:12:00.000","Title":"Jupyter not rendering latex","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have decided to learn generic algorithms recently and I needed to install Tensorflow package. Tensorflow run on python 64 bit only, so i install python 3.5.0 64 bit without uninstalling python 32 bit. because i was afraid to lose my packages on python 32 bit by uninstalling it. The problem is how can i force pip install to install a package on my python 64 bit version instead of 32 bit version.","AnswerCount":5,"Available Count":1,"Score":-0.0399786803,"is_accepted":false,"ViewCount":30428,"Q_Id":43434028,"Users Score":-1,"Answer":"There's nothing much you can do. I also had this issue. The best thing to do is to change your python path and install the packages on the 64 bits python.","Q_Score":12,"Tags":"python,tensorflow,pip,32bit-64bit,python-module","A_Id":64636321,"CreationDate":"2017-04-16T05:27:00.000","Title":"how to pip install 64 bit packages while having both 64 bit and 32 bit versions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to show some plots using plt.show (). i get the plots shown on the IPython console, but I need to see each figure in a new window. What can I do ?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":15399,"Q_Id":43449023,"Users Score":4,"Answer":"You want to type %matplotlib qt into your iPython console. This changes it for the session you're in only. To change it for the future, go Tools > Preferences, select iPython Console > Graphics, then set Graphics Backend to Qt4 or Qt5. This ought to work.","Q_Score":4,"Tags":"python,python-2.7,matplotlib,plt","A_Id":43449375,"CreationDate":"2017-04-17T09:45:00.000","Title":"plt.show () does not open a new figure window","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a csv file with single sheet. I want to know how to create csv file with multiple sheets using python language.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":6564,"Q_Id":43449169,"Users Score":4,"Answer":"A csv file is a simple file type with flat data, separated by commas. Unlike an excel file, for example, it cannot contain multiple sheets.\nIf you need multiple sheets, you will have to make multiple csv files.","Q_Score":3,"Tags":"python","A_Id":43449238,"CreationDate":"2017-04-17T09:55:00.000","Title":"How to create multiple sheets in csv using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just recently started learning Ubuntu (17.04) and have managed to figure out how get plain Python3.5 + Spyder3 running, have created a virtual environment, and gotten the v-env running with Spyder by changing the interpreter setting within Spyder via pointing it to the virtual environment bin. \nHowever, I saw numerous other ways of installing Spyder, primarily via a pip3 install in the environment itself, but I found nothing as to how to actually RUN the pip-installed Spyder. Running \"Spyder3\" always runs the default install regardless of location.\nDoes anyone know how to actually run it?\nI was curious because I figured it would allow for a similar functionality that Anaconda provides where you can simply select your virtual environment and run the respective Spyder version for it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1124,"Q_Id":43456097,"Users Score":3,"Answer":"I figured out the issue. Seems that I was somehow running it from the wrong location, just had to run Spyder3 from the v-env bin folder.","Q_Score":2,"Tags":"python,ubuntu,ide,virtualenv,spyder","A_Id":43456751,"CreationDate":"2017-04-17T17:15:00.000","Title":"Running a pip-installed Spyder in virtual environment on Ubuntu without Anaconda?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Jupyer 4.3.0. I find that when I update my ~\/.jupyter\/custom\/custom.css, the changes are not reflected in my notebook until I kill jupyter-notebook and start it again. This is annoying, so how can I make Jupyter Notebook recognize the custom.css file changes without completely restarting the notebook?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":643,"Q_Id":43457337,"Users Score":4,"Answer":"I'm using Jupyter 5.0. \nRight now I've tried to edit custom.css and the changes are reflected immediately after reloading a page without restarting. \nI'm not sure about 4.3 version, but I guess it should work the same way. What did the property you change?","Q_Score":4,"Tags":"css,ipython-notebook,jupyter-notebook,jupyter","A_Id":43461264,"CreationDate":"2017-04-17T18:33:00.000","Title":"Jupyter reload custom.css?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Jupyer 4.3.0. I find that when I update my ~\/.jupyter\/custom\/custom.css, the changes are not reflected in my notebook until I kill jupyter-notebook and start it again. This is annoying, so how can I make Jupyter Notebook recognize the custom.css file changes without completely restarting the notebook?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":643,"Q_Id":43457337,"Users Score":0,"Answer":"The \/custom\/custom.css stopped working for me when I generated a config file, but if anyone stumbles to this problem too, the solution is to uncomment the line c.NotebookApp.extra_static_paths = [] in the jupyter_notebook_config.py file and add \".\/custom\/\" - or whatever path you chose for your custom css - inside the brackets.\nP.S.: OS is Linux Manjaro 5.12 and Jupyter Notebook version is 6.3.0.","Q_Score":4,"Tags":"css,ipython-notebook,jupyter-notebook,jupyter","A_Id":67893531,"CreationDate":"2017-04-17T18:33:00.000","Title":"Jupyter reload custom.css?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a project in which there is a for loop running about 14 times. In every iteration, a 2D array is created with this shape (4,3). I would like to concatenate those 2D arrays into one 3D array (with the shape of 4,3,14) so that every 2D array would be in different \"layer\". \nHow should that be implemented in Python?","AnswerCount":4,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":8835,"Q_Id":43466644,"Users Score":-2,"Answer":"If your arrays are only 'list', sumplt defines an empty list at the beginning and append item into it:\nfoo=[]\nfor i in range(14):\n    ...\n    foo.append(tab)","Q_Score":6,"Tags":"python,arrays","A_Id":43467467,"CreationDate":"2017-04-18T07:54:00.000","Title":"how to combine 2D arrays into a 3D array in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a chat bot using wit.ai, which will recognize the speech and convert into text in chat bot.\nIs it possible with the GUI of wit.ai to make such kind of chat bot?\nI actually converted the voice into text, but facing difficulty to integrate the voice input with chat bot. How to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":771,"Q_Id":43470642,"Users Score":0,"Answer":"since the new release of messenger, you can convert speech into text, so if you are developing for messenger or another app with a good voice-to-text, you can rely on the app instead of trying doing it by yourself. In the end you're gonna have just text inputs, but people would be able to convert it's speech into text.","Q_Score":0,"Tags":"python-2.7,wit.ai","A_Id":43544729,"CreationDate":"2017-04-18T11:16:00.000","Title":"how to make speech recognition chat bot using wit.ai?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building a regression model with about 300 features using Python Sklearn. One of the features has over 100 categories and I end up having ~100 dummy columns for this feature.Now each of the dummy column has its own coefficient, or a feature ranking score (if using Random Forest or xgb) - which is something I dont like.  However, when I create the same model in SAS JMP, it gives me one single feature score for the feature with 100 categories -it apparently handles categories automatically. Can someone tell me how SAS JMP combines the coefficients\/feature importances of 100 dummy variables into one metric. And how can i can achieve the same in Python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":284,"Q_Id":43483717,"Users Score":0,"Answer":"You may google SAS STAT manual \/User guide. Check out any major regression procedures there that support Class statement. Underneath the Class it details Reference... option. They all detail how a design matrix is fashioned out. The way you fed your 100 dummies must have been obvious enough to trigger JMP to roll back to a temp class variable that re-engineer back to one single variable. If you want to know how exactly JMP is triggered to do roll back, go to JMP website and open a technical support track. But mechanically I am confident this is what happens.","Q_Score":1,"Tags":"python,sas,regression,random-forest,dummy-variable","A_Id":48334045,"CreationDate":"2017-04-18T23:14:00.000","Title":"Combining effects of dummy variables in a regression model","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Appium-Python with AWS Device farm. And I noticed that AWS run my tests in a random order.\nSince my tests are part dependent I need to find a way to tell AWS to run my tests in a specific order.\nAny ideas about how can I accomplish that?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":251,"Q_Id":43520574,"Users Score":0,"Answer":"I work for the AWS Device Farm team. \nThis seems like an old thread but I will answer so that it is helpful to everyone in future. \nDevice Farm parses the test in a random order. In case of Appium Python it will be the order what is received from pytest --collect-only. \nThis order may change across executions. \nThe only way to guarantee an order right now is to wrap all the test calls in a new test which will be the only test called. Although not the prettiest solution this is the only way to achieve this today.\nWe are working on bringing more parity between your local environment and Device Farm in the coming weeks.","Q_Score":1,"Tags":"pytest,python-appium,aws-device-farm","A_Id":44378193,"CreationDate":"2017-04-20T13:12:00.000","Title":"AWS Device Farm- Appium Python - Order of tests","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For one of my pet projects I would like to create an arbitrary number of different integer hashes. After a bit of research I figured that universal hashing is the way to go. However, I struggle with the (numpy) implementation. Say I'm trying to use the hash family h(a,b)(x) = ((a * x + b) mod p) mod m and my x can be anywhere in the range of uint32. Then choosing p >= max(x) and a, b < p means that in the worst case a * x + b overflows not only uint32 but also uint64. I tried to find an implementation which solves this problem but only found clever ways to speed up the modulo operation and nothing about overflow.\nAny suggestions for how to implement this are greatly appreciated. Thanks :-)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":189,"Q_Id":43531607,"Users Score":1,"Answer":"(x + y) % z == ((x % z) + (y % z)) % z. So you could take the modulus before doing the sum:\n\nCast a and x to uint64. (Multiply two uint32 will never overflow uint64).\nCompute h = (a * x) % p + b\nReturn (h - p) if h > p else h. (Alternatively: return h % p)","Q_Score":1,"Tags":"python,numpy,hash","A_Id":43531728,"CreationDate":"2017-04-20T23:40:00.000","Title":"Integer overflow in universal hashing implementation","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to write a script that will have a count that starts a 001, and increasing by one every time that the script is run. \nI just help some help started this off, what can I do to set it up so that it knows where it start from every time? Is there is way that I can build it into the script to do this? \nMy bad ideas about how to do this so far: \n - Have the number(001) exported to a text file, and have the script change that number at the end of every script (001 +1).\n\nThis number will also be in a spreadsheet, so have the script read to value from the spreadsheet, and add one to that value. \n\nI feel like there has to be an easier way, and I'd prefer a way that was self-contained within the script. Can someone help point me in the right direction?\nThanks for your input.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":545,"Q_Id":43546529,"Users Score":3,"Answer":"if you want some kind of state persistance then your options are limited:\n\nsave the state into a file as you suggest in your question (either a text file or spreadsheet, but spreadsheet is harder to do)\nchange your concept so that instead of \"running the script\" multiple times, the script is always running, but you give it some kind of signal (keyboard input, GUI with a button etc) to let it know to increment the counter\nsplit your script into two halves, a server script and a client. the server would listen for connections from the client, and keep track of the current count, the client would then connect and tell the server to increment the count, if needed it could also send the previous or new count back to the client for some kind of output. this would prevent having many writes to disk, but the count would be lost if the server process is closed.","Q_Score":3,"Tags":"python,python-3.x","A_Id":43546641,"CreationDate":"2017-04-21T15:25:00.000","Title":"Python script to input the next number in a sequence every time it runs.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to move an image from its center using pygame. I loaded the image using pygame but I have the top corner coordinates of the image. how do i get the coordinates of center.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1167,"Q_Id":43549448,"Users Score":0,"Answer":"You can also query the size of the image.  Adjust the corner coordinates by half of the size in each direction.","Q_Score":0,"Tags":"python,image,pygame","A_Id":43549524,"CreationDate":"2017-04-21T18:13:00.000","Title":"Finding the position of center using pygame","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was trying to do some exploratory analyses on a large (2.7 GB) JSON dataset using R, however, the file doesn't even load in the first place. When looking for solutions, I saw that I could process the data in smaller chunks, namely by iterating through the larger file or by down-sampling it. But I'm not really sure how to do that with a JSON dataset. I also thought of converting the original JSON data into .csv, but after having a look around that option didn't look that helpful.\nAny ideas here?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":609,"Q_Id":43563447,"Users Score":1,"Answer":"The jsonlite R package supports streaming your data. In that way there is no need to read all the json data into memory. See the documentation of jsonlite for more details, the stream_in function in particular.\n\nAlternatively:\nI would dump the json into a mongo database and process the data from that. You need to install mongodb, and start running mongod. After that you can use mongoimport to import the json file into the database. \nAfter that, you can use the mongolite package to read data from the database.","Q_Score":1,"Tags":"python,json,r,bigdata","A_Id":43563552,"CreationDate":"2017-04-22T19:05:00.000","Title":"How to iterate\/ loop through a large (>2GB) JSON dataset in R\/ Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to write a program with the following requirement. \narr = ['a', 'b']\nHow to write a python program which choose a from arr x% of time.\n(For example 80% of time).\nI have no idea how should I start. Please help.   \nI know random.choice(arr). But it will give a random choice I can not make it biased.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":43579175,"Users Score":0,"Answer":"random.choices(['a', 'b'], weights=[0.8, 0.2], k=2)","Q_Score":1,"Tags":"python,python-3.x,numpy","A_Id":43579231,"CreationDate":"2017-04-24T03:07:00.000","Title":"arr = [a,b] choose a, x% of time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created window in the curses and created my call flow (data). \nwindow = curses.newwin(2500, 2500, 0, 0)\nHow should i copy the window content(exact replica) to the file ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":971,"Q_Id":43580876,"Users Score":0,"Answer":"putwin() and getwin() are the functions for saving and restoring an individual window, and they're available in Python.","Q_Score":1,"Tags":"python-2.7,ncurses,curses,python-curses","A_Id":43591335,"CreationDate":"2017-04-24T06:08:00.000","Title":"how to write the curses window content to the file in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using 3.6 Python version in anaconda spyder on my mac. But I want to change it to Python 2.7. \nCan any one tell me how to do that?","AnswerCount":8,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":189338,"Q_Id":43592879,"Users Score":4,"Answer":"In Preferences, select Python Interpreter\nUnder Python Interpreter, change from \"Default\" to \"Use the following Python interpreter\"\nThe path there should be the default Python executable. Find your Python 2.7 executable and use that.","Q_Score":42,"Tags":"python,anaconda,spyder","A_Id":43593102,"CreationDate":"2017-04-24T16:04:00.000","Title":"How to change python version in anaconda spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using 3.6 Python version in anaconda spyder on my mac. But I want to change it to Python 2.7. \nCan any one tell me how to do that?","AnswerCount":8,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":189338,"Q_Id":43592879,"Users Score":4,"Answer":"Set python3 as a main version in the terminal:\nln -sf python3 \/usr\/bin\/python\nInstall pip3:\napt-get install python3-pip\nUpdate spyder:\npip install -U spyder\n\nEnjoy","Q_Score":42,"Tags":"python,anaconda,spyder","A_Id":54063608,"CreationDate":"2017-04-24T16:04:00.000","Title":"How to change python version in anaconda spyder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to make a single gaussian kernel density plot of a dataframe with multiple columns which includes all columns of the dataframe. Does anyone know how to do this?\nSo far I only found how to draw a gaussian kernel plot of a single column with seaborn. ax = sns.kdeplot(df['shop1'])\nHowever, neither ax = sns.kdeplot(df)norax = sns.kdeplot(df['shop1','shop2]) do not work. \nOtherwise is there a workaround where I could transform the dataframe with shape df.shape(544, 33) to (17952, 2), by appending each columns to eachother?\nThe dataframe includes normalized prices for one product, whereas each column represents a different seller and the rows indicate date and time of the prices.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":465,"Q_Id":43596345,"Users Score":0,"Answer":"I did find how to work around by transforming the dataframe's columns into one single column. \n\ndf.stack()","Q_Score":0,"Tags":"python,kernel-density","A_Id":43597467,"CreationDate":"2017-04-24T19:34:00.000","Title":"python: one kernel density plot which includes multiple columns in a single dataframe","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm using g2.2 xlarge instance of amazon.\nI'm having this function that takes 3 minutes to run on my laptop which is so slow.\n         However, when running it on EC2 it takes the same time , sometimes even more.\nSeeing the statistics , I noticed EC2 uses at its best 25% of CPU.\nI paralleled my code, It's better but I get the same execution time between my laptop and EC2.\nfor my function:\nI have an image as input,I run my function 2 times(image with and without image processing) that I managed to run them in parallel.  I then extract 8 text fields from that image using 2 machine learning algorithms(faster-rcnn(field detection)+clstm(text reading) and then the text is displayed on my computer.\nAny idea how to improve performance (processing time) in EC2?","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":1356,"Q_Id":43607466,"Users Score":4,"Answer":"I think you need to profile your code locally and ensure it really is CPU bound. Could it be that time is spent on the network or accessing disk (e.g. reading the image to start with). \nIf it is CPU bound then explore how to exploit all the cores available (and 25% sounds suspicious - is it maxing out one core?). Python can be hard to parallelise due to the (in)famous GIL. However, only worry about this when you can prove it's a problem, profile first!","Q_Score":1,"Tags":"python,python-2.7,amazon-web-services,amazon-ec2","A_Id":43607778,"CreationDate":"2017-04-25T09:58:00.000","Title":"Why amazon EC2 is as slow as my machine when running python code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I use cqlengine with django. In some occasions Cassandra throws an error indicating that user has no permissions do to something. Sometimes this is select, sometimes this is update or sometimes it is something else. I have no code to share, because there is no specific line that does this. I am very sure that user has all the permissions, and sometimes it works. So if user did not have the permissions it should always throw no permission error. \nSo what might be the reasons behind this and how to find the problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":43622277,"Users Score":0,"Answer":"Is the system_auth keyspace RF the same as the amount of nodes? Did you try to run a repair on the system_auth keyspace already? If not do so.\nFor me it sounds like a consistency issue.","Q_Score":0,"Tags":"python,django,cassandra,permissions,cqlengine","A_Id":43630653,"CreationDate":"2017-04-25T22:54:00.000","Title":"Cassandra: occasional permission errors","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I use cqlengine with django. In some occasions Cassandra throws an error indicating that user has no permissions do to something. Sometimes this is select, sometimes this is update or sometimes it is something else. I have no code to share, because there is no specific line that does this. I am very sure that user has all the permissions, and sometimes it works. So if user did not have the permissions it should always throw no permission error. \nSo what might be the reasons behind this and how to find the problem?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":43622277,"Users Score":0,"Answer":"If you have authentication enabled, make sure you set appropriate RF for keyspace system_auth (should be equal to number of nodes).\nSecondly, make sure the user you have created has following permissions on all keyspaces. {'ALTER', 'CREATE', 'DROP', 'MODIFY', 'SELECT'}. If you have the user as a superuser make sure you add 'AUTHORIZE' as a permission along with the ones listed above for that user.  \nThirdly, you can set off a read-repair job for all the data in system_auth keyspace by running CONSISTENCY ALL;\nSELECT * from system_auth.users ;\nSELECT * from system_auth.permissions ;\nSELECT * from system_auth.credentials ;\nHope this will resolve the issue !","Q_Score":0,"Tags":"python,django,cassandra,permissions,cqlengine","A_Id":43645204,"CreationDate":"2017-04-25T22:54:00.000","Title":"Cassandra: occasional permission errors","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a corpus of around 6000 texts with comments from social network (FB, twitter), news content from general and regional news and magazines, etc. I have gone through first 300 of these texts and tag each of these 300 texts' content as either customer complaint or non-complaint. \nInstead of naive way of bag of words, I am wondering how can I accurately extract the features of these complaints and non-complaints texts? My goal is to use SVM or other classification algorithm\/ library such as Liblinear to most accurately classify the rest of these texts as either complaint or non-complaint with the current training set of 300 texts. Is this procedure similar to sentiment analysis? If not, where should I start?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":319,"Q_Id":43624308,"Users Score":0,"Answer":"I think you will find that bag-of-words is not so naive. It's actually a perfectly valid way of representing your data to give it to an SVM. If that's not giving you enough accuracy you can always include bigrams, i.e. word pairs, in your feature vector instead of just unigrams.","Q_Score":1,"Tags":"python,nlp,classification,feature-extraction,sentiment-analysis","A_Id":43625960,"CreationDate":"2017-04-26T03:07:00.000","Title":"How to extract COMPLAINT features from texts in order to classify complaints from non-complaints texts","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I stop\/kill a running task on Airflow UI? I am using LocalExecutor.\nEven if I use CeleryExecutor, how do can I kill\/stop the running task?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":83312,"Q_Id":43631693,"Users Score":6,"Answer":"As menioned by Pablo and Jorge pausing the Dag will not stop the task from being executed if the execution already started. However there is a way to stop a running task from the UI but it's a bit hacky.\nWhen the task is on running state you can click on CLEAR this will call job.kill() the task will be set to shut_down and moved to up_for_retry immediately hence it is stopped.\nClearly Airflow did not meant for you to clear tasks in Running state however since Airflow did not disable it either you can use it as I suggested. Airflow meant CLEAR to be used with failed, up_for_retry etc...  Maybe in the future the community will use this bug(?) and implement this as a functionality with \"shut down task\" button.","Q_Score":55,"Tags":"python,hadoop,airflow","A_Id":53409092,"CreationDate":"2017-04-26T10:33:00.000","Title":"How to stop\/kill Airflow tasks from the UI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I stop\/kill a running task on Airflow UI? I am using LocalExecutor.\nEven if I use CeleryExecutor, how do can I kill\/stop the running task?","AnswerCount":5,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":83312,"Q_Id":43631693,"Users Score":11,"Answer":"from airflow gitter (@villasv)\n\n\" Not gracefully, no. You can stop a dag (unmark as running) and clear\nthe tasks states or even delete them in the UI. The actual running\ntasks in the executor won't stop, but might be killed if the\nexecutor realizes that it's not in the database anymore. \"","Q_Score":55,"Tags":"python,hadoop,airflow","A_Id":50707968,"CreationDate":"2017-04-26T10:33:00.000","Title":"How to stop\/kill Airflow tasks from the UI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A python program P running on server S1, listening port 8443.\nSome other services can send id_isa, ip pair to P. P could use this pair and make a ssh connection to the ip (create a ssh process).\nHow to make protect the id_rsa file even the machine S1 is cracked ? How to let root user can't get the id_rsa content (It seems ssh can use -i keyfile only)?\nThe main problem is P must save the id_rsa file to the disk,so that ssh can use it to conect to the ip.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":48,"Q_Id":43633459,"Users Score":0,"Answer":"Why don't you just add an ssh-daemon on Port 8443 and use ssh-Agent forwarding?\nThat way the private key never gets written down on P and you don't have to write and maintain your own program.","Q_Score":1,"Tags":"python,linux,security,ssh","A_Id":43633928,"CreationDate":"2017-04-26T11:53:00.000","Title":"how to design this security demands?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As I learn more about Python I am starting to get into the realm of classes. I have been reading on how to properly call a class and how to import the module or package.module but I was wondering if it is really needed to do this.\nMy question is this: Is it required to move your class to a separate module for a functional reason or is it solely for readability? I can perform all the same task using defined functions within my main module so what is the need for the class if any outside of readability?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":201,"Q_Id":43660353,"Users Score":1,"Answer":"You can do as you please. If the code for your classes is short, putting them all in your main script is fine. If they're longish, then splitting them out into separate files is a useful organizing technique (that has the added benefit of the code in them no getting recompiled into byte-code everytime the the script they are used in is run.\nPutting them in modules also encourages their reuse since they're no longer mixed in with a lot of other unrelated stuff.\nLastly, they may be useful because modules are esstentially singleton objects, meaning that there's only once instance of them in your program which is created the first time it's imported. Later imports in other modules will just reuse the existing instance. This can be a nice way to do initialize that only has to be done once.","Q_Score":0,"Tags":"python,class,module,readability","A_Id":43661711,"CreationDate":"2017-04-27T14:14:00.000","Title":"Is there a reason to create classes on seperate modules?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a piece of python code that scrapes the odds of horse races from a bookmaker's site. I wish to now:\n\nRun the code at prescribed increasingly frequent times as the race draws closer.\nStore the scraped data in a database fit for extraction and statistical analysis in R.\n\nApologies if the question is poorly phrased\/explained - I'm entirely self taught and so have no formal training in computer science. I don't know how to tell a piece of python code to run itself every say n-minutes and I also have no idea how to correctly approach building such a data base or what factors I should be considering. Can someone point me in the right direction for getting started on the above?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":43670334,"Users Score":0,"Answer":"In windows, you can use Task Scheduler or in Linux crontab. You can configure these to run python with your script at set intervals of time. This way you don't have a python script continuously running preventing some hangup in a single call from impacting all subsequent attempts to scrape or store in database.\nTo store the data there are many options which could either be a flat file(write to a text file), save as a python binary(use shelf or pickle), or install an actual database like MySQL or PostgreSQL and many more. Google for info. Additionally an ORM like SQLAlchemy may make controlling, querying, and updating your database a little easier since it will handle all tables as objects and create the SQL itself so you don't need to code all queries as strings.","Q_Score":0,"Tags":"python,database-design,web-scraping","A_Id":43670482,"CreationDate":"2017-04-28T01:07:00.000","Title":"How to run python code at prescribed time and store output in database","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Given a bunch of names, how can we find out which are Chinese names and which are English names? For the Chinese names, I build a list of the Chinese last names to find out the Chinese names. For example, Bruce Lee, Lee is a Chinese last name, so we regard Bruce Lee is a Chinese name. However, the Chinese last names list is large. Is there any better way to do it? If you are not familiar with the Chinese name, you can tell how you will distinct the English names from some other names, like French names, Italian names, etc.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1206,"Q_Id":43684654,"Users Score":2,"Answer":"If you have the lists of typical Chinese and English names and the problem is performance only, I suggest you convert the lists into sets and then ask for membership in both sets as this is much faster than finding out whether an element is present in a large list.","Q_Score":2,"Tags":"python,machine-learning","A_Id":43684698,"CreationDate":"2017-04-28T16:13:00.000","Title":"How to recognize Chinese or English name using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, as you may know there are certain apps on Windows that can be installed from the app store, and are classified as Windows Trusted Apps. I am not sure, but I think these do not use the classic .exe format. So I am writing a python script to automate some stuff when I start my pc, and I need to start a certain Windows App, but I don't know how to do this as I don't know what I need to start to do so, and I also do not know where these files are located. Anyone can help?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":11049,"Q_Id":43696735,"Users Score":0,"Answer":"You can use this new technique, its called winapps its used for searching, modifying, and uninstalling apps. Its download command on cmd windows is pip install winapps.","Q_Score":2,"Tags":"python,windows,python-3.x,automation,windows-10","A_Id":59797481,"CreationDate":"2017-04-29T14:20:00.000","Title":"How can I open a Windows 10 app with a python script?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to download the random module and was wondering if I copy a code and put it in a file editor, how do I go about installing it through pip? I placed the code in notepad and saved it on my desktop as random.py. What do I do now so that I can get this in installed through anaconda? I tried pip install random.py but it says the package is not found. Is there perhaps a zip file of the random module that I can install?","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":11349,"Q_Id":43709095,"Users Score":-1,"Answer":"Use pip install random. That works with every Python distribution.","Q_Score":2,"Tags":"python,python-3.x","A_Id":43709925,"CreationDate":"2017-04-30T17:10:00.000","Title":"Downloading Random.py Using Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to download the random module and was wondering if I copy a code and put it in a file editor, how do I go about installing it through pip? I placed the code in notepad and saved it on my desktop as random.py. What do I do now so that I can get this in installed through anaconda? I tried pip install random.py but it says the package is not found. Is there perhaps a zip file of the random module that I can install?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":11349,"Q_Id":43709095,"Users Score":0,"Answer":"If using python3, it will simply be\n pip3 install random \nas @Remi stated.","Q_Score":2,"Tags":"python,python-3.x","A_Id":43709432,"CreationDate":"2017-04-30T17:10:00.000","Title":"Downloading Random.py Using Anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a work to do on numerical analysis that consists on implementing algorithms for root-finding problems. Among them are the Newton method which calculates values for a function f(x) and it's first derivative on each iteraction. \nFor that method I need a way to the user of my application enter a (mathematical) function and save it as a variable and use that information to give values of that function on different points. I know just the very basic of Python programming and maybe this is pretty easy, but how can I do it?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":239,"Q_Id":43711437,"Users Score":1,"Answer":"If you trust the user, you could input a string, the complete function expression as it would be done in Python, then call eval() on that string. Python itself evaluates the expression. However, the user could use that string to do many things in your program, many of them very nasty such as taking over your computer or deleting files.\nIf you do not trust the user, you have much more work to do. You could program a \"function builder\", much like the equation editor in Microsoft Word and similar programs. If you \"know just the very basic of Python programming\" this is beyond you. You might be able to use a search engine to find one for Python.\nOne more possibility is to write your own evaluator. That would also be beyond you, and you also might be able to find one you can use.\nIf you need more detail, show some more work of your own then ask.","Q_Score":1,"Tags":"python,math,mathematical-expressions","A_Id":43711560,"CreationDate":"2017-04-30T21:20:00.000","Title":"Mathematical functions on Python 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to build an app in Django that lets the user do some task everyday at the time they specify at runtime.\nI have looked at Celery but couldn't\u200b find anything that will help. I found apply_async and I can get the task to execute once at the specificied duration but not recurrent. I am missing something but don't know what. \nPlease suggest how can I achieve this.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":6721,"Q_Id":43733387,"Users Score":2,"Answer":"There is django-celery-beat package which allows you to dynamicly add tasks to database and then they are executed as you defined in database.(e.g. every 5 minutes) But currently they have bug which causes that task is not appended to celery queue when added to database. One suggested workaround is to restart celery process every time that new task is added. \nI solved it with Dan Baders schedule package. I scheduled task on every minute which checks database for tasks that need to be executed in current minute. Then I start each of this tasks in new thread.\nHope this helps.","Q_Score":6,"Tags":"python,django,celery","A_Id":43733656,"CreationDate":"2017-05-02T08:29:00.000","Title":"How to dynamically schedule tasks in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I process a report that consists of date fields. There are some instances wherein the date seen in the cell is not a number (how do I know? I use the isnumber() function from excel to check if a date value is really a number).\nUsing a recorded macro, for all the date columns, I do the text to columns function in excel to make these dates pass the isnumber() validation. \nAnd then I continue further processing using my python sccipt.\nBut now I need to replicate the text to column action in excel, and imitate this in Python openpyxl.\nI naively tried to do the int(cell.value) but this didn't worked.\nSo to sum up the questions, is there a way in Python to convert a date represented as text, to be changed to a date represented as a number?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":940,"Q_Id":43779887,"Users Score":0,"Answer":"Sounds like you might want to take advantage of the type guessing in openpyxl. If so, open the workbook with guess_types=True and see if that helps. NB. this feature is more suited to working with text sources like CSV and is likely to be removed in future releases.","Q_Score":0,"Tags":"python,excel,openpyxl","A_Id":43783883,"CreationDate":"2017-05-04T10:07:00.000","Title":"How to convert date formatted as string to a number in excel using openpyxl","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an AWS EC2 machine that has been running nightly google analytics scripts to load into a database.  It has been working fine up for months until this weekend.  I have not made any changes to the code.\nThese are the two errors that are showing up in my logs:\n\/venv\/lib\/python3.5\/site-packages\/oauth2client\/_helpers.py:256: UserWarning: Cannot access analytics.dat: No such file or directory\n  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))\nFailed to start a local webserver listening on either port 8080\nor port 8090. Please check your firewall settings and locally\nrunning programs that may be blocking or using those ports.\nFalling back to --noauth_local_webserver and continuing with\nauthorization.\nIt looks like it is missing my analytics.dat file but I have checked and the file is in the same folder as the script that calls the GA API.  I have been searching for hours trying to figure this out but there are very little resources on the above errors for GA.\nDoes anyone know what might be going on here?  Any ideas on how to troubleshoot more?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":913,"Q_Id":43787699,"Users Score":1,"Answer":"I am not sure why this is happening, But I have a list of steps which might help you.\n\ncheck if this issue is caused by google analytics API version, google generally deprecates the previous versions of their API.\nI am guessing that you are running this code on cron on your EC2 serv, make sure that you include the path to the folder where the .dat file is.\n3.check whether you have the latest credentials in the .dat file.\n\nAuthentication to the API will happen through the .dat file.\nHope this solves your issue.","Q_Score":6,"Tags":"python,amazon-web-services,amazon-ec2,oauth-2.0,google-analytics-api","A_Id":48089379,"CreationDate":"2017-05-04T15:56:00.000","Title":"Google analytics .dat file missing, falling back to noauth_local_webserver","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From experience I know that sometimes while copying and  pasting a password into the password filed a white space is copied along with the password and this is causing errors (I don't know how common this is, but it happens). Now I'm learning Python (no previous programming experience) and came across rstrip() lstrip() and strip() method. What would be the \"right\" way to handle such situations ? \nAny inside is highly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":367,"Q_Id":43790494,"Users Score":0,"Answer":"I would recommend not doing anything. I don't believe in editing any password submissions, except for sanitizing to prevent security risks.","Q_Score":1,"Tags":"python-3.x","A_Id":43790837,"CreationDate":"2017-05-04T18:41:00.000","Title":"white spaces while copying password into password filed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"From experience I know that sometimes while copying and  pasting a password into the password filed a white space is copied along with the password and this is causing errors (I don't know how common this is, but it happens). Now I'm learning Python (no previous programming experience) and came across rstrip() lstrip() and strip() method. What would be the \"right\" way to handle such situations ? \nAny inside is highly appreciated.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":367,"Q_Id":43790494,"Users Score":1,"Answer":"I would use strip() to strip both sides :-) I think it's very annoying when you copy paste a password and it's not accepted because you mis-copied with some extra blank characters.","Q_Score":1,"Tags":"python-3.x","A_Id":43790613,"CreationDate":"2017-05-04T18:41:00.000","Title":"white spaces while copying password into password filed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to write and read from a file in S3 using boto. I'm wondering if there is a way to append to a file without having to download the file and re-upload an edited version?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4234,"Q_Id":43791236,"Users Score":5,"Answer":"There is no way to append data to an existing object in S3.  You would have to grab the data locally, add the extra data, and then write it back to S3.","Q_Score":5,"Tags":"python-3.x,amazon-s3,boto,boto3","A_Id":43791579,"CreationDate":"2017-05-04T19:24:00.000","Title":"Appending to a text file in S3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"With dulwich I can stage a file using repo.stage, but how do I remove a file ?\nI am looking for the equivalent of git rm","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":75,"Q_Id":43824204,"Users Score":0,"Answer":"You can \"stage\" a file that no longer exists, which will remove it. Alternatively, there is also a dulwich.porcelain.remove function that provides the equivalent of git rm (i.e. removes the file if it exists and then unversions it).","Q_Score":0,"Tags":"python,dulwich","A_Id":46393625,"CreationDate":"2017-05-06T18:51:00.000","Title":"How do I remove a file from a git repository with dulwich?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to connect to a data stream written in C++ with my current program in Python, any advice or resources on how to connect?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":95,"Q_Id":43836766,"Users Score":0,"Answer":"Java has a native keyword that allows functions from c++ to be brought into java as methods. Python might have the same feature.","Q_Score":4,"Tags":"python,c++","A_Id":43836803,"CreationDate":"2017-05-07T21:12:00.000","Title":"Connecting to a data stream with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After doing a bit of research I am finding it difficult to find out how to use mysql timestamps in matplotlib.\nMysql fields to plot\nX-axis:\nField: entered\nType: timestamp\nNull: NO\nDefault: CURRENT TIMESTAMP\nSample: 2017-05-08 18:25:10\nY-axis:\nField: value\nType: float(12,6)\nNull: NO\nSample: 123.332\nWhat date format is matplotlib looking for? How do I convert to this format? I found out how to convert from unix timestamp to a format that is acceptable with matplotlib, is unix timestamp better than the timestamp field type I am using? Should I convert my whole table to unix timestamps instead?\nWould appreciate any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":202,"Q_Id":43859988,"Users Score":0,"Answer":"you can use datetime module,although i use now() function to extract datetime from mysql,but i consider the format is the same\u3002\nfor instance\npython>import datetime as dt\ni put the datetime data into a list named datelist,and now you can use  datetime.strptime function to convert the date format to what you want\npython>dates = [dt.datetime.strptime(d,'%Y-%m-%d %H:%M:%S') for d in datelist\nAt last,you can put the list named dates into plot X-axis\nI hope it helps you.","Q_Score":0,"Tags":"python,mysql,matplotlib","A_Id":43860724,"CreationDate":"2017-05-09T02:17:00.000","Title":"Python - convert mysql timestamps type to matplotlib and graph","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a page that I want to behave like this: First, the user only sees a single form, for the sake of example, lets say it allows the user to select the type of product. Upon submitting this form, a second form (whose contents depend on the product type) appears below it. The user can then either fill out the second form and submit it, or revise and resubmit the first form - either way I want the first form to maintain the user's input (in this case, the product type), even if the second form is submitted.\nHow can I do this cleanly in django? What I am struggling with is preserving the data in the first form: e.g. if the user submits the second form and it has validation errors, when the page displays the first form the product type will be rendered blank but I want the option to remain set to what the user picked. This behaviour isn't mysterious or unexpected, but is not what I want. Also, if the user submits the second form successfully, I would like to redirect so that the first form maintains the selection and the second form is cleared. \nThe best that I've thought of is mucking up the URL with the fields of the first form (admittedly not too many parameters) and storing its state there, or combining both forms into one form object in HTML and responding differently based on the name of the submit button (though I don't see how I could use a redirect to clear the second form and keep the first if I do this). Are there any cleaner, more obvious ways that I'm missing? Thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":43862233,"Users Score":0,"Answer":"may be you can store the first form values in session and provide them as initial data for the first form when you are rendering the second form with error. For eg: data={\"f1\":request.session['abc'],\"f2\":request.session[\"xyz\"]} form1 = abc(initial=data)","Q_Score":0,"Tags":"python,django,forms","A_Id":43864634,"CreationDate":"2017-05-09T06:03:00.000","Title":"Retain edit data for one form when submitting a second","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Our task is to create a turtle that always stays within a rectangle.\nIt would be really great if you could show me how I can make a turtle run away from a line another turtle has created.\nPlease don't fix the problem for me.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":220,"Q_Id":43866696,"Users Score":0,"Answer":"First, you need the bounds of the rectangle in some form -- it can be the lower left position plus a width and height or it can be the lower left position and the upper right position, etc.  (It could even be the formulas of the four lines that make up the rectangle.)\nThen write a predicate function that tests if an (x,y) position is fully within the rectangle or not.  You can simply do a series of comparisons to make sure x is greater than the lower left x and less than the upper right x, and ditto for y.  Typically returning True or False.\nIf the predicate returns False, indicating you've touched or crossed some line of the rectangle, then turn around and go in the opposite direction (or some other recovery technique.)  You can also consider first using turtle's undo feature to eliminate the move that made you touch the line.\nIf you'd like example code that does the above, please indicate such.","Q_Score":1,"Tags":"python-3.x,turtle-graphics","A_Id":43875556,"CreationDate":"2017-05-09T09:56:00.000","Title":"How can I make a turtle not touch a line?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to know how can I proceed in order to concatenate two csv files, here is the composition of this two files:\n\nThe first one contains some datas related to water chemical parameters, these measurements are taken in different dates.\nThe second one shows the different flow values of waste water, during a certain period of time.\n\nThe problem is that I am looking to assign each value of the second file (Flow values) to the right row in the first file (water chemical parameters) in such a way that the flow and the other chemical parameters are measured in the same moments.\nAny suggestions ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":43871444,"Users Score":0,"Answer":"The first file is smth like: \nTimestamp ;       Flow1 ;    Flow 2\n2017\/02\/17 00:05 ; 540 ;       0 \n2017\/02\/17 00:10 ; 535 ;       0 \n2017\/02\/17 00:15 ; 543 ;       0 \n2017\/02\/17 00:20 ; 539 ;       0 \nCSV file #2:\nTimestamp ; DOC ; Temperatute ; UV254; \n2017\/02\/17 00:14 ; 668.9 ; 15,13 ; 239,23 \n2017\/02\/17 00:15 ; 669,46 ; 15,14 ; 239,31 \n2017\/02\/17 00:19 ; 668 ; 15,13 ; 239,43 \n2017\/02\/17 00:20 ; 669,9 ; 15,14 ; 239,01 \nhe output file is supposed to be like : \n                                                                    Timestamp      ;  DOC  ;   Temperatute  ; UV254  ;   Flow1 ;    Flow2                                                   2017\/02\/17 00:15  ; 669,46 ; 15,14   ;     239,31  ;    543    ;       0\n2017\/02\/17 00:20  ; 669,9   ; 15,14   ;     239,01  ;    539   ;       0","Q_Score":0,"Tags":"python,csv,dataframe,merge","A_Id":43872949,"CreationDate":"2017-05-09T13:39:00.000","Title":"Merging two DataFrames (CSV files) with different dates using Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have a table in Azure Table Storage that is storing a LOT of data in it (IoT stuff). We are attempting a simple migration away from Azure Tables Storage to our own data services.\nI'm hoping to get a rough idea of how much data we are migrating exactly. \nEG: 2,000,000 records for IoT device #1234. \nThe problem I am facing is in getting a count of all the records that are present in the table with some constrains (EG: Count all records pertaining to one IoT device #1234 etc etc).\nI did some fair amount of research to find posts that say that this count feature is not implemented in the ATS. These posts however, were circa 2010 to 2014.\nI'm assumed (hoped) that this feature has been implemented now since it's now 2017 and I'm trying to find docs to it.\nI'm using python to interact with out ATS.\nCould someone please post the link to the docs here that show how I can get the count of records using python (or even HTTP \/ rest etc)?\nOr if someone knows for sure that this feature is still unavailable, that would help me move on as well and figure another way to go about things!\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1349,"Q_Id":43884375,"Users Score":1,"Answer":"Returning number of entities in the table storage is for sure not available in Azure Table Storage SDK and service. You could make a table scan query to return all entities from your table but if you have millions of these entities the query will probably time out. it is also going to have pretty big perf impact on your table. Alternatively you could try making segmented queries in a loop until you reach the end of the table.","Q_Score":0,"Tags":"python,azure,azure-table-storage","A_Id":43884796,"CreationDate":"2017-05-10T05:42:00.000","Title":"Counting Records in Azure Table Storage (Year: 2017)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning Python through Pythonista on the iPhone. The first thing I did was make a simple touch-screen joystick (controller). Im starting to work on the actual game, but i don't know how to merge or overlay the 2 scenes. (One is the actual game, the other is the controller I made in another file.)  I have already tried importing and running it, but it seems like only 1 could be run at once, the controller file or the game file. Any help is appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":528,"Q_Id":43896486,"Users Score":0,"Answer":"Instead of putting the joystick on a separate scene, you should draw it on a scene.Node. Then in your game scene, you can add it like another sprite, using Scene.add_child().\nTo convert the touch positions to the nodes coordinate system, you can use Node.point_from_scene(), and to convert back to the scene\u2019s coordinate system, you use Node.point_to_scene()","Q_Score":0,"Tags":"python,2d-games,pythonista","A_Id":48909025,"CreationDate":"2017-05-10T15:12:00.000","Title":"Running multiple scenes in Pythonista","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to access a Spreadsheet on a Team Drive using gspread. It is not working.  It works if the spreadsheet is on my Google Drive. I was wondering if gspread has the new Google Drive API v3 capability available to open spreadsheets on Team Drives. If so, how do I specify the fact I want to open a spreadsheet on a Google Team Drive and not my own Google drive? If not, when will that functionality be available? Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":426,"Q_Id":43897009,"Users Score":0,"Answer":"Make sure you're using the latest version of gspread. The one that is e.g. bundled with Google Colab is outdated:\n!pip install --upgrade gspread\nThis fixed the error in gs.csv_import for me on a team drive.","Q_Score":1,"Tags":"python,google-apps-script,gspread","A_Id":65546184,"CreationDate":"2017-05-10T15:34:00.000","Title":"Does gspread Support Accessing Spreadsheets on Team Drives?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Has anyone here ever worked with chalice?  Its an aws tool for creating api's.  I want to use it to create a single page application, but Im not sure how to actually serve html from it.  I've seen videos where its explored, but I can't figure out how they actually built the thing.  Anyone have any advice on where to go, how to start this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":923,"Q_Id":43898566,"Users Score":1,"Answer":"You wouldn't serve HTML from Chalice directly. It is explicitly designed to work in concert with AWS Lambda and API Gateway to serve dynamic, API-centric content. For the static parts of an SPA, you would use a web server (nginx or Apache) or S3 (with or without CloudFront). \nAssuming you are interested in a purely \"serverless\" application model, I suggest looking into using the API Gateway \"Proxy\" resource type, forwarding to static resources on S3. \nWorth noting that it's probably possible to serve HTML from Chalice, but from an architecture perspective, that's not the intent of the framework and you'd be swimming upstream to get all the capabilities and benefits from tools purpose-built for serving static traffic (full HTTP semantics w\/ caching, conditional gets, etc)","Q_Score":1,"Tags":"python,amazon-web-services,chalice","A_Id":44975845,"CreationDate":"2017-05-10T16:54:00.000","Title":"Using aws chalice to build a single page application?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to analyze the vectors looking for patterns and stuff, and use SVM on them to complete a classification task between class A and B, the task should be supervised. (I know it may sound odd but it's our homework.) so as a result I really need to know:\n1- how to extract the coded vectors of a document using a trained model?\n2- how to interpret them and how does word2vec code them?\nI'm using gensim's word2vec.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1519,"Q_Id":43904029,"Users Score":2,"Answer":"If you have trained word2vec model, you can get word-vector by __getitem__ method\nmodel = gensim.models.Word2Vec(sentences)\nprint(model[\"some_word_from_dictionary\"])\nUnfortunately, embeddings from word2vec\/doc2vec not interpreted by a person (in contrast to topic vectors from LdaModel)\n\nP\/S If you have texts at the object in your tasks, then you should use Doc2Vec model","Q_Score":1,"Tags":"python,machine-learning,gensim,word2vec,text-classification","A_Id":43976879,"CreationDate":"2017-05-10T23:09:00.000","Title":"How extract vocabulary vectors from gensim's word2vec?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm sending an item to my html page and put a value off this item in an input.\nWhat i want is when i change the input, i want to dynamically print the new value next to the input.\nSomething like that :\n\n<input type='text' value=\"{{item.qty}}\"\/>\n  {{myNewInputValue}}\n\nI know how to do this with angular but don't know if it's possible with Python\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":61,"Q_Id":43922344,"Users Score":0,"Answer":"Unfortunately you can't do this directly with Django. You'll have to set up an AJAX handler (probably on keypress) in order to do this.","Q_Score":1,"Tags":"django,python-2.7,jinja2","A_Id":43922380,"CreationDate":"2017-05-11T17:44:00.000","Title":"How to show input value next to it ? Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm bringing you this issue: I'm trying to create a program to run in Windows using PyQT, to work on a pen drive. My idea is: I plug my pen drive, and everything that I need to run the program is there, including Python 3, PyQT, etc.. I don't want the user to install all the requirements, I just want one executable that install all the programs necessary and then, there will be the executable to open the program. Considering, of course, that Python 3 is not installed in this Windows Machine\nJust wondering how can I do it? Do you guys have any idea? \nThanks, \nGus.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":322,"Q_Id":43939873,"Users Score":0,"Answer":"Just an idea - not sure if that would work under your specific conditions (PyQT etc), but couldn't you run it from the pen drive directly? As in create a Python virtual environment (for example using venv, with all the dependencies) on the pendrive and then call your program using the python interpreter in the installed virtual environment.\nOr use the virtual environment and it's interpreter to install the dependencies?","Q_Score":0,"Tags":"python,windows","A_Id":43940430,"CreationDate":"2017-05-12T14:11:00.000","Title":"Creating a \"pen drive program\" with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how exactly is the request handled, I mean,I think it's something like this:\n\nNginx receives the request, does initial handling based on configuration,passes to Gunicorn\nGunicorn receives it, and initiate a instance of the Flask app, with the request data\nFlask app receives the request data, and does the work it was programmed to\n\nIs it something like this? Does a new instance of the Flask app get initiated at each request?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":538,"Q_Id":43941174,"Users Score":2,"Answer":"Not quite. Basically flask is the webapp, it gets loaded when gunicorn starts up. \nAt that point the flask app is up and running and gunicorn itself can answer requests by sending them to the flask app within its python processes (ie, no net traffic).\nNginx sits on top of gunicorn and proxies requests between clients and gunicorn as gunicorn is not a web server.\nSo nginx -> gunicorn -> flask (loaded by gunicorn itself)\nWhen gunicorn starts up, it loads and initialises the flask app on its own. Doing that on every request would be very slow.\nNginx just proxies to gunicorn's listening port. It does not load a Flask app by itself, which is really a WSGI compliant Python webapp.","Q_Score":1,"Tags":"python,python-3.x,nginx,gunicorn","A_Id":43942327,"CreationDate":"2017-05-12T15:15:00.000","Title":"How does the Flask-Gunicorn-Nginx setup works under the hood?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to understand what eventlet.tpool is useful for. The docs say that tpool.execute() lets you take a blocking function and run it in a new thread. However, the tpool.execute() method itself blocks until the thread is complete! So how is this possibly useful? If I have some blocking\/long running function myfunc() and call it directly, it will block. If I call it inside tpool.execute(myfunc) then the tpool.execute(myfunc) call will block. What exactly is the difference? \nThe only thing I can guess is that when myfunc() is called directly, it not only blocks this coroutine but also prevents other coroutines from running, while calling tpool.execute() will block the current coroutine but somehow yields so that other coroutines can run. Is this the case? Otherwise I don't see how tpool can be useful.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1179,"Q_Id":43947405,"Users Score":5,"Answer":"You wrote the answer yourself, I can only rephrase it.\nWith regard to Eventlet, Gevent, Twisted, Asyncio and other cooperative multitasking libraries we use term \"blocking\" to denote that it blocks everything. Unpatched time.sleep(1) will block all coroutines\/greenthreads as opposed to OS threads semantics where it would only block caller OS thread and allow other OS threads to continue.\nTo differentiate things that block OS thread from things that block coroutine\/greenthread we use term \"yielding\". A yielding function is one that allows execution to rest of coroutines, while blocking (due to Python execution semantics) only caller coroutine.\nArmed with that powerful terminology, tpool.execute() turns blocking call into yielding one.\nCombined with eventlet.spawn(tpool.execute, fun, ...) it would not block even the caller coroutine. Maybe you find this a helpful combination.\nAnd patches are always welcome. Eventlet is a great library because it contains combined effort of many great people.","Q_Score":2,"Tags":"python,multithreading,coroutine,eventlet","A_Id":43962169,"CreationDate":"2017-05-12T22:42:00.000","Title":"How is eventlet tpool useful?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to find out the distance between the camera and the people (detected using the HOG descriptor) in front of camera.I'm looking into more subtle approach rather than calibrating the camera and without knowing any distances before hand.\nThis can fall under the scenario of an autonomous car finding the distance between the car in front.\nCan someone help me out with a sample code or an explanation on how to do so","AnswerCount":1,"Available Count":1,"Score":-0.3799489623,"is_accepted":false,"ViewCount":2354,"Q_Id":43954187,"Users Score":-2,"Answer":"I am sorry but finding a distance is a metrology problem, so you need to calibrate your camera. Calibrating is a relatively easy process which is necessary for any measurements.\nLet's assume you only have one calibrated camera, if the orientation\/position of this camera is fixed relatively to the ground plane, it is possible to calculate the distance between the camera and the feet of somebody (assuming the feet are visible).","Q_Score":0,"Tags":"python,opencv,image-processing,distance","A_Id":43954917,"CreationDate":"2017-05-13T14:16:00.000","Title":"How to finding distance between camera and detected object using openCV in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a project to classify 30 second samples of audio from 5 different genres (rock, electronic, rap, country, jazz). My dataset consists of 600 songs, exactly 120 for each genre. The features are a 1D array of 13 mfccs for each song and the labels are the genres.\nEssentially I take the mean of each set of 13 mfccs for each frame of the 30 second sample. This leads to 13 mfccs for each song. I then get the entire dataset, and use sklearn's scaling function.\nMy goal is to compare svm, knearest, and naive bayes classifiers (using the sklearn toolset). I have done some testing already but I've noticed that results vary depending on whether I do random sampling\/do stratified sampling.\nI do the following function in sklearn to get training and testing sets:\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=0, stratify=y)\nIt has the parameters \"random state\" and \"stratify\". When \"random state\" is ommitted, it randomly samples from the entire dataset; when it is set to 0, the training and test sets are guaranteed to be the same each time.\nMy question is, how do I appropriately compare different classifiers. I assume I should make the same identical call to this function before training and testing each classifer. My suspicion is that I should be handing the exact same split to each classifier, so it should not be random sampling, and stratifying as well.\nOr should I be stratifying (and random sampling)?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":894,"Q_Id":43972059,"Users Score":0,"Answer":"To evaluate a classifier's accuracy against another classifier, you need to randomly sample from the dataset for training and test. Use the test dataset to evaluate each classifier and compare the accuracy in one go. \nGiven a dataset stored in a dataframe , split it into training and test (random sampling is better to get an indepth understanding of how good your classifier is for all cases , stratified sampling can sometimes mask your true accuracy) Why? Let's take an example :\nIf you are doing stratified sampling on some particular category (and let's assume this category has an exceptionally large amount of data[skewed] and the classifier predicts that one category well , you might be led to believe that the classifier works well, even if doesn't perform better on categories with less information. Where does stratified sampling work better? When you know that the real world data will also be skewed and you will be satisifed if the most important categories are predicted correctly. (This definitely does not mean that your classifier will work bad on categories with less info, it can work well , it's just that stratified sampling sometimes does not present a full picture)\nUse the same training dataset to train all classifers and the same testing dataset to evaluate them. Also , random sampling would be better.","Q_Score":1,"Tags":"python,machine-learning,scikit-learn,statistical-sampling","A_Id":43972717,"CreationDate":"2017-05-15T05:25:00.000","Title":"Music genre classification with sklearn: how to accurately evaluate different models","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to get new packages (request for example) and trying to do it through easy_install, but when I try to open it (both easy_install and easy_install-3.6) all I get is a blank terminal screen popping up for a second and than closing with nothing happening. What's wrong with it and how can I get new packages?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":347,"Q_Id":43980261,"Users Score":1,"Answer":"easy_install must be used as a command in the command prompt and it cannot be opened as an application. Go to the folder where easy_install is and open command-prompt in that folder. Now perform installation of any libraries using:\n>easy_install pandas #example\nOr you can set this path in your environment variables and use it instead of using this path to install everytime.","Q_Score":1,"Tags":"python,python-3.x,packages,easy-install","A_Id":43981171,"CreationDate":"2017-05-15T13:01:00.000","Title":"easy_install not working with no error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I started to to something with opengl in pygame, but I'm stuck at the point where  gluLookAt takes world coordinates to orient the camera, but I want to move the camera with the mouse, so I have values like \"mouse moved 12 pixels to the right\".\nAt the moment I have gluLookAt(player_object.x, player_object.y, player_object.z, lookat_x, lookat_y, -100, 0, 1, 0) but I don't know how to convert the movement of the mouse to these coordinates.\nMaybe someone knows the answer or a formula to convert it. (I use python, but I think it's easy to port code or just a formula)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":198,"Q_Id":43988174,"Users Score":1,"Answer":"You need to compute the player forward vector:\nThe forward vector is the vector that points in the forward direction seen from the player's eyes - it tells you in which direction the eyes of the player are looking.\nThe local forward vector (I call it lfw for now) is probably (0,0,1) because you specified the y axis as \"up\".\nThe world forward vector (called wfv for now) is: (rotationMatrix * lfw); \nThat is the direction which the player is looking at in world coordinates because you multiplied it with the players rotationMatrix.\nThe final lookAt position is: position + wfv ( means: make one step from position in the forward direction --> yields the point after you took the step.)\nHope this helps a bit","Q_Score":0,"Tags":"python,opengl,math,pygame","A_Id":43988562,"CreationDate":"2017-05-15T20:22:00.000","Title":"opengl gluLookAt with orientation in degrees instead of coordinates","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to load function from another .py file. I have in the same folder: algo.py and test_algo.py. I need to import all functions from algo in test_algo so I use the command:\nfrom algo import *\nThe import is succesful however one function do_sthg() takes 3 arguments in algo but the imported version requires 4 arguments which was the case in a very old version of the code. I deleted all .py~ related files and there are not any other scripts with the name algo on my computer. How is that possible and how can i solve this issue?\n(I can not specify the full links to my script as it should change over time, I am using 2.7 version of Python) \nAny help would be appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":875,"Q_Id":44005182,"Users Score":1,"Answer":"I have not been able to determine where the problem was so I just specificied the full path using the command getcwd from os. It has worked so far. It means I must have a hidden .pyc or .py~ file somewhere.","Q_Score":1,"Tags":"python","A_Id":44025088,"CreationDate":"2017-05-16T15:06:00.000","Title":"Old version of a script is imported using import on Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use pyaudio with python2.7.13 to record wav ,but my pragram dead when I record more than 1 hour , how can I do if I want to record for more than 1 hour with py2.7. Thanks for your replay!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":204,"Q_Id":44006560,"Users Score":2,"Answer":"Surely you can record audio for more than an hour using pyaudio. Try invoking the recording function in a thread and put the main process in a loop or sleep for that period. \nNote: Make sure you do not run out of memory.","Q_Score":0,"Tags":"python,pyaudio","A_Id":44007671,"CreationDate":"2017-05-16T16:12:00.000","Title":"I want to use pyaudio to record wav more than hours","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently in the process of hacking together a bit of bash and python3 to integrate my Minecraft server with my friends Discord. I managed to power through most of the planned features with nary a hitch, however now I've gotten myself stuck halfway into the chat integration. I can send messages from the Discord to the server no problem, but I have no idea how to read the console output of the server instance, which is running in a screen session.\nI would appreciate some pointers in the right direction, if you know how this sort of thing is done. Ideally I would like a solution that is capable of running asynchronously, so I don't have to do a whole lot of busy-waiting to check for messages.\nP.S.: Sorry if this belongs on superuser instead, I wasn't sure where to put it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":254,"Q_Id":44010155,"Users Score":1,"Answer":"Well, the ideal solution would be to write a bukkit plugin\/forge mod to do this, rather than doing this entirely from outside the actual server. That being said, however, your best bet is probably watching the log files, as JNevill says in the comment.","Q_Score":1,"Tags":"linux,bash,python-3.x,minecraft,gnu-screen","A_Id":44896034,"CreationDate":"2017-05-16T19:37:00.000","Title":"How do I grab console output from a program running in a screen session?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a program in c++, but i cant make the program because in one part of the code I need to run a python program from c++ and I dont know how to do it. I've been trying many ways of doing it but none of them worked. So the code should look sometihnglike this:somethingtoruntheprogram(\"pytestx.py\"); or something close to that. Id prefer doing it without python.h. I just need to execute this program, I need to run the program because I have redirected output and input from the python program with sys.stdout and sys.stdin to text files and then I need to take data from those text files and compare them. I am using windows.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":362,"Q_Id":44023863,"Users Score":0,"Answer":"There's POSIX popen and on Windows _popen, which is halfway between exec and system. It offers the required control over stdin and stdout, which system does not. But on the other hand, it's not as complicated as the exec family of functions.","Q_Score":0,"Tags":"python,c++,python-3.x,c++11","A_Id":44025218,"CreationDate":"2017-05-17T11:41:00.000","Title":"How to run a python program from c++","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Thanks for your help on this.\nThis feels like a silly question, and I may be overcomplicating things.  Some background information - I just recently learned some machine learning methodologies in Python (scikit and some statsmodels), such as linear regression, logistic regression, KNN, etc. I can work the steps of prepping the data in pandas data frames and transforming categorical data to 0's and 1's.  I can also load those into a model (like, logistic regression in scikit learn).  I know how to train and test it (using CV, etc.), and some fine tuning methods (gridscore, etc.). But this is all in the scope of predicting outcomes on new data.  I mainly focused on learning on building a model to predict on new X values, and testing that model to confirm accuracy\/precision.  \nHowever, now I'm having trouble identifying and executing the steps to the OTHER kinds of questions that say, a regression model, can answer, like:\nWhy did customer service calls drop last month?\nShould we go with this promotion model or another one?\nAssuming we have all our variables\/predictor sets, how would we determine those two questions using any supervised machine learning model, or just a stat model in the statsmodels package.\nHope this makes sense.  I can certainly go into more detail.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":200,"Q_Id":44045913,"Users Score":0,"Answer":"Why did customer service calls drop last month?\n\nIt depends on what type and features of data you have to analyze and explore the data. One of the basic things is to look at correlation between features and target variable to check if you can identify any feature that can correlate with the drop of calls. So exploring different statistic might help better to answer this question than prediction models.\nAlso it is always a good practice to analyze and explore the data before you even start working on prediction models as its often necessary to improve the data (scaling, removing outliers, missing data etc) depending on the prediction model you chose. \n\nShould we go with this promotion model or another one?\n\nThis question can be answered based on the regression or any other prediction models you designed for this data. These models would help you to predict the sales\/outcome for the feature if you can provide the input features of the promotion models.","Q_Score":0,"Tags":"python,machine-learning,statistics,regression,data-science","A_Id":44049390,"CreationDate":"2017-05-18T10:59:00.000","Title":"Answering business questions with machine learning models (scikit or statsmodels)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to export a file as mp3 in pydub, but I get this error:\n\nAutomatic encoder selection failed for output stream #0:0. Default encoder for format mp3 is probably disabled. Please choose an encoder manually\n\nHow do I select an encoder manually, what is the default encoder, and how could I enable it?\nPS: My Pydub opens mp3 files without any problem. I'm using Windows and Libav.","AnswerCount":3,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":8086,"Q_Id":44058544,"Users Score":6,"Answer":"The other solution did not work for me. The problem for me was that the ffmpeg version that came installed with Anaconda did not seem to be compiled with an encoder. So instead of:\nDEA.L. mp3                  MP3 (MPEG audio layer 3) (decoders: mp3 mp3float mp3_at ) (encoders: libmp3lame )\nI saw:\nDEA.L. mp3                  MP3 (MPEG audio layer 3) (decoders: mp3 mp3float mp3_at )\nWithout the (encoders: ...) part.\nMy solution was to do this:\n\nffmpeg -codecs | grep mp3, to check if there is any encoder (there isn't!).\nconda uninstall ffmpeg\nOpen new terminal window.\nbrew install ffmpeg --with-libmp3lame\nffmpeg -codecs | grep mp3, to check if there is any encoder (now there is!).","Q_Score":5,"Tags":"python,audio,mp3,encoder,pydub","A_Id":48354157,"CreationDate":"2017-05-18T22:11:00.000","Title":"Pydub export error - Choose encoder manually","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to build a script that opens the Google Earth.app which I can see in Finder, but when I go to the applications folder it is not present. I looked at some other posts to find the filepath of Google Earth.app via sudo find \/ -iname *.app, which was \/Applications\/Google Earth.app. When I try and find this file I get 'No such file or directory'. Could some one please explain why you applications that are in Finder don't show up in terminal? Also how would I find the correct file path so I can use subprocess.Popen() to open Google Earth in Python.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":103,"Q_Id":44089046,"Users Score":0,"Answer":"Two problems going on here:\n1) That path is probably correct. You're not using find correctly, in particular. You need to do sudo find \/ -name \"*.app\" (note the quotes around *app). From the man page:\n\n-iname pattern\n      Like -name, but the match is case insensitive. For example, the patterns 'fo*' and 'F??' match the file names 'Foo', 'FOO', 'foo', 'fOo', etc. In these patterns, unlike filename expansion by the shell, an initial '.' can be matched by '*'. That is, find -name *bar will match the file '.foobar'. Please note that you should quote patterns as a matter of course, otherwise the shell will expand any wildcard characters in them. \n\n2) Try using subprocess.Popen([\"\/Applications\/Google Earth.app\"], shell=True). Don't worry too much about security problems with shell=True unless you are taking user input. If it's just hardcoded to use your path to Google Earth, you're fine. If you have user input in your logic, however, DO NOT use shell=True. shell=True just means that shell metacharacters will work if they are in the command. The reason you need it is that subprocess.Popen() will have trouble parsing your command since there is a space in the path. Alternatively, you could just use os.system(\"\/Applications\/Google Earth.app\").","Q_Score":0,"Tags":"python,terminal,filepath","A_Id":44089362,"CreationDate":"2017-05-20T17:43:00.000","Title":"Trying to open Google Earth via a Script, file path nonexistent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have problem about importing OpenCV to my project.\nNot actually problem, but I didn't find how to do that. I know it's trivial, but I really don't know.\nI have opencv downloaded and compiled in my home directory.\nI know how to import it in virtualenv, but how to import it directly from original - non virtualenv python2.7?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":71,"Q_Id":44089424,"Users Score":0,"Answer":"To import opencv in your python project import cv2","Q_Score":0,"Tags":"python,opencv,import","A_Id":48517382,"CreationDate":"2017-05-20T18:28:00.000","Title":"How to import opencv in python (not from virtualenv) [UBUNTU]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've built a small telegram bot using python-telegram-bot.\nWhen a conversation is started,I add a periodical job to the job queue and then message back to the user every X minutes.\nProblem is when my bot goes offline (maintenance, failures, etc), the jobqueue is lost and clients do not receive updates anymore unless they send \/start again\nI could maybe store all chat_ids in a persistent queue and restore them at startup but how do I send a message without responding to an update ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":778,"Q_Id":44090457,"Users Score":0,"Answer":"you have lots of options. at first you need to store all chat_ids. you can do it in database or simple text file.\nthen you need a trigger in order to start sending messages. I'm not familiar with your technology but i just create simple service in order to do it.","Q_Score":1,"Tags":"telegram-bot,python-telegram-bot","A_Id":44094915,"CreationDate":"2017-05-20T20:19:00.000","Title":"Restoring job-queue between telegram-bot restarts","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing a python webpage scraper .\nSome tutorial told me to use this package: BeautifulSoup. So I installed it using pip.\nThen, in my script, I try to import BeautifulSoup as bs. But I was warned that no module named BeautifulSoup.\nIs there a reliable way to get module name out of an installed package?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":91,"Q_Id":44100906,"Users Score":-1,"Answer":"Try this from bs4 import BeautifulSoup\nEdit: Was already answered by @jonsharpe and @Vin\u00edcius Aguiar in the comments under the question.","Q_Score":1,"Tags":"python,python-3.x","A_Id":44100972,"CreationDate":"2017-05-21T19:23:00.000","Title":"I installed a pip package, how to know the module name to import?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the python libraries from the Assistant SDK for speech recognition via gRPC. I have the speech recognized and returned as a string calling the method resp.result.spoken_request_text from \\googlesamples\\assistant\\__main__.py and I have the answer as an audio stream from the assistant API with the method resp.audio_out.audio_data also from \\googlesamples\\assistant\\__main__.py\nI would like to know if it is possible to have the answer from the service as a string as well (hoping it is available in the service definition or that it could be included), and how I could access\/request the answer as string.\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.4621171573,"is_accepted":false,"ViewCount":1474,"Q_Id":44123641,"Users Score":5,"Answer":"Currently (Assistant SDK Developer Preview 1), there is no direct way to do this. You can probably feed the audio stream into a Speech-to-Text system, but that really starts getting silly.\nSpeaking to the engineers on this subject while at Google I\/O, they indicated that there are some technical complications on their end to doing this, but they understand the use cases. They need to see questions like this to know that people want the feature.\nHopefully it will make it into an upcoming Developer Preview.","Q_Score":3,"Tags":"python,google-assistant-sdk,google-assist-api","A_Id":44134868,"CreationDate":"2017-05-22T23:41:00.000","Title":"How to receive answer from Google Assistant as a String, not as an audio stream","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"guys.\nI have a large data set (60k samples with 50 features). One of this features (which is really relevant for me) is job names. There are many jobs names that I'd like to encode to fit in some models, like linear regression or SVCs. However, I don't know how to handle them.\nI tried to use pandas dummy variables and Scikit-learn One-hot Encoding, but it generate many features that I may not be encounter on test set. I tried to use the scikit-learn LabelEncoder(), but I also got some errors when I was encoding the variables float() > str() error, for example.\nWhat would you guys recommend me to handle with this several categorical features? Thank you all.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1235,"Q_Id":44124471,"Users Score":0,"Answer":"One another solution is that, you can do a bivariate analysis of the categorical variable with the target variable. What yo will get is a result of how each level affects the target. Once you get this you can combine those levels that have a similar effect on the data. This will help you reduce number of levels, as well as each well would have a significant impact.","Q_Score":0,"Tags":"python,machine-learning,scikit-learn","A_Id":54380982,"CreationDate":"2017-05-23T01:40:00.000","Title":"How to encode categorical with many levels on scikit-learn?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am currently in the phase of data preparation and have a certain issue I would like to make easy. \nThe content of my columns: 10 MW \/ color. All the columns which have this content are named with line nr. [int] or a [str]\nWhat I want to display and which is the data of interest is the color. What I did was following: \ndf['columnname'] = df['columnname'].str.split('\/').str[-1]\nThe problem which occurs is that this operation should be done on all columns which names start with the string \"line\". How could I do this?\nI thought about doing it with a for-loop or a while-loop but I am quite unsure how to do the referencing in the data frame then since I am a nooby in python for now. \nThanks for your help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":50,"Q_Id":44133280,"Users Score":0,"Answer":"Ok just solved the question: \nwith df.shape I found out what the dimensions are and then started a for loop:\nfor i in range(1,x):\ndf[df.columns[i]]= df[df.columns[i]].str.split('\/').[-1]\nIf you have any more efficient ways let me know :)","Q_Score":0,"Tags":"python,string,pandas,split","A_Id":44134880,"CreationDate":"2017-05-23T11:17:00.000","Title":"Strip certain content of columns in multiple columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am from electrical engineering and currently working on a project using UP-Board, I have attached LEDs, switch, Webcam, USB flash drive with it. I have created an executable script that I want to run at startup. \nwhen I try to run the script in terminal using the code sudo \/etc\/init.d\/testRun start it runs perfectly. Now when I write this command in terminal sudo update-rc.d testRun defaults to register the script to be run at startup it gives me the following error\n\ninsserv: warning: script 'testRun' missing LSB tags and overrides\n\nPlease guide me how to resolve this? I am from Electrical engineering background, so novice in this field of coding. Thanks a lot :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":24,"Q_Id":44140535,"Users Score":0,"Answer":"The thing to remember is that you run the script as you but like chron startup does not, so you need to:\n\nEnsure that the executable flags are set for all users and that it is in a directory that everybody has access to.\nUse the absolute path for every thing, including the script.\nSpecify what to run it with, again with the absolute path.","Q_Score":0,"Tags":"python","A_Id":44140659,"CreationDate":"2017-05-23T16:39:00.000","Title":"Error while Registering the script to be run at start-up, how to resolve?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using PyMC3 to cluster my grouped data. Basically, I have g vectors and would like to cluster the g vectors into m clusters. However, I have two problems.\nThe first one is that, it seems PyMC3 could only deal with one-dimensional data but not vectors. The second problem is, I do not know how to extract the cluster id for the raw data. I do extract the number of components (k) and corresponding weights. But I could not extract the id that indicating the which cluster that each point belongs to.\nAny ideas or comments are welcomed!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":95,"Q_Id":44141059,"Users Score":0,"Answer":"If I understand you correctly, you're trying to extract which category (1 through k) a data point belongs to. However, a Dirichlet random variable only produces a probability vector. This should be used as a prior for a Categorical RV, and when that is sampled from, it will result in a numbered category.","Q_Score":0,"Tags":"python,process,cluster-computing,pymc3,dirichlet","A_Id":44144746,"CreationDate":"2017-05-23T17:08:00.000","Title":"How to extract cluster id from Dirichlet process in PyMC3 for grouped data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating a GUI interface that will be using a 7\" touch display with a raspberry pi 3.  I want the GUI to take the place of the desktop, I do not want it displayed in a window on the desktop. any thoughts on how to do that.  I have read the raspberry pi documentation to edit the rc.local script to start the application at login, but I can not figure out how to set up the python GUI with out creating a window","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":737,"Q_Id":44186905,"Users Score":0,"Answer":"Your pi boots up and displays a console - just text - by running a program (getty). Then you run another application called a graphical display manager which then runs a window manager. On a pi it is usually gnome but there are many others,.. this window manager is what displays your GUI window. What you want is obviously possible, it is just that it is non-trivial to do. What you are talking about is either kiosk-mode application still running 'on the desktop' as you say but which obscures the desktop completely and does not allow you to switch or de-focus or an even more complicated JeOS like Kodi\/XBMC bare metal installation running without your current window manager. Your python would have to do the job of the display manager and the window manager and it would be very, very slow. \nUse a really light window manager and go kiosk mode. Or you could go with text! There are libraries eg ncurses but I'm not sure how that would work with your touch screen display.","Q_Score":1,"Tags":"python,user-interface,raspberry-pi3","A_Id":44188711,"CreationDate":"2017-05-25T17:55:00.000","Title":"how to replace the desktop interface with a python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If an aircraft is flying VFR in the US, if the heading is east, the altitude must be an odd thousand plus 500 feet (1500, 3500, 5500, etc). If flying west, the altitude must be an even thousand plus 500 feet (2500, 4500, 6500, etc). If I input a given altitude, but it is the wrong (odd or even) for the heading, how do I get Python to correct it next higher odd or even thousandths (1500 becomes 2500, 6500 becomes 7500, etc)? We never round down for altitudes. Thanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":54,"Q_Id":44188070,"Users Score":0,"Answer":"You could divide your altitude by 1000.0 and cast to an int which would drop the decimal: \nif int(altitude\/1000.0) % 2 == 0 \nThen you can do whatever you want with that information.","Q_Score":1,"Tags":"python,rounding","A_Id":44205462,"CreationDate":"2017-05-25T19:07:00.000","Title":"Determining Thousandths in a number","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"in my app I have a mixin that defines 2 fields like start_date and end_date. I've added this mixin to all table declarations which require these fields. \nI've also defined a function that returns filters (conditions) to test a timestamp (e.g. now) to be >= start_date and < end_date. Currently I'm manually adding these filters whenever I need to query a table with these fields.\nHowever sometimes me or my colleagues forget to add the filters, and I wonder whether it is possible to automatically extend any query on such a table. Like e.g. an additional function in the mixin that is invoked by SQLalchemy whenever it \"compiles\" the statement. I'm using 'compile' only as an example here, actually I don't know when or how to best do that.\nAny idea how to achieve this?\nIn case it works for SELECT, does it also work for INSERT and UPDATE?\nthanks a lot for your help\nJuergen","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":44207726,"Users Score":0,"Answer":"I tried extending Query but had a hard time. Eventually (and unfortunately) I moved back to my previous approach of little helper functions returning filters and applying them to queries.\nI still wish I would find an approach that automatically adds certain filters if a table (Base) has certain columns.\nJuergen","Q_Score":1,"Tags":"python,sqlalchemy","A_Id":44395701,"CreationDate":"2017-05-26T18:06:00.000","Title":"sqlalchemy automatically extend query or update or insert upon table definition","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In a Django website of mine, I allow usernames that are alphanumeric, and\/or contain @ _ . + -. Moreover, whitespaces are allowed too. I've written a simple regex to ensure this: '^[\\w\\s.@+-]+$'. \nIt might be an obvious question, but how do I capture characters that do not pass regex validation? I want to display such characters in a tool tip to my users.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":26,"Q_Id":44217644,"Users Score":1,"Answer":"Using the carat inside of square brackets (e.g. [^...]) makes it an inverse. So, for example, [A-Za-z0-9_] would match alpha numerics and underscores, whereas [^A-Za-z0-9_] would match anything that is not alpha numerics or underscores. In your case, the regex you seem to want is r'^[^\\w\\s\\.\\@\\+\\-]+$'.","Q_Score":0,"Tags":"python,regex,django","A_Id":44217707,"CreationDate":"2017-05-27T13:50:00.000","Title":"Catching characters that do not pass regex validation","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've just started learning python few days ago and I'd like to know how to simulate mouse movements inside games that have forced mouse coordinates.\ndirectx environments?\nI've currently tested pyautogui, ctypes, wxpython. I've also tried using directpython11 but I've had trouble installing it, ton of dll errors.\nCan't find any topics helping with this in google, lots of pages on how to click or write in these kinds of cases but nothing about moving the mouse.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1950,"Q_Id":44233219,"Users Score":1,"Answer":"Found a perfect solution, it will require some extra stuff to run but its the shortest way.  \nHaven't found anyone who actually knows how to simulate mouse but decided to ask Sentdex for help and he recommended using vJoy to simulate controller.\nSo you need to simulate a controller instead of mouse by using a combination of vJoy(controller driver) and FreePIE(Input emulator).  \nAfter doing some research, for my purpose the best solution for moving on the  axis(x,y) is to bind controller (x,y) axis movements to keyboard shortcuts(E.g. W.A.S.D) and make the main script to press these shortcuts, if I'm looking in the wrong direction.  \ntl;dr Simulate controller. NEED: vJoy, FreePie","Q_Score":1,"Tags":"python,directx,mouseevent,mouse,mousemove","A_Id":44331240,"CreationDate":"2017-05-29T00:21:00.000","Title":"How to simulate mouseMovement in-game?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to detect the difference between a spade, club, diamond and hart. the number on the card is irrelevant, just the suit matters.\ni've tried color detection by looking at just the red or black colors, but that still leaves me with two results per color. how could i make sure i can detect each symbol individually? \nfor instance: i have a picture of a red hart, a red diamond, a black spade and a black club. i want to draw the contours of each symbol in a different color. \nI'm using my webcam as a camera.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4838,"Q_Id":44242207,"Users Score":0,"Answer":"As the card symbol is at fixed positions, you may try below (e.g. in OpenCV 3.2 Python):\n\nCrop the symbol at top left corner, image = image[h1:h2,w1:w2] \nThreshold the symbol colors to black, the rest to white, thresh = mask = cv2.inRange(image,(0,0,0),(100,100,100)) \nPerform a find contour detection, _, contours, hierarchy = cv2.findContours()\nGet the area size of the contour. area = cv2.contourArea(contour)\nCompare the area to determine which one of the 4 symbols it belongs to.\n\nIn which you have to build the area thresholds of each symbol for step 4 to compare. All the cv2 functions above are just for reference.\nHope this help.","Q_Score":0,"Tags":"python,opencv","A_Id":44246824,"CreationDate":"2017-05-29T12:12:00.000","Title":"detect card symbol using opencv python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have couple of file with same name, and I wanted to get the latest file \n[root@xxx tmp]# ls -t1 abclog*\nabclog.1957\nabclog.1830\nabclog.1799\nabclog.1742\nI can accomplish that by executing below command.\n[root@xxx tmp]# ls -t1  abclog*| head -n 1\nabclog.1957\nBut when I am trying to execute the same in python , getting error :\n\n\n\nsubprocess.check_output(\"ls -t1 abclog* | head -n 1\",shell=True)\n      ls: cannot access abclog*: No such file or directory\n      ''\n\n\n\nSeems it does not able to recognize '*' as a special parameter. How can I achieve the same ?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":44243853,"Users Score":0,"Answer":"Make sure you execute this in the directory where the files exist. If you just fire up Idle to run this code, you will not be in that directory.","Q_Score":0,"Tags":"python,shell,subprocess","A_Id":44243964,"CreationDate":"2017-05-29T13:35:00.000","Title":"how to use subprocess.check_output() in Python to list any file name as \"abc*\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm just trying to find a way to access the name property of an Area element inside Revit Python Shell, tried looking on Jeremy Tammik's amazingly informative blog, tried AUGI, Revit API docs, been looking for 2 days now...\nTried accessing via a bunch of ways, FilteredElementsCollector(doc).OfCategory(BuiltInCategory.OST_Areas), tried by Area class, tried through AreaTag, every single time I get an error under every circumstance and it's driving me nuts, it seems like such a simple issue that I can't seem to grasp!\nEDIT: Also tried by element id, through tags, through area schemes, nada, no go...\nCan anyone please tell me how to access this property via RPS?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":127,"Q_Id":44259535,"Users Score":1,"Answer":"To answer my own question, I actually never thought of looking through the code of other Revit Python scripts... in this case of PyRevit, which is in my opinion far more eloquently written than RPS, raelly looking forward for their console work to be done!\nBasically, I had mistakenly used GetParameter('parameter') instead of LookupParameter('parameter').\nAs I said, it was something stupidly simple that I just didn't understand.\nIf anyone has sufficient knowledge to coherently clarify this, please do answer!\nMany thanks!","Q_Score":1,"Tags":"revit-api,revitpythonshell","A_Id":44261410,"CreationDate":"2017-05-30T10:19:00.000","Title":"Accessing Area.Name Throws Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I get a ximgproc_DisparityWLSFilter from cv2.ximgproc.createDisparityWLSFilter(left_matcher),\nbut I cannot get ximgproc_DisparityWLSFilter.filter() to work.\nThe error I get is \n\nOpenCV Error: Assertion failed (!disparity_map_right.empty() && (disparity_map_right.depth() == CV_16S) && (disparity_map_right.channels() == 1)) in cv::ximgproc::DisparityWLSFilterImpl::filter, file ......\\opencv_contrib\\modules\\ximgproc\\src\\disparity_filters.cpp, line 262\n\nIn general, how do I figure out how to use this, when there isn't a single google result for \"ximgproc_DisparityWLSFilter\"?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2604,"Q_Id":44276962,"Users Score":0,"Answer":"Unlike c++, Python doesn't work well with pointers. So the arguments are \nFiltered_disp = ximgproc_DisparityWLSFilter.filter(left_disp,left, None,right_disp)\nNote that it's no longer a void function in Python!\nI figured this out through trial and error though.","Q_Score":2,"Tags":"python,opencv,disparity-mapping","A_Id":44306111,"CreationDate":"2017-05-31T06:10:00.000","Title":"What are the ximgproc_DisparityWLSFilter.filter() Arguments?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm new to AWS in general, and would like to learn how to deploy a dynamic website with AWS. I'm coming from a self-hosted perspective (digitalocean + flask app), so I'm confused on what exactly the process would be for AWS.\nWith self-hosting solution, the process is something like:\n\nUser makes a request to my server (nginx)\nnginx then directs the request to my flask app\nflask app handles the specific route (ie, GET \/users)\nflask does db operations, then builds an html page using jinja2 with the results from the db operation\nreturns html to user and user's browser renders the page.\n\nWith AWS, I understand the following:\n\nUser makes a request to Amazon's API Gateway (ie, GET \/users)\nAPI Gateway can call a AWS Lambda function\nAWS Lambda function does db functions or whatever, returns some data\nAPI Gateway returns the result as JSON (assuming I set the content-type to JSON)\n\n\nThe confusing part is how do I generate the webpage for the user, not just return the JSON data? I see two options:\n1) Somehow get AWS Lambda to use Jinja2 module, and use it to build the HTML pages after querying the db for data. API Gateway will just return the finished HTML text. Downside is this will no longer be a pure api, and so I lose flexibility.\n2) Deploy Flask app onto Amazon Beanstalk. Flask handles application code, like session handling, routes, HTML template generation, and makes calls to Amazon's API Gateway to get any necessary data for the page.\nI think (2) is the 'correct' way to do things; I get the benefit of scaling the flask app with Beanstalk, and I get the flexibility of calling an API with the API Gateway.\n\nAm I missing anything? Did I misunderstand something in (2) for serving webpages? Is there another way to host a dynamic website without using a web framework like Flask through AWS, that I don't know about?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":818,"Q_Id":44297372,"Users Score":1,"Answer":"The recommended way to host a server with lambda and without EC2 is: \n\nHost your front static files on S3 (html, css, js). \nConfigure your S3 bucket to be a static web server \nConfigure your lambdas for dynamic treatments and open it to the outside with API-gateway \nyour JS call the lambda through API-gateway, so don't forget to activate CORS (on the S3 bucket AND on API-gateway). \nconfigure route53 to link it with your bucket (your route53 config must have the same name as your bucket) so you can use your own DNS name, not the generic S3-webserver url","Q_Score":2,"Tags":"python,amazon-web-services,flask,aws-lambda,aws-api-gateway","A_Id":44307224,"CreationDate":"2017-06-01T02:06:00.000","Title":"Serving dynamic webpages using aws?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm new to AWS in general, and would like to learn how to deploy a dynamic website with AWS. I'm coming from a self-hosted perspective (digitalocean + flask app), so I'm confused on what exactly the process would be for AWS.\nWith self-hosting solution, the process is something like:\n\nUser makes a request to my server (nginx)\nnginx then directs the request to my flask app\nflask app handles the specific route (ie, GET \/users)\nflask does db operations, then builds an html page using jinja2 with the results from the db operation\nreturns html to user and user's browser renders the page.\n\nWith AWS, I understand the following:\n\nUser makes a request to Amazon's API Gateway (ie, GET \/users)\nAPI Gateway can call a AWS Lambda function\nAWS Lambda function does db functions or whatever, returns some data\nAPI Gateway returns the result as JSON (assuming I set the content-type to JSON)\n\n\nThe confusing part is how do I generate the webpage for the user, not just return the JSON data? I see two options:\n1) Somehow get AWS Lambda to use Jinja2 module, and use it to build the HTML pages after querying the db for data. API Gateway will just return the finished HTML text. Downside is this will no longer be a pure api, and so I lose flexibility.\n2) Deploy Flask app onto Amazon Beanstalk. Flask handles application code, like session handling, routes, HTML template generation, and makes calls to Amazon's API Gateway to get any necessary data for the page.\nI think (2) is the 'correct' way to do things; I get the benefit of scaling the flask app with Beanstalk, and I get the flexibility of calling an API with the API Gateway.\n\nAm I missing anything? Did I misunderstand something in (2) for serving webpages? Is there another way to host a dynamic website without using a web framework like Flask through AWS, that I don't know about?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":818,"Q_Id":44297372,"Users Score":1,"Answer":"You definitely have to weigh the pros and cons of serving the dynamic website via API GW and Lambda. \nPros:\n\nLikely cheaper at low volume\nDon't have to worry about scaling\nLambda Functions are easier to manage than even beanstalk.\n\nCons:\n\nThere will be some latency overhead \nIn some ways less flexible, although Python is well supported and you should be able to import the jinja2 module.\n\nBoth of your proposed solutions would work well, it kind of depends on how you view the pros and cons.","Q_Score":2,"Tags":"python,amazon-web-services,flask,aws-lambda,aws-api-gateway","A_Id":44312884,"CreationDate":"2017-06-01T02:06:00.000","Title":"Serving dynamic webpages using aws?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to map  to select the document like in a normal browser. I tried using ggVG ( vim equivalent) but 'V' didn't work. Does anyone know how to do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":958,"Q_Id":44298778,"Users Score":5,"Answer":"Lower-case v should work (unless you use the QtWebEngine backend). Otherwise, Ctrl-A in insert mode does.\nHowever, Stackoverflow is for programming questions - this isn't about programming. ;-)","Q_Score":2,"Tags":"python,browser","A_Id":44317597,"CreationDate":"2017-06-01T04:52:00.000","Title":"How to select all the text in a page in QuteBrowser?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know easy way, make a few different fields for needed currencies, but that's not only ugly, but the currencies will be hardcoded. It seems to me be more elegant through django-parler, but I do not quite understand how to do it.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":210,"Q_Id":44313288,"Users Score":1,"Answer":"The simplest way to localize prices in django-SHOP, is to use the MoneyInXXX class. This class can be generated for each currency using the MoneyMaker factory.\nWhenever an amount of a Money class is formatted, it is localized properly.","Q_Score":1,"Tags":"python,django,django-parler,django-shop","A_Id":50614495,"CreationDate":"2017-06-01T17:00:00.000","Title":"What the right way to localize the price in the Django-shop?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I currently installed via plug-in manager of Notepad++ the Python Indent plug-in\nI cannot uninstall it.\nIt's in update pane of Notepad++ plug-in manager, I check it and update it.\nAfter update installation it is there again and not in installed plug-ins.\nSo it cannot be uninstalled.\nAny idea how to remove it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1831,"Q_Id":44356514,"Users Score":0,"Answer":"Yeah, I had also this problem of a plugin crashing my notepad++ every minute, but I used notepad++ portable, instead, you just go to the directory where it's installed and look for the plugins directory, notepad++ should offer an inner functionality of doing this.","Q_Score":1,"Tags":"python,plugins,notepad++","A_Id":51279361,"CreationDate":"2017-06-04T16:50:00.000","Title":"How to uninstall Python indent plug-in from Notepad++?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If for example I want to show a zero(0) for all users to see, and I want all users to add one(1) to the number With their Identity only shown for superusers. And how to make sure that each user only can add one time, and of course what is the Security requirements that have to be done to prevent unautohrized Access to change any of this or to get any information?\nI understand this is a big topic, but could someone briefly explain for me what parts of Programming that are involved, and maybe some good books on these topics?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":79,"Q_Id":44358307,"Users Score":4,"Answer":"The web is stateless. This means that if a browser requests the same page twice, a traditional web server has no real way of knowing if it's the same user.\nEnter sessions. Django has an authentication system which requires each user to log in. When the user is logged in they're given a session. A session is made of two parts; A cookie containing a randomly generated token, and a database entry with that same token.\nWhen a user logs in, a new session token is generated and sent, via a cookie, back to the user which the browser stores. At the same time, that record is created in the database. Each time a browser makes a request to Django, it sends its session cookie along with the request and Django compares this to the tokens in the database. If the token exists, the user is considered to be logged in. If the token doesn't exist, the user isn't logged in.\nIn Django, there are User models which make it easy to check who the currently logged in user is for each request. They're doing all that token checking in the background for us on each and every request made by every user. Armed with this, we can associate other models via \"foreign key\" relationships to indicate who owns what.\nSay you were making a blog where multiple users could write articles. If you wanted to build an editing feature you'd probably want to restrict users to only be allowed to edit their own articles and nobody else's. In this situation, you'd receive the request, find out who the current user was from it, compare that user to the \"author\" field on the blog Post model and see if that foreign key matches. If it matches, then the user making the current request is the owner and is allowed to edit.\nThis whole process is secured by the fact that the session tokens are randomly generated hashes, rather than simple ID numbers. A malicious attacker can't simply take the hash and increment the value to try and access adjacent accounts, they'd have to intercept another user's hash entirely. This can be further secured by using SSL certificates so that your connections go over https:\/\/ and all traffic is encrypted between the browser and your server.","Q_Score":0,"Tags":"python,django","A_Id":44358407,"CreationDate":"2017-06-04T20:06:00.000","Title":"How does django know which user owns what data?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to get eta of task in celery each time with get request. There is no direct api in celery to get task scheduled time (except inspect() - but it's seems very costly to me)\nHow can i manage eta of particular task? The downside of storing eta time in Django model is not consistent ( either i couldnt store taks_id because i can't -  dont know how get eta from task_id)\nI see on one question that there is no api, cause it somehow depends on brokers and etc. But i hope that there is some solution\nSo what's the best way manage task_id to get eta? \nBackend and broker is redis","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":429,"Q_Id":44367961,"Users Score":0,"Answer":"I don't think there is a magic way to do this.\nWhat I do in my app is just log the execution time for each task and return that as an ETA. If you wanted to get a little more accurate you could also factor in the redis queue size and the task consumption rate.","Q_Score":0,"Tags":"python,redis,celery,estimation","A_Id":44961359,"CreationDate":"2017-06-05T11:28:00.000","Title":"Celery best way manage\/get eta of task","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I just bought a VPS server from Vultr. Then I went on ServerPilot, and installed it on my server.\nNow I can access, via SFTP, all the files on my server.\nBut how can I access these files from my web-browser via Internet? I mean, when I type in the IP address of my Vultr Server, I land on the ServerPilot page \"your app xxx is set up\". Alright, but how can I access the other files I uploaded now?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":110,"Q_Id":44376270,"Users Score":1,"Answer":"you can connect to your server\/serverpilot app via SSH\/SFTP.\nFilezilla, codeanywhere are options that allow you to do this.","Q_Score":0,"Tags":"python,html,hosting,vps","A_Id":46166962,"CreationDate":"2017-06-05T19:26:00.000","Title":"Beginner VPS Vultr\/ServerPilot -> How to change the homepage & access the files I uploaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I developed a Python code and I converted it to an .exe with pyinstaller but the problem is that there is no publisher so each time a computer runs my program, Windows Defender throws an alert that says that there is no publisher so the program is not sure...\nDoes anyone know how to change the publisher of an .exe from none to something or how to implement Publisher in pyinstaller?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12698,"Q_Id":44377666,"Users Score":0,"Answer":"This is a known False Positive with Windows Defender. This happens to my files as well when tested on a Windows 10 VM, and it happens to others as well. Also, Windows Defender 'Smartscreen' may block any unsigned file even when using another Antivirus, but you should be able to click more information and then continue\nYou can exclude the file from Windows Defender, but the best solution is to use another antivirus, as Windows Defender is not very good anyway. (that is not just based on my experience but off AV tests)\nI am not sure what other antivirues have the same False Positive, but I know there are a few.\nYou also could test on a VM, where you could disable Windows Defender and Smartscreen, while leaving it enabled on your host system. (VirtualBox is a great free VM software for Windows)","Q_Score":7,"Tags":"python,pyinstaller,publisher,windows-defender","A_Id":69619137,"CreationDate":"2017-06-05T21:04:00.000","Title":"Pyinstaller .exe throws Windows Defender [no publisher]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a website with some backprocessing with python. I want to know how to execute my python code from the server ?\nThere is no direct link between my HTML pages and my python code.\nLet's say I want to do an addition with python in the server, how can I do that ?\nThanks so much in advence :)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":105,"Q_Id":44387283,"Users Score":0,"Answer":"is your server is linux or windows?\nfor linux: you can add a script to run your script on runlevel 3 or 5\nwrite a script put it under \/etc\/init.d\/ folder then link your script \/etc\/rc3.d or \/etc\/rc5.d to be start","Q_Score":0,"Tags":"python,server","A_Id":44387505,"CreationDate":"2017-06-06T10:15:00.000","Title":"Running python code on server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a 100x100 Matrix with Zeros. I want to add a 10x20 ellipsis around a specific point in the Matrix - lets say at position 40,60. The Ellipsis should be filled with values from 0 to 1. (1 in the center - 0 at the edge) - The numbers should be gaussian-distributed.\nMaybe someone can give me a clue, how to start with this problem..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":221,"Q_Id":44387854,"Users Score":0,"Answer":"You need to draw samples from a multi-variate gaussian distribution. The function you can use is numpy.random.multivariate_normal\nYou mean value matrix should be [40, 60]. The covariance C matrix should be 2X2. Regarding its values:\nC[1, 1], C[2, 2]: decides the width of the ellipse along each axis. Choose it so that 3*C[i,i] is almost equal to the width of the ellipse along this axis.\nThe diagonal values are zero if you want the ellipse to be along the axes, otherwise put larger values (keep in mind that C[2, 1]==C[1, 2]\nHowever, keep in mind that, since it is a Gaussian distribution, the output values will be close to 0 at distance 3*C[i,i] from the center, but they will never be truly zero.","Q_Score":0,"Tags":"python,matrix,ellipse,gaussianblur","A_Id":44388121,"CreationDate":"2017-06-06T10:43:00.000","Title":"Create Matrix with gaussian-distributed ellipsis in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"C++ part\nI have a class a with a public variable 2d int array b that I want to print out in python.(The way I want to access it is a.b)\nI have been able to wrap the most part of the code and I can call most of the functions in class a in python now.\nSo how can I read b in python? How to read it into an numpy array with numpy.i(I find some solution on how to work with a function not variable)? Is there a way I can read any array in the c++ library? Or I have to deal with each of the variables in the interface file.\nfor now b is <Swig Object of type 'int (*)[24]' at 0x02F65158> when I try to use it in python\nps:\n1. If possible I don't want to modify the cpp part.\n\nI'm trying to access a variable, not a function. \n\nSo don't refer me to links that doesn't really answer my question, thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":569,"Q_Id":44424308,"Users Score":0,"Answer":"You'll find that passing things back and forth between languages is much easier if you use a one-dimensional array in which you access elements using, e.g. arr[y*WIDTH+x].\nSince you are operating in C++ you can even wrap these arrays in classes with nice operator()(int x, int y) methods for use on the C++ side.\nIn fact, this is the internal representation which Numpy uses for arrays: they are all one-dimensional.","Q_Score":0,"Tags":"python,c++,arrays,numpy,swig","A_Id":44424756,"CreationDate":"2017-06-07T23:26:00.000","Title":"Reading c++ 2d array in python swig","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm doing procedural programming and for my final assignment I have to create an application that will allow the user to do the following:\n\nAllow the user to enter the customer\u2019s details: name, postcode and loyalty card details \nCheck if the card has expired \nCheck the loyalty card number is valid by: \n\n\nAllowing the user to enter the 8 digits shown on the front of the card \nRemoving the 8th digit and storing it as \u2018check_digit\u2019 \nReversing the numbers \nMultiplying the 1st, 3rd, 5th and 7th digits by 2 \nIf the result of the multiplication is greater than 9 then subtract 9 from the result \nAdding together the resulting 7 digits \nChecking if the sum of the added digits plus the \u2018check_digit\u2019 is divisible by 10 \n\nOutput whether the loyalty card is valid or not \nOutput customer and loyalty card details. \n\nBut, how do I go about removing the 'last digit' then storing it as a check_digit?  Sorry if this is vague, this is copied directly from my assignment brief.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":77,"Q_Id":44425362,"Users Score":0,"Answer":"To get the last digit, you have to divide the number by 10 and get the remainder.\nFor example, to get the last digit of 123, you can do 123 % 10 which results to 3.\nTo remove the last digit, you have to divide the number by 10 and discard the remainder.\nFor example, to remove the last digit of 123, you can do 123 \/\/ 10 which results to 12.","Q_Score":0,"Tags":"python-3.x","A_Id":44425421,"CreationDate":"2017-06-08T01:45:00.000","Title":"Assignment 3 in Procedural Programming","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to use SVM from sklearn for a classification problem. I got a highly sparse dataset with more than 50K rows and binary outputs.\nThe problem is I don't know quite well how to efficiently choose the parameters, mainly the kernel, gamma anc C.   \nFor the kernels for example, am I supposed to try all kernels and just keep the one that gives me the most satisfying results or is there something related to our data that we can see in the first place before choosing the kernel ?\nSame goes for C and gamma.\nThanks !","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":726,"Q_Id":44441002,"Users Score":0,"Answer":"Yes, this is mostly a matter of experimentation -- especially as you've told us very little about your data set: separability, linearity, density, connectivity, ... all the characteristics that affect classification algorithms.\nTry the linear and Gaussian kernels for starters.  If linear doesn't work well and Gaussian does, then try the other kernels.\nOnce you've found the best 1 or 2 kernels, then play with the cost and gamma parameters.  Gamma is a \"slack\" parameter: it gives the kernel permission to make a certain proportion of raw classification errors as a trade-off for other benefits: width of the gap, simplicity of the partition function, etc.\nI haven't yet had an application that got more than trivial benefit from altering the cost.","Q_Score":1,"Tags":"python,machine-learning,scikit-learn,svm","A_Id":44441810,"CreationDate":"2017-06-08T16:24:00.000","Title":"How to choose parameters for svm in sklearn","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Amazon Web Services (AWS) & I am using the free tier t2.micro right now ( 1 CPU and 1 GB memory).  Doing some backtesting\/ simulation stuff and it seems free tier is quite inadequate. Pretty slow actually. Thus thinking of options which will help me to run my code at a faster speed for few hours.\nOption 1 : I can 1 buy CPU optimized\/ higher Memory instance ( 4 cores and 4 GB RAM for example ) and then make an image of my t2.micro and run my stuff in that new one. It will be expensive though if I keep it running, so I need to \"stop\" the instance when I am not working  ( or nothing is running ) to reduce the cost. \nOption 2 : I can buy spot instances. I am not sure how to use the CPU and RAM of that spot instance from my existing t2.micro. Can I create a temporary grid\/cluster where my Head Node will be running in my t2.micro but compute node will be the spot instance ( higher CPU and RAM ), thus all my calculations, etc will be using the spot instance. \nMy question : Is the Option 2 possible ? I program everything in python and I have all the relevant softwares\/python IDEs etc are already installed in my t2.micro instance.\nAny existing grid\/cluster software I can use right now ? I don't know C++, Csharp, Java etc. Know only phython & R so any programming stuff I need to do to build a grid\/cluster must use Python :)\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":582,"Q_Id":44468527,"Users Score":0,"Answer":"Much of what you are asking depends upon your use-case. For example, if you have work continually arriving then you will need capacity continually available. However, if it is more batch-oriented then you could start\/stop capacity and even use the new Amazon Batch service that can allocate resources when needed and remove them when jobs are finished.\nSome things to note:\n\nYou can change the Instance Type when an instance is stopped. So, your t2.micro instance can be changed to a large instance (eg m4.xlarge) by stopping it, changing the instance type and starting it again.\nThe t2.micro Instance Type is actually extremely powerful when CPU burst credits are available, but it limited in capability when all CPU Credits are consumed. A good machine for bursty workloads, but not continual workloads.\nSpot instances are great, but please note that they will be terminated if the Spot Price goes above your bid price. Prices vary by region, Availability Zone within a region and instance type, so you could launch instances with a variety of attributes (different AZs, different instance types) that would make it unlikely that you would lose all capacity at the same time. Spot can save considerable costs and is well worth investigating.\nTake a look at Amazon EMR, which runs Hadoop to provide parallel processing across a cluster of instances.\nStop instances when you don't need them. That's the best way to get good value!","Q_Score":0,"Tags":"python,amazon-web-services","A_Id":44469173,"CreationDate":"2017-06-10T01:04:00.000","Title":"Cluster with t2.micro instances in AWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a column called amount with holds values that look like this: $3,092.44 when I do dataframe.dtypes() it returns this column as an object how can i convert this column to type int?","AnswerCount":15,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12214,"Q_Id":44469313,"Users Score":0,"Answer":"This will also work:  dframe.amount.str.replace(\"$\",\"\").astype(int)","Q_Score":4,"Tags":"python,pandas,ipython-notebook","A_Id":59876018,"CreationDate":"2017-06-10T03:50:00.000","Title":"Price column object to int in pandas","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using the Stanford NLP, I want my text to go through lemmatization and coreference resolution.\nSo for an input.txt:     \"Stanford is located in California.  It is a great University, founded in 1891.\"\nI would want the output.txt:      \"Stanford be located in California. Stanford be a great University, found in 1891.\"\nI am also looking to get a table where the first column consists of the name-entities that were recognized in the text, and the second column is the name class they were identified as. Thus, for the example sentence above, it would be something like:\n1st Column                    2nd Column\nStanford                      Location, Organization\nCalifornia                    Location\nThus, in the table, the name-entities would occur only once. \nThere's nothing I was able to find online about manipulating the default xml output or making direct changes to the input text file using the NLP.  Could you give me any tips on how to go about this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":784,"Q_Id":44487269,"Users Score":0,"Answer":"If you are using the command line you can use -outputFormat text to get a human readable version or -outputFormat json to get a json version.  In Java code you can use edu.stanford.nlp.pipeline.StanfordCoreNLP.prettyPrint() or edu.stanford.nlp.pipeline.StanfordCoreNLP.jsonPrint() to print out an Annotation.","Q_Score":0,"Tags":"java,python,stanford-nlp","A_Id":44512629,"CreationDate":"2017-06-11T18:29:00.000","Title":"Stanford NLP Output Formatting","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In the cntk.layers package we have the option to do zero padding:\npad (bool or tuple of bools, defaults to False) \u2013 if False, then the filter will be shifted over the \u201cvalid\u201d area of input, that is, no value outside the area is used. If pad=True on the other hand, the filter will be applied to all input positions, and positions outside the valid region will be considered containing zero. Use a tuple to specify a per-axis value.\nBut how can I use other types of padding like reflect or symmetric padding?\nIs it possible to integrate my own padding criterion in the cntk.layers?\nI'm a beginner in cntk and really grateful for every help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":44504140,"Users Score":0,"Answer":"There is a new pad operation (in master; will be released with CNTK 2.2) that supports reflect and symmetric padding.","Q_Score":1,"Tags":"python,padding,cntk","A_Id":45828029,"CreationDate":"2017-06-12T16:16:00.000","Title":"CNTK & Python: How to do reflect or symmetric padding instead of zero padding?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have trained a model in CNTK. Then I clone it and change some parameters; when I try to test the quantized model, I get\n\nRuntimeError: Block Function 'softplus:  -> Unknown': Inputs\n'Constant('Constant70738', [], []), Constant('Constant70739', [], []),\nParameter('alpha', [], []), Constant('Constant70740', [], [])' of the\nnew clone do not match the cloned inputs 'Constant('Constant70738',\n[], []), Constant('Constant70739', [], []), Constant('Constant70740',\n[], []), Parameter('alpha', [], [])' of the clonee Block Function.\n\nI have no idea what this error means or how to fix it. Do you have any ideas?\nP.S. I clone and edit the model by doing\n\nclonedModel = model.clone(cntk.ops.CloneMethod.clone)\ncloneModel.parameters[0].value = cloneModel.parameters[0].value*4\n\nthen when I try to use cloneModel I get that error above.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":115,"Q_Id":44517122,"Users Score":0,"Answer":"This line\n\ncloneModel.parameters[0] = cloneModel.parameters[0]*4\n\ntries to replace the first parameter with an expression (a CNTK graph) that multiplies the parameter by 4. I don't think that's the intent here. Rather, you want to do the above on the .value attribute of the parameter. Try this instead:\n\ncloneModel.parameters[0].value = cloneModel.parameters[0].value*4","Q_Score":1,"Tags":"python,runtime-error,cntk","A_Id":44535536,"CreationDate":"2017-06-13T09:13:00.000","Title":"CNTK: The new clone do not match the cloned inputs of the clonee Block Function","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have two given points (3.0, 3.2) and (7.0, 4.59) .\nMy job here is very simple but I don't even know how to start. I just need to plot 4 nonlinear functions that go through these two points.\nDid somebody have a similar problem before? How does one even start?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":44526642,"Users Score":0,"Answer":"It looks more like a math problem to me here, since you ask \"how to start\".\nyou know that a function's plot is just a lot of points (x, y) where y=f(x).\nAnd I know that for any two pairs of points (not vertically aligned), I have an infinity of second-degree functions (parabolas) going through these two points.\nthey are given by y=ax^2+bx+c \nYou want the parabola to go through your 2 points, so you can substitute x and y for each of the 2 points, that will give you 2 equations (where a, b and c are the unknown) .\nThen you can add a random point (I would suggest on the y-axis :  (0; r) ).\nThis will give you a third equation.\nWith these 3 equations, solve for a, b and c. (in function of r)\nnow, for any value of r, you will have some a, b and c that define a parabola going through your 2 known points.\nOnce you understand how to solve this math problem, the python part is completely independant.","Q_Score":0,"Tags":"python-2.7,nonlinear-functions","A_Id":44526860,"CreationDate":"2017-06-13T16:10:00.000","Title":"Generate a random nonlinear function going through given points in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Python 2.7 for a while now and installing packages using pip install without any issue. I just started using python 3 for a certain code and realized how confusing having different versions of Python can get.\nI have Fedora 25, the default Python version is 2.7.13 and the default Python 3 version is Python 3.5.3, \nI want to be able to use python 2.7 and python 3, my general question is: \nWhat are the best practices when installing packages for both Python 2 and Python 3 on one machine?\nAs I mentioned using pip install in Python 2.7 works fine, but what about Python 3? I can:\n\nuse pip3 install\nuse python3 -m pip install\n\nWhich one should I use and how does it affect the python 2 version of the module? pip3 is not installed on Fedora 25, which raises a new question: how should I install it? as I understand I can:\n\nuse dnf install python3-pip (it is unclear if that actually works when pip for Python 2.7 is installed)\nuse python3 get-pip.py\n\nFinally, would it be a good idea to create a Python 2 and a Python 3 virtual environment to address this issue?\nFrom what I have read on the internet there does not seem to be a clear consensus on these questions, I hope this thread will clarify.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":170,"Q_Id":44528223,"Users Score":3,"Answer":"pip3 install and python3 -m pip install \u2014 both work perfectly and don't have any impact on Python 2. You can have as many Pythons in your system as you want; I for one have Python 2.7, 3.4, 3.5 and 3.6. To distinguish different versions of pip I use versioned names: pip3.4 install.\nAnd of course I use virtual environments and virtualenvwrapper quite intensively.","Q_Score":2,"Tags":"python,python-2.7,python-3.x,pip,packages","A_Id":44571919,"CreationDate":"2017-06-13T17:43:00.000","Title":"Package management for coexisting Python 2 and 3","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have a few Packages that I have made and I want to share them with my friends and I want to put them in separate github repositories, now I know how to make a project in eclipse, I already have my packages in the project and I also cloned the empty github repository in my local computer now when i connect the project to the local repository and push it into github it actually copies the complete project into the repository but i want only the packages to be copied i.e.\nright now its like githubrepository\/pythonproject\/pythonpackage\nbut i want it to be githubrepository\/pythonpackage\ncan someone suggest a link or some ways to solve it?am i making a mistake?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":21,"Q_Id":44547072,"Users Score":0,"Answer":"On git, you always work with the repo as a whole (even if you see only a part of it on Eclipse).\nSo, to do what you want, you have to actually create a new repo and copy the sources you want and then push from there (there are ways to do that with git saving the history too if that's important to you).\nYou might want to take a look at git submodules too...","Q_Score":0,"Tags":"python,eclipse,github,pydev,egit","A_Id":44783503,"CreationDate":"2017-06-14T14:04:00.000","Title":"How do I properly share my Python Packages using Eclipse+pydev+egit?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a 1 column excel file. I want to import all the values it has in a variable x (something like x=[1,2,3,4.5,-6.....]), then use this variable to run numpy.correlate(x,x,mode='full') to get autocorrelation, after I import numpy.\nWhen I manually enter x=[1,2,3...], it does the job fine, but when I try to copy paste all the values in x=[], it gives me a NameError: name 'NO' is not defined.\nCan someone tell me how to go around doing this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":57,"Q_Id":44554135,"Users Score":0,"Answer":"You can use Pandas to import a CSV file with the pd.read_csv function.","Q_Score":0,"Tags":"python","A_Id":44554231,"CreationDate":"2017-06-14T20:25:00.000","Title":"Import a column from excel into python and run autocorrelation on it","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a .exe file using Py2exe on Windows 10 but when I try to run it on a Windows 7 computer it says that the os version is wrong. \nCan anyone tell me how to fix this? (like using another Python or Py2exe version or setting a specific configuration inside setup.py)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":850,"Q_Id":44577583,"Users Score":0,"Answer":"I solved the problem myself and I'm going to share the answer if someone ever has the same mistake. I just had to download a 32-bit version of Canopy (with Python 2.7) and py2exe in order for them to work on Windows 7.","Q_Score":5,"Tags":"python,windows,py2exe","A_Id":44632191,"CreationDate":"2017-06-15T21:49:00.000","Title":"Py2exe - Can't run a .exe created on Windows 10 with a Windows 7 computer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"windows power shell or cmd uses anaconda python instead of the default windows installation\nhow to make them use the default python installation?\nmy os is win 8.1\npython 3.6\nanaconda python 3.6","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1228,"Q_Id":44586049,"Users Score":0,"Answer":"Set the environment path variable of your default python interpreter in system properties.\nor if this doesn't work do:\nin cmd  C:\\Python27\\python.exe yourfilename.py\nin the command first part is your interpreter location and second is your file name","Q_Score":2,"Tags":"python,anaconda,default","A_Id":44586285,"CreationDate":"2017-06-16T09:43:00.000","Title":"How to change cmd python from anaconda to default python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server then get the number of uses, when someone joins the server, it checks to see the invite that has gone up a use. But I don't  know if this is the most efficient method or at least the used method.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":13355,"Q_Id":44594309,"Users Score":1,"Answer":"In Discord, you're never going to 100% sure who invited the user.\nUsing Invite, you know who created the invite.\nUsing on_member_join, you know who joined.\nSo, yes, you could have to check invites and see which invite got revoked. However, you will never know for sure who invited since anyone can paste the same invite link anywhere.","Q_Score":3,"Tags":"python,discord,discord.py","A_Id":44830944,"CreationDate":"2017-06-16T16:50:00.000","Title":"Discord.py show who invited a user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server then get the number of uses, when someone joins the server, it checks to see the invite that has gone up a use. But I don't  know if this is the most efficient method or at least the used method.","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":13355,"Q_Id":44594309,"Users Score":1,"Answer":"Watching the number of uses an invite has had, or for when they run out of uses and are revoked, is the only way to see how a user was invited to the server.","Q_Score":3,"Tags":"python,discord,discord.py","A_Id":45571128,"CreationDate":"2017-06-16T16:50:00.000","Title":"Discord.py show who invited a user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to get the unix file type of a file specified by path (find out whether it is a regular file, a named pipe, a block device, ...)\nI found in the docs os.stat(path).st_type but in Python 3.6, this seems not to work.\nAnother approach is to use os.DirEntry objects (e. g. by os.listdir(path)), but there are only methods is_dir(), is_file() and is_symlink().\nAny ideas how to do it?","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1711,"Q_Id":44595736,"Users Score":1,"Answer":"Python 3.6 has pathlib and its Path objects have methods:\n\nis_dir()\nis_file()\nis_symlink()\nis_socket()\nis_fifo()\nis_block_device()\nis_char_device()\n\npathlib takes a bit to get used to (at least for me having come to Python from C\/C++ on Unix), but it is a nice library","Q_Score":6,"Tags":"python,unix,operating-system","A_Id":44595853,"CreationDate":"2017-06-16T18:24:00.000","Title":"Get unix file type with Python os module","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When and how should I use fit_generator?\nWhat is the difference between fit and fit_generator?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3009,"Q_Id":44597555,"Users Score":2,"Answer":"They are useful for on-the-fly augmentations, which the previous poster mentioned. This however is not neccessarily restricted to generators, because you can fit for one epoch and then augment your data and fit again.\nWhat does not work with fit is using too much data per epoch though. This means that if you have a dataset of 1 TB and only 8 GB of RAM you can use the generator to load the data on the fly and only hold a couple of batches in memory. This helps tremendously on scaling to huge datasets.","Q_Score":4,"Tags":"python,deep-learning","A_Id":44609082,"CreationDate":"2017-06-16T20:33:00.000","Title":"How to use model.fit_generator in keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Firstly, this question isn't a request for code suggestions- it's more of a question about a general approach others would take for a given problem. \nI've been given the task of writing a web application in python to allow users to check the content of media files held on a shared server. There will also likely be a postgres database from which records for each file will be gathered.\nI want the web app to:\n1) Suggest the next file to check (from files that have yet to be checked) and have a link to the next unchecked file once the result of the previous check have been submitted. \n2) Prevent the app from suggesting the same file to multiple users simultaneously. \nIf it was just one user checking the files it would be easier, but I'm having trouble conceptualising how i'm going to achieve the two points above with multiple simultaneous users.\nAs I say, this isn't a code request i'm just just interested in what approach\/tools others feel would be best suited to this type of project. \nIf there are any python libraries that could be useful i'd be interested to hear any recommendations.\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":49,"Q_Id":44606342,"Users Score":1,"Answer":"These requirements are more or less straightforward to follow. Given that you will have a persistent database that can share the state of each file with multiple sessions - and even multiple deploys - of your system - and that is more or less a given with Python + PostgreSQL.\nI'd  suggest you to create a Python class with a few fields yuu can use for the whole process, and use an ORM like SQLAlchemy or Django's to bind those to a database. The fields you will need are more or less: filename, filpath, timestamp, check_status - and some extra like \"locked_for_checking\", and \"checker\" (which might be a foreignkey to a Users collection). On presenting a file as a sugestion for  a given user, you set the \"locked_for_checking\" flag - and for the overall listing, yu create a list that exc\u00e7uds files \"checked\" or \"locked_for_checking\". (and sort the  files by timestamp\/size or other metadata that attends your requirements). \nYou will need some logic to \"unlock for checking\" if the first user does not complete  the checking in a given time frame, but that is it.","Q_Score":0,"Tags":"python,postgresql,python-3.x,flask","A_Id":44608243,"CreationDate":"2017-06-17T15:37:00.000","Title":"Python web app ideas- incremental\/unique file suggestions for multiple users","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to share data between programs that run locally which uses different languages, I don't know how to approach this. \nFor example, if I have a program that uses C# to run and another that uses python to run, and I want to share some strings between the two, how can I do it?\nI thought about using sockets for this but I'm not sure that this is the right approach, I also thought about saving the data in a file, then reading the file from the other program, but, it might even be worse than using sockets.\nNote that I need to share strings almost a thousand times between the programs","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":406,"Q_Id":44618760,"Users Score":1,"Answer":"Any kind of IPC (InterProcess Communication) \u2014 sockets or shared memory. Any common format \u2014 plain text files or structured, JSON, e.g. Or a database.","Q_Score":0,"Tags":"c#,python,data-sharing,multiple-languages","A_Id":44618813,"CreationDate":"2017-06-18T19:31:00.000","Title":"How to share data between programs that use different languages to run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to share data between programs that run locally which uses different languages, I don't know how to approach this. \nFor example, if I have a program that uses C# to run and another that uses python to run, and I want to share some strings between the two, how can I do it?\nI thought about using sockets for this but I'm not sure that this is the right approach, I also thought about saving the data in a file, then reading the file from the other program, but, it might even be worse than using sockets.\nNote that I need to share strings almost a thousand times between the programs","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":406,"Q_Id":44618760,"Users Score":3,"Answer":"There are a lot of ways to do so, I would recommend you reading more about IPC (Inter Process Communication) - sockets, pipes, named pipes, shared memory and etc...\nEach method has it's own advantages, therefore, you need to think about what you're trying to achieve and choose the method that fits you the best.","Q_Score":0,"Tags":"c#,python,data-sharing,multiple-languages","A_Id":44618831,"CreationDate":"2017-06-18T19:31:00.000","Title":"How to share data between programs that use different languages to run","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do I sniff packets that are only outbound packets?\nI tried to sniff only destination port but it doesn't succeed at all","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":736,"Q_Id":44618843,"Users Score":0,"Answer":"Maybe you can get your device MAC address and filter any packets with that address as source address.","Q_Score":1,"Tags":"python-3.x,scapy,packet-sniffers,sniffing","A_Id":44703883,"CreationDate":"2017-06-18T19:41:00.000","Title":"Python(scapy): how to sniff packets that are only outboun packets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to find the same words in two different excel workbooks. I have two excel workbooks (data.xls and data1.xls). If in data.xls have the same words in the data1.xls, i want it to print the row of data1.xls that contain of the same words with data.xls. I hope u can help me. Thank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":67,"Q_Id":44626578,"Users Score":0,"Answer":"I am assuming that both excel sheets have a list of words, with one word in each cell. \nThe best way to write this program would be something like this:\n\nOpen the first excel file, you might find it easier to open if you export it as a CSV first. \nCreate a Dictionary to store word and Cell Index Pairs\nIterate over each cell\/word, add the word to the dictionary as the Key, with the Cell Reference as the Value. \nOpen the second excel file.\nIterate over each cell\/word, check if the word is present in the Dictionary, if it is, you can print out the corresponding cells or store them however you want.","Q_Score":0,"Tags":"excel,windows,python-2.7","A_Id":44626892,"CreationDate":"2017-06-19T09:17:00.000","Title":"python- how to find same words in two different excel workbooks","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if it's possible to store an array in a Django model?\nI'm asking this because I need to store an array of int (e.g [1,2,3]) in a field and then be able to search a specific array and get a match with it or by it's possible combinations.\nI was thinking to store that arrays as strings in CharFields and then, when I need to search something, concatenate the values(obtained by filtering other model) with '[', ']' and ',' and then use a object filter with that generated string. The problem is that I will have to generate each possible combination and then filter them one by one until I get a match, and I believe that this might be inefficient.\nSo, I hope you can give me other ideas that I could try.\nI'm not asking for code, necessarily, any ideas on how to achieve this will be good.","AnswerCount":5,"Available Count":1,"Score":0.0798297691,"is_accepted":false,"ViewCount":103363,"Q_Id":44630642,"Users Score":2,"Answer":"I don't know why nobody has suggested it, but you can always pickle things and put the result into a binary field.\nThe advantages of this method are that it will work with just about any database, it's efficient, and it's applicable to more than just arrays.  The downside is that you can't have the database run queries on the pickled data (not easily, anyway).","Q_Score":52,"Tags":"python,arrays,django","A_Id":61437282,"CreationDate":"2017-06-19T12:30:00.000","Title":"Is it possible to store an array in Django model?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to build a twitter chat bot which is interactive and replies according to incoming messages from users. Webhook documentation is unclear on how do I receive incoming message notifications. I'm using python.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":662,"Q_Id":44632982,"Users Score":0,"Answer":"Answering my own question.\nWebhook isn't needed, after searching for long hours on Twitter Documentation, I made a well working DM bot, it uses Twitter Stream API, and StreamListener class from tweepy, whenever a DM is received, I send requests to REST API which sends DM to the mentioned recipient.","Q_Score":0,"Tags":"python,api,twitter,twitter-oauth,chatbot","A_Id":44717595,"CreationDate":"2017-06-19T14:15:00.000","Title":"Does twitter support webhooks for chatbots or should i use Stream API?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a tensor of shape (10, 100, 20, 3). Basically, it can be thought of as a batch of images. So the image height is 100 and width is 20 and channel depth is 3.\nI have run some computations to generate a set of 10*50 indices corresponding to 50 columns I would like to keep per image in the batch. The indices are stored in a tensor of shape (10, 50). I would like to end up with a tensor of shape (10, 50, 20, 3).\nI have looked into tf.batch_nd() but I can't figure out the semantics for how indices are actually used.\nAny thoughts?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":78,"Q_Id":44639106,"Users Score":0,"Answer":"I can't comment on the question because of low rep, so using an answer instead.\nCan you clarify your question a bit, maybe with a small concrete example using very small tensors?\nWhat are the \"columns\" you are referring to? You say that you want to keep 50 columns (presumably 50 numbers) per image. If so, the (10, 50) shape seems like what you want - it has 50 numbers for each image in the batch. The (10, 50, 20, 3) shape you mention would allocate 50 numbers to each \"image_column x channel\". That is 20*3*50 = 3000 numbers per image. How do you want to construct them from the 50 that you have?\nAlso, can you give a link to tf.batch_nd(). I did not find anything similar and relevant.","Q_Score":0,"Tags":"python,tensorflow","A_Id":44937787,"CreationDate":"2017-06-19T20:10:00.000","Title":"TensorFlow extracting columns","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently my Enter key stopped working. For sure it's a hardware problem!. However I managed so many days without Enter key by using the alternatives ctrl + j or ctrl + m .Running python programs was fine as I would run the script by saving it in a file. Now that I need to give commandline values I have to press enter for it to be accepted in the IDLE Interpreter. While typing this too I can't press enter or ctrl + j or ctrl + m.\nBut how did I do this? (This newline?) I copied a empty newline from another file. Even this doesn't work in the interpreter. Someone help any way to enter values in python IDLE Interpreter without actually using enter key. \nOne good alternative would be to use the cmd or terminal and using the command line python script.py. And then using ctrl+m as this works there.\nBut I miss the python interpreter. Any alternatives any suggestion? \nOfcourse onscreen keyboard is an option but I'm looking for any key alternatives to enter in python Interpreter. Is that even possible?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1474,"Q_Id":44651925,"Users Score":2,"Answer":"Normally, IDLE has an Option \/ Configure IDLE menu which allows you to remap almost any action to a key combination. The newline and indent action is by default mapped to Key Return and Num Keypad Return, while Ctrl J is used for plain newline and indent. But it is easy to change this mapping configuration.","Q_Score":1,"Tags":"python,linux,windows,keyboard-shortcuts,interpreter","A_Id":44653688,"CreationDate":"2017-06-20T11:33:00.000","Title":"Alternative for 'enter' key in python interpreter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Basically I'm working on porting a program from being packaged with RPM into using setup.py to package it as a wheel. My core question is whether there exists some guide or tool on how to make this conversion.\nThe key issue is that I'm looking to convert dependencies as specified by RPM's spec file to setup.py and can't find any information online as to how to do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":497,"Q_Id":44677753,"Users Score":0,"Answer":"Any answer likely depends on the distro for which the rpm was built.  A generic, albeit manual approach, would to start with rpm -q --requires $PACKAGE but as you already have the spec file, you can simply rpmspec -q --requires *spec to get that same info.  Look for the packages providing Python resources, e.g., python3-requests.  You'll need to translate each of these into the Python package name, e.g., 'requests' for your setup.py.  You may find that rpm -q --provides python3-requests to be useful at this step; maybe not.","Q_Score":0,"Tags":"python,rpm,packaging,distutils,rpm-spec","A_Id":46433084,"CreationDate":"2017-06-21T13:37:00.000","Title":"How to convert RPM spec file dependencies to Python setup.py?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running some code with selenium using python, and I figured out that I need to dynamically change the UserAgent after I already created the webdriver. Any advice if it is possible and how this could be done? Just to highlight - I want to change it on the fly, after almost each GET or POST request I send","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1149,"Q_Id":44678133,"Users Score":0,"Answer":"I would go with creating a new driver and copy all the necessary attributes from the old driver except the user agent.","Q_Score":0,"Tags":"python,selenium,selenium-chromedriver,user-agent","A_Id":44678533,"CreationDate":"2017-06-21T13:53:00.000","Title":"Python selenium with chrome webdriver - change user agent","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"been searching for this with no success, i don't know if i am missing something but i have a virtualenv already but how do i create a project to associate the virtualenv with, thanks\nP.S. Am on windows","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":3130,"Q_Id":44678706,"Users Score":2,"Answer":"Requirements:\n\nVirtual Env\nPycharm\n\nGo to Virtual env and type which python\nAdd remote project interpreter (File > Default Settings > Project Interpreter (cog) add remote)\nYou'll need to set up your file system so that PyCharm can also open the project.\nNOTE:\n\ndo not turn off your virtual environment without saving your run configurations that will cause pycharm to see your run configurations as corrupt \nThere's a button on the top right that reads share enable this and your run configs will be saved to a .idea file and you'll have a lot less issues","Q_Score":4,"Tags":"python,python-3.x,virtualenv,virtualenvwrapper","A_Id":44679103,"CreationDate":"2017-06-21T14:17:00.000","Title":"Associating a python project with a virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"been searching for this with no success, i don't know if i am missing something but i have a virtualenv already but how do i create a project to associate the virtualenv with, thanks\nP.S. Am on windows","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3130,"Q_Id":44678706,"Users Score":1,"Answer":"If you already have your virtualenv installed you just need to start using it.\n\nCreate your projects virtual environment using virtualenv env_name on cmd. To associate a specific version of python with your environment use: virtualenv env_name -p pythonx.x;\nActivate your environment by navigating into its Scripts folder and executing activate.\nYour terminal now is using your virtual environment, that means every python package you install and the python version you run will be the ones you configured inside your env.\n\nI like to create environments with the names similar to my projects, I always use one environment to each project, that helps keeping track of which packages my specific projects need to run.\nIf you haven't read much about venvs yet, try googling about requirements.txt along with pip freeze command those are pretty useful to keep track of your project's packages.","Q_Score":4,"Tags":"python,python-3.x,virtualenv,virtualenvwrapper","A_Id":44679249,"CreationDate":"2017-06-21T14:17:00.000","Title":"Associating a python project with a virtual environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a filter for packets that contain HTTP data, yet I don't have a clue on how to do so.\nI.E. Is there a way to filter packets using Scapy that are only HTTP?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":3860,"Q_Id":44679656,"Users Score":1,"Answer":"Yes, you can. You can filter by TCP port 80 (checking each packet or using BPF) and then check the TCP payload to ensure there is an HTTP header.","Q_Score":2,"Tags":"python,http,scapy","A_Id":44703791,"CreationDate":"2017-06-21T14:58:00.000","Title":"Using Scapy to fitler HTTP packets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I edited my dispatch.yaml and deployed on app engine using\n appcfg.py update_dispatch .\nBut when I go and see source code under StackDriver debug, I don't see the change.\nWhy the changes doesn't get reflected. But when I deploy complete app by appcfg.py update . the changes get reflected.\nBut in case, If I only want to update dispatch how do I do???","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":306,"Q_Id":44698229,"Users Score":1,"Answer":"Try\n\ngcloud app deploy dispatch.yaml\n\n...to connect services to dispatch rules.","Q_Score":0,"Tags":"python,google-app-engine","A_Id":62299368,"CreationDate":"2017-06-22T11:33:00.000","Title":"dispatch.yaml not getting updated","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to build a temperature control module that can be controlled over a network or with manual controls. the individual parts of my program all work but I'm having trouble figuring out how to make them all work together.also my temperature control module is python and the client is C#.\nso far as physical components go i have a keypad that sets a temperature and turns the heater on and off and an lcd screen that displays temperature data and of course a temperature sensor.\nfor my network stuff i need to:\nconstantly send temperature data to the client. \nsend a list of log files to the client.\nawait prompts from the client to either set the desired temperature or send a log file to the client.\nso far all the hardware works fine and each individual part of the network functions work but not together. I have not tried to use both physical and network components.\nI have been attempting to use threads for this but was wondering if i should be using something else?\nEDIT:\nhere is the basic logic behind what i want to do:\nHardware:\nkeypad takes a number inputs until '*' it then sets a temp variable.\ntemp variable is compared to sensor data and the heater is turned on or off accordingly.\n'#' turns of the heater and sets temp variable to 0.\nsensor data is written to log files while temp variable is not 0\nNetwork:\nupon client connect the client is sent a list of log files\ntemperature sensor data is continuously sent to client.\nprompt handler listens for prompts.\nif client requests log file the temperature data is halted and the file sent after which the temperature data is resumed.\nclient can send a command to the prompt handler to set the temp variable to trigger the heater\nclient can send a command to the prompt handler to stop the heater and set temp variable to 0\ncommands from either the keypad or client should work at all times.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":53,"Q_Id":44703003,"Users Score":1,"Answer":"Multiprocessing is generally for when you want to take advantage of the computational power of multiple processing cores. Multiprocessing limits your options on how to handle shared state between components of your program, as memory is copied initially on process creation, but not shared or updated automatically. Threads execute from the same region of memory, and do not have this restriction, but cannot take advantage of multiple cores for computational performance. Your application does not sound like it would require large amounts of computation, and simply would benefit from concurrency to be able to handle user input, networking, and a small amount of processing at the same time. I would say you need threads not processes. I am not experienced enough with asyncio to give a good comparison of that to threads.\nEdit: This looks like a fairly involved project, so don't expect it to go perfectly the first time you hit \"run\", but definitely very doable and interesting.\nHere's how I would structure this project...\nI see effectively four separate threads here (maybe small ancillary dameon threads for stupid little tasks)\n\nI would have one thread acting as your temperature controller (PID control \/ whatever) that has sole control of the heater output. (other threads get to make requests to change setpoint \/ control mode (duty cycle \/ PID))\nI would have one main thread (with a few dameon threads) to handle the data logging: Main thead listens for logging commands (pause, resume, get, etc.) dameon threads to poll thermometer, rotate log files, etc..\nI am not as familiar with networking, and this will be specific to your client application, but I would probably get started with http.server just for prototyping, or maybe something like websockets and a little bit of asyncio. The main thing is that it would interact with the data logger and temperature controller threads with getters and setters rather than directly modifying values\nFinally, for the keypad input, I would likely just make up a quick tkinter application to grab keypresses, because that's what I know. Again, form a request with the tkinter app, but don't modify values directly; use getters and setters when \"talking\" between threads. It just keeps things better organized and compartmentalized.","Q_Score":1,"Tags":"python,multithreading","A_Id":44703268,"CreationDate":"2017-06-22T14:59:00.000","Title":"should i be using threads multiprocessing or asycio for my project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to run a python script that uses a custom module written by someone else. I created that module by running CMake according to the creator's instructions. Running my python script, I get the error: ImportError: libopencv_imgproc.so.3.1: cannot open shared object file: No such file or directory. This error is caused by the module I created earlier.\nThere is no file of that name since I have OpenCV 3.2.0 installed, so in usr\/local\/lib there's libopencv_imgproc.so.3.2.0. I don't know how to fix this or where to start looking. The CMakeLists.txt of the module has a line \nfind_package(OpenCV 3 COMPONENTS core highgui imgproc REQUIRED).\nI tried changing it to \nfind_package(OpenCV 3.2.0 COMPONENTS core highgui imgproc REQUIRED), \nwithout success.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":430,"Q_Id":44705077,"Users Score":0,"Answer":"The problem was an old version of the module lurking an a different folder where the python script was actually looking. This must have been created in the past with an OpenCV 3.1 environment.","Q_Score":0,"Tags":"python,opencv,cmake","A_Id":44717895,"CreationDate":"2017-06-22T16:39:00.000","Title":"How can I force CMake to use the correct OpenCV version?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm a Python3 User. And I'm now face some problem about byte to string control..\nFirst, I'm get data from some server as a byte. \n[Byte data] : b'\\xaaD\\x12\\x1c+\\x00\\x00 \\x18\\x08\\x00\\x00\\x88\\xb4\\xa2\\x07\\xf8\\xaf\\xb6\\x19\\x00\\x00\\x00\\x00\\x03Q\\xfa3\/\\x00\\x00\\x00\\x1d\\x00\\x00\\x00\\x86=\\xbd\\xc9~\\x98uA>\\xdf#=\\x9a\\xd8\\xdb\\x18\\x1c_\\x9c\\xc1\\xe4\\xb4\\xfc;'\nThis data isn't escape any string type such as utf-8, unicode-escape ...\nWho know the solution how to control these data?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1232,"Q_Id":44711048,"Users Score":0,"Answer":"You need to decode the byte data:\nbyte_data.decode(\"utf-8\")","Q_Score":1,"Tags":"python,string,utf-8,byte","A_Id":44711115,"CreationDate":"2017-06-22T23:57:00.000","Title":"How to escape the string \"\\x0a\\xfd\\x .....\" in python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am learning Python by watching youtube videos and also through an online course that I bought.  In every video I watch, the first line of each file is: _author_='dev'.  For some reason when I start a new file this does not come up.  What does this mean and if it is an issue how do I correct it?  \nFYI I am using IntelliJ IDEA as an IDE.  \nThank you!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":91,"Q_Id":44711871,"Users Score":1,"Answer":"It is pre-compiled in some IDEs like PyDev but not in IDEA, you can add it manually if you want it. I also recommend you to use PyCharm instead of IDEA for python.","Q_Score":0,"Tags":"python,python-3.x,intellij-idea,ide","A_Id":44711956,"CreationDate":"2017-06-23T01:55:00.000","Title":"script first line _author_=\"dev\" does not show up","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After applying KernelPCA to my data and passing it to a classifier (SVC) I'm getting the following error:\n\nValueError: Input contains NaN, infinity or a value too large for\n  dtype('float64').\n\nand this warning while performing KernelPCA:\n\nRuntimeWarning: invalid value encountered in sqrt X_transformed =\n  self.alphas_ * np.sqrt(self.lambdas_)\n\nLooking at the transformed data I've found several nan values.\nIt makes no difference which kernel I'm using. I tried cosine, rbf and linear.\nBut what's interesting:\n\nMy original data only contains values between 0 and 1 (no inf or nan), it's scaled with MinMaxScaler\nApplying standard PCA works, which I thought to be the same as KernelPCA with linear kernel.\n\nSome more facts:\n\nMy data is high dimensional ( > 8000 features) and mostly sparse.\nI'm using the newest version of scikit-learn, 18.2 \n\nAny idea how to overcome this and what could be the reason?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":622,"Q_Id":44716368,"Users Score":3,"Answer":"The NaNs are produced because the eigenvalues (self.lambdas_) of the input matrix are negative which provoke the ValueError as the square root does not operate with negative values.\nThe issue might be overcome by setting KernelPCA(remove_zero_eig=True, ...) but such action would not preserve the original dimensionality of the data. Using this parameter is a last resort as the model's results may be skewed.\nActually, it has been stated negative eigenvalues indicate a model misspecification, which is obviously bad. Possible solution for evading that fact without corroding the dimensionality of the data with remove_zero_eig parameter might be reducing the quantity of the original features, which are greatly correlated. Try to build the correlation matrix and see what those values are. Then, try to omit the redundant features and fit the KernelPCA() again.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn","A_Id":44736370,"CreationDate":"2017-06-23T08:14:00.000","Title":"KernelPCA produces NaNs","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So basically I used pip to import the docx python package and it installed correctly, (verified by the freeze command). However I cannot import the package in eclipse.\nThrough some serious effort I've noticed that I can import the package using the 32 bit IDLE shell whereas I cannot when using the 64 bit IDLE shell. My PC is 64 bit and so I do not why I cannot import a 32 bit package in eclipse, a problem I've never encountered before.\nDoes anybody have any insights as to how I can import this package properly in eclipse? I'm sure there's a very reasonable cause and hopefully solution as to why this is happening and would really appreciate if anyone could help with this issue as I need to use this package for the specific project I aim to do.\nside note: I'm using python 3.6 if that's of any relevance","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":582,"Q_Id":44721450,"Users Score":0,"Answer":"thanks for the reply.\nThe actual problem was that I was using python 3.6 where eclipse only accepts python grammar versions up to 3.5. The docx package also only works with python 2.6, 2.7, 3.3, or 3.4 so I installed python 3.4 and docx is now working!","Q_Score":0,"Tags":"python,eclipse,import,pip,docx","A_Id":44775360,"CreationDate":"2017-06-23T12:27:00.000","Title":"Eclipse cannot import already installed pip package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was trying to train CIFAR10 and MNIST dataset on VGG16 network. In my first attempt, I got an error which says shape of input_2 (labels) must be (None,2,2,10). What information does this structure hold in 2x2x10 array because I expect input_2 to have shape (None, 10) (There are 10 classes in both my datasets).\nI tried to expand dimensions of my labels from (None,10) to (None,2,2,10). But I am sure this is not the correct way to do it since I obtain a very low accuracy (around 0.09)\n(I am using keras, Python3.5)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":212,"Q_Id":44723464,"Users Score":0,"Answer":"Low accuracy is caused by the problem in layers. I just modified my network and obtained .7496 accuracy.","Q_Score":1,"Tags":"python,machine-learning,deep-learning,keras","A_Id":45011256,"CreationDate":"2017-06-23T14:08:00.000","Title":"VGG16 Training new dataset: Why VGG16 needs label to have shape (None,2,2,10) and how do I train mnist dataset with this network?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I already tried to convert my .py file into .exe file. Unfortunately, the .exe file gives problems; I believe this is because my code is fairly complicated.\nSo, I am trying to schedule directly my .py file with Task Scheduler but every time I do it and then run it to see if works, a window pops up and asks me how I would like to open the program?-.-\nDoes any of you know how I can successfully schedule my .py file with Task Scheduler? Please help, thanks\nWindows 10\nPython 3.5.2","AnswerCount":9,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":80315,"Q_Id":44727232,"Users Score":0,"Answer":"This absolutely worked for me . I am using windows 10 professional edition and it has taken me almost 6 months to get this solution.Thanks to the suggestion made above.  \nI followed this suggestion and it worked right away and smoothly. All I did was to instruct the scheduler to run python.exe with my script as an argument just as explained by this fellow below \nThis what I did Suppose the script you want to run is E:\\My script.py. Instead of running the script directly, instruct the task scheduler to run python.exe with the script as an argument. For example:\nC:\\Python27\\ArcGIS10.2\\python.exe \n\"E:\\My script.py\"\nThe location of python.exe depends on your install. If you don\u2019t know where it is, you can discover its location; copy and paste the following code into a new Python script then execute the script. The script will print the location of python.exe as well as other information about your Python environment.","Q_Score":39,"Tags":"python","A_Id":57961296,"CreationDate":"2017-06-23T17:45:00.000","Title":"Scheduling a .py file on Task Scheduler in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I already tried to convert my .py file into .exe file. Unfortunately, the .exe file gives problems; I believe this is because my code is fairly complicated.\nSo, I am trying to schedule directly my .py file with Task Scheduler but every time I do it and then run it to see if works, a window pops up and asks me how I would like to open the program?-.-\nDoes any of you know how I can successfully schedule my .py file with Task Scheduler? Please help, thanks\nWindows 10\nPython 3.5.2","AnswerCount":9,"Available Count":2,"Score":0.022218565,"is_accepted":false,"ViewCount":80315,"Q_Id":44727232,"Users Score":1,"Answer":"The script you execute would be the exe found in your python directory\nex) C:\\Python27\\python.exe\nThe \"argument\" would be the path to your script\nex) C:\\Path\\To\\Script.py\nSo think of it like this: you aren't executing your script technically as a scheduled task. You are executing the root python exe for your computer with your script being fed as a parameter.","Q_Score":39,"Tags":"python","A_Id":44728388,"CreationDate":"2017-06-23T17:45:00.000","Title":"Scheduling a .py file on Task Scheduler in Windows 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have 45000 text records in my dataframe. I wanted to convert those 45000 records into word vectors so that I can train a classifier on the word vector. I am not tokenizing the sentences. I just split the each entry into list of words.\nAfter training word2vec model with 300 features, the shape of the model resulted in only 26000. How can I preserve all of my 45000 records ? \nIn the classifier model, I need all of those 45000 records, so that it can match 45000 output labels.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":277,"Q_Id":44740161,"Users Score":2,"Answer":"If you are splitting each entry into a list of words, that's essentially 'tokenization'. \nWord2Vec just learns vectors for each word, not for each text example ('record') \u2013 so there's nothing to 'preserve', no vectors for the 45,000 records are ever created. But if there are 26,000 unique words among the records (after applying min_count), you will have 26,000 vectors at the end. \nGensim's Doc2Vec (the '\nParagraph Vector' algorithm) can create a vector for each text example, so you may want to try that. \nIf you only have word-vectors, one simplistic way to create a vector for a larger text is to just add all the individual word vectors together. Further options include choosing between using the unit-normed word-vectors or raw word-vectors of many magnitudes; whether to then unit-norm the sum; and whether to otherwise weight the words by any other importance factor (such as TF\/IDF). \nNote that unless your documents are very long, this is a quite small training set for either Word2Vec or Doc2Vec.","Q_Score":0,"Tags":"python-3.x,nlp,word2vec","A_Id":44740700,"CreationDate":"2017-06-24T19:25:00.000","Title":"how to preserve number of records in word2vec?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Exactly how do I utilize the various event methods that widgets have? Say I have a comboBox(drop down list) and I want to initiate a function every time someone changes the choice. There is the changeEvent() method in the documentation but It would be great if someone explains to me with a piece of code.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":102,"Q_Id":44771725,"Users Score":0,"Answer":"This is a pretty broad question.  I recommend checking out the many tutorials on Youtube.com.  \nHowever, in your init method, put something like this:\nself.ui.charge_codes_combo.currentIndexChanged.connect(self.setup_payments)\n\nIn my example, the combo box was placed on a form in Qt Designer.  Self.setup_payment is a method triggered by the change in the combo box.\nI hope this helps!","Q_Score":0,"Tags":"python,python-3.x,pyqt,pyqt4","A_Id":44775948,"CreationDate":"2017-06-27T03:13:00.000","Title":"How to use pyqt widget event() method?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have sentences with state codes followed by a . (ie. \"CA.\", \"AL.\", but also good \"CA\", \"AL\") or things like \"acct.\" or \"no.\"\nI'd like to:\n1. remove those \".\" \n2. keep other \".\"\n3. change no. to #\nFor example, I'd like:\n\"Mr. J. Edgar Hoover from CA. owes us $123.45 from acct. no. 98765.\"\nto become\n\"Mr. J. Edgar Hoover from CA owes us $123.45 from acct # 98765.\" \nChanging \" no.\"  to \" #\" \n         and \"acct.\" to \"acct\" \nis easily done with regex or replace and I could do that first to get those out of the way. (I'm open to other efficient approaches).\nBut how do I change state code . to state code and keep the right state code?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":59,"Q_Id":44788533,"Users Score":0,"Answer":"state code always contains 2 uppercase characters, so you can use this pattern to do your replacement.\nmatch this: \n([A-Z]{2}).\nand replace by this: $1","Q_Score":0,"Tags":"python,regex,str-replace","A_Id":44788966,"CreationDate":"2017-06-27T19:40:00.000","Title":"Python remove . after state","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I  am trying to create a model via a form that has multiple other models related to it. Say I have a model Publisher, then another model Article with a foreign key to Publisher. When creating a Publisher via a form, I want to create An article at the same time. I know how to do this via formsets. However, I don't know how to add a button that says add extra article at the same view, without having to be redirected to a new page and losing the old data since the form was not saved. What I want is when someone clicks add new article, for a new form for article to appear and for the user to add a new Article. Is this possible to be done in the same view in django, if so can someone give me and idea how to approach this?\nI would show code or my attempts, but I am not sure how to even approach it.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":56,"Q_Id":44810259,"Users Score":0,"Answer":"This can only be done using JavaScript. The hard part is to have the management form sync up with the number of rows.\nBut there's two alternatives:\n\nSemi-javascript (Mezzanine's approach): Generate a ton of rows in the formset and only show one empty. Upon the click of the \"add another row\" button, unhide the next one. This makes it easier to handle the management form as the unfilled extra's don't need any work.\nNo fix needed: Add as many rows as is humanly sane. In general, people don't need 40 rows, they get bored with filling out the form or worry that all that work is lost when the browser crashes.\n\nHope this helps you along. Good luck!","Q_Score":1,"Tags":"python,django,forms","A_Id":44810611,"CreationDate":"2017-06-28T18:42:00.000","Title":"Option to add extra choices in django form","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to use some R packages requiring R version 3.4 and above. I want to access these packages in python (3.6.1) through rpy2 (2.8).\nI have R version 3.4 installed, and it is located in \/Library\/Frameworks\/R.framework\/Resources However, when I use pip3 install rpy2 to install and use the python 3.6.1 in \/Library\/Frameworks\/Python.framework\/Versions\/3.6\/bin\/python3.6) as my interpreter, I get the error:\n\nTraceback (most recent call last):\n    File \"\/Users\/vincentliu\/PycharmProjects\/magic\/rpy2tester.py\", line 1, in \n      from rpy2 import robjects\n    File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/robjects\/init.py\", line 16, in \n      import rpy2.rinterface as rinterface\n    File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/rinterface\/init.py\", line 92, in \n      from rpy2.rinterface._rinterface import (baseenv,\n  ImportError: dlopen(\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/rinterface\/_rinterface.cpython-36m-darwin.so, 2): Library not loaded: @rpath\/libiconv.2.dylib\n    Referenced from: \/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/rinterface\/_rinterface.cpython-36m-darwin.so\n    Reason: Incompatible library version: _rinterface.cpython-36m-darwin.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0\n\nWhich first seemed like a problem caused by Anaconda, and so I remove all Anaconda-related files but the problem persists.\nI then uninstalled rpy2, reinstalled Anaconda and used conda install rpy2 to install, which also installs R version 3.3.2 through Anaconda. I can then change the interpreter to \/anaconda\/bin\/python and can use rpy2 fine, but I couldn't use the R packages I care about because they need R version 3.4 and higher. Apparently, the oldest version Anaconda can install is 3.3.2, so is there any way I can use rpy2 with R version 3.4?\nI can see two general solutions to this problem. One is to install rpy2 through conda and then somehow change its depending R to the 3.4 one in the system. Another solution is to resolve the error\n\nIncompatible library version: _rinterface.cpython-36m-darwin.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0\n\nAfter much struggling, I've found no good result with either.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1095,"Q_Id":44836123,"Users Score":1,"Answer":"I uninstalled rpy2 and reinstalled with --verborse. I then found  \n\nld: warning: ignoring file \/opt\/local\/lib\/libpcre.dylib, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/lib\/libpcre.dylib\n      ld: warning: ignoring file \/opt\/local\/lib\/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/lib\/liblzma.dylib\n      ld: warning: ignoring file \/opt\/local\/lib\/libbz2.dylib, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/lib\/libbz2.dylib\n      ld: warning: ignoring file \/opt\/local\/lib\/libz.dylib, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/lib\/libz.dylib\n      ld: warning: ignoring file \/opt\/local\/lib\/libiconv.dylib, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/lib\/libiconv.dylib\n      ld: warning: ignoring file \/opt\/local\/lib\/libicuuc.dylib, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/lib\/libicuuc.dylib\n      ld: warning: ignoring file \/opt\/local\/lib\/libicui18n.dylib, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/lib\/libicui18n.dylib\n      ld: warning: ignoring file \/opt\/local\/Library\/Frameworks\/R.framework\/R, file was built for x86_64 which is not the architecture being linked (i386): \/opt\/local\/Library\/Frameworks\/R.framework\/R\n\nSo I supposed the reason is the architecture incompatibility of the libiconv in opt\/local, causing make to fall back onto the outdate libiconv in usr\/lib. This is strange because my machine should be running on x86_64 not i386. I then tried export ARCHFLAGS=\"-arch x86_64\" and reinstalled libiconv using port. This resolved the problem.","Q_Score":2,"Tags":"r,conda,python-3.6,rpy2,libiconv","A_Id":44935654,"CreationDate":"2017-06-29T22:49:00.000","Title":"Installing rpy2 to work with R 3.4.0 on OSX","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to use some R packages requiring R version 3.4 and above. I want to access these packages in python (3.6.1) through rpy2 (2.8).\nI have R version 3.4 installed, and it is located in \/Library\/Frameworks\/R.framework\/Resources However, when I use pip3 install rpy2 to install and use the python 3.6.1 in \/Library\/Frameworks\/Python.framework\/Versions\/3.6\/bin\/python3.6) as my interpreter, I get the error:\n\nTraceback (most recent call last):\n    File \"\/Users\/vincentliu\/PycharmProjects\/magic\/rpy2tester.py\", line 1, in \n      from rpy2 import robjects\n    File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/robjects\/init.py\", line 16, in \n      import rpy2.rinterface as rinterface\n    File \"\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/rinterface\/init.py\", line 92, in \n      from rpy2.rinterface._rinterface import (baseenv,\n  ImportError: dlopen(\/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/rinterface\/_rinterface.cpython-36m-darwin.so, 2): Library not loaded: @rpath\/libiconv.2.dylib\n    Referenced from: \/Library\/Frameworks\/Python.framework\/Versions\/3.6\/lib\/python3.6\/site-packages\/rpy2\/rinterface\/_rinterface.cpython-36m-darwin.so\n    Reason: Incompatible library version: _rinterface.cpython-36m-darwin.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0\n\nWhich first seemed like a problem caused by Anaconda, and so I remove all Anaconda-related files but the problem persists.\nI then uninstalled rpy2, reinstalled Anaconda and used conda install rpy2 to install, which also installs R version 3.3.2 through Anaconda. I can then change the interpreter to \/anaconda\/bin\/python and can use rpy2 fine, but I couldn't use the R packages I care about because they need R version 3.4 and higher. Apparently, the oldest version Anaconda can install is 3.3.2, so is there any way I can use rpy2 with R version 3.4?\nI can see two general solutions to this problem. One is to install rpy2 through conda and then somehow change its depending R to the 3.4 one in the system. Another solution is to resolve the error\n\nIncompatible library version: _rinterface.cpython-36m-darwin.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0\n\nAfter much struggling, I've found no good result with either.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1095,"Q_Id":44836123,"Users Score":0,"Answer":"I had uninstall the version pip installed and install from source python setup.py install on the download https:\/\/bitbucket.org\/rpy2\/rpy2\/downloads\/. FWIW not using Anaconda at all either.","Q_Score":2,"Tags":"r,conda,python-3.6,rpy2,libiconv","A_Id":53839320,"CreationDate":"2017-06-29T22:49:00.000","Title":"Installing rpy2 to work with R 3.4.0 on OSX","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type \"python --version\" It is showing python 2.7 instead of 3.6. How can I change this?\nPlease help me.","AnswerCount":4,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":3626,"Q_Id":44839204,"Users Score":0,"Answer":"Try to type \"python3 --version\". This can work on linux, but I am not sure whether it works on pythonanywhere","Q_Score":2,"Tags":"python,django,web-deployment,pythonanywhere","A_Id":44839307,"CreationDate":"2017-06-30T05:32:00.000","Title":"how can I change default python version in pythonanywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type \"python --version\" It is showing python 2.7 instead of 3.6. How can I change this?\nPlease help me.","AnswerCount":4,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":3626,"Q_Id":44839204,"Users Score":2,"Answer":"Python 3.6 is available as python3.6 in a console on PythonAnywhere.","Q_Score":2,"Tags":"python,django,web-deployment,pythonanywhere","A_Id":44850691,"CreationDate":"2017-06-30T05:32:00.000","Title":"how can I change default python version in pythonanywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type \"python --version\" It is showing python 2.7 instead of 3.6. How can I change this?\nPlease help me.","AnswerCount":4,"Available Count":3,"Score":0.0996679946,"is_accepted":false,"ViewCount":3626,"Q_Id":44839204,"Users Score":2,"Answer":"to set your default python version from 2.7 to 3.7 run the command below\n$ alias python=python3\nthat's it now check the version \n$ python --version \nit should be solved","Q_Score":2,"Tags":"python,django,web-deployment,pythonanywhere","A_Id":55050163,"CreationDate":"2017-06-30T05:32:00.000","Title":"how can I change default python version in pythonanywhere?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have built a MITM with python and scapy.I want to make the \"victim\" device be redirected to a specific page each time it tried to access a website. Any suggestions on how to do it?\n*Keep in mind that all the traffic from the device already passes through my machine before being routed.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":141,"Q_Id":44851959,"Users Score":0,"Answer":"You can directly answer HTTP requests to pages different to that specific webpage with HTTP redirections (e.g. HTTP 302). Moreover, you should only route packets going to the desired webpage and block the rest (you can do so with a firewall such as iptables).","Q_Score":0,"Tags":"python,scapy","A_Id":44997621,"CreationDate":"2017-06-30T17:24:00.000","Title":"Python : Redirecting device with MITM","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a binary image of large size (2000x2000). In this image most of the pixel values are zero and some of them are 1. I need to get only 100 randomly chosen pixel coordinates with value 1 from image. I am beginner in python, so please answer.","AnswerCount":4,"Available Count":1,"Score":0.1488850336,"is_accepted":false,"ViewCount":3545,"Q_Id":44857970,"Users Score":3,"Answer":"I'd suggest making a list of coordinates of all non-zero pixels (by checking all pixels in the image), then using random.shuffle on the list and taking the first 100 elements.","Q_Score":4,"Tags":"python,random,pixel","A_Id":44858027,"CreationDate":"2017-07-01T06:19:00.000","Title":"how to get random pixel index from binary image with value 1 in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi on running a code in the console I am getting the display as:\n\n\nrunfile('C:\/Users\/DX\/Desktop\/me template\/Part 1 - Data Preprocessing\/praCTICE.py', wdir='C:\/Users\/DX\/Desktop\/me template\/Part 1 - Data Preprocessing')\n\n\nand on viewing a small matrix it is showing up as \n\narray([['France', 44.0, 72000.0],\n         ['Spain', 27.0, 48000.0],\n         ['Germany', 30.0, 54000.0],\n         ..., \n         ['France', 48.0, 79000.0],\n         ['Germany', 50.0, 83000.0],\n         ['France', 37.0, 67000.0]], dtype=object)\n\nEven though the matrix is pity small how to change it to get the default view when i cun my codes in ipython console \nI installed the latest version of anaconda","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":272,"Q_Id":44871312,"Users Score":1,"Answer":"(Spyder developer here) Please use the Variable Explorer to visualize Numpy arrays and Pandas DataFrames. That's its main purpose.","Q_Score":0,"Tags":"python-3.x,anaconda,spyder","A_Id":44871723,"CreationDate":"2017-07-02T13:26:00.000","Title":"In spyder how to get back default view of running a code in Ipython console","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to install python 3.5 packages so they would be available in Jupyter notebook with pyspark3 kernel.\nI've tried to run the following script action:\n#!\/bin\/bash\nsource \/usr\/bin\/anaconda\/envs\/py35\/bin\/activate py35\nsudo \/usr\/bin\/anaconda\/envs\/py35\/bin\/conda install -y keras tensorflow theano gensim\n\nbut the packages get installed on python 2.7 and not in 3.5","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2656,"Q_Id":44902885,"Users Score":0,"Answer":"Have you tried installing using pip? \nIn some cases where you have both Python 2 and Python 3, you have to run pip3 instead of just pip to invoke pip for Python 3.","Q_Score":1,"Tags":"python,azure,pyspark,jupyter-notebook,azure-hdinsight","A_Id":44903656,"CreationDate":"2017-07-04T10:02:00.000","Title":"how to install python package on azure hdinsight pyspark3 kernel?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to install a postgresql database which resides on Azure for my python flask application; but the installation of psycopg2 package requires the pg_config file which comes when postgresql is installed. So how do I export the pg_config file from the postgresql database which also resides on azure? Is pg_config all psycopg2 need for a successful installation?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":164,"Q_Id":44911066,"Users Score":2,"Answer":"You don't need the specific pg_config from the target database. It's only being used to compile against libpq, the client library for PostgreSQL, so you only need the matching PostgreSQL client installed on your local machine.\nIf you're on Windows I strongly advise you to install a pre-compiled PostgreSQL. You can just install the whole server, it comes with the client libraries.\nIf you're on Linux, you'll probably need the PostgreSQL -devel or -dev package that matches your PostgreSQL version.","Q_Score":0,"Tags":"python,postgresql,azure,psycopg2","A_Id":44915875,"CreationDate":"2017-07-04T16:59:00.000","Title":"How to retrieve the pg_config file from Azure postgresql Database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose I want a program Foo.py which has some arbitrary routines Bar(), Quux(), and Fizz(). Let's say that the usual order of execution from a procedural perspective should be Bar() -> Quux() -> Fizz(). However, Fizz() should conditionally call a function Buzz() depending on some runtime action, and calling Buzz() at any time during Fizz() should return the process back to Quux(). \nI have a fair understanding of how concurrent processes can be implemented in assembly using system calls depending on the architecture, but what options are available to me in Python, where I can't \u2013 and frankly would prefer not to \u2013 use lots of jumps and directly move an instruction pointer around? When searching for an answer, I found loops and recursion as a suggestion for going back in a program. I don't think a loop would work without stopping the Fizz() process to wait for the condition check for Buzz(), and I'm not sure how recursion could be implemented in this scenario either. (My Buzz() would be like a \"Back\" button on a GUI).","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":55,"Q_Id":44955528,"Users Score":0,"Answer":"Using coroutines (multithreading) will provide the desired concurrent functionality. Source in the comments of the question and of user2357112's answer.","Q_Score":0,"Tags":"python","A_Id":44977316,"CreationDate":"2017-07-06T17:31:00.000","Title":"What are my options for navigating through subroutines?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What would be a pythonic way to create a list of (to illustrate with an example) the fifth string of every line of a text file, assuming it ressembles something like this:\n12, 27.i, 3, 6.7, Hello, 438\nIn this case, the script would add \"Hello\" (without quotes) to the list.\nIn other words (to generalize), with an input \"input.txt\", how could I get a list in python that takes the nth string (n being a defined number) of every line?\nMany thanks in advance!","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":202,"Q_Id":44956676,"Users Score":0,"Answer":"This may not be the most efficient solution, but you could also just hard code it e.g. create a variable equivalent to zero, add one to the variable for each word in the line, and append the word to a list when variable = 5. Then reset the variable equal to zero.","Q_Score":1,"Tags":"python,python-3.x","A_Id":44957535,"CreationDate":"2017-07-06T18:44:00.000","Title":"How to create a list of string in nth position of every line in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I set an environment variable with the location of the pytest.ini, tox.ini or setup.cfg for running pytest by default?\nI created a docker container with a volume pointing to my project directory, so every change I make is also visible inside the docker container. The problem is that I have a pytest.ini file on my project root which won't apply to the docker container. \nSo I want to set an environment variable inside the docker container to specify where to look for the pytest configuration. Does anyone have any idea how could I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7501,"Q_Id":44958993,"Users Score":6,"Answer":"There is no way to do that. You can use a different pytest configuration using pytest -c but tox.ini and setup.cfg must reside in the top-level directory of your package, next to setup.py.","Q_Score":5,"Tags":"python,docker,pytest,pytest-django","A_Id":44959229,"CreationDate":"2017-07-06T21:16:00.000","Title":"pytest: environment variable to specify pytest.ini location","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The text file I'm searching through looks like a lot of text blocks like this:\n\nMKC,2017-06-23 07:54,-94.5930,39.1230,79.00,73.90,84.41,220.00,4.00,0.00,29.68,1003.90,10.00,M,FEW,M,M,M,9500.00,M,M,M,M,KMKC 230754Z 22004KT 10SM FEW095 26\/23 A2968 RMK AO2 SLP039 T02610233\n\n(That's all one line)\nI'm looking to grab the 2nd occurrence in the line that matches r',\\d\\.\\d{2},', which in this case would be 0.00\nI don't know how to specify that I want the nth occurrence of the pattern.\nExtra: I've never seen the first value that matches the same pattern go over 9.99, meaning 10.00 and then it would no longer match the same pattern, but it would be nice if there was a way to take this into account.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":44981576,"Users Score":0,"Answer":"You could use the re.findall(regex, string, flags) function in python. That returns non-overlapping matches of the patter in string in a list of strings. You could then grab the second member of the returned list.","Q_Score":0,"Tags":"python,regex","A_Id":44981592,"CreationDate":"2017-07-08T01:11:00.000","Title":"How to grab the nth occurence of a float on a line using regex?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to add trigger s3 bucket to lambda function with boto3, then I want attach that lambda function to dynamically created s3 buckets using programmatically(boto3)","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3218,"Q_Id":44982302,"Users Score":1,"Answer":"Three steps I followed\n1) connected to aws lambda with boto3 used add_permission API\n2)also applyed get_policy\n3)connected to S3 with boto resource to  configuring BucketNotification API,put LambdaFunctionConfigurations","Q_Score":2,"Tags":"python-2.7,amazon-web-services,amazon-s3,aws-lambda,aws-sdk","A_Id":45005925,"CreationDate":"2017-07-08T03:50:00.000","Title":"how to add the trigger s3 bucket to lambda function dynamically(python boto3 API)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning Django and to practice I'm currently developing a clone page of YTS, it's a movie torrents repository*. \nAs of right now, I scrapped all the movies in the website and have them on a single db table called Movie with all the basic information of each movie (I'm planning on adding one more for Genre).\nEvery few days YTS will post new movies and I want my clone-web to automatically add them to the database. I'm currently stuck on deciding how to do this:\n\nI was planning on comparing the movie id of the last movie in my db against the last movie in the YTS db each time the user enters the website, but that'd mean make a request to YTS every time my page loads, it'd also mean some very slow code should be executed inside my index() views method.\nAnother strategy would be to query the last time my db was updated (new entries were introduced) and if it's let's say bigger than a day then request new movies to YTS. Problem with this is I don't seem to find any method to query the time of last db updates. Does it even exist such method?\nI could also set a cron job to update the information but I'm having problems to make changes from a separated Python function (I import django.db and such but the interpreter refuses to execute django db instructions).\n\nSo, all in all, what's the best strategy to update my database from a third party service\/website without bothering the user with loading times? How do you set such updates in non-intrusive way to the user? How do you generally do it?\n* I know a torrents website borders the illegal and I'm not intended, in any way, to make my project available to the public","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":114,"Q_Id":44988422,"Users Score":2,"Answer":"I think you should choose definetely the third alternative, a cron job to update the database regularly seems the best option.\n You don' t need to use a seperate python function, you can schedule a task with celery, which can be easily integrated with django using django-celery","Q_Score":0,"Tags":"python,django,database,cron","A_Id":44988567,"CreationDate":"2017-07-08T16:35:00.000","Title":"Updating my Django website's database from a third party service, strategies?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a website and i want to destroy some session or cookie in django when user discoonet suddenly or get offline (wifi discoonect or disconnect mobil data).\nBut i dont know to how do this!\nIs there any default library to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":748,"Q_Id":44994358,"Users Score":0,"Answer":"Well you can't know if users disconnected their internet or WiFi.\nBut you can check if user is still online and browsing the website.\nto achieve that you can use javascript to send a request every 10 second (less or more) and check if user is still on the site. and if user is not online anymore you can make some changes or etc but in general you can't access to the users device and check the status for wifi or ...","Q_Score":1,"Tags":"python,django,session,cookies,session-cookies","A_Id":44994487,"CreationDate":"2017-07-09T08:11:00.000","Title":"Destroy session or cookie in django when user get offline","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am migrating my personal hobby python web application from 127.0.0.1 to cloud 9 lately, but found myself completely new to the idea of setting up ssl certificate. I did some online research on openssl and its python wrapper but still couldn't find any definitive guide on how to set it up in practice, specifically for the cloud 9 IDE platform.\nCould someone please give a walkthough, or point out some references link here? Thanks.\nBy the way, I'm using cherrypy for the python server.\nEDIT: specifically, I have the following questions:\n\nis it requred to run openssl from the server(in my case, cloud9 bash), or I can run openssl from my local laptop then upload the generated key and cert?\ndoes it make any sense to use passphrase to protect the key? I don't see any point here, correct me if I'm wrong please\nhow to install it to cloud9?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":184,"Q_Id":44996563,"Users Score":0,"Answer":"Cloud9 runs your app behind an https proxy, so you need to just use http, since cloud9 proxy won't accept your self signed certificate.","Q_Score":0,"Tags":"python,ssl,cloud9-ide","A_Id":44998382,"CreationDate":"2017-07-09T12:49:00.000","Title":"Could someone please provide a walkthrough on how to setup a self signing ssl certificate on cloud 9?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"FindPythonLibs.cmake is somehow finding Python versions that don't exist\/were uninstalled. \nWhen I run find_package(PythonLibs 3 REQUIRED) CMake properly finds my Python3.6 installation and adds its include path, but then I get the error\nNo rule to make target 'C:\/Users\/ultim\/Anaconda2\/libs\/python27.lib', needed by 'minotaur-cpp.exe'.  Stop.\nThis directory doesn't exist, and I recently uninstalled Anaconda and the python that came with it. I've looked through my environment variables and registry, but find no reference to this location.\nWould anyone know where there might still be a reference to this location?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":44997969,"Users Score":0,"Answer":"Since the \"REQUIRED\" option to find_package() is not working, you can be explicit about which Python library using CMake options with cache variables:\ncmake -DPYTHON_INCLUDE_DIR=C:\\Python36\\include -DPYTHON_LIBRARY=C:\\Python36\\libs\\python36.lib ..","Q_Score":1,"Tags":"python,cmake,anaconda","A_Id":44999337,"CreationDate":"2017-07-09T15:20:00.000","Title":"CMake's find packages finds nonexisting python library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm thinking of starting to use Apache Airflow for a project and am wondering how people manage continuous integration and dependencies with airflow. More specifically\nSay I have the following set up\n3 Airflow servers: dev staging and production.\nI have two python DAG'S whose source code I want to keep in seperate repos.\nThe DAG's themselves are simple, basically just use a Python operator to call main(*args, **kwargs). However the actually code that's run by main is very large and stretches several files\/modules.\nEach python code base has different dependencies\nfor example,\nDag1 uses Python2.7 pandas==0.18.1, requests=2.13.0\nDag2 uses Python3.6 pandas==0.20.0 and Numba==0.27 as well as some cythonized code that needs to be compiled\nHow do I manage Airflow running these two Dag's with completely different dependencies?\nAlso, how do I manage the continuous integration of the code for both these Dags into each different Airflow enivornment (dev, staging, Prod)(do I just get jenkins or something to ssh to the airflow server and do something like git pull origin BRANCH)\nHopefully this question isn't too vague and people see the problems i'm having.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":1922,"Q_Id":45015116,"Users Score":3,"Answer":"We use docker to run the code with different dependencies and DockerOperator in airflow DAG, which can run docker containers, also on remote machines (with docker daemon already running). We actually have only one airflow server to run jobs but more machines with docker daemon running, which the airflow executors call.\nFor continuous integration we use gitlab CI with the Gitlab container registry for each repository. This should be easily doable with Jenkins.","Q_Score":6,"Tags":"python,airflow","A_Id":45117737,"CreationDate":"2017-07-10T14:46:00.000","Title":"Apache Airflow Continous Integration Workflow and Dependency management","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a GUI that starts off with a video written in Kivy. That GUI is supposed to then begin loading the whole program in the background while the clip is playing, and after the clip, a window for login is supposed to come up. How do I load the whole program and at the same time load the video to play at the start of the program?\nI used event dispatcher but it didn't work.\nAdditionally, how do I tell the window to open from the video to the login to the first page of the GUI without being separate GUIs to load from?\nThank you very much.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":45041154,"Users Score":0,"Answer":"i think you should first try and convert the video to an image format (gif) and then load it in the Image class in the kv file and then use clock to schedule it to load a new screen(login) after some seconds depending on the duration of the gif","Q_Score":0,"Tags":"python,python-2.7,python-3.x,user-interface,kivy","A_Id":45068664,"CreationDate":"2017-07-11T17:31:00.000","Title":"Placing a Video at Start of GUI to Transition to Main Code Kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm running ODOO 10 from source code in Eclipse on Windows 10. It's running ok in the web interface (on localhost)\nI want to control the odoo via command line at the same time. Can I do so while its running in the web interface?\nIf so how do I invoke the odoo commands to the server?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1605,"Q_Id":45043181,"Users Score":0,"Answer":"You can try below\npython .\/odoo-bin -c odoo.conf\nHope this help you","Q_Score":1,"Tags":"python,windows,eclipse,odoo-10","A_Id":56924563,"CreationDate":"2017-07-11T19:37:00.000","Title":"How to control odoo 10 from command line while its running in the web","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When you make a file field with WTForms in Flask, it only returns the filename. Does anyone know how to get it to return the full path of the file?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":786,"Q_Id":45043654,"Users Score":0,"Answer":"The file was uploaded from the user, the browser gets it and keeps it on the sky, so you can save it with a path. That's why you can't get its full path. \nIf an apple flies in the sky, how do you know which apple tree he comes from?","Q_Score":0,"Tags":"python,flask,wtforms,flask-wtforms","A_Id":45047577,"CreationDate":"2017-07-11T20:09:00.000","Title":"Python Flask Wtforms File Field full path","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm getting the following error when trying to run\n$ bazel build object_detection\/...\nAnd I'm getting ~20 of the same error (1 for each time it attempts to build that). I think it's something with the way I need to configure bazel to recognize the py_proto_library, but I don't know where, or how I would do this.\n\/src\/github.com\/tensorflow\/tensorflow_models\/object_detection\/protos\/BUILD:325:1: name 'py_proto_library' is not defined (did you mean 'cc_proto_library'?).\nI also think it could be an issue with the fact that initially I had installed the cpp version of tensorflow, and then I built it for python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":802,"Q_Id":45043961,"Users Score":0,"Answer":"Are you using load in the BUILD file you're building?\nload(\"@protobuf\/\/:protobuf.bzl\", \"py_proto_library\")?\nThe error seems to indicate the symbol py_proto_library  isn't loaded into skylark.","Q_Score":0,"Tags":"python,tensorflow,protocol-buffers,bazel","A_Id":45048559,"CreationDate":"2017-07-11T20:31:00.000","Title":"Bazel has no definition for py_proto_library","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have an application backend in Django-rest-framework, and I have a reactjs app.\nHow can I do to they work together ? \nFor development I open 2 terminals and run them separately. There is some way to make them work together ? \nAlso to deploy it to production I have no idea how I can do that.\nI tried to look for some github project ready, but couldn't find anything\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":999,"Q_Id":45045165,"Users Score":0,"Answer":"For dev:\nYou can run both of them on two different shells. By default, your django rest api will be at 127.0.0.1:8000 and React will at 127.0.0.1:8081. I do not think there will be any issues for the two to communicate via the fetch api. Just make sure you have ALLOWED_HOSTS=['127.0.0.1'] in your django's settings file.\nFor production:\nIt will work like any other mobile app or web app does! Host your your RESTful API on an application server (aws, heroku or whatever you choose) and create and host your React App separately. Use Javascript's fetch api to send requests to your django endpoints and use the json\/xml response to render your views in React.","Q_Score":3,"Tags":"python,django,reactjs,django-rest-framework","A_Id":45045751,"CreationDate":"2017-07-11T22:01:00.000","Title":"How to configure Django Rest Framework + React","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an AWS Lambda handler in Python 2.7 that is deployed from Travis CI.  However, when I try running the function I received an error from AWS saying that it cannot import the enum module (enum34).  Is there a simple way to resolve this?  Should Travis CI include the virtual environment that Python is running in?  If not, how do I include that virtualenv?\nAdditionally, when I deploy from Travis CI, it seems to prepend an \"index.\" onto the handler_name field.  Does anyone know why this happens, or how to disable it?  I can't seem to find an answer.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":297,"Q_Id":45053733,"Users Score":1,"Answer":"Solved it.  I was installing the Python modules into a subdirectory of my project root, rather than in the project root itself.\nEssentially was doing this:\npip install -r requirements.txt .\/virtualenv\/\nwhen I should have been doing this:\npip install -r requirements.txt .\/","Q_Score":0,"Tags":"python,amazon-web-services,lambda,virtualenv,travis-ci","A_Id":45054273,"CreationDate":"2017-07-12T09:27:00.000","Title":"Enum Module with AWS Lambda Python 2.7, Deployed with Travis CI","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to translate some matlab code to python. In the matlab code, I have a radon transform function. I start with a 146x146 image, feed it into the radon() function, and get a 211x90 image. When I feed the same image into my python radon() function, I get a 146x90 image. The documentation for the python radon () function says it is a circular radon transform. Is the matlab function also circular? Why are these returning different shaped images and how can I get the outputs to match?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":269,"Q_Id":45060419,"Users Score":0,"Answer":"Matlab's radon() function is not circular. This was the problem. Although the output image sizes do still differ, I am getting essentially the result I want.","Q_Score":0,"Tags":"python,matlab","A_Id":45061095,"CreationDate":"2017-07-12T14:24:00.000","Title":"is the Matlab radon() function a \"circular\" radon transform?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know how to send custom header (or metadata) using Python gRPC. I looked into documents and I couldn't find anything.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":12988,"Q_Id":45071567,"Users Score":0,"Answer":"If you metadata has one key\/value you can only use list(eg: [(key, value)]) ,If you metadata has Mult k\/v you should use list(eg: [(key1, value1), (key2,value2)]) or tuple(eg: ((key1, value1), (key2,value2))","Q_Score":9,"Tags":"python,grpc","A_Id":70484074,"CreationDate":"2017-07-13T04:43:00.000","Title":"How to send custom header (metadata) with Python gRPC?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"i started a new project in Django but local environment settings come from the previous project.\nSo how can i reset local environment settings?\nThank you..","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1354,"Q_Id":45088254,"Users Score":0,"Answer":"Started a new project. And you replaced the settings.py from another project? If so just update your database and install the required packages with pip. To update the database: python manage.py makemigrations and then python manage.py migrate.","Q_Score":1,"Tags":"python,django,localhost","A_Id":45088312,"CreationDate":"2017-07-13T18:17:00.000","Title":"Django Local Environment Settings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have this list of delivery times in days for cars that are 0 years old. The list contains nearly 20,000 delivery days with many days being repeated. My question is how do i get the histogram to show bin sizes as 1 day. I have set the bin size to the amount of unique delivery days there by:\n len(set(list)) \nbut when i generate the histogram, the frequency of 0 delivery days is over 5000, however when i do list.count(0) it returns with 4500.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1029,"Q_Id":45104994,"Users Score":0,"Answer":"As you pointed out, len(set(list)) is the number of unique values for the \"delivery days\" variable. This is not the same thing as the bin size; it's the number of distinct bins. I would use \"bin size\" to describe the number of items in one bin; \"bin count\" would be a better name for the number of bins.\nIf you want to generate a histogram, supposing the original list of days is called days_list, a quick high-level approach is:\n\nMake a new set unique_days = set(days_list)\nIterate over each value day in unique_days\nFor the current day, set the height of the bar (or size of the bin) in the \nhistogram to be equal to days_list.count(day). This will tell you the number \nof times the current \"day\" value for number of delivery days appeared in the \ndays_list list of delivery times.\n\nDoes this make sense?\nIf the problem is not that you're manually calculating the histogram wrong but that pyplot is doing something wrong, it would help if you included some code for how you are using pyplot.","Q_Score":0,"Tags":"python-3.x,matplotlib,statistics,histogram","A_Id":45105114,"CreationDate":"2017-07-14T14:05:00.000","Title":"Histogram bins size to equal 1 day - pyplot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Someone know how can I send string by socket qpython3 android (client) to python2.7 linux (server)?\nFor python2.7 linux (server) ok, I know, but I dont know how create the client with qpython3 android.\nSomeone Know?\nTKS","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":217,"Q_Id":45111731,"Users Score":0,"Answer":"It's your loopback address this wont work\nHOST = '127.0.0.1'\nInstead that use true ip address on network for your host and make sure port of 5000 on server is open already","Q_Score":0,"Tags":"python-2.7,sockets,qpython3","A_Id":69265192,"CreationDate":"2017-07-14T21:17:00.000","Title":"Sending string via socket qpython3 android (client) to python2.7 linux (server)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can anyone let me know how to set PYTHONPATH?\nDo we need to set it in the environment variables (is it system specific) or we can independently set the PYTHONPATH and use it to run any independent python application? \ni need to pick the module from a package available in directory which is different from the directory from which I am running my application . How to include these packages in my application","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":371,"Q_Id":45144525,"Users Score":1,"Answer":"I assume you are using Linux\nBefore executing your application u can metion pythonpath=path && execution script\nOther elegant way is using virtualenv. Where u can have diff packages for each application.\nBefore exection say workon env and then deactivate \nPython3 has virtualenv by default","Q_Score":0,"Tags":"python,python-3.x,pythonpath","A_Id":45145568,"CreationDate":"2017-07-17T12:37:00.000","Title":"how to use PYTHONPATH for independent python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing this application where the user can perform a web search to obtain some information from a particular website.\nEverything works well except when I'm connected to the Internet via Proxy (it's a corporate proxy).\nThe thing is, it works sometimes.\nBy sometimes I mean that if it stops working, all I have to do is to use any web browser (Chrome, IE, etc.) to surf the internet and then python's requests start working as before.\nThe error I get is:\nOSError('Tunnel connection failed: 407 Proxy Authentication Required',)\nMy guess is that some sort of credentials are validated and the proxy tunnel is up again.\nI tried with the proxies handlers but it remains the same.\nMy doubts are:\n\nHow do I know if the proxy need authentication, and if so, how to do it without hardcoding the username and password since this application will be used by others?\nIs there a way to use the Windows default proxy configuration so it will work like the browsers do?\nWhat do you think that happens when I surf the internet and then the python requests start working again?\n\nI tried with requests and urllib.request\nAny help is appreciated.\nThank you!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1617,"Q_Id":45156592,"Users Score":0,"Answer":"Check if there is any proxy setting in chrome","Q_Score":0,"Tags":"python,proxy,python-requests,urllib","A_Id":45156637,"CreationDate":"2017-07-18T02:39:00.000","Title":"Python URL Request under corporate proxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"i try to run my android test script by \"monkeyrunner cameraTest.py\"\nbut it can't work, the cmd show me this \nSWT folder '..\\framework\\x86' does not exist.\nPlease set ANDROID_SWT to point to the folder containing swt.jar for your platform.\nanyone know how to deal with this\uff1fthanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2025,"Q_Id":45163450,"Users Score":0,"Answer":"In addition to @ohbo's solution, copying AdbWinApi.dll, AdbWinUsbApi.dll into framework folder solved my problem.","Q_Score":2,"Tags":"java,android,python,testing,monkeyrunner","A_Id":49088774,"CreationDate":"2017-07-18T10:00:00.000","Title":"SWT folder '..\\framework\\x86' does not exist. Please set ANDROID_SWT to point to the folder containing swt.jar for your platform","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to open a multi-channel audio file (two or more microphones) and record the audio of each of them on a different file. With PyAudio I know how to open a multi-channel file (open method) and stop when 1.5 seconds of silence are recorded, but eventually I end up with a single (multi-channel) file. I would like to work live on each of input channels separately: record them on a separate file when a pause is detected. For instance if channel 1 has a silence after 5 seconds I stop its recording on a file, while I keep on recording channel 2 until a silence on that channel is detected as well (e.g., after 10 seconds). Could anyone tell me if this is possible with PyAudio, or point me to the right (Python) library if not?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":476,"Q_Id":45177975,"Users Score":1,"Answer":"My solution is not very elegant, but it does work. Open separate streams with the appropriate input_device_index for each.\nstream1 = audio.open(input_device_index = 1 ...)\nstream2 = audio.open(input_device_index = 2 ...)","Q_Score":1,"Tags":"python,audio,pyaudio,channels","A_Id":46686683,"CreationDate":"2017-07-18T22:12:00.000","Title":"Read different streams separately","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a column in my dataframe (call it 'FY') which has financial year values in the format: 2015\/2016 or 2016\/2017.\nI want to convert the whole column so it says 15\/16 or 16\/17 etc instead.\nI presume you somehow only take the 3rd, 4th and 5th character from the string, as well as the 8th and 9th, but haven't got a clue how to do it.\nCould anyone help me? Thank you.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":138,"Q_Id":45198564,"Users Score":1,"Answer":"If you have a string you can always just choose parts of it by writing:\nfoo = 'abcdefg'\nfoo2 = foo[2:4]\nprint foo2\nthen the output would be:\ncd","Q_Score":1,"Tags":"python,pandas,dataframe","A_Id":45198690,"CreationDate":"2017-07-19T18:37:00.000","Title":"Python Pandas - Dataframe column - Convert FY in format '2015\/2016' to '15\/16'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've followed the pet detector tutorial, i have exported the model using \"export_inference_graph.py\".\nHowever when I try to freeze the graph using the provided \"freeze_graph.py\" but now sure what --output_node_names to use.\nDoes anyone know which I should use, or more importantly how I find out what to use for when I train my own model.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1483,"Q_Id":45218374,"Users Score":0,"Answer":"To find what to use for output_node_names, just checkout the graph.pbtxt file. In this case it was Softmax","Q_Score":1,"Tags":"python,tensorflow,object-detection","A_Id":45222284,"CreationDate":"2017-07-20T14:57:00.000","Title":"freezing the \"tensorflow object detection api pet detector\" graph","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a datetime stamp (e.g. time(6,30)) which would return 06:30:00.\nI was wondering how I could then convert this into 6.5 hrs.\nKind regards","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5634,"Q_Id":45247320,"Users Score":1,"Answer":"Assuming that you mean 6.5 hours of elapsed time, that would be a timedelta.  The time object is for time-of-day, as on a 24-hour clock.  These are different concepts, and shouldn't be mixed.\nYou should also not think of time-of-day as \"time elapsed since midnight\", as some days include daylight saving time transitions, which can increase or decrease this value.  For example, for most locations of the United States, on 2017-11-05 the time you gave of 06:30:00 will have 7.5 hours elapsed since midnight, as the hour between 1 and 2 repeats for the fall-back transition.\nSo the answer to your question is - don't.","Q_Score":6,"Tags":"python,datetime,time","A_Id":45247574,"CreationDate":"2017-07-21T22:02:00.000","Title":"Convert datetime into number of hours?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed Anaconda with Python 2.7 and then later installed the Python 3.6 kernel. I have lots of Python 2 packages and I don't want to have to manually install all of the packages for Python 3. Has anyone written, or does anyone know how to write, a bash script that will go through all my Python 2 packages and just run pip3 install [PACKAGE NAME]?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":45250797,"Users Score":2,"Answer":"In your Python 2 pip, run pip freeze > requirements.txt. This will write all your installed packages to a text file. \nThen, using your Python 3 pip (perhaps pip3), run pip install -r \/path\/to\/requirements.txt. This will install all of the packages as listed in the requirements.txt file.","Q_Score":1,"Tags":"python,linux,bash,python-2.7,python-3.x","A_Id":45251074,"CreationDate":"2017-07-22T04:48:00.000","Title":"How can I install all my python 2 packages for python 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have existing REST APIs, written using Django Rest Framework and now due to some client requirements I have to expose some of them as SOAP web services. \nI want to know how to go about writing a wrapper in python so that I can expose some of my REST APIs as SOAP web services. OR should I make SOAP web services separately and reuse code ?\nI know this is an odd situation but any help would be greatly appreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3292,"Q_Id":45279148,"Users Score":0,"Answer":"Lets Discuss both the Approaches and their pros and cons\nSeperate SOAP Service \n\nReusing Same Code -  if you are sure the code changes will not impact the two code flow ,it is good to go.\nExtension of Features - if you are sure that new feature extension will not impact other parts it is again best to go.\nScalablity - if new API are part of same application and you are sure that it will be scalable with more load ,it is again a good option.\nExtension - if you are sure in future adding more API will not create a mess of code, it is again good to go for.\n\nSoap Wrapper Using Python (my favourate and suggested way to go)\n\nSeperation of Concern with this you can make sure ,what ever code you write is sperate from main logic and you can easly plug in and plug out new things.\n\nAnswer for all the above question in case of this is YES.\nYour Call ,\nComments and critisicsm are most welcome","Q_Score":15,"Tags":"django,python-3.x,rest,soap,django-rest-framework","A_Id":45458723,"CreationDate":"2017-07-24T11:13:00.000","Title":"Write a wrapper to expose existing REST APIs as SOAP web services?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This is a non-specific question about best practice in Django. Also note when I say \"app\" I'm referring to Django's definition of apps within a project.\nHow should you go about deciding when to use a new view and when to create an entirely new app? In theory, you can have a simple webapp running entirely on one views.py for an existing app.\nSo how do you go about deciding when to branch off to a new app or just add a new function in your views.py? Is it just whatever makes the most sense?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":28,"Q_Id":45281971,"Users Score":1,"Answer":"It totally depends on your application.\nIf you are an only developer working on project .\nIt is advisable to write one view for each web page or event.\nIf you have multiple developers in your house you can split the view if you want to make a part of it reusable or something like that.\nAgain its all about how your team work,better stick to the same style for the entire project\nall the best","Q_Score":0,"Tags":"python,django","A_Id":45282175,"CreationDate":"2017-07-24T13:29:00.000","Title":"When To Use A View Vs. A New Project","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am doing some sentiment analysis with Tensorflow, but there is a problem I can't solve:\nI have one tensor (input) shaped as [?, 38] [batch_size, max_word_length] and one (prediction) shaped as [?, 3] [batch_size, predicted_label].\nMy goal is to combine both tensors into a single tensor with the shape of [?, 38, 3].\nThis tensor is used as the input of my second stage.\nSeems easy, but i can't find a way of doing it.\nCan (and will) you tell me how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":834,"Q_Id":45282194,"Users Score":0,"Answer":"This is impossible. You have tensor, which contains batch_size * max_word_length \n elements and tensor which contains batch_size * predicted_label elements. Hence there are \nbatch_size * (max_word_length + predicted_label) \nelements. And now you want to create new tensor [batch_size, max_word_length, predicted_label] with \nbatch_size * max_word_length * predicted_label \nelements. You don't have enough elements for this.","Q_Score":0,"Tags":"python,tensorflow","A_Id":45282483,"CreationDate":"2017-07-24T13:39:00.000","Title":"Tensorflow: combining two tensors with dimension X into one tensor with dimension X+1","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing a module in odoo. I hve defined some parent products and their child products. I want to do, when I'm selecting a parent product from many2one field, this parent product's childs will open in Treeview lines automatically. This tree view field is defined as one2many field. \nI used onchange_parent_product funtion, also added filter according to parent_product_id. \nBut treeview nothing show when I select a parent product.. \nPlease help me how can I fill treeview lines automatically ?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":433,"Q_Id":45298393,"Users Score":0,"Answer":"to use one2many field you need many2one field in products\nto this new model that you create. to make it easy use many2many\nfield it's better that way and use onchange to fill it.\njust search for product that have parent_id equals to the selected\n  product and add this record to your many2many field.\nif you need to keep it using o2m field it's better to add more code \nto see what you did and what is the many2one field that you added\nin your product to your new model.","Q_Score":0,"Tags":"python,treeview,openerp,one2many","A_Id":45298797,"CreationDate":"2017-07-25T08:53:00.000","Title":"How to autofill child produts in treeview, when parent product (BOM) is selected in odoo?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using tensorflow to scale images by a factor of 2. But since the tensor (batchsize, height, width, channels) determines the resolution it only accepts images of only one resolution for inference and training.\nFor other resolutions I have to modify the code and retrain the model. Is it possible to make my code resolution independent? In theory convolutions of images are resolution independent, I don't see a reason why this wouldn't be possible.\nI have no idea how to do this in tensorflow though. Is there anything out there to help me with this?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":208,"Q_Id":45299561,"Users Score":0,"Answer":"Okay so here is what I did:\ninput and output tensors now have the shape (batchsize, None, None, channels)\nThe training images now have to be resized outside of the network.\nImportant reminder: training images have to be the same size since they are in batches! Images in one batch have to have the same size. When inferencing the batch size is 1 so the size does not matter.","Q_Score":1,"Tags":"python,tensorflow,resolution,inference,tensor","A_Id":45456995,"CreationDate":"2017-07-25T09:43:00.000","Title":"Variable Resolution with Tensorflow for Superresolution","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a python script that zooms in and out of matplotlib graphs along the horizontal axis. My plot is a set of horizontal bar graphs.\nI also want to make that able to take any generic matplotlib graph. \nI do not want to just load an image and zoom into that, I want to zoom into the graph along the horizontal axis. (I know how to do this)\nIs there some way I can save and load a created graph as a data file or is there an object I can save and load later?\n(typically, I would be creating my graph and then displaying it with the matplotlib plt.show, but the graph creation takes time and I do not want to recreate the graph every time I want to display it)","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":6630,"Q_Id":45310481,"Users Score":3,"Answer":"@Cedric's Answer.\nAdditionally, if you get the pickle error for pickling functions, add the 'dill' library to your pickling script. You just need to import it at the start, it will do the rest.","Q_Score":4,"Tags":"python,matplotlib","A_Id":45312185,"CreationDate":"2017-07-25T17:55:00.000","Title":"python matplotlib save graph as data file","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to download pygame on my computer and use it, but from what I've seen, I need the 32-bit python not the 64-bit one I have. however, I cannot find where the file is on my computer to delete it. I looked through all of my files with the name of 'python' but nothing has shown up about the 64-bit pre installed program. Anyone know how to find it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":98,"Q_Id":45311601,"Users Score":0,"Answer":"Type \nwhich python\non terminal.","Q_Score":0,"Tags":"python","A_Id":45311699,"CreationDate":"2017-07-25T19:04:00.000","Title":"Where is python on mac? (osx el capitan)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck.\nI used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying \"'python' is not recognized as an internal or external command, operable program or batch file\" as if I have not yet installed it.\nUnlike answers to previous questions, I have already added \";C:\\Python36\" to my Path environment variable, so what am I doing wrong? \nI am relatively new to python, but know how to use it on my Mac, so please let me know if I'm just fundamentally confused about something.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":262,"Q_Id":45335812,"Users Score":1,"Answer":"In environmental variables under path, add your python path... you said you already so please ensure is their comma separation between previous path..\nAnd once added save environment variables tab.  And close all command prompt then open it.  \nThen only command prompt will refresh with your python config..\nMain thing,  if you enter python which mean python 2.  \nFor python3 type, python3 then it should work","Q_Score":0,"Tags":"python","A_Id":45335902,"CreationDate":"2017-07-26T19:26:00.000","Title":"Downloading python 3 on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck.\nI used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying \"'python' is not recognized as an internal or external command, operable program or batch file\" as if I have not yet installed it.\nUnlike answers to previous questions, I have already added \";C:\\Python36\" to my Path environment variable, so what am I doing wrong? \nI am relatively new to python, but know how to use it on my Mac, so please let me know if I'm just fundamentally confused about something.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":45335812,"Users Score":0,"Answer":"Thanks everyone, I ended up uninstalling and then re-downloading python, and selecting the button that says \"add to environment variables.\" Previously, I typed the addition to Path myself, so I thought it might make a difference if I included it in the installation process instead. Then, I completely restarted my computer rather than just Command Prompt itself. I'm not sure which of these two things did it, but it works now!","Q_Score":0,"Tags":"python","A_Id":45361096,"CreationDate":"2017-07-26T19:26:00.000","Title":"Downloading python 3 on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck.\nI used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying \"'python' is not recognized as an internal or external command, operable program or batch file\" as if I have not yet installed it.\nUnlike answers to previous questions, I have already added \";C:\\Python36\" to my Path environment variable, so what am I doing wrong? \nI am relatively new to python, but know how to use it on my Mac, so please let me know if I'm just fundamentally confused about something.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":262,"Q_Id":45335812,"Users Score":0,"Answer":"Why are you using command prompt? I just use the python shell that comes with IDLE. It\u2019s much simpler.\nIf you have to use command prompt for some reason, you\u2019re problem is probably that you need to type in python3. Plain python is what you use for using Python 2 in the command prompt.","Q_Score":0,"Tags":"python","A_Id":45338244,"CreationDate":"2017-07-26T19:26:00.000","Title":"Downloading python 3 on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know some basics of Java and C++, and am looking to learn Python\nI am trying to develop some random stuffs to get a good feel of how it works, but i can only make 1 line scripts that run every time i press enter to go to the next line. \nI've seen tutorial videos where they can just open up files from a menu and type away until they eventually run the program. \nI'm using IDLE, and i don't see options to open up new stuffs; I can only make one or two line programs. When i tried to make a calculator program, i didnt know how to run it because it ran every line of code i typed in unless there were ...'s under the >>>'s. \nI think it's because i am in interactive mode, whatever that is.\nHow do i turn it off, if that's the problem?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":45341070,"Users Score":0,"Answer":"To exit out of the \"interactive mode\" that you mentioned (the included REPL shell in IDLE) and write a script, you will have to create a new file by either selecting the option from the top navigation bar or pressing Control-N. As for running the file, there's also that option on the navigation bar; alternatively, you can press F5 to run the program.","Q_Score":0,"Tags":"python","A_Id":45341485,"CreationDate":"2017-07-27T03:50:00.000","Title":"python 3.6.2 not giving me option to create or run files or anything of the sort","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Feeling the need to learn how to use asyncio, but cannot think of applicable problem (or problem set) that can help me learn this new technique.\nCould you suggest a problem that can help me understand and learn asyncio usage in practice?\nIn another words: can you suggest me an example of some abstract problem or application, which, while coding it, will help me to learn how to use asyncio in practice.\nThank you","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1304,"Q_Id":45350985,"Users Score":2,"Answer":"Any I\/O bound task would be a good case for asyncio. In the context of the network programming - any application, that requires simultaneous handling of the thousands of connections. Web server, web crawler, chat backend, MMO game backend, torrent tracker and so on. Keep in mind, though, that you should go async all the way and use async versions of all libraries performing blocking I\/O, like the database drivers, etc.","Q_Score":6,"Tags":"python-3.x,asynchronous,parallel-processing,python-asyncio","A_Id":46352707,"CreationDate":"2017-07-27T12:34:00.000","Title":"Python asyncio training exercises","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What I can observe:\n\nI am using windows 7 64bit My code (establish an odbc connection with\na SQL server on the network, simple reading operations only) is\nwritten in python 3.6.2 32bit \nI pip installed pyodbc, so I assume that was 32bit as well. \nI downloaded and installed the 64bit \"Microsoft\u00ae ODBC Driver 13.1 for SQL Server\u00ae\" from microsoft website.\nMy python code connects to\nother computers on the network, which run server2003 32bit and either SQL Server 2005(32bit) or sql2008(32bit).\n\nThe setup works.\nMoreover: cursory test shows that, the above setup can successfully connect to a computer with Microsoft server2008(64bit) running sql2012(64bit) with the configuration under \"SQL Server Network Connection (32bit)\" being empty (meaing, the 32bit dll is missing), while the default 64 bit network connection configuration contains the usual config options like ip adress and listening port info.\nMy own explanation: \n[1] the client and the server's OS and ODBC interfaces can be of any 32\/64 bit combination, but the protocol that travels thru the network between my computer and the sql computer will be identical.\n[2] 32 bit python+pyodbc can talk to microsoft's 64bit odbc driver, because... 32 bit python knows how to use a 64 bit DLL...?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1620,"Q_Id":45362440,"Users Score":1,"Answer":"A 32bit application can NOT invoke a 64bit dll, so python 32bit can not talk to a 64bit driver for sure.\nmsodbc driver for sql server is in essence a dll file: msodbcsql13.dll\nI just found out (which is not even mentioned by microsoft) that \"odbc for sql server 13.1 x64\" will install a 64bit msodbcsql13.dll in system32 and a 32bit msodbcsql13.dll in SysWOW64 ( 32bit version of \"system32\" on a 64bit windows system)\nI can not however be certain that the network protocol between a 32bit client talking to 64bit sql server will be the same as a 64bit client talking to a 64bit sql server. But, I believe that, once a request is put on the network by the client to the server, 32bit or 64bit doesn't matter anymore. Someone please comment on this","Q_Score":0,"Tags":"python-3.x,odbc,driver,32bit-64bit,pyodbc","A_Id":45365583,"CreationDate":"2017-07-27T23:12:00.000","Title":"32bit pyodbc for 32bit python (3.6) works with microsoft's 64 bit odbc driver. Why?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a GUI that I would like to put at the disposal for my colleagues to use under the form of .exe , after some researchs i found pyinstaller as \"freezer\" which work great after downloading the github version , but my issue is even if the .exe is created when i run it , it show up for less than a second on the screen and it disapears\nI would like to know how to keep it on the screen (most important part) and getting it closed when the user close it himself..\nThanks in advance for the help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":177,"Q_Id":45368358,"Users Score":0,"Answer":"Another option would be to manually open a CMD window, navigate to, and then execute your exe, rather than letting the packaged application spawn the instance.","Q_Score":1,"Tags":"python-3.x,user-interface,tkinter,pyinstaller,tkinter-canvas","A_Id":51119738,"CreationDate":"2017-07-28T08:18:00.000","Title":"avoiding a pyinstaller .exe disapear of the screen without closing","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a little confused as to how the PVM gets the cpu to carry out the bytecode instructions. I had read somewhere on StackOverflow that it doesn't convert byte-code to machine code, (alas, I can't find the thread now). \nDoes it already have tons of pre-compiled machine instructions hard-coded that it runs\/chooses one of those depending on the byte code?\nThank you.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2285,"Q_Id":45380268,"Users Score":2,"Answer":"If you mean Standard Python (CPython) by Python, then no! The byte-code (.pyc or .pyo files) are just a binary version of your code line by line, and is interpreted at run-time. But if you use pypy, yes! It has a JIT Compiler and it runs your byte-codeas like Java dn .NET (CLR).","Q_Score":6,"Tags":"python","A_Id":45380349,"CreationDate":"2017-07-28T18:36:00.000","Title":"Does the Python Virtual Machine (CPython) convert bytecode into machine language?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When we work with Django in local environment, we change the structure of the Data Base using Command Prompt through migration. \nBut for using Django in server, i don't now how can i apply such changes? How can i type commands to change Data Base structure? Is it a good way to upload site files every time that i do some change again.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":196,"Q_Id":45385751,"Users Score":1,"Answer":"The whole point of migrations is that you run them on both your local database and in production, to keep them in sync.","Q_Score":1,"Tags":"python,django,database,django-models","A_Id":45386569,"CreationDate":"2017-07-29T05:45:00.000","Title":"Changing database structure of Django in server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I can get html of a web site using lxml module if authentication is not required. However, when it required, how do I input 'User Name' and 'Password' using python?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":29,"Q_Id":45406471,"Users Score":0,"Answer":"It very much depends on the method of authentication used. If it's HTTP Basic Auth, then you should be able to pass those headers along with the request. If it's using a web page-based login, you'll need to automate that request and pass back the cookies or whatever session token is used with the next request.","Q_Score":0,"Tags":"python,authentication,login,web-crawler,lxml","A_Id":45406522,"CreationDate":"2017-07-31T01:51:00.000","Title":"How to get html using python when the site requires authenticasion?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using scrapy-redis now, and I am ok with it, and I am success to crawl in different computer by using the same redis server.\nBut I don't understand how to use the scrapy-redis pipeline properly.\nIn my understanding, I think I need another script than the spiders to deal with the item in the redis pipeline list, then I can do stuffs like store them into the database.\nDo I understand right, do I have to write another script, which is somehow dependent from the spider?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":489,"Q_Id":45410078,"Users Score":0,"Answer":"The pipeline is a different script, yes. In the settings file you can enable the pipeline. A pipeline can be used to store the crawled results in any database you want.","Q_Score":0,"Tags":"python,redis,scrapy","A_Id":45420788,"CreationDate":"2017-07-31T07:44:00.000","Title":"how to use scrapy-redis pipeline?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am currently reading \"Reinforcement Learning\" from Sutton & Barto and I am attempting to write some of the methods myself.\nPolicy iteration is the one I am currently working on. I am trying to use OpenAI Gym for a simple problem, such as CartPole or continuous mountain car. \nHowever, for policy iteration, I need both the transition matrix between states and the Reward matrix. \nAre these available from the 'environment' that you build in OpenAI Gym. \nI am using python. \nIf not, how do I calculate these values, and use the environment?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1540,"Q_Id":45437357,"Users Score":2,"Answer":"No, OpenAI Gym environments will not provide you with the information in that form. In order to collect that information you will need to explore the environment via sampling: i.e. selecting actions and receiving observations and rewards. With these samples you can estimate them.\nOne basic way to approximate these values is to use LSPI (least square policy iteration), as far as I remember, you will find more about this in Sutton too.","Q_Score":3,"Tags":"python,machine-learning,reinforcement-learning,openai-gym","A_Id":45468144,"CreationDate":"2017-08-01T12:05:00.000","Title":"Implementing Policy iteration methods in Open AI Gym","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been struggling to understand the use of size parameter in the gensim.models.Word2Vec\nFrom the Gensim documentation, size is the dimensionality of the vector. Now, as far as my knowledge goes, word2vec creates a vector of the probability of closeness with the other words in the sentence for each word. So, suppose if my vocab size is 30 then how does it create a vector with the dimension greater than 30? Can anyone please brief me on the optimal value of Word2Vec size? \nThank you.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":14983,"Q_Id":45444964,"Users Score":21,"Answer":"size is, as you note, the dimensionality of the vector.\nWord2Vec needs large, varied text examples to create its 'dense' embedding vectors per word. (It's the competition between many contrasting examples during training which allows the word-vectors to move to positions that have interesting distances and spatial-relationships with each other.)\nIf you only have a vocabulary of 30 words, word2vec is unlikely an appropriate technology. And if trying to apply it, you'd want to use a vector size much lower than your vocabulary size \u2013 ideally much lower. For example, texts containing many examples of each of tens-of-thousands of words might justify 100-dimensional word-vectors.\nUsing a higher dimensionality than vocabulary size would more-or-less guarantee 'overfitting'. The training could tend toward an idiosyncratic vector for each word \u2013 essentially like a 'one-hot' encoding \u2013 that would perform better than any other encoding, because there's no cross-word interference forced by representing a larger number of words in a smaller number of dimensions. \nThat'd mean a model that does about as well as possible on the Word2Vec internal nearby-word prediction task \u2013 but then awful on other downstream tasks, because there's been no generalizable relative-relations knowledge captured. (The cross-word interference is what the algorithm needs, over many training cycles, to incrementally settle into an arrangement where similar words must be similar in learned weights, and contrasting words different.)","Q_Score":9,"Tags":"python,gensim,word2vec","A_Id":45453040,"CreationDate":"2017-08-01T18:12:00.000","Title":"Python: What is the \"size\" parameter in Gensim Word2vec model class","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been struggling to understand the use of size parameter in the gensim.models.Word2Vec\nFrom the Gensim documentation, size is the dimensionality of the vector. Now, as far as my knowledge goes, word2vec creates a vector of the probability of closeness with the other words in the sentence for each word. So, suppose if my vocab size is 30 then how does it create a vector with the dimension greater than 30? Can anyone please brief me on the optimal value of Word2Vec size? \nThank you.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":14983,"Q_Id":45444964,"Users Score":0,"Answer":"It's equal to vector_size.\nTo make it easy, it's a uniform size of dimension of the output vectors for each word that you trained with word2vec.","Q_Score":9,"Tags":"python,gensim,word2vec","A_Id":65432085,"CreationDate":"2017-08-01T18:12:00.000","Title":"Python: What is the \"size\" parameter in Gensim Word2vec model class","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"During the process of making a lmdb file,we are supposed to make a train.txt and val.txt file,i have already made a train.txt file which consists of the image name space its corresponding label.Ex image1.JPG 0.\nNow that i have to make the val.txt file im confused as to how do i give it its corresponding values since it is my test data and i am hoping to predict those.Can anyone tell me what thisval.txt file is and what is it supposed to be doing.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":427,"Q_Id":45446829,"Users Score":0,"Answer":"You are confusing test and validation sets. A validation set is a set where you know the labels (like in training) but you do not train on it. The validation set is used to make sure you are not overfitting the training data.\nAt test time you may present your model with unlabeled data and make prediction for these samples.","Q_Score":1,"Tags":"python,caffe","A_Id":45447380,"CreationDate":"2017-08-01T20:08:00.000","Title":"Caffe LMDB train and val.txt","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to use xlwings wit the OPTIMIZED_CONNECTION set to TRUE. I would like to modify the setting but somehow cannot find where to do it. I change the _xlwings.conf sheet name in my workbook but this seems to have no effect. Also I cannot find these settings in VBA as I think I am supposed to under what is called \"Functions settings in VBA module\" in the xlwings documentation. I tried to re-import the VBA module but cannot find xlwings.bas on my computer.(only xlwings.xlam that I cannot access in VBA)\nI am using the 0.11.4 version of xlwings.\nSorry for this boring question and thanks in advance for any help.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":702,"Q_Id":45455892,"Users Score":0,"Answer":"The add-in replaces the need for the settings in VBA in newer versions.\nOne can debug the xlam module using \"xlwings\" as a password.\nThis enabled me to realize that the OPTIMIZED_CONNECTION parameter is now set through \"USE UDF SERVER\" keyword in the xlwings.conf sheet (which does work)","Q_Score":0,"Tags":"python,windows,xlwings","A_Id":45456886,"CreationDate":"2017-08-02T08:47:00.000","Title":"xlwings VBA function settings edit","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"all.\nI want to change 1 to 0 and 0 to 1 in binary.\nfor example,\nif binary is 00000110.\nI want to change it to 11111001.\nhow to do that in python3?\nBest regards.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":865,"Q_Id":45475587,"Users Score":0,"Answer":"You can use the ~ operator. If A = 00100, ~A = 11011.\nIf A is a string version of a decimal, convert it into int first.","Q_Score":0,"Tags":"python,binary,complement","A_Id":45475668,"CreationDate":"2017-08-03T05:31:00.000","Title":"how to change 1 to 0 and 0 to 1 in binary(Python)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Good Morning everyone, I am attempting to install CherryPy on a server without internet access. It has windows Server 2012. I can RDP to it, which is how i have attempted to install it. The server has Python 2.7 installed.\nWhat I have tried (unsuccessfully):\nRDP to the server, pip install cherrypy from command line (issue is that it is offline)\nDownloaded the .grz files, RDP to server, from CL ran python (source to the setup.py file) install. says that there are dependencies that are unable to be downloaded (because offline).\nDownloaded the whl file, attempted to run, did not work.\nIs there a way to download the the package, along with all dependencies, on a remote computer (with internet access) and them copy the files over and install? I have attempted to find this information without success.\nthank you all for your help.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":259,"Q_Id":45487397,"Users Score":-1,"Answer":"Ended up copying my entire lib\\site-packages folder to the remote server, placed where it would have been on my old server, and it worked fine.\nTL:DR copy you %Python_home%\/lib\/site-packages folder to your remote machine and it might work. need to have the same version of python installed. In my case it was 2.7.","Q_Score":0,"Tags":"python,pip,cherrypy","A_Id":45493774,"CreationDate":"2017-08-03T14:38:00.000","Title":"Unable to install cherrypy on an offline server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I was trying learn sqlite and how to use it from Ipython notebook, and I have a sqlite object named db.\nI am executing this command:\n\nsel=\" \" \" SELECT * FROM candidates;\" \" \"\nc=db.cursor().execute(sel)\n\nand when I do this in the next cell:\n\nc.fetchall()\n\nit does print out all the rows but when I run this same command again i.e. I run\nc.fetchall() again it doesn't print out anything, it just displays a two square brackets with nothing inside them. But when I run the above first command ie, c=db.cursor().execute(sel) and then run db.fetchall() it again prints out the table.\nThis is very weird and I don't understand it, what does this mean?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":189,"Q_Id":45498188,"Users Score":1,"Answer":"That is because .fetchall() makes your cursor(c) pointing the last row.\nif you want to select your DB again, you should .execute again.\nOr, if you just want to use your fetched data again, you can store c.fetchall() into your variable.","Q_Score":0,"Tags":"python,sqlite,ipython","A_Id":45498306,"CreationDate":"2017-08-04T04:16:00.000","Title":"Weird behavior by db.cursor.execute()","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using django 1.10 and python 3.6.1\nwhen executing \nget_or_none(models.Character, pk=0), with SQL's get method, the query returns a hashmap i.e.: <Character: example>\nHow can I extract the value example?\nI tried .values(), I tried iterating, I tried .Character\nnothing seems to work, and I can't find a solution in the documentation.\nThank you,","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":414,"Q_Id":45500972,"Users Score":0,"Answer":"@Daniel Roseman helped me understand the answer.\nSOLVED:\nWhat I was getting from the query was the model of character, so I couldn't have accessed it thru result.Character but thru result.Field_Inside_Of_Character","Q_Score":0,"Tags":"python,mysql,sql,django","A_Id":45501557,"CreationDate":"2017-08-04T07:43:00.000","Title":"Django SQL get query returns a  hashmap, how to access the value?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have to SSH into 120 machines and make a dump of a table in databases and export this back on to my local machine every day, (same database structure for all 120 databases).\nThere isn't a field in the database that I can extract the name from to be able to identify which one it comes from, it's vital that it can be identified, as it's for data analysis.\nI'm using the Python tool Fabric to automate the process and export the CSV on to my machine..\n\nfab -u PAI -H 10.0.0.35,10.0.0.XX,10.0.0.0.XX,10.0.0.XX -z 1\n  cmdrun:\"cd \/usr\/local\/mysql\/bin && .\/mysql -u root -p -e 'SELECT *\n  FROM dfs_va2.artikel_trigger;' >\n  \/Users\/admin\/Documents\/dbdump\/dump.csv\"\n  download:\"\/Users\/johnc\/Documents\/Imports\/dump.csv\"\n\nAbove is what I've got working so far but clearly, they'll all be named \"dump.csv\" is there any awesome people out there can give me a good idea on how to approach this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":62,"Q_Id":45508137,"Users Score":0,"Answer":"You can try to modify your command as follow:\n\nmysql -uroot -p{your_password} -e 'SELECT * FROM dfs_va2.artikel_trigger;' > \/Users\/admin\/Documents\/dbdump\/$(hostname)_dump.csv\" download:\"\/Users\/johnc\/Documents\/Imports\/$(hostname)_dump.csv\"\n\nhostname returns current machine name so all your files should be unique (of course if machines have unique names)\nAlso you don't need to navigate to \/bin\/mysql every time, you can use simply mysql or absolute path \/usr\/local\/mysql\/bin\/mysql","Q_Score":0,"Tags":"python,automation,fabric,devops","A_Id":45508534,"CreationDate":"2017-08-04T13:28:00.000","Title":"Best way to automate file names of multiple databases","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going through a book on Python which spends a decent time on module reloading, but does not explain well when it would be useful. \nHence, I am wondering, what are some real-life examples of when such technique becomes handy?\nThat is, I understand what reloading does. I am trying to understand how one would use it in real world.\nEdit:\nI am not suggesting that this technique is not useful. Instead, I am trying to learn more about its applications as it seems quite cool.\nAlso, I think people who marked this question as duplicate took no time to actually read the question and how it is different from the proposed duplicate. \nI am not asking HOW TO reload a module in Python. I already know how to do that. I am asking WHY one would want to reload a module in Python in real life. There is a huge difference in nature of these questions.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":92,"Q_Id":45513191,"Users Score":0,"Answer":"As an appendix to DYZ's answer, I use module reloading when analysing large data in interactive Python interpreter.\nLoading and preprocessing of the data takes some time and I prefer to keep them in the memory (in a module BTW) rather than restart the interpreter every time I change something in my modules.","Q_Score":4,"Tags":"python,python-3.x,module,reload","A_Id":47103371,"CreationDate":"2017-08-04T18:17:00.000","Title":"Real-life module reloading in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am not talking about the softwares like surf online, HTtrack, or any other 'save page' feature of browsers but I need to know how actually it happens in the background. I am interested in making my own program to do that.\nAlso is it possible to do in JavaScript. If yes what are the libraries I should look into or any other APIs that could be helpful. Please give me any kind of information about the topic I couldn't find any relevant thing to contribute my research.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":188,"Q_Id":45517437,"Users Score":0,"Answer":"Download entire HTML content of the web page \nFor JS files, look for the <script> tags and download the js file using the src attribute or any inline scripts inside the tag\nFor CSS, use <link> tag to download the CSS file and also look for any <style> tags for inline CSS styling\nFor Images, scan for <img> tag and download the image using src attribute\n\nSame approach can be used for audio\/video etc","Q_Score":1,"Tags":"javascript,php,python,angularjs,web","A_Id":45517697,"CreationDate":"2017-08-05T01:40:00.000","Title":"How to get all files like: js,css,images from a website to save it for offline use?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"How to calculate expiry date in odoo 10 and how to notify to customers from email\/sms before 10 days?\nfor example:- \nIf expiry date is near, the customer gets notification through mail or sms.\nCan anyone suggest any solution?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":325,"Q_Id":45518829,"Users Score":1,"Answer":"You need to create a scheduler it should run everyday. It should calculate the expiry dates which are ending in next 10 days. For those records you have to trigger the mail.\n\nCreate a scheduler\nFind the expiry dates\nCreate email template\nTrigger Email\n\nPlease refer sale subscription it has subscription expiry reminder","Q_Score":0,"Tags":"python-2.7,odoo-10","A_Id":45519483,"CreationDate":"2017-08-05T06:05:00.000","Title":"expiry date in odoo 10","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to include sqlite3 in an electron project I am getting my hands dirty with. I have never used electron, nor Node before, excuse my ignorance. I understand that to do this on Windows, I need Python installed, I need to download sqlite3, and I need to install it. \nAs per the NPM sqlite3 page, I am trying to install it using npm install --build-from-source\nIt always fails with \n\nunpack_sqlite_dep\n    'python' is not recognized as an internal or external command,\n    operable program or batch file.\n\nI have Python 2.7 installed and the path has been added to environment variable PATH. I can verify that if I type 'python' in cmd, I get the same response. BUT, if I type 'py', it works....\nSo, my question is: how can I make node-gyp use the 'py' command instead of 'python' when trying to unpack sqlite3?\nIf this is not possible, how can I make 'python' an acceptable command to use?\nI am using Windows 10 if this helps. Also, please let me know if I can do this whole procedure in a different way.\nThanks for any help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":259,"Q_Id":45527497,"Users Score":0,"Answer":"This has been resolved....\nUninstalled Python 2.7.13. Reinstalled, added path to PATH variable again, now command 'python' works just fine...","Q_Score":0,"Tags":"python-2.7,sqlite,electron,node-gyp","A_Id":45533423,"CreationDate":"2017-08-06T00:18:00.000","Title":"Failing to install sqlite3 plugin for electron project on windows","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am having some trouble with NLTK's FreqDist. Let me give you some context first:\n\nI have built a web crawler that crawls webpages of companies selling wearable products (smartwatches etc.). \nI am then doing some linguistic analysis and for that analysis I am also using some NLTK functions - in this case FreqDist.\nnltk.FreqDist works fine in general - it does the job and does it well; I don't get any errors etc.\n\nMy only problem is that the word \"heart rate\" comes up often and because I am generating a list of the most frequently used words, I get heart and rate separately to the tune of a few hundred occurrences each.\nNow of course rate and heart can both occur without being used as \"heart rate\" but how do I count the occurrences of \"heart rate\" instead of just the 2 words separately and I do mean in an accurate way. I don't want to subtract one from the other in my current Counters or anything like that.\nThank you in advance!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1205,"Q_Id":45531514,"Users Score":0,"Answer":"This is a well-known problem in NLP and it is often referred to Tokenization. I can think about two possible solutions:\n\ntry different NLTK tokenizers (e.g. twitter tokenizer), which maybe will be able to cover all of your cases\nrun a Name Entity Recognition (NER) on your sentences. This allows you to recognise entity present in the text. This could work because it can recognise Heart rate as a single entity, thus as a single token.","Q_Score":0,"Tags":"python,nltk","A_Id":45533385,"CreationDate":"2017-08-06T11:23:00.000","Title":"NLTK FreqDist counting two words as one","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"To be clear I have no idea what I'm doing here and any help would be useful.\nI have a number of saved files, Keras neural network models and dataframes. I want to create a program that loads all of these files so that the data is there and waiting for when needed.\nAny data sent to the algorithm will be standardised and fed into the neural networks.\nThe algorithm may be called hundreds of times in quick succession and so I don't want to have to import the model and standardisation parameters every time as it will slow everything down.\nAs I understand it the plan is to have this program running in the background on a server and then somehow call it when required.\nHow would I go about setting up something like this? I'm asking here first because I've never attempted anything like this before and I don't even know where to start. I'm really hoping you can help me find some direction or maybe provide an example of something similar. Even a  search term that would help me research would be useful.\nMany thanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28,"Q_Id":45537958,"Users Score":0,"Answer":"Wrap it in a Python based web server listening on some agreed-on port.  Hit it with HTTP requests when you want to supply a new file or retrieve results.","Q_Score":0,"Tags":"python,scripting,neural-network","A_Id":45537986,"CreationDate":"2017-08-07T00:35:00.000","Title":"Python have program running and ready for when called","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created a path variable for my project using\nproj_path = pathlib.Path('C:\/users\/data\/lives\/here') \nI now want to save a seaborn plot as png so I created a new path variable for the file\nplot_path = proj_path.joinpath('plot_name.png')\nbut when I call plot_name.savefig(plot_path) returns\nTypeError: Object does not appear to be a 8-bit string path or a Python file-like object \nWhat path format is accepted by savefig and how do I convert plot_path?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":670,"Q_Id":45575016,"Users Score":0,"Answer":"You probably want to use\nplot_name.savefig(plot_path)\ninstead of \nplot_name.savefig('plot_path') (note no '-s).","Q_Score":1,"Tags":"python,path,seaborn","A_Id":45575093,"CreationDate":"2017-08-08T17:56:00.000","Title":"What format of path should be used for savefig?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How do you print (in the terminal) a subset of columns from a pandas dataframe?\nI don't want to remove any columns from the dataframe; I just want to see a few columns in the terminal to get an idea of how the data is pulling through.\nRight now, I have  print(df2.head(10)) which prints the first 10 rows of the dataframe, but how to I choose a few columns to print?  Can you choose columns by their indexed number and\/or name?","AnswerCount":1,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":31744,"Q_Id":45577630,"Users Score":25,"Answer":"print(df2[['col1', 'col2', 'col3']].head(10)) will select the top 10 rows from columns 'col1', 'col2', and 'col3' from the dataframe without modifying the dataframe.","Q_Score":11,"Tags":"python,python-3.x,pandas","A_Id":45577693,"CreationDate":"2017-08-08T20:38:00.000","Title":"Print sample set of columns from dataframe in Pandas?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to make a python package that relies on a command line utility to work. I am wondering if anyone knows how to make pip install that command line utility when pip installs my package. The only documentation I can seem to find is on dependency_links which looks to be depreciated.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":103,"Q_Id":45601984,"Users Score":0,"Answer":"You can set dependencies on another python package (e.g. using install_requires in your setup.py), but if your code relies on a specific non-Python binary you cannot have that installed automatically as part of the pip install process. \nYou could create a native package for your operating system, which would allow you to set dependencies on other system packages such that when your Python script was installed with apt\/yum\/dnf\/etc, the necessary binary would be installed as well.","Q_Score":0,"Tags":"python","A_Id":45602412,"CreationDate":"2017-08-09T23:10:00.000","Title":"Installing a command line utility from installing a python package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Imagine that I've written a celery task, and put the code to the server, however, when I want to send the task to the server, I need to reuse the code written before.\nSo my question is that are there any methods to seperate the code between server and client.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":222,"Q_Id":45608490,"Users Score":0,"Answer":"Try a web server like flask that forwards requests to the celery workers. Or try a server that reads from a queue (SQS, AMQP,...) and does the same.\nNo matter the solution you choose, you end up with 2 services: the celery worker itself and the \"server\" that calls the celery tasks. They both share the same code but are launched with different command lines.\nAlternately, if the task code is small enough, you could just import the git repository in your code and call it from there","Q_Score":1,"Tags":"python,celery","A_Id":45608632,"CreationDate":"2017-08-10T08:36:00.000","Title":"how to seperate celery code into server and client side?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have deployed a django app on heroku. So far it works fine. Now I have to schedule a task (its in the form of python script) once a day. The job would take the data from heroku database perform some calculations and post the results back in the database. I have looked at some solutions for this usually they are using rails in heroku. I am confused whether I should do it using the cron jobs extension available in django or using the scheduled jobs option in heroku. Since the application is using using heroku I thought of using that only but I dont get any help how to add python jobs in it. Kindly help.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":397,"Q_Id":45612349,"Users Score":1,"Answer":"I suggest you to create a Django management command for your project like python mananage.py run_this_once_a_day. And you can use Heroku schedular to trigger this scheduling.","Q_Score":0,"Tags":"python,django,heroku","A_Id":45612723,"CreationDate":"2017-08-10T11:22:00.000","Title":"running scheduled job in django app deployed on heroku","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say I have a Frame in tkinter with a set width and height (placed using the place method), and I add a child Frame to that parent Frame (using the pack method). In that child Frame, I add an arbitrary amount of widgets, so that the child Frame's width is dynamically set depending on its children.\nMy question is how do I get the width of the child Frame if it's width is greater than its parent?\nI know there's a winfo_width method to get the width of a widget, but it only returns the width of the parent Frame if its width is greater than its parent. In other words, how do I get the actual width of a widget, not just the width of the part of the widget that is displayed?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":45625918,"Users Score":2,"Answer":"The width will never be bigger than the parent frame. \nYou can call winfo_reqwidth to get the requested width of the widget. I'm not sure if that will give you the answer you are looking for. I'm not entirely what the real problem is that you are trying to solve.","Q_Score":2,"Tags":"python,python-3.x,tkinter,width","A_Id":45626120,"CreationDate":"2017-08-11T02:12:00.000","Title":"Get width of child in tkinter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python Scraper that I run periodically in my free tier AWS EC2 instance using Cron that outputs a csv file every day containing around 4-5000 rows with 8 columns. I have been ssh-ing into it from my home Ubuntu OS and adding the new data to a SQLite database which I can then use to extract the data I want.\nNow I would like to try the free tier AWS MySQL database so I can have the database in the Cloud and pull data from it from my terminal on my home PC. I have searched around and found no direct tutorial on how this could be done. It would be great if anyone that has done this could give me a conceptual idea of the steps I would need to take. Ideally I would like to automate the updating of the database as soon as my EC2 instance updates with a new csv table. I can do all the de-duping once the table is in the aws MySQL database.\nAny advice or link to tutorials on this most welcome. As I stated, I have searched quite a bit for guides but haven't found anything on this. Perhaps the concept is completely wrong and there is an entirely different way of doing it that I am not seeing?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":158,"Q_Id":45630562,"Users Score":1,"Answer":"The problem is you don't have access to RDS filesystem, therefore cannot upload csv there (and import too).\nModify your Python Scraper to connect to DB directly and insert data there.","Q_Score":0,"Tags":"python,mysql,database,database-design,amazon-ec2","A_Id":45643778,"CreationDate":"2017-08-11T08:36:00.000","Title":"Exported scraped .csv file from AWS EC2 to AWS MYSQL database","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"So I am working on a project that has a Raspberry Pi connected to a Serial Device via a USB to Serial Connector.  I am trying to use PySerial to track the data being sent over the connected Serial device, however there is a problem.\nCurrently, I have my project set up so that every 5 seconds it calls a custom port.open() method I have created, which returns True if the port is actually open.  This is so that I don't have to have the Serial Device plugged in when I initially go to start the program.\nHowever I'd also like to set it up so that the program can also detect when my serial device is disconnected, and then reconnected.  But I am not sure how to accomplish this.\nIf I attempt to use the PySerial method isOpen() to check if the device is there, I am always having it return true as long as the USB to Serial connector is plugged in, even if I have no Serial device hooked up to the connector itself.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1786,"Q_Id":45634854,"Users Score":0,"Answer":"You might be able to tell whether the device is physically plugged in by checking the status of one of the RS232 control lines - CTS, DSR, RI, or CD (all of which are exposed as properties in PySerial).  Not all USB-serial adapters support any of these.\nIf the only connection to the device is the TX\/RX lines, your choices are extremely limited:\n\nSend a command to the device and see if it responds.  Hopefully its protocol includes a do-nothing command for this purpose.\nIf the device sends data periodically without needing an explicit command, save a timestamp whenever data is received, and return False if it's been significantly longer than the period since the last reception.","Q_Score":0,"Tags":"python,raspberry-pi,pyserial","A_Id":45635399,"CreationDate":"2017-08-11T12:07:00.000","Title":"PySerial, check if Serial is Connected","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I ran pip install pyaudio in my terminal and got this error:\n\nCommand \"\/home\/oliver\/anaconda3\/bin\/python -u -c \"import setuptools,\n  tokenize;file='\/tmp\/pip-build-ub9alt7s\/pyaudio\/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\\r\\n',\n  '\\n');f.close();exec(compile(code, file, 'exec'))\" install\n  --record \/tmp\/pip-e9_md34a-record\/install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in \/tmp\/pip-build-ub9alt7s\/pyaudio\/\n\nSo I ran sudo apt-install python-pyaudio python3-pyaudio\nwhich seemed to work. \nThen in jupyter:\nimport pyaudio\nerror: \n\nModuleNotFoundError: No module named 'pyaudio'\n\nCan anyone help me work out this problem? I am not familiar with Ubuntu and it's commands paths etc as I've only been using it a few months.\nIf you need more information, let me know what, and how. Thanks","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":5269,"Q_Id":45676247,"Users Score":0,"Answer":"Check in the documentation of pyaudio if it is compatible with your python version\nSome modules which are not compatible may be installed without issues, yet still won't work when trying to access them","Q_Score":1,"Tags":"python,python-3.x,pyaudio","A_Id":45676889,"CreationDate":"2017-08-14T13:57:00.000","Title":"ModuleNotFoundError: No module named 'pyaudio'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I ran pip install pyaudio in my terminal and got this error:\n\nCommand \"\/home\/oliver\/anaconda3\/bin\/python -u -c \"import setuptools,\n  tokenize;file='\/tmp\/pip-build-ub9alt7s\/pyaudio\/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\\r\\n',\n  '\\n');f.close();exec(compile(code, file, 'exec'))\" install\n  --record \/tmp\/pip-e9_md34a-record\/install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in \/tmp\/pip-build-ub9alt7s\/pyaudio\/\n\nSo I ran sudo apt-install python-pyaudio python3-pyaudio\nwhich seemed to work. \nThen in jupyter:\nimport pyaudio\nerror: \n\nModuleNotFoundError: No module named 'pyaudio'\n\nCan anyone help me work out this problem? I am not familiar with Ubuntu and it's commands paths etc as I've only been using it a few months.\nIf you need more information, let me know what, and how. Thanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5269,"Q_Id":45676247,"Users Score":0,"Answer":"if you are using windows then these command on the terminal:\npip install pipwin\npipwin install pyaudio","Q_Score":1,"Tags":"python,python-3.x,pyaudio","A_Id":59344854,"CreationDate":"2017-08-14T13:57:00.000","Title":"ModuleNotFoundError: No module named 'pyaudio'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm working a lot with Excel xlsx files which I convert using Python 3 into Pandas dataframes, wrangle the data using Pandas and finally write the modified data into xlsx files again. \nThe files contain also text data which may be formatted. While most modifications (which I have done) have been pretty straight forward, I experience problems when it comes to partly formatted text within a single cell:\nExample of cell content: \"Medical device whith remote control and a Bluetooth module for communication\"\nThe formatting in the example is bold and italic but may also be a color. \nSo, I have two questions:\n\nIs there a way of preserving such formatting in xlsx files when importing the file into a Python environment?\nIs there a way of creating\/modifying such formatting using a specific python library?\n\nSo far I have been using Pandas, OpenPyxl, and XlsxWriter but have not succeeded yet. So I shall appreciate your help!\nAs pointed out below in a comment and the linked question OpenPyxl does not allow for this kind of formatting:\nAny other ideas on how to tackle my task?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":190,"Q_Id":45688168,"Users Score":0,"Answer":"i have been recently working with openpyxl. Generally if one cell has the same style(font\/color), you can get the style from cell.font:    cell.font.bmeans bold andcell.font.i means italic, cell.font.color contains color object.\nbut if the style is different within one cell, this cannot help. only some minor indication on cell.value","Q_Score":0,"Tags":"python,excel,pandas,openpyxl,xlsxwriter","A_Id":45689273,"CreationDate":"2017-08-15T07:22:00.000","Title":"Modifying and creating xlsx files with Python, specifically formatting single words of a e.g. sentence in a cell","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to make program1 run program2 and program2 run program1 and so on. I have already tried using os.system() on each program to run the other, but a really long line of errors comes up and says maximum recursion depth reached\nThanks","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":45711940,"Users Score":1,"Answer":"Except the weirdness of the question :)\nWhat you did is a correct way, but each time you call a new program your stack gets bigger and after a while your stack is full and you get a stack overflow (no you don't get this site :p ), but just an error which this site is named after as you encountered.\nIf you really want to keep their system busy I would try to do something heavy inside one program.","Q_Score":0,"Tags":"python-3.x","A_Id":45712201,"CreationDate":"2017-08-16T11:09:00.000","Title":"Can I make an endless loop of python programs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to achieve a 3D-reconstruction algorithm with sfm,\nBut how should i set the parameters of the Camera Matrix?\nI have double cameras,both know their focal length.\nAnd how about Rotation Matrix and Translation Matrix from world view?\ni use python","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":574,"Q_Id":45725440,"Users Score":1,"Answer":"You already have a code for camera calibration and printing a camera matrix in your OpenCV installation. Go to this path if you are on windows -\nC:\\opencv\\sources\\samples\\python\nThere you have  a file called calibrate","Q_Score":1,"Tags":"python,opencv,matrix,camera,3d-reconstruction","A_Id":45727419,"CreationDate":"2017-08-17T01:51:00.000","Title":"How can i obtain Camera Matrix in 3Dreconstruction?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As we all know; Apple ship OSX with Python, but it locks it away.\nThis force me and anyone else that use python, to install another version and start the painful process of installing with pip with 100 tricks and cheats.\nNow, I would like to understand how to do this right; and sorry but I can't go with the route of the virtualenv, due to the fact that I run this for a build server running Jenkins, and I have no idea how to set that up correctly.\nCould you please clarify for me these?\n\nHow do you tell OSX to run the python from brew, instead than system one?\nWhere is the official python living, and where are the packages installed, when I run pip install with and without the -U and\/or the --user option?\nIn which order should I install a bunch of packages starting from scratch.on a fresh OSX machine,so I can set it up reliably every time?\n\nMostly I use opencv, scikit-image, numpy, scipy and pillow. These are giving me so many issues and I can't get a reliable setup so that Jenkins is happy to run the python code, using these libraries.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":37,"Q_Id":45726623,"Users Score":0,"Answer":"Brew installs packages into \/usr\/local\/Cellar and then links them to \/usr\/local\/bin (i.e. \/usr\/local\/bin\/python3). In my case, I just make sure to have \/usr\/local\/bin in my PATH prior to \/usr\/bin. \nexport PATH=\/usr\/local\/bin:$PATH\nBy using brew, your new packages will be installed to: \n\/usr\/local\/Cellar\/python\nor \n\/usr\/local\/Cellar\/python3\nPackage install order shouldn't matter.","Q_Score":1,"Tags":"python","A_Id":45726701,"CreationDate":"2017-08-17T04:32:00.000","Title":"Questions about double install of Python on OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When running this example\uff1a\" python mnist_with_summaries.py \", it has\noccurred the following error:\ndetailed errors\uff1a\n\nTraceback (most recent call last):\n    File \"mnist_with_summaries.py\", line 214, in \n      tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)\n    File \"D:\\ProgramData\\Anaconda2\\envs\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\platform\\app.py\"\n  , line 48, in run\n      _sys.exit(main(_sys.argv[:1] + flags_passthrough))\n    File \"mnist_with_summaries.py\", line 186, in main\n      tf.gfile.MakeDirs(FLAGS.log_dir)\n    File \"D:\\ProgramData\\Anaconda2\\envs\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\lib\\io\\file_io.p\n  y\", line 367, in recursive_create_dir\n      pywrap_tensorflow.RecursivelyCreateDir(compat.as_bytes(dirname), status)\n    File \"D:\\ProgramData\\Anaconda2\\envs\\Anaconda3\\lib\\contextlib.py\", line 89, in exit\n      next(self.gen)\n    File \"D:\\ProgramData\\Anaconda2\\envs\\Anaconda3\\lib\\site-packages\\tensorflow\\python\\framework\\errors\n  _impl.py\", line 466, in raise_exception_on_not_ok_status\n      pywrap_tensorflow.TF_GetCode(status))\n  tensorflow.python.framework.errors_impl.NotFoundError: Failed to create a directory: \/tmp\\tensorflow\n\nRunning environment\uff1awindows7+Anaconda3+python3.6+tensorflow1.3.0\nWhy?Any idea on how to resolve this problem?Thank you\uff01","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":249,"Q_Id":45731787,"Users Score":1,"Answer":"I have solved this problem. \nI changed line 204 and line 210 of mnist_with_summaries.py to the local directories, and I created some folders.\nOR, don't change the code, and I created some folders in the local disk where is the running environment according to the code. \n\nline 204: create \/tmp\/tensorflow\/mnist\/input_data \nline 210: create \/tmp\/tensorflow\/mnist\/logs\/mnist_with_summaries","Q_Score":1,"Tags":"python-3.x,tensorflow,mnist","A_Id":45747350,"CreationDate":"2017-08-17T09:47:00.000","Title":"When running \" python mnist_with_summaries.py \", it has occurred the error","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I would like to know how to insert into same MongoDb collection from different python scripts running at the same time using pymongo\nany help redirecting guidance would be very appreciated because I couldn't find any clear documentation in pymongo or mongdb about it yet\nthank in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":754,"Q_Id":45737486,"Users Score":1,"Answer":"You should be able to just insert into the collection in parallel without needing to do anything special.  If you are updating documents then you might find there are issues with locking, and depending on the storage engine which your MongoDB is using there may be collection locking, but this should not affect how you write your python script.","Q_Score":1,"Tags":"python,mongodb,python-3.x,pymongo,pymongo-3.x","A_Id":45737589,"CreationDate":"2017-08-17T14:11:00.000","Title":"Writing in parallel to MongoDb collection from python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a MetaTrader4 Terminal and I'm experienced python developer.\nDoes anyone know, how can I connect MT4 and Python? I want to:\n- connect to MT4\n- read USD\/EUR data\n - make order (buy\/sell)\nDoes anyone know some library, a page with instructions or a documentation or have at least idea how to do that? \nI googled first 30 page but I didn't find anything useful.","AnswerCount":5,"Available Count":1,"Score":0.0399786803,"is_accepted":false,"ViewCount":12826,"Q_Id":45740126,"Users Score":1,"Answer":"Several options: \n\nexchange with files (write data from mt4 into a file for python, another folder in opposite direction with buy\/sell instructions); \n0MQ (or something like that) as a better option.","Q_Score":2,"Tags":"python,distributed-computing,mt4","A_Id":45751233,"CreationDate":"2017-08-17T16:08:00.000","Title":"How to control MT4 from python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to create a wizard which has several pages.\nI know how to pass to 'target' new or current, to pass the action to a form or tree view, but what I actually need, before that, is to create several steps which will be on different \"views\" of this wizard, like a form with 'next' and 'back' buttons.\nIs there some example code I can look for that?\nI've searched on default addons, with no success.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":639,"Q_Id":45747880,"Users Score":4,"Answer":"The best way to do this is to have a popup target=new and have a statusbar on top right which will be clickable\/not readonly (so that the user can go back). And depending on the state of your record, show the appropriate fields\nYou can of course create a popup, and when the user clicks next destroy that popup and create another one but that doesn't seem like a good idea to me.","Q_Score":0,"Tags":"python,openerp,qweb","A_Id":45753702,"CreationDate":"2017-08-18T03:08:00.000","Title":"Add button next page - wizard - Odoo v8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm in IPython and want to run a simple python script that I've saved in a file called \"test.py\". \nI'd like to use the %run test.py command to execute it inside IPython, but I don't know to which folder I need to save my test.py. \nAlso, how can I change that default folder to something else, for example C:\\Users\\user\\foldername ? \nI tried with the .ipython folder (original installation folder) but that's not working.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":475,"Q_Id":45760932,"Users Score":0,"Answer":"%run myprogram works for Python scripts\/programs.\nTo run any arbitrary programs, use ! as a prefix, e.g. !myprogram.\nMany common shell commands\/programs (cd, ls, less, ...) are also registered as IPython magic commands (run via %cd, %ls, ...), and also have registered aliases, so you can directly run them without any prefix, just as cd, ls, less, ...","Q_Score":1,"Tags":"python,ipython","A_Id":60616311,"CreationDate":"2017-08-18T16:13:00.000","Title":"IPython - running a script with %run command - saved to which folder?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For a flood warning system, my Raspberry Pi rings the bells in near-real-time but uses a NAS drive as a postbox to output data files to a PC for slower-time graphing and reporting, and to receive various input data files back.  Python on the Pi takes precisely 10 seconds to establish that the NAS drive right next to it is not currently available.  I need that to happen in less than a second for each access attempt, otherwise the delays add up and the Pi fails to refresh the hardware watchdog in time.  (The Pi performs tasks on a fixed cycle:  every second, every 15 seconds (watchdog), every 75 seconds and every 10 minutes.)  All disc access attempts are preceded by tests with try-except.  But try-except doesn't help, as tests like os.path.exists() or with open() both take 10 seconds before raising the exception, even when the NAS drive is powered down.  It's as though there's a 10-second timeout way down in the comms protocol rather than up in the software.\nIs there a way of telling try-except not to be so patient?  If not, how can I get a more immediate indicator of whether the NAS drive is going to hold up the Pi at the next read\/write, so that the Pi can give up and wait till the next cycle?  I've done all the file queueing for that, but it's wasted if every check takes 10 seconds.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":226,"Q_Id":45764187,"Users Score":0,"Answer":"Taking on MQTT at this stage would be a big change to this nearly-finished project.  But your suggestion of decoupling the near-real-time Python from the NAS drive by using a second script is I think the way to go.  If the Python disc interface commands wait 10 seconds for an answer, I can't help that.  But I can stop it holding up the time-critical Python functions by keeping all time-critical file accesses local in Pi memory, and replicating whole files in both directions between the Pi and the NAS drive whenever they change.  In fact I already have the opportunistic replicator code in Python - I just need to move it out of the main time-critical script into a separate script that will replicate the files.  And the replicator Python script will do any waiting, rather than the time-critical Python script.  The Pi scheduler will decouple the two scripts for me.  Thanks for your help - I was beginning to despair!","Q_Score":0,"Tags":"python,exception-handling,timing,nas","A_Id":45768586,"CreationDate":"2017-08-18T19:55:00.000","Title":"How can Python test the availability of a NAS drive really quickly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Python, how do you check that an external program is running? I'd like to track my use of some programs, so I can see the amount of time I've spent with them. For example, if I launch my program , I want to be able to see if Chrome has already been launched, and if so, start a timer which would end when I exit Chrome.\nIve seen that then subprocess module can launch external programs, but this is not what I'm looking for.\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":47,"Q_Id":45772510,"Users Score":0,"Answer":"In my case I would try something using Task Manager data, probably using subprocess.check_output(ps)(for me that looks good), but you can the [psutil][1] library.\nTell us what you did later :)","Q_Score":0,"Tags":"python","A_Id":45772896,"CreationDate":"2017-08-19T14:05:00.000","Title":"python: how to check the use of an external program","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to basically call a python script from HTML, after the script is called and it finished running, I would like to execute a javascript file(wich I know how to do.) Now my question is: Can I do this with just pure HTML and javascript or do I need to get a library for python? If I dont need a library, how would I go about doing this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":76,"Q_Id":45787213,"Users Score":0,"Answer":"You can use Two Python libraries.\n\nDjango\nFlask\n\nI recommend Django. Django is easy and fast to make.\nthe Flask is more complex but you can make more detail functions.","Q_Score":0,"Tags":"javascript,python,html","A_Id":45788234,"CreationDate":"2017-08-20T22:08:00.000","Title":"Runnning python script on HTML page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if their is anyway to go through and make copies of each .ipynb file in a folder and then change that file to .py. I want to keep the .ipynb files but I would like to have a .py file as well. I know how to do it manually but would like a way to do it automatically for each file in a specified directory.","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":1236,"Q_Id":45802690,"Users Score":2,"Answer":"find . -name \"*.py\" -exec ipython nbconvert --to=python {} \\; should work on Linux.","Q_Score":2,"Tags":"python","A_Id":45802768,"CreationDate":"2017-08-21T17:28:00.000","Title":"Converting all files in folder to .py files","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am running pytest on a Jenkins machine; although I am not sure which Python it is actually running.\nThe machine is running OSX; and I did install various libraries (like numpy and others), on top of another Python install via Brew, so I keep things separated.\nWhen I run the commands from console; I specify python2.6 -m pytest mytest.py, which works, but when I run the same via shell in Jenkins, it fail, because it can't find the right libraries (which are the extra libraries I did install, after installing Python via Brew).\nIs there a way to know what is Jenkins using, so I can force it to run the correct python binary, which has access to my extra libraries?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":171,"Q_Id":45806967,"Users Score":0,"Answer":"You can use which python to find which python Jenkins use.\nYou can use ABSPATH\/OF\/python to run your pytest","Q_Score":0,"Tags":"python,jenkins","A_Id":45807814,"CreationDate":"2017-08-21T23:45:00.000","Title":"how to find out which Python is called when I run pytest via Jenkins","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently using anaconda and python 3.6 on windows bash. Every time i want to use matplotlib I have to paste a copy of the matplotlibrc file into my working directory otherwise my code won't run or plot and I get the warning - \/home\/computer\/anaconda3\/lib\/python3.6\/site-packages\/matplotlib\/init.py:1022: UserWarning: could not find rc file;returning defaults\nmy matplotlibrc file is located at C:\\Users\\user\\AppData\\Local\\lxss\\home\\puter\\anaconda3\\lib\\python3.6\\site-packages\\matplotlib\\mpl-data\nI thought to fix this I could edit my .condarc file and set it to look for matplotlibrc in the correct directory. Could anyone tell me how to do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":950,"Q_Id":45813527,"Users Score":0,"Answer":"It looks like when anaconda or matplotlib was installed it's created the matplotlibrc file in C:\\Users\\user\\AppData\\Local\\lxss\\home\\puter\\anaconda3\\lib\\py\u200c\u200bthon3.6\\site-package\u200c\u200bs\\matplotlib\\mpl-dat\u200c\u200ba using the windows environment. This has caused the file not to be recognised in WSL.\nTo fix this create another matplotlibrc file in bash or whatever shell you're using. In the directory listed above copy the contents of the previously created matplotlibrc file into your new matplotlibrc file. Make sure you don't create this file in the windows environment otherwise it won't be recognised.","Q_Score":0,"Tags":"python,matplotlib,anaconda,windows-subsystem-for-linux","A_Id":45832556,"CreationDate":"2017-08-22T09:16:00.000","Title":"how to change matplotlibrc default directory","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to do some applications with python, but I haven't found any way of getting a tool-box of buttons, check box, etc.\nCan some explain me please how can I do that with:\n1. Pycharm.\n2. If it is problem with Pycharm, visual studio community is also okay.\nThanks,\nAyal","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":795,"Q_Id":45817703,"Users Score":0,"Answer":"This is what I have found:\nThere is a designer from QT, to build a ui file. There is a tool for translating the ui into python. Then you can edit the logic, with any python tool. You only need PyQt the current version is PyQt5.","Q_Score":0,"Tags":"python-3.x","A_Id":45877103,"CreationDate":"2017-08-22T12:30:00.000","Title":"Python windows forms application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I was wondering how to make a .tar.gz file of all pip packages used in a project.  The project will not have access to the internet when a user sets up the application.  So, I though it would be easiest to create .tar.gz file that would contain an all the necessary packages and the user would just extract and install them with a setup.py file (example) or something along those lines.  Thanks","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1561,"Q_Id":45822389,"Users Score":1,"Answer":"Do:\n\npip freeze > requirements.txt\nIt will store all your requirements in file requirements.txt\n\npip wheel -r requirements.txt --wheel-dir=\"packages\"\nIt will pre-package or bundle your dependencies into the directory packages\n\nNow you can turn-off your Wi-fi and install the dependencies when ever you want from the \"packages\" folder.\nJust Run this:\n\n\npip install --force-reinstall --ignore-installed --upgrade --no-index --no-deps packages\/*\nThanks :)","Q_Score":0,"Tags":"python,linux,pip","A_Id":71218863,"CreationDate":"2017-08-22T16:03:00.000","Title":"How do you make a .tar.gz file of all your pip packages used in a project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to generate a pdf417 barcode in python using treepoem but pycharm keeps giving me the following error:\nTraceback (most recent call last):\nFile \"C:\/Users\/.\/Documents\/barcodes.py\", line 175, in \n    image = generate_barcode(barcode_type=\"pdf417\",data=barcode, options=dict(eclevel=5, rows=27, columns=12))\n  File \"C:\\Users.\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\treepoem__init__.py\", line 141, in generate_barcode\n    bbox_lines = _get_bbox(code)\n  File \"C:\\Users.\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\treepoem__init__.py\", line 81, in _get_bbox\n    ghostscript = _get_ghostscript_binary()\n  File \"C:\\Users.\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\treepoem__init__.py\", line 108, in _get_ghostscript_binary\n    'Cannot determine path to ghostscript, is it installed?'\ntreepoem.TreepoemError: Cannot determine path to ghostscript, is it installed?\nI've tried to install ghostcript, using both the .exe I found online and using pip install ghostscript (successfully completed the first time, and now tells me the requirement is satisfied), yet I still keep getting this error. Any ideas on how to fix it?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2240,"Q_Id":45828456,"Users Score":1,"Answer":"You are installing on Windows, the Windows binary differs in name from the Linux binaries and indeed differs depending whether  you installed the 64 or 32-bit version.\nOn Linux (and MacOS) the Ghostscript binary is called 'gs', on Windows its 'gswin32' or 'gswin64' or 'gswin32c' or 'gswin64c' depending on whether you want the 32 or 64 bit version, and the command line or windowed executable.\nMy guess is that your script is looking for simply 'gs' and is probably expecting the path to be in the $PATH environment variable, its not clear to me what its expecting.\nYou could probably 'fix' this by making sure the installation path is in the $PATH environment variable and copying the executable to 'gs.exe' in that directory.\nOther than that you'll need someone who can tell you what the script is looking for. Quite possibly you could just grep it.","Q_Score":1,"Tags":"python,ghostscript","A_Id":45833436,"CreationDate":"2017-08-22T23:36:00.000","Title":"Treepoem barcode generator unable to find ghostscript","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm writing a basic socket program in Python3, which consists of three different programs - sender.py, channel.py, and receiver.py. The sender should send a packet through the channel to the receiver, then receiver sends an acknowledgement packet back.\nIt works for sending one packet - it goes through the channel to the receiver, and the receiver sends an acknowledgement packet through the channel to the sender, which gets it successfully. But when the sender tries to send a second packet, it attempts to send it but gets no response, so it sends it again. When it does, it gets BrokenPipeError: [Errno 32] Broken pipe. The channel gives no indication that it receives the second packet, and just sits there waiting. What does this mean and how can it be avoided?\nI never call close() on any of the sockets.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":56,"Q_Id":45838549,"Users Score":0,"Answer":"It was because I was generating a new socket each time, rather than just re-using one socket.","Q_Score":0,"Tags":"python,sockets","A_Id":51373042,"CreationDate":"2017-08-23T11:32:00.000","Title":"How do I avoid a BrokenPipeError while using the sockets module in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to store a \"set\" in a database (specifically PostgreSQL) efficiently, but I'm not sure how to do that efficiently.\nThere are a few options that pop to mind:\n\nstore as a list ({'first item', 2, 3.14}) in a text or binary column.  This has the downside of requiring parsing when inserting into the database and pulling out.  For sets of text strings only, this seems to work pretty well, and the parsing is minimal.  For anything more complicated, parsing becomes difficult.\nstore as a pickle in a binary column.  This seems like it should be quick, and it is complete (anything picklable works), but isn't portable across languages.\nstore as json (either as a binary object or a text stream).  Larger problems than just plain text, but better defined parsing.\n\nAre there any other options?  Does anyone have any experience with these?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":76,"Q_Id":45848956,"Users Score":2,"Answer":"What you want to do is store a one-to-many relationship between a row in your table and the members of the set.\nNone of your solutions allow the members of the set to be queried by SQL. You can't do something like select * from mytable where 'first item' in myset. Instead you have to retrieve the text\/blob and use another programming language to decode or parse it. That means if you want to do a query on the elements of the set you have to do a full table scan every time.\nI would be very reluctant to let you do something like that in one of my databases. \nI think you should break out your set into a separate table. By which I mean (since that is clearly not as obvious as I thought), one row per set element, indexed over primary key of the table you are referring from or, if you want to enforce no duplicates at the cost of a little extra space, primary key of the table you are referring from + set element value. \nSince your set elements appear to be of heterogeneous types I see no harm in storing them as strings, as long as you normalize the numbers somehow.","Q_Score":0,"Tags":"python,sql,json,postgresql,pickle","A_Id":45850429,"CreationDate":"2017-08-23T20:42:00.000","Title":"How to store a \"set\" (the python type) in a database efficiently?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How to produce kafka topic using message batch or buffer with pykafka. I mean one producer can produce many message in one produce process. i know the concept using message batch or buffer message but i dont know how to implement it. I hope someone can help me here","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":4131,"Q_Id":45859384,"Users Score":0,"Answer":"Just use the send() method.  You do not need to manage it by yourself.\n\nsend() is asynchronous.  When called it adds the record to a buffer of\n  pending record sends and immediately returns. This allows the producer\n  to batch together individual records for efficiency.\n\nYour task is only that configure two props about this: batch_size and linger_ms.\n\nThe producer maintains buffers of unsent records for each partition.\n  These buffers are of a size specified by the \u2018batch_size\u2019 config.\n  Making this larger can result in more batching, but requires more\n  memory (since we will generally have one of these buffers for each\n  active partition).\n\nThe two props will be done by the way below: \n\nonce we get batch_size worth of records for a partition it will be sent immediately regardless of this setting, however if we have fewer than this many bytes accumulated for this partition we will \u2018linger\u2019 for the specified time waiting for more records to show up.","Q_Score":1,"Tags":"python,apache-kafka,kafka-producer-api,pykafka","A_Id":45862977,"CreationDate":"2017-08-24T10:37:00.000","Title":"How to produce kafka topic using message batch or buffer with pykafka","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using jupyter notebooks to write some explanations on how to use certain functions. The code i am showing there is not complete, meaning it will give errors when executed. Is there a way to write display-only code in a jupyter notebook?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5049,"Q_Id":45865164,"Users Score":0,"Answer":"You can use markdowns. Or you can put in comment your code but it will be not in \"jupyter way\"","Q_Score":3,"Tags":"python,jupyter-notebook,jupyter","A_Id":45865241,"CreationDate":"2017-08-24T15:10:00.000","Title":"Jupyter notebook display code only","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am looking for the following (IMHO, very important) feature:\n\nSuppose I have two functions fa() and fb(), both of them has a breakpoint.\nI am now stopped in the breakpoint in fa function.\nIn the interactive debugger console I am calling fb().\n\nI want to stop in fb breakpoint, but, unfortunately pb() runs but ignores the breakpoint.\nsomeone in another SO thread called it \"nested breakpoints\".\nI am a developer that come from Matlab, in Matlab no matter how a function is called, from console, from debugger. if it has a breakpoint it stops.\nI read past threads about this subject and did not find any solution.\nI also tried latest pycharm community and latest pydev and no luck.\nI also read that visual studio can not make it.\nIs this inherent in Python and technically can not be done?\nIs there a technique \/ another IDE that supports it?","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":846,"Q_Id":45902890,"Users Score":-1,"Answer":"Take a look at Eric Python IDE and VSC(Visual Studio Code)","Q_Score":3,"Tags":"python,debugging,pycharm,pydev,breakpoints","A_Id":45904346,"CreationDate":"2017-08-27T08:03:00.000","Title":"any Python IDE supports stopping in breakpoint from the debugger","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm fairly new to Python and I have a python script that I would like to ultimately convert to a Windows executable (which I already know how to do). Is there a way I can write something in the script that would make it run as a background process in Windows instead of being visible in the foreground?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3312,"Q_Id":45911894,"Users Score":0,"Answer":"You can run the file using pythonw instead of python means run the command pythonw myscript.py instead of python myscript.py","Q_Score":7,"Tags":"python,windows,background-process","A_Id":60206875,"CreationDate":"2017-08-28T04:43:00.000","Title":"How to put a Python script in the background without pythonw.exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am student and i am totally new to scraping etc, today my supervisor gave me task to get the list of followers of a user or page(celebrity etc)\nthe list should contain information about every user (i.e user name, screen name etc)\nAfter a long search i found that i can't get the age and gender of any user on twitter.\nsecondly i got help regarding getting list of my followers but i couldnt find help about \"how i can get user list of public account\"\nkindly suggest me that its possible or not, and if it is possible, what are the ways to get to my goals\nthank you in advance","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":45923490,"Users Score":0,"Answer":"Hardly so, and even if you manage to somehow do it, you'll most likely get blacklisted. Also, please read the community guidelines when it comes to posting questions.","Q_Score":0,"Tags":"python,twitter,web-scraping,text-mining,scrape","A_Id":45959340,"CreationDate":"2017-08-28T16:26:00.000","Title":"is it possible to scrape list of followers of a public twitter acount (page)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Does anyone know how I'll be able to get the current user from airflow? We have our backend enabled to airflow\/contrib\/auth\/backends\/ldap_auth.pyand so users log in via that authentication and I want to know how to get the current user that clicks on something (a custom view we have as a plugin).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1335,"Q_Id":45935428,"Users Score":1,"Answer":"You can get it by calling {{ current_user.user.username }} or {{ current_user.user }} in your html jenja template.","Q_Score":0,"Tags":"python,airflow,flask-login,apache-airflow","A_Id":46274739,"CreationDate":"2017-08-29T09:28:00.000","Title":"Airflow: Get user logged in with ldap","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"if you are using a custom python layer - and assuming you wrote the class correctly in python - let's say the name of the class is \"my_ugly_custom_layer\"; and you execute caffe in the linux command line interface, \nhow do you make sure that caffe knows how to find the file where you wrote the class for your layer? do you just place the .py file in the same directory as the train.prototxt?\nor\nif you wrote a custom class in python you need to use the python wrapper interface?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":263,"Q_Id":45942883,"Users Score":2,"Answer":"Your python layer has two parameters in the prototxt: layer: where you define the python class name implementing your layer, and moduule: where you define the .py file name where the layer class is implemented.\nWhen you run caffe (either from command line or via python interface) you need to make sure your module is in the PYTHONPATH","Q_Score":1,"Tags":"python,caffe,layer","A_Id":45944107,"CreationDate":"2017-08-29T15:22:00.000","Title":"Bekeley caffe command line interface","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"excuse my English\nI'm beginner in django and i want to achieve this in my model and form:\nthe scenario is like purchasing shoes on amazon:\n1. the shoes has list of size a user can select form \n2. the user select and add it to the cart \n3. user place an order which is saved in a model with the respective size included\nnow imagine a shoe seller when selling can enter a list of sizes like this in python size = [1, 2, 3, 4] which is also saved on a shoe-model \nhow can implement this in django and how to save a list of size entered but a seller to  a model and how can i display this list so the user can select only one of the value of this list?\nplease help","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":858,"Q_Id":45947457,"Users Score":0,"Answer":"You can convert the list to json and store it in a charfield.","Q_Score":1,"Tags":"python,django,python-3.x,django-models","A_Id":45951472,"CreationDate":"2017-08-29T20:01:00.000","Title":"Django: how can i get a model that store a list(like in python or anyway) of a sizes of a shoes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an existing python\/django app with jinja template engine.\nI have a template with a filter and a list the gets rendered correctly via server, also the filters work perfectly without javascript.\n(based on url with parameters)\nThe server also responds with json if the same filter url is requested by ajax. So it's ready for an enhanced version.\nNow:\nI would like to make it nicer and update\/rerender the list asynchronously when I change the filter based on the json response I receive.\nQuestions:\n\nWhen I init the vue on top of the page template, it removes\/rerenders everything in the app. All within the vue root element becomes white.\nCan I declare only parts of my whole template ( the one filter and the list) as separate vue components and combine these instances (there are other parts that are not part of the async update part vue should not take of)\nCan I somehow use the existing markup of my components in jinja to be used to rerender the components again with vue or do I have to copy paste it into javascript (please no!) ?\n\nTLDR: I don't wan't to create the whole model with vue and then prerender the whole app (modern SSR way) and vue will find out the diff.\nI just want to use vue on top of an existing working django app.","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":464,"Q_Id":45959832,"Users Score":-1,"Answer":"I think the best method really is to split up the front and backend into two seperate entities, communicating via an API rather than bleeding the two together as in the long run it creates headaches.","Q_Score":0,"Tags":"python,django,vue.js,vue-component,server-side-rendering","A_Id":45959886,"CreationDate":"2017-08-30T11:58:00.000","Title":"Vue.JS on top of existing python\/django\/jinja app for filter and list render","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a CentOS 7 machine which already has Python 2.7.5 installed. Now i want to install Python version 3 also side by side without disturbing the original Python version 2. If i install with pip i fear that it would install version 3 on top of the already existing version. \nCan someone please guide me how to do the same ? Also i have created a virtualenvs directory inside my installation where i want to create the virualenvs.\nAt present whenever i create any virtualenvs using the virtualenv command it automatically copies the Python version 2 installable over there.\nI want my virtualenvs to contain version 3 and anything outside my virtualenvs should run with version 2.\nIs this even possible.\nThanks a lot for any answers.","AnswerCount":4,"Available Count":1,"Score":-1.0,"is_accepted":false,"ViewCount":6155,"Q_Id":45997541,"Users Score":-5,"Answer":"You can simply apt-get install python3 and then use -p python3 while creating your virtual environment. Installing python3 will not disturb your system python (2.7).","Q_Score":2,"Tags":"python","A_Id":45998552,"CreationDate":"2017-09-01T09:50:00.000","Title":"Install Python version 3 side by side with version 2 in Centos 7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to to use numbers to indicate references in footnotes, so I was wondering inside of Jupyter Notebook how can I use superscripts and subscripts?","AnswerCount":4,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":58725,"Q_Id":46011785,"Users Score":32,"Answer":"<sup>superscript text <\/sup>  also works, and might be better because latex formatting changes the whole line etc.","Q_Score":46,"Tags":"python,jupyter-notebook,ipython-notebook,jupyter,data-science","A_Id":48120444,"CreationDate":"2017-09-02T08:08:00.000","Title":"How to do superscripts and subscripts in Jupyter Notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset and there are missing values which are encoded as ?. My problem is how can I change the missing values, ?, to NaN? So I can drop any row with NaN. Can I just use .replace() ?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":8652,"Q_Id":46016838,"Users Score":1,"Answer":"You can also do like this,\n\ndf[df == '?'] = np.nan","Q_Score":2,"Tags":"python,pandas,dataframe","A_Id":58381427,"CreationDate":"2017-09-02T18:14:00.000","Title":"How can I convert '?' to NaN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset and there are missing values which are encoded as ?. My problem is how can I change the missing values, ?, to NaN? So I can drop any row with NaN. Can I just use .replace() ?","AnswerCount":4,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":8652,"Q_Id":46016838,"Users Score":2,"Answer":"You can also read the data initially by passing \ndf = pd.read_csv('filename',na_values = '?')\nIt will automatically replace '?' to NaN","Q_Score":2,"Tags":"python,pandas,dataframe","A_Id":52961763,"CreationDate":"2017-09-02T18:14:00.000","Title":"How can I convert '?' to NaN","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2193,"Q_Id":46018812,"Users Score":0,"Answer":"I know it's an old question but let me give it a shot. When you say Google Cloud instance do you mean their compute engine (virtual machine)? If so, you don't need to keep your laptop running all the time to continue a process on cloud, there is an alternative. You can run your python programs from terminal and use tools like Screen or tmux, which keep running your (training) process even if your GC instance is disconnected. You can even turn your system off. I just finished a 24 hr long Hyperparameter optimization marathon few days back.\nAllow me to also mention here that sometimes \"Screen\" throws X11 display related errors, so tmux can be used instead.\nUsage Instructions:\n\nInstall tmux : sudo apt-get install tmux \nstart new tmux session to run your process : tmux new -s \"name_of_sess\" --> this opens a new window in terminal. Type your command here like : python my_program.py to start your training.\ndetach session : ctrl+B -> release -> press 'd' (while inside session) \nlist of all the tmux session running : tmux ls \nattach a session : tmux attach -t \"id_from_above_command_lists\" \nkill a tmux session : ctrl+shift+d\n\nNote: Commands are mentioned based on what I remember, it may have mistakes. Quick search would give you exact syntax. Idea is to show how easy it is to use.","Q_Score":0,"Tags":"python,google-cloud-platform,jupyter-notebook","A_Id":55023413,"CreationDate":"2017-09-02T22:37:00.000","Title":"Keep Google Cloud Jupyter Notebook Running while computer sleeps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":2193,"Q_Id":46018812,"Users Score":0,"Answer":"In the remote (GCP) SSH client:\n\nInstall tmux: sudo apt-get install tmux.\nStart a new tmux session: tmux new -s \"session\".\nRun commands as normal.","Q_Score":0,"Tags":"python,google-cloud-platform,jupyter-notebook","A_Id":56662974,"CreationDate":"2017-09-02T22:37:00.000","Title":"Keep Google Cloud Jupyter Notebook Running while computer sleeps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","AnswerCount":3,"Available Count":3,"Score":0.1325487884,"is_accepted":false,"ViewCount":2193,"Q_Id":46018812,"Users Score":2,"Answer":"I just discovered this huge oversight in GCP. I don't understand how they could design it this way. This behavior defeats a major point of using the cloud. They want us to pay for this? I use a laptop which sometimes needs to be asleep in a backpack, I can't keep a computer on all day just so a cloud computer can run. \nIf I can't figure anything else out, we are just going to have to use two cloud computers. Maybe use like a small free cloud computer to keep the big datalab one running. We shouldn't have to resort to this.","Q_Score":0,"Tags":"python,google-cloud-platform,jupyter-notebook","A_Id":51087148,"CreationDate":"2017-09-02T22:37:00.000","Title":"Keep Google Cloud Jupyter Notebook Running while computer sleeps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried making a cronjob to run my script every second, i used *\/60 * * * * this a parameter to run every second but it didn't worked, pls suggest me how should i run my script every second ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1441,"Q_Id":46024476,"Users Score":0,"Answer":"Well, no. Your argument - *\/60 * * * * - means \"run every 60 minutes\". And you can't specify a shorter interval than 1 minute, not in standard Unix cron anyway.","Q_Score":1,"Tags":"python,cron","A_Id":46024560,"CreationDate":"2017-09-03T14:34:00.000","Title":"I want to make a cronjob such that it runs a python script every second","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a 64 bit PC, and python 3.6.2 (64 bit), python 3.5.4 (32 bit), and python 3.5.4 (64 bit), all installed and added to my path.\nIn Pycharm, I created a virtual environment based off of python 3.5.4 (32 bit) and wrote a project in this env. Each version of python I have installed has an associated virtual env, and all of them have pyinstaller installed on them via Pycharm's installer.\nHowever, when I open up a command prompt in the project folder and type \npyinstaller -F project_name.py\nit spits out a .exe that only runs on 64 bit machines. Everything is tested and works perfectly well on 64 bit PCs, but I get an error on 32 bit PCs asking me to check whether or not the system is 32 bit or 64 bit.\nHow can this be possible, and how do I fix it?\nEDIT: It seems as though pyinstaller is accessing the python35 folder instead of the python35-32 folder when running. How do I stop this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2959,"Q_Id":46028132,"Users Score":0,"Answer":"It seems like your Pyinstaller is using the wrong version of Python, to make it use the correct one you probably want to use an explicit declaration of what Python interpreter you're using. \nIt's normally something like python -m pyinstaller {args} but other ones could be python3.5\nI'd recommend using a virtual environment so you're sure what Python interpreter you're using.","Q_Score":0,"Tags":"python,python-3.x,exe,pyinstaller","A_Id":46028466,"CreationDate":"2017-09-03T21:51:00.000","Title":"Making a 32 bit .exe from PyInstaller using PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a project that use Deep CNN to classify parking lot. My idea is to classify every space whether there is a car or not. and my question is, how do i prepare my image dataset to train my model ?\ni have downloaded PKLot dataset for training included negative and positive image.\nshould i turn all my data training image to grayscale ? should i rezise all my training image to one fix size? (but if i resize my training image to one fixed size, i have landscape and portrait image). Thanks :)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":822,"Q_Id":46038671,"Users Score":1,"Answer":"First detect the cars present in the image, and obtain their size and alignment. Then go for segmentation and labeling of the parking lot by fixing a suitable size and alignment.","Q_Score":0,"Tags":"python,computer-vision,artificial-intelligence,keras,training-data","A_Id":46039296,"CreationDate":"2017-09-04T13:59:00.000","Title":"how to prepare image dataset for training model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a project that use Deep CNN to classify parking lot. My idea is to classify every space whether there is a car or not. and my question is, how do i prepare my image dataset to train my model ?\ni have downloaded PKLot dataset for training included negative and positive image.\nshould i turn all my data training image to grayscale ? should i rezise all my training image to one fix size? (but if i resize my training image to one fixed size, i have landscape and portrait image). Thanks :)","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":822,"Q_Id":46038671,"Users Score":1,"Answer":"as you want use pklot dataset for training your machine and test with real data, the best approach is to make both datasets similar and homological, they must be normalized , fixed sized , gray-scaled and  parameterized shapes. then you can use Scale-invariant feature transform (SIFT) for image feature extraction as basic method.the exact definition often depends on the problem or the type of application. Since features are used as the starting point and main primitives for subsequent algorithms, the overall algorithm will often only be as good as its feature detector. you can use these types of image features based on your problem:\n\nCorners \/ interest points\nEdges\nBlobs \/ regions of interest points\nRidges\n...","Q_Score":0,"Tags":"python,computer-vision,artificial-intelligence,keras,training-data","A_Id":46153830,"CreationDate":"2017-09-04T13:59:00.000","Title":"how to prepare image dataset for training model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to install Python from cmd on Windows? If so, how to do it?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":66195,"Q_Id":46056161,"Users Score":1,"Answer":"For Windows\nI was unable to find a way to Download python using just CMD but if you have python.exe in your system then you can use the below Method to install it  (you can also make .bat file to automate it.)\n\nDownload the python.exe file on your computer from the official site.\n\nOpen CMD and change Your directory to the path where you have python.exe\n\nPast this code in your Command prompt make sure to change the name with your file version In the below code(e.g python-3.8.5.exe)\n\n\npython-3.6.0.exe \/quiet InstallAllUsers=1 PrependPath=1 Include_test=0\nIt will also set the path Variables.","Q_Score":7,"Tags":"python,cmd,installation,python-install","A_Id":63153547,"CreationDate":"2017-09-05T13:26:00.000","Title":"How to install Python using Windows Command Prompt","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how to handle not labeled parts of an image in image segmentation using TensorFlow. For example, my input is an image of height * width * channels. The labels are too of the size height * width, with one label for every pixel.\nSome parts of the image are annotated, other parts are not. I would wish that those parts have no influence on the gradient computation whatsoever. Furthermore, I am not interested in the network predicting this \u201cvoid\u201d label.\nIs there a label or a function for this? At the moment I am using tf.nn.sparse_softmax_cross_entropy_with_logits.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3236,"Q_Id":46097968,"Users Score":2,"Answer":"If I understand correctly you have a portion of each image with label void in which you are not interested at all. Since there is not a easy way to obtain the real value behind this void spots, why don't you map these points to background label and try to get results for your model? I would try in a preprocessing state to clear the data labels from this void label and substitute them with background label. \nAnother possible strategy ,if you don's simply want to map void labels to background, is to run a mask (with a continuous motion from top to bottom from right to left) to check the neigthbooring pixels from a void pixel (let's say an area of 5x5 pixels) and assign to the void pixels the most common label besides void.\nAlso you can always keep a better subset of the data, filtering data where the percentage of void labels is over a threshold. You can keep only images with no void labels, or more likeley you can keep images that have only under a threshold (e.g. 5%) of non-labeled points. In this images you can implement the beforementioned strategies for replacing the void labels.","Q_Score":21,"Tags":"python,tensorflow,neural-network,deep-learning,image-segmentation","A_Id":46203664,"CreationDate":"2017-09-07T13:42:00.000","Title":"TensorFlow: How to handle void labeled data in image segmentation?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a way to show html to a user if they call from a browser or just give them the API response in JSON if the call is made from an application, terminal with curl or generally any other way.\nI know a number of APIs do this and I believe Django's REST framework does this.\nI've been able to fool a number of those APIs by passing in my browser's useragent to curl so I know this is done using useragents, but how do I implement this? To cover every single possible or most useragents out there.\nThere has to be a file\/database or a regex, so that I don't have to worry about updating my useragent lists every few months, and worrying that my users on the latest browsers might not be able to access my website.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1500,"Q_Id":46099439,"Users Score":3,"Answer":"I know this post is a few years old, but since I stumbled upon it...\ntldr; Do not use the user agent to determine the return format unless absolutely necessary.  Use the Accept header or (less ideal) use a separate endpoint\/URL.\nThe standard and most future-proof way to set the desired return format for a specific endpoint is to use the Accept header.  Accept is explicitly designed to allow the client to state what response format they would like returned.  The value will be a standard MIME type.\nWeb browsers, by default, will send text\/html as the value of the Accept header.  Most Javascript libraries and frontend frameworks will send application\/json, but this can usually be explicitly set to something else (e.g. text\/xml) if needed.  All mobile app frameworks and HTTP client libraries that I am aware of have the ability to set this header if needed.\nThere are two big problems with trying to use user agent for simply determining the response format:\n\nThe list will be massive.  You will need to account for every possible client which needs to be supported today.  If this endpoint is used internally, this may not be an immediate problem as you might be able to enforce which user agents you will accept (may cause its own set of problems in the future, e.g. forcing your users to a specific version of Internet Explorer indefinitely) which will help keep this list small. If this endpoint is to be exposed externally, you will almost certainly miss something you badly need to accept.\nThe list will change.  You will need to account for every possible client which needs to be supported tomorrow, next week, next year, and in five years.  This becomes a self-induced maintenance headache.\n\nTwo notes regarding Accept:\n\nPlease read up on how to use the Accept header before attempting to implement against it.  Here is an actual example from this website: text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/avif,image\/webp,image\/apng,*\/*;q=0.8,application\/signed-exchange;v=b3;q=0.9.  Given this, I would return back HTML.\nThe value of the header can be *\/*, which basically just says \"whatever\" or \"I don't care\".  At that point, the server is allowed to determine the response format.","Q_Score":2,"Tags":"python,api,curl,user-agent","A_Id":69885034,"CreationDate":"2017-09-07T14:52:00.000","Title":"How to detect if a GET request is from a browser or not","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going to make a telegram bot in Python 3 which is a random chat bot. As I am new in telegram bots, I don't know how to join two different people in a chat bot. Is there a guide available for this?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":2352,"Q_Id":46101394,"Users Score":0,"Answer":"I am not sure to understand your question, can you give us what you pretend to do more explained?\nYou have a few options, creating a group and adding the bot to it.\nIn private chat you only can talk with a single user at a time.","Q_Score":1,"Tags":"python,python-3.x,chat,bots,telegram","A_Id":46103183,"CreationDate":"2017-09-07T16:39:00.000","Title":"how can i join two users in a telegram chat bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am going to make a telegram bot in Python 3 which is a random chat bot. As I am new in telegram bots, I don't know how to join two different people in a chat bot. Is there a guide available for this?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":2352,"Q_Id":46101394,"Users Score":0,"Answer":"You need to make a database with chatID as primary column. and another column as partner. which stores his\/her chat partner chatID.\nnow when a user sends a message to you bot you just need to check the database for that user and send the message to her chat partner.\nafter the chat is done you should empty partner fields of both users.\nAnd for the picking part. when a user wants to find a new partner, choose a random row from your database WHERE partnerChatID is Null and set them to first users ID and vise versa.","Q_Score":1,"Tags":"python,python-3.x,chat,bots,telegram","A_Id":46113831,"CreationDate":"2017-09-07T16:39:00.000","Title":"how can i join two users in a telegram chat bot?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For some reason, when I put nltk.download() in my .py file after import nltk, it doesn't run correctly in Spyder. It does run with the anaconda prompt though. Should I include it in my .py file? If so, how do I get Spyder to be ok with that? \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":46107591,"Users Score":0,"Answer":"I don't know what you want actually. If you just need the corpus in nltk, you don't have to put nltk.download() in you code but run nltk.download() once in the shell and download the corpus you need. Remind there is another function called nltk.download-gui(). You can try it in spyder or maybe you should change the graphics backend to Qt5 in your spyder settings if that's the problem.","Q_Score":0,"Tags":"python,nltk,spyder","A_Id":46107776,"CreationDate":"2017-09-08T02:07:00.000","Title":"Should I put ntlk.download() in my .py file?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I often find some functions defined like open(name[, mode[, buffering]]) and I know it means optional parameters.\nPython document says it's module-level function. When I try to define a function with this style, it always failed.\nFor example\ndef f([a[,b]]): print('123')\ndoes not work.\nCan someone tell me what the module-level means and how can I define a function with this style?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":1720,"Q_Id":46127941,"Users Score":1,"Answer":"Up to now, I still don't get an answer expected. Initially, when I saw this way of expression open(name[, mode[, buffering]]), I really want to know what does that mean. It means optional parameters obviously. At that moment, I found it may be a different way(different from normal way like f(a,b,c=None,d='balabala')) to define a function with optional parameters but not only tell us it's optional parameters. The benefit of this writing can help us use optional parameters but no default value, so I think it's a more clear and more simple way to define optional parameters.\nWhat I really want to know is about 2 things: 1. if we can define optional parameters using this way(no at present) 2. It will be nice if someone could explain what does the module-level function mean?\nI am really appreciated for the above answers and comments! THANKS A LOT","Q_Score":3,"Tags":"python","A_Id":46129112,"CreationDate":"2017-09-09T06:47:00.000","Title":"python how to define function with optional parameters by square brackets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I often find some functions defined like open(name[, mode[, buffering]]) and I know it means optional parameters.\nPython document says it's module-level function. When I try to define a function with this style, it always failed.\nFor example\ndef f([a[,b]]): print('123')\ndoes not work.\nCan someone tell me what the module-level means and how can I define a function with this style?","AnswerCount":3,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1720,"Q_Id":46127941,"Users Score":1,"Answer":"\"1. if we can define optional parameters using this way(no at present)\" \nThe square bracket notation not python syntax, it is Backus-Naur form - it is a documentation standard only.  \n\nA module-level function is a function defined in a module (including __main__) - this is in contrast to a function defined within a class (a method).","Q_Score":3,"Tags":"python","A_Id":46131685,"CreationDate":"2017-09-09T06:47:00.000","Title":"python how to define function with optional parameters by square brackets?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a MCMC model to simulate a changing beavior over time. I have to simulate one day with a time interval of 10-minutes. I have several observations of one day from N users in 144 intervals. So I have  U_k=U_1,...,U_N  U users with k ranging from 1 to N and for each user I have X_i=X_1,...X_t samples. Each user has two possible states, 1 and 0. I have understood that I have to build a transition probability matrix for each time step and then run the MCMC model. Is it right? But I did not understood how to build it in pyMC can anybody provided me suggestion?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":245,"Q_Id":46152636,"Users Score":1,"Answer":"Perhaps, assuming each user behaves the same way in a particular time interval, at each interval t we can get the matrix\n[ Pr 0->0 , Pr 1->0;\n  Pr 1->0 , Pr 1->0]\nwhere Pr x ->y = (the number of people in interval t+1 who are in state y AND who were in state x in interval t) divided by (the number of people who were in state x in interval t), i.e. the probability based on the sample that someone in the given time interval in state x (0 or 1) will transition to state y (0 or 1) in the next time interval.","Q_Score":1,"Tags":"python,pymc,markov-chains,mcmc","A_Id":46322688,"CreationDate":"2017-09-11T09:44:00.000","Title":"Monte Carlo Marcov Chain with pymc","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Very new to the PyDictionary library, and have had some trouble finding proper documentation for it. So, I've come here to ask:\nA) Does anybody know how to check if a word (in english) exists, using PyDictionary?\nB) Does anybody know of some more full documentation for PyDictionary?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1845,"Q_Id":46166696,"Users Score":1,"Answer":"If you read the code here in theory there is this:\nmeaning(term, disable_errors=False)\nso you should be able to pass True to avoid printing the error in case the word is not in the dictionary. I tried but I guess the version I installed via pip does not contains that code...","Q_Score":0,"Tags":"python","A_Id":53291691,"CreationDate":"2017-09-12T01:48:00.000","Title":"Using PyDictionary to check if a word exists","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"i see a lot of examples of how to use multiprocessing but they all talk about spawning workers and controlling them while the main process is alive. my question is how to control background workers in the following way:\nstart 5 worker from command line:\n\nmanager.py --start 5\n\nafter that, i will be able to list and stop workers on demand from command line:\n\nmanager.py --start 1    #will add 1 more worker\nmanager.py --list\nmanager.py --stop 2\nmanager.py --sendmessagetoall \"hello\"\nmanager.py --stopall\n\nthe important point is that manager.py should exit after every run. what i don't understand is how to get a list of already running workers from an newly created manager.py program and communicate with them.\nedit: Bilkokuya suggested that i will have (1)a manager process that manage a list of workers... and will also listen to incoming commands. and (2) a small command line tool that will send messages to the first manager process... actually it sounds like a good solution. but still, the question remains the same - how do i communicate with another process on a newly created command line program (process 2)? all the examples i see (of Queue for example) works only when both processes are running all the time","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":223,"Q_Id":46174679,"Users Score":0,"Answer":"The most portable solution I can suggest (although this will still involve further research for you), is to have a long-running process that manages the \"background worker\" processes. This shouldn't ever be killed off, as it handles the logic for piping messages to each sub process.\nManager.py can then implement logic to create communication to that long-running process (whether that's via pipes, sockets, HTTP or any other method you like). So manager.py effectively just passes on a message to the 'server' process \"hey please stop all the child processes\" or \"please send a message to process 10\" etc.\nThere is a lot of work involved in this, and a lot to research. But the main thing you'll want to look up is how to handle IPC (Inter-Process Communication). This will allow your Manager.py script to interact with an existing\/long-running process that can better manage each background worker.\nThe alternative is to rely fully on your operating system's process management APIs. But I'd suggest from experience that this is a much more error prone and troublesome solution.","Q_Score":0,"Tags":"python,multiprocessing,python-multiprocessing","A_Id":46175030,"CreationDate":"2017-09-12T10:59:00.000","Title":"using python multiprocessing to control independent background workers after the spawning process has been closed","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So .loc and .iloc are not your typical functions. They somehow use [ and ] to surround the arguments so that it is comparable to normal array indexing. However, I have never seen this in another library (that I can think of, maybe numpy as something like this that I'm blanking on), and I have no idea how it technically works\/is defined in the python code.\nAre the brackets in this case just syntactic sugar for a function call? If so, how then would one make an arbitrary function use brackets instead of parenthesis? Otherwise, what is special about their use\/defintion Pandas?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":3012,"Q_Id":46176656,"Users Score":2,"Answer":"Underneath the covers, both are using the __setitem__ and __getitem__ functions.","Q_Score":19,"Tags":"python,pandas,pandas-loc","A_Id":46176863,"CreationDate":"2017-09-12T12:40:00.000","Title":"Why\/How does Pandas use square brackets with .loc and .iloc?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm trying to connect to a PostgreSQL database on Google Cloud using SQLAlchemy. Making a connection to the database requires specifying a database URL of the form:  dialect+driver:\/\/username:password@host:port\/database\nI know what the dialect + driver is (postgresql), I know my username and password, and I know the database name. But I don't know how to find the host and port on the Google Cloud console. I've tried using the instance connection name, but that doesn't seem to work. Anyone know where I can find this info on Google Cloud?","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6507,"Q_Id":46178062,"Users Score":3,"Answer":"Hostname is the Public IP address.","Q_Score":3,"Tags":"python,postgresql,google-cloud-platform,google-cloud-storage,google-cloud-sql","A_Id":64040093,"CreationDate":"2017-09-12T13:42:00.000","Title":"What is the hostname for a Google Cloud PostgreSQL instance?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used Beautiful Soup with great success when crawling single pages of a site, but I have a new project in which I have to check a large list of sites to see if they contain a mention or a link to my site. Therefore, I need to check the entire site of each site.\nWith BS I just don't know yet how to tell my scraper that it is done with a site, so I'm hitting recursion limits. Is that something Scrapy handles out of the box?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":344,"Q_Id":46183843,"Users Score":2,"Answer":"Scrapy uses a link follower to traverse through a site, until the list of available links is gone.  Once a page is visited, it's removed from the list and Scrapy makes sure that link is not visited again.\nAssuming all the websites pages have links on other pages, Scrapy would be able to visit every page of a website. \nI've used Scrapy to traverse thousands of websites, mainly small businesses, and have had no problems.  It's able to walk through the whole site.","Q_Score":1,"Tags":"python,web-scraping,beautifulsoup,scrapy","A_Id":46185425,"CreationDate":"2017-09-12T19:15:00.000","Title":"Does Scrapy 'know' when it has crawled an entire site?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have my Python script and my requirements.txt ready.\nWhat I want to do is to get all the packages listed in the \"requirements.txt\" into a folder. In the bundle, I'd for example have the full packages of \"pymysql\", \"bs4\" as well as all their dependencies.\nI have absolutely no idea how to do this. Could you help me please? I am stuck and I am really struggling with this.\nI am using Python 3.6\nI am using \"pip download -r requirements.txt\" but it's not downloading the dependencies and outputs me only.whl files whereas I'm looking for \"proper\" folders..","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":244,"Q_Id":46184423,"Users Score":0,"Answer":"Couldn't you just use a virtual environment (virtualenv folder_name) and then activate it unless you are looking for something else. \nOnce it's activated install of your libraries and drown its there using pip install","Q_Score":0,"Tags":"python,python-3.x,package,bundle","A_Id":46187452,"CreationDate":"2017-09-12T19:57:00.000","Title":"Bundle all packages required from a Python script into a folder","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using django to create a blog. In my model I am using a text field for my blog content. But I am unable to insert any image or a clickable link. How to add links(clickable) and insert images?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":814,"Q_Id":46194582,"Users Score":0,"Answer":"there is no thing like clickable link in Database.you can put link as text and while importing it to your HTML use , and for Images there are two options. either you put your image path name in database or change TextField in models to FileField.","Q_Score":0,"Tags":"python,django,django-models,django-admin","A_Id":46196573,"CreationDate":"2017-09-13T10:03:00.000","Title":"how to add links and images in text field of django admin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following scenario. Data (packets in this case) are received processed by a Python function in real-time as each datum streams by. So each datum is received and translated into a python object. There is a light-weight algorithm done on that object which returns an output (small dictionary). Then the object is discarded and the next one is handled. I have that program running. \nNow, for each object the algorithm will produce a small dictionary of output data. This dictionary needs to be processed (also in real time) by a separate, second algorithm. I envision my code running two processes. I need to have the second process \"listen\" for the outputs of the first. \nSo how do I write this second algorithm in python so it can listen for and accept the data that is produced by the first? for a concrete example, suppose the first algorithm applies the timestamp, then passes to a buffer, and the second algorithm listens-- it grabs from the buffer and processes it. If there is nothing in the buffer, then as soon as something appears it processes it.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":395,"Q_Id":46202639,"Users Score":0,"Answer":"If you need to use different processes (as opposed to multiple functions in a single process), perhaps a messaging queue would work well for you? Whereby your first process would do whatever it does and put the results in a message queue, which your second process is listening to.\nThere are obviously a lot of options available but based on your description, this sounds like a reasonable approach.","Q_Score":0,"Tags":"python,multiprocessing,buffer","A_Id":46202744,"CreationDate":"2017-09-13T16:31:00.000","Title":"How to send, buffer, and receive Python objects between two python programs?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We are using RIDE IDE and are trying to integrate TestRail and JIRA. We have downloaded the TestRail API python file (testrail.py), but we are not able to import it in our project in RIDE.\nCan we know how to implement the same.\nIs there any steps or tutorial video for integrating TestRail and JIRA in RIDE ?\nWe are using RIDE 1.5.2.1 running on Python 2.7.12\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1211,"Q_Id":46214501,"Users Score":1,"Answer":"If you want to use a python library in a robot test, you will need to create your own library that provides keywords that use the library. You can't just import any random python library and expect it to work like a robot keyword library.","Q_Score":0,"Tags":"python,jira,robotframework,testrail,robotframework-ide","A_Id":46220408,"CreationDate":"2017-09-14T08:47:00.000","Title":"TestRail and JIRA integration with Robot Framework (RIDE IDE)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Selenium IDE is a very useful tool to create Selenium tests quickly. Sadly, it has been unmaintained for a long time and now not compatible with new Firefox versions.\nHere is my work routine to create Selenium test without Selenium IDE:\n\nOpen the Inspector\nFind and right click on the element\nSelect Copy CSS Selector\nPaste to IDE\/Code editor\nType some code\nBack to step 2\n\nThat is a lot of manual work, switching back and for. How can I write Selenium tests faster?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":116,"Q_Id":46235088,"Users Score":0,"Answer":"The best way is to learn how your app is constructed, and to work with the developers to add an id element and\/or distinctive names and classes to the items you need to interact with. With that, you aren't dependent on using the fragile xpaths and css paths that the inspector returns and instead can create short, concise expressions that will hold up even when the underlying structure of the page changes.","Q_Score":0,"Tags":"python,selenium,automated-tests,selenium-ide,web-testing","A_Id":46241635,"CreationDate":"2017-09-15T08:30:00.000","Title":"Since Selenium IDE is unmaintained, how to write Selenium tests quickly?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to estimate a logit model with individual fixed effects in a panel data setting, i.e. a conditional logit model, with python.\nI have found the pylogit library. However, the documentation I could find, explained how to use the conditional logit model for multinomial models with varying choice attributes. This model does not seem to be the same use case as a simple binary panel model.\nSo my questions are: \nDoes pylogit allow to estimate conditional logits for panel data? \nIf so, is there documentation? \nIf not, are there other libraries that allow you to estimate this type of model?\nAny help would be much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":2528,"Q_Id":46244095,"Users Score":4,"Answer":"I'm the creator of pylogit.\nI don't have built in utilities for estimating conditional logits with fixed effects. However, you can use pylogit to estimate this model. Simply\n\nCreate dummy variables for each decision maker. Be sure to leave out one decision maker for identification.\nFor each created dummy variable, add dummy variable's column name to the one's utility specification.","Q_Score":1,"Tags":"python","A_Id":48470963,"CreationDate":"2017-09-15T16:34:00.000","Title":"conditional logit for panel data in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"So I have a directory called \/src, which has several contents:\na.png, file.text, \/sub_dir1, \/sub_dir2\nI want to copy these contents into destination directory \/dst such that the inside of \/dst looks like this (assuming \/dst is previously empty):\na.png, file.text, \/sub_dir1, \/sub_dir2\nI have tried shutil.copytree(src, dst), but when I open up \/dst I see:\n\/src\nwhich, although contains everything I want, should not be there, as I do not want the \/src directory itself copied over, only its inner contents. Does anyone know how to do this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":46245240,"Users Score":0,"Answer":"I made a mistake with the file pathways I inputted into the copytree function. The function works as expected, in the way I mentioned I wanted it to in my question.","Q_Score":3,"Tags":"python,directory,shutil,copytree","A_Id":46245531,"CreationDate":"2017-09-15T17:58:00.000","Title":"Using shutil library to copy contents of a directory from src to dst, but not the directory itself","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set up a gameshow type system where I have 5 stations each having a monitor and a button. The monitor will show a countdown timer and various animations. My plan is to program the timer, animations, and button control through pygame and put a pi at each station each running it's own pygame script, waiting for the start signal (can be keypress or gpio).\nI'm having trouble figuring out how to send that signal simultaneously to all stations. Additionally I need to be able to send a 'self destruct' signal to each station to stop the timer. I can ssh into each station but I don't know how to send keypress\/gpio signals through the command line to a running pygame script..\nI was thinking of putting a rf receiver on each pi, all at the same wavelength and using a common transmitter, but that seems very hacky and not necessarily so simultaneous.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":114,"Q_Id":46246197,"Users Score":0,"Answer":"This ought to work ... but it's purely hypothetical:\nUse a parallel circuit to set a pin \"high\" and \"low\" - \"high\" means start the timer; \"low\" means stop the timer.  The next \"high\" resets and restarts the timer.\nYou could use two circuits.  One for start\/stop and one for \"reset\".  You'd probably need some code to not reset while running.\nThe parallel circuit can be controlled manually (for testing) or automatically (perhaps with a master program?).","Q_Score":0,"Tags":"python,raspberry-pi,pygame","A_Id":46246348,"CreationDate":"2017-09-15T19:17:00.000","Title":"Control Multiple Raspberry Pis Remotely \/ Gameshow Type System","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to extract reviews from public facebook pages like airline page, hospital page, to perform sentiment analysis. I have app id and app secret id which i generated from facebook graph API using my facebook account, But to extract the reviews I need page access token and as I am not the owner\/admin of the page so I can not generate that page access token. Is any one know how to do it or it requires some paid service? \nKindly help.\nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":259,"Q_Id":46252155,"Users Score":1,"Answer":"Without a Page Token of the Page, it is impossible to get the reviews\/ratings. You can only get those for Pages you own. There is no paid service either, you can only ask the Page owners to give you access.","Q_Score":0,"Tags":"r,python-2.7,facebook-graph-api","A_Id":46254610,"CreationDate":"2017-09-16T09:07:00.000","Title":"How to extract reviews from facebook public page without page access token?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a program that asks the user for, in this example, lets say a username and password, then store this (I assume in a text file). The area I am struggling with is how to allow the user to update this their password stored in the text file? I am writing this in Python.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3881,"Q_Id":46267910,"Users Score":0,"Answer":"Because you've asked to focus on how to handle the updates in a text file, I've focused on that part of your question.  So, in effect I've focused on answering how would you go about having something that changes in a text file when those changes impact the length and structure of the text file.  That question is independent of the thing in the text file being a password.\nThere are significant concerns related to whether you should store a password, or whether you should store some quantity that can be used to verify a password.  All that depends on what you're trying to do, what your security model is, and on what else your program needs to interact with.  You've ruled all that out of scope for your question by asking us to focus on the text file update part of the problem.\nYou might adopt the following pattern to accomplish this task:\n\nAt the beginning see if the text file is present.  Read it and if so assume you are doing an update rather than a new user\nAsk for the username and password.  If it is an update prompt with the old values and allow them to be changed\nWrite out the text file.\n\nMost strategies for updating things stored in text files involve rewriting the text file entirely on every update.","Q_Score":0,"Tags":"python,text-files","A_Id":46267961,"CreationDate":"2017-09-17T19:14:00.000","Title":"Storing a username and password, then allowing user update. Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a program that asks the user for, in this example, lets say a username and password, then store this (I assume in a text file). The area I am struggling with is how to allow the user to update this their password stored in the text file? I am writing this in Python.","AnswerCount":4,"Available Count":2,"Score":-0.0996679946,"is_accepted":false,"ViewCount":3881,"Q_Id":46267910,"Users Score":-2,"Answer":"Is this a single user application that you have? If you can provide more information one where you're struggling \nYou can read the password file (which has usernames and passwords)\n- When user authenticate, match the username and password to the combination in text file\n- When user wants to change password, then user provides old and new password. The username and old password combination is compared to the one in text file and if matches, stores the new","Q_Score":0,"Tags":"python,text-files","A_Id":46267983,"CreationDate":"2017-09-17T19:14:00.000","Title":"Storing a username and password, then allowing user update. Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to execute my webbrowser (opera) from python code, how can i get it?  \nPython version 3.6, OS MS Windows 7","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":737,"Q_Id":46268174,"Users Score":0,"Answer":"You can use Selenium to launch web browser through python.","Q_Score":0,"Tags":"python,python-3.x,webbrowser-control,opera","A_Id":46268349,"CreationDate":"2017-09-17T19:41:00.000","Title":"How can i execute my webbrowser in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So if I have two timedelta values such as 21:00:00(PM) as start time and 03:00:00 (AM) as end time and I wish to compare 23:00:00 within this range, to see whether it falls between these two, without having the date value, how could I do so?\nSo although in this example it will see 23:00:00 larger than 21:00:00 it will not see 23:00:00 less than 03:00:00, which is my issue. I need to be able to compare time on a 24 hour circle using timedelta or a conversion away from timedelta is fine. \nNote: The start\/end time ranges can change, so any could be AM\/PM. So I cannot just add a day to the end time for example.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":972,"Q_Id":46289679,"Users Score":0,"Answer":"It becomes \"difficult\" only when endtime is smaller than starttime (IE, next day). But, you could have a test, if this is the case, add 12 hours to all three items, so now you can easily test and verify that 11am is between 9am and 3pm.","Q_Score":0,"Tags":"python,time,compare,timedelta","A_Id":46289757,"CreationDate":"2017-09-18T23:43:00.000","Title":"Checking if time-delta value is in range past midnight","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have the following problem.\nI need to replace a file with another one. As far as the new is transfered over the network, owner and group bits are lost. \nSo I have the following idea. To save current permissions and file owner bits and than after replacing the file restore them.\nCould you please suggest how to do this in Python or maybe you could propose a better way to achieve this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":120,"Q_Id":46293283,"Users Score":0,"Answer":"You can use rsync facility to copy the file to remote location with same permissions. A simple os.system(rsync -av SRC <DEST_IP>:~\/location\/) call can do this. Another methods include using a subprocess.","Q_Score":0,"Tags":"python,python-2.7,file-permissions,file-ownership","A_Id":46293476,"CreationDate":"2017-09-19T06:23:00.000","Title":"Python save file permissions & owner\/group and restore later","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use Pycharm for a while now and I'm getting really annoyed that my Pycharm interpreter settings always resets for some reason.\nMeaning that whenever I open up a new\/old project it will always tell me that:\n\nNo Python interpreter configured...\n\neven after I change and apply the settings in\nFile > Settings > Project: ProjectName > Project Interpreter\nor\nFile > Default Settings > Project Interpreter.\n(These changes only apply for as long as Pycharm is open. Once it's closed I need to repeat the whole procedure, which is my problem here.)\nThen I noticed that all my projects that I open for some reason end up being opened in the tmp folder.\n(e.g. \"\/tmp\/Projectname.py\")\nWhich is also the reason why I cant open recent projects via the menu.\nSo my question is, how do I actually make Pycharm save my interpreter settings and stop asking me about it.\nI know that there seems to be similar questions about it, but either they are not solved or the solution doesn't work. And I hope that this tmp folder thing might be of use to solve this problem.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":583,"Q_Id":46293320,"Users Score":2,"Answer":"how do I actually make Pycharm save my interpreter settings and stop asking me about it.\n\nI was having a similar issue when I used PyCharm Community 2017.3 on Ubuntu 16.04 for the first time. The solution was to open the project folder rather than a specific script.","Q_Score":0,"Tags":"python-3.x,ubuntu,pycharm","A_Id":47638054,"CreationDate":"2017-09-19T06:26:00.000","Title":"Pycharm default interpreter and tmp working directory on Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm trying to run python code from Sublime Text 3, but I'm not sure how. Even if it was only from the console, that would be fine. Anybody know how???","AnswerCount":8,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":51441,"Q_Id":46306331,"Users Score":13,"Answer":"Tools->Build System->Python\nor Ctrl+B","Q_Score":3,"Tags":"python,sublimetext","A_Id":51280447,"CreationDate":"2017-09-19T17:18:00.000","Title":"How to run python code in Sublime Text 3?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Django-Storages provides an S3 file storage backend for Django.  It lists\nAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as required settings.  If I am using an AWS Instance Profile to provide S3 access instead of a key pair, how do I configure Django-Storages?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":1069,"Q_Id":46307447,"Users Score":1,"Answer":"The docs now explain this:\n\nIf AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set, boto3 internally looks up IAM credentials.","Q_Score":3,"Tags":"django,amazon-s3,boto3,python-django-storages","A_Id":61942402,"CreationDate":"2017-09-19T18:28:00.000","Title":"Use Django-Storages with IAM Instance Profiles","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to all the tensorflow and Python programming and have installed tensorflow through pip and virtualenv but now I read that in order to use Spyder for Python it is best to use Anaconda. I know that tf can be installed through conda as well but how do I go about it now? Do I have to completely remove the existing installations first and if yes, can someone explain in detail which and how I can do it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":633,"Q_Id":46307874,"Users Score":0,"Answer":"Yes, after a short reading into the topic, I simply unistalled tf using sudo pip uninstall tensorflow within my virtualenv and then deactivated the virtualenv. Don't know how to really uninstall the virtualenv as well but I guess that is already enough then and I can proceed with the installation of Anaconda?\nI also have installed some additional packages like mathplotlib, ipython etc. but I can keep them as well without problems?\nThanks","Q_Score":1,"Tags":"python,tensorflow,pip,anaconda,virtualenv","A_Id":46308361,"CreationDate":"2017-09-19T18:54:00.000","Title":"Completely removing Tensorflow, pip and virtualenv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to all the tensorflow and Python programming and have installed tensorflow through pip and virtualenv but now I read that in order to use Spyder for Python it is best to use Anaconda. I know that tf can be installed through conda as well but how do I go about it now? Do I have to completely remove the existing installations first and if yes, can someone explain in detail which and how I can do it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":633,"Q_Id":46307874,"Users Score":0,"Answer":"Just install Anaconda it will take care of everything. Uninstalling the existing ones is up to you, they wont harm anything.","Q_Score":1,"Tags":"python,tensorflow,pip,anaconda,virtualenv","A_Id":46308280,"CreationDate":"2017-09-19T18:54:00.000","Title":"Completely removing Tensorflow, pip and virtualenv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a program in python that can read emails, my program can now read emails from GMAIL even with attachment but my program can't read the email that was sent from Apple Mail. \nUnlike the email that I sent from GMAIL when I use Message.get_payload() in apple mail it does not have a value. I'm a newbie on python and this is my first project so please bear with me. Thank you in advance.\nNote: The email I sent from Apple has attachment on it.\nUpdate: I can now read the text inside the email my only problem now is how to get the attachment since when I loop all the payloads since it is multipart it only prints the text inside and this \n\"[<email.message.Message object at 0x000001ED832BF6D8>, <email.message.Message object at 0x000001ED832BFDD8>]\"","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":471,"Q_Id":46314148,"Users Score":0,"Answer":"This is okay now It seems like the content type of the email i sent from Apple Mail was multipart which includes a \"text\/plain\" which contains the text inside my email and \"multipart\/related\" that contains the image i attached. So i just needed to check if the email is a multipart if so then loop it to print all payloads.","Q_Score":0,"Tags":"python,email,apple-mail","A_Id":46314807,"CreationDate":"2017-09-20T05:47:00.000","Title":"Python: Apple Email Content","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am developing a program using C#, but I just figured out that what I am going to program is very very difficult in C# yet easy in Python. So what I want to do is make a .PYD file and use it in C# program, but I don't know how. I've been searching about it but I couldn't find anything. \nSo these are my questions: How do I use .PYD file in C#? I know that .PYD files are similar to .DLL files, so are .PYD files still usable in computers that have no Python installed?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2953,"Q_Id":46317830,"Users Score":2,"Answer":"A .pyd file IS a DLL but with function init*() where * is the name of your .pyd file. For example, spam.pyd has a function named initspam(). They are not just similar, but the same! They are usable on PCs without Python.\n\nDo not forget: builtins will NOT be available. Search for them in C, add them as an extern in your Cython code and compile!","Q_Score":3,"Tags":"c#,python,pyd","A_Id":46322006,"CreationDate":"2017-09-20T09:09:00.000","Title":"Using .PYD file in C#?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i am new to serverless framework and aws, and i need to create a lambda function on python that will send email whenever an ec2 is shut down, but i really don't know how to do it using serverless. So please if any one could help me do that or at least give me some tracks to start with.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":203,"Q_Id":46322899,"Users Score":3,"Answer":"You can use CloudWatch for this.\nYou can create a cloudwatch rule\n\nService Name -  Ec2 \nEvent Type - EC2 Instance change notification\nSpecific state(s) - shutting-down\n\nThen use an SNS target to deliver email.","Q_Score":1,"Tags":"python,amazon-web-services,amazon-ec2,aws-lambda,serverless-framework","A_Id":46323508,"CreationDate":"2017-09-20T13:05:00.000","Title":"send email whenever ec2 is shut down using serverless","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've created with python and kivy an android app that works offline, app shows landscape photos, how can i open my app only when wifi is enabled? to let my app upload ads,have patience with me im new Thank You.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":127,"Q_Id":46347262,"Users Score":0,"Answer":"There's a dirty method though.. try requesting google.com or any other reliable website in the background with urllib or requests or socket, if its not getting any reply it must mean that system is not connected to internet","Q_Score":0,"Tags":"python,kivy","A_Id":63662212,"CreationDate":"2017-09-21T14:59:00.000","Title":"How can i open my app only when wifi is enabled for upload Ads?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I using jupyter notebook and graphlab \/ turi for tfidf-nearest_neighbors model, which works fine so far.\nHowever, when I query the model like \ntfidf_model.query(Test_AD)\nI always just get the head - [5 rows x 4 columns]\nI am supposed to use \"print_rows(num_rows=m, num_columns=n)\" to print more rows and columns like:\ntfidf_model.query(Test_AD).print_rows(num_rows=50, num_columns=4)\nhowever, when I used it, I dont get any rows anymore, only the summary field:\nStarting pairwise querying.\n+--------------+---------+-------------+--------------+\n| Query points | # Pairs | % Complete. | Elapsed Time |\n+--------------+---------+-------------+--------------+\n| 0            | 1       | 0.00519481  | 13.033ms     |\n| Done         |         | 100         | 106.281ms    |\n+--------------+---------+-------------+--------------+\nThat's it. No error message, nothing. Any Ideas, how to get all\/ more rows?\nI tried to convert into pandas or .show() command etc., didnt help.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1900,"Q_Id":46347289,"Users Score":0,"Answer":"ok, well, seems like I have to define the number or neighbours with:\ntfidf_model.query(Test_AD, k=100).show()\nso I can get a list of first 100 in the canvass.","Q_Score":0,"Tags":"python-2.7,jupyter-notebook,rows,nearest-neighbor,graphlab","A_Id":46347870,"CreationDate":"2017-09-21T15:00:00.000","Title":"print_rows(num_rows=m, num_columns=n) in graphlab \/ turi not working","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"So, I'm programming in Python 3.2 on android (the app I'm using is QPython3) and I wonder if I could make a game\/app with a graphic interface for android, using only a smartphone. Is it possible? If yes, how do I do that?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3395,"Q_Id":46376713,"Users Score":0,"Answer":"Look at using Linux (a different Kernal) distro on your phone. Many will basically act as a pc, just lacking power. I'm sure there is one you can run regular Python with. Then you may also look at renpy for porting it to android, or even kivy but i'm thinking kivy would be very different than anything you have, and require learning a new language basically.\nSadly changing the OS on your phone is the only option I can think of, and probably the best. I cannot imagine any frameworks for android to be as vast as those that have been developed for PC. You may be able to find some hacked, port version of something that may help, a tool something idk.","Q_Score":2,"Tags":"android,python-3.x,kivy,2d-games,qpython3","A_Id":61050929,"CreationDate":"2017-09-23T06:22:00.000","Title":"Pygame\/Kivy on Android?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm focusing on the special case where A is a n x d matrix (where k < d) representing an orthogonal basis for a subspace of R^d and b is known to be inside the subspace.\nI thought of using the tools provided with numpy, however they only work with square matrices. I had the approach of filling in the matrix with some linearly independent vectors to \"square\" it and then solve, but I could not figure out how to choose those vectors so that they will be linearly independent of the basis vectors, plus I think it's not the only approach and I'm missing something that can make this easier.\nis there indeed a simpler approach than the one I mentioned? if not, how indeed do I choose those vectors that would complete Ainto a square matrix?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":23050,"Q_Id":46377331,"Users Score":0,"Answer":"Can use:\n\nnp.linalg.lstsq(x, y)\nnp.linalg.pinv(X) @ y\nLinearRegression().fit(X, y)\n\nWhere 1 and 2 are from numpy and 3 is from sklearn.linear_model.\nAs a side note you will need to concatenate ones(use np.ones_like) in both 1 and 2 to represent the bias from the equation y = ax + b","Q_Score":8,"Tags":"python,numpy,matrix","A_Id":72120529,"CreationDate":"2017-09-23T07:49:00.000","Title":"solving Ax =b for a non-square matrix A using python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"can I get some advice, how to make mechanism for inserts, that will check if the values of PK is used? \nIf it is not used in the table, it will insert row with number. If it is used, it will increment value and check next value if it's used. So on...","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":26,"Q_Id":46380101,"Users Score":0,"Answer":"This is too long for a comment.\nYou would need a trigger in the database to correctly implement this functionality.  If you try to do it in the application layer, then you will be subject to race conditions in a multi-client environment.\nWithin Oracle, I would recommend just using an auto-generated column for the primary key.  Don't try inserting it yourself.  In Oracle 12C, you can define this directly using generated always as.  In earlier versions, you need to use a sequence to define the numbers and a trigger to assign them.","Q_Score":0,"Tags":"python,oracle,cx-oracle","A_Id":46380171,"CreationDate":"2017-09-23T13:31:00.000","Title":"cx_oracle PK autoincrementarion","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I installed jupyter notebook along with anaconda python as the only python on my PC (Windows 10). However I recently installed python 3.6.2 and I wonder if I can somehow add it to jupyter so as I can use them changeably. \nI remember having both on my other machine when I installed python first and then after that I installed the whole anaconda package with the jupyter notebook (so I had python 3 and python(conda) option for kernels).\nSo how can I add to jupyter?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":6917,"Q_Id":46383189,"Users Score":0,"Answer":"Simple, just find where the script jupyter-notebook resides, for example ~\/.local\/bin if you installed it locally.\nThen just edit the first line to:   #!\/usr\/bin\/python3 will be fine.","Q_Score":2,"Tags":"python,jupyter-notebook","A_Id":47618302,"CreationDate":"2017-09-23T18:53:00.000","Title":"How do I add a python3 kernel to my jupyter notebook?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to understand the way Gevent\/Greenlet chooses the next greenlet to be run. Threads use the OS Scheduler. Go Runtime uses 2 hierarchical queues. \nBy default, Gevent uses libevent to its plumbling. But how do libevent chooses the next greenlet to be ran, if many are ready to?\nIs it random?\nI already had read their docs and had a sight on the sourcecode. Still do not know.\nUpdated: Text changed to recognize that Gevent uses libevent. The question still applies over libevent.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":46384607,"Users Score":0,"Answer":"It's underlying dispatch model, is the event loop in libevent, which uses the event base, which monitors for the different events, and reacts to them accordiningly, then from what I gleamed , it will take the greenlets do some fuckery with semaphores, and then dispatch it onto libevent.","Q_Score":0,"Tags":"python,concurrency,gevent,cpython,greenlets","A_Id":46387137,"CreationDate":"2017-09-23T21:52:00.000","Title":"How do libevent chooses the next Gevent greenlet to run?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace?","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":5816,"Q_Id":46384630,"Users Score":2,"Answer":"I am not sure how you try to run this program, but you can just go to menu View \u2192 Terminal and type python your_program.py in TERMINAL from the folder where your program is located.\nAnd please check if you have not accidentally installed Visual\u00a0Studio instead of Visual Studio Code (those are two completely different programs).","Q_Score":3,"Tags":"python,visual-studio-code","A_Id":46384705,"CreationDate":"2017-09-23T21:55:00.000","Title":"How can I create a workspace in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":5816,"Q_Id":46384630,"Users Score":0,"Answer":"VSCode workspaces are basically just folders. If you open an empty folder in VSCode it will get treated as a workspace, and you can add any scripts you want to it. VSCode will create a new hidden folder in the folder you chose that will hold settings for the workspace. For python, make sure you install the python extension (just grab the one with the most downloads) and follow the instructions there to make sure your python environment is properly configured. If you're using git, you might want to add that hidden folder to the gitignore.","Q_Score":3,"Tags":"python,visual-studio-code","A_Id":69560073,"CreationDate":"2017-09-23T21:55:00.000","Title":"How can I create a workspace in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I happen to have a list y = [y1, y2, ... yn]. I need to generate random numbers ai such that 0<=ai<=c (for some constant c) and sum of all ai*yi = 0. Can anyone help me out on how to code this in python? Even pseudocode\/logic works, I am having a conceptual problem here. While the first constraint is easy to satisfy, I cannot get anything for the second constraint. \nEDIT: Take all yi = +1 or -1, if that helps, but a general solution to this would be interesting.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1846,"Q_Id":46392625,"Users Score":0,"Answer":"If you need random integer values between 0 and c use random.randint(0, c). For random floating point values between 0 anc c use random.uniform(0, c).","Q_Score":1,"Tags":"python,random","A_Id":46392727,"CreationDate":"2017-09-24T17:04:00.000","Title":"Generating Random Numbers Under some constraints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I happen to have a list y = [y1, y2, ... yn]. I need to generate random numbers ai such that 0<=ai<=c (for some constant c) and sum of all ai*yi = 0. Can anyone help me out on how to code this in python? Even pseudocode\/logic works, I am having a conceptual problem here. While the first constraint is easy to satisfy, I cannot get anything for the second constraint. \nEDIT: Take all yi = +1 or -1, if that helps, but a general solution to this would be interesting.","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1846,"Q_Id":46392625,"Users Score":0,"Answer":"I like splitting this problem up. Note that there must be some positive and some negative values of y (otherwise sum(ai*yi) can't equal zero). \n\nGenerate random positive coefficients ai for the negative values of y, and construct the sum of ai*yi over only the negative values of y (let's say this sum is -R). \nAssuming there are \"m\" remaining positive values, choose random numbers for the first m-1 of the ai coefficients for positive yi values, according to ai = uniform(R\/(m*max(y)).\nUse your constraint to determine am = (R-sum(aiyi | yi> 0))\/ym. Notice that, by construction, all ai are positive and the sum of aiyi = 0.\nAlso note that multiplying all ai by the same amount k will also satisfy the constraint. Therefore, find the largest ai (let's call it amax), and if amax is greater than c, multiply all values of ai by c\/(amax + epsilon), where epsilon is any number greater than zero.\n\nDid I miss anything?","Q_Score":1,"Tags":"python,random","A_Id":46440005,"CreationDate":"2017-09-24T17:04:00.000","Title":"Generating Random Numbers Under some constraints","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. \nDoes somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.","AnswerCount":3,"Available Count":3,"Score":0.1973753202,"is_accepted":false,"ViewCount":995,"Q_Id":46394954,"Users Score":3,"Answer":"There are ways of doing this in music21 (audioSearch module) but it's more of a proof of concept and not for production work. There are much better software packages for analyzing audio (try sonic visualizer or jMIR or a commercial package). Music21's strength is in working with scores.","Q_Score":3,"Tags":"python,mp3,music21","A_Id":46396673,"CreationDate":"2017-09-24T21:16:00.000","Title":"Is it possible to analyze mp3 file using music21?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. \nDoes somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.","AnswerCount":3,"Available Count":3,"Score":1.2,"is_accepted":true,"ViewCount":995,"Q_Id":46394954,"Users Score":4,"Answer":"No, this is not possible. Music21 can only process data stored in musical notation data formats, like MIDI, MusicXML, and ABC.\nConverting a MP3 audio file to notation is a complex task, and isn't something that software can reliably accomplish at this point.","Q_Score":3,"Tags":"python,mp3,music21","A_Id":46395044,"CreationDate":"2017-09-24T21:16:00.000","Title":"Is it possible to analyze mp3 file using music21?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. \nDoes somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":995,"Q_Id":46394954,"Users Score":1,"Answer":"Check out librosa. It can read mp3s and give some basic info such as tempo.","Q_Score":3,"Tags":"python,mp3,music21","A_Id":46417595,"CreationDate":"2017-09-24T21:16:00.000","Title":"Is it possible to analyze mp3 file using music21?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a strange problem at my iphone, \nwhen  I remove the mdm profile, \nthe camera always be disabled, it's not come back , the mdm profile is only one , how to reset it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":27,"Q_Id":46397244,"Users Score":0,"Answer":"Did you remove the Profile from the Device settings or through the Apple Configurator?\nMany times even if you remove profile from Device settings, its still there in the Device.\nYou can see if its still there in the Device using Apple Configurator and try removing it from there.","Q_Score":0,"Tags":"python,iphone,mdm","A_Id":46548859,"CreationDate":"2017-09-25T03:36:00.000","Title":"remove the profile but the camera always be disabled","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Lets say I have a model called Thingy, and there are 20 Thingies in my database. When I retrieve all Thingies, serializer.to_represenatation() is executed 20 times. This is good.\nHowever, when I retrieve just a single Thingy from \/api\/thingies\/1, I observe that serializer.to_representation() is executed four (4!!!) times.\nWhy does this happen, and how can I get away with just one call to to_representation()?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":229,"Q_Id":46421437,"Users Score":3,"Answer":"That's because you are using the browsable API.\nJSON renderer will only call it once.\nBrowsable API needs several calls:\n\nfor the result itself\nfor the raw data tab when you can modify a resource through PUT\nfor the raw data tab when you can modify a resource through PATCH\nfor the HTML form tab","Q_Score":0,"Tags":"django,python-3.x,django-rest-framework,django-serializer","A_Id":46424881,"CreationDate":"2017-09-26T08:29:00.000","Title":"Why does retrieving a single resource execute serializer.to_representation() multiple times in Django REST framework?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using a WPF application that has custom stack panel, which is basically a list. The item in the list is exactly the same so I'm not able to select a specific text to uniquely identify the elements. And some other values such as time are dynamic.\nIs there a way for me to get the list of elements returned. I know it's possible because the error was thrown, ElementAmbiguousError state the count.\nIf I could do that, then from that list I can use the index and validate what I need.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6545,"Q_Id":46432544,"Users Score":3,"Answer":"You can add found_index=0 or other index to the window specification object. This is the first way to disambiguate the search.\nAlso there are methods .children() and .descendants() with additional params like control_type or title (as I remember title should work), but some window specification params are not supported in these methods.","Q_Score":1,"Tags":"python,automation,pywinauto","A_Id":46433055,"CreationDate":"2017-09-26T17:29:00.000","Title":"Pywinauto how do I get the list of returned elements","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I need to store some date stamped data in a JSON file. It is a sensor output. Each day the same JSON file is updated with the additional data. Now, is it possible to put some write protection on already available data to ensure that only new lines could be added to the document and no manual tampering should occur with it? \nI suspect that creating checksums after every update may help, but I am not sure how do I implement it? I mean if some part of JSON file is editable then probably checksum is also editable.\nAny other way for history protection?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":46444065,"Users Score":0,"Answer":"Write protection normally only exists for complete files.  So you could revoke write permissions for the file, but then also appending isn't possible anymore.\nFor ensuring that no tampering has taken place, the standard way would be to cryptographically sign the data.  You can do this like this, in principle:\n\nTake the contents of the file.\nAdd a secret key (any arbitrary string or random characters will do, the longer the better) to this string.\nCreate a cryptographical checksum (SHA256 hash or similar).\nAppend this hash to the file. (Newlines before and after.)\n\nYou can do this again every time you append something to the file.  Because nobody except you knows your secret key, nobody except you will be able to produce the correct hash codes of the part of the file above the hash code.\nThis will not prevent tampering but it will be detectable.\nThis is relatively easily done using shell utilities like sha256sum for mere text files.  But you have a JSON structure in a file.  This is a complex case because the position in the file does not correlate with the age of the data anymore (unlike in a text file which is only being appended to).\nTo still achieve what you want you need to have an age information on the data.  Do you have this?  If you provide the JSON structure as @Rohit asked for we might be able to give more detailed advice.","Q_Score":0,"Tags":"javascript,java,python","A_Id":46444255,"CreationDate":"2017-09-27T09:20:00.000","Title":"Is it possible to write protect old data of JSON Files and only enable appending?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a question about sqlite3. If I were to host a database online, how would I access it through python's sqlite3 module? \nE.g. Assume I had a database hosted at \"www.example.com\/database.db\". Would it be as simple as just forming a connection with sqlite3.connect (\"www.example.com\/database.db\") or is there more I need to add so that the string is interpreted as a url and not a filename?","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":1622,"Q_Id":46492388,"Users Score":3,"Answer":"SQLite3 is embedded-only database so it does not have network connection capabilities. You will need to somehow mount the remote filesystem.\nWith that being said, SQLite3 is not meant for this. Use PostgreSQL or MySQL (or anything else) for such purposes.","Q_Score":4,"Tags":"python,database,sqlite","A_Id":46492537,"CreationDate":"2017-09-29T15:39:00.000","Title":"Connecting to an online database through python sqlite3","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a high-dimensional dataset which is categorical in nature and I have used Kmodes to identify clusters, I want to visualize the clusters, what would be the best way to do that? PCA doesn't seem to be a recommended method for dimensionality reduction in a categorical dataset, how to visualize in such a scenario?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1437,"Q_Id":46516325,"Users Score":0,"Answer":"Agreeing with @DIMKOIM, Multiple Correspondence Analysis is your best bet. PCA is mainly used for continuous variables. To visualize your data, you can build a scatter plot from scratch.","Q_Score":0,"Tags":"python,machine-learning,cluster-analysis,categorical-data","A_Id":51921509,"CreationDate":"2017-10-01T19:56:00.000","Title":"How to plot a cluster in python prepared using categorical data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"When i'm running my tensorflow training module in pycharm IDE in Ubuntu 16.04, it doesn't show any training with GPU and it trains usually with CPU. But When i run the same python script using terminal it runs using GPU training. I want to know how to configure GPU training in Pycharm IDE.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":691,"Q_Id":46536893,"Users Score":0,"Answer":"Actually the problem was, the python environment for the pycharm project is not the same as which is in run configurations. This issue was fixed by changing the environment in run configurations.","Q_Score":1,"Tags":"python,ubuntu,tensorflow,pycharm,tensorflow-gpu","A_Id":50614889,"CreationDate":"2017-10-03T03:44:00.000","Title":"Tensorflow GPU doesn't work in Pycharm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For the last few months i've been working on a Rest API for a web app for the company I work for. The endpoints supply data such as transaction history, user data, and data for support tickets. However, I keep running into one issue that always seems to set me back to some extent.\nThe issue I seem to keep running into is how do I handle user authentication for the Rest API securely? All data is going to be sent over a SSL connection, but there's a part of me that's paranoid about potential security problems that could arise. As it currently stands when a client attempts to login the client must provide a username or email address, and a password to a login endpoint (E.G \"\/api\/login\"). Along with with this information, a browser fingerprint must be supplied through header of the request that's sending the login credentials. The API then validates whether or not the specified user exists, checks whether or not the password supplied is correct, and stores the fingerprint in a database model. To access any other endpoints in the API a valid token from logging in, and a valid browser fingerprint are required.\nI've been using browser fingerprints as a means to prevent token-hijacking, and as a way make sure that the same device used to login is being used to make the requests. However, I have noticed a scenario where this practice backfires on me. The client-side library i'm using to generate browser fingerprints isn't always accurate. Sometimes the library spits out a different fingerprint entirely. Which causes some client requests to fail as the different fingerprint isn't recognized by the API as being valid. I would like to keep track of what devices are used to make requests to the API. Is there a more consistent way of doing so, while still protecting tokens from being hijacked?\nWhen thinking of the previous question, there is another one that also comes to mind. How do I store auth tokens on client-side securely, or in a way that makes it difficult for someone to obtain the tokens through malicious means such as a xss-attack? I understand setting a strict Content-Security Policy on browser based clients can be effective in defending against xss-attacks. However, I still get paranoid about storing tokens as cookies or in local storage.\nI understand oauth2 is usually a good solution to user authentication, and I have considered using it before to deal with this problem. Although, i'm writing the API using Flask, and i'm also using JSON Web tokens. As it currently stands, Flask's implementation of oauth2 has no way to use JWTs as access tokens when using oauth for authentication.\nThis is my first large-scale project where I have had to deal with this issue and i am not sure what to do. Any help, advice, or critiques are appreciated. I'm in need of the help right now.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":260,"Q_Id":46562267,"Users Score":0,"Answer":"Put  an API Gateway in front of your API , your API Gateway is publicly ( i.e in the DMZ ) exposed while the actual API are internal.\nYou can look into Kong..","Q_Score":0,"Tags":"python-3.x,rest,api,security,authentication","A_Id":46562640,"CreationDate":"2017-10-04T10:10:00.000","Title":"How to handle Rest API user authentication securely?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing some image processing routines for a micro-controller that supports MicroPython. The bad news is that it only has 0.5 MB of RAM. This means that if I want to work with relatively big images\/matrices like 256x256, I need to treat it as a collection of smaller matrices (e.g. 32x32) and perform the operation on them. Leaving at aside the fact of reconstructing the final output of the orignal (256x256) matrix from its (32x32) submatrices, I'd like to focus on how to do the loading\/saving from\/to disk (an SD card in this case) of this smaller matrices from a big image.\nGiven that intro, here is my question: Assuming I have a 256x256 on disk that I'd like to apply some operation onto (e.g. convolution), what's the most convenient way of storing that image so it's easy to load it into 32x32 image patches? I've seen there is a MicroPython implementation of the pickle module, is this a good idea for my problem?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":52,"Q_Id":46583487,"Users Score":0,"Answer":"Sorry, but your question contains the answer - if you need to work with 32x32 tiles, the best format is that which represents your big image as a sequence of tiles (and e.g. not as one big 256x256 image, though reading tiles out of it is also not a rocket science and should be fairly trivial to code in MicroPython, though 32x32 tiles would be more efficient of course).\nYou don't describe the exact format of your images, but I wouldn't use pickle module for it, but store images as raw bytes and load them into array.array() objects (using inplace .readinto() operation).","Q_Score":0,"Tags":"python,data-structures,microcontroller,micropython","A_Id":47052669,"CreationDate":"2017-10-05T10:31:00.000","Title":"Load portions of matrix into RAM","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"So I have two table in a one-to-many relationship. When I make a new row of Table1, I want to populate Table2 with the related rows. However, this population actually involves computing the Table2 rows, using data in other related tables. \nWhat's a good way to do that using the ORM layer? That is, assuming that that the Table1 mappings are created through the ORM, where\/how should I call the code to populate Table2?\nI thought about using the after_insert hook, but i want to have a session to pass to the population method.\nThanks.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":46594866,"Users Score":1,"Answer":"After asking around in #sqlalchemy IRC, it was pointed out that this could be done using ORM-level relationships in an before_flush event listener.\nIt was explained that when you add a mapping through a relationship, the foreign key is automatically filled on flush, and the appropriate insert statement generated by the ORM.","Q_Score":1,"Tags":"python,sql,database,orm,sqlalchemy","A_Id":46777010,"CreationDate":"2017-10-05T21:11:00.000","Title":"Populating related table in SqlAlchemy ORM","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a beginner at programming (and also an older person), so I don't really know how to express what I want correctly. I've tried to describe my question as thoroughly as possible, so really appreciate your patience! \nI would like to store the winning scores associated with each user.\n\nEach user would have different number of winning scores.\nI do not need to seperate users first name and last name, they can all be one string.\nI do not need the scores to be ordered in any way, and I don't need to be able to change them. \nI only need to be able to add the scores whenever the user wins and sort users by amount of wins.\nI will extract all the winning scores for statistics, but the statistics will not be concerned with what score belongs to what user.   \nOnce the program stops, it can all be erased from memory.\n\nFrom what I've researched so far it seems my best options are to either create a user class, where I store a list and add to the list each time. Or to create a dictionary with a key for each user. But since each user may have a different amount of winning scores, I don't know if I can use dictionaries with that (unless each key is associated with a list maybe?). I don't think I need something like a numpy array, since I want to create very simple statistics without worrying about what score belongs to what user. \nI need to think about not using an unnecessary amount of memory etc., especially because there may be a hundred winning scores for each user. But I can't really find clear information on what the benefits of dictionaries vs classes are. The programming community is amazingly helpful and full of answers, but unfortunately I often don't understand the answers. \nGreatful for any help I can get! And don't be afraid to tell me my ideas are dumb, I want to learn how to think like a programmer.","AnswerCount":6,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":69,"Q_Id":46599013,"Users Score":0,"Answer":"class is used when there is both state and behavior . dict is used when there's only state. since you have both  use class.","Q_Score":1,"Tags":"python,list,dictionary,key-value","A_Id":46599399,"CreationDate":"2017-10-06T05:44:00.000","Title":"Beginners python. Best way to store different amount of items for each key?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I'm a beginner at programming (and also an older person), so I don't really know how to express what I want correctly. I've tried to describe my question as thoroughly as possible, so really appreciate your patience! \nI would like to store the winning scores associated with each user.\n\nEach user would have different number of winning scores.\nI do not need to seperate users first name and last name, they can all be one string.\nI do not need the scores to be ordered in any way, and I don't need to be able to change them. \nI only need to be able to add the scores whenever the user wins and sort users by amount of wins.\nI will extract all the winning scores for statistics, but the statistics will not be concerned with what score belongs to what user.   \nOnce the program stops, it can all be erased from memory.\n\nFrom what I've researched so far it seems my best options are to either create a user class, where I store a list and add to the list each time. Or to create a dictionary with a key for each user. But since each user may have a different amount of winning scores, I don't know if I can use dictionaries with that (unless each key is associated with a list maybe?). I don't think I need something like a numpy array, since I want to create very simple statistics without worrying about what score belongs to what user. \nI need to think about not using an unnecessary amount of memory etc., especially because there may be a hundred winning scores for each user. But I can't really find clear information on what the benefits of dictionaries vs classes are. The programming community is amazingly helpful and full of answers, but unfortunately I often don't understand the answers. \nGreatful for any help I can get! And don't be afraid to tell me my ideas are dumb, I want to learn how to think like a programmer.","AnswerCount":6,"Available Count":2,"Score":0.0333209931,"is_accepted":false,"ViewCount":69,"Q_Id":46599013,"Users Score":1,"Answer":"You can use Dictionary as values in dicts can be mutable like a list where you can keep all the scores\/winning scores for each user.\n{'player1' : [22,33,44,55],\n'player2' : [23,34,45],\n.....\n}\n\nIf this is not an exercise that you will repeat dicts make sense but if it is an exercise that might need to be done again in future Classes are better alternative as explained in other answers by Stuart and Hallsville3.\nHope it helps!","Q_Score":1,"Tags":"python,list,dictionary,key-value","A_Id":46600049,"CreationDate":"2017-10-06T05:44:00.000","Title":"Beginners python. Best way to store different amount of items for each key?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Tried anaconda today , it seems fine but when I tried to launch Spyder each time I get this error:  Traceback (most recent call last):\n  File \"C:\\ProgramData\\Anaconda3\\Scripts\\spyder-script.py\", line 6, in <module>\n    from spyder.app.start import main\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\spyder\\app\\start.py\", line 23, in <module>\n    from spyder.utils.external import lockfile\n  File \"C:\\ProgramData\\Anaconda3\\lib\\site-packages\\spyder\\utils\\external\\lockfile.py\", line 22, in <module>\n    import psutil\n  File \"C:\\Users\\Jaker\\AppData\\Roaming\\Python\\Python36\\site-packages\\psutil\\__init__.py\", line 126, in <module>\n    from . import _pswindows as _psplatform\n  File \"C:\\Users\\Jaker\\AppData\\Roaming\\Python\\Python36\\site-packages\\psutil\\_pswindows.py\", line 16, in <module>\n    from . import _psutil_windows as cext\nImportError: cannot import name '_psutil_windows'\nAny help regarding this ? Also how do I get python 3.6.3 in anaconda..?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":927,"Q_Id":46600280,"Users Score":0,"Answer":"The problem is you have two Python versions installed in your system: one in C:\\ProgramData\\Anaconda3\\ and the other in C:\\Users\\Jaker\\AppData\\Roaming\\Python\\Python36.\nPlease uninstall one of them and the problem will be solved.","Q_Score":0,"Tags":"python,python-3.x,anaconda,spyder","A_Id":46607726,"CreationDate":"2017-10-06T07:17:00.000","Title":"Error installing Spyder in anaconda","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"update.callback_query.from_user Inside the same function I used\nupdate.message.text\nwhere i tried to get message from user update.message.text is not working  giving me 'NoneType' object has no attribute 'text'\nhow can i use two update in same function","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1504,"Q_Id":46605599,"Users Score":1,"Answer":"To be exact you can find the message object (or\/and the text) of a callback_query at update.callback_query.message.text.\nOr for convenience you can always use update.effective_chat, update.effective_message and update.effective_user to access the chat, message and from_user objects wherever they are in (no matter it's a normal message, a callback_query, an inline_query etc.)","Q_Score":0,"Tags":"python,python-telegram-bot","A_Id":46637593,"CreationDate":"2017-10-06T12:19:00.000","Title":"I used Update.callback_query after which i used Update.message in same function its not working","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Start with a one dimensional space of length m, where m = 2 * n + 1. Take a step either to the left or to the right at random, with equal probability. Continue taking random steps until you go off one edge of the space, for which I'm using while 0 <= position < m. \nWe have to write a program that executes the random walk. We have to create a 1D space using size n = 5 and place the marker in the middle. Every step, move it either to the left or to the right using the random number generator. There should be an equal probability that it moves in either direction.  \nI have an idea for the plan but do not know how to write it in python:\n\nInitialize n = 1, m = 2n + 1, and j = n + 1.\nLoop until j = 0 or j = m + 1 as shown. At each step:\n\n\nMove j left or right at random.\nDisplay the current state of the walk, as shown.\n\nMake another variable to count the total number of steps.\n\n\nInitialize this variable to zero before the loop.\nHowever j moves always increase the step count.\n\nAfter the loop ends, report the total steps.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":327,"Q_Id":46620657,"Users Score":1,"Answer":"1 - Start with a list initialized with 5 items (maybe None?) \n2 - place the walker at index 2\n3 - randomly chose a direction (-1 or + 1)\n4 - move the walker in the chosen direction  \n5 - maybe print the space and mark the location of the walker\n6 - repeat at step 3 as many times as needed","Q_Score":0,"Tags":"python,random","A_Id":46620696,"CreationDate":"2017-10-07T13:23:00.000","Title":"How to use random numbers that executes a one dimensional random walk in python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I currently have a Django project running on a server behind Cloudflare. However, a number of the apps contain functionality that requires synchronizing data with certain web services. This is a security risk, because these web services may reveal the IP address of my server. Therefore I need a solution to prevent this. \nSo far I came up two alternatives: using a proxy or splitting the project to two servers. One server responsible for responding to requests through Cloudflare and one server responsible for synchronizing data with other web services. The IP address of the latter server will be exposed to the public, however attacks on this server will not cause the website to be offline. I prefer the second solution, because this will also split the load between two servers.\nThe problem is that I do not know how I should do this with Django without duplicating code. I know I can re-use apps, but for most of them counts that I, for instance, only need the models and the serializers and not the views etc. How should I solve this? What is the best approach to take? In addition, what is an appropriate naming for the two servers? Thanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":68,"Q_Id":46621609,"Users Score":0,"Answer":"This sounds like a single project that is being split as part of the deployment strategy. So it makes sense to use just a single codebase for it, rather than splitting it into two projects. If that's the case, re-use is a non-issue since both servers are using the same code.\nTo support multiple deployments, then, you just create two settings files and load the appropriate one on the appropriate server. The degree to which they are different is up to you. If you want to support different views you can use different ROOT_URLCONF settings. The INSTALLED_APPS can be different, and so forth.","Q_Score":1,"Tags":"python,django,architecture,django-rest-framework,cloudflare","A_Id":46624369,"CreationDate":"2017-10-07T14:59:00.000","Title":"django - split project to two servers (due to Cloudflare) without duplicating code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I would like to ask about how to use pip install for Python 2.7, when I previously installing for and using Python 3.6 ? (*I now have to versions of Python on Windows) \npip install ... keeps installing for Python 3.6\n\nI need to use the previous version, to rewrite the code in Python 2.7. (this is for building a Kivy app, although Kivy says it now supports Python 3 but it also says * Warning.) In order to do this, I have to import necessary modules : kivy and numpy.\nHope for feedbacks on this, Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1491,"Q_Id":46630267,"Users Score":3,"Answer":"If you have the 2 versions really installed, you should have a pip2 or pip2.x available in your PATH","Q_Score":2,"Tags":"python,python-2.7,python-3.x,pip","A_Id":46630308,"CreationDate":"2017-10-08T10:52:00.000","Title":"How to python pip install for Python 2.7, having using Python 3.6 before on Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how do I write\/execute a Python script full screen at the terminal.\nI want to write a small Programm which shoud be shown like \"vim\", \"sl\", or \"nano\".","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":675,"Q_Id":46636125,"Users Score":0,"Answer":"As fas as I can understand from your question, you can make the terminal to be fullscreen by pressing F11 (at least in Ubuntu)","Q_Score":0,"Tags":"python,terminal","A_Id":46636156,"CreationDate":"2017-10-08T21:13:00.000","Title":"Execute Python script in terminal fullscreen","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to figure out how to code how many times my main program has been called.\nI want to count how many times my program has been called, lets call the program \"test\". In the program different sub-functions can be called. therefore i want to be able to count those aswell, let's call them \"program-1, Program-2 ...etc\"\nAlso i want to be able to see how many times the program has been stopped, like how many times a user needed to push the kill-switch.\nAnyone out there who might have any idea how to do this?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":46642598,"Users Score":0,"Answer":"You can use a variable that will increment when the function calls or stops.","Q_Score":0,"Tags":"python,python-3.x,count","A_Id":46642725,"CreationDate":"2017-10-09T09:05:00.000","Title":"Count number of times my code has been called?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"i have had a rough time getting my scripts to work on my raspberry pi zero w and the last program i need installed requires selenium. This script was designed for windows 10 + python 2.7 because i make my scripts in this environment. \nI was wondering if it is possible to use selenium on a raspberry pi zero w and preferably headless if possible.\nI can't find any info, help or guidelines online anywhere and have no idea how to use pip in raspbian (if it even has pip).","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":757,"Q_Id":46675769,"Users Score":0,"Answer":"I don't see why you couldn't. You can install pip with apt install python-pip, you'll probably need to sudo that command unless you login as root.\nThen you can just open a terminal and use the pip install command to get selenium. If that doesn't work you can try running python -m pip install instead.","Q_Score":0,"Tags":"python-2.7,selenium","A_Id":46677415,"CreationDate":"2017-10-10T20:49:00.000","Title":"Selenium (Maybe headless) on raspberry pi zero w","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Could some one explain to me please how to customize docstring color for Python in VSCode's default theme? I want to do it thru User Settings because want to be able to save my config file.\nI tried to use \"editor.tokenColorCustomizations\": {} but it affects all strings.","AnswerCount":3,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":4945,"Q_Id":46689334,"Users Score":3,"Answer":"Leonard's answer above is perfect.\nJust for the googlers in 2020, I would add that the command in Command Palette: Developer: Inspect TM Scopes seems to have changed to: Developer: Inspect Editor Tokens and Scopes.\nThis option shows both the standard token types, as well as TextMate scopes.","Q_Score":14,"Tags":"python,colors,visual-studio-code,themes","A_Id":63959173,"CreationDate":"2017-10-11T13:21:00.000","Title":"How to customize docstring color for Python in VSCode's default theme?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using remote interpreter all the times before, but suddenly it shows failed error message: can't run python interpreter: error connecting to remote host: \nI am using SFTP, and I have tried \"Test SFTP connection\", got success message with the same host.\nI am wondering how do I see verbose message in the remote debugging connection. \nI am using PyCharm 2017.2 professional.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1301,"Q_Id":46696267,"Users Score":4,"Answer":"Solve the problem. There are two places to edit the same remote interpreter. One is from Default Setting-> Project Interpreter -> Setting Icon -> More -> edit icon, another is from Tools -> Deployment -> Configuration. The settings in both places need to be correct for the same remote interpreter.\nFor some reason, the password in my first location was cleared.","Q_Score":1,"Tags":"python,pycharm,remote-debugging","A_Id":46715433,"CreationDate":"2017-10-11T19:41:00.000","Title":"Pycharm stopped working in remote interpreter","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to find the length of a 1-D float array and convert it into a 2-d array in python. Also when I am trying to print the elements of the float array the following error is coming:-\n'float' object is not iterable","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":608,"Q_Id":46701431,"Users Score":0,"Answer":"Length of array: len(array). Try to do 2 cycles to spread all values to 2-d array.","Q_Score":0,"Tags":"python,arrays","A_Id":46701588,"CreationDate":"2017-10-12T04:29:00.000","Title":"How to find the number of elements of a float array in python and how to convert it to a 2-dimensional float array?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a game where I have to get data from the server (through REST WebService with JSON) but the problem is I don't know when the data will be available on the server. So, I decided to use such a method that hit Server after specific time or on request on every frame of the game. But certainly this is not the right, scale able and efficient approach. Obviously, hammering is not the right choice. \nNow my question is that how do I know that data has arrived at server so that I can use this data to run my game. Or how should I direct the back-end team to design the server in an efficient way that it responds efficiently. \nRemember at server side I have Python while client side is C# with unity game-engine.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":46,"Q_Id":46708236,"Users Score":0,"Answer":"It is clearly difficult to provide an answer with little details. TL;DR is that it depends on what game you are developing. However, polling is very inefficient for at least three reasons:\n\nThe former, as you have already pointed out, it is inefficient because you generate additional workload when there is no need\nThe latter, because it requires TCP - server-generated updates can be sent using UDP instead, with some pros and cons (like potential loss of packets due to lack of ACK)\nYou may get the updates too late, particularly in the case of multiplayer games. Imagine that the last update happened right after the previous poll, and your poll is each 5 seconds. The status could be already stale.\n\nThe long and the short of it is that if you are developing a turn-based game, poll could be alright. If you are developing (as the use of Unity3D would suggest) a real-time game, then server-generated updates, ideally using UDP, are in my opinion the way to go.\nHope that helps and good luck with your project.","Q_Score":0,"Tags":"c#,python,json,rest,web-services","A_Id":46719477,"CreationDate":"2017-10-12T11:16:00.000","Title":"Check the data has updated at server without requesting every frame of the game","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Im going to run query that returns a huge table (about 700Mb) from Redshift and save it to CSV using SQLAlchemy and python 2.7 on my local machine (mac pro).\nI've never done this with such a huge queries before and obviously there could be some memory and other issues. \nMy question is what i shall take into account and how to use sql alchemy in order to make the process work?\nThanks,\nAlex","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1752,"Q_Id":46714971,"Users Score":0,"Answer":"If you don't run much else on that machine then memory should not be an issue. Give it a try. Monitor memory use during the execution. Also use \"load\" to see what pressure on the system is.","Q_Score":0,"Tags":"python,sql,sqlalchemy,amazon-redshift","A_Id":46715732,"CreationDate":"2017-10-12T16:48:00.000","Title":"Python\/SQLAlchemy: How to save huge redshift table to CSV?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In R I can use \ninstall.packages(\"pkgName\")\nto install a new package no problems. But when I tried python and do pip install package it fails with error\n\nRetrying (Retry(total=4, connect=None, read=None, redirect=None,\n  status=None)) after connection broken by\n  'NewConnectionError(': Failed to establish a new connection:\n  [Errno 11004] getaddrinfo failed',)': \/simple\/pyarrow\/\n\nI think it's because pip doesn't know how to automatically detect the proxy (that's gets set in Internet Explorer) like R can. \nMost of the info I find online either don't work or is just too complicated for someone without specialist knowledge to follow.\nconda install fails as well.\nIs there an easy fix to this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2851,"Q_Id":46720222,"Users Score":2,"Answer":"Try using the below command on windows command prompt or PowerShell:\npip install --proxy DOMAIN\\username:password@proxyserver:port packagename \nReplace the DOMAIN, username, password, proxy server and port with values specific to your system. This works for a windows 10 installation authenticated by Active Directory that is behind a corporate proxy server.","Q_Score":2,"Tags":"python,pip,conda","A_Id":46825476,"CreationDate":"2017-10-12T23:12:00.000","Title":"How to use conda\/pip install to install packages behind a corporate proxy?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Say, I have a source file encoded in utf8, when python interpreter loads that source file, will it convert file content to unicode in memory and then try to evaluate source code in unicode?\nIf I have a string with non ASCII char in it, like\n\nastring = '\u4e2d\u6587'\n\nand the file is encoded in gbk.\nRunning that file with python 2, I found that string actually is still in raw gbk bytes. \nSo I dboubt, python 2 interpret does not convert source code to unicode. Beacause if so, the string content will be in unicode(I heard it is actually UTF16)\nIs that right? And if so, how about python 3 interpreter? Does it convert source code to unicode format?\nAcutally, I know how to define unicode and raw string in both Python2 and 3. \nI'm just curious about one detail when the interpreter loads source code.  \nWill it convert the WHOLE raw source code (encoded bytes) to unicode at very beginning and then try to interpret unicode format source code piece by piece? \nOr instead, it just loads raw source piece by piece, and only decodes what it think should. For example,  when it hits the statement u'\u4e2d\u6587'  , OK, decode to unicode. While it hits statment  b'\u4e2d\u6587', OK, no need to decode.  \nWhich way the interpreter will go?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":93,"Q_Id":46742589,"Users Score":0,"Answer":"Python source is only plain ASCII, meaning that the actual encoding does not matter except for litteral strings, be them unicode strings or byte strings. Identifiers can use non ascii characters (IMHO it would be a very bad practice), but their meaning is normally internal to the Python interpreter, so the way it reads them is not really important\nByte strings are always left unchanged. That means that normal strings in Python 2 and byte litteral strings in Python 3 are never converted.\nUnicode strings are always converted:\n\nif the special string coding: charset_name exists in a comment on first or second line, the original byte string is converted as it would be with decode(charset_name)\nif not encoding is specified, Python 2 will assume ASCII and Python 3 will assume utf8","Q_Score":0,"Tags":"python,unicode,utf-8","A_Id":46790379,"CreationDate":"2017-10-14T08:41:00.000","Title":"when python interpreter loads source file, will it convert file content to unicode in memory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have MySQL database where I'm loading big files which insert more than 190 000 rows. I'm using python script which is doing some stuff and then load data from csv file into mysql execute query and commit.\nMy question is if I'm sending such a big file, is database ready after commit command or how to trigger when all datas are inserted in database?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":54,"Q_Id":46742682,"Users Score":1,"Answer":"The COMMIT does not actually return until the data has been... committed... so, yes, once you have committed any transaction, the work from that transaction is entirely done, as far as your application is concerned.","Q_Score":0,"Tags":"python,mysql","A_Id":46745333,"CreationDate":"2017-10-14T08:53:00.000","Title":"MySQL commit trigger done","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know very little about js and I'm trying to create a program that will get information about a browser based javascript game while I play it. I can't use a webdriver as I will be playing the game at the time. \nWhen I inspect the js on google chrome and look at the console, I can see all the information that I want to work with but I don't know how I can save that to a file or access it at the time in order to parse it. Preferably I'd be able to do this with python as that's what I will use for my code that will handle the info once I have it. \nAny help or a point in the right direction would be appreciated, thank you :)\nps, I'm on Windows if that's important","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":36,"Q_Id":46759726,"Users Score":0,"Answer":"hacking a game I see. Provided you are aware that what you are doing may diminish the validity of other's playtime as well as potentially committing a crime, I shall provide a solution:\nYou would need to get a piece of \"sniffing\" software which allows modifications.\nThe modifications are likely to be the addition of \"Querystring\" and \"JSON\" parsers to read the data traffic. At this point, you can begin learning how their particular system works, slowly replacing traffic with modified versions for your nefarious purposes.\n\"TCP Sniffing\" includes creating a \"RAW TCP SOCKET\" in whatever language and then repeatedly \"READ'ing \/ RECV'ing\" from that socket. The socket MUST be bound TO THE SPECIFIC NETWORK INTERFACE CARD (NIC). Hint: \"LOCALHOST\" and \"127.0.0.1\" are NOT the addresses of any NIC.\nYou would then parse the data as a HTTP req\/res stream, ensuring that you can read the contents of the frame correctly.\nYou would then be looking to either modify the contents of the POST body or the GET querystring. Either, depending on how the game designers designed their network system.","Q_Score":0,"Tags":"python,screen-scraping","A_Id":46760481,"CreationDate":"2017-10-15T20:35:00.000","Title":"How to scrape javascript while using a webpage normally?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, the tuple (1,[0,1,2]). I understand why from a design perspective; if the tuple were still hashable, then it would be trivial to make any unhashable type hashable by wrapping it in a tuple, which breaks the correct behavior of hashability, since you can change the value of the object without changing the hash value of the tuple. But if the tuple is not hashable, then I don't understand what makes an object hashable -- I thought it simply had to have __hash__(self) implemented, which tuple does. \nBased on other answers I've looked at, and from testing examples, it seems that such an object is not hashable. It seems like sensible behavior would be for tuple.__hash__() to call __hash__ for its component objects, but I don't understand how that would work from an implementation perspective, e.g. I don't know how a dictionary recognizes it as an unhashable type when it is still type tuple and tuple still defines __hash__.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":765,"Q_Id":46782716,"Users Score":2,"Answer":"I assume that tuple.__hash__() calls hash(item) for each item in the tuple and then XOR's the results together. If one of the items isn't hashable, then that will raise a TypeError that bubbles up to the original caller.","Q_Score":5,"Tags":"python","A_Id":46782764,"CreationDate":"2017-10-17T04:53:00.000","Title":"Why is a tuple containing an unhashable type unhashable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For example, the tuple (1,[0,1,2]). I understand why from a design perspective; if the tuple were still hashable, then it would be trivial to make any unhashable type hashable by wrapping it in a tuple, which breaks the correct behavior of hashability, since you can change the value of the object without changing the hash value of the tuple. But if the tuple is not hashable, then I don't understand what makes an object hashable -- I thought it simply had to have __hash__(self) implemented, which tuple does. \nBased on other answers I've looked at, and from testing examples, it seems that such an object is not hashable. It seems like sensible behavior would be for tuple.__hash__() to call __hash__ for its component objects, but I don't understand how that would work from an implementation perspective, e.g. I don't know how a dictionary recognizes it as an unhashable type when it is still type tuple and tuple still defines __hash__.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":765,"Q_Id":46782716,"Users Score":5,"Answer":"tuple implements its own hash by computing and combining the hashes of the values it contains. When hashing one of those values fails, it lets the resulting exception propagate unimpeded. \nBeing unhashable just means calling hash() on you triggers a TypeError; one way to do that is to not define a __hash__ method, but it works equally well if, in the course of your __hash__ method you raise a TypeError (or any other error really) by some other means.\nBasically, tuple is a hashable type (isinstance((), collections.abc.Hashable) is true, as is isinstance(([],), collections.abc.Hashable) because it's a type level check for the existence of __hash__), but if it stores unhashable types, any attempt to compute the hash will raise an exception at time of use, so it behaves like an unhashable type in that scenario.","Q_Score":5,"Tags":"python","A_Id":46782773,"CreationDate":"2017-10-17T04:53:00.000","Title":"Why is a tuple containing an unhashable type unhashable?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a really simple app in Python for a school project. It is for a skillsharing community that our club is trying to start up. Imagine Venmo, but without any money involved. It's essentially a record of favors done for those in the community.\nThe users' info is stored as a dictionary within a dictionary of all users. The dictionary is pickled and the .pkl is updated automatically whenever user info is changed. I want the users to be able to access the information online, by logging in via username and password. It will be used regularly by people and security isn't really a concern since it doesn't store personal info and the users are a small group that are in our club.\nAnyhow, my issue is that I only know how to do backend stuff and basic tkinter GUIs (which, AFAIK can't be used for my needs). I'm a self-taught and uncommitted novice programmer, so I don't even know how to search for what I'm trying to do. I imagine what I need to do is put the program and the .pkl on the server that will host my website. (I have a domain name, but never figured out how to actually make it a website...) From there, I imagine I have to write some code that will create a login screen and allow users to login and view the attributes associated with their profile as well as send \"payment\" (as favors) to other users.\nHow do I do any\/all of this? I'm looking for online resources or explanations from the community that will help me get this project off the ground. Also, telling me what it is called that I am trying to do would be greatly appreciated. Thanks!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":60,"Q_Id":46783732,"Users Score":1,"Answer":"If I got your idea right then you just want to create python web application.\nFirst, you should check out python WebFrameworks and choose right one for you.\nThen you should check how to work with it on your existing web server.\nAnd last but not least (if I didn't forget anything) you should check some info on front-end programming.\nSorry, if I gor your idea wrong or misguiding you at somwe point.","Q_Score":0,"Tags":"python,web-applications","A_Id":46784214,"CreationDate":"2017-10-17T06:23:00.000","Title":"How do I make an app available online? [Python]","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a simple python script which will directly transfer objects from blender to Maya. I created a python script which exports the object from blender to a temp folder. now I want to import that object into Maya without actually going to Maya>file>import. I searched for the solution for a while and found out that I can create a standalone instance of Maya with mayapy.exe and work in non-GUI instance of Maya. but what I want to do is import the object into an already running instance of Maya(GUI version) as soon as the exporting script is done running.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":249,"Q_Id":46783775,"Users Score":0,"Answer":"as suggested by Andrea, I opened the commandPort of maya and connected to it using socket in python script. now i can send commands to maya using that python script as long as the maya commandPort is open.","Q_Score":1,"Tags":"python,maya","A_Id":46792329,"CreationDate":"2017-10-17T06:26:00.000","Title":"how to give commands to the running instance of maya with mayapy.exe?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The program would follow the below steps:\n\nClick on executable program made through python \nFile explorer pops up for user to choose excel file to alter\nChoose excel file for executable program to alter \nSpits out txt file OR excel spreadsheet with newly altered data to same folder location as the original spreadsheet","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":123,"Q_Id":46803803,"Users Score":0,"Answer":"Yes this is perfectly doable. I suggest you look at PyQT5 or TkInter for the user interface, pyexcel for the excel interface and pyinstaller for packaging up an executable as you asked. There are many great tutorials on all of these modules.","Q_Score":0,"Tags":"python,excel,file,exe,explorer","A_Id":46803941,"CreationDate":"2017-10-18T06:09:00.000","Title":"Python - how to get executable program to get the windows file browser to pop up for user to choose an excel file or any other document?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have just started exploring bokeh and here is a small issue I am stuck with. This is in regards with live graphs. \nThe problem is with the axis values. Initially if I start with say 10, till 90 it shows correct values but while printing 100, it only show 10 and the last zero(0) is hidden. It's not visible.\nThat is when it switches from 2 digit number to a 3 or more digit number only the first two digits are visible.\nIs there any figure property I am missing or what I am not sure of.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":601,"Q_Id":46817031,"Users Score":1,"Answer":"This is a known bug with current versions (around 0.12.10) for now the best workaround is to increase plot.min_border (or p.min_border_left, etc) to be able to accommodate whatever the longest label you expect is. Or to rotate the labels to be parallel to the axis so that they always take up the same space, e.g. p.yaxis.major_label_orientation = \"vertical\"","Q_Score":1,"Tags":"python-3.x,bokeh","A_Id":46832946,"CreationDate":"2017-10-18T18:37:00.000","Title":"Bokeh Plots Axis Value don't show completely","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a data set which contains 12 years of weather data. For first 10 years, the data was recorded per day. For last two years, it is now being recorded per week. I want to use this data in Python Pandas for analysis but I am little lost on how to normalize this for use.\nMy thoughts\n\nConvert first 10 years data also into weekly data using averages. Might work but so much data is lost in translation.\nWeekly data cannot be converted to per day data.\nIgnore daily data - that is a huge loss\nIgnore weekly data - I lose more recent data.\n\nAny ideas on this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":46841117,"Users Score":0,"Answer":"First, you need to define what output you need, then, deduce how to treat the input to get the desired output.\nRegarding daily data for the first 10 years, it could be a possible option to keep only one day per week. Sub-sampling does not always mean loosing information, and does not always change the final result. It depends on the nature of the collected data: speed of variations of the data, measurement error, noise.\nSpeed of variations: Refer to Shannon to decide whether no information is lost by sampling once every week instead of every day. Given that for the 2 last year, some people had decided to sample only once every week, it seems to say that they have observed that data does not vary much every day and that a sample every week is enough information. That provides a hint to vote for a final data set that would include one sample every week for the total 12 years. Unless they reduced the sampling for cost reason, making a compromise between accuracy and cost of doing the sampling. Try to find in the literature a what speed your data is expected to vary.\nMeasurement error: If the measurement error contains a small epsilon that is randomly positive or negative, then, taking the average of 7 days to make a \"one week\" data will be better because it will increase the chances to cancel this variation. Otherwise, it is enough to do a sub-sampling taking only 1 day per week and throwing other days of the week. I would try both methods, averaging, and sub-sampling, and see if the output is significantly different.","Q_Score":0,"Tags":"python,pandas,periodicity","A_Id":46842124,"CreationDate":"2017-10-20T01:26:00.000","Title":"Data Periodicity - How to normalize?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to parse some web domains (tens of thousands) to see if they contain any English words.\nIt is easy for me to parse the domains to grab the main part of the domain with tldextract and then I tried to use enchant to see if they exist in the English dictionary. \nThe problem is I do not know how to split the domains in to multiple words to check, i.e. latimes returns as False but times would return as True.\nDoes anyone know a clever way to do look if there is an english word contained at all in the strings?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":87,"Q_Id":46855255,"Users Score":0,"Answer":"Unless you need to do that in a hurry, you could just chip off letters from the beginning or the end of the string, and check if it's a known word; if it is, cut it off and repeat. With e.g. 50k words 20 letters each, at worst you'll do 1M lookups. With a lookup taking e.g. 5ms (hitting an HDD every time), it will take 5000 seconds (about 1.5 hours), shorter than you'd spend coming up with a better algorithm.","Q_Score":0,"Tags":"python,parsing,dataframe,web","A_Id":46855571,"CreationDate":"2017-10-20T18:32:00.000","Title":"How to find if english words exist in string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the difference between os.system(\"timeout 1\") and time.sleep(1) in Python? I know the first one will call out the command line and let it do the timeout, but not sure how the second one make the system idle. \nAlso, which one can save more CPU power or make less memory occupied? \nThanks!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":372,"Q_Id":46860706,"Users Score":0,"Answer":"Efficient way is using time.sleep.\nSecond method is just sleeping (idle) the process for it's own for 1 second. It doesn't use any other resources more that itself.\nFirst method is making an another process, which takes more memory space, CPU, etc., and waiting to end (os.system's behavior). Luckily the another process was just timeout, so the result seems same.","Q_Score":0,"Tags":"python,memory,time,operating-system,cpu","A_Id":46860767,"CreationDate":"2017-10-21T06:34:00.000","Title":"What is the difference between os.system(\"timeout 1\") and time.sleep(1)? Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a lambda function and for that lambda function my cloudwatch event is a trigger on it...\nat the end of the lambda function i need to delete the trigger (cloud watch event ) on that lambda function programatically using python .\nhow can i do that ? is there any python library to do that?","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":2408,"Q_Id":46864499,"Users Score":1,"Answer":"Came across the same issue and found the solution. What you want is remove_permission() on the lambda client","Q_Score":3,"Tags":"python-3.x,amazon-web-services,aws-lambda","A_Id":70804457,"CreationDate":"2017-10-21T14:48:00.000","Title":"Delete trigger on a AWS Lambda function in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a list called movies with two sublists embedded it. Do the sublists have names too? I want to use len() BIF to measure all items in the list and sublists, how do I do that?","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":65,"Q_Id":46867272,"Users Score":1,"Answer":"U can use the len() function by specifying the inner sublists \nmovies = [  [list1] ,  [list2] ] ;\nprint(len(movies[0]));  # prints length of 1st sublist \nprint(len(movies[1])); #prints length of second sublist","Q_Score":0,"Tags":"python","A_Id":46867396,"CreationDate":"2017-10-21T19:36:00.000","Title":"Python len function on list with embedded sublists and strings","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some sensor nodes. they are connected to a Raspberry Pi 2 and send data on it. the data on Raspberry Pi is sending the data to Thingspeak.com and it shows the data from sensor nodes. \nnow I am developing a Kaa server and wanna see my data (from Raspberry Pi) on Kaa. is there any chance to connect the current programmed Raspberry Pi(in Python) to Kaa? \nMany thanks, \nShid","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":495,"Q_Id":46871792,"Users Score":0,"Answer":"Mashid. From what I know, to use a KAA server, you should utilize the SDK obtained when you create a new application on the KAA server. This SDK also functions as an API key that will connect the device with a KAA server (on a KAA server named with Application Token). The platforms provided for using this SDK are C, C ++, Java, Android, and Objective C. There is currently no SDK for the Python platform.","Q_Score":0,"Tags":"python,raspberry-pi,sandbox,iot,kaa","A_Id":48001019,"CreationDate":"2017-10-22T07:59:00.000","Title":"how to connect a programmed raspberry pi to a Kaa platform?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using Dev C++. Include Python.h doesnt work, and IDE states it cant find the file or directory. I can pull up the Python.h C file, so I know I have it. How do I connect two-and-two? I imagine I have to tell my IDE where the file path is, but how would I do that?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1269,"Q_Id":46878736,"Users Score":1,"Answer":"check that in dev-C++ tools > compiler options > directories > c includes and c++ includes have the path to where your Python.h is.","Q_Score":1,"Tags":"python,c++,ide","A_Id":46878851,"CreationDate":"2017-10-22T20:16:00.000","Title":"How to get Dev C++ to find Python.h","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working my way through Google Foobar and I'm very confused about \"Free the Bunny Prisoners\".  I'm not looking for code, but I could use some insight from anyone that's completed it.  First, the problem:\n\nFree the Bunny Prisoners\nYou need to free the bunny prisoners before Commander Lambda's space\n  station explodes! Unfortunately, the commander was very careful with\n  her highest-value prisoners - they're all held in separate,\n  maximum-security cells. The cells are opened by putting keys into each\n  console, then pressing the open button on each console simultaneously.\n  When the open button is pressed, each key opens its corresponding lock\n  on the cell. So, the union of the keys in all of the consoles must be\n  all of the keys. The scheme may require multiple copies of one key\n  given to different minions.\nThe consoles are far enough apart that a separate minion is needed for\n  each one. Fortunately, you have already freed some bunnies to aid you\n  - and even better, you were able to steal the keys while you were working as Commander Lambda's assistant. The problem is, you don't\n  know which keys to use at which consoles. The consoles are programmed\n  to know which keys each minion had, to prevent someone from just\n  stealing all of the keys and using them blindly. There are signs by\n  the consoles saying how many minions had some keys for the set of\n  consoles. You suspect that Commander Lambda has a systematic way to\n  decide which keys to give to each minion such that they could use the\n  consoles.\nYou need to figure out the scheme that Commander Lambda used to\n  distribute the keys. You know how many minions had keys, and how many\n  consoles are by each cell.  You know that Command Lambda wouldn't\n  issue more keys than necessary (beyond what the key distribution\n  scheme requires), and that you need as many bunnies with keys as there\n  are consoles to open the cell.\nGiven the number of bunnies available and the number of locks required\n  to open a cell, write a function answer(num_buns, num_required) which\n  returns a specification of how to distribute the keys such that any\n  num_required bunnies can open the locks, but no group of (num_required\n  - 1) bunnies can.\nEach lock is numbered starting from 0. The keys are numbered the same\n  as the lock they open (so for a duplicate key, the number will repeat,\n  since it opens the same lock). For a given bunny, the keys they get is\n  represented as a sorted list of the numbers for the keys. To cover all\n  of the bunnies, the final answer is represented by a sorted list of\n  each individual bunny's list of keys.  Find the lexicographically\n  least such key distribution - that is, the first bunny should have\n  keys sequentially starting from 0.\nnum_buns will always be between 1 and 9, and num_required will always\n  be between 0 and 9 (both inclusive).  For example, if you had 3\n  bunnies and required only 1 of them to open the cell, you would give\n  each bunny the same key such that any of the 3 of them would be able\n  to open it, like so: [   [0],   [0],   [0], ] If you had 2 bunnies and\n  required both of them to open the cell, they would receive different\n  keys (otherwise they wouldn't both actually be required), and your\n  answer would be as follows: [   [0],   [1], ] Finally, if you had 3\n  bunnies and required 2 of them to open the cell, then any 2 of the 3\n  bunnies should have all of the keys necessary to open the cell, but no\n  single bunny would be able to do it.  Thus, the answer would be: [\n  [0, 1],   [0, 2],   [1, 2], ]\nLanguages\nTo provide a Python solution, edit solution.py To provide a Java\n  solution, edit solution.java\nTest cases\nInputs:\n      (int) num_buns = 2\n      (int) num_required = 1 Output:\n      (int) [[0], [0]]\nInputs:\n      (int) num_buns = 5\n      (int) num_required = 3 Output:\n      (int) [[0, 1, 2, 3, 4, 5], [0, 1, 2, 6, 7, 8], [0, 3, 4, 6, 7, 9], [1, 3, 5, 6, 8, 9], [2, 4, 5, 7, 8, 9]]\nInputs:\n      (int) num_buns = 4\n      (int) num_required = 4 Output:\n      (int) [[0], [1], [2], [3]]\n\nI can't figure out why answer(5, 3) = [[0, 1, 2, 3, 4, 5], [0, 1, 2, 6, 7, 8], [0, 3, 4, 6, 7, 9], [1, 3, 5, 6, 8, 9], [2, 4, 5, 7, 8, 9]].  It seems to me that [[0], [0, 1, 2], [0, 1, 2], [1], [2]] completely satisfies the requirements laid out in the description.  I don't know why you'd ever have keys with a value greater than num_required-1.\nOne possibility I thought of was that there are unwritten rules that say all of the minions\/bunnies need to have the same number of keys, and you can only have num_required of each key.  However, if that's the case, then [[0, 1, 2], [0, 1, 2], [0, 3, 4], [1, 3, 4], [2, 3, 4]] would be okay.\nNext I thought that maybe the rule about needing to be able to use all num_required keys at once extended beyond 0, 1, and 2, regardless of how many consoles there are.  That is, you should be able to make [6, 7, 8] as well as [0, 1, 2].  However, that requirement would be broken because the first bunny doesn't have any of those numbers.\nI'm stuck.  Any hints would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4292,"Q_Id":46898131,"Users Score":4,"Answer":"I think you missed the part where it says \nbut no group of (num_required - 1) bunnies can.\nI can explain my solution further, but I will ruin the fun. (I'm the owner of that repo).\nLet's try it with your answer.\n[[0], [0, 1, 2], [0, 1, 2], [1], [2]]\nYour consoles are 3. Bunny 2 can open it on its own, Bunny 3 can open it also on his own -> it does NOT satisfy the rule.","Q_Score":3,"Tags":"java,python","A_Id":46918732,"CreationDate":"2017-10-23T20:40:00.000","Title":"Google Foobar: Free the Bunny Prisoners clarification","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Today I messed up the versions of Python on my CentOS machine. Even yum cannot work properly. I made the mistake that I removed the default \/usr\/bin\/python which led to this situation. How could I get back a clear Python environment? I thought remove them totally and reinstall Python may work, but do not know how to do it. Wish somebody could help!","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":19404,"Q_Id":46915455,"Users Score":-1,"Answer":"To install Python on CentOS: sudo yum install python2\/3 (select the version as per requirement)\nTo uninstall Python on CentOS: sudo yum remove python2\/3 (select the version as per your requirement)\nTo check version for python3(which you installed): python3 --version\nTo check version for python2 (which you installed): python2 --version","Q_Score":3,"Tags":"python,centos,rpm,yum","A_Id":63481093,"CreationDate":"2017-10-24T16:20:00.000","Title":"Remove clearly and reinstall python on CentOS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to install bluepy 1.0.5. However, I get receiving error below.  Any idea how can i solve it? (I am using Mac OS X El Capitan)\n\n40:449: execution error: The directory '\/Users\/isozyesil\/Library\/Caches\/pip\/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.\n  The directory '\/Users\/isozyesil\/Library\/Caches\/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.\n  Command \/usr\/bin\/python -u -c \"import setuptools, tokenize;__file__='\/private\/var\/folders\/95\/f900ttf95g1b7h02y2_rtk400000gn\/T\/pycharm-packaging669\/bluepy\/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record \/var\/folders\/95\/f900ttf95g1b7h02y2_rtk400000gn\/T\/pip-djih0T-record\/install-record.txt --single-version-externally-managed --compile\n  failed with error code 1 in \/private\/var\/folders\/95\/f900ttf95g1b7h02y2_rtk400000gn\/T\/pycharm-packaging669\/bluepy\/\n       (1)","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2751,"Q_Id":46918646,"Users Score":0,"Answer":"What part of the diagnostic message did you find unclear?\nDid you consider ensuring writable self-owned files by doing sudo chown -R isozyesil \/Users\/isozyesil\/Library\/Caches\/pip ?\nDid you consider sudo pip install bluepy ?","Q_Score":2,"Tags":"python,serial-port,pycharm,signals,signal-processing","A_Id":46918772,"CreationDate":"2017-10-24T19:32:00.000","Title":"Bluepy Installation Error","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am running a uwsgi application on my linux mint. it has does work with a database and shows it on my localhost. i run it on 127.0.0.1 IP and 8080 port. after that i want to test its performance by ab(apache benchmark).\nwhen i run the app by command uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi and get test of it, it works correctly but slowly.\nso i want to run the app with more than one thread to speed up. so i use --threads option and command is uwsgi --socket 0.0.0.0:8080 --protocol=http -w wsgi --threads 8 for example. \nbut when i run ab to test it, after 2 or 3 request, my application stops with some errors and i don't know how to fix it. every time i run it, type of errors are different. some of errors are like these:\n\n(Traceback (most recent call last): 2014, 'Command Out of Sync')\n\nor \n\n(Traceback (most recent call last):   File \".\/wsgi.py\", line 13, in\n  application\n      return show_description(id)   File \".\/wsgi.py\", line 53, in show_description\n      cursor.execute(\"select * from info where id = %s;\" %id)   File \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/cursors.py\",\n  line 166, in execute\n      result = self._query(query)   File \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/cursors.py\",\n  line 322, in _query\n      conn.query(q)   File \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/connections.py\",\n  line 856, in query\n      self._affected_rows = self._read_query_result(unbuffered=unbuffered) 'Packet sequence number\n  wrong - got 1 expected 2',)   File\n  \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/connections.py\",\n  line 1057, in _read_query_result\n\nor \n\n('Packet sequence number wrong - got 1 expected 2',) Traceback (most\n  recent call last):\n\nor \n\n('Packet sequence number wrong - got 1 expected 2',) Traceback (most\n  recent call last):   File \".\/wsgi.py\", line 13, in application\n      return show_description(id)   File \".\/wsgi.py\", line 52, in show_description\n      cursor.execute('UPDATE info SET  views = views+1 WHERE id = %s;', id)   File\n  \"\/home\/mohammadhossein\/myFirstApp\/myappenv\/local\/lib\/python2.7\/site-packages\/pymysql\/cursors.py\",\n  line 166, in execute\n      result = self._query(query)\n\nPlease help me how to run my uwsgi application wiht more than one thread safety. any help will be welcome","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":238,"Q_Id":46927517,"Users Score":0,"Answer":"it has solved.\nthe point is that you should create separate connection for each completely separate query to avoid missing data during each query execution","Q_Score":0,"Tags":"python,multithreading,server,uwsgi","A_Id":47568008,"CreationDate":"2017-10-25T08:26:00.000","Title":"uwsgi application stops with error when running it with multi thread","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a program that can output results either as JSON or Python data structure literals. I am wondering how to succinctly name the latter option.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":58,"Q_Id":46940171,"Users Score":2,"Answer":"JavaScript literals are not called JSON. JSON derived its name and syntax from JavaScript, but they\u2019re not the same thing. Use \u201cPython literals\u201d.","Q_Score":2,"Tags":"python,json,object-literal,object-notation","A_Id":46940207,"CreationDate":"2017-10-25T19:01:00.000","Title":"Is there a name for Python literals? The way JavaScript literals are called JSON?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Okay i can send audio with some url in inline mode. But how can i send the local audio from the directory? Telegram Bot API return me this:\n\nA request to the Telegram API was unsuccessful. The server returned\n  HTTP 400 Bad Request. Response body:\n  [b'{\"ok\":false,\"error_code\":400,\"description\":\"Bad Request:\n  CONTENT_URL_INVALID\"}']","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":505,"Q_Id":46940780,"Users Score":0,"Answer":"InlineQueryResultAudio only accepts links while InlineQueryResultCachedAudio only accepts file_id. What you can do is post the files to your own server or upload it elsewhere to use the former one, or use SendAudio to get the file_id of it and use the latter one.","Q_Score":0,"Tags":"python,telegram-bot,python-telegram-bot","A_Id":46947479,"CreationDate":"2017-10-25T19:37:00.000","Title":"Telegram Bot API InlineQueryResultAudio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am a total noob with Django, I come from the PHP world and I am used to doing things differently.\nI'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more experienced django devs go about it?\nDo they override all the django.contrib.admin templates, or do they build custom templates and login\/register next to it, and use the django.contrib.admin only for the superuser?\nWhat is the django way?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":451,"Q_Id":46941115,"Users Score":1,"Answer":"Django admin is intended for administration purposes. For all intents and purposes it is a direct interface to your database. While I have seen some people building customer facing interfaces using admin, this is most definitely not the way to make a general Django web application.\nYou should define views for your models. You can use built-in APIs to login and authenticate users. You should most likely restrict access to admin to internal users only.\nAs for templates, the modern way of doing things is to dynamically fetch data using an API and do all the UI logic in Javascript. Django can be used very well to provide an API to a frontend. Look into Django REST Framework. The basic idea is to write serializers for your models and have view functions serve the serialized data to the front end.\nYou could go the old school way and render your pages using templates of course. In that case your views would render templates using data provided by your models.","Q_Score":1,"Tags":"python,django","A_Id":46941490,"CreationDate":"2017-10-25T20:00:00.000","Title":"Overriding Django admin vs creating new templates\/views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I am a total noob with Django, I come from the PHP world and I am used to doing things differently.\nI'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more experienced django devs go about it?\nDo they override all the django.contrib.admin templates, or do they build custom templates and login\/register next to it, and use the django.contrib.admin only for the superuser?\nWhat is the django way?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":451,"Q_Id":46941115,"Users Score":0,"Answer":"Yes. The admin pages is actually for administering the webpage. For user login and registration you create the templates. However, if you want your backend to look different then you can tweak the template for the admin page, admin login page as well. And you can also have permission based admin views. It's okay to over ride the defaults as long as you know what you're doing. Hope that helped.","Q_Score":1,"Tags":"python,django","A_Id":46941275,"CreationDate":"2017-10-25T20:00:00.000","Title":"Overriding Django admin vs creating new templates\/views","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a dataset that includes 7 different covariates and an output variable, the 'success rate'. \nI'm trying to find the important factors that predict the success rate. One of the covariates in my dataset is a categorical variable that takes on 700 values (0- 700), each representing the ID of the district they're from. \nHow should I deal with this variable while performing logistic regression?\nIf I make 700 dummy columns, how can I make it easier to interpret the results? \nI'm using Python and statsmodels.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":755,"Q_Id":46998234,"Users Score":1,"Answer":"You can apply grouping and then do logistic regression on each group. Or you treat it as multilabel classifier and do \"Softmax regression\".","Q_Score":0,"Tags":"python,pandas,regression,statsmodels","A_Id":46998392,"CreationDate":"2017-10-29T08:29:00.000","Title":"Logistic Regression- Working with categorical variable in Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I am using a genetic algorithm to train a feedforward neural network, tasked with recognizing a function given to the genetic algorithm. I.e x = x**2 or something more complicated obviously.\nI realized I am using random inputs in my fitness function, which causes the fitness to be somewhat random for a member of the population, however, still in line with how close it is to the given function obviously. A colleague remarked that it is stranged that the same member of the population doesnt always get the same fitness, which I agree is a little unconventional. However, it got me thinking, is there any reason why this would be bad for the genetic algorithm? I actually think it might be quite good because it enables me to have a rather small testset, speeding up number of generations while still avoiding overfitting to any given testest.\nDoes anyone have experience with this?\n(fitness function is MSE compared to given function, for a randomly generated testset of 10 iterations)","AnswerCount":2,"Available Count":1,"Score":-0.0996679946,"is_accepted":false,"ViewCount":495,"Q_Id":46999584,"Users Score":-1,"Answer":"Normally you use a seed for genetic algorithms, which should be fixed. It will always generate the same \"random\" childs sequentially, which makes your approach reproducible. So the genetic algorithm is kind of pseudo-random. That is state of art how to perform genetic algorithms.","Q_Score":0,"Tags":"python,neural-network,artificial-intelligence,genetic-algorithm","A_Id":46999668,"CreationDate":"2017-10-29T11:24:00.000","Title":"Random element in fitness function genetic algorithm","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Suppose we have a directory: main that includes:\n\ndirectory_1\n\nfile_1.py\n\ndirectory_2\n\nfile_2.py \n\n\nIf the main code is inside file_1.py, how can I import file_2.py?\nIf it helps, I am using pycharm.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":55,"Q_Id":47009499,"Users Score":0,"Answer":"just simply add __init__.py to each directory (dir_1 and dir_2). \nNote that you don't need to write anything to 2 of __init__.py, it's fine to just leave it blank.","Q_Score":1,"Tags":"python,pycharm,parent-child","A_Id":47011258,"CreationDate":"2017-10-30T06:51:00.000","Title":"how to let files in pycharm see different ones?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to iterate \/\/span[@class=\"postNum and contains(text(),1)] This xpath over the range of 1 to 10 and store it in a variable. I want it to be done in HTML format and not XML.\npseudo code:\nfor e in range(1,11):\n     xpathvar[e]='\/\/span[@class=\"postNum and contains(text(),e)]'\nhow to implement this so that xpathvar[1] will contain the first xpath with e=1. I cannot do this because the element in RHS is a string.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":204,"Q_Id":47011332,"Users Score":0,"Answer":"I solved it myself. What I wanted to do was with using slice, I wanted to traverse to all xpath using iteration where the iterative will be in digits coming from for loop.","Q_Score":0,"Tags":"python-3.x,xpath,lxml","A_Id":47045098,"CreationDate":"2017-10-30T09:01:00.000","Title":"How to iterate over a XPath in HTML format using lxml and python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Fetch failed: Unable to find remote helper for 'https'\nWhen I tried to fetch on PyCharm from my GitHub repository, the above is the message I ended up getting. I was wondering how I could fix this.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":161,"Q_Id":47023092,"Users Score":1,"Answer":"This may seems like an overkill way of handling the problem but I have fixed it myself by re-installing git on my machine. It seems to actually be the fix for this. Another thing you could do is try git-bash (Git for Windows app) in the future.","Q_Score":2,"Tags":"python,windows,github,pycharm","A_Id":47023220,"CreationDate":"2017-10-30T19:46:00.000","Title":"Can't seem to fetch from GitHub repository in PyCharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to add new product.product fields to the default product.template view, problem is, that I've tried many examples, but none seems to be working.\nThe issue is that I do have added these fields to the product.product default view, (as an inherit view) BUT, that view is only available on sales module, the vast majority of the Odoo's product views are from product.template\nDoes anybody has an idea on how to achieve this on the xml view?\nIs it possible at all? Being product.product the model ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1258,"Q_Id":47024145,"Users Score":3,"Answer":"You should add those fields to product.template model and then they will be automatically added to product.product by the inheritance. This way you will be able to show the fields in product.template views.\nI do not know what is the exact problem that you are trying to solve but when you need to add a field to a product you should think if its value is going to be different for each variant of the product (product.product are variants and product.template are the original product). If it is going to have the same value (You want to add it to product.template view so I imagine it is going to have it) then, add it to product.template model.\nI hope it helps you.","Q_Score":1,"Tags":"python,openerp,odoo-8","A_Id":57271414,"CreationDate":"2017-10-30T21:05:00.000","Title":"Add product.product fields to product.template view - Odoo v8","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a GSM Modem SIM 900D. I am using it with my server and Python code to send and receive messages. I want to know how many Text SMS I could send and receive through this GSM modem per minute.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":377,"Q_Id":47030098,"Users Score":0,"Answer":"If you consider all protocols involved, including radio part, 300+ messages across a good dozen of protocols would have to be sent in order to deliver outgoing SMS to SMSC, and a great deal of waiting and synchronization will have to be involved. This (high overhead) will be your limiting factor and you would probably get 10-15 SMS per minute or so. \nReducing overhead is only possible with a different connectivity methods, mostly to eliminate radio part and mobility management protocols. Usual methods are: connecting to a dedicated SMS gateway provider via whatever protocol they fancy, or acting as SMSC yourself and connecting to SS7 network directly.","Q_Score":0,"Tags":"python,sms,gsm,sms-gateway","A_Id":47046290,"CreationDate":"2017-10-31T07:37:00.000","Title":"GSM 900D Module Limit for Text Messages Sending & Receiving","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am writing a program in Python which should import *.dat files, subtract a specific value from certain columns and subsequently save the file in *.dat format in a different directory. \nMy current tactic is to load the datafiles in a numpy array, perform the calculation and then save it. I am stuck with the saving part. I do not know how to save a file in python in the *.dat format. Can anyone help me? Or is there an alternative way without needing to import the *.dat file as a numpy array? Many thanks!","AnswerCount":5,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41290,"Q_Id":47038101,"Users Score":0,"Answer":"Correct me if I'm wrong, but opening, writing to, and subsequently closing a file should count as \"saving\" it. You can test this yourself by running your import script and comparing the last modified dates.","Q_Score":0,"Tags":"python,database,save","A_Id":47038338,"CreationDate":"2017-10-31T14:42:00.000","Title":"Save data as a *.dat file?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Where to store payment gateway secret key when using python Django with apache server?\nI don't what to store in settings.py as i will checking this file in my git. \nCan i do it the same way amazon store AWS ec2 keys. If possible how to do it.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":112,"Q_Id":47038309,"Users Score":2,"Answer":"You can set secrets in environment variables and get them in python code as password = os.getenv('ENVNAME').","Q_Score":0,"Tags":"python,django,apache,amazon-ec2,ubuntu-14.04","A_Id":47038557,"CreationDate":"2017-10-31T14:52:00.000","Title":"Where to store payment gateway secret key when using python Django with apache server hosted on aws ec2 Ubuntu","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating python script to configure router settings remotely but recently  stumbled on problem how to logout or close session after job is done?\nFrom searching I found that Basic-Authentication doesn\u00b4t have option to logout. How to solve it in python script?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":395,"Q_Id":47044392,"Users Score":0,"Answer":"with python requests you can open your session, do your job, then logout with:\nr = requests.get('logouturl', params={...})\nthe logout action is just an http Get method.","Q_Score":0,"Tags":"python,python-requests,basic-authentication","A_Id":47045020,"CreationDate":"2017-10-31T20:54:00.000","Title":"Basic-Auth session using python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am creating python script to configure router settings remotely but recently  stumbled on problem how to logout or close session after job is done?\nFrom searching I found that Basic-Authentication doesn\u00b4t have option to logout. How to solve it in python script?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":395,"Q_Id":47044392,"Users Score":0,"Answer":"Basic auth doesn't have a concept of a logout but your router's page should have some implementation. If not, perhaps it has a timeout and you just leave it. \nSince you're using the requests module it may be difficult to do an actual logout if there is no endpoint or parameter for it. I think the best one can do at that point is log in again but with invalid credentials. Studying the structure of the router's pages and the parameters that appear in the urls could give you more options. \nIf you want to go a different route and use something like a headless web browser you could actually click a logout button if it exists. Something like Selenium can do this.","Q_Score":0,"Tags":"python,python-requests,basic-authentication","A_Id":47044849,"CreationDate":"2017-10-31T20:54:00.000","Title":"Basic-Auth session using python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently updated to the most recent version of JupyterLab (0.28.12). I'm on Windows. \nI've tried adjusting the variables.css file located in \\Lib\\site-packages\\jupyterlab\\themes\\@jupyterlab\\theme-light-extension of my Miniconda\/Anaconda folder. I mainly want to change the font family and size, which I've tried using the variables.css file. However, I can't see any changes. \nI went to the extreme point of deleting both theme folders, but still I can change themes without a problem through the Lab interface. \nWhere are the JupyterLab theme .css files located? Or how can I find them? I've searched for css files and the themes sub folder seems to be the only location for them. I can't seem to find any in my user directory either c:\\Users\\User\\.jupyter where the .css files were for Jupyter Notebook were located. \nThanks!","AnswerCount":5,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":36582,"Q_Id":47048278,"Users Score":0,"Answer":"You should change the font size in the website. It should be at Settings->Fonts->Code->Size for code editor and Settings->Fonts->Content->Size for main contents\nThe css file should be <prefix>\/share\/jupyter\/lab\/themes\/@jupyterlab\/<your theme>\/index.css.\nTo change the font, find all the place in the css file which looks like setting font, and change it.","Q_Score":18,"Tags":"python,css,jupyter-lab","A_Id":62358081,"CreationDate":"2017-11-01T04:30:00.000","Title":"jupyterlab - change styling - font, font size","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I recently updated to the most recent version of JupyterLab (0.28.12). I'm on Windows. \nI've tried adjusting the variables.css file located in \\Lib\\site-packages\\jupyterlab\\themes\\@jupyterlab\\theme-light-extension of my Miniconda\/Anaconda folder. I mainly want to change the font family and size, which I've tried using the variables.css file. However, I can't see any changes. \nI went to the extreme point of deleting both theme folders, but still I can change themes without a problem through the Lab interface. \nWhere are the JupyterLab theme .css files located? Or how can I find them? I've searched for css files and the themes sub folder seems to be the only location for them. I can't seem to find any in my user directory either c:\\Users\\User\\.jupyter where the .css files were for Jupyter Notebook were located. \nThanks!","AnswerCount":5,"Available Count":2,"Score":0.1586485043,"is_accepted":false,"ViewCount":36582,"Q_Id":47048278,"Users Score":4,"Answer":"It is now possible to change the font sizes of most elements of the interface via the Settings menu .e.g: Settings->JupyterLab Theme->Increase Code Font Size etc.\nNote: These do not change if View->Presentation Mode is ticked.\nTo change the font style one still needs to go to Settings->Advanced Settings Editor (as mentioned in other answers) - and one can also changes font sizes there - which will take effect even if Presentation Mode is enabled.","Q_Score":18,"Tags":"python,css,jupyter-lab","A_Id":65618110,"CreationDate":"2017-11-01T04:30:00.000","Title":"jupyterlab - change styling - font, font size","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I don't know when and how it started but now I have such a glitch:\n\nopen CMD\nenter python command: \"django-admin.py help\"\nVisual Studio Code starts up and opens manage.py for editing.\nThe CMD command itself does not return anything.\non the other hand, if I enter: \"django-admin help\" (without .py)\nthe CMD shows help and VSCODE does not react in any way.\n\nWhat is this magic? How to change VSCODE reaction to .py mentioning?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":93,"Q_Id":47057011,"Users Score":1,"Answer":"It also happened to me, i tried creating a django project using django-admin.py startproject example, I asked around and i found out that the django-admin.py does not work on vscode for windows (am not really sure about mac), vscode sees it as a file and not as a command, cause vscode doesnt need the .py extension to execute the command.","Q_Score":0,"Tags":"python,django,visual-studio-code","A_Id":47057170,"CreationDate":"2017-11-01T14:18:00.000","Title":"VSCode starts up when I use \".py\" extension with CMD commands","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Using dockerbuild file, how can I do there something like:\nexport PYTHONPATH=\/:$PYTHONPATH\nusing RUN directive or other option","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2449,"Q_Id":47079459,"Users Score":7,"Answer":"In your Dockerfile, either of these should work:\n\nUse the ENV instruction (ENV PYTHONPATH=\"\/:$PYTHONPATH\")\nUse a prefix during the RUN instruction (RUN export PYTHONPATH=\/:$PYTHONPATH && <do something>)\n\nThe former will persist the changes across layers. The latter will take effect in that layer\/RUN command","Q_Score":2,"Tags":"python,docker","A_Id":47079624,"CreationDate":"2017-11-02T15:50:00.000","Title":"Adding path to pythonpath in dockerbuild file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building an experiment in Psychopy in which, depending on the participants response, I append an element to a list. I'd need to remove\/pop\/del it after a specific amount of time has passed after it was appended (e.g. 10 seconds). I was considering creating a clock to each element added, but as I need to give a name to each clock and the number of elements created is unpredictable (dependent on the participants responses), I think I'd have to create names to each of the clocks created on the go. However, I don't know how to do that and, on my searches about this, people usually say this isn't a good idea. \nWould anyone see a solution to the issue: remove\/pop\/del after a specific time has passed after appending the element?\nBest,\nFelipe","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":95,"Q_Id":47080385,"Users Score":3,"Answer":"I would take a slightly different approach: I would wrap the items you're inserting into the list with a thin object that has a timestamp field.\nThen I'd just leave it there, and when you iterate the list to find an object to pop - check the timestamp first and if it's bigger than 10 seconds, discard it. Do it iteratively until you find the next element that is younger than 10 seconds and use it for your needs.\nImplementing this approach should be considerably simpler than triggering events based on time and making sure they run accurately and etc.","Q_Score":1,"Tags":"python,list,append,psychopy,del","A_Id":47080508,"CreationDate":"2017-11-02T16:39:00.000","Title":"Append an element to a list and del\/pop\/remove it after a a specific amount of time has passed since it was appended","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem.\nI once was in a situation where a package used in one of my projects only worked with Python 3.4, but I had recently updated to 3.6. My code no longer ran, and I had to scour the system for Python 3.4 to actually fire up the project. It was a huge PITA. \nI recently wiped my computer and would like to avoid some of my past mistakes. Perhaps this is na\u00efve, but I'd like to limit version installation to brew. (Unless that's non-sensical \u2014 I'm open to other suggestions!) Furthermore, I'd like to know how to resolve my past version management woes (i.e. situations like the one above). I've heard of pyenv, but would that conflict with brew?\nThanks!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":432,"Q_Id":47082736,"Users Score":0,"Answer":"I agree to using virtualenv, it allows you to manage different python versions separately for different projects and clients. \nThis basically allows you to have each project it's own dependencies which are isolated from others.","Q_Score":0,"Tags":"python,macos,homebrew","A_Id":47084214,"CreationDate":"2017-11-02T18:58:00.000","Title":"Managing multiple Python versions on OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem.\nI once was in a situation where a package used in one of my projects only worked with Python 3.4, but I had recently updated to 3.6. My code no longer ran, and I had to scour the system for Python 3.4 to actually fire up the project. It was a huge PITA. \nI recently wiped my computer and would like to avoid some of my past mistakes. Perhaps this is na\u00efve, but I'd like to limit version installation to brew. (Unless that's non-sensical \u2014 I'm open to other suggestions!) Furthermore, I'd like to know how to resolve my past version management woes (i.e. situations like the one above). I've heard of pyenv, but would that conflict with brew?\nThanks!","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":432,"Q_Id":47082736,"Users Score":2,"Answer":"Use virtualenvs to reduce package clash between independent projects.  After activating the venv use pip to install packages. This way each project has an independent view of the package space. \nI use brew to install both Python 2.7 and 3.6. The venv utility from each of these will build a 2 or 3 venv respectively. \nI also have pyenv installed from brew which I use if I want a specific version that is not the latest in brew. After activating a specific version in a directory, I will then create a venv and use this to manage the package isolation. \nI can't really say what is best. Let's see what other folks say.","Q_Score":0,"Tags":"python,macos,homebrew","A_Id":47083151,"CreationDate":"2017-11-02T18:58:00.000","Title":"Managing multiple Python versions on OSX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have written a python code which takes an input data file, performs some processing on the data and writes another data file as output. \nI should distribute my code now but the users should not see the source code but be able to just giving the input and getting the output!\nI have never done this before. \nI would appreciate any advice on how to achieve this in the easiest way.\nThanks a lot in advance","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":11558,"Q_Id":47096120,"Users Score":1,"Answer":"One other option, of course, is to expose the functionality over the web, so that the user can interact through the browser without ever having access to the actual code.","Q_Score":1,"Tags":"python,dll,source-code-protection","A_Id":51919783,"CreationDate":"2017-11-03T12:44:00.000","Title":"How to protect my Python code before distribution?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a django view that takes in a json object and from that object I am able to get a uri. The uri contains an xml object. What I want to do is get the data from the xml object but I am not sure how to do this. I'm using django rest, which I am fairly inexperienced in using, but I do not know the uri until I search the json object in the view. I have tried parsing it in the template but ran into CORS issues amongst others. Any ideas on how this could be done in the view? My main issue is not so much parsing the xml but how to get around the CORS issue which I have no experience in dealing with","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":47102090,"Users Score":0,"Answer":"You don't really do this in view part of Django. \nWhat you should do is take the json, find the uri, get the content of uri through urllib, requests etc, get the relevant content from the response, add a new field to the json and then pass it to your view.","Q_Score":0,"Tags":"python,django,xml,django-rest-framework","A_Id":47103539,"CreationDate":"2017-11-03T18:10:00.000","Title":"Getting data from a uri django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As in the title, when running the appserver I get a DistributionNotFound exception for google-cloud-storage:\n\nFile \"\/home\/[me]\/Desktop\/apollo\/lib\/pkg_resources\/init.py\", line 867, in resolve\n      raise DistributionNotFound(req, requirers)\n  DistributionNotFound: The 'google-cloud-storage' distribution was not found and is required by the application\n\nRunning pip show google-cloud-storage finds it just fine, in the site packages dir of my venv.  Everything seems to be in order with python -c \"import sys; print('\\n'.join(sys.path))\" too; the cloud SDK dir is in there too, if that matters.\nNot sure what to do next.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1810,"Q_Id":47104930,"Users Score":0,"Answer":"The solution for me was that both google-cloud-storage and pkg_resources need to be in the same directory.\nIt sounds like your google-cloud-storage is in venv and your pkg_resources is in the lib folder","Q_Score":7,"Tags":"google-cloud-platform,google-cloud-storage,google-cloud-python","A_Id":65637184,"CreationDate":"2017-11-03T21:56:00.000","Title":"google-cloud-storage distribution not found despite being installed in venv","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am data scientist in beijing and working with anaconda in win7\nbut after I pip installed tensorflow v1.4,code completion of my IDE spyder in anaconda not work, before anything of code completion function is work perfectly. \nNow even I uninstall tensorflow,code completion function of spyder still not work. Any help?\nmy envirment:\nwin7\nanaconda3 v5.0 for win64 (py3.6)\ntensorflow v1.4 for win (tf_nightly-1.4.0.dev20171006-cp36-cp36m-win_amd64.whl)\nSo two question:\n1 How can i fix it so to make anaconda3 spyder code completion work again?\n2 After uninstall tensorflow, anaconda3 spyder code completion still not work, what can I do?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":487,"Q_Id":47109343,"Users Score":0,"Answer":"Now that I have to use a temporary alternative, I installed anaconda version without an installed tensorflow in anaconda's envs. And I use it when I don't use tensorflow. I hope this question can be complement answered, please attent my answer.","Q_Score":0,"Tags":"python,tensorflow,anaconda,spyder,code-completion","A_Id":47526695,"CreationDate":"2017-11-04T09:36:00.000","Title":"how can i make anaconda spyder code completion work again after installing tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am data scientist in beijing and working with anaconda in win7\nbut after I pip installed tensorflow v1.4,code completion of my IDE spyder in anaconda not work, before anything of code completion function is work perfectly. \nNow even I uninstall tensorflow,code completion function of spyder still not work. Any help?\nmy envirment:\nwin7\nanaconda3 v5.0 for win64 (py3.6)\ntensorflow v1.4 for win (tf_nightly-1.4.0.dev20171006-cp36-cp36m-win_amd64.whl)\nSo two question:\n1 How can i fix it so to make anaconda3 spyder code completion work again?\n2 After uninstall tensorflow, anaconda3 spyder code completion still not work, what can I do?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":487,"Q_Id":47109343,"Users Score":0,"Answer":"I try pip rope_py3k\u3001jedi and readline, and reset the set of tool, but all are not useful.\nand my Spyder code editing area also can not be automatically completed after the installation of tensorflow, I have re-installed again and found the same problem.\nHowever,when I re-installed all envs except tensorflow,it can work!! \n My environment is win10, anaconda3.5, python3.6.3, tensorflow1.4.\nDid you resolve it?And I hope you can teach me.","Q_Score":0,"Tags":"python,tensorflow,anaconda,spyder,code-completion","A_Id":47525945,"CreationDate":"2017-11-04T09:36:00.000","Title":"how can i make anaconda spyder code completion work again after installing tensorflow","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run from flask.ext.mysql import MySQL I get the warning Importing flask.ext.mysql is deprecated, use flask_mysql instead. \nSo I installed flask_mysql using pip install flask_mysql,installed it successfully but then when I run from flask_mysql import MySQL I get the error No module named flask_mysql. In the first warning I also get  Detected extension named flaskext.mysql, please rename it to flask_mysql. The old form is deprecated.\n  .format(x=modname), ExtDeprecationWarning. Could you please tell me how exactly should I rename it to flask_mysql? \nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3318,"Q_Id":47116912,"Users Score":3,"Answer":"flask.ext. is a deprecated pattern which was used prevalently in older extensions and tutorials. The warning is telling you to replace it with the direct import, which it guesses to be flask_mysql. However, Flask-MySQL is using an even more outdated pattern, flaskext.. There is nothing you can do about that besides convincing the maintainer to release a new version that fixes it. from flaskext.mysql import MySQL should work and avoid the warning, although preferably the package would be updated to use flask_mysql instead.","Q_Score":4,"Tags":"python,mysql,flask","A_Id":47117043,"CreationDate":"2017-11-05T00:06:00.000","Title":"Python flask.ext.mysql is deprecated?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am comfortable with basic filtering and querying using Pandas. For example, if I have a dataframe called df I can do df[df['field1'] < 2] or df[df['field2'] < 3]. I can also chain multiple criteria together, for example:\ndf[(df['field1'] < 3) & (df['field2'] < 2)].\nWhat if I don't know in advance how many criteria I will need to use? Is there a way to \"chain\" an arbitrary number of these operations together? I would like to pass a list of filters such as [('field1', 3), ('field2', 2), ('field3', 4)] which would result in the chaining of these 3 conditions together.\nThanks!","AnswerCount":6,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":813,"Q_Id":47147414,"Users Score":0,"Answer":"I believe that reduce( (lambda x, y: x & (df[y[0]]<y[1])), list_of_filters ) will do it.","Q_Score":4,"Tags":"python,pandas","A_Id":47147531,"CreationDate":"2017-11-06T23:13:00.000","Title":"Filter Pandas Dataframe using an arbitrary number of conditions","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to insert date and time into mongo ,using pymongo.\nHowever, I can insert datetime but not just date or time .\nhere is the example code :\nnow = datetime.datetime.now()\nlog_date = now.date()\nlog_time = now.time()\nself.logs['test'].insert({'log_date_time': now, 'log_date':log_date, 'log_time':log_time})\nit show errors :\nbson.errors.InvalidDocument: Cannot encode object: datetime.time(9, 12, 39, 535769)\nin fact , i don't know how to insert just date or time in mongo shell  too.\ni  know insert datetime is new Date(), but I just want the date or time filed.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":515,"Q_Id":47148516,"Users Score":0,"Answer":"You are experiencing the defined behavior.  MongoDB has a single datetime type (datetime).   There are no separate, discrete types of just date or just time.\nWorkarounds:  Plenty, but food for thought:\nStoring just date is straightforward:  assume Z time, use a time component of 00:00:00, and ignore the time offset upon retrieval.\nStoring just time is trickier but doable:  establish a base date like the epoch and only vary the time component, and ignore the date component upon retrieval.","Q_Score":0,"Tags":"python,mongodb,datetime,pymongo","A_Id":47148634,"CreationDate":"2017-11-07T01:23:00.000","Title":"questions about using pymongo to insert date and time into mongo","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is it possible to use Scrapy to generate a sitemap of a website including the URL of each page and its level\/depth (the number of links I need to follow from the home page to get there)? The format of the sitemap doesn't have to be XML, it's just about the information. Furthermore I'd like to save the complete HTML source of the crawled pages for further analysis instead of scraping only certain elements from it.\nCould somebody experienced in using Scrapy tell me whether this is a possible\/reasonable scenario for Scrapy and give me some hints on how to find instructions? So far I could only find far more complex scenarios but no approach for this seemingly simple problem.\nAddon for experienced webcrawlers: Given it is possible, do you think Scrapy is even the right tool for this? Or would it be easier to write my own crawler with a library like requests etc.?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1378,"Q_Id":47160587,"Users Score":-1,"Answer":"Yes, it's possible to do what you're trying with Scrapy's LinkExtractor library. This will help you document the URLs for all of the pages on your site. \nOnce this is done, you can iterate through the URLs and the source (HTML) for each page using the urllib Python library. \nThen you can use RegEx to find whatever patterns you're looking for within the HTML for each page in order to perform your analysis.","Q_Score":5,"Tags":"python,scrapy,scrapy-spider","A_Id":61992037,"CreationDate":"2017-11-07T14:39:00.000","Title":"Sitemap creation with Scrapy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wonder how does Postgres sever determine to close a DB connection, if I forgot at the Python source code side. \nDoes the Postgres server send a ping to the source code? From my understanding, this is not possible.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":41,"Q_Id":47166301,"Users Score":2,"Answer":"When your script quits your connection will close and the server will clean it up accordingly. Likewise, it's often the case in garbage collected languages like Python that when you stop using the connection and it falls out of scope it will be closed and cleaned up.\nIt is possible to write code that never releases these resources properly, that just perpetually creates new handles, something that can be problematic if you don't have something server-side that handles killing these after some period of idle time. Postgres doesn't do this by default, though it can be configured to, but MySQL does.\nIn short Postgres will keep a database connection open until you kill it either explicitly, such as via a close call, or implicitly, such as the handle falling out of scope and being deleted by the garbage collector.","Q_Score":0,"Tags":"python,database,postgresql","A_Id":47166411,"CreationDate":"2017-11-07T19:49:00.000","Title":"How does Postges Server know to keep a database connection open","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm still pretty new to Python and I am still confused about using a parameter vs an argument. For example, how would I write a function that accepts a string as an argument?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":28483,"Q_Id":47169033,"Users Score":0,"Answer":"A parameter is the placeholder; an argument is what holds the place.\nParameters are conceptual; arguments are actual.\nParameters are the function-call signatures defined at compile-time; Arguments are the values passed at run-time.\nMnemonic: \"Pee\" for Placeholder Parameters, \"Aeigh\" for Actual Arguments.","Q_Score":31,"Tags":"python,string,function,parameters,arguments","A_Id":70921285,"CreationDate":"2017-11-07T23:21:00.000","Title":"Parameter vs Argument Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The purpose is to implement a pool like database connection pool in my web application. My application is write by Django.\nThe problem is that every time a http request come, my code  will be loaded and run through. So if I write some code to initiate a pool. These code will be run per http request. And the pool will be initiated per request. So it is meaningless.\nSo how should I write this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":917,"Q_Id":47173204,"Users Score":0,"Answer":"Your understanding of how things work is wrong, unfortunately. The way Django runs is very much dependent on the way you are deploying it, but in almost all circumstances it does not load code or initiate globals on every request. Certainly, uWSGI does not behave that way; it runs a set of long-lived workers that persist across many requests.\nIn effect, uWSGI is already a connection pool. In other words, you are trying to solve a problem that does not exist.","Q_Score":0,"Tags":"python,django,web-applications,connection-pool","A_Id":47176595,"CreationDate":"2017-11-08T06:45:00.000","Title":"How to implement a connection pool in web application like django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"After running sudo pip install google.cloud.pubsub\nI am running the following python code in ubtunu google compute engine:\nimport google.cloud.pubsub_v1\nI get the following error when importing this:\n\nImportError: No module named pubsub_v1 attribute 'SubscriberClient'\n\nCan anyone tell me how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":558,"Q_Id":47193190,"Users Score":1,"Answer":"Update your google-cloud-pubsub to the latest version. It should resolve the issue","Q_Score":2,"Tags":"python,cloud,publish-subscribe","A_Id":51531222,"CreationDate":"2017-11-09T03:02:00.000","Title":"AttributeError: 'module' object has no attribute 'SubscriberClient'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm new to asyncio and I was wondering how you prevent race conditions from occuring.  I don't see implementation for locks - is there a different way this is handled?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":704,"Q_Id":47231950,"Users Score":1,"Answer":"asyncio only runs one coroutine at a time and only switches at points you define, so race conditions aren't really a thing.  Since you're not worried about race conditions, you're not really worried about locks (although technically you could still get into a deadlock situation if you have 2 coroutines that wake each other, but you'd have to try really hard to make that happen)","Q_Score":1,"Tags":"python,python-3.x","A_Id":47231983,"CreationDate":"2017-11-10T22:15:00.000","Title":"Race Conditions with asyncio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using python 3.6.2 on WSL (Windows Linux subsystem) and trying to set tensorflow environment (and installing some other libraries as well). However, i always get an error when I exit and login again:\nModuleNotFoundError: No module named 'tensorflow'\nSo I have to reinstall the libraries again and the problem will be fixed until I logout again. This problem only happens with my python3. I also tried python3 and use import tensorflow to find the library, but it also returned the same error. \nI think the problem may be related with system path because python cannot find the library in its original searching directory. when i enter sys.path it returns:\n['', '\/home\/jeoker\/anaconda3\/lib\/python36.zip', '\/home\/jeoker\/anaconda3\/lib\/python3.6', '\/home\/jeoker\/anaconda3\/lib\/python3.6\/lib-dynload', '\/home\/jeoker\/anaconda3\/lib\/python3.6\/site-packages']\nBut when I do conda list, the result always show the files in \/home\/jeoker\/anaconda2. I tried sudo pip3 install tensorflow, but it gived me this: Requiement already satisfied. It seems that the path where the libraries are installed is not the same as where python is looking into.\nDoes anyone know how can I fix this problem? thanks in advance!!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1381,"Q_Id":47252394,"Users Score":0,"Answer":"Well, since no one is answering this question, I have to close the question. What I did to overcome the issue was just to uninstall the whole WSL and reinstall it.","Q_Score":2,"Tags":"python,python-3.x,windows-subsystem-for-linux","A_Id":48129500,"CreationDate":"2017-11-12T18:32:00.000","Title":"WSL python3 ModuleNotFoundError: No module named xxx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Recently, I learnt how to write\/delete\/read a file in Python (I am a beginner). However, something has got me thinking: is it possible to write\/delete\/read a file  in a different user account from the same network (i.e same ip address)? If so, how? Don't worry, I'll just try it at home. ;)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":47270367,"Users Score":0,"Answer":"If you can remove the file without Python, then you can remove it with Python. Otherwise, the answer is \"no\".","Q_Score":0,"Tags":"python,file,networking","A_Id":47270457,"CreationDate":"2017-11-13T17:42:00.000","Title":"How can you write\/delete\/read a file in a different user account with the same ip address with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Recently, I learnt how to write\/delete\/read a file in Python (I am a beginner). However, something has got me thinking: is it possible to write\/delete\/read a file  in a different user account from the same network (i.e same ip address)? If so, how? Don't worry, I'll just try it at home. ;)","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":47270367,"Users Score":0,"Answer":"This is running into more of an OS question. The answer is if you have permission to do so then yes you can but if you do not have permissions over the file then you cannot.","Q_Score":0,"Tags":"python,file,networking","A_Id":47270609,"CreationDate":"2017-11-13T17:42:00.000","Title":"How can you write\/delete\/read a file in a different user account with the same ip address with python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using OpenCV's Optical Flow module. I understand the examples in the documentation but those take the entire image and then get the optical flow over the image.\nI only want to pass it over some parts of an image. Is it possible to do that? If yes, how do I go about it?\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":279,"Q_Id":47277332,"Users Score":0,"Answer":"Yes, it's possible. cv2.calcOpticalFlowPyrLK() will be the optical flow function you need. Before you make that function call, you will have to create an image mask. I did a similar project, but in C++, though I can outline the steps for you:\n\nCreate an empty matrix with same width and height of your images\nUsing the points from your ROI, create a shape out of it (I did mine using cv2.fillPoly()) and fill the inside of the shape with white (Your image mask should only be comprised of black and white color)\nIf you are planning on using corners as features, then call cv2.goodFeaturesToTrack() and pass in the mask you've made as one of its arguments. \nIf you're using the Feature2D module to detect features, you can use the same mask to only extract the features in that masked area.   \nBy this step, you should now have a collection of features\/points that are only within the bounds of the shape! Call the optical flow function and then process the results.\n\nI hope that helps.","Q_Score":0,"Tags":"python,opencv,opticalflow,cv2","A_Id":47689288,"CreationDate":"2017-11-14T03:49:00.000","Title":"cv2 running optical flow on particular rectangles","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a Windows computer and have been using Git Bash up until now without a problem. However, Git Bash seems to be missing some commands that Cygwin can provide, so I switched to Cygwin.\nI need to use AWS CLI with Cygwin but any time I input any aws command, I get the following error:\n\nC:\\users\\myusername\\appdata\\local\\programs\\python\\python36\\python.exe:\n  can't open file\n  '\/cygdrive\/c\/Users\/myusername\/AppData\/Local\/Programs\/Python\/Python36\/Scripts\/aws':\n  [Errno 2] No such file or directory\n\nI've seen other questions about getting Cygwin working with AWS, but they seem to talk about AWS CLI being incompatible with Windows' Anaconda version of Python (which mine doesn't seem to be). Any thoughts on how to fix this? Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":942,"Q_Id":47289424,"Users Score":0,"Answer":"Ok, so I spent ages trying to do this as well because I wanted to get setup on the fast.ai course. Nothing seemed to work. However, I uninstalled Anaconda3 and installed Anaconda2 instead. That did the trick!","Q_Score":0,"Tags":"python,amazon-web-services,cygwin,aws-cli","A_Id":47595992,"CreationDate":"2017-11-14T15:24:00.000","Title":"AWS CLI not working in Cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am working on a Windows computer and have been using Git Bash up until now without a problem. However, Git Bash seems to be missing some commands that Cygwin can provide, so I switched to Cygwin.\nI need to use AWS CLI with Cygwin but any time I input any aws command, I get the following error:\n\nC:\\users\\myusername\\appdata\\local\\programs\\python\\python36\\python.exe:\n  can't open file\n  '\/cygdrive\/c\/Users\/myusername\/AppData\/Local\/Programs\/Python\/Python36\/Scripts\/aws':\n  [Errno 2] No such file or directory\n\nI've seen other questions about getting Cygwin working with AWS, but they seem to talk about AWS CLI being incompatible with Windows' Anaconda version of Python (which mine doesn't seem to be). Any thoughts on how to fix this? Thanks.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":942,"Q_Id":47289424,"Users Score":0,"Answer":"You are mixing cygwin posix path with with a not cygwin Python.\nC:\\users\\myusername\\appdata\\local\\programs\\python\\python36\\python.exe \nIs not the cygwin python so it can't open the file as \n\/cygdrive\/c\/Users\/myusername\/AppData\/Local\/Programs\/Python\/Python36\/Scripts\/aws is not a windows path that it can understand . Only Cygwin programs understand it.\nTwo possible solutions:\n1 Use a windows path\n2 Use a cygwin Python","Q_Score":0,"Tags":"python,amazon-web-services,cygwin,aws-cli","A_Id":47312502,"CreationDate":"2017-11-14T15:24:00.000","Title":"AWS CLI not working in Cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have anaconda 3 with python 3 that works perfectly in anaconda prompt but I want to make anaconda python my default python. file names 'python.exe' is located at 'C:\\ProgramData\\Anaconda3\\python.exe' but when I go to PATH Variables there's no file named python in Anaconda3 folder. Any suggestions on how to do it?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4281,"Q_Id":47290296,"Users Score":1,"Answer":"C:\\ProgramData\\Anaconda3;C:\\ProgramData\\Anaconda3\\Scripts;C:\\ProgramData\\Anaconda3\\Library\\bin;\nThese three settings should be set automatically in the path folder by Anaconda? If not done automatically, put them at the very beginning of the list.","Q_Score":2,"Tags":"python,python-3.x,path,anaconda,conda","A_Id":47290366,"CreationDate":"2017-11-14T16:09:00.000","Title":"How can I set Anaconda3 python my default on windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used Python Faker for generating fake data. But I need to know what is the maximum number of distinct fake data (eg: fake names) can be generated using faker (eg: fake.name() ).\nI have generated 100,000 fake names and I got less than 76,000 distinct names. I need to know the maximum limit so that I can know how much we can scale using this package for generating data. \nI need to generate huge dataset. I also want to know is Php faker, perl faker are all same for different environments? \nOther packages for generating huge dataset will be highly appreciated.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1947,"Q_Id":47299415,"Users Score":2,"Answer":"I had this same issue and looked more into it.\nIn the en_US provider there about 1000 last names and 750 first names for about 750000 unique combos. If you randomly select a first and last name, there is a chance you'll get duplicates. But in reality, that's how the real world works, there are many John Smiths and Robert Doyles out there.\nThere are 7203 first names and 473 last names in the en profile which can kind of help. Faker chooses the combo of first name and last name meaning there are about 7203 * 473 = 3407019.\nBut still, there is a chance you'll get duplicates.\nI solve this problem by adding numbers to names. \n\nI need to generate huge dataset.\n\nKeep in mind that in reality, any huge dataset of names will have duplicates. I work with large datasets (> 1 million names) and we see a ton of duplicate first and last names.\nIf you read the faker package code, you can probably figure out how to modify it so you get all 3M distinct names.","Q_Score":6,"Tags":"python,faker","A_Id":51228688,"CreationDate":"2017-11-15T04:34:00.000","Title":"Maximum Limit of distinct fake data using Python Faker package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to make output 22\/\/7 on python 2.7 become 3.14159 ?i try use float(22\/7) but it just give me 3.0. I try use Decimal but it just give me 3, use round(x, 6) only give 3.0 just like float.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":780,"Q_Id":47301667,"Users Score":1,"Answer":"Here, int\/int will return int only that is what happening here 22\/7 gives 3 and you're type casting it to float(3) which is giving 3.0 but if you will perform float\/int or int\/float then it will result into float so you convert any of them to float as shown following.\nreplace float(22\/7) with float(22)\/7","Q_Score":0,"Tags":"python,python-3.x,python-2.7","A_Id":47301713,"CreationDate":"2017-11-15T07:28:00.000","Title":"different result 22\/7 on python 2.7.12 and 3.6","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using C# CNTK 2.2.0 API for training.\nI have installed Nuget package CNTK.CPUOnly and CNTK.GPU.\nI am looking for following learners in C#.\n1. AdaDelta\n2. Adam\n3. AdaGrad\n4. Neterov\nLooks like Python supports these learners but C#\npackage is not showing them.\nI can see only SGD and SGDMomentun learners in C# there.\nAny thoughts, how to get and set other learners in C#.\nDo I need to install any additional package to get these learners?\nAppreciate your help.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":447,"Q_Id":47324511,"Users Score":0,"Answer":"Checked that CNTKLib is providing those learners in CPUOnly package.\nNestrov is missing in there but present in python.\nThere is a difference while creating the trainer object \nwith CNTKLib learner function vs Learner class.\nIf a learner class is used, \nnet parameters are provided as a IList.\nThis can be obtained using netout.parameter() ;\nIf CNTKLib is used, \nparameters are provided as ParameterVector. \nBuild ParameterVector while building the network.\nand provide it while creating Trainer object.\nParameterVector pv = new ParameterVector () \npv.Add(weightParameter)\npv.Add(biasParameter)\nThanks everyone for your answers.","Q_Score":0,"Tags":"c#,python,cntk","A_Id":47371621,"CreationDate":"2017-11-16T08:07:00.000","Title":"Learners in CNTK C# API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using C# CNTK 2.2.0 API for training.\nI have installed Nuget package CNTK.CPUOnly and CNTK.GPU.\nI am looking for following learners in C#.\n1. AdaDelta\n2. Adam\n3. AdaGrad\n4. Neterov\nLooks like Python supports these learners but C#\npackage is not showing them.\nI can see only SGD and SGDMomentun learners in C# there.\nAny thoughts, how to get and set other learners in C#.\nDo I need to install any additional package to get these learners?\nAppreciate your help.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":447,"Q_Id":47324511,"Users Score":0,"Answer":"Download the NCCL 2 app to configure in c# www.nvidia. com or google NCCL download","Q_Score":0,"Tags":"c#,python,cntk","A_Id":47324718,"CreationDate":"2017-11-16T08:07:00.000","Title":"Learners in CNTK C# API","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to solve Optimisation problem with pyomo (Pyomo 5.3 (CPython 2.7.13 on Linux 3.10.0-514.26.2.el7.x86_64)) using CBC solver (Version: 2.9.8) and specifying a time limit in solver of 60 sec. The solver is getting a feasible solution (-1415.8392) but apparently not yet optimal (-1415.84) as you can see below.\nAfter time limit ends model seemingly exits with an error code. I want to print or get values of all variables of feasible solution using CBC in specified time limit. Or is there any other way by which I can set, if Model gets 99% value of an Optimal solution, to exit and print the feasible solution.\nThe error code is posted below.\n\nCbc0004I Integer solution of -1415.8392 found after 357760 iterations and 29278 nodes (47.87 seconds)\nCbc0010I After 30000 nodes, 6350 on tree, -1415.8392 best solution, best possible -1415.84 (48.87 seconds)\nCbc0010I After 31000 nodes, 6619 on tree, -1415.8392 best solution, best possible -1415.84 (50.73 seconds)\nCbc0010I After 32000 nodes, 6984 on tree, -1415.8392 best solution, best possible -1415.84 (52.49 seconds)\nCbc0010I After 33000 nodes, 7384 on tree, -1415.8392 best solution, best possible -1415.84 (54.31 seconds)\nCbc0010I After 34000 nodes, 7419 on tree, -1415.8392 best solution, best possible -1415.84 (55.73 seconds)\nCbc0010I After 35000 nodes, 7824 on tree, -1415.8392 best solution, best possible -1415.84 (57.37 seconds)\nTraceback (most recent call last):\n  File \"model_final.py\", line 392, in \n    solver.solve(model, timelimit = 60*1, tee=True)\n  File \"\/home\/aditya\/0r\/lib\/python2.7\/site-packages\/pyomo\/opt\/base\/solvers.py\", line 655, in solve\n    default_variable_value=self._default_variable_value)\n  File \"\/home\/aditya\/0r\/lib\/python2.7\/site-packages\/pyomo\/core\/base\/PyomoModel.py\", line 242, in load_from\n    % str(results.solver.status))\nValueError: Cannot load a SolverResults object with bad status: error\n\nWhen I run the model generated by pyomo manually using the same command-line parameters as pyomo \/usr\/bin\/cbc -sec 60 -printingOptions all -import \/tmp\/tmpJK1ieR.pyomo.lp -import -stat=1 -solve -solu \/tmp\/tmpJK1ieR.pyomo.soln it seems to exit normally and also writes the solution as shown below.\n\nCbc0010I After 35000 nodes, 7824 on tree, -1415.8392 best solution, best possible -1415.84 (57.06 seconds)\nCbc0038I Full problem 205 rows 289 columns, reduced to 30 rows 52 columns\nCbc0010I After 36000 nodes, 8250 on tree, -1415.8392 best solution, best possible -1415.84 (58.73 seconds)\nCbc0020I Exiting on maximum time\nCbc0005I Partial search - best objective -1415.8392 (best possible -1415.84), took 464553 iterations and 36788 nodes (60.11 seconds)\nCbc0032I Strong branching done 15558 times (38451 iterations), fathomed 350 nodes and fixed 2076 variables\nCbc0035I Maximum depth 203, 5019 variables fixed on reduced cost\nCbc0038I Probing was tried 31933 times and created 138506 cuts of which 0 were active after adding rounds of cuts (4.431 seconds)\nCbc0038I Gomory was tried 30898 times and created 99534 cuts of which 0 were active after adding rounds of cuts (4.855 seconds)\nCbc0038I Knapsack was tried 30898 times and created 12926 cuts of which 0 were active after adding rounds of cuts (8.271 seconds)\nCbc0038I Clique was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)\nCbc0038I MixedIntegerRounding2 was tried 30898 times and created 13413 cuts of which 0 were active after adding rounds of cuts (3.652 seconds)\nCbc0038I FlowCover was tried 100 times and created 4 cuts of which 0 were active after adding rounds of cuts (0.019 seconds)\nCbc0038I TwoMirCuts was tried 30898 times and created 15292 cuts of which 0 were active after adding rounds of cuts (2.415 seconds)\nCbc0038I Stored from first was tried 30898 times and created 15734 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)\nCbc0012I Integer solution of -1411.9992 found by Reduced search after 467825 iterations and 36838 nodes (60.12 seconds)\nCbc0020I Exiting on maximum time\nCbc0005I Partial search - best objective -1411.9992 (best possible -1415.4522), took 467825 iterations and 36838 nodes (60.12 seconds)\nCbc0032I Strong branching done 476 times (1776 iterations), fathomed 1 nodes and fixed 18 variables\nCbc0035I Maximum depth 21, 39 variables fixed on reduced cost\nCuts at root node changed objective from -1484.12 to -1415.45\nProbing was tried 133 times and created 894 cuts of which 32 were active after adding rounds of cuts (0.060 seconds)\nGomory was tried 133 times and created 1642 cuts of which 0 were active after adding rounds of cuts (0.047 seconds)\nKnapsack was tried 133 times and created 224 cuts of which 0 were active after adding rounds of cuts (0.083 seconds)\nClique was tried 100 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.001 seconds)\nMixedIntegerRounding2 was tried 133 times and created 163 cuts of which 0 were active after adding rounds of cuts (0.034 seconds)\nFlowCover was tried 100 times and created 5 cuts of which 0 were active after adding rounds of cuts (0.026 seconds)\nTwoMirCuts was tried 133 times and created 472 cuts of which 0 were active after adding rounds of cuts (0.021 seconds)\nImplicationCuts was tried 25 times and created 41 cuts of which 0 were active after adding rounds of cuts (0.003 seconds)\n\nResult - Stopped on time limit\n\nObjective value:                -1411.99922848\nLower bound:                    -1415.452\nGap:                            0.00\nEnumerated nodes:               36838\nTotal iterations:               467825\nTime (CPU seconds):             60.13\nTime (Wallclock seconds):       60.98\n\nTotal time (CPU seconds):       60.13   (Wallclock seconds):       61.01\n\nThe top few lines of the CBC solution file are:\n\nStopped on time - objective value -1411.99922848\n      0 c_e_x1454_                         0                       0\n      1 c_e_x1455_                         0                       0\n      2 c_e_x1456_                         0                       0\n      3 c_e_x1457_                         0                       0\n      4 c_e_x1458_                         0                       0\n      5 c_e_x1459_                         0                       0\n      6 c_e_x1460_                         0                       0\n      7 c_e_x1461_                         0                       0\n      8 c_e_x1462_                         0                       0\n\nCan anyone tell me how can I get these values without generating any error?\nThanks in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1241,"Q_Id":47334254,"Users Score":0,"Answer":"You could try to set the bound gap tolerance such that it will accept the other answer. I'm surprised that the solver status is coming back with error if there is a feasible solution found. Could you print out the whole results object?","Q_Score":0,"Tags":"python-2.7,pyomo,coin-or-cbc","A_Id":47336205,"CreationDate":"2017-11-16T16:08:00.000","Title":"Error reported while running pyomo optimization with cbc solver and using timelimit","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I'm writing a graphics program in Python and I would like to know how to make a Canvas update only on-demand; that is, stop a canvas from updating every run of the event loop and instead update only when I tell it to.\nI want to do this because in my program I have a separate thread that reads graphics data from standard input to prevent blocking the event loop (given that there's no reliable, portable way to poll standard input in Python, and polling sucks anyway), but I want the screen to be updated only at intervals of a certain amount of time, not whenever the separate thread starts reading input.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":467,"Q_Id":47337197,"Users Score":3,"Answer":"You can't pause the update of the canvas without pausing the entire GUI.\nA simple solution would be for you to not draw to the canvas until you're ready for the update. Instead of calling canvas commands, push those commands onto a queue. When you're ready to refresh the display, iterate over the commands and run them. \nYou could also do your own double-buffering, where you have two canvases. The one you are actively drawing would be behind the visible one. When you are ready to display the results, swap the stacking order of the canvases.","Q_Score":0,"Tags":"python-3.x,tkinter,tkinter-canvas","A_Id":47337880,"CreationDate":"2017-11-16T18:57:00.000","Title":"How to make tkinter Canvas update only on-demand?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a Reddit bot with praw, and I want to have the bot do things based on private messages sent to it. I searched the documentation for a bit, but couldn't find anything on reading private messages, only sending them. I want to get both the title and the content of the message. So how can I do this?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":527,"Q_Id":47340391,"Users Score":2,"Answer":"Didn't find it in the docs, but a friend who knows a bit of raw helped me out.\nUse for message in r.inbox.messages() (where r is an instance of reddit) to get the messages.\nUse message.text to get the content, and message.subject to get the title.","Q_Score":1,"Tags":"python,praw","A_Id":47340599,"CreationDate":"2017-11-16T22:45:00.000","Title":"How to read private messages with PRAW?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I would like to fit a generalized ordered logit model to some data I have. I first tried to use the ordered logit model using the MASS package from R, but it seems that the proportional odds assumption is violated by the data. Indeed, not all independent variables do exert the same effect across all categories of the dependent variable. Hence I am a bit blocked. I say that I could use the generalized ordered logit model instead, but could not find how to use it. Indeed, I can not find any package on either R or python that coud help me on that. \nIf someone has any hints on packages I could use, it would be of great help!\nThank you very much!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1939,"Q_Id":47346321,"Users Score":0,"Answer":"Try the 'VGAM' package. There is a function called vglm.\nexample: vglm(Var2~factor(Var1),cumulative(parallel = F),data) generalized order model\ncumulative(parallel=T) will perform a proportional odds model.\nparallel=F is the default.","Q_Score":3,"Tags":"python,r,logistic-regression","A_Id":59307014,"CreationDate":"2017-11-17T08:33:00.000","Title":"generalized ordered logit in R or python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to move from using stan in R (I've mainly used the brms package) to pystan, but having trouble locating any methods in pystan that will give me predictive posterior distributions for new data. In R, I've been using brms::posterior_linpred() to do this. Does anyone know if this is possible in pystan?\nIf not, can it be bolted on without too much problem?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":174,"Q_Id":47351601,"Users Score":1,"Answer":"As far as I know, they are not any Python libraries that do what the brms and rstanarm R packages do, i.e. come with precompiled Stan models that allow users to draw from the predictive distribution in the high-level language. There are things like prophet and survivalstan but those are for a pretty niche set of models.","Q_Score":0,"Tags":"python,r,stan","A_Id":47353749,"CreationDate":"2017-11-17T13:20:00.000","Title":"how to obtain predictive posteriors in pystan?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run my compiled program (cx_Freeze) it says __init__line 31. no module named codecs.\nI have Python 3.6, does anybody know why it says that, and how to maybe fix it?\nI have seen the other questions here on StackOverflow, but they don't seem to solve the problem for me and possibly other too.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":541,"Q_Id":47359677,"Users Score":1,"Answer":"If you are using cx_Freeze 5.1, there was a bug that resulted in this error. It has been corrected in the source so if you checkout the latest source and compile it yourself it should work for you. If not, let me know!","Q_Score":1,"Tags":"python,python-3.x,cx-freeze","A_Id":47395605,"CreationDate":"2017-11-17T21:38:00.000","Title":"Python cx_Freeze __init__ \"no module named codecs\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I created and installed a python package by doing the following: coding a bunch of functions in an init.py file and run  'python setup.py install dist' to create a tar.gz, which was installed through pip.\nEverything works well and I can import the package and the functions.\nI decided to add a new function in the init file, and redid the whole procedure described above to reinstall (or update) my package. \nThe new function added doesn't seem to be available when importing the package, even after update.\nAny ideas on how to update my package?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":931,"Q_Id":47362271,"Users Score":1,"Answer":"As @metatoaster suggested,  python setup.py develop  reflects changes immediately in the environment, and makes the new functions available.\nI haven't tried @Paul H's suggestion which is  pip install . -e.\nThank you both for your comments, problem is solved.","Q_Score":3,"Tags":"python,pip","A_Id":47368605,"CreationDate":"2017-11-18T03:44:00.000","Title":"Python: upgrade my own package","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to python\/django\/pip. I created a virtualenv and I was in the bin dir when I did a pip install django. It created the django files there which is not what I wanted. So I did pip uninstall django. Then I created a folder called web in my virtualenv root and tried pip install again. This time it said loading from cache and installed django in bin folder again. So I deleted it and tried again with --no-cache-dir. This downloaded django fresh, but I am still finding the installation in bin directory! This is driving me crazy, how can I get it to install in the web directory?\nAny help much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":801,"Q_Id":47370367,"Users Score":1,"Answer":"You can't tell pip where to install packages. There's a standard place for packages, and that's where it installs them. \npip makes sure it installs utilities (such as django-admin) in the path, so when the virtual environment is activated you can run it.","Q_Score":1,"Tags":"python,django,pip,virtualenv","A_Id":47370397,"CreationDate":"2017-11-18T19:52:00.000","Title":"Django not installing in folder where I want","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making an elimination style voting website. People log in, vote for their least favorite participant, and at the end of the day the person with the most votes goes inactive. Almost everything works: The log in, the voting, etc. But I have no idea how to make a program that checks for the most votes and alters the database to change the status of a participant at a particular time without needing a user to enter the website. \nI don't even know where to put the code. And how would I make sure it's constantly running? The way I see it, views.py only works when a user goes to the URL, so if no one visited the website at the time of vote recopilation it wouldn't work, so that's a no no. I could make a script outside of the Django project that does this, and then run it with nohup &, but then I'd lose on the model notation and would have to make manual queries, plus I'm sure there's a better, more Django way to do this.\nAny solutions to this problem? Or maybe some direction you can point me in?","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":47373656,"Users Score":0,"Answer":"The answer is django celery. Its for any tasks which need to be run with a condition. Look at the beats functionality for your use in celery","Q_Score":0,"Tags":"python,sql,django","A_Id":47373721,"CreationDate":"2017-11-19T04:22:00.000","Title":"How to make a code that alters database in background Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making an elimination style voting website. People log in, vote for their least favorite participant, and at the end of the day the person with the most votes goes inactive. Almost everything works: The log in, the voting, etc. But I have no idea how to make a program that checks for the most votes and alters the database to change the status of a participant at a particular time without needing a user to enter the website. \nI don't even know where to put the code. And how would I make sure it's constantly running? The way I see it, views.py only works when a user goes to the URL, so if no one visited the website at the time of vote recopilation it wouldn't work, so that's a no no. I could make a script outside of the Django project that does this, and then run it with nohup &, but then I'd lose on the model notation and would have to make manual queries, plus I'm sure there's a better, more Django way to do this.\nAny solutions to this problem? Or maybe some direction you can point me in?","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":41,"Q_Id":47373656,"Users Score":1,"Answer":"If your scenario is just to update the database based on the number of votes, you can straight away go for cron.\nWrite a script that checks for the votes and changes the status of the user in the database. Schedule it in cron to run it once at the end of the day \/ poll.\nPlace the script in a directory that is not reachable by outsiders.\ncron entry for a script to run once a day at 23:30 hrs:\n30 23 * * * python \/root\/scripts\/status_change_script.py","Q_Score":0,"Tags":"python,sql,django","A_Id":47373793,"CreationDate":"2017-11-19T04:22:00.000","Title":"How to make a code that alters database in background Django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know you can probably do a limit of a mathematical operation, say the limit of n + 1 as n approaches infinity, but can I do the limit of a function? For instances the limit of dividing to Fibonacci numbers as their index (and value) gets greater, approaching infinity? For example\nlim(func, start, approach)\nI have looked at sympy, and it is either not possible or I don't know how to pass a symbol argument as an integer. Eg:\niters = Symbol(\"iters\")\nprint limit(main(iters),iters,0)","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":148,"Q_Id":47383691,"Users Score":1,"Answer":"I didn't need to make my integer a symbol.\nThe code above works.","Q_Score":2,"Tags":"python,python-2.7,math","A_Id":47383747,"CreationDate":"2017-11-20T00:55:00.000","Title":"Do A Limit on the Output of a Function in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I'm trying to get a working code in Python that will eject\/unmount all USB flash drives attached to the Pi (Running Raspbian) - so that they can be removed safely. The final code will be run from within the python program. \nAdditionally, I'd like to eject\/unmount the USB flash drive even if it's in use. \nI've looked around and can't see how to do this. Thanks. \n\nudisks --detach \/media\/pi\/DOCS\/ - 'Blocked device... Resource temporarily available'... \nudisks --detach \/media\/pi\/ - 'Blocked device...Resource temporarily available'... \nudisks --detach \/media\/ - 'Blocked device...Resource temporarily available'... \nsudo udisks --detach \/media\/pi\/DOCS\/ - still blocked...\nsudo umount \/path\/to\/devicename - command not found...\neject \/media\/pi\/DOCS\/ - Unable to open '\/dev\/sda'\n(DOCS is the name if my USB flash drive. - though I want to eject all USB flash drives - not just my one)\n\nSo I'm going to ask the user in Python to select their USB flash drive from a list, which is pretty easy (just read in the folder) - so I will have the pathway to the USB. I'm still not sure which code can safely disconnect the USB flash drive - Maybe more research is the answer. Thanks for your help so far.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6438,"Q_Id":47418025,"Users Score":2,"Answer":"For udisks --detach the parameter should be the device, not the mounting point.\nFor example, if the USB Disk is \/dev\/sdb the command would be udisks --detach \/dev\/sdb\nIf the command still doesn't work you could try udiskctl power-off -b <device> which should also work.","Q_Score":2,"Tags":"bash,python-3.x,raspberry-pi,raspbian","A_Id":47431418,"CreationDate":"2017-11-21T16:30:00.000","Title":"Ejecting\/unmounting random USB flash drive in Raspberry pi \/ Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am not sure what it is called. I have seen a installer program have stored data at the end of the installer script, looked like just a mess of random text, which then got turn into a seperate file upon running the installer. There was some comand that said something like line xxx -> end | file.txt. Im so sorry if this makes no sense but if anyone knows what I am looking for id like to do the same thing in a python script. directions to a resource or an explination on how to do it here would be great thanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":47422506,"Users Score":0,"Answer":"One reason shell scripts do this is that a shell variable cannot contain arbitrary binary data (namely, null bytes). Python variables have no such limitations; just store the data in a variable.","Q_Score":0,"Tags":"python,python-3.x,file,io","A_Id":47422562,"CreationDate":"2017-11-21T20:52:00.000","Title":"Store a file insde python file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For now, I'm trying to use flask-oauthlib with flask-login together.\nflask-oauthlib provides a simple way to use oauth, but I want a login manager to automatically redirect all users who are not logged in to \/login. In flask-login, I can use login_required to accomplish this. But how could I achieve this by flask-oauthlib?\nFurther, how to manage session when using flask-oauthlib? I understand how SSO works, but I'm confusing how could I know if this token is expired or not?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":504,"Q_Id":47449444,"Users Score":0,"Answer":"So, I've spent some time thinking about this (as I want to do it for my own website), and I've come up with a theoretical solution.\nFrom what I understand in my implementation of Google's OAuth API, OAuth is about sending the user on a link to the server that hosts the OAuth keys, and then returning back to the sender. So, my idea is that in the login form, you have buttons that act as links to the OAuth client.\nI haven't tested this, but since no one else has replied to this I figure this will give you a nice little project to implement yourself and let us know if it works.","Q_Score":1,"Tags":"python,flask,single-sign-on,flask-login,flask-oauthlib","A_Id":47532413,"CreationDate":"2017-11-23T07:04:00.000","Title":"How to use flask-oauthlib with flask-login together?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm wondering how I could run python3 by default when I type python in windows CMD?\nThis is not a duplicated question because I've added the C:\\Python36 to the path variables, so when I type py in CMD, it gives me python 3.6.2, while if I type py2, then it gives me python 2.7.11. \nSince now I need to run python script.py through another application, then I can't really change the command to be py script.py, so my question is how could I run python 3  if using the command python script.py? I've tried to place the python3 preceeding python2 like C:\\Python36;C:\\Python27 in the variables, but when I type python, CMD still shows python 2.7.11...I'm confused about why it didn't work..\nThank you very much in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":100,"Q_Id":47454016,"Users Score":0,"Answer":"OK! I figured out the issue - The python36 folder was not placed in the C: location. Now I've corrected it and it's working for me! Thanks!","Q_Score":0,"Tags":"windows,python-3.x,variables,cmd,path","A_Id":47454887,"CreationDate":"2017-11-23T11:06:00.000","Title":"How to run Python 3 when I type \"python\" in windows CMD","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using the Python3, Django and database as Postgresql, and I wanted to use the Thingsboard dashboard in my web application. can anyone pls guide me how can I use this","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":304,"Q_Id":47454686,"Users Score":0,"Answer":"ThingsBoard has APIs which you can use. You may also customise it based on your requirements.","Q_Score":0,"Tags":"django,python-3.x,postgresql,mqtt,thingsboard","A_Id":47798648,"CreationDate":"2017-11-23T11:41:00.000","Title":"I am using the python django, and i wanted to know to get use thingsboard dashboard, and database as postgresql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to convert a string acbdefrg into an array of individual letters [a,b,c,d,e,f,r,g]. I understand how it's done in python through list(your_string).\nHoever this code does not work in jinja2. Is this possible, or will I have to make the array in python and pass it over to jinja?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":375,"Q_Id":47466390,"Users Score":1,"Answer":"If you mean to just iterate through the string, you can explicitly make the array in python and pass it into jinja.\nTry to minimise logic in jinja as much as possible.","Q_Score":0,"Tags":"python,python-3.x,jinja2","A_Id":47466422,"CreationDate":"2017-11-24T04:30:00.000","Title":"Split string into individual charactor array in jinja2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am asking this for mgx4:\nI imported a .uff file containing FRF from Experimental Modal Analysis (EMA). I generated the mesh (geometry) of the tested structure with lines and triangle surfaces. I succeed to realize the analysis and extract eigen frequencies and modal damping. What I am still unable to do is to animate the geometry according to eigen shapes as a function of eigen frequencies. When I am on the tab \"Measurement\" on the tab menu \"ANIMATION\" and I put the frequency cursor on one peak of the FRF and I click on \"Play\", I can just see one node moving. I would like to observe all the nodes moving in order to identify the eigen shape of the mode observed. Do you please have an idea on how to do that? Thank you for your help!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":45,"Q_Id":47469591,"Users Score":0,"Answer":"in animation tab try a right click on model and under \"roving type\" select\n\"response roved\".","Q_Score":0,"Tags":"python,open-source","A_Id":47469592,"CreationDate":"2017-11-24T08:56:00.000","Title":"Animating modes in openmodal: roving type","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have an issue with StaticText, and I do not know how to make it accept only the following data = '0123456789.' . Of course, when you type any letter, the letter is automatically deleted. Can you help me please","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":35,"Q_Id":47491757,"Users Score":0,"Answer":"You probably mean TextCtrl, don't you? You can use a validator, there is an example in the wxPython demo, which is a part of the Docs and Demo package.","Q_Score":0,"Tags":"wxpython","A_Id":47568957,"CreationDate":"2017-11-26T00:07:00.000","Title":"wxpython make StaticText limit","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I define for example tkinter.Button widget with parameters (width=10, height=1)(in characters) and then I want to retrieve it's size in pixels, how do I do it?\nEDIT:\nI tried widget.winfo_height() and widget.geometry(), but all these functions return height defined in number of characters. I think it would be possible to create the same widget in a frame and then write frame.winfo_height() which would return size in pixels, but this is not so elegant solution.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":5427,"Q_Id":47495285,"Users Score":9,"Answer":"Ok, I figured it out. We must call widget.update() first before calling widget.winfo_height().","Q_Score":1,"Tags":"python,tkinter,size,pixels","A_Id":47622396,"CreationDate":"2017-11-26T10:48:00.000","Title":"Get tkinter widget size in pixels","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I found that kivy is very nice framework to build cross platform application and I am very interested in kivy just to do android application as I think is easy and comfortable in kivy.\nAfter trying few examples, I am interested to know how should handle android run time permission for the kivy app.\nActually I had searched on google, but no single working example out there. Should I go back to android \/ java or it possible with kivy and some other python libs.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7102,"Q_Id":47510030,"Users Score":1,"Answer":"i know this answer is a little late, but to get permissions you have to specify them before the build. E.g buildozer uses a buildozer.spec. In this file you can specify the permissions you need.","Q_Score":4,"Tags":"android,python,kivy,android-permissions,pyjnius","A_Id":63417403,"CreationDate":"2017-11-27T11:34:00.000","Title":"How to handle android runtime permission with kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I found that kivy is very nice framework to build cross platform application and I am very interested in kivy just to do android application as I think is easy and comfortable in kivy.\nAfter trying few examples, I am interested to know how should handle android run time permission for the kivy app.\nActually I had searched on google, but no single working example out there. Should I go back to android \/ java or it possible with kivy and some other python libs.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7102,"Q_Id":47510030,"Users Score":1,"Answer":"python-for-android doesn't have any code for handling runtime permissions. I expect to look at it sooner rather than later, but there's no ETA for it.\nYou can probably add the code for it yourself if you're interested and know how. If you'd like to try it, such contributions would be very welcome.","Q_Score":4,"Tags":"android,python,kivy,android-permissions,pyjnius","A_Id":47522452,"CreationDate":"2017-11-27T11:34:00.000","Title":"How to handle android runtime permission with kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a complete newbie trying to use pycharm with python but my interpretor shows a version of 2.7 when i have installed 3.6. Totally confused and need help!\nOn pycharm I do the following steps: \nPreferences > Python Console > Python Interpretor\nI only see Python 2.7.8 (\/Library\/Framework\/....) and beneath this I see options beginning with (\/Library\/Framework.... ) <-- some of these end in bin\/python3.6\nI am not sure how to configure Pycharm to use the new version of Python. Being a complete newbie I am really confused as to what to do? and whether changing this makes any difference. \nAny help would be much appreciated. \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":3512,"Q_Id":47512599,"Users Score":1,"Answer":"Go to File > Settings > Project > Project Interpreter (it should take you there automatically as soon as you open Settings) and select the version you want to use from the drop-menu. If it is not there, try restarting PyCharm (if it was active whilst the Python 3 installation) - else, it probably means you didn't install Python 3 properly.","Q_Score":2,"Tags":"python,python-3.x,python-2.7,pycharm","A_Id":47514912,"CreationDate":"2017-11-27T13:53:00.000","Title":"Pycharm shows interpretor version of 2.7 but I have downloaded 3.6?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"how to make ensure one active session per one user using python flask?\nDescription: if one user logged in two different machines with same credentials\nI want  mechanism to force logout earlier active sessions of that user with flask and python. Please help me out in this.\nI am currently using flask-login, load_user() and login_manager libraries for login mechanism.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":821,"Q_Id":47525351,"Users Score":2,"Answer":"One way for ensuring this would be by generating a session id from server. You would need to generate a unique session id every time a user logs in and store it in some database against that user. Apart from this you would need to authenticate user every time an endpoint call, which requires user to be logged in, is made. And of course discard the session id on logout.\nThis way whenever a user logs in the old session id is discarded and the previous session no more remains valid.","Q_Score":0,"Tags":"python,session,flask,flask-login","A_Id":47525555,"CreationDate":"2017-11-28T06:36:00.000","Title":"how to make ensure one active session per one user using python flask?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"[text element].font.size returns None if the element has inherited its size from a parent text style.\nThe documentation refers to a style hierarchy but doesn't appear to include documentation about it. Does anyone know how you traverse this hierarchy to determine the actual size of a font element if it has inherited its size from somewhere else?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":322,"Q_Id":47530337,"Users Score":1,"Answer":"The hierarchy governing the inheritance of font style is knowledge that belongs to the ill-documented black arts of PowerPoint. I don't know of a place where it's clearly described.\nIf I needed to learn it, I would start with a Google search on \"powerpoint style hierarchy\" to gather candidate participants and then settle in for a long period of experimentation.\nThe candidates I can think of are, roughly in order of precedence:\n\nformatting directly applied at the run level\ndefault run formatting applied at the paragraph level (this doesn't always take effect)\nformatting inherited from a placeholder, if the shape was originally a placeholder.\nA theme related to the slide, its slide layout, or its slide master.\nA table style\nPresentation-default formatting.\n\nI would devote a generous period to getting anything I could from Google, form a set of hypotheses, then set up experiments to prove or disprove those hypotheses.\nNote the challenge is made more complex by the conditions involved, such as \"is in a table\" and \"is a placeholder\", etc.","Q_Score":3,"Tags":"python-pptx","A_Id":47537303,"CreationDate":"2017-11-28T11:22:00.000","Title":"python-pptx font size from hierarchy \/ template \/ master","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have JS running and essentially getting user entries from my HTML session storage and pushing these to a DB. I also need to use a HTTP request to pass a json object containing the entries to a python file hosted somewhere else. \nDoes anyone have any idea of documentation I could look at, or perhaps how to get JSON objects from JS to Python. \nMy client does not want me to grab the variables directly from the DB.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":37,"Q_Id":47535356,"Users Score":0,"Answer":"You have to create some sort of communication channel between the javascript and python code. This could be anything, SOAP, HTTP, RPC, any number of and flavor of message queue.\nIf nothing like that is in place, it's quite the long way around.  A complex application might warrant you doing this, think micro services communicating across some sort of service bus.   It's a sound strategy and perhaps that's why your client is asking for it.\nYou already have Firebase, though! Firebase is a real-time database that already has many of the characteristics of a queue. The simplest and most idiomatic thing to do would be to let the python code be notified of changes by Firebase: Firebase as service bus is a nice strategy too!","Q_Score":0,"Tags":"python,html,json,node.js,firebase-realtime-database","A_Id":47537413,"CreationDate":"2017-11-28T15:36:00.000","Title":"How do you pass variables using a HTTP post from a JS file\/function to a separate python file\/function hosted somewhere else?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have an HTML web page with many download links in a table. I have isolated the path to my desired zips. They all contain an .xlsx file but sometimes other files. \n\nIs there a way to avoid downloading the zips and directly accessing the files inside?\nIf I do need to download them, how can I track where the zips have been downloaded to? (So I can extract the .xlsx)\n\nI am currently looking into zipfile and requests for solutions. zipfile.extract needs the path of the zip file, but I don't know exactly where the script will download to. requests gives a response object, but how do I prompt it to download?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":35,"Q_Id":47572918,"Users Score":1,"Answer":"Is there a way to avoid downloading the zips and directly accessing the files inside?\n\nGenerally speaking : no. A web server serves files in a file system, not in a zip archive.\n\nIf I do need to download them, how can I track where the zips have been downloaded to? (So I can extract the .xlsx)\n\nIf not specified, the location is the current directory, the one the script has been launched in.","Q_Score":0,"Tags":"python,python-3.x,python-requests,zip","A_Id":47573727,"CreationDate":"2017-11-30T11:54:00.000","Title":"unzipping an html link with python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am loading a cascade classifier from a file in OpenCV using python. Since the CascadeClassifier() method requires the filename to be the absolute filename, I have to load the absolute filename.\nHowever, I am deploying and using it on Heroku and I can't seem to get the absolute path of the file. I've tried using os.getcwd() + '\\cascader_file.xml', but that still does not work.\nI would like to know how to load the classifier on the Heroku deployment","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":174,"Q_Id":47585666,"Users Score":0,"Answer":"I figured it out. All I needed to do was use the os.path.abspath() method to convert the relative path to an absolute path","Q_Score":0,"Tags":"python,opencv,heroku,cascade-classifier","A_Id":47585710,"CreationDate":"2017-12-01T02:13:00.000","Title":"Load classifier on Heroku Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a series of tests that are quite complicated. Unfortunately, the builtin Pycharm Debugger is waaay too slow to handle them. I tried making it faster, but any attempts failed, so I have to resort to using pdb. \nMy problem is that the command line that appears if I run my tests with pycharm and come across a pdb breakpoint is quite annoying:\n\nIt does not support code completion (of course I googled it, but my attempts failed). \nI can't even press 'up' to get the last command again\nMost annoyingly: When I already wrote some code in the command line and jump to the beginning of the line to edit it, the cursor automatically jumps to the end of the line.\n\nI noticed that it is not the iPython console which I get when I go into pdb debug mode when I don't use pytest.\nDo you have any idea on how to solve any of these issues? Ideally on how to speed up the Pycharm debugger, or how to get the iPython console also in pytest? \nHelp is much appreciated. Thanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":560,"Q_Id":47590564,"Users Score":0,"Answer":"A few things that might help you with debugging speed are: \n\nusing Python 3.5\/3.6. \nIf you're running in linux\/macos install the cython extension (you get prompted) \nUse the latest Pycharm, 2017.3 at this moment. \nTry to simplify tests. If not possible, just run those you need for the debugging process by creating a special runner in Pycharm and using the -k 'pattern' argument for pytest.\n\nMoreover, I don't understand why you're invoking pdb if you're using the Pycharm debugger.","Q_Score":0,"Tags":"python,debugging,pycharm,pytest","A_Id":47594318,"CreationDate":"2017-12-01T09:43:00.000","Title":"Debugging pytests in Pycharm with pdb shows annoying console","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed on my system several Python interpreters, 2.x and 3.x versions. I am trying to prepare my work environment to allow easily switch between code written in both Python version. It is really important to have as much flexible setting in Visual Studio Code (VSC).\nThe problem is that I have no idea how to set VSC terminal to run code in Python 2.x. Terminal output is needed because it allows to provide user input easily. \nI've tried instructions provided on VSC page, like manual interpreter's path indication in folder or workspace setting. I reinstalled Python 2.x to ensure PATH variable has been updated.\nWhen I run code with CodeRunner extension, it always run it in Python 3.x. \nDoes anyone have similar issue and found how to change Python environment used by this integrated terminal?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":18249,"Q_Id":47602151,"Users Score":2,"Answer":"At the bottom of the MS Code screen is an info bar that lets you know what line, col, text encoding, etc... It also shows the python interpreter you are accessing.\nIf you click on the text for the version of python that is running, it will open a list of available interpreters on your system. If 2.7 is in your path, you can select it.","Q_Score":6,"Tags":"python,visual-studio,terminal","A_Id":49505028,"CreationDate":"2017-12-01T22:07:00.000","Title":"How to change interpreter in Visual Studio Code?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making a game using Pygame where there are random obstacles on the screen (like boxes). The boxes can be removed by the player when they place a bomb next to it. I have some items that I would like to have randomly appear in place of the box if it is removed. I'm not sure how to go about this logically. Does anyone have any tips? No code is necessary (but helpful), I just want some steps logic-wise to get me started.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":30,"Q_Id":47604678,"Users Score":1,"Answer":"In order to have the box removed you need to call a ~destructor function on it, which would remove the image of the box and so on correct?\nTake advantage of that and create a function that chooses which item to spawn (could be random, up to you) in the position where the box used to be. \nThen call this function at the end of the destructor. That's how imagine it working.","Q_Score":0,"Tags":"python,pygame","A_Id":47604704,"CreationDate":"2017-12-02T04:44:00.000","Title":"Making items appear from obstacles in game?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've used YOLO detection with trained model using my GPU - Nvidia 1060 3Gb, and everything worked fine. \nNow I am trying to generate my own model, with param --gpu 1.0. Tensorflow can see my gpu, as I can read at start those communicates:\n\"name: GeForce GTX 1060 major: 6 minor: 1 memoryClockRate(GHz): 1.6705\"\n\"totalMemory: 3.00GiB freeMemory: 2.43GiB\"\nAnyway, later on, when program loads data, and is trying to start learning i got following error:\n\"failed to allocate 832.51M (872952320 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY\"\nI've checked if it tries to use my other gpu (Intel 630) , but it doesn't.\nAs i run the train process without \"--gpu\" mode option, it works fine, but slowly. \n( I've tried also --gpu 0.8, 0.4 ect.)\nAny idea how to fix it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1053,"Q_Id":47606161,"Users Score":0,"Answer":"Problem solved. Changing batch size and image size in config file didn't seem to help as they didn't load correctly. I had to go to defaults.py file and change them up there to lower, to make it possible for my GPU to calculate the steps.","Q_Score":1,"Tags":"python-3.x,tensorflow,darkflow","A_Id":47685678,"CreationDate":"2017-12-02T08:53:00.000","Title":"YOLO - tensorflow works on cpu but not on gpu","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I've used YOLO detection with trained model using my GPU - Nvidia 1060 3Gb, and everything worked fine. \nNow I am trying to generate my own model, with param --gpu 1.0. Tensorflow can see my gpu, as I can read at start those communicates:\n\"name: GeForce GTX 1060 major: 6 minor: 1 memoryClockRate(GHz): 1.6705\"\n\"totalMemory: 3.00GiB freeMemory: 2.43GiB\"\nAnyway, later on, when program loads data, and is trying to start learning i got following error:\n\"failed to allocate 832.51M (872952320 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY\"\nI've checked if it tries to use my other gpu (Intel 630) , but it doesn't.\nAs i run the train process without \"--gpu\" mode option, it works fine, but slowly. \n( I've tried also --gpu 0.8, 0.4 ect.)\nAny idea how to fix it?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1053,"Q_Id":47606161,"Users Score":0,"Answer":"Look like your custom model use to much memory and the graphic card cannot support it. You only need to use the --batch option to control the size of memory.","Q_Score":1,"Tags":"python-3.x,tensorflow,darkflow","A_Id":50273011,"CreationDate":"2017-12-02T08:53:00.000","Title":"YOLO - tensorflow works on cpu but not on gpu","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"when should I write methods in the model itself and when in the model manager?\nis it like all methods to get something should be written in manager and others in model","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":120,"Q_Id":47621228,"Users Score":0,"Answer":"There's a simple difference. Model methods act on a single instance. Manager methods create queries to act on multiple instances.","Q_Score":0,"Tags":"python,django,django-models","A_Id":47622247,"CreationDate":"2017-12-03T17:40:00.000","Title":"when should I write custom methods in model vs model manager\/ queryset","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Just like the title. I was struggling to work with that, but I couldn't find any way to make that work.\nIs there anyone know how to do that. Please help, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":83,"Q_Id":47631328,"Users Score":0,"Answer":"Finally, this problem has been solved by changing the match-clients dynamically through ssh and then rndc reload. This make the remote server only access to the specific view in which you want to update the zone using dnspython.","Q_Score":0,"Tags":"python,view,dns,bind,dnspython","A_Id":47667697,"CreationDate":"2017-12-04T10:32:00.000","Title":"Is there any way to update zone in specific views using dnspython?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently using the exchangelib library in python. I would like to compare the mail of the account connected to exchangelib and the mail of a meeting organizer. I can have the account mail by typing \"account.primary_smtp_address\" but I don't know how I could get the meeting organizer mail.\nFor now i can only get the organizer's name by typing \"item.subject\" where \"item\" is my meeting.\nConversely, is it possible to get the account's name (the complete name: \"Michael JORDAN\" for example) which I could compare with the meeting organizer's name.\nThank you !","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":134,"Q_Id":47656709,"Users Score":0,"Answer":"The meeting organizer is available on CalendarItem objects as item.organizer.","Q_Score":1,"Tags":"python,email,organizer,exchangelib","A_Id":47670437,"CreationDate":"2017-12-05T15:03:00.000","Title":"Exchangelib - Get meeting organizer mail","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I open a python file without a workspace and start debugging it, the debugger breaks on the first line. I would like to change this behaviour, but I don't know how to do it for files that are opened without a workspace.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":32,"Q_Id":47665047,"Users Score":0,"Answer":"Open launch.json (gear icon when on debugger tab).  Find the section for the python debugger you are using.  Change \"stopOnEntry\" from true to false.  Save.","Q_Score":0,"Tags":"python,configuration,visual-studio-code","A_Id":47665163,"CreationDate":"2017-12-06T00:45:00.000","Title":"How to disable stopOnEntry for files that are opened without a workspace?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python project that I want to convert into an executable. I have installed Pyinstaller. I only know how to convert one single script into .exe, but I have multiple packages with multiple python scripts.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":3628,"Q_Id":47671023,"Users Score":-1,"Answer":"1)  Open the command prompt \n2)  Install pyinstaller \n    Pip install pyinstaller\n3)   Test your python script first just to check python script should work with normal \n    .py extension. Saurabh is the name of python file\n     python saurabh.py \n4)  Convert the python into executable file\n     pyinstaller --onefile Saurabh.py\nNotice we have passed \u201c\u2013onefile\u201d as a argument which tell pyinstaller to create only one file\n5)   Go to directory and navigate to the dist folder.\nPrerequisite : Install PyQt5   to avoid error. \npip install PyQt5","Q_Score":3,"Tags":"python,project,executable,pyinstaller","A_Id":53550927,"CreationDate":"2017-12-06T09:37:00.000","Title":"How to convert Python project into executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python project that I want to convert into an executable. I have installed Pyinstaller. I only know how to convert one single script into .exe, but I have multiple packages with multiple python scripts.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":3628,"Q_Id":47671023,"Users Score":-1,"Answer":"Converting the main script into .exe should solve the problem, use -onefile to convert it to one exe and rest of the .py files should be included.","Q_Score":3,"Tags":"python,project,executable,pyinstaller","A_Id":47671205,"CreationDate":"2017-12-06T09:37:00.000","Title":"How to convert Python project into executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to create a web application using python which has a HTML form and the form data is used as a command line input to start an application. I know how to initiate the CLI tool from web app, but want a way to get the output of the CLI tool from Linux terminal real time and show it in the web application. \nThe CLI tool will run for a day and the terminal output will change in real time. Is there a way to display the changing Linux terminal output in to the web application. Information about any web terminal or way to get and store the real-time screen output of a linux application will be helpful.\nWhen ever the screen O\/P of the application running in linux changes then the web application should also be updated with the change. \nAny python lib or tools will be useful and easy to Integrate?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":515,"Q_Id":47709408,"Users Score":0,"Answer":"A quick solution I would do (without any libraries or stuff):\n\ninvoke your CLI program and set it up to continuously output to a file on the server. Make sure you know the file name.\nuse Ajax calls to fetch the output to the client. OR (if you are in for hard stuff) use a webSocket to output to the client.","Q_Score":1,"Tags":"html,linux,python-3.x,web,terminal","A_Id":47709772,"CreationDate":"2017-12-08T07:09:00.000","Title":"Getting a Linux terminal output of a CLI tool and displaying in Web page","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to match any Chinese character in  \"\"\uff0c but not in the comment of Lua, i.e: after --. \nFor example, in string Tips(\"\u4e2d\u6587\") -- \"\u6ce8\u91ca\"\uff0c\u4e2d\u6587 should be matched, but not \u6ce8\u91ca.\nThe regex I write is ur'(?<!--.*?)\"([\\u4e00-\\u9fff]+)\"'\uff0cbut Python gives an error: look-behind requires fixed-width pattern.\nSo how to fix this?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":70,"Q_Id":47709687,"Users Score":0,"Answer":"You could just capture all Chinese characters between quotes, capture any comment start \u00b4--\u00b4 indicators, and then throw away all the matches after that indicator.","Q_Score":2,"Tags":"python,regex","A_Id":47709796,"CreationDate":"2017-12-08T07:30:00.000","Title":"Regex in Python. How to match a string but not in comments?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm currently working on a project, which will dynamically fetch some informations of my job and display them in a html page. To accomplish this i wrote a python script, which will be invoked using a PHP webservice. The script needs to edit some files in order to work.\nBasically PHP executes the script using \n $output = shell_exec('python script.py'); \nThe problem is, that if the webservice is called, the script does not have the needed permissions to edit the files.\nSo the webserver should call the script using something like  $output = shell_exec('sudo python script.py');  \nI may need to change the permissions to the project folder but i don't know how.\nSome additional informations:\nI'm using a raspberry pi 3 with LAMP installation on raspian as webserver\nThe folder structure is the following:\n\nprojectfolder \n| \n- style (containing css)\n-script.py\n-script2.py\n-filetoedit1.txt\n-filetoedit2.html\nAny help is appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":25,"Q_Id":47720160,"Users Score":0,"Answer":"As suggested by @wpercy you have figure out which user is executing the file. Usually that user is called  www-data !\nTo find out which user is calling the service use\n ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\\  -f1  \nAfter you figured out the user you have to change the permission for the folder. That command schould be something like  chown -R www-data:www-data \/var\/www\/html\/Projectfolder \nSpecial thanks to wpercy!","Q_Score":0,"Tags":"php,python,linux,webserver,file-permissions","A_Id":47720634,"CreationDate":"2017-12-08T18:23:00.000","Title":"Linux editing privilege over webservice","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run python someCode.py in my terminal, I am actually using python 2.7\nI have installed python 3.6 on my Mac and would like to use it in terminal. how can I do that?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":15774,"Q_Id":47751125,"Users Score":7,"Answer":"Just type python3 where you would have typed python. \nFor example open repl type python3 run app.py program with python3.6 type python3 app.py","Q_Score":2,"Tags":"python,macos,terminal","A_Id":47751976,"CreationDate":"2017-12-11T10:43:00.000","Title":"How do I use python 3 on terminal Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"When I run python someCode.py in my terminal, I am actually using python 2.7\nI have installed python 3.6 on my Mac and would like to use it in terminal. how can I do that?","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":15774,"Q_Id":47751125,"Users Score":1,"Answer":"type python3 on command window\/ terminal window & press enter \nfor exit from python type quit() & press enter","Q_Score":2,"Tags":"python,macos,terminal","A_Id":54866894,"CreationDate":"2017-12-11T10:43:00.000","Title":"How do I use python 3 on terminal Mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I don't know how this happens or why, \nbut I'll be in a jupyter notebook grouping by things and I will very conciously type in dataframe.groupby, write some other code and hit ctrl+ enter\nand there will be that damn error. Every single time, I will go back and delete the 'groupyouby' and type in groupby. \nI doubt that anyone has run into this error,and I don't know how long it will be until someone else creates the mess of libraries that I have that resulted in this chinese water tourture like nightmare. I am here, to let you know, that you are not alone. \nAlso if someone has a fix that would be great. I got nothing for you other than that description above.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":39,"Q_Id":47757753,"Users Score":1,"Answer":"Grammarly was the cause of this. \nIf you use jupyter notebooks and have the grammarly extension. It will cause problems.","Q_Score":0,"Tags":"python,jupyter","A_Id":49182635,"CreationDate":"2017-12-11T17:00:00.000","Title":"Jupyternotebook corrects groupby to groupyouby Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have implemented a lambda project which has 4 modules\/project inside it. Each module\/project has python(s) files which implement module functionality.\nI have to write the test cases for each module so that it goes through CircleCI and execute on themselves:\n\nThat the module is starting and stopping a stepfunction.\nmodule is calling Rest service.\nIt is writing\/reading files from S3 Bucket.\n\nEverywhere, it is like a test driven development to write unit test, but now I have completed project implementation, how do I write automated test cases for my module ?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1070,"Q_Id":47758329,"Users Score":1,"Answer":"When it comes to unit testing, there's nothing special you have to do about AWS Lambda projects.\nYou Lambda handler is a Python function. Therefore, you can import it on your tests, call it with some input, and assert the output. Just like a normal Python function.","Q_Score":1,"Tags":"python,automated-tests,aws-lambda","A_Id":47763008,"CreationDate":"2017-12-11T17:36:00.000","Title":"How do I write test cases for my AWS Python-based lambda project?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to monitor a file and if there is a change file I need to execute a script but the catch is cron job is not allowed, also this will be executed on AIX system.\nCan somebody help me here on how to proceed.Thank You","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":73,"Q_Id":47764837,"Users Score":0,"Answer":"One way I can think of is to write a daemon (another script perhaps) and keep checking the file for changes.\nIt is possible to write a script with infinite loop and the loop can contain the file check logic.","Q_Score":0,"Tags":"python,shell,cron,scheduled-tasks,aix","A_Id":47767204,"CreationDate":"2017-12-12T03:19:00.000","Title":"how to monitor changes in file without cron job in AIX","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have created a workspace and clone all files in to that. Now, I'm running my code through jenkins. Can anyone assist how to display all the files in my workspace through any command. I tried with ${workspace} dir in Jenkins but it is showing any output.\nBasically, if you are at any folder in your system and you open cmd and exceute dir in windows, it will display all the files in it. \nThe same thing I want to see in Jenkins for windows.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2946,"Q_Id":47774073,"Users Score":3,"Answer":"Just dir no ${workspace}\nbat 'dir' in a pipeline script.\nSelect a \"execute batch command\" option and write the commands you want to execute in there. \nThen check the console output of the build which was successful.","Q_Score":3,"Tags":"java,python,grails,jenkins","A_Id":47774670,"CreationDate":"2017-12-12T13:39:00.000","Title":"Jenkins command to display all file in directory?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I tried import apiai on pycharm, but it didn't work so I ran pip install apiai then freezed to the requirements.txt it still didn't work on pycharm.\nI went and tested my code in the prompt after i ran it in the env environment and it worked just fine.\nMy question is how can i make it work on pycharm too ?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":101,"Q_Id":47787413,"Users Score":0,"Answer":"On pycharm go to\nFile > Settings > project interpreter.. Under this add your env as an interpreter.","Q_Score":0,"Tags":"python,pycharm","A_Id":47787770,"CreationDate":"2017-12-13T07:11:00.000","Title":"I am unable to import apiai on pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am performing some perspective transforms on camera images, however in certain cases the roll and pitch of the camera are not zero. In other words, the camera is not level and I would like to be able to correct for this.\nI have some questions:\n1) Can the transformation matrix (from M = cv2.getPerspectiveTransform(...) ) be corrected for the pitch and roll angles?\n2) Should I just transform the source points and get a new transformation matrix? Roll seems like a simple enough correction since it's analogous to rotating the image, but how can I get the proper transformation for both roll and pitch?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":715,"Q_Id":47794365,"Users Score":0,"Answer":"If the camera motion is approximately a rotation about its optical center \/ lens entrance pupil (for example, pan-tilt-roll on a tripod with the subject distance much larger than the translation of the optical center), then images taken from rotated viewpoints are related by a homography.\nIf you know the 3D rotation (pan\/tilt\/roll), then you can explicitly compute the homography and apply it to the image. If not, but you have two images upon which you can identify 4 corresponding points or more, then you can estimate the homography directly from those correspondences.","Q_Score":1,"Tags":"python,opencv,graphics,computer-vision","A_Id":47808839,"CreationDate":"2017-12-13T13:37:00.000","Title":"OpenCV perspective transform with camera roll and pitch correction","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In Weblogic how to find WLST python version. Its known that WLST is made up by python.\nAnd Python 2 and Python 3 is different from one another Architecture wise and bit wise. Python 2 available for 64 bit considering Windows OS. Python 3 is still 32-bit as far I know. Python is well known simplest Higher Level Language that is widely used in many Industry, but classified like version 2 and 3.\nWhen I work in WLST I wonder what would be the Python version it is made up of.\nWhen Weblogic version differs does it differ. However it so, how to find out, is there a specific command or function for it while operating in WLST shell","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1545,"Q_Id":47797170,"Users Score":2,"Answer":"This command will print the Python version used by WLST : \n\nprint (sys.version)","Q_Score":2,"Tags":"python,wlst","A_Id":47809130,"CreationDate":"2017-12-13T15:50:00.000","Title":"How to find WLST python version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have two environments in anaconda, namely: root, 2env. When I open anaconda prompt, I can switch from root to 2env by typing: activate 2env. I also have conda in  my powershell, but when I open powershell and try to run conda activate 2env it gives the following error: \n\nCommandNotFoundError: 'activate'\n\nAny suggestions on how to fix this?","AnswerCount":6,"Available Count":4,"Score":-1.0,"is_accepted":false,"ViewCount":49258,"Q_Id":47800794,"Users Score":-5,"Answer":"Here is a work around - start cmd shell .  Run - activate   .  Check - conda env list .  Start powershell - powershell .","Q_Score":40,"Tags":"python,powershell,command-line,anaconda,conda","A_Id":48412773,"CreationDate":"2017-12-13T19:29:00.000","Title":"How to activate different anaconda environment from powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have two environments in anaconda, namely: root, 2env. When I open anaconda prompt, I can switch from root to 2env by typing: activate 2env. I also have conda in  my powershell, but when I open powershell and try to run conda activate 2env it gives the following error: \n\nCommandNotFoundError: 'activate'\n\nAny suggestions on how to fix this?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":49258,"Q_Id":47800794,"Users Score":8,"Answer":"I found this command while using vs code & cmd \/k \"activate <env> & powershell\" .\nIt is working","Q_Score":40,"Tags":"python,powershell,command-line,anaconda,conda","A_Id":52237127,"CreationDate":"2017-12-13T19:29:00.000","Title":"How to activate different anaconda environment from powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have two environments in anaconda, namely: root, 2env. When I open anaconda prompt, I can switch from root to 2env by typing: activate 2env. I also have conda in  my powershell, but when I open powershell and try to run conda activate 2env it gives the following error: \n\nCommandNotFoundError: 'activate'\n\nAny suggestions on how to fix this?","AnswerCount":6,"Available Count":4,"Score":0.0333209931,"is_accepted":false,"ViewCount":49258,"Q_Id":47800794,"Users Score":1,"Answer":"I have been battling this issue for a while. I found a solution by using a batch script and calling call activate %env%. I hope this can help somebody.","Q_Score":40,"Tags":"python,powershell,command-line,anaconda,conda","A_Id":51418747,"CreationDate":"2017-12-13T19:29:00.000","Title":"How to activate different anaconda environment from powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have two environments in anaconda, namely: root, 2env. When I open anaconda prompt, I can switch from root to 2env by typing: activate 2env. I also have conda in  my powershell, but when I open powershell and try to run conda activate 2env it gives the following error: \n\nCommandNotFoundError: 'activate'\n\nAny suggestions on how to fix this?","AnswerCount":6,"Available Count":4,"Score":0.0,"is_accepted":false,"ViewCount":49258,"Q_Id":47800794,"Users Score":0,"Answer":"Open PowerShell.\nRun conda init (not conda init powershell as the accepted answer suggests).\nClose and re-open PowerShell.\nUse conda normally.","Q_Score":40,"Tags":"python,powershell,command-line,anaconda,conda","A_Id":67298072,"CreationDate":"2017-12-13T19:29:00.000","Title":"How to activate different anaconda environment from powershell","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to do textual analysis on a bunch (about 140 ) of textual documents. Each document, after preprocessing and removing unnecessary words and stopwords, has about 7000 sentences (as determined by nlkt's sentence tokenizer) and each sentence has about 17 words on average. My job is to find hidden themes in those documents. \nI have thought about doing topic modeling. However, I cannot decide if the data I have is enough to obtain meaningful results via LDA or is there anything else that I can do. \nAlso, how do I divide the texts into different documents? Is 140 documents (each with roughly 7000 x 17 words) enough ? or should I consider each sentence as a document. But then each document will have only 17 words on average; much like tweets. \nAny suggestions would be helpful. \nThanks in advance.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":66,"Q_Id":47827130,"Users Score":0,"Answer":"I have worked on similar lines. This approach can work till 300 such documents. But, taking it to higher scale you need to replicate the approach using spark.\nHere it goes:\n1) Prepare TF-IDF matrix: Represent documents in terms Term Vectors. Why not LDA because you need to supply number of themes first which you don't know first. You can use other methods of representing documents if want to be more sophisticated (better than semantics) try word2Vec, GloVe, Google News Vectors etc.\n2) Prepare a Latent Semantic Space from the above TF-IDF. Creation of LSA uses SVD approach (one can choose the kaiser criteria to choose the number of dimensions). \nWhy we do 2)?\na) TF-IDF is very sparse. Step 3 (tSne) which is computationally expensive. \nb) This LSA can be used to create a semantic search engine\nYou can bypass 2) when your TF-IDF size is very small but i don't think given your situation that would be the case and also, you don't have other needs like having semantic search on these documents.\n3) Use tSne (t-stochastic nearest embedding) to represent the documents in 3 dimensions. Prepare a spherical plot from the euclidean cordinates.\n4) Apply K-means iteratively to find the optimal number of clusters.\nOnce decided. Prepare word clouds for each categories. Have your themes.","Q_Score":0,"Tags":"python-3.x,nlp,gensim,text-analysis","A_Id":47830720,"CreationDate":"2017-12-15T06:44:00.000","Title":"Suggestion on LDA","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am asking for generally checking if all elements of a page has been loaded. Is there a way to check that basically? \nIn the concrete example there is a page, I click on some button, and then I have to wait until I click on the 'next' button. However, this 'Next' button is available, selectable and clickable ALL THE TIME. So how to check with selenium that 'state'(?) of a page?\nAs a reminder: This is a question about selenium and not the quality of the webpage in question....","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":5281,"Q_Id":47832693,"Users Score":0,"Answer":"Reliably determining whether a page has been fully loaded can be challenging. There is no way to know if all the elements have been loaded just like that. You must define some \"anchor\" points in each page so that as far as you aware, if these elements has been loaded, it is fair to assume the whole page has been loaded. Usually this involves a combination of tests. So for example, you can define that if the below combination of tests passes, the page is considered loaded:\n\nJavaScript document.readyState === 'complete'\n\"Anchor\" elements\nAll kinds of \"spinners\", if exist, disappeared.","Q_Score":1,"Tags":"python,selenium,selenium-webdriver","A_Id":47832860,"CreationDate":"2017-12-15T12:44:00.000","Title":"Is there a way with python-selenium to wait until all elements of a page has loaded?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"How can I tell a turtle to face a direction in turtle graphics?\nI would like the turtle to turn and face a direction no matter its original position, how can I achieve this?","AnswerCount":7,"Available Count":1,"Score":0.0285636566,"is_accepted":false,"ViewCount":9625,"Q_Id":47841384,"Users Score":1,"Answer":"You can use:\nturtle.right(angle)\nor:\nturtle.left(angle).\nHope this helps!","Q_Score":4,"Tags":"python,turtle-graphics,python-turtle","A_Id":62399262,"CreationDate":"2017-12-16T00:14:00.000","Title":"Turtle direction in turtle graphics?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm making onefile executables with pyinstaller on windows 10. I'm including data files (pickle files) by editing the .spec file...\nHow can I store changes made to these files during run time? My understanding is that the data files are copied to a temp directory during execution. I can read from the files using the path I get from sys._MEIPASS but the changes I write are lost after restarting the program.\nIs there a way to write to pickle files stored inside the exe?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":590,"Q_Id":47863640,"Users Score":0,"Answer":"Do not mention the pickle file to pyinstaller and put the pickle file in the same folder than the bundled onefile. For me this works even if you have two files in the folder instead of one.","Q_Score":1,"Tags":"python,pyinstaller","A_Id":61203249,"CreationDate":"2017-12-18T07:11:00.000","Title":"how to change bundled data file pyinstaller on execute","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am evaluating MessageBird service. I got a Virtual Mobile Number. I am able to send message to dummy numbers (until i get approval for sending messages to real USA number)\nUnknown: My problem is about reading the messages received by a VMN. \nDetails: If I as a VMN owner send a message to consumer e.g. +1(111)111-1111 and i am interested in reading the response from the consumer, how to do get it?\nMessageBird documentation expects me to know the ID for response message object (or my understanding is wrong). The documentation is good but i don't see a way to programmatically achieve it. Any suggestions How to achieve it?\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":146,"Q_Id":47878687,"Users Score":0,"Answer":"Messagebird have a feature of forward incoming sms data through webhook(get or post method). if you set an url then Messagebird will forward every incoming sms to you(or your server). You can easily read get\/post response.","Q_Score":1,"Tags":"python-3.x,sms,sms-gateway,messagebird","A_Id":68136708,"CreationDate":"2017-12-19T01:11:00.000","Title":"MessageBird: How to read a response from consumer","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData\/Continuum\/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:\/Program Files, but several of the python script did not like the space and it failed to install.\nWhat can I do to access the Anaconda prompt?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":214781,"Q_Id":47914980,"Users Score":10,"Answer":"I added \"\\Anaconda3_64\\\" and \"\\Anaconda3_64\\Scripts\\\" to the PATH variable. Then I can use conda from powershell or command prompt.","Q_Score":49,"Tags":"python,anaconda","A_Id":53872163,"CreationDate":"2017-12-20T22:01:00.000","Title":"How to access Anaconda command prompt in Windows 10 (64-bit)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData\/Continuum\/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:\/Program Files, but several of the python script did not like the space and it failed to install.\nWhat can I do to access the Anaconda prompt?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":214781,"Q_Id":47914980,"Users Score":46,"Answer":"Go with the mouse to the Windows Icon (lower left) and start typing \"Anaconda\". There should show up some matching entries. Select \"Anaconda Prompt\". A new command window, named \"Anaconda Prompt\" will open. Now, you can work from there with Python, conda and other tools.","Q_Score":49,"Tags":"python,anaconda","A_Id":47915189,"CreationDate":"2017-12-20T22:01:00.000","Title":"How to access Anaconda command prompt in Windows 10 (64-bit)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData\/Continuum\/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:\/Program Files, but several of the python script did not like the space and it failed to install.\nWhat can I do to access the Anaconda prompt?","AnswerCount":6,"Available Count":4,"Score":0.1325487884,"is_accepted":false,"ViewCount":214781,"Q_Id":47914980,"Users Score":4,"Answer":"If Anaconda Prompt is missing, you can create it by creating a shortcut file of Command Prompt (cmd.exe) and change its target to:\n%windir%\\System32\\cmd.exe \"\/K\" <Anaconda Location>\\anaconda3\\Scripts\\activate.bat\nExample:\n%windir%\\system32\\cmd.exe \"\/K\" C:\\Users\\user_1\\AppData\\Local\\Continuum\\anaconda3\\Scripts\\activate.bat","Q_Score":49,"Tags":"python,anaconda","A_Id":56891764,"CreationDate":"2017-12-20T22:01:00.000","Title":"How to access Anaconda command prompt in Windows 10 (64-bit)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData\/Continuum\/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:\/Program Files, but several of the python script did not like the space and it failed to install.\nWhat can I do to access the Anaconda prompt?","AnswerCount":6,"Available Count":4,"Score":1.0,"is_accepted":false,"ViewCount":214781,"Q_Id":47914980,"Users Score":16,"Answer":"To run Anaconda Prompt using an icon, I made an icon and put:\n%windir%\\System32\\cmd.exe \"\/K\" C:\\ProgramData\\Anaconda3\\Scripts\\activate.bat C:\\ProgramData\\Anaconda3 (The file location would be different in each computer.)\nat icon -> right click -> Property -> Shortcut -> Target\nI see %HOMEPATH% at icon -> right click -> Property -> Start in\nTest environment\n\u00a0\u00a0 OS: Windows 10\n\u00a0\u00a0 Library: Anaconda 10 (64 bit)","Q_Score":49,"Tags":"python,anaconda","A_Id":55545141,"CreationDate":"2017-12-20T22:01:00.000","Title":"How to access Anaconda command prompt in Windows 10 (64-bit)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm writing Python script cron-job, which is periodically get updates from RabbitMQ and process them. Every time I process them I need only to get current snapshot of RMQ queue. I use queue_declare to get number of messages in it.\nI know how to get messages one by one with basic_get. Also, I can use basic_consume\/start_consuming and get messages in background, store them in some list and periodically get from that list, but what if script will fail with some error? I will lost all read messages in list. Also, I can use few consumers (pool of connections to RMQ) and get messages one by one. Maybe there is some other approach to do it?\nSo, my question is - what is the best (i.e. secure and fast) way to get current messages from RabbiMQ queue?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":517,"Q_Id":47925668,"Users Score":3,"Answer":"The best way to consume the messages is using basic_consume.\nbasic_get is slow","Q_Score":0,"Tags":"python,rabbitmq","A_Id":47937389,"CreationDate":"2017-12-21T13:06:00.000","Title":"The best way to read a lot of messages from RabbitMQ queue?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Pycharm for years and have never had any problem.  However, after my most recent PyCharm update I can no longer configure the interpreter.\nAlso each time I create a new project it creates a vent directory under my project.  When I go to File\/Default Settings\/Project Interpreter, I am provided with new options.\nIn this window it allows you to configure a virtual environment, the conda environment, and the system interpreter.  I am assuming that I should configure the system interpreter.  From there I point PyCharm to the interpreter on my Mac at \/usr\/local\/Cellar\/python3\/3.6.3\/bin\/python3 and hit OK.\nIt then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message:\n\nCannot Save Settings please use a different SDK name\n\nIt doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this?\nInterestingly my old projects still work correctly.","AnswerCount":10,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":16186,"Q_Id":47932725,"Users Score":10,"Answer":"I ran into this issue when trying to get docker up and running with Pycharm 2018.1 and using the container's Interpreter. I would get the error below. \n\n\"Cannot Save Settings please use a different SDK name\"\n\nThe issue I had was due to having multiple python interpreters of the same name. \nUnder Pycharm || Preferences || Project Interpreter\nClick \"show all\" within the Project Interpreter dropdown and then delete any \/ all interpreters that you don't need.","Q_Score":22,"Tags":"python-3.x,pycharm","A_Id":49899116,"CreationDate":"2017-12-21T21:08:00.000","Title":"Configuring interpreter in PyCharm: \"please use a different SDK name\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Pycharm for years and have never had any problem.  However, after my most recent PyCharm update I can no longer configure the interpreter.\nAlso each time I create a new project it creates a vent directory under my project.  When I go to File\/Default Settings\/Project Interpreter, I am provided with new options.\nIn this window it allows you to configure a virtual environment, the conda environment, and the system interpreter.  I am assuming that I should configure the system interpreter.  From there I point PyCharm to the interpreter on my Mac at \/usr\/local\/Cellar\/python3\/3.6.3\/bin\/python3 and hit OK.\nIt then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message:\n\nCannot Save Settings please use a different SDK name\n\nIt doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this?\nInterestingly my old projects still work correctly.","AnswerCount":10,"Available Count":6,"Score":1.0,"is_accepted":false,"ViewCount":16186,"Q_Id":47932725,"Users Score":35,"Answer":"I had the same problem while setting up the virtual environment for my project and no matter if I create a new virtual environment or select an existing one, I get the warning:\n\n\"Cannot Save Settings please use a different SDK name\"\n\nFinally I found the solution:\nClick on the project interpreter dropdown and select show all.... There you might be having multiple virtual environments with same name. Now here is the conflict you need to fix manually by renaming them so every item has the unique name.","Q_Score":22,"Tags":"python-3.x,pycharm","A_Id":48535675,"CreationDate":"2017-12-21T21:08:00.000","Title":"Configuring interpreter in PyCharm: \"please use a different SDK name\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Pycharm for years and have never had any problem.  However, after my most recent PyCharm update I can no longer configure the interpreter.\nAlso each time I create a new project it creates a vent directory under my project.  When I go to File\/Default Settings\/Project Interpreter, I am provided with new options.\nIn this window it allows you to configure a virtual environment, the conda environment, and the system interpreter.  I am assuming that I should configure the system interpreter.  From there I point PyCharm to the interpreter on my Mac at \/usr\/local\/Cellar\/python3\/3.6.3\/bin\/python3 and hit OK.\nIt then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message:\n\nCannot Save Settings please use a different SDK name\n\nIt doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this?\nInterestingly my old projects still work correctly.","AnswerCount":10,"Available Count":6,"Score":0.0199973338,"is_accepted":false,"ViewCount":16186,"Q_Id":47932725,"Users Score":1,"Answer":"Go to Project > Project Interpreter > Select the dropdown menu > \"Show All\".\nFor me, there were several Python environments, two of which were red with an  tag. Remove the envs that are red \/ have an  tag, select the remaining valid one, and re-apply settings.","Q_Score":22,"Tags":"python-3.x,pycharm","A_Id":57827910,"CreationDate":"2017-12-21T21:08:00.000","Title":"Configuring interpreter in PyCharm: \"please use a different SDK name\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Pycharm for years and have never had any problem.  However, after my most recent PyCharm update I can no longer configure the interpreter.\nAlso each time I create a new project it creates a vent directory under my project.  When I go to File\/Default Settings\/Project Interpreter, I am provided with new options.\nIn this window it allows you to configure a virtual environment, the conda environment, and the system interpreter.  I am assuming that I should configure the system interpreter.  From there I point PyCharm to the interpreter on my Mac at \/usr\/local\/Cellar\/python3\/3.6.3\/bin\/python3 and hit OK.\nIt then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message:\n\nCannot Save Settings please use a different SDK name\n\nIt doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this?\nInterestingly my old projects still work correctly.","AnswerCount":10,"Available Count":6,"Score":0.0798297691,"is_accepted":false,"ViewCount":16186,"Q_Id":47932725,"Users Score":4,"Answer":"How fix this in Windows 10:\n\nclose Pycharm .\ndelete this file: C:\\Users\\<username>\\.PyCharmCE2018.3\\config\\options\\jdk.table.xml\nopen Pycahrm again and load all python interceptors again.","Q_Score":22,"Tags":"python-3.x,pycharm","A_Id":57171648,"CreationDate":"2017-12-21T21:08:00.000","Title":"Configuring interpreter in PyCharm: \"please use a different SDK name\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Pycharm for years and have never had any problem.  However, after my most recent PyCharm update I can no longer configure the interpreter.\nAlso each time I create a new project it creates a vent directory under my project.  When I go to File\/Default Settings\/Project Interpreter, I am provided with new options.\nIn this window it allows you to configure a virtual environment, the conda environment, and the system interpreter.  I am assuming that I should configure the system interpreter.  From there I point PyCharm to the interpreter on my Mac at \/usr\/local\/Cellar\/python3\/3.6.3\/bin\/python3 and hit OK.\nIt then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message:\n\nCannot Save Settings please use a different SDK name\n\nIt doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this?\nInterestingly my old projects still work correctly.","AnswerCount":10,"Available Count":6,"Score":0.0,"is_accepted":false,"ViewCount":16186,"Q_Id":47932725,"Users Score":0,"Answer":"In my case, I moved my project to a different location and PyCharm started complaining about Cannot Save Settings please use a different SDK name. At the top of the main editor, it asks me to Configure Project Interpreter. I clicked it, and then ...\nMy solution\n\nRemove all existing interpreters that are marked as invalid in the preference.\nSelect the interpreter in the moved venv subfolder in my project.\n\nWithout doing both, I kept getting the same \"SDK name\" error. It seemed that the project thinks that it already has an interpreter called \"python.exe\", if you don't actively remove all \"invalid\" ones.","Q_Score":22,"Tags":"python-3.x,pycharm","A_Id":55686153,"CreationDate":"2017-12-21T21:08:00.000","Title":"Configuring interpreter in PyCharm: \"please use a different SDK name\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Pycharm for years and have never had any problem.  However, after my most recent PyCharm update I can no longer configure the interpreter.\nAlso each time I create a new project it creates a vent directory under my project.  When I go to File\/Default Settings\/Project Interpreter, I am provided with new options.\nIn this window it allows you to configure a virtual environment, the conda environment, and the system interpreter.  I am assuming that I should configure the system interpreter.  From there I point PyCharm to the interpreter on my Mac at \/usr\/local\/Cellar\/python3\/3.6.3\/bin\/python3 and hit OK.\nIt then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message:\n\nCannot Save Settings please use a different SDK name\n\nIt doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this?\nInterestingly my old projects still work correctly.","AnswerCount":10,"Available Count":6,"Score":0.0199973338,"is_accepted":false,"ViewCount":16186,"Q_Id":47932725,"Users Score":1,"Answer":"You cannot have 2 or more virtual environments with same name. Even if you have projects with same name stored at 2 different places, please give unique name to its venv. This will solve your problem.\nTo check all the virtual environments:\nGo to File >> Settings >> Project: your_project_name >> Project Interpreter\nAnd rename the venv name.","Q_Score":22,"Tags":"python-3.x,pycharm","A_Id":51556018,"CreationDate":"2017-12-21T21:08:00.000","Title":"Configuring interpreter in PyCharm: \"please use a different SDK name\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using online library and able to fetch words from an image with their locations.\nNow I want to form sentences exactly like which are in image.\nAny idea how can I do that?\nEarlier i used the distance between two words and if there are pretty close then it means it is a part of a sentence but this approach is not working fine\nPlease help\nThis is the json I am receiving I have...\n\"WordText\": \"Word 1\",\n                                \"Left\": 106,\n                                \"Top\": 91,\n                                \"Height\": 9,\n                                \"Width\": 11\n                                },\n                                {\n                                \"WordText\": \"Word 2\",\n                                \"Left\": 121,\n                                \"Top\": 90,\n                                \"Height\": 13,\n                                \"Width\": 51\n                                }\n                                .\n                                .\n                                .\n                                More Words","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":47941250,"Users Score":0,"Answer":"I don't if I am understanding your problem correctly, but I'm assuming each dictionary in your json is giving you the coordinates for a word.\nMy approach would be to first find the difference in pixels for the space between any 2 words, and you use this value to detect the sequence of words.\nFor example:\nimg1 = {'coordinates': 'information'}\nimg2 = {'coordinates': 'information'}\nspace_value = 10  # for example\nif img1['Height'] == img2['Height'] and (img1['Left'] + img1['Width'] + space_value) == img2['Left']:\nnext_word = True","Q_Score":0,"Tags":"javascript,python,image-processing,ocr,image-conversion","A_Id":47942101,"CreationDate":"2017-12-22T12:06:00.000","Title":"Able to fetch text with their locations from an image...How can I form sentence?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I've been messing around with the standard operators in classes to try and see what i can make, but i haven't been able to find how to edit the boolean and operator.\nI can edit the bitwise &operator by defining __and__(self), but not the way that and behaves. Does anyone know how I can change the behavior of a and b where a and bare instances of the class I'm making?\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":576,"Q_Id":47941694,"Users Score":4,"Answer":"The and operator converts the first operands to boolean using __bool__, and then does a predefined action to the booleans (if first.__bool__() is True, return second, else return first). There is no way to change this behavior.","Q_Score":5,"Tags":"python,boolean,operators","A_Id":47941734,"CreationDate":"2017-12-22T12:37:00.000","Title":"Edit boolean and operator","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Any ideas on how to export the yearly seasonal trend using fbprophet library?\nThe plot_components() function plots the trend, yearly, and weekly.\nI want to obtain the values for yearly only.","AnswerCount":2,"Available Count":1,"Score":0.2913126125,"is_accepted":false,"ViewCount":3166,"Q_Id":47946518,"Users Score":3,"Answer":"There is a simple solution in the current version of the library. You can use from the predicted model fc. What you want for the value of yearly can be found with fc['yearly'] without using the functions in the above solution.\nMoreover, if you want all the other components like trend, you can use fc['trend'].","Q_Score":7,"Tags":"python-3.x,time-series,facebook-prophet","A_Id":51340436,"CreationDate":"2017-12-22T19:34:00.000","Title":"Python fbprophet - export values from plot_components() for yearly","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So, my project does a lot of mathematics for the user. It lets them enter equations and then solves them with some fairly complicated items like eigenvalues. I do some of this is javascript, but I have also written a python script utilizing numpy. I would like the user to be able to have the option of having the script on their local machine and then solving the mathematics there instead of on my server.\nSo, the user would enter an equation and hit enter. The javascript would then call a python script running on the users local machine. The equation is solved there with my code and the result is returned to the web page.\nI thought that this would be possible with CGI, but I cannot seem to find clear documentation on how this would be accomplished. Is there a better way?\nI do not want to run third party software and I do not want to run the python code in the browser.\nThanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":399,"Q_Id":47956052,"Users Score":0,"Answer":"Short answer is: no, this isn't possible.\nSure, they can download your script and run it themselves if they have a compatible version of Python installed, but you won't be able to run it from the browser (that would be a severe security problem!)\nYour options are either to write it in JS, or create an API on your server, or find and use an existing API.","Q_Score":0,"Tags":"python,cgi","A_Id":47956075,"CreationDate":"2017-12-23T21:12:00.000","Title":"Call python script from web page and get results","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am learning python and i am currently scraping reddit. Somehow reddit has figured out that I am a bot (which my software actually is) but how do they know that? And how we trick them into thinking that we are normal users. \nI found practical solution for that, but I am asking for bit more in depth theoretical understanding.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":6861,"Q_Id":47956527,"Users Score":18,"Answer":"There's a large array of techniques that internet service providers use to detect and combat bots and scrapers. At the core of all of them is to build heuristics and statistical models that can identify non-human-like behavior. Things such as:\n\nTotal number of requests from a certain IP per specific time frame, for example, anything more than 50 requests per second, or 500 per minute, or 5000 per day may seem suspicious or even malicious. Counting number of requests per IP per unit of time is a very common, and arguably effective, technique. \nRegularity of incoming requests rate, for example, a sustained flow of 10 requests per second may seem like a robot programmed to make a request, wait a little, make the next request, and so on.\nHTTP Headers. Browsers send predictable User-Agent headers with each request that helps the server identify their vendor, version, and other information. In combination with other headers, a server might be able to figure out that requests are coming from an unknown or otherwise exploitative source. \nA stateful combination of authentication tokens, cookies, encryption keys, and other ephemeral pieces of information that require subsequent requests to be formed and submitted in a special manner. For example, the server may send down a certain key (via cookies, headers, in the response body, etc) and expect that your browser include or otherwise use that key for the subsequent request it makes to the server. If too many requests fail to satisfy that condition, it's a telltale sign they might be coming from a bot. \nMouse and keyboard tracking techniques: if the server knows that a certain API can only be called when the user clicks a certain button, they can write front-end code to ensure that the proper mouse-activity is detected (i.e. the user did actually click on the button) before the API request is made. \n\nAnd many many more techniques. Imagine you are the person trying to detect and block bot activity. What approaches would you take to ensure that requests are coming from human users? How would you define human behavior as opposed to bot behavior, and what metrics can you use to discern the two? \nThere's a question of practicality as well: some approaches are more costly and difficult to implement. Then the question will be: to what extent (how reliably) would you need to detect and block bot activity? Are you combatting bots trying to hack into user accounts? Or do you simply need to prevent them (perhaps in a best-effort manner) from scraping some data from otherwise publicly visible web pages? What would you do in case of false-negative and false-positive detections? These questions inform the complexity and ingenuity of the approach you might take to identify and block bot activity.","Q_Score":2,"Tags":"python,web-scraping,web,bots","A_Id":47956652,"CreationDate":"2017-12-23T22:28:00.000","Title":"How do websites detect bots?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django site that I want to add videos. Currently users can upload their photos and I want each user to be able to add their videos as well. I am not sure how to do this, since I am a beginner programmer. Can you please direct me to right way?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":93,"Q_Id":47966082,"Users Score":0,"Answer":"Handling video files is much more complicated than dealing with images. There are two ways you can do it: you let users embed videos uploaded to other sites (like youtube) or you let them upload photos to your website. The first option is easier: most of the video websites offer some way to copy&paste a code to embed their videos on other sites. You just need to let users paste the html code on your website and there are some security measures you should take care of. \nIf you want them to upload the files it's getting hard.There are many video formats, files are much bigger, different compression rates etc. A video site usually accepts a wide range of video formats, converts a video to the most convenient format and different resolutions (to save space and bandwidth). It means a lot of asynchronous and CPU intensive tasks on your server.\nIt's also more complicated to put the file on the website and let it play.\nThere's a video tag in HTML5 that makes things much easier than before although if you want to make it really nice and easy you should find some JS player.","Q_Score":0,"Tags":"python,django,web-applications,video-embedding","A_Id":47990584,"CreationDate":"2017-12-25T05:57:00.000","Title":"Video embedding","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"More details:\nMacbook Air 10.12.6 (16G1036);\nPython version: python3.6\nIDE: Pycharm 2017.3.1\nError:\nUsers\/lrh\/PycharmProjects\/TensorFlowDemo\/venv\/bin\/python \/Applications\/PyCharm.app\/Contents\/helpers\/pydev\/pydev_run_in_console.py 51562 51563 \/Users\/lrh\/PycharmProjects\/TensorFlowDemo\/demo1.py\nError starting server with host: \"localhost\", port: \"51562\", client_port: \"51563\"\nTraceback (most recent call last):\n  File \"\/Applications\/PyCharm.app\/Contents\/helpers\/pydev\/pydevconsole.py\", line 270, in start_console_server\n    server = XMLRPCServer((host, port), logRequests=False, allow_none=True)\n  File \"\/Users\/lrh\/anaconda3\/lib\/python3.6\/xmlrpc\/server.py\", line 598, in init\n    socketserver.TCPServer.init(self, addr, requestHandler, bind_and_activate)\n  File \"\/Users\/lrh\/anaconda3\/lib\/python3.6\/socketserver.py\", line 453, in init\n    self.server_bind()\n  File \"\/Users\/lrh\/anaconda3\/lib\/python3.6\/socketserver.py\", line 467, in server_bind\n    self.socket.bind(self.server_address)\nOSError: [Errno 49] Can't assign requested address\nConsole server didn't start\nhow can i fix it?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":675,"Q_Id":47966943,"Users Score":0,"Answer":"Because the console uses the port 51562 and 51563. So you might didnt exit a program correctly to cause the ports are still using.","Q_Score":0,"Tags":"python,console,pycharm","A_Id":47967440,"CreationDate":"2017-12-25T08:22:00.000","Title":"When I use pycharm to run code, the error \"OSError: [Errno 49] Can't assign requested address\" happended.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"how do I go about installing for python2.7 version only?\nRight now when I  run this : python -m pip install requests tweepy python-bittrex\nIt's only for python 3\nI'd like to install for python 2\n(I have both versions installed)\nTHanks","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":236,"Q_Id":47968124,"Users Score":0,"Answer":"There might be a conflict with environment variables.\nTry this\n\npython2.7 -m pip install","Q_Score":1,"Tags":"python,pip,installation","A_Id":47968167,"CreationDate":"2017-12-25T11:20:00.000","Title":"Python Pip Install For Specific Version","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working with alembic and it automatically creates a table called alembic_revision on your database.  How, do I specify the name of this table instead of using the default name?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":874,"Q_Id":47979390,"Users Score":8,"Answer":"After you run your init. Open the env.py file and update context.configure, add version_table='alembic_version_your_name as a kwarg.","Q_Score":4,"Tags":"python,sqlalchemy,alembic","A_Id":47979603,"CreationDate":"2017-12-26T13:36:00.000","Title":"Alembic, how do you change the name of the revision database?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I would like to implement a transparent IMAPS (SSL\/TLS) proxy from zero using python (pySocks and imaplib).\nThe user and the proxy are in the same network and the mail server is outside (example: gmail servers). All the traffic on port 993 is redirected to the proxy. The user should retrieve his emails using his favorite email application (example: thunderbird). The proxy should receive the commands and transmit it to the user\/server and should be able to read the content of the retrieved emails.\nHowever, as the traffic is encrypted, I don't know how to get the account and the password of the user (without using a database) OR how to read the content of the emails without knowing the account and the password of the user.\nAfter few days looking for a solution, I still don't have any track. Maybe it is not possible ? If you have any track, I would be happy to read it.\nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":221,"Q_Id":47988332,"Users Score":0,"Answer":"You must implement your proxy as a Man In The Middle attack. That means that there are two different SSL\/TLS encrypted communication channels: one between the client and the proxy, one between the the proxy and the server. That means that either:\n\nthe client explicitely sets the proxy as its mail server (if only few servers are to be used with one name\/address per actual server)\nthe proxy has a certificate for the real mail server that will be trusted by the client. A common way is to use a dummy CA: the proxy has a private certificate trusted by the client that can be used to sign certificates for any domains like antivirus softwares do.\n\nOnce this is set up, the proxy has just to pass all commands and responses, and process the received mails on the fly.\nI acknowledge that this is not a full answer, but a full answer would be far beyond the scope of SO and I hope it could a path to it. Feel free to ask more precise questions here if you are later stuck in actual implementation.","Q_Score":0,"Tags":"python,imap","A_Id":47988655,"CreationDate":"2017-12-27T07:48:00.000","Title":"Transparent IMAPs proxy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Keras for a project and I don't understand how Keras uses data input, that is to say how Keras reads our input data when creating the first layer. \nFor example: \n\nmodel = Sequential()\nmodel.add(Dense(10, activation='sigmoid', input_dim=3,name='layer1'))\n\nIn this model, what does it mean to have 10 neurons and an input with 3 dimensions? If the input data has 100 examples (number of lines in the matrix data), how does Keras use them?\nThank you.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1223,"Q_Id":47988983,"Users Score":2,"Answer":"input_dim=3 means that your data have 3 features which will be used to determine final result eg. if you want to determine what animal data refer to you could put width, height and color as data.\n100 examples of different animals widths, heights and colors combinations allow neural network to adjust its parameters (learn) what width, height and color refers to what kind of animal. Keras starts with random weights for neurons and goes one by one 100 times using provided samples to adjust network weights. Keras actually uses batches which means 100 samples are divided into smaller groups for better learning rate and general performance (less data to store in memory at once).\n10 neurons are 10 'places' where network is able to store multiplications results between neuron weights and input data. You could imagine neuron as a bulb which lights a bit brighter or darker depending whether data shows some useful data feature eg. if animal is above 3 meters tall. Each neuron has its own set of weights which are changed just a bit when network examines next sample from your data. At the end you should have 10 neurons (bulbs) which react in more or less intense way depending on presence of different features in your data eg. if animal is very tall. \nThe more neurons you have the more possible features you can track eg. if animal is tall, hairy, orange, spotted etc. But the more neurons you have there is also the higher risk that your network will be too exact and will learn features which are unique for your training example (it's called overfitting) but do not help you to recognize animal samples which were not included in your training data (it's called ability to generalize and is most important point of actually training neural network). Selecting number of neurons is then a bit of practical exercise where you search for one which works for your need.\nI hope it clarifies your doubts. If you would like to get deeper in this field there are a lot of good resources online explaining neural networks training process in details including features, neurons and learning.","Q_Score":0,"Tags":"python,machine-learning,neural-network,keras,keras-layer","A_Id":47990202,"CreationDate":"2017-12-27T08:43:00.000","Title":"How does Keras read input data?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using discord.py to create my bot and I was wondering how to create roles\/permissions specific to the bot? \nWhat that means is when the bot enters the server for the first time, it has predefined permissions and role set in place so the admin of the server doesn't need to set a role and permissions for the bot.\nI have been trying to look up a reference implementation of this but no luck. If someone can point me at example of how to get a simple permission\/role for a bot that will be great!","AnswerCount":3,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":7000,"Q_Id":47999716,"Users Score":1,"Answer":"you want to do this through oath2 using the url parameters","Q_Score":0,"Tags":"python,bots,discord","A_Id":48163714,"CreationDate":"2017-12-27T23:15:00.000","Title":"How to create a role for a Discord Bot","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I have 2 apps for my django project. In the default mysite folder, you have the urls.py file. I cant seem to find out how to write all my urls for all the apps in just the one urls.py file.\nI have tried this: \nfrom reviews.models import *\nhowever that isnt working. \nThanks for any help!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":29,"Q_Id":48008791,"Users Score":0,"Answer":"Just realised that i was importing the models instead of the views.\nthe code above should be from reviews.views import *","Q_Score":0,"Tags":"python,django","A_Id":48009047,"CreationDate":"2017-12-28T13:56:00.000","Title":"Django URLs from different apps in just the base one","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to build a AWS Lambda function using APi Gateway which utlizes pyodbc python package. I have followed the steps as mentioned in the documentation. I keep getting the following error Unable to import module 'app': libodbc.so.2: cannot open shared object file: No such file or directory when I test run the Lambda function. \nAny help appreciated. I am getting the same error when I deployed my package using Chalice. It seems it could be that I need to install unixodbc-dev. Any idea how to do that through AWS Lambda?","AnswerCount":6,"Available Count":1,"Score":0.0333209931,"is_accepted":false,"ViewCount":6014,"Q_Id":48016091,"Users Score":1,"Answer":"Fisrt, install unixODBC and unixODBC-devel packages using yum install unixODBC unixODBC-devel. This step will install everything required for pyodbc module. \nThe library you're missing is located in \/usr\/lib64 folder on you Amazon Linux instance.\nCopy the library to your python project's root folder (libodbc.so.2 is just a symbolic link, make sure you copy symbolic link and library itself as listed): libodbc.so, libodbc.so.2 and libodbc.so.2.0.0","Q_Score":3,"Tags":"python,amazon-web-services,aws-lambda,chalice","A_Id":50925535,"CreationDate":"2017-12-29T00:40:00.000","Title":"Unable to use pyodbc with aws lambda and API Gateway","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a file that has several tabs that have pivot tables that are based on one data tab. I am able to write the data to the data tab without issue, but I can't figure out how to get all of the tabs with pivot tables to refresh.\nIf this can be accomplished with openpyxl that would be ideal.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":7810,"Q_Id":48016206,"Users Score":0,"Answer":"Currently what I do is in my template I create a dynamic data range that gets the data from the raw data sheet and then I set that named range to the tables data source.  Then in the pivot table options there is a \"refresh on open\" parameter and I enable that.  When the excel file opens it refreshes and you can see it refresh.  Currently looking for a way to do it in openpyxl but this is where im at","Q_Score":6,"Tags":"python,excel,openpyxl","A_Id":49428497,"CreationDate":"2017-12-29T01:00:00.000","Title":"Using openpyxl to refresh pivot tables in Excle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a file that has several tabs that have pivot tables that are based on one data tab. I am able to write the data to the data tab without issue, but I can't figure out how to get all of the tabs with pivot tables to refresh.\nIf this can be accomplished with openpyxl that would be ideal.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":7810,"Q_Id":48016206,"Users Score":1,"Answer":"If the data source range is always the same, you can set each pivot table as \"refresh when open\". To do that, just go to the pivot table tab, click on the pivot table, under \"Analyze\" - > Options -> Options -> Data -> select \"Refresh data when opening the file\". \nIf the data source range is dynamic, you can set a named range, and in the pivot table tab, Change Data Source to the named range. And again set \"refresh when open\". \nSo the above is achieved without using any python package, alternatively you can use openpyxl to refresh. However make sure that you're using the 2.5 release or above, because otherwise the pivot table format will be lost.","Q_Score":6,"Tags":"python,excel,openpyxl","A_Id":52547674,"CreationDate":"2017-12-29T01:00:00.000","Title":"Using openpyxl to refresh pivot tables in Excle","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I made a GLADE file, a main window of type \"GtkNotebook\" and there are several pages in it (Window1 = Page1, Page2, Page3, Page4). \na) Is it possible, like a web-browser, to take one of this page and separate it from the main windows? Example Page4 taken away with the cursor would create a Windows2\nb) If not (I could not achieve it till now), I will have probably to create 2 windows which open automatically when I start my application (one will be Window1 = Page1, Page2, Page3, the second one will be Window2 with Page4). I will search how to do this after I have a feedback from here if a) could be done in any way.\nThanks (this is my first post here)","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":96,"Q_Id":48021783,"Users Score":0,"Answer":"I think that is not posible to do dinamically.\nAs you know on Pygtk we load the glade file by this way wTree = gtk.glade.XML(\"localize.glade\") only once time, and after that we have on scope the access to all tree of controls and componets.\nIf you have a window loaded, you can load another window, but not pull apart a tab that belong to a window loaded already, is something that not insted on pygtk, is not supported. Each window run on a singular process, i can not figure out how to pull apart it from the root proccess.\nI hope its helps you out.","Q_Score":3,"Tags":"python-3.x,pygtk,glade","A_Id":48027204,"CreationDate":"2017-12-29T11:18:00.000","Title":"GLADE & Pygtk: how to split dynamically windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am submitting a python script to condor. When condor runs it it gets\nan import error. Condor runs it as\n\/var\/lib\/condor\/execute\/dir_170475\/condor_exec.exe. If I manually copy\nthe python script to the execute machine and put it in the same place\nand run it, it does not get an import error. I am wondering how to\ndebug this.\nHow can I see the command line condor uses to run it? Can the file\ncopied to \/var\/lib\/condor\/execute\/dir_170475\/condor_exec.exe be\nretained after the failure so I can see it? Any other suggestions on\nhow to debug this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":289,"Q_Id":48031855,"Users Score":1,"Answer":"You can simply run an interactive job (basically just a job with sleep or cat as command) and do ssh_to_job to run it.\nGenerally you need to set-up your python environment on the compute node, it is best to have a venv and activate it inside your start script.","Q_Score":1,"Tags":"python,condor","A_Id":61310906,"CreationDate":"2017-12-30T07:18:00.000","Title":"Debugging htcondor issue running python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Does anyone know how I can see the final acceptance-rate in PyMC3 (Metropolis-Hastings) ? Or in general, how can I see all the information that pymc3.sample() returns ? \nThanks","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":551,"Q_Id":48036741,"Users Score":0,"Answer":"Let step = pymc3.Metropolis() be our sampler, we can get the final acceptance-rate through\n\"step.accepted\"\nJust for beginners (pymc3) like myself, after each variable\/obj. put a \".\" and hit the tab key; you will see some interesting suggestions ;)","Q_Score":0,"Tags":"python,pymc3","A_Id":48042507,"CreationDate":"2017-12-30T18:28:00.000","Title":"Acceptance-rate in PyMC3 (Metropolis-Hastings)","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am wondering how I can take only positive values in a list in Python.\nFor example, if I have A = [1, 2, 3], it should return [1, 2, 3]\nIf I have A = [-1, 2, 3], it should return [2, 3]\nif I have A = [-1, -2], it should return None\nThank you very much!","AnswerCount":3,"Available Count":1,"Score":0.1325487884,"is_accepted":false,"ViewCount":20880,"Q_Id":48039657,"Users Score":2,"Answer":"You can try  newlist = filter(lambda a: a > 0, [1, 2, 3]) or None or [i for i in original_list if i > 0] or None","Q_Score":1,"Tags":"python","A_Id":48039677,"CreationDate":"2017-12-31T03:12:00.000","Title":"How to take only positive values in a list in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have read a bunch of posts here and on Google, but my question is far more basic than the answers: If Python(2.7) came pre-installed on my MacBook Pro (High Sierra), can I just do sudo easy_install pip (as suggested) from the command line--withOUT causing issues? I have a vague understanding of global\/local installations, and my understanding is certain Python installations aren't compatible with local\/global kernel installations. I hope I am getting the terminology right, but I saw several warnings about installing pip for \"a homebrew based python installation\", but I am not sure whether Python on my laptop is installed via homebrew (nor how to find out).\nMy question came about because I wanted to install the Hydrogen package to use in Atom, the text editor (to help me learn Python). I finally succeeded in installing Hydrogen, but got stumped by the missing kernels (not sure which ones I need, so I am willing to install them all). But I can't seem to install the kernels without pip. So here I am. \nMy apologies for asking such a basic question--and thanks!","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":442,"Q_Id":48040573,"Users Score":1,"Answer":"Well although I am no Mac expert I've given it a shot anyway:\nYes you could but do you really want to risk it (or even do it)?  \nMac-OS must rely on Python to fulfill something in the OS otherwise it would not come inbuilt. This means two things:\nThe Python installation will be minimal.  By that I mean it will have things missing (any large library for a start).  They will do this mainly to cut down on the OS size.  Therefore you will not have the full Python library and in the long term you may end up missing out.\nSecond if anything went wrong (IE you broke your installation or even modified it -yep I've done this in Linux and have ended up factory resetting) then you may cause something to stop working and may need to factory reset or perform some other drastic action on your OS.  A separate installation would prevent your from risking this.  This is very useful because there comes a time when you may decide to update certain modules with pip and find it can't or it updates something that you shouldn't be messing with.\nYes it's possible you may run into compatibility problems but I think it's most widely accepted that you do not use the inbuilt one as it needs to remain unchanged if the OS is to use it correctly.  Messing with it increases the chances of it breaking.\nConclusion:  So even though installing modules with pip (and getting pip) can be done with the inbuilt Python it comes down whether you want to risk harming your OS.  I strongly suggest you get a separate installation and leave the inbuilt one as it is.  Second as you mentioned you will find that the inbuilt versions are never up-to-date or are built were they are not really compatible with standard libraries (expect things like the missing runtime libraries all the time) , just another reason to stay clear of them.","Q_Score":1,"Tags":"python,macos,pip,kernel,atom-editor","A_Id":48050542,"CreationDate":"2017-12-31T06:45:00.000","Title":"How to install pip for a total newbie","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've been thinking of this for a LONG time the past few days and can't figure out with my current toolset how to implement this in Django.\nWhat I want is something that can be implemented trivially in Java for example, but how I'd do that on the web is much more difficult\nThe problem\nI want to send data to a HTML template, specific example:\n\"What is 5 + 50?\"\nThe data must be dynamically generated, so the 5 and 50 are actually randomly generated.\nI think I am comfortable doing this part, as I'd simply pass a random variable to a template using the views.py\nThis is where I do not know how to proceed\nI want the user to be able to enter their answer, and have them notified if it correct.\nTo do this, I'd need to pass the variables from the template back to another view function. I am not sure how to do that, if it is possible at all.\nThis is how I'm deciding to pursue my projecti dea, and I'm not sure if this is the most efficient way\ntl;dr I just wanted data to be randomly generated and calculated using Django","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":131,"Q_Id":48041129,"Users Score":0,"Answer":"A pure django solution would be:\n\ncreate a form with three integer fields (say, num1, num2 and result)\nin your view, populate num1 and num2 with the numbers to be added\nrender the form in your template (num1 and num2 fields should be read only)\nthe user enters the answer in the result field and submits the form\nin your view, determine whether num1 + num2 == result\nredirect to a success page if the answer is correct, otherwise redisplay the form","Q_Score":0,"Tags":"python,django","A_Id":48041312,"CreationDate":"2017-12-31T08:40:00.000","Title":"Coding mental block with specific Django task","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to learn how to use pyinstaller to make an executable. I wrote a little script  in 2.7 as a test. Print 'test\" and named it test-print. When I click on the executable in the Build folder a cmd screen flashes, and that all she wrote. I tried adding a x = raw_input('input something: ') hoping that would cause the cmd screen, or some kind of screen to persist, but to no avail. I know this is basic stuff, but a voice of experience would be most helpful.\nF","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1732,"Q_Id":48041557,"Users Score":0,"Answer":"First try running the command from a command line (terminal) so you can see what happens.  Not from inside any IDE.\nIf you created the script in a MSWindows environment, be sure your PATH includes the executable (or explicitly give the path to the script).\nIn Linux\/Unix, be sure to enable execute permission for the script.  chmod +x scriptname","Q_Score":0,"Tags":"python,pyinstaller","A_Id":48041611,"CreationDate":"2017-12-31T10:03:00.000","Title":"pyinstaller -- script not found.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to learn how to use pyinstaller to make an executable. I wrote a little script  in 2.7 as a test. Print 'test\" and named it test-print. When I click on the executable in the Build folder a cmd screen flashes, and that all she wrote. I tried adding a x = raw_input('input something: ') hoping that would cause the cmd screen, or some kind of screen to persist, but to no avail. I know this is basic stuff, but a voice of experience would be most helpful.\nF","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1732,"Q_Id":48041557,"Users Score":0,"Answer":"In pyinstaller the actual executable is located in the dist folder. I assume you did not use pyinstallers \"--onefile\" switch so once you finish compiling, navigate to dist then test-print. Afterwards look for test-print.exe in that folder. That is your executable.","Q_Score":0,"Tags":"python,pyinstaller","A_Id":48043401,"CreationDate":"2017-12-31T10:03:00.000","Title":"pyinstaller -- script not found.","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"and thank you for your answer in advance. I am making a python program to automate something for my friend, and converted it into a .exe file with cx_Freeze so I could give it to him. But I have a x64 machine and he has a x86 machine. Can anyone please tell me how to make a x86 .exe file on my PC. I'm using Win 10 x64 and Python 3.6","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":181,"Q_Id":48041979,"Users Score":0,"Answer":"The .exe output actually depends on the installation you are using (I'm assuming x64) so if you used an x86bit or x32bit Python installation it will output the bit version your installation is (I know both will run on x64 computers) and just freeze in the normal way.  \nBear in mind that x32 works on x86, x64 as well so you might do best with that bit version.","Q_Score":0,"Tags":"windows,python-3.x,cx-freeze","A_Id":48140125,"CreationDate":"2017-12-31T11:13:00.000","Title":"Making a x86 .exe on a x64 machine","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was having a memory error in Python with a program, I found out I had to upgrade my Python to 64 bit. I did that. I then copied all the files from the Lib\/site-packages folder of the Python 32 bit and pasted it in the 64 bit folder. I did this so I wouldn't have to install the modules again for my program. \nI ran the program and got the following error:\n\nNameError: name 'numpy' is not defined\n\nAnd yes, I had import numpy in the program\nI think the problem is that I have to actually pip install numpy inside of the 64 bit Python (even though I copied the exact same Lib\/site-packages from 32 bit to 64 bit) using cmd. If that is the problem, how do I specifically pip install inside of the 64 bit Python folder rather than the default 32 bit folder? \nOtherwise, any suggestions?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":48043217,"Users Score":0,"Answer":"In Windows I use always this:\n\nRename the pip.exe to pip64.exe for example\nAdd python folder to Sys path if not exists.\nYou can use \"pip64 install package_name\"","Q_Score":0,"Tags":"python,python-3.x,numpy,64-bit","A_Id":48043323,"CreationDate":"2017-12-31T14:20:00.000","Title":"Using 32-bit and 64-bit Python - \"NameError: global name 'numpy' etc. is not defined\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was having a memory error in Python with a program, I found out I had to upgrade my Python to 64 bit. I did that. I then copied all the files from the Lib\/site-packages folder of the Python 32 bit and pasted it in the 64 bit folder. I did this so I wouldn't have to install the modules again for my program. \nI ran the program and got the following error:\n\nNameError: name 'numpy' is not defined\n\nAnd yes, I had import numpy in the program\nI think the problem is that I have to actually pip install numpy inside of the 64 bit Python (even though I copied the exact same Lib\/site-packages from 32 bit to 64 bit) using cmd. If that is the problem, how do I specifically pip install inside of the 64 bit Python folder rather than the default 32 bit folder? \nOtherwise, any suggestions?","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":302,"Q_Id":48043217,"Users Score":0,"Answer":"For windows Shift-Right-Click on your 64-bit installation folder that has python.exe and select Open command window here. Then type python.exe -m pip install numpy in there and press Enter.\nWhat this does is that it calls 64-bit python's pip to install numpy instead.","Q_Score":0,"Tags":"python,python-3.x,numpy,64-bit","A_Id":48043249,"CreationDate":"2017-12-31T14:20:00.000","Title":"Using 32-bit and 64-bit Python - \"NameError: global name 'numpy' etc. is not defined\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I was having a memory error in Python with a program, I found out I had to upgrade my Python to 64 bit. I did that. I then copied all the files from the Lib\/site-packages folder of the Python 32 bit and pasted it in the 64 bit folder. I did this so I wouldn't have to install the modules again for my program. \nI ran the program and got the following error:\n\nNameError: name 'numpy' is not defined\n\nAnd yes, I had import numpy in the program\nI think the problem is that I have to actually pip install numpy inside of the 64 bit Python (even though I copied the exact same Lib\/site-packages from 32 bit to 64 bit) using cmd. If that is the problem, how do I specifically pip install inside of the 64 bit Python folder rather than the default 32 bit folder? \nOtherwise, any suggestions?","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":302,"Q_Id":48043217,"Users Score":1,"Answer":"I then copied all the files from the Scripts folder of the Python 32\n  bit and pasted it in the 64 bit folder. I did this so I wouldn't have\n  to install the modules again for my program.\n\nThat wasn't a good idea. There are executables in the Scripts folder that are not the same for 32-bit and 64-bit Python. You have to do pip install separately for 32-bit and 64-bit Python. Any DLL involved in the install will not be the same for both versions, in fact 64-bit Python will not even see a 32-bit DLL.\nDo it the long way. I know that's a drag but taking shortcuts is likely to lead to baffling errors.","Q_Score":0,"Tags":"python,python-3.x,numpy,64-bit","A_Id":48043267,"CreationDate":"2017-12-31T14:20:00.000","Title":"Using 32-bit and 64-bit Python - \"NameError: global name 'numpy' etc. is not defined\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"By default, candlestick and ohlc charts display a rangeslider. \nIt seems like there's no parameter to change the setting. So I've looked at javascript code in html file but was not able to find a clue to remove it.\nCan someone explain how to remove the rangeslider from candlestick chart?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2723,"Q_Id":48085374,"Users Score":5,"Answer":"I found the solution..\nFollowing code hides the rangeslider graph on the bottom of candle stick chart..\nxaxis : {fixedrange: true, rangeslider: {visible: false}}","Q_Score":1,"Tags":"javascript,python,plotly","A_Id":48085729,"CreationDate":"2018-01-03T21:28:00.000","Title":"Plotly - How to remove the rangeslider","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a workbook that has several tabs with pivot tables.  I can put data on the tab that holds the data for each pivot.  My problem is that I don't know how to refresh the pivot tables.  I would assume that I would need to cycle through each sheet, check to see if there is a pivot table, and refresh it.  I just can't find how to do that.  All of the examples I find use win32 options, but I'm using a Mac and Linux.\nI would like to achieve with openpyxl if possible.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3004,"Q_Id":48088137,"Users Score":0,"Answer":"Worksheets(\"SheetName\").PivotTables(\"PivotTableName\").PivotCache().Refresh()","Q_Score":0,"Tags":"python,excel,pivot-table,openpyxl","A_Id":52813212,"CreationDate":"2018-01-04T03:10:00.000","Title":"Refresh Excel Pivot Tables","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am kind a stuck. I have tried to make Tetris game with music to .exe, but I really don't know how to do it. Can someone give some tips, how to make .py to .exe?\n I have tried Pyinstaller, cx_Freeze and none of them work.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":88,"Q_Id":48092110,"Users Score":1,"Answer":"They should all work.  Py2exe and Py2app are the ones that don't.  If they don't work they you haven't used them properly.  Particularly cx_Freeze that requires you to \"tune things manually\".\nHere are some debug steps that will help you resolve your error:\n\nWhen freezing for the first time don't hide the console.  This will hide any errors that occur.  You need to see those.\nWhen building look for any errors that appear at the end.  These may give you a clue as to how to solve the problem.\nIf you have errors the terminal will appear shortly then close. Run the executable through the terminal and the terminal will stay open allowing you to read the messages. This can be done in the following way:\n\n\n    C:\\Location>cd \\Of\\App \n    C:\\Location\\Of\\App>NameOfExecutable\ncd is a command that stands for change dictionary and assuming your .exe is called NameOfExecutable.\nUnder PowerShell you would use the same but .\/NmeOfExecutable to execute instead.\n\nSee what errors that appear.  If you get an error that says a package is missing includes often does the trick (remember to include the top level package as well as the exact one missing.\nIf you use external files or images remember to use include_files to add them along as well.  Note that you can add runtimes (or DLLs) in this way too\nAttempt a build folder before going for an msi.  Get the build folder working first then go for the msi.","Q_Score":1,"Tags":"python,python-3.x,exe,executable","A_Id":48123001,"CreationDate":"2018-01-04T09:20:00.000","Title":"Converting Python 3.6.1 Tetris game with music, to exe","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"for a project i have to make a GUI for python. It should show some variables (temp etc). But I don't know how I can pass variables trough GTK to the window. Any answers appreciated :)\nsome info: I am using a RPi3, but that's nothing which is important, or is it? I have a 7\" display attached, on which the program should be seen in full screen. In the end, there should stand sth like temp, humidity, water etc\nI don't exactly know which GTK i use, but it's in python. So I think it's pygtk\nThanks for reading,\nFabian","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":104,"Q_Id":48092543,"Users Score":1,"Answer":"Done. I've used Flask, Socket.io and gtk to make an app, showing a html file in full screen, with python variables in it.","Q_Score":0,"Tags":"python,html,python-2.7,gtk,webkitgtk","A_Id":48123502,"CreationDate":"2018-01-04T09:45:00.000","Title":"Give python variables to GTK+ with an html file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm working on a windows 7 and using Cygwin for unix-like functionality. I can write and run Python scripts fine from the Cygwin console, and the installation of Python packages using pip installis successful and the installed package appears under pip list. However, if I try to run a script that imports these packages, for example the 'aloe' package, I get the error \"no such module named 'aloe'\". \nI have discovered that the packages are being installed to c:\\python27\\lib\\site-packages, i.e. the computer's general list of python packages, and not to \/usr\/lib\/python3.6\/site-packages, i.e. the list of python packages available within Cygwin. I don't know how to rectify this though. If I try to specify the install location using easy_install-3.6 aloe I get the error\n\n[Errno 13] Permission denied: '\/usr\/lib\/python3.6\/site-packages\/test-easy-install-7592.write-test'.\n\nIn desperation also tried directly copying the 'aloe' directory to the Cygwin Python packages directory using cmd with cp -r \\python27\\lib\\site-packages\\aloe \\cygwin\\lib\\python3.6\\site-packages and the move was successful, but the problem persists and when I check in the Cygwin console using ls \/usr\/lib\/python3.6\/site-packages I can't see 'aloe'.\nI have admin rights to the computer in general (sudo is not available in Cygwin anyway) so really can't figure out what the problem is. Any help would be greatly appreciated.\nThanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3417,"Q_Id":48093726,"Users Score":1,"Answer":"just make sure you are in admin mode.\ni.e. right click on Cygwin, select running as administrator.\nthen install your package specifically using pip3, for python3.\ni.e. pip3 install your_package\nwith updated version, do pip3 install --upgrade your_package","Q_Score":1,"Tags":"python,cygwin","A_Id":48096083,"CreationDate":"2018-01-04T10:55:00.000","Title":"permission denied when installing python packages through cygwin","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a Flask app and want it to work for www.domain-a.net and www.domain-b.net behind Apache + WSGI. I can get it to work for one or the other, but can't find a way to get it to work for both. It seems that the domain which registers first is the only one that works.\nPreferably this would work by having two Apache VirtualHosts set up to use the same WSGI config. I can get that part to work. But Flask just returns 404 for everything sent from the second VirtualHost.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":392,"Q_Id":48122283,"Users Score":1,"Answer":"It seems that having SERVER_NAME set in the os environment was causing this problem in conjunction with subdomains in blueprint registration. I removed SERVER_NAME from \/etc\/apache2\/envvars and the subdomain logic and it worked.","Q_Score":2,"Tags":"python,apache,flask,virtualhost","A_Id":48142441,"CreationDate":"2018-01-05T22:38:00.000","Title":"how do I get Flask blueprints to work with multiple domains?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to calculate intersection of two planes in form of AX+BY+CZ+D=0 and get a line in form of two (x,y,z) points. I know how to do the math, but I want to avoid inventing a bicycle and use something effective and tested. Is there any library which already implements this? Tried to search opencv and google, but with no success.","AnswerCount":3,"Available Count":1,"Score":-0.1325487884,"is_accepted":false,"ViewCount":8472,"Q_Id":48126838,"Users Score":-2,"Answer":"This is solved by elementary vector computation and is not substantial\/useful enough to deserve a library implementation. Work out the math with Numpy.\nThe line direction is given by the cross product of the two normal vectors (A, B, C), and it suffices to find a single point, say the intersection of the two given planes and the plane orthogonal to the line direction and through the origin (by solving a 3x3 system).\n\nComputation will of course fail for parallel planes, and be numerically unstable for nearly parallel ones, but I don't think there's anything you can do.","Q_Score":8,"Tags":"python,computational-geometry,intersection,plane","A_Id":48129094,"CreationDate":"2018-01-06T11:25:00.000","Title":"Plane-plane intersection in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using gurobi with anaconda and python, and recently downloaded an updated version (7.5.2) to update the already installed 7.0.2 version that is on my computer.\nI can find the conda command line prompts to remove the conda installed package, but cannot find any code anywhere to remove the 7.0.2 version from my computer so that it doesn't keep referencing 7.0.2 when I try to install new version via conda again.\nIf anyone can offer any advice it would be much appreciated! Interesting that there is nothing in the gurobi docs that states how to do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1726,"Q_Id":48140731,"Users Score":0,"Answer":"I suggest the following:\nconda list to see what's in the environment, and how it was installed.\nIf gurobi was installed as a conda package then use conda uninstall gurobi, if using pip then use pip uninstall gurobi.","Q_Score":0,"Tags":"python,conda,gurobi","A_Id":48141155,"CreationDate":"2018-01-07T19:23:00.000","Title":"How to remove old version of gurobi in Windows","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a FlowFile and I want to insert the attributes into RDS.  If this was a local machine, I'd create a DBCPConnectionPool, reference a JDBC driver, etc.\nWith RDS, what am I supposed to do?  Something similar (how would I do this on AWS)?  Or am I stuck using ExecuteScript?  If it's the later, is there a Python example for how to do this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1019,"Q_Id":48162075,"Users Score":1,"Answer":"Question might not have been clear based on the feedback, but here is the answer to get a NiFi (running on an AWS EC2 instance) communicating with an Amazon RDS instance:\n\nOn the EC2 instance, download the latest JDBC driver (wget \"https:\/\/driver.jar\")\n(If needed) Move the JDBC driver into a safe folder.\nCreate the DBCPConnectionPool, referencing the fully-resolved file path to the driver.jar (helpful: use readlink -f driver.jar to get the path).\nDon't forget -- under your AWS Security Groups, add an inbound rule that allows your EC2 instance to access RDS (under Source, you should put the security group of your EC2 instance).","Q_Score":0,"Tags":"python,amazon-rds,apache-nifi","A_Id":48170299,"CreationDate":"2018-01-09T05:44:00.000","Title":"How best to interact with AWS RDS Postgres via NiFi","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"everyone!\nI want to implement the Turtle into my application just for the purpose of coordinate generation. The problem is that I need to get the coordinates of turtle move (etc.) without any \"pop-up window\" containing the graphics or even worse animation. Is it possible somehow to disable initialization of turtle graphics?\nThanks a lot!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":60,"Q_Id":48189504,"Users Score":0,"Answer":"OK, I have solved the situation by using: speed(0); turtle.tracer(False); turtle.bye(). The graphics window is intialized but suddenly closed.","Q_Score":0,"Tags":"python,turtle-graphics","A_Id":48210844,"CreationDate":"2018-01-10T14:22:00.000","Title":"How to disable initializing of graphics window of Python Turtle","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Flask app that I run with uWSGI. I have configured logging to file in the Python\/Flask application, so on service start it logs that the application has been started.\nI want to be able to do this when the service stops as well, but I don't know how to implement it.\nFor example, if I run the uwsgi app in console, and then interrupt it with Ctrl-C, I get only uwsgi logs (\"Goodbye to uwsgi\" etc) in console, but no logs from the stopped python application. Not sure how to do this.\nI would be glad if someone advised on possible solutions.\nEdit:\nI've tried to use Python's atexit module, but the function that I registered to run on exit is executed not one time, but 4 times (which is the number of uWSGI workers).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":183,"Q_Id":48206010,"Users Score":1,"Answer":"There is no \"stop\" event in WSGI, so there is no way to detect when the application stops, only when the server \/ worker stops.","Q_Score":0,"Tags":"python,logging,flask,uwsgi","A_Id":48211175,"CreationDate":"2018-01-11T11:29:00.000","Title":"Logging uWSGI application stop in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My code is as follow:\nlist = re.findall((\"PROGRAM S\\d\\d\"), contents\nIf I print the list I just print S51 but I want to take everything.\nI want to findall everything like that \"PROGRAM S51_Mix_Station\". I know how to put the digits to find them but I don\u00b4t know how to find everything until the next space because usually after the last character there is an space.\nThanks in advance.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":48209706,"Users Score":0,"Answer":"Ok, thanks. I find another solution.\nlista = re.findall((\"PROGRAM S\\d\\d\\S+\") To find any character after the digit as repetition.","Q_Score":0,"Tags":"python,regex","A_Id":48210007,"CreationDate":"2018-01-11T14:43:00.000","Title":"Regular expression help to find space after a long string","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I need to convert my .py files into .exe files for Python 3.6.4.  I have tried almost everything on Google and YouTube and none of it seems to work for me.  It seems as though a lot of the explanations either gloss over the most technical aspects of installing any modules that convert .py files into .exe files or they are outdated.  Can someone give me a step by step example of how to convert my .py files into .exe files for Python 3.6.4.?  I was able to convert the .py files easily for Python 3.4 but not 3.6.4.  My file path is: This Pc > C: > Users > XXXX > AppData > Local > Programs > Python > Python36-32","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":133,"Q_Id":48211634,"Users Score":0,"Answer":"Most of the external packages are still not supporting 3.6.\nTry with cx_Freeze in 3.6 else go with pyinstaller but python version should be 3.5(this works fine for me)","Q_Score":1,"Tags":"python-3.x","A_Id":51157311,"CreationDate":"2018-01-11T16:21:00.000","Title":"How to convert a .py file into a .exe file for Python 3.6.4","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What is the difference in the functionalities of tf.layers.conv1d and tf.layers.conv2d in tensorflow and how to decide which one to choose?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":4923,"Q_Id":48219121,"Users Score":8,"Answer":"tf.layers.conv1d is used when you slide your convolution kernels along 1 dimensions (i.e. you reuse the same weights, sliding them along 1 dimensions), whereas tf.layers.conv2d is used when you slide your convolution kernels along 2 dimensions (i.e. you reuse the same weights, sliding them along 2 dimensions).\nSo the typical use case for tf.layers.conv2d is if you have a 2D image. And possible use-cases for tf.layers.conv1d are, for example:\n\nConvolutions in Time\nConvolutions on Piano notes","Q_Score":2,"Tags":"python,tensorflow,neural-network,conv-neural-network","A_Id":48223162,"CreationDate":"2018-01-12T03:24:00.000","Title":"Difference between tf.layers.conv1d vs tf.layers.conv2d","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have to develop an Android application which makes use of machine learning algorithms at the back end. Now, for developing the Android app, I use Java and for implementing the machine learning algorithms I use Python.\nMy question is how to link the Python code to an Android app written in Java. That is supposed my Python code generates an output, now how to send this data to an Android application?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":347,"Q_Id":48237510,"Users Score":0,"Answer":"If you have access to python from java android app. You can write python output in file, then in java code read that file.\nOr if python output is in web, you will need some web service that provides json\/xml output, and then in java code you should call that web service.","Q_Score":0,"Tags":"java,android,python","A_Id":48238627,"CreationDate":"2018-01-13T06:37:00.000","Title":"How to link python code to android application developed in java?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a flow sensor that I have to read with c because python isn't fast enough but the rest of my code is python. What I want to do is have the c code running in the background and just have the python request a value from it every now and then. I know that popen is probably the easiest way to do this but I don't fully understand how to use it. I don't want completed code I just want a way to send text\/numbers back and forth between a python and a c code. I am running raspbian on a raspberry pi zero w. Any help would be appreciated.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":48265821,"Users Score":0,"Answer":"Probably not a full answer, but I expect it gives some hints and it is far too long for a comment. You should think twice about your requirements, because it will probably not be that easy depending on your proficiency in C and what OS you are using. \nIf I have correctly understood, you have a sensor that sends data (which is already weird unless the sensor is an intelligent one). You want to write a C program that will read that data and either buffer it, and retain only last (you did not say...) and at the same time will wait for requests from a Python script to give it back what it has received (and kept) from the sensor. That probably means a dual thread program with quite a bit of synchronization.\nYou will also need to specify the communication way between C and Python. You can certainly use the subprocess module, but do not forget to use unbuffered output in C. But you could also imagine an independant program that uses a FIFO or a named piped with a well defined protocol for external requests, in order to completely separate both problems.\nSo my opinion is that this is currently too broad for a single SO question...","Q_Score":0,"Tags":"python,c,popen","A_Id":48266333,"CreationDate":"2018-01-15T15:18:00.000","Title":"How to read a sensor in c but then use that input in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Scenario:\nI have a Source which maintains the transactions data. They have around 900 columns and based on the requirements of the new business, they add additional columns.\nWe are a BI team and we only extract around 200 columns which are required for our reporting. But when new business is launched \/ new analysis is required, sometimes users approach us and request us to pull extra columns from the source.\nCurrent Design:\nWe have created a table with extra columns for future columns as well.\nWe are maintaining a 400 column table with the future column names like str_01, str_02...., numer_01, numer_02... date_01, date_02... etc.\nWe have a mapping table which maps the columns in our table and columns in Source table. Using this mapping table, we extract the data from source.\nProblem:\nRecently, we have reached the 400 column limit of our table and we won't be able to onboard any new columns. One approach that we can implement is to modify the table to increase the columns to 500 (or 600) but I am looking for other solutions on how to implement ETL \/ design the table structure for these scenarios.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":131,"Q_Id":48272093,"Users Score":1,"Answer":"I suppose your additional columns are measures, not dimensions. So you can keep the dimensions in the individual columns and include them into sort key, and store measures in JSON, accessing them whenever you need. Also if you can distinguish between frequently used measures vs. occasional you can store the frequently used ones in columns and the occasional ones in JSON. Redshift has native support for extracting the value given the key, and you also have the ability to set up Python UDFs for more complex processing.","Q_Score":0,"Tags":"python,amazon-redshift,etl,emr,amazon-emr","A_Id":48276498,"CreationDate":"2018-01-15T23:26:00.000","Title":"ETL for a frequently changing Table structure","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"For my automation purposes, I'm using Fabric. But I could not run 2 tasks at the same time?\nFor example, I want to run task 1 to collect data in the tmp folder. I want to run task 2 which will generate data and put in tmp. Tas1 2 will be running a bit before task 2.\nHere is my sudo code:\noutput1 = run(\".\/task1_data_logger &\")\noutput2 = run(\".\/task2_main_program\")        \nRESULT: Task2_main_program is running fine but I didn't see task1_data_logger running at all. I thought I put the & so that Task1 can be run in the background.\nI've read Parallel execution document but it is more for running parallel in multiple host, which is not my case. \nAnyone knows how to 2 tasks simultaneously instead of serially? \nThank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":114,"Q_Id":48273001,"Users Score":0,"Answer":"The task1 did not run at all because running a command with & in Fabric does not work.\nIt is because, in linux when you log out of a session all the processes associated with it are terminated.\nSo if you want to make sure a command keeps running even after you log out of the session you need to run it like this:\nrun('nohup sh command &')","Q_Score":0,"Tags":"python,parallel-processing,fabric","A_Id":48341150,"CreationDate":"2018-01-16T01:45:00.000","Title":"Running 2 tasks at the same time using Fabric","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm relatively new to python and I am using difflib to compare two files and I want to find all the lines that don't match. The first file is just one line so it is essentially comparing against all the lines of the second file. When using difflib, the results show the '-' sign in front of the lines that don't match and it doesn't show anything in front of the line that does match. (I thought it would show a '+'). For the lines that have a '-' in front, how can I just write those lines to a brand new file (without the '-' in front) ? Below is the code snippet I am using for the difflib. Any help is greatly appreciated.\nf=open('fg_new.txt','r')\nf1=open('out.txt','r')\nstr1=f.read()\nstr2=f1.read()\nstr1=str1.split()\nstr2=str2.split()\nd=difflib.Differ()\ndiff=list(d.compare(str2,str1))\nprint ('\\n'.join(diff))","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":252,"Q_Id":48273710,"Users Score":0,"Answer":"You may use below\nset(str1).intersection(set(str2))\nwhich will give you the difference of the two list.","Q_Score":0,"Tags":"python,compare,difflib","A_Id":48273885,"CreationDate":"2018-01-16T03:33:00.000","Title":"difflib and removing lines even without + in front of them python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm facing a weird issue on Pandas now, not sure if a pandas pitfall or just something I'm missing...\nMy pd.Series is just\nfoo\nFalse\nFalse\nFalse\n\n> a.foo.dtype\ndtype('bool')\n\nWhen I use a dataframe.set_value(index, col, None), my whole Series is converted to dtype('float64') (same thing applies to a.at[index, col] = None).\nNow my Series is\n\nfoo\nNaN\nNaN\nNaN\n\nDo you have any idea on how this happens and how to fix it?\nThanks in advance. :)\nEdit:\nUsing 0.20.1.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":37,"Q_Id":48302876,"Users Score":1,"Answer":"I think the problem is related to the fact that I was trying to assign a None to a bool Series, then it just tries to convert to a different type (why not object?)\nFixed changing the dtype to object first: dataframe.foo = dataframe.foo.astype(object).\nWorks like a charm now.","Q_Score":0,"Tags":"python,pandas","A_Id":48303455,"CreationDate":"2018-01-17T13:57:00.000","Title":"dtype changes after set_value\/at","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Edited Question:\nI guess I worded my previous question improperly, I actually want to get away from \"unit tests\" and create automated, modular system tests that build off of each other to test the application as whole.  Many parts are dependent upon the previous pages and subsequent pages cannot be reached without first performing the necessary steps on the previous pages.  \nFor example (and I am sorry I cannot give the actual code), I want to sign into an app, then insert some data, then show that the data was sent successfully.  It is more involved than that, however, I would like to make the web driver portion, 'Module 1.x'. Then the sign in portion, 'Module 2.x'.  The data portion, 'Module 3.x'.  Finally, success portion, 'Module 4.x'.  I was hoping to achieve this so that I could eventually say, \"ok, for this test, I need it to be a bit more complicated so let's do, IE (ie. Module 1.4), sign in (ie. Module 2.1), add a name (ie Module 3.1), add an address (ie. Module 3.2), add a phone number (ie Module 3.3), then check for success (ie Module 4.1).  So, I need all of these strung together.  (This is extremely simplified and just an example of what I need to occur.  Even in the case of the unit tests, I am unable to simply skip to a page to check that the elements are present without completing the required prerequisite information.) The issue that I am running into with the lengthy tests that I have created is that each one requires multiple edits when something is changed and then multiplied by the number of drivers, in this case Chrome, IE, Edge and Firefox (a factor of 4).  Maybe my approach is totally wrong but this is new ground for me, so any advice is much appreciated. Thank you again for your help!\nPrevious Question:\nI have found many answers for creating unit tests, however, I am unable to find any advice on how to make said tests sequential.  \nI really want to make modular tests that can be reused when the same action is being performed repeatedly.  I have tried various ways to achieve this but I have been unsuccessful.  Currently I have several lengthy tests that reuse much of the same code in each test, but I have to adjust each one individually with any new changes.  \nSo, I really would like to have .py files that only contain a few lines of code for the specific task that I am trying to complete, while re-using the same browser instance that is already open and on the page where the previous portion of the test left off.  Hoping to achieve this by 'calling' the smaller\/modular test files.  \nAny help and\/or examples are greatly appreciated.  Thank you for your time and assistance with this issue.\nRespectfully, \nBilliamaire","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":150,"Q_Id":48309776,"Users Score":0,"Answer":"You don't really want your tests to be sequential. That breaks one of the core rules of unit tests where they should be able to be run in any order.\nYou haven't posted any code so it's hard to know what to suggest but if you aren't using the page object model, I would suggest that you start. There are a lot of resources on the web for this but the basics are that you create a single class per page or widget. That class would hold all the code and locators that pertains to that page. This will help with the modular aspect of what you are seeking because in your script you just instantiate the page object and then consume the API. The details of interacting with the page, the logic, etc. all lives in the page object is exposed via the API it provides.\nChanges\/updates are easy. If the login page changes, you edit the page object for the login page and you're done. If the page objects are properly implemented and the changes to the page aren't severe, many times you won't need to change the scripts at all.\nA simple example would be the login page. In the login class for that page, you would have a login() method that takes username and password. The login() method would handle entering the username and password into the appropriate fields and clicking the sign in button, etc.","Q_Score":0,"Tags":"python,selenium,automated-tests,modular","A_Id":48311473,"CreationDate":"2018-01-17T20:50:00.000","Title":"Is it possible to make sequential tests in Python-Selenium tests?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"assuming the following sentence:\nthis is @sys.any and. here @names hello. and good.bye\nhow would I find all the '.' besides the ones appearing in words that start with @?\ndisclaimer, been playing at regex101 for over 2 hours now after reading a few answers on SO and other forums.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":98,"Q_Id":48323434,"Users Score":2,"Answer":"(^|\\s)(\\w*(\\.))+ - this may satisfy the sample text you've posted. You can find all '.' in third group \nUPDATE: if in your text you have words, started with any other symbol, for instance, #asd.qwe.zxc, you can improve your reg exp:\n(^|\\s)[^@]?(\\w*(\\.))+","Q_Score":1,"Tags":"javascript,python,regex,regex-negation,regex-group","A_Id":48323646,"CreationDate":"2018-01-18T14:20:00.000","Title":"Regex find char '.' except for words starting with @","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I've currently got a flask app that I'm using to run a testing app, (this works on local host) but I cant work out how to launch it so I can test the connectivity from other devices (public).\ncan someone explain how I can go about launching it, or at least point me in the right direction to some documentation about how to make it public. I don't think I'm either port forwarding it correctly or i need a web server like xampp to run it.\nthanks","AnswerCount":3,"Available Count":2,"Score":0.0665680765,"is_accepted":false,"ViewCount":243,"Q_Id":48330515,"Users Score":1,"Answer":"to make an application works with public host you have to make sure enabling port forwarding in your modem device, you can etablish a cnx with the nginx server","Q_Score":0,"Tags":"python,flask","A_Id":48330614,"CreationDate":"2018-01-18T21:21:00.000","Title":"Launching a flask app\/website so other networks can connect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So I've currently got a flask app that I'm using to run a testing app, (this works on local host) but I cant work out how to launch it so I can test the connectivity from other devices (public).\ncan someone explain how I can go about launching it, or at least point me in the right direction to some documentation about how to make it public. I don't think I'm either port forwarding it correctly or i need a web server like xampp to run it.\nthanks","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":243,"Q_Id":48330515,"Users Score":0,"Answer":"If you change the ip address of the flask server from the default 0.0.0.0 to your the ip address of your computer (eg 192.168.1.2) the other clients on your local network can connect.\nIf you want to expose your app the whole of the internet you should get a host that (eg try heroku.com) that has a fixed ip assigned and is reachable from the internet.","Q_Score":0,"Tags":"python,flask","A_Id":48330687,"CreationDate":"2018-01-18T21:21:00.000","Title":"Launching a flask app\/website so other networks can connect","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using the PYGMO package to solve some nasty non-linear minimization problems, and am very interested in using their simulated_annealing algorithm, however it has a lot of hyper-parameters for which I don't really have any good intuition. These include:\nTs (float) \u2013 starting temperature\n Tf (float) \u2013 final temperature\n n_T_adj (int) \u2013 number of temperature adjustments in the annealing schedule\n n_range_adj (int) \u2013 number of adjustments of the search range performed at a constant temperature\n bin_size (int) \u2013 number of mutations that are used to compute the acceptance rate\n start_range (float) \u2013 starting range for mutating the decision vector\nLet's say I have a 4 dimensional geometric registration (homography) problem with variables and search ranges:\nx1: [-10,10] (a shift in x)\n x2: [10,30]  (a shift in y)\n x3: [-45,0]  (rotation angle)\n x4: [0.5,2]  (scaling\/magnification factor)\nAnd the cost function for a random (bad) choice of values is 50. A good value is around zero. \nI understand that Ts and Tf are for the Metropolis acceptance criterion of new solutions. That means Ts should be about the expected size of the initial changes in the cost function, and Tf small enough that no more changes are expected. \nIn Corana's paper, there are many hyperparameters listed that make sense: N_s is the number of evaluation cycles before changing step sizes, N_T are the number of step-size changes before changing the temperature, and r_T is the factor by which the temp is reduced each time. However, I can't figure out how these correlate to pygmo's parameters of n_T_adj, n_range_adj, bin_size, and start_range.\nI'm really curious if anyone can explain how pygmo's hyperparameters are used, and how they relate to the original paper by Corana et al?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":175,"Q_Id":48344081,"Users Score":0,"Answer":"Gonna answer my own question here. I climbed into the actual .cpp code and found the answers.\nIn Corana's method, you select how many total iterations N of annealing you want. Then the minimization is a nested series of loops where you vary the step sizes, number of step-size adjustments, and temperature values at user-defined intervals. In PAGMO, they changed this so you explicitly specify how many times you will do these. Those are the n_* parameters and bin_size. I don't think bin_size is a good name here, because it isn't actually a size. It is the number of steps taken through a bin range, such that N=n_T_adj * n_range_adj * bin_range. I think just calling it n_bins or n_bins_adj makes more sense. Every bin_size function evaluations, the stepsize is modified (see below for limits). \nIn Corana's method you specify the multiplicative factor to decrease the temperature each time it is needed; it could be that you reach the minimum temp before running out of iterations, or vice versa. In PAGMO, the algorithm automatically computes the temperature-change factor so that you reach Tf at the end of the iteration sequence: r_t=(Tf\/Ts)**(1\/n_T_adj). \nThe start_range is, I think, a bad name for this variable. The stepsize in the alorithm is a fraction between 0 and start_range which defines the width of the search bins between the upper and lower bounds for each variable. So if stepsize=0.5, width=0.5*(upper_bound-lower_bound). At each iteration, the step size is adjusted based on how many function calls were accepted. If the step size grows larger than start_range, it is reset to that value. I think I would call it step_limit instead. But there you go.","Q_Score":0,"Tags":"python,minimization,simulated-annealing","A_Id":48346637,"CreationDate":"2018-01-19T15:09:00.000","Title":"PAGMO\/PYGMO: Anyone understand the options for Corana\u2019s Simulated Annealing?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a simple IDE that is web based in Python. For now, this IDE will support C only. I know it is possible to call the gcc with Python to compile and run a single C file. But what if I would like to compile and run multiple C files from a single project (i.e. linking .h files and .c files), is this possible? If yes, can you please tell me how?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":330,"Q_Id":48349091,"Users Score":0,"Answer":"Well assuming you want to handle all type of projects and their dependencies (which is not easy) the best way is to have a module that generates a Makefile for the project and use it to compile and solve all dependencies","Q_Score":0,"Tags":"python,c,gcc","A_Id":48350932,"CreationDate":"2018-01-19T20:32:00.000","Title":"Calling gcc to compile multiple files with Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Within AWS Glue how do I deal with files from S3 that will change every week.\nExample:\nWeek 1: \u201cfilename01072018.csv\u201d\nWeek 2: \u201cfilename01142018.csv\u201d\nThese files are setup in the same format but I need Glue to be able to change per week to load this data into Redshift from S3. The code for Glue uses native Python as the backend.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":292,"Q_Id":48353544,"Users Score":0,"Answer":"AWS Glue should be able to process all the files in a folder irrespective of the name in a single job. If you don\u2019t want the old file to be processed again move it using boto3 api for s3 to another location after each run.","Q_Score":1,"Tags":"python,python-3.x,amazon-redshift,aws-glue","A_Id":54622059,"CreationDate":"2018-01-20T07:00:00.000","Title":"Aws Glue - S3 - Native Python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been using Django Postman for a few weeks now, and in order to limit the number of messages sent by each user, I have been wondering what would be the best way to limit the number of messages a user can send a day, a week... using Django-postman? \nI have been browsing dedicated documentation for weeks too in order to find an answer for the how, but I think this is not a usecase for now, and I do not really know how to manage that. \nOf course I am not looking for a well cooked answer, but I would like to avoid writing labyrinthine code, so maybe just a few ideas about it could help me to see clear through that problematic.\nMany thanks for your help on that topic!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":427,"Q_Id":48370499,"Users Score":0,"Answer":"as a simple idea the  inserting of new msg in database should be with a condition to limit their numbers (the count of the previous msg  isn't > max )\n another method : you will show the input of the msg jsut when  (selet * form table where userid=sesion and count(usermsg)< max )","Q_Score":3,"Tags":"python,django,django-apps","A_Id":48372180,"CreationDate":"2018-01-21T18:54:00.000","Title":"Is it possible to limit the number of messages a user can send a day with Django postman?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm working on a competitive programming problem where we're trying to find the median of two sorted arrays. The optimal algorithm is to perform a binary search and identify splitting points, i and j, between the two arrays.\nI'm having trouble deriving the solution myself. I don't understand the initial logic.  I will follow how I think of the problem so far.\nThe concept of the median is to partition the given array into two sets.  Consider a hypothetical left array and a hypothetical right array after merging the two given arrays. Both these arrays are of the same length.\nWe know that the median given both those hypothetical arrays works out to be [max(left) + min(right)]\/2. This makes sense so far. But the issue here is now knowing how to construct the left and right arrays. \nWe can choose a splitting point on ArrayA as i and a splitting point on ArrayB as j. Note that len(ArrayB[:j] + ArrayB[:i]) == len(ArrayB[j:] +ArrayB[i:]).\nNow we just need to find the cutting points. We could try all splitting points i, j such that they satisfy the median condition. However this works out to be O(m*n) where M is size of ArrayB and where N is size of ArrayA. \nI'm not sure how to get where I am to the binary search solution using my train of thought. If someone could give me pointers - that would be awesome.","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":711,"Q_Id":48386293,"Users Score":3,"Answer":"Here is my approach that I managed to come up with.\nFirst of all we know that the resulting array will contain N+M elements, meaning that the left part will contain (N+M)\/2 elements, and the right part will contain (N+M)\/2 elements as well. Let's denote the resulting array as Ans, and denote the size of one of its parts as PartSize.\nPerform a binary search operation on array A. The range of such binary search will be [0, N]. This binary search operation will help you determine the number of elements from array A that will form the left part of the resulting array.\nNow, suppose we are testing the value i. If i elements from array A are supposed to be included in the left part of the resulting array, this means that j = PartSize - i elements must be included from array B in the first part as well. We have the following possibilities:\n\nj > M this is an invalid state. In this case it means we still need to choose more elements from array A, so our new binary search range becomes [i + 1, N].\nj <= M & A[i+1] < B[j] This is a tricky case. Think about it. If the next element in array A is smaller than the element j in array B, this means that element A[i+1] is supposed to be in the left part rather than element B[j]. In this case our new binary search range becomes [i+1, N].\nj <= M & A[i] > B[j+1] This is close to the previous case. If the next element in array B is smaller than the element i in array A, the means that element B[j+1] is supposed to be in the left part rather than element A[i]. In this case our new binary search range becomes [0, i-1].\nj <= M & A[i+1] >= B[j] & A[i] <= B[j+1] this is the optimal case, and you have finally found your answer.\n\nAfter the binary search operation is finished, and you managed to calculate both i and j, you can now easily find the value of the median. You need to handle a few cases here depending on whether N+M is odd or even.\nHope it helps!","Q_Score":1,"Tags":"python,arrays,algorithm","A_Id":48389275,"CreationDate":"2018-01-22T16:37:00.000","Title":"How to find the median between two sorted arrays?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm a beginner and my textbook just covered iterations and loops in Python. Lists have only been given cursory coverage at this point. \nThe exercise I'm struggling with is this:  Write a program which repeatedly reads numbers until the user enters \"done\". Once \"done\" is entered print out the total, count and average of all the numbers.  If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number. \nAll of this I can manage, except for how to get the program to store multiple user inputs. No matter what I write I only end manipulating the last number entered. Considering we haven't formally covered lists yet I find it hard to believe I should be using append, and therefore must be overthinking this problem to death. \nAny and all advice is much appreciated.","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":89,"Q_Id":48408263,"Users Score":2,"Answer":"You only need to remember the sum and the number of inputs in two variables that are updated when the user writes a number.\nWhen the user enters 'done', compute the mean (sum \/ number_of_inputs).","Q_Score":0,"Tags":"python,python-3.x,list,loops","A_Id":48408389,"CreationDate":"2018-01-23T18:13:00.000","Title":"Possible to write a loop in Python that stores user input for future manipulation without using append?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I understand generator generates value once at a time, which could save a lot memory and not like list which stores all value in memory.\nI want to know in python, how yield knows which value should be returned during the iteration without storing all data at once in memory? \nIn my understanding, if i want to print 1 to 100 using yield, it is necessary that yield needs to know or store 1 to 100 first and then move point one by one to return value ?\nIf not, then how yield return value once at a time, but without storing all value in memory?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1899,"Q_Id":48435165,"Users Score":3,"Answer":"Simply put, yield delays the execution but remembers where it left off. However, more specifically, when yield is called, the variables in the state of the generator function are saved in a \"frozen\" state. When yield is called again, the built in next function sends back the data in line to be transmitted. If there is no more data to be yielded (hence a StopIteration is raised), the generator data stored in its \"frozen\" state is discarded.","Q_Score":3,"Tags":"python,generator,yield","A_Id":48435262,"CreationDate":"2018-01-25T03:29:00.000","Title":"where does the yield store value in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a java program and I need it to get some data calculated by a python script. \nI've already got java to send an integer to python via jython's PythonInterpreter and displayed it, but I can't recover it to make other operations. Also, it would be great to send a full integer array rather than a single integer but I can't wrap my mind arround PyObjects and how to use them.\nIs there any useful tutorial that covers arrays? I've been searching for a while but I just find integer and float related tutorials.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":298,"Q_Id":48453620,"Users Score":1,"Answer":"If you want a simple solution then I suggest that you write and read the integers to a file. Perhaps not the most elegant way but it would only take a couple of minutes to implement.","Q_Score":0,"Tags":"java,python,arrays,jython","A_Id":48453704,"CreationDate":"2018-01-25T23:32:00.000","Title":"How can I send a data array back and forth between java and python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a java program and I need it to get some data calculated by a python script. \nI've already got java to send an integer to python via jython's PythonInterpreter and displayed it, but I can't recover it to make other operations. Also, it would be great to send a full integer array rather than a single integer but I can't wrap my mind arround PyObjects and how to use them.\nIs there any useful tutorial that covers arrays? I've been searching for a while but I just find integer and float related tutorials.","AnswerCount":3,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":298,"Q_Id":48453620,"Users Score":0,"Answer":"If the solution of writing\/reading the numbers to a file somehow is not sufficient, you can try the following:\nInstead of using Jython, you can use Pyro4 (and the Pyrolite client library for your java code) to call a running Python program from your java code.\nThis allows you to run your python code in a 'normal' python 3.6 interpreter for instance, rather than being limited to what version Jython is stuck on.\nYou'll have to launch the Python interpreter in a separate process though (but this could very well even be on a different machine)","Q_Score":0,"Tags":"java,python,arrays,jython","A_Id":48453799,"CreationDate":"2018-01-25T23:32:00.000","Title":"How can I send a data array back and forth between java and python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have a java program and I need it to get some data calculated by a python script. \nI've already got java to send an integer to python via jython's PythonInterpreter and displayed it, but I can't recover it to make other operations. Also, it would be great to send a full integer array rather than a single integer but I can't wrap my mind arround PyObjects and how to use them.\nIs there any useful tutorial that covers arrays? I've been searching for a while but I just find integer and float related tutorials.","AnswerCount":3,"Available Count":3,"Score":0.0665680765,"is_accepted":false,"ViewCount":298,"Q_Id":48453620,"Users Score":1,"Answer":"I've worked on similar project. Here's brief outline of what Java and Python was doing respectively.\nJava\nWe used Java as a main server for receiving requests from clients and sending back responses after some data manipulation. \nPython\nPython was in charge of data manipulation or calculation. Data was sent from Java via socket network. We first defined the data we needed in string format, then cncerted them into bytes in order to have them semt via socket network. \nSince there were limitations, though, using socket network, I changed it to Rest Api using Python Flask. In that way we could easily communicate with, not only but in this case mainly, Java with key-value json format. In this way, I was able to recieve any data type that could be passed through Api including array object you mentioned.","Q_Score":0,"Tags":"java,python,arrays,jython","A_Id":48454007,"CreationDate":"2018-01-25T23:32:00.000","Title":"How can I send a data array back and forth between java and python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a chat program with Python. I would like to use nohup because users always can access server when I am logout. \nI could run nohup very well. It was great.But I am a admin and I can write messages,and can see online users as using python. after I worked nohup, and logout, when I login I can't access the python progress. I want to foreground it again. \nYeah, I can see it in background with ps -aux . I see its PID,STAT but I don't know how to access it. I should access it.jobs doesn't see it. fg don't work. or I can't do. How can I do?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":48466626,"Users Score":0,"Answer":"If you nohup a process, when you log out the parent of the process switches to being init (1) and you can't get control of it again.\nThe best approach is to have the program open a socket and then use that for ipc. You probably want to split your code in to 2 pieces - a daemon that runs in the background and keeps a socket open, and a client which connects to the socket to control the daemon.","Q_Score":1,"Tags":"python,linux,server,nohup,foreground","A_Id":48466757,"CreationDate":"2018-01-26T17:34:00.000","Title":"Access a progress that work background with nohup (LINUX) -get foreground","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've made a desktop app using Python 3 and PyQt 5 and it works except for the playback of the MP4 video files (compiled by pyrcc5). They are visible and play on the video widget but there is a green line down the right side. I tried to put a green frame (using a Style Sheet) around the QVideoWidget but with no success.\nDoes anyone have any advice on how to resolve this issue?\nThanks","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":273,"Q_Id":48478792,"Users Score":1,"Answer":"Okay, so I couldn't find anything on \"MP4 and green line\" so I looked at how to modify the PyQt5 interface as a way of hiding the issue.\nThe option I chose was QGroupBox and changing the padding in the stylesheet to -9 (in my particular case - you may find another value works better but it depends on the UI).\nI did attempt to use QFrame, as my other option, but this didn't personally work for me.","Q_Score":0,"Tags":"python-3.x,video,pyqt5","A_Id":49198231,"CreationDate":"2018-01-27T17:57:00.000","Title":"Python 3, PyQt 5 - MP4 as resource file issue","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm creating a Python 3 spider that scrapes Tor hidden services for useful data. I'm storing this data in a PostgreSQL database using the psycopg2 library. Currently, the spider script and the database are hosted on the same network, so they have no trouble communicating. However, I plan to migrate the database to a remote server on a VPS so that I can have a team of users running the spider script from a number of remote locations, all contributing to the same database. For example, I could be running the script at my house, my friend could run it from his VPS, and my professor could run the script from a few different systems in the lab at the university, and all of these individual systems could synchronize with the PostgreSQL server runnning on my remote VPS.\nThis would be easy enough if I simply opened the database VPS to accept connections from anywhere, making the database public. However, I do not want to do this, for security reasons. I know I could tunnel the connection through SSH, but that would require giving each person a username and password that would grant them access to the server itself. I don't wish to do this. I'd prefer simply giving them access to the database without granting access to a shell account.\nI'd prefer to limit connections to the local system 127.0.0.1 and create a Tor hidden service .onion address for the database, so that my remote spider clients can connect to the database .onion through Tor.\nThe problem is, I don't know how to connect to a remote database through a proxy using psycopg2. I can connect to remote databases, but I don't see any option for connecting through a proxy.\nDoes anyone know how this might be done?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":367,"Q_Id":48480183,"Users Score":0,"Answer":"This would be easy enough if I simply opened the database VPS to accept connections from anywhere\n\nHere lies your issue. Just simply lock down your VPS using fail2ban and ufw. Create a ufw role to only allow connection to your Postgres port from the IP address you want to give access from to that VPS ip address. \nThis way, you don't open your Postgres port to anyone (from *) but only to a specific other server or servers that you control. This is how you do it. Don't run an onion service to connect Postgres content because that will only complicate things and slow down the reads to your Postgres database that I am assuming an API will be consuming eventually to get to the \"useful data\" you will be scraping.\nI hope that at least points you in the right direction. Your question was pretty general, so I am keeping my answer along the same vein.","Q_Score":0,"Tags":"python,python-3.x,postgresql,psycopg2,tor","A_Id":48602297,"CreationDate":"2018-01-27T20:24:00.000","Title":"Connect to remote PostgreSQL server over Tor? [python] [Tor]","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have downloaded Anaconda on my computer however Anaconda is installed for all users on my mac therefore when I try and access python2.7 by typing in the path: \/anaconda3\/envs\/py27\/bin:\/anaconda3\/bin:\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/sbin:\/sbin\nEven if I open from terminal the path above is not in the current directory since:\nmachintoshHD\/anaconda3\/....\nmachintoshHD\/Users\/adam\/desktop....\nhow can i redirect the configure script feature in the atom package script so that i can run python 2?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":423,"Q_Id":48481203,"Users Score":0,"Answer":"Only way I can change Atom python is to run it from a directory that has a different default python version. if I type python from a terminal window, whichever version of python that opens is the version Atom uses. I use virtual environments so I can run python 2.7.13 or python 3.6. If I want Atom to run python 3, I activate my python 3 environment and then run atom.\nThere may be a way to do this from within Atom but I haven't found it yet.","Q_Score":0,"Tags":"python,atom-editor","A_Id":48512683,"CreationDate":"2018-01-27T22:28:00.000","Title":"Atom script configure script run python 2.7","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am encoding Chinese characters using gb18030 in python. I want to access part of the encoded string. For example, the string for \u674e is: '\\xc0\\xee'. I want to extract 'c0' and 'ee' out of this. However, python is not treating '\\xc0\\xee' as a 8 character string, but as a 2 character string. How I do turn it into a 8 character string so that I could access the individual roman letters in it?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":16,"Q_Id":48481801,"Users Score":1,"Answer":"Found the solution. repr() will do.","Q_Score":1,"Tags":"python,encoding","A_Id":48481828,"CreationDate":"2018-01-27T23:59:00.000","Title":"how to access part of a encoded (gb18020) string in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The question on my assignment is as follows:\n\nWrite a function that takes, as an argument, a string, identified by the variable aString. If the string only contains digits 0 and 1, return the string formed by concatenating the argument with the string \"is a binary string.\" Otherwise, return a string indicating the length of the argument, as specified in the examples that follow. Name this function AmIBinary(aString). \n\nI am having trouble figuring out how to form a loop which searches through a string and determines whether or not the string is a binary string. I understand how to get the length of a string, I just don't understand how to figure out if it is a binary string.","AnswerCount":4,"Available Count":1,"Score":-0.049958375,"is_accepted":false,"ViewCount":2689,"Q_Id":48494296,"Users Score":-1,"Answer":"A binary string has been defined as a string that only contains \"0\" or \"1\". So, how about checking each 'character' in the string, and if it's not a \"0\" or \"1\" you will know that the string is not a binary string.","Q_Score":0,"Tags":"python,loops,binary","A_Id":48494319,"CreationDate":"2018-01-29T04:13:00.000","Title":"Python Binary String Loop","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"hello I'm using PyWinRM to poll a remote windows server.\n\ns = winrm.Session('10.10.10.10', auth=('administrator', 'password'))\n\nAs there is no s.close() function available, I am worried about leaking file descriptors. \nI've checked by using lsof -p <myprocess> | wc -l and my fd count is stable\nbut my google searches show that ansible had fd leaks previously; ansible relies on pywinrm to manage remote window hosts as well\nkindly advice, thanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":987,"Q_Id":48501645,"Users Score":0,"Answer":"Actually, I had a quick look at the code of wirm (as of 20201117)\nand the \"Session\" is not an actual session in the traditional sense, but only an object holding the creds to authenticate.\nEach time run_cmd or run_ps is invoked, a session in opened on the target and closed on completion of the task. So there's nothing to close, really.","Q_Score":3,"Tags":"windows,python-3.x,powershell,winrm,wsman","A_Id":64877092,"CreationDate":"2018-01-29T12:47:00.000","Title":"how do you close a Pywinrm session?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a way to implement a partially undirect graph. This is,  graphs where edges can be directed (or not)  and with different type of arrow (>, *, #, etc.).\nMy problem is that when I try to use undirect grpah from Networkx and stored arrow type as an attribute, I don't find an efficient way to tell networkx if that attribute (type arrorw) is from a to b or from b to a.\nDoes anyone know how to handle this?","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":215,"Q_Id":48503540,"Users Score":0,"Answer":"I guess you can use a directed graph and store the direction as an attribute if you don't need to represent that directed graph.","Q_Score":0,"Tags":"python,graph,networkx","A_Id":48504499,"CreationDate":"2018-01-29T14:27:00.000","Title":"Partially undirect graphs in Networkx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm looking for a way to implement a partially undirect graph. This is,  graphs where edges can be directed (or not)  and with different type of arrow (>, *, #, etc.).\nMy problem is that when I try to use undirect grpah from Networkx and stored arrow type as an attribute, I don't find an efficient way to tell networkx if that attribute (type arrorw) is from a to b or from b to a.\nDoes anyone know how to handle this?","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":215,"Q_Id":48503540,"Users Score":0,"Answer":"After search it in a lot of different sources, the only way to do a partial undirect graph I've found it is this is through adjacent matrices. \nNetworkx has a good tools to move between graph and adjacent matrix (in pandas and numpy array format). \nThe disadvantage is if you need networkx functions you have to program it yourself or convert the adjacent matrix to networkx format and then return it back to your previous adjacent matrix.","Q_Score":0,"Tags":"python,graph,networkx","A_Id":48583218,"CreationDate":"2018-01-29T14:27:00.000","Title":"Partially undirect graphs in Networkx","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am executing a Python-Tensorflow script on Amazon Sagemaker.  I need to checkpoint my model to the S3 instance I am using, but I can't find out how to do this without using the Sagemake Tensorflow version.\nHow does one checkpoint to an S3 instance without using the Sagemaker TF version?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":895,"Q_Id":48525733,"Users Score":0,"Answer":"Create an object in S3 and enable versioning to the bucket. Everytime you change the model and save it to S3, it will be automatically versioned and stored in the bucket. \nHope it helps.","Q_Score":0,"Tags":"python,tensorflow,amazon-s3,amazon-sagemaker","A_Id":48531968,"CreationDate":"2018-01-30T16:03:00.000","Title":"TensorFlow Checkpoints to S3","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"The title says it all i want to be able to use the packages that are installed with anaconda with idle so are there any ways of making this work?\nWhen i try to import packages with idle that i installed using anaconda it says package not found.\nI need some help please and thank you in advance.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3178,"Q_Id":48528477,"Users Score":0,"Answer":"The IDLE that comes with python 3.5.2 can only be run by python 3.5.2.  Code you submit to python 3.5.2 through that IDLE can normally only access packages installed for 3.5.2, plus your own code.  I believe Anaconda 3.6.3 comes with Python 3.6.3 and the 3.6.3 standard library, including the 3.6.3 version of idlelib.\nIn order for your code to use the packages installed with anaconda, you must run your code with the anaconda binary.  To run your code from IDLE with the anaconda binary, you must run IDLE with that binary instead of some other binary (like the 3.5.2 binary.\nWhen running Python 3.6.3 interactively, you can start IDLE 3.6.3 at a >>> prompt with import idlelib.idle.  If you can start python 3.6.3 in a terminal (Command Prompt on Windows), then adding the arguments -m idlelib will start IDLE.\nOn Windows, I have no idea whether or not Anaconda adds 'Edit with IDLE 3.6.3' to the right-click context menu for .py and .pyw files, the way the python.org installer does.  On any system, you should be able to create a file or icon that will start 3.6.3 with IDLE, but details depend heavily on OS and version.","Q_Score":1,"Tags":"python,anaconda,packages,python-idle","A_Id":48535641,"CreationDate":"2018-01-30T18:46:00.000","Title":"how can i get IDLE (Python) to use packages installed by anaconda (windows 7 32bit)?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a multiclass classification problem with an unbalanced dataset of images(different class). I tried imblearn library, but it is not working on the image dataset.\nI have a dataset of images belonging to 3 class namely A,B,C. A has 1000 data, B has 300 and C has 100. I want to oversample class B and C, so that I can avoid data imbalance. Please let me know how to oversample the image dataset using python.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2828,"Q_Id":48532069,"Users Score":1,"Answer":"Thanks for the clarification.  In general, you don't oversample with Python.  Rather, you pre-process your data base, duplicating the short-handed classes.  In the case you cite, you might duplicate everything in class B, and make 5 copies of everything in class C.  This gives you a new balance of 1000:600:500, likely more palatable to your training routines.  Instead of the original 1400 images, you now shuffle 2100.\nDoes that solve your problem?","Q_Score":3,"Tags":"python-3.x,machine-learning,deep-learning,computer-vision,imblearn","A_Id":48550016,"CreationDate":"2018-01-30T23:20:00.000","Title":"How to oversample image dataset using Python?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working with the 3.6.4 source release of Python. I have no trouble building it with Visual Studio as a dynamic library (\/MDd) I can link the Python .dll to my own code and verify its operation.\nBut when I build it (and my code) with (\/MTd) it soon runs off the rails when I try to open a file with a Python program. A Debug assertion fails in read.cpp  (\"Expression: _osfile(fh) & FOPEN\").  What I believe is happening is the Python .dll is linking with improper system libraries.  What I can't figure out is how to get it to link with the correct ones (static libraries).","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1688,"Q_Id":48545255,"Users Score":3,"Answer":"This is what I needed to do to build and use python statically embedded in another application.\nTo build the static python library  (e.g., python36_d.lib, python36.lib)\n\nConvert ALL projects in the python solution (pcbuild.sln) to static.  This is about 40 projects, so it may take awhile.  This includes setting library products to be build as 'static lib', and setting all \/MD and \/MDd build options to \/MT and \/MTd.\nFor at least the pythoncore project alter the Preprocess define to be Py_NO_ENABLE_SHARED.  This tells the project it will be looking for calls from static libraries.\nBy hook or crook, find yourself a pyconfig.h file and put it in the Include area of your Python build.  It is unclear how this file is built from Windows tools, but one seems to be able to snag one from other sources and it works ok.  One could probably grab the pyconfig.h from the Pre-compiled version of the code you are building.  [By the way, the Python I built was 3.6.5 and was built with Windows 2015, update 3.]\n\nHopefully, this should enable you to build both python36.lib and python36_d.lib.  Now you need to make changes to your application project(s) to enable it to link with the python library.  You need to do this:\n\nAdd the Python Include directory to the General->Include Directories list.\nAdd the Python Library directories to the General->Library Directories lists.\nThis will be ..\\PCBuild\\win32   and ..\\PCBuild\\amd64.\nAdd the define Py_NO_ENABLE_SHARED to the C\/C++ -> Preprocessor area.\nFor Linker->input add (for releases) python36.lib;shlwapi.lib;version.lib and (for debugs) python36_d.lib;shlwapi.lib;version.lib.\n\nAnd that should be it.  It should run and work.  But one more thing. In order to be able to function, the executable needs to access the Lib directory of the python build.  So a copy of that needs to be moved to wherever the executable (containing the embedded python) resides.  Or you can add the Lib area to the execution PATH for windows.  That should work as well.\nThat's about all of it.","Q_Score":2,"Tags":"python,visual-studio-2015,static-libraries,libcmtd","A_Id":49984841,"CreationDate":"2018-01-31T15:03:00.000","Title":"I cannot build python.dll as a static library (\/MTd) using Visual Studio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm currently using Qpython and Sl4A to run python scripts on my Droid device.\nDoes anybody know of a way to use something like PyAutoGUI on mobile to automate tapping sequences (which would be mouse clicks on a desktop or laptop)?\nI feel like it wouldn't be too hard, but I'm not quite sure how to get the coordinates for positions on the mobile device.","AnswerCount":2,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":8687,"Q_Id":48558151,"Users Score":7,"Answer":"Something like PyAutoGui for Android is AutoInput. It's a part of the main app Tasker. If you've heard about Tasker, then you know what I'm taking about. \nIf not, them Tasker is an app built to automate your Android Device. If you need specific taps and scrolls, then you can install the plug-in Auto Input for Tasker. It's precisely allows you to tap a point in your screen. \nOr, if you have a rooted device, then you can directly run shell commands from Tasker without the need of any Plug-in.\nNow, you can get the precise location of your x,y coordinate easily. \nGo to settings, About Phone, and Tap on\nBuild Number until it says, \"You've unlocked developer options.\"\nNow, in the settings app, you will have a new developer options. Click on that, then scroll down till you find \"Show Pointer Location\" and turn that on. Now wherever you tap and hold the screen, the top part of your screen will give you the x,y coordinate of that spot.\nI hope this helps. Please comment if you have any queries.","Q_Score":3,"Tags":"user-interface,automation,sl4a,pyautogui,qpython3","A_Id":48928935,"CreationDate":"2018-02-01T08:18:00.000","Title":"Way to use something like PyAutoGUI on Mobile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm currently using Qpython and Sl4A to run python scripts on my Droid device.\nDoes anybody know of a way to use something like PyAutoGUI on mobile to automate tapping sequences (which would be mouse clicks on a desktop or laptop)?\nI feel like it wouldn't be too hard, but I'm not quite sure how to get the coordinates for positions on the mobile device.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":8687,"Q_Id":48558151,"Users Score":2,"Answer":"Unfortunately no. PyAutoGUI only runs on Windows, macOS, and Linux","Q_Score":3,"Tags":"user-interface,automation,sl4a,pyautogui,qpython3","A_Id":66658332,"CreationDate":"2018-02-01T08:18:00.000","Title":"Way to use something like PyAutoGUI on Mobile?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Tried googling up, but could not find how to implement Sklearn metrics like cohen kappa, roc, f1score in keras as a metric for imbalanced data.\nHow to implement Sklearn Metric in Keras as Metric?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2808,"Q_Id":48567012,"Users Score":5,"Answer":"Metrics in Keras and in Sklearn mean different things.  \nIn Keras metrics are almost same as loss. They get called during training at the end of each batch and each epoch for reporting and logging purposes. Example use is having the loss 'mse' but you still would like to see 'mae'. In this case you can add 'mae' as a metrics to the model.  \nIn Sklearn metric functions are applied on predictions as per the definition \"The metrics module implements functions assessing prediction error for specific purposes\". While there's an overlap, the statistical functions of Sklearn doesn't fit to the definition of metrics in Keras. Sklearn metrics can return float, array, 2D array with both dimensions greater than 1. There is no such object in Keras by the predict method.   \nAnswer to your question:\nIt depends where you want to trigger:\n\nEnd of each batch or each epoch\nYou can write a custom callback that is fired at the end of batch.  \nAfter prediction\nThis seems to be easier. Let Keras predict on the entire dataset, capture the result and then feed the y_true and y_pred arrays to the respective Sklearn metric.","Q_Score":2,"Tags":"python,machine-learning,scikit-learn,keras","A_Id":48573176,"CreationDate":"2018-02-01T16:05:00.000","Title":"How to implement Sklearn Metric in Keras as Metric?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"MongoDB uses self-signed certificate. I want to setup service on EVE to work with it. I searched documentation and SO but found only information how to use self-signed cert to access EVE itself. What should I do to connect to MongoDB from EVE with self-signed certificate?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":228,"Q_Id":48572258,"Users Score":0,"Answer":"Resolved by passing required parameters (ssl, ssl_ca_certs, etc) to MongoClient via MONGO_OPTIONS setting.","Q_Score":0,"Tags":"python,mongodb,ssl,eve","A_Id":48727022,"CreationDate":"2018-02-01T21:46:00.000","Title":"Connect to MongoDB with self-signed certificate from EVE","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"So I'm not sure how to word this correctly but I have a .sh file that I use to turn on my python app and it runs fine when I run this command .\/start_dev.sh in my terminal. But I am having trouble trying to have it run in pycharm because my app is run in Ubuntu and I don't know how to direct the interpreter path to my Ubuntu virtualenv bash command. Is this even possible?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1297,"Q_Id":48573443,"Users Score":-1,"Answer":"You should be able to go to Run->Edit Configurations and then add configurations, including an Interpreter path where you can set the path to your virtualenv bash executable","Q_Score":0,"Tags":"python,bash,pycharm,sh","A_Id":48573531,"CreationDate":"2018-02-01T23:30:00.000","Title":"Unable to get pycharm to run my .sh file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using jupyter notebook for coding, hence my file format is ipynb. I would like to turn this piece of code into an executable file .exe for later uses.\nSo far I have managed to get the exe file by going to anaconda prompt, executed the following command\n---> pyinstaller --name \u2018name of the exe\u2019 python_code.ipynb\nThis gives me two folders build and dist, both contains .exe file.\nHowever, none of them worked. I would like to know why and how to fix it.\nby double click on the exe, it shows a black cmd pop up and then it went away.\nnothing else happens.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":7843,"Q_Id":48573989,"Users Score":1,"Answer":"Try exporting your .ipynb file to a normal .py file and running pyinstaller on the .py file instead.\nYou can export as .py by going to File > Download As > Python (.py) in the Jupyter Notebook interface","Q_Score":0,"Tags":"python,python-2.7,jupyter-notebook,exe","A_Id":48626144,"CreationDate":"2018-02-02T00:32:00.000","Title":"ipynb python file to executable exe file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have seen a few variants of my question but not quite exactly what I am looking for, hence opening a new question. \nI have a Flask\/Gunicorn app that for each request inserts some data in a store and, consequently, kicks off an indexing job. The indexing is 2-4 times longer than the main data write and I would like to do that asynchronously to reduce the response latency. \nThe overall request lifespan is 100-150ms for a large request body.\nI have thought about a few ways to do this, that is as resource-efficient as possible:\n\nUse Celery. This seems the most obvious way to do it, but I don't want to introduce a large library and most of all, a dependency on Redis or other system packages. \nUse subprocess.Popen. This may be a good route but my bottleneck is I\/O, so threads could be more efficient.\nUsing threads? I am not sure how and if that can be done. All I know is how to launch multiple processes concurrently with ThreadPoolExecutor, but I only need to spawn one additional task, and return immediately without waiting for the results. \nasyncio? This too I am not sure how to apply to my situation. asyncio has always a blocking call. \nLaunching data write and indexing concurrently: not doable. I have to wait for a response from the data write to launch indexing. \n\nAny suggestions are welcome!\nThanks.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":500,"Q_Id":48584712,"Users Score":0,"Answer":"Celery will be your best bet - it's exactly what it's for.\nIf you have a need to introduce dependencies, it's not a bad thing to have dependencies.  Just as long as you don't have unneeded dependencies.\nDepending on your architecture, though, more advanced and locked-in solutions might be available.  You could, if you're using AWS, launch an AWS Lambda function by firing off an AWS SNS notification, and have that handle what it needs to do.  The sky is the limit.","Q_Score":0,"Tags":"python,multithreading,asynchronous","A_Id":48588092,"CreationDate":"2018-02-02T14:23:00.000","Title":"Flask: spawning a single async sub-task within a request","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have some experience with SQL and python.\nIn one of my SQL stored procedures I want to use some python code block and some functions of python numpy.\nWhat is the best way to do it.SQL server version is 2014.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":662,"Q_Id":48595683,"Users Score":0,"Answer":"First install the MySQL connector for python from the MySQL website and then import the mysql.connector module and initialize a variable to a mysql.connector.connect object and use cursors to modify and query data. Look at the documentation for more help.\nIf you don't have problem with no networking capabilities and less concurrency use sqlite, it is better than MySQL in these cases.","Q_Score":1,"Tags":"python,sql,sql-server","A_Id":48687137,"CreationDate":"2018-02-03T09:01:00.000","Title":"how to use python inside SQL server 2014","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have the bulk of my web application in React (front-end) and Node (server), and am trying to use Python for certain computations. My intent is to send data from my Node application to a Python web service in JSON format, do the calculations in my Python web service, and send the data back to my Node application. \nFlask looks like a good option, but I do not intend to have any front-end usage for my Python web service. Would appreciate any thoughts on how to do this.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":48600583,"Users Score":0,"Answer":"In terms of thoughts:\n1) You can build a REST interface to your python code using Flask. Make REST calls from your nodejs. \n2) You have to decide if your client will wait synchronously for the result. If it takes a relatively long time you can use a web hook as a callback for the result.","Q_Score":0,"Tags":"python,node.js,rest,api,web-services","A_Id":48600936,"CreationDate":"2018-02-03T18:27:00.000","Title":"Python web service with React\/Node Application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I\u2019ve started working a lot with Flask SocketIO in Python with Eventlet and are looking for a solution to handle concurrent requests\/threading. I\u2019ve seen that it is possible with gevent, but how can I do it if I use eventlet?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2111,"Q_Id":48611425,"Users Score":5,"Answer":"The eventlet web server supports concurrency through greenlets, same as gevent. No need for you to do anything, concurrency is always enabled.","Q_Score":2,"Tags":"python,socket.io,webserver,flask-socketio,eventlet","A_Id":48616158,"CreationDate":"2018-02-04T18:10:00.000","Title":"Handle concurrent requests or threading Flask SocketIO with eventlet","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed python 3.6.4 on my MAC OS and have Eclipse neon 2.0 running. I have added pydev plugin to work on python projects. I need to import pandas library, but there is no such option as windows -> preferences -> libraries \nCan someone help me with any other way to install python libraries in neon 2.\nAnd also how to run python cmds in terminal window in pydev?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1889,"Q_Id":48649927,"Users Score":0,"Answer":"I faced same problem when working with eclipse pydev project.\nhere are steps that helped me resolve the issue\n\nIn eclipse open the workspace, click on Windows->Preferences->pydev-> interpreters-> python interpreter -> Click on Manage with PIP\n\nIn Command to execute , enter install pandas.\n\n\nProblem solved","Q_Score":1,"Tags":"eclipse,python-3.x,pandas,pydev","A_Id":71702890,"CreationDate":"2018-02-06T18:49:00.000","Title":"installing pandas in pydev eclipse neon 2","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a project that does a giveaway every Monday. There are three prizes, the basic prize, the \"lucky\" prize, and the jackpot prize. The basic prize is given out 70% of the time, the lucky prize gets given out 25% of the time and the jackpot prize gets rewarded the final 5% of the time.\nThere are multiple people that get prizes each Monday. Each person in the giveaway gets at least the basic prize.\nRight now I'm just generating a random number and then assigning the prizes to each participant on my local computer. This works, but the participants have to trust that I'm not rigging the giveaway.\nI want to improve this giveaway by using the blockchain to be the random number generator. The problem is that I don't know how to do this technically.\nHere is my start to figuring out how to do it: When the giveaway is created, a block height is defined as being the source of randomness. Each participant has a userID. When the specific block number is found, the block hash is catenated to the userID and then hashed. The resulting hash is then \"ranged\" across the odds defined in the giveaway.\nThe part I can't figure out is how to do the \"ranging\". I think it might involve the modulo operator, but I'm not sure. If the resulting hash falls into the 5% range, then that user gets the jackpot prize. If the hash falls into the 70% range, then he gets the basic prize, etc.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":27,"Q_Id":48656958,"Users Score":0,"Answer":"I figured this out, the solution is below:\nint(hashlib.sha256(block_header + userID).hexdigest(), 16) \/ float(2**256)\nYou conver the hash into an integer, then divide that integer by 2**256. This gives you a decimal from 0 to 1 that can be compared to a random.random() to get the prize.","Q_Score":0,"Tags":"python,probability,blockchain","A_Id":48712283,"CreationDate":"2018-02-07T06:00:00.000","Title":"Assigning giveaways based on cryptocurrency block header","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering if there was an effective way to recursively search for a given filename using ftplib. I know that I could use FTP.cwd() and FTP.retrlines('LIST), but I think that it would be rather repetitive and inefficient. Is there something that lets me find files on an FTP server in Python, such as how os can do os.path.walk()?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":198,"Q_Id":48675264,"Users Score":0,"Answer":"No. Using FTP.retrlines('LIST') is the only solution with FTP protocol.\n\nIf you need a faster approach, you would have to use another interface. Like shell, some web API, etc.","Q_Score":0,"Tags":"python,ftp,ftplib","A_Id":48761226,"CreationDate":"2018-02-07T23:51:00.000","Title":"Finding a file in an FTP server using ftplib","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Django server which responds to a call like this 127.0.0.1:8000\/ao\/. Before adding further applications to the server, I would like to experiment the load balancing which are supported by Django.\nCan anyone please explain how to implement load balancing. I spent sometime in understanding the architecture but was unable to find a solution.\nI work on Windows OS and I am new to servers.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2681,"Q_Id":48677643,"Users Score":0,"Answer":"Load balancing is not anything to do with Django. It is something you implement at a much higher layer, via servers that sit in front of the machines that Django is running on.\nHowever, if you've just started creating your site, it is much too early to start thinking about this.","Q_Score":2,"Tags":"python,django","A_Id":48680841,"CreationDate":"2018-02-08T04:38:00.000","Title":"load balancing in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm learning about basic back-end and server mechanics and how to connect it with the front end of an app. More specifically, I want to create a React Native app and connect it to a database using Python(simply because Python is easy to write and fast). From my research I've determined I'll need to make an API that communicates via HTTP with the server, then use the API with React Native. I'm still confused as to how the API works and how I can integrate it into my React Native front-end, or any front-end that's not Python-based for that matter.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":6331,"Q_Id":48698110,"Users Score":2,"Answer":"You have to create a flask proxy, generate JSON endpoints then use fetch or axios to display this data in your react native app. You also have to be more specific next time.","Q_Score":2,"Tags":"python,rest,http,react-native,server","A_Id":48718794,"CreationDate":"2018-02-09T03:04:00.000","Title":"How to create a Python API and use it with React Native?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have fitted a curve using lmfit but the trendline\/curve is short. Please how do I extend the trendline\/curve in both directions because the trendline\/curve is hanging. Sample codes are warmly welcome my senior programmers. Thanks.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":213,"Q_Id":48699357,"Users Score":0,"Answer":"More detail about what you are actually doing would be helpful.  That is, vague questions can really only get vague answers.\nAssuming you are doing curve fitting with lmfit's Model class, then once you have your Model and a set of Parameters (say, after a fit has refined them to best match some data), then you can use those to evaluate the Model (with the model.eval() method) for any values of the independent variable (typically called x).  That allows on a finer grid or extending past the range of the data you actually used in the fit.\nOf course, predicting past the end of the data range assumes that the model is valid outside the range of the data.  It's hard to know when that assumption is correct, especially when you have no data ;). \"It's tough to make predictions, especially about the future.\"","Q_Score":0,"Tags":"python,lmfit","A_Id":48707014,"CreationDate":"2018-02-09T05:38:00.000","Title":"Extending a trendline in a lmfit plot","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to chatbot application and RASA as well, can anyone please help me to understand how should i use RASA NLU with RASA CORE.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1115,"Q_Id":48700554,"Users Score":14,"Answer":"RASA NLU is the natural language understanding piece, which is used for taking examples of natural language and translating them into \"intents.\"  For example: \"yes\", \"yeah\", \"yep\" and \"for sure\" would all be translated into the \"yes\" intent.\nRASA CORE on the other hand is the engine that processes the flow of conversation after the intent of the user has already been determined.  RASA CORE can use other natural language translators as well, so while it pairs very nicely with RASA NLU they don't both have to be used together.\nAs an example if you were using both:\n\nUser says \"hey there\" to RASA core bot\nRasa core bot calls RASA NLU to understand what \"hey there\" means\nRASA NLU translates \"hey there\" into intent = hello (with 85% confidence)\nRasa core receives \"hello\" intent\nRasa core runs through it's training examples to guess what it should do when it receives the \"hello\" intent\nRasa core predicts (with 92% confidence) that it should respond with the \"utter_hello\" template\nRasa core responds to user \"Hi, I'm your friendly Rasa bot\"\n\nHope this helps.","Q_Score":2,"Tags":"python,rasa-nlu,rasa-core","A_Id":49782296,"CreationDate":"2018-02-09T07:15:00.000","Title":"How to use RASA NLU with RASA CORE","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Basically, no counter is allowed. No iterables (arrays, dictionaries, etc.) allowed either to store insertion. There are two linked lists: one storing odd insertions and even insertions. Each node has the priority, and the object. Is there any pattern you can find? Or is this impossible? \nEdit: sorry for not mentioning, we need to extract the first one that was inserted.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":240,"Q_Id":48702629,"Users Score":0,"Answer":"Since all items are arranged in a prioritised manner, just extract them in the way they come out...as it is a queue. Or you could apply more conditions on how you would like to arrange the items with same priorities among themselves.","Q_Score":0,"Tags":"python,queue,priority-queue","A_Id":48710792,"CreationDate":"2018-02-09T09:28:00.000","Title":"Priority Queue: If two objects have same priority, how do I determine which to extract?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a dataset of peak load for a year. Its a simple two column dataset with the date and load(kWh). \nI want to train it on the first 9 months and then let it predict the next three months .  I can't get my head around how to implement SVR. I understand my 'y' would be predicted value in kWh but what about my X values?\nCan anyone help?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2181,"Q_Id":48715867,"Users Score":0,"Answer":"given multi-variable regression, y = \nRegression is a multi-dimensional separation which can be hard to visualize in ones head since it is not 3D.\nThe better question might be, which  are consequential to the output value `y'.\nSince you have the code to the loadavg in the kernel source, you can use the input parameters.","Q_Score":0,"Tags":"python,scikit-learn,time-series,svm","A_Id":48715905,"CreationDate":"2018-02-10T00:08:00.000","Title":"support vector regression time series forecasting - python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am currently developing my first more complex Web Application and want to ask for directions from more experienced Developers.\nFirst I want to explain the most important requirements.\nI want to develop a Web App (no mobile apps or desktop apps) and want to use as much django as possible. Because I am comfortable with the ecosystem right now and don't have that much time to learn something new that is too complex. I am inexperienced in the Javascript World, but I am able to do a little bit of jQuery.\nThe idea is to have one database and many different Frontends that are branded differently and have different users and administrators. So my current approach is to develop a Backend with Django and use Django Rest Framework to give the specific data to the Frontends via REST. Because I have not that much time to learn a Frontend-Framework I wanted to use another Django instance to use as a Frontend, as I really like the Django Template language. This would mean one Django instance one Frontend, where there would be mainly TemplateViews. The Frontends will be served on different subdomains, while the backend exposes the API Endpoints on the top level domain.\nIt is not necessary to have a Single Page App. A Normal Website with mainly the normal request\/response-cycle is fine.\nDo you think this is a possible approach to do things? I am currently thinking about how to use the data in the frontend sites in the best way. As I am familiar with the Django template language I thought about writing a middleware that asks about the user details in every request cycle from the backend. The thought is to use a request.user as normally as possible while getting the data from the backend.\nOr is ist better to ask these details via jQuery and Ajax Calls and don't use the django template language very much?\nMaybe there is also a way to make different Frontends for the same database without using REST?\nOr what would you think about using a database with each frontend, which changes everytime I make a change in the main database in the backend? Although I don't really like this approach due to the possibility of differences in data if I make a mistake.\nHopefully this is not to confusing for you. If there are questions I will answer them happily. Maybe I am also totally on the wrong track. Please don't hesitate to point that out, too.\nI thank you very much in advance for your guiding and wish you a nice day.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":548,"Q_Id":48730694,"Users Score":0,"Answer":"as per my experience and knowledge, you are almost going towards correct direction.\nmy recommendation is for making backend rest api Django and django rest framework is the best option however for consuming those api you can look for the angular or react both works very well in terms of consuming API.","Q_Score":0,"Tags":"python,jquery,django,django-rest-framework","A_Id":48730768,"CreationDate":"2018-02-11T10:49:00.000","Title":"Design Decision Django Rest Framework - Django as Frontend","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"So basically I have created an A.I assistant and was wondering if anyone had suggestions on how to make visuals that react with the sound?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":41,"Q_Id":48738338,"Users Score":0,"Answer":"You can just measure the loudness of the voice command spoken in mDb. You can then process these numbers to change the UI. \nLike , higher the loudness makes the bar longer. Let me know which speech to text engine are you using so that I can provide further help.","Q_Score":0,"Tags":"python,artificial-intelligence","A_Id":51712117,"CreationDate":"2018-02-12T01:22:00.000","Title":"Making my Artificial Intelligence visuals that react with sound change","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to calculate something like this: a^b mod c, where all three numbers are large.\nThings I've tried:\n\nPython's pow() function is taking hours and has yet to produce a result. (if someone could tell me how it's implemented that would be very helpful!)\nA right-to-left binary method that I implemented, with O(log e) time, would take about 30~40 hours (don't wanna wait that long).\nVarious recursion methods are producing segmentation faults (after I changed the recursion limits)\n\nAny optimizations I could make?","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1213,"Q_Id":48738650,"Users Score":2,"Answer":"It sounds like you are trying to evaluate pow(a, b) % c. You should be using the 3-argument form, pow(a, b, c), which takes advantage of the fact that a * b mod c == a mod c * b mod c, which means you can reduce subproducts as they are computed while computing a ^ b, rather than having to do all the multiplications first.","Q_Score":1,"Tags":"python,algorithm,pow,modular-arithmetic,cryptanalysis","A_Id":48738710,"CreationDate":"2018-02-12T02:10:00.000","Title":"How to implement modular exponentiation?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have developed few modules in python and I want to import them to rstudio RMarkdown file. However, I am not sure how I can do it.\nFor example, I can't do from code.extract_feat.cluster_blast import fill_df_by_blast as fill_df as I am used to do it in pycharm.\nAny hint?\nThanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":378,"Q_Id":48753128,"Users Score":0,"Answer":"First I had to make a setup.py file for my project.\nactivate the virtual environment corresponding to my project source activate, then run python setup.py develop \nNow, I can import my own python library from R as I installed it in my environment.","Q_Score":0,"Tags":"python,rstudio,r-markdown,python-import","A_Id":49017753,"CreationDate":"2018-02-12T18:28:00.000","Title":"Import my python module to rstudio","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"tensorflow works using python in a virtualenv I created, but tensorflow doesn't work in the same virtualenv with ipython. This is the error I get:\nException: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.\nI have tried installing ipython within the virtual environment. This is the message I get:\nRequirement already satisfied: ipython in \/opt\/local\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\nIf I try to uninstall ipython within the virtual environment. I get this message:\nNot uninstalling ipython at \/opt\/local\/Library\/Frameworks\/Python.framework\/Versions\/2.7\/lib\/python2.7\/site-packages\nAny ideas on how to get this to work? I don't know how to force the install of ipython to be inside the virtual environment. I've tried deleting the virtual environment and making a new one from scratch, but I get the same error.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":213,"Q_Id":48757970,"Users Score":0,"Answer":"I think I figured out the problem. pip was pointing to \/Library\/Frameworks\/Python.framework\/Versions\/3.4\/bin\/pip\nMy ipython was pointing to \/opt\/local\/bin\/ipython\nI re-installed tensorflow within my virtual environment by calling \/opt\/local\/bin\/pip-2.7 install --upgrade tensorflow\nNow I can use tensorflow within ipython.","Q_Score":0,"Tags":"tensorflow,ipython","A_Id":48777636,"CreationDate":"2018-02-13T00:58:00.000","Title":"Running tensorflow in ipython","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I read the document about the function and I understood how NMS works. What I'm not clear is scores argument to this function. I think NMS first look at bottom right coordinate and sort according to it and calculate IoU then discard some boxes which have IoU greater than the threshold that you set. In this theory scores argument does absolutely nothing and the document doesn't tell much about scores arguments. I want to know how the argument affect the function. Thank you.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":537,"Q_Id":48759535,"Users Score":0,"Answer":"The scores argument decides the sorting order. The method tf.image.non_max_suppression goes through (greedily, so all input entries are covered) input bounding boxes in order decided by this scores argument, selects only those bounding boxes from them which are not overlapping (more than iou_threshold) with boxes already selected.\n\nNMS first look at bottom right coordinate and sort according to it and calculate IoU...\n\nThis is not correct, can you site any resource which made you think this way?","Q_Score":1,"Tags":"python,tensorflow,computer-vision","A_Id":48761331,"CreationDate":"2018-02-13T04:35:00.000","Title":"What does tensorflow nonmaximum suppression function's argument \"score\" do to this function?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Can Google Cloud Functions handle python with packages like sklearn, pandas, etc? If so, can someone point me in the direction of resources on how to do so.\nI've been searching a while and it seems like this is impossible, all I've found are resources to deploy the base python language to google cloud.","AnswerCount":4,"Available Count":1,"Score":0.049958375,"is_accepted":false,"ViewCount":12755,"Q_Id":48772583,"Users Score":1,"Answer":"You can use AWS lambda as well if you want to work around and still use Python as your main language. Some modules\/packages will need to be imported via zip file with AWS Lambda but it has a broader range of usable languages than GCF","Q_Score":10,"Tags":"python,google-cloud-platform,google-cloud-functions","A_Id":50966006,"CreationDate":"2018-02-13T17:39:00.000","Title":"Python in Google Cloud Functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"And if so, how would one add a tooltip to a checkbox object? It appears that the control inherits from wxWindow which has tooltips, so can it be added to a wxCheckBox?\nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":438,"Q_Id":48779478,"Users Score":0,"Answer":"Try this:\nself.YourCheckboxObject.SetToolTip(wx.ToolTip(\"Paste your tooltip text here\"))","Q_Score":0,"Tags":"python-3.x,wxwidgets","A_Id":48779658,"CreationDate":"2018-02-14T04:04:00.000","Title":"Python - can you add a tooltip on a wx.CheckBox object?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got this error in in Python3.6 ModuleNotFoundError: No module named 'oauth2client.client',i tried pip3.6 install --upgrade google-api-python-client,But I don't know how to fix\nPlease tell me how to fix,\nThanks","AnswerCount":1,"Available Count":1,"Score":0.761594156,"is_accepted":false,"ViewCount":7084,"Q_Id":48780634,"Users Score":5,"Answer":"Use below code, this worked for me:\npip3 install --upgrade oauth2client","Q_Score":2,"Tags":"python-3.x","A_Id":52187177,"CreationDate":"2018-02-14T06:04:00.000","Title":"ModuleNotFoundError: No module named 'oauth2client.client'","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am using webots for my project at university. I want my robot to do a specific action for a certain amount of time, but I cannot find a way to do it without blocking the code and the sensors and consequently the whole simulation. I tried both the commands robot.step() and time.sleep() but they both blocck the code and by the time the action is finished the robot does not do anything else even when it is normally supposed to. Specificaly I want the robot to go backwards for a certain ammount of time if the sesnsors at the front and the sides read below a specific distance. Any ideas on how to do it without blocking the code? because if for example I use one of the above commands and there is an object behind the robot the beck sensor will not work because it is blocked and the robot will hit on the object. Thank you.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":529,"Q_Id":48806894,"Users Score":0,"Answer":"I tried robot.step() and it works thank you. I use small increments of time so that the code is not continuously blocing and there is time for my sensors to do the reading.","Q_Score":0,"Tags":"python","A_Id":49682887,"CreationDate":"2018-02-15T12:06:00.000","Title":"Webots programming with Python - blocking code","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have accidentally removed several parts of python and now am trying to start again... The installer says that 57 files are still on my PC and I cannot find them. Does anyone know how to get a copy of the uninstaller? As it should find the remaining files.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":3423,"Q_Id":48832344,"Users Score":0,"Answer":"This depends on the OS and how Python was installed.\nFor windows, look under %USERPROFILE%\\AppData\\Local\\Programs\\Python - or just run the installer again, it should have an option to fix or remove the current install.","Q_Score":0,"Tags":"python,uninstallation","A_Id":50609180,"CreationDate":"2018-02-16T17:51:00.000","Title":"How to remove the remains of python 3.7?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I developed a flask app running on virtualenv, how do I deploy it into production? I have a Red Hat Enterprise Linux Server release 5.6, cannot use docker.\nThe server has cgi and wsgi setup. Python 2.7.\nI know using the pip install -r requirements.txt, but how do I get the virtualenv to persist on production once my session is terminated?\nI am using source x..\/venv\/bin\/activate\nexport FLASK_APP=myapp.py\nflask run --host=0.0.0.0 --port=8082\nand this will allow me to access myurl:8082\nHow do I present a way for other users once I terminate session?","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2680,"Q_Id":48876711,"Users Score":0,"Answer":"You may want to look at using a  requirements.txt file in Python.  Using $ pip freeze > requirements.txt can build that file with what pip has installed in your virtualenv.","Q_Score":0,"Tags":"python,flask,virtualenv","A_Id":48877242,"CreationDate":"2018-02-20T01:44:00.000","Title":"How to deploy flask virtualenv into production","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I use GoogleColab to test data stuctures like chain-hashmap,probe-hashmap,AVL-tree,red-black-tree,splay-tree(written in Python),and I store very large dataset(key-value pairs) with these data stuctures to test some operation running time,its scale just like a small wikipedia,so run these python script will use very much memory(RAM),GoogleColab offers a approximately 12G RAM but not enough for me,these python scripts will use about 20-30G RAM,so when I run python program in GoogleColab,will often raise an exception that\"your program run over 12G upper bound\",and often restarts.On the other hand,I have some PythonScript to do some recursion algorithm,as is seen to all,recursion algorithm use CPU vety mush(as well as RAM),when I run these algorithm with 20000+ recursion,GoogleColab often fails to run and restart,I knew that GoogleColab uses two cores of Intel-XEON CPU,but how do I apply more cores of CPU from Google?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":13142,"Q_Id":48879495,"Users Score":2,"Answer":"There is no way to request more CPU\/RAM from Google Colaboratory at this point, sorry.","Q_Score":1,"Tags":"python,recursion,data-structures,intel,google-colaboratory","A_Id":48922199,"CreationDate":"2018-02-20T06:56:00.000","Title":"How to apply GoogleColab stronger CPU and more RAM?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to build a multilabel-classifier to predict the probabilities of some input data being either 0 or 1. I'm using a neural network and Tensorflow + Keras (maybe a CNN later).\nThe problem is the following: \nThe data is highly skewed. There are a lot more negative examples than positive maybe 90:10. So my neural network nearly always outputs very low probabilities for positive examples. Using binary numbers it would predict 0 in most of the cases.\nThe performance is > 95% for nearly all classes, but this is due to the fact that it nearly always predicts zero...\nTherefore the number of false negatives is very high.\nSome suggestions how to fix this?\nHere are the ideas I considered so far:\n\nPunishing false negatives more with a customized loss function (my first attempt failed). Similar to class weighting positive examples inside a class more than negative ones. This is similar to class weights but within a class.\nHow would you implement this in Keras? \nOversampling positive examples by cloning them and then overfitting the neural network such that positive and negative examples are balanced.\n\nThanks in advance!","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":1027,"Q_Id":48880273,"Users Score":2,"Answer":"You're on the right track.\nUsually, you would either balance your data set before training, i.e. reducing the over-represented class or generate artificial (augmented) data for the under-represented class to boost its occurrence.\n\nReduce over-represented class\nThis one is simpler, you would just randomly pick as many samples as there are in the under-represented class, discard the rest and train with the new subset. The disadvantage of course is that you're losing some learning potential, depending on how complex (how many features) your task has.\nAugment data\nDepending on the kind of data you're working with, you can \"augment\" data. That just means that you take existing samples from your data and slightly modify them and use them as additional samples. This works very well with image data, sound data. You could flip\/rotate, scale, add-noise, in-\/decrease brightness, scale, crop etc.\nThe important thing here is that you stay within bounds of what could happen in the real world. If for example you want to recognize a \"70mph speed limit\" sign, well, flipping it doesn't make sense, you will never encounter an actual flipped 70mph sign. If you want to recognize a flower, flipping or rotating it is permissible. Same for sound, changing volume \/ frequency slighty won't matter much. But reversing the audio track changes its \"meaning\" and you won't have to recognize backwards spoken words in the real world.\n\nNow if you have to augment tabular data like sales data, metadata, etc... that's much trickier as you have to be careful not to implicitly feed your own assumptions into the model.","Q_Score":8,"Tags":"python,tensorflow,neural-network,keras,multilabel-classification","A_Id":49065611,"CreationDate":"2018-02-20T07:57:00.000","Title":"Classification: skewed data within a class","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I know how to build an encoder using dynamic rnn in Tensorflow, but my question is how can we use it for decoder?\nBecause in decoder at each time step we should feed the prediction of previous time step.\nThanks in advance!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":342,"Q_Id":48899234,"Users Score":1,"Answer":"If for example, you are using Tensorflow's attention_decoder method, pass a parameter \"loop_function\" to your decoder. Google search for \"extract_argmax_and_embed\", that is your loop function.","Q_Score":1,"Tags":"python,tensorflow,recurrent-neural-network,sequence-to-sequence,encoder-decoder","A_Id":48899306,"CreationDate":"2018-02-21T06:13:00.000","Title":"How to build a decoder using dynamic rnn in Tensorflow?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try install pcap package in pycharam tools but did not install and show blow error :\n\nCollecting pcap Could not find a version that satisfies the\n  requirement pcap (from versions: ) No matching distribution found for\n  pcap\n\nhow can i  fix installing package?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":717,"Q_Id":48904701,"Users Score":1,"Answer":"On the command line, go to the location where you had installed your setup and use this command to install the missing package:\npip install pcap","Q_Score":0,"Tags":"python,python-2.7,pycharm","A_Id":59266936,"CreationDate":"2018-02-21T11:26:00.000","Title":"Can't install pcap in pycharm?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I am trying to create a simple scene in 3d (in python) where you have a cube in front of you, and you are able to rotate it around with the mouse. \nI understand that you should rotate the complete scene to mimic camera movement but i can't figure out how you should do this.\nJust to clarify I want the camera (or scene) to move a bit like blender (the program).\nThanks in advance","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":553,"Q_Id":48911436,"Users Score":0,"Answer":"Ok I think i have found what you should do\njust for the people that have trouble with this like I did this is the way you should do it:\nto rotate around a cube with the camera in opengl:\nyour x mouse value has to be added to the z rotator of your scene\nand the cosinus of your y mouse value has to be added to the x rotator\nand then the sinus of your y mouse value has to be subtracted of your y rotator\nthat should do it","Q_Score":0,"Tags":"python,pygame,blender,pyopengl","A_Id":48952393,"CreationDate":"2018-02-21T16:58:00.000","Title":"PyOpenGL how to rotate a scene with the mouse","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I got something like this:\n\ncur.execute(\"INSERT INTO name VALUES(HERE_IS_VARIABLE,'string',int,'string')\")\n\nStuff with %s (like in python 2.*) not working.\nI got errors, which tells me that im trying to use \"column name\" in place where i put my variable.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":376,"Q_Id":48914074,"Users Score":0,"Answer":"You can try using f-Strings and separating out the statement from the execution:\nstatement = f\"INSERT INTO name VALUES({VARIABLE_NAME},'string',int,'string')\" \ncur.execute(statement)\nYou might also want to try with '' around {VARIABLE_NAME}: '{VARIABLE_NAME}'\nIn f-strings, the expressions in {} get evaluated and their values inserted into the string. \nBy separating out the statement you can print it and see if the string is what you were expecting. \nNote, the f-string can be used within the cur.execute function, however I find it more readable to separate out. \nIn python3.6+ this is a better way of formatting strings then with %s. \nIf this does not solve the problem, more information will help debug:\nwhat is the name table's schema?\nwhat variable \/ value are you trying to insert?\nwhat is the exact error you are given?","Q_Score":0,"Tags":"postgresql,python-3.6","A_Id":53563271,"CreationDate":"2018-02-21T19:35:00.000","Title":"Python3.6 + Postgresql how to put VARIABLES to SQL query?","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have created a login page for my application and set the session out for 3 minutes and it is working fine, but the problem is when session out happened the user is still able to do many activities on the current page i.e the logout page do not show until unless user do a page refresh or redirect to the other page.\nSo, how is it possible to do the logout once the session out and user do any of the activity on the current page?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":231,"Q_Id":48921619,"Users Score":0,"Answer":"You can run a javascript setTimeout in the background which will check if user is logged in and after three minutes the browser window will refresh. \nOR (better)\nYou can run this timer server-side and when the client would try to change something, firstly look at the timer or the value where is the time until when is the client logged in and then based on the time perform the action or not. So After you three minutes interval user would be able to see the content but when he would try to change something the backend would reject the request and would require him to log in again.\nIt is much better solution because when it comes to the authentication and similar things, it's better everytime to do them server-side rather than in client browser so that it could not be exploited.\nBUT\nBoth solutions can be applied simultaneously (so that client's browser would reload the window and redirect client to the login page and server would reject the request so that data would not be modified in any way).","Q_Score":0,"Tags":"python,django,django-sessions","A_Id":48923389,"CreationDate":"2018-02-22T07:16:00.000","Title":"Django: detect the mouse click if session out","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a conda environment at the default location for windows, which is C:\\ProgramData\\Anaconda2\\envs\\myenv. Also, as recommended, the conda scripts and executables are not in the %PATH% environment variable.\nI opened a project in pycharm and pointed the python interpreter to \nC:\\ProgramData\\Anaconda2\\envs\\myenv\\python.exe\nand pycharm seems to work well with the environment in the python console, in the run environment, and in debug mode. \nHowever, when opening the terminal the environment is not activated (I made sure that the checkbox for activating the environment is checked). To be clear - when I do the same thing with a virtualenv the terminal does activate the environment without a problem.\nHere are a few things I tried and did not work:\n\nCopied the activate script from the anaconda folder to the environment folder\nCopied the activate script from the anaconda folder to the Scripts folder under the environment\nCopied an activate script from the virtualenv (an identical one for which the environment is activated)\nAdded the anaconda folders to the path\n\nNone of these worked. \nI can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","AnswerCount":13,"Available Count":3,"Score":0.0153834017,"is_accepted":false,"ViewCount":19602,"Q_Id":48924787,"Users Score":1,"Answer":"Found a solution. Problem is we have been creating conda environments from within Pycharm while starting a new project.\nThis is created at the location \/Users\/<username>\/.conda\/envs\/<env-name>.\ne.g. \/Users\/taponidhi\/.conda\/envs\/py38.\nInstead create environments from terminal using conda create --name py38.\nThis will create the environment at \/opt\/anaconda3\/envs\/.\nAfter this, when starting a new project, select this environment from existing environments. Everything works fine.","Q_Score":30,"Tags":"python,windows,pycharm,anaconda","A_Id":64291969,"CreationDate":"2018-02-22T10:14:00.000","Title":"PyCharm terminal doesn't activate conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a conda environment at the default location for windows, which is C:\\ProgramData\\Anaconda2\\envs\\myenv. Also, as recommended, the conda scripts and executables are not in the %PATH% environment variable.\nI opened a project in pycharm and pointed the python interpreter to \nC:\\ProgramData\\Anaconda2\\envs\\myenv\\python.exe\nand pycharm seems to work well with the environment in the python console, in the run environment, and in debug mode. \nHowever, when opening the terminal the environment is not activated (I made sure that the checkbox for activating the environment is checked). To be clear - when I do the same thing with a virtualenv the terminal does activate the environment without a problem.\nHere are a few things I tried and did not work:\n\nCopied the activate script from the anaconda folder to the environment folder\nCopied the activate script from the anaconda folder to the Scripts folder under the environment\nCopied an activate script from the virtualenv (an identical one for which the environment is activated)\nAdded the anaconda folders to the path\n\nNone of these worked. \nI can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","AnswerCount":13,"Available Count":3,"Score":0.0614608973,"is_accepted":false,"ViewCount":19602,"Q_Id":48924787,"Users Score":4,"Answer":"Solution for Windows\nGo to Settings -> Tools -> Terminal\nset Shell path to:\n\nFor powershell (I recommend this):\npowershell.exe -ExecutionPolicy ByPass -NoExit -Command \"& 'C:\\tools\\miniconda3\\shell\\condabin\\conda-hook.ps1'\nFor cmd.exe:\ncmd.exe \"C:\\tools\\miniconda3\\Scripts\\activate.bat\"\n\nPyCharm will change environment automatically in the terminal\nPS: I'm using my paths to miniconda, so replace it with yours","Q_Score":30,"Tags":"python,windows,pycharm,anaconda","A_Id":69735670,"CreationDate":"2018-02-22T10:14:00.000","Title":"PyCharm terminal doesn't activate conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I have a conda environment at the default location for windows, which is C:\\ProgramData\\Anaconda2\\envs\\myenv. Also, as recommended, the conda scripts and executables are not in the %PATH% environment variable.\nI opened a project in pycharm and pointed the python interpreter to \nC:\\ProgramData\\Anaconda2\\envs\\myenv\\python.exe\nand pycharm seems to work well with the environment in the python console, in the run environment, and in debug mode. \nHowever, when opening the terminal the environment is not activated (I made sure that the checkbox for activating the environment is checked). To be clear - when I do the same thing with a virtualenv the terminal does activate the environment without a problem.\nHere are a few things I tried and did not work:\n\nCopied the activate script from the anaconda folder to the environment folder\nCopied the activate script from the anaconda folder to the Scripts folder under the environment\nCopied an activate script from the virtualenv (an identical one for which the environment is activated)\nAdded the anaconda folders to the path\n\nNone of these worked. \nI can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","AnswerCount":13,"Available Count":3,"Score":0.0,"is_accepted":false,"ViewCount":19602,"Q_Id":48924787,"Users Score":0,"Answer":"I am using OSX and zshell has become the default shell in 2020.\nI faced the same problem: my conda environment was not working inside pycharm's terminal.\nFile -> Settings -> Tools -> Terminal. the default shell path was configured as \/bin\/zsh --login\nI tested on a separate OSX terminal that \/bin\/zsh --login somehow messes up $PATH variable. conda activate keep adding conda env path at the end instead of at the beginning. So the default python (2.7) always took precedence because of messed up PATH string. This issue had nothing to do with pycharm (just how zshell behaved with --login),\nI removed --login part from the script path; just \/bin\/zsh works (I had to restart pycharm  after this change!)","Q_Score":30,"Tags":"python,windows,pycharm,anaconda","A_Id":64384425,"CreationDate":"2018-02-22T10:14:00.000","Title":"PyCharm terminal doesn't activate conda environment","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"Imagine you are given set S of n points in 3 dimensions. Distance between any 2 points is simple Euclidean distance. You want to chose subset Q of k points from this set such that they are farthest from each other. In other words there is no other subset Q\u2019 of k points exists such that min of all pair wise distances in Q is less than that in Q\u2019.\nIf n is approximately 16 million and k is about 300, how do we efficiently do this?\nMy guess is that this NP-hard so may be we just want to focus on approximation. One idea I can think of is using Multidimensional scaling to sort these points in a line and then use version of binary search to get points that are furthest apart on this line.","AnswerCount":4,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":3420,"Q_Id":48925086,"Users Score":0,"Answer":"Find the maximum extent of all points. Split into 7x7x7 voxels. For all points in a voxel find the point closest to its centre. Return these 7x7x7 points. Some voxels may contain no points, hopefully not too many.","Q_Score":13,"Tags":"python,algorithm,computational-geometry,dimensionality-reduction,multi-dimensional-scaling","A_Id":60953415,"CreationDate":"2018-02-22T10:29:00.000","Title":"Choosing subset of farthest points in given set of points","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Imagine you are given set S of n points in 3 dimensions. Distance between any 2 points is simple Euclidean distance. You want to chose subset Q of k points from this set such that they are farthest from each other. In other words there is no other subset Q\u2019 of k points exists such that min of all pair wise distances in Q is less than that in Q\u2019.\nIf n is approximately 16 million and k is about 300, how do we efficiently do this?\nMy guess is that this NP-hard so may be we just want to focus on approximation. One idea I can think of is using Multidimensional scaling to sort these points in a line and then use version of binary search to get points that are furthest apart on this line.","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":3420,"Q_Id":48925086,"Users Score":1,"Answer":"If you can afford to do ~ k*n distance calculations then you could\n\nFind the center of the distribution of points.\nSelect the point furthest from the center. (and remove it from the set of un-selected points).\nFind the point furthest from all the currently selected points and select it.\nRepeat 3. until you end with k points.","Q_Score":13,"Tags":"python,algorithm,computational-geometry,dimensionality-reduction,multi-dimensional-scaling","A_Id":48925457,"CreationDate":"2018-02-22T10:29:00.000","Title":"Choosing subset of farthest points in given set of points","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is there a way in python by which I can get contribution of each feature in probability predicted  by my gradient boosting classification model for each test observation. Can anyone give actual mathematics behind probability prediction in gradient boosting classification model and how can it be implemented in Python.","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":1153,"Q_Id":48936542,"Users Score":1,"Answer":"Use the feature_importances_ property. Very easy.","Q_Score":1,"Tags":"python,scikit-learn","A_Id":48936596,"CreationDate":"2018-02-22T20:22:00.000","Title":"gradient boosting- features contribution","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am basically running my personal project,but i'm stuck in some point.I am trying to make a login request to hulu.com using Python's request module but the problem is hulu needs a cookie and a CSRF token.When I inspected the request with HTTP Debugger it shows me the action URL and some request headers.But the cookie and the CSRF token was already there.But how to can do that with request module? I mean getting the cookies and the CSRF token before the post request? Any ideas?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":882,"Q_Id":48940807,"Users Score":0,"Answer":"First create a session then use GET and use session.cookies.get_dict() it will return a dict and it should have appropriate values you need","Q_Score":0,"Tags":"python,post,cookies,request","A_Id":48940818,"CreationDate":"2018-02-23T03:48:00.000","Title":"How to get cookies before making request in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Hi i am new to GRPC and i want to send one message from server to client first. I understood how to implement client sending a message and getting response from server. But i wanna try how server could initiate a message to connected clients. How could i do that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":325,"Q_Id":48969107,"Users Score":0,"Answer":"Short answer: you can't\ngRPC is a request-response framework based on HTTP2. Just as you cannot make a website that initiates a connection to a browser, you cannot make a gRPC service initiating a connection to the client. How would the service even know who to talk to?\nA solution could be to open a gRPC server on the client. This way both the client and the server can accept connections from one another.","Q_Score":0,"Tags":"python,grpc","A_Id":49018750,"CreationDate":"2018-02-25T00:38:00.000","Title":"How to let server send the message first in GRPC using python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A simple program about storing rivers and their respective locations in a dictionary. I was wondering how I would go about looping through a dictionary key and looking if the dictionary key (or value) contains a certain word, if the word is present in the key, remove it.\nEX: rivers_dict = {'mississippi river': 'mississippi'}\nHow would I remove the word 'river' in the dictionary key 'mississippi river'? I know i can assign something such as: rivers_dict['mississippi'] = rivers_dict.pop('mississippi river'). Is there a way to do this in a more modular manner? Thanks in advance.","AnswerCount":4,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":899,"Q_Id":48970752,"Users Score":0,"Answer":"Use the enumerate function that will count all the words like looping it as\nfor index, value in enumerate(dic):","Q_Score":2,"Tags":"python,dictionary","A_Id":48970792,"CreationDate":"2018-02-25T06:10:00.000","Title":"If a dictionary key contains a certain word, how would I remove it?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've created a script for my school project that works with data. I'm quite new to working remotely on a server, so this might seem like a dumb question, but how do I execute my script named \n\nstats.py\n\nso that it continues executing even after I log off PuTTy? The script file is located on the server. It has to work with a lot of data, so I don't want to just try something and then few days later find out that it has exited right after I logged off.\nThank you for any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1277,"Q_Id":48977688,"Users Score":1,"Answer":"There are many ways you can run a python program after you disconnect from an SSH session.\n1) Tmux or Screen\nTmux is a \"terminal multiplexer\" which enables a number of terminals to be accessed by a single one.\nYou start by sshing as you do, run it by typing tmux and executing it. Once you are done you can disconnect from putty and when you login back you can relog to the tmux session you left\nScreen also does that you just type screen instead of tmux\n2) nohup\n\"nohup is a POSIX command to ignore the HUP signal. The HUP signal is, by convention, the way a terminal warns dependent processes of logout.\"\nYou can run it by typing nohup <pythonprogram> &","Q_Score":0,"Tags":"python,server,putty","A_Id":48977787,"CreationDate":"2018-02-25T19:43:00.000","Title":"How to run a python script on a remote server that it doesn't quit after I log off?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As I know, standard new user process registration (Django 2.x) is validate email field only for exists and equals for E-mail Schemas. But users may be write e-mail address like this: JOHN_DOE@MAIL.COM (via Caps Lock) and save it to DB.\n\nIt's would be dangerous, because other user can register account for these e-mail, but in lowercase: john_doe@mail.com or similar, but still that e-mail address!\n\nSo, question now is how to (smart) clean up e-mail address when user is registering?. My ideas:\n\nset email to lowercase before save to DB\ncheck if it exist\/unique in DB (in lowercase view, of course)\n\nI search for best practice for solve this question, btw.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":122,"Q_Id":48985145,"Users Score":0,"Answer":"I would change it to lowercase and then save it because it looks like the least number of operations to be done. Also it should make the shortest code.\nIf you'll decide to check if it's unique in lowercase in DB and then save it you may end up checking DB two times (one when first check, 2nd when saving) if you'll implement it in wrong way.","Q_Score":0,"Tags":"python,django,email,user-registration","A_Id":48985464,"CreationDate":"2018-02-26T09:27:00.000","Title":"Clean email field when new user is registering in Django?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to use Lyft Driver api like in the Mystro android app however iv searched everywhere and all I could find is lyft api.\nTo elaborate more on what I'm trying to achieve, I want api that will allow me to intergrate with the lyft driver app and not the lyft rider app, I want to be able to for example view nearby ride requests as a driver.\nThe Mystro android app has this feature, how is it done","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":249,"Q_Id":49011180,"Users Score":1,"Answer":"The Mystro app does not have any affiliation with either Uber or Lyft nor do they use their APIs to interact with a driver (as neither Uber or Lyft have a publicly accessible driver API like this).  They use an Android Accessibility \"feature\" that let's the phone look into and interact with other apps you have running.\nSo basically Mystro uses this accessibility feature (Google has since condemned the use of the accessibility feature like this) to interact with the Uber and Lyft app on the driver's behalf.","Q_Score":0,"Tags":"android,python,ios,node.js,lyft-api","A_Id":52992307,"CreationDate":"2018-02-27T14:36:00.000","Title":"How do I use Lyft driver API like Mystro android app?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to create a minimal webpage where concurrent users can upload a file and I can process the file (which is expected to take some hours) and email back to the user later on.\nSince I am hosting this on AWS, I was thinking of invoking some background process once I receive the file so that even if the user closes the browser window, the processing keeps taking place and I am able to send the results after few hours, all through some pre-written scripts.\nCan you please help me with the logistics of how should I do this?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":912,"Q_Id":49027447,"Users Score":1,"Answer":"Here's how it might look like (hosting-agnostic):\n\nA user uploads a file on the web server\nThe file is saved in a storage that can be accessed later by the background jobs\nSome metadata (location in the storage, user's email etc) about the file is saved in a DB\/message broker\nBackground jobs tracking the DB\/message broker pick up the metadata and start handling the file (this is why it needs to be accessible by it in p.2) and notify the user\n\nMore specifically, in case of python\/django + aws you might use the following stack:\n\nLets assume you're using python + django\nYou can save the uploaded files in a private AWS S3 bucket\nSome meta might be saved in the db or use celery + AWS SQS or AWS SQS directly or bring up something like rabbitmq or redis(+pubsub)\nHave python code handling the job - depends on what your opt for in p.3. The only requirement is that it can pull data from your S3 bucket. After the job is done notify the user via AWS SES\n\nThe simplest single-server setup that doesn't require any intermediate components:\n\nYour python script that simply saves the file in a folder and gives it a name like someuser@yahoo.com-f9619ff-8b86-d011-b42d-00cf4fc964ff\nCron job looking for any files in this folder that would handle found files and notify the user. Notice if you need multiple background jobs running in parallel you'll need to slightly complicate the scheme to avoid race conditions (i.e. rename the file being processed so that only a single job would handle it) \n\nIn a prod app you'll likely need something in between depending on your needs","Q_Score":2,"Tags":"python,bash,concurrency,background-process","A_Id":49088871,"CreationDate":"2018-02-28T10:35:00.000","Title":"Concurrent file upload\/download and running background processes","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've gone through the docs of Provider and Resource of Django OAuth Toolkit, but all I'm able to find is how to 'authenticate' a user, not how to register a user.\nI'm able to set up everything on my machine, but not sure how to register a user using username & password. I know I'm missing something very subtle. How do I exactly register a user and get an access token in return to talk to my resource servers.\nOR \nIs it like that I've to first register the user using normal Django mechanism and then get the token of the same?","AnswerCount":4,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":6515,"Q_Id":49031954,"Users Score":6,"Answer":"You have to create the user using normal Django mechanism (For example, you can add new users from admin or from django shell). However, to get access token, OAuth consumer should send a request to OAuth server where user will authorize it, once the server validates the authorization, it will return the access token.","Q_Score":11,"Tags":"python,django,django-rest-framework,django-registration,django-oauth","A_Id":49129766,"CreationDate":"2018-02-28T14:31:00.000","Title":"Django OAuth Toolkit - Register a user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I've gone through the docs of Provider and Resource of Django OAuth Toolkit, but all I'm able to find is how to 'authenticate' a user, not how to register a user.\nI'm able to set up everything on my machine, but not sure how to register a user using username & password. I know I'm missing something very subtle. How do I exactly register a user and get an access token in return to talk to my resource servers.\nOR \nIs it like that I've to first register the user using normal Django mechanism and then get the token of the same?","AnswerCount":4,"Available Count":2,"Score":0.049958375,"is_accepted":false,"ViewCount":6515,"Q_Id":49031954,"Users Score":1,"Answer":"I'm registering user with regular django mechanism combined with django-oauth-toolkit's application client details (client id and client secret key).\nI have separate UserRegisterApiView which is not restricted with token authentication but it checks for client id and client secret key while making post request to register a new user. In this way we are restricting register url access to only registered OAuth clients.\nHere is the registration workflow:\n\nUser registration request from React\/Angular\/View app with client_id and client_secret.\nDjango will check if client_id and client_secret are valid if not respond 401 unauthorized.\nIf valid and register user data is valid, register the user.\nOn successful response redirect user to login page.","Q_Score":11,"Tags":"python,django,django-rest-framework,django-registration,django-oauth","A_Id":59511833,"CreationDate":"2018-02-28T14:31:00.000","Title":"Django OAuth Toolkit - Register a user","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"At the moment i am working on an odoo project and i have a kanban view. My question is how do i put a kanban element to the bottom via xml or python. Is there an index for the elements or something like that?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":63,"Q_Id":49046224,"Users Score":0,"Answer":"I solved it myself. I just added _order = 'finished asc' to the class. finished is a record of type Boolean and tells me if the Task is finished or not.","Q_Score":0,"Tags":"python-2.7,odoo-8,odoo","A_Id":49046718,"CreationDate":"2018-03-01T09:10:00.000","Title":"Is there a way to put a kanban element to the bottom in odoo","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to install the mod_wsgi module in apache in my Ubuntu server but I need it to be specifically for version 2.7.13 in Python.For whatever reason every time I run sudo apt-get install  libapache2-mod-wsgi it installs the mod_wsgi module for Python 2.7.12.I'm doing all of this because I'm running into a weird python version issue.When I run one of my python Scripts in my server terminal it works perfectly with version 2.7.13.In Apache however the script doesn't work.I managed to figure out that my Apache is running version 2.7.12 and I think this is the issue.Still can't figure out how to change that apache python version yet though.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":623,"Q_Id":49074360,"Users Score":1,"Answer":"Eventually Figured it out.The problem was that I had 2 versions of Python 2.7 installed in my server(2.7.12 and 2.7.13) so the definitions of one were conflicting with the other.Solved it when I completely  removed Python 2.7.13 from the server.","Q_Score":0,"Tags":"python,ubuntu,server,mod-wsgi","A_Id":49112016,"CreationDate":"2018-03-02T17:30:00.000","Title":"How to install mod_wsgi to specific python version in Ubuntu?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This may be a basic question, but I'm still learning Kivy and I'm not sure how to do this.\nThe program that I'm writing with Python 2.7 and Kivy reads a folder full of images, and then will display them one at a time as the user clicks through. \nRight now, I'm calling a function that reads the next image on the click of a button. This means that I have a bit of lag between each image.\nI'd like to load all the images in the beginning, or at least some of them, so that there isn't a lag as I click through the images. \nI'm not sure if this is done on the Python side or the Kivy side, but I appreciate any help!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":485,"Q_Id":49083639,"Users Score":0,"Answer":"Loading all your images in memory will be a problem when you have a lot of images in the folder, but you could have a hidden image with the next image as source (it's not even needed to add the Image to the widget tree, you could just keep it in an attribute of your app), so everytime the user load the next image, it's displayed instantly, since it's cached already, and while the user is looking at this image, the second image widget, which stays invisible, would start loading the next image.\nOf course, if you want to load more than 1 image, you'll have to do something more clever, you could have a list of Image widgets in memory, and always replace the currently displayed source with the next in line for pre-fetching).","Q_Score":0,"Tags":"python,python-2.7,kivy","A_Id":49100661,"CreationDate":"2018-03-03T11:28:00.000","Title":"How can I pre-load or cache images with Python 2.7 and Kivy","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I bought the card reader ACR122U and try to read mifare 1k classic cards with nfcpy.\nSo my question is, how can i read or write on a mifare 1k classic card using nfcpy?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":526,"Q_Id":49095353,"Users Score":2,"Answer":"Nfcpy only supports the standardized NFC Forum Type 1, 2, 3, and 4 Tags. Mifare 1K Classic uses a proprietary communication format and requires reader hardware with NXP Crypto-1 support.","Q_Score":1,"Tags":"python,nfc","A_Id":49120363,"CreationDate":"2018-03-04T12:23:00.000","Title":"How to use nfcpy for MiFare 1k classic","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using form.py and the user is typing some Email-id, let us say I want to send an email to that particular email and write all that email into google sheet using gspread, I am able to do this in my views.py, but the problem is it's taking a lot of time to write which slow down the rendering process.\nIs there any other way I can use my logic after rendering the template.","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":67,"Q_Id":49099308,"Users Score":1,"Answer":"You should use some queuing mechanism like worker and consumer to avoid this problem.\nFor example Celery. \nSteps to do for sending email:\n1. Add email and info to the queue referred as task\n2. Consume the queue. (It runs in the different process may be parallel too)\nYou can also use Channels newly added in Django family of apps.\nThis will provide you an asynchronous way to handle email\/any other deferred task.","Q_Score":0,"Tags":"python,django,django-models,django-templates,django-views","A_Id":49099402,"CreationDate":"2018-03-04T19:10:00.000","Title":"how to call some logic in my views after rendering template in django","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have used Shiny for R and specifically the Shinydashboard package to build easily navigatable dashboards in the past year or so. I have recently started using the Python, pandas, etc ecosystem for doing data analysis. I now want to build a dashboard with a number of inputs and outputs. I can get the functionality up running using Dash, but defining the layout and look of the app is really time consuming compared to using the default layout from the shinydashboard's package in R.\nThe convenience that Shiny and Shinydashboard provides is:\n\nEasy layout of components because it is based on Bootstrap\nA quite nice looking layout where skinning is build in.\nA rich set of input components where the label\/title of the input is bundled together with the input.\n\nMy question is now this:\n\nAre there any extensions to Dash which provides the above functionality, or alternatively some good examples showing how to do the above?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":836,"Q_Id":49106413,"Users Score":2,"Answer":"I have similar experience. A lot said python is more readable, while I agree, however, I don't find it as on par with R or Shiny in their respective fields yet.","Q_Score":3,"Tags":"python,plotly-dash","A_Id":49108001,"CreationDate":"2018-03-05T08:42:00.000","Title":"Building a dashboard in Dash","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I wrote a dataframe in Python 2.7 but now I need to open it in Python 3.6, and vice versa (I want to compare two dataframes written in both versions).\nIf I open a Python2.7-generated HDF file using pandas in Python 3.6, this is the error produced:\n\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xde in position 1: ordinal not in range(128)\n\nIf I open a Python3.6-generated HDF file using pandas in Python 2.7, this is the error:\n\nValueError: unsupported pickle protocol: 4\n\nFor both cases I simply saved the file by df.to_hdf.\nDoes anybody have a clue how to go about this?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":348,"Q_Id":49108596,"Users Score":1,"Answer":"Not exactly a solution but more of a workaround.\nI simply read the files in their corresponding Python versions and saved them as a CSV file, which can then be read any version of Python.","Q_Score":1,"Tags":"python,python-3.x,python-2.7,pandas","A_Id":49135392,"CreationDate":"2018-03-05T10:43:00.000","Title":"How do I read\/convert an HDF file containing a pandas dataframe written in Python 2.7 in Python 3.6?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"Is it possible to set two different django projects on the same IP address\/server (Linode in this case)? For exmaple, django1_project running on www.example.com and django2_project on django2.example.com. This is preferable, but if this is not possible then how to make two djangos, i.e. one running on www.example.com\/django1 and the second on www.example.com\/django2? Do I need to adapt the settings.py, wsgi.py files or apache files (at \/etc\/apache2\/sites-available) or something else?\nThank you in advance for your help!","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":591,"Q_Id":49112945,"Users Score":0,"Answer":"I'm not familiar with Linode restrictions, but if you have control over your Apache files then you could certainly do it with name-based virtual hosting. Set up two VirtualHost containers with the same IP address and port (and this assumes that both www.example.com and django2.example.com resolve to that IP address) and then differentiate requests using the ServerName setting in the container. In Apache 2.4 name-based virtual hosting is automatic. In Apache 2.2 you need the NameVirtualHost directive.","Q_Score":0,"Tags":"python,django,apache,server,mod-wsgi","A_Id":49113295,"CreationDate":"2018-03-05T14:41:00.000","Title":"Two django project on the same ip address (server)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Is it possible to set two different django projects on the same IP address\/server (Linode in this case)? For exmaple, django1_project running on www.example.com and django2_project on django2.example.com. This is preferable, but if this is not possible then how to make two djangos, i.e. one running on www.example.com\/django1 and the second on www.example.com\/django2? Do I need to adapt the settings.py, wsgi.py files or apache files (at \/etc\/apache2\/sites-available) or something else?\nThank you in advance for your help!","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":591,"Q_Id":49112945,"Users Score":2,"Answer":"Yes that's possible to host several Python powered sites with Apache + mod_wsgi from one host \/ Apache instance. The only constraint : all apps \/ sites must be powered by the same Python version, though each app may have (or not) its own virtualenv (which is strongly recommended). It is also recommended to use mod_wsgi daemon mode and have each Django site run in separate daemon process group.","Q_Score":0,"Tags":"python,django,apache,server,mod-wsgi","A_Id":49113277,"CreationDate":"2018-03-05T14:41:00.000","Title":"Two django project on the same ip address (server)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how concurrency works in python 3.6 with asyncio. My understanding is that when the interpreter executing await statement, it will leave it there until the awaiting process is complete and then move on to execute the other coroutine task. But what I see here in the code below is not like that. The program runs synchronously, executing task one by one.\nWhat is wrong with my understanding and my impletementation code?\n\n    import asyncio\n    import time\n\n    async def myWorker(lock, i):\n        print(\"Attempting to attain lock {}\".format(i))\n        # acquire lock\n        with await lock:\n            # run critical section of code\n            print(\"Currently Locked\")\n\n            time.sleep(10)\n\n        # our worker releases lock at this point\n        print(\"Unlocked Critical Section\")\n\n    async def main():\n        # instantiate our lock\n        lock = asyncio.Lock()\n        # await the execution of 2 myWorker coroutines \n        # each with our same lock instance passed in \n        # await asyncio.wait([myWorker(lock), myWorker(lock)])\n        tasks = []\n\n        for i in range(0, 100):\n            tasks.append(asyncio.ensure_future(myWorker(lock, i)))\n\n        await asyncio.wait(tasks)\n\n\n    # Start up a simple loop and run our main function\n    # until it is complete\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n    print(\"All Tasks Completed\")\n    loop.close()","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":448,"Q_Id":49119793,"Users Score":0,"Answer":"asyncio use a loop to run everything, await would yield back the control to the loop so it can arrange the next coroutine to run.","Q_Score":0,"Tags":"python,python-3.x,python-asyncio,coroutine","A_Id":49226915,"CreationDate":"2018-03-05T21:29:00.000","Title":"Understanding Python Concurrency with Asyncio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I was wondering how concurrency works in python 3.6 with asyncio. My understanding is that when the interpreter executing await statement, it will leave it there until the awaiting process is complete and then move on to execute the other coroutine task. But what I see here in the code below is not like that. The program runs synchronously, executing task one by one.\nWhat is wrong with my understanding and my impletementation code?\n\n    import asyncio\n    import time\n\n    async def myWorker(lock, i):\n        print(\"Attempting to attain lock {}\".format(i))\n        # acquire lock\n        with await lock:\n            # run critical section of code\n            print(\"Currently Locked\")\n\n            time.sleep(10)\n\n        # our worker releases lock at this point\n        print(\"Unlocked Critical Section\")\n\n    async def main():\n        # instantiate our lock\n        lock = asyncio.Lock()\n        # await the execution of 2 myWorker coroutines \n        # each with our same lock instance passed in \n        # await asyncio.wait([myWorker(lock), myWorker(lock)])\n        tasks = []\n\n        for i in range(0, 100):\n            tasks.append(asyncio.ensure_future(myWorker(lock, i)))\n\n        await asyncio.wait(tasks)\n\n\n    # Start up a simple loop and run our main function\n    # until it is complete\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(main())\n    print(\"All Tasks Completed\")\n    loop.close()","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":448,"Q_Id":49119793,"Users Score":2,"Answer":"Invoking a blocking call such as time.sleep in an asyncio coroutine blocks the whole event loop, defeating the purpose of using asyncio.\nChange time.sleep(10) to await asyncio.sleep(10), and the code will behave like you expect.","Q_Score":0,"Tags":"python,python-3.x,python-asyncio,coroutine","A_Id":49119860,"CreationDate":"2018-03-05T21:29:00.000","Title":"Understanding Python Concurrency with Asyncio","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to share my local WebSocket on the internet but ngrok only support HTTP but my ws.py address is ws:\/\/localhost:8000\/\nit is good working on localhost buy is not know how to use this on the internet?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":2555,"Q_Id":49129451,"Users Score":1,"Answer":"You can use ngrok http 8000 to access it. It will work. Although, ws is altogether a different protocol than http but ngrok handles it internally.","Q_Score":2,"Tags":"python,websocket,localhost,ngrok,serve","A_Id":52701751,"CreationDate":"2018-03-06T11:12:00.000","Title":"how to use ws(websocket) via ngrok","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"file2.py is just variables \nI want file1.py to import those variables (import file2) increment them, truncate file2.py and rewrite it with the newly incremented variables \n\nI know how to increment them I'm just not sure how I would rewrite a python file with another python file while that file is also being imported... \nThanks!","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":777,"Q_Id":49158613,"Users Score":0,"Answer":"There's no conflict with import & write.  Once the import is done, you have all the needed information held locally.  You can overwrite the file without disturbing the values you hold in your run-time space.","Q_Score":0,"Tags":"python","A_Id":49158696,"CreationDate":"2018-03-07T18:09:00.000","Title":"How do I rewrite python file with a python script","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to set up a cronjob that executes a python (3.6) script every day at a given time that connects to an oracle 12g database with a 32 bit client (utilizing the cx_Oracle and sqlalchemy libs). The code itself was developed on a win64 bit machine.\nHowever, when trying to deploy the script onto an Ubuntu 16.04 server, I run into a dilemma when it comes to 32 vs 64 bit architectures.\n\nThe server is based on a 64 bit architecture\nThe oracle db is accessible via a 32 bit client\nmy current python version on ubuntu is based on 64 bit and I spent about an hour of how to get a 32 bit version running on a 64 bit linux machine without much success. \n\nThe error I receive at this moment when trying to run the python script refers to the absence of an oracle client (DPI-1047). However, I already encountered a similar problem in windows when it was necessary to switch the python version to the 32 bit version and to install a 32 bit oracle client.\nIs this also necessary in the ubuntu case or are there similar measurements needed to be taken? and if so, how do I get ubuntu to install and run python3.6 in 32 bit as well as the oracle client in 32 bit?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":698,"Q_Id":49171782,"Users Score":4,"Answer":"I am a bit confused about your question but this should give some clarification:\n\nA 32-bit client can connect to a 64-bit Oracle database server - and vice versa\nYou can install and run 32-bit applications on a 64-bit machine - this is at least valid for Windows, I don't know how it works on Linux.\nYour application (the python in your case) must have the same \"bitness\" as installed Oracle Client.","Q_Score":0,"Tags":"python,oracle,ubuntu,32bit-64bit,cx-oracle","A_Id":49172856,"CreationDate":"2018-03-08T11:15:00.000","Title":"Running a Python Script in 32 Bit on 64 linux machine to connect to oracle DB with 32 bit client","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I'm new to Airflow and Python. I'm trying to connect Airflow with Google Sheets and although I have no problem connecting with Python, I do not know how I could do it from Airflow.\nI have searched for information everywhere but I only find Python information with gspread or with BigQuery, but not with Google Sheets.\nI would appreciate any advice or link.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":2341,"Q_Id":49177246,"Users Score":0,"Answer":"As far as I know there is no gsheet hook or operator in airflow at the moment. If security is not a concern you could publish it to the web and pull it in airflow using the SimpleHttpOperator.\nIf security is a concern I recommend going the PythonOperator route and use df2gspread library. Airflow version >= 1.9 can help obtaining credentials for df2gspread","Q_Score":0,"Tags":"python,google-sheets,airflow","A_Id":49181497,"CreationDate":"2018-03-08T15:53:00.000","Title":"Airflow and Google Sheets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I am using Django1.8 and I need help. how to display images and files on pythonanywhere by using model filefield and imagefield.\non my development server everything is ok.but during de production I have donne everything these two field.the parodox is bootstrap is well integread.\nmy project is on githb: Geyd\/eces_edu.git\nhelp me !!!","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":39,"Q_Id":49185114,"Users Score":1,"Answer":"You need to actually serve the files. On your local machine, Django is serving static files for you. On PythonAnywhere, it is not. There is extensive documentation on the PythonAnywhere help pages to get you started with configuring static files.","Q_Score":0,"Tags":"pythonanywhere","A_Id":49196785,"CreationDate":"2018-03-09T01:14:00.000","Title":"how to diplay file field and image field on pythonaywhere","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Tanh activation functions bounds the output to [-1,1]. I wonder how does it work, if the input (features & Target Class) is given in 1-hot-Encoded form  ?\nHow keras (is managing internally) the negative output of activation function to compare them with the class labels (which are in one-hot-encoded form) -- means only 0's and 1's (no \"-\"ive values)\nThanks!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":641,"Q_Id":49188928,"Users Score":0,"Answer":"First of all you simply should'nt use them in your output layer. Depending on your loss function you may even get an error. A loss function like mse should be able to take the ouput of tanh, but it won't make much sense.\nBut if were talking about hidden layers you're perfectly fine. Also keep in mind, that there are biases which can train an offset to the layer before giving the ouput of the layer to the activation function.","Q_Score":0,"Tags":"python-3.x,neural-network,keras,multiclass-classification,activation-function","A_Id":49190269,"CreationDate":"2018-03-09T07:46:00.000","Title":"Keras \"Tanh Activation\" function -- edit: hidden layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This may be a stupid question, but I am new to ML and can't seem to find a clear answer.\nI have implemented a ML algorithm on a Python web app.\nRight now I am storing the data that the algorithm uses in an offline CSV file, and every time the algorithm is run, it analyzes all of the data (one new piece of data gets added each time the algorithm is used).\nApologies if I am being too vague, but I am wondering how one should generally go about implementing the data and algorithm properly so that:\n\nThe data isn't stored in a CSV (Do I simply store it in a database like I would with any other type of data?)\nSome form of preprocessing is used so that the ML algorithm doesn't have to analyze the same data repeatedly each time it is used (or does it have to given that one new piece of data is added every time the algorithm is used?).","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":92,"Q_Id":49195008,"Users Score":1,"Answer":"The data isn't stored in a CSV (Do I simply store it in a database like I would with any other type of data?)\n\nYou can store in whatever format you like.\n\nSome form of preprocessing is used so that the ML algorithm doesn't have to analyze the same data repeatedly each time it is used (or does it have to given that one new piece of data is added every time the algorithm is used?).\n\nThis depends very much on what algorithm you use. Some algorithms can easily be implemented to learn in an incremental manner. For example, Linear\/Logistic Regression implemented with Stochastic Gradient Descent could easily just run a quick update on every new instance as it gets added. For other algorithms, full re-trains are the only option (though you could of course elect not to always do them over and over again for every new instance; you could, for example, simply re-train once per day at a set point in time).","Q_Score":3,"Tags":"python,python-3.x,algorithm,machine-learning","A_Id":49195249,"CreationDate":"2018-03-09T13:34:00.000","Title":"Preprocessing machine learning data","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a query as to whether what I want to achieve is doable, and if so, perhaps someone could give me some advice on how to achieve this.\nSo I have set up a health check on Route 53 for my server, and I have arranged so that if the health check fails, the user will be redirected to a static website I have set up at a backup site.\nI also have a web scraper running regularly collecting data, and my question is, would their be a way to use the data I have collected, and depending on its value, either pass or fail the heath check, therefore determining what site the user would be diverted to.\nI have discussed with AWS support and they have said that their policies and conditions are there by design, and long story short would not support what I am trying to achieve.\nI'm a pretty novice programmer so I'm not sure if it's possible to work this, but this is my final hurdle so any advice or help would be hugely appreciated.\nThanks!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":42,"Q_Id":49198057,"Users Score":2,"Answer":"Make up a filename.  Let's say healthy.txt. \nPut that file on your web server, in the HTML root.  It doesn't really matter what's in the file.\nVerify that if you go to your site and try to download it using a web browser, it works.\nConfigure the Route 53 health check as HTTP and set the Path for the check to use \/healthy.txt.\n\nTo make your server \"unhealthy,\" just delete the file.  The Route 53 health checker will get a 404 error -- unhealthy.\nTo make the server \"healthy\" again, just re-create the file.","Q_Score":0,"Tags":"python,amazon-web-services,amazon-route53,health-monitoring","A_Id":49201020,"CreationDate":"2018-03-09T16:24:00.000","Title":"Intentionally Fail Health Check using Route 53 AWS","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I try write a game with GoranM\/bdx plugin. When i create plate with texture and  try export to code I get fatal error.\n\nTraceback (most recent call last):\n    File \"C:\\Users\\Myuser\\AppData\\Roaming\\Blender Foundation\\Blender\\2.79\\scripts\\addons\\bdx\\ops\\exprun.py\", line 225, in execute\n      export(self, context, bpy.context.scene.bdx.multi_blend_export, bpy.context.scene.bdx.diff_export)\n    File \"C:\\Users\\Myuser\\AppData\\Roaming\\Blender Foundation\\Blender\\2.79\\scripts\\addons\\bdx\\ops\\exprun.py\", line 123, in export\n      bpy.ops.export_scene.bdx(filepath=file_path, scene_name=scene.name, exprun=True)\n    File \"C:\\Program Files\\Blender Foundation\\Blender\\2.79\\scripts\\modules\\bpy\\ops.py\", line 189, in call\n      ret = op_call(self.idname_py(), None, kw)\n  RuntimeError: Error: Traceback (most recent call last):\n    File \"C:\\Users\\Myuser\\AppData\\Roaming\\Blender Foundation\\Blender\\2.79\\scripts\\addons\\bdx\\exporter.py\", line 903, in execute\n      return export(context, self.filepath, self.scene_name, self.exprun, self.apply_modifier)\n    File \"C:\\Users\\Myuser\\AppData\\Roaming\\Blender Foundation\\Blender\\2.79\\scripts\\addons\\bdx\\exporter.py\", line 829, in export\n      \"models\": srl_models(objects, apply_modifier),\n    File \"C:\\Users\\Myuser\\AppData\\Roaming\\Blender Foundation\\Blender\\2.79\\scripts\\addons\\bdx\\exporter.py\", line 117, in srl_models\n      verts = vertices(mesh)\n    File \"C:\\Users\\Myuser\\AppData\\Roaming\\Blender Foundation\\Blender\\2.79\\scripts\\addons\\bdx\\exporter.py\", line 53, in vertices\n      vert_uv = list(uv_layer[li].uv)\n  IndexError: bpy_prop_collection[index]: index 0 out of range, size 0\nlocation: C:\\Program Files\\Blender Foundation\\Blender\\2.79\\scripts\\modules\\bpy\\ops.py:189\nlocation: :-1\n\nMaybe someone had same problem and you know how to fix it?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":1262,"Q_Id":49199787,"Users Score":-1,"Answer":"Go into Object Mode before calling that function.\nbpy.ops.object.mode_set(mode='OBJECT', toggle=False)","Q_Score":1,"Tags":"python,libgdx,blender,index-error","A_Id":58185138,"CreationDate":"2018-03-09T18:14:00.000","Title":"Blender IndexError: bpy_prop_collection","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have a docker volume that I created by running volume create my_volume and have been running my docker image with the command docker run -v my_volume:\/Volumes\/docker-volume\/ my_image.  Within the docker-volume directory I have a python file that I would like to import, but I can't figure out how to do so.  Everything I've tried results in a ModuleNotFound error.  It feels like there's some fundamental issue, perhaps relating to how a docker image interacts with a volume, that I'm missing.  Any help would be greatly appreciated!","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":700,"Q_Id":49201628,"Users Score":0,"Answer":"It looks like there is an issue with your volume mapping.\nThe volume mapping syntax is of format \"-v {local volume}:{directory inside container}\nSo you would have to create that particular directory in your image before mapping it.","Q_Score":1,"Tags":"docker,python-import,docker-volume","A_Id":49201697,"CreationDate":"2018-03-09T20:25:00.000","Title":"import python file from docker volume","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"ive been having trouble using a 32 bit python for canopy on mac. I dont know how to import a external version of python. Ive tried sites, but they all are from 2013-14. They just say to download the v1 with 32 bit python. I want any version of python that is 32 bit to work with canopy, I hope someone knows how, thanks.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":38,"Q_Id":49203197,"Users Score":0,"Answer":"Sorry, Canopy on Mac has not provided 32-bit Python since January 2015.\nIf you've got a really old (32-bit) version of OSX, then you're out of luck. Otherwise (you've got a recent OSX but just want to run 32-bit Python for some reason (WHY?) then...\nI'm not clear from your question whether you have a 32-bit \/ IPython available. If so, then from a terminal where that is your default Python, you can start a 32-bit kernel with ipython kernel.\nIf that version of Ipython is not too old (sorry, not sure what exactly that means), then you should then be able to connect to that kernel from Canopy's Run menu (\"Connect to existing kernel\"). Not super convenient, as you'd need to redo both steps every time you wanted to do this.","Q_Score":0,"Tags":"python,macos,32-bit,canopy","A_Id":49203609,"CreationDate":"2018-03-09T22:34:00.000","Title":"Canopy python 32 bit Mac os x","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to Python and recently installed Python 3.6 on Windows 10. When I try to open IDLE, Python's IDE, I keep getting a message saying that it can not establish a subprocess. I have tried uninstalling and installing several times. I have seen several forums which say that there could be a .py file that is in the directory that is messing up IDLE. This is not my case, as I have not even been able to start using Python and I do not have a firewall either. Can someone tell me how I can get IDLE to work?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1726,"Q_Id":49203567,"Users Score":0,"Answer":"I work with over 30 Python developers and without fail when this happens they were behind a proxy \/ vpn. Turn off your proxy \/ vpn and it will work. Must have had this happen hundreds of times and this solution always worked.","Q_Score":0,"Tags":"python,windows,python-idle","A_Id":56514353,"CreationDate":"2018-03-09T23:15:00.000","Title":"Windows 10: IDLE can't establish a subprocess","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As an exercise, I came up with an idea of the following Django project: a web app with literally one button to scrape room data from Airbnb and one text area to display the retrieved data in a sorted manner.\nPreferably, for scraping I would like to use Selenium, as there is no API for this page. So the button would somehow need to launch the browser automation.\nSo question number one is: is it possible to launch selenium from a web app?\nFurthermore, I already have the working script for collecting the data, however I dont't know how to fit it in a Django project: models, views, separate script? My initial idea was to launch the scraping script on button click, then dump retrieved room-related data to database (updating model's Room attributes like \"price\" and \"link\" for example) and display the data back in the text area mentioned before. \nSo question two is: is it possbile to launch Python script in a web app on button click, for example by nesting in a Django template? Or would other technologies be required, such as Javascript?\nI know my question is general, but I am also looking for general advice, not a ready code sample. I am also open to other approach if what I just wrote doesn't make any sense.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":740,"Q_Id":49206319,"Users Score":2,"Answer":"The simplest option would be a view function (i.e. a function linked to a URL that receives a GET or POST request) in your app which does the scraping and immediately returns the results by rendering a template. For example you could have a starting page with a form and when that form is submitted that will create a POST request which will contain details that the view can use to decide which page to scrape and so on. This doesn't require Javascript or database models.\nIf you're not comfortable with Django yet, consider starting with Flask instead as it's simpler to get going.","Q_Score":0,"Tags":"python,django","A_Id":49206357,"CreationDate":"2018-03-10T07:01:00.000","Title":"How to scrape data from inside Django app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"As an exercise, I came up with an idea of the following Django project: a web app with literally one button to scrape room data from Airbnb and one text area to display the retrieved data in a sorted manner.\nPreferably, for scraping I would like to use Selenium, as there is no API for this page. So the button would somehow need to launch the browser automation.\nSo question number one is: is it possible to launch selenium from a web app?\nFurthermore, I already have the working script for collecting the data, however I dont't know how to fit it in a Django project: models, views, separate script? My initial idea was to launch the scraping script on button click, then dump retrieved room-related data to database (updating model's Room attributes like \"price\" and \"link\" for example) and display the data back in the text area mentioned before. \nSo question two is: is it possbile to launch Python script in a web app on button click, for example by nesting in a Django template? Or would other technologies be required, such as Javascript?\nI know my question is general, but I am also looking for general advice, not a ready code sample. I am also open to other approach if what I just wrote doesn't make any sense.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":740,"Q_Id":49206319,"Users Score":2,"Answer":"Django follows MVT i.e Model (part where you write things related to the database ) , View (the logic analogous to what we did in controller - ref. Java) , Template(things that you'll actually see) . \n As suggested by Alex you can have some inputs collected on your home page and using that data to scrape desired pages. \nComing to your next question, yes you can launch the script on button click and basic working knowledge of JS would do good. \nThis is like a very general answer synonymous to how general the question is so please feel free to get more specific requests if needed.","Q_Score":0,"Tags":"python,django","A_Id":50174783,"CreationDate":"2018-03-10T07:01:00.000","Title":"How to scrape data from inside Django app","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python file in \/Users\/homedir\/... and I want it to access a csv file on an external hard drive.\nDoes anyone know how to do this?  I only need reading permission.","AnswerCount":2,"Available Count":1,"Score":1.0,"is_accepted":false,"ViewCount":7016,"Q_Id":49214989,"Users Score":8,"Answer":"External drives can be found under \/Volumes on macOS. If you provide the full path and have read access you should be able to read in your csv.","Q_Score":6,"Tags":"python,macos,io","A_Id":49215074,"CreationDate":"2018-03-10T23:14:00.000","Title":"Access file in external hard drive using python on mac","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"My dataset has few features with yes\/no (categorical data). Few of the machine learning algorithms that I am using, in python, do not handle categorical data directly. I know how to convert yes\/no, to 0\/1, but my question is -\nIs this a right approach to go about it?\nCan these values of no\/yes to 0\/1, be misinterpreted by algorithms ?\nThe algorithms I am planning to use for my dataset are - Decision Trees (DT), Random Forests (RF) and Neural Networks (NN).","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":1491,"Q_Id":49227490,"Users Score":2,"Answer":"Yes, in my opinion, encoding yes\/no to 1\/0 would be the right approach for you.\nPython's sklearn requires features in numerical arrays.\nThere are various ways of encoding : Label Encoder; One Hot Encoder. etc\nHowever, since your variable only has 2 levels of categories, it wouldnt make much difference if you go for LabelEncoder or OneHotEncoder.","Q_Score":1,"Tags":"python,python-3.x,pandas,neural-network,decision-tree","A_Id":49227672,"CreationDate":"2018-03-12T02:48:00.000","Title":"Categorical Data yes\/no to 0\/1 python - is it a right approach?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"What exactly is happening when I call time.sleep(5) in a python script? Is the program using a lot of resources from the computer? \nI see people using the sleep function in their programs to schedule tasks, but this requires you leave your hard drive running the whole time right? That would be taking for you computer over the long haul right? \nI'm trying to figure out what's to run programs at specific times remotely, but I haven't found an explanation of how to do this that is very intuitive.  \nAny suggestions?","AnswerCount":1,"Available Count":1,"Score":0.537049567,"is_accepted":false,"ViewCount":101,"Q_Id":49231589,"Users Score":3,"Answer":"sleep will mark the process (thread) for being inactive until the given time is up.  During this time the kernel will simply not schedule this process (thread).  It will not waste resources.\nHard disks typically have spin-down policies based solely on their usage.  If they aren't accessed for a specific time, they will spin down.  They will spin up as soon as some process (thread) is accessing them again.\nThis means that letting a process (thread) sleep for some time gives the hard disk a chance to spin down (especially if the sleep duration is large, say, more than some minutes).","Q_Score":3,"Tags":"python,cron,sleep,schedule","A_Id":49231744,"CreationDate":"2018-03-12T09:14:00.000","Title":"What is happening when you use the python sleep module?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have required to send POS Receipt to customer while validating POS order, the challenge is ticket is defined in point_of_sale\/xml\/pos.xml \nreceipt name is <t t-name=\"PosTicket\"> \nhow can i send this via email to customer.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":205,"Q_Id":49235894,"Users Score":0,"Answer":"You can create a wizard at the time of validation of POS order which popup after validating order. In that popup enter mail id of customer and by submit that receipt is directly forwarded to that customer.","Q_Score":0,"Tags":"python-3.x,odoo,point-of-sale,odoo-11","A_Id":52870087,"CreationDate":"2018-03-12T12:59:00.000","Title":"Send POS Receipt Email to Customer While Validating POS Order","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have installed MySQL connector for python 3.6 in centos 7\nIf I search for installed modules with below command \n\nit's showing as below\n      pip3.6 freeze\n      mysql-connector==2.1.6\n      mysql-connector-python==2.1.7\n      pymongo==3.6.1\npip3.6 search mysql-connector\n     mysql-connector-python (8.0.6)   -MYSQL driver written in Python\n     INSTALLED: 2.1.7\n     LATEST:    8.0.6\n     mysql-connector (2.1.6)      - MySQL driver written in Python\n     INSTALLED: 2.1.6 (latest)\n\nMySQL connector installed.But when trying to run the program using MySQL connector then its showing error no module installed MySQL connector.I am using MariaDB 10.0\n\npython3.6 mysql1.py\n      Traceback (most recent call last):\n      File \"mysql1.py\", line 2, in \n      import mysql.connector as mariadb\n      File \"\/root\/Python_environment\/my_Scripts\/mysql.py\", line 2, in \n      import mysql.connector\n  ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package\n\ncan any one know how to resolve","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":455,"Q_Id":49248489,"Users Score":1,"Answer":"You must not name your script mysql.py \u2014 in that case Python tries to import mysql from the script \u2014 and fails.\nRename your script \/root\/Python_environment\/my_Scripts\/mysql.py to something else.","Q_Score":0,"Tags":"python,pip,mariadb,centos7","A_Id":49254109,"CreationDate":"2018-03-13T04:47:00.000","Title":"Mysql Connector issue in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I have installed MySQL connector for python 3.6 in centos 7\nIf I search for installed modules with below command \n\nit's showing as below\n      pip3.6 freeze\n      mysql-connector==2.1.6\n      mysql-connector-python==2.1.7\n      pymongo==3.6.1\npip3.6 search mysql-connector\n     mysql-connector-python (8.0.6)   -MYSQL driver written in Python\n     INSTALLED: 2.1.7\n     LATEST:    8.0.6\n     mysql-connector (2.1.6)      - MySQL driver written in Python\n     INSTALLED: 2.1.6 (latest)\n\nMySQL connector installed.But when trying to run the program using MySQL connector then its showing error no module installed MySQL connector.I am using MariaDB 10.0\n\npython3.6 mysql1.py\n      Traceback (most recent call last):\n      File \"mysql1.py\", line 2, in \n      import mysql.connector as mariadb\n      File \"\/root\/Python_environment\/my_Scripts\/mysql.py\", line 2, in \n      import mysql.connector\n  ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package\n\ncan any one know how to resolve","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":455,"Q_Id":49248489,"Users Score":0,"Answer":"This is the problem I faced in Environment created by python.Outside the python environment i am able to run the script.Its running succefully.In python environment i am not able run script i am working on it.if any body know can give suggestion on this","Q_Score":0,"Tags":"python,pip,mariadb,centos7","A_Id":49376529,"CreationDate":"2018-03-13T04:47:00.000","Title":"Mysql Connector issue in Python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I want to remove the actual Close, minimize and maximize buttons of a window and create my own custom buttons, just like in chrome. I therefore want to add corner widgets to my tabwidget. Is there a way so that I can add three buttons as corner widgets of a QTabWidget?\nIs it somehow possible to achieve using the QHBoxLayout ?\nThe setCornerWidget function just takes one widget as its input.","AnswerCount":1,"Available Count":1,"Score":0.6640367703,"is_accepted":false,"ViewCount":545,"Q_Id":49254062,"Users Score":4,"Answer":"Add a generic QWidget as the corner widget.\nGive it a QHBoxLayout.\nAdd your buttons to the layout.\n\nI use this frequently, often by subclassing QTabWidget and creating accessor functions that return the individual buttons. Adding signals like buttonClicked(int) with the index and buttonClicked(QAbstractButton) with the button itself are helpful, too.","Q_Score":1,"Tags":"python,qt,pyqt,pyqt5,qtabwidget","A_Id":49256651,"CreationDate":"2018-03-13T10:42:00.000","Title":"PyQt QTabWidget Multiple Corner WIdgets","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to cluster a number of words using the KMeans algorithm from scikit learn.\nIn particular, I use pre-trained word embeddings (300 dimensional vectors) to map each word with a number vector and then I feed these vectors to KMeans and provide the number of clusters. \nMy issue is that there are certain words in my input corpus which I can not find in the pretrained word embeddings dictionary. This means that in these cases, instead of a vector, I get a numpy array full of nan values. This does not work with the kmeans algorithm and therefore I have to exclude these arrays. However, I am interested in seeing all these cases that were not found in the word embeddings and what is more, if possible throw them inside a separate cluster that will contain only them.\nMy idea at this point is to set a condition that if the word is returned with a nan-values array from the embeddings index, then assign an arbitrary vector to it. Each dimension of the embeddings vector lie within [-1,1]. Therefore, if I assign the following vector [100000]*300 to all nan words, I have created a set of outliers. In practice, this works as expected, since this particular set of vectors are forced in a separate cluster. However, the initialization of the kmeans centroids is affected by these outlier values and therefore all the rest of my clusters get messed up as well. As a remedey, I tried to initiate the kmeans using init = k-means++ but first, it takes significantly longer to execute and second the improvement is not much better.\nAny suggestions as to how to approach this issue?\nThank you.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":2184,"Q_Id":49273536,"Users Score":0,"Answer":"If you don't have data on a word, then skip it.\nYou could try to compute a word vector on the fly based on the context, but that essentially is the same as just skipping it.","Q_Score":2,"Tags":"python,cluster-analysis,k-means","A_Id":49294559,"CreationDate":"2018-03-14T09:08:00.000","Title":"Python KMeans Clustering - Handling nan Values","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"the code below replaces numbers with the token NUMB:\nraw_corpus.loc[:,'constructed_recipe']=raw_corpus['constructed_recipe'].str.replace('\\d+','NUMB')\nIt works fine if the numbers have a space before and a space after, but creates a problem if the numbers are included in another string. \nHow do I modify the code so that it only replaces numbers with NUMB if the numbers are surrounded by a space on both sides? e.g. do not modify this string: \"from url 500px\", but do modify this string: \"dishwasher 10 pods\" to \"dishwasher NUMB pods\".\nI'm not sure how to modify '\\d+' to make this happen. Any ideas?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":415,"Q_Id":49289969,"Users Score":0,"Answer":"I also tried ' \\d+ ' and that works! probably not \"pythonic\" though...","Q_Score":1,"Tags":"python,string,replace,whitespace","A_Id":49290127,"CreationDate":"2018-03-15T01:00:00.000","Title":"replace numbers with token if numbers have whitespace on both side","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have just inherited an extreemly legacy application (built on windows 95 - Magic7 for the connoisseurs) now backed against a recentish mssql db (2012). That's not the db system it was first designed on, and it thus comes with some seriously odd design for tables.\nI'm looking for a python ORM to help me talk to this thing easily. Namely, I'm after an ORM that can easily, for instance, merge 2 tables as if they were one.\nFor instance I may have tables BILLS and BILLS_HISTORY, with different column names, and perhaps even different column types, so different strictly speaking, but sementically containing the same information (same number of columns, sementically identical values).\nI'm looking for an ORM that lets me define only one Bill object, that maps to both tables, and that gives me the right hooks to decide where things go, and how to write them when tweaks are needed.\nAnother Example : say I have an object called a good. If a good is finished, it goes in the GOODS table, if it is not finished, it goes in the GOODS_UNFINISHED table. I'm looking for a goods object that can read both tables, and give me a finished property set to the right value depending which table it comes from  (and  with the hooks to change it from one table to the other if the property is set in some way).\nI'm fine with python, but I have not done much such db work before so my knowledge is limited there. I could, and might end up writing my own tailor made ORM, but that seems like a waste of time for something that will be thrown away in 6 months when the full transition is done to something new. Does anyone know of an ORM with such capabilities ? I'm planning to study ponyORM and SQLAlchemy, but I have a feeling it will take me a few days to come to a conclusion wether they are suitable for my use case. So I thought I'd ask the community too ...\nCheers","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":235,"Q_Id":49325336,"Users Score":0,"Answer":"For the record I've ended up with a hybrid approach using sqlalchemy.\nSqlalchemy was not flexible enough to do everything I wanted out of the box in a non verbose fashion, but had the required functionality to get a fair bit of the way along if one took the pain of writing explicitely everything needed. So I wrote a program that generates about 6000 lines of sqlalchemy code in order to have a 1 to 1 mapping between sqlalchemy objects to tables in the way required (basically defining everything explicitely for sqla). Sqlalchemy has a lot of hooks during autoload, but I have found it hard\/impossible to leverage different hooks and set fine grained behaviour at each hook at the same time, that's why I went the automated explicit way.\nOn top of these sqlalchemy objects, I've written objects that wraps them to hide the \"which table\" traffic control things. A bit of a kludge and I think that I could have done something with type heritance and sqlachemy objects, but time was passing and I only needed very little functionality or maintainability in that layer, so just charged ahead.","Q_Score":0,"Tags":"python,python-3.x,orm,sqlalchemy,ponyorm","A_Id":51031086,"CreationDate":"2018-03-16T16:19:00.000","Title":"Looking for a particular python ORM","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"A collaborator of mine wrote a software package in Python 2.7, took advantage of it to run some tests and obtain some scientific results. We wrote together a paper about the methods he developed and the results he obtained.\nEverything worked out well so he recently put this package publically available on his GitHub webpage.\nThen I thought it would have been useful to have a Python 3.5 version of that package. Therefore I downloaded the original software and made the proper changes to have it working on Python 3.5.\nNow I don't know how to properly release this Python 3.5 package.\nI envision three possibilities:\n\nShould I put it on his original GitHub project repository? This option would lead to some confusion, because people would have to download both the Python 2.7 and the Python 3.5 code.\nShould I create a new repository only for my Python 3.5 package, in addition to the Python 2.7 one released by my collaborator? This option would lead to the existence of two running code repositories, and to some confusion as well, because people might not know which is the \"official one\" to use.\nShould I create a new repository only for my Python 3.5 package, and ask my collaborator to delete his Python 2.7 repository? This option would make our paper inconsistent, because it states that tests were done with Python 2.7.\n\nDo you envision any other option I did not include?\nDo you have any suggestion?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":44,"Q_Id":49326559,"Users Score":1,"Answer":"I think number 1. and 2. should both work as long as you provide enough details in the README.md file in the repository. \nIn case of option 1, you should ask your collaborator to add you as a collaborator to the repository.\nIn case of number 2, you should definitely cross-link each other's repositories in your README-files respectively. \nI'd definitely add a requirements.txt file for each python version so that the users can conveniently install your dependencies with pip install -r requirements.txt or pip3 install -r requirements.txt.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,github,version","A_Id":49326823,"CreationDate":"2018-03-16T17:36:00.000","Title":"What's the best way to release two versions of the same software package on GitHub?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want assign the data which is retrieve from database (sqlit3) particular column  for a variable and call that variable for word tokenize.\nplease help with this\nI know tokenize part but I want to know how to assign the db value to a variable in python.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":143,"Q_Id":49340877,"Users Score":0,"Answer":"This is worked but when using c.fetchall it didn't work.shows error saying TypeError: expected string or buffer\nimport sqlite3\nimport nltk\nfrom nltk.tokenize import sent_tokenize, word_tokenize\nconn = sqlite3.connect('ACE.db')\nc = conn.cursor()\nc.execute('SELECT can_answer FROM Can_Answer')\nrows = c.fetchone()\nfor row in rows:\n    print(row)\nprint(word_tokenize(row))","Q_Score":0,"Tags":"python,sqlite","A_Id":49361558,"CreationDate":"2018-03-17T19:12:00.000","Title":"how to assign db column value to variable and call it to tokenize in python","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm building a dedicated OAuth2 as a service for my application, where users will be both authenticating and authorizing themselves. \nI've the following concerns\n1) Is OAuth2 TokenScope similar to Django Permissions?\n2) If I want to make role-level hierarchy application, how do I go about building one with OAuth2?","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":59,"Q_Id":49356867,"Users Score":1,"Answer":"Actually there is a difference between Django permissions and OAuth token scope, Django permissions use for define access level to your endpoint addresses like when you want just authenticated user see some data but OAuth token scope is for time you want to have third-party login and you define when somebody login what access he\/she has, like when you authenticate from Gmail in scope Gmail, for example, says read and you just have read access when you login .\nand I didn't get you concern number 2","Q_Score":1,"Tags":"python,django,django-permissions,django-oauth","A_Id":53847566,"CreationDate":"2018-03-19T06:18:00.000","Title":"Is OAuth2 TokenScope similar to Django Permissions?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am new to configuring and setting up Python from scratch.\nI have installed Anaconda and I plan to use Spyder for python development. I also have a older version of Python installed on the same machine elsewhere.\nI needed to get my hands on a package to use in Spyder which I needed to download and install.\nI downloaded and installed pip directly from the website and then I used this in the command line of the older python install to obtain the package I required.\nHowever I don't understand how I go about making this available to Spyder. I believe it works on a folder structure within it's own directory and I am unsure how to change this to get the package I have already downloaded.\nI thought I might be able to copy it across, or point it at the directory where the package was downloaded to but I cannot work out how to do this.\nI also tried using pip from within Spyder to work but it cannot find it.\nCan you please let me know what I need to check?","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":49383201,"Users Score":0,"Answer":"Try to:\nOpen Anaconda Prompt and then do:  pip install whatever - to install wheels\nIf you want to install spyder the open Anaconda Navigator - and you should be in the home tab - then highlat spyder and press install - thats all.","Q_Score":0,"Tags":"python,packages","A_Id":49383321,"CreationDate":"2018-03-20T11:36:00.000","Title":"Install Python packages and directories (windows)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a python code which is quite heavy, my computer cant run it efficiently, therefore i want to run the python code on cloud.\nPlease tell me how to do it ? any step by step tutorial available\nthanks","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":3979,"Q_Id":49386402,"Users Score":0,"Answer":"You can try Heroku. It's free and they got their own tutorials. But it's good enough only if you will use it for studying. AWS, Azure or google cloud are much better for production.","Q_Score":3,"Tags":"python,cloud","A_Id":49386557,"CreationDate":"2018-03-20T14:04:00.000","Title":"How to run python code on cloud","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"Hi everyone I am trying to write some script to automate my work in Maya. \nRight now I am looking for the way to add materials to the hypershade.\nI can't see anything on console (Script editor) so I can't se what python api I should use. \nI know that maya treat materials as sets, and to assign a material to polygon I need to put it in this set, but I don't know how to create a new set. \nSo my question is:\nHow I add a material to the scene using python maya-api?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":49390281,"Users Score":1,"Answer":"you have to use createNode :\nnode = cmds.createNode('blinn', name='yipikai')","Q_Score":0,"Tags":"python,maya,maya-api","A_Id":49390999,"CreationDate":"2018-03-20T17:08:00.000","Title":"How to add an material to the maya scene?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":0,"REVIEW":0},{"Question":"I have Python 2.7 installed (as default in Windows 7 64bit) and also have Python 3 installed in an environment (called Python3).\nI would like to use Spyder as my IDE. I have installed Spyder3 in my Python3 environment, but when I open Spyder 3 (from within my Python 3 env), then it opens Spyder for python 2.7 and not python 3.5 as I would've hoped for.). I don't know why.\nI have done TOOLS--Preferences--Python Interpreter -- Use the following Python interpreter: C:\\Users\\16082834\\AppData\\Local\\Continuum\\Anaconda2\\envs\\Python3\\python.exe, but this didn't work either.\nMany of us are running multiple python environments; I am sure some of you might have managed to use Spyder for these different environments.\nPlease tell me how I can get Python 3 using this method.","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":4452,"Q_Id":49408048,"Users Score":1,"Answer":"So, when you create a new environment with: conda create --name python36 python=3.6 anaconda \nThis will create an env. called python36 and the package to be installed is anaconda (which basically contains everything you'll need for python). \nBe sure that your new env. actually is running the ecorrect python version by doing the following:\nactivate python environmentwith: active python36\nthen type: python \nthis will indicate what python version is running in your env. It turns out, for some reason, my environment was running python2.7 and not 3.6\nThe cool thing is that anaconda distribution comes with spyder. Just be sure that you run Spyder from within your environment.\nSo to do this: activate python36\nthen type: spyder\nIt will automatically open spyder3 for python3. \nMy initial issue was therefore that even though i created a python3 environment, it was still running python2.7. But after removing the old python3 environment and creating a new python3 env. and installing the desired libraries\/packages it now works perfect. \nI have a 2.7 and 3.6 environment which can both be edited with spyder2 and spyder3 IDE","Q_Score":0,"Tags":"python,python-3.x,python-2.7,spyder","A_Id":49424870,"CreationDate":"2018-03-21T13:47:00.000","Title":"How to install Spyder for Python 2 and Python 3 and get Python 3 in my Spyder env?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have Python 2.7 installed (as default in Windows 7 64bit) and also have Python 3 installed in an environment (called Python3).\nI would like to use Spyder as my IDE. I have installed Spyder3 in my Python3 environment, but when I open Spyder 3 (from within my Python 3 env), then it opens Spyder for python 2.7 and not python 3.5 as I would've hoped for.). I don't know why.\nI have done TOOLS--Preferences--Python Interpreter -- Use the following Python interpreter: C:\\Users\\16082834\\AppData\\Local\\Continuum\\Anaconda2\\envs\\Python3\\python.exe, but this didn't work either.\nMany of us are running multiple python environments; I am sure some of you might have managed to use Spyder for these different environments.\nPlease tell me how I can get Python 3 using this method.","AnswerCount":2,"Available Count":2,"Score":0.1973753202,"is_accepted":false,"ViewCount":4452,"Q_Id":49408048,"Users Score":2,"Answer":"One possible way is to run activate Python3 and then run pip install Spyder.","Q_Score":0,"Tags":"python,python-3.x,python-2.7,spyder","A_Id":49408240,"CreationDate":"2018-03-21T13:47:00.000","Title":"How to install Spyder for Python 2 and Python 3 and get Python 3 in my Spyder env?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to find pid of a oracle process by using below command\nps -ef | grep pmon | grep orcl | grep -v grep\nWhen trying to use python \noracle_pid = os.system(\"echo ps -ef | grep pmon | grep %s | grep -v grep | awk '{print $2}'\" %(oracle_sid))\nprint(oracle_pid)\nit is printing 0 as value\nAny suggestions on how to achieve just the pid as output?\nRegards","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":182,"Q_Id":49419095,"Users Score":0,"Answer":"Thanks for the reply !!!\nThe command works but it is adding extra characters\n\n\n\nimport subprocess\n      subprocess.check_output(\"ps -ef | grep pmon | grep orcl | grep -v grep | awk '{print $2}'\", stderr=subprocess.STDOUT, shell=True)\n      b'21648\\n'","Q_Score":1,"Tags":"python,python-3.6","A_Id":49436806,"CreationDate":"2018-03-22T01:28:00.000","Title":"Find pid using python by grepping two variables","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python script deployed and running in azure virtual machine, however in the script, I have to read a local CSV file for further processing, that leads a failure, server came back with notice that: \"file does not exist \" \nMay I ask how can I running Python script in VM but read and save on my computer local file ?\nIf not possible, may I ask how to overcome this problem with cloud storage, particularly with Azure?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1594,"Q_Id":49438230,"Users Score":0,"Answer":"You could possible map the directory to the vm as a network resource?","Q_Score":0,"Tags":"python,virtual-machine","A_Id":49438506,"CreationDate":"2018-03-22T20:51:00.000","Title":"How to running Python script in virtual machine but read and save on computer local csv file","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using ldap3.\nI can connect and read all attributes without any issue, but I don't know how to display the photo of the attribute thumbnailPhoto.\nIf I print(conn.entries[0].thumbnailPhoto) I get a bunch of binary values like b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF.....'.\nI have to display it on a bottle web page. So I have to put this value in a jpeg or png file.\nHow can I do that?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":4282,"Q_Id":49458945,"Users Score":1,"Answer":"The easiest way is to save the raw byte value in a file and open it with a picture editor. The photo is probably a jpeg, but it can be in any format.","Q_Score":1,"Tags":"python-3.x,ldap","A_Id":49470034,"CreationDate":"2018-03-23T22:11:00.000","Title":"how to get and display photo from ldap","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I get the following error when trying to use tensorflow\n\nimportError                               Traceback (most recent call\n  last)  in ()\n  ----> 1 import tensorflow as tf\n~\\Anaconda3\\lib\\site-packages\\tensorflow__init__.py in ()\n       22 \n       23 # pylint: disable=wildcard-import\n  ---> 24 from tensorflow.python import *\n       25 # pylint: enable=wildcard-import\n       26 \n~\\Anaconda3\\lib\\site-packages\\tensorflow\\python__init__.py in\n  ()\n       54 # imported using tf.load_op_library() can access symbols defined in\n       55 # _pywrap_tensorflow.so.\n  ---> 56 import numpy as np\n       57 try:\n       58   if hasattr(sys, 'getdlopenflags') and hasattr(sys, 'setdlopenflags'):\n~\\Anaconda3\\lib\\site-packages\\numpy__init__.py in ()\n      140         return loader(*packages, **options)\n      141 \n  --> 142     from . import add_newdocs\n      143     all = ['add_newdocs',\n      144                'ModuleDeprecationWarning',\n~\\Anaconda3\\lib\\site-packages\\numpy\\add_newdocs.py in ()\n       11 from future import division, absolute_import, print_function\n       12 \n  ---> 13 from numpy.lib import add_newdoc\n       14 \n       15 ###############################################################################\n~\\Anaconda3\\lib\\site-packages\\numpy\\lib__init__.py in ()\n        6 from numpy.version import version as version\n        7 \n  ----> 8 from .type_check import *\n        9 from .index_tricks import *\n       10 from .function_base import *\n~\\Anaconda3\\lib\\site-packages\\numpy\\lib\\type_check.py in ()\n        9            'common_type']\n       10 \n  ---> 11 import numpy.core.numeric as _nx\n       12 from numpy.core.numeric import asarray, asanyarray, array, isnan, zeros\n       13 from .ufunclike import isneginf, isposinf\n~\\Anaconda3\\lib\\site-packages\\numpy\\core__init__.py in ()\n       36 from . import numerictypes as nt\n       37 multiarray.set_typeDict(nt.sctypeDict)\n  ---> 38 from . import numeric\n       39 from .numeric import *\n       40 from . import fromnumeric\n~\\Anaconda3\\lib\\site-packages\\numpy\\core\\numeric.py in ()\n  1818     1819 # Use numarray's printing function\n  -> 1820 from .arrayprint import array2string, get_printoptions, set_printoptions    1821     1822 \n~\\Anaconda3\\lib\\site-packages\\numpy\\core\\arrayprint.py in ()\n       42 from .umath import absolute, not_equal, isnan, isinf, isfinite, isnat\n       43 from . import multiarray\n  ---> 44 from .multiarray import (array, dragon4_positional, dragon4_scientific,\n       45                          datetime_as_string, datetime_data, dtype, ndarray,\n       46                          set_legacy_print_mode)\n\nThis error occured after I tried to upgrade TF from version 1.1 to the latest version. So I dont know what current TF version I am using.\nI am using Windows 10 without a GPU.\nDo you know how to fix it?","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":1449,"Q_Id":49477640,"Users Score":0,"Answer":"This looks like it is an issue with Numpy, which is a dependency of Tensorflow. Did you try upgrading your version of numpy using pip or conda?\nLike such: pip install --ignore-installed --upgrade numpy","Q_Score":0,"Tags":"python,python-3.x,tensorflow","A_Id":52206018,"CreationDate":"2018-03-25T15:41:00.000","Title":"TensorFlow: ImportError: cannot import name 'dragon4_positional'","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":1,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"At first, I am learning Python and Django only... So I'm a noobie yet.\nI need to build a microservice architecture to I could run each my service on a separate server machine. In the Django I need to create an environment, project and apps. So, can I run these apps after on different servers? If no, how can I make it with Django? Do I need to create a separate project for each service?\nP.S. If my question is stupid, pls, explain where am I wrong. I am from Java Spring world where I was need to create just new app for each service.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":36,"Q_Id":49480796,"Users Score":1,"Answer":"Either approach will work.\nIf it makes sense for your services to share the same code base, you can create a single project and use separate apps for each service and separate settings files for each deployment. The settings file would activate the desired app by listing it in INSTALLED_APPS, and would include settings specific to that service.\nOr, if you don't need the services to be coupled in that way, you could certainly make each one its own project.","Q_Score":0,"Tags":"django,python-3.x","A_Id":49482862,"CreationDate":"2018-03-25T20:50:00.000","Title":"Different IPs are for different apps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have never worked with audio before.\nFor a monophonic wav file read() returns an 1-D array of integers. What do these integers represent? Are they the frequencies? If not how do I use them to get the frequencies?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":152,"Q_Id":49481114,"Users Score":1,"Answer":"wavfile.read() returns two things:\ndata: This is the data from your wav file which is the amplitude of the audio taken at even intervals of time.\nsample rate: How many of those intervals make up one second of audio.","Q_Score":0,"Tags":"python-3.x,audio,scipy","A_Id":49957782,"CreationDate":"2018-03-25T21:26:00.000","Title":"What is returned by scipy.io.wavefile.read()?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have using nltk packages and train a model using Naive Bayes. I have save the model to a file using pickle package. Now i wonder how can i use this model to test like a random text not in the dataset and the model will tell if the sentence belong to which categorize?\nLike my idea is i have a sentence : \" Ronaldo have scored 2 goals against Egypt\" And pass it to the model file and return categorize \"sport\".","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":147,"Q_Id":49484820,"Users Score":0,"Answer":"Just saving the model will not help. You should also save your VectorModel (like tfidfvectorizer or countvectorizer what ever you have used for fitting the train data). You can save those the same way using pickle. Also save all those models you used for pre-processing the train data like normalization\/scaling models, etc. For the test data repeat the same steps by loading the pickle models that you saved and transform the test data in train data format that you used for model building and then you will be able to classify.","Q_Score":0,"Tags":"python,nltk,text-mining,naivebayes","A_Id":49485045,"CreationDate":"2018-03-26T05:57:00.000","Title":"Text Categorization Test NLTK python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"If I understand correctly, the python syntax from ... import ... can be used in two ways\n\nfrom package-name import module-name\nfrom module-name import function-name\n\nI would like to know a bit of how Python internally treats the two different forms. Imagine, for example,  that the interpreter gets \"from A import B\", does the interpreter actually try to determine whether A is a package-name\/ module-name, or does it internally treat packages and modules as the same class of objects (something like Linux treats files and directories very similarly)?","AnswerCount":1,"Available Count":1,"Score":-0.1973753202,"is_accepted":false,"ViewCount":175,"Q_Id":49491650,"Users Score":-1,"Answer":"First of all, a module is a python file that contains classes and functions. when you say From A Import B python searches for A(a module) in the standard python library and then imports B(the function or class) which is the module if it finds A. If it doesn't it goes out and starts searching in the directory were packages are stored and searches for the package name( A ) and then if it finds it, it imports the Module name(B). If it fails in the past 2 processes it returns an error.\nHope this helps.","Q_Score":0,"Tags":"python,import,python-internals","A_Id":49491846,"CreationDate":"2018-03-26T12:36:00.000","Title":"How does Python internally distinguish \"from package import module\" between \"from module import function\"","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm crawling web pages to create a search engine and have been able to crawl close to 9300 pages in 1 hour using Scrapy. I'd like to know how much more can I improve and what value is considered as a 'good' crawling speed.","AnswerCount":3,"Available Count":2,"Score":-0.0665680765,"is_accepted":false,"ViewCount":453,"Q_Id":49494093,"Users Score":-1,"Answer":"I'm no expert but I would say that your speed is pretty slow. I just went to google, typed in the word \"hats\", pressed enter and: about 650,000,000 results (0.63 seconds). That's gonna be tough to compete with. I'd say that there's plenty of room to improve.","Q_Score":5,"Tags":"python,scrapy,web-crawler","A_Id":49523000,"CreationDate":"2018-03-26T14:38:00.000","Title":"What is a good crawling speed rate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I'm crawling web pages to create a search engine and have been able to crawl close to 9300 pages in 1 hour using Scrapy. I'd like to know how much more can I improve and what value is considered as a 'good' crawling speed.","AnswerCount":3,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":49494093,"Users Score":0,"Answer":"It really depends but you can always check your crawling benchmarks for your hardware by typing scrapy bench on your command line","Q_Score":5,"Tags":"python,scrapy,web-crawler","A_Id":70224507,"CreationDate":"2018-03-26T14:38:00.000","Title":"What is a good crawling speed rate?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"os.path.ismount() will verify whether the given path is mounted on the local linux machine. Now I want to verify whether the path is mounted on the remote machine. Could you please help me how to achieve this.\nFor example: my dev machine is : xx:xx:xxx\nI want to verify whether the '\/path' is mounted on yy:yy:yyy. \nHow can achieve this by using os.path.ismount() function","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":128,"Q_Id":49504741,"Users Score":0,"Answer":"If you have access to both machines, then one way could be to leverage python's sockets. The client on the local machine would send a request to the server on the remote machine, then the server would do os.path.ismount('\/path') and send back the return value to the client.","Q_Score":0,"Tags":"python,python-2.7","A_Id":49505061,"CreationDate":"2018-03-27T05:06:00.000","Title":"Verify mountpoint in the remote server","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'd like to parse a c and\/or c++ header file in python using llvmlite.  Is this possible?  And if so, how do I create an IR representation of the header's contents?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":216,"Q_Id":49523349,"Users Score":0,"Answer":"llvmlite is a python binding for LLVM, which is independent from C or C++ or any other language. To parse C or C++, one option is to use the python binding for libclang.","Q_Score":0,"Tags":"python,llvm,header-files","A_Id":49525779,"CreationDate":"2018-03-27T22:23:00.000","Title":"How to parse a c\/c++ header with llvmlite in python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Coding is entirely new to me. \nRight now, I am teaching myself Python. As of now, I am only going over algorithms. I watched a few crash courses online about the language. Based on that, I don't feel like I am able to code any sort of website or software which leads me wonder if the libraries and frameworks of any programming language are the most important bit?\nShould I spend more time teaching myself how to code with frameworks and libraries?\nThanks","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":43,"Q_Id":49526618,"Users Score":1,"Answer":"First of all, you should try to be comfortable with every Python mechanisms (classes, recursion, functions... everything you usually find in any book or complete tutorial). It could be useful for any problem you want to solve. \nThen, you should start your own project using the suitable libraries and frameworks. You must set a clear goal, do you want to build a website or a software ? You won't use the same libraries\/framework for any purpose. Some of them are really often used so you could start by reading their documentation.\nAnyhow, to answer your question, framework and libraries are not the most important bit of coding. They are just your tools, whereas the way you think to solve problems and build your algorithms is your art.  \nThe most important thing to be a painter is not knowing how to use a brush (even if, of course, it's really useful)","Q_Score":1,"Tags":"python,frameworks,libraries","A_Id":49530470,"CreationDate":"2018-03-28T05:18:00.000","Title":"Are framework and libraries the more important bit of coding?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script.\nClass Model seem to have the property model.name, but when changing it I get \"AttributeError: can't set attribute\".\nWhat is the Problem here?\n2) Additionally, I am using sequential API and I want to give a name to layers, which seems to be possibile with Functional API, but I found no solution for sequential API. Does anonye know how to do it for sequential API?\nUPDATE TO 2): Naming the layers works, although it seems to be not documented. Just add the argument name, e.g. model.add(Dense(...,...,name=\"hiddenLayer1\"). Watch out, Layers with same name share weights!","AnswerCount":9,"Available Count":2,"Score":-1.0,"is_accepted":false,"ViewCount":40090,"Q_Id":49550182,"Users Score":-4,"Answer":"for 1), I think you may build another model with right name and same structure with the exist one. then set weights from layers of the exist model to layers of the new model.","Q_Score":27,"Tags":"python,keras","A_Id":51157225,"CreationDate":"2018-03-29T07:20:00.000","Title":"Keras rename model and layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script.\nClass Model seem to have the property model.name, but when changing it I get \"AttributeError: can't set attribute\".\nWhat is the Problem here?\n2) Additionally, I am using sequential API and I want to give a name to layers, which seems to be possibile with Functional API, but I found no solution for sequential API. Does anonye know how to do it for sequential API?\nUPDATE TO 2): Naming the layers works, although it seems to be not documented. Just add the argument name, e.g. model.add(Dense(...,...,name=\"hiddenLayer1\"). Watch out, Layers with same name share weights!","AnswerCount":9,"Available Count":2,"Score":1.0,"is_accepted":false,"ViewCount":40090,"Q_Id":49550182,"Users Score":10,"Answer":"To rename a keras model in TF2.2.0:\nmodel._name = \"newname\"\nI have no idea if this is a bad idea - they don't seem to want you to do it, but it does work. To confirm, call model.summary() and you should see the new name.","Q_Score":27,"Tags":"python,keras","A_Id":63853924,"CreationDate":"2018-03-29T07:20:00.000","Title":"Keras rename model and layers","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm developing a chatbot using heroku and python. I have a file fetchWelcome.py in which I have written a function. I need to import the function from fetchWelcome into my main file. \nI wrote \"from fetchWelcome import fetchWelcome\" in main file. But because we need to mention all the dependencies in the requirement file, it shows error. I don't know how to mention user defined requirement.\nHow can I import the function from another file into the main file ? Both the files ( main.py and fetchWelcome.py ) are in the same folder.","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":694,"Q_Id":49561062,"Users Score":0,"Answer":"If we need to import function from fileName into main.py, write \"from .fileName import functionName\". Thus we don't need to write any dependency in requirement file.","Q_Score":0,"Tags":"python,heroku","A_Id":49571369,"CreationDate":"2018-03-29T16:33:00.000","Title":"Heroku Python import local functions","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":0},{"Question":"I understand how random state is used to randomly split data into training and test set. As Expected, my algorithm gives different accuracy each time I change it. Now I have to submit a report in my university and I am unable to understand the final accuracy to mention there. Should I choose the maximum accuracy I get? Or should I run it with different RandomStates and then take its average? Or something else?","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":5696,"Q_Id":49561882,"Users Score":1,"Answer":"For me personally, I set random_state to a specific number (usually 42) so if I see variation in my programs accuracy I know it was not caused by how the data was split.\nHowever, this can lead to my network over fitting on that specific split.  I.E. I tune my network so it works well with that split, but not necessarily on a different split.  Because of this, I think it's best to use a random seed when you submit your code so the reviewer knows you haven't over fit to that particular state.\nTo do this with sklearn.train_test_split you can simply not provide a random_state and it will pick one randomly using np.random.","Q_Score":5,"Tags":"python,pandas,machine-learning,scikit-learn,svm","A_Id":49562017,"CreationDate":"2018-03-29T17:21:00.000","Title":"How to choose RandomState in train_test_split?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a Python app that uses websockets and gevent. It's quite a big application in my personal experience.\nI've encountered a problem with it: when I run it on Windows (with 'pipenv run python myapp'), it can (suddenly but very rarily) freeze, and stop accepting messages. If I then enter CTRL+C in cmd, it starts reacting to all the messages, that were issued when it was hanging.\nI understand, that it might block somewhere, but I don't know how to debug theses types of errors, because I don't see anything in the code, that could do it. And it happens very rarily on completely different stages of the application's runtime.\nWhat is the best way to debug it? And to actually see what goes behind the scenes? My logs show no indication of a problem.\nCould it be an error with cmd and not my app?","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":453,"Q_Id":49572547,"Users Score":0,"Answer":"Your answer may be as simple as adding timeouts to some of your spawns or gevent calls.  Gevent is still single threaded, and so if an IO bound resource hangs, it can't context switch until it's been received.  Setting a timeout might help bypass these issues and move your app forward?","Q_Score":0,"Tags":"python,websocket,gevent","A_Id":49618957,"CreationDate":"2018-03-30T10:14:00.000","Title":"Python application freezes, only CTRL-C helps","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":1,"REVIEW":1},{"Question":"I am writing a sql query using pandas within python. In the where clause I need to compare a date column (say review date 2016-10-21) with this value '2016Q4'. In other words if the review dates fall in or after Q4 in 2016 then they will be selected. Now how do I convert the review date to something comparable to 'yyyyQ4' format. Is there any python function for that ? If not, how so I go about writing one for this purpose ?","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":798,"Q_Id":49576487,"Users Score":1,"Answer":"Once you are able to get the month out into a variable: mon\nyou can use the following code to get the quarter information:\nfor mon in range(1, 13):\n  print (mon-1)\/\/3 + 1,\nprint\nwhich would return: \n\nfor months 1 - 3    : 1\nfor months 4 - 6    : 2\nfor months 7 - 9    : 3\nfor months 10 - 12  : 4","Q_Score":1,"Tags":"sql,python-3.x,pandas","A_Id":49577047,"CreationDate":"2018-03-30T14:45:00.000","Title":"How to compare date (yyyy-mm-dd) with year-Quarter (yyyyQQ) in python","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex.\nI am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate.\nPossible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape.\nI will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method.\nUpdate:\nI found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1361,"Q_Id":49584153,"Users Score":0,"Answer":"A sample-based approach is what I'd try first. Generate a bunch of points in the unioned bounding AABB, and divide the number of points in A and B by the number of points in A or B. (You can adapt this measure to your use case -- it doesn't work very well when A and B have very different volumes.) To check whether a given point is in a given volume, use a crossing number test, which Google. There are acceleration structures that can help with this test, but my guess is that the number of samples that'll give you reasonable accuracy is lower than the number of samples necessary to benefit overall from building the acceleration structure.\nAs a variant of this, you can check line intersection instead of point intersection: Generate a random (axis-aligned, for efficiency) line, and measure how much of it is contained in A, in B, and in both A and B. This requires more bookkeeping than point-in-polyhedron, but will give you better per-sample information and thus reduce the number of times you end up iterating through all the faces.","Q_Score":3,"Tags":"python,3d,computational-geometry,bin-packing","A_Id":49597211,"CreationDate":"2018-03-31T04:10:00.000","Title":"Measurement for intersection of 2 irregular shaped 3d object","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex.\nI am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate.\nPossible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape.\nI will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method.\nUpdate:\nI found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1361,"Q_Id":49584153,"Users Score":0,"Answer":"By straight voxelization:\nIf the faces are of similar size (if needed triangulate the large ones), you can use a gridding approach: define a regular 3D grid with a spacing size larger than the longest edge and store one bit per voxel.\nThen for every vertex of the mesh, set the bit of the cell it is included in (this just takes a truncation of the coordinates). By doing this, you will obtain the boundary of the object as a connected surface. You will obtain an estimate of the volume by means of a 3D flood filling algorithm, either from an inside or an outside pixel. (Outside will be easier but be sure to leave a one voxel margin around the object.)\nEstimating the volumes of both objects as well as intersection or union is straightforward with this machinery. The cost will depend on the number of faces and the number of voxels.","Q_Score":3,"Tags":"python,3d,computational-geometry,bin-packing","A_Id":49688037,"CreationDate":"2018-03-31T04:10:00.000","Title":"Measurement for intersection of 2 irregular shaped 3d object","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":1,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like Spyder, you can execute code block. how can i do in Pycharm in science mode. in spyder you use \n# In[] \nHow can i do this in pycharm","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":94,"Q_Id":49585758,"Users Score":1,"Answer":"you can just import numpy to actvate science mode.\nimport numpy as np","Q_Score":1,"Tags":"python,machine-learning,pycharm","A_Id":49585883,"CreationDate":"2018-03-31T08:19:00.000","Title":"How executed code block Science mode in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Like Spyder, you can execute code block. how can i do in Pycharm in science mode. in spyder you use \n# In[] \nHow can i do this in pycharm","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":94,"Q_Id":49585758,"Users Score":1,"Answer":"pycharm use code cell. you can do with this\n'#%% '","Q_Score":1,"Tags":"python,machine-learning,pycharm","A_Id":49585817,"CreationDate":"2018-03-31T08:19:00.000","Title":"How executed code block Science mode in Pycharm","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"In mininet-wifi examples, I found a sample (6LowPAN.py) that creates a simple topology contains 3 nodes.\nNow, I intend to create another topology as follows:\n\n1- Two groups of sensor nodes such that each group connects to a 'Sink\n  node' \n2- Connect each 'Sink node' to an 'ovSwitch' \n3- Connect the two switches to a 'Controller'\n\nIs that doable using mininet-wifi? Any tips how to do it??\nMany thanks in advance :)","AnswerCount":1,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":444,"Q_Id":49586831,"Users Score":1,"Answer":"Yes, you can do this with 6LowPAN.py. You then add switches and controller into the topology with their links.","Q_Score":0,"Tags":"python,emulation,sdn,mininet,openflow","A_Id":49602289,"CreationDate":"2018-03-31T10:41:00.000","Title":"Building WSN topology integrated with SDN controller (mininet-wifi)","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"It is a common practice to normalize input values (to a neural network) to speed up the learning process, especially if features have very large scales.\nIn its theory, normalization is easy to understand. But I wonder how this is done if the training data set is very large, say for 1 million training examples..? If # features per training example is large as well (say, 100 features per training example), 2 problems pop up all of a sudden:\n- It will take some time to normalize all training samples\n- Normalized training examples need to be saved somewhere, so that we need to double the necessary disk space (especially if we do not want to overwrite the original data).\nHow is input normalization solved in practice, especially if the data set is very large?\nOne option maybe is to normalize inputs dynamically in the memory per mini batch while training.. But normalization results will then be changing from one mini batch to another. Would it be tolerable then?\nThere is maybe someone in this platform having hands on experience on this question. I would really appreciate if you could share your experiences.\nThank you in advance.","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1045,"Q_Id":49593985,"Users Score":1,"Answer":"A large number of features makes it easier to parallelize the normalization of the dataset. This is not really an issue. Normalization on large datasets would be easily GPU accelerated, and it would be quite fast. Even for large datasets like you are describing. One of my frameworks that I have written can normalize the entire MNIST dataset in under 10 seconds on a 4-core 4-thread CPU. A GPU could easily do it in under 2 seconds. Computation is not the problem. While for smaller datasets, you can hold the entire normalized dataset in memory, for larger datasets, like you mentioned, you will need to swap out to disk if you normalize the entire dataset. However, if you are doing reasonably large batch sizes, about 128 or higher, your minimums and maximums will not fluctuate that much, depending upon the dataset. This allows you to normalize the mini-batch right before you train the network on it, but again this depends upon the network. I would recommend experimenting based on your datasets, and choosing the best method.","Q_Score":0,"Tags":"python,tensorflow,machine-learning,neural-network,deep-learning","A_Id":49594057,"CreationDate":"2018-04-01T01:28:00.000","Title":"Neural Network - Input Normalization","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":1},{"Question":"I just installed the abcde CD utility but it's complaining that it can't find eyeD3, the Python ID3 program. This appears to be a well-known and unresolved deficiency in the abcde dependencies, and I'm not a Python programmer, so I'm clueless.\nI have the Python 2.7.12 came with Mint 18, and something called python3 (3.5.2). If I try to install eyeD3 with pip (presumably acting against 2.7.12), it says it's already installed (in \/usr\/lib\/python2.7\/dist-packages\/eyeD3). I don't know how to force pip to install under python3.\nIf I do a find \/ -name eyeD3, the only other thing it turns up is \/usr\/share\/pyshared\/eyeD3. But both of those are only directories, and both just contain Python libraries, not executables. \nThere isn't any other file called eyeD3 anywhere on disk.\nDoes anyone know what it's supposed to be called, where it's supposed to live, and how I can install it? \nP","AnswerCount":2,"Available Count":2,"Score":0.0,"is_accepted":false,"ViewCount":1262,"Q_Id":49599452,"Users Score":0,"Answer":"Gave up...waste of my time and everyone else's sorry.\nWhat I apparently needed was the eyed3 (lowercase 'd') non-python utility.","Q_Score":2,"Tags":"python,eyed3","A_Id":49675091,"CreationDate":"2018-04-01T15:08:00.000","Title":"Finding the eyeD3 executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I just installed the abcde CD utility but it's complaining that it can't find eyeD3, the Python ID3 program. This appears to be a well-known and unresolved deficiency in the abcde dependencies, and I'm not a Python programmer, so I'm clueless.\nI have the Python 2.7.12 came with Mint 18, and something called python3 (3.5.2). If I try to install eyeD3 with pip (presumably acting against 2.7.12), it says it's already installed (in \/usr\/lib\/python2.7\/dist-packages\/eyeD3). I don't know how to force pip to install under python3.\nIf I do a find \/ -name eyeD3, the only other thing it turns up is \/usr\/share\/pyshared\/eyeD3. But both of those are only directories, and both just contain Python libraries, not executables. \nThere isn't any other file called eyeD3 anywhere on disk.\nDoes anyone know what it's supposed to be called, where it's supposed to live, and how I can install it? \nP","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1262,"Q_Id":49599452,"Users Score":1,"Answer":"I don't know how to force pip to install under python3.\n\npython3 -m pip install eyeD3 will install it for Python3.","Q_Score":2,"Tags":"python,eyed3","A_Id":49600355,"CreationDate":"2018-04-01T15:08:00.000","Title":"Finding the eyeD3 executable","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Trying to take data from a csv like this:\ncol1   col2\neggs   sara\nbacon  john\nham    betty\nThe number of items in each column can vary and may not be the same. Col1 may have 25 and col2 may have 3. Or the reverse, more or less.\nAnd loop through each entry so its output into a text file like this\nbreakfast_1\nbreakfast_item eggs\nperson sara\nbreakfast_2\nbreakfast_item bacon\nperson sara\nbreakfast_3\nbreakfast_item ham\nperson sara\nbreakfast_4\nbreakfast_item eggs\nperson john\nbreakfast_5\nbreakfast_item bacon\nperson john\nbreakfast_6\nbreakfast_item ham\nperson john\nbreakfast_7\nbreakfast_item eggs\nperson betty\nbreakfast_8\nbreakfast_item bacon\nperson betty\nbreakfast_9\nbreakfast_item ham\nperson betty\nSo the script would need to add the \"breakfast\" number and loop through each breakfast_item and person.\nI know how to create one combo but not how to pair up each in a loop?\nAny tips on how to do this would be very helpful.","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":50,"Q_Id":49619655,"Users Score":0,"Answer":"First, get a distinct of all breakfast items.\nA pseudo code like below \nIterate through each line\nCollect item and person in 2 different lists\nDo a set on those 2 lists\nSay persons, items\n\nCounter = 1\nfor  person in persons:\n  for  item in items:\n    Print \"breafastitem\", Counter\n    Print person, item","Q_Score":0,"Tags":"python,csv,text","A_Id":49623125,"CreationDate":"2018-04-02T22:28:00.000","Title":"python pair multiple field entries from csv","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"Windows command netsh interface show interface shows all network connections and their names. A name could be Wireless Network Connection, Local Area Network or Ethernet etc.\nI would like to change an IP address with netsh interface ip set address \"Wireless Network Connection\" static 192.168.1.3 255.255.255.0 192.168.1.1 1 with Python script, but I need a network interface name. \nIs it possible to have this information like we can have a hostname with socket.gethostname()? Or I can change an IP address with Python in other way?","AnswerCount":1,"Available Count":1,"Score":0.3799489623,"is_accepted":false,"ViewCount":2892,"Q_Id":49624485,"Users Score":2,"Answer":"I don't know of a Python netsh API. But it should not be hard to do with a pair of subprocess calls. First issue netsh interface show interface, parse the output you get back, then issue your set address command.\nOr am I missing the point?","Q_Score":0,"Tags":"python,static-ip-address","A_Id":49625033,"CreationDate":"2018-04-03T07:25:00.000","Title":"How to find out Windows network interface name in Python?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm reading headfirst python and have just completed the section where I created a module for printing nested list items, I've created the code and the setup file and placed them in a file labeled \"Nester\" that is sitting on my desktop. The book is now asking for me to install this module onto my local copy of Python. The thing is, in the example he is using the mac terminal, and I'm on windows. I tried to google it but I'm still a novice and a lot of the explanations just go over my head. Can someone give me clear thorough guide?.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":888,"Q_Id":49629518,"Users Score":0,"Answer":"On Windows systems, third-party modules (single files containing one or more functions or classes) and third-party packages (a folder [a.k.a. directory] that contains more than one module (and sometimes other folders\/directories) are usually kept in one of two places: c:\\\\Program Files\\\\Python\\\\Lib\\\\site-packages\\\\ and c:\\\\Users\\\\[you]\\\\AppData\\\\Roaming\\\\Python\\\\. \nThe location in Program Files is usually not accessible to normal users, so when PIP installs new modules\/packages on Windows it places them in the user-accessible folder in the Users location indicated above. You have direct access to that, though by default the AppData folder is \"hidden\"--not displayed in the File Explorer list unless you set FE to show hidden items (which is a good thing to do anyway, IMHO). You can put the module you're working on in the AppData\\\\Roaming\\\\Python\\\\ folder.\nYou still need to make sure the folder you put it in is in the PATH environment variable. PATH is a string that tells Windows (and Python) where to look for needed files, in this case the module you're working on. Google \"set windows path\" to find how to check and set your path variable, then just go ahead and put your module in a folder that's listed in your path.\nOf course, since you can add any folder\/directory you want to PATH, you could put your module anywhere you wanted--including leaving it on the Desktop--as long as the location is included in PATH. You could, for instance, have a folder such as Documents\\\\Programming\\\\Python\\\\Lib to put your personal modules in, and use Documents\\\\Programming\\\\Python\\\\Source for your Python programs. You'd just need to include those in the PATH variable. \nFYI: Personally, I don't like the way python is (by default) installed on Windows (because I don't have easy access to c:\\\\Program Files), so I installed Python in a folder off the drive root: c:\\Python36. In this way, I have direct access to the \\\\Lib\\\\site-packages\\\\ folder.","Q_Score":0,"Tags":"python,python-3.x,cmd,module","A_Id":49639764,"CreationDate":"2018-04-03T11:57:00.000","Title":"how do I install my modual onto my local copy of python on windows?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":1,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am fairly new to Django and could not figure out by reading the docs or by looking at existing questions. I looked into Django permissions and authentication but could not find a solution.\nLet's say I have a Detail View listing all instances of a Model called Item. For each Item, I want to control which User can view it, and for how long. In other words, for each User having access to the Item, I want the right\/permission to view it to expire after a specified period of time. After that period of time, the Item would disapear from the list and the User could not access the url detailing the Item.\nThe logic to implement is pretty simple, I know, but the \"per user \/ per object\" part confuses me. Help would be much appreciated!","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":469,"Q_Id":49637924,"Users Score":1,"Answer":"Information about UserItemExpiryDate has to be stored in a separate table (Model). I would recommend using your coding in Django. \nThere are few scenarios to consider: \n1) A new user is created, and he\/she should have access to items. \nIn this case, you add entries to UserItemExpiry with new User<>Item combination (as key) and expiry date. Then, for logged in user you look for items from Items that has User<>Item in UserItemExpiry in the future. \n2) A new item is created, and it has to be added to existing users. \nIn such case, you add entries to UserItemExpiry with ALL users<> new Item combination (as key) and expiry date. And logic for \"selecting\" valid items is the same as in point 1. \nBest of luck, \nRadek Szwarc","Q_Score":1,"Tags":"python,django,django-admin,django-authentication,django-permissions","A_Id":49638105,"CreationDate":"2018-04-03T19:38:00.000","Title":"Django : how to give user\/group permission to view model instances for a specified period of time","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am working on a excel file with large text data. 2 columns have lot of text data. Like descriptions, job duties. \nWhen i import my file in python df=pd.read_excel(\"form1.xlsx\"). It shows the columns with text data as NaN. \nHow do I import all the text in the columns ?\nI want to do analysis on job title , description and job duties. Descriptions and Job Title are long text. I have over 150 rows.","AnswerCount":2,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":2378,"Q_Id":49652693,"Users Score":1,"Answer":"Try converting the file from .xlsx to .CSV \nI had the same problem with text columns so i tried converting to CSV (Comma Delimited) and it worked. Not very helpful, but worth a try.","Q_Score":0,"Tags":"excel,python-3.x,pandas,import","A_Id":49656081,"CreationDate":"2018-04-04T13:46:00.000","Title":"how to read text from excel file in python pandas?","Data Science and Machine Learning":1,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I want to know that if I can make a web server with Flask in my pc like xampp apache (php) for after I can access this page in others places across the internet. Or even in my local network trough the wifi connection or lan ethernet. Is it possible ? I saw some ways to do this, like using \"uwsgi\".. something like this... but I colud never do it.\nOBS: I have a complete application in Flask already complete, with databases and all things working. The only problem is that I don't know how to start the server and access by the others pc's.","AnswerCount":2,"Available Count":1,"Score":0.1973753202,"is_accepted":false,"ViewCount":5337,"Q_Id":49656877,"Users Score":2,"Answer":"Yes, you can.\nJust like you said, you can use uwsgi to run your site efficiently. There are other web servers like uwsgi: I usually use Gunicorn. But note that Flask can run without any of these, it will simply be less efficient (but if it is just for you then it should not be a problem).\nYou can find tutorials on the net with a few keywords like \"serving flask app\".\nIf you want to access your site from the internet (outside of your local network), you will need to configure your firewall and router\/modem to accept connections on port 80 (HTTP) or 443 (HTTPS).\nGood luck :)","Q_Score":2,"Tags":"python,html,web,flask","A_Id":49656968,"CreationDate":"2018-04-04T17:20:00.000","Title":"make a web server in localhost with flask","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been wanting to know how to make a GUI without using a module on Python, I have looked into GUI's in Python but everything leads to Tkinter or other Python GUI modules. The reason I do not want to use Tkinter is because I want to understand how to do it myself. I have looked at the Tkinter modules files but it imports like 4 other Modules.\nI don't mind the modules like system, os or math just not modules which I will use and not understand. If you do decide to answer my question please include as much detail and information on the matter. Thanks -- Darrian Penman","AnswerCount":2,"Available Count":2,"Score":0.0996679946,"is_accepted":false,"ViewCount":1223,"Q_Id":49658301,"Users Score":1,"Answer":"For the same reason that you can't write to a database without using a database module, you can't create GUIs without a GUI module. There simply is no way to draw directly on the screen in a cross-platform way without a module.\nWriting GUIs is very complex. These modules exist to reduce the complexity.","Q_Score":0,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":49658628,"CreationDate":"2018-04-04T18:48:00.000","Title":"Python - How do I make a window along with widgets without using modules like Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have been wanting to know how to make a GUI without using a module on Python, I have looked into GUI's in Python but everything leads to Tkinter or other Python GUI modules. The reason I do not want to use Tkinter is because I want to understand how to do it myself. I have looked at the Tkinter modules files but it imports like 4 other Modules.\nI don't mind the modules like system, os or math just not modules which I will use and not understand. If you do decide to answer my question please include as much detail and information on the matter. Thanks -- Darrian Penman","AnswerCount":2,"Available Count":2,"Score":1.2,"is_accepted":true,"ViewCount":1223,"Q_Id":49658301,"Users Score":1,"Answer":"You cannot write a GUI in Python without importing either a GUI module or importing ctypes.  The latter would require calling OS-specific graphics primitives, and would be far worse than doing the same thing in C.  (EDIT: see Roland comment below for X11 systems.)\nThe python-coded tkinter mainly imports the C-coded _tkinter, which interfaces to the tcl- and C- coded tk GUI package.  There are separate versions of tcl\/tk for Windows, *nix, and MacOS.","Q_Score":0,"Tags":"python,python-3.x,user-interface,tkinter","A_Id":49658596,"CreationDate":"2018-04-04T18:48:00.000","Title":"Python - How do I make a window along with widgets without using modules like Tkinter?","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":1,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm doing the cipher for python. I'm confused on how to use Regular Expression to find a paired word in a text dictionary. \nFor example, there is dictionary.txt with many English words in it. I need to find word paired with \"th\" at the beginning. Like they, them, the, their .....\nWhat kind of Regular Expression should I use to find \"th\" at the beginning?\nThank you!","AnswerCount":3,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":68,"Q_Id":49660637,"Users Score":0,"Answer":"^(th\\w*) \n\ngives you all results where the string begins with th . If there is more than one word in the string you will only get the first.\n\n(^|\\s)(th\\w*)\n\nwil give you all the words begining with th even if there is more than one word begining with th","Q_Score":0,"Tags":"python,regex","A_Id":49660779,"CreationDate":"2018-04-04T21:19:00.000","Title":"Regular Expression in python how to find paired words","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"This has been a very annoying problem for me and I couldn't find any keymaps or settings that could cause this behavior.\nSetup:\n\nPycharm Professional 2018.1 installed on redhat linux\nI remote into the linux machine using mobaX and launch pycharm with window forwarding\n\nScenario 1:\nI open a browser on windows, copy some text, go to editor or console, paste it somewhere without highlighting any text, hit ctrl+v, it pastes fine\nScenario 2:\nI open a browser on windows, copy some text, go to editor or console, highlight some text there, hit ctrl+v in attempt to replace the highlighted text with what's in my clipboard. The text didn't change. I leave pycharm and paste somewhere else, the text in clipboard has now become the text I highlighted.\nEdit:\nok I just realized this: as soon as I highlight the text, it gets copied...I've turned this feature off for terminal, but couldn't find a global settings for the editor etc. Anyone know how?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":360,"Q_Id":49661492,"Users Score":1,"Answer":"I figured it out: it's caused by the copy-on-select setting of my linux system. To turn it off, go to mobax-settings-configurations-x11-clipboard-disable 'copy on select'","Q_Score":0,"Tags":"python,ide,pycharm,copy-paste","A_Id":49679290,"CreationDate":"2018-04-04T22:36:00.000","Title":"pycharm ctrl+v copies the item in console instead paste when highlighted","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I have a model that starts with a Conv2D layer and so it must take input of shape (samples, rows, cols, channels) (and the model must ultimately output a shape of (1)). However, for my purposes one full unit of input needs to be some (fixed) number of samples, so the overall input shape sent into this model when given a batch of input ends up being (batch_size, samples, rows, cols, channels) (which is expected and correct, but...). How do I send each item in the batch through this model so that I end up with an output of shape (batch_size, 1)?\nWhat I have tried so far:\nI tried creating an inner model containing the Conv2D layer et al then wrapping the entire thing in a TimeDistributed wrapper, followed by a Dense(units=1) layer. This compiled, but resulted in an output shape of (batch_size, samples, 1). I feel like I am missing something simple...","AnswerCount":3,"Available Count":1,"Score":0.0665680765,"is_accepted":false,"ViewCount":587,"Q_Id":49662869,"Users Score":1,"Answer":"At the moment you are returning a 3D array.\nAdd a Flatten() layer to convert the array to 2D, and then add a Dense(1). This should output (batch_size, 1).","Q_Score":1,"Tags":"python,tensorflow,keras","A_Id":49662938,"CreationDate":"2018-04-05T01:37:00.000","Title":"In Keras, how to send each item in a batch through a model?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm trying to train a neural net on a GPU using Keras and am getting a \"Resource exhausted: OOM when allocating tensor\" error.  The specific tensor it's trying to allocate isn't very big, so I assume some previous tensor consumed almost all the VRAM.  The error message comes with a hint that suggests this:\n\nHint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.\n\nThat sounds good, but how do I do it?  RunOptions appears to be a Tensorflow thing, and what little documentation I can find for it associates it with a \"session\".  I'm using Keras, so Tensorflow is hidden under a layer of abstraction and its sessions under another layer below that.\nHow do I dig underneath everything to set this option in such a way that it will take effect?","AnswerCount":4,"Available Count":1,"Score":0.0996679946,"is_accepted":false,"ViewCount":26528,"Q_Id":49665757,"Users Score":2,"Answer":"OOM means out of memory. May be it is using more memory at that time.\nDecrease batch_size significantly. I set to 16, then it worked fine","Q_Score":27,"Tags":"python,tensorflow,keras,gpu","A_Id":64231036,"CreationDate":"2018-04-05T06:45:00.000","Title":"How to add report_tensor_allocations_upon_oom to RunOptions in Keras","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":1,"ERRORS":1,"REVIEW":0},{"Question":"I have a problem with multilanguage and multi character encoded text. \nProject use OpenGraph and it will save in mysql database some information from websites. But database have problem with character encoding. I tryed encoding them  to byte. That is problem, becouse in admin panel text show us bute and it is not readable. \nPlease help me. How can i save multilanguage text in database and if i need encode to byte them how can i correctly decode them in admin panel and in views","AnswerCount":2,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":89,"Q_Id":49672291,"Users Score":0,"Answer":"You should encode all data as UTF-8 which is unicode.","Q_Score":0,"Tags":"python,django","A_Id":49672440,"CreationDate":"2018-04-05T12:22:00.000","Title":"Django multilanguage text and saving it on mysql","Data Science and Machine Learning":0,"Database and SQL":1,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":1,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":1,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I'm using python 2.7.10 virtualenv when running python codes in IntelliJ. I need to install requests[security] package. However I'm not sure how to add that [security] option\/config when installing requests package using the Package installer in File > Project Structure settings window.","AnswerCount":1,"Available Count":1,"Score":0.0,"is_accepted":false,"ViewCount":852,"Q_Id":49679283,"Users Score":0,"Answer":"Was able to install it by doing:\n\nActivating the virtualenv in the 'Terminal' tool window:\nsource <virtualenv dir>\/bin\/activate\nExecuting a pip install requests[security]","Q_Score":1,"Tags":"python,python-2.7,intellij-idea,virtualenv","A_Id":49679964,"CreationDate":"2018-04-05T18:38:00.000","Title":"How to Install requests[security] in virtualenv in IntelliJ","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":1,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"We have an ontology but we need to use the reasoner HermiT to infer the sentiment of a given expression. We have no idea how to use and implement a reasoner in python and we could not find a good explanation on the internet. We found that we can use sync_reasoner() for this, but what does this do exactly? And do we have to call the reasoner manually everytime or does it happen automatically?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":736,"Q_Id":49687824,"Users Score":3,"Answer":"You do not need to implement the reasoner. The sync_reasoner() function already calls HermiT internally and does the reasoning for you. \nA reasoner will reclassify individuals and classes for you which means it creates a parent-child hierarchy of classes and individuals. When you load an ontology only explicit parent-child relations are represented. However, when you call the reasoner, the parent-child hierarchy is updated to include inferred relations as well.\nAn example of this is provided in Owlready2-0.5\/doc\/intro.rst. Before calling sync_reasoner() calling test_pizza.__class__ prints onto.Pizza, which is explicit information. However, after calling sync_reasoner() calling test_pizza.__class__ prints onto.NonVegetarianPizza, which is the inferred information.","Q_Score":5,"Tags":"python,ontology,reasoner,owlready,hermit","A_Id":49688765,"CreationDate":"2018-04-06T07:42:00.000","Title":"Use HermiT in Python","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am using Pyinstaller to create my Python app from a set of scripts. This script uses a library that saves downloaded data to the '~\/' directory (using the os.join function).\nI was wondering how to edit the code in the library so that when it runs, it saves data to inside the app (like in the package, the Contents\/Resources maybe)?","AnswerCount":1,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":148,"Q_Id":49698480,"Users Score":1,"Answer":"I was wondering how to edit the code in the library so that when it runs, it saves data to inside the app\n\nDon't do that. This isn't a standard practice in macOS applications, and will fail in some standard system configurations. For example, it will fail if the application is used by a non-administrator user, or if the application is run from a read-only disk image or network share.\nMore importantly, it'll also make it difficult or impossible to sign the application bundle with a developer certificate.","Q_Score":1,"Tags":"python,macos,pyinstaller,dylib","A_Id":49698626,"CreationDate":"2018-04-06T17:50:00.000","Title":"Saving data to MacOS python application","Data Science and Machine Learning":0,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":1,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":1,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0},{"Question":"I am building my own Tensor class in Rust, and I am trying to make it like PyTorch's implementation. \nWhat is the most efficient way to store tensors programmatically, but, specifically, in a strongly typed language like Rust? Are there any resources that provide good insights into how this is done?\nI am currently building a contiguous array, so that, given dimensions of 3 x 3 x 3, my array would just have 3^3 elements in it, which would represent the tensor. However, this does make some of the mathematical operations and manipulations of the array harder.\nThe dimension of the tensor should be dynamic, so that I could have a tensor with n dimensions.","AnswerCount":2,"Available Count":1,"Score":1.2,"is_accepted":true,"ViewCount":1685,"Q_Id":49724954,"Users Score":6,"Answer":"Contiguous array\nThe commonly used way to store such data is in a single array that is laid out as a single, contiguous block within memory. More concretely, a 3x3x3 tensor would be stored simply as a single array of 27 values, one after the other. \nThe only place where the dimensions are used is to calculate the mapping between the (many) coordinates and the offset within that array. For example, to fetch the item [3, 1, 1] you would need to know if it is a 3x3x3 matrix, a 9x3x1 matrix, or a 27x1x1 matrix - in all cases the \"storage\" would be 27 items long, but the interpretation of \"coordinates\" would be different. If you use zero-based indexing, the calculation is trivial, but you need to know the length of each dimension.\nThis does mean that resizing and similar operations may require copying the whole array, but that's ok, you trade off the performance of those (rare) operations to gain performance for the much more common operations, e.g. sequential reads.","Q_Score":14,"Tags":"python,python-3.x,rust,pytorch,tensor","A_Id":49734613,"CreationDate":"2018-04-09T02:59:00.000","Title":"How are PyTorch's tensors implemented?","Data Science and Machine Learning":1,"Database and SQL":0,"GUI and Desktop Applications":0,"Networking and APIs":0,"Other":0,"Python Basics and Environment":0,"System Administration and DevOps":0,"Web Development":0,"API_CHANGE":0,"API_USAGE":1,"CONCEPTUAL":0,"DISCREPANCY":0,"DOCUMENTATION":0,"ERRORS":0,"REVIEW":0}]